peon-mem 1.0.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.
Files changed (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +301 -0
  3. package/bin/peon-mem.mjs +273 -0
  4. package/dist/brain.d.ts +72 -0
  5. package/dist/brain.js +224 -0
  6. package/dist/compression.d.ts +9 -0
  7. package/dist/compression.js +37 -0
  8. package/dist/config.d.ts +22 -0
  9. package/dist/config.js +99 -0
  10. package/dist/daemon-cli.d.ts +2 -0
  11. package/dist/daemon-cli.js +54 -0
  12. package/dist/daemon.d.ts +23 -0
  13. package/dist/daemon.js +1078 -0
  14. package/dist/embedding-store.d.ts +43 -0
  15. package/dist/embedding-store.js +169 -0
  16. package/dist/embeddings.d.ts +93 -0
  17. package/dist/embeddings.js +345 -0
  18. package/dist/entities.d.ts +61 -0
  19. package/dist/entities.js +191 -0
  20. package/dist/entity-extraction.d.ts +33 -0
  21. package/dist/entity-extraction.js +75 -0
  22. package/dist/eval-metrics.d.ts +27 -0
  23. package/dist/eval-metrics.js +50 -0
  24. package/dist/evaluation.d.ts +58 -0
  25. package/dist/evaluation.js +244 -0
  26. package/dist/global-extraction.d.ts +15 -0
  27. package/dist/global-extraction.js +61 -0
  28. package/dist/global-memory.d.ts +43 -0
  29. package/dist/global-memory.js +306 -0
  30. package/dist/global-promotion.d.ts +25 -0
  31. package/dist/global-promotion.js +29 -0
  32. package/dist/hyde.d.ts +31 -0
  33. package/dist/hyde.js +46 -0
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.js +246 -0
  36. package/dist/injection.d.ts +38 -0
  37. package/dist/injection.js +133 -0
  38. package/dist/logger.d.ts +17 -0
  39. package/dist/logger.js +63 -0
  40. package/dist/memory-mutations.d.ts +24 -0
  41. package/dist/memory-mutations.js +57 -0
  42. package/dist/memory-store.d.ts +194 -0
  43. package/dist/memory-store.js +1205 -0
  44. package/dist/monitor.d.ts +13 -0
  45. package/dist/monitor.js +977 -0
  46. package/dist/overview.d.ts +73 -0
  47. package/dist/overview.js +104 -0
  48. package/dist/processor.d.ts +90 -0
  49. package/dist/processor.js +450 -0
  50. package/dist/quality.d.ts +86 -0
  51. package/dist/quality.js +338 -0
  52. package/dist/recuration.d.ts +13 -0
  53. package/dist/recuration.js +65 -0
  54. package/dist/reranker.d.ts +34 -0
  55. package/dist/reranker.js +89 -0
  56. package/dist/retrieval.d.ts +106 -0
  57. package/dist/retrieval.js +392 -0
  58. package/dist/session-index.d.ts +34 -0
  59. package/dist/session-index.js +87 -0
  60. package/dist/temporal.d.ts +20 -0
  61. package/dist/temporal.js +62 -0
  62. package/dist/token-ab-monitor.d.ts +1 -0
  63. package/dist/token-ab-monitor.js +7 -0
  64. package/dist/tools.d.ts +232 -0
  65. package/dist/tools.js +546 -0
  66. package/dist/types.d.ts +169 -0
  67. package/dist/types.js +1 -0
  68. package/docs/assets/neural-universe.png +0 -0
  69. package/package.json +57 -0
  70. package/scripts/claude-peon-hook.mjs +522 -0
  71. package/scripts/codex-peon-hook.mjs +4 -0
  72. package/scripts/eval-retrieval-labeled.mjs +135 -0
  73. package/scripts/eval-retrieval.mjs +96 -0
  74. package/scripts/evaluate-peon.mjs +47 -0
  75. package/scripts/install-peon-stl.mjs +82 -0
  76. package/scripts/install-peon.mjs +318 -0
  77. package/scripts/lib/eval-ledger.mjs +104 -0
  78. package/scripts/lib/stl-classify.mjs +44 -0
  79. package/scripts/longmemeval-eval.mjs +144 -0
  80. package/scripts/peon-report.mjs +155 -0
  81. package/scripts/peon-stl.mjs +506 -0
  82. package/scripts/token-ab-monitor.html +235 -0
@@ -0,0 +1,232 @@
1
+ import { type MaybeProcessMemoryResult, type ProcessMemoryResult } from "./processor.js";
2
+ import { selectMemoryRecordsForContext, type RankedMemoryRecord } from "./retrieval.js";
3
+ import { type MemoryQualityReport } from "./quality.js";
4
+ import { type GlobalMemorySource } from "./global-memory.js";
5
+ import type { BrainAction } from "./brain.js";
6
+ import { type EvaluationReport, type ExpectedMemoryInput } from "./evaluation.js";
7
+ import { type ContextInjection } from "./injection.js";
8
+ import type { BrainInspection, MemoryRecord, MemoryRecordInput, MemoryStatus, MemoryType, PeonEvent, PeonRole, PeonSession, ProcessedMemory, ProjectContext } from "./types.js";
9
+ export interface CreatePeonToolsOptions {
10
+ daemonUrl?: string;
11
+ globalMemoryDir?: string;
12
+ /** Path to the durable sessionId → project index. Defaults to the global Peon dir. */
13
+ sessionIndexPath?: string;
14
+ }
15
+ export interface StartSessionToolInput {
16
+ projectPath: string;
17
+ client: string;
18
+ cwd?: string;
19
+ }
20
+ export interface StartSessionToolResult {
21
+ sessionId: string;
22
+ projectPath: string;
23
+ }
24
+ export interface RecordMessageToolInput {
25
+ sessionId: string;
26
+ role: PeonRole;
27
+ content: string;
28
+ }
29
+ export interface RecordEventToolInput {
30
+ sessionId: string;
31
+ type: string;
32
+ content: string;
33
+ }
34
+ export interface EndSessionToolInput {
35
+ sessionId: string;
36
+ }
37
+ export interface GetContextToolInput {
38
+ projectPath: string;
39
+ query?: string;
40
+ maxChars?: number;
41
+ }
42
+ export interface InspectBrainToolInput {
43
+ projectPath: string;
44
+ query?: string;
45
+ maxChars?: number;
46
+ }
47
+ export interface ProcessMemoryToolInput {
48
+ projectPath: string;
49
+ reason?: string;
50
+ aiResult?: ProcessedMemory;
51
+ }
52
+ export interface MaybeProcessMemoryToolInput {
53
+ projectPath: string;
54
+ trigger: string;
55
+ force?: boolean;
56
+ aiResult?: ProcessedMemory;
57
+ }
58
+ export interface SearchMemoryToolInput {
59
+ projectPath: string;
60
+ query: string;
61
+ limit?: number;
62
+ maxChars?: number;
63
+ }
64
+ export interface SearchMemoryToolResult {
65
+ projectPath: string;
66
+ query: string;
67
+ records: RankedMemoryRecord[];
68
+ selected: ReturnType<typeof selectMemoryRecordsForContext>;
69
+ injectionPreview: string;
70
+ }
71
+ export interface QualityReportToolInput {
72
+ projectPath: string;
73
+ staleAfterDays?: number;
74
+ }
75
+ export interface GlobalMemoryToolInput {
76
+ memory: MemoryRecordInput;
77
+ source?: GlobalMemorySource;
78
+ }
79
+ export interface SearchGlobalMemoryToolInput {
80
+ query?: string;
81
+ type?: MemoryType;
82
+ status?: MemoryStatus;
83
+ }
84
+ export interface ImportGlobalMemoryToolInput {
85
+ projectPath: string;
86
+ }
87
+ export interface PromoteToGlobalToolInput {
88
+ projectPath: string;
89
+ }
90
+ export interface BrainActivityItem {
91
+ at: string;
92
+ scope: "project" | "global";
93
+ projectName: string;
94
+ type: string;
95
+ detail: string;
96
+ }
97
+ export interface GlobalDashboard {
98
+ totalBeliefs: number;
99
+ byType: Record<string, number>;
100
+ topEntities: Array<{
101
+ entity: string;
102
+ count: number;
103
+ }>;
104
+ recentActions: BrainActivityItem[];
105
+ records: Array<{
106
+ id: string;
107
+ type: string;
108
+ content: string;
109
+ entities: string[];
110
+ }>;
111
+ }
112
+ export interface PromoteToGlobalToolResult {
113
+ projectPath: string;
114
+ promoted: MemoryRecord[];
115
+ }
116
+ export interface UpdateMemoryToolInput {
117
+ projectPath: string;
118
+ id: string;
119
+ content?: string;
120
+ importance?: number;
121
+ confidence?: number;
122
+ status?: MemoryStatus;
123
+ pinned?: boolean;
124
+ }
125
+ export interface DeleteMemoryToolInput {
126
+ projectPath: string;
127
+ id: string;
128
+ }
129
+ export interface MergeMemoryToolInput {
130
+ projectPath: string;
131
+ keepId: string;
132
+ dropId: string;
133
+ }
134
+ export interface EvaluateProjectToolInput {
135
+ projectPath: string;
136
+ expectedMemories?: Array<string | ExpectedMemoryInput>;
137
+ }
138
+ export interface BuildInjectionToolInput {
139
+ projectPath: string;
140
+ query?: string;
141
+ maxChars?: number;
142
+ includeInactive?: boolean;
143
+ }
144
+ export interface CrossProjectSearchToolInput {
145
+ query: string;
146
+ /** Projects to search. When omitted, the daemon fills this with all known projects. */
147
+ projectPaths?: string[];
148
+ /** Usually the current project — excluded so you only get OTHER projects' beliefs. */
149
+ excludeProjectPath?: string;
150
+ limit?: number;
151
+ perProjectLimit?: number;
152
+ /** Cap on how many projects to FULLY (semantically) rank after the cheap pre-filter. */
153
+ maxProjects?: number;
154
+ }
155
+ export interface CrossProjectHit {
156
+ projectPath: string;
157
+ projectName: string;
158
+ record: MemoryRecord;
159
+ score: number;
160
+ explanation: string;
161
+ }
162
+ export interface CrossProjectSearchToolResult {
163
+ query: string;
164
+ projectsSearched: string[];
165
+ results: CrossProjectHit[];
166
+ }
167
+ export interface PeonTools {
168
+ startSession(input: StartSessionToolInput): Promise<StartSessionToolResult>;
169
+ recordMessage(input: RecordMessageToolInput): Promise<PeonEvent>;
170
+ recordEvent(input: RecordEventToolInput): Promise<PeonEvent>;
171
+ endSession(input: EndSessionToolInput): Promise<PeonSession>;
172
+ getContext(input: GetContextToolInput): Promise<ProjectContext>;
173
+ inspectBrain(input: InspectBrainToolInput): Promise<BrainInspection>;
174
+ searchMemory(input: SearchMemoryToolInput): Promise<SearchMemoryToolResult>;
175
+ qualityReport(input: QualityReportToolInput): Promise<MemoryQualityReport>;
176
+ rememberGlobal(input: GlobalMemoryToolInput): Promise<MemoryRecord>;
177
+ searchGlobalMemory(input: SearchGlobalMemoryToolInput): Promise<MemoryRecord[]>;
178
+ importGlobalMemory(input: ImportGlobalMemoryToolInput): Promise<MemoryRecord[]>;
179
+ promoteToGlobal(input: PromoteToGlobalToolInput): Promise<PromoteToGlobalToolResult>;
180
+ extractGlobal(input: {
181
+ projectPath: string;
182
+ }): Promise<{
183
+ promoted: MemoryRecord[];
184
+ }>;
185
+ recurateProject(input: {
186
+ projectPath: string;
187
+ }): Promise<{
188
+ archived: number;
189
+ considered: number;
190
+ capped?: boolean;
191
+ }>;
192
+ brainPass(input: {
193
+ projectPath: string;
194
+ recalledIds?: string[];
195
+ compress?: boolean;
196
+ }): Promise<{
197
+ actions: BrainAction[];
198
+ }>;
199
+ globalBrainPass(input: {
200
+ compress?: boolean;
201
+ }): Promise<{
202
+ actions: BrainAction[];
203
+ }>;
204
+ brainActivity(input: {
205
+ projectPaths: string[];
206
+ limit?: number;
207
+ }): Promise<BrainActivityItem[]>;
208
+ globalDashboard(): Promise<GlobalDashboard>;
209
+ brainActions(input: {
210
+ projectPath: string;
211
+ limit?: number;
212
+ }): Promise<Array<{
213
+ at: string;
214
+ actions: BrainAction[];
215
+ }>>;
216
+ restoreBackup(input: {
217
+ projectPath: string;
218
+ }): Promise<{
219
+ restored: boolean;
220
+ }>;
221
+ updateMemory(input: UpdateMemoryToolInput): Promise<MemoryRecord | null>;
222
+ deleteMemory(input: DeleteMemoryToolInput): Promise<{
223
+ deleted: boolean;
224
+ }>;
225
+ mergeMemory(input: MergeMemoryToolInput): Promise<MemoryRecord | null>;
226
+ evaluateProject(input: EvaluateProjectToolInput): Promise<EvaluationReport>;
227
+ buildInjection(input: BuildInjectionToolInput): Promise<ContextInjection>;
228
+ crossProjectSearch(input: CrossProjectSearchToolInput): Promise<CrossProjectSearchToolResult>;
229
+ processMemory(input: ProcessMemoryToolInput): Promise<ProcessMemoryResult>;
230
+ maybeProcessMemory(input: MaybeProcessMemoryToolInput): Promise<MaybeProcessMemoryResult>;
231
+ }
232
+ export declare function createPeonTools(options?: CreatePeonToolsOptions): PeonTools;