@openanonymity/nanomem 0.1.0 → 0.1.2
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 +64 -18
- package/package.json +7 -3
- package/src/backends/BaseStorage.js +147 -3
- package/src/backends/indexeddb.js +21 -8
- package/src/browser.js +227 -0
- package/src/bullets/parser.js +8 -9
- package/src/cli/auth.js +1 -1
- package/src/cli/commands.js +58 -9
- package/src/cli/config.js +1 -1
- package/src/cli/help.js +5 -2
- package/src/cli/output.js +4 -0
- package/src/cli.js +6 -3
- package/src/engine/compactor.js +3 -6
- package/src/engine/deleter.js +187 -0
- package/src/engine/executors.js +474 -11
- package/src/engine/ingester.js +98 -63
- package/src/engine/recentConversation.js +110 -0
- package/src/engine/retriever.js +243 -37
- package/src/engine/toolLoop.js +51 -9
- package/src/imports/chatgpt.js +1 -1
- package/src/imports/claude.js +85 -0
- package/src/imports/importData.js +462 -0
- package/src/imports/index.js +10 -0
- package/src/index.js +95 -2
- package/src/llm/openai.js +204 -58
- package/src/llm/tinfoil.js +508 -0
- package/src/omf.js +343 -0
- package/src/prompt_sets/conversation/ingestion.js +111 -12
- package/src/prompt_sets/document/ingestion.js +98 -4
- package/src/prompt_sets/index.js +12 -4
- package/src/types.js +135 -4
- package/src/vendor/tinfoil.browser.d.ts +2 -0
- package/src/vendor/tinfoil.browser.js +41596 -0
- package/types/backends/BaseStorage.d.ts +19 -0
- package/types/backends/indexeddb.d.ts +1 -0
- package/types/browser.d.ts +17 -0
- package/types/engine/deleter.d.ts +67 -0
- package/types/engine/executors.d.ts +56 -2
- package/types/engine/recentConversation.d.ts +18 -0
- package/types/engine/retriever.d.ts +22 -9
- package/types/imports/claude.d.ts +14 -0
- package/types/imports/importData.d.ts +29 -0
- package/types/imports/index.d.ts +2 -0
- package/types/index.d.ts +9 -0
- package/types/llm/openai.d.ts +6 -9
- package/types/llm/tinfoil.d.ts +13 -0
- package/types/omf.d.ts +40 -0
- package/types/prompt_sets/conversation/ingestion.d.ts +8 -3
- package/types/prompt_sets/document/ingestion.d.ts +8 -3
- package/types/types.d.ts +127 -2
- package/types/vendor/tinfoil.browser.d.ts +6348 -0
package/types/types.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ export type ToolFunctionParameters = {
|
|
|
77
77
|
properties: Record<string, {
|
|
78
78
|
type: string;
|
|
79
79
|
description?: string;
|
|
80
|
+
items?: object;
|
|
80
81
|
}>;
|
|
81
82
|
required: string[];
|
|
82
83
|
};
|
|
@@ -136,6 +137,8 @@ export type ProgressEvent = {
|
|
|
136
137
|
tool?: string | undefined;
|
|
137
138
|
args?: Record<string, any> | undefined;
|
|
138
139
|
result?: string | Record<string, any> | undefined;
|
|
140
|
+
toolState?: "started" | "finished" | undefined;
|
|
141
|
+
toolCallId?: string | undefined;
|
|
139
142
|
paths?: string[] | undefined;
|
|
140
143
|
iteration?: number | undefined;
|
|
141
144
|
path?: string | undefined;
|
|
@@ -148,6 +151,16 @@ export type RetrievalResult = {
|
|
|
148
151
|
paths: string[];
|
|
149
152
|
assembledContext: string | null;
|
|
150
153
|
};
|
|
154
|
+
export type AugmentQueryResult = {
|
|
155
|
+
files: {
|
|
156
|
+
path: string;
|
|
157
|
+
content: string;
|
|
158
|
+
}[];
|
|
159
|
+
paths: string[];
|
|
160
|
+
reviewPrompt: string;
|
|
161
|
+
apiPrompt: string;
|
|
162
|
+
assembledContext: string | null;
|
|
163
|
+
};
|
|
151
164
|
export type IngestOptions = {
|
|
152
165
|
updatedAt?: string | undefined;
|
|
153
166
|
/**
|
|
@@ -176,11 +189,18 @@ export type ToolCallLogEntry = {
|
|
|
176
189
|
result: string;
|
|
177
190
|
toolCallId: string;
|
|
178
191
|
};
|
|
192
|
+
export type ToolCallEventMeta = {
|
|
193
|
+
status: "started" | "finished";
|
|
194
|
+
toolCallId: string;
|
|
195
|
+
iteration: number;
|
|
196
|
+
terminal?: boolean | undefined;
|
|
197
|
+
};
|
|
179
198
|
export type ToolLoopResult = {
|
|
180
199
|
textResponse: string;
|
|
181
200
|
terminalToolResult: {
|
|
182
201
|
name: string;
|
|
183
202
|
arguments: Record<string, any>;
|
|
203
|
+
result?: string;
|
|
184
204
|
} | null;
|
|
185
205
|
messages: LLMMessage[];
|
|
186
206
|
iterations: number;
|
|
@@ -196,21 +216,24 @@ export type ToolLoopOptions = {
|
|
|
196
216
|
maxIterations?: number | undefined;
|
|
197
217
|
maxOutputTokens?: number | undefined;
|
|
198
218
|
temperature?: number | undefined;
|
|
199
|
-
onToolCall?: ((name: string, args: Record<string, any>, result: string) => void) | null | undefined;
|
|
219
|
+
onToolCall?: ((name: string, args: Record<string, any>, result: string | null, meta: ToolCallEventMeta) => void) | null | undefined;
|
|
200
220
|
onModelText?: ((text: string, iteration: number) => void) | null | undefined;
|
|
201
221
|
onReasoning?: ((chunk: string, iteration: number) => void) | null | undefined;
|
|
202
222
|
signal?: AbortSignal | null | undefined;
|
|
223
|
+
executeTerminalTool?: boolean | undefined;
|
|
203
224
|
};
|
|
204
225
|
export type ExtractionExecutorHooks = {
|
|
205
226
|
normalizeContent?: ((content: string, path: string) => string) | undefined;
|
|
206
227
|
mergeWithExisting?: ((existing: string | null, incoming: string, path: string) => string) | undefined;
|
|
207
228
|
refreshIndex?: ((path: string) => Promise<void>) | undefined;
|
|
208
229
|
onWrite?: ((path: string, before: string, after: string) => void) | undefined;
|
|
230
|
+
updatedAt?: string | undefined;
|
|
209
231
|
};
|
|
210
232
|
export type ToolExecutor = (args: any) => Promise<string>;
|
|
211
233
|
export type StorageBackend = {
|
|
212
234
|
init: () => Promise<void>;
|
|
213
235
|
read: (path: string) => Promise<string | null>;
|
|
236
|
+
resolvePath?: ((path: string) => Promise<string | null>) | undefined;
|
|
214
237
|
write: (path: string, content: string) => Promise<void>;
|
|
215
238
|
delete: (path: string) => Promise<void>;
|
|
216
239
|
exists: (path: string) => Promise<boolean>;
|
|
@@ -223,6 +246,7 @@ export type StorageBackend = {
|
|
|
223
246
|
};
|
|
224
247
|
export type StorageFacade = {
|
|
225
248
|
read: (path: string) => Promise<string | null>;
|
|
249
|
+
resolvePath?: ((path: string) => Promise<string | null>) | undefined;
|
|
226
250
|
write: (path: string, content: string) => Promise<void>;
|
|
227
251
|
delete: (path: string) => Promise<void>;
|
|
228
252
|
exists: (path: string) => Promise<boolean>;
|
|
@@ -239,6 +263,10 @@ export type MemoryBankLLMConfig = {
|
|
|
239
263
|
model?: string | undefined;
|
|
240
264
|
provider?: string | undefined;
|
|
241
265
|
headers?: Record<string, string> | undefined;
|
|
266
|
+
enclaveURL?: string | undefined;
|
|
267
|
+
configRepo?: string | undefined;
|
|
268
|
+
attestationBundleURL?: string | undefined;
|
|
269
|
+
transport?: "ehbp" | "tls" | undefined;
|
|
242
270
|
};
|
|
243
271
|
export type MemoryBankConfig = {
|
|
244
272
|
llm?: MemoryBankLLMConfig | undefined;
|
|
@@ -248,7 +276,7 @@ export type MemoryBankConfig = {
|
|
|
248
276
|
storagePath?: string | undefined;
|
|
249
277
|
onProgress?: ((event: ProgressEvent) => void) | undefined;
|
|
250
278
|
onCompactProgress?: ((event: ProgressEvent) => void) | undefined;
|
|
251
|
-
onToolCall?: ((name: string, args: Record<string, any>, result: string) => void) | undefined;
|
|
279
|
+
onToolCall?: ((name: string, args: Record<string, any>, result: string | null, meta: ToolCallEventMeta) => void) | undefined;
|
|
252
280
|
onModelText?: ((text: string) => void) | undefined;
|
|
253
281
|
};
|
|
254
282
|
export type Message = {
|
|
@@ -260,6 +288,87 @@ export type ChatGptSession = {
|
|
|
260
288
|
messages: Message[];
|
|
261
289
|
updatedAt: string | null;
|
|
262
290
|
};
|
|
291
|
+
export type MemoryImportConversation = {
|
|
292
|
+
title?: string | null | undefined;
|
|
293
|
+
messages: Message[];
|
|
294
|
+
updatedAt?: string | number | null | undefined;
|
|
295
|
+
mode?: "document" | "conversation" | undefined;
|
|
296
|
+
};
|
|
297
|
+
export type ImportFormat = "auto" | "normalized" | "oa-fastchat" | "chatgpt" | "messages" | "transcript" | "markdown";
|
|
298
|
+
export type ImportProgressEvent = {
|
|
299
|
+
stage: "start" | "item_start" | "item_complete" | "complete";
|
|
300
|
+
totalItems: number;
|
|
301
|
+
itemIndex?: number | undefined;
|
|
302
|
+
itemTitle?: string | null | undefined;
|
|
303
|
+
itemStatus?: "processed" | "skipped" | "error" | undefined;
|
|
304
|
+
itemError?: string | null | undefined;
|
|
305
|
+
};
|
|
306
|
+
export type ImportDataOptions = {
|
|
307
|
+
format?: ImportFormat | undefined;
|
|
308
|
+
sourceName?: string | undefined;
|
|
309
|
+
sessionId?: string | undefined;
|
|
310
|
+
sessionTitle?: string | undefined;
|
|
311
|
+
mode?: "document" | "conversation" | undefined;
|
|
312
|
+
onProgress?: ((event: ImportProgressEvent) => void) | undefined;
|
|
313
|
+
};
|
|
314
|
+
export type ImportDataItemResult = {
|
|
315
|
+
title: string | null;
|
|
316
|
+
updatedAt: string | null;
|
|
317
|
+
status: "processed" | "skipped" | "error";
|
|
318
|
+
writeCalls: number;
|
|
319
|
+
error?: string | undefined;
|
|
320
|
+
};
|
|
321
|
+
export type ImportDataResult = {
|
|
322
|
+
totalItems: number;
|
|
323
|
+
imported: number;
|
|
324
|
+
skipped: number;
|
|
325
|
+
errors: number;
|
|
326
|
+
totalWriteCalls: number;
|
|
327
|
+
authError: string | null;
|
|
328
|
+
results: ImportDataItemResult[];
|
|
329
|
+
};
|
|
330
|
+
export type OmfMemoryItem = {
|
|
331
|
+
content: string;
|
|
332
|
+
category?: string | undefined;
|
|
333
|
+
tags?: string[] | undefined;
|
|
334
|
+
status?: "active" | "archived" | "expired" | undefined;
|
|
335
|
+
created_at?: string | undefined;
|
|
336
|
+
updated_at?: string | undefined;
|
|
337
|
+
expires_at?: string | undefined;
|
|
338
|
+
extensions?: Record<string, any> | undefined;
|
|
339
|
+
};
|
|
340
|
+
export type OmfDocument = {
|
|
341
|
+
omf: string;
|
|
342
|
+
exported_at: string;
|
|
343
|
+
source?: {
|
|
344
|
+
app?: string;
|
|
345
|
+
} | undefined;
|
|
346
|
+
memories: OmfMemoryItem[];
|
|
347
|
+
};
|
|
348
|
+
export type OmfImportOptions = {
|
|
349
|
+
includeArchived?: boolean | undefined;
|
|
350
|
+
};
|
|
351
|
+
export type OmfImportPreview = {
|
|
352
|
+
total: number;
|
|
353
|
+
filtered: number;
|
|
354
|
+
toImport: number;
|
|
355
|
+
duplicates: number;
|
|
356
|
+
newFiles: number;
|
|
357
|
+
existingFiles: number;
|
|
358
|
+
byFile: Record<string, {
|
|
359
|
+
new: number;
|
|
360
|
+
duplicate: number;
|
|
361
|
+
document?: boolean;
|
|
362
|
+
}>;
|
|
363
|
+
};
|
|
364
|
+
export type OmfImportResult = {
|
|
365
|
+
total: number;
|
|
366
|
+
imported: number;
|
|
367
|
+
duplicates: number;
|
|
368
|
+
skipped: number;
|
|
369
|
+
filesWritten: number;
|
|
370
|
+
errors: string[];
|
|
371
|
+
};
|
|
263
372
|
export type SessionSummary = {
|
|
264
373
|
id: string;
|
|
265
374
|
title: string;
|
|
@@ -280,11 +389,27 @@ export type BulletItem = {
|
|
|
280
389
|
export type MemoryBank = {
|
|
281
390
|
init: () => Promise<void>;
|
|
282
391
|
retrieve: (query: string, conversationText?: string) => Promise<RetrievalResult | null>;
|
|
392
|
+
augmentQuery: (query: string, conversationText?: string) => Promise<AugmentQueryResult | null>;
|
|
283
393
|
ingest: (messages: Message[], options?: IngestOptions) => Promise<IngestResult>;
|
|
394
|
+
importData: (input: string | unknown | MemoryImportConversation | MemoryImportConversation[] | Array<{
|
|
395
|
+
path: string;
|
|
396
|
+
content: string;
|
|
397
|
+
}>, options?: ImportDataOptions) => Promise<ImportDataResult>;
|
|
398
|
+
exportOmf: () => Promise<OmfDocument>;
|
|
399
|
+
previewOmfImport: (doc: OmfDocument, options?: OmfImportOptions) => Promise<OmfImportPreview>;
|
|
400
|
+
importOmf: (doc: OmfDocument, options?: OmfImportOptions) => Promise<OmfImportResult>;
|
|
284
401
|
compact: () => Promise<{
|
|
285
402
|
filesChanged: number;
|
|
286
403
|
filesTotal: number;
|
|
287
404
|
} | undefined>;
|
|
405
|
+
deleteContent?: ((query: string, options?: {
|
|
406
|
+
deep?: boolean;
|
|
407
|
+
mode?: string;
|
|
408
|
+
}) => Promise<{
|
|
409
|
+
status: string;
|
|
410
|
+
deleteCalls: number;
|
|
411
|
+
writes: Array<any>;
|
|
412
|
+
}>) | undefined;
|
|
288
413
|
storage: StorageFacade;
|
|
289
414
|
serialize: () => Promise<string>;
|
|
290
415
|
toZip: () => Promise<Uint8Array>;
|