@namzu/sdk 20.2.0 → 20.3.0
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 +43 -0
- package/dist/manager/run/persistence.d.ts +2 -2
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +14 -5
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/public-runtime.d.ts +1 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +1 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/context.d.ts +2 -0
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +1 -0
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/index.d.ts +11 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/run/disk.d.ts +10 -8
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/run/memory.d.ts +46 -0
- package/dist/store/run/memory.d.ts.map +1 -0
- package/dist/store/run/memory.js +104 -0
- package/dist/store/run/memory.js.map +1 -0
- package/dist/types/run/config.d.ts +12 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/index.d.ts +1 -0
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +1 -0
- package/dist/types/run/index.js.map +1 -1
- package/dist/types/run/store.d.ts +103 -0
- package/dist/types/run/store.d.ts.map +1 -0
- package/dist/types/run/store.js +30 -0
- package/dist/types/run/store.js.map +1 -0
- package/package.json +1 -1
- package/src/manager/run/persistence.ts +17 -7
- package/src/public-runtime.ts +1 -0
- package/src/runtime/query/context.ts +3 -0
- package/src/runtime/query/index.ts +13 -0
- package/src/store/index.ts +1 -0
- package/src/store/run/disk.ts +10 -8
- package/src/store/run/memory.ts +121 -0
- package/src/types/run/config.ts +13 -0
- package/src/types/run/index.ts +1 -0
- package/src/types/run/store.ts +112 -0
package/dist/store/run/disk.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { CheckpointId, IterationCheckpoint } from '../../types/hitl/index.js';
|
|
2
2
|
import type { Run, RunEvent, RunStoreConfig } from '../../types/run/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import type { CompletedToolRecord, RunStore } from '../../types/run/store.js';
|
|
4
|
+
/**
|
|
5
|
+
* One finished tool call, recovered from the transcript.
|
|
6
|
+
*
|
|
7
|
+
* Re-exported from the store contract rather than declared twice. Two
|
|
8
|
+
* declarations of one concept, each populated by its own mapper, is the shape
|
|
9
|
+
* this repository has a rule about.
|
|
10
|
+
*/
|
|
11
|
+
export type { CompletedToolRecord };
|
|
12
|
+
export declare class RunDiskStore implements RunStore {
|
|
11
13
|
private baseDir;
|
|
12
14
|
private runDir;
|
|
13
15
|
private log;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disk.d.ts","sourceRoot":"","sources":["../../../src/store/run/disk.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"disk.d.ts","sourceRoot":"","sources":["../../../src/store/run/disk.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAClF,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,MAA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C,KAAK,CAAC;QACL,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,MAAM,CAAA;QACd,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,CAAA;KAChB,CAAC,CACF;IAWK,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CA8CzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAiBtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disk.js","sourceRoot":"","sources":["../../../src/store/run/disk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"disk.js","sourceRoot":"","sources":["../../../src/store/run/disk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAe,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAE3D;;;;;;;GAOG;AACH,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAA;AAW9E,MAAM,OAAO,YAAY;IAChB,OAA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AAO,MAAM,CAAC,EAAE,KAAK,QAAQ;QAC7B,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACpC,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ;QACpC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9B,CAAC;QACF,MAAM,IAAI,KAAK,CACd,oBAAoB,IAAI,uKAAuK,CAC/L,CAAA;IACF,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACd,oBAAoB,IAAI,+QAA+Q,CACvS,CAAA;IACF,CAAC;IAED,OAAO,MAA6B,CAAA;AACrC,CAAC;AAED,SAAS,cAAc,CAAC,GAAY;IACnC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ,CAAA;AACnG,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Run } from '../../types/run/entity.js';
|
|
2
|
+
import type { RunEvent } from '../../types/run/events.js';
|
|
3
|
+
import type { CompletedToolRecord, RunStore } from '../../types/run/store.js';
|
|
4
|
+
/**
|
|
5
|
+
* Process-local {@link RunStore}: a run's evidence with no filesystem.
|
|
6
|
+
*
|
|
7
|
+
* The reason it ships rather than living in a test file is that it is the
|
|
8
|
+
* only way to demonstrate the seam actually is one. A contract with a single
|
|
9
|
+
* implementation is a refactor; the second implementation is what proves a
|
|
10
|
+
* host could supply a third. It is also the parity partner for the disk
|
|
11
|
+
* store — a memory store that answers differently from disk is worse than
|
|
12
|
+
* none, because a host tests against one and ships the other.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately not durable. It is for tests, for a single-process host that
|
|
15
|
+
* genuinely wants a run's evidence to die with the process, and for
|
|
16
|
+
* environments with no writable filesystem at all.
|
|
17
|
+
*/
|
|
18
|
+
export declare class InMemoryRunStore implements RunStore {
|
|
19
|
+
private runId;
|
|
20
|
+
private parentRunId;
|
|
21
|
+
private meta;
|
|
22
|
+
private messages;
|
|
23
|
+
private report;
|
|
24
|
+
private readonly events;
|
|
25
|
+
initRun(runId: string, parentRunId?: string): Promise<string | null>;
|
|
26
|
+
private requireInit;
|
|
27
|
+
/** The run this store is bound to, and its parent when it has one. */
|
|
28
|
+
get boundTo(): {
|
|
29
|
+
runId: string;
|
|
30
|
+
parentRunId?: string;
|
|
31
|
+
} | null;
|
|
32
|
+
writeRunMeta(run: Run): Promise<void>;
|
|
33
|
+
writeMessages(run: Run): Promise<void>;
|
|
34
|
+
appendEvent(event: RunEvent): Promise<void>;
|
|
35
|
+
writeReport(content: string): Promise<string | null>;
|
|
36
|
+
readCompletedTools(): Promise<Map<string, CompletedToolRecord>>;
|
|
37
|
+
getRunDir(): string | null;
|
|
38
|
+
/** Everything recorded for the bound run, for tests and parity checks. */
|
|
39
|
+
snapshot(): {
|
|
40
|
+
meta: Run | null;
|
|
41
|
+
messages: Run['messages'];
|
|
42
|
+
report: string | null;
|
|
43
|
+
events: readonly RunEvent[];
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/store/run/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAE7E;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAiB,YAAW,QAAQ;IAChD,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IAElC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAU1E,OAAO,CAAC,WAAW;IAOnB,sEAAsE;IACtE,IAAI,OAAO,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAI5D;IAEK,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IASrC,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtC,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAS3C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAMpD,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAuBrE,SAAS,IAAI,MAAM,GAAG,IAAI;IAS1B,0EAA0E;IAC1E,QAAQ,IAAI;QACX,IAAI,EAAE,GAAG,GAAG,IAAI,CAAA;QAChB,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;QACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;QACrB,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAA;KAC3B;CAGD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local {@link RunStore}: a run's evidence with no filesystem.
|
|
3
|
+
*
|
|
4
|
+
* The reason it ships rather than living in a test file is that it is the
|
|
5
|
+
* only way to demonstrate the seam actually is one. A contract with a single
|
|
6
|
+
* implementation is a refactor; the second implementation is what proves a
|
|
7
|
+
* host could supply a third. It is also the parity partner for the disk
|
|
8
|
+
* store — a memory store that answers differently from disk is worse than
|
|
9
|
+
* none, because a host tests against one and ships the other.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately not durable. It is for tests, for a single-process host that
|
|
12
|
+
* genuinely wants a run's evidence to die with the process, and for
|
|
13
|
+
* environments with no writable filesystem at all.
|
|
14
|
+
*/
|
|
15
|
+
export class InMemoryRunStore {
|
|
16
|
+
runId = null;
|
|
17
|
+
parentRunId;
|
|
18
|
+
meta = null;
|
|
19
|
+
messages = [];
|
|
20
|
+
report = null;
|
|
21
|
+
events = [];
|
|
22
|
+
async initRun(runId, parentRunId) {
|
|
23
|
+
this.runId = runId;
|
|
24
|
+
this.parentRunId = parentRunId;
|
|
25
|
+
// No location, and that is the honest answer rather than a defect.
|
|
26
|
+
// Callers render `null` as "this run is not on a filesystem"; a
|
|
27
|
+
// synthesized path would put a directory that does not exist in front
|
|
28
|
+
// of an operator.
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
requireInit() {
|
|
32
|
+
if (this.runId === null) {
|
|
33
|
+
throw new Error('InMemoryRunStore not initialized — call initRun() first');
|
|
34
|
+
}
|
|
35
|
+
return this.runId;
|
|
36
|
+
}
|
|
37
|
+
/** The run this store is bound to, and its parent when it has one. */
|
|
38
|
+
get boundTo() {
|
|
39
|
+
return this.runId === null
|
|
40
|
+
? null
|
|
41
|
+
: { runId: this.runId, ...(this.parentRunId ? { parentRunId: this.parentRunId } : {}) };
|
|
42
|
+
}
|
|
43
|
+
async writeRunMeta(run) {
|
|
44
|
+
this.requireInit();
|
|
45
|
+
// Copied, not referenced. The caller keeps mutating this object for
|
|
46
|
+
// the rest of the run, so storing it by reference would make every
|
|
47
|
+
// historical read return the run's present state — a transcript that
|
|
48
|
+
// silently rewrites itself is worse than no transcript.
|
|
49
|
+
this.meta = structuredClone(run);
|
|
50
|
+
}
|
|
51
|
+
async writeMessages(run) {
|
|
52
|
+
this.requireInit();
|
|
53
|
+
this.messages = structuredClone(run.messages);
|
|
54
|
+
}
|
|
55
|
+
async appendEvent(event) {
|
|
56
|
+
this.requireInit();
|
|
57
|
+
// Stamped on write, exactly as the disk store stamps its transcript
|
|
58
|
+
// line — a parity test compares the two read-backs, and a timestamp
|
|
59
|
+
// present in one medium and absent in the other would make identical
|
|
60
|
+
// runs look different depending on where they were recorded.
|
|
61
|
+
this.events.push({ ...event, timestamp: Date.now() });
|
|
62
|
+
}
|
|
63
|
+
async writeReport(content) {
|
|
64
|
+
this.requireInit();
|
|
65
|
+
this.report = content;
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
async readCompletedTools() {
|
|
69
|
+
this.requireInit();
|
|
70
|
+
const completed = new Map();
|
|
71
|
+
for (const event of this.events) {
|
|
72
|
+
const e = event;
|
|
73
|
+
if (e.type !== 'tool_completed')
|
|
74
|
+
continue;
|
|
75
|
+
const toolUseId = e.toolUseId;
|
|
76
|
+
const toolName = e.toolName;
|
|
77
|
+
if (typeof toolUseId !== 'string' || typeof toolName !== 'string')
|
|
78
|
+
continue;
|
|
79
|
+
// Last write wins: a retried tool emits one event per attempt and
|
|
80
|
+
// the final one is what actually answered the call. Same rule the
|
|
81
|
+
// disk store applies, and it has to be the same rule — a resumed
|
|
82
|
+
// run must not depend on which backend it was recorded with.
|
|
83
|
+
completed.set(toolUseId, {
|
|
84
|
+
toolUseId,
|
|
85
|
+
toolName,
|
|
86
|
+
result: typeof e.result === 'string' ? e.result : '',
|
|
87
|
+
isError: e.isError === true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return completed;
|
|
91
|
+
}
|
|
92
|
+
getRunDir() {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
// `addToIndex` is deliberately not implemented. It maintains a browsable
|
|
96
|
+
// catalogue for a human reading a directory, and there is no directory
|
|
97
|
+
// here. The optional method exists on the contract precisely so a backend
|
|
98
|
+
// can decline it rather than implement a no-op that looks like a listing.
|
|
99
|
+
/** Everything recorded for the bound run, for tests and parity checks. */
|
|
100
|
+
snapshot() {
|
|
101
|
+
return { meta: this.meta, messages: this.messages, report: this.report, events: this.events };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/store/run/memory.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,gBAAgB;IACpB,KAAK,GAAkB,IAAI,CAAA;IAC3B,WAAW,CAAoB;IAC/B,IAAI,GAAe,IAAI,CAAA;IACvB,QAAQ,GAAoB,EAAE,CAAA;IAC9B,MAAM,GAAkB,IAAI,CAAA;IACnB,MAAM,GAAe,EAAE,CAAA;IAExC,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,WAAoB;QAChD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,mEAAmE;QACnE,gEAAgE;QAChE,sEAAsE;QACtE,kBAAkB;QAClB,OAAO,IAAI,CAAA;IACZ,CAAC;IAEO,WAAW;QAClB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;QAC3E,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAA;IAClB,CAAC;IAED,sEAAsE;IACtE,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI;YACzB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAA;IACzF,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,GAAQ;QAC1B,IAAI,CAAC,WAAW,EAAE,CAAA;QAClB,oEAAoE;QACpE,m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EAAE;gBACxB,SAAS;gBACT,QAAQ;gBACR,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;gBACpD,OAAO,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI;aAC3B,CAAC,CAAA;QACH,CAAC;QACD,OAAO,SAAS,CAAA;IACjB,CAAC;IAED,SAAS;QACR,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,yEAAyE;IACzE,uEAAuE;IACvE,0EAA0E;IAC1E,0EAA0E;IAE1E,0EAA0E;IAC1E,QAAQ;QAMP,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAA;IAC9F,CAAC;CACD"}
|
|
@@ -125,6 +125,18 @@ export interface RunPersistenceConfig {
|
|
|
125
125
|
* hosts inject a scope-keyed backend (e.g. Postgres) here.
|
|
126
126
|
*/
|
|
127
127
|
checkpointStore?: CheckpointStore;
|
|
128
|
+
/**
|
|
129
|
+
* Optional run-evidence persistence override. Defaults to the disk layout
|
|
130
|
+
* under `outputDir` (a
|
|
131
|
+
* {@link import('../../store/run/disk.js').RunDiskStore}); hosts inject
|
|
132
|
+
* their own backend here.
|
|
133
|
+
*
|
|
134
|
+
* The sibling of `checkpointStore`, and it should have been one from the
|
|
135
|
+
* start: checkpoints got an injectable seam while the run record, its
|
|
136
|
+
* messages, its transcript and its report did not, so the evidence was
|
|
137
|
+
* the one part of a run that could not leave the local filesystem.
|
|
138
|
+
*/
|
|
139
|
+
runStore?: import('./store.js').RunStore;
|
|
128
140
|
}
|
|
129
141
|
export interface RunStoreConfig {
|
|
130
142
|
baseDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../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;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,OAAO,YAAY,EAAE,QAAQ,CAAA;CACxC;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,kBAAkB;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,sBAAsB,EAAE,MAAM,CAAA;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAK3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EACX,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzF,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAK3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EACX,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzF,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/types/run/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './prepare-step.js';
|
|
|
3
3
|
export * from './stop-reason.js';
|
|
4
4
|
export * from './config.js';
|
|
5
5
|
export * from './checkpoint-store.js';
|
|
6
|
+
export * from './store.js';
|
|
6
7
|
export * from './entity.js';
|
|
7
8
|
export * from './replay.js';
|
|
8
9
|
// Domain `RunStatus` (session-hierarchy.md §4.6 state machine). Safe to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,sBAAsB;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAQ1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/run/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,sBAAsB;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAQ1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunStore — persistence contract for a run's own evidence.
|
|
3
|
+
*
|
|
4
|
+
* The checkpoint store got an injectable seam and this did not, which left
|
|
5
|
+
* the run record, its messages, its transcript and its report reachable only
|
|
6
|
+
* through a concrete filesystem class. For a kernel whose stated purpose is
|
|
7
|
+
* auditable evidence, the evidence was the one thing that could not be
|
|
8
|
+
* pointed at durable storage: on ephemeral infrastructure the transcript dies
|
|
9
|
+
* with the container, and behind a load balancer two replicas write two
|
|
10
|
+
* disjoint run trees for one tenant.
|
|
11
|
+
*
|
|
12
|
+
* The location was already injectable through a path builder — but that
|
|
13
|
+
* returns filesystem path strings, so it relocates the directory without
|
|
14
|
+
* changing the medium.
|
|
15
|
+
*
|
|
16
|
+
* ## Bound to one run, unlike {@link CheckpointStore}
|
|
17
|
+
*
|
|
18
|
+
* Every accessor here addresses the run the store was bound to by
|
|
19
|
+
* {@link RunStore.initRun}, where a `CheckpointStore` takes an explicit scope
|
|
20
|
+
* per call. That asymmetry is inherited rather than chosen: this contract is
|
|
21
|
+
* extracted from a class the runtime already constructs per run and holds for
|
|
22
|
+
* the run's lifetime, and re-keying it would change every call site in the
|
|
23
|
+
* same change that introduces the seam — two risks where one will do.
|
|
24
|
+
*
|
|
25
|
+
* A host implementing a shared backend therefore keys its rows by the
|
|
26
|
+
* attribution it was constructed with plus the bound run id. If this is later
|
|
27
|
+
* re-keyed per call, it happens once, deliberately, as its own change.
|
|
28
|
+
*/
|
|
29
|
+
import type { Run } from './entity.js';
|
|
30
|
+
import type { RunEvent } from './events.js';
|
|
31
|
+
/**
|
|
32
|
+
* One finished tool call, recovered from the run's own transcript.
|
|
33
|
+
*
|
|
34
|
+
* Re-declared here rather than imported from the disk store so the contract
|
|
35
|
+
* does not depend on an implementation of itself.
|
|
36
|
+
*/
|
|
37
|
+
export interface CompletedToolRecord {
|
|
38
|
+
readonly toolUseId: string;
|
|
39
|
+
readonly toolName: string;
|
|
40
|
+
readonly result: string;
|
|
41
|
+
readonly isError: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface RunStore {
|
|
44
|
+
/**
|
|
45
|
+
* Bind this store to a run, before any other call.
|
|
46
|
+
*
|
|
47
|
+
* Returns a location when the backend has one — the built-in disk store
|
|
48
|
+
* returns the run's directory — and `null` when it does not. A caller
|
|
49
|
+
* that renders the value must treat `null` as "this run is not on a
|
|
50
|
+
* filesystem" rather than as an error: an in-memory or object-storage
|
|
51
|
+
* backend has nothing to print, and inventing a path for it would put a
|
|
52
|
+
* directory that does not exist in front of an operator.
|
|
53
|
+
*/
|
|
54
|
+
initRun(runId: string, parentRunId?: string): Promise<string | null>;
|
|
55
|
+
/** Persist the run record: status, metadata, usage, timings. */
|
|
56
|
+
writeRunMeta(run: Run): Promise<void>;
|
|
57
|
+
/** Persist the run's full message history. */
|
|
58
|
+
writeMessages(run: Run): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Append one event to the run's durable event log.
|
|
61
|
+
*
|
|
62
|
+
* High-frequency streaming deltas are excluded before they reach here —
|
|
63
|
+
* that exclusion is a deliberate trade and belongs to the emitter, not to
|
|
64
|
+
* the backend, so a store must not re-filter.
|
|
65
|
+
*/
|
|
66
|
+
appendEvent(event: RunEvent): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Persist the run's final report. Returns a location, or `null` when the
|
|
69
|
+
* backend has none. See {@link RunStore.initRun}.
|
|
70
|
+
*/
|
|
71
|
+
writeReport(content: string): Promise<string | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Every tool call this run has already finished, keyed by `toolUseId`.
|
|
74
|
+
*
|
|
75
|
+
* A batch's results reach the message history only once the WHOLE batch
|
|
76
|
+
* settles, so a hard kill part-way through loses every result that had
|
|
77
|
+
* already come back, and the resumed run re-executes those calls. For a
|
|
78
|
+
* file write that is waste; for a payment or an email it is a second one.
|
|
79
|
+
*
|
|
80
|
+
* A backend that does not retain individual events answers with an empty
|
|
81
|
+
* map, which costs re-execution and is honest. It must not answer with a
|
|
82
|
+
* PARTIAL map: a caller reads a present entry as "this call is already
|
|
83
|
+
* answered", so a half-remembered batch is worse than a forgotten one.
|
|
84
|
+
*/
|
|
85
|
+
readCompletedTools(): Promise<Map<string, CompletedToolRecord>>;
|
|
86
|
+
/**
|
|
87
|
+
* Where this run's evidence lives, or `null` when it is not on a
|
|
88
|
+
* filesystem. Valid only after {@link RunStore.initRun}.
|
|
89
|
+
*/
|
|
90
|
+
getRunDir(): string | null;
|
|
91
|
+
/**
|
|
92
|
+
* Record the run in a browsable catalogue of runs. OPTIONAL.
|
|
93
|
+
*
|
|
94
|
+
* Optional because it is the one method here that is not evidence: it
|
|
95
|
+
* maintains a convenience listing for a human reading the directory, and
|
|
96
|
+
* a backend whose runs are already queryable has nothing to add. The
|
|
97
|
+
* programmatic answer to "which runs are there" is
|
|
98
|
+
* `CheckpointStore.listDurableRuns`, which carries attribution and
|
|
99
|
+
* includes sub-runs; this does neither.
|
|
100
|
+
*/
|
|
101
|
+
addToIndex?(run: Run): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/types/run/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CACzB;AAED,MAAM,WAAW,QAAQ;IACxB;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAEpE,gEAAgE;IAChE,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAErC,8CAA8C;IAC9C,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtC;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3C;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAEpD;;;;;;;;;;;;OAYG;IACH,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;IAE/D;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI,CAAA;IAE1B;;;;;;;;;OASG;IACH,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RunStore — persistence contract for a run's own evidence.
|
|
3
|
+
*
|
|
4
|
+
* The checkpoint store got an injectable seam and this did not, which left
|
|
5
|
+
* the run record, its messages, its transcript and its report reachable only
|
|
6
|
+
* through a concrete filesystem class. For a kernel whose stated purpose is
|
|
7
|
+
* auditable evidence, the evidence was the one thing that could not be
|
|
8
|
+
* pointed at durable storage: on ephemeral infrastructure the transcript dies
|
|
9
|
+
* with the container, and behind a load balancer two replicas write two
|
|
10
|
+
* disjoint run trees for one tenant.
|
|
11
|
+
*
|
|
12
|
+
* The location was already injectable through a path builder — but that
|
|
13
|
+
* returns filesystem path strings, so it relocates the directory without
|
|
14
|
+
* changing the medium.
|
|
15
|
+
*
|
|
16
|
+
* ## Bound to one run, unlike {@link CheckpointStore}
|
|
17
|
+
*
|
|
18
|
+
* Every accessor here addresses the run the store was bound to by
|
|
19
|
+
* {@link RunStore.initRun}, where a `CheckpointStore` takes an explicit scope
|
|
20
|
+
* per call. That asymmetry is inherited rather than chosen: this contract is
|
|
21
|
+
* extracted from a class the runtime already constructs per run and holds for
|
|
22
|
+
* the run's lifetime, and re-keying it would change every call site in the
|
|
23
|
+
* same change that introduces the seam — two risks where one will do.
|
|
24
|
+
*
|
|
25
|
+
* A host implementing a shared backend therefore keys its rows by the
|
|
26
|
+
* attribution it was constructed with plus the bound run id. If this is later
|
|
27
|
+
* re-keyed per call, it happens once, deliberately, as its own change.
|
|
28
|
+
*/
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/types/run/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import type { ProviderErrorInfo } from '../../types/provider/index.js'
|
|
|
9
9
|
import type { CheckpointRunScope, CheckpointStore } from '../../types/run/checkpoint-store.js'
|
|
10
10
|
import type { EmergencySaveData } from '../../types/run/emergency.js'
|
|
11
11
|
import type { Run, RunPersistenceConfig, StepResult, StopReason } from '../../types/run/index.js'
|
|
12
|
+
import type { RunStore } from '../../types/run/store.js'
|
|
12
13
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
13
14
|
import { type ModelPricing, ZERO_COST, accumulateCost } from '../../utils/cost.js'
|
|
14
15
|
import { generateEmergencySaveId } from '../../utils/id.js'
|
|
@@ -16,7 +17,7 @@ import type { Logger } from '../../utils/logger.js'
|
|
|
16
17
|
|
|
17
18
|
export class RunPersistence {
|
|
18
19
|
private run: Run
|
|
19
|
-
private runStore:
|
|
20
|
+
private runStore: RunStore
|
|
20
21
|
private checkpointStore: CheckpointStore
|
|
21
22
|
private pricing?: ModelPricing
|
|
22
23
|
|
|
@@ -38,10 +39,17 @@ export class RunPersistence {
|
|
|
38
39
|
this._tenantId = config.tenantId
|
|
39
40
|
this._projectId = config.projectId
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// The run's own evidence goes through the same kind of injectable seam
|
|
43
|
+
// the checkpoint store already had. Without it the transcript, the run
|
|
44
|
+
// record and the report could only ever live on a local filesystem —
|
|
45
|
+
// which for a kernel whose purpose is auditable evidence made the
|
|
46
|
+
// evidence the one thing that could not be pointed at durable storage.
|
|
47
|
+
this.runStore =
|
|
48
|
+
config.runStore ??
|
|
49
|
+
new RunDiskStore({
|
|
50
|
+
baseDir: config.outputDir,
|
|
51
|
+
logger: config.log,
|
|
52
|
+
})
|
|
45
53
|
|
|
46
54
|
// Checkpoints go through the injectable seam; the disk layout under
|
|
47
55
|
// `outputDir` (same tree the runStore writes to) stays the default.
|
|
@@ -137,7 +145,7 @@ export class RunPersistence {
|
|
|
137
145
|
return this.run
|
|
138
146
|
}
|
|
139
147
|
|
|
140
|
-
getRunStore():
|
|
148
|
+
getRunStore(): RunStore {
|
|
141
149
|
return this.runStore
|
|
142
150
|
}
|
|
143
151
|
|
|
@@ -457,7 +465,9 @@ export class RunPersistence {
|
|
|
457
465
|
async persist(): Promise<void> {
|
|
458
466
|
await this.runStore.writeRunMeta(this.run)
|
|
459
467
|
await this.runStore.writeMessages(this.run)
|
|
460
|
-
|
|
468
|
+
// Optional on the contract: a backend whose runs are already queryable
|
|
469
|
+
// has no browsable directory to add a row to.
|
|
470
|
+
await this.runStore.addToIndex?.(this.run)
|
|
461
471
|
|
|
462
472
|
if (this.run.result) {
|
|
463
473
|
await this.runStore.writeReport(this.run.result)
|
package/src/public-runtime.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { PermissionMode } from '../../types/permission/index.js'
|
|
|
17
17
|
import type { LLMProvider } from '../../types/provider/index.js'
|
|
18
18
|
import type { CheckpointStore } from '../../types/run/checkpoint-store.js'
|
|
19
19
|
import type { AgentRunConfig } from '../../types/run/index.js'
|
|
20
|
+
import type { RunStore } from '../../types/run/store.js'
|
|
20
21
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
21
22
|
import type { ModelPricing } from '../../utils/cost.js'
|
|
22
23
|
import { generateRunId } from '../../utils/id.js'
|
|
@@ -62,6 +63,7 @@ export interface RunContextConfig {
|
|
|
62
63
|
* output directory.
|
|
63
64
|
*/
|
|
64
65
|
checkpointStore?: CheckpointStore
|
|
66
|
+
runStore?: RunStore
|
|
65
67
|
|
|
66
68
|
/**
|
|
67
69
|
* Optional injected migrator — tests pass a stub; production code relies
|
|
@@ -186,6 +188,7 @@ export class RunContextFactory {
|
|
|
186
188
|
parentRunId: config.parentRunId,
|
|
187
189
|
depth: config.depth,
|
|
188
190
|
checkpointStore: config.checkpointStore,
|
|
191
|
+
runStore: config.runStore,
|
|
189
192
|
})
|
|
190
193
|
|
|
191
194
|
const trackingConfig = resolveActivityTracking(permissionMode, config.enableActivityTracking)
|
|
@@ -70,6 +70,7 @@ import type {
|
|
|
70
70
|
} from '../../types/run/index.js'
|
|
71
71
|
import type { PromoteMemory } from '../../types/run/memory-promotion.js'
|
|
72
72
|
import { memoryCandidateFor } from '../../types/run/memory-promotion.js'
|
|
73
|
+
import type { RunStore } from '../../types/run/store.js'
|
|
73
74
|
import type { Sandbox, SandboxProvider } from '../../types/sandbox/index.js'
|
|
74
75
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
75
76
|
import type { Skill } from '../../types/skills/index.js'
|
|
@@ -412,6 +413,17 @@ export interface QueryParams {
|
|
|
412
413
|
*/
|
|
413
414
|
checkpointStore?: CheckpointStore
|
|
414
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Where this run records its own evidence — the run record, its messages,
|
|
418
|
+
* its transcript and its report. Defaults to the disk layout under the
|
|
419
|
+
* resolved output directory.
|
|
420
|
+
*
|
|
421
|
+
* The sibling of {@link QueryParams.checkpointStore}, and it should always
|
|
422
|
+
* have been one: checkpoints could be pointed at durable storage and the
|
|
423
|
+
* evidence could not.
|
|
424
|
+
*/
|
|
425
|
+
runStore?: RunStore
|
|
426
|
+
|
|
415
427
|
runId?: RunId
|
|
416
428
|
|
|
417
429
|
parentRunId?: RunId
|
|
@@ -610,6 +622,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
610
622
|
tenantId: params.tenantId,
|
|
611
623
|
pathBuilder: params.pathBuilder,
|
|
612
624
|
checkpointStore: params.checkpointStore,
|
|
625
|
+
runStore: params.runStore,
|
|
613
626
|
runId: params.runId,
|
|
614
627
|
parentRunId: params.parentRunId,
|
|
615
628
|
depth: params.depth,
|
package/src/store/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { InMemoryStore } from './InMemoryStore.js'
|
|
|
2
2
|
export type { Identifiable, Timestamped } from './InMemoryStore.js'
|
|
3
3
|
|
|
4
4
|
export { RunDiskStore } from './run/disk.js'
|
|
5
|
+
export { InMemoryRunStore } from './run/memory.js'
|
|
5
6
|
export { DiskCheckpointStore } from './run/checkpoint-disk.js'
|
|
6
7
|
export type { DiskCheckpointStoreAttribution } from './run/checkpoint-disk.js'
|
|
7
8
|
export { InMemoryCheckpointStore } from './run/checkpoint-memory.js'
|
package/src/store/run/disk.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { appendFile, mkdir, readFile, readdir, unlink } from 'node:fs/promises'
|
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import type { CheckpointId, IterationCheckpoint } from '../../types/hitl/index.js'
|
|
4
4
|
import type { Run, RunEvent, RunStoreConfig } from '../../types/run/index.js'
|
|
5
|
+
import type { CompletedToolRecord, RunStore } from '../../types/run/store.js'
|
|
5
6
|
import { atomicWriteFile } from '../../utils/atomic-write.js'
|
|
6
7
|
import { type Logger, getRootLogger } from '../../utils/logger.js'
|
|
7
8
|
import { defineSchema, migrate, stamp } from '../schema.js'
|
|
@@ -16,15 +17,16 @@ import { defineSchema, migrate, stamp } from '../schema.js'
|
|
|
16
17
|
*/
|
|
17
18
|
const SCHEMA = defineSchema({ kind: 'run-store', current: 1, migrations: {} })
|
|
18
19
|
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
/**
|
|
21
|
+
* One finished tool call, recovered from the transcript.
|
|
22
|
+
*
|
|
23
|
+
* Re-exported from the store contract rather than declared twice. Two
|
|
24
|
+
* declarations of one concept, each populated by its own mapper, is the shape
|
|
25
|
+
* this repository has a rule about.
|
|
26
|
+
*/
|
|
27
|
+
export type { CompletedToolRecord }
|
|
26
28
|
|
|
27
|
-
export class RunDiskStore {
|
|
29
|
+
export class RunDiskStore implements RunStore {
|
|
28
30
|
private baseDir: string
|
|
29
31
|
private runDir: string | null = null
|
|
30
32
|
private log: Logger
|