opencode-harnmem 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +45 -2
- package/index.js +512 -0
- package/lib/engine.mjs +72 -0
- package/lib/format.mjs +119 -0
- package/lib/settings.mjs +131 -0
- package/package.json +23 -3
- package/vendor/core/assets.d.ts +52 -0
- package/vendor/core/assets.d.ts.map +1 -0
- package/vendor/core/assets.js +227 -0
- package/vendor/core/assets.js.map +1 -0
- package/vendor/core/config.d.ts +36 -0
- package/vendor/core/config.d.ts.map +1 -0
- package/vendor/core/config.js +134 -0
- package/vendor/core/config.js.map +1 -0
- package/vendor/core/consolidate.d.ts +14 -0
- package/vendor/core/consolidate.d.ts.map +1 -0
- package/vendor/core/consolidate.js +237 -0
- package/vendor/core/consolidate.js.map +1 -0
- package/vendor/core/data/synonyms.en.txt +61 -0
- package/vendor/core/data/synonyms.zh.txt +157 -0
- package/vendor/core/extract.d.ts +49 -0
- package/vendor/core/extract.d.ts.map +1 -0
- package/vendor/core/extract.js +179 -0
- package/vendor/core/extract.js.map +1 -0
- package/vendor/core/frontmatter.d.ts +31 -0
- package/vendor/core/frontmatter.d.ts.map +1 -0
- package/vendor/core/frontmatter.js +372 -0
- package/vendor/core/frontmatter.js.map +1 -0
- package/vendor/core/harnmem.d.ts +87 -0
- package/vendor/core/harnmem.d.ts.map +1 -0
- package/vendor/core/harnmem.js +918 -0
- package/vendor/core/harnmem.js.map +1 -0
- package/vendor/core/hot-context.d.ts +28 -0
- package/vendor/core/hot-context.d.ts.map +1 -0
- package/vendor/core/hot-context.js +179 -0
- package/vendor/core/hot-context.js.map +1 -0
- package/vendor/core/index.d.ts +16 -0
- package/vendor/core/index.d.ts.map +1 -0
- package/vendor/core/index.js +10 -0
- package/vendor/core/index.js.map +1 -0
- package/vendor/core/indexer.d.ts +107 -0
- package/vendor/core/indexer.d.ts.map +1 -0
- package/vendor/core/indexer.js +282 -0
- package/vendor/core/indexer.js.map +1 -0
- package/vendor/core/inspect.d.ts +278 -0
- package/vendor/core/inspect.d.ts.map +1 -0
- package/vendor/core/inspect.js +643 -0
- package/vendor/core/inspect.js.map +1 -0
- package/vendor/core/lifecycle.d.ts +50 -0
- package/vendor/core/lifecycle.d.ts.map +1 -0
- package/vendor/core/lifecycle.js +249 -0
- package/vendor/core/lifecycle.js.map +1 -0
- package/vendor/core/project.d.ts +41 -0
- package/vendor/core/project.d.ts.map +1 -0
- package/vendor/core/project.js +197 -0
- package/vendor/core/project.js.map +1 -0
- package/vendor/core/prompts/README.md +96 -0
- package/vendor/core/prompts/consolidate-digest.md +31 -0
- package/vendor/core/prompts/extract.md +80 -0
- package/vendor/core/prompts/migrate.md +96 -0
- package/vendor/core/prompts/synonyms.md +43 -0
- package/vendor/core/prompts/write-policy.md +12 -0
- package/vendor/core/retrieval.d.ts +95 -0
- package/vendor/core/retrieval.d.ts.map +1 -0
- package/vendor/core/retrieval.js +569 -0
- package/vendor/core/retrieval.js.map +1 -0
- package/vendor/core/store.d.ts +145 -0
- package/vendor/core/store.d.ts.map +1 -0
- package/vendor/core/store.js +511 -0
- package/vendor/core/store.js.map +1 -0
- package/vendor/core/suggest.d.ts +128 -0
- package/vendor/core/suggest.d.ts.map +1 -0
- package/vendor/core/suggest.js +384 -0
- package/vendor/core/suggest.js.map +1 -0
- package/vendor/core/text.d.ts +80 -0
- package/vendor/core/text.d.ts.map +1 -0
- package/vendor/core/text.js +253 -0
- package/vendor/core/text.js.map +1 -0
- package/vendor/core/types.d.ts +453 -0
- package/vendor/core/types.d.ts.map +1 -0
- package/vendor/core/types.js +14 -0
- package/vendor/core/types.js.map +1 -0
- package/vendor/core/util.d.ts +38 -0
- package/vendor/core/util.d.ts.map +1 -0
- package/vendor/core/util.js +248 -0
- package/vendor/core/util.js.map +1 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HarnMem public API — frozen contract v1 (see docs/design/07-adapter-contract.md).
|
|
3
|
+
*
|
|
4
|
+
* Harness adapters (pi / dsh / claude / cli) may only depend on this file's
|
|
5
|
+
* exported types and the `HarnMem` facade in `./harnmem.js`. Everything else is
|
|
6
|
+
* internal and may change.
|
|
7
|
+
*
|
|
8
|
+
* Design rules:
|
|
9
|
+
* - zero runtime dependencies (node: builtins only)
|
|
10
|
+
* - on-disk format is the SSOT; every index file is rebuildable
|
|
11
|
+
* - the engine never writes outside `harnmem.home` except for reads
|
|
12
|
+
*/
|
|
13
|
+
export declare const HARNMEM_API_VERSION = 1;
|
|
14
|
+
/** A harness that talks to harnmem. Free-form string, well-known ids below. */
|
|
15
|
+
export type HarnessId = "pi" | "dsh" | "claude" | "cli" | (string & {});
|
|
16
|
+
/** Four canonical memory types (aligned with dsh-auto-memory / ZCode / Claude Code). */
|
|
17
|
+
export type MemoryType = "user" | "feedback" | "project" | "reference";
|
|
18
|
+
/** Fine-grained semantics; free-form short tag, used for weighting/display only. */
|
|
19
|
+
export type MemoryCategory = "profile" | "preference" | "decision" | "convention" | "lesson" | "pitfall" | "state" | "external" | (string & {});
|
|
20
|
+
export type MemoryScope = "user" | "project";
|
|
21
|
+
/**
|
|
22
|
+
* Lifecycle state. `superseded` and `archived` are still on disk and readable;
|
|
23
|
+
* `dropped` means moved to `trash/` (restorable until purge).
|
|
24
|
+
*/
|
|
25
|
+
export type MemoryStatus = "active" | "superseded" | "archived" | "dropped";
|
|
26
|
+
/** Where a memory originally came from. */
|
|
27
|
+
export interface MemorySource {
|
|
28
|
+
harness: HarnessId;
|
|
29
|
+
session?: string;
|
|
30
|
+
turn?: number;
|
|
31
|
+
ts: number;
|
|
32
|
+
/** Migration origin, if this record was imported from another system. */
|
|
33
|
+
migratedFrom?: {
|
|
34
|
+
system: string;
|
|
35
|
+
path?: string;
|
|
36
|
+
originalId?: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** A single memory record (SSOT object; persisted as one markdown file). */
|
|
40
|
+
export interface MemoryRecord {
|
|
41
|
+
schema: 1;
|
|
42
|
+
/** `mem_` + 26 Crockford Base32 chars (ULID-like, time-sortable). */
|
|
43
|
+
id: string;
|
|
44
|
+
type: MemoryType;
|
|
45
|
+
category?: MemoryCategory;
|
|
46
|
+
scope: MemoryScope;
|
|
47
|
+
/** Project id (`slug-hash`) when scope === "project". */
|
|
48
|
+
project?: string;
|
|
49
|
+
/** Display name of the project at write time (for humans; not authoritative). */
|
|
50
|
+
projectName?: string;
|
|
51
|
+
/** ≤ 80 chars; shown in indexes. */
|
|
52
|
+
title: string;
|
|
53
|
+
/** ≤ 200 chars; one-line hook used by retrieval and injection. */
|
|
54
|
+
description: string;
|
|
55
|
+
/** Markdown body, ≤ 64 KB. */
|
|
56
|
+
content: string;
|
|
57
|
+
tags: string[];
|
|
58
|
+
entities: string[];
|
|
59
|
+
/** 0..10 */
|
|
60
|
+
importance: number;
|
|
61
|
+
/** 0..1 */
|
|
62
|
+
confidence: number;
|
|
63
|
+
pinned: boolean;
|
|
64
|
+
status: MemoryStatus;
|
|
65
|
+
created: number;
|
|
66
|
+
updated: number;
|
|
67
|
+
lastUsed?: number;
|
|
68
|
+
usedCount: number;
|
|
69
|
+
/** Bi-temporal: when the fact became true (defaults to created). */
|
|
70
|
+
validFrom: number;
|
|
71
|
+
/** Bi-temporal: when the fact stopped being true (null = still true). */
|
|
72
|
+
validTo: number | null;
|
|
73
|
+
/** When the fact was observed/stated (may differ from created on import). */
|
|
74
|
+
observedAt?: number;
|
|
75
|
+
/** Number of corroborating references. */
|
|
76
|
+
evidence: number;
|
|
77
|
+
source: MemorySource;
|
|
78
|
+
/** Change/merge origin chain (`harness:session#turn`). */
|
|
79
|
+
provenance: string[];
|
|
80
|
+
links: string[];
|
|
81
|
+
supersedes: string[];
|
|
82
|
+
supersededBy: string | null;
|
|
83
|
+
sensitive?: boolean;
|
|
84
|
+
/** Free-form extra frontmatter fields preserved for forward compatibility. */
|
|
85
|
+
extra?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
/** Reasons that trigger a hot-index rebuild. */
|
|
88
|
+
export type ContextReason = "session_start" | "resume" | "compaction" | "day_rollover" | "memory_write" | "manual" | "always";
|
|
89
|
+
export interface ContextBlock {
|
|
90
|
+
/** Byte-stable injected text. Empty string when there is nothing to inject. */
|
|
91
|
+
text: string;
|
|
92
|
+
reason: ContextReason;
|
|
93
|
+
/** Timestamp the snapshot was built (ms). Never embed this in per-turn text. */
|
|
94
|
+
snapshotAt: number;
|
|
95
|
+
/** Memory ids mentioned in the index. */
|
|
96
|
+
ids: string[];
|
|
97
|
+
/** Rough token estimate (chars/2.8 for mixed CJK). */
|
|
98
|
+
tokensEstimate: number;
|
|
99
|
+
}
|
|
100
|
+
export interface SearchOptions {
|
|
101
|
+
query: string;
|
|
102
|
+
/** Default 8. */
|
|
103
|
+
limit?: number;
|
|
104
|
+
/** Default "all" (user + current project). */
|
|
105
|
+
scope?: MemoryScope | "all";
|
|
106
|
+
/** Override the current project shard(s). */
|
|
107
|
+
project?: string;
|
|
108
|
+
/** Include archived/superseded records (default false). */
|
|
109
|
+
includeArchived?: boolean;
|
|
110
|
+
/** Include superseded history (default false). */
|
|
111
|
+
includeHistory?: boolean;
|
|
112
|
+
/** Bi-temporal: only facts valid at this instant. */
|
|
113
|
+
asOf?: number | string;
|
|
114
|
+
/** Restrict to records mentioning this entity. */
|
|
115
|
+
entity?: string;
|
|
116
|
+
/** Weight override for the lexical signal (advanced). */
|
|
117
|
+
weights?: Partial<Record<"lex" | "imp" | "conf" | "rec" | "use" | "pin" | "link" | "stale", number>>;
|
|
118
|
+
/** Include per-signal score breakdowns. */
|
|
119
|
+
debug?: boolean;
|
|
120
|
+
}
|
|
121
|
+
export interface ScoreParts {
|
|
122
|
+
lex: number;
|
|
123
|
+
imp: number;
|
|
124
|
+
conf: number;
|
|
125
|
+
rec: number;
|
|
126
|
+
use: number;
|
|
127
|
+
pin: number;
|
|
128
|
+
link: number;
|
|
129
|
+
stale: number;
|
|
130
|
+
total: number;
|
|
131
|
+
}
|
|
132
|
+
export interface SearchHit {
|
|
133
|
+
id: string;
|
|
134
|
+
type: MemoryType;
|
|
135
|
+
category?: MemoryCategory;
|
|
136
|
+
scope: MemoryScope;
|
|
137
|
+
project?: string;
|
|
138
|
+
title: string;
|
|
139
|
+
description: string;
|
|
140
|
+
/** Body excerpt (~400 chars) when requested. */
|
|
141
|
+
snippet?: string;
|
|
142
|
+
score: number;
|
|
143
|
+
status: MemoryStatus;
|
|
144
|
+
pinned: boolean;
|
|
145
|
+
/** True when the record is a historical (superseded) version. */
|
|
146
|
+
historical: boolean;
|
|
147
|
+
updated: number;
|
|
148
|
+
parts?: ScoreParts;
|
|
149
|
+
}
|
|
150
|
+
export interface SearchResult {
|
|
151
|
+
query: string;
|
|
152
|
+
total: number;
|
|
153
|
+
results: SearchHit[];
|
|
154
|
+
/** True when the engine decided not to recall anything (no confident match). */
|
|
155
|
+
abstained: boolean;
|
|
156
|
+
debug?: {
|
|
157
|
+
candidateCount: number;
|
|
158
|
+
truncated: string[];
|
|
159
|
+
elapsedMs: number;
|
|
160
|
+
shards: string[];
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export interface WriteInput {
|
|
164
|
+
type: MemoryType;
|
|
165
|
+
category?: MemoryCategory;
|
|
166
|
+
scope?: MemoryScope | "auto";
|
|
167
|
+
project?: string;
|
|
168
|
+
title: string;
|
|
169
|
+
description: string;
|
|
170
|
+
content: string;
|
|
171
|
+
tags?: string[];
|
|
172
|
+
entities?: string[];
|
|
173
|
+
importance?: number;
|
|
174
|
+
confidence?: number;
|
|
175
|
+
pinned?: boolean;
|
|
176
|
+
links?: string[];
|
|
177
|
+
supersedes?: string[];
|
|
178
|
+
evidence?: string[];
|
|
179
|
+
sensitive?: boolean;
|
|
180
|
+
/** Override source metadata (defaults filled by the engine from config). */
|
|
181
|
+
source?: Partial<MemorySource>;
|
|
182
|
+
}
|
|
183
|
+
export type WriteAction = "NEW" | "SKIP" | "MERGE" | "SUPERSEDE" | "LINK";
|
|
184
|
+
export interface WriteResult {
|
|
185
|
+
id: string;
|
|
186
|
+
action: WriteAction;
|
|
187
|
+
/** Ids of records superseded by this write. */
|
|
188
|
+
superseded: string[];
|
|
189
|
+
warnings: string[];
|
|
190
|
+
record?: MemoryRecord;
|
|
191
|
+
}
|
|
192
|
+
export interface ReadOptions {
|
|
193
|
+
/** Read the version valid at this instant (bi-temporal). */
|
|
194
|
+
asOf?: number | string;
|
|
195
|
+
/** Include the superseded history chain. */
|
|
196
|
+
includeHistory?: boolean;
|
|
197
|
+
}
|
|
198
|
+
export interface ReadResult {
|
|
199
|
+
record: MemoryRecord;
|
|
200
|
+
/** Ids of records that link to this one. */
|
|
201
|
+
backlinks: string[];
|
|
202
|
+
/** Older versions when `includeHistory` is true. */
|
|
203
|
+
history?: MemoryRecord[];
|
|
204
|
+
}
|
|
205
|
+
export interface ImportOptions {
|
|
206
|
+
/** Apply the same dedupe/supersede decisions as `write` (default false). */
|
|
207
|
+
dedupe?: boolean;
|
|
208
|
+
/** Compute decisions but don't write anything. */
|
|
209
|
+
dryRun?: boolean;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Bulk-import shape: like WriteInput but with explicit identity/timestamps/
|
|
213
|
+
* lifecycle fields so migrations and eval corpora can materialize exact records
|
|
214
|
+
* without the interactive dedupe path.
|
|
215
|
+
*/
|
|
216
|
+
export interface ImportRecord {
|
|
217
|
+
id?: string;
|
|
218
|
+
type: MemoryType;
|
|
219
|
+
title: string;
|
|
220
|
+
description?: string;
|
|
221
|
+
content?: string;
|
|
222
|
+
category?: MemoryCategory;
|
|
223
|
+
scope?: MemoryScope;
|
|
224
|
+
project?: string;
|
|
225
|
+
projectName?: string;
|
|
226
|
+
tags?: string[];
|
|
227
|
+
entities?: string[];
|
|
228
|
+
importance?: number;
|
|
229
|
+
confidence?: number;
|
|
230
|
+
pinned?: boolean;
|
|
231
|
+
status?: MemoryStatus;
|
|
232
|
+
created?: number;
|
|
233
|
+
updated?: number;
|
|
234
|
+
lastUsed?: number;
|
|
235
|
+
usedCount?: number;
|
|
236
|
+
validFrom?: number;
|
|
237
|
+
validTo?: number | null;
|
|
238
|
+
observedAt?: number;
|
|
239
|
+
evidence?: number;
|
|
240
|
+
source?: Partial<MemorySource>;
|
|
241
|
+
provenance?: string[];
|
|
242
|
+
links?: string[];
|
|
243
|
+
supersedes?: string[];
|
|
244
|
+
supersededBy?: string | null;
|
|
245
|
+
sensitive?: boolean;
|
|
246
|
+
extra?: Record<string, unknown>;
|
|
247
|
+
}
|
|
248
|
+
export interface ImportResult {
|
|
249
|
+
ids: string[];
|
|
250
|
+
skipped: number;
|
|
251
|
+
superseded: string[];
|
|
252
|
+
warnings: string[];
|
|
253
|
+
}
|
|
254
|
+
export interface ForgetResult {
|
|
255
|
+
id: string;
|
|
256
|
+
ok: boolean;
|
|
257
|
+
mode: "trash" | "hard";
|
|
258
|
+
}
|
|
259
|
+
export interface RestoreResult {
|
|
260
|
+
id: string;
|
|
261
|
+
ok: boolean;
|
|
262
|
+
}
|
|
263
|
+
export interface TranscriptMessage {
|
|
264
|
+
role: "user" | "assistant" | "tool" | "system";
|
|
265
|
+
text: string;
|
|
266
|
+
ts?: number;
|
|
267
|
+
/** Tool name for role=tool. */
|
|
268
|
+
name?: string;
|
|
269
|
+
}
|
|
270
|
+
export interface SessionEndInput {
|
|
271
|
+
sessionId?: string;
|
|
272
|
+
cwd?: string;
|
|
273
|
+
/** Recent conversation, oldest first. Engine truncates as needed. */
|
|
274
|
+
messages: TranscriptMessage[];
|
|
275
|
+
/** Free-form reason ("quit" | "session_end" | ...). */
|
|
276
|
+
reason?: string;
|
|
277
|
+
/** Skip extraction even if autoExtract is on. */
|
|
278
|
+
skipExtract?: boolean;
|
|
279
|
+
}
|
|
280
|
+
export type ExtractStatus = "skipped" | "done" | "failed" | "no_llm";
|
|
281
|
+
export interface ExtractResult {
|
|
282
|
+
status: ExtractStatus;
|
|
283
|
+
added: string[];
|
|
284
|
+
superseded: string[];
|
|
285
|
+
skipped: number;
|
|
286
|
+
error?: string;
|
|
287
|
+
/** Why extraction was skipped (when status = skipped). */
|
|
288
|
+
skipReason?: string;
|
|
289
|
+
}
|
|
290
|
+
export interface Stats {
|
|
291
|
+
version: 1;
|
|
292
|
+
home: string;
|
|
293
|
+
project: string | null;
|
|
294
|
+
shards: Array<{
|
|
295
|
+
name: string;
|
|
296
|
+
scope: MemoryScope;
|
|
297
|
+
total: number;
|
|
298
|
+
active: number;
|
|
299
|
+
superseded: number;
|
|
300
|
+
archived: number;
|
|
301
|
+
pinned: number;
|
|
302
|
+
bytes: number;
|
|
303
|
+
}>;
|
|
304
|
+
index: {
|
|
305
|
+
seq: number;
|
|
306
|
+
builtAt: number;
|
|
307
|
+
stale: boolean;
|
|
308
|
+
sizeBytes: number;
|
|
309
|
+
overhead: number;
|
|
310
|
+
};
|
|
311
|
+
health: {
|
|
312
|
+
overBudget: boolean;
|
|
313
|
+
duplicateCandidates: number;
|
|
314
|
+
orphans: number;
|
|
315
|
+
lastConsolidate: number | null;
|
|
316
|
+
};
|
|
317
|
+
extraction: {
|
|
318
|
+
pending: number;
|
|
319
|
+
failed: number;
|
|
320
|
+
skipReasons: Record<string, number>;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
export interface ConsolidateOptions {
|
|
324
|
+
dryRun?: boolean;
|
|
325
|
+
/** Only mechanical passes (no LLM). */
|
|
326
|
+
mechanicalOnly?: boolean;
|
|
327
|
+
maxLlmCalls?: number;
|
|
328
|
+
}
|
|
329
|
+
export interface ConsolidationReport {
|
|
330
|
+
runId: string;
|
|
331
|
+
startedAt: number;
|
|
332
|
+
finishedAt: number;
|
|
333
|
+
merged: Array<{
|
|
334
|
+
into: string;
|
|
335
|
+
from: string[];
|
|
336
|
+
}>;
|
|
337
|
+
supersededChainsCompressed: number;
|
|
338
|
+
archived: string[];
|
|
339
|
+
digestsWritten: string[];
|
|
340
|
+
skipped: number;
|
|
341
|
+
llmCalls: number;
|
|
342
|
+
dryRun: boolean;
|
|
343
|
+
}
|
|
344
|
+
/** LLM bridge supplied by the harness adapter. Engine never does network I/O. */
|
|
345
|
+
export interface LlmRequest {
|
|
346
|
+
system: string;
|
|
347
|
+
prompt: string;
|
|
348
|
+
maxTokens?: number;
|
|
349
|
+
temperature?: number;
|
|
350
|
+
reasoningEffort?: "low" | "medium" | "high";
|
|
351
|
+
/** Abort support when the harness can cancel. */
|
|
352
|
+
signal?: AbortSignal;
|
|
353
|
+
}
|
|
354
|
+
export interface LlmResponse {
|
|
355
|
+
text: string;
|
|
356
|
+
promptTokens?: number;
|
|
357
|
+
completionTokens?: number;
|
|
358
|
+
}
|
|
359
|
+
export type LlmFn = (req: LlmRequest) => Promise<LlmResponse>;
|
|
360
|
+
export interface BudgetConfig {
|
|
361
|
+
/** Max tokens for injected hot index (default 1200). */
|
|
362
|
+
injectTokens: number;
|
|
363
|
+
/** Max tokens for search tool results (default 1200). */
|
|
364
|
+
searchTokens: number;
|
|
365
|
+
/** Max entries in the hot index (default 24). */
|
|
366
|
+
hotEntries: number;
|
|
367
|
+
/** Max pinned entries in injection (default 10). */
|
|
368
|
+
maxPinned: number;
|
|
369
|
+
}
|
|
370
|
+
export interface RetrievalConfig {
|
|
371
|
+
k1: number;
|
|
372
|
+
b: number;
|
|
373
|
+
weights: {
|
|
374
|
+
lex: number;
|
|
375
|
+
imp: number;
|
|
376
|
+
conf: number;
|
|
377
|
+
rec: number;
|
|
378
|
+
use: number;
|
|
379
|
+
pin: number;
|
|
380
|
+
link: number;
|
|
381
|
+
stale: number;
|
|
382
|
+
};
|
|
383
|
+
decayPerHour: number;
|
|
384
|
+
mmrLambda: number;
|
|
385
|
+
abstainLex: number;
|
|
386
|
+
ttlDays: {
|
|
387
|
+
user: number;
|
|
388
|
+
feedback: number;
|
|
389
|
+
project: number;
|
|
390
|
+
reference: number;
|
|
391
|
+
};
|
|
392
|
+
synonyms: boolean;
|
|
393
|
+
/** Field weights for BM25F (title/description/tags/entities/body). */
|
|
394
|
+
fields?: Partial<{
|
|
395
|
+
title: number;
|
|
396
|
+
description: number;
|
|
397
|
+
tags: number;
|
|
398
|
+
entities: number;
|
|
399
|
+
body: number;
|
|
400
|
+
}>;
|
|
401
|
+
/** Disable 2-hop link diffusion (ablation A4). */
|
|
402
|
+
linkDiffusion: boolean;
|
|
403
|
+
/** Disable MMR diversity (ablation A5). */
|
|
404
|
+
mmr: boolean;
|
|
405
|
+
}
|
|
406
|
+
export interface WriteConfig {
|
|
407
|
+
autoExtract: boolean;
|
|
408
|
+
/** Skip auto-extraction when the model already wrote this many memories. */
|
|
409
|
+
skipExtractIfModelWrote: number;
|
|
410
|
+
/** Minimum real user messages for extraction. */
|
|
411
|
+
minUserMessages: number;
|
|
412
|
+
/** Minimum digest length in chars. */
|
|
413
|
+
minDigestChars: number;
|
|
414
|
+
/** Max memories per extraction run. */
|
|
415
|
+
maxPerRun: number;
|
|
416
|
+
/** Extraction confidence floor. */
|
|
417
|
+
minConfidence: number;
|
|
418
|
+
/** Per-run LLM timeout in ms (adapter also enforces its own). */
|
|
419
|
+
llmTimeoutMs: number;
|
|
420
|
+
}
|
|
421
|
+
export interface GovernanceConfig {
|
|
422
|
+
maxUserRecords: number;
|
|
423
|
+
maxProjectRecords: number;
|
|
424
|
+
maxBodyBytes: number;
|
|
425
|
+
consolidateEveryWrites: number;
|
|
426
|
+
trashGraceDays: number;
|
|
427
|
+
archiveRetention: number;
|
|
428
|
+
archiveR0: number;
|
|
429
|
+
}
|
|
430
|
+
export interface HarnMemConfig {
|
|
431
|
+
/** Root directory (default `$HARNMEM_HOME` or `~/.harnmem`). */
|
|
432
|
+
home?: string;
|
|
433
|
+
harness: HarnessId;
|
|
434
|
+
sessionId?: string;
|
|
435
|
+
/** Working directory used to resolve the current project. */
|
|
436
|
+
cwd: string;
|
|
437
|
+
/** Explicit project id (skips project resolution). */
|
|
438
|
+
project?: string;
|
|
439
|
+
now?: () => number;
|
|
440
|
+
llm?: LlmFn | null;
|
|
441
|
+
budget?: Partial<BudgetConfig>;
|
|
442
|
+
retrieval?: Partial<Omit<RetrievalConfig, "weights" | "ttlDays">> & {
|
|
443
|
+
weights?: Partial<RetrievalConfig["weights"]>;
|
|
444
|
+
ttlDays?: Partial<RetrievalConfig["ttlDays"]>;
|
|
445
|
+
};
|
|
446
|
+
write?: Partial<WriteConfig>;
|
|
447
|
+
governance?: Partial<GovernanceConfig>;
|
|
448
|
+
/** Disable all automatic extraction (tool writes still work). */
|
|
449
|
+
readOnly?: boolean;
|
|
450
|
+
/** Extra debug logging sink (optional). */
|
|
451
|
+
log?: (level: "debug" | "info" | "warn" | "error", msg: string, data?: unknown) => void;
|
|
452
|
+
}
|
|
453
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,+EAA+E;AAC/E,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG,QAAQ,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAExE,wFAAwF;AACxF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;AAEvE,oFAAoF;AACpF,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,YAAY,GACZ,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,SAAS,GACT,OAAO,GACP,UAAU,GACV,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5E,2CAA2C;AAC3C,MAAM,WAAW,YAAY;I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KAAK,IAAI,CAAC;CACzF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HarnMem public API — frozen contract v1 (see docs/design/07-adapter-contract.md).
|
|
3
|
+
*
|
|
4
|
+
* Harness adapters (pi / dsh / claude / cli) may only depend on this file's
|
|
5
|
+
* exported types and the `HarnMem` facade in `./harnmem.js`. Everything else is
|
|
6
|
+
* internal and may change.
|
|
7
|
+
*
|
|
8
|
+
* Design rules:
|
|
9
|
+
* - zero runtime dependencies (node: builtins only)
|
|
10
|
+
* - on-disk format is the SSOT; every index file is rebuildable
|
|
11
|
+
* - the engine never writes outside `harnmem.home` except for reads
|
|
12
|
+
*/
|
|
13
|
+
export const HARNMEM_API_VERSION = 1;
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** ULID-like 26-char Crockford base32 id, time-sortable. */
|
|
2
|
+
export declare function newMemoryId(now?: number): string;
|
|
3
|
+
export declare function sha256Hex(input: string | Buffer): string;
|
|
4
|
+
export declare function sha1Hex(input: string | Buffer): string;
|
|
5
|
+
/** FNV-1a 64-bit as bigint (used for simhash feature hashing). */
|
|
6
|
+
export declare function fnv1a64(input: string): bigint;
|
|
7
|
+
/** 64-bit SimHash over weighted tokens (weights: Map token -> weight). */
|
|
8
|
+
export declare function simhash64(weights: Map<string, number>): bigint;
|
|
9
|
+
export declare function hamming64(a: bigint, b: bigint): number;
|
|
10
|
+
export declare function simhashHex(value: bigint): string;
|
|
11
|
+
export declare function parseSimhashHex(hex: string | undefined | null): bigint | null;
|
|
12
|
+
/** Jaccard similarity of two string sets (or arrays). */
|
|
13
|
+
export declare function jaccard(a: Iterable<string>, b: Iterable<string>): number;
|
|
14
|
+
/** Character n-grams (default 3) for CJK-friendly fuzzy comparison. */
|
|
15
|
+
export declare function charNgrams(text: string, n?: number): Set<string>;
|
|
16
|
+
export declare function normalizeForCompare(text: string): string;
|
|
17
|
+
export declare function normalizeNewlines(text: string): string;
|
|
18
|
+
/** Estimate tokens for mixed CJK/English text (chars/2.8 is conservative for zh). */
|
|
19
|
+
export declare function estimateTokens(text: string): number;
|
|
20
|
+
export declare function ensureDir(dir: string): Promise<void>;
|
|
21
|
+
export declare function atomicWriteFile(file: string, data: string): Promise<void>;
|
|
22
|
+
export declare function readJson<T>(file: string, fallback: T): Promise<T>;
|
|
23
|
+
export declare function writeJson(file: string, value: unknown): Promise<void>;
|
|
24
|
+
export declare function pathExists(path: string): Promise<boolean>;
|
|
25
|
+
export declare function readTextIfExists(file: string): Promise<string | null>;
|
|
26
|
+
export declare function expandHome(input: string): string;
|
|
27
|
+
export declare function resolveHome(input?: string): string;
|
|
28
|
+
export declare function truncateText(text: string, maxChars: number): string;
|
|
29
|
+
/** Deterministic date key in local time, e.g. 2026-10-20. */
|
|
30
|
+
export declare function dayKey(ts?: number): string;
|
|
31
|
+
export declare function parseTimestamp(value: number | string | undefined, fallback: number): number;
|
|
32
|
+
/** "2026-10-20" / ISO string -> end-of-day timestamp for as-of queries. */
|
|
33
|
+
export declare function parseAsOf(value: number | string, fallback: number): number;
|
|
34
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
35
|
+
export declare function sortedUnique(values: Iterable<string>): string[];
|
|
36
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
37
|
+
export declare function withTimeout<T>(promise: Promise<T>, ms: number, label?: string): Promise<T>;
|
|
38
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAUA,4DAA4D;AAC5D,wBAAgB,WAAW,CAAC,GAAG,GAAE,MAAmB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