@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.
@@ -103,8 +103,11 @@ import { ResultCallback } from '@nozbe/watermelondb/utils/fp/Result';
103
103
  * unreadable flag would fail open. Existing rows stay NULL (= legacy,
104
104
  * unknown provenance, embedded as before) with no backfill, matching the v37
105
105
  * read-time-fallback precedent
106
+ * - v45: Added `media` to memory_vault — the photo(s) a server-extracted
107
+ * memory came from, as JSON `[{feed_item_id, object_key}]`. Null on every
108
+ * row that did not come from a photo, which is all of them before this
106
109
  */
107
- declare const SDK_SCHEMA_VERSION = 44;
110
+ declare const SDK_SCHEMA_VERSION = 45;
108
111
  /**
109
112
  * Combined WatermelonDB schema for all SDK storage modules.
110
113
  *
@@ -4524,6 +4527,10 @@ declare class VaultMemory extends Model$1 {
4524
4527
  /** Unix ms of the last `topics` write. Separate from `updated_at`, which every
4525
4528
  * topic writer pins on purpose (recall recency) — see the schema note. */
4526
4529
  topicsUpdatedAt: number | null;
4530
+ /** The photo(s) a SERVER-EXTRACTED memory came from — JSON
4531
+ * `[{feed_item_id, object_key}]`, exactly the shape
4532
+ * GET /api/memories/published returns. Null on anything not from a photo. */
4533
+ media: string | null;
4527
4534
  /** Unix ms of the last LLM topic-extraction pass. Null = never extracted
4528
4535
  * standalone (linked legacy rows are grandfathered as extracted).
4529
4536
  * DEPRECATED (v42) — subsumed by `topics_updated_at`; see the schema note. */
@@ -5999,8 +6006,16 @@ interface StoredVaultMemory {
5999
6006
  sourceChunkIds: string[] | null;
6000
6007
  /** Times this fact has been re-observed (for ranking + UX badges). */
6001
6008
  proofCount: number | null;
6002
- /** How the memory was created: manual | auto-extracted | capsule. */
6009
+ /** How the memory was created: manual | auto-extracted | capsule | photo. */
6003
6010
  source: string | null;
6011
+ /** The photo(s) a SERVER-EXTRACTED memory was read out of. Null on every
6012
+ * memory that did not come from a photo. See {@link PhotoMediaRef}.
6013
+ *
6014
+ * OPTIONAL rather than required: every read path sets it (the row mappers
6015
+ * always call parseMedia), but making it required would be a compile-break
6016
+ * for any caller that CONSTRUCTS a StoredVaultMemory — fixtures, mocks, and
6017
+ * anything downstream — for a field that is null on all but photo rows. */
6018
+ media?: PhotoMediaRef[] | null;
6004
6019
  /** W6 temporal lane — Unix ms when the event occurred (point/start of range). */
6005
6020
  eventTimeStart: number | null;
6006
6021
  /** W6 temporal lane — Unix ms when the event ended (range only). */
@@ -6059,6 +6074,26 @@ interface StoredVaultMemory {
6059
6074
  updatedAt: Date;
6060
6075
  isDeleted: boolean;
6061
6076
  }
6077
+ /**
6078
+ * A photo a server-extracted memory came from, as
6079
+ * GET /api/memories/published returns it in `media[]`.
6080
+ *
6081
+ * Both identifiers travel because both are needed: `feedItemId` is the server's
6082
+ * handle for the photo, and `objectKey` is what a client turns into a CDN URL
6083
+ * without another round-trip per memory.
6084
+ */
6085
+ interface PhotoMediaRef {
6086
+ feedItemId: number;
6087
+ objectKey: string | null;
6088
+ }
6089
+ /**
6090
+ * Decode the stored `media` column. Returns null for "no photo behind this
6091
+ * memory" (the column is null on every non-photo row) and tolerates a corrupt
6092
+ * or unexpected payload by reading it as null too — a memory whose photo
6093
+ * reference cannot be parsed is still a perfectly good memory, and losing the
6094
+ * thumbnail is a better failure than losing the row.
6095
+ */
6096
+ declare function parseMedia(value: unknown): PhotoMediaRef[] | null;
6062
6097
  interface CreateVaultMemoryOptions {
6063
6098
  content: string;
6064
6099
  /** Scope for the memory. Defaults to "private" if omitted. */
@@ -6500,6 +6535,95 @@ declare function hardDeleteDecayedOp(ctx: VaultMemoryOperationsContext, id: stri
6500
6535
  }): Promise<boolean>;
6501
6536
  declare function updateVaultMemoryEmbeddingOp(ctx: VaultMemoryOperationsContext, id: string, embedding: string, embeddingModel: string): Promise<boolean>;
6502
6537
 
6538
+ /**
6539
+ * Ingest server-extracted photo memories into the local vault.
6540
+ *
6541
+ * A photo uploaded to People Nearby is read by the server, which extracts
6542
+ * durable facts about the user, embeds them and publishes them
6543
+ * (anuma-ai/nearby#114). Until those rows reach the device they exist only
6544
+ * server-side: the user's own assistant cannot recall them, and no screen can
6545
+ * show them — so the "visible and deletable" promise the design makes is not
6546
+ * kept. This is the path that brings them home.
6547
+ *
6548
+ * Three things about the shape of this, each of which is load-bearing:
6549
+ *
6550
+ * 1. **It takes rows; it does not fetch them.** The publish reconciler already
6551
+ * calls `listPublished()` on every pass and gets `text`, `media[]`,
6552
+ * `event_time` and `user_authored` back. Ingest consumes that response. No
6553
+ * new endpoint, no second network call, no change to nearby's API.
6554
+ *
6555
+ * 2. **The vault row's id IS the server's `memory_id`.** That is what makes a
6556
+ * revoke addressable: the reconciler's ledger, its published set and its
6557
+ * `toRevoke` list are all keyed on that id, so a locally-minted id would
6558
+ * leave the user with a switch that cannot reach the row it appears to
6559
+ * control. It is also what makes ingest idempotent for free — a second pass
6560
+ * sees the id already present and writes nothing.
6561
+ *
6562
+ * 3. **These rows never go through `retain()`.** That path is for facts being
6563
+ * learned on-device: it dedupes and merges candidates against local rows and
6564
+ * mints its own ids, both of which would break (2). A photo memory is not a
6565
+ * candidate to be reconciled against the vault — it is an already-decided
6566
+ * fact the server has published.
6567
+ *
6568
+ * The rows are written `visibility: "public"` because they genuinely ARE
6569
+ * published — the reconciler reads local visibility as the user's intent, and
6570
+ * anything else would make it immediately revoke a memory the user never turned
6571
+ * off. They carry `source: SOURCE_PHOTO`, which is what exempts them from
6572
+ * decay's auto-archive; see the note there for why archiving one would silently
6573
+ * unpublish it.
6574
+ *
6575
+ * No embedding is computed here. `searchTool`'s un-embedded lane embeds any row
6576
+ * lacking a vector at search time, uses it in that same search and persists it
6577
+ * via `updateVaultMemoryEmbeddingOp` — so a row ingested without one is picked
6578
+ * up on first recall rather than costing an embedding call at ingest.
6579
+ */
6580
+
6581
+ /**
6582
+ * One row of `GET /api/memories/published`, narrowed to what ingest needs.
6583
+ *
6584
+ * Deliberately structural rather than an import from the transport client: this
6585
+ * op is in the SDK and the two hand-written nearby clients live in the app, so
6586
+ * a shared nominal type would drag one across a package boundary for no gain.
6587
+ */
6588
+ interface PublishedPhotoMemory {
6589
+ /** The server-minted memory id. `photo:<feedItemID>:fact:NN` or `:caption`. */
6590
+ memoryId: string;
6591
+ /** The projected fact text. */
6592
+ text: string;
6593
+ /** The photo(s) this fact was read out of. */
6594
+ media?: PhotoMediaRef[] | null;
6595
+ /** When the event in the memory happened, if the server knows. */
6596
+ eventTime?: {
6597
+ start: number | null;
6598
+ end: number | null;
6599
+ kind: "point" | "range" | "ongoing" | null;
6600
+ } | null;
6601
+ /** True when the text is the user's own words (a kept caption). */
6602
+ userAuthored?: boolean;
6603
+ }
6604
+ /** What one ingest pass did, for the caller's logs and tests. */
6605
+ interface PhotoIngestResult {
6606
+ /** Rows newly written to the vault. */
6607
+ inserted: number;
6608
+ /** Rows already present, left untouched. */
6609
+ skipped: number;
6610
+ }
6611
+ /**
6612
+ * Write the published photo memories this vault does not already have.
6613
+ *
6614
+ * Idempotent on `memoryId`: a row whose id is already in the vault is counted as
6615
+ * skipped and NOT rewritten, even when the server's text has since changed.
6616
+ * That is deliberate — the local row is the user's copy, they may have edited
6617
+ * it, and silently overwriting an edit to match the server would be the same
6618
+ * class of bug as publishing a version the user has since changed. Re-ingesting
6619
+ * changed text is a follow-up that needs a merge decision, not a clobber.
6620
+ *
6621
+ * Non-`photo:` ids are ignored: everything else in the published set is a
6622
+ * client-published memory that by definition already lives in this vault (or in
6623
+ * another device's, which is not ours to recreate).
6624
+ */
6625
+ declare function ingestPublishedPhotoMemoriesOp(ctx: VaultMemoryOperationsContext, rows: PublishedPhotoMemory[]): Promise<PhotoIngestResult>;
6626
+
6503
6627
  declare class Project extends Model$1 {
6504
6628
  static table: string;
6505
6629
  static associations: Associations;
@@ -7703,6 +7827,15 @@ declare function createChunkVectorCache(maxSize?: number): ChunkVectorCache;
7703
7827
  * shared purge buffer for every row, so an already-archived manual memory is
7704
7828
  * still deleted after the window (the archived check runs before the manual
7705
7829
  * short-circuit by design).
7830
+ *
7831
+ * `source === "photo"` (server-extracted photo memories) is protected the same
7832
+ * way, and for a sharper reason than curation: those rows are PUBLISHED, and
7833
+ * auto-archiving one would silently un-publish it. Archived rows drop out of the
7834
+ * default vault read, the publish reconciler builds its desired set from that
7835
+ * read, and anything it previously adopted but no longer sees goes into
7836
+ * `toRevoke` — so an age-archive at the medium TTL would revoke a memory from
7837
+ * the server that the user never switched off. Revoking is the user's decision
7838
+ * and has exactly one entry point: the publish switch.
7706
7839
  */
7707
7840
  /** The verdict for a single memory. */
7708
7841
  type DecayVerdict = "keep" | "archive" | "delete";
@@ -10069,4 +10202,4 @@ declare function sanitizeQuotes(s: string): string;
10069
10202
  declare function renderTemplate(value: string | null | undefined, template: string): string | null;
10070
10203
  declare function buildSystemPrompt(ctx: PromptContext, options?: BuildPromptOptions): BuildPromptResult;
10071
10204
 
10072
- export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, 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, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LlmTokenUsage, MAX_HOPS, MAX_MESSAGES_PER_SUMMARIZATION, MEDIUM_TTL_MS, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, Message, type MessageChunk, type MessageFeedback, type MessageOrigin, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, NEVER_TTL_MS, NODE_BUDGET, type NeighborRefiner, type NowSource, type ObservationTrend, type ObservationTrendInput, type OperationExecutor, PAST_EVENT_GRACE_MS, PROFILE_DOC_VERSION, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QuarantinedMemoryInfo, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, 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 ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunTerminalState, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SHORT_TTL_MS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, type SynthesizeProfileOptions, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, VaultMemory, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, capHopsForDensity, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createMessageSourceResolver, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDecayCandidatesRawOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultMemoryOp, getVideosOp, hardDeleteDecayedOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, injectionSignatureCatalog, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, relinkMemoryTopicsOp, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, restoreVaultMemoryOp, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, seedEncryptionKeys, selectServerToolsForPrompt, serverPlatformStorage, setMemoryVisibilityOp, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, summaryToSystemMessage, supersedeVaultMemoryOp, synthesizeProfile, toolSetSystemPrompts, traverseGraphLane, ttlForType, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp, verifyMemoriesForPublish };
10205
+ export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, 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, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LlmTokenUsage, MAX_HOPS, MAX_MESSAGES_PER_SUMMARIZATION, MEDIUM_TTL_MS, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryQuarantinedEvent, type MemoryToVerify, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, Message, type MessageChunk, type MessageFeedback, type MessageOrigin, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, NEVER_TTL_MS, NODE_BUDGET, type NeighborRefiner, type NowSource, type ObservationTrend, type ObservationTrendInput, type OperationExecutor, PAST_EVENT_GRACE_MS, PROFILE_DOC_VERSION, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PhotoIngestResult, type PhotoMediaRef, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type PublishedPhotoMemory, type QuarantinedMemoryInfo, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, 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 ReflectOptions, type ReflectResult, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunTerminalState, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SHORT_TTL_MS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, type SynthesizeProfileOptions, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, VAULT_SIZE_HOP_CAP, type VaultEmbeddingCache, VaultMemory, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultSaveOperation, type VaultSearchResult, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, archiveVaultMemoryOp, backfillMemoryTopicsOp, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, capHopsForDensity, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createDecaySweeper, createLlmDecayClassifier, createLlmNeighborRefiner, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createMessageSourceResolver, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDecayCandidatesRawOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultMemoryOp, getVideosOp, hardDeleteDecayedOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, onKeyAvailable, parseMedia, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, rankProfileCandidates, recall, reflect, refreshEncryptionKeyIfMatches, relinkMemoryTopicsOp, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, restoreVaultMemoryOp, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, seedEncryptionKeys, selectServerToolsForPrompt, serverPlatformStorage, setMemoryVisibilityOp, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, summaryToSystemMessage, supersedeVaultMemoryOp, synthesizeProfile, toolSetSystemPrompts, traverseGraphLane, ttlForType, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp, verifyMemoriesForPublish };
@@ -63,6 +63,7 @@ import {
63
63
  encryptDataWithKey,
64
64
  encryptField,
65
65
  encryptJsonField,
66
+ encryptVaultMemoryContent,
66
67
  exportPublicKey,
67
68
  generateConversationId,
68
69
  generateEmbedding,
@@ -93,6 +94,7 @@ import {
93
94
  makeSyntheticStoredMessage,
94
95
  onClearAllEncryptionState,
95
96
  onKeyAvailable,
97
+ parseMedia,
96
98
  preEmbedVaultMemories,
97
99
  prepareVaultCandidates,
98
100
  rankPreparedVaultCandidates,
@@ -137,7 +139,7 @@ import {
137
139
  updateVaultMemoryOp,
138
140
  upsertMessageOp,
139
141
  vaultMemoryToStored
140
- } from "./chunk-6JS7SY6A.mjs";
142
+ } from "./chunk-S5WEN7TE.mjs";
141
143
  import {
142
144
  createStreamingDeAnonymizer,
143
145
  notifyConsolidationFallback,
@@ -1139,6 +1141,9 @@ __decorateClass([
1139
1141
  __decorateClass([
1140
1142
  (0, import_decorators6.field)("topics_updated_at")
1141
1143
  ], VaultMemory.prototype, "topicsUpdatedAt", 2);
1144
+ __decorateClass([
1145
+ (0, import_decorators6.field)("media")
1146
+ ], VaultMemory.prototype, "media", 2);
1142
1147
  __decorateClass([
1143
1148
  (0, import_decorators6.field)("topics_extracted_at")
1144
1149
  ], VaultMemory.prototype, "topicsExtractedAt", 2);
@@ -1322,7 +1327,7 @@ __decorateClass([
1322
1327
  ], VaultFolder.prototype, "context", 2);
1323
1328
 
1324
1329
  // src/lib/db/schema.ts
1325
- var SDK_SCHEMA_VERSION = 44;
1330
+ var SDK_SCHEMA_VERSION = 45;
1326
1331
  var sdkSchema = (0, import_watermelondb12.appSchema)({
1327
1332
  version: SDK_SCHEMA_VERSION,
1328
1333
  tables: [
@@ -1470,6 +1475,18 @@ var sdkSchema = (0, import_watermelondb12.appSchema)({
1470
1475
  // paths key on `updated_at` — so without this a topic-only change would
1471
1476
  // neither upload nor merge. Null = `topics` never written.
1472
1477
  { name: "topics_updated_at", type: "number", isOptional: true },
1478
+ // The photo(s) a SERVER-EXTRACTED memory was read out of, as a JSON
1479
+ // array of `{feed_item_id, object_key}` — exactly what
1480
+ // GET /api/memories/published returns in `media[]`. Enough to render the
1481
+ // source image without a second round-trip per memory.
1482
+ //
1483
+ // A JSON column rather than a join table: nothing on the client ever
1484
+ // queries BY photo (the only direction is memory -> render its image),
1485
+ // so a table would add a sync lane and a local-id space to serve a
1486
+ // question nobody asks. `topics` and `source_chunk_ids` set the
1487
+ // precedent for a list that is only ever read back whole. Null on
1488
+ // anything not extracted from a photo.
1489
+ { name: "media", type: "string", isOptional: true },
1473
1490
  // Unix ms of the last LLM topic-extraction pass over this memory's
1474
1491
  // content. Null = never extracted standalone (legacy rows with entity
1475
1492
  // links are grandfathered — see getMemoriesNeedingTopicExtractionOp).
@@ -2304,6 +2321,20 @@ var sdkMigrations = (0, import_migrations.schemaMigrations)({
2304
2321
  columns: [{ name: "origin", type: "string", isOptional: true }]
2305
2322
  })
2306
2323
  ]
2324
+ },
2325
+ // v44 -> v45: `media` on memory_vault — the photo(s) a server-extracted
2326
+ // memory was read out of, as JSON `[{feed_item_id, object_key}]`, mirroring
2327
+ // the `media[]` that GET /api/memories/published already returns. Existing
2328
+ // rows keep NULL, which is the correct value for every memory that did not
2329
+ // come from a photo (i.e. all of them until photo ingest runs).
2330
+ {
2331
+ toVersion: 45,
2332
+ steps: [
2333
+ (0, import_migrations.addColumns)({
2334
+ table: "memory_vault",
2335
+ columns: [{ name: "media", type: "string", isOptional: true }]
2336
+ })
2337
+ ]
2307
2338
  }
2308
2339
  ]
2309
2340
  });
@@ -3582,6 +3613,133 @@ async function cleanupConversationSummary(database, conversationId) {
3582
3613
  }
3583
3614
  }
3584
3615
 
3616
+ // src/lib/memory/decay.ts
3617
+ var DAY_MS = 24 * 60 * 60 * 1e3;
3618
+ var SHORT_TTL_MS = 30 * DAY_MS;
3619
+ var MEDIUM_TTL_MS = 180 * DAY_MS;
3620
+ var SOURCE_PHOTO = "photo";
3621
+ var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
3622
+ var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
3623
+ var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
3624
+ var DEFAULT_DECAY_POLICY = {
3625
+ ttlByType: {
3626
+ identity: NEVER_TTL_MS,
3627
+ preference: NEVER_TTL_MS,
3628
+ relationship: NEVER_TTL_MS,
3629
+ constraint: NEVER_TTL_MS,
3630
+ plan: SHORT_TTL_MS,
3631
+ ongoing_context: SHORT_TTL_MS,
3632
+ other: MEDIUM_TTL_MS
3633
+ },
3634
+ fallbackTtlMs: MEDIUM_TTL_MS,
3635
+ hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
3636
+ pastEventGraceMs: PAST_EVENT_GRACE_MS
3637
+ };
3638
+ function resolvePolicy(policy) {
3639
+ if (!policy) return DEFAULT_DECAY_POLICY;
3640
+ return {
3641
+ ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
3642
+ fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
3643
+ hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
3644
+ pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
3645
+ };
3646
+ }
3647
+ function ttlForType(factType, policy) {
3648
+ const resolved = resolvePolicy(policy);
3649
+ if (factType === null) return resolved.fallbackTtlMs;
3650
+ return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
3651
+ }
3652
+ function isTimeSensitiveType(factType) {
3653
+ return factType === "plan" || factType === "ongoing_context";
3654
+ }
3655
+ function hasFiniteTimestamps(m, now) {
3656
+ return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
3657
+ }
3658
+ function classifyDecay(m, now, policy) {
3659
+ const resolved = resolvePolicy(policy);
3660
+ if (!hasFiniteTimestamps(m, now)) {
3661
+ getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
3662
+ now,
3663
+ updatedAt: m.updatedAt,
3664
+ archivedAt: m.archivedAt,
3665
+ factType: m.factType
3666
+ });
3667
+ return "keep";
3668
+ }
3669
+ if (m.archivedAt !== null) {
3670
+ return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
3671
+ }
3672
+ if (m.source === "manual" || m.source === SOURCE_PHOTO) return "keep";
3673
+ if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
3674
+ if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
3675
+ if (m.eventTimeEnd >= now) return "keep";
3676
+ }
3677
+ if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
3678
+ return "keep";
3679
+ }
3680
+
3681
+ // src/lib/db/memoryVault/photoIngest.ts
3682
+ var PHOTO_MEMORY_ID_PREFIX = "photo:";
3683
+ async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
3684
+ const byId = /* @__PURE__ */ new Map();
3685
+ for (const r of rows) {
3686
+ if (typeof r.memoryId !== "string" || !r.memoryId.startsWith(PHOTO_MEMORY_ID_PREFIX)) continue;
3687
+ if (!byId.has(r.memoryId)) byId.set(r.memoryId, r);
3688
+ }
3689
+ const photoRows = [...byId.values()];
3690
+ if (photoRows.length === 0) return { inserted: 0, skipped: 0 };
3691
+ const known = await ctx.vaultMemoryCollection.query().fetchIds().then((ids) => new Set(ids));
3692
+ const candidates = photoRows.filter((r) => !known.has(r.memoryId));
3693
+ if (candidates.length === 0) return { inserted: 0, skipped: photoRows.length };
3694
+ const fresh = candidates;
3695
+ const contents = await Promise.all(
3696
+ fresh.map(async (r) => {
3697
+ if (ctx.walletAddress && ctx.signMessage) {
3698
+ return encryptVaultMemoryContent(
3699
+ r.text,
3700
+ ctx.walletAddress,
3701
+ ctx.signMessage,
3702
+ ctx.embeddedWalletSigner
3703
+ );
3704
+ }
3705
+ return r.text;
3706
+ })
3707
+ );
3708
+ const now = Date.now();
3709
+ let inserted = 0;
3710
+ await ctx.database.write(async () => {
3711
+ const present = new Set(await ctx.vaultMemoryCollection.query().fetchIds());
3712
+ const writable = fresh.map((row, i) => ({ row, content: contents[i] })).filter(({ row }) => !present.has(row.memoryId));
3713
+ inserted = writable.length;
3714
+ if (writable.length === 0) return;
3715
+ const prepared = writable.map(
3716
+ ({ row, content }) => ctx.vaultMemoryCollection.prepareCreate((record) => {
3717
+ record._raw.id = row.memoryId;
3718
+ record._setRaw("content", content);
3719
+ record._setRaw("scope", "private");
3720
+ record._setRaw("folder_id", null);
3721
+ record._setRaw("user_id", ctx.userId ?? null);
3722
+ record._setRaw("is_deleted", false);
3723
+ record._setRaw("proof_count", 1);
3724
+ record._setRaw("source", SOURCE_PHOTO);
3725
+ record._setRaw(
3726
+ "media",
3727
+ row.media && row.media.length > 0 ? JSON.stringify(row.media) : null
3728
+ );
3729
+ record._setRaw("visibility", "public");
3730
+ record._setRaw("published_at", now);
3731
+ if (row.eventTime) {
3732
+ record._setRaw("event_time_start", row.eventTime.start ?? null);
3733
+ record._setRaw("event_time_end", row.eventTime.end ?? null);
3734
+ record._setRaw("event_time_kind", row.eventTime.kind ?? null);
3735
+ }
3736
+ })
3737
+ );
3738
+ await ctx.database.batch(...prepared);
3739
+ });
3740
+ return { inserted, skipped: photoRows.length - inserted };
3741
+ }
3742
+
3585
3743
  // src/lib/db/project/operations.ts
3586
3744
  var import_watermelondb15 = __toESM(require_watermelondb());
3587
3745
 
@@ -6252,70 +6410,6 @@ function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
6252
6410
  return new LRUCache(maxSize);
6253
6411
  }
6254
6412
 
6255
- // src/lib/memory/decay.ts
6256
- var DAY_MS = 24 * 60 * 60 * 1e3;
6257
- var SHORT_TTL_MS = 30 * DAY_MS;
6258
- var MEDIUM_TTL_MS = 180 * DAY_MS;
6259
- var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
6260
- var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
6261
- var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
6262
- var DEFAULT_DECAY_POLICY = {
6263
- ttlByType: {
6264
- identity: NEVER_TTL_MS,
6265
- preference: NEVER_TTL_MS,
6266
- relationship: NEVER_TTL_MS,
6267
- constraint: NEVER_TTL_MS,
6268
- plan: SHORT_TTL_MS,
6269
- ongoing_context: SHORT_TTL_MS,
6270
- other: MEDIUM_TTL_MS
6271
- },
6272
- fallbackTtlMs: MEDIUM_TTL_MS,
6273
- hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
6274
- pastEventGraceMs: PAST_EVENT_GRACE_MS
6275
- };
6276
- function resolvePolicy(policy) {
6277
- if (!policy) return DEFAULT_DECAY_POLICY;
6278
- return {
6279
- ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
6280
- fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
6281
- hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
6282
- pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
6283
- };
6284
- }
6285
- function ttlForType(factType, policy) {
6286
- const resolved = resolvePolicy(policy);
6287
- if (factType === null) return resolved.fallbackTtlMs;
6288
- return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
6289
- }
6290
- function isTimeSensitiveType(factType) {
6291
- return factType === "plan" || factType === "ongoing_context";
6292
- }
6293
- function hasFiniteTimestamps(m, now) {
6294
- return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
6295
- }
6296
- function classifyDecay(m, now, policy) {
6297
- const resolved = resolvePolicy(policy);
6298
- if (!hasFiniteTimestamps(m, now)) {
6299
- getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
6300
- now,
6301
- updatedAt: m.updatedAt,
6302
- archivedAt: m.archivedAt,
6303
- factType: m.factType
6304
- });
6305
- return "keep";
6306
- }
6307
- if (m.archivedAt !== null) {
6308
- return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
6309
- }
6310
- if (m.source === "manual") return "keep";
6311
- if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
6312
- if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
6313
- if (m.eventTimeEnd >= now) return "keep";
6314
- }
6315
- if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
6316
- return "keep";
6317
- }
6318
-
6319
6413
  // src/lib/memory/decayClassifier.ts
6320
6414
  var DEFAULT_MODEL2 = "inclusionai/ling-2.6-flash";
6321
6415
  var DEFAULT_ATTEMPTS2 = 2;
@@ -6413,7 +6507,7 @@ function toDecayInput(c) {
6413
6507
  };
6414
6508
  }
6415
6509
  function isBorderline(input) {
6416
- if (input.source === "manual") return false;
6510
+ if (input.source === "manual" || input.source === SOURCE_PHOTO) return false;
6417
6511
  if (input.trustTier === "quarantined") return false;
6418
6512
  if (input.archivedAt !== null) return false;
6419
6513
  if (input.factType === null || input.factType === "other") return true;
@@ -13653,6 +13747,7 @@ export {
13653
13747
  hardDeleteMediaOp,
13654
13748
  hasEncryptionKey,
13655
13749
  hasKeyPair,
13750
+ ingestPublishedPhotoMemoriesOp,
13656
13751
  injectionSignatureCatalog,
13657
13752
  isRerankerAvailable,
13658
13753
  isSupportedFile,
@@ -13663,6 +13758,7 @@ export {
13663
13758
  mediaToStored,
13664
13759
  migrateFromModelPreferencesOp,
13665
13760
  onKeyAvailable,
13761
+ parseMedia,
13666
13762
  preEmbedVaultMemories,
13667
13763
  preprocessFiles,
13668
13764
  progressiveSummarize,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-6JS7SY6A.mjs";
3
+ } from "./chunk-S5WEN7TE.mjs";
4
4
  import "./chunk-OBDRKQQI.mjs";
5
5
  import "./chunk-3RPGXXPZ.mjs";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",