@asaidimu/utils-workspace 6.1.0 → 6.2.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/README.md +157 -88
- package/index.d.mts +444 -689
- package/index.d.ts +444 -689
- package/index.js +288 -1
- package/index.mjs +287 -1
- package/package.json +3 -2
package/index.d.ts
CHANGED
|
@@ -1,477 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Buffers write operations across one or more stores and commits them atomically.
|
|
6
|
-
*
|
|
7
|
-
* ## How atomicity works
|
|
8
|
-
*
|
|
9
|
-
* ### IndexedDB stores (same database)
|
|
10
|
-
* At commit time, TransactionContext collects the names of every IDB store that
|
|
11
|
-
* received operations, then opens a **single** `IDBTransaction` spanning all of
|
|
12
|
-
* them via `ConnectionManager.openTransaction`. Each store's `executeInTransaction`
|
|
13
|
-
* receives that shared transaction object and performs its writes against it
|
|
14
|
-
* without opening a new transaction of its own. IDB commits or aborts the
|
|
15
|
-
* entire multi-store transaction as one unit.
|
|
16
|
-
*
|
|
17
|
-
* ### MemoryStore
|
|
18
|
-
* MemoryStore's `executeInTransaction` receives `null` for the shared transaction.
|
|
19
|
-
* It applies ops against an internal staging map and returns. If a later
|
|
20
|
-
* participant fails, TransactionContext calls `rollbackMemory` on each
|
|
21
|
-
* MemoryStore that already applied its staged ops. MemoryStore restores its
|
|
22
|
-
* pre-transaction snapshot.
|
|
23
|
-
*
|
|
24
|
-
* ### Mixed (IDB + Memory in the same transaction)
|
|
25
|
-
* All IDB stores are committed first as a single atomic IDB transaction, then
|
|
26
|
-
* each MemoryStore is committed. If a MemoryStore fails after IDB has already
|
|
27
|
-
* committed, the IDB side cannot be rolled back — this is an inherent limitation
|
|
28
|
-
* of mixing two different storage engines. In practice the schema store is
|
|
29
|
-
* always MemoryStore-or-IDB consistently, so mixed transactions should not arise
|
|
30
|
-
* in normal usage.
|
|
31
|
-
*/
|
|
32
|
-
declare class TransactionContext {
|
|
33
|
-
readonly id: string;
|
|
34
|
-
/**
|
|
35
|
-
* Flat list of every operation staged so far, in the order they were added.
|
|
36
|
-
* We keep the store reference alongside the op so commit() can group them.
|
|
37
|
-
*/
|
|
38
|
-
private staged;
|
|
39
|
-
private done;
|
|
40
|
-
constructor();
|
|
41
|
-
/**
|
|
42
|
-
* Stages a single write operation against a store.
|
|
43
|
-
* Does NOT touch the store — no I/O happens until commit().
|
|
44
|
-
*/
|
|
45
|
-
addOp<T extends Record<string, any>>(store: Store$1<T>, type: "put" | "delete" | "add", data: any): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Commits all staged operations atomically.
|
|
48
|
-
*
|
|
49
|
-
* For IDB stores: opens one shared IDBTransaction across all participating
|
|
50
|
-
* stores, then dispatches ops to each store's executeInTransaction.
|
|
51
|
-
* For MemoryStores: dispatches sequentially; rolls back on failure.
|
|
52
|
-
*/
|
|
53
|
-
commit(): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Discards all staged operations. No I/O has occurred so there is nothing
|
|
56
|
-
* to undo — we simply clear the buffer.
|
|
57
|
-
*/
|
|
58
|
-
rollback(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Opens ONE IDBTransaction across all participating IDB stores and lets
|
|
61
|
-
* each store execute its ops against the shared transaction handle.
|
|
62
|
-
*
|
|
63
|
-
* We obtain the IDBDatabase from the first store (they all share the same
|
|
64
|
-
* ConnectionManager / database) and open the transaction ourselves so that
|
|
65
|
-
* the commit/abort lifecycle belongs entirely to this method.
|
|
66
|
-
*/
|
|
67
|
-
private commitIDB;
|
|
68
|
-
/**
|
|
69
|
-
* Commits MemoryStore groups sequentially.
|
|
70
|
-
* Maintains a list of stores that have already applied their ops; if any
|
|
71
|
-
* store throws, all previously-applied stores are rolled back via the
|
|
72
|
-
* store-level `_rollbackMemory(snapshot)` escape hatch.
|
|
73
|
-
*/
|
|
74
|
-
private commitMemory;
|
|
75
|
-
completed(): boolean;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
interface CursorCallbackResult<T> {
|
|
79
|
-
value: T | null;
|
|
80
|
-
done: boolean;
|
|
81
|
-
offset?: number;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Callback function for cursor iteration over store records.
|
|
85
|
-
*
|
|
86
|
-
* @template T - The type of records stored.
|
|
87
|
-
* @param value - The current record value (cloned, not a live reference).
|
|
88
|
-
* @param key - The key (ID) of the current record.
|
|
89
|
-
* @param cursor - The underlying cursor object (implementation-specific; may be `null` in memory adapters).
|
|
90
|
-
* @returns A promise resolving to an object indicating whether iteration should stop,
|
|
91
|
-
* and an optional offset to advance.
|
|
92
|
-
*/
|
|
93
|
-
type CursorCallback<T> = (value: T, key: string | number, cursor: any) => Promise<CursorCallbackResult<T>>;
|
|
94
|
-
/**
|
|
95
|
-
* A generic representation of a key range, replacing the browser-specific IDBKeyRange.
|
|
96
|
-
*/
|
|
97
|
-
interface StoreKeyRange {
|
|
98
|
-
lower?: any;
|
|
99
|
-
upper?: any;
|
|
100
|
-
lowerOpen?: boolean;
|
|
101
|
-
upperOpen?: boolean;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* A single buffered operation staged inside a TransactionContext.
|
|
105
|
-
* Kept intentionally minimal — the context only needs to know what to
|
|
106
|
-
* replay against a store during commit.
|
|
107
|
-
*/
|
|
108
|
-
type BufferedOperation<T> = {
|
|
109
|
-
type: "add" | "put";
|
|
110
|
-
data: T | T[];
|
|
111
|
-
} | {
|
|
112
|
-
type: "delete";
|
|
113
|
-
data: string | number | (string | number)[];
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Storage adapter interface for a single object store (collection).
|
|
117
|
-
*
|
|
118
|
-
* Stores own their indexes. Index lifecycle (create, drop) and index-aware reads
|
|
119
|
-
* (findByIndex) are part of this contract so that both MemoryStore and IndexedDBStore
|
|
120
|
-
* implement them natively — MemoryStore via in-memory index maps, IndexedDB via its
|
|
121
|
-
* native index mechanism.
|
|
122
|
-
*
|
|
123
|
-
* @template T - The type of objects stored. Must include the key path property.
|
|
124
|
-
*/
|
|
125
|
-
interface Store$1<T extends Record<string, any> = Record<string, any>> {
|
|
126
|
-
/**
|
|
127
|
-
* Returns the name of this store (the IDB object store / collection name).
|
|
128
|
-
* Used by TransactionContext to group operations and open a correctly-scoped
|
|
129
|
-
* multi-store IDB transaction at commit time.
|
|
130
|
-
*/
|
|
131
|
-
name(): string;
|
|
132
|
-
/**
|
|
133
|
-
* Opens the store, ensuring underlying storage structures exist.
|
|
134
|
-
*/
|
|
135
|
-
open(): Promise<void>;
|
|
136
|
-
/**
|
|
137
|
-
* Adds one or more records to the store.
|
|
138
|
-
* If a record does not have a value for the store's key path, an automatic
|
|
139
|
-
* key may be assigned. Throws if a record with the same key already exists.
|
|
140
|
-
*/
|
|
141
|
-
add(data: T | T[]): Promise<string | number | (string | number)[]>;
|
|
142
|
-
/**
|
|
143
|
-
* Removes all records from the store without destroying index structures.
|
|
144
|
-
*/
|
|
145
|
-
clear(): Promise<void>;
|
|
146
|
-
/**
|
|
147
|
-
* Returns the total number of records in the store.
|
|
148
|
-
*/
|
|
149
|
-
count(): Promise<number>;
|
|
150
|
-
/**
|
|
151
|
-
* Deletes one or more records by their keys.
|
|
152
|
-
*/
|
|
153
|
-
delete(id: string | number | (string | number)[]): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Retrieves a single record by its primary key.
|
|
156
|
-
*/
|
|
157
|
-
getById(id: string | number): Promise<T | undefined>;
|
|
158
|
-
/**
|
|
159
|
-
* Retrieves the first record matching an exact index key (point lookup).
|
|
160
|
-
* Useful for unique indexes — returns the single matching record or undefined.
|
|
161
|
-
*
|
|
162
|
-
* @param indexName - The name of the index to query.
|
|
163
|
-
* @param key - The exact key value to look up.
|
|
164
|
-
*/
|
|
165
|
-
getByIndex(indexName: string, key: any): Promise<T | undefined>;
|
|
166
|
-
/**
|
|
167
|
-
* Retrieves all records from a named index, optionally filtered by a key range.
|
|
168
|
-
* Use this for range scans over an index (e.g. all records where age >= 18).
|
|
169
|
-
*
|
|
170
|
-
* @param indexName - The name of the index to query.
|
|
171
|
-
* @param keyRange - Optional range to filter results.
|
|
172
|
-
*/
|
|
173
|
-
getByKeyRange(indexName: string, keyRange?: StoreKeyRange): Promise<T[]>;
|
|
174
|
-
/**
|
|
175
|
-
* Retrieves all records from the store without index involvement.
|
|
176
|
-
*/
|
|
177
|
-
getAll(): Promise<T[]>;
|
|
178
|
-
/**
|
|
179
|
-
* Inserts or replaces a record. Validates OCC if a record with the same key exists.
|
|
180
|
-
*/
|
|
181
|
-
put(data: T): Promise<string | number>;
|
|
182
|
-
/**
|
|
183
|
-
* Iterates over records using a cursor, allowing early termination and skipping.
|
|
184
|
-
*
|
|
185
|
-
* @param callback - Invoked for each record; return `{ done: true }` to stop,
|
|
186
|
-
* `{ offset: n }` to skip ahead n records.
|
|
187
|
-
* @param direction - Iteration order.
|
|
188
|
-
* @param keyRange - Optional range to restrict iteration.
|
|
189
|
-
*/
|
|
190
|
-
cursor(callback: CursorCallback<T>, direction?: "forward" | "backward", keyRange?: StoreKeyRange): Promise<T | null>;
|
|
191
|
-
/**
|
|
192
|
-
* Executes a batch of write operations atomically within this store.
|
|
193
|
-
* All operations succeed or fail together.
|
|
194
|
-
*
|
|
195
|
-
* Used for standalone (single-store) atomic writes. For cross-store atomicity,
|
|
196
|
-
* use executeInTransaction instead.
|
|
197
|
-
*/
|
|
198
|
-
batch(operations: Array<{
|
|
199
|
-
type: "add" | "put";
|
|
200
|
-
data: T | T[];
|
|
201
|
-
} | {
|
|
202
|
-
type: "delete";
|
|
203
|
-
data: string | number | (string | number)[];
|
|
204
|
-
}>): Promise<void>;
|
|
205
|
-
/**
|
|
206
|
-
* Registers a new index on the store. Idempotent — no-op if the index already exists.
|
|
207
|
-
* For IndexedDB, this triggers a database version upgrade.
|
|
208
|
-
* For MemoryStore, this builds the index map from existing records.
|
|
209
|
-
*
|
|
210
|
-
* @param definition - The full index definition from the schema.
|
|
211
|
-
*/
|
|
212
|
-
createIndex(definition: IndexDefinition): Promise<void>;
|
|
213
|
-
/**
|
|
214
|
-
* Removes a named index from the store.
|
|
215
|
-
* For IndexedDB, this triggers a database version upgrade.
|
|
216
|
-
* For MemoryStore, this drops the in-memory index map.
|
|
217
|
-
*
|
|
218
|
-
* @param name - The index name as declared in IndexDefinition.name.
|
|
219
|
-
*/
|
|
220
|
-
dropIndex(name: string): Promise<void>;
|
|
221
|
-
/**
|
|
222
|
-
* Returns all records matching an exact index key.
|
|
223
|
-
* Unlike getByIndex (which returns only the first match), this returns all matches —
|
|
224
|
-
* essential for non-unique indexes where multiple records share the same indexed value.
|
|
225
|
-
*
|
|
226
|
-
* @param indexName - The name of the index to query.
|
|
227
|
-
* @param value - The exact value to look up.
|
|
228
|
-
*/
|
|
229
|
-
findByIndex(indexName: string, value: any): Promise<T[]>;
|
|
230
|
-
/**
|
|
231
|
-
* Executes a set of buffered operations as part of a cross-store atomic transaction.
|
|
232
|
-
*
|
|
233
|
-
* For IndexedDBStore: `sharedTx` is the single IDBTransaction opened across all
|
|
234
|
-
* participating stores. Operations are applied directly to `sharedTx.objectStore(name)`
|
|
235
|
-
* without opening a new transaction — IDB commits or aborts the whole thing atomically.
|
|
236
|
-
*
|
|
237
|
-
* For MemoryStore: `sharedTx` is null. The store applies ops against its own staging
|
|
238
|
-
* area. The caller (TransactionContext) is responsible for coordinating rollback across
|
|
239
|
-
* all MemoryStores if any participant fails.
|
|
240
|
-
*
|
|
241
|
-
* This method must NOT open, commit, or abort any transaction itself.
|
|
242
|
-
*
|
|
243
|
-
* @param ops - The buffered operations to apply.
|
|
244
|
-
* @param sharedTx - The shared IDBTransaction (IndexedDB only), or null (MemoryStore).
|
|
245
|
-
*/
|
|
246
|
-
executeInTransaction(ops: BufferedOperation<T>[], sharedTx: IDBTransaction | null): Promise<void>;
|
|
247
|
-
}
|
|
248
|
-
interface Collection<T> {
|
|
249
|
-
/**
|
|
250
|
-
* Finds a single document matching the query.
|
|
251
|
-
*/
|
|
252
|
-
find: (query: QueryFilter<T>) => Promise<Document<T> | null>;
|
|
253
|
-
/**
|
|
254
|
-
* Lists documents with pagination. Returns an AsyncIterator so consumers can
|
|
255
|
-
* wrap it in their own iteration protocol (e.g. for-await-of via AsyncIterable).
|
|
256
|
-
*/
|
|
257
|
-
list: (query: PaginationOptions) => Promise<AsyncIterator<Document<T>[]>>;
|
|
258
|
-
/**
|
|
259
|
-
* Filters all documents matching the query.
|
|
260
|
-
*/
|
|
261
|
-
filter: (query: QueryFilter<T>) => Promise<Document<T>[]>;
|
|
262
|
-
/**
|
|
263
|
-
* Creates a new document in the collection.
|
|
264
|
-
*
|
|
265
|
-
* When a TransactionContext is provided the initial store.add is buffered into
|
|
266
|
-
* the transaction rather than written immediately. The document is returned in
|
|
267
|
-
* its fully initialised in-memory state regardless — callers can use it before
|
|
268
|
-
* the transaction commits.
|
|
269
|
-
*
|
|
270
|
-
* @param initial - The initial data for the document.
|
|
271
|
-
* @param tx - Optional transaction to buffer the write into.
|
|
272
|
-
*/
|
|
273
|
-
create: (initial: T, tx?: TransactionContext) => Promise<Document<T>>;
|
|
274
|
-
/**
|
|
275
|
-
* Updates all documents matching the query with the provided partial data.
|
|
276
|
-
* Returns the number of documents updated.
|
|
277
|
-
*/
|
|
278
|
-
update: (query: QueryFilter<T>, data: Partial<T>, tx?: TransactionContext) => Promise<number>;
|
|
279
|
-
/**
|
|
280
|
-
* Deletes all documents matching the query.
|
|
281
|
-
* Returns the number of documents deleted.
|
|
282
|
-
*/
|
|
283
|
-
delete: (query: QueryFilter<T>, tx?: TransactionContext) => Promise<number>;
|
|
284
|
-
/**
|
|
285
|
-
* Subscribes to collection-level events.
|
|
286
|
-
*/
|
|
287
|
-
subscribe: (event: CollectionEventType | TelemetryEventType, callback: (event: CollectionEvent<T> | TelemetryEvent) => void) => () => void;
|
|
288
|
-
/**
|
|
289
|
-
* Validates data against the collection's schema.
|
|
290
|
-
*/
|
|
291
|
-
validate(data: Record<string, any>): Promise<{
|
|
292
|
-
value?: any;
|
|
293
|
-
issues: Array<{
|
|
294
|
-
message: string;
|
|
295
|
-
path: Array<string>;
|
|
296
|
-
}>;
|
|
297
|
-
}>;
|
|
298
|
-
invalidate(): void;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Event payload for Collection events.
|
|
302
|
-
*/
|
|
303
|
-
type CollectionEventType = "document:create" | "collection:read" | "migration:start" | "migration:end";
|
|
304
|
-
type CollectionEvent<T> = {
|
|
305
|
-
type: CollectionEventType;
|
|
306
|
-
document?: T;
|
|
307
|
-
model?: string;
|
|
308
|
-
method?: keyof Collection<T>;
|
|
309
|
-
metadata?: Record<string, unknown>;
|
|
310
|
-
timestamp: number;
|
|
311
|
-
};
|
|
312
|
-
interface Database {
|
|
313
|
-
/**
|
|
314
|
-
* Opens an existing collection by name.
|
|
315
|
-
*/
|
|
316
|
-
collection: <T>(schemaName: string) => Promise<Collection<T>>;
|
|
317
|
-
/**
|
|
318
|
-
* Creates a new collection from a schema definition.
|
|
319
|
-
*/
|
|
320
|
-
createCollection: <T>(schema: SchemaDefinition) => Promise<Collection<T>>;
|
|
321
|
-
/**
|
|
322
|
-
* Deletes a collection and its schema record.
|
|
323
|
-
*/
|
|
324
|
-
deleteCollection: (schemaName: string) => Promise<boolean>;
|
|
325
|
-
/**
|
|
326
|
-
* Updates an existing collection's schema record.
|
|
327
|
-
*/
|
|
328
|
-
updateCollection: (schema: SchemaDefinition) => Promise<boolean>;
|
|
329
|
-
/**
|
|
330
|
-
* Migrates an existing collection's data and schema definition.
|
|
331
|
-
* Processes data in a streaming fashion to avoid loading the full collection
|
|
332
|
-
* into memory.
|
|
333
|
-
*/
|
|
334
|
-
migrateCollection: <T>(name: string, opts: CollectionMigrationOptions, batchSize?: number) => Promise<Collection<T>>;
|
|
335
|
-
/**
|
|
336
|
-
* Executes a callback within a TransactionContext.
|
|
337
|
-
* Writes buffered inside the callback are flushed atomically on commit.
|
|
338
|
-
* If the callback throws, the buffer is discarded (no writes are flushed).
|
|
339
|
-
*/
|
|
340
|
-
transaction: (callback: (tx: TransactionContext) => Promise<void>) => Promise<void>;
|
|
341
|
-
/**
|
|
342
|
-
* Subscribes to database-level events.
|
|
343
|
-
*/
|
|
344
|
-
subscribe: (event: DatabaseEventType | "telemetry", callback: (event: DatabaseEvent | TelemetryEvent) => void) => () => void;
|
|
345
|
-
/**
|
|
346
|
-
* Releases in-memory references and event bus subscriptions.
|
|
347
|
-
* Does not delete any persisted data.
|
|
348
|
-
*/
|
|
349
|
-
close: () => void;
|
|
350
|
-
clear: () => Promise<void>;
|
|
351
|
-
/**
|
|
352
|
-
* Ensures a collection exists; creates it if it doesn't. Idempotent.
|
|
353
|
-
*/
|
|
354
|
-
ensureCollection: (schema: SchemaDefinition) => Promise<void>;
|
|
355
|
-
/**
|
|
356
|
-
* Ensures multiple collections exist; creates any that don't. Idempotent.
|
|
357
|
-
*/
|
|
358
|
-
setupCollections: (schemas: SchemaDefinition[]) => Promise<void>;
|
|
359
|
-
}
|
|
360
|
-
type CollectionMigrationOptions = {
|
|
361
|
-
changes: SchemaChange<any>[];
|
|
362
|
-
description: string;
|
|
363
|
-
rollback?: SchemaChange<any>[];
|
|
364
|
-
transform?: string | DataTransform<any, any>;
|
|
365
|
-
};
|
|
366
|
-
type DatabaseEventType = "collection:create" | "collection:delete" | "collection:update" | "collection:read" | "migrate";
|
|
367
|
-
type DatabaseEvent = {
|
|
368
|
-
type: DatabaseEventType;
|
|
369
|
-
schema?: SchemaDefinition | Partial<SchemaDefinition>;
|
|
370
|
-
timestamp: number;
|
|
371
|
-
};
|
|
372
|
-
type DocumentMetadata = {
|
|
373
|
-
$id?: string;
|
|
374
|
-
$created?: string | Date;
|
|
375
|
-
$updated?: string | Date;
|
|
376
|
-
$version?: number;
|
|
377
|
-
};
|
|
378
|
-
type Document<T> = {
|
|
379
|
-
readonly [K in keyof T]: T[K];
|
|
380
|
-
} & DocumentMetadata & {
|
|
381
|
-
read: () => Promise<boolean>;
|
|
382
|
-
save: (tx?: TransactionContext) => Promise<boolean>;
|
|
383
|
-
update: (props: Partial<T>, tx?: TransactionContext) => Promise<boolean>;
|
|
384
|
-
delete: (tx?: TransactionContext) => Promise<boolean>;
|
|
385
|
-
subscribe: (event: DocumentEventType | TelemetryEventType, callback: (event: DocumentEvent<T> | TelemetryEvent) => void) => () => void;
|
|
386
|
-
state(): T;
|
|
387
|
-
$metadata(): DocumentMetadata;
|
|
388
|
-
};
|
|
389
|
-
type DocumentEventType = "document:create" | "document:write" | "document:update" | "document:delete" | "document:read";
|
|
390
|
-
type DocumentEvent<T> = {
|
|
391
|
-
type: DocumentEventType;
|
|
392
|
-
data?: Partial<T>;
|
|
393
|
-
timestamp: number;
|
|
394
|
-
};
|
|
395
|
-
type TelemetryEventType = "telemetry";
|
|
396
|
-
type TelemetryEvent = {
|
|
397
|
-
type: TelemetryEventType;
|
|
398
|
-
method: string;
|
|
399
|
-
timestamp: number;
|
|
400
|
-
source: any;
|
|
401
|
-
metadata: {
|
|
402
|
-
args: any[];
|
|
403
|
-
performance: {
|
|
404
|
-
durationMs: number;
|
|
405
|
-
};
|
|
406
|
-
source: {
|
|
407
|
-
level: "database" | "collection" | "document";
|
|
408
|
-
collection?: string;
|
|
409
|
-
document?: string;
|
|
410
|
-
};
|
|
411
|
-
result?: {
|
|
412
|
-
type: "array" | string;
|
|
413
|
-
size?: number;
|
|
414
|
-
};
|
|
415
|
-
error: {
|
|
416
|
-
message: string;
|
|
417
|
-
name: string;
|
|
418
|
-
stack?: string;
|
|
419
|
-
} | null;
|
|
420
|
-
};
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Interface defining the shape of the EventBus.
|
|
425
|
-
* @template TEventMap - A record mapping event names to their respective payload types.
|
|
426
|
-
*/
|
|
427
|
-
interface EventBus<TEventMap extends Record<string, any>> {
|
|
428
|
-
/**
|
|
429
|
-
* Subscribes to a specific event by name.
|
|
430
|
-
* @param eventName - The name of the event to subscribe to.
|
|
431
|
-
* @param callback - The function to call when the event is emitted.
|
|
432
|
-
* @returns A function to unsubscribe from the event.
|
|
433
|
-
*/
|
|
434
|
-
subscribe: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
435
|
-
/**
|
|
436
|
-
* Subscribes to an event and automatically unsubscribes after it fires once.
|
|
437
|
-
* @param eventName - The name of the event to subscribe to.
|
|
438
|
-
* @param callback - The function to call when the event is emitted.
|
|
439
|
-
* @returns A function to cancel the one-shot subscription before it fires.
|
|
440
|
-
*/
|
|
441
|
-
once: <TEventName extends keyof TEventMap>(eventName: TEventName, callback: (payload: TEventMap[TEventName]) => void) => () => void;
|
|
442
|
-
/**
|
|
443
|
-
* Emits an event with a payload to all subscribed listeners.
|
|
444
|
-
* @param event - An object containing the event name and payload.
|
|
445
|
-
*/
|
|
446
|
-
emit: <TEventName extends keyof TEventMap>(event: {
|
|
447
|
-
name: TEventName;
|
|
448
|
-
payload: TEventMap[TEventName];
|
|
449
|
-
}) => void;
|
|
450
|
-
/**
|
|
451
|
-
* Retrieves metrics about event bus usage.
|
|
452
|
-
* @returns An object containing various metrics.
|
|
453
|
-
*/
|
|
454
|
-
metrics: () => EventMetrics;
|
|
455
|
-
/**
|
|
456
|
-
* Clears all subscriptions and resets metrics.
|
|
457
|
-
* After calling clear(), the bus is fully reset and can be reused —
|
|
458
|
-
* cross-tab communication is re-established if it was previously enabled.
|
|
459
|
-
*/
|
|
460
|
-
clear: () => void;
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Interface defining the metrics tracked by the EventBus.
|
|
464
|
-
*/
|
|
465
|
-
interface EventMetrics {
|
|
466
|
-
/** Total number of events emitted (both sync and deferred paths). */
|
|
467
|
-
totalEvents: number;
|
|
468
|
-
/** Number of active subscriptions across all event names. */
|
|
469
|
-
activeSubscriptions: number;
|
|
470
|
-
/** Map of event names to their emission counts. */
|
|
471
|
-
eventCounts: Map<string, number>;
|
|
472
|
-
/** Average duration of event dispatch in milliseconds. */
|
|
473
|
-
averageEmitDuration: number;
|
|
474
|
-
}
|
|
1
|
+
import { SchemaDefinition } from '@asaidimu/anansi';
|
|
2
|
+
import { Collection, Database, Document } from '@core/database';
|
|
3
|
+
import { EventBus } from '@core/events';
|
|
4
|
+
import { GenerateContentParameters, GoogleGenAI, GenerateContentResponse, Content, Part } from '@google/genai';
|
|
475
5
|
|
|
476
6
|
/**
|
|
477
7
|
* Utility type for representing partial updates to the state, allowing deep nesting.
|
|
@@ -883,44 +413,45 @@ interface Preference {
|
|
|
883
413
|
/** UTC timestamp of when this preference was established or last updated. */
|
|
884
414
|
timestamp: Timestamp;
|
|
885
415
|
}
|
|
886
|
-
/**
|
|
887
|
-
type
|
|
888
|
-
/** Denotes raw, unstructured text. */
|
|
416
|
+
/** Supported payload for text-based context. */
|
|
417
|
+
type TextContextContent = {
|
|
889
418
|
kind: "text";
|
|
890
|
-
/** The text payload to inject. */
|
|
891
419
|
value: string;
|
|
892
|
-
}
|
|
893
|
-
|
|
420
|
+
};
|
|
421
|
+
/** Supported payload for structured JSON context. */
|
|
422
|
+
type JsonContextContent = {
|
|
894
423
|
kind: "json";
|
|
895
|
-
/** The JSON payload. */
|
|
896
424
|
value: unknown;
|
|
897
|
-
}
|
|
898
|
-
|
|
425
|
+
};
|
|
426
|
+
/** Supported payload for blob-based context. */
|
|
427
|
+
type BlobContextContent = {
|
|
899
428
|
kind: "blob";
|
|
900
|
-
/** The hash linking to the full blob record. */
|
|
901
429
|
sha256: SHA256;
|
|
902
|
-
/** The mime-type of the blob. */
|
|
903
430
|
mediaType: BlobMediaType;
|
|
904
|
-
/** File size in bytes. */
|
|
905
431
|
sizeBytes: number;
|
|
906
|
-
/** Human-readable filename. */
|
|
907
432
|
filename?: string;
|
|
908
|
-
}
|
|
909
|
-
|
|
433
|
+
};
|
|
434
|
+
/** Supported payload for remote URI context. */
|
|
435
|
+
type RemoteContextContent = {
|
|
910
436
|
kind: "remote";
|
|
911
|
-
/** The fully qualified URI to the external resource. */
|
|
912
437
|
uri: URI;
|
|
913
|
-
/** Optional hint for the expected mime-type at the remote destination. */
|
|
914
438
|
mediaType?: BlobMediaType;
|
|
915
439
|
};
|
|
440
|
+
/** Union of built-in context types. */
|
|
441
|
+
type DefaultContextContent = TextContextContent | JsonContextContent | BlobContextContent | RemoteContextContent;
|
|
442
|
+
/**
|
|
443
|
+
* Discriminated union of types that can be injected into the AI context.
|
|
444
|
+
* Extensions provide their own T which MUST include a unique 'kind' discriminator.
|
|
445
|
+
*/
|
|
446
|
+
type ContextContent<T = any> = DefaultContextContent | T;
|
|
916
447
|
/** A contextual item (file, snippet, or data) attached to a session or prompt. */
|
|
917
|
-
interface Context {
|
|
448
|
+
interface Context<T = any> {
|
|
918
449
|
/** Unique lookup key for this context entry. */
|
|
919
450
|
key: string;
|
|
920
451
|
/** Topics linking this context to relevant sessions or roles. */
|
|
921
452
|
topics: string[];
|
|
922
453
|
/** The actual payload of the context block. */
|
|
923
|
-
content: ContextContent
|
|
454
|
+
content: ContextContent<T>;
|
|
924
455
|
/** UTC timestamp of when the context was added. */
|
|
925
456
|
timestamp: Timestamp;
|
|
926
457
|
/** Extensible key-value store for application-specific contextual metadata. */
|
|
@@ -988,6 +519,8 @@ interface PreferenceSummary {
|
|
|
988
519
|
interface ContextSummary {
|
|
989
520
|
/** The unique key for the context item. */
|
|
990
521
|
key: string;
|
|
522
|
+
/** The kind of context (e.g. 'text', 'blob', 'task'). Used for routing. */
|
|
523
|
+
kind: string;
|
|
991
524
|
/** Associated semantic topics. */
|
|
992
525
|
topics: string[];
|
|
993
526
|
/** UTC timestamp of addition. */
|
|
@@ -1475,200 +1008,37 @@ interface SessionSnapshot {
|
|
|
1475
1008
|
}
|
|
1476
1009
|
|
|
1477
1010
|
/**
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1480
|
-
* Contains fully ranked and conflict-resolved preferences, context, and a
|
|
1481
|
-
* catalogue of blob references — but is NOT truncated and does NOT contain
|
|
1482
|
-
* resolved binary blob data. The adapter is responsible for:
|
|
1483
|
-
* - Deciding what fits within the model's context window.
|
|
1484
|
-
* - Resolving only the BlobRefs that survive truncation.
|
|
1485
|
-
* - Uploading inline blobs to the provider where required.
|
|
1011
|
+
* Registry for managing context kind definitions and their behaviors.
|
|
1486
1012
|
*/
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
session: UUID;
|
|
1492
|
-
/** System-level instructions, context, and preferences. */
|
|
1493
|
-
system: {
|
|
1494
|
-
/** The active role's persona string. */
|
|
1495
|
-
persona: string;
|
|
1496
|
-
/** Global or session-level instructions. */
|
|
1497
|
-
instructions?: string;
|
|
1498
|
-
/** Conflict-resolved, relevance-ordered preferences. */
|
|
1499
|
-
preferences: Preference[];
|
|
1500
|
-
/** Ranked context entries (text and json kinds only). Blob context is
|
|
1501
|
-
* represented as referential blocks in the transcript instead. */
|
|
1502
|
-
context: Context[];
|
|
1503
|
-
};
|
|
1504
|
-
/** Active conversation chain, oldest to newest. May include synthetic turns.
|
|
1505
|
-
* Image and document blocks carry a BlobRef only; the adapter resolves them. */
|
|
1506
|
-
transcript: Turn[];
|
|
1013
|
+
declare class ContextRegistry {
|
|
1014
|
+
private readonly store;
|
|
1015
|
+
constructor();
|
|
1016
|
+
private registerDefaults;
|
|
1507
1017
|
/**
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
1511
|
-
* Values are BlobRefs — metadata only, no binary data. The adapter uses
|
|
1512
|
-
* this catalogue to resolve or upload blobs for whichever turns and context
|
|
1513
|
-
* entries survive its truncation pass.
|
|
1018
|
+
* Registers a new context definition.
|
|
1019
|
+
* @param definition The context definition to register.
|
|
1514
1020
|
*/
|
|
1515
|
-
|
|
1516
|
-
/** The role object — for inspection and adapter use. */
|
|
1517
|
-
role: Role;
|
|
1518
|
-
/** Model constraints to be merged by the adapter (turn > session > role). */
|
|
1519
|
-
constraints: ModelConstraintMap;
|
|
1021
|
+
register(definition: ContextDefinition): void;
|
|
1520
1022
|
/**
|
|
1521
|
-
*
|
|
1522
|
-
*
|
|
1523
|
-
* Examples: summarizer failures, unresolvable blob refs.
|
|
1023
|
+
* Retrieves a context definition by kind.
|
|
1024
|
+
* @param kind The context kind to retrieve.
|
|
1524
1025
|
*/
|
|
1525
|
-
|
|
1026
|
+
get(kind: string): ContextDefinition | undefined;
|
|
1027
|
+
/**
|
|
1028
|
+
* Lists all registered context definitions.
|
|
1029
|
+
*/
|
|
1030
|
+
list(): ContextDefinition[];
|
|
1526
1031
|
}
|
|
1032
|
+
|
|
1527
1033
|
/**
|
|
1528
|
-
*
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
ready: boolean;
|
|
1537
|
-
/** Token window limits and current usage. */
|
|
1538
|
-
window: {
|
|
1539
|
-
/** Total context window size in tokens. */
|
|
1540
|
-
size: number;
|
|
1541
|
-
/** Maximum output tokens for this model. */
|
|
1542
|
-
out: number;
|
|
1543
|
-
/** Tokens remaining — estimated or as reported by the provider. */
|
|
1544
|
-
free?: number;
|
|
1545
|
-
};
|
|
1546
|
-
/** Capability flags for this model. */
|
|
1547
|
-
feature: {
|
|
1548
|
-
/** Whether the model can process image inputs. */
|
|
1549
|
-
vision: boolean;
|
|
1550
|
-
/** Whether the model supports tool/function calling. */
|
|
1551
|
-
tools: boolean;
|
|
1552
|
-
/** Whether the model supports structured JSON output mode. */
|
|
1553
|
-
json: boolean;
|
|
1554
|
-
/** Whether the provider supports prompt caching. */
|
|
1555
|
-
cache: boolean;
|
|
1556
|
-
/** Whether the adapter supports streaming. */
|
|
1557
|
-
streaming: boolean;
|
|
1558
|
-
/** Whether the model supports extended thinking/reasoning tokens. */
|
|
1559
|
-
thinking: boolean;
|
|
1560
|
-
};
|
|
1561
|
-
/** Pricing tiers for this model. */
|
|
1562
|
-
pricing: Array<{
|
|
1563
|
-
unit: 'token' | 'call' | "image";
|
|
1564
|
-
/** Exponent: price is per 10^scale units. */
|
|
1565
|
-
scale: number;
|
|
1566
|
-
/** Price per unit in USD. */
|
|
1567
|
-
cost: {
|
|
1568
|
-
input: number;
|
|
1569
|
-
output: number;
|
|
1570
|
-
cache?: {
|
|
1571
|
-
read: number;
|
|
1572
|
-
write: number;
|
|
1573
|
-
};
|
|
1574
|
-
};
|
|
1575
|
-
}>;
|
|
1576
|
-
/** Current rate limit state. */
|
|
1577
|
-
rate: {
|
|
1578
|
-
/** Current saturation as a fraction of the most constrained limit (0.0 to 1.0). */
|
|
1579
|
-
load: number;
|
|
1580
|
-
/** Milliseconds until the next request is permitted. */
|
|
1581
|
-
timeout?: number;
|
|
1582
|
-
/** The hard limits enforced by the provider. */
|
|
1583
|
-
capacity: Array<{
|
|
1584
|
-
unit: 'token' | 'call' | string;
|
|
1585
|
-
/** Maximum units allowed per period. */
|
|
1586
|
-
max: number;
|
|
1587
|
-
/** Period length in seconds. */
|
|
1588
|
-
period: number;
|
|
1589
|
-
}>;
|
|
1590
|
-
};
|
|
1591
|
-
/** Adapter-level notes, e.g. model deprecation warnings. */
|
|
1592
|
-
notes?: string[];
|
|
1593
|
-
}
|
|
1594
|
-
/**
|
|
1595
|
-
* The result of `PreparedPrompt.execute()`. Contains the turn and derived effects.
|
|
1596
|
-
*/
|
|
1597
|
-
interface ExecuteResult {
|
|
1598
|
-
/** The newly generated assistant turn. */
|
|
1599
|
-
turn: Turn;
|
|
1600
|
-
/** Side-effect commands to dispatch against the workspace. */
|
|
1601
|
-
effects: BaseCommand[];
|
|
1602
|
-
}
|
|
1603
|
-
/**
|
|
1604
|
-
* A single labelled section of the system prompt.
|
|
1605
|
-
* Mirrors PreparedPrompt.system exactly — the assembler's output is stored
|
|
1606
|
-
* there directly, giving callers full inspection without re-parsing the string.
|
|
1607
|
-
*/
|
|
1608
|
-
interface PromptSection {
|
|
1609
|
-
/**
|
|
1610
|
-
* Origin label for this section.
|
|
1611
|
-
* Core sections use fixed labels: 'operating-system' | 'persona' |
|
|
1612
|
-
* 'preferences' | 'context' | 'instructions'.
|
|
1613
|
-
* Extensions carry whatever label the injector provides.
|
|
1614
|
-
*/
|
|
1615
|
-
label: string;
|
|
1616
|
-
/** Text content exactly as it will be sent to the model. */
|
|
1617
|
-
content: string;
|
|
1618
|
-
/** Optional structured metadata for richer UI display or tooling. */
|
|
1619
|
-
metadata?: Record<string, any>;
|
|
1620
|
-
}
|
|
1621
|
-
/**
|
|
1622
|
-
* The complete, final prompt exactly as the model will receive it.
|
|
1623
|
-
* Generic, provider-agnostic, fully inspectable, and executable.
|
|
1624
|
-
*/
|
|
1625
|
-
interface PreparedPrompt {
|
|
1626
|
-
/** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
|
|
1627
|
-
model: string;
|
|
1628
|
-
/** The complete system instruction broken into labelled sections for inspection. */
|
|
1629
|
-
instructions: Array<PromptSection>;
|
|
1630
|
-
/** Final transcript turns that will be sent after adapter-level truncation. */
|
|
1631
|
-
transcript: Turn[];
|
|
1632
|
-
/** Final context entries included after adapter-level truncation. */
|
|
1633
|
-
context: Context[];
|
|
1634
|
-
/** Final preferences included after adapter-level truncation. */
|
|
1635
|
-
preferences: Preference[];
|
|
1636
|
-
/** The resolved model constraints for this request. */
|
|
1637
|
-
constraints: ModelConstraint;
|
|
1638
|
-
/** Token accounting (estimated or exact). */
|
|
1639
|
-
tokens: {
|
|
1640
|
-
/** Breakdown by section. Keys are adapter-defined. */
|
|
1641
|
-
breakdown: Record<string, number>;
|
|
1642
|
-
/** Total input tokens — estimated or exact. */
|
|
1643
|
-
total: number;
|
|
1644
|
-
/** Whether total is an estimate or exact (provider-supplied). */
|
|
1645
|
-
source: 'estimated' | 'exact';
|
|
1646
|
-
/** Maximum output tokens configured for this request. */
|
|
1647
|
-
output?: number;
|
|
1648
|
-
/** Tokens remaining in the context window after this prompt. */
|
|
1649
|
-
remaining?: number;
|
|
1650
|
-
};
|
|
1651
|
-
/**
|
|
1652
|
-
* Sends this prompt to the model.
|
|
1653
|
-
* @returns The parsed assistant Turn plus any execution side-effects.
|
|
1654
|
-
*/
|
|
1655
|
-
execute(): Promise<Result<ExecuteResult, WorkspaceError>>;
|
|
1656
|
-
/**
|
|
1657
|
-
* Streaming variant of execute(). Yields partial turns as tokens arrive.
|
|
1658
|
-
* Present only if the adapter and model support streaming.
|
|
1659
|
-
*/
|
|
1660
|
-
executeStream?(): AsyncIterable<Partial<Turn> | ExecuteResult>;
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
/**
|
|
1664
|
-
* Optional filter passed to schema(), description(), and rules() to control
|
|
1665
|
-
* which block definitions are included in the output.
|
|
1666
|
-
*
|
|
1667
|
-
* Resolution order:
|
|
1668
|
-
* 1. `emittable` gate is always applied first — non-emittable blocks never
|
|
1669
|
-
* appear in schema/description/rules regardless of other filters.
|
|
1670
|
-
* 2. If `only` is provided, only those types are included. `exclude` is ignored.
|
|
1671
|
-
* 3. If `exclude` is provided (and `only` is not), those types are removed.
|
|
1034
|
+
* Optional filter passed to schema(), description(), and rules() to control
|
|
1035
|
+
* which block definitions are included in the output.
|
|
1036
|
+
*
|
|
1037
|
+
* Resolution order:
|
|
1038
|
+
* 1. `emittable` gate is always applied first — non-emittable blocks never
|
|
1039
|
+
* appear in schema/description/rules regardless of other filters.
|
|
1040
|
+
* 2. If `only` is provided, only those types are included. `exclude` is ignored.
|
|
1041
|
+
* 3. If `exclude` is provided (and `only` is not), those types are removed.
|
|
1672
1042
|
*/
|
|
1673
1043
|
interface BlockFilter {
|
|
1674
1044
|
/**
|
|
@@ -1819,6 +1189,18 @@ interface SystemPromptAssembler {
|
|
|
1819
1189
|
*/
|
|
1820
1190
|
join(sections: PromptSection[]): string;
|
|
1821
1191
|
}
|
|
1192
|
+
type BlockMapper = {
|
|
1193
|
+
/**
|
|
1194
|
+
* Convert a workspace block into a provider-specific part.
|
|
1195
|
+
* The return type is `unknown` — the adapter casts it internally.
|
|
1196
|
+
*/
|
|
1197
|
+
to(block: BaseContentBlock<string>): unknown;
|
|
1198
|
+
/**
|
|
1199
|
+
* Convert a provider-extracted raw JSON object into a workspace block.
|
|
1200
|
+
* Return `null` if parsing fails.
|
|
1201
|
+
*/
|
|
1202
|
+
from(raw: any): BaseContentBlock<any> | null;
|
|
1203
|
+
};
|
|
1822
1204
|
/**
|
|
1823
1205
|
* A registered content block — self-contained and provider-agnostic.
|
|
1824
1206
|
*/
|
|
@@ -1886,12 +1268,204 @@ interface WorkspaceServices {
|
|
|
1886
1268
|
* Self-describing catalogue of all known content block types.
|
|
1887
1269
|
*/
|
|
1888
1270
|
blockRegistry: ContentBlockRegistry;
|
|
1271
|
+
/**
|
|
1272
|
+
* Registry for managing custom context kinds.
|
|
1273
|
+
*/
|
|
1274
|
+
contextRegistry: ContextRegistry;
|
|
1889
1275
|
/**
|
|
1890
1276
|
* Model registry
|
|
1891
1277
|
*/
|
|
1892
1278
|
models: ModelRegistry;
|
|
1893
1279
|
}
|
|
1894
1280
|
|
|
1281
|
+
/**
|
|
1282
|
+
* Output of PromptBuilder.build(). Input to LLMAdapter.resolve().
|
|
1283
|
+
*
|
|
1284
|
+
* Contains fully ranked and conflict-resolved preferences, context, and a
|
|
1285
|
+
* catalogue of blob references — but is NOT truncated and does NOT contain
|
|
1286
|
+
* resolved binary blob data. The adapter is responsible for:
|
|
1287
|
+
* - Deciding what fits within the model's context window.
|
|
1288
|
+
* - Resolving only the BlobRefs that survive truncation.
|
|
1289
|
+
* - Uploading inline blobs to the provider where required.
|
|
1290
|
+
*/
|
|
1291
|
+
interface Prompt {
|
|
1292
|
+
/** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
|
|
1293
|
+
model?: string;
|
|
1294
|
+
/** Correlates this prompt to its session for logging and evaluation. */
|
|
1295
|
+
session: UUID;
|
|
1296
|
+
/** System-level instructions, context, and preferences. */
|
|
1297
|
+
system: {
|
|
1298
|
+
/** The active role's persona string. */
|
|
1299
|
+
persona: string;
|
|
1300
|
+
/** Global or session-level instructions. */
|
|
1301
|
+
instructions?: string;
|
|
1302
|
+
/** Conflict-resolved, relevance-ordered preferences. */
|
|
1303
|
+
preferences: Preference[];
|
|
1304
|
+
/** Ranked context entries (text and json kinds only). Blob context is
|
|
1305
|
+
* represented as referential blocks in the transcript instead. */
|
|
1306
|
+
context: Context[];
|
|
1307
|
+
/** Additional sections injected by the adapter or application layer. */
|
|
1308
|
+
extensions?: AssemblerExtension[];
|
|
1309
|
+
};
|
|
1310
|
+
/** Active conversation chain, oldest to newest. May include synthetic turns.
|
|
1311
|
+
* Image and document blocks carry a BlobRef only; the adapter resolves them. */
|
|
1312
|
+
transcript: Turn[];
|
|
1313
|
+
/**
|
|
1314
|
+
* Lightweight catalogue of every blob referenced anywhere in this prompt
|
|
1315
|
+
* (system.context or transcript), keyed by SHA256.
|
|
1316
|
+
*
|
|
1317
|
+
* Values are BlobRefs — metadata only, no binary data. The adapter uses
|
|
1318
|
+
* this catalogue to resolve or upload blobs for whichever turns and context
|
|
1319
|
+
* entries survive its truncation pass.
|
|
1320
|
+
*/
|
|
1321
|
+
blobs: Map<SHA256, BlobRef>;
|
|
1322
|
+
/** The role object — for inspection and adapter use. */
|
|
1323
|
+
role: Role;
|
|
1324
|
+
/** Model constraints to be merged by the adapter (turn > session > role). */
|
|
1325
|
+
constraints: ModelConstraintMap;
|
|
1326
|
+
/**
|
|
1327
|
+
* Non-fatal warnings generated during the build phase.
|
|
1328
|
+
* Adapters and callers should surface or log these.
|
|
1329
|
+
* Examples: summarizer failures, unresolvable blob refs.
|
|
1330
|
+
*/
|
|
1331
|
+
warnings: string[];
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Reflects the current state of the LLM adapter (limits, headroom, and readiness).
|
|
1335
|
+
*/
|
|
1336
|
+
interface AdapterStatus {
|
|
1337
|
+
/** Provider name (e.g., "google", "anthropic", "openai"). */
|
|
1338
|
+
provider: string;
|
|
1339
|
+
/** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
|
|
1340
|
+
model: string;
|
|
1341
|
+
/** Whether the adapter is currently able to accept requests. */
|
|
1342
|
+
ready: boolean;
|
|
1343
|
+
/** Token window limits and current usage. */
|
|
1344
|
+
window: {
|
|
1345
|
+
/** Total context window size in tokens. */
|
|
1346
|
+
size: number;
|
|
1347
|
+
/** Maximum output tokens for this model. */
|
|
1348
|
+
out: number;
|
|
1349
|
+
/** Tokens remaining — estimated or as reported by the provider. */
|
|
1350
|
+
free?: number;
|
|
1351
|
+
};
|
|
1352
|
+
/** Capability flags for this model. */
|
|
1353
|
+
feature: {
|
|
1354
|
+
/** Whether the model can process image inputs. */
|
|
1355
|
+
vision: boolean;
|
|
1356
|
+
/** Whether the model supports tool/function calling. */
|
|
1357
|
+
tools: boolean;
|
|
1358
|
+
/** Whether the model supports structured JSON output mode. */
|
|
1359
|
+
json: boolean;
|
|
1360
|
+
/** Whether the provider supports prompt caching. */
|
|
1361
|
+
cache: boolean;
|
|
1362
|
+
/** Whether the adapter supports streaming. */
|
|
1363
|
+
streaming: boolean;
|
|
1364
|
+
/** Whether the model supports extended thinking/reasoning tokens. */
|
|
1365
|
+
thinking: boolean;
|
|
1366
|
+
};
|
|
1367
|
+
/** Pricing tiers for this model. */
|
|
1368
|
+
pricing: Array<{
|
|
1369
|
+
unit: "token" | "call" | "image";
|
|
1370
|
+
/** Exponent: price is per 10^scale units. */
|
|
1371
|
+
scale: number;
|
|
1372
|
+
/** Price per unit in USD. */
|
|
1373
|
+
cost: {
|
|
1374
|
+
input: number;
|
|
1375
|
+
output: number;
|
|
1376
|
+
cache?: {
|
|
1377
|
+
read: number;
|
|
1378
|
+
write: number;
|
|
1379
|
+
};
|
|
1380
|
+
};
|
|
1381
|
+
}>;
|
|
1382
|
+
/** Current rate limit state. */
|
|
1383
|
+
rate: {
|
|
1384
|
+
/** Current saturation as a fraction of the most constrained limit (0.0 to 1.0). */
|
|
1385
|
+
load: number;
|
|
1386
|
+
/** Milliseconds until the next request is permitted. */
|
|
1387
|
+
timeout?: number;
|
|
1388
|
+
/** The hard limits enforced by the provider. */
|
|
1389
|
+
capacity: Array<{
|
|
1390
|
+
unit: "token" | "call" | string;
|
|
1391
|
+
/** Maximum units allowed per period. */
|
|
1392
|
+
max: number;
|
|
1393
|
+
/** Period length in seconds. */
|
|
1394
|
+
period: number;
|
|
1395
|
+
}>;
|
|
1396
|
+
};
|
|
1397
|
+
/** Adapter-level notes, e.g. model deprecation warnings. */
|
|
1398
|
+
notes?: string[];
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* The result of `PreparedPrompt.execute()`. Contains the turn and derived effects.
|
|
1402
|
+
*/
|
|
1403
|
+
interface ExecuteResult {
|
|
1404
|
+
/** The newly generated assistant turn. */
|
|
1405
|
+
turn: Turn;
|
|
1406
|
+
/** Side-effect commands to dispatch against the workspace. */
|
|
1407
|
+
effects: BaseCommand[];
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* A single labelled section of the system prompt.
|
|
1411
|
+
* Mirrors PreparedPrompt.system exactly — the assembler's output is stored
|
|
1412
|
+
* there directly, giving callers full inspection without re-parsing the string.
|
|
1413
|
+
*/
|
|
1414
|
+
interface PromptSection {
|
|
1415
|
+
/**
|
|
1416
|
+
* Origin label for this section.
|
|
1417
|
+
* Core sections use fixed labels: 'operating-system' | 'persona' |
|
|
1418
|
+
* 'preferences' | 'context' | 'instructions'.
|
|
1419
|
+
* Extensions carry whatever label the injector provides.
|
|
1420
|
+
*/
|
|
1421
|
+
label: string;
|
|
1422
|
+
/** Text content exactly as it will be sent to the model. */
|
|
1423
|
+
content: string;
|
|
1424
|
+
/** Optional structured metadata for richer UI display or tooling. */
|
|
1425
|
+
metadata?: Record<string, any>;
|
|
1426
|
+
}
|
|
1427
|
+
/**
|
|
1428
|
+
* The complete, final prompt exactly as the model will receive it.
|
|
1429
|
+
* Generic, provider-agnostic, fully inspectable, and executable.
|
|
1430
|
+
*/
|
|
1431
|
+
interface PreparedPrompt {
|
|
1432
|
+
/** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
|
|
1433
|
+
model: string;
|
|
1434
|
+
/** The complete system instruction broken into labelled sections for inspection. */
|
|
1435
|
+
instructions: Array<PromptSection>;
|
|
1436
|
+
/** Final transcript turns that will be sent after adapter-level truncation. */
|
|
1437
|
+
transcript: Turn[];
|
|
1438
|
+
/** Final context entries included after adapter-level truncation. */
|
|
1439
|
+
context: Context[];
|
|
1440
|
+
/** Final preferences included after adapter-level truncation. */
|
|
1441
|
+
preferences: Preference[];
|
|
1442
|
+
/** The resolved model constraints for this request. */
|
|
1443
|
+
constraints: ModelConstraint;
|
|
1444
|
+
/** Token accounting (estimated or exact). */
|
|
1445
|
+
tokens: {
|
|
1446
|
+
/** Breakdown by section. Keys are adapter-defined. */
|
|
1447
|
+
breakdown: Record<string, number>;
|
|
1448
|
+
/** Total input tokens — estimated or exact. */
|
|
1449
|
+
total: number;
|
|
1450
|
+
/** Whether total is an estimate or exact (provider-supplied). */
|
|
1451
|
+
source: "estimated" | "exact";
|
|
1452
|
+
/** Maximum output tokens configured for this request. */
|
|
1453
|
+
output?: number;
|
|
1454
|
+
/** Tokens remaining in the context window after this prompt. */
|
|
1455
|
+
remaining?: number;
|
|
1456
|
+
};
|
|
1457
|
+
/**
|
|
1458
|
+
* Sends this prompt to the model.
|
|
1459
|
+
* @returns The parsed assistant Turn plus any execution side-effects.
|
|
1460
|
+
*/
|
|
1461
|
+
execute(): Promise<Result<ExecuteResult, WorkspaceError>>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Streaming variant of execute(). Yields partial turns as tokens arrive.
|
|
1464
|
+
* Present only if the adapter and model support streaming.
|
|
1465
|
+
*/
|
|
1466
|
+
executeStream?(): AsyncIterable<Partial<Turn> | ExecuteResult>;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1895
1469
|
/**
|
|
1896
1470
|
* A simple LRU (Least Recently Used) cache implementation.
|
|
1897
1471
|
* Used for caching frequently accessed entities in memory.
|
|
@@ -2048,17 +1622,23 @@ declare const COLLECTIONS: {
|
|
|
2048
1622
|
readonly BLOB: "blob";
|
|
2049
1623
|
readonly TOPIC: "topic";
|
|
2050
1624
|
};
|
|
2051
|
-
type Collections = typeof COLLECTIONS[keyof typeof COLLECTIONS];
|
|
1625
|
+
type Collections = (typeof COLLECTIONS)[keyof typeof COLLECTIONS];
|
|
2052
1626
|
|
|
2053
1627
|
declare class ContextStore implements Store<Context, ContextSummary, string> {
|
|
2054
1628
|
private readonly collection;
|
|
2055
1629
|
private readonly cache;
|
|
2056
|
-
|
|
2057
|
-
|
|
1630
|
+
private readonly registry?;
|
|
1631
|
+
private readonly delegates;
|
|
1632
|
+
constructor(collection: Collection<Context>, cache: LRUCache<string, Context>, registry?: ContextRegistry | undefined);
|
|
1633
|
+
/**
|
|
1634
|
+
* Registers a specialized store for a specific context kind.
|
|
1635
|
+
*/
|
|
1636
|
+
registerDelegate(kind: string, store: Store<Context, ContextSummary, string>): void;
|
|
1637
|
+
get(key: string, kind?: string): Promise<Context | null>;
|
|
2058
1638
|
add(context: Context): Promise<void>;
|
|
2059
1639
|
list(): Promise<Context[]>;
|
|
2060
|
-
update(key: string, updates: Partial<Context
|
|
2061
|
-
delete(key: string): Promise<boolean>;
|
|
1640
|
+
update(key: string, updates: Partial<Context>, kind?: string): Promise<Context | null>;
|
|
1641
|
+
delete(key: string, kind?: string): Promise<boolean>;
|
|
2062
1642
|
/**
|
|
2063
1643
|
* Retrieves all context items referenced by the given topics using the in-memory index.
|
|
2064
1644
|
*/
|
|
@@ -2183,6 +1763,38 @@ declare class WorkspaceStore implements Store<WorkspaceMetadata, WorkspaceMetada
|
|
|
2183
1763
|
* A function that rebuilds a portion of the workspace index from persistent storage.
|
|
2184
1764
|
*/
|
|
2185
1765
|
type Indexer = (ctx: WorkspaceContext) => Promise<DeepPartial<Workspace>>;
|
|
1766
|
+
/**
|
|
1767
|
+
* Definition of a specific kind of context and how the system interacts with it.
|
|
1768
|
+
*/
|
|
1769
|
+
interface ContextDefinition<T = any> {
|
|
1770
|
+
/** Unique discriminator for this context kind (e.g., 'text', 'blob', 'task'). */
|
|
1771
|
+
kind: string;
|
|
1772
|
+
/**
|
|
1773
|
+
* Where this context prefers to live in the prompt.
|
|
1774
|
+
* 'system' -> Rendered into the system instructions.
|
|
1775
|
+
* 'transcript' -> Rendered as a synthetic turn prefixing the transcript.
|
|
1776
|
+
*/
|
|
1777
|
+
target: "system" | "transcript";
|
|
1778
|
+
/**
|
|
1779
|
+
* Transforms the context item into one or more content blocks.
|
|
1780
|
+
* If these blocks contain BlobRefs, the PromptBuilder will automatically
|
|
1781
|
+
* catalogue them for the adapter.
|
|
1782
|
+
*/
|
|
1783
|
+
render(context: Context<T>): ContentBlock | ContentBlock[];
|
|
1784
|
+
/**
|
|
1785
|
+
* Returns a plain text representation for the RAG/retriever system.
|
|
1786
|
+
*/
|
|
1787
|
+
toString(context: Context<T>): string;
|
|
1788
|
+
/**
|
|
1789
|
+
* Produces a condensed summary for the workspace index projection.
|
|
1790
|
+
*/
|
|
1791
|
+
summarize(context: Context<T>): ContextSummary;
|
|
1792
|
+
/**
|
|
1793
|
+
* Optional factory for a custom store for this context kind.
|
|
1794
|
+
* If omitted, the default 'context' collection is used.
|
|
1795
|
+
*/
|
|
1796
|
+
store?: (ctx: WorkspaceContext) => Store<Context<T>, ContextSummary, string>;
|
|
1797
|
+
}
|
|
2186
1798
|
/**
|
|
2187
1799
|
* A bundle of domain-specific logic that can be plugged into the workspace.
|
|
2188
1800
|
* Allows app builders to group related schemas, reducers, stores, and blocks.
|
|
@@ -2200,6 +1812,8 @@ interface WorkspaceExtension {
|
|
|
2200
1812
|
stores?: (ctx: Omit<WorkspaceContext, "workspace">) => Record<string, Store<any>> | Promise<Record<string, Store<any>>>;
|
|
2201
1813
|
/** Content block definitions for the LLM adapter. */
|
|
2202
1814
|
blocks?: ContentBlockDefinition[];
|
|
1815
|
+
/** Custom context kind definitions. */
|
|
1816
|
+
contexts?: ContextDefinition[];
|
|
2203
1817
|
}
|
|
2204
1818
|
/**
|
|
2205
1819
|
* The full set of stores passed to every reducer and middleware call.
|
|
@@ -2627,12 +2241,153 @@ declare function computeSHA256(data: Uint8Array): Promise<SHA256>;
|
|
|
2627
2241
|
*/
|
|
2628
2242
|
declare function bufferToBase64(buffer: Uint8Array): string;
|
|
2629
2243
|
/**
|
|
2630
|
-
* Short, deterministic hash of a string (4 chars in base36).
|
|
2631
|
-
* Suitable for AI-friendly reference tokens.
|
|
2632
|
-
*/
|
|
2244
|
+
* Short, deterministic hash of a string (4 chars in base36).
|
|
2245
|
+
* Suitable for AI-friendly reference tokens.
|
|
2246
|
+
*/
|
|
2633
2247
|
declare function shortHash(s: string, length?: number): string;
|
|
2634
2248
|
declare function getExtension<K extends string, V>(index: Index, key: K): Record<string, V>;
|
|
2635
2249
|
|
|
2250
|
+
declare const createEmptySession: (overrides?: Partial<SessionMetadata>) => SessionMetadata;
|
|
2251
|
+
declare const createEmptyTurn: (overrides?: Partial<Turn>, session?: SessionMetadata) => Turn;
|
|
2252
|
+
/**
|
|
2253
|
+
* Creates a new, empty workspace with default values.
|
|
2254
|
+
* All indices (roles, preferences, context, sessions, topics, blobs, tools) are empty objects.
|
|
2255
|
+
*
|
|
2256
|
+
* @param overrides - Partial workspace fields to override the default empty workspace.
|
|
2257
|
+
* @returns A fully formed Workspace object ready for use.
|
|
2258
|
+
*/
|
|
2259
|
+
declare const createEmptyWorkspace: (overrides?: DeepPartial<Workspace>) => Workspace;
|
|
2260
|
+
|
|
2261
|
+
/**
|
|
2262
|
+
* In-process implementation backed by plain Maps.
|
|
2263
|
+
* Suitable for development, testing, and server-side runtimes without
|
|
2264
|
+
* access to IndexedDB.
|
|
2265
|
+
*/
|
|
2266
|
+
declare class MemoryBlobStorage implements BlobStorage {
|
|
2267
|
+
private readonly bytes;
|
|
2268
|
+
private readonly records;
|
|
2269
|
+
storeBytes(sha256: SHA256, data: Uint8Array): Promise<void>;
|
|
2270
|
+
loadBytes(sha256: SHA256): Promise<Uint8Array | null>;
|
|
2271
|
+
hasBytes(sha256: SHA256): Promise<boolean>;
|
|
2272
|
+
deleteBytes(sha256: SHA256): Promise<void>;
|
|
2273
|
+
saveRecord(record: BlobRecord): Promise<void>;
|
|
2274
|
+
loadRecord(sha256: SHA256): Promise<BlobRecord | null>;
|
|
2275
|
+
deleteRecord(sha256: SHA256): Promise<void>;
|
|
2276
|
+
listRecords(): Promise<BlobRecord[]>;
|
|
2277
|
+
exportAllBytes(): Promise<Array<[SHA256, Uint8Array]>>;
|
|
2278
|
+
/**
|
|
2279
|
+
* Atomic register for MemoryBlobStorage — sequential ops are atomic
|
|
2280
|
+
* in a single-threaded JS runtime, so this is equivalent to two separate
|
|
2281
|
+
* calls, but we implement it for interface consistency.
|
|
2282
|
+
*/
|
|
2283
|
+
registerBlob(record: BlobRecord, data: Uint8Array): Promise<void>;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
interface IndexedDBBlobConfig {
|
|
2287
|
+
/** Name of the IndexedDB database. Defaults to 'aiworkspace-blobs'. */
|
|
2288
|
+
dbName?: string;
|
|
2289
|
+
}
|
|
2290
|
+
/**
|
|
2291
|
+
* IndexedDB-backed blob storage.
|
|
2292
|
+
*
|
|
2293
|
+
* Bytes are stored as raw Uint8Array — IndexedDB handles binary natively,
|
|
2294
|
+
* no base64 encoding at rest. This is important for large files.
|
|
2295
|
+
*
|
|
2296
|
+
* Transaction discipline: never await inside an active transaction.
|
|
2297
|
+
* All multi-step operations chain synchronous IDB request handlers
|
|
2298
|
+
* inside a single Promise.
|
|
2299
|
+
*/
|
|
2300
|
+
declare class IndexedDBBlobStorage implements BlobStorage {
|
|
2301
|
+
private readonly dbName;
|
|
2302
|
+
private db;
|
|
2303
|
+
constructor(config?: IndexedDBBlobConfig);
|
|
2304
|
+
open(): Promise<void>;
|
|
2305
|
+
private createSchema;
|
|
2306
|
+
close(): void;
|
|
2307
|
+
deleteDatabase(): Promise<void>;
|
|
2308
|
+
private getDB;
|
|
2309
|
+
private readTx;
|
|
2310
|
+
private writeTx;
|
|
2311
|
+
storeBytes(sha256: SHA256, data: Uint8Array): Promise<void>;
|
|
2312
|
+
loadBytes(sha256: SHA256): Promise<Uint8Array | null>;
|
|
2313
|
+
hasBytes(sha256: SHA256): Promise<boolean>;
|
|
2314
|
+
deleteBytes(sha256: SHA256): Promise<void>;
|
|
2315
|
+
saveRecord(record: BlobRecord): Promise<void>;
|
|
2316
|
+
loadRecord(sha256: SHA256): Promise<BlobRecord | null>;
|
|
2317
|
+
deleteRecord(sha256: SHA256): Promise<void>;
|
|
2318
|
+
listRecords(): Promise<BlobRecord[]>;
|
|
2319
|
+
exportAllBytes(): Promise<Array<[SHA256, Uint8Array]>>;
|
|
2320
|
+
/**
|
|
2321
|
+
* Atomically stores bytes and saves a record together.
|
|
2322
|
+
* Preferred over calling storeBytes + saveRecord separately when both
|
|
2323
|
+
* are new — avoids a window where bytes exist without a record.
|
|
2324
|
+
*/
|
|
2325
|
+
registerBlob(record: BlobRecord, data: Uint8Array): Promise<void>;
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
declare class GoogleGenAIAdapter implements LLMAdapter<GenerateContentParameters> {
|
|
2329
|
+
private readonly client;
|
|
2330
|
+
private readonly services;
|
|
2331
|
+
private readonly model;
|
|
2332
|
+
private readonly _models;
|
|
2333
|
+
constructor(client: GoogleGenAI, services: WorkspaceServices, options?: {
|
|
2334
|
+
model: string;
|
|
2335
|
+
models?: Array<ModelProfile>;
|
|
2336
|
+
});
|
|
2337
|
+
private registerGeminiMappings;
|
|
2338
|
+
status(_?: string): Promise<AdapterStatus>;
|
|
2339
|
+
resolve(params: {
|
|
2340
|
+
prompt: Prompt;
|
|
2341
|
+
} & Partial<GenerateContentParameters>): Promise<PreparedPrompt>;
|
|
2342
|
+
static provider(): string;
|
|
2343
|
+
static models(): ModelProfile[];
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
declare const mappings: Record<string, BlockMapper>;
|
|
2347
|
+
|
|
2348
|
+
declare const GOOGLE_MODELS: Array<ModelProfile>;
|
|
2349
|
+
|
|
2350
|
+
/**
|
|
2351
|
+
* Extracts workspace ContentBlocks from a Gemini GenerateContentResponse.
|
|
2352
|
+
*
|
|
2353
|
+
* Responsibility split:
|
|
2354
|
+
* - This function owns the Gemini wire format (candidates, parts, thought flag).
|
|
2355
|
+
* - Block validation and construction is fully delegated to the registry.
|
|
2356
|
+
* Unknown block types returned by the model are silently dropped (registry
|
|
2357
|
+
* returns null for unregistered types) and logged by the registry itself.
|
|
2358
|
+
*/
|
|
2359
|
+
declare function parseModelResponse(response: GenerateContentResponse, registry: ContentBlockRegistry): Result<ContentBlock[], WorkspaceError>;
|
|
2360
|
+
|
|
2361
|
+
/**
|
|
2362
|
+
* Maps a workspace Turn into a Gemini Content object.
|
|
2363
|
+
*
|
|
2364
|
+
* Blob blocks (image, document) are resolved to inline or remote Parts via
|
|
2365
|
+
* mapBlobRefToPart. All other blocks are dispatched through the registry's
|
|
2366
|
+
* provider mapping for provider() — a missing mapping is a programming error
|
|
2367
|
+
* and throws immediately rather than silently degrading.
|
|
2368
|
+
*/
|
|
2369
|
+
declare function mapTurnToContent(turn: Turn, resolveBlob: BlobResolver, registry: ContentBlockRegistry): Promise<Content>;
|
|
2370
|
+
/**
|
|
2371
|
+
* Maps a single workspace block to a Gemini Part via the registry's provider mapping.
|
|
2372
|
+
*
|
|
2373
|
+
* Throws if no mapping is registered for provider() — every block type that can
|
|
2374
|
+
* appear in a transcript must have a Gemini mapping registered by the adapter at
|
|
2375
|
+
* initialisation time. There is no silent fallback: an unmapped block is a gap in
|
|
2376
|
+
* the adapter's setup, not a recoverable runtime condition.
|
|
2377
|
+
*/
|
|
2378
|
+
declare function mapBlockToPart(block: BaseContentBlock<string>, registry: ContentBlockRegistry): Part | null;
|
|
2379
|
+
|
|
2380
|
+
declare const index_GOOGLE_MODELS: typeof GOOGLE_MODELS;
|
|
2381
|
+
type index_GoogleGenAIAdapter = GoogleGenAIAdapter;
|
|
2382
|
+
declare const index_GoogleGenAIAdapter: typeof GoogleGenAIAdapter;
|
|
2383
|
+
declare const index_mapBlockToPart: typeof mapBlockToPart;
|
|
2384
|
+
declare const index_mapTurnToContent: typeof mapTurnToContent;
|
|
2385
|
+
declare const index_mappings: typeof mappings;
|
|
2386
|
+
declare const index_parseModelResponse: typeof parseModelResponse;
|
|
2387
|
+
declare namespace index {
|
|
2388
|
+
export { index_GOOGLE_MODELS as GOOGLE_MODELS, index_GoogleGenAIAdapter as GoogleGenAIAdapter, index_mapBlockToPart as mapBlockToPart, index_mapTurnToContent as mapTurnToContent, index_mappings as mappings, index_parseModelResponse as parseModelResponse };
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2636
2391
|
interface CreateWorkspaceParams {
|
|
2637
2392
|
db: Database;
|
|
2638
2393
|
blobStorage: BlobStorage;
|
|
@@ -2666,4 +2421,4 @@ declare function createWorkspace(params: CreateWorkspaceParams): Promise<{
|
|
|
2666
2421
|
services: WorkspaceServices;
|
|
2667
2422
|
}>;
|
|
2668
2423
|
|
|
2669
|
-
export { type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BlobCommand, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BranchInfo, type BranchTurn, COLLECTIONS, type Collections, type Command, type ContentBlock, type Context, type ContextContent, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTopic, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type DuplicateKeyError, EMPTY_SYSTEM_ROLE, type EditTurn, type ForkSession, type ImageBlock, type ImageMediaType, type Index, type IndexExtensions, type Indexer, type InvalidCommandError, type LLMAdapter, type LLMAdapterStatic, LRUCache, type MergeTopics, type ModelConstraint, type ModelConstraintMap, type ModelName, type ModelProfile, type ModelRegistry, type NotFoundError, type OverrideSessionPreferences, type PermissionDeniedError, type PermissionGuard, type Preference, type PreferenceSummary, type Project, type PromptBuilder, type PromptBuilderOptions, type PurgeBlob, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type ResolvedBlob, type ResolvedSession, type Result, type RetainBlob, type Role, type RoleSummary, type RoleTransitionBlock, type SHA256, Session, SessionManager, type SessionMetadata, type SessionSnapshot, type Settings, type Store, type Summarizer, type SummaryBlock, type SwitchSessionRole, type SyncWorkspace, type SystemActor, type TextBlock, type ThinkingBlock, type Timestamp, type ToolCall, type ToolCallCommand, type ToolRegistry, type ToolResultBlock, type ToolSummary, type ToolUseBlock, type Topic, type TopicIndex, type Turn, TurnBuilder, type TurnKey, type TurnNode, type TurnProcessor, type TurnRef, TurnTree, type URI, type UUID, type UpdateContext, type UpdatePreference, type UpdateRole, type UpdateSession, type UpdateTopic, type UpdateTurn, type Workspace, type WorkspaceBundle, type WorkspaceContext, type WorkspaceDatabase, type WorkspaceError, type WorkspaceEvents, type WorkspaceExtension, WorkspaceManager, type WorkspaceMiddleware, type WorkspaceReducer, bufferToBase64, computeSHA256, createWorkspace, createWorkspaceDatabase, del, error, getExtension, merge, ok, omitNullUndefined, shortHash, success };
|
|
2424
|
+
export { type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BlobCommand, type BlobContextContent, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BranchInfo, type BranchTurn, COLLECTIONS, type Collections, type Command, type ContentBlock, type Context, type ContextContent, type ContextDefinition, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DefaultContextContent, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTopic, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type DuplicateKeyError, EMPTY_SYSTEM_ROLE, type EditTurn, type ForkSession, index as GoogleAdapter, type ImageBlock, type ImageMediaType, type Index, type IndexExtensions, type IndexedDBBlobConfig, IndexedDBBlobStorage, type Indexer, type InvalidCommandError, type JsonContextContent, type LLMAdapter, type LLMAdapterStatic, LRUCache, MemoryBlobStorage, type MergeTopics, type ModelConstraint, type ModelConstraintMap, type ModelName, type ModelProfile, type ModelRegistry, type NotFoundError, type OverrideSessionPreferences, type PermissionDeniedError, type PermissionGuard, type Preference, type PreferenceSummary, type Project, type PromptBuilder, type PromptBuilderOptions, type PurgeBlob, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type RemoteContextContent, type ResolvedBlob, type ResolvedSession, type Result, type RetainBlob, type Role, type RoleSummary, type RoleTransitionBlock, type SHA256, Session, SessionManager, type SessionMetadata, type SessionSnapshot, type Settings, type Store, type Summarizer, type SummaryBlock, type SwitchSessionRole, type SyncWorkspace, type SystemActor, type TextBlock, type TextContextContent, type ThinkingBlock, type Timestamp, type ToolCall, type ToolCallCommand, type ToolRegistry, type ToolResultBlock, type ToolSummary, type ToolUseBlock, type Topic, type TopicIndex, type Turn, TurnBuilder, type TurnKey, type TurnNode, type TurnProcessor, type TurnRef, TurnTree, type URI, type UUID, type UpdateContext, type UpdatePreference, type UpdateRole, type UpdateSession, type UpdateTopic, type UpdateTurn, type Workspace, type WorkspaceBundle, type WorkspaceContext, type WorkspaceDatabase, type WorkspaceError, type WorkspaceEvents, type WorkspaceExtension, WorkspaceManager, type WorkspaceMiddleware, type WorkspaceReducer, bufferToBase64, computeSHA256, createEmptySession, createEmptyTurn, createEmptyWorkspace, createWorkspace, createWorkspaceDatabase, del, error, getExtension, merge, ok, omitNullUndefined, shortHash, success };
|