@jungjaehoon/mama-core 1.6.0 → 1.7.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/db/migrations/037-create-context-packets.sql +32 -0
- package/dist/cases/wiki-page-index.js +6 -2
- package/dist/context-compile/boundary-defaults.d.ts +12 -0
- package/dist/context-compile/boundary-defaults.js +105 -0
- package/dist/context-compile/compiler-policy.d.ts +39 -0
- package/dist/context-compile/compiler-policy.js +147 -0
- package/dist/context-compile/compiler.d.ts +18 -0
- package/dist/context-compile/compiler.js +401 -0
- package/dist/context-compile/index.d.ts +9 -0
- package/dist/context-compile/index.js +25 -0
- package/dist/context-compile/packet-store.d.ts +9 -0
- package/dist/context-compile/packet-store.js +255 -0
- package/dist/context-compile/ref.d.ts +7 -0
- package/dist/context-compile/ref.js +102 -0
- package/dist/context-compile/source-readers.d.ts +69 -0
- package/dist/context-compile/source-readers.js +707 -0
- package/dist/context-compile/types.d.ts +138 -0
- package/dist/context-compile/types.js +11 -0
- package/dist/context-compile/visibility.d.ts +21 -0
- package/dist/context-compile/visibility.js +200 -0
- package/dist/db-adapter/node-sqlite-adapter.d.ts +3 -0
- package/dist/db-adapter/node-sqlite-adapter.js +76 -0
- package/dist/edges/ref-validation.js +55 -16
- package/dist/edges/types.d.ts +2 -0
- package/dist/embeddings.d.ts +3 -0
- package/dist/embeddings.js +37 -10
- package/dist/entities/store.d.ts +4 -1
- package/dist/entities/store.js +206 -78
- package/dist/entities/types.d.ts +5 -1
- package/dist/entities/types.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/memory/provenance.js +1 -0
- package/dist/memory/types.d.ts +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compileContext = compileContext;
|
|
7
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
8
|
+
const ref_validation_js_1 = require("../edges/ref-validation.js");
|
|
9
|
+
const ref_js_1 = require("./ref.js");
|
|
10
|
+
const visibility_js_1 = require("./visibility.js");
|
|
11
|
+
const visibility_js_2 = require("./visibility.js");
|
|
12
|
+
const boundary_defaults_js_1 = require("./boundary-defaults.js");
|
|
13
|
+
const source_readers_js_1 = require("./source-readers.js");
|
|
14
|
+
const compiler_policy_js_1 = require("./compiler-policy.js");
|
|
15
|
+
const COMPILER_VERSION = 'context-compile-v0';
|
|
16
|
+
function packetId() {
|
|
17
|
+
return `ctxp_${node_crypto_1.default.randomUUID().replace(/-/g, '')}`;
|
|
18
|
+
}
|
|
19
|
+
function emptyResult() {
|
|
20
|
+
return {
|
|
21
|
+
candidates: [],
|
|
22
|
+
hidden: { total: 0, by_kind: {}, by_reason: {} },
|
|
23
|
+
source_refs: [],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function mergeHidden(left, right) {
|
|
27
|
+
left.total += right.total;
|
|
28
|
+
for (const [kind, count] of Object.entries(right.by_kind)) {
|
|
29
|
+
const key = kind;
|
|
30
|
+
left.by_kind[key] = (left.by_kind[key] ?? 0) + count;
|
|
31
|
+
}
|
|
32
|
+
for (const [reason, count] of Object.entries(right.by_reason)) {
|
|
33
|
+
left.by_reason[reason] = (left.by_reason[reason] ?? 0) + count;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function assertNotAborted(deps) {
|
|
37
|
+
if (deps.signal?.aborted) {
|
|
38
|
+
throw new Error('Context compile aborted');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function isBudgetDeadlineExceeded(deps, now) {
|
|
42
|
+
if (typeof deps.deadlineMs === 'number' && now() >= deps.deadlineMs) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
function maxToolCalls(input) {
|
|
48
|
+
if (typeof input.max_tool_calls !== 'number' || !Number.isFinite(input.max_tool_calls)) {
|
|
49
|
+
return Number.POSITIVE_INFINITY;
|
|
50
|
+
}
|
|
51
|
+
return Math.max(0, Math.floor(input.max_tool_calls));
|
|
52
|
+
}
|
|
53
|
+
function parseTimeMs(value, field) {
|
|
54
|
+
if (value === null || value === undefined) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
58
|
+
return Math.floor(value);
|
|
59
|
+
}
|
|
60
|
+
if (typeof value === 'string') {
|
|
61
|
+
const trimmed = value.trim();
|
|
62
|
+
if (trimmed.length === 0) {
|
|
63
|
+
throw new Error(`Invalid context compile ${field}: ${String(value)}`);
|
|
64
|
+
}
|
|
65
|
+
const numeric = Number(trimmed);
|
|
66
|
+
if (Number.isFinite(numeric)) {
|
|
67
|
+
return Math.floor(numeric);
|
|
68
|
+
}
|
|
69
|
+
const parsed = Date.parse(trimmed);
|
|
70
|
+
if (Number.isFinite(parsed)) {
|
|
71
|
+
return parsed;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
throw new Error(`Invalid context compile ${field}: ${String(value)}`);
|
|
75
|
+
}
|
|
76
|
+
function rangeBoundaryMs(value, field) {
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
81
|
+
return Math.floor(value);
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`Invalid context compile ${field}: ${String(value)}`);
|
|
84
|
+
}
|
|
85
|
+
function minVisibleMs(input) {
|
|
86
|
+
return rangeBoundaryMs(input.range?.start_ms, 'range.start_ms');
|
|
87
|
+
}
|
|
88
|
+
function maxVisibleMs(input) {
|
|
89
|
+
const ends = [
|
|
90
|
+
rangeBoundaryMs(input.range?.end_ms, 'range.end_ms'),
|
|
91
|
+
parseTimeMs(input.as_of, 'as_of'),
|
|
92
|
+
].filter((value) => typeof value === 'number' && Number.isFinite(value));
|
|
93
|
+
return ends.length > 0 ? Math.min(...ends.map((value) => Math.floor(value))) : null;
|
|
94
|
+
}
|
|
95
|
+
function normalizeContextRange(range) {
|
|
96
|
+
if (range === undefined) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
if (range === null || typeof range !== 'object') {
|
|
100
|
+
throw new Error(`Invalid context compile range: ${String(range)}`);
|
|
101
|
+
}
|
|
102
|
+
const startMs = rangeBoundaryMs(range.start_ms, 'range.start_ms');
|
|
103
|
+
const endMs = rangeBoundaryMs(range.end_ms, 'range.end_ms');
|
|
104
|
+
if (startMs !== null && endMs !== null && startMs > endMs) {
|
|
105
|
+
throw new Error('Invalid context compile range: range.start_ms must be <= range.end_ms');
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
...(startMs !== null ? { start_ms: startMs } : {}),
|
|
109
|
+
...(endMs !== null ? { end_ms: endMs } : {}),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function rawCanonicalRefForRef(adapter, rawId) {
|
|
113
|
+
const row = adapter
|
|
114
|
+
.prepare(`
|
|
115
|
+
SELECT source_connector, source_id, channel
|
|
116
|
+
FROM connector_event_index
|
|
117
|
+
WHERE event_index_id = ?
|
|
118
|
+
LIMIT 1
|
|
119
|
+
`)
|
|
120
|
+
.get(rawId);
|
|
121
|
+
if (typeof row?.source_connector !== 'string') {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const ref = {
|
|
125
|
+
kind: 'raw',
|
|
126
|
+
connector: row.source_connector,
|
|
127
|
+
raw_id: rawId,
|
|
128
|
+
};
|
|
129
|
+
if (typeof row.source_id === 'string' && row.source_id.length > 0) {
|
|
130
|
+
ref.source_id = row.source_id;
|
|
131
|
+
}
|
|
132
|
+
ref.channel_id = typeof row.channel === 'string' ? row.channel : null;
|
|
133
|
+
return ref;
|
|
134
|
+
}
|
|
135
|
+
function canonicalizeRawSeedRefs(adapter, seedRefs) {
|
|
136
|
+
if (!adapter) {
|
|
137
|
+
return [...seedRefs];
|
|
138
|
+
}
|
|
139
|
+
return seedRefs.map((ref) => {
|
|
140
|
+
if (ref.kind !== 'raw') {
|
|
141
|
+
return ref;
|
|
142
|
+
}
|
|
143
|
+
return rawCanonicalRefForRef(adapter, ref.raw_id) ?? ref;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function hasSeedRefVisibilityConstraints(input, boundary) {
|
|
147
|
+
return (boundary !== undefined ||
|
|
148
|
+
input.scopes !== undefined ||
|
|
149
|
+
input.connectors !== undefined ||
|
|
150
|
+
input.project_refs !== undefined ||
|
|
151
|
+
(input.tenant_id !== undefined && input.tenant_id !== null) ||
|
|
152
|
+
input.range !== undefined ||
|
|
153
|
+
(input.as_of !== undefined && input.as_of !== null));
|
|
154
|
+
}
|
|
155
|
+
function assertSeedRefsVisibleToInput(adapter, input, seedRefs) {
|
|
156
|
+
if (seedRefs.length === 0) {
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
if (Array.isArray(input.scopes) && input.scopes.length === 0) {
|
|
160
|
+
throw new Error('Seed refs are outside the empty requested context scope set');
|
|
161
|
+
}
|
|
162
|
+
if (Array.isArray(input.connectors) &&
|
|
163
|
+
input.connectors.length === 0 &&
|
|
164
|
+
seedRefs.some((ref) => ref.kind === 'raw')) {
|
|
165
|
+
throw new Error('Seed raw refs are outside the empty requested connector set');
|
|
166
|
+
}
|
|
167
|
+
if (Array.isArray(input.project_refs) &&
|
|
168
|
+
input.project_refs.length === 0 &&
|
|
169
|
+
seedRefs.some((ref) => ref.kind === 'raw')) {
|
|
170
|
+
throw new Error('Seed raw refs are outside the empty requested project ref set');
|
|
171
|
+
}
|
|
172
|
+
if (!adapter) {
|
|
173
|
+
throw new Error('Context seed refs require adapter-backed visibility validation');
|
|
174
|
+
}
|
|
175
|
+
(0, ref_validation_js_1.assertTwinRefsVisible)(adapter, seedRefs.map(ref_js_1.toTwinRef), {
|
|
176
|
+
scopes: input.scopes,
|
|
177
|
+
connectors: input.connectors,
|
|
178
|
+
projectRefs: input.project_refs,
|
|
179
|
+
tenantId: input.tenant_id,
|
|
180
|
+
startMs: minVisibleMs(input),
|
|
181
|
+
asOfMs: maxVisibleMs(input),
|
|
182
|
+
});
|
|
183
|
+
for (const ref of seedRefs) {
|
|
184
|
+
if (ref.kind !== 'raw') {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const actualRef = rawCanonicalRefForRef(adapter, ref.raw_id);
|
|
188
|
+
if (actualRef?.kind !== 'raw' || actualRef.connector !== ref.connector) {
|
|
189
|
+
throw new Error(`Seed raw ref connector does not match visible raw record: ${ref.raw_id}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return canonicalizeRawSeedRefs(adapter, seedRefs);
|
|
193
|
+
}
|
|
194
|
+
function canReadMore(state, input) {
|
|
195
|
+
return state.usedToolCalls < maxToolCalls(input);
|
|
196
|
+
}
|
|
197
|
+
function sourceInput(input, boundary) {
|
|
198
|
+
const strictness = normalizeStrictness(input.strictness);
|
|
199
|
+
return {
|
|
200
|
+
task: input.task,
|
|
201
|
+
scopes: input.scopes,
|
|
202
|
+
connectors: input.connectors,
|
|
203
|
+
project_refs: input.project_refs,
|
|
204
|
+
tenant_id: input.tenant_id ?? null,
|
|
205
|
+
boundary,
|
|
206
|
+
range: input.range,
|
|
207
|
+
as_of: input.as_of,
|
|
208
|
+
limit: input.limit,
|
|
209
|
+
threshold: undefined,
|
|
210
|
+
strictness,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function normalizeStrictness(strictness) {
|
|
214
|
+
switch (strictness) {
|
|
215
|
+
case 'low':
|
|
216
|
+
case 'recall':
|
|
217
|
+
return 'recall';
|
|
218
|
+
case 'high':
|
|
219
|
+
case 'strict':
|
|
220
|
+
return 'strict';
|
|
221
|
+
case 'medium':
|
|
222
|
+
case 'balanced':
|
|
223
|
+
case undefined:
|
|
224
|
+
return 'balanced';
|
|
225
|
+
default: {
|
|
226
|
+
const _exhaustive = strictness;
|
|
227
|
+
throw new Error(`Unsupported context compile strictness: ${String(_exhaustive)}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function appendResult(state, step, result) {
|
|
232
|
+
state.candidates.push(...result.candidates);
|
|
233
|
+
state.sourceRefs.push(...result.source_refs);
|
|
234
|
+
mergeHidden(state.hidden, result.hidden);
|
|
235
|
+
state.expansionTrace.push({
|
|
236
|
+
step,
|
|
237
|
+
candidates: result.candidates.length,
|
|
238
|
+
source_refs: result.source_refs.length,
|
|
239
|
+
hidden: result.hidden.total,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function uniqueRefs(refs) {
|
|
243
|
+
const seen = new Set();
|
|
244
|
+
const unique = [];
|
|
245
|
+
for (const ref of refs) {
|
|
246
|
+
const key = (0, ref_js_1.serializeContextRefForProvenance)(ref);
|
|
247
|
+
if (seen.has(key)) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
seen.add(key);
|
|
251
|
+
unique.push(ref);
|
|
252
|
+
}
|
|
253
|
+
return unique;
|
|
254
|
+
}
|
|
255
|
+
async function compileContext(input, deps = {}) {
|
|
256
|
+
const now = deps.now ?? Date.now;
|
|
257
|
+
const startedAt = now();
|
|
258
|
+
const effectiveDeadline = typeof input.max_ms === 'number' && Number.isFinite(input.max_ms)
|
|
259
|
+
? Math.min(deps.deadlineMs ?? Number.POSITIVE_INFINITY, startedAt + Math.max(0, input.max_ms))
|
|
260
|
+
: deps.deadlineMs;
|
|
261
|
+
const effectiveDeps = { ...deps, deadlineMs: effectiveDeadline };
|
|
262
|
+
assertNotAborted(effectiveDeps);
|
|
263
|
+
const boundary = deps.boundary;
|
|
264
|
+
const seedRefs = (0, visibility_js_1.normalizeSeedRefs)(input.seed_refs);
|
|
265
|
+
let canonicalSeedRefs = canonicalizeRawSeedRefs(deps.adapter, seedRefs);
|
|
266
|
+
const effectiveInput = (0, boundary_defaults_js_1.applyContextBoundaryReadDefaults)(input, boundary);
|
|
267
|
+
const effectiveRange = normalizeContextRange(effectiveInput.range);
|
|
268
|
+
effectiveInput.range = effectiveRange;
|
|
269
|
+
parseTimeMs(effectiveInput.as_of, 'as_of');
|
|
270
|
+
if (boundary) {
|
|
271
|
+
(0, visibility_js_2.assertContextBoundaryAllowsInput)({
|
|
272
|
+
boundary,
|
|
273
|
+
requestedScopes: effectiveInput.scopes,
|
|
274
|
+
requestedConnectors: effectiveInput.connectors,
|
|
275
|
+
requestedProjectRefs: effectiveInput.project_refs,
|
|
276
|
+
requestedTenantId: effectiveInput.tenant_id,
|
|
277
|
+
seedRefs,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (deps.adapter || hasSeedRefVisibilityConstraints(effectiveInput, boundary)) {
|
|
281
|
+
canonicalSeedRefs = assertSeedRefsVisibleToInput(deps.adapter, effectiveInput, seedRefs);
|
|
282
|
+
}
|
|
283
|
+
const canonicalScopes = (0, visibility_js_2.canonicalizeContextScopes)(effectiveInput.scopes);
|
|
284
|
+
const readInput = sourceInput(effectiveInput, boundary);
|
|
285
|
+
const state = {
|
|
286
|
+
candidates: [],
|
|
287
|
+
sourceRefs: [...canonicalSeedRefs],
|
|
288
|
+
hidden: { total: 0, by_kind: {}, by_reason: {} },
|
|
289
|
+
expansionTrace: [{ step: 'seed_refs', source_refs: canonicalSeedRefs.length }],
|
|
290
|
+
usedToolCalls: 0,
|
|
291
|
+
};
|
|
292
|
+
let budgetExhausted = isBudgetDeadlineExceeded(effectiveDeps, now);
|
|
293
|
+
const skippedOperators = [];
|
|
294
|
+
const markBudgetSkipped = (operator) => {
|
|
295
|
+
budgetExhausted = true;
|
|
296
|
+
skippedOperators.push(operator);
|
|
297
|
+
};
|
|
298
|
+
if (!canReadMore(state, effectiveInput)) {
|
|
299
|
+
markBudgetSkipped('memory_recall');
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
assertNotAborted(effectiveDeps);
|
|
303
|
+
if (isBudgetDeadlineExceeded(effectiveDeps, now)) {
|
|
304
|
+
markBudgetSkipped('memory_recall');
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
state.usedToolCalls += 1;
|
|
308
|
+
const memoryResult = await (deps.readMemoryCandidates?.(readInput) ??
|
|
309
|
+
(0, source_readers_js_1.readMemoryCandidates)(readInput, deps.adapter ? { adapter: deps.adapter } : {}));
|
|
310
|
+
await appendResult(state, 'memory_recall', memoryResult);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const shouldReadRaw = (effectiveInput.connectors?.length ?? 0) > 0;
|
|
314
|
+
if (shouldReadRaw) {
|
|
315
|
+
if (!canReadMore(state, effectiveInput)) {
|
|
316
|
+
markBudgetSkipped('raw_window');
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
assertNotAborted(effectiveDeps);
|
|
320
|
+
if (isBudgetDeadlineExceeded(effectiveDeps, now)) {
|
|
321
|
+
markBudgetSkipped('raw_window');
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
state.usedToolCalls += 1;
|
|
325
|
+
const rawResult = await (deps.readRawCandidates?.(readInput) ??
|
|
326
|
+
(deps.adapter ? (0, source_readers_js_1.readRawCandidates)(deps.adapter, readInput) : emptyResult()));
|
|
327
|
+
await appendResult(state, 'raw_window', rawResult);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const visibleRefsForGraph = uniqueRefs([...state.sourceRefs]);
|
|
332
|
+
if (visibleRefsForGraph.length > 0) {
|
|
333
|
+
if (!canReadMore(state, effectiveInput)) {
|
|
334
|
+
markBudgetSkipped('graph_neighborhood');
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
assertNotAborted(effectiveDeps);
|
|
338
|
+
if (isBudgetDeadlineExceeded(effectiveDeps, now)) {
|
|
339
|
+
markBudgetSkipped('graph_neighborhood');
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
state.usedToolCalls += 1;
|
|
343
|
+
const graphResult = await (deps.readGraphCandidates?.(readInput, visibleRefsForGraph) ??
|
|
344
|
+
(deps.adapter
|
|
345
|
+
? (0, source_readers_js_1.readGraphCandidates)(deps.adapter, readInput, visibleRefsForGraph)
|
|
346
|
+
: emptyResult()));
|
|
347
|
+
await appendResult(state, 'graph_neighborhood', graphResult);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
assertNotAborted(effectiveDeps);
|
|
352
|
+
if (isBudgetDeadlineExceeded(effectiveDeps, now)) {
|
|
353
|
+
budgetExhausted = true;
|
|
354
|
+
}
|
|
355
|
+
const policy = (0, compiler_policy_js_1.applyContextCompilerPolicy)({
|
|
356
|
+
task: effectiveInput.task,
|
|
357
|
+
candidates: state.candidates,
|
|
358
|
+
hidden: state.hidden,
|
|
359
|
+
limit: effectiveInput.limit,
|
|
360
|
+
strictness: normalizeStrictness(effectiveInput.strictness),
|
|
361
|
+
max_tokens: effectiveInput.max_tokens,
|
|
362
|
+
});
|
|
363
|
+
const caveats = budgetExhausted ? [...policy.caveats, 'budget_exhausted'] : policy.caveats;
|
|
364
|
+
const completedAt = now();
|
|
365
|
+
return {
|
|
366
|
+
packet_id: deps.packetId?.() ?? packetId(),
|
|
367
|
+
mode: 'general',
|
|
368
|
+
task: effectiveInput.task,
|
|
369
|
+
scopes: canonicalScopes.scopes,
|
|
370
|
+
scope_hash: canonicalScopes.scopeHash,
|
|
371
|
+
generated_at: new Date(completedAt).toISOString(),
|
|
372
|
+
range: effectiveRange ?? null,
|
|
373
|
+
as_of: effectiveInput.as_of ?? null,
|
|
374
|
+
compiler_version: COMPILER_VERSION,
|
|
375
|
+
source_refs: uniqueRefs([...canonicalSeedRefs, ...policy.source_refs]),
|
|
376
|
+
selected_evidence: policy.selected_evidence,
|
|
377
|
+
evidence_clusters: policy.evidence_clusters,
|
|
378
|
+
related_decisions: policy.related_decisions,
|
|
379
|
+
rejected_refs: policy.rejected_refs,
|
|
380
|
+
rejected_refs_truncated: false,
|
|
381
|
+
rejected_summary: policy.rejected_summary,
|
|
382
|
+
missing_context: policy.missing_context,
|
|
383
|
+
caveats,
|
|
384
|
+
expansion_trace: state.expansionTrace,
|
|
385
|
+
retrieval_diagnostics: policy.retrieval_diagnostics,
|
|
386
|
+
budget: {
|
|
387
|
+
max_tool_calls: effectiveInput.max_tool_calls,
|
|
388
|
+
used_tool_calls: state.usedToolCalls,
|
|
389
|
+
max_ms: effectiveInput.max_ms,
|
|
390
|
+
elapsed_ms: Math.max(0, completedAt - startedAt),
|
|
391
|
+
max_tokens: effectiveInput.max_tokens,
|
|
392
|
+
estimated_tokens: policy.estimated_tokens,
|
|
393
|
+
budget_exhausted: budgetExhausted,
|
|
394
|
+
},
|
|
395
|
+
budget_manifest: {
|
|
396
|
+
budget_exhausted: budgetExhausted,
|
|
397
|
+
skipped_operators: skippedOperators,
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './boundary-defaults.js';
|
|
3
|
+
export * from './ref.js';
|
|
4
|
+
export * from './visibility.js';
|
|
5
|
+
export * from './packet-store.js';
|
|
6
|
+
export * from './source-readers.js';
|
|
7
|
+
export * from './compiler-policy.js';
|
|
8
|
+
export * from './compiler.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types.js"), exports);
|
|
18
|
+
__exportStar(require("./boundary-defaults.js"), exports);
|
|
19
|
+
__exportStar(require("./ref.js"), exports);
|
|
20
|
+
__exportStar(require("./visibility.js"), exports);
|
|
21
|
+
__exportStar(require("./packet-store.js"), exports);
|
|
22
|
+
__exportStar(require("./source-readers.js"), exports);
|
|
23
|
+
__exportStar(require("./compiler-policy.js"), exports);
|
|
24
|
+
__exportStar(require("./compiler.js"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from '../db-manager.js';
|
|
2
|
+
import type { ContextPacketRecord, TrustedContextPacketLookupInput } from './types.js';
|
|
3
|
+
type ContextPacketAdapter = Pick<DatabaseAdapter, 'prepare'>;
|
|
4
|
+
export declare function insertContextPacket(adapter: ContextPacketAdapter, packet: ContextPacketRecord): ContextPacketRecord;
|
|
5
|
+
export declare function getContextPacket(adapter: ContextPacketAdapter, packetId: string): ContextPacketRecord | null;
|
|
6
|
+
export declare function listContextPacketsForModelRun(adapter: ContextPacketAdapter, modelRunId: string, limit?: number): ContextPacketRecord[];
|
|
7
|
+
export declare function getContextPacketForTrustedUse(adapter: ContextPacketAdapter, input: TrustedContextPacketLookupInput): ContextPacketRecord | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=packet-store.d.ts.map
|