@anuma/sdk 6.2.0 → 6.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/dist/expo/{chunk-NH5VY3G7.mjs → chunk-PBCULYOW.mjs} +21 -1
- package/dist/expo/index.cjs +198 -74
- package/dist/expo/index.d.mts +136 -3
- package/dist/expo/index.d.ts +136 -3
- package/dist/expo/index.mjs +163 -67
- package/dist/expo/{recall-ZIKIYARO.mjs → recall-UVM2366D.mjs} +1 -1
- package/dist/react/{chunk-EMVLDEPB.mjs → chunk-TI3UVQPF.mjs} +21 -1
- package/dist/react/index.cjs +198 -74
- package/dist/react/index.d.mts +136 -3
- package/dist/react/index.d.ts +136 -3
- package/dist/react/index.mjs +163 -67
- package/dist/react/{recall-B7POS7NA.mjs → recall-PCM7H5TA.mjs} +1 -1
- package/dist/server/{chunk-6JS7SY6A.mjs → chunk-S5WEN7TE.mjs} +21 -1
- package/dist/server/index.cjs +198 -74
- package/dist/server/index.d.mts +136 -3
- package/dist/server/index.d.ts +136 -3
- package/dist/server/index.mjs +163 -67
- package/dist/server/{recall-IM6RLRI6.mjs → recall-BQSCJBGI.mjs} +1 -1
- package/package.json +1 -1
package/dist/expo/index.d.ts
CHANGED
|
@@ -4661,6 +4661,10 @@ declare class VaultMemory extends Model {
|
|
|
4661
4661
|
/** Unix ms of the last `topics` write. Separate from `updated_at`, which every
|
|
4662
4662
|
* topic writer pins on purpose (recall recency) — see the schema note. */
|
|
4663
4663
|
topicsUpdatedAt: number | null;
|
|
4664
|
+
/** The photo(s) a SERVER-EXTRACTED memory came from — JSON
|
|
4665
|
+
* `[{feed_item_id, object_key}]`, exactly the shape
|
|
4666
|
+
* GET /api/memories/published returns. Null on anything not from a photo. */
|
|
4667
|
+
media: string | null;
|
|
4664
4668
|
/** Unix ms of the last LLM topic-extraction pass. Null = never extracted
|
|
4665
4669
|
* standalone (linked legacy rows are grandfathered as extracted).
|
|
4666
4670
|
* DEPRECATED (v42) — subsumed by `topics_updated_at`; see the schema note. */
|
|
@@ -6045,8 +6049,16 @@ interface StoredVaultMemory {
|
|
|
6045
6049
|
sourceChunkIds: string[] | null;
|
|
6046
6050
|
/** Times this fact has been re-observed (for ranking + UX badges). */
|
|
6047
6051
|
proofCount: number | null;
|
|
6048
|
-
/** How the memory was created: manual | auto-extracted | capsule. */
|
|
6052
|
+
/** How the memory was created: manual | auto-extracted | capsule | photo. */
|
|
6049
6053
|
source: string | null;
|
|
6054
|
+
/** The photo(s) a SERVER-EXTRACTED memory was read out of. Null on every
|
|
6055
|
+
* memory that did not come from a photo. See {@link PhotoMediaRef}.
|
|
6056
|
+
*
|
|
6057
|
+
* OPTIONAL rather than required: every read path sets it (the row mappers
|
|
6058
|
+
* always call parseMedia), but making it required would be a compile-break
|
|
6059
|
+
* for any caller that CONSTRUCTS a StoredVaultMemory — fixtures, mocks, and
|
|
6060
|
+
* anything downstream — for a field that is null on all but photo rows. */
|
|
6061
|
+
media?: PhotoMediaRef[] | null;
|
|
6050
6062
|
/** W6 temporal lane — Unix ms when the event occurred (point/start of range). */
|
|
6051
6063
|
eventTimeStart: number | null;
|
|
6052
6064
|
/** W6 temporal lane — Unix ms when the event ended (range only). */
|
|
@@ -6105,6 +6117,26 @@ interface StoredVaultMemory {
|
|
|
6105
6117
|
updatedAt: Date;
|
|
6106
6118
|
isDeleted: boolean;
|
|
6107
6119
|
}
|
|
6120
|
+
/**
|
|
6121
|
+
* A photo a server-extracted memory came from, as
|
|
6122
|
+
* GET /api/memories/published returns it in `media[]`.
|
|
6123
|
+
*
|
|
6124
|
+
* Both identifiers travel because both are needed: `feedItemId` is the server's
|
|
6125
|
+
* handle for the photo, and `objectKey` is what a client turns into a CDN URL
|
|
6126
|
+
* without another round-trip per memory.
|
|
6127
|
+
*/
|
|
6128
|
+
interface PhotoMediaRef {
|
|
6129
|
+
feedItemId: number;
|
|
6130
|
+
objectKey: string | null;
|
|
6131
|
+
}
|
|
6132
|
+
/**
|
|
6133
|
+
* Decode the stored `media` column. Returns null for "no photo behind this
|
|
6134
|
+
* memory" (the column is null on every non-photo row) and tolerates a corrupt
|
|
6135
|
+
* or unexpected payload by reading it as null too — a memory whose photo
|
|
6136
|
+
* reference cannot be parsed is still a perfectly good memory, and losing the
|
|
6137
|
+
* thumbnail is a better failure than losing the row.
|
|
6138
|
+
*/
|
|
6139
|
+
declare function parseMedia(value: unknown): PhotoMediaRef[] | null;
|
|
6108
6140
|
interface CreateVaultMemoryOptions {
|
|
6109
6141
|
content: string;
|
|
6110
6142
|
/** Scope for the memory. Defaults to "private" if omitted. */
|
|
@@ -6546,6 +6578,95 @@ declare function hardDeleteDecayedOp(ctx: VaultMemoryOperationsContext, id: stri
|
|
|
6546
6578
|
}): Promise<boolean>;
|
|
6547
6579
|
declare function updateVaultMemoryEmbeddingOp(ctx: VaultMemoryOperationsContext, id: string, embedding: string, embeddingModel: string): Promise<boolean>;
|
|
6548
6580
|
|
|
6581
|
+
/**
|
|
6582
|
+
* Ingest server-extracted photo memories into the local vault.
|
|
6583
|
+
*
|
|
6584
|
+
* A photo uploaded to People Nearby is read by the server, which extracts
|
|
6585
|
+
* durable facts about the user, embeds them and publishes them
|
|
6586
|
+
* (anuma-ai/nearby#114). Until those rows reach the device they exist only
|
|
6587
|
+
* server-side: the user's own assistant cannot recall them, and no screen can
|
|
6588
|
+
* show them — so the "visible and deletable" promise the design makes is not
|
|
6589
|
+
* kept. This is the path that brings them home.
|
|
6590
|
+
*
|
|
6591
|
+
* Three things about the shape of this, each of which is load-bearing:
|
|
6592
|
+
*
|
|
6593
|
+
* 1. **It takes rows; it does not fetch them.** The publish reconciler already
|
|
6594
|
+
* calls `listPublished()` on every pass and gets `text`, `media[]`,
|
|
6595
|
+
* `event_time` and `user_authored` back. Ingest consumes that response. No
|
|
6596
|
+
* new endpoint, no second network call, no change to nearby's API.
|
|
6597
|
+
*
|
|
6598
|
+
* 2. **The vault row's id IS the server's `memory_id`.** That is what makes a
|
|
6599
|
+
* revoke addressable: the reconciler's ledger, its published set and its
|
|
6600
|
+
* `toRevoke` list are all keyed on that id, so a locally-minted id would
|
|
6601
|
+
* leave the user with a switch that cannot reach the row it appears to
|
|
6602
|
+
* control. It is also what makes ingest idempotent for free — a second pass
|
|
6603
|
+
* sees the id already present and writes nothing.
|
|
6604
|
+
*
|
|
6605
|
+
* 3. **These rows never go through `retain()`.** That path is for facts being
|
|
6606
|
+
* learned on-device: it dedupes and merges candidates against local rows and
|
|
6607
|
+
* mints its own ids, both of which would break (2). A photo memory is not a
|
|
6608
|
+
* candidate to be reconciled against the vault — it is an already-decided
|
|
6609
|
+
* fact the server has published.
|
|
6610
|
+
*
|
|
6611
|
+
* The rows are written `visibility: "public"` because they genuinely ARE
|
|
6612
|
+
* published — the reconciler reads local visibility as the user's intent, and
|
|
6613
|
+
* anything else would make it immediately revoke a memory the user never turned
|
|
6614
|
+
* off. They carry `source: SOURCE_PHOTO`, which is what exempts them from
|
|
6615
|
+
* decay's auto-archive; see the note there for why archiving one would silently
|
|
6616
|
+
* unpublish it.
|
|
6617
|
+
*
|
|
6618
|
+
* No embedding is computed here. `searchTool`'s un-embedded lane embeds any row
|
|
6619
|
+
* lacking a vector at search time, uses it in that same search and persists it
|
|
6620
|
+
* via `updateVaultMemoryEmbeddingOp` — so a row ingested without one is picked
|
|
6621
|
+
* up on first recall rather than costing an embedding call at ingest.
|
|
6622
|
+
*/
|
|
6623
|
+
|
|
6624
|
+
/**
|
|
6625
|
+
* One row of `GET /api/memories/published`, narrowed to what ingest needs.
|
|
6626
|
+
*
|
|
6627
|
+
* Deliberately structural rather than an import from the transport client: this
|
|
6628
|
+
* op is in the SDK and the two hand-written nearby clients live in the app, so
|
|
6629
|
+
* a shared nominal type would drag one across a package boundary for no gain.
|
|
6630
|
+
*/
|
|
6631
|
+
interface PublishedPhotoMemory {
|
|
6632
|
+
/** The server-minted memory id. `photo:<feedItemID>:fact:NN` or `:caption`. */
|
|
6633
|
+
memoryId: string;
|
|
6634
|
+
/** The projected fact text. */
|
|
6635
|
+
text: string;
|
|
6636
|
+
/** The photo(s) this fact was read out of. */
|
|
6637
|
+
media?: PhotoMediaRef[] | null;
|
|
6638
|
+
/** When the event in the memory happened, if the server knows. */
|
|
6639
|
+
eventTime?: {
|
|
6640
|
+
start: number | null;
|
|
6641
|
+
end: number | null;
|
|
6642
|
+
kind: "point" | "range" | "ongoing" | null;
|
|
6643
|
+
} | null;
|
|
6644
|
+
/** True when the text is the user's own words (a kept caption). */
|
|
6645
|
+
userAuthored?: boolean;
|
|
6646
|
+
}
|
|
6647
|
+
/** What one ingest pass did, for the caller's logs and tests. */
|
|
6648
|
+
interface PhotoIngestResult {
|
|
6649
|
+
/** Rows newly written to the vault. */
|
|
6650
|
+
inserted: number;
|
|
6651
|
+
/** Rows already present, left untouched. */
|
|
6652
|
+
skipped: number;
|
|
6653
|
+
}
|
|
6654
|
+
/**
|
|
6655
|
+
* Write the published photo memories this vault does not already have.
|
|
6656
|
+
*
|
|
6657
|
+
* Idempotent on `memoryId`: a row whose id is already in the vault is counted as
|
|
6658
|
+
* skipped and NOT rewritten, even when the server's text has since changed.
|
|
6659
|
+
* That is deliberate — the local row is the user's copy, they may have edited
|
|
6660
|
+
* it, and silently overwriting an edit to match the server would be the same
|
|
6661
|
+
* class of bug as publishing a version the user has since changed. Re-ingesting
|
|
6662
|
+
* changed text is a follow-up that needs a merge decision, not a clobber.
|
|
6663
|
+
*
|
|
6664
|
+
* Non-`photo:` ids are ignored: everything else in the published set is a
|
|
6665
|
+
* client-published memory that by definition already lives in this vault (or in
|
|
6666
|
+
* another device's, which is not ours to recreate).
|
|
6667
|
+
*/
|
|
6668
|
+
declare function ingestPublishedPhotoMemoriesOp(ctx: VaultMemoryOperationsContext, rows: PublishedPhotoMemory[]): Promise<PhotoIngestResult>;
|
|
6669
|
+
|
|
6549
6670
|
/**
|
|
6550
6671
|
* Queue Types
|
|
6551
6672
|
*
|
|
@@ -7045,6 +7166,15 @@ declare function createChunkVectorCache(maxSize?: number): ChunkVectorCache;
|
|
|
7045
7166
|
* shared purge buffer for every row, so an already-archived manual memory is
|
|
7046
7167
|
* still deleted after the window (the archived check runs before the manual
|
|
7047
7168
|
* short-circuit by design).
|
|
7169
|
+
*
|
|
7170
|
+
* `source === "photo"` (server-extracted photo memories) is protected the same
|
|
7171
|
+
* way, and for a sharper reason than curation: those rows are PUBLISHED, and
|
|
7172
|
+
* auto-archiving one would silently un-publish it. Archived rows drop out of the
|
|
7173
|
+
* default vault read, the publish reconciler builds its desired set from that
|
|
7174
|
+
* read, and anything it previously adopted but no longer sees goes into
|
|
7175
|
+
* `toRevoke` — so an age-archive at the medium TTL would revoke a memory from
|
|
7176
|
+
* the server that the user never switched off. Revoking is the user's decision
|
|
7177
|
+
* and has exactly one entry point: the publish switch.
|
|
7048
7178
|
*/
|
|
7049
7179
|
/** The verdict for a single memory. */
|
|
7050
7180
|
type DecayVerdict = "keep" | "archive" | "delete";
|
|
@@ -9195,8 +9325,11 @@ declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageR
|
|
|
9195
9325
|
* unreadable flag would fail open. Existing rows stay NULL (= legacy,
|
|
9196
9326
|
* unknown provenance, embedded as before) with no backfill, matching the v37
|
|
9197
9327
|
* read-time-fallback precedent
|
|
9328
|
+
* - v45: Added `media` to memory_vault — the photo(s) a server-extracted
|
|
9329
|
+
* memory came from, as JSON `[{feed_item_id, object_key}]`. Null on every
|
|
9330
|
+
* row that did not come from a photo, which is all of them before this
|
|
9198
9331
|
*/
|
|
9199
|
-
declare const SDK_SCHEMA_VERSION =
|
|
9332
|
+
declare const SDK_SCHEMA_VERSION = 45;
|
|
9200
9333
|
/**
|
|
9201
9334
|
* Combined WatermelonDB schema for all SDK storage modules.
|
|
9202
9335
|
*
|
|
@@ -9808,4 +9941,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
|
|
|
9808
9941
|
*/
|
|
9809
9942
|
declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
|
|
9810
9943
|
|
|
9811
|
-
export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type SynthesizeProfileOptions, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
|
|
9944
|
+
export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type SynthesizeProfileOptions, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, parseMedia, preEmbedVaultMemories, quantizeEmbedding, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
|
package/dist/expo/index.mjs
CHANGED
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
embedMessage,
|
|
54
54
|
encryptField,
|
|
55
55
|
encryptJsonField,
|
|
56
|
+
encryptVaultMemoryContent,
|
|
56
57
|
extractAssistantText,
|
|
57
58
|
extractUserMessageFromMessages,
|
|
58
59
|
finalizeThoughtProcess,
|
|
@@ -90,6 +91,7 @@ import {
|
|
|
90
91
|
makeSyntheticStoredMessage,
|
|
91
92
|
onClearAllEncryptionState,
|
|
92
93
|
onKeyAvailable,
|
|
94
|
+
parseMedia,
|
|
93
95
|
postApiV1CreditsPurchase,
|
|
94
96
|
preEmbedVaultMemories,
|
|
95
97
|
prepareVaultCandidates,
|
|
@@ -121,7 +123,7 @@ import {
|
|
|
121
123
|
upsertMessageOp,
|
|
122
124
|
useEncryption,
|
|
123
125
|
vaultMemoryToStored
|
|
124
|
-
} from "./chunk-
|
|
126
|
+
} from "./chunk-PBCULYOW.mjs";
|
|
125
127
|
import {
|
|
126
128
|
PII_PATTERNS,
|
|
127
129
|
PiiRedactor,
|
|
@@ -5637,6 +5639,9 @@ __decorateClass([
|
|
|
5637
5639
|
__decorateClass([
|
|
5638
5640
|
field3("topics_updated_at")
|
|
5639
5641
|
], VaultMemory.prototype, "topicsUpdatedAt", 2);
|
|
5642
|
+
__decorateClass([
|
|
5643
|
+
field3("media")
|
|
5644
|
+
], VaultMemory.prototype, "media", 2);
|
|
5640
5645
|
__decorateClass([
|
|
5641
5646
|
field3("topics_extracted_at")
|
|
5642
5647
|
], VaultMemory.prototype, "topicsExtractedAt", 2);
|
|
@@ -5684,6 +5689,133 @@ __decorateClass([
|
|
|
5684
5689
|
field3("is_deleted")
|
|
5685
5690
|
], VaultMemory.prototype, "isDeleted", 2);
|
|
5686
5691
|
|
|
5692
|
+
// src/lib/memory/decay.ts
|
|
5693
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
5694
|
+
var SHORT_TTL_MS = 30 * DAY_MS;
|
|
5695
|
+
var MEDIUM_TTL_MS = 180 * DAY_MS;
|
|
5696
|
+
var SOURCE_PHOTO = "photo";
|
|
5697
|
+
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
5698
|
+
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
|
|
5699
|
+
var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
|
|
5700
|
+
var DEFAULT_DECAY_POLICY = {
|
|
5701
|
+
ttlByType: {
|
|
5702
|
+
identity: NEVER_TTL_MS,
|
|
5703
|
+
preference: NEVER_TTL_MS,
|
|
5704
|
+
relationship: NEVER_TTL_MS,
|
|
5705
|
+
constraint: NEVER_TTL_MS,
|
|
5706
|
+
plan: SHORT_TTL_MS,
|
|
5707
|
+
ongoing_context: SHORT_TTL_MS,
|
|
5708
|
+
other: MEDIUM_TTL_MS
|
|
5709
|
+
},
|
|
5710
|
+
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
5711
|
+
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
5712
|
+
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
5713
|
+
};
|
|
5714
|
+
function resolvePolicy(policy) {
|
|
5715
|
+
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
5716
|
+
return {
|
|
5717
|
+
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
5718
|
+
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
5719
|
+
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
5720
|
+
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
5721
|
+
};
|
|
5722
|
+
}
|
|
5723
|
+
function ttlForType(factType, policy) {
|
|
5724
|
+
const resolved = resolvePolicy(policy);
|
|
5725
|
+
if (factType === null) return resolved.fallbackTtlMs;
|
|
5726
|
+
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
5727
|
+
}
|
|
5728
|
+
function isTimeSensitiveType(factType) {
|
|
5729
|
+
return factType === "plan" || factType === "ongoing_context";
|
|
5730
|
+
}
|
|
5731
|
+
function hasFiniteTimestamps(m, now) {
|
|
5732
|
+
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
5733
|
+
}
|
|
5734
|
+
function classifyDecay(m, now, policy) {
|
|
5735
|
+
const resolved = resolvePolicy(policy);
|
|
5736
|
+
if (!hasFiniteTimestamps(m, now)) {
|
|
5737
|
+
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
5738
|
+
now,
|
|
5739
|
+
updatedAt: m.updatedAt,
|
|
5740
|
+
archivedAt: m.archivedAt,
|
|
5741
|
+
factType: m.factType
|
|
5742
|
+
});
|
|
5743
|
+
return "keep";
|
|
5744
|
+
}
|
|
5745
|
+
if (m.archivedAt !== null) {
|
|
5746
|
+
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
5747
|
+
}
|
|
5748
|
+
if (m.source === "manual" || m.source === SOURCE_PHOTO) return "keep";
|
|
5749
|
+
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
5750
|
+
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
5751
|
+
if (m.eventTimeEnd >= now) return "keep";
|
|
5752
|
+
}
|
|
5753
|
+
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
5754
|
+
return "keep";
|
|
5755
|
+
}
|
|
5756
|
+
|
|
5757
|
+
// src/lib/db/memoryVault/photoIngest.ts
|
|
5758
|
+
var PHOTO_MEMORY_ID_PREFIX = "photo:";
|
|
5759
|
+
async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
5760
|
+
const byId = /* @__PURE__ */ new Map();
|
|
5761
|
+
for (const r of rows) {
|
|
5762
|
+
if (typeof r.memoryId !== "string" || !r.memoryId.startsWith(PHOTO_MEMORY_ID_PREFIX)) continue;
|
|
5763
|
+
if (!byId.has(r.memoryId)) byId.set(r.memoryId, r);
|
|
5764
|
+
}
|
|
5765
|
+
const photoRows = [...byId.values()];
|
|
5766
|
+
if (photoRows.length === 0) return { inserted: 0, skipped: 0 };
|
|
5767
|
+
const known = await ctx.vaultMemoryCollection.query().fetchIds().then((ids) => new Set(ids));
|
|
5768
|
+
const candidates = photoRows.filter((r) => !known.has(r.memoryId));
|
|
5769
|
+
if (candidates.length === 0) return { inserted: 0, skipped: photoRows.length };
|
|
5770
|
+
const fresh = candidates;
|
|
5771
|
+
const contents = await Promise.all(
|
|
5772
|
+
fresh.map(async (r) => {
|
|
5773
|
+
if (ctx.walletAddress && ctx.signMessage) {
|
|
5774
|
+
return encryptVaultMemoryContent(
|
|
5775
|
+
r.text,
|
|
5776
|
+
ctx.walletAddress,
|
|
5777
|
+
ctx.signMessage,
|
|
5778
|
+
ctx.embeddedWalletSigner
|
|
5779
|
+
);
|
|
5780
|
+
}
|
|
5781
|
+
return r.text;
|
|
5782
|
+
})
|
|
5783
|
+
);
|
|
5784
|
+
const now = Date.now();
|
|
5785
|
+
let inserted = 0;
|
|
5786
|
+
await ctx.database.write(async () => {
|
|
5787
|
+
const present = new Set(await ctx.vaultMemoryCollection.query().fetchIds());
|
|
5788
|
+
const writable = fresh.map((row, i) => ({ row, content: contents[i] })).filter(({ row }) => !present.has(row.memoryId));
|
|
5789
|
+
inserted = writable.length;
|
|
5790
|
+
if (writable.length === 0) return;
|
|
5791
|
+
const prepared = writable.map(
|
|
5792
|
+
({ row, content }) => ctx.vaultMemoryCollection.prepareCreate((record) => {
|
|
5793
|
+
record._raw.id = row.memoryId;
|
|
5794
|
+
record._setRaw("content", content);
|
|
5795
|
+
record._setRaw("scope", "private");
|
|
5796
|
+
record._setRaw("folder_id", null);
|
|
5797
|
+
record._setRaw("user_id", ctx.userId ?? null);
|
|
5798
|
+
record._setRaw("is_deleted", false);
|
|
5799
|
+
record._setRaw("proof_count", 1);
|
|
5800
|
+
record._setRaw("source", SOURCE_PHOTO);
|
|
5801
|
+
record._setRaw(
|
|
5802
|
+
"media",
|
|
5803
|
+
row.media && row.media.length > 0 ? JSON.stringify(row.media) : null
|
|
5804
|
+
);
|
|
5805
|
+
record._setRaw("visibility", "public");
|
|
5806
|
+
record._setRaw("published_at", now);
|
|
5807
|
+
if (row.eventTime) {
|
|
5808
|
+
record._setRaw("event_time_start", row.eventTime.start ?? null);
|
|
5809
|
+
record._setRaw("event_time_end", row.eventTime.end ?? null);
|
|
5810
|
+
record._setRaw("event_time_kind", row.eventTime.kind ?? null);
|
|
5811
|
+
}
|
|
5812
|
+
})
|
|
5813
|
+
);
|
|
5814
|
+
await ctx.database.batch(...prepared);
|
|
5815
|
+
});
|
|
5816
|
+
return { inserted, skipped: photoRows.length - inserted };
|
|
5817
|
+
}
|
|
5818
|
+
|
|
5687
5819
|
// src/lib/db/queue/manager.ts
|
|
5688
5820
|
import { v7 as uuidv72 } from "uuid";
|
|
5689
5821
|
var MAX_OPERATIONS_PER_WALLET = 1e3;
|
|
@@ -7439,70 +7571,6 @@ function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
|
|
|
7439
7571
|
return new LRUCache(maxSize);
|
|
7440
7572
|
}
|
|
7441
7573
|
|
|
7442
|
-
// src/lib/memory/decay.ts
|
|
7443
|
-
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
7444
|
-
var SHORT_TTL_MS = 30 * DAY_MS;
|
|
7445
|
-
var MEDIUM_TTL_MS = 180 * DAY_MS;
|
|
7446
|
-
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
7447
|
-
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
|
|
7448
|
-
var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
|
|
7449
|
-
var DEFAULT_DECAY_POLICY = {
|
|
7450
|
-
ttlByType: {
|
|
7451
|
-
identity: NEVER_TTL_MS,
|
|
7452
|
-
preference: NEVER_TTL_MS,
|
|
7453
|
-
relationship: NEVER_TTL_MS,
|
|
7454
|
-
constraint: NEVER_TTL_MS,
|
|
7455
|
-
plan: SHORT_TTL_MS,
|
|
7456
|
-
ongoing_context: SHORT_TTL_MS,
|
|
7457
|
-
other: MEDIUM_TTL_MS
|
|
7458
|
-
},
|
|
7459
|
-
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
7460
|
-
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
7461
|
-
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
7462
|
-
};
|
|
7463
|
-
function resolvePolicy(policy) {
|
|
7464
|
-
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
7465
|
-
return {
|
|
7466
|
-
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
7467
|
-
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
7468
|
-
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
7469
|
-
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
7470
|
-
};
|
|
7471
|
-
}
|
|
7472
|
-
function ttlForType(factType, policy) {
|
|
7473
|
-
const resolved = resolvePolicy(policy);
|
|
7474
|
-
if (factType === null) return resolved.fallbackTtlMs;
|
|
7475
|
-
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
7476
|
-
}
|
|
7477
|
-
function isTimeSensitiveType(factType) {
|
|
7478
|
-
return factType === "plan" || factType === "ongoing_context";
|
|
7479
|
-
}
|
|
7480
|
-
function hasFiniteTimestamps(m, now) {
|
|
7481
|
-
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
7482
|
-
}
|
|
7483
|
-
function classifyDecay(m, now, policy) {
|
|
7484
|
-
const resolved = resolvePolicy(policy);
|
|
7485
|
-
if (!hasFiniteTimestamps(m, now)) {
|
|
7486
|
-
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
7487
|
-
now,
|
|
7488
|
-
updatedAt: m.updatedAt,
|
|
7489
|
-
archivedAt: m.archivedAt,
|
|
7490
|
-
factType: m.factType
|
|
7491
|
-
});
|
|
7492
|
-
return "keep";
|
|
7493
|
-
}
|
|
7494
|
-
if (m.archivedAt !== null) {
|
|
7495
|
-
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
7496
|
-
}
|
|
7497
|
-
if (m.source === "manual") return "keep";
|
|
7498
|
-
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
7499
|
-
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
7500
|
-
if (m.eventTimeEnd >= now) return "keep";
|
|
7501
|
-
}
|
|
7502
|
-
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
7503
|
-
return "keep";
|
|
7504
|
-
}
|
|
7505
|
-
|
|
7506
7574
|
// src/lib/memory/decayClassifier.ts
|
|
7507
7575
|
var DEFAULT_MODEL2 = "inclusionai/ling-2.6-flash";
|
|
7508
7576
|
var DEFAULT_ATTEMPTS2 = 2;
|
|
@@ -7600,7 +7668,7 @@ function toDecayInput(c) {
|
|
|
7600
7668
|
};
|
|
7601
7669
|
}
|
|
7602
7670
|
function isBorderline(input) {
|
|
7603
|
-
if (input.source === "manual") return false;
|
|
7671
|
+
if (input.source === "manual" || input.source === SOURCE_PHOTO) return false;
|
|
7604
7672
|
if (input.trustTier === "quarantined") return false;
|
|
7605
7673
|
if (input.archivedAt !== null) return false;
|
|
7606
7674
|
if (input.factType === null || input.factType === "other") return true;
|
|
@@ -12258,7 +12326,7 @@ __decorateClass([
|
|
|
12258
12326
|
], VaultFolder.prototype, "context", 2);
|
|
12259
12327
|
|
|
12260
12328
|
// src/lib/db/schema.ts
|
|
12261
|
-
var SDK_SCHEMA_VERSION =
|
|
12329
|
+
var SDK_SCHEMA_VERSION = 45;
|
|
12262
12330
|
var sdkSchema = appSchema2({
|
|
12263
12331
|
version: SDK_SCHEMA_VERSION,
|
|
12264
12332
|
tables: [
|
|
@@ -12406,6 +12474,18 @@ var sdkSchema = appSchema2({
|
|
|
12406
12474
|
// paths key on `updated_at` — so without this a topic-only change would
|
|
12407
12475
|
// neither upload nor merge. Null = `topics` never written.
|
|
12408
12476
|
{ name: "topics_updated_at", type: "number", isOptional: true },
|
|
12477
|
+
// The photo(s) a SERVER-EXTRACTED memory was read out of, as a JSON
|
|
12478
|
+
// array of `{feed_item_id, object_key}` — exactly what
|
|
12479
|
+
// GET /api/memories/published returns in `media[]`. Enough to render the
|
|
12480
|
+
// source image without a second round-trip per memory.
|
|
12481
|
+
//
|
|
12482
|
+
// A JSON column rather than a join table: nothing on the client ever
|
|
12483
|
+
// queries BY photo (the only direction is memory -> render its image),
|
|
12484
|
+
// so a table would add a sync lane and a local-id space to serve a
|
|
12485
|
+
// question nobody asks. `topics` and `source_chunk_ids` set the
|
|
12486
|
+
// precedent for a list that is only ever read back whole. Null on
|
|
12487
|
+
// anything not extracted from a photo.
|
|
12488
|
+
{ name: "media", type: "string", isOptional: true },
|
|
12409
12489
|
// Unix ms of the last LLM topic-extraction pass over this memory's
|
|
12410
12490
|
// content. Null = never extracted standalone (legacy rows with entity
|
|
12411
12491
|
// links are grandfathered — see getMemoriesNeedingTopicExtractionOp).
|
|
@@ -13240,6 +13320,20 @@ var sdkMigrations = schemaMigrations2({
|
|
|
13240
13320
|
columns: [{ name: "origin", type: "string", isOptional: true }]
|
|
13241
13321
|
})
|
|
13242
13322
|
]
|
|
13323
|
+
},
|
|
13324
|
+
// v44 -> v45: `media` on memory_vault — the photo(s) a server-extracted
|
|
13325
|
+
// memory was read out of, as JSON `[{feed_item_id, object_key}]`, mirroring
|
|
13326
|
+
// the `media[]` that GET /api/memories/published already returns. Existing
|
|
13327
|
+
// rows keep NULL, which is the correct value for every memory that did not
|
|
13328
|
+
// come from a photo (i.e. all of them until photo ingest runs).
|
|
13329
|
+
{
|
|
13330
|
+
toVersion: 45,
|
|
13331
|
+
steps: [
|
|
13332
|
+
addColumns2({
|
|
13333
|
+
table: "memory_vault",
|
|
13334
|
+
columns: [{ name: "media", type: "string", isOptional: true }]
|
|
13335
|
+
})
|
|
13336
|
+
]
|
|
13243
13337
|
}
|
|
13244
13338
|
]
|
|
13245
13339
|
});
|
|
@@ -14706,12 +14800,14 @@ export {
|
|
|
14706
14800
|
getVaultMemoryOp,
|
|
14707
14801
|
hardDeleteDecayedOp,
|
|
14708
14802
|
hasEncryptionKey,
|
|
14803
|
+
ingestPublishedPhotoMemoriesOp,
|
|
14709
14804
|
injectionSignatureCatalog,
|
|
14710
14805
|
isPiiRedactor,
|
|
14711
14806
|
isRerankerAvailable,
|
|
14712
14807
|
moveMemoriesToFolderOp,
|
|
14713
14808
|
noopLogger,
|
|
14714
14809
|
onKeyAvailable,
|
|
14810
|
+
parseMedia,
|
|
14715
14811
|
preEmbedVaultMemories,
|
|
14716
14812
|
quantizeEmbedding,
|
|
14717
14813
|
queueManager,
|
|
@@ -2560,6 +2560,22 @@ async function decryptVaultMemoryFields(memory, address, signMessage, embeddedWa
|
|
|
2560
2560
|
};
|
|
2561
2561
|
}
|
|
2562
2562
|
|
|
2563
|
+
// src/lib/db/memoryVault/types.ts
|
|
2564
|
+
function parseMedia(value) {
|
|
2565
|
+
if (typeof value !== "string" || value === "") return null;
|
|
2566
|
+
try {
|
|
2567
|
+
const parsed = JSON.parse(value);
|
|
2568
|
+
if (!Array.isArray(parsed)) return null;
|
|
2569
|
+
const refs = parsed.filter((r) => typeof r === "object" && r !== null).map((r) => ({
|
|
2570
|
+
feedItemId: Number(r.feedItemId ?? r.feed_item_id),
|
|
2571
|
+
objectKey: r.objectKey ?? r.object_key ?? null
|
|
2572
|
+
})).filter((r) => Number.isFinite(r.feedItemId));
|
|
2573
|
+
return refs.length > 0 ? refs : null;
|
|
2574
|
+
} catch {
|
|
2575
|
+
return null;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2563
2579
|
// src/lib/db/memoryVault/operations.ts
|
|
2564
2580
|
function visibilityOrPrivate(value) {
|
|
2565
2581
|
return value === "public" ? value : "private";
|
|
@@ -2623,6 +2639,7 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
2623
2639
|
sourceChunkIds,
|
|
2624
2640
|
proofCount: memory.proofCount ?? null,
|
|
2625
2641
|
source: memory.source ?? null,
|
|
2642
|
+
media: parseMedia(memory.media),
|
|
2626
2643
|
eventTimeStart: memory.eventTimeStart ?? null,
|
|
2627
2644
|
eventTimeEnd: memory.eventTimeEnd ?? null,
|
|
2628
2645
|
eventTimeKind: memory.eventTimeKind ?? null,
|
|
@@ -2905,6 +2922,7 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
2905
2922
|
eventTimeKind: raw.event_time_kind ?? null,
|
|
2906
2923
|
// SQLite stores booleans as 0/1, LokiJS as true/false — coerce both.
|
|
2907
2924
|
topicsUserManaged: raw.topics_user_managed === true || raw.topics_user_managed === 1,
|
|
2925
|
+
media: parseMedia(raw.media),
|
|
2908
2926
|
topics: parseTopics(raw.topics),
|
|
2909
2927
|
topicsUpdatedAt: raw.topics_updated_at ?? null,
|
|
2910
2928
|
topicsExtractedAt: raw.topics_extracted_at ?? null,
|
|
@@ -6783,7 +6801,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
6783
6801
|
subQueries = decomp.subQueries;
|
|
6784
6802
|
}
|
|
6785
6803
|
}
|
|
6786
|
-
const { recall: recall2 } = await import("./recall-
|
|
6804
|
+
const { recall: recall2 } = await import("./recall-PCM7H5TA.mjs");
|
|
6787
6805
|
let recallDegraded = [];
|
|
6788
6806
|
const result = await recall2(
|
|
6789
6807
|
query,
|
|
@@ -7838,6 +7856,8 @@ export {
|
|
|
7838
7856
|
backfillMemoryEntityUserIdsOp,
|
|
7839
7857
|
getMemoriesByEntityNamesOp,
|
|
7840
7858
|
getEntitiesByMemoryIdsOp,
|
|
7859
|
+
encryptVaultMemoryContent,
|
|
7860
|
+
parseMedia,
|
|
7841
7861
|
vaultMemoryToStored,
|
|
7842
7862
|
createVaultMemoryOp,
|
|
7843
7863
|
createSupersedingMemoryOp,
|