@anuma/sdk 6.7.2 → 6.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{react/chunk-B5UPJRCU.mjs → expo/chunk-CJ32HO6Q.mjs} +62 -11
  2. package/dist/expo/{chunk-VOMDHMKH.mjs → chunk-OUFITMDL.mjs} +1 -1
  3. package/dist/expo/{chunk-2YHVYDEL.mjs → chunk-YO5UXOC4.mjs} +3 -2
  4. package/dist/{react/consolidate-ZCGS7QUA.mjs → expo/consolidate-4BMNVOL4.mjs} +3 -2
  5. package/dist/expo/index.cjs +101 -18
  6. package/dist/expo/index.d.mts +105 -2
  7. package/dist/expo/index.d.ts +105 -2
  8. package/dist/expo/index.mjs +34 -10
  9. package/dist/expo/{recall-M3JVFTZL.mjs → recall-IEKVX4JL.mjs} +2 -2
  10. package/dist/index.cjs +10 -0
  11. package/dist/index.d.mts +49 -1
  12. package/dist/index.d.ts +49 -1
  13. package/dist/index.mjs +8 -0
  14. package/dist/{expo/chunk-B5UPJRCU.mjs → react/chunk-CJ32HO6Q.mjs} +62 -11
  15. package/dist/react/{chunk-2ARMO2NN.mjs → chunk-DY5VGC6K.mjs} +1 -1
  16. package/dist/react/{chunk-S6WPXD5N.mjs → chunk-POCLKALT.mjs} +3 -2
  17. package/dist/{expo/consolidate-TWE6OSSZ.mjs → react/consolidate-5TP3J6BY.mjs} +3 -2
  18. package/dist/react/index.cjs +101 -18
  19. package/dist/react/index.d.mts +105 -2
  20. package/dist/react/index.d.ts +105 -2
  21. package/dist/react/index.mjs +34 -10
  22. package/dist/react/{recall-ROEK55FJ.mjs → recall-B2AIAPCM.mjs} +2 -2
  23. package/dist/server/{chunk-TD7SMY7C.mjs → chunk-FS6DNUNT.mjs} +3 -2
  24. package/dist/server/{chunk-VHWLLYKO.mjs → chunk-KF5OU4IN.mjs} +62 -11
  25. package/dist/server/{chunk-CR5P3YIK.mjs → chunk-MEQ2PAEX.mjs} +1 -1
  26. package/dist/server/{consolidate-FWYK5KXB.mjs → consolidate-QDWEYFTZ.mjs} +3 -2
  27. package/dist/server/index.cjs +101 -18
  28. package/dist/server/index.d.mts +105 -2
  29. package/dist/server/index.d.ts +105 -2
  30. package/dist/server/index.mjs +34 -10
  31. package/dist/server/{recall-CGDEW2LQ.mjs → recall-2GAPE2XH.mjs} +2 -2
  32. package/package.json +1 -1
@@ -4680,6 +4680,44 @@ interface EntityOperationsContext {
4680
4680
  allowUnscopedRows?: boolean;
4681
4681
  }
4682
4682
 
4683
+ /**
4684
+ * Shared portal LLM call for the memory pipeline.
4685
+ *
4686
+ * The three LLM-driven steps (`extractFacts`, `consolidateMemory`,
4687
+ * `decomposeQuery`) share the same shape: POST to `/api/v1/chat/completions`
4688
+ * with a system+user prompt and `response_format: json_object`, parse
4689
+ * `choices[0].message.content` as JSON, validate, return null on any failure.
4690
+ * This helper owns the fetch+timeout+parse+log boilerplate so each caller
4691
+ * stays focused on its prompt and validator.
4692
+ *
4693
+ * PROMPT CACHING. The portal inserts explicit prompt-cache breakpoints only for
4694
+ * `anthropic/` models. Its request schema does carry OpenAI's
4695
+ * `prompt_cache_key`, but that is a routing hint for OpenAI's own implicit
4696
+ * cache rather than a switch that enables caching, and we deliberately don't
4697
+ * send it: the memory pipeline runs open-weights models by default (gpt-oss for
4698
+ * extraction/topics, ling for consolidation), and this module already has one
4699
+ * hard lesson about OpenAI-standard fields a non-OpenAI provider hard-400s on
4700
+ * (`response_format`, below). Revisit only with a verified per-provider gate.
4701
+ *
4702
+ * So on the models this pipeline actually uses, the only cache that can hit is
4703
+ * the provider's own implicit prefix cache — which makes prefix stability the
4704
+ * one lever a caller controls. Messages are assembled system-first (below), so
4705
+ * every caller must pass a CONSTANT `systemPrompt` and keep all per-call
4706
+ * material in `userMessage`: a single interpolated timestamp, id, or count in a
4707
+ * system prompt shifts every byte after it and misses the cache on every
4708
+ * request thereafter. The memory callers are regression-gated on that property
4709
+ * in `promptPrefixStability.test.ts`.
4710
+ *
4711
+ * Whether those implicit caches hit is observable: each successful response
4712
+ * logs the portal's reported token counts at debug level, including
4713
+ * `portal.cached_tokens` (the prompt tokens the provider served from cache —
4714
+ * the portal omits the field when there was no hit). See {@link logPortalUsage}.
4715
+ *
4716
+ * There is no batch/async-bulk route on the portal, so a backfill or reindex
4717
+ * has no discounted-throughput path either; its only levers are the same stable
4718
+ * prefix and caller-side batching (e.g. topicExtract's 10-memories-per-call).
4719
+ */
4720
+
4683
4721
  /**
4684
4722
  * Auth for portal LLM calls (extraction, consolidation, decomposition,
4685
4723
  * reflection). Mirrors `memoryEngine`'s `EmbeddingOptions` dual-auth:
@@ -4698,6 +4736,60 @@ interface PortalLlmAuth {
4698
4736
  /** Function to get an auth token (e.g., Privy's getIdentityToken). Token is sent as `Authorization: Bearer`. */
4699
4737
  getToken?: () => Promise<string | null>;
4700
4738
  }
4739
+ /**
4740
+ * Why a portal JSON completion gave up, as a STABLE low-cardinality code.
4741
+ *
4742
+ * The retry loop has always classified its failures precisely, but only as an
4743
+ * interpolated `reason` string for `log.warn` — and prod ships no SDK log
4744
+ * (sdk#883), so in production every one of these collapsed into a single
4745
+ * `empty-after-retry` with no way to tell them apart. That is what made the
4746
+ * 2026-08-11 audit need a Prometheus cross-check to discover that the portal
4747
+ * was returning HTTP 200 with an empty body on ~60% of extraction turns.
4748
+ *
4749
+ * Codes are deliberately an enum, not the `reason` string: the strings embed
4750
+ * status codes and error messages, so they are unbounded and useless as an
4751
+ * analytics property. Keep this list SHORT and stable — it is a telemetry
4752
+ * contract, and a value added here has to mean the same thing in six months.
4753
+ *
4754
+ * @public
4755
+ */
4756
+ type PortalLlmFailureReason =
4757
+ /** No usable credential — `getToken` returned null or threw. Terminal. */
4758
+ "auth-unavailable"
4759
+ /** Non-retryable HTTP status (400/403/404, or 401 on the static-apiKey path). */
4760
+ | "http-terminal"
4761
+ /** Retryable status (408/409/425/429/5xx) that never succeeded. */
4762
+ | "http-retryable"
4763
+ /** Network error or the per-attempt timeout aborted the fetch. */
4764
+ | "network"
4765
+ /** HTTP 200 but the envelope itself wasn't JSON. */
4766
+ | "body-parse-failed"
4767
+ /**
4768
+ * HTTP 200 with NO completion content. The reasoning-class failure mode:
4769
+ * the model spends its budget on unreturned thinking and answers empty.
4770
+ */
4771
+ | "empty-content"
4772
+ /** Content present, but no parseable JSON in it (prose, a clarifying question). */
4773
+ | "invalid-json"
4774
+ /** Content parsed to a literal `null`, which is never a valid response. */
4775
+ | "null-completion"
4776
+ /** `totalTimeoutMs` was spent before the next attempt could run. */
4777
+ | "time-budget-exhausted";
4778
+ /**
4779
+ * A give-up report: the classified {@link PortalLlmFailureReason} plus the
4780
+ * little context worth carrying into telemetry. Both extra fields are bounded
4781
+ * (a status code, a small attempt count), so both are safe as event properties.
4782
+ *
4783
+ * @public
4784
+ */
4785
+ interface PortalLlmFailure {
4786
+ /** Stable code for the last failure observed. */
4787
+ reason: PortalLlmFailureReason;
4788
+ /** HTTP status, when the failure was an HTTP one. */
4789
+ httpStatus?: number;
4790
+ /** How many attempts ran before giving up (1-based, ≥ 1). */
4791
+ attempts: number;
4792
+ }
4701
4793
 
4702
4794
  /**
4703
4795
  * Optional LLM injection classifier — Tier-0 security second layer (PR5).
@@ -5893,8 +5985,14 @@ interface ExtractFactsOptions extends PortalLlmAuth {
5893
5985
  * `{candidates: []}` "nothing durable here". Lets callers distinguish a
5894
5986
  * silently-degrading extractor from quiet turns (the two are otherwise
5895
5987
  * indistinguishable). See {@link extractAndRetain}'s `outcome`.
5988
+ *
5989
+ * Receives the classified {@link PortalLlmFailure}. Knowing THAT extraction
5990
+ * failed was not enough: the 2026-08-11 audit found ~60% of production turns
5991
+ * ending here and had to cross-check Prometheus to learn that the cause was
5992
+ * HTTP-200-with-empty-body rather than the 403 everyone assumed. Forward
5993
+ * `failure.reason` into analytics so the next such question is a query.
5896
5994
  */
5897
- onExhaustedEmpty?: () => void;
5995
+ onExhaustedEmpty?: (failure: PortalLlmFailure) => void;
5898
5996
  /**
5899
5997
  * Called when the extractor DID produce candidates but PII de-anonymization
5900
5998
  * dropped every one of them — the model mangled its placeholders (so they
@@ -6017,6 +6115,11 @@ declare function extractAndRetain(messages: AutoExtractMessage[], retainCtx: Ret
6017
6115
  * "extracted but held for review".
6018
6116
  */
6019
6117
  quarantined: QuarantinedMemoryInfo[];
6118
+ /**
6119
+ * Present only when `outcome` is `empty-after-retry` — the classified cause of
6120
+ * the give-up, so "extraction is failing" can be reported as *why* it failed.
6121
+ */
6122
+ failure?: PortalLlmFailure;
6020
6123
  }>;
6021
6124
 
6022
6125
  /**
@@ -10275,4 +10378,4 @@ declare function sanitizeQuotes(s: string): string;
10275
10378
  declare function renderTemplate(value: string | null | undefined, template: string): string | null;
10276
10379
  declare function buildSystemPrompt(ctx: PromptContext, options?: BuildPromptOptions): BuildPromptResult;
10277
10380
 
10278
- 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 };
10381
+ 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, type PortalLlmFailure, type PortalLlmFailureReason, 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 };
@@ -141,12 +141,12 @@ import {
141
141
  updateVaultMemoryOp,
142
142
  upsertMessageOp,
143
143
  vaultMemoryToStored
144
- } from "./chunk-TD7SMY7C.mjs";
144
+ } from "./chunk-FS6DNUNT.mjs";
145
145
  import {
146
146
  createStreamingDeAnonymizer,
147
147
  notifyConsolidationFallback,
148
148
  resolvePiiRedactor
149
- } from "./chunk-CR5P3YIK.mjs";
149
+ } from "./chunk-MEQ2PAEX.mjs";
150
150
  import {
151
151
  INTERNAL_FLOW_MARKER,
152
152
  callPortalJsonCompletion,
@@ -154,9 +154,10 @@ import {
154
154
  getLogger,
155
155
  resolvePortalAuthHeaders,
156
156
  supportsResponseFormat,
157
+ taskTypeHeader,
157
158
  validateEndpointOverride,
158
159
  withInternalFlowMarker
159
- } from "./chunk-VHWLLYKO.mjs";
160
+ } from "./chunk-KF5OU4IN.mjs";
160
161
  import {
161
162
  BASE_URL,
162
163
  __commonJS,
@@ -3408,7 +3409,12 @@ async function callSummarizationLlm(prompt, model, token, baseUrl) {
3408
3409
  method: "POST",
3409
3410
  headers: {
3410
3411
  "Content-Type": "application/json",
3411
- Authorization: `Bearer ${token}`
3412
+ Authorization: `Bearer ${token}`,
3413
+ // Names the task so the portal can own this prompt server-side instead of
3414
+ // trusting the one we build. Summarization is the archetypal Class-B flow:
3415
+ // one fixed purpose, no conversation, and today its instructions are ours
3416
+ // to reword.
3417
+ ...taskTypeHeader("summarize")
3412
3418
  },
3413
3419
  body: JSON.stringify({
3414
3420
  model,
@@ -5219,6 +5225,7 @@ async function classifyInjectionCandidates(candidates, options) {
5219
5225
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
5220
5226
  ...options.getToken !== void 0 && { getToken: options.getToken },
5221
5227
  ...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
5228
+ taskType: "memory_injection_check",
5222
5229
  model: options.model ?? DEFAULT_MODEL,
5223
5230
  systemPrompt: SYSTEM_PROMPT,
5224
5231
  userMessage: `Candidate facts:
@@ -5693,7 +5700,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
5693
5700
  content: m.content,
5694
5701
  similarity: m.similarity
5695
5702
  }));
5696
- const { consolidateMemory: doConsolidate } = await import("./consolidate-FWYK5KXB.mjs");
5703
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-QDWEYFTZ.mjs");
5697
5704
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
5698
5705
  if (decision.action === "create") return null;
5699
5706
  if (decision.action === "supersede" && decision.content) {
@@ -5910,10 +5917,15 @@ async function extractFacts(messages, options) {
5910
5917
  }
5911
5918
  const transcript = transcriptLines.join("\n");
5912
5919
  const today = formatLocalDate(options.now ?? Date.now());
5920
+ let failure;
5913
5921
  const parsed = await callPortalJsonCompletion({
5922
+ onFailure: (f) => {
5923
+ failure = f;
5924
+ },
5914
5925
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
5915
5926
  ...options.getToken !== void 0 && { getToken: options.getToken },
5916
5927
  ...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
5928
+ taskType: "memory_extract",
5917
5929
  ...options.endpointOverride !== void 0 && {
5918
5930
  endpointOverride: options.endpointOverride
5919
5931
  },
@@ -5933,7 +5945,7 @@ Extract durable user facts.`,
5933
5945
  ...options.backoffMs && { backoffMs: options.backoffMs }
5934
5946
  });
5935
5947
  if (parsed === null) {
5936
- options.onExhaustedEmpty?.();
5948
+ options.onExhaustedEmpty?.(failure ?? { reason: "empty-content", attempts: 1 });
5937
5949
  return [];
5938
5950
  }
5939
5951
  const fallbackSourceId = [...messages].reverse().find((m) => m.role === "user")?.id;
@@ -5977,14 +5989,16 @@ async function extractAndRetain(messages, retainCtx, options) {
5977
5989
  ...resolvedConsolidatePii !== void 0 && { piiRedaction: resolvedConsolidatePii }
5978
5990
  } : void 0;
5979
5991
  let exhaustedEmpty = false;
5992
+ let exhaustedFailure;
5980
5993
  let droppedAfterRedaction = false;
5981
5994
  const callerOnExhaustedEmpty = options.extract.onExhaustedEmpty;
5982
5995
  const callerOnCandidatesDropped = options.extract.onCandidatesDropped;
5983
5996
  const candidates = await extractFacts(messages, {
5984
5997
  ...options.extract,
5985
- onExhaustedEmpty: () => {
5998
+ onExhaustedEmpty: (failure) => {
5986
5999
  exhaustedEmpty = true;
5987
- callerOnExhaustedEmpty?.();
6000
+ exhaustedFailure = failure;
6001
+ callerOnExhaustedEmpty?.(failure);
5988
6002
  },
5989
6003
  onCandidatesDropped: () => {
5990
6004
  droppedAfterRedaction = true;
@@ -6103,12 +6117,19 @@ async function extractAndRetain(messages, retainCtx, options) {
6103
6117
  results,
6104
6118
  failedCount: failedWrites,
6105
6119
  outcome,
6106
- quarantined: quarantinedInfo
6120
+ quarantined: quarantinedInfo,
6121
+ // Only meaningful alongside `outcome: "empty-after-retry"`. Returned as well
6122
+ // as pushed through the callback so a consumer that only inspects the result
6123
+ // (rather than wiring a hook) can still report WHY.
6124
+ ...exhaustedFailure !== void 0 && { failure: exhaustedFailure }
6107
6125
  };
6108
6126
  }
6127
+ var UTTERANCE_ECHO_RE = /^(?:said|says|asked|answered|replied|guessed|typed)\s*:\s*(?:'[^']*'|"[^"]*"|‘[^’]*’|“[^”]*”)[\s.!?]*$/iu;
6109
6128
  function isLowSignalContent(content, ownNames) {
6110
- const normalized = content.trim().replace(/[.!?]+$/, "").toLowerCase();
6129
+ const trimmed = content.trim();
6130
+ const normalized = trimmed.replace(/[.!?]+$/, "").toLowerCase();
6111
6131
  if (normalized.length < MIN_CONTENT_LENGTH) return true;
6132
+ if (UTTERANCE_ECHO_RE.test(trimmed)) return true;
6112
6133
  if (ownNames.some(
6113
6134
  (n) => normalized === n.trim().replace(/[.!?]+$/, "").toLowerCase()
6114
6135
  )) {
@@ -6467,6 +6488,7 @@ function createLlmDecayClassifier(options) {
6467
6488
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
6468
6489
  ...options.getToken !== void 0 && { getToken: options.getToken },
6469
6490
  ...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
6491
+ taskType: "memory_decay",
6470
6492
  model: options.model ?? DEFAULT_MODEL2,
6471
6493
  systemPrompt: SYSTEM_PROMPT3,
6472
6494
  userMessage: `Memory content:
@@ -7590,6 +7612,7 @@ When a memory refers to one of these, reuse the EXACT existing name (same spelli
7590
7612
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
7591
7613
  ...options.getToken !== void 0 && { getToken: options.getToken },
7592
7614
  ...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
7615
+ taskType: "memory_topic",
7593
7616
  ...options.endpointOverride !== void 0 && {
7594
7617
  endpointOverride: options.endpointOverride
7595
7618
  },
@@ -7779,6 +7802,7 @@ ${evidence}`);
7779
7802
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
7780
7803
  ...options.getToken !== void 0 && { getToken: options.getToken },
7781
7804
  ...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
7805
+ taskType: "memory_verify_support",
7782
7806
  model: options.model ?? DEFAULT_MODEL4,
7783
7807
  systemPrompt: SYSTEM_PROMPT5,
7784
7808
  userMessage: `Stored facts and their sources:
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-TD7SMY7C.mjs";
4
- import "./chunk-VHWLLYKO.mjs";
3
+ } from "./chunk-FS6DNUNT.mjs";
4
+ import "./chunk-KF5OU4IN.mjs";
5
5
  import "./chunk-3RPGXXPZ.mjs";
6
6
  export {
7
7
  recall
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.7.2",
3
+ "version": "6.8.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",