opencode-memory-pro 1.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/LICENSE +24 -0
- package/README.md +409 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +398 -0
- package/dist/embedder.d.ts +26 -0
- package/dist/embedder.js +260 -0
- package/dist/extract.d.ts +4 -0
- package/dist/extract.js +181 -0
- package/dist/graph.js +701 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +953 -0
- package/dist/llm.d.ts +14 -0
- package/dist/llm.js +212 -0
- package/dist/logger.d.ts +9 -0
- package/dist/logger.js +126 -0
- package/dist/ports.d.ts +34 -0
- package/dist/ports.js +129 -0
- package/dist/preference.d.ts +10 -0
- package/dist/preference.js +125 -0
- package/dist/scope.d.ts +2 -0
- package/dist/scope.js +48 -0
- package/dist/store.d.ts +194 -0
- package/dist/store.js +2738 -0
- package/dist/summarize.d.ts +52 -0
- package/dist/summarize.js +350 -0
- package/dist/tools/episodic.d.ts +68 -0
- package/dist/tools/episodic.js +145 -0
- package/dist/tools/feedback.d.ts +51 -0
- package/dist/tools/feedback.js +112 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/memory.d.ts +293 -0
- package/dist/tools/memory.js +1487 -0
- package/dist/types.d.ts +489 -0
- package/dist/types.js +54 -0
- package/dist/utils.d.ts +18 -0
- package/dist/utils.js +214 -0
- package/package.json +49 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
export type EmbeddingProvider = "ollama" | "openai";
|
|
2
|
+
export type EmbedderStatus = "healthy" | "degraded" | "unavailable";
|
|
3
|
+
export type RetrievalMode = "hybrid" | "vector";
|
|
4
|
+
export type InjectionMode = "fixed" | "budget" | "adaptive";
|
|
5
|
+
export type SummarizationMode = "none" | "truncate" | "extract" | "auto";
|
|
6
|
+
export type CodeTruncationMode = "smart" | "signature" | "preserve";
|
|
7
|
+
export type ContentType = "text" | "code" | "mixed";
|
|
8
|
+
export interface ContentDetection {
|
|
9
|
+
hasCode: boolean;
|
|
10
|
+
isPureCode: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface EmbedderRetryConfig {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
maxAttempts: number;
|
|
15
|
+
initialDelayMs: number;
|
|
16
|
+
backoffMultiplier: number;
|
|
17
|
+
}
|
|
18
|
+
export interface EmbedderHealth {
|
|
19
|
+
status: EmbedderStatus;
|
|
20
|
+
lastError: string | null;
|
|
21
|
+
lastSuccess: number | null;
|
|
22
|
+
retryCount: number;
|
|
23
|
+
fallbackActive: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface EmbeddingConfig {
|
|
26
|
+
provider: EmbeddingProvider;
|
|
27
|
+
model: string;
|
|
28
|
+
baseUrl?: string;
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
retry?: EmbedderRetryConfig;
|
|
32
|
+
}
|
|
33
|
+
export interface SummarizedContent {
|
|
34
|
+
type: "kept" | "truncated" | "summarized" | "mixed";
|
|
35
|
+
content: string;
|
|
36
|
+
originalLength: number;
|
|
37
|
+
estimatedTokens: number;
|
|
38
|
+
}
|
|
39
|
+
export type MemoryCategory = "preference" | "fact" | "decision" | "entity" | "other";
|
|
40
|
+
export type TaskType = "coding" | "documentation" | "review" | "release" | "general";
|
|
41
|
+
export interface InjectionProfile {
|
|
42
|
+
maxMemories: number;
|
|
43
|
+
budgetTokens: number;
|
|
44
|
+
summaryTargetChars: number;
|
|
45
|
+
categoryWeights: Partial<Record<MemoryCategory, number>>;
|
|
46
|
+
}
|
|
47
|
+
export type CaptureOutcome = "considered" | "skipped" | "stored";
|
|
48
|
+
export type CaptureSkipReason = "empty-buffer" | "below-min-chars" | "no-positive-signal" | "initialization-unavailable" | "embedding-unavailable" | "empty-embedding" | "duplicate-similarity" | "duplicate-exact";
|
|
49
|
+
export type FeedbackType = "missing" | "wrong" | "useful";
|
|
50
|
+
export type RecallSource = "system-transform" | "manual-search";
|
|
51
|
+
export type MemoryScope = "project" | "global";
|
|
52
|
+
export type SchemaVersion = 1 | 2;
|
|
53
|
+
export interface RetrievalConfig {
|
|
54
|
+
mode: RetrievalMode;
|
|
55
|
+
vectorWeight: number;
|
|
56
|
+
bm25Weight: number;
|
|
57
|
+
minScore: number;
|
|
58
|
+
rrfK: number;
|
|
59
|
+
recencyBoost: boolean;
|
|
60
|
+
recencyHalfLifeHours: number;
|
|
61
|
+
importanceWeight: number;
|
|
62
|
+
feedbackWeight: number;
|
|
63
|
+
}
|
|
64
|
+
export interface CodeSummarizationConfig {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
pureCodeThreshold: number;
|
|
67
|
+
maxCodeLines: number;
|
|
68
|
+
codeTruncationMode: CodeTruncationMode;
|
|
69
|
+
preserveComments: boolean;
|
|
70
|
+
preserveImports: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface InjectionConfig {
|
|
73
|
+
mode: InjectionMode;
|
|
74
|
+
maxMemories: number;
|
|
75
|
+
minMemories: number;
|
|
76
|
+
budgetTokens: number;
|
|
77
|
+
maxCharsPerMemory: number;
|
|
78
|
+
summarization: SummarizationMode;
|
|
79
|
+
summaryTargetChars: number;
|
|
80
|
+
scoreDropTolerance: number;
|
|
81
|
+
injectionFloor: number;
|
|
82
|
+
codeSummarization: CodeSummarizationConfig;
|
|
83
|
+
taskTypeProfiles: Record<TaskType, InjectionProfile>;
|
|
84
|
+
}
|
|
85
|
+
export interface SummarizationConfig {
|
|
86
|
+
mode: SummarizationMode;
|
|
87
|
+
textThreshold: number;
|
|
88
|
+
codeThreshold: number;
|
|
89
|
+
summaryTargetChars: number;
|
|
90
|
+
maxCodeLines: number;
|
|
91
|
+
codeTruncationMode: CodeTruncationMode;
|
|
92
|
+
preserveComments: boolean;
|
|
93
|
+
preserveImports: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface DedupConfig {
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
writeThreshold: number;
|
|
98
|
+
consolidateThreshold: number;
|
|
99
|
+
candidateLimit: number;
|
|
100
|
+
}
|
|
101
|
+
export interface MemoryRuntimeConfig {
|
|
102
|
+
provider: string;
|
|
103
|
+
dbPath: string;
|
|
104
|
+
embedding: EmbeddingConfig;
|
|
105
|
+
retrieval: RetrievalConfig;
|
|
106
|
+
injection: InjectionConfig;
|
|
107
|
+
dedup: DedupConfig;
|
|
108
|
+
includeGlobalScope: boolean;
|
|
109
|
+
globalDetectionThreshold: number;
|
|
110
|
+
globalDiscountFactor: number;
|
|
111
|
+
unusedDaysThreshold: number;
|
|
112
|
+
minCaptureChars: number;
|
|
113
|
+
maxEntriesPerScope: number;
|
|
114
|
+
retention?: {
|
|
115
|
+
effectivenessEventsDays: number;
|
|
116
|
+
memory?: {
|
|
117
|
+
enabled: boolean;
|
|
118
|
+
unusedDays: number;
|
|
119
|
+
minAgeDays: number;
|
|
120
|
+
minGroupSize: number;
|
|
121
|
+
targetChars: number;
|
|
122
|
+
minImportance: number;
|
|
123
|
+
protectedCategories: string[];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
graph?: {
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
dbPath: string;
|
|
129
|
+
boostLambda: number;
|
|
130
|
+
maxEntitiesPerMemory: number;
|
|
131
|
+
maxEdgeProvenance: number;
|
|
132
|
+
typedEdges: boolean;
|
|
133
|
+
expansionEnabled: boolean;
|
|
134
|
+
maxHops: number;
|
|
135
|
+
expansionLimit: number;
|
|
136
|
+
expansionLambda: number;
|
|
137
|
+
};
|
|
138
|
+
summarize?: {
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
minAgeDays: number;
|
|
141
|
+
minGroupSize: number;
|
|
142
|
+
targetChars: number;
|
|
143
|
+
replace: boolean;
|
|
144
|
+
};
|
|
145
|
+
capture?: {
|
|
146
|
+
mode: "heuristics" | "llm";
|
|
147
|
+
llm: {
|
|
148
|
+
provider: string;
|
|
149
|
+
model: string;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
logging?: {
|
|
153
|
+
level: "debug" | "info" | "warn" | "error";
|
|
154
|
+
file: string | null;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export type MemoryStatus = "active" | "disabled" | "merged";
|
|
158
|
+
export type CitationSource = "auto-capture" | "llm-capture" | "explicit-remember" | "import" | "external";
|
|
159
|
+
export type CitationStatus = "verified" | "pending" | "invalid" | "expired";
|
|
160
|
+
export interface CitationRecord {
|
|
161
|
+
source: CitationSource;
|
|
162
|
+
timestamp: number;
|
|
163
|
+
status: CitationStatus;
|
|
164
|
+
chain: string[];
|
|
165
|
+
verifiedAt?: number;
|
|
166
|
+
expiresAt?: number;
|
|
167
|
+
}
|
|
168
|
+
export interface MemoryRecord {
|
|
169
|
+
id: string;
|
|
170
|
+
text: string;
|
|
171
|
+
vector: number[];
|
|
172
|
+
category: MemoryCategory;
|
|
173
|
+
scope: string;
|
|
174
|
+
importance: number;
|
|
175
|
+
timestamp: number;
|
|
176
|
+
lastRecalled: number;
|
|
177
|
+
recallCount: number;
|
|
178
|
+
projectCount: number;
|
|
179
|
+
schemaVersion: number;
|
|
180
|
+
embeddingModel: string;
|
|
181
|
+
vectorDim: number;
|
|
182
|
+
metadataJson: string;
|
|
183
|
+
userId?: string;
|
|
184
|
+
teamId?: string;
|
|
185
|
+
sourceSessionId?: string;
|
|
186
|
+
confidence?: number;
|
|
187
|
+
tags?: string[];
|
|
188
|
+
status?: MemoryStatus;
|
|
189
|
+
parentId?: string;
|
|
190
|
+
citationSource?: CitationSource;
|
|
191
|
+
citationTimestamp?: number;
|
|
192
|
+
citationStatus?: CitationStatus;
|
|
193
|
+
citationChain?: string[];
|
|
194
|
+
}
|
|
195
|
+
export interface SearchResult {
|
|
196
|
+
record: MemoryRecord;
|
|
197
|
+
score: number;
|
|
198
|
+
vectorScore: number;
|
|
199
|
+
bm25Score: number;
|
|
200
|
+
}
|
|
201
|
+
export interface CaptureCandidate {
|
|
202
|
+
text: string;
|
|
203
|
+
category: MemoryCategory;
|
|
204
|
+
importance: number;
|
|
205
|
+
}
|
|
206
|
+
export interface CaptureCandidateResult {
|
|
207
|
+
candidate: CaptureCandidate | null;
|
|
208
|
+
skipReason?: CaptureSkipReason;
|
|
209
|
+
}
|
|
210
|
+
interface MemoryEffectivenessEventBase {
|
|
211
|
+
id: string;
|
|
212
|
+
scope: string;
|
|
213
|
+
sessionID?: string;
|
|
214
|
+
timestamp: number;
|
|
215
|
+
memoryId?: string;
|
|
216
|
+
text?: string;
|
|
217
|
+
metadataJson: string;
|
|
218
|
+
}
|
|
219
|
+
export interface CaptureEvent extends MemoryEffectivenessEventBase {
|
|
220
|
+
type: "capture";
|
|
221
|
+
outcome: CaptureOutcome;
|
|
222
|
+
skipReason?: CaptureSkipReason;
|
|
223
|
+
sourceSessionId?: string;
|
|
224
|
+
}
|
|
225
|
+
export interface RecallEvent extends MemoryEffectivenessEventBase {
|
|
226
|
+
type: "recall";
|
|
227
|
+
resultCount: number;
|
|
228
|
+
injected: boolean;
|
|
229
|
+
source?: RecallSource;
|
|
230
|
+
}
|
|
231
|
+
export interface FeedbackEvent extends MemoryEffectivenessEventBase {
|
|
232
|
+
type: "feedback";
|
|
233
|
+
feedbackType: FeedbackType;
|
|
234
|
+
helpful?: boolean;
|
|
235
|
+
labels?: string[];
|
|
236
|
+
reason?: string;
|
|
237
|
+
sourceSessionId?: string;
|
|
238
|
+
confidenceDelta?: number;
|
|
239
|
+
relatedMemoryId?: string;
|
|
240
|
+
context?: Record<string, unknown>;
|
|
241
|
+
}
|
|
242
|
+
export type MemoryEffectivenessEvent = CaptureEvent | RecallEvent | FeedbackEvent;
|
|
243
|
+
export interface EffectivenessSummary {
|
|
244
|
+
scope: string;
|
|
245
|
+
totalEvents: number;
|
|
246
|
+
capture: {
|
|
247
|
+
considered: number;
|
|
248
|
+
stored: number;
|
|
249
|
+
skipped: number;
|
|
250
|
+
successRate: number;
|
|
251
|
+
skipReasons: Partial<Record<CaptureSkipReason, number>>;
|
|
252
|
+
};
|
|
253
|
+
recall: {
|
|
254
|
+
requested: number;
|
|
255
|
+
injected: number;
|
|
256
|
+
returnedResults: number;
|
|
257
|
+
hitRate: number;
|
|
258
|
+
injectionRate: number;
|
|
259
|
+
auto: {
|
|
260
|
+
requested: number;
|
|
261
|
+
injected: number;
|
|
262
|
+
returnedResults: number;
|
|
263
|
+
hitRate: number;
|
|
264
|
+
injectionRate: number;
|
|
265
|
+
};
|
|
266
|
+
manual: {
|
|
267
|
+
requested: number;
|
|
268
|
+
returnedResults: number;
|
|
269
|
+
hitRate: number;
|
|
270
|
+
};
|
|
271
|
+
manualRescueRatio: number;
|
|
272
|
+
};
|
|
273
|
+
feedback: {
|
|
274
|
+
missing: number;
|
|
275
|
+
wrong: number;
|
|
276
|
+
useful: {
|
|
277
|
+
positive: number;
|
|
278
|
+
negative: number;
|
|
279
|
+
helpfulRate: number;
|
|
280
|
+
};
|
|
281
|
+
falsePositiveRate: number;
|
|
282
|
+
falseNegativeRate: number;
|
|
283
|
+
};
|
|
284
|
+
duplicates: {
|
|
285
|
+
flaggedCount: number;
|
|
286
|
+
consolidatedCount: number;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
export type TrendDirection = "improving" | "stable" | "declining" | "insufficient-data";
|
|
290
|
+
export interface TrendIndicator {
|
|
291
|
+
direction: TrendDirection;
|
|
292
|
+
percentageChange: number;
|
|
293
|
+
}
|
|
294
|
+
export interface MemoryFeedbackStats {
|
|
295
|
+
memoryId: string;
|
|
296
|
+
helpful: number;
|
|
297
|
+
unhelpful: number;
|
|
298
|
+
wrong: number;
|
|
299
|
+
helpfulRate: number;
|
|
300
|
+
feedbackFactor: number;
|
|
301
|
+
}
|
|
302
|
+
export interface DashboardSummary {
|
|
303
|
+
scope: string;
|
|
304
|
+
periodDays: number;
|
|
305
|
+
currentPeriodStart: number;
|
|
306
|
+
currentPeriodEnd: number;
|
|
307
|
+
previousPeriodStart: number;
|
|
308
|
+
previousPeriodEnd: number;
|
|
309
|
+
current: EffectivenessSummary;
|
|
310
|
+
previous: EffectivenessSummary | null;
|
|
311
|
+
trends: {
|
|
312
|
+
captureSuccessRate: TrendIndicator;
|
|
313
|
+
recallHitRate: TrendIndicator;
|
|
314
|
+
feedbackHelpfulRate: TrendIndicator;
|
|
315
|
+
};
|
|
316
|
+
insights: string[];
|
|
317
|
+
recentMemories: {
|
|
318
|
+
total: number;
|
|
319
|
+
byCategory: Partial<Record<MemoryCategory, {
|
|
320
|
+
count: number;
|
|
321
|
+
samples: string[];
|
|
322
|
+
}>>;
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
export interface RetryToSuccessMetric {
|
|
326
|
+
status: "ok" | "insufficient-data" | "no-failed-tasks";
|
|
327
|
+
rate: number;
|
|
328
|
+
totalFailedTasks: number;
|
|
329
|
+
succeededAfterRetry: number;
|
|
330
|
+
sampleCount: number;
|
|
331
|
+
}
|
|
332
|
+
export interface MemoryLiftMetric {
|
|
333
|
+
status: "ok" | "insufficient-data" | "no-recall-data";
|
|
334
|
+
lift: number;
|
|
335
|
+
successRateWithRecall: number;
|
|
336
|
+
successRateWithoutRecall: number;
|
|
337
|
+
withRecallCount: number;
|
|
338
|
+
withoutRecallCount: number;
|
|
339
|
+
}
|
|
340
|
+
export interface KpiSummary {
|
|
341
|
+
scope: string;
|
|
342
|
+
periodDays: number;
|
|
343
|
+
retryToSuccess: RetryToSuccessMetric;
|
|
344
|
+
memoryLift: MemoryLiftMetric;
|
|
345
|
+
}
|
|
346
|
+
export type PreferenceCategory = "language" | "tool" | "style" | "workflow" | "other";
|
|
347
|
+
export type PreferenceScope = "project" | "global";
|
|
348
|
+
export type PreferenceSource = "explicit" | "inferred";
|
|
349
|
+
export interface PreferenceSignal {
|
|
350
|
+
key: string;
|
|
351
|
+
value: string;
|
|
352
|
+
category: PreferenceCategory;
|
|
353
|
+
source: PreferenceSource;
|
|
354
|
+
timestamp: number;
|
|
355
|
+
memoryId: string;
|
|
356
|
+
}
|
|
357
|
+
export interface Preference {
|
|
358
|
+
key: string;
|
|
359
|
+
value: string;
|
|
360
|
+
category: PreferenceCategory;
|
|
361
|
+
confidence: number;
|
|
362
|
+
scope: PreferenceScope;
|
|
363
|
+
lastUpdated: number;
|
|
364
|
+
sourceCount: number;
|
|
365
|
+
}
|
|
366
|
+
export interface PreferenceProfile {
|
|
367
|
+
scope: string;
|
|
368
|
+
preferences: Preference[];
|
|
369
|
+
updatedAt: number;
|
|
370
|
+
}
|
|
371
|
+
export type TaskState = "pending" | "running" | "success" | "failed" | "timeout";
|
|
372
|
+
export type FailureType = "syntax" | "runtime" | "logic" | "resource" | "unknown";
|
|
373
|
+
export type ValidationType = "type-check" | "build" | "test";
|
|
374
|
+
export type ValidationStatus = "pass" | "fail" | "skipped";
|
|
375
|
+
export interface ValidationOutcome {
|
|
376
|
+
type: ValidationType;
|
|
377
|
+
status: ValidationStatus;
|
|
378
|
+
timestamp: number;
|
|
379
|
+
errorCount?: number;
|
|
380
|
+
errorTypes?: string[];
|
|
381
|
+
passedCount?: number;
|
|
382
|
+
failedCount?: number;
|
|
383
|
+
output?: string;
|
|
384
|
+
}
|
|
385
|
+
export interface SuccessPattern {
|
|
386
|
+
commands: string[];
|
|
387
|
+
tools: string[];
|
|
388
|
+
confidence: number;
|
|
389
|
+
extractedAt: number;
|
|
390
|
+
}
|
|
391
|
+
export interface RetryAttempt {
|
|
392
|
+
attemptNumber: number;
|
|
393
|
+
timestamp: number;
|
|
394
|
+
outcome: "success" | "failed" | "abandoned";
|
|
395
|
+
errorMessage?: string;
|
|
396
|
+
failureType?: FailureType;
|
|
397
|
+
}
|
|
398
|
+
export interface RecoveryStrategy {
|
|
399
|
+
name: string;
|
|
400
|
+
attemptedAt: number;
|
|
401
|
+
succeeded: boolean;
|
|
402
|
+
}
|
|
403
|
+
export interface RetryBudgetSuggestion {
|
|
404
|
+
suggestedRetries: number;
|
|
405
|
+
confidence: number;
|
|
406
|
+
basedOnCount: number;
|
|
407
|
+
shouldStop: boolean;
|
|
408
|
+
stopReason?: string;
|
|
409
|
+
}
|
|
410
|
+
export interface StrategySuggestion {
|
|
411
|
+
strategy: string;
|
|
412
|
+
reason: string;
|
|
413
|
+
confidence: number;
|
|
414
|
+
basedOnTask?: string;
|
|
415
|
+
}
|
|
416
|
+
import { z } from "zod";
|
|
417
|
+
declare const EpisodicTaskRecordBaseSchema: z.ZodObject<{
|
|
418
|
+
id: z.ZodString;
|
|
419
|
+
sessionId: z.ZodString;
|
|
420
|
+
scope: z.ZodString;
|
|
421
|
+
taskId: z.ZodString;
|
|
422
|
+
state: z.ZodEnum<{
|
|
423
|
+
pending: "pending";
|
|
424
|
+
running: "running";
|
|
425
|
+
success: "success";
|
|
426
|
+
failed: "failed";
|
|
427
|
+
timeout: "timeout";
|
|
428
|
+
}>;
|
|
429
|
+
startTime: z.ZodNumber;
|
|
430
|
+
endTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
431
|
+
failureType: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
432
|
+
syntax: "syntax";
|
|
433
|
+
runtime: "runtime";
|
|
434
|
+
logic: "logic";
|
|
435
|
+
resource: "resource";
|
|
436
|
+
unknown: "unknown";
|
|
437
|
+
}>>>;
|
|
438
|
+
errorMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
439
|
+
commandsJson: z.ZodString;
|
|
440
|
+
validationOutcomesJson: z.ZodString;
|
|
441
|
+
successPatternsJson: z.ZodString;
|
|
442
|
+
retryAttemptsJson: z.ZodString;
|
|
443
|
+
recoveryStrategiesJson: z.ZodString;
|
|
444
|
+
metadataJson: z.ZodString;
|
|
445
|
+
taskDescriptionVector: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNumber>>>;
|
|
446
|
+
}, z.core.$strip>;
|
|
447
|
+
export type EpisodicTaskRecord = z.infer<typeof EpisodicTaskRecordBaseSchema>;
|
|
448
|
+
export declare function validateEpisodicRecord(raw: unknown): EpisodicTaskRecord;
|
|
449
|
+
export declare function validateEpisodicRecordArray(raw: unknown): EpisodicTaskRecord[];
|
|
450
|
+
export interface RecallFactors {
|
|
451
|
+
relevance: {
|
|
452
|
+
overall: number;
|
|
453
|
+
vectorScore: number;
|
|
454
|
+
bm25Score: number;
|
|
455
|
+
};
|
|
456
|
+
recency: {
|
|
457
|
+
timestamp: number;
|
|
458
|
+
ageHours: number;
|
|
459
|
+
withinHalfLife: boolean;
|
|
460
|
+
decayFactor: number;
|
|
461
|
+
};
|
|
462
|
+
citation?: {
|
|
463
|
+
source?: CitationSource;
|
|
464
|
+
status?: CitationStatus;
|
|
465
|
+
timestamp?: number;
|
|
466
|
+
};
|
|
467
|
+
importance: number;
|
|
468
|
+
scope: {
|
|
469
|
+
memoryScope: string;
|
|
470
|
+
matchesCurrentScope: boolean;
|
|
471
|
+
isGlobal: boolean;
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
export interface MemoryExplanation {
|
|
475
|
+
memoryId: string;
|
|
476
|
+
text: string;
|
|
477
|
+
factors: RecallFactors;
|
|
478
|
+
generatedAt: number;
|
|
479
|
+
}
|
|
480
|
+
export interface LastRecallSession {
|
|
481
|
+
timestamp: number;
|
|
482
|
+
query: string;
|
|
483
|
+
results: Array<{
|
|
484
|
+
memoryId: string;
|
|
485
|
+
score: number;
|
|
486
|
+
factors: RecallFactors;
|
|
487
|
+
}>;
|
|
488
|
+
}
|
|
489
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// === Episodic Record Runtime Validation (BL-046) ===
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const ValidationOutcomeSchema = z.object({
|
|
4
|
+
type: z.enum(["type-check", "build", "test"]),
|
|
5
|
+
status: z.enum(["pass", "fail", "skipped"]),
|
|
6
|
+
timestamp: z.number(),
|
|
7
|
+
errorCount: z.number().optional(),
|
|
8
|
+
errorTypes: z.array(z.string()).optional(),
|
|
9
|
+
passedCount: z.number().optional(),
|
|
10
|
+
failedCount: z.number().optional(),
|
|
11
|
+
output: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
const SuccessPatternSchema = z.object({
|
|
14
|
+
commands: z.array(z.string()),
|
|
15
|
+
tools: z.array(z.string()),
|
|
16
|
+
confidence: z.number(),
|
|
17
|
+
extractedAt: z.number(),
|
|
18
|
+
});
|
|
19
|
+
const RetryAttemptSchema = z.object({
|
|
20
|
+
attemptNumber: z.number(),
|
|
21
|
+
timestamp: z.number(),
|
|
22
|
+
outcome: z.enum(["success", "failed", "abandoned"]),
|
|
23
|
+
errorMessage: z.string().nullish(),
|
|
24
|
+
failureType: z.enum(["syntax", "runtime", "logic", "resource", "unknown"]).nullish(),
|
|
25
|
+
});
|
|
26
|
+
const RecoveryStrategySchema = z.object({
|
|
27
|
+
name: z.string(),
|
|
28
|
+
attemptedAt: z.number(),
|
|
29
|
+
succeeded: z.boolean(),
|
|
30
|
+
});
|
|
31
|
+
const EpisodicTaskRecordBaseSchema = z.object({
|
|
32
|
+
id: z.string(),
|
|
33
|
+
sessionId: z.string(),
|
|
34
|
+
scope: z.string(),
|
|
35
|
+
taskId: z.string(),
|
|
36
|
+
state: z.enum(["pending", "running", "success", "failed", "timeout"]),
|
|
37
|
+
startTime: z.number(),
|
|
38
|
+
endTime: z.number().nullish(),
|
|
39
|
+
failureType: z.enum(["syntax", "runtime", "logic", "resource", "unknown"]).nullish(),
|
|
40
|
+
errorMessage: z.string().nullish(),
|
|
41
|
+
commandsJson: z.string(),
|
|
42
|
+
validationOutcomesJson: z.string(),
|
|
43
|
+
successPatternsJson: z.string(),
|
|
44
|
+
retryAttemptsJson: z.string(),
|
|
45
|
+
recoveryStrategiesJson: z.string(),
|
|
46
|
+
metadataJson: z.string(),
|
|
47
|
+
taskDescriptionVector: z.array(z.number()).nullish(),
|
|
48
|
+
});
|
|
49
|
+
export function validateEpisodicRecord(raw) {
|
|
50
|
+
return EpisodicTaskRecordBaseSchema.parse(raw);
|
|
51
|
+
}
|
|
52
|
+
export function validateEpisodicRecordArray(raw) {
|
|
53
|
+
return z.array(EpisodicTaskRecordBaseSchema).parse(raw);
|
|
54
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FailureType } from "./types.js";
|
|
2
|
+
export declare function expandHomePath(input: string): string;
|
|
3
|
+
export declare function toNumber(value: unknown, fallback: number): number;
|
|
4
|
+
export declare function toBoolean(value: unknown, fallback: boolean): boolean;
|
|
5
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
6
|
+
export declare function stableHash(input: string): string;
|
|
7
|
+
export declare function tokenize(text: string): string[];
|
|
8
|
+
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
9
|
+
export declare function generateId(): string;
|
|
10
|
+
export declare function parseJsonObject<T>(value: string | undefined, fallback: T): T;
|
|
11
|
+
export declare function classifyFailure(errorMessage: string): FailureType;
|
|
12
|
+
export declare function parseValidationOutput(output: string, type: "type-check" | "build" | "test"): {
|
|
13
|
+
status: "pass" | "fail" | "skipped";
|
|
14
|
+
errorCount?: number;
|
|
15
|
+
errorTypes?: string[];
|
|
16
|
+
passedCount?: number;
|
|
17
|
+
failedCount?: number;
|
|
18
|
+
};
|