@orquentra/codebuddy 0.0.0-stage → 2.4.1
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/ARCHITECTURE.md +269 -0
- package/CLAUDE_CODEX.md +433 -0
- package/LICENSE +21 -0
- package/README.md +55 -2
- package/WORKFLOW.md +152 -0
- package/dist/chunk-3ZELDCR3.js +204 -0
- package/dist/chunk-3ZELDCR3.js.map +1 -0
- package/dist/chunk-5OWZVZSO.js +476 -0
- package/dist/chunk-5OWZVZSO.js.map +1 -0
- package/dist/chunk-DSN5CEHO.js +175 -0
- package/dist/chunk-DSN5CEHO.js.map +1 -0
- package/dist/chunk-GDJH7XJC.js +119 -0
- package/dist/chunk-GDJH7XJC.js.map +1 -0
- package/dist/chunk-IBMJYIEP.js +1578 -0
- package/dist/chunk-IBMJYIEP.js.map +1 -0
- package/dist/chunk-IE2OUO54.js +199 -0
- package/dist/chunk-IE2OUO54.js.map +1 -0
- package/dist/chunk-IHQM2ZDV.js +19 -0
- package/dist/chunk-IHQM2ZDV.js.map +1 -0
- package/dist/chunk-ITGRANYW.js +63 -0
- package/dist/chunk-ITGRANYW.js.map +1 -0
- package/dist/chunk-K63EOA4B.js +416 -0
- package/dist/chunk-K63EOA4B.js.map +1 -0
- package/dist/chunk-OLFCOR4U.js +8580 -0
- package/dist/chunk-OLFCOR4U.js.map +1 -0
- package/dist/chunk-PQK3GKZH.js +98 -0
- package/dist/chunk-PQK3GKZH.js.map +1 -0
- package/dist/chunk-PYLH4MH5.js +34 -0
- package/dist/chunk-PYLH4MH5.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-TI5TQD6D.js +324 -0
- package/dist/chunk-TI5TQD6D.js.map +1 -0
- package/dist/chunk-WHZSVY2L.js +144 -0
- package/dist/chunk-WHZSVY2L.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/codebuddy-D2xJ6hFk.d.ts +841 -0
- package/dist/config-S2TULOMK.js +11 -0
- package/dist/config-S2TULOMK.js.map +1 -0
- package/dist/index.d.ts +2527 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/dist/langgraph/index.d.ts +53 -0
- package/dist/langgraph/index.js +143 -0
- package/dist/langgraph/index.js.map +1 -0
- package/dist/lean-command-D6TZJEFX.js +13 -0
- package/dist/lean-command-D6TZJEFX.js.map +1 -0
- package/dist/main-BFDVQHKO.js +4575 -0
- package/dist/main-BFDVQHKO.js.map +1 -0
- package/dist/memory-NIBFAMY4.js +57 -0
- package/dist/memory-NIBFAMY4.js.map +1 -0
- package/dist/pretool-command-MQQ2UNQM.js +10 -0
- package/dist/pretool-command-MQQ2UNQM.js.map +1 -0
- package/dist/rerank-Q7MIFNKA.js +60 -0
- package/dist/rerank-Q7MIFNKA.js.map +1 -0
- package/dist/summaries-TSE44KUQ.js +18 -0
- package/dist/summaries-TSE44KUQ.js.map +1 -0
- package/dist/zvec-F27AR357.js +23 -0
- package/dist/zvec-F27AR357.js.map +1 -0
- package/docker-compose.yml +20 -0
- package/examples/claude-code/README.md +67 -0
- package/examples/claude-desktop/README.md +54 -0
- package/examples/claude-desktop/claude_desktop_config.json +13 -0
- package/examples/langgraph-agent/README.md +32 -0
- package/examples/langgraph-agent/index.ts +71 -0
- package/examples/multi-agent-handoff/README.md +35 -0
- package/examples/multi-agent-handoff/index.ts +68 -0
- package/package.json +108 -4
- package/src/db/migrations/0000_cultured_satana.sql +144 -0
- package/src/db/migrations/0001_embedding_lease.sql +3 -0
- package/src/db/migrations/0002_embedding_lease_token.sql +1 -0
- package/src/db/migrations/0003_embedding_space.sql +9 -0
- package/src/db/migrations/0004_markdown_reconcile.sql +5 -0
- package/src/db/migrations/0005_fact_propositions.sql +1 -0
- package/src/db/migrations/meta/0000_snapshot.json +1169 -0
- package/src/db/migrations/meta/0002_snapshot.json +1181 -0
- package/src/db/migrations/meta/0003_snapshot.json +1214 -0
- package/src/db/migrations/meta/0004_snapshot.json +1225 -0
- package/src/db/migrations/meta/0005_snapshot.json +1231 -0
- package/src/db/migrations/meta/_journal.json +48 -0
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
type ProviderCallType = "embedding" | "llm";
|
|
4
|
+
type ProviderCallStatus = "success" | "failed" | "timeout" | "rate_limited" | "gated" | "fallback";
|
|
5
|
+
type ProviderCallMetadata = {
|
|
6
|
+
model: string;
|
|
7
|
+
type: ProviderCallType;
|
|
8
|
+
status: ProviderCallStatus;
|
|
9
|
+
latencyMs: number;
|
|
10
|
+
tokens?: number;
|
|
11
|
+
error?: string;
|
|
12
|
+
retries: number;
|
|
13
|
+
fallbackTriggered: boolean;
|
|
14
|
+
coldStartWaitMs: number;
|
|
15
|
+
/** Wall-clock arrival stamp (ms epoch) set by repositories that keep call logs. */
|
|
16
|
+
recordedAt?: number;
|
|
17
|
+
};
|
|
18
|
+
type ProviderDiagnosticsHook = (metadata: ProviderCallMetadata) => void | Promise<void>;
|
|
19
|
+
type EmbeddingRequest = {
|
|
20
|
+
input: string | string[];
|
|
21
|
+
model?: string;
|
|
22
|
+
};
|
|
23
|
+
type EmbeddingResponse = {
|
|
24
|
+
model: string;
|
|
25
|
+
/** Use an immutable revision when the provider supports one. */
|
|
26
|
+
revision?: string;
|
|
27
|
+
/** Version of pooling, normalization, and other preprocessing. */
|
|
28
|
+
schema?: string;
|
|
29
|
+
dimensions: number;
|
|
30
|
+
vectors: number[][];
|
|
31
|
+
};
|
|
32
|
+
type TextGenerationRequest = {
|
|
33
|
+
prompt: string;
|
|
34
|
+
model?: string;
|
|
35
|
+
};
|
|
36
|
+
type TextGenerationResponse = {
|
|
37
|
+
model: string;
|
|
38
|
+
text: string;
|
|
39
|
+
};
|
|
40
|
+
type ModelProvider = {
|
|
41
|
+
embed(request: EmbeddingRequest): Promise<EmbeddingResponse>;
|
|
42
|
+
generateText(request: TextGenerationRequest): Promise<TextGenerationResponse>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type ProviderConfig = {
|
|
46
|
+
type: "huggingface";
|
|
47
|
+
apiKey?: string;
|
|
48
|
+
};
|
|
49
|
+
type WorkerConfig = {
|
|
50
|
+
pollIntervalMs?: number;
|
|
51
|
+
batchSize?: number;
|
|
52
|
+
maxAttempts?: number;
|
|
53
|
+
};
|
|
54
|
+
type CodeBuddyConfig = {
|
|
55
|
+
postgresUrl: string;
|
|
56
|
+
provider: ProviderConfig;
|
|
57
|
+
namespace: string;
|
|
58
|
+
projectRoot?: string;
|
|
59
|
+
tokenBudget?: number;
|
|
60
|
+
graphify?: {
|
|
61
|
+
enabled: boolean;
|
|
62
|
+
graphPath?: string | undefined;
|
|
63
|
+
};
|
|
64
|
+
worker?: WorkerConfig;
|
|
65
|
+
};
|
|
66
|
+
type CodeBuddyStatus = {
|
|
67
|
+
ready: boolean;
|
|
68
|
+
phase: "foundation" | "storage" | "runtime";
|
|
69
|
+
message: string;
|
|
70
|
+
namespaceId: string;
|
|
71
|
+
};
|
|
72
|
+
type MemoryWriteType = "interaction" | "fact" | "summary";
|
|
73
|
+
type RememberInput = {
|
|
74
|
+
sessionId?: string;
|
|
75
|
+
content: string;
|
|
76
|
+
type?: MemoryWriteType;
|
|
77
|
+
idempotencyKey?: string;
|
|
78
|
+
agentId?: string;
|
|
79
|
+
};
|
|
80
|
+
type RememberBatchItem = RememberInput;
|
|
81
|
+
type RememberResult = {
|
|
82
|
+
id: string;
|
|
83
|
+
sessionId: string;
|
|
84
|
+
deduplicated: boolean;
|
|
85
|
+
};
|
|
86
|
+
type RecallInput = {
|
|
87
|
+
sessionId: string;
|
|
88
|
+
query: string;
|
|
89
|
+
budget?: number;
|
|
90
|
+
callerModel?: string;
|
|
91
|
+
conflictMode?: "all" | "latest" | "highest_confidence";
|
|
92
|
+
};
|
|
93
|
+
type RecallResult = PlannedContext;
|
|
94
|
+
type ShareInput = {
|
|
95
|
+
from: string;
|
|
96
|
+
to: string;
|
|
97
|
+
factIds: string[];
|
|
98
|
+
mode?: "reference" | "snapshot";
|
|
99
|
+
/** Snapshot mode: root of the target project whose Markdown store receives the copy. */
|
|
100
|
+
targetProjectRoot?: string;
|
|
101
|
+
agentId?: string;
|
|
102
|
+
};
|
|
103
|
+
type ShareResult = {
|
|
104
|
+
shared: number;
|
|
105
|
+
};
|
|
106
|
+
type UnshareInput = {
|
|
107
|
+
to: string;
|
|
108
|
+
factIds: string[];
|
|
109
|
+
agentId?: string;
|
|
110
|
+
};
|
|
111
|
+
type UnshareResult = {
|
|
112
|
+
revoked: number;
|
|
113
|
+
};
|
|
114
|
+
type ForgetResult = {
|
|
115
|
+
ok: boolean;
|
|
116
|
+
entityType: "interaction" | "fact" | "unknown";
|
|
117
|
+
};
|
|
118
|
+
type EmbeddingJobStatus = "pending" | "processing" | "ready" | "failed";
|
|
119
|
+
type AuditAction = "remember" | "remember_batch" | "share" | "forget" | "config";
|
|
120
|
+
|
|
121
|
+
type NamespaceRow = {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
};
|
|
125
|
+
type InteractionInsert = {
|
|
126
|
+
id: string;
|
|
127
|
+
namespaceId: string;
|
|
128
|
+
sessionId: string;
|
|
129
|
+
content: string;
|
|
130
|
+
contentHash: string;
|
|
131
|
+
tokenCount: number;
|
|
132
|
+
createdByAgent?: string | undefined;
|
|
133
|
+
};
|
|
134
|
+
type FactInsert = {
|
|
135
|
+
id: string;
|
|
136
|
+
namespaceId: string;
|
|
137
|
+
content: string;
|
|
138
|
+
contentHash: string;
|
|
139
|
+
subject: string;
|
|
140
|
+
predicate: string;
|
|
141
|
+
object: string;
|
|
142
|
+
/** Explicit single-valued proposition identity; null/absent allows multiple values. */
|
|
143
|
+
propositionKey?: string | null | undefined;
|
|
144
|
+
/** Imported provenance/lifecycle from the Markdown source; defaults apply when absent. */
|
|
145
|
+
confidence?: number | undefined;
|
|
146
|
+
createdAt?: Date | undefined;
|
|
147
|
+
sourceDeleted?: boolean | undefined;
|
|
148
|
+
supersededBy?: string | null | undefined;
|
|
149
|
+
sourceInteractionId?: string | undefined;
|
|
150
|
+
createdByAgent?: string | undefined;
|
|
151
|
+
};
|
|
152
|
+
type SummaryInsert = {
|
|
153
|
+
id: string;
|
|
154
|
+
namespaceId: string;
|
|
155
|
+
sessionId: string;
|
|
156
|
+
content: string;
|
|
157
|
+
version?: number | undefined;
|
|
158
|
+
tokenCount: number;
|
|
159
|
+
createdByAgent?: string | undefined;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* A fact as declared by its Markdown file. Unlike {@link FactInsert} (which
|
|
163
|
+
* deduplicates `remember` writes by content), this upserts by stable ID and
|
|
164
|
+
* carries every field the file owns so import never resets lifecycle state.
|
|
165
|
+
*/
|
|
166
|
+
type FactFileUpsert = FactInsert & {
|
|
167
|
+
confidence: number;
|
|
168
|
+
sourceDeleted: boolean;
|
|
169
|
+
supersededBy: string | null;
|
|
170
|
+
createdAt: Date;
|
|
171
|
+
};
|
|
172
|
+
type SummaryFileUpsert = SummaryInsert & {
|
|
173
|
+
createdAt: Date;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* `unchanged` writes nothing (replays are free); `updated` re-embeds only when
|
|
177
|
+
* the content changed.
|
|
178
|
+
*/
|
|
179
|
+
type FileUpsertResult = {
|
|
180
|
+
status: "inserted" | "updated" | "unchanged";
|
|
181
|
+
};
|
|
182
|
+
type PendingEmbeddingInsert = {
|
|
183
|
+
id: string;
|
|
184
|
+
namespaceId: string;
|
|
185
|
+
ownerType: MemoryWriteType;
|
|
186
|
+
ownerId: string;
|
|
187
|
+
embeddingModel: string;
|
|
188
|
+
};
|
|
189
|
+
type EmbeddingJob = {
|
|
190
|
+
id: string;
|
|
191
|
+
leaseToken: string;
|
|
192
|
+
leaseMs: number;
|
|
193
|
+
namespaceId: string;
|
|
194
|
+
ownerType: MemoryWriteType;
|
|
195
|
+
ownerId: string;
|
|
196
|
+
embeddingModel: string;
|
|
197
|
+
attempts: number;
|
|
198
|
+
content: string;
|
|
199
|
+
};
|
|
200
|
+
type WriteResult = {
|
|
201
|
+
id: string;
|
|
202
|
+
embeddingId: string;
|
|
203
|
+
sessionId: string;
|
|
204
|
+
deduplicated: boolean;
|
|
205
|
+
};
|
|
206
|
+
type AuditEntry = {
|
|
207
|
+
id: string;
|
|
208
|
+
namespaceId: string;
|
|
209
|
+
action: AuditAction;
|
|
210
|
+
entityType: string;
|
|
211
|
+
entityId?: string | undefined;
|
|
212
|
+
createdByAgent?: string | undefined;
|
|
213
|
+
metadata?: Record<string, unknown> | undefined;
|
|
214
|
+
};
|
|
215
|
+
type ModelCallEntry = {
|
|
216
|
+
id: string;
|
|
217
|
+
namespaceId?: string | undefined;
|
|
218
|
+
metadata: ProviderCallMetadata;
|
|
219
|
+
};
|
|
220
|
+
type ShareWriteInput = {
|
|
221
|
+
id: string;
|
|
222
|
+
fromNamespaceId: string;
|
|
223
|
+
toNamespaceId: string;
|
|
224
|
+
sourceFactId: string;
|
|
225
|
+
mode: "reference" | "snapshot";
|
|
226
|
+
snapshotFactId?: string | undefined;
|
|
227
|
+
createdByAgent?: string | undefined;
|
|
228
|
+
};
|
|
229
|
+
type EmbeddingStatusSnapshot = {
|
|
230
|
+
id: string;
|
|
231
|
+
status: EmbeddingJobStatus;
|
|
232
|
+
attempts: number;
|
|
233
|
+
lastError: string | null;
|
|
234
|
+
};
|
|
235
|
+
type ReadyEmbedding = {
|
|
236
|
+
embeddingId: string;
|
|
237
|
+
ownerType: MemoryWriteType;
|
|
238
|
+
ownerId: string;
|
|
239
|
+
vector: number[];
|
|
240
|
+
embeddingModel: string;
|
|
241
|
+
embeddingSpace: string | null;
|
|
242
|
+
};
|
|
243
|
+
/** Bounded owner references; vectors stay inside the repository. */
|
|
244
|
+
type SimilarEmbedding = Omit<ReadyEmbedding, "vector"> & {
|
|
245
|
+
score: number;
|
|
246
|
+
};
|
|
247
|
+
type SimilaritySearchInput = {
|
|
248
|
+
namespaceId: string;
|
|
249
|
+
/** Exact embedding space key (#37); vectors from another space never compare. */
|
|
250
|
+
embeddingSpace: string;
|
|
251
|
+
embeddingModel: string;
|
|
252
|
+
vector: number[];
|
|
253
|
+
limit: number;
|
|
254
|
+
};
|
|
255
|
+
type SimilaritySearchResult = {
|
|
256
|
+
method: "exact_pgvector" | "exact_memory";
|
|
257
|
+
candidates: SimilarEmbedding[];
|
|
258
|
+
compatibleReady: number;
|
|
259
|
+
};
|
|
260
|
+
type LexicalFactSearchResult = {
|
|
261
|
+
candidates: Array<RecentFact & {
|
|
262
|
+
score: number;
|
|
263
|
+
}>;
|
|
264
|
+
matchedFacts: number;
|
|
265
|
+
};
|
|
266
|
+
type RecentInteraction = {
|
|
267
|
+
id: string;
|
|
268
|
+
sessionId: string;
|
|
269
|
+
content: string;
|
|
270
|
+
tokenCount: number;
|
|
271
|
+
createdAt: Date;
|
|
272
|
+
};
|
|
273
|
+
type RecentFact = {
|
|
274
|
+
id: string;
|
|
275
|
+
content: string;
|
|
276
|
+
subject: string;
|
|
277
|
+
predicate: string;
|
|
278
|
+
object: string;
|
|
279
|
+
propositionKey: string | null;
|
|
280
|
+
confidence: number;
|
|
281
|
+
sourceDeleted: boolean;
|
|
282
|
+
supersededBy: string | null;
|
|
283
|
+
createdByAgent: string | null;
|
|
284
|
+
createdAt: Date;
|
|
285
|
+
};
|
|
286
|
+
type RecentSummary = {
|
|
287
|
+
id: string;
|
|
288
|
+
sessionId: string;
|
|
289
|
+
content: string;
|
|
290
|
+
tokenCount: number;
|
|
291
|
+
createdAt: Date;
|
|
292
|
+
};
|
|
293
|
+
type PendingEmbeddingCounts = {
|
|
294
|
+
pending: number;
|
|
295
|
+
/** Claimed and inside their lease window. */
|
|
296
|
+
processing: number;
|
|
297
|
+
failed: number;
|
|
298
|
+
ready: number;
|
|
299
|
+
};
|
|
300
|
+
type ListedFact = {
|
|
301
|
+
id: string;
|
|
302
|
+
subject: string;
|
|
303
|
+
predicate: string;
|
|
304
|
+
object: string;
|
|
305
|
+
content: string;
|
|
306
|
+
confidence: number;
|
|
307
|
+
sourceInteractionId: string | null;
|
|
308
|
+
sourceDeleted: boolean;
|
|
309
|
+
supersededBy: string | null;
|
|
310
|
+
createdByAgent: string | null;
|
|
311
|
+
createdAt: Date;
|
|
312
|
+
};
|
|
313
|
+
type ListedSummary = {
|
|
314
|
+
id: string;
|
|
315
|
+
sessionId: string;
|
|
316
|
+
content: string;
|
|
317
|
+
version: number;
|
|
318
|
+
tokenCount: number;
|
|
319
|
+
createdByAgent: string | null;
|
|
320
|
+
createdAt: Date;
|
|
321
|
+
};
|
|
322
|
+
type FactCursor = {
|
|
323
|
+
createdAt: Date;
|
|
324
|
+
id: string;
|
|
325
|
+
};
|
|
326
|
+
type NamespaceSummary = {
|
|
327
|
+
name: string;
|
|
328
|
+
factCount: number;
|
|
329
|
+
lastActivity: Date | null;
|
|
330
|
+
};
|
|
331
|
+
type AgentWriteBreakdown = {
|
|
332
|
+
agentId: string | null;
|
|
333
|
+
writes: number;
|
|
334
|
+
};
|
|
335
|
+
type MemoryStats = {
|
|
336
|
+
namespaces: number;
|
|
337
|
+
interactions: number;
|
|
338
|
+
facts: number;
|
|
339
|
+
summaries: number;
|
|
340
|
+
embeddings: PendingEmbeddingCounts;
|
|
341
|
+
modelCalls: {
|
|
342
|
+
last60s: number;
|
|
343
|
+
lastHour: number;
|
|
344
|
+
last24h: number;
|
|
345
|
+
gatedFailures: number;
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
type VectorIndexHealth = {
|
|
349
|
+
vectorCount: number;
|
|
350
|
+
indexName: string | null;
|
|
351
|
+
indexDefinition: string | null;
|
|
352
|
+
needsTuning: boolean;
|
|
353
|
+
};
|
|
354
|
+
type MemoryRepository = {
|
|
355
|
+
ensureNamespace(name: string): Promise<NamespaceRow>;
|
|
356
|
+
getNamespaceByName(name: string): Promise<NamespaceRow | null>;
|
|
357
|
+
withSessionLock<T>(namespaceId: string, sessionId: string, fn: () => Promise<T>): Promise<T>;
|
|
358
|
+
writeInteraction(input: {
|
|
359
|
+
interaction: InteractionInsert;
|
|
360
|
+
embedding: PendingEmbeddingInsert;
|
|
361
|
+
audit: AuditEntry;
|
|
362
|
+
}): Promise<WriteResult>;
|
|
363
|
+
writeFact(input: {
|
|
364
|
+
fact: FactInsert;
|
|
365
|
+
embedding: PendingEmbeddingInsert;
|
|
366
|
+
audit: AuditEntry;
|
|
367
|
+
}): Promise<WriteResult>;
|
|
368
|
+
writeSummary(input: {
|
|
369
|
+
summary: SummaryInsert;
|
|
370
|
+
embedding: PendingEmbeddingInsert;
|
|
371
|
+
audit: AuditEntry;
|
|
372
|
+
}): Promise<WriteResult>;
|
|
373
|
+
/**
|
|
374
|
+
* Markdown import: insert or update the fact with this ID in `namespaceId`,
|
|
375
|
+
* marking it file-backed. Throws (without writing) when the ID belongs to
|
|
376
|
+
* another namespace or the content duplicates a different fact.
|
|
377
|
+
*/
|
|
378
|
+
upsertFactFromFile(input: {
|
|
379
|
+
fact: FactFileUpsert;
|
|
380
|
+
embedding: PendingEmbeddingInsert;
|
|
381
|
+
audit: AuditEntry;
|
|
382
|
+
}): Promise<FileUpsertResult>;
|
|
383
|
+
upsertSummaryFromFile(input: {
|
|
384
|
+
summary: SummaryFileUpsert;
|
|
385
|
+
embedding: PendingEmbeddingInsert;
|
|
386
|
+
audit: AuditEntry;
|
|
387
|
+
}): Promise<FileUpsertResult>;
|
|
388
|
+
/** IDs of rows a reindex imported from Markdown (the only rows reconcile may delete). */
|
|
389
|
+
listFileBackedIds(namespaceId: string): Promise<{
|
|
390
|
+
facts: string[];
|
|
391
|
+
summaries: string[];
|
|
392
|
+
}>;
|
|
393
|
+
claimPendingEmbeddings(limit: number): Promise<EmbeddingJob[]>;
|
|
394
|
+
renewEmbeddingLease(id: string, leaseToken: string): Promise<boolean>;
|
|
395
|
+
markEmbeddingReady(id: string, leaseToken: string, vector: number[], model: string, space?: string): Promise<boolean>;
|
|
396
|
+
markEmbeddingFailed(id: string, leaseToken: string, error: string, attempts: number, options?: {
|
|
397
|
+
maxAttempts?: number;
|
|
398
|
+
}): Promise<boolean>;
|
|
399
|
+
getEmbeddingStatus(id: string): Promise<EmbeddingStatusSnapshot | null>;
|
|
400
|
+
/** Grant (or re-grant after revocation) a live reference. Idempotent per target+fact. */
|
|
401
|
+
shareReference(input: ShareWriteInput): Promise<void>;
|
|
402
|
+
/** Tombstone live reference shares; returns how many were revoked. */
|
|
403
|
+
revokeShares(fromNamespaceId: string, toNamespaceId: string, factIds: string[]): Promise<number>;
|
|
404
|
+
/**
|
|
405
|
+
* Copy a fact into the target namespace. Idempotent: an existing snapshot of
|
|
406
|
+
* the same source (or an identical copy already in the target) is reused.
|
|
407
|
+
*/
|
|
408
|
+
shareSnapshot(input: {
|
|
409
|
+
share: ShareWriteInput;
|
|
410
|
+
snapshotFact: FactInsert;
|
|
411
|
+
embedding: PendingEmbeddingInsert;
|
|
412
|
+
}): Promise<{
|
|
413
|
+
snapshotFactId: string;
|
|
414
|
+
}>;
|
|
415
|
+
/**
|
|
416
|
+
* Delete an interaction and mark every fact derived from it `sourceDeleted`.
|
|
417
|
+
* Returns the marked fact ids so callers can persist the same lifecycle
|
|
418
|
+
* state to Markdown.
|
|
419
|
+
*/
|
|
420
|
+
forgetInteraction(namespaceId: string, id: string, audit: AuditEntry): Promise<{
|
|
421
|
+
found: boolean;
|
|
422
|
+
sourceDeletedFactIds: string[];
|
|
423
|
+
}>;
|
|
424
|
+
forgetFact(namespaceId: string, id: string, audit: AuditEntry): Promise<{
|
|
425
|
+
found: boolean;
|
|
426
|
+
}>;
|
|
427
|
+
forgetSummary(namespaceId: string, id: string, audit: AuditEntry): Promise<{
|
|
428
|
+
found: boolean;
|
|
429
|
+
}>;
|
|
430
|
+
recordModelCall(entry: ModelCallEntry): Promise<void>;
|
|
431
|
+
recordAudit(entry: AuditEntry): Promise<void>;
|
|
432
|
+
/**
|
|
433
|
+
* Ready embeddings visible to the namespace: its own, plus facts shared to it
|
|
434
|
+
* through live (non-tombstoned) reference shares from the owning namespace.
|
|
435
|
+
*/
|
|
436
|
+
getReadyEmbeddings(namespaceId: string, limit: number, space?: string): Promise<ReadyEmbedding[]>;
|
|
437
|
+
/** Rank every compatible visible vector (own + live shares) before applying the limit. */
|
|
438
|
+
searchSimilarEmbeddings(input: SimilaritySearchInput): Promise<SimilaritySearchResult>;
|
|
439
|
+
/** Search durable facts across every session, including pending/failed embeddings. */
|
|
440
|
+
searchFactsLexically(namespaceId: string, query: string, limit: number): Promise<LexicalFactSearchResult>;
|
|
441
|
+
getRecentInteractions(namespaceId: string, sessionId: string, limit: number): Promise<RecentInteraction[]>;
|
|
442
|
+
getRecentFacts(namespaceId: string, limit: number): Promise<RecentFact[]>;
|
|
443
|
+
getLatestSummary(namespaceId: string, sessionId: string): Promise<RecentSummary | null>;
|
|
444
|
+
getInteractionsByIds(namespaceId: string, ids: string[]): Promise<RecentInteraction[]>;
|
|
445
|
+
/** Facts visible to the namespace (own + live reference shares), by id. */
|
|
446
|
+
getFactsByIds(namespaceId: string, ids: string[]): Promise<RecentFact[]>;
|
|
447
|
+
getSummariesByIds(namespaceId: string, ids: string[]): Promise<RecentSummary[]>;
|
|
448
|
+
/** Fetch one fact with its full SPO fields, or null when missing. */
|
|
449
|
+
getFactById(namespaceId: string, id: string): Promise<ListedFact | null>;
|
|
450
|
+
countEmbeddingStatuses(namespaceId: string): Promise<PendingEmbeddingCounts>;
|
|
451
|
+
listFacts(input: {
|
|
452
|
+
namespaceId: string;
|
|
453
|
+
subject?: string;
|
|
454
|
+
limit: number;
|
|
455
|
+
cursor?: FactCursor;
|
|
456
|
+
}): Promise<ListedFact[]>;
|
|
457
|
+
listSummaries(input: {
|
|
458
|
+
namespaceId: string;
|
|
459
|
+
limit: number;
|
|
460
|
+
}): Promise<ListedSummary[]>;
|
|
461
|
+
listNamespaces(): Promise<NamespaceSummary[]>;
|
|
462
|
+
getAgentWriteBreakdown(namespaceId?: string): Promise<AgentWriteBreakdown[]>;
|
|
463
|
+
getStats(namespaceId?: string): Promise<MemoryStats>;
|
|
464
|
+
pruneBefore(cutoff: Date): Promise<{
|
|
465
|
+
interactions: number;
|
|
466
|
+
facts: number;
|
|
467
|
+
summaries: number;
|
|
468
|
+
}>;
|
|
469
|
+
getVectorIndexHealth(namespaceId?: string): Promise<VectorIndexHealth>;
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
/** Identity of the coordinate system, including provider preprocessing. */
|
|
473
|
+
type EmbeddingSpace = {
|
|
474
|
+
model: string;
|
|
475
|
+
revision: string;
|
|
476
|
+
schema: string;
|
|
477
|
+
dimensions: number;
|
|
478
|
+
};
|
|
479
|
+
type QueryEmbedding = {
|
|
480
|
+
vector: number[];
|
|
481
|
+
space: EmbeddingSpace;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
type ConflictMode = "all" | "latest" | "highest_confidence";
|
|
485
|
+
type PlanInput = {
|
|
486
|
+
namespace: string;
|
|
487
|
+
namespaceId: string;
|
|
488
|
+
sessionId: string;
|
|
489
|
+
query: string;
|
|
490
|
+
budget: number;
|
|
491
|
+
callerModel?: string | undefined;
|
|
492
|
+
conflictMode: ConflictMode;
|
|
493
|
+
queryEmbedding: QueryEmbedding | null;
|
|
494
|
+
repository: MemoryRepository;
|
|
495
|
+
};
|
|
496
|
+
/** Structured provenance for a recalled fact; `conflict` is set when its proposition key had rivals. */
|
|
497
|
+
type FactProvenance = {
|
|
498
|
+
id: string;
|
|
499
|
+
subject: string;
|
|
500
|
+
predicate: string;
|
|
501
|
+
object: string;
|
|
502
|
+
propositionKey: string | null;
|
|
503
|
+
confidence: number;
|
|
504
|
+
createdAt: string;
|
|
505
|
+
createdByAgent: string | null;
|
|
506
|
+
conflict?: {
|
|
507
|
+
/** All recalled candidates sharing the proposition key, sorted by id. */
|
|
508
|
+
candidateIds: string[];
|
|
509
|
+
/** True when rival objects remain that the conflict mode could not decide between. */
|
|
510
|
+
unresolved: boolean;
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
type PlannedMessage = {
|
|
514
|
+
role: "system" | "user" | "assistant";
|
|
515
|
+
content: string;
|
|
516
|
+
fact?: FactProvenance;
|
|
517
|
+
};
|
|
518
|
+
type SkipReason = "budget_exhausted" | "low_score" | "duplicate" | "superseded" | "source_deleted";
|
|
519
|
+
type PlannerStats = {
|
|
520
|
+
/** cl100k tokens in system plus every message content; excludes transport framing. */
|
|
521
|
+
tokensUsed: number;
|
|
522
|
+
budgetStatus?: "within_budget" | "overflow";
|
|
523
|
+
budgetWarning?: string;
|
|
524
|
+
itemsIncluded: number;
|
|
525
|
+
itemsSkipped: number;
|
|
526
|
+
budgetHeadroom: number;
|
|
527
|
+
fallback: "none" | "recency" | "summary" | "recency_summary";
|
|
528
|
+
skipReasons: Partial<Record<SkipReason, number>>;
|
|
529
|
+
embeddingCoverage: {
|
|
530
|
+
ready: number;
|
|
531
|
+
pending: number;
|
|
532
|
+
failed: number;
|
|
533
|
+
};
|
|
534
|
+
/** Optional for custom policy compatibility; always supplied by DefaultPolicy. */
|
|
535
|
+
candidateCoverage?: {
|
|
536
|
+
scope: "full_namespace";
|
|
537
|
+
method: "exact_pgvector" | "exact_memory" | "lexical";
|
|
538
|
+
compatibleReady: number;
|
|
539
|
+
candidateLimit: number;
|
|
540
|
+
vectorCandidates: number;
|
|
541
|
+
lexicalCandidates: number;
|
|
542
|
+
lexicalMatchedFacts: number;
|
|
543
|
+
hydratedCandidates: number;
|
|
544
|
+
/** Embedding space key the vector search was restricted to (#37). */
|
|
545
|
+
spaceFilter: string | null;
|
|
546
|
+
};
|
|
547
|
+
fallbackReason?: "query_embedding_unavailable" | "invalid_query_vector" | "no_ready_embeddings" | "no_compatible_embeddings" | "no_hydratable_candidates";
|
|
548
|
+
explain?: string[];
|
|
549
|
+
budgetClamped: boolean;
|
|
550
|
+
budgetClampReason?: string;
|
|
551
|
+
};
|
|
552
|
+
type PlannedContext = {
|
|
553
|
+
system: string;
|
|
554
|
+
messages: PlannedMessage[];
|
|
555
|
+
stats: PlannerStats;
|
|
556
|
+
};
|
|
557
|
+
type ContextPolicy = {
|
|
558
|
+
plan(input: PlanInput): Promise<PlannedContext>;
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
type TraceMetadata = Record<string, unknown>;
|
|
562
|
+
type TraceSpan = {
|
|
563
|
+
end(metadata?: TraceMetadata): void;
|
|
564
|
+
fail(error: unknown, metadata?: TraceMetadata): void;
|
|
565
|
+
};
|
|
566
|
+
type Tracer = {
|
|
567
|
+
enabled: boolean;
|
|
568
|
+
startSpan(name: string, input?: TraceMetadata): TraceSpan;
|
|
569
|
+
withSpan<T>(name: string, input: TraceMetadata, fn: () => Promise<T>): Promise<T>;
|
|
570
|
+
};
|
|
571
|
+
declare function isLangSmithTracingEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
572
|
+
declare function createTracer(env?: NodeJS.ProcessEnv): Tracer;
|
|
573
|
+
|
|
574
|
+
declare const codeBuddyConfigSchema: z.ZodObject<{
|
|
575
|
+
postgresUrl: z.ZodString;
|
|
576
|
+
provider: z.ZodObject<{
|
|
577
|
+
type: z.ZodLiteral<"huggingface">;
|
|
578
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
579
|
+
}, z.core.$strip>;
|
|
580
|
+
namespace: z.ZodString;
|
|
581
|
+
projectRoot: z.ZodOptional<z.ZodString>;
|
|
582
|
+
tokenBudget: z.ZodOptional<z.ZodNumber>;
|
|
583
|
+
graphify: z.ZodOptional<z.ZodObject<{
|
|
584
|
+
enabled: z.ZodBoolean;
|
|
585
|
+
graphPath: z.ZodOptional<z.ZodString>;
|
|
586
|
+
}, z.core.$strip>>;
|
|
587
|
+
worker: z.ZodOptional<z.ZodObject<{
|
|
588
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
589
|
+
batchSize: z.ZodOptional<z.ZodNumber>;
|
|
590
|
+
maxAttempts: z.ZodOptional<z.ZodNumber>;
|
|
591
|
+
}, z.core.$strip>>;
|
|
592
|
+
}, z.core.$strip>;
|
|
593
|
+
type ValidatedCodeBuddyConfig = z.infer<typeof codeBuddyConfigSchema>;
|
|
594
|
+
|
|
595
|
+
declare const FACT_CATEGORIES: readonly ["general", "incident"];
|
|
596
|
+
type FactCategory = (typeof FACT_CATEGORIES)[number];
|
|
597
|
+
declare const INCIDENT_SEVERITIES: readonly ["low", "medium", "high", "critical"];
|
|
598
|
+
type IncidentSeverity = (typeof INCIDENT_SEVERITIES)[number];
|
|
599
|
+
declare const factFrontMatterSchema: z.ZodObject<{
|
|
600
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
601
|
+
id: z.ZodString;
|
|
602
|
+
namespace: z.ZodString;
|
|
603
|
+
type: z.ZodLiteral<"fact">;
|
|
604
|
+
subject: z.ZodString;
|
|
605
|
+
predicate: z.ZodString;
|
|
606
|
+
object: z.ZodString;
|
|
607
|
+
propositionKey: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
608
|
+
confidence: z.ZodNumber;
|
|
609
|
+
createdAt: z.ZodPreprocess<z.ZodString, unknown>;
|
|
610
|
+
createdByAgent: z.ZodNullable<z.ZodString>;
|
|
611
|
+
sourceInteractionId: z.ZodNullable<z.ZodString>;
|
|
612
|
+
sourceDeleted: z.ZodBoolean;
|
|
613
|
+
category: z.ZodDefault<z.ZodEnum<{
|
|
614
|
+
incident: "incident";
|
|
615
|
+
general: "general";
|
|
616
|
+
}>>;
|
|
617
|
+
paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
618
|
+
severity: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
619
|
+
low: "low";
|
|
620
|
+
medium: "medium";
|
|
621
|
+
high: "high";
|
|
622
|
+
critical: "critical";
|
|
623
|
+
}>>>;
|
|
624
|
+
introducedBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
625
|
+
resolvedBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
626
|
+
fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
627
|
+
sourcePlanId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
628
|
+
sourceSessionId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
629
|
+
verification: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
630
|
+
supersededBy: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
631
|
+
sharedWith: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
632
|
+
}, z.core.$strip>;
|
|
633
|
+
declare const summaryFrontMatterSchema: z.ZodObject<{
|
|
634
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
635
|
+
id: z.ZodString;
|
|
636
|
+
namespace: z.ZodString;
|
|
637
|
+
type: z.ZodLiteral<"summary">;
|
|
638
|
+
sessionId: z.ZodString;
|
|
639
|
+
version: z.ZodNumber;
|
|
640
|
+
tokenCount: z.ZodNumber;
|
|
641
|
+
createdAt: z.ZodPreprocess<z.ZodString, unknown>;
|
|
642
|
+
createdByAgent: z.ZodNullable<z.ZodString>;
|
|
643
|
+
}, z.core.$strip>;
|
|
644
|
+
type FactFile = z.infer<typeof factFrontMatterSchema> & {
|
|
645
|
+
content: string;
|
|
646
|
+
path: string;
|
|
647
|
+
};
|
|
648
|
+
type FactFileWrite = Omit<FactFile, "path" | "schemaVersion" | "type" | "category" | "paths" | "severity" | "introducedBy" | "resolvedBy" | "fingerprint" | "sourcePlanId" | "sourceSessionId" | "verification" | "supersededBy" | "sharedWith" | "propositionKey"> & Partial<Pick<FactFile, "category" | "paths" | "severity" | "introducedBy" | "resolvedBy" | "fingerprint" | "sourcePlanId" | "sourceSessionId" | "verification" | "supersededBy" | "sharedWith" | "propositionKey">>;
|
|
649
|
+
type IncidentFactFile = FactFile & {
|
|
650
|
+
category: "incident";
|
|
651
|
+
severity: IncidentSeverity;
|
|
652
|
+
};
|
|
653
|
+
type SummaryFile = z.infer<typeof summaryFrontMatterSchema> & {
|
|
654
|
+
content: string;
|
|
655
|
+
path: string;
|
|
656
|
+
};
|
|
657
|
+
type SummaryFileWrite = Omit<SummaryFile, "path" | "schemaVersion" | "type">;
|
|
658
|
+
/** A managed memory file that exists on disk but could not be parsed. */
|
|
659
|
+
type InvalidMemoryFile = {
|
|
660
|
+
id: string;
|
|
661
|
+
path: string;
|
|
662
|
+
error: string;
|
|
663
|
+
};
|
|
664
|
+
declare class MemoryFileStore {
|
|
665
|
+
readonly repositoryRoot: string;
|
|
666
|
+
readonly factsDirectory: string;
|
|
667
|
+
readonly summariesDirectory: string;
|
|
668
|
+
constructor(repositoryRoot?: string);
|
|
669
|
+
writeFact(raw: FactFileWrite): Promise<string>;
|
|
670
|
+
writeSummary(input: SummaryFileWrite): Promise<string>;
|
|
671
|
+
readFact(pathOrId: string): Promise<FactFile>;
|
|
672
|
+
listFacts(): Promise<FactFile[]>;
|
|
673
|
+
/**
|
|
674
|
+
* Parse every managed fact file. Hand-written markdown is ignored, and a
|
|
675
|
+
* schema-invalid/corrupt fact is reported in `invalid` (not thrown) so one
|
|
676
|
+
* bad file can't break recall, capture or reindexing for the whole project.
|
|
677
|
+
* Invalid files stay on disk for manual repair.
|
|
678
|
+
*/
|
|
679
|
+
scanFacts(): Promise<{
|
|
680
|
+
facts: FactFile[];
|
|
681
|
+
invalid: InvalidMemoryFile[];
|
|
682
|
+
}>;
|
|
683
|
+
/**
|
|
684
|
+
* List incident facts for the namespace, ranked by severity then recency.
|
|
685
|
+
* Unlike {@link findIncidentFactsForPaths} this does not filter by path, so
|
|
686
|
+
* callers (e.g. the context engine's project bootstrap) can surface the
|
|
687
|
+
* repository's incident hotspots before any specific edit target is known.
|
|
688
|
+
*/
|
|
689
|
+
listIncidentFacts(input?: {
|
|
690
|
+
namespace?: string;
|
|
691
|
+
includeResolved?: boolean;
|
|
692
|
+
}): Promise<IncidentFactFile[]>;
|
|
693
|
+
findIncidentFactsForPaths(input: {
|
|
694
|
+
namespace?: string;
|
|
695
|
+
paths: string[];
|
|
696
|
+
includeResolved?: boolean;
|
|
697
|
+
}): Promise<IncidentFactFile[]>;
|
|
698
|
+
readSummary(pathOrId: string): Promise<SummaryFile>;
|
|
699
|
+
listSummaries(): Promise<SummaryFile[]>;
|
|
700
|
+
scanSummaries(): Promise<{
|
|
701
|
+
summaries: SummaryFile[];
|
|
702
|
+
invalid: InvalidMemoryFile[];
|
|
703
|
+
}>;
|
|
704
|
+
private scan;
|
|
705
|
+
deleteFact(id: string): Promise<void>;
|
|
706
|
+
markIncidentResolved(id: string, resolvedBy: string): Promise<void>;
|
|
707
|
+
markFactSuperseded(id: string, supersededBy: string): Promise<void>;
|
|
708
|
+
setFactSharedWith(id: string, sharedWith: string[]): Promise<void>;
|
|
709
|
+
/** Persist interaction deletion in Markdown before the derived DB is updated. */
|
|
710
|
+
markSourceInteractionDeleted(namespace: string, sourceInteractionId: string): Promise<void>;
|
|
711
|
+
/** Persist that a fact's source interaction was forgotten, keeping its provenance id. */
|
|
712
|
+
markFactSourceDeleted(id: string): Promise<void>;
|
|
713
|
+
private factPath;
|
|
714
|
+
private summaryPath;
|
|
715
|
+
private safePath;
|
|
716
|
+
private prepareDirectory;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
type EmbeddingWorkerOptions = {
|
|
720
|
+
repository: MemoryRepository;
|
|
721
|
+
provider: ModelProvider;
|
|
722
|
+
pollIntervalMs?: number;
|
|
723
|
+
batchSize?: number;
|
|
724
|
+
maxAttempts?: number;
|
|
725
|
+
onDiagnostic?: ModelCallSink;
|
|
726
|
+
};
|
|
727
|
+
type ModelCallSink = (entry: ModelCallEntry) => void | Promise<void>;
|
|
728
|
+
type WorkerState = "idle" | "running" | "draining" | "stopped";
|
|
729
|
+
declare class EmbeddingWorker {
|
|
730
|
+
private readonly repo;
|
|
731
|
+
private readonly provider;
|
|
732
|
+
private readonly pollIntervalMs;
|
|
733
|
+
private readonly batchSize;
|
|
734
|
+
private readonly maxAttempts;
|
|
735
|
+
private readonly onDiagnostic;
|
|
736
|
+
private state;
|
|
737
|
+
private loopPromise;
|
|
738
|
+
private wake;
|
|
739
|
+
private idleResolvers;
|
|
740
|
+
private inFlight;
|
|
741
|
+
constructor(options: EmbeddingWorkerOptions);
|
|
742
|
+
getState(): WorkerState;
|
|
743
|
+
start(): void;
|
|
744
|
+
notify(): void;
|
|
745
|
+
/**
|
|
746
|
+
* Resolve once the worker reaches an empty poll (no in-flight jobs and
|
|
747
|
+
* nothing left to claim). Retained for API compatibility: with
|
|
748
|
+
* repository-side leases and backoff there is no unbounded claim window to
|
|
749
|
+
* wait out anymore.
|
|
750
|
+
*/
|
|
751
|
+
drain(): Promise<void>;
|
|
752
|
+
stop(): Promise<void>;
|
|
753
|
+
shutdown(): Promise<void>;
|
|
754
|
+
getInFlight(): number;
|
|
755
|
+
private loop;
|
|
756
|
+
private flushIdleResolvers;
|
|
757
|
+
private processJob;
|
|
758
|
+
private emitDiagnostic;
|
|
759
|
+
private sleep;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
type CodeBuddyDependencies = {
|
|
763
|
+
repository: MemoryRepository;
|
|
764
|
+
memoryFileStore?: MemoryFileStore;
|
|
765
|
+
provider?: ModelProvider;
|
|
766
|
+
worker?: EmbeddingWorker;
|
|
767
|
+
policy?: ContextPolicy;
|
|
768
|
+
tracer?: Tracer;
|
|
769
|
+
};
|
|
770
|
+
declare class CodeBuddy {
|
|
771
|
+
readonly config: ValidatedCodeBuddyConfig;
|
|
772
|
+
private readonly repo;
|
|
773
|
+
private readonly provider;
|
|
774
|
+
private readonly worker;
|
|
775
|
+
private readonly policy;
|
|
776
|
+
private readonly tracer;
|
|
777
|
+
private readonly memoryFileStore;
|
|
778
|
+
private namespaceId;
|
|
779
|
+
private initialized;
|
|
780
|
+
constructor(config: CodeBuddyConfig, deps?: CodeBuddyDependencies);
|
|
781
|
+
init(): Promise<CodeBuddyStatus>;
|
|
782
|
+
shutdown(): Promise<void>;
|
|
783
|
+
getWorker(): EmbeddingWorker;
|
|
784
|
+
remember(input: RememberInput): Promise<RememberResult>;
|
|
785
|
+
rememberBatch(items: RememberBatchItem[]): Promise<RememberResult[]>;
|
|
786
|
+
recall(input: RecallInput): Promise<RecallResult>;
|
|
787
|
+
/** Score only eligible file facts supplied by the context engine, without generating text. */
|
|
788
|
+
rankContextFacts(task: string, factIds: string[]): Promise<Record<string, number>>;
|
|
789
|
+
private embedQueryWithFallback;
|
|
790
|
+
/**
|
|
791
|
+
* Share facts owned by the configured namespace. A reference is a live grant
|
|
792
|
+
* recorded durably in the source fact's Markdown (`sharedWith`); a snapshot is
|
|
793
|
+
* a copy owned by the target and written to the target project's own store.
|
|
794
|
+
*/
|
|
795
|
+
share(input: ShareInput): Promise<ShareResult>;
|
|
796
|
+
/** Revoke live reference shares of configured-namespace facts to `to`. */
|
|
797
|
+
unshare(input: UnshareInput): Promise<UnshareResult>;
|
|
798
|
+
/** Keep the source fact's durable `sharedWith` list in step with the shares table. */
|
|
799
|
+
private updateSharedWith;
|
|
800
|
+
forget(id: string): Promise<ForgetResult>;
|
|
801
|
+
/**
|
|
802
|
+
* Reconcile the derived database with the Markdown memory files (the source
|
|
803
|
+
* of truth) for this namespace: upsert by stable ID, preserving the file's
|
|
804
|
+
* lifecycle metadata; re-embed only changed content; delete rows whose file
|
|
805
|
+
* is gone. Only rows a reindex previously imported from Markdown
|
|
806
|
+
* (`file_backed`) are ever deleted, so DB-only legacy memory survives. Each
|
|
807
|
+
* file is applied independently: malformed or conflicting files are reported
|
|
808
|
+
* in `failures` and never abort healthy imports (nor count as deletions).
|
|
809
|
+
*/
|
|
810
|
+
reindexMemory(): Promise<ReindexResult>;
|
|
811
|
+
reindexFacts(): Promise<ReindexCounts>;
|
|
812
|
+
private requireNamespaceId;
|
|
813
|
+
private writeOne;
|
|
814
|
+
private restoreShares;
|
|
815
|
+
private importFactFile;
|
|
816
|
+
private importSummaryFile;
|
|
817
|
+
}
|
|
818
|
+
type ReindexCounts = {
|
|
819
|
+
/** Managed files seen for this namespace (including malformed ones). */
|
|
820
|
+
scanned: number;
|
|
821
|
+
imported: number;
|
|
822
|
+
updated: number;
|
|
823
|
+
unchanged: number;
|
|
824
|
+
/** File-backed rows removed because their Markdown file is gone. */
|
|
825
|
+
deleted: number;
|
|
826
|
+
failed: number;
|
|
827
|
+
};
|
|
828
|
+
type ReindexFailure = {
|
|
829
|
+
kind: "fact" | "summary";
|
|
830
|
+
id: string;
|
|
831
|
+
path: string;
|
|
832
|
+
error: string;
|
|
833
|
+
};
|
|
834
|
+
type ReindexResult = {
|
|
835
|
+
facts: ReindexCounts;
|
|
836
|
+
summaries: ReindexCounts;
|
|
837
|
+
/** Per-file problems, capped at {@link MAX_REPORTED_FAILURES}; counts stay exact. */
|
|
838
|
+
failures: ReindexFailure[];
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
export { type AgentWriteBreakdown as A, type ShareResult as B, CodeBuddy as C, type SkipReason as D, type EmbeddingRequest as E, FACT_CATEGORIES as F, type SummaryFile as G, type SummaryFileWrite as H, INCIDENT_SEVERITIES as I, type TraceSpan as J, type Tracer as K, type ListedFact as L, type MemoryRepository as M, type NamespaceSummary as N, type UnshareResult as O, type PlannedContext as P, type QueryEmbedding as Q, type RecallInput as R, type ShareInput as S, type TextGenerationRequest as T, type UnshareInput as U, type WorkerState as V, type WorkerConfig as W, createTracer as X, isLangSmithTracingEnabled as Y, type CodeBuddyConfig as a, MemoryFileStore as b, type ModelProvider as c, type ContextPolicy as d, type PlanInput as e, type ProviderDiagnosticsHook as f, type EmbeddingResponse as g, type TextGenerationResponse as h, type CodeBuddyDependencies as i, type CodeBuddyStatus as j, type ConflictMode as k, type EmbeddingSpace as l, EmbeddingWorker as m, type FactCategory as n, type FactFile as o, type FactFileWrite as p, type ForgetResult as q, type IncidentFactFile as r, type IncidentSeverity as s, type MemoryWriteType as t, type PlannedMessage as u, type PlannerStats as v, type RecallResult as w, type RememberBatchItem as x, type RememberInput as y, type RememberResult as z };
|