@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/src/types.js
CHANGED
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
/**
|
|
121
121
|
* @typedef {object} ToolFunctionParameters
|
|
122
122
|
* @property {'object'} type
|
|
123
|
-
* @property {Record<string, { type: string; description?: string }>} properties
|
|
123
|
+
* @property {Record<string, { type: string; description?: string; items?: object }>} properties
|
|
124
124
|
* @property {string[]} required
|
|
125
125
|
*/
|
|
126
126
|
|
|
@@ -199,6 +199,8 @@
|
|
|
199
199
|
* @property {string} [tool]
|
|
200
200
|
* @property {Record<string, any>} [args]
|
|
201
201
|
* @property {string | Record<string, any>} [result]
|
|
202
|
+
* @property {'started' | 'finished'} [toolState]
|
|
203
|
+
* @property {string} [toolCallId]
|
|
202
204
|
* @property {string[]} [paths]
|
|
203
205
|
* @property {number} [iteration]
|
|
204
206
|
* @property {string} [path]
|
|
@@ -211,6 +213,15 @@
|
|
|
211
213
|
* @property {string | null} assembledContext
|
|
212
214
|
*/
|
|
213
215
|
|
|
216
|
+
/**
|
|
217
|
+
* @typedef {object} AugmentQueryResult
|
|
218
|
+
* @property {{ path: string; content: string }[]} files
|
|
219
|
+
* @property {string[]} paths
|
|
220
|
+
* @property {string} reviewPrompt
|
|
221
|
+
* @property {string} apiPrompt
|
|
222
|
+
* @property {string | null} assembledContext
|
|
223
|
+
*/
|
|
224
|
+
|
|
214
225
|
/**
|
|
215
226
|
* @typedef {object} IngestOptions
|
|
216
227
|
* @property {string} [updatedAt]
|
|
@@ -235,10 +246,18 @@
|
|
|
235
246
|
* @property {string} toolCallId
|
|
236
247
|
*/
|
|
237
248
|
|
|
249
|
+
/**
|
|
250
|
+
* @typedef {object} ToolCallEventMeta
|
|
251
|
+
* @property {'started' | 'finished'} status
|
|
252
|
+
* @property {string} toolCallId
|
|
253
|
+
* @property {number} iteration
|
|
254
|
+
* @property {boolean} [terminal]
|
|
255
|
+
*/
|
|
256
|
+
|
|
238
257
|
/**
|
|
239
258
|
* @typedef {object} ToolLoopResult
|
|
240
259
|
* @property {string} textResponse
|
|
241
|
-
* @property {{ name: string; arguments: Record<string, any
|
|
260
|
+
* @property {{ name: string; arguments: Record<string, any>; result?: string } | null} terminalToolResult
|
|
242
261
|
* @property {LLMMessage[]} messages
|
|
243
262
|
* @property {number} iterations
|
|
244
263
|
* @property {ToolCallLogEntry[]} toolCallLog
|
|
@@ -255,10 +274,11 @@
|
|
|
255
274
|
* @property {number} [maxIterations]
|
|
256
275
|
* @property {number} [maxOutputTokens]
|
|
257
276
|
* @property {number} [temperature]
|
|
258
|
-
* @property {((name: string, args: Record<string, any>, result: string) => void) | null} [onToolCall]
|
|
277
|
+
* @property {((name: string, args: Record<string, any>, result: string | null, meta: ToolCallEventMeta) => void) | null} [onToolCall]
|
|
259
278
|
* @property {((text: string, iteration: number) => void) | null} [onModelText]
|
|
260
279
|
* @property {((chunk: string, iteration: number) => void) | null} [onReasoning]
|
|
261
280
|
* @property {AbortSignal | null} [signal]
|
|
281
|
+
* @property {boolean} [executeTerminalTool]
|
|
262
282
|
*/
|
|
263
283
|
|
|
264
284
|
/**
|
|
@@ -267,6 +287,7 @@
|
|
|
267
287
|
* @property {(existing: string | null, incoming: string, path: string) => string} [mergeWithExisting]
|
|
268
288
|
* @property {(path: string) => Promise<void>} [refreshIndex]
|
|
269
289
|
* @property {(path: string, before: string, after: string) => void} [onWrite]
|
|
290
|
+
* @property {string} [updatedAt]
|
|
270
291
|
*/
|
|
271
292
|
|
|
272
293
|
/**
|
|
@@ -277,6 +298,7 @@
|
|
|
277
298
|
* @typedef {object} StorageBackend
|
|
278
299
|
* @property {() => Promise<void>} init
|
|
279
300
|
* @property {(path: string) => Promise<string | null>} read
|
|
301
|
+
* @property {(path: string) => Promise<string | null>} [resolvePath]
|
|
280
302
|
* @property {(path: string, content: string) => Promise<void>} write
|
|
281
303
|
* @property {(path: string) => Promise<void>} delete
|
|
282
304
|
* @property {(path: string) => Promise<boolean>} exists
|
|
@@ -291,6 +313,7 @@
|
|
|
291
313
|
/**
|
|
292
314
|
* @typedef {object} StorageFacade
|
|
293
315
|
* @property {(path: string) => Promise<string | null>} read
|
|
316
|
+
* @property {(path: string) => Promise<string | null>} [resolvePath]
|
|
294
317
|
* @property {(path: string, content: string) => Promise<void>} write
|
|
295
318
|
* @property {(path: string) => Promise<void>} delete
|
|
296
319
|
* @property {(path: string) => Promise<boolean>} exists
|
|
@@ -311,6 +334,10 @@
|
|
|
311
334
|
* @property {string} [model]
|
|
312
335
|
* @property {'openai' | 'anthropic' | 'tinfoil' | 'custom' | string} [provider]
|
|
313
336
|
* @property {Record<string, string>} [headers]
|
|
337
|
+
* @property {string} [enclaveURL]
|
|
338
|
+
* @property {string} [configRepo]
|
|
339
|
+
* @property {string} [attestationBundleURL]
|
|
340
|
+
* @property {'ehbp' | 'tls'} [transport]
|
|
314
341
|
*/
|
|
315
342
|
|
|
316
343
|
/**
|
|
@@ -322,7 +349,7 @@
|
|
|
322
349
|
* @property {string} [storagePath]
|
|
323
350
|
* @property {(event: ProgressEvent) => void} [onProgress]
|
|
324
351
|
* @property {(event: ProgressEvent) => void} [onCompactProgress]
|
|
325
|
-
* @property {(name: string, args: Record<string, any>, result: string) => void} [onToolCall]
|
|
352
|
+
* @property {(name: string, args: Record<string, any>, result: string | null, meta: ToolCallEventMeta) => void} [onToolCall]
|
|
326
353
|
* @property {(text: string) => void} [onModelText]
|
|
327
354
|
*/
|
|
328
355
|
|
|
@@ -341,6 +368,104 @@
|
|
|
341
368
|
* @property {string | null} updatedAt
|
|
342
369
|
*/
|
|
343
370
|
|
|
371
|
+
/**
|
|
372
|
+
* @typedef {object} MemoryImportConversation
|
|
373
|
+
* @property {string | null} [title]
|
|
374
|
+
* @property {Message[]} messages
|
|
375
|
+
* @property {string | number | null} [updatedAt]
|
|
376
|
+
* @property {'conversation' | 'document'} [mode]
|
|
377
|
+
*/
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* @typedef {'auto' | 'normalized' | 'oa-fastchat' | 'chatgpt' | 'messages' | 'transcript' | 'markdown'} ImportFormat
|
|
381
|
+
*/
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @typedef {object} ImportProgressEvent
|
|
385
|
+
* @property {'start' | 'item_start' | 'item_complete' | 'complete'} stage
|
|
386
|
+
* @property {number} totalItems
|
|
387
|
+
* @property {number} [itemIndex]
|
|
388
|
+
* @property {string | null} [itemTitle]
|
|
389
|
+
* @property {'processed' | 'skipped' | 'error'} [itemStatus]
|
|
390
|
+
* @property {string | null} [itemError]
|
|
391
|
+
*/
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* @typedef {object} ImportDataOptions
|
|
395
|
+
* @property {ImportFormat} [format]
|
|
396
|
+
* @property {string} [sourceName]
|
|
397
|
+
* @property {string} [sessionId]
|
|
398
|
+
* @property {string} [sessionTitle]
|
|
399
|
+
* @property {'conversation' | 'document'} [mode]
|
|
400
|
+
* @property {(event: ImportProgressEvent) => void} [onProgress]
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* @typedef {object} ImportDataItemResult
|
|
405
|
+
* @property {string | null} title
|
|
406
|
+
* @property {string | null} updatedAt
|
|
407
|
+
* @property {'processed' | 'skipped' | 'error'} status
|
|
408
|
+
* @property {number} writeCalls
|
|
409
|
+
* @property {string} [error]
|
|
410
|
+
*/
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @typedef {object} ImportDataResult
|
|
414
|
+
* @property {number} totalItems
|
|
415
|
+
* @property {number} imported
|
|
416
|
+
* @property {number} skipped
|
|
417
|
+
* @property {number} errors
|
|
418
|
+
* @property {number} totalWriteCalls
|
|
419
|
+
* @property {string | null} authError
|
|
420
|
+
* @property {ImportDataItemResult[]} results
|
|
421
|
+
*/
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* @typedef {object} OmfMemoryItem
|
|
425
|
+
* @property {string} content
|
|
426
|
+
* @property {string} [category]
|
|
427
|
+
* @property {string[]} [tags]
|
|
428
|
+
* @property {'active' | 'archived' | 'expired'} [status]
|
|
429
|
+
* @property {string} [created_at]
|
|
430
|
+
* @property {string} [updated_at]
|
|
431
|
+
* @property {string} [expires_at]
|
|
432
|
+
* @property {Record<string, any>} [extensions]
|
|
433
|
+
*/
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @typedef {object} OmfDocument
|
|
437
|
+
* @property {string} omf
|
|
438
|
+
* @property {string} exported_at
|
|
439
|
+
* @property {{ app?: string }} [source]
|
|
440
|
+
* @property {OmfMemoryItem[]} memories
|
|
441
|
+
*/
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* @typedef {object} OmfImportOptions
|
|
445
|
+
* @property {boolean} [includeArchived]
|
|
446
|
+
*/
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* @typedef {object} OmfImportPreview
|
|
450
|
+
* @property {number} total
|
|
451
|
+
* @property {number} filtered
|
|
452
|
+
* @property {number} toImport
|
|
453
|
+
* @property {number} duplicates
|
|
454
|
+
* @property {number} newFiles
|
|
455
|
+
* @property {number} existingFiles
|
|
456
|
+
* @property {Record<string, { new: number, duplicate: number, document?: boolean }>} byFile
|
|
457
|
+
*/
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* @typedef {object} OmfImportResult
|
|
461
|
+
* @property {number} total
|
|
462
|
+
* @property {number} imported
|
|
463
|
+
* @property {number} duplicates
|
|
464
|
+
* @property {number} skipped
|
|
465
|
+
* @property {number} filesWritten
|
|
466
|
+
* @property {string[]} errors
|
|
467
|
+
*/
|
|
468
|
+
|
|
344
469
|
/**
|
|
345
470
|
* @typedef {object} SessionSummary
|
|
346
471
|
* @property {string} id
|
|
@@ -370,8 +495,14 @@
|
|
|
370
495
|
* @typedef {object} MemoryBank
|
|
371
496
|
* @property {() => Promise<void>} init
|
|
372
497
|
* @property {(query: string, conversationText?: string) => Promise<RetrievalResult | null>} retrieve
|
|
498
|
+
* @property {(query: string, conversationText?: string) => Promise<AugmentQueryResult | null>} augmentQuery
|
|
373
499
|
* @property {(messages: Message[], options?: IngestOptions) => Promise<IngestResult>} ingest
|
|
500
|
+
* @property {(input: string | unknown | MemoryImportConversation | MemoryImportConversation[] | Array<{ path: string, content: string }>, options?: ImportDataOptions) => Promise<ImportDataResult>} importData
|
|
501
|
+
* @property {() => Promise<OmfDocument>} exportOmf
|
|
502
|
+
* @property {(doc: OmfDocument, options?: OmfImportOptions) => Promise<OmfImportPreview>} previewOmfImport
|
|
503
|
+
* @property {(doc: OmfDocument, options?: OmfImportOptions) => Promise<OmfImportResult>} importOmf
|
|
374
504
|
* @property {() => Promise<{filesChanged: number, filesTotal: number} | undefined>} compact
|
|
505
|
+
* @property {(query: string, options?: {deep?: boolean, mode?: string}) => Promise<{status: string, deleteCalls: number, writes: Array<any>}>} [deleteContent]
|
|
375
506
|
* @property {StorageFacade} storage
|
|
376
507
|
* @property {() => Promise<string>} serialize
|
|
377
508
|
* @property {() => Promise<Uint8Array>} toZip
|