@mikesaintsg/core 0.0.1 → 0.0.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/README.md +175 -365
- package/dist/index.d.ts +26 -433
- package/dist/index.js +164 -746
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,43 +3,6 @@ export declare interface AbortableOptions {
|
|
|
3
3
|
readonly signal?: AbortSignal;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
/** Anthropic embedding adapter options */
|
|
7
|
-
export declare interface AnthropicEmbeddingAdapterOptions {
|
|
8
|
-
readonly apiKey: string;
|
|
9
|
-
readonly model?: string;
|
|
10
|
-
readonly baseURL?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/** Anthropic provider adapter options */
|
|
14
|
-
export declare interface AnthropicProviderAdapterOptions {
|
|
15
|
-
readonly apiKey: string;
|
|
16
|
-
readonly model?: string;
|
|
17
|
-
readonly baseURL?: string;
|
|
18
|
-
readonly defaultOptions?: GenerationDefaults;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Anthropic tool schema format */
|
|
22
|
-
export declare interface AnthropicTool {
|
|
23
|
-
readonly name: string;
|
|
24
|
-
readonly description: string;
|
|
25
|
-
readonly input_schema: unknown;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Anthropic tool format adapter options */
|
|
29
|
-
export declare interface AnthropicToolFormatAdapterOptions {
|
|
30
|
-
readonly toolChoice?: 'auto' | 'any' | {
|
|
31
|
-
readonly name: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Anthropic tool use content block */
|
|
36
|
-
export declare interface AnthropicToolUse {
|
|
37
|
-
readonly type: 'tool_use';
|
|
38
|
-
readonly id: string;
|
|
39
|
-
readonly name: string;
|
|
40
|
-
readonly input: Readonly<Record<string, unknown>>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
6
|
/** Batched embedding adapter interface - extends base with batching */
|
|
44
7
|
export declare interface BatchedEmbeddingAdapterInterface extends EmbeddingAdapterInterface {
|
|
45
8
|
queue(text: string, options?: AbortableOptions): Promise<Embedding>;
|
|
@@ -130,95 +93,9 @@ export declare class CoreError extends Error {
|
|
|
130
93
|
/** Core package error codes */
|
|
131
94
|
export declare type CoreErrorCode = 'ADAPTER_ERROR' | 'BRIDGE_ERROR' | 'VALIDATION_ERROR' | 'NOT_FOUND' | 'TIMEOUT' | 'ABORTED';
|
|
132
95
|
|
|
133
|
-
/**
|
|
134
|
-
* Create an Anthropic-compatible embedding adapter.
|
|
135
|
-
*
|
|
136
|
-
* Note: Anthropic recommends Voyage AI for embeddings, so this adapter
|
|
137
|
-
* uses the Voyage AI API. The apiKey should be a Voyage AI API key.
|
|
138
|
-
*
|
|
139
|
-
* @param options - Adapter configuration
|
|
140
|
-
* @returns An embedding adapter for Anthropic/Voyage
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* const adapter = createAnthropicEmbeddingAdapter({
|
|
145
|
-
* apiKey: process.env.VOYAGE_API_KEY,
|
|
146
|
-
* model: 'voyage-2',
|
|
147
|
-
* })
|
|
148
|
-
*
|
|
149
|
-
* const embeddings = await adapter.embed(['Hello, world!'])
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
export declare function createAnthropicEmbeddingAdapter(options: AnthropicEmbeddingAdapterOptions): EmbeddingAdapterInterface;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Create an Anthropic tool format adapter.
|
|
156
|
-
*
|
|
157
|
-
* @param options - Adapter options
|
|
158
|
-
* @returns A tool format adapter for Anthropic
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```ts
|
|
162
|
-
* const adapter = createAnthropicToolFormatAdapter({
|
|
163
|
-
* toolChoice: 'auto',
|
|
164
|
-
* })
|
|
165
|
-
*
|
|
166
|
-
* const formatted = adapter.formatSchemas(schemas)
|
|
167
|
-
* const calls = adapter.parseToolCalls(response)
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
export declare function createAnthropicToolFormatAdapter(_options?: AnthropicToolFormatAdapterOptions): ToolFormatAdapterInterface;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Create a batched embedding adapter that wraps any embedding adapter.
|
|
174
|
-
*
|
|
175
|
-
* @param adapter - The base embedding adapter to wrap
|
|
176
|
-
* @param options - Batching configuration options
|
|
177
|
-
* @returns A batched embedding adapter instance
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* const baseAdapter = createOpenAIEmbeddingAdapter({ apiKey: '...' })
|
|
182
|
-
* const cache = createEmbeddingCache({ maxEntries: 1000 })
|
|
183
|
-
*
|
|
184
|
-
* const batched = createBatchedEmbeddingAdapter(baseAdapter, {
|
|
185
|
-
* maxBatchSize: 100,
|
|
186
|
-
* flushDelayMs: 50,
|
|
187
|
-
* deduplicate: true,
|
|
188
|
-
* cache,
|
|
189
|
-
* })
|
|
190
|
-
*
|
|
191
|
-
* // These will be batched together
|
|
192
|
-
* const [e1, e2] = await Promise.all([
|
|
193
|
-
* batched.queue('text 1'),
|
|
194
|
-
* batched.queue('text 2'),
|
|
195
|
-
* ])
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
|
-
export declare function createBatchedEmbeddingAdapter(adapter: EmbeddingAdapterInterface, options?: EmbeddingBatchOptions): BatchedEmbeddingAdapterInterface;
|
|
199
|
-
|
|
200
96
|
/** Factory function for creating embedding cache */
|
|
201
97
|
export declare type CreateEmbeddingCache = (options?: EmbeddingCacheOptions) => EmbeddingCacheInterface;
|
|
202
98
|
|
|
203
|
-
/**
|
|
204
|
-
* Create an in-memory embedding cache with LRU eviction.
|
|
205
|
-
*
|
|
206
|
-
* @param options - Cache configuration options
|
|
207
|
-
* @returns An embedding cache instance
|
|
208
|
-
*
|
|
209
|
-
* @example
|
|
210
|
-
* ```ts
|
|
211
|
-
* const cache = createEmbeddingCache({
|
|
212
|
-
* maxEntries: 1000,
|
|
213
|
-
* ttlMs: 60 * 60 * 1000, // 1 hour
|
|
214
|
-
* })
|
|
215
|
-
*
|
|
216
|
-
* cache.set('hash123', embedding)
|
|
217
|
-
* const cached = cache.get('hash123')
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
export declare function createEmbeddingCache(options?: EmbeddingCacheOptions): EmbeddingCacheInterface;
|
|
221
|
-
|
|
222
99
|
/**
|
|
223
100
|
* Create a navigation guard that prevents leaving when form is dirty.
|
|
224
101
|
*
|
|
@@ -245,102 +122,6 @@ export declare function createEmbeddingCache(options?: EmbeddingCacheOptions): E
|
|
|
245
122
|
*/
|
|
246
123
|
export declare function createFormDirtyGuard<TFormData = unknown, TPage extends string = string>(options: FormDirtyGuardOptions<TFormData, TPage>): NavigationGuard<TPage>;
|
|
247
124
|
|
|
248
|
-
/**
|
|
249
|
-
* Create an HTTP persistence adapter for VectorStore.
|
|
250
|
-
*
|
|
251
|
-
* @param options - Adapter configuration
|
|
252
|
-
* @returns A persistence adapter using HTTP
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* const adapter = createHTTPVectorStorePersistence({
|
|
257
|
-
* baseURL: 'https://api.example.com/vectors',
|
|
258
|
-
* headers: { 'Authorization': 'Bearer token' },
|
|
259
|
-
* })
|
|
260
|
-
*
|
|
261
|
-
* await adapter.save({ id: 'doc1', content: 'hello', embedding: new Float32Array([...]) })
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
export declare function createHTTPVectorStorePersistence(options: HTTPPersistenceOptions): VectorStorePersistenceAdapterInterface;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Create an IndexedDB persistence adapter for VectorStore.
|
|
268
|
-
*
|
|
269
|
-
* @param options - Adapter configuration
|
|
270
|
-
* @returns A persistence adapter using IndexedDB
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* ```ts
|
|
274
|
-
* import { createDatabase } from '@mikesaintsg/indexeddb'
|
|
275
|
-
*
|
|
276
|
-
* const db = await createDatabase({ name: 'vectors' })
|
|
277
|
-
* const adapter = createIndexedDBVectorStorePersistence({
|
|
278
|
-
* database: db,
|
|
279
|
-
* documentsStore: 'embeddings',
|
|
280
|
-
* })
|
|
281
|
-
*
|
|
282
|
-
* await adapter.save({ id: 'doc1', content: 'hello', embedding: new Float32Array([...]) })
|
|
283
|
-
* ```
|
|
284
|
-
*/
|
|
285
|
-
export declare function createIndexedDBVectorStorePersistence(options: IndexedDBVectorStorePersistenceOptions): VectorStorePersistenceAdapterInterface;
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Create an OpenAI embedding adapter.
|
|
289
|
-
*
|
|
290
|
-
* @param options - OpenAI adapter configuration
|
|
291
|
-
* @returns An embedding adapter for OpenAI
|
|
292
|
-
*
|
|
293
|
-
* @example
|
|
294
|
-
* ```ts
|
|
295
|
-
* const adapter = createOpenAIEmbeddingAdapter({
|
|
296
|
-
* apiKey: process.env.OPENAI_API_KEY,
|
|
297
|
-
* model: 'text-embedding-3-small',
|
|
298
|
-
* })
|
|
299
|
-
*
|
|
300
|
-
* const embeddings = await adapter.embed(['Hello, world!'])
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
export declare function createOpenAIEmbeddingAdapter(options: OpenAIEmbeddingAdapterOptions): EmbeddingAdapterInterface;
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Create an OpenAI tool format adapter.
|
|
307
|
-
*
|
|
308
|
-
* @param options - Adapter options
|
|
309
|
-
* @returns A tool format adapter for OpenAI
|
|
310
|
-
*
|
|
311
|
-
* @example
|
|
312
|
-
* ```ts
|
|
313
|
-
* const adapter = createOpenAIToolFormatAdapter({
|
|
314
|
-
* toolChoice: 'auto',
|
|
315
|
-
* })
|
|
316
|
-
*
|
|
317
|
-
* const formatted = adapter.formatSchemas(schemas)
|
|
318
|
-
* const calls = adapter.parseToolCalls(response)
|
|
319
|
-
* ```
|
|
320
|
-
*/
|
|
321
|
-
export declare function createOpenAIToolFormatAdapter(_options?: OpenAIToolFormatAdapterOptions): ToolFormatAdapterInterface;
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Create an OPFS persistence adapter for VectorStore.
|
|
325
|
-
*
|
|
326
|
-
* @param options - Adapter configuration
|
|
327
|
-
* @returns A persistence adapter using OPFS
|
|
328
|
-
*
|
|
329
|
-
* @example
|
|
330
|
-
* ```ts
|
|
331
|
-
* import { createDirectory } from '@mikesaintsg/filesystem'
|
|
332
|
-
*
|
|
333
|
-
* const dir = await createDirectory({ name: 'vectors' })
|
|
334
|
-
* const adapter = createOPFSVectorStorePersistence({
|
|
335
|
-
* directory: dir,
|
|
336
|
-
* chunkSize: 50,
|
|
337
|
-
* })
|
|
338
|
-
*
|
|
339
|
-
* await adapter.save({ id: 'doc1', content: 'hello', embedding: new Float32Array([...]) })
|
|
340
|
-
* ```
|
|
341
|
-
*/
|
|
342
|
-
export declare function createOPFSVectorStorePersistence(options: OPFSVectorStorePersistenceOptions): VectorStorePersistenceAdapterInterface;
|
|
343
|
-
|
|
344
125
|
/**
|
|
345
126
|
* Create a retrieval tool for use with contextprotocol tool registry.
|
|
346
127
|
*
|
|
@@ -432,38 +213,18 @@ export declare interface DeduplicationResult {
|
|
|
432
213
|
}
|
|
433
214
|
|
|
434
215
|
/**
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
* @param data - The plain object from JSON.parse
|
|
439
|
-
* @returns A StoredDocument with proper Float32Array embedding
|
|
440
|
-
*
|
|
441
|
-
* @example
|
|
442
|
-
* ```ts
|
|
443
|
-
* const data = JSON.parse(json)
|
|
444
|
-
* const doc = deserializeStoredDocument(data)
|
|
445
|
-
* ```
|
|
216
|
+
* Base error class for all ecosystem errors.
|
|
217
|
+
* All package-specific errors should extend this class.
|
|
446
218
|
*/
|
|
447
|
-
export declare function deserializeStoredDocument(data: Record<string, unknown>): StoredDocument;
|
|
448
|
-
|
|
449
|
-
/** Base ecosystem error */
|
|
450
219
|
export declare abstract class EcosystemError extends Error {
|
|
451
220
|
abstract readonly code: string;
|
|
452
221
|
readonly cause: Error | undefined;
|
|
222
|
+
constructor(message: string, cause?: Error);
|
|
453
223
|
}
|
|
454
224
|
|
|
455
225
|
/** Embedding vector */
|
|
456
226
|
export declare type Embedding = Float32Array;
|
|
457
227
|
|
|
458
|
-
/** Default flush delay in milliseconds for batched embeddings */
|
|
459
|
-
export declare const EMBEDDING_BATCH_DEFAULT_FLUSH_DELAY_MS = 50;
|
|
460
|
-
|
|
461
|
-
/** Default maximum batch size for embedding requests */
|
|
462
|
-
export declare const EMBEDDING_BATCH_DEFAULT_MAX_SIZE = 100;
|
|
463
|
-
|
|
464
|
-
/** Default maximum entries for embedding cache */
|
|
465
|
-
export declare const EMBEDDING_CACHE_DEFAULT_MAX_ENTRIES = 1000;
|
|
466
|
-
|
|
467
228
|
/** Embedding generation contract */
|
|
468
229
|
export declare interface EmbeddingAdapterInterface {
|
|
469
230
|
embed(texts: readonly string[], options?: AbortableOptions): Promise<readonly Embedding[]>;
|
|
@@ -545,14 +306,6 @@ export declare function err<E>(error: E): Err<E>;
|
|
|
545
306
|
/** Extract error code type */
|
|
546
307
|
export declare type ErrorCode<T extends EcosystemError> = T['code'];
|
|
547
308
|
|
|
548
|
-
/**
|
|
549
|
-
* Estimate the byte size of an embedding.
|
|
550
|
-
*
|
|
551
|
-
* @param embedding - The embedding to measure
|
|
552
|
-
* @returns The byte length of the embedding
|
|
553
|
-
*/
|
|
554
|
-
export declare function estimateEmbeddingBytes(embedding: Embedding): number;
|
|
555
|
-
|
|
556
309
|
/** Default form dirty guard message */
|
|
557
310
|
export declare const FORM_DIRTY_DEFAULT_MESSAGE = "You have unsaved changes. Are you sure you want to leave?";
|
|
558
311
|
|
|
@@ -601,15 +354,13 @@ export declare type FrameType = 'system' | 'instruction' | 'section' | 'file' |
|
|
|
601
354
|
|
|
602
355
|
/** Generation defaults for provider adapters */
|
|
603
356
|
export declare interface GenerationDefaults {
|
|
357
|
+
readonly model?: string;
|
|
604
358
|
readonly temperature?: number;
|
|
605
359
|
readonly maxTokens?: number;
|
|
606
360
|
readonly topP?: number;
|
|
607
361
|
readonly stop?: readonly string[];
|
|
608
362
|
}
|
|
609
363
|
|
|
610
|
-
/** Default timeout for HTTP persistence requests in milliseconds */
|
|
611
|
-
export declare const HTTP_DEFAULT_TIMEOUT = 30000;
|
|
612
|
-
|
|
613
364
|
/** HTTP persistence options */
|
|
614
365
|
export declare interface HTTPPersistenceOptions {
|
|
615
366
|
readonly baseURL: string;
|
|
@@ -617,12 +368,6 @@ export declare interface HTTPPersistenceOptions {
|
|
|
617
368
|
readonly timeout?: number;
|
|
618
369
|
}
|
|
619
370
|
|
|
620
|
-
/** Default documents store name for IndexedDB persistence */
|
|
621
|
-
export declare const INDEXEDDB_DEFAULT_DOCUMENTS_STORE = "documents";
|
|
622
|
-
|
|
623
|
-
/** Default metadata store name for IndexedDB persistence */
|
|
624
|
-
export declare const INDEXEDDB_DEFAULT_METADATA_STORE = "metadata";
|
|
625
|
-
|
|
626
371
|
/** IndexedDB VectorStore persistence options */
|
|
627
372
|
export declare interface IndexedDBVectorStorePersistenceOptions {
|
|
628
373
|
readonly database: MinimalDatabaseAccess;
|
|
@@ -655,7 +400,23 @@ export declare interface InMemoryEmbeddingCacheOptions {
|
|
|
655
400
|
*/
|
|
656
401
|
export declare function isCoreError(error: unknown): error is CoreError;
|
|
657
402
|
|
|
658
|
-
/**
|
|
403
|
+
/**
|
|
404
|
+
* Type guard for ecosystem errors.
|
|
405
|
+
*
|
|
406
|
+
* @param error - The value to check
|
|
407
|
+
* @returns True if the error is an EcosystemError
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```ts
|
|
411
|
+
* try {
|
|
412
|
+
* await someOperation()
|
|
413
|
+
* } catch (error) {
|
|
414
|
+
* if (isEcosystemError(error)) {
|
|
415
|
+
* console.log('Code:', error.code)
|
|
416
|
+
* }
|
|
417
|
+
* }
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
659
420
|
export declare function isEcosystemError(error: unknown): error is EcosystemError;
|
|
660
421
|
|
|
661
422
|
/**
|
|
@@ -714,14 +475,6 @@ export declare interface JSONSchema7 {
|
|
|
714
475
|
readonly definitions?: Readonly<Record<string, JSONSchema7>>;
|
|
715
476
|
}
|
|
716
477
|
|
|
717
|
-
/** Internal LRU cache entry with access tracking */
|
|
718
|
-
export declare interface LRUCacheEntry {
|
|
719
|
-
readonly embedding: Embedding;
|
|
720
|
-
readonly createdAt: number;
|
|
721
|
-
hitCount: number;
|
|
722
|
-
lastAccess: number;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
478
|
/**
|
|
726
479
|
* Map a function over a success value.
|
|
727
480
|
*
|
|
@@ -823,95 +576,6 @@ export declare interface Ok<T> {
|
|
|
823
576
|
*/
|
|
824
577
|
export declare function ok<T>(value: T): Ok<T>;
|
|
825
578
|
|
|
826
|
-
/** OpenAI API base URL */
|
|
827
|
-
export declare const OPENAI_API_BASE_URL = "https://api.openai.com/v1";
|
|
828
|
-
|
|
829
|
-
/** Default dimensions for OpenAI text-embedding-3-small */
|
|
830
|
-
export declare const OPENAI_DEFAULT_EMBEDDING_DIMENSIONS = 1536;
|
|
831
|
-
|
|
832
|
-
/** Default OpenAI embedding model */
|
|
833
|
-
export declare const OPENAI_DEFAULT_EMBEDDING_MODEL = "text-embedding-3-small";
|
|
834
|
-
|
|
835
|
-
/** OpenAI embedding adapter options */
|
|
836
|
-
export declare interface OpenAIEmbeddingAdapterOptions {
|
|
837
|
-
readonly apiKey: string;
|
|
838
|
-
readonly model?: string;
|
|
839
|
-
readonly baseURL?: string;
|
|
840
|
-
readonly dimensions?: number;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
/** OpenAI embedding data item */
|
|
844
|
-
export declare interface OpenAIEmbeddingData {
|
|
845
|
-
readonly object: 'embedding';
|
|
846
|
-
readonly index: number;
|
|
847
|
-
readonly embedding: readonly number[];
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
/** OpenAI embedding API response */
|
|
851
|
-
export declare interface OpenAIEmbeddingResponse {
|
|
852
|
-
readonly object: 'list';
|
|
853
|
-
readonly data: readonly OpenAIEmbeddingData[];
|
|
854
|
-
readonly model: string;
|
|
855
|
-
readonly usage: OpenAIEmbeddingUsage;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
/** OpenAI embedding usage stats */
|
|
859
|
-
export declare interface OpenAIEmbeddingUsage {
|
|
860
|
-
readonly prompt_tokens: number;
|
|
861
|
-
readonly total_tokens: number;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
/** OpenAI provider adapter options */
|
|
865
|
-
export declare interface OpenAIProviderAdapterOptions {
|
|
866
|
-
readonly apiKey: string;
|
|
867
|
-
readonly model?: string;
|
|
868
|
-
readonly baseURL?: string;
|
|
869
|
-
readonly organization?: string;
|
|
870
|
-
readonly defaultOptions?: GenerationDefaults;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
/** OpenAI tool schema format */
|
|
874
|
-
export declare interface OpenAITool {
|
|
875
|
-
readonly type: 'function';
|
|
876
|
-
readonly function: OpenAIToolFunction;
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
/** OpenAI tool call from response */
|
|
880
|
-
export declare interface OpenAIToolCall {
|
|
881
|
-
readonly id: string;
|
|
882
|
-
readonly type: 'function';
|
|
883
|
-
readonly function: OpenAIToolCallFunction;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
/** OpenAI tool call function */
|
|
887
|
-
export declare interface OpenAIToolCallFunction {
|
|
888
|
-
readonly name: string;
|
|
889
|
-
readonly arguments: string;
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
/** OpenAI tool format adapter options */
|
|
893
|
-
export declare interface OpenAIToolFormatAdapterOptions {
|
|
894
|
-
readonly toolChoice?: 'auto' | 'none' | 'required' | {
|
|
895
|
-
readonly name: string;
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
/** OpenAI tool function definition */
|
|
900
|
-
export declare interface OpenAIToolFunction {
|
|
901
|
-
readonly name: string;
|
|
902
|
-
readonly description: string;
|
|
903
|
-
readonly parameters: unknown;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
/** Default chunk size for OPFS persistence */
|
|
907
|
-
export declare const OPFS_DEFAULT_CHUNK_SIZE = 100;
|
|
908
|
-
|
|
909
|
-
/** Documents file name prefix for OPFS persistence */
|
|
910
|
-
export declare const OPFS_DOCUMENTS_PREFIX = "chunk_";
|
|
911
|
-
|
|
912
|
-
/** Metadata file name for OPFS persistence */
|
|
913
|
-
export declare const OPFS_METADATA_FILE = "_metadata.json";
|
|
914
|
-
|
|
915
579
|
/** OPFS VectorStore persistence options */
|
|
916
580
|
export declare interface OPFSVectorStorePersistenceOptions {
|
|
917
581
|
readonly directory: MinimalDirectoryAccess;
|
|
@@ -935,25 +599,6 @@ export declare interface PackageErrorData<TCode extends string> {
|
|
|
935
599
|
readonly cause?: Error;
|
|
936
600
|
}
|
|
937
601
|
|
|
938
|
-
/** Pending embedding request in batch queue */
|
|
939
|
-
export declare interface PendingEmbeddingRequest {
|
|
940
|
-
readonly text: string;
|
|
941
|
-
readonly contentHash: ContentHash;
|
|
942
|
-
resolve: (embedding: Embedding) => void;
|
|
943
|
-
reject: (error: unknown) => void;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
/**
|
|
947
|
-
* Provider adapter interface for LLM providers.
|
|
948
|
-
* Implemented by OpenAI, Anthropic, and other provider adapters.
|
|
949
|
-
*/
|
|
950
|
-
export declare interface ProviderAdapterInterface {
|
|
951
|
-
getId(): string;
|
|
952
|
-
supportsTools(): boolean;
|
|
953
|
-
supportsStreaming(): boolean;
|
|
954
|
-
getCapabilities(): ProviderCapabilities;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
602
|
/** Provider capabilities information */
|
|
958
603
|
export declare interface ProviderCapabilities {
|
|
959
604
|
readonly supportsTools: boolean;
|
|
@@ -1012,7 +657,7 @@ export declare interface ScoredResult {
|
|
|
1012
657
|
*/
|
|
1013
658
|
export declare interface SerializableSession {
|
|
1014
659
|
getMessages(): readonly SerializedMessage[];
|
|
1015
|
-
getMetadata():
|
|
660
|
+
getMetadata(): SerializedSessionMetadata;
|
|
1016
661
|
}
|
|
1017
662
|
|
|
1018
663
|
/** Serialized message for persistence */
|
|
@@ -1027,27 +672,12 @@ export declare interface SerializedMessage {
|
|
|
1027
672
|
export declare interface SerializedSession {
|
|
1028
673
|
readonly id: string;
|
|
1029
674
|
readonly messages: readonly SerializedMessage[];
|
|
1030
|
-
readonly metadata:
|
|
675
|
+
readonly metadata: SerializedSessionMetadata;
|
|
1031
676
|
readonly updatedAt: number;
|
|
1032
677
|
}
|
|
1033
678
|
|
|
1034
|
-
/**
|
|
1035
|
-
|
|
1036
|
-
* Converts Float32Array embeddings to regular arrays.
|
|
1037
|
-
*
|
|
1038
|
-
* @param doc - The document to serialize
|
|
1039
|
-
* @returns A plain object suitable for JSON.stringify
|
|
1040
|
-
*
|
|
1041
|
-
* @example
|
|
1042
|
-
* ```ts
|
|
1043
|
-
* const serialized = serializeStoredDocument(doc)
|
|
1044
|
-
* const json = JSON.stringify(serialized)
|
|
1045
|
-
* ```
|
|
1046
|
-
*/
|
|
1047
|
-
export declare function serializeStoredDocument(doc: StoredDocument): Record<string, unknown>;
|
|
1048
|
-
|
|
1049
|
-
/** Session metadata for persistence */
|
|
1050
|
-
export declare interface SessionMetadata {
|
|
679
|
+
/** Serialized session metadata for persistence */
|
|
680
|
+
export declare interface SerializedSessionMetadata {
|
|
1051
681
|
readonly model: string;
|
|
1052
682
|
readonly provider: string;
|
|
1053
683
|
readonly createdAt: number;
|
|
@@ -1140,6 +770,7 @@ export declare interface ToolCallBridgeOptions {
|
|
|
1140
770
|
/**
|
|
1141
771
|
* Tool format adapter interface.
|
|
1142
772
|
* Converts between internal tool representations and provider-specific formats.
|
|
773
|
+
* Implemented in @mikesaintsg/adapters.
|
|
1143
774
|
*/
|
|
1144
775
|
export declare interface ToolFormatAdapterInterface {
|
|
1145
776
|
formatSchemas(schemas: readonly ToolSchema[]): unknown;
|
|
@@ -1187,12 +818,6 @@ export declare type TruncationReason = 'budget_exceeded' | 'priority_too_low' |
|
|
|
1187
818
|
/** Truncation strategy */
|
|
1188
819
|
export declare type TruncationStrategy = 'priority' | 'fifo' | 'lifo' | 'score' | 'custom';
|
|
1189
820
|
|
|
1190
|
-
/**
|
|
1191
|
-
* @mikesaintsg/core
|
|
1192
|
-
*
|
|
1193
|
-
* Type definitions for the core library.
|
|
1194
|
-
* All public types and interfaces are defined here as the SOURCE OF TRUTH.
|
|
1195
|
-
*/
|
|
1196
821
|
/** Cleanup function returned by event subscriptions */
|
|
1197
822
|
export declare type Unsubscribe = () => void;
|
|
1198
823
|
|
|
@@ -1226,9 +851,6 @@ export declare function unwrap<T, E>(result: Result<T, E>, defaultValue: T): T;
|
|
|
1226
851
|
*/
|
|
1227
852
|
export declare function unwrapOrThrow<T, E>(result: Result<T, E>): T;
|
|
1228
853
|
|
|
1229
|
-
/** Metadata key for VectorStore in persistence */
|
|
1230
|
-
export declare const VECTORSTORE_METADATA_KEY = "vectorstore_metadata";
|
|
1231
|
-
|
|
1232
854
|
/** VectorStore metadata for persistence */
|
|
1233
855
|
export declare interface VectorStoreMetadata {
|
|
1234
856
|
readonly dimensions: number;
|
|
@@ -1267,33 +889,4 @@ export declare interface VectorStoreSearchOptions<TMetadata = unknown> {
|
|
|
1267
889
|
readonly filter?: TMetadata;
|
|
1268
890
|
}
|
|
1269
891
|
|
|
1270
|
-
/** Voyage AI API base URL */
|
|
1271
|
-
export declare const VOYAGE_API_BASE_URL = "https://api.voyageai.com/v1";
|
|
1272
|
-
|
|
1273
|
-
/** Default dimensions for Voyage AI voyage-2 */
|
|
1274
|
-
export declare const VOYAGE_DEFAULT_EMBEDDING_DIMENSIONS = 1024;
|
|
1275
|
-
|
|
1276
|
-
/** Default Voyage AI embedding model (recommended by Anthropic) */
|
|
1277
|
-
export declare const VOYAGE_DEFAULT_EMBEDDING_MODEL = "voyage-2";
|
|
1278
|
-
|
|
1279
|
-
/** Voyage AI embedding data item */
|
|
1280
|
-
export declare interface VoyageEmbeddingData {
|
|
1281
|
-
readonly object: 'embedding';
|
|
1282
|
-
readonly index: number;
|
|
1283
|
-
readonly embedding: readonly number[];
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
/** Voyage AI embedding API response */
|
|
1287
|
-
export declare interface VoyageEmbeddingResponse {
|
|
1288
|
-
readonly object: 'list';
|
|
1289
|
-
readonly data: readonly VoyageEmbeddingData[];
|
|
1290
|
-
readonly model: string;
|
|
1291
|
-
readonly usage: VoyageEmbeddingUsage;
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
/** Voyage AI embedding usage stats */
|
|
1295
|
-
export declare interface VoyageEmbeddingUsage {
|
|
1296
|
-
readonly total_tokens: number;
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
892
|
export { }
|