@anuma/sdk 6.26.0 → 6.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/index.cjs +72 -2
- package/dist/expo/index.d.mts +93 -1
- package/dist/expo/index.d.ts +93 -1
- package/dist/expo/index.mjs +68 -2
- package/dist/index.cjs +68 -0
- package/dist/index.d.mts +80 -1
- package/dist/index.d.ts +80 -1
- package/dist/index.mjs +64 -0
- package/dist/react/index.cjs +523 -127
- package/dist/react/index.d.mts +333 -206
- package/dist/react/index.d.ts +333 -206
- package/dist/react/index.mjs +519 -127
- package/dist/server/index.cjs +440 -121
- package/dist/server/index.d.mts +85 -7
- package/dist/server/index.d.ts +85 -7
- package/dist/server/index.mjs +439 -121
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -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
|
}
|
|
@@ -21205,6 +21249,7 @@ function useChatStorage(options) {
|
|
|
21205
21249
|
embeddingModel = DEFAULT_API_EMBEDDING_MODEL,
|
|
21206
21250
|
minContentLength = DEFAULT_MIN_CONTENT_LENGTH,
|
|
21207
21251
|
preProcessors,
|
|
21252
|
+
smoothing,
|
|
21208
21253
|
resumable = false,
|
|
21209
21254
|
onCancelResult,
|
|
21210
21255
|
onStreamMeta,
|
|
@@ -21630,6 +21675,7 @@ function useChatStorage(options) {
|
|
|
21630
21675
|
onError,
|
|
21631
21676
|
apiType,
|
|
21632
21677
|
preProcessors,
|
|
21678
|
+
smoothing,
|
|
21633
21679
|
resumable,
|
|
21634
21680
|
onCancelResult,
|
|
21635
21681
|
onStreamMeta,
|
|
@@ -24589,6 +24635,26 @@ async function _ensureDefaultFoldersImpl(ctx) {
|
|
|
24589
24635
|
return folderMap;
|
|
24590
24636
|
}
|
|
24591
24637
|
|
|
24638
|
+
// src/lib/processors/fileStatusNotes.ts
|
|
24639
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
24640
|
+
function formatMegabytes(bytes) {
|
|
24641
|
+
const mb = bytes / (1024 * 1024);
|
|
24642
|
+
return `${Number.isInteger(mb) ? mb : mb.toFixed(1)} MB`;
|
|
24643
|
+
}
|
|
24644
|
+
function formatFileProcessingNotes(statuses, options = {}) {
|
|
24645
|
+
const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
|
|
24646
|
+
const why = {
|
|
24647
|
+
too_large: `the file is larger than ${formatMegabytes(maxFileSizeBytes)}`,
|
|
24648
|
+
unsupported_type: "its file type is not supported for reading",
|
|
24649
|
+
no_data: "its contents were not available to the app",
|
|
24650
|
+
empty: "no text or images could be extracted from it (it may be blank)",
|
|
24651
|
+
timeout: "reading it took too long and was stopped",
|
|
24652
|
+
error: "its text could not be extracted (it may be password-protected or damaged)"
|
|
24653
|
+
};
|
|
24654
|
+
const lines = statuses.filter((s) => s.status === "skipped" || s.status === "failed").map((s) => `[${s.fileName} could not be read: ${why[s.reason ?? "error"]}]`);
|
|
24655
|
+
return lines.length > 0 ? lines.join("\n") : null;
|
|
24656
|
+
}
|
|
24657
|
+
|
|
24592
24658
|
// src/expo/index.ts
|
|
24593
24659
|
init_logger();
|
|
24594
24660
|
|
|
@@ -25561,7 +25627,9 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
|
25561
25627
|
addConversationMemoriesOp,
|
|
25562
25628
|
archiveVaultMemoryOp,
|
|
25563
25629
|
assembleMemoryContext,
|
|
25630
|
+
attachFileContextToLastUserMessage,
|
|
25564
25631
|
backfillMemoryTopicsOp,
|
|
25632
|
+
buildAttachedFilesText,
|
|
25565
25633
|
buildNotionAuthUrl,
|
|
25566
25634
|
capHopsForDensity,
|
|
25567
25635
|
chatStorageMigrations,
|
|
@@ -25629,6 +25697,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
|
25629
25697
|
extractAndRetain,
|
|
25630
25698
|
extractEntitiesForMemories,
|
|
25631
25699
|
extractFacts,
|
|
25700
|
+
formatFileProcessingNotes,
|
|
25632
25701
|
generateConversationId,
|
|
25633
25702
|
generateEmbedding,
|
|
25634
25703
|
generateEmbeddings,
|
|
@@ -25654,6 +25723,7 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
|
25654
25723
|
hasEncryptionKey,
|
|
25655
25724
|
ingestPublishedPhotoMemoriesOp,
|
|
25656
25725
|
injectionSignatureCatalog,
|
|
25726
|
+
isAttachedFilesText,
|
|
25657
25727
|
isDegradedTopicSkip,
|
|
25658
25728
|
isEncrypted,
|
|
25659
25729
|
isPiiRedactor,
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -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
|
|
@@ -3931,6 +3970,8 @@ interface BaseUseChatStorageOptions {
|
|
|
3931
3970
|
* a custom one matching `PromptPreProcessor`.
|
|
3932
3971
|
*/
|
|
3933
3972
|
preProcessors?: PromptPreProcessor[];
|
|
3973
|
+
/** Output pacing forwarded to useChat. Set false when the UI batches streamed updates. */
|
|
3974
|
+
smoothing?: StreamSmoothingConfig | boolean;
|
|
3934
3975
|
/**
|
|
3935
3976
|
* Enable best-effort, client-side PII obfuscation (NOT a compliance
|
|
3936
3977
|
* guarantee). Outbound message text is scanned for personally identifiable
|
|
@@ -10991,6 +11032,57 @@ declare function ensureDefaultFoldersOp(ctx: VaultFolderOperationsContext): Prom
|
|
|
10991
11032
|
*/
|
|
10992
11033
|
declare const TOOL_RESULT_ORIGIN = "tool_result";
|
|
10993
11034
|
|
|
11035
|
+
/**
|
|
11036
|
+
* True when a text part is the attachment-contents part built by {@link buildAttachedFilesText}.
|
|
11037
|
+
*
|
|
11038
|
+
* Matches the whole generated shape — opening tag plus the fixed header line, and the closing
|
|
11039
|
+
* tag — not just the tag, so user text that merely starts with `<attached_files>` is still
|
|
11040
|
+
* treated as the user's prompt.
|
|
11041
|
+
*/
|
|
11042
|
+
declare function isAttachedFilesText(text: string | undefined | null): boolean;
|
|
11043
|
+
/**
|
|
11044
|
+
* Wrap a turn's extracted file contents (the `[Extracted content from <name>]`
|
|
11045
|
+
* blocks `preprocessFiles` emits) in the tagged part that rides on that turn's
|
|
11046
|
+
* user message.
|
|
11047
|
+
*/
|
|
11048
|
+
declare function buildAttachedFilesText(fileContext: string): string;
|
|
11049
|
+
/**
|
|
11050
|
+
* Put the current turn's extracted attachment contents on the last user
|
|
11051
|
+
* message, as a text part inserted right after that message's LAST text part:
|
|
11052
|
+
* after everything the user wrote, and before any parts that follow it
|
|
11053
|
+
* (typically images). With interleaved parts such as `[text, image, text,
|
|
11054
|
+
* image]` it lands between the second text and the second image.
|
|
11055
|
+
*
|
|
11056
|
+
* Why not a system message: a detached system message at the front of the
|
|
11057
|
+
* request ("the user has attached files to this conversation") is separated
|
|
11058
|
+
* from the words that refer to it by the whole system prompt, tool catalog and
|
|
11059
|
+
* history. In a long, multi-file conversation fast models stopped connecting
|
|
11060
|
+
* the two and told users the attachment was unreadable even though its text
|
|
11061
|
+
* was in the request. Keeping the contents on the turn that attached them is
|
|
11062
|
+
* how native file attachments work on every provider, and survives the auto
|
|
11063
|
+
* router switching models between turns.
|
|
11064
|
+
*
|
|
11065
|
+
* The part goes AFTER the user's own text because the portal's query
|
|
11066
|
+
* classifier routes on the first text part of the last user message — it must
|
|
11067
|
+
* keep reading the user's prompt, not the document.
|
|
11068
|
+
*
|
|
11069
|
+
* Returns a new array; the input is not mutated. When there is no user
|
|
11070
|
+
* message the messages are returned unchanged.
|
|
11071
|
+
*/
|
|
11072
|
+
declare function attachFileContextToLastUserMessage(messages: LlmapiMessage[], fileContext: string): LlmapiMessage[];
|
|
11073
|
+
|
|
11074
|
+
/**
|
|
11075
|
+
* One line per file the model did NOT get, saying why — e.g.
|
|
11076
|
+
* `[order.pdf could not be read: the file is larger than 10 MB]`.
|
|
11077
|
+
*
|
|
11078
|
+
* Put these in the same `<attached_files>` part as the extracted contents so the model can tell
|
|
11079
|
+
* the user exactly which attachment it could not read instead of guessing ("an unreadable image
|
|
11080
|
+
* placeholder"). Returns null when every file was read.
|
|
11081
|
+
*/
|
|
11082
|
+
declare function formatFileProcessingNotes(statuses: FileProcessingStatus[], options?: {
|
|
11083
|
+
maxFileSizeBytes?: number;
|
|
11084
|
+
}): string | null;
|
|
11085
|
+
|
|
10994
11086
|
/**
|
|
10995
11087
|
* Pluggable logger for the Anuma SDK.
|
|
10996
11088
|
*
|
|
@@ -11208,4 +11300,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
|
|
|
11208
11300
|
*/
|
|
11209
11301
|
declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
|
|
11210
11302
|
|
|
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 };
|
|
11303
|
+
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 StreamSmoothingConfig, 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 };
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -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
|
|
@@ -3931,6 +3970,8 @@ interface BaseUseChatStorageOptions {
|
|
|
3931
3970
|
* a custom one matching `PromptPreProcessor`.
|
|
3932
3971
|
*/
|
|
3933
3972
|
preProcessors?: PromptPreProcessor[];
|
|
3973
|
+
/** Output pacing forwarded to useChat. Set false when the UI batches streamed updates. */
|
|
3974
|
+
smoothing?: StreamSmoothingConfig | boolean;
|
|
3934
3975
|
/**
|
|
3935
3976
|
* Enable best-effort, client-side PII obfuscation (NOT a compliance
|
|
3936
3977
|
* guarantee). Outbound message text is scanned for personally identifiable
|
|
@@ -10991,6 +11032,57 @@ declare function ensureDefaultFoldersOp(ctx: VaultFolderOperationsContext): Prom
|
|
|
10991
11032
|
*/
|
|
10992
11033
|
declare const TOOL_RESULT_ORIGIN = "tool_result";
|
|
10993
11034
|
|
|
11035
|
+
/**
|
|
11036
|
+
* True when a text part is the attachment-contents part built by {@link buildAttachedFilesText}.
|
|
11037
|
+
*
|
|
11038
|
+
* Matches the whole generated shape — opening tag plus the fixed header line, and the closing
|
|
11039
|
+
* tag — not just the tag, so user text that merely starts with `<attached_files>` is still
|
|
11040
|
+
* treated as the user's prompt.
|
|
11041
|
+
*/
|
|
11042
|
+
declare function isAttachedFilesText(text: string | undefined | null): boolean;
|
|
11043
|
+
/**
|
|
11044
|
+
* Wrap a turn's extracted file contents (the `[Extracted content from <name>]`
|
|
11045
|
+
* blocks `preprocessFiles` emits) in the tagged part that rides on that turn's
|
|
11046
|
+
* user message.
|
|
11047
|
+
*/
|
|
11048
|
+
declare function buildAttachedFilesText(fileContext: string): string;
|
|
11049
|
+
/**
|
|
11050
|
+
* Put the current turn's extracted attachment contents on the last user
|
|
11051
|
+
* message, as a text part inserted right after that message's LAST text part:
|
|
11052
|
+
* after everything the user wrote, and before any parts that follow it
|
|
11053
|
+
* (typically images). With interleaved parts such as `[text, image, text,
|
|
11054
|
+
* image]` it lands between the second text and the second image.
|
|
11055
|
+
*
|
|
11056
|
+
* Why not a system message: a detached system message at the front of the
|
|
11057
|
+
* request ("the user has attached files to this conversation") is separated
|
|
11058
|
+
* from the words that refer to it by the whole system prompt, tool catalog and
|
|
11059
|
+
* history. In a long, multi-file conversation fast models stopped connecting
|
|
11060
|
+
* the two and told users the attachment was unreadable even though its text
|
|
11061
|
+
* was in the request. Keeping the contents on the turn that attached them is
|
|
11062
|
+
* how native file attachments work on every provider, and survives the auto
|
|
11063
|
+
* router switching models between turns.
|
|
11064
|
+
*
|
|
11065
|
+
* The part goes AFTER the user's own text because the portal's query
|
|
11066
|
+
* classifier routes on the first text part of the last user message — it must
|
|
11067
|
+
* keep reading the user's prompt, not the document.
|
|
11068
|
+
*
|
|
11069
|
+
* Returns a new array; the input is not mutated. When there is no user
|
|
11070
|
+
* message the messages are returned unchanged.
|
|
11071
|
+
*/
|
|
11072
|
+
declare function attachFileContextToLastUserMessage(messages: LlmapiMessage[], fileContext: string): LlmapiMessage[];
|
|
11073
|
+
|
|
11074
|
+
/**
|
|
11075
|
+
* One line per file the model did NOT get, saying why — e.g.
|
|
11076
|
+
* `[order.pdf could not be read: the file is larger than 10 MB]`.
|
|
11077
|
+
*
|
|
11078
|
+
* Put these in the same `<attached_files>` part as the extracted contents so the model can tell
|
|
11079
|
+
* the user exactly which attachment it could not read instead of guessing ("an unreadable image
|
|
11080
|
+
* placeholder"). Returns null when every file was read.
|
|
11081
|
+
*/
|
|
11082
|
+
declare function formatFileProcessingNotes(statuses: FileProcessingStatus[], options?: {
|
|
11083
|
+
maxFileSizeBytes?: number;
|
|
11084
|
+
}): string | null;
|
|
11085
|
+
|
|
10994
11086
|
/**
|
|
10995
11087
|
* Pluggable logger for the Anuma SDK.
|
|
10996
11088
|
*
|
|
@@ -11208,4 +11300,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
|
|
|
11208
11300
|
*/
|
|
11209
11301
|
declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
|
|
11210
11302
|
|
|
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 };
|
|
11303
|
+
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 StreamSmoothingConfig, 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 };
|
package/dist/expo/index.mjs
CHANGED
|
@@ -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
|
}
|
|
@@ -19542,6 +19582,7 @@ function useChatStorage(options) {
|
|
|
19542
19582
|
embeddingModel = DEFAULT_API_EMBEDDING_MODEL,
|
|
19543
19583
|
minContentLength = DEFAULT_MIN_CONTENT_LENGTH,
|
|
19544
19584
|
preProcessors,
|
|
19585
|
+
smoothing,
|
|
19545
19586
|
resumable = false,
|
|
19546
19587
|
onCancelResult,
|
|
19547
19588
|
onStreamMeta,
|
|
@@ -19967,6 +20008,7 @@ function useChatStorage(options) {
|
|
|
19967
20008
|
onError,
|
|
19968
20009
|
apiType,
|
|
19969
20010
|
preProcessors,
|
|
20011
|
+
smoothing,
|
|
19970
20012
|
resumable,
|
|
19971
20013
|
onCancelResult,
|
|
19972
20014
|
onStreamMeta,
|
|
@@ -22927,6 +22969,26 @@ async function _ensureDefaultFoldersImpl(ctx) {
|
|
|
22927
22969
|
return folderMap;
|
|
22928
22970
|
}
|
|
22929
22971
|
|
|
22972
|
+
// src/lib/processors/fileStatusNotes.ts
|
|
22973
|
+
var DEFAULT_MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
22974
|
+
function formatMegabytes(bytes) {
|
|
22975
|
+
const mb = bytes / (1024 * 1024);
|
|
22976
|
+
return `${Number.isInteger(mb) ? mb : mb.toFixed(1)} MB`;
|
|
22977
|
+
}
|
|
22978
|
+
function formatFileProcessingNotes(statuses, options = {}) {
|
|
22979
|
+
const maxFileSizeBytes = options.maxFileSizeBytes ?? DEFAULT_MAX_FILE_SIZE_BYTES;
|
|
22980
|
+
const why = {
|
|
22981
|
+
too_large: `the file is larger than ${formatMegabytes(maxFileSizeBytes)}`,
|
|
22982
|
+
unsupported_type: "its file type is not supported for reading",
|
|
22983
|
+
no_data: "its contents were not available to the app",
|
|
22984
|
+
empty: "no text or images could be extracted from it (it may be blank)",
|
|
22985
|
+
timeout: "reading it took too long and was stopped",
|
|
22986
|
+
error: "its text could not be extracted (it may be password-protected or damaged)"
|
|
22987
|
+
};
|
|
22988
|
+
const lines = statuses.filter((s) => s.status === "skipped" || s.status === "failed").map((s) => `[${s.fileName} could not be read: ${why[s.reason ?? "error"]}]`);
|
|
22989
|
+
return lines.length > 0 ? lines.join("\n") : null;
|
|
22990
|
+
}
|
|
22991
|
+
|
|
22930
22992
|
// src/react/LoggerProvider.tsx
|
|
22931
22993
|
import { useLayoutEffect } from "react";
|
|
22932
22994
|
function LoggerProvider({ logger, children }) {
|
|
@@ -23894,7 +23956,9 @@ export {
|
|
|
23894
23956
|
addConversationMemoriesOp,
|
|
23895
23957
|
archiveVaultMemoryOp,
|
|
23896
23958
|
assembleMemoryContext,
|
|
23959
|
+
attachFileContextToLastUserMessage,
|
|
23897
23960
|
backfillMemoryTopicsOp,
|
|
23961
|
+
buildAttachedFilesText,
|
|
23898
23962
|
buildNotionAuthUrl,
|
|
23899
23963
|
capHopsForDensity,
|
|
23900
23964
|
chatStorageMigrations,
|
|
@@ -23962,6 +24026,7 @@ export {
|
|
|
23962
24026
|
extractAndRetain,
|
|
23963
24027
|
extractEntitiesForMemories,
|
|
23964
24028
|
extractFacts,
|
|
24029
|
+
formatFileProcessingNotes,
|
|
23965
24030
|
generateConversationId,
|
|
23966
24031
|
generateEmbedding,
|
|
23967
24032
|
generateEmbeddings,
|
|
@@ -23987,6 +24052,7 @@ export {
|
|
|
23987
24052
|
hasEncryptionKey,
|
|
23988
24053
|
ingestPublishedPhotoMemoriesOp,
|
|
23989
24054
|
injectionSignatureCatalog,
|
|
24055
|
+
isAttachedFilesText,
|
|
23990
24056
|
isDegradedTopicSkip,
|
|
23991
24057
|
isEncrypted,
|
|
23992
24058
|
isPiiRedactor,
|