@anuma/sdk 6.25.3 → 6.26.1

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.
@@ -709,7 +709,7 @@ function supportsResponseFormat(model, variant = "json_object") {
709
709
  const allow = variant === "json_schema" ? RESPONSE_SCHEMA_OK : RESPONSE_FORMAT_OK;
710
710
  return model.split("/").some((seg) => allow.has(seg));
711
711
  }
712
- var RESPONSES_ONLY_MODEL_PREFIXES = ["gpt-5.6"];
712
+ var RESPONSES_ONLY_MODEL_PREFIXES = ["gpt-5.6", "gpt-6-sol", "gpt-6-luna", "gpt-6-astra"];
713
713
  function requiresResponsesTransport(model) {
714
714
  return model.split("/").some((seg) => RESPONSES_ONLY_MODEL_PREFIXES.some((prefix) => seg.startsWith(prefix)));
715
715
  }
@@ -2,7 +2,7 @@ import {
2
2
  callPortalJsonCompletion,
3
3
  notifyConsolidationFallback,
4
4
  resolvePiiRedactor
5
- } from "./chunk-EDABJLYN.mjs";
5
+ } from "./chunk-N5CKISI3.mjs";
6
6
  import "./chunk-GYKJOWEO.mjs";
7
7
 
8
8
  // src/lib/memory/consolidate.ts
@@ -1174,7 +1174,7 @@ var init_portalLlm = __esm({
1174
1174
  RESPONSE_FORMAT_OK = /* @__PURE__ */ new Set(["openai", "inclusionai", "deepseek"]);
1175
1175
  RESPONSE_SCHEMA_OK = /* @__PURE__ */ new Set(["openai"]);
1176
1176
  JSON_CONTRACT_REMINDER = "Output ONLY the strict JSON object requested. No prose, no explanation, no markdown.";
1177
- RESPONSES_ONLY_MODEL_PREFIXES = ["gpt-5.6"];
1177
+ RESPONSES_ONLY_MODEL_PREFIXES = ["gpt-5.6", "gpt-6-sol", "gpt-6-luna", "gpt-6-astra"];
1178
1178
  CHAT_TO_RESPONSES_FIELDS = {
1179
1179
  max_completion_tokens: "max_output_tokens"
1180
1180
  };
@@ -1450,7 +1450,9 @@ __export(index_exports, {
1450
1450
  addConversationMemoriesOp: () => addConversationMemoriesOp,
1451
1451
  archiveVaultMemoryOp: () => archiveVaultMemoryOp,
1452
1452
  assembleMemoryContext: () => assembleMemoryContext,
1453
+ attachFileContextToLastUserMessage: () => attachFileContextToLastUserMessage,
1453
1454
  backfillMemoryTopicsOp: () => backfillMemoryTopicsOp,
1455
+ buildAttachedFilesText: () => buildAttachedFilesText,
1454
1456
  buildNotionAuthUrl: () => buildNotionAuthUrl,
1455
1457
  capHopsForDensity: () => capHopsForDensity,
1456
1458
  chatStorageMigrations: () => chatStorageMigrations,
@@ -1518,6 +1520,7 @@ __export(index_exports, {
1518
1520
  extractAndRetain: () => extractAndRetain,
1519
1521
  extractEntitiesForMemories: () => extractEntitiesForMemories,
1520
1522
  extractFacts: () => extractFacts,
1523
+ formatFileProcessingNotes: () => formatFileProcessingNotes,
1521
1524
  generateConversationId: () => generateConversationId,
1522
1525
  generateEmbedding: () => generateEmbedding,
1523
1526
  generateEmbeddings: () => generateEmbeddings,
@@ -1543,6 +1546,7 @@ __export(index_exports, {
1543
1546
  hasEncryptionKey: () => hasEncryptionKey,
1544
1547
  ingestPublishedPhotoMemoriesOp: () => ingestPublishedPhotoMemoriesOp,
1545
1548
  injectionSignatureCatalog: () => injectionSignatureCatalog,
1549
+ isAttachedFilesText: () => isAttachedFilesText,
1546
1550
  isDegradedTopicSkip: () => isDegradedTopicSkip,
1547
1551
  isEncrypted: () => isEncrypted,
1548
1552
  isPiiRedactor: () => isPiiRedactor,
@@ -2898,6 +2902,46 @@ async function assembleDecryptedMessage(message, address) {
2898
2902
  // src/lib/db/chat/types.ts
2899
2903
  var import_uuid = require("uuid");
2900
2904
 
2905
+ // src/lib/chat/fileContext.ts
2906
+ var ATTACHED_FILES_OPEN_TAG = "<attached_files>";
2907
+ var ATTACHED_FILES_CLOSE_TAG = "</attached_files>";
2908
+ var ATTACHED_FILES_PREFIX = `${ATTACHED_FILES_OPEN_TAG}
2909
+ The user attached the following file(s) to this message. Their extracted contents are below; when the user refers to "the attached file", "this file" or "the document", they mean these.`;
2910
+ function isAttachedFilesText(text12) {
2911
+ return typeof text12 === "string" && text12.startsWith(ATTACHED_FILES_PREFIX) && text12.endsWith(ATTACHED_FILES_CLOSE_TAG);
2912
+ }
2913
+ function buildAttachedFilesText(fileContext) {
2914
+ return `${ATTACHED_FILES_PREFIX}
2915
+
2916
+ ${fileContext}
2917
+ ${ATTACHED_FILES_CLOSE_TAG}`;
2918
+ }
2919
+ function attachFileContextToLastUserMessage(messages, fileContext) {
2920
+ if (!fileContext.trim()) return messages;
2921
+ let lastUserIndex = -1;
2922
+ for (let i = messages.length - 1; i >= 0; i--) {
2923
+ if (messages[i].role === "user") {
2924
+ lastUserIndex = i;
2925
+ break;
2926
+ }
2927
+ }
2928
+ if (lastUserIndex === -1) return messages;
2929
+ const message = messages[lastUserIndex];
2930
+ const existing = message.content ?? [];
2931
+ let insertAt = 0;
2932
+ existing.forEach((part, index) => {
2933
+ if (part.type === "text") insertAt = index + 1;
2934
+ });
2935
+ const filePart = {
2936
+ type: "text",
2937
+ text: buildAttachedFilesText(fileContext)
2938
+ };
2939
+ const content = [...existing.slice(0, insertAt), filePart, ...existing.slice(insertAt)];
2940
+ const result = [...messages];
2941
+ result[lastUserIndex] = { ...message, content };
2942
+ return result;
2943
+ }
2944
+
2901
2945
  // src/lib/chat/useChat/strategies/types.ts
2902
2946
  function isChatCompletionResponse(r) {
2903
2947
  if (r.object === "response") return false;
@@ -3019,7 +3063,7 @@ function extractUserMessageFromMessages(messages) {
3019
3063
  const textParts = [];
3020
3064
  const files = [];
3021
3065
  for (const part of lastUserMessage.content) {
3022
- if (part.type === "text" && part.text) {
3066
+ if (part.type === "text" && part.text && !isAttachedFilesText(part.text)) {
3023
3067
  textParts.push(part.text);
3024
3068
  } else if (part.type === "image_url" && part.image_url?.url) {
3025
3069
  files.push({
@@ -7615,7 +7659,7 @@ function extractLastUserText(messages) {
7615
7659
  const content = lastUserMsg.content;
7616
7660
  if (typeof content === "string") return content;
7617
7661
  if (Array.isArray(content)) {
7618
- return content.filter((c) => c?.type === "text").map((c) => c.text ?? "").join(" ");
7662
+ return content.filter((c) => c?.type === "text" && !isAttachedFilesText(c.text)).map((c) => c.text ?? "").join(" ");
7619
7663
  }
7620
7664
  return "";
7621
7665
  }
@@ -24589,6 +24633,26 @@ async function _ensureDefaultFoldersImpl(ctx) {
24589
24633
  return folderMap;
24590
24634
  }
24591
24635
 
24636
+ // src/lib/processors/fileStatusNotes.ts
24637
+ var DEFAULT_MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
24638
+ function formatMegabytes(bytes) {
24639
+ const mb = bytes / (1024 * 1024);
24640
+ return `${Number.isInteger(mb) ? mb : mb.toFixed(1)} MB`;
24641
+ }
24642
+ function formatFileProcessingNotes(statuses, options = {}) {
24643
+ const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
24644
+ const why = {
24645
+ too_large: `the file is larger than ${formatMegabytes(maxFileSizeBytes)}`,
24646
+ unsupported_type: "its file type is not supported for reading",
24647
+ no_data: "its contents were not available to the app",
24648
+ empty: "no text or images could be extracted from it (it may be blank)",
24649
+ timeout: "reading it took too long and was stopped",
24650
+ error: "its text could not be extracted (it may be password-protected or damaged)"
24651
+ };
24652
+ const lines = statuses.filter((s) => s.status === "skipped" || s.status === "failed").map((s) => `[${s.fileName} could not be read: ${why[s.reason ?? "error"]}]`);
24653
+ return lines.length > 0 ? lines.join("\n") : null;
24654
+ }
24655
+
24592
24656
  // src/expo/index.ts
24593
24657
  init_logger();
24594
24658
 
@@ -25561,7 +25625,9 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
25561
25625
  addConversationMemoriesOp,
25562
25626
  archiveVaultMemoryOp,
25563
25627
  assembleMemoryContext,
25628
+ attachFileContextToLastUserMessage,
25564
25629
  backfillMemoryTopicsOp,
25630
+ buildAttachedFilesText,
25565
25631
  buildNotionAuthUrl,
25566
25632
  capHopsForDensity,
25567
25633
  chatStorageMigrations,
@@ -25629,6 +25695,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
25629
25695
  extractAndRetain,
25630
25696
  extractEntitiesForMemories,
25631
25697
  extractFacts,
25698
+ formatFileProcessingNotes,
25632
25699
  generateConversationId,
25633
25700
  generateEmbedding,
25634
25701
  generateEmbeddings,
@@ -25654,6 +25721,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
25654
25721
  hasEncryptionKey,
25655
25722
  ingestPublishedPhotoMemoriesOp,
25656
25723
  injectionSignatureCatalog,
25724
+ isAttachedFilesText,
25657
25725
  isDegradedTopicSkip,
25658
25726
  isEncrypted,
25659
25727
  isPiiRedactor,
@@ -3180,6 +3180,18 @@ interface ProcessedFileResult {
3180
3180
  imageDataUrls?: string[];
3181
3181
  /** Optional metadata about the extraction */
3182
3182
  metadata?: {
3183
+ /**
3184
+ * True when the processor itself dropped part of the file (e.g. spreadsheet rows past the
3185
+ * per-sheet cap). Surfaces as a `"truncated"` {@link FileProcessingStatus}.
3186
+ */
3187
+ truncated?: boolean;
3188
+ /**
3189
+ * The exact sentence in `extractedText` that describes `imageDataUrls` (e.g. "pages 2-3
3190
+ * rendered as images and included in this message"). A consumer that drops some or all of
3191
+ * those images (the cross-file image budget, a zip archive) replaces this sentence so the
3192
+ * model is never told an image was included when it was not.
3193
+ */
3194
+ imageNote?: string;
3183
3195
  pageCount?: number;
3184
3196
  sheetCount?: number;
3185
3197
  sheetNames?: string[];
@@ -3204,6 +3216,33 @@ interface FileProcessor {
3204
3216
  */
3205
3217
  process(file: FileWithData): Promise<ProcessedFileResult | null>;
3206
3218
  }
3219
+ /**
3220
+ * Why a file was not (fully) read. Paired with {@link FileProcessingStatus}.
3221
+ *
3222
+ * - `too_large`: over `maxFileSizeBytes`
3223
+ * - `unsupported_type`: no processor handles the file's type
3224
+ * - `no_data`: the file has no URL/data to read
3225
+ * - `empty`: the file was read but contained no extractable content
3226
+ * - `timeout`: processing exceeded `timeoutMs`
3227
+ * - `error`: the processor threw (corrupt, password-protected, …)
3228
+ */
3229
+ type FileProcessingReason = "too_large" | "unsupported_type" | "no_data" | "empty" | "timeout" | "error";
3230
+ /**
3231
+ * What happened to one attached file during preprocessing — so the app can tell the user
3232
+ * precisely which attachment the model could not read, and why.
3233
+ *
3234
+ * - `extracted`: its full text reached the model
3235
+ * - `truncated`: part of it reached the model (a size/row/image budget cut the rest)
3236
+ * - `rendered_as_images`: some or all pages were sent as images (scanned PDF)
3237
+ * - `skipped`: not processed (see `reason`)
3238
+ * - `failed`: processing was attempted and failed (see `reason`)
3239
+ */
3240
+ interface FileProcessingStatus {
3241
+ fileId: string;
3242
+ fileName: string;
3243
+ status: "extracted" | "truncated" | "rendered_as_images" | "skipped" | "failed";
3244
+ reason?: FileProcessingReason;
3245
+ }
3207
3246
 
3208
3247
  /**
3209
3248
  * Server-side tools caching module
@@ -10991,6 +11030,57 @@ declare function ensureDefaultFoldersOp(ctx: VaultFolderOperationsContext): Prom
10991
11030
  */
10992
11031
  declare const TOOL_RESULT_ORIGIN = "tool_result";
10993
11032
 
11033
+ /**
11034
+ * True when a text part is the attachment-contents part built by {@link buildAttachedFilesText}.
11035
+ *
11036
+ * Matches the whole generated shape — opening tag plus the fixed header line, and the closing
11037
+ * tag — not just the tag, so user text that merely starts with `<attached_files>` is still
11038
+ * treated as the user's prompt.
11039
+ */
11040
+ declare function isAttachedFilesText(text: string | undefined | null): boolean;
11041
+ /**
11042
+ * Wrap a turn's extracted file contents (the `[Extracted content from <name>]`
11043
+ * blocks `preprocessFiles` emits) in the tagged part that rides on that turn's
11044
+ * user message.
11045
+ */
11046
+ declare function buildAttachedFilesText(fileContext: string): string;
11047
+ /**
11048
+ * Put the current turn's extracted attachment contents on the last user
11049
+ * message, as a text part inserted right after that message's LAST text part:
11050
+ * after everything the user wrote, and before any parts that follow it
11051
+ * (typically images). With interleaved parts such as `[text, image, text,
11052
+ * image]` it lands between the second text and the second image.
11053
+ *
11054
+ * Why not a system message: a detached system message at the front of the
11055
+ * request ("the user has attached files to this conversation") is separated
11056
+ * from the words that refer to it by the whole system prompt, tool catalog and
11057
+ * history. In a long, multi-file conversation fast models stopped connecting
11058
+ * the two and told users the attachment was unreadable even though its text
11059
+ * was in the request. Keeping the contents on the turn that attached them is
11060
+ * how native file attachments work on every provider, and survives the auto
11061
+ * router switching models between turns.
11062
+ *
11063
+ * The part goes AFTER the user's own text because the portal's query
11064
+ * classifier routes on the first text part of the last user message — it must
11065
+ * keep reading the user's prompt, not the document.
11066
+ *
11067
+ * Returns a new array; the input is not mutated. When there is no user
11068
+ * message the messages are returned unchanged.
11069
+ */
11070
+ declare function attachFileContextToLastUserMessage(messages: LlmapiMessage[], fileContext: string): LlmapiMessage[];
11071
+
11072
+ /**
11073
+ * One line per file the model did NOT get, saying why — e.g.
11074
+ * `[order.pdf could not be read: the file is larger than 10 MB]`.
11075
+ *
11076
+ * Put these in the same `<attached_files>` part as the extracted contents so the model can tell
11077
+ * the user exactly which attachment it could not read instead of guessing ("an unreadable image
11078
+ * placeholder"). Returns null when every file was read.
11079
+ */
11080
+ declare function formatFileProcessingNotes(statuses: FileProcessingStatus[], options?: {
11081
+ maxFileSizeBytes?: number;
11082
+ }): string | null;
11083
+
10994
11084
  /**
10995
11085
  * Pluggable logger for the Anuma SDK.
10996
11086
  *
@@ -11208,4 +11298,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
11208
11298
  */
11209
11299
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
11210
11300
 
11211
- export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, 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, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, 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 ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, 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 PortalLlmFailure, type PortalLlmFailureReason, 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 RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, 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, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, 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 VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, 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, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, 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, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
11301
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, 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, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, 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 ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, 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 PortalLlmFailure, type PortalLlmFailureReason, 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 RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, 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, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, 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 VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, 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, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, 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, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
@@ -3180,6 +3180,18 @@ interface ProcessedFileResult {
3180
3180
  imageDataUrls?: string[];
3181
3181
  /** Optional metadata about the extraction */
3182
3182
  metadata?: {
3183
+ /**
3184
+ * True when the processor itself dropped part of the file (e.g. spreadsheet rows past the
3185
+ * per-sheet cap). Surfaces as a `"truncated"` {@link FileProcessingStatus}.
3186
+ */
3187
+ truncated?: boolean;
3188
+ /**
3189
+ * The exact sentence in `extractedText` that describes `imageDataUrls` (e.g. "pages 2-3
3190
+ * rendered as images and included in this message"). A consumer that drops some or all of
3191
+ * those images (the cross-file image budget, a zip archive) replaces this sentence so the
3192
+ * model is never told an image was included when it was not.
3193
+ */
3194
+ imageNote?: string;
3183
3195
  pageCount?: number;
3184
3196
  sheetCount?: number;
3185
3197
  sheetNames?: string[];
@@ -3204,6 +3216,33 @@ interface FileProcessor {
3204
3216
  */
3205
3217
  process(file: FileWithData): Promise<ProcessedFileResult | null>;
3206
3218
  }
3219
+ /**
3220
+ * Why a file was not (fully) read. Paired with {@link FileProcessingStatus}.
3221
+ *
3222
+ * - `too_large`: over `maxFileSizeBytes`
3223
+ * - `unsupported_type`: no processor handles the file's type
3224
+ * - `no_data`: the file has no URL/data to read
3225
+ * - `empty`: the file was read but contained no extractable content
3226
+ * - `timeout`: processing exceeded `timeoutMs`
3227
+ * - `error`: the processor threw (corrupt, password-protected, …)
3228
+ */
3229
+ type FileProcessingReason = "too_large" | "unsupported_type" | "no_data" | "empty" | "timeout" | "error";
3230
+ /**
3231
+ * What happened to one attached file during preprocessing — so the app can tell the user
3232
+ * precisely which attachment the model could not read, and why.
3233
+ *
3234
+ * - `extracted`: its full text reached the model
3235
+ * - `truncated`: part of it reached the model (a size/row/image budget cut the rest)
3236
+ * - `rendered_as_images`: some or all pages were sent as images (scanned PDF)
3237
+ * - `skipped`: not processed (see `reason`)
3238
+ * - `failed`: processing was attempted and failed (see `reason`)
3239
+ */
3240
+ interface FileProcessingStatus {
3241
+ fileId: string;
3242
+ fileName: string;
3243
+ status: "extracted" | "truncated" | "rendered_as_images" | "skipped" | "failed";
3244
+ reason?: FileProcessingReason;
3245
+ }
3207
3246
 
3208
3247
  /**
3209
3248
  * Server-side tools caching module
@@ -10991,6 +11030,57 @@ declare function ensureDefaultFoldersOp(ctx: VaultFolderOperationsContext): Prom
10991
11030
  */
10992
11031
  declare const TOOL_RESULT_ORIGIN = "tool_result";
10993
11032
 
11033
+ /**
11034
+ * True when a text part is the attachment-contents part built by {@link buildAttachedFilesText}.
11035
+ *
11036
+ * Matches the whole generated shape — opening tag plus the fixed header line, and the closing
11037
+ * tag — not just the tag, so user text that merely starts with `<attached_files>` is still
11038
+ * treated as the user's prompt.
11039
+ */
11040
+ declare function isAttachedFilesText(text: string | undefined | null): boolean;
11041
+ /**
11042
+ * Wrap a turn's extracted file contents (the `[Extracted content from <name>]`
11043
+ * blocks `preprocessFiles` emits) in the tagged part that rides on that turn's
11044
+ * user message.
11045
+ */
11046
+ declare function buildAttachedFilesText(fileContext: string): string;
11047
+ /**
11048
+ * Put the current turn's extracted attachment contents on the last user
11049
+ * message, as a text part inserted right after that message's LAST text part:
11050
+ * after everything the user wrote, and before any parts that follow it
11051
+ * (typically images). With interleaved parts such as `[text, image, text,
11052
+ * image]` it lands between the second text and the second image.
11053
+ *
11054
+ * Why not a system message: a detached system message at the front of the
11055
+ * request ("the user has attached files to this conversation") is separated
11056
+ * from the words that refer to it by the whole system prompt, tool catalog and
11057
+ * history. In a long, multi-file conversation fast models stopped connecting
11058
+ * the two and told users the attachment was unreadable even though its text
11059
+ * was in the request. Keeping the contents on the turn that attached them is
11060
+ * how native file attachments work on every provider, and survives the auto
11061
+ * router switching models between turns.
11062
+ *
11063
+ * The part goes AFTER the user's own text because the portal's query
11064
+ * classifier routes on the first text part of the last user message — it must
11065
+ * keep reading the user's prompt, not the document.
11066
+ *
11067
+ * Returns a new array; the input is not mutated. When there is no user
11068
+ * message the messages are returned unchanged.
11069
+ */
11070
+ declare function attachFileContextToLastUserMessage(messages: LlmapiMessage[], fileContext: string): LlmapiMessage[];
11071
+
11072
+ /**
11073
+ * One line per file the model did NOT get, saying why — e.g.
11074
+ * `[order.pdf could not be read: the file is larger than 10 MB]`.
11075
+ *
11076
+ * Put these in the same `<attached_files>` part as the extracted contents so the model can tell
11077
+ * the user exactly which attachment it could not read instead of guessing ("an unreadable image
11078
+ * placeholder"). Returns null when every file was read.
11079
+ */
11080
+ declare function formatFileProcessingNotes(statuses: FileProcessingStatus[], options?: {
11081
+ maxFileSizeBytes?: number;
11082
+ }): string | null;
11083
+
10994
11084
  /**
10995
11085
  * Pluggable logger for the Anuma SDK.
10996
11086
  *
@@ -11208,4 +11298,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
11208
11298
  */
11209
11299
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
11210
11300
 
11211
- export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, 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, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, 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 ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, 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 PortalLlmFailure, type PortalLlmFailureReason, 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 RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, 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, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, 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 VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, 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, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, 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, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
11301
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, 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, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, 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 ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, 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 PortalLlmFailure, type PortalLlmFailureReason, 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 RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, 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, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSkipReason, 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 VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, 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, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, maskScopedEmbeddingCache, 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, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, verifyMemoriesForPublish, xhrTransport };
@@ -19,7 +19,7 @@ import {
19
19
  taskTypeHeader,
20
20
  validateEndpointOverride,
21
21
  withInternalFlowMarker
22
- } from "./chunk-EDABJLYN.mjs";
22
+ } from "./chunk-N5CKISI3.mjs";
23
23
  import {
24
24
  BASE_URL,
25
25
  MCP_R2_DOMAIN,
@@ -1317,6 +1317,46 @@ async function assembleDecryptedMessage(message, address) {
1317
1317
  // src/lib/db/chat/types.ts
1318
1318
  import { v7 as uuidv7 } from "uuid";
1319
1319
 
1320
+ // src/lib/chat/fileContext.ts
1321
+ var ATTACHED_FILES_OPEN_TAG = "<attached_files>";
1322
+ var ATTACHED_FILES_CLOSE_TAG = "</attached_files>";
1323
+ var ATTACHED_FILES_PREFIX = `${ATTACHED_FILES_OPEN_TAG}
1324
+ The user attached the following file(s) to this message. Their extracted contents are below; when the user refers to "the attached file", "this file" or "the document", they mean these.`;
1325
+ function isAttachedFilesText(text12) {
1326
+ return typeof text12 === "string" && text12.startsWith(ATTACHED_FILES_PREFIX) && text12.endsWith(ATTACHED_FILES_CLOSE_TAG);
1327
+ }
1328
+ function buildAttachedFilesText(fileContext) {
1329
+ return `${ATTACHED_FILES_PREFIX}
1330
+
1331
+ ${fileContext}
1332
+ ${ATTACHED_FILES_CLOSE_TAG}`;
1333
+ }
1334
+ function attachFileContextToLastUserMessage(messages, fileContext) {
1335
+ if (!fileContext.trim()) return messages;
1336
+ let lastUserIndex = -1;
1337
+ for (let i = messages.length - 1; i >= 0; i--) {
1338
+ if (messages[i].role === "user") {
1339
+ lastUserIndex = i;
1340
+ break;
1341
+ }
1342
+ }
1343
+ if (lastUserIndex === -1) return messages;
1344
+ const message = messages[lastUserIndex];
1345
+ const existing = message.content ?? [];
1346
+ let insertAt = 0;
1347
+ existing.forEach((part, index) => {
1348
+ if (part.type === "text") insertAt = index + 1;
1349
+ });
1350
+ const filePart = {
1351
+ type: "text",
1352
+ text: buildAttachedFilesText(fileContext)
1353
+ };
1354
+ const content = [...existing.slice(0, insertAt), filePart, ...existing.slice(insertAt)];
1355
+ const result = [...messages];
1356
+ result[lastUserIndex] = { ...message, content };
1357
+ return result;
1358
+ }
1359
+
1320
1360
  // src/lib/chat/useChat/strategies/types.ts
1321
1361
  function isChatCompletionResponse(r) {
1322
1362
  if (r.object === "response") return false;
@@ -1438,7 +1478,7 @@ function extractUserMessageFromMessages(messages) {
1438
1478
  const textParts = [];
1439
1479
  const files = [];
1440
1480
  for (const part of lastUserMessage.content) {
1441
- if (part.type === "text" && part.text) {
1481
+ if (part.type === "text" && part.text && !isAttachedFilesText(part.text)) {
1442
1482
  textParts.push(part.text);
1443
1483
  } else if (part.type === "image_url" && part.image_url?.url) {
1444
1484
  files.push({
@@ -6020,7 +6060,7 @@ function extractLastUserText(messages) {
6020
6060
  const content = lastUserMsg.content;
6021
6061
  if (typeof content === "string") return content;
6022
6062
  if (Array.isArray(content)) {
6023
- return content.filter((c) => c?.type === "text").map((c) => c.text ?? "").join(" ");
6063
+ return content.filter((c) => c?.type === "text" && !isAttachedFilesText(c.text)).map((c) => c.text ?? "").join(" ");
6024
6064
  }
6025
6065
  return "";
6026
6066
  }
@@ -13876,7 +13916,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
13876
13916
  content: m.content,
13877
13917
  similarity: m.similarity
13878
13918
  }));
13879
- const { consolidateMemory: doConsolidate } = await import("./consolidate-5WM3CFKK.mjs");
13919
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-N56RXPCW.mjs");
13880
13920
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
13881
13921
  if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
13882
13922
  if (decision.action === "supersede" && decision.content) {
@@ -22927,6 +22967,26 @@ async function _ensureDefaultFoldersImpl(ctx) {
22927
22967
  return folderMap;
22928
22968
  }
22929
22969
 
22970
+ // src/lib/processors/fileStatusNotes.ts
22971
+ var DEFAULT_MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
22972
+ function formatMegabytes(bytes) {
22973
+ const mb = bytes / (1024 * 1024);
22974
+ return `${Number.isInteger(mb) ? mb : mb.toFixed(1)} MB`;
22975
+ }
22976
+ function formatFileProcessingNotes(statuses, options = {}) {
22977
+ const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
22978
+ const why = {
22979
+ too_large: `the file is larger than ${formatMegabytes(maxFileSizeBytes)}`,
22980
+ unsupported_type: "its file type is not supported for reading",
22981
+ no_data: "its contents were not available to the app",
22982
+ empty: "no text or images could be extracted from it (it may be blank)",
22983
+ timeout: "reading it took too long and was stopped",
22984
+ error: "its text could not be extracted (it may be password-protected or damaged)"
22985
+ };
22986
+ const lines = statuses.filter((s) => s.status === "skipped" || s.status === "failed").map((s) => `[${s.fileName} could not be read: ${why[s.reason ?? "error"]}]`);
22987
+ return lines.length > 0 ? lines.join("\n") : null;
22988
+ }
22989
+
22930
22990
  // src/react/LoggerProvider.tsx
22931
22991
  import { useLayoutEffect } from "react";
22932
22992
  function LoggerProvider({ logger, children }) {
@@ -23894,7 +23954,9 @@ export {
23894
23954
  addConversationMemoriesOp,
23895
23955
  archiveVaultMemoryOp,
23896
23956
  assembleMemoryContext,
23957
+ attachFileContextToLastUserMessage,
23897
23958
  backfillMemoryTopicsOp,
23959
+ buildAttachedFilesText,
23898
23960
  buildNotionAuthUrl,
23899
23961
  capHopsForDensity,
23900
23962
  chatStorageMigrations,
@@ -23962,6 +24024,7 @@ export {
23962
24024
  extractAndRetain,
23963
24025
  extractEntitiesForMemories,
23964
24026
  extractFacts,
24027
+ formatFileProcessingNotes,
23965
24028
  generateConversationId,
23966
24029
  generateEmbedding,
23967
24030
  generateEmbeddings,
@@ -23987,6 +24050,7 @@ export {
23987
24050
  hasEncryptionKey,
23988
24051
  ingestPublishedPhotoMemoriesOp,
23989
24052
  injectionSignatureCatalog,
24053
+ isAttachedFilesText,
23990
24054
  isDegradedTopicSkip,
23991
24055
  isEncrypted,
23992
24056
  isPiiRedactor,