@anuma/sdk 3.0.0 → 3.1.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.
- package/dist/expo/{chunk-IY7NNIYM.mjs → chunk-IP2B74KE.mjs} +30 -866
- package/dist/expo/index.cjs +1658 -1070
- package/dist/expo/index.d.mts +179 -10
- package/dist/expo/index.d.ts +179 -10
- package/dist/expo/index.mjs +1563 -77
- package/dist/expo/{recall-DJ5LD5WJ.mjs → recall-NSSIYFNY.mjs} +1 -1
- package/dist/index.cjs +415 -394
- package/dist/index.mjs +412 -391
- package/dist/react/{chunk-OSDVRDLI.mjs → chunk-XVC7DWDN.mjs} +22 -1003
- package/dist/react/index.cjs +1702 -1731
- package/dist/react/index.d.mts +103 -12
- package/dist/react/index.d.ts +103 -12
- package/dist/react/index.mjs +1216 -228
- package/dist/react/{recall-3BDCIEQF.mjs → recall-VDP3H3QT.mjs} +1 -1
- package/dist/server/{chunk-QQOIC37O.mjs → chunk-4GKKHVF7.mjs} +21 -833
- package/dist/server/index.cjs +244 -966
- package/dist/server/index.d.mts +95 -12
- package/dist/server/index.d.ts +95 -12
- package/dist/server/index.mjs +189 -32
- package/dist/server/{recall-6QLUEYB7.mjs → recall-KYSR3XZJ.mjs} +1 -1
- package/dist/tools/selection/chunk-4ETHWSXJ.mjs +25 -0
- package/dist/tools/selection/clientConfig-WITO4T6L.mjs +12 -0
- package/dist/tools/selection/index.cjs +1977 -0
- package/dist/tools/selection/index.d.mts +1380 -0
- package/dist/tools/selection/index.d.ts +1380 -0
- package/dist/tools/selection/index.mjs +1859 -0
- package/package.json +8 -1
package/dist/react/index.d.mts
CHANGED
|
@@ -4232,6 +4232,33 @@ interface CachedServerTools {
|
|
|
4232
4232
|
/** Checksum from the server for cache invalidation */
|
|
4233
4233
|
checksum?: string;
|
|
4234
4234
|
}
|
|
4235
|
+
/**
|
|
4236
|
+
* Pluggable persistence for the fetched server-tools list.
|
|
4237
|
+
*
|
|
4238
|
+
* The default backend ({@link localStorageToolsCache}) writes to browser
|
|
4239
|
+
* `localStorage` and is a silent no-op where `localStorage` is undefined
|
|
4240
|
+
* (Node, React Native). Pass a custom backend to `getServerTools` to cache
|
|
4241
|
+
* somewhere that survives on those platforms — e.g. an AsyncStorage/MMKV
|
|
4242
|
+
* adapter on RN, or an in-memory `Map` on a server. Methods may be sync or
|
|
4243
|
+
* async; `getServerTools` awaits them either way.
|
|
4244
|
+
*
|
|
4245
|
+
* The stored payload carries a `version`; `getServerTools` discards any entry
|
|
4246
|
+
* whose version does not match the current cache format, so a stale custom
|
|
4247
|
+
* backend can never feed an incompatible shape back into selection.
|
|
4248
|
+
*/
|
|
4249
|
+
interface ToolsCacheBackend {
|
|
4250
|
+
/** Return the cached payload, or null when absent/unreadable. */
|
|
4251
|
+
get(): CachedServerTools | null | Promise<CachedServerTools | null>;
|
|
4252
|
+
/** Persist the payload. Implementations should swallow write failures. */
|
|
4253
|
+
set(value: CachedServerTools): void | Promise<void>;
|
|
4254
|
+
/**
|
|
4255
|
+
* Remove the cached payload. Optional — a read/write-only backend may omit it,
|
|
4256
|
+
* in which case `clearServerToolsCache` (and the version-mismatch
|
|
4257
|
+
* invalidation) is a no-op for that backend. The default
|
|
4258
|
+
* {@link localStorageToolsCache} implements it.
|
|
4259
|
+
*/
|
|
4260
|
+
clear?(): void | Promise<void>;
|
|
4261
|
+
}
|
|
4235
4262
|
/**
|
|
4236
4263
|
* Options for fetching server tools
|
|
4237
4264
|
*/
|
|
@@ -4246,6 +4273,12 @@ interface ServerToolsOptions {
|
|
|
4246
4273
|
getToken?: () => Promise<string | null>;
|
|
4247
4274
|
/** Direct API key for server-side usage (uses X-API-Key header) */
|
|
4248
4275
|
apiKey?: string;
|
|
4276
|
+
/**
|
|
4277
|
+
* Where to read/write the cached tools list. Defaults to
|
|
4278
|
+
* {@link localStorageToolsCache} (browser `localStorage`; no-op elsewhere).
|
|
4279
|
+
* Provide a backend to enable caching on Node / React Native.
|
|
4280
|
+
*/
|
|
4281
|
+
cache?: ToolsCacheBackend;
|
|
4249
4282
|
}
|
|
4250
4283
|
/** Default cache expiration: 1 day */
|
|
4251
4284
|
declare const DEFAULT_CACHE_EXPIRATION_MS: number;
|
|
@@ -4261,14 +4294,21 @@ interface ParsedServerToolsResponse {
|
|
|
4261
4294
|
*/
|
|
4262
4295
|
declare function getCachedServerTools(): CachedServerTools | null;
|
|
4263
4296
|
/**
|
|
4264
|
-
* Clear the server tools
|
|
4297
|
+
* Clear the cached server tools. Defaults to the browser-`localStorage` backend;
|
|
4298
|
+
* pass the SAME {@link ToolsCacheBackend} you gave `getServerTools` to invalidate
|
|
4299
|
+
* a custom backend (a no-op when that backend defines no `clear`). Returns the
|
|
4300
|
+
* backend's clear result, which may be async.
|
|
4265
4301
|
*/
|
|
4266
4302
|
declare function clearServerToolsCache(): void;
|
|
4303
|
+
declare function clearServerToolsCache(cache: ToolsCacheBackend): void | Promise<void>;
|
|
4267
4304
|
/**
|
|
4268
|
-
* Get the checksum of currently cached tools
|
|
4269
|
-
*
|
|
4305
|
+
* Get the checksum of the currently cached tools, or undefined when there is no
|
|
4306
|
+
* cache / no stored checksum. Defaults to the browser-`localStorage` backend;
|
|
4307
|
+
* pass the SAME backend you gave `getServerTools` to read a custom backend's
|
|
4308
|
+
* checksum (an async backend yields a promise).
|
|
4270
4309
|
*/
|
|
4271
4310
|
declare function getToolsChecksum(): string | undefined;
|
|
4311
|
+
declare function getToolsChecksum(cache: ToolsCacheBackend): string | undefined | Promise<string | undefined>;
|
|
4272
4312
|
/**
|
|
4273
4313
|
* Check if tools should be refreshed based on checksum comparison.
|
|
4274
4314
|
* Returns true if:
|
|
@@ -4280,11 +4320,12 @@ declare function getToolsChecksum(): string | undefined;
|
|
|
4280
4320
|
* - Checksums match
|
|
4281
4321
|
*/
|
|
4282
4322
|
declare function shouldRefreshTools(responseChecksum: string | undefined): boolean;
|
|
4323
|
+
declare function shouldRefreshTools(responseChecksum: string | undefined, cache: ToolsCacheBackend | undefined): boolean | Promise<boolean>;
|
|
4283
4324
|
/**
|
|
4284
4325
|
* Get server tools with caching support.
|
|
4285
4326
|
*
|
|
4286
4327
|
* Flow:
|
|
4287
|
-
* 1. Check localStorage cache
|
|
4328
|
+
* 1. Check the cache backend (localStorage by default; override via `cache`)
|
|
4288
4329
|
* 2. If cache valid and not force refresh, return cached tools
|
|
4289
4330
|
* 3. Otherwise, fetch from API, cache, and return
|
|
4290
4331
|
* 4. On fetch failure, return cached tools if available (stale-while-error)
|
|
@@ -4574,6 +4615,11 @@ interface SelectServerToolsForPromptOptions {
|
|
|
4574
4615
|
embeddingModel?: string;
|
|
4575
4616
|
/** Cache expiration in ms for the server-tools catalog fetch. */
|
|
4576
4617
|
cacheExpirationMs?: number;
|
|
4618
|
+
/**
|
|
4619
|
+
* Where to read/write the cached catalog. Defaults to browser `localStorage`
|
|
4620
|
+
* (a no-op on Node/RN); pass a backend to persist on those platforms.
|
|
4621
|
+
*/
|
|
4622
|
+
cache?: ToolsCacheBackend;
|
|
4577
4623
|
/**
|
|
4578
4624
|
* Phase 3 defer-loading. When `enabled`, this helper returns the FULL catalog (skipping semantic/
|
|
4579
4625
|
* static filtering) to mirror useChatStorage's responses send path, which swaps in the full catalog
|
|
@@ -4993,6 +5039,13 @@ interface BaseUseChatStorageOptions {
|
|
|
4993
5039
|
* {@link DeferLoadingConfig}.
|
|
4994
5040
|
*/
|
|
4995
5041
|
deferLoading?: DeferLoadingConfig;
|
|
5042
|
+
/**
|
|
5043
|
+
* Where to read/write the cached server-tools catalog. Defaults to browser
|
|
5044
|
+
* `localStorage`, which is a silent no-op on React Native — so on RN pass an
|
|
5045
|
+
* AsyncStorage/MMKV-backed {@link ToolsCacheBackend} here or every send
|
|
5046
|
+
* refetches the whole catalog. Forwarded to `getServerTools`.
|
|
5047
|
+
*/
|
|
5048
|
+
cache?: ToolsCacheBackend;
|
|
4996
5049
|
};
|
|
4997
5050
|
/**
|
|
4998
5051
|
* Automatically generate embeddings for messages after saving.
|
|
@@ -7064,14 +7117,14 @@ declare function createChunkVectorCache(maxSize?: number): ChunkVectorCache;
|
|
|
7064
7117
|
declare function recall(query: string, ctx: RecallContext, options?: RecallOptions): Promise<RecallResult>;
|
|
7065
7118
|
|
|
7066
7119
|
/**
|
|
7067
|
-
*
|
|
7120
|
+
* Recall tool constants — deliberately dependency-free.
|
|
7068
7121
|
*
|
|
7069
|
-
*
|
|
7070
|
-
*
|
|
7071
|
-
* `
|
|
7072
|
-
*
|
|
7122
|
+
* Split out of `recallTool.ts` so the tool NAME can be referenced from
|
|
7123
|
+
* node/React-Native-safe modules (e.g. the client-tool selector in
|
|
7124
|
+
* `../tools/clientToolSelection`) without dragging `recall()` and its
|
|
7125
|
+
* WatermelonDB-backed operations into the module graph. `recallTool.ts`
|
|
7126
|
+
* re-exports these to preserve their public identity.
|
|
7073
7127
|
*/
|
|
7074
|
-
|
|
7075
7128
|
/** Tool name surfaced to the LLM. Exported so bench harnesses and chat
|
|
7076
7129
|
* clients reference the same string — drift between prod and bench would
|
|
7077
7130
|
* mask tool-routing bugs in eval. */
|
|
@@ -7079,6 +7132,16 @@ declare const RECALL_TOOL_NAME = "recall_memory";
|
|
|
7079
7132
|
/** Maximum results the executor will return to the LLM, regardless of
|
|
7080
7133
|
* the LLM-supplied `limit`. */
|
|
7081
7134
|
declare const RECALL_MAX_LIMIT = 50;
|
|
7135
|
+
|
|
7136
|
+
/**
|
|
7137
|
+
* Unified Recall Tool
|
|
7138
|
+
*
|
|
7139
|
+
* Single chat-completion tool that searches both vault facts and
|
|
7140
|
+
* conversation chunks via `recall()`. Replaces the legacy pair of
|
|
7141
|
+
* `memory_vault_search` (facts) + `search_memory` (chunks) — the LLM no
|
|
7142
|
+
* longer has to route between two tools.
|
|
7143
|
+
*/
|
|
7144
|
+
|
|
7082
7145
|
interface RecallToolOptions {
|
|
7083
7146
|
/** Lanes to search. Default: ["fact", "chunk"]. */
|
|
7084
7147
|
types?: MemoryKind[];
|
|
@@ -7382,11 +7445,26 @@ declare function chunkText(text: string, options?: ChunkingOptions): TextChunk[]
|
|
|
7382
7445
|
declare function shouldChunkMessage(content: string, chunkSize?: number): boolean;
|
|
7383
7446
|
|
|
7384
7447
|
/**
|
|
7385
|
-
*
|
|
7448
|
+
* Embedding generation — dependency-free core.
|
|
7449
|
+
*
|
|
7450
|
+
* The raw "text → embedding" calls, split out of `embeddings.ts` so they can be
|
|
7451
|
+
* imported by node/React-Native-safe modules (the server-tool + client-tool
|
|
7452
|
+
* selection engine in `../tools`) WITHOUT pulling in the WatermelonDB-backed
|
|
7453
|
+
* `db/chat/operations` that `embeddings.ts` needs for its message-persistence
|
|
7454
|
+
* helpers (`embedMessage`, `embedAllMessages`, `chunkAndEmbed*`).
|
|
7386
7455
|
*
|
|
7387
|
-
*
|
|
7456
|
+
* Nothing here touches the database; the only I/O is the HTTP embeddings
|
|
7457
|
+
* endpoint. `embeddings.ts` re-exports these so existing importers of
|
|
7458
|
+
* `../memoryEngine/embeddings` (and the `../memoryEngine` barrel) keep working.
|
|
7388
7459
|
*/
|
|
7389
7460
|
|
|
7461
|
+
/**
|
|
7462
|
+
* Generate an embedding for text using the API
|
|
7463
|
+
*
|
|
7464
|
+
* Supports two auth methods:
|
|
7465
|
+
* - `apiKey`: Uses X-API-Key header (for server-side/CLI usage)
|
|
7466
|
+
* - `getToken`: Uses Authorization: Bearer header (for Privy identity tokens)
|
|
7467
|
+
*/
|
|
7390
7468
|
declare function generateEmbedding(text: string, options: EmbeddingOptions): Promise<number[]>;
|
|
7391
7469
|
/**
|
|
7392
7470
|
* Generate embeddings for multiple texts, automatically chunking large inputs.
|
|
@@ -7401,6 +7479,18 @@ declare function generateEmbedding(text: string, options: EmbeddingOptions): Pro
|
|
|
7401
7479
|
* @returns Array of embeddings in the same order as input texts
|
|
7402
7480
|
*/
|
|
7403
7481
|
declare function generateEmbeddings(texts: string[], options: EmbeddingOptions): Promise<number[][]>;
|
|
7482
|
+
|
|
7483
|
+
/**
|
|
7484
|
+
* Memory Retrieval Embeddings
|
|
7485
|
+
*
|
|
7486
|
+
* Message-level embedding + persistence helpers: find messages via the
|
|
7487
|
+
* WatermelonDB-backed `db/chat/operations`, embed their content, and store the
|
|
7488
|
+
* vectors/chunks back. The raw "text → embedding" calls live in `./generate`
|
|
7489
|
+
* (dependency-free so the tool-selection engine can import them without the DB
|
|
7490
|
+
* layer) and are re-exported here so existing importers of
|
|
7491
|
+
* `../memoryEngine/embeddings` and the `../memoryEngine` barrel keep working.
|
|
7492
|
+
*/
|
|
7493
|
+
|
|
7404
7494
|
/**
|
|
7405
7495
|
* Embed a single message and store the embedding in the database
|
|
7406
7496
|
*
|
|
@@ -7688,6 +7778,7 @@ declare function previewToolSelection(options: {
|
|
|
7688
7778
|
serverToolsConfig?: {
|
|
7689
7779
|
cacheExpirationMs?: number;
|
|
7690
7780
|
deferLoading?: DeferLoadingConfig;
|
|
7781
|
+
cache?: ToolsCacheBackend;
|
|
7691
7782
|
};
|
|
7692
7783
|
/** Bearer-token auth (browser sessions). Provide this or `apiKey`. */
|
|
7693
7784
|
getToken?: () => Promise<string | null>;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -4232,6 +4232,33 @@ interface CachedServerTools {
|
|
|
4232
4232
|
/** Checksum from the server for cache invalidation */
|
|
4233
4233
|
checksum?: string;
|
|
4234
4234
|
}
|
|
4235
|
+
/**
|
|
4236
|
+
* Pluggable persistence for the fetched server-tools list.
|
|
4237
|
+
*
|
|
4238
|
+
* The default backend ({@link localStorageToolsCache}) writes to browser
|
|
4239
|
+
* `localStorage` and is a silent no-op where `localStorage` is undefined
|
|
4240
|
+
* (Node, React Native). Pass a custom backend to `getServerTools` to cache
|
|
4241
|
+
* somewhere that survives on those platforms — e.g. an AsyncStorage/MMKV
|
|
4242
|
+
* adapter on RN, or an in-memory `Map` on a server. Methods may be sync or
|
|
4243
|
+
* async; `getServerTools` awaits them either way.
|
|
4244
|
+
*
|
|
4245
|
+
* The stored payload carries a `version`; `getServerTools` discards any entry
|
|
4246
|
+
* whose version does not match the current cache format, so a stale custom
|
|
4247
|
+
* backend can never feed an incompatible shape back into selection.
|
|
4248
|
+
*/
|
|
4249
|
+
interface ToolsCacheBackend {
|
|
4250
|
+
/** Return the cached payload, or null when absent/unreadable. */
|
|
4251
|
+
get(): CachedServerTools | null | Promise<CachedServerTools | null>;
|
|
4252
|
+
/** Persist the payload. Implementations should swallow write failures. */
|
|
4253
|
+
set(value: CachedServerTools): void | Promise<void>;
|
|
4254
|
+
/**
|
|
4255
|
+
* Remove the cached payload. Optional — a read/write-only backend may omit it,
|
|
4256
|
+
* in which case `clearServerToolsCache` (and the version-mismatch
|
|
4257
|
+
* invalidation) is a no-op for that backend. The default
|
|
4258
|
+
* {@link localStorageToolsCache} implements it.
|
|
4259
|
+
*/
|
|
4260
|
+
clear?(): void | Promise<void>;
|
|
4261
|
+
}
|
|
4235
4262
|
/**
|
|
4236
4263
|
* Options for fetching server tools
|
|
4237
4264
|
*/
|
|
@@ -4246,6 +4273,12 @@ interface ServerToolsOptions {
|
|
|
4246
4273
|
getToken?: () => Promise<string | null>;
|
|
4247
4274
|
/** Direct API key for server-side usage (uses X-API-Key header) */
|
|
4248
4275
|
apiKey?: string;
|
|
4276
|
+
/**
|
|
4277
|
+
* Where to read/write the cached tools list. Defaults to
|
|
4278
|
+
* {@link localStorageToolsCache} (browser `localStorage`; no-op elsewhere).
|
|
4279
|
+
* Provide a backend to enable caching on Node / React Native.
|
|
4280
|
+
*/
|
|
4281
|
+
cache?: ToolsCacheBackend;
|
|
4249
4282
|
}
|
|
4250
4283
|
/** Default cache expiration: 1 day */
|
|
4251
4284
|
declare const DEFAULT_CACHE_EXPIRATION_MS: number;
|
|
@@ -4261,14 +4294,21 @@ interface ParsedServerToolsResponse {
|
|
|
4261
4294
|
*/
|
|
4262
4295
|
declare function getCachedServerTools(): CachedServerTools | null;
|
|
4263
4296
|
/**
|
|
4264
|
-
* Clear the server tools
|
|
4297
|
+
* Clear the cached server tools. Defaults to the browser-`localStorage` backend;
|
|
4298
|
+
* pass the SAME {@link ToolsCacheBackend} you gave `getServerTools` to invalidate
|
|
4299
|
+
* a custom backend (a no-op when that backend defines no `clear`). Returns the
|
|
4300
|
+
* backend's clear result, which may be async.
|
|
4265
4301
|
*/
|
|
4266
4302
|
declare function clearServerToolsCache(): void;
|
|
4303
|
+
declare function clearServerToolsCache(cache: ToolsCacheBackend): void | Promise<void>;
|
|
4267
4304
|
/**
|
|
4268
|
-
* Get the checksum of currently cached tools
|
|
4269
|
-
*
|
|
4305
|
+
* Get the checksum of the currently cached tools, or undefined when there is no
|
|
4306
|
+
* cache / no stored checksum. Defaults to the browser-`localStorage` backend;
|
|
4307
|
+
* pass the SAME backend you gave `getServerTools` to read a custom backend's
|
|
4308
|
+
* checksum (an async backend yields a promise).
|
|
4270
4309
|
*/
|
|
4271
4310
|
declare function getToolsChecksum(): string | undefined;
|
|
4311
|
+
declare function getToolsChecksum(cache: ToolsCacheBackend): string | undefined | Promise<string | undefined>;
|
|
4272
4312
|
/**
|
|
4273
4313
|
* Check if tools should be refreshed based on checksum comparison.
|
|
4274
4314
|
* Returns true if:
|
|
@@ -4280,11 +4320,12 @@ declare function getToolsChecksum(): string | undefined;
|
|
|
4280
4320
|
* - Checksums match
|
|
4281
4321
|
*/
|
|
4282
4322
|
declare function shouldRefreshTools(responseChecksum: string | undefined): boolean;
|
|
4323
|
+
declare function shouldRefreshTools(responseChecksum: string | undefined, cache: ToolsCacheBackend | undefined): boolean | Promise<boolean>;
|
|
4283
4324
|
/**
|
|
4284
4325
|
* Get server tools with caching support.
|
|
4285
4326
|
*
|
|
4286
4327
|
* Flow:
|
|
4287
|
-
* 1. Check localStorage cache
|
|
4328
|
+
* 1. Check the cache backend (localStorage by default; override via `cache`)
|
|
4288
4329
|
* 2. If cache valid and not force refresh, return cached tools
|
|
4289
4330
|
* 3. Otherwise, fetch from API, cache, and return
|
|
4290
4331
|
* 4. On fetch failure, return cached tools if available (stale-while-error)
|
|
@@ -4574,6 +4615,11 @@ interface SelectServerToolsForPromptOptions {
|
|
|
4574
4615
|
embeddingModel?: string;
|
|
4575
4616
|
/** Cache expiration in ms for the server-tools catalog fetch. */
|
|
4576
4617
|
cacheExpirationMs?: number;
|
|
4618
|
+
/**
|
|
4619
|
+
* Where to read/write the cached catalog. Defaults to browser `localStorage`
|
|
4620
|
+
* (a no-op on Node/RN); pass a backend to persist on those platforms.
|
|
4621
|
+
*/
|
|
4622
|
+
cache?: ToolsCacheBackend;
|
|
4577
4623
|
/**
|
|
4578
4624
|
* Phase 3 defer-loading. When `enabled`, this helper returns the FULL catalog (skipping semantic/
|
|
4579
4625
|
* static filtering) to mirror useChatStorage's responses send path, which swaps in the full catalog
|
|
@@ -4993,6 +5039,13 @@ interface BaseUseChatStorageOptions {
|
|
|
4993
5039
|
* {@link DeferLoadingConfig}.
|
|
4994
5040
|
*/
|
|
4995
5041
|
deferLoading?: DeferLoadingConfig;
|
|
5042
|
+
/**
|
|
5043
|
+
* Where to read/write the cached server-tools catalog. Defaults to browser
|
|
5044
|
+
* `localStorage`, which is a silent no-op on React Native — so on RN pass an
|
|
5045
|
+
* AsyncStorage/MMKV-backed {@link ToolsCacheBackend} here or every send
|
|
5046
|
+
* refetches the whole catalog. Forwarded to `getServerTools`.
|
|
5047
|
+
*/
|
|
5048
|
+
cache?: ToolsCacheBackend;
|
|
4996
5049
|
};
|
|
4997
5050
|
/**
|
|
4998
5051
|
* Automatically generate embeddings for messages after saving.
|
|
@@ -7064,14 +7117,14 @@ declare function createChunkVectorCache(maxSize?: number): ChunkVectorCache;
|
|
|
7064
7117
|
declare function recall(query: string, ctx: RecallContext, options?: RecallOptions): Promise<RecallResult>;
|
|
7065
7118
|
|
|
7066
7119
|
/**
|
|
7067
|
-
*
|
|
7120
|
+
* Recall tool constants — deliberately dependency-free.
|
|
7068
7121
|
*
|
|
7069
|
-
*
|
|
7070
|
-
*
|
|
7071
|
-
* `
|
|
7072
|
-
*
|
|
7122
|
+
* Split out of `recallTool.ts` so the tool NAME can be referenced from
|
|
7123
|
+
* node/React-Native-safe modules (e.g. the client-tool selector in
|
|
7124
|
+
* `../tools/clientToolSelection`) without dragging `recall()` and its
|
|
7125
|
+
* WatermelonDB-backed operations into the module graph. `recallTool.ts`
|
|
7126
|
+
* re-exports these to preserve their public identity.
|
|
7073
7127
|
*/
|
|
7074
|
-
|
|
7075
7128
|
/** Tool name surfaced to the LLM. Exported so bench harnesses and chat
|
|
7076
7129
|
* clients reference the same string — drift between prod and bench would
|
|
7077
7130
|
* mask tool-routing bugs in eval. */
|
|
@@ -7079,6 +7132,16 @@ declare const RECALL_TOOL_NAME = "recall_memory";
|
|
|
7079
7132
|
/** Maximum results the executor will return to the LLM, regardless of
|
|
7080
7133
|
* the LLM-supplied `limit`. */
|
|
7081
7134
|
declare const RECALL_MAX_LIMIT = 50;
|
|
7135
|
+
|
|
7136
|
+
/**
|
|
7137
|
+
* Unified Recall Tool
|
|
7138
|
+
*
|
|
7139
|
+
* Single chat-completion tool that searches both vault facts and
|
|
7140
|
+
* conversation chunks via `recall()`. Replaces the legacy pair of
|
|
7141
|
+
* `memory_vault_search` (facts) + `search_memory` (chunks) — the LLM no
|
|
7142
|
+
* longer has to route between two tools.
|
|
7143
|
+
*/
|
|
7144
|
+
|
|
7082
7145
|
interface RecallToolOptions {
|
|
7083
7146
|
/** Lanes to search. Default: ["fact", "chunk"]. */
|
|
7084
7147
|
types?: MemoryKind[];
|
|
@@ -7382,11 +7445,26 @@ declare function chunkText(text: string, options?: ChunkingOptions): TextChunk[]
|
|
|
7382
7445
|
declare function shouldChunkMessage(content: string, chunkSize?: number): boolean;
|
|
7383
7446
|
|
|
7384
7447
|
/**
|
|
7385
|
-
*
|
|
7448
|
+
* Embedding generation — dependency-free core.
|
|
7449
|
+
*
|
|
7450
|
+
* The raw "text → embedding" calls, split out of `embeddings.ts` so they can be
|
|
7451
|
+
* imported by node/React-Native-safe modules (the server-tool + client-tool
|
|
7452
|
+
* selection engine in `../tools`) WITHOUT pulling in the WatermelonDB-backed
|
|
7453
|
+
* `db/chat/operations` that `embeddings.ts` needs for its message-persistence
|
|
7454
|
+
* helpers (`embedMessage`, `embedAllMessages`, `chunkAndEmbed*`).
|
|
7386
7455
|
*
|
|
7387
|
-
*
|
|
7456
|
+
* Nothing here touches the database; the only I/O is the HTTP embeddings
|
|
7457
|
+
* endpoint. `embeddings.ts` re-exports these so existing importers of
|
|
7458
|
+
* `../memoryEngine/embeddings` (and the `../memoryEngine` barrel) keep working.
|
|
7388
7459
|
*/
|
|
7389
7460
|
|
|
7461
|
+
/**
|
|
7462
|
+
* Generate an embedding for text using the API
|
|
7463
|
+
*
|
|
7464
|
+
* Supports two auth methods:
|
|
7465
|
+
* - `apiKey`: Uses X-API-Key header (for server-side/CLI usage)
|
|
7466
|
+
* - `getToken`: Uses Authorization: Bearer header (for Privy identity tokens)
|
|
7467
|
+
*/
|
|
7390
7468
|
declare function generateEmbedding(text: string, options: EmbeddingOptions): Promise<number[]>;
|
|
7391
7469
|
/**
|
|
7392
7470
|
* Generate embeddings for multiple texts, automatically chunking large inputs.
|
|
@@ -7401,6 +7479,18 @@ declare function generateEmbedding(text: string, options: EmbeddingOptions): Pro
|
|
|
7401
7479
|
* @returns Array of embeddings in the same order as input texts
|
|
7402
7480
|
*/
|
|
7403
7481
|
declare function generateEmbeddings(texts: string[], options: EmbeddingOptions): Promise<number[][]>;
|
|
7482
|
+
|
|
7483
|
+
/**
|
|
7484
|
+
* Memory Retrieval Embeddings
|
|
7485
|
+
*
|
|
7486
|
+
* Message-level embedding + persistence helpers: find messages via the
|
|
7487
|
+
* WatermelonDB-backed `db/chat/operations`, embed their content, and store the
|
|
7488
|
+
* vectors/chunks back. The raw "text → embedding" calls live in `./generate`
|
|
7489
|
+
* (dependency-free so the tool-selection engine can import them without the DB
|
|
7490
|
+
* layer) and are re-exported here so existing importers of
|
|
7491
|
+
* `../memoryEngine/embeddings` and the `../memoryEngine` barrel keep working.
|
|
7492
|
+
*/
|
|
7493
|
+
|
|
7404
7494
|
/**
|
|
7405
7495
|
* Embed a single message and store the embedding in the database
|
|
7406
7496
|
*
|
|
@@ -7688,6 +7778,7 @@ declare function previewToolSelection(options: {
|
|
|
7688
7778
|
serverToolsConfig?: {
|
|
7689
7779
|
cacheExpirationMs?: number;
|
|
7690
7780
|
deferLoading?: DeferLoadingConfig;
|
|
7781
|
+
cache?: ToolsCacheBackend;
|
|
7691
7782
|
};
|
|
7692
7783
|
/** Bearer-token auth (browser sessions). Provide this or `apiKey`. */
|
|
7693
7784
|
getToken?: () => Promise<string | null>;
|