@asaidimu/utils-workspace 7.0.0 → 7.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/index.d.mts CHANGED
@@ -2,7 +2,132 @@ import * as _asaidimu_anansi from '@asaidimu/anansi';
2
2
  import { IndexDefinition, SchemaDefinition, SchemaChange, DataTransform, PredicateMap } from '@asaidimu/anansi';
3
3
  import { QueryFilter, PaginationOptions } from '@asaidimu/query';
4
4
  import { GoogleGenAI, GenerateContentParameters } from '@google/genai';
5
- import { LanguageModel, ContentPart } from 'ai';
5
+
6
+ /**
7
+ * Severity levels for structured issues and errors.
8
+ */
9
+ type Severity = "error" | "warning" | "info";
10
+ /**
11
+ * Represents a detailed validation or operational problem.
12
+ * Designed to be machine-readable while remaining human-friendly.
13
+ */
14
+ interface Issue {
15
+ /** Machine-readable identifier (e.g., "REQUIRED_FIELD_MISSING"). */
16
+ readonly code: string;
17
+ /** Human-readable description of the problem. */
18
+ readonly message: string;
19
+ /** Field path in a document or state (e.g., "users.0.email"). */
20
+ readonly path?: string;
21
+ /** Optional array index when the issue relates to a specific element. */
22
+ readonly index?: number;
23
+ /** Seriousness of the issue. Defaults to "error". */
24
+ readonly severity?: Severity;
25
+ /** Optional detailed explanation, can be multi-line. */
26
+ readonly description?: string;
27
+ /** Nested issues that caused this one. */
28
+ readonly cause?: readonly Issue[];
29
+ }
30
+ /**
31
+ * Standardized error code format: CATEGORY-XXX[-SUFFIX]
32
+ * Examples:
33
+ * - VAL-001 (Validation: required field missing)
34
+ * - DB-002-NF (Database: not found)
35
+ * - AUTH-003-DENIED (Auth: permission denied)
36
+ */
37
+ interface ErrorCodeMetadata {
38
+ /** The formal error code (e.g., "VAL-001") */
39
+ readonly code: string;
40
+ /** Human-readable name for the error type */
41
+ readonly name: string;
42
+ /** Detailed description of when this error occurs */
43
+ readonly description: string;
44
+ /** Suggested action for handling or resolving the error */
45
+ readonly action?: string;
46
+ /** HTTP status code mapping (if applicable) */
47
+ readonly httpStatus?: number;
48
+ /** Category of the error */
49
+ readonly category: ErrorCategory;
50
+ /** Whether this error should be logged as warning vs error */
51
+ readonly logLevel?: "debug" | "info" | "warn" | "error";
52
+ }
53
+ type ErrorCategory = "validation" | "database" | "auth" | "business" | "system" | "network" | "concurrency" | "custom";
54
+ /**
55
+ * SystemError is the primary error type for all operational and validation errors.
56
+ * Supports both predefined and custom error codes with full metadata.
57
+ */
58
+ declare class SystemError extends Error {
59
+ readonly code: string;
60
+ readonly codeMetadata: ErrorCodeMetadata;
61
+ readonly severity: Severity;
62
+ readonly path?: string;
63
+ readonly operation?: string;
64
+ readonly issues: readonly Issue[];
65
+ readonly cause?: unknown;
66
+ constructor(params: {
67
+ code: string;
68
+ message?: string;
69
+ severity?: Severity;
70
+ path?: string;
71
+ operation?: string;
72
+ issues?: readonly Issue[];
73
+ cause?: unknown;
74
+ metadata?: Partial<Omit<ErrorCodeMetadata, "code">>;
75
+ });
76
+ /**
77
+ * Returns a new SystemError with the specified path.
78
+ */
79
+ withPath(path: string): SystemError;
80
+ /**
81
+ * Returns a new SystemError with the specified operation name.
82
+ */
83
+ withOperation(operation: string): SystemError;
84
+ /**
85
+ * Returns a new SystemError with the specified issue appended.
86
+ */
87
+ withIssue(issue: Issue): SystemError;
88
+ /**
89
+ * Returns a new SystemError with multiple issues appended.
90
+ */
91
+ withIssues(issues: readonly Issue[]): SystemError;
92
+ /**
93
+ * Returns a new SystemError wrapping the specified cause.
94
+ */
95
+ withCause(cause: unknown): SystemError;
96
+ /**
97
+ * Returns the HTTP status code for this error (if applicable).
98
+ */
99
+ getHttpStatus(): number | undefined;
100
+ /**
101
+ * Formats the error for logging with structured metadata.
102
+ */
103
+ toLogEntry(): Record<string, unknown>;
104
+ /**
105
+ * Produces a human-readable representation suitable for logging.
106
+ */
107
+ toString(): string;
108
+ }
109
+ /**
110
+ * Factory for creating a new SystemError with automatic metadata.
111
+ */
112
+ declare function createError(code: string, message?: string): SystemError;
113
+ /**
114
+ * A functional wrapper for operations that can fail.
115
+ * Encourages explicit error handling over try/catch blocks.
116
+ */
117
+ type Result$1<T, E = SystemError> = {
118
+ readonly ok: true;
119
+ readonly value: T;
120
+ } | {
121
+ readonly ok: false;
122
+ readonly error: E;
123
+ };
124
+ /**
125
+ * Type-safe helpers for creating Results.
126
+ */
127
+ declare const Result$1: {
128
+ ok: <T>(value: T) => Result$1<T, never>;
129
+ fail: <E>(error: E) => Result$1<never, E>;
130
+ };
6
131
 
7
132
  type SerializerResult<T> = {
8
133
  value: T | null;
@@ -123,97 +248,19 @@ declare const Branded: {
123
248
  };
124
249
 
125
250
  /**
126
- * Severity levels for structured issues and errors.
127
- */
128
- type Severity = "error" | "warning" | "info";
129
- /**
130
- * Represents a detailed validation or operational problem.
131
- * Designed to be machine-readable while remaining human-friendly.
132
- */
133
- interface Issue {
134
- /** Machine-readable identifier (e.g., "REQUIRED_FIELD_MISSING"). */
135
- readonly code: string;
136
- /** Human-readable description of the problem. */
137
- readonly message: string;
138
- /** Field path in a document or state (e.g., "users.0.email"). */
139
- readonly path?: string;
140
- /** Optional array index when the issue relates to a specific element. */
141
- readonly index?: number;
142
- /** Seriousness of the issue. Defaults to "error". */
143
- readonly severity?: Severity;
144
- /** Optional detailed explanation, can be multi-line. */
145
- readonly description?: string;
146
- /** Nested issues that caused this one. */
147
- readonly cause?: readonly Issue[];
148
- }
149
- /**
150
- * SystemError is the primary error type for all operational and validation errors.
151
- * It provides rich contextual information and supports immutable composition
152
- * through a fluent API.
153
- */
154
- declare class SystemError extends Error {
155
- readonly code: string;
156
- readonly severity: Severity;
157
- readonly path?: string;
158
- readonly operation?: string;
159
- readonly issues: readonly Issue[];
160
- readonly cause?: unknown;
161
- constructor(params: {
162
- code: string;
163
- message: string;
164
- severity?: Severity;
165
- path?: string;
166
- operation?: string;
167
- issues?: readonly Issue[];
168
- cause?: unknown;
169
- });
170
- /**
171
- * Returns a new SystemError with the specified path.
172
- * Path typically indicates the location in a data structure where the error occurred.
173
- */
174
- withPath(path: string): SystemError;
175
- /**
176
- * Returns a new SystemError with the specified operation name.
177
- * Describes what was being attempted when the error occurred.
178
- */
179
- withOperation(operation: string): SystemError;
180
- /**
181
- * Returns a new SystemError with the specified issue appended.
182
- */
183
- withIssue(issue: Issue): SystemError;
184
- /**
185
- * Returns a new SystemError with multiple issues appended.
186
- */
187
- withIssues(issues: readonly Issue[]): SystemError;
188
- /**
189
- * Returns a new SystemError wrapping the specified cause.
190
- */
191
- withCause(cause: unknown): SystemError;
192
- /**
193
- * Produces a human-readable representation suitable for logging.
194
- */
195
- toString(): string;
196
- }
197
- /**
198
- * Factory for creating a new SystemError.
199
- */
200
- declare function createError(code: string, message: string): SystemError;
201
- /**
202
- * Predefined common error codes.
251
+ * Predefined common error codes, mapped to the standard ErrorCodes registry.
203
252
  */
204
253
  declare const CommonErrors: {
205
- readonly NOT_FOUND: "NOT_FOUND";
206
- readonly DUPLICATE_KEY: "DUPLICATE_KEY";
207
- readonly INVALID_COMMAND: "INVALID_COMMAND";
208
- readonly PERMISSION_DENIED: "PERMISSION_DENIED";
209
- readonly BACKEND_ERROR: "BACKEND_ERROR";
210
- readonly INTERNAL_ERROR: "INTERNAL_ERROR";
211
- readonly VALIDATION_FAILED: "VALIDATION_FAILED";
212
- readonly CONCURRENCY_ERROR: "CONCURRENCY_ERROR";
213
- /** Returned when an operation cannot proceed because a resource is locked. */
214
- readonly RESOURCE_LOCKED: "RESOURCE_LOCKED";
215
- /** Returned when an operation was explicitly aborted or the system is shutting down. */
216
- readonly OPERATION_ABORTED: "OPERATION_ABORTED";
254
+ readonly NOT_FOUND: "DB-001-NF";
255
+ readonly DUPLICATE_KEY: "DB-002-DUP";
256
+ readonly INVALID_COMMAND: "BUS-001";
257
+ readonly PERMISSION_DENIED: "AUTH-001-DENIED";
258
+ readonly BACKEND_ERROR: "SYS-002";
259
+ readonly INTERNAL_ERROR: "SYS-001";
260
+ readonly VALIDATION_FAILED: "VAL-001";
261
+ readonly CONCURRENCY_ERROR: "CON-001";
262
+ readonly RESOURCE_LOCKED: "DB-003-LOCK";
263
+ readonly OPERATION_ABORTED: "BUS-002-ABORT";
217
264
  };
218
265
 
219
266
  /**
@@ -336,14 +383,25 @@ interface Event<T extends string = string, P = any, M extends Metadata = {}> {
336
383
  readonly meta: M;
337
384
  }
338
385
  /**
339
- * A pure function that calculates a state patch based on a command.
340
- * Reducers are the primary mechanism for state mutation in the CQRS loop.
386
+ * Represents the structured outcome of an Action.
387
+ * Allows an action to specify both a state patch and a computational result.
388
+ */
389
+ interface ActionOutcome<S extends Record<string, any>, I extends Index, R = any> {
390
+ /** The speculative state patch to be applied to the system. */
391
+ patch?: DeepPartial<State<S, I>>;
392
+ /** The computational return value for the caller. */
393
+ result?: R;
394
+ }
395
+ /**
396
+ * A pure-ish function that calculates a state patch and/or a result based on a command.
397
+ * Actions are the primary mechanism for logic execution in the CQRS loop.
341
398
  *
342
399
  * @template S - The Domain State type.
343
400
  * @template I - The Index type.
344
401
  * @template C - The specific Command type being handled.
402
+ * @template R - The result type.
345
403
  */
346
- type Action<S extends Record<string, any>, I extends Index, C extends Command<any, any, any>> = (state: State<S, I>, command: C) => DeepPartial<State<S, I>> | Promise<DeepPartial<State<S, I>>>;
404
+ type Action<S extends Record<string, any>, I extends Index, C extends Command<any, any, any>, R = any> = (state: State<S, I>, command: C) => Result<DeepPartial<State<S, I>> | ActionOutcome<S, I, R>, SystemError> | Promise<Result<DeepPartial<State<S, I>> | ActionOutcome<S, I, R>, SystemError>>;
347
405
  type ActionEntry<S extends Record<string, any>, I extends Index, C extends Command<any, any, any>> = {
348
406
  action: Action<S, I, C>;
349
407
  namespace: string;
@@ -363,8 +421,8 @@ type Middleware<S extends Record<string, any>, I extends Index> = (api: {
363
421
  /** Returns the current consistent snapshot of the state. */
364
422
  state: () => State<S, I>;
365
423
  /** Re-dispatches a command through the full pipeline. */
366
- dispatch: <C extends Command<any, any, any>>(command: C) => Promise<Result<void, SystemError>>;
367
- }) => (next: (command: Command<any, any, any>) => Promise<Result<DeepPartial<State<S, I>>, SystemError>>) => (command: Command<any, any, any>) => Promise<Result<DeepPartial<State<S, I>>, SystemError>>;
424
+ dispatch: <C extends Command<any, any, any>, R = any>(command: C) => Promise<Result<R, SystemError>>;
425
+ }) => (next: (command: Command<any, any, any>) => Promise<Result<ActionOutcome<S, I>, SystemError>>) => (command: Command<any, any, any>) => Promise<Result<ActionOutcome<S, I>, SystemError>>;
368
426
  /**
369
427
  * A collection of named registries that collectively know how to produce
370
428
  * a materialized index projection.
@@ -405,17 +463,8 @@ interface StateManager<T extends Record<string, any>> {
405
463
  * @returns The new full state tree after the patch is applied.
406
464
  */
407
465
  set(update: DeepPartial<T>): Promise<T>;
408
- /**
409
- * Subscribes to state changes.
410
- * Useful for UI components or background workers that need to remain
411
- * reactive to the evolving system state.
412
- *
413
- * @param listener - Function called whenever the state is updated.
414
- * @returns An unsubscribe function.
415
- */
416
- subscribe(listener: (state: T) => void): () => void;
417
466
  }
418
- type StateReader<T extends Record<string, any>> = Pick<StateManager<T>, "get" | "subscribe">;
467
+ type StateReader<T extends Record<string, any>> = Pick<StateManager<T>, "get">;
419
468
 
420
469
  /**
421
470
  * Buffers write operations across one or more stores and commits them atomically.
@@ -835,7 +884,7 @@ type TelemetryEvent = {
835
884
  } | null;
836
885
  };
837
886
  };
838
- interface DatabaseConfig {
887
+ interface DatabaseConfig$1 {
839
888
  database: string;
840
889
  keyPath?: string;
841
890
  schemasStoreName?: string;
@@ -843,7 +892,7 @@ interface DatabaseConfig {
843
892
  predicates?: PredicateMap;
844
893
  validate?: boolean;
845
894
  }
846
- type StoreConfig = DatabaseConfig & {
895
+ type StoreConfig = DatabaseConfig$1 & {
847
896
  collection: string;
848
897
  };
849
898
 
@@ -888,7 +937,7 @@ interface Store<T extends Metadata, K extends StoreKey<T>, S = T> {
888
937
  * Retrieves all entities from the store.
889
938
  * @returns Array of all entities (empty array if none exist)
890
939
  */
891
- list(): Promise<T[]>;
940
+ list(keys?: Array<T[K]>): Promise<T[]>;
892
941
  /**
893
942
  * Distills a full entity into a lightweight summary for indexing operations.
894
943
  * Used to optimize memory usage when working with large collections.
@@ -1057,13 +1106,13 @@ interface CommandRegistry<S extends Record<string, any>, I extends Index = {}> {
1057
1106
  interface CommandCoordinator<T extends string> {
1058
1107
  /**
1059
1108
  * Dispatches a single command through the auth → middleware → reducer
1060
- * state pipeline.
1109
+ * pipeline and commits the resulting state patch.
1061
1110
  *
1062
1111
  * @param ctx - The verified identity and permissions of the actor.
1063
1112
  * @param command - The command carrying intent and payload.
1064
- * @returns - A Result indicating success or a structured failure.
1113
+ * @returns - A Result containing the computational return value or a SystemError.
1065
1114
  */
1066
- dispatch<C extends Command<any, any, any>>(ctx: AuthContext<T>, command: C): Promise<Result<void, SystemError>>;
1115
+ dispatch<C extends Command<any, any, any>, R = any>(ctx: AuthContext<T>, command: C): Promise<Result<R, SystemError>>;
1067
1116
  /**
1068
1117
  * Executes a sequence of steps as an atomic saga.
1069
1118
  *
@@ -1112,7 +1161,10 @@ interface IRegistry<T> {
1112
1161
  clear(): void;
1113
1162
  /** Creates a deep clone of the registry. */
1114
1163
  clone(): IRegistry<T>;
1164
+ /** Returns a record of entrys keyed by a string key */
1115
1165
  entries(): Record<string, T>;
1166
+ /** Returns number of items in registry */
1167
+ count(): number;
1116
1168
  }
1117
1169
  /** The read/write contract for a registry. */
1118
1170
  type IRegistryReader<T> = Pick<IRegistry<T>, "get" | "list" | "entries" | "has">;
@@ -1264,12 +1316,13 @@ declare class Registry<T> implements IRegistry<T> {
1264
1316
  * Creates a deep clone of the registry.
1265
1317
  * @returns A new Registry instance with deeply cloned items
1266
1318
  */
1267
- clone(): Registry<T>;
1319
+ clone(): IRegistry<T>;
1268
1320
  /**
1269
1321
  * Returns all registry entries as a plain object.
1270
1322
  * @returns Object with all registry key-value pairs
1271
1323
  */
1272
1324
  entries(): Record<string, T>;
1325
+ count(): number;
1273
1326
  }
1274
1327
 
1275
1328
  /**
@@ -1298,7 +1351,7 @@ declare class ExecutionEngine<T extends string, S extends Record<string, any>, I
1298
1351
  get authorizer(): Authorizer<T, S, I>;
1299
1352
  register<C extends Command<any, any, any>>(namespace: string, type: C["type"], reducer: Action<S, I, C>): Result<void, SystemError>;
1300
1353
  use(middleware: Middleware<S, I>): void;
1301
- dispatch<C extends Command<any, any, any>>(ctx: AuthContext<T>, command: C): Promise<Result<void, SystemError>>;
1354
+ dispatch<C extends Command<any, any, any>, R = any>(ctx: AuthContext<T>, command: C): Promise<Result<R, SystemError>>;
1302
1355
  transact(ctx: AuthContext<T>, steps: TransactionStep[]): Promise<Result<void, SystemError>>;
1303
1356
  /**
1304
1357
  * Core dispatch pipeline: auth → middleware chain → reducer → state.
@@ -1348,7 +1401,7 @@ declare class ExecutionEngine<T extends string, S extends Record<string, any>, I
1348
1401
  declare class KernelCoordinator<T extends string, S extends Record<string, any>, I extends Index = {}> implements CommandCoordinator<T>, AuthorizationProvider<T, S, I> {
1349
1402
  private readonly engine;
1350
1403
  private readonly serializer;
1351
- constructor(engine: ExecutionEngine<T, S, I>, serializer: Serializer<Result<void, SystemError>>);
1404
+ constructor(engine: ExecutionEngine<T, S, I>, serializer: Serializer<Result<any, SystemError>>);
1352
1405
  get authorizer(): Authorizer<T, S, I>;
1353
1406
  /**
1354
1407
  * Dispatches a single command through the serialized execution pipeline.
@@ -1359,7 +1412,7 @@ declare class KernelCoordinator<T extends string, S extends Record<string, any>,
1359
1412
  * @param ctx - The verified identity and permissions of the actor.
1360
1413
  * @param command - The command carrying intent and payload.
1361
1414
  */
1362
- dispatch<C extends Command<any, any, any>>(ctx: AuthContext<T>, command: C): Promise<Result<void, SystemError>>;
1415
+ dispatch<C extends Command<any, any, any>, R = any>(ctx: AuthContext<T>, command: C): Promise<Result<R, SystemError>>;
1363
1416
  /**
1364
1417
  * Executes a multi-step transaction through the serialized pipeline.
1365
1418
  *
@@ -1527,7 +1580,7 @@ declare function createAuthContext<ActorType extends string, Meta extends Metada
1527
1580
  /**
1528
1581
  * Pre-built auth contexts for common scenarios.
1529
1582
  */
1530
- declare const SystemActor$1: {
1583
+ declare const SystemAuth: {
1531
1584
  /**
1532
1585
  * Create a system actor auth context with full permissions.
1533
1586
  * The system actor bypasses most authorization checks.
@@ -1557,6 +1610,140 @@ declare function createAnonymousContext(): AuthContext<"anonymous">;
1557
1610
  */
1558
1611
  declare function createUserContext(userId: UUID, scopes?: string[], metadata?: UUID): AuthContext<"user">;
1559
1612
 
1613
+ /**
1614
+ * A ultra-compact, runtime-scoped tracking registry.
1615
+ * Translates multi-segment semantic components or dynamic types
1616
+ * into 1-token safe base36 structural short-hashes.
1617
+ */
1618
+ declare class ShortKeyRegistry<T extends string = string> {
1619
+ private readonly counters;
1620
+ private readonly runtimeSalt;
1621
+ constructor();
1622
+ /**
1623
+ * Generates a compact, non-colliding short token key.
1624
+ * Compresses the target scope tracking increment into a deterministic signature.
1625
+ */
1626
+ next(scope: T): string;
1627
+ /**
1628
+ * Reset local execution indices for context window boundary updates.
1629
+ */
1630
+ clear(): void;
1631
+ }
1632
+
1633
+ /**
1634
+ * Utility class for common blob and binary data operations.
1635
+ * Optimized for environments supporting Node.js, Browsers, and Edge runtimes.
1636
+ */
1637
+ declare class BlobUtilities {
1638
+ /**
1639
+ * Computes the SHA-256 hash of a given Uint8Array.
1640
+ * @param data The Uint8Array to hash.
1641
+ * @returns A Promise that resolves to the SHA-256 hash as a hexadecimal string.
1642
+ */
1643
+ static computeSHA256(data: Uint8Array): Promise<string>;
1644
+ /**
1645
+ * Computes a CRC32 checksum of a given Uint8Array for fast data integrity verification.
1646
+ * @param data The Uint8Array to checksum.
1647
+ * @returns The CRC32 checksum as a hexadecimal string.
1648
+ */
1649
+ static computeCRC32(data: Uint8Array): string;
1650
+ /**
1651
+ * Converts a Uint8Array to a Base64 string.
1652
+ * Uses native Buffer in Node.js/Deno, and falls back to a chunked btoa()
1653
+ * implementation for Browsers and Edge environments to avoid stack overflows.
1654
+ * @param buffer The Uint8Array to convert.
1655
+ * @returns The Base64 encoded string.
1656
+ */
1657
+ static bufferToBase64(buffer: Uint8Array): string;
1658
+ /**
1659
+ * Converts a Base64 string back to a Uint8Array.
1660
+ * @param base64 The Base64 encoded string.
1661
+ * @returns The decoded Uint8Array.
1662
+ */
1663
+ static base64ToBuffer(base64: string): Uint8Array;
1664
+ /**
1665
+ * Generates a short, deterministic hash of a string.
1666
+ * Returns a uniformly distributed, fixed-length base36 string.
1667
+ * @param s The string to hash.
1668
+ * @param length The desired length of base36 hash. Defaults to 4.
1669
+ * @returns The short base36 hash string.
1670
+ */
1671
+ static shortHash(s: string, length?: number): string;
1672
+ /**
1673
+ * Converts a Blob to a Uint8Array.
1674
+ * @param blob The Blob to convert.
1675
+ * @returns A Promise that resolves to the Uint8Array.
1676
+ */
1677
+ static blobToUint8Array(blob: Blob): Promise<Uint8Array>;
1678
+ /**
1679
+ * Creates a Blob from a Uint8Array.
1680
+ * @param data The Uint8Array to create the blob from.
1681
+ * @param mimeType The MIME type of the blob (e.g., 'application/octet-stream').
1682
+ * @returns The resulting Blob.
1683
+ */
1684
+ static uint8ArrayToBlob(data: Uint8Array, mimeType?: string): Blob;
1685
+ /**
1686
+ * Encodes a string into a Uint8Array using UTF-8.
1687
+ * @param text The string to encode.
1688
+ * @returns The encoded Uint8Array.
1689
+ */
1690
+ static textToUint8Array(text: string): Uint8Array;
1691
+ /**
1692
+ * Decodes a Uint8Array into a string using UTF-8.
1693
+ * @param data The Uint8Array to decode.
1694
+ * @returns The decoded string.
1695
+ */
1696
+ static uint8ArrayToText(data: Uint8Array): string;
1697
+ /**
1698
+ * Converts a Uint8Array to a URL-safe Base64 string.
1699
+ * Replaces '+' with '-', '/' with '_', and removes trailing '=' padding.
1700
+ * @param buffer The Uint8Array to convert.
1701
+ * @returns The URL-safe Base64 encoded string.
1702
+ */
1703
+ static bufferToUrlSafeBase64(buffer: Uint8Array): string;
1704
+ /**
1705
+ * Converts a URL-safe Base64 string back to a Uint8Array.
1706
+ * Restores padding and replaces characters back to standard Base64.
1707
+ * @param base64 The URL-safe Base64 encoded string.
1708
+ * @returns The decoded Uint8Array.
1709
+ */
1710
+ static urlSafeBase64ToBuffer(base64: string): Uint8Array;
1711
+ /**
1712
+ * Slices a Blob into chunks of a specified size.
1713
+ * This is useful for uploading large files in parts or feeding data into LLM context windows.
1714
+ * @param blob The Blob to slice.
1715
+ * @param chunkSize The size of each chunk in bytes.
1716
+ * @param options An optional configuration for the chunking process.
1717
+ * @returns An async generator that yields Uint8Arrays of the binary data.
1718
+ */
1719
+ static chunkBlob(blob: Blob, chunkSize?: number): AsyncGenerator<Uint8Array>;
1720
+ /**
1721
+ * Wraps a Uint8Array with metadata providing business context for ERP systems.
1722
+ * The metadata is stored as a JSON string at the start of the Blob, followed by the length of the length of the metadata length.
1723
+ * @param buffer The binary data to wrap.
1724
+ * @param metadata own a single object containing metadata keys/values.
1725
+ * @returns A Uint8Array containing metadata and binary data.
1726
+ */
1727
+ static wrapBlobMetadata(buffer: Uint8Array, metadata: Record<string, any>): Uint8Array;
1728
+ /**
1729
+ * Unwraps a Uint8Array containing metadata wrapped by wrapBlobMetadata.
1730
+ * @param wrappedBuffer own a Uint8Array containing metadata and metadata length.
1731
+ * @returns An object containing the original binary data and the metadata object.
1732
+ * @throws Error if the buffer is too small or contains invalid metadata length.
1733
+ */
1734
+ static unwrapBlobMetadata(wrappedBuffer: Uint8Array): {
1735
+ data: Uint8Array;
1736
+ metadata: Record<string, any>;
1737
+ };
1738
+ }
1739
+
1740
+ type DatabaseConfig = {
1741
+ factory: StoreFactory;
1742
+ database: string;
1743
+ validate?: boolean;
1744
+ predicates?: Record<string, any>;
1745
+ schemas: Array<SchemaDefinition>;
1746
+ };
1560
1747
  /**
1561
1748
  * Robust implementation of WorkspaceDatabase using @asaidimu/database.
1562
1749
  * Manages the complete lifecycle of database connections and handles
@@ -1582,13 +1769,7 @@ declare class WorkspaceDatabase implements IWorkspaceDatabase {
1582
1769
  * @param config.validate - Whether to validate schema definitions
1583
1770
  * @param config.schemas - Core schemas to register (always loaded)
1584
1771
  */
1585
- constructor(config: {
1586
- factory: StoreFactory;
1587
- database: string;
1588
- validate?: boolean;
1589
- predicates?: Record<string, any>;
1590
- schemas: Array<SchemaDefinition>;
1591
- });
1772
+ constructor(config: DatabaseConfig);
1592
1773
  /**
1593
1774
  * Opens the database connection and registers schemas.
1594
1775
  * Core schemas from config are always registered, followed by
@@ -1689,7 +1870,7 @@ declare abstract class BaseStore<T extends Metadata, K extends StoreKey<T>, S =
1689
1870
  *
1690
1871
  * @returns Array of entities (limited by this.limit)
1691
1872
  */
1692
- list(): Promise<T[]>;
1873
+ list(keys?: Array<T[K]>): Promise<T[]>;
1693
1874
  /**
1694
1875
  * Converts a full entity into a lightweight summary for indexing.
1695
1876
  * Default implementation returns the full entity as the summary.
@@ -1824,7 +2005,7 @@ declare class ModuleAggregator<T extends string, S extends Record<string, any>,
1824
2005
  }
1825
2006
 
1826
2007
  type ContentCoreState = any;
1827
- interface Blob extends Identifiable, Timestamped, Versioned {
2008
+ interface Blob$1 extends Identifiable, Timestamped, Versioned {
1828
2009
  readonly checksum: SHA256;
1829
2010
  readonly size: number;
1830
2011
  readonly mime: string;
@@ -1844,7 +2025,7 @@ interface Blob extends Identifiable, Timestamped, Versioned {
1844
2025
  * A lightweight reference to a blob.
1845
2026
  * Used in content blocks to avoid passing heavy metadata or binary data across boundaries.
1846
2027
  */
1847
- type BlobRef = Pick<Blob, "id" | "checksum" | "mime" | "size">;
2028
+ type BlobRef = Pick<Blob$1, "id" | "checksum" | "mime" | "size">;
1848
2029
  type ResolvedBlob = {
1849
2030
  /** Indicates the blob data is available in the local memory space. */
1850
2031
  kind: "inline";
@@ -1982,191 +2163,201 @@ interface ContentDefinition<ContentType extends string, Data extends Record<stri
1982
2163
  * Used for displaying context in prompts, logs, or debugging.
1983
2164
  */
1984
2165
  format?: (block: Content<ContentType, Data>) => string | null;
1985
- }
1986
-
1987
- /**
1988
- * Hybrid BlobStore that coordinates between Anansi (metadata)
1989
- * and BlobStorage (raw bytes).
1990
- *
1991
- * This implementation addresses the constraint that Anansi should
1992
- * not store large binary payloads directly.
1993
- */
1994
- declare class BlobStore extends BaseStore<Blob, "id", Blob> {
1995
- private readonly storage;
1996
- constructor(collection: Collection<Blob>, storage: BlobStorage);
1997
- /**
1998
- * Overridden to hydrate the binary data from specialized storage.
1999
- */
2000
- get(id: UUID): Promise<Blob | null>;
2001
- /**
2002
- * Overridden to separate metadata and binary data during creation.
2003
- */
2004
- add(entity: Blob): Promise<void>;
2005
- /**
2006
- * Overridden to ensure bytes are purged when the record is deleted.
2007
- */
2008
- delete(id: UUID): Promise<boolean>;
2009
- /**
2010
- * Finds a blob by its content checksum.
2011
- */
2012
- findByChecksum(checksum: SHA256): Promise<Blob | null>;
2013
- /**
2014
- * Resolves a BlobRef to a ResolvedBlob (inline or remote) or null.
2015
- *
2016
- * Resolution precedence:
2017
- * 1. provider provided and remote mapping exists for that provider → remote blob
2018
- * 2. otherwise → local bytes
2019
- */
2020
- resolve(id: UUID, provider?: string): Promise<Result<ResolvedBlob | null, SystemError>>;
2021
2166
  /**
2022
- * Resolves multiple blobs concurrently.
2167
+ * Scans a content block of this type for actionable side effects.
2168
+ * Returns a list of Commands to be dispatched against the workspace.
2023
2169
  */
2024
- resolveMany(ids: UUID[], provider?: string): Promise<Result<Map<UUID, ResolvedBlob>, SystemError>>;
2170
+ parse?: (block: Content<ContentType, Data>) => Command<any>[];
2025
2171
  }
2026
2172
 
2027
2173
  /**
2028
- * Content Module Commands
2174
+ * Data shape for preference (instructional) content.
2029
2175
  */
2030
- type AddContentCommand = Command<"content:add", Content<any, any>>;
2031
- type UpdateContentCommand = Command<"content:update", {
2032
- id: UUID;
2033
- updates: Partial<Content<any, any>>;
2034
- }>;
2035
- type DeleteContentCommand = Command<"content:delete", {
2036
- id: UUID;
2037
- }>;
2038
- /**
2039
- * Blob Management Commands (Durable Registry)
2040
- */
2041
- /** Registers a new blob in the system. */
2042
- type RegisterBlobCommand = Command<"blob:register", {
2043
- id: UUID;
2176
+ interface PreferenceData {
2177
+ instruction: string;
2178
+ }
2179
+ interface BlobData {
2180
+ id: string;
2044
2181
  checksum: SHA256;
2045
2182
  size: number;
2046
2183
  mime: string;
2047
- data: Uint8Array;
2048
2184
  filename?: string;
2049
- metadata?: Record<string, any>;
2050
- }>;
2051
- /** Increments the reference count of a blob to prevent garbage collection. */
2052
- type RetainBlobCommand = Command<"blob:retain", {
2053
- id: UUID;
2054
- }>;
2055
- /** Decrements the reference count of a blob. */
2056
- type ReleaseBlobCommand = Command<"blob:release", {
2057
- id: UUID;
2058
- }>;
2059
- /** Immediately removes a blob and its binary data. */
2060
- type PurgeBlobCommand = Command<"blob:purge", {
2061
- id: UUID;
2062
- }>;
2063
- /** Records a mapping between a local blob and an external provider's ID. */
2064
- type RecordBlobRemoteIdCommand = Command<"blob:record_remote_id", {
2065
- id: UUID;
2066
- providerId: string;
2067
- fileId: string;
2068
- timestamp?: Timestamp;
2069
- }>;
2070
- /**
2071
- * Union of all Content and Blob commands.
2072
- */
2073
- type ContentCommand = AddContentCommand | UpdateContentCommand | DeleteContentCommand | RegisterBlobCommand | RetainBlobCommand | ReleaseBlobCommand | PurgeBlobCommand | RecordBlobRemoteIdCommand;
2185
+ }
2186
+ interface ToolResultData {
2187
+ /** Name of the tool that produced this result */
2188
+ name: string;
2189
+ /** The output returned by the tool (any JSON-serializable value) */
2190
+ result: unknown;
2191
+ /** Identifier that links this result to the original tool-call */
2192
+ key: string;
2193
+ /** Optional error message if the tool execution failed */
2194
+ error?: string;
2195
+ }
2196
+ type PreferenceContent = Content<"preference", PreferenceData>;
2197
+ type ToolResultContent = Content<"tool:result", ToolResultData>;
2074
2198
 
2075
2199
  /**
2076
- * Durable storage for Content entities.
2200
+ * Reflects the current state of the LLM adapter (limits, headroom, and readiness).
2077
2201
  */
2078
- declare class ContentStore extends BaseStore<Content<any>, "id", ContentSummary<any>> {
2079
- constructor(collection: Collection<Content<any>>);
2202
+ interface ModelStatus {
2203
+ /** Provider name (e.g., "google", "anthropic", "openai"). */
2204
+ provider: string;
2205
+ /** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
2206
+ model: string;
2207
+ /** Whether the adapter is currently able to accept requests. */
2208
+ ready: boolean;
2209
+ /** Token window limits and current usage. */
2210
+ window: {
2211
+ /** Total context window size in tokens. */
2212
+ size: number;
2213
+ /** Maximum output tokens for this model. */
2214
+ out: number;
2215
+ /** Tokens remaining - estimated or as reported by the provider. */
2216
+ free?: number;
2217
+ };
2218
+ /** Capability flags for this model. */
2219
+ feature: {
2220
+ /** Whether the model can process image inputs. */
2221
+ vision: boolean;
2222
+ /** Whether the model supports tool/function calling. */
2223
+ tools: boolean;
2224
+ /** Whether the model supports structured JSON output mode. */
2225
+ json: boolean;
2226
+ /** Whether the provider supports prompt caching. */
2227
+ cache: boolean;
2228
+ /** Whether the adapter supports streaming. */
2229
+ streaming: boolean;
2230
+ /** Whether the model supports extended thinking/reasoning tokens. */
2231
+ thinking: boolean;
2232
+ };
2233
+ /** Pricing tiers for this model. */
2234
+ pricing: Array<{
2235
+ unit: "token" | "call" | "image";
2236
+ /** Exponent: price is per 10^scale units. */
2237
+ scale: number;
2238
+ /** Price per unit in USD. */
2239
+ cost: {
2240
+ input: number;
2241
+ output: number;
2242
+ cache?: {
2243
+ read: number;
2244
+ write: number;
2245
+ };
2246
+ };
2247
+ }>;
2248
+ /** Current rate limit state. */
2249
+ rate: {
2250
+ /** Current saturation as a fraction of the most constrained limit (0.0 to 1.0). */
2251
+ load: number;
2252
+ /** Milliseconds until the next request is permitted. */
2253
+ timeout?: number;
2254
+ /** The hard limits enforced by the provider. */
2255
+ capacity: Array<{
2256
+ unit: "token" | "call" | string;
2257
+ /** Maximum units allowed per period. */
2258
+ max: number;
2259
+ /** Period length in seconds. */
2260
+ period: number;
2261
+ }>;
2262
+ };
2263
+ /** Adapter-level notes, e.g. model deprecation warnings. */
2264
+ notes?: string[];
2265
+ }
2266
+ interface ModelProfile {
2267
+ /** Provider identifier, e.g. "google". */
2268
+ provider: string;
2269
+ /** Canonical model string as accepted by the API, e.g. "gemini-2.0-flash". */
2270
+ name: string;
2271
+ /** Display friendly name for the model, e.g "Gemini-2-flash" */
2272
+ label: string;
2273
+ /** Context window and output limits. */
2274
+ window: ModelStatus["window"];
2275
+ /** Capability flags. */
2276
+ feature: ModelStatus["feature"];
2277
+ /** Pricing tiers. */
2278
+ pricing: ModelStatus["pricing"];
2080
2279
  /**
2081
- * Distills a full Content entity into a lightweight summary for indexing.
2280
+ * Hard rate limit capacity as enforced by the provider.
2281
+ * Does not include runtime state (load, timeout).
2082
2282
  */
2083
- summarize(entity: Content<any>): ContentSummary<any>;
2283
+ capacity: ModelStatus["rate"]["capacity"];
2284
+ }
2285
+ /** Unique string identifier for a model (e.g., 'gemini-2.0-flash'). */
2286
+ type ModelName = string;
2287
+ /** Execution constraints applied to a specific model. */
2288
+ interface ModelConstraint {
2289
+ /** Sampling temperature. 0.0 = deterministic, higher = more creative. */
2290
+ temperature?: number;
2291
+ /** Limits and stop boundaries for token generation. */
2292
+ tokens: {
2293
+ /** Maximum output tokens for this request. Overrides adapter defaults. */
2294
+ max?: number;
2295
+ /** Stop sequences — generation halts immediately when any of these are produced. */
2296
+ stops?: string[];
2297
+ /** Thinking/reasoning budget in tokens. (For supported models only). */
2298
+ thought?: number;
2299
+ };
2300
+ }
2301
+ /** Map of model names to their explicit, active constraints. */
2302
+ type ModelConstraints = Record<ModelName, ModelConstraint>;
2303
+ /** A system persona containing specific instructions and associated preferences. */
2304
+ interface Role extends Timestamped, Versioned {
2305
+ /** Unique identifier name used system-wide (e.g. "software-architect"). */
2306
+ name: string;
2307
+ /** Human-readable display label shown in the UI. */
2308
+ label: string;
2309
+ /** Optional human-readable description of what this persona is intended for. */
2310
+ description?: string;
2311
+ /** The core instructions (system prompt base) establishing this persona's behavior. */
2312
+ persona: string;
2313
+ /** Array of Preference UUIDs explicitly bound to this role. */
2314
+ preferences: UUID[];
2315
+ /** Array of semantic Topics associated with this role to guide RAG retrieval. */
2316
+ topics: string[];
2317
+ /** Model constraints natively attached at the role level. */
2318
+ constraints?: ModelConstraints;
2084
2319
  }
2085
-
2086
2320
  /**
2087
- * The ContentModule manages all durable content and binary assets.
2321
+ * Summary of a Role for indexing.
2088
2322
  */
2089
- declare class ContentModule implements Module<"user" | "system", ContentCoreState, ContentIndex, ContentCommand, {
2090
- content: ContentStore;
2091
- blobs: BlobStore;
2092
- }> {
2093
- readonly name = "content";
2094
- readonly schemas: _asaidimu_anansi.SchemaDefinition[];
2095
- registries: Record<string, Registry<any>>;
2096
- private _contentStore?;
2097
- private _blobStore?;
2098
- private _blobStorage;
2099
- constructor({ blobStorage, logger, }: {
2100
- blobStorage: BlobStorage;
2101
- logger: Logger$1;
2102
- });
2103
- stores: (db: any) => Promise<{
2104
- content: ContentStore;
2105
- blobs: BlobStore;
2106
- }>;
2107
- actions: {
2108
- "content:add": (_: State<ContentCoreState, ContentIndex>, command: AddContentCommand) => Promise<{
2109
- index: {
2110
- content: {
2111
- items: {
2112
- [x: string]: ContentSummary<any>;
2113
- };
2114
- keys: {
2115
- [x: string]: string;
2116
- };
2117
- };
2118
- };
2119
- }>;
2120
- "content:update": (state: State<ContentCoreState, ContentIndex>, command: UpdateContentCommand) => Promise<{
2121
- index?: undefined;
2122
- } | {
2123
- index: {
2124
- content: {
2125
- items: {
2126
- [x: string]: ContentSummary<any>;
2127
- };
2128
- keys: {};
2129
- };
2130
- };
2131
- }>;
2132
- "content:delete": (state: State<ContentCoreState, ContentIndex>, command: DeleteContentCommand) => Promise<{
2133
- index?: undefined;
2134
- } | {
2135
- index: {
2136
- content: {
2137
- items: {
2138
- [x: string]: any;
2139
- };
2140
- keys: {
2141
- [x: number]: any;
2142
- };
2143
- };
2144
- };
2145
- }>;
2146
- "blob:register": (state: State<ContentCoreState, ContentIndex>, command: RegisterBlobCommand) => Promise<{
2147
- index: {
2148
- content: {
2149
- blobs: any;
2150
- };
2151
- };
2152
- }>;
2153
- "blob:retain": (_state: State<ContentCoreState, ContentIndex>, command: RetainBlobCommand) => Promise<{}>;
2154
- "blob:release": (_state: State<ContentCoreState, ContentIndex>, command: ReleaseBlobCommand) => Promise<{}>;
2155
- "blob:purge": (state: State<ContentCoreState, ContentIndex>, command: PurgeBlobCommand) => Promise<{
2156
- index?: undefined;
2157
- } | {
2158
- index: {
2159
- content: {
2160
- blobs: any;
2161
- };
2162
- };
2163
- }>;
2164
- "blob:record_remote_id": (_state: State<ContentCoreState, ContentIndex>, command: RecordBlobRemoteIdCommand) => Promise<{}>;
2323
+ interface RoleSummary {
2324
+ readonly name: string;
2325
+ readonly label: string;
2326
+ readonly description?: string;
2327
+ readonly preferences: number;
2328
+ readonly topics: readonly string[];
2329
+ readonly constraints?: ModelConstraints;
2330
+ }
2331
+ /**
2332
+ * Agent Index (Read Model projection)
2333
+ */
2334
+ interface AgentIndex extends Index {
2335
+ readonly roles: Record<string, RoleSummary>;
2336
+ }
2337
+ /**
2338
+ * A tool that can be called by an agent.
2339
+ * Descriptions and parameter structures serve both human engineers (for debugging/registry)
2340
+ * and LLMs (for precise function execution routing).
2341
+ */
2342
+ interface ToolDefinition<Name extends string = string, Params extends Record<string, any> = any> {
2343
+ /** The unique name of the tool. Used in the model response to identify which tool to call. */
2344
+ name: Name;
2345
+ /** Human-readable description explaining what the tool does, its side effects, and when to use it. */
2346
+ description: string;
2347
+ /** JSON Schema fragment defining the tool's parameters. */
2348
+ parameters?: Record<string, unknown>;
2349
+ /** * Explicit execution arguments showcasing expected input profiles.
2350
+ * Directly utilized to ground structured model inferences and guide developers.
2351
+ */
2352
+ example: {
2353
+ input?: Params;
2354
+ explanation: string;
2165
2355
  };
2166
2356
  /**
2167
- * Rebuilds the ContentIndex from durable storage.
2357
+ * The actual implementation function.
2358
+ * This is executed by the system when the model requests this tool.
2168
2359
  */
2169
- index(_: State<ContentCoreState, ContentIndex>): Promise<DeepPartial<ContentIndex>>;
2360
+ execute: (params: Params) => Promise<any>;
2170
2361
  }
2171
2362
 
2172
2363
  /**
@@ -2237,22 +2428,22 @@ type TurnKey = Pick<Turn, "version" | "id" | "session">;
2237
2428
  */
2238
2429
  interface Turn extends Identifiable, Versioned, Timestamped {
2239
2430
  /** The UUID of the chat session this turn belongs to. */
2240
- readonly session: UUID;
2431
+ session: UUID;
2241
2432
  /** The entity (user, model, system) that produced this turn's content. */
2242
- readonly actor: SystemActor;
2433
+ actor: SystemActor;
2243
2434
  /** An ordered array of content blocks comprising the payload of this turn. */
2244
- readonly blocks: Content<any>[];
2435
+ blocks: Content<any>[];
2245
2436
  /** Name of the role (persona) active at the exact time this turn occurred. */
2246
- readonly role?: string;
2437
+ role?: string;
2247
2438
  /** Name of the model that produced this turn. */
2248
- readonly model?: string;
2439
+ model?: string;
2249
2440
  /** Link to the preceding turn in the conversation tree, defining the DAG graph. */
2250
- readonly parent?: {
2441
+ parent?: {
2251
2442
  readonly id: UUID;
2252
2443
  readonly version: number;
2253
2444
  };
2254
2445
  /** Extensible key-value store for turn-specific metadata. */
2255
- readonly metadata?: Record<string, any>;
2446
+ metadata?: Record<string, any>;
2256
2447
  }
2257
2448
  /** Reference to a specific iteration of a turn. */
2258
2449
  type TurnRef = Pick<Turn, "id" | "version">;
@@ -2276,6 +2467,8 @@ interface Session$1 extends Identifiable, Timestamped {
2276
2467
  label: string;
2277
2468
  /** The active Role (persona) name guiding this specific session. */
2278
2469
  role: string;
2470
+ /** Name of the model being used for inference in this session. */
2471
+ model: string;
2279
2472
  /** Semantic topics governing what context and tools are active for this session. */
2280
2473
  topics: string[];
2281
2474
  /** Array of UUIDs pointing to explicitly active preferences for this session. */
@@ -2303,6 +2496,7 @@ interface SessionSummary {
2303
2496
  readonly id: UUID;
2304
2497
  readonly label: string;
2305
2498
  readonly role: string;
2499
+ readonly model: string;
2306
2500
  readonly topics: string[];
2307
2501
  readonly preferences: string[];
2308
2502
  readonly content: string[];
@@ -2316,73 +2510,7 @@ interface SessionSummary {
2316
2510
  }
2317
2511
 
2318
2512
  /**
2319
- * Creates a new conversation session.
2320
- */
2321
- type CreateSessionCommand = Command<"session:create", Omit<Session$1, "created" | "updated">>;
2322
- /**
2323
- * Updates an existing session's metadata or state.
2324
- * This covers role switches, topic updates, preference changes, and head pointers.
2325
- */
2326
- type UpdateSessionCommand = Command<"session:update", {
2327
- id: UUID;
2328
- updates: Partial<Session$1>;
2329
- }>;
2330
- /**
2331
- * Creates a new session by forking an existing one at a specific point.
2332
- */
2333
- type ForkSessionCommand = Command<"session:fork", {
2334
- id: UUID;
2335
- newId: UUID;
2336
- label: string;
2337
- role?: string;
2338
- topics?: string[];
2339
- }>;
2340
- /**
2341
- * Deletes an entire conversation session and its history.
2342
- */
2343
- type DeleteSessionCommand = Command<"session:delete", {
2344
- id: UUID;
2345
- }>;
2346
- /**
2347
- * Appends a new turn to a session.
2348
- */
2349
- type AddTurnCommand = Command<"turn:add", Omit<Turn, "created" | "updated">>;
2350
- /**
2351
- * Updates an existing turn record (e.g., correcting content in place).
2352
- */
2353
- type UpdateTurnCommand = Command<"turn:update", Omit<Turn, "created" | "updated">>;
2354
- /**
2355
- * Creates a new version of an existing turn (e.g., when the user edits their message).
2356
- */
2357
- type EditTurnCommand = Command<"turn:edit", {
2358
- id: UUID;
2359
- session: UUID;
2360
- version: number;
2361
- content: Content<any>[];
2362
- role?: string;
2363
- model?: string;
2364
- }>;
2365
- /**
2366
- * Creates a new branch in the conversation history from a specific turn.
2367
- */
2368
- type BranchTurnCommand = Command<"turn:branch", Turn>;
2369
- /**
2370
- * Removes a specific version of a turn.
2371
- */
2372
- type DeleteTurnCommand = Command<"turn:delete", {
2373
- session: UUID;
2374
- id: UUID;
2375
- version: number;
2376
- /** The fallback position if deleting the current head. */
2377
- newHead?: TurnRef;
2378
- }>;
2379
- /**
2380
- * Union of all Session and Turn commands.
2381
- */
2382
- type SessionCommand = CreateSessionCommand | UpdateSessionCommand | ForkSessionCommand | DeleteSessionCommand | AddTurnCommand | UpdateTurnCommand | EditTurnCommand | BranchTurnCommand | DeleteTurnCommand;
2383
-
2384
- /**
2385
- * Durable storage for Session metadata.
2513
+ * Durable storage for Session metadata.
2386
2514
  */
2387
2515
  declare class SessionStore extends BaseStore<Session$1, "id", SessionSummary> {
2388
2516
  constructor(collection: Collection<Session$1>);
@@ -2411,328 +2539,85 @@ declare class TurnStore extends BaseStore<Turn, "id"> {
2411
2539
  listBySession(sessionId: UUID): Promise<Turn[]>;
2412
2540
  }
2413
2541
 
2542
+ /** Complete snapshot of the session provided to the PromptBuilder. */
2543
+ interface SessionSnapshot {
2544
+ /** Session identifier. */
2545
+ id: UUID;
2546
+ /** Top-level session definition fields. */
2547
+ meta: SessionSummary;
2548
+ /** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
2549
+ model: string;
2550
+ /** The active role — persona, instructions, role-level constraints. */
2551
+ role: Role;
2552
+ /** Unfiltered, unranked preferences attached strictly to the role or session. */
2553
+ preferences: Content<any>[];
2554
+ /** All context entries whose topics overlap with the session's active topics. */
2555
+ content: Content<any>[];
2556
+ /** Full active chain from TurnTree — oldest to newest. Untruncated. */
2557
+ transcript: Turn[];
2558
+ /** The session's active semantic topic set. */
2559
+ topics: string[];
2560
+ /** Global workspace instructions from Settings.prompt, if set. */
2561
+ instructions?: string;
2562
+ /** Model constraints structured by their hierarchical application level. */
2563
+ constraints: {
2564
+ /** Broadest constraints explicitly linked to the active role. */
2565
+ role?: ModelConstraints;
2566
+ /** Overriding constraints attached to the active session. */
2567
+ session?: ModelConstraints;
2568
+ /** The most explicit constraints captured at the last user turn. */
2569
+ turn?: ModelConstraints;
2570
+ };
2571
+ }
2572
+ /** UI helper for navigating between different versions of a turn (e.g. "2 of 5"). */
2573
+ interface BranchInfo {
2574
+ /** Array of all available version numbers for a turn. */
2575
+ versions: number[];
2576
+ /** The array index currently being viewed. */
2577
+ currentIndex: number;
2578
+ /** The total count of available versions. */
2579
+ total: number;
2580
+ /** Indicates if an older version exists to navigate back to. */
2581
+ hasPrev: boolean;
2582
+ /** Indicates if a newer version exists to navigate forward to. */
2583
+ hasNext: boolean;
2584
+ }
2585
+
2414
2586
  /**
2415
- * The SessionModule manages conversation sessions and their turn history.
2587
+ * Durable storage for Content entities.
2416
2588
  */
2417
- declare class SessionModule implements Module<"user" | "system", Record<string, any>, SessionIndex, SessionCommand, {
2418
- sessions: SessionStore;
2419
- turns: TurnStore;
2420
- }> {
2421
- readonly name = "sessions";
2422
- readonly schemas: _asaidimu_anansi.SchemaDefinition[];
2423
- private _sessionStore?;
2424
- private _turnStore?;
2425
- stores: (db: any) => Promise<{
2426
- sessions: SessionStore;
2427
- turns: TurnStore;
2428
- }>;
2429
- actions: {
2430
- "session:create": (_: State<any, SessionIndex>, command: CreateSessionCommand) => Promise<{
2431
- index: {
2432
- sessions: {
2433
- [x: string]: SessionSummary;
2434
- };
2435
- };
2436
- }>;
2437
- "session:update": (state: State<any, SessionIndex>, command: UpdateSessionCommand) => Promise<{
2438
- index?: undefined;
2439
- } | {
2440
- index: {
2441
- sessions: {
2442
- [x: string]: SessionSummary;
2443
- };
2444
- };
2445
- }>;
2446
- "session:fork": (state: State<any, SessionIndex>, command: ForkSessionCommand) => Promise<{
2447
- index?: undefined;
2448
- } | {
2449
- index: {
2450
- sessions: {
2451
- [x: string]: SessionSummary;
2452
- };
2453
- };
2454
- }>;
2455
- "session:delete": (state: State<any, SessionIndex>, command: DeleteSessionCommand) => Promise<{
2456
- index?: undefined;
2457
- } | {
2458
- index: {
2459
- sessions: {
2460
- [x: string]: any;
2461
- };
2462
- };
2463
- }>;
2464
- "turn:add": (state: State<any, SessionIndex>, command: AddTurnCommand) => Promise<{
2465
- index?: undefined;
2466
- } | {
2467
- index: {
2468
- sessions: {
2469
- [x: string]: SessionSummary;
2470
- };
2471
- };
2472
- }>;
2473
- "turn:update": (state: State<any, SessionIndex>, command: UpdateTurnCommand) => Promise<{
2474
- index?: undefined;
2475
- } | {
2476
- index: {
2477
- sessions: {
2478
- [x: string]: SessionSummary;
2479
- };
2480
- };
2481
- }>;
2482
- "turn:edit": (state: State<any, SessionIndex>, command: EditTurnCommand) => Promise<{
2483
- index?: undefined;
2484
- } | {
2485
- index: {
2486
- sessions: {
2487
- [x: string]: any;
2488
- };
2489
- };
2490
- }>;
2491
- "turn:branch": (state: State<any, SessionIndex>, command: BranchTurnCommand) => Promise<{
2492
- index?: undefined;
2493
- } | {
2494
- index: {
2495
- sessions: {
2496
- [x: string]: SessionSummary;
2497
- };
2498
- };
2499
- }>;
2500
- "turn:delete": (state: State<any, SessionIndex>, command: DeleteTurnCommand) => Promise<{
2501
- index?: undefined;
2502
- } | {
2503
- index: {
2504
- sessions: {
2505
- [x: string]: SessionSummary;
2506
- };
2507
- };
2508
- }>;
2509
- };
2589
+ declare class ContentStore extends BaseStore<Content<any>, "id", ContentSummary<any>> {
2590
+ constructor(collection: Collection<Content<any>>);
2510
2591
  /**
2511
- * Rebuilds the SessionIndex from durable storage.
2592
+ * Distills a full Content entity into a lightweight summary for indexing.
2512
2593
  */
2513
- index(_: State<any, SessionIndex>): Promise<DeepPartial<SessionIndex>>;
2594
+ summarize(entity: Content<any>): ContentSummary<any>;
2514
2595
  }
2515
2596
 
2516
2597
  /**
2517
- * Configuration parameters for creating a new Workspace.
2598
+ * Discriminated union for snapshot targets, replacing the ambiguous
2599
+ * `UUID | Turn` overload. UUID and Turn both have string shapes that
2600
+ * make a runtime `typeof` guard unsound.
2518
2601
  */
2519
- interface CreateWorkspaceParams<T extends string, S extends Record<string, any>, I extends Index> {
2520
- /** The reactive state manager for the Materialized Index. */
2521
- state: StateManager<State<S, I>>;
2522
- /** The durable database connection. */
2523
- database: IWorkspaceDatabase;
2524
- /** Binary storage provider for content and assets. */
2525
- storage: BlobStorage;
2526
- /** Authorization logic for validating command execution. */
2527
- authorizer: Authorizer<T, S, I>;
2528
- /** Optional domain-specific modules to extend workspace functionality. */
2529
- extensions?: Module<T, S, I, any, any, any>[];
2530
- /** Optional logger instance for system-wide observability. */
2531
- logger?: Logger$1;
2532
- }
2602
+ type SnapshotTarget = {
2603
+ kind: "turn-id";
2604
+ id: UUID;
2605
+ } | {
2606
+ kind: "turn";
2607
+ turn: Turn;
2608
+ };
2533
2609
  /**
2534
- * createWorkspace is the primary factory for the new architecture.
2535
- *
2536
- * It instantiates the "Base Workspace" by pre-wiring core modules
2537
- * (Content, Session, Workspace) and allowing users to pass their own
2538
- * extension modules.
2610
+ * Wraps each effect dispatch outcome so callers can inspect per-effect
2611
+ * failures without the sequence being aborted by a throw.
2539
2612
  */
2540
- declare function createWorkspace<T extends string, S extends Record<string, any>, I extends Index>(params: CreateWorkspaceParams<T, S, I>): Promise<{
2541
- /** The core coordination engine. Entry point for mutations. */
2542
- kernel: Kernel<T, S, I>;
2543
- /** Map of all module-instantiated stores for downstream manager setup. */
2544
- stores: Record<string, Store<any, any, any>>;
2545
- /** The aggregated registry and indexing engine. */
2546
- aggregator: ModuleAggregator<string, S, I>;
2547
- }>;
2548
-
2613
+ type EffectResult = {
2614
+ effect: Command<any>;
2615
+ result: Result<any, any>;
2616
+ };
2549
2617
  /**
2550
- * Reflects the current state of the LLM adapter (limits, headroom, and readiness).
2551
- */
2552
- interface ModelStatus {
2553
- /** Provider name (e.g., "google", "anthropic", "openai"). */
2554
- provider: string;
2555
- /** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
2556
- model: string;
2557
- /** Whether the adapter is currently able to accept requests. */
2558
- ready: boolean;
2559
- /** Token window limits and current usage. */
2560
- window: {
2561
- /** Total context window size in tokens. */
2562
- size: number;
2563
- /** Maximum output tokens for this model. */
2564
- out: number;
2565
- /** Tokens remaining - estimated or as reported by the provider. */
2566
- free?: number;
2567
- };
2568
- /** Capability flags for this model. */
2569
- feature: {
2570
- /** Whether the model can process image inputs. */
2571
- vision: boolean;
2572
- /** Whether the model supports tool/function calling. */
2573
- tools: boolean;
2574
- /** Whether the model supports structured JSON output mode. */
2575
- json: boolean;
2576
- /** Whether the provider supports prompt caching. */
2577
- cache: boolean;
2578
- /** Whether the adapter supports streaming. */
2579
- streaming: boolean;
2580
- /** Whether the model supports extended thinking/reasoning tokens. */
2581
- thinking: boolean;
2582
- };
2583
- /** Pricing tiers for this model. */
2584
- pricing: Array<{
2585
- unit: "token" | "call" | "image";
2586
- /** Exponent: price is per 10^scale units. */
2587
- scale: number;
2588
- /** Price per unit in USD. */
2589
- cost: {
2590
- input: number;
2591
- output: number;
2592
- cache?: {
2593
- read: number;
2594
- write: number;
2595
- };
2596
- };
2597
- }>;
2598
- /** Current rate limit state. */
2599
- rate: {
2600
- /** Current saturation as a fraction of the most constrained limit (0.0 to 1.0). */
2601
- load: number;
2602
- /** Milliseconds until the next request is permitted. */
2603
- timeout?: number;
2604
- /** The hard limits enforced by the provider. */
2605
- capacity: Array<{
2606
- unit: "token" | "call" | string;
2607
- /** Maximum units allowed per period. */
2608
- max: number;
2609
- /** Period length in seconds. */
2610
- period: number;
2611
- }>;
2612
- };
2613
- /** Adapter-level notes, e.g. model deprecation warnings. */
2614
- notes?: string[];
2615
- }
2616
- interface ModelProfile {
2617
- /** Provider identifier, e.g. "google". */
2618
- provider: string;
2619
- /** Canonical model string as accepted by the API, e.g. "gemini-2.0-flash". */
2620
- name: string;
2621
- /** Display friendly name for the model, e.g "Gemini-2-flash" */
2622
- label: string;
2623
- /** Context window and output limits. */
2624
- window: ModelStatus["window"];
2625
- /** Capability flags. */
2626
- feature: ModelStatus["feature"];
2627
- /** Pricing tiers. */
2628
- pricing: ModelStatus["pricing"];
2629
- /**
2630
- * Hard rate limit capacity as enforced by the provider.
2631
- * Does not include runtime state (load, timeout).
2632
- */
2633
- capacity: ModelStatus["rate"]["capacity"];
2634
- }
2635
- /** Unique string identifier for a model (e.g., 'gemini-2.0-flash'). */
2636
- type ModelName = string;
2637
- /** Execution constraints applied to a specific model. */
2638
- interface ModelConstraint {
2639
- /** Sampling temperature. 0.0 = deterministic, higher = more creative. */
2640
- temperature?: number;
2641
- /** Limits and stop boundaries for token generation. */
2642
- tokens: {
2643
- /** Maximum output tokens for this request. Overrides adapter defaults. */
2644
- max?: number;
2645
- /** Stop sequences — generation halts immediately when any of these are produced. */
2646
- stops?: string[];
2647
- /** Thinking/reasoning budget in tokens. (For supported models only). */
2648
- thought?: number;
2649
- };
2650
- }
2651
- /** Map of model names to their explicit, active constraints. */
2652
- type ModelConstraints = Record<ModelName, ModelConstraint>;
2653
- /** A system persona containing specific instructions and associated preferences. */
2654
- interface Role extends Timestamped, Versioned {
2655
- /** Unique identifier name used system-wide (e.g. "software-architect"). */
2656
- name: string;
2657
- /** Human-readable display label shown in the UI. */
2658
- label: string;
2659
- /** Optional human-readable description of what this persona is intended for. */
2660
- description?: string;
2661
- /** The core instructions (system prompt base) establishing this persona's behavior. */
2662
- persona: string;
2663
- /** Array of Preference UUIDs explicitly bound to this role. */
2664
- preferences: UUID[];
2665
- /** Array of semantic Topics associated with this role to guide RAG retrieval. */
2666
- topics: string[];
2667
- /** Model constraints natively attached at the role level. */
2668
- constraints?: ModelConstraints;
2669
- }
2670
- /**
2671
- * Summary of a Role for indexing.
2672
- */
2673
- interface RoleSummary {
2674
- readonly name: string;
2675
- readonly label: string;
2676
- readonly description?: string;
2677
- readonly preferences: number;
2678
- readonly topics: readonly string[];
2679
- readonly constraints?: ModelConstraints;
2680
- }
2681
- /**
2682
- * Agent Index (Read Model projection)
2683
- */
2684
- interface AgentIndex extends Index {
2685
- readonly roles: Record<string, RoleSummary>;
2686
- }
2687
-
2688
- /** Complete snapshot of the session provided to the PromptBuilder. */
2689
- interface SessionSnapshot {
2690
- /** Session identifier. */
2691
- id: UUID;
2692
- /** Top-level session definition fields. */
2693
- meta: SessionSummary;
2694
- /** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
2695
- model?: string;
2696
- /** The active role — persona, instructions, role-level constraints. */
2697
- role: Role;
2698
- /** Unfiltered, unranked preferences attached strictly to the role or session. */
2699
- preferences: Content<any>[];
2700
- /** All context entries whose topics overlap with the session's active topics. */
2701
- content: Content<any>[];
2702
- /** Full active chain from TurnTree — oldest to newest. Untruncated. */
2703
- transcript: Turn[];
2704
- /** The session's active semantic topic set. */
2705
- topics: string[];
2706
- /** Global workspace instructions from Settings.prompt, if set. */
2707
- instructions?: string;
2708
- /** Model constraints structured by their hierarchical application level. */
2709
- constraints: {
2710
- /** Broadest constraints explicitly linked to the active role. */
2711
- role?: ModelConstraints;
2712
- /** Overriding constraints attached to the active session. */
2713
- session?: ModelConstraints;
2714
- /** The most explicit constraints captured at the last user turn. */
2715
- turn?: ModelConstraints;
2716
- };
2717
- }
2718
- /** UI helper for navigating between different versions of a turn (e.g. "2 of 5"). */
2719
- interface BranchInfo {
2720
- /** Array of all available version numbers for a turn. */
2721
- versions: number[];
2722
- /** The array index currently being viewed. */
2723
- currentIndex: number;
2724
- /** The total count of available versions. */
2725
- total: number;
2726
- /** Indicates if an older version exists to navigate back to. */
2727
- hasPrev: boolean;
2728
- /** Indicates if a newer version exists to navigate forward to. */
2729
- hasNext: boolean;
2730
- }
2731
-
2732
- /**
2733
- * Session is a session‑scoped coordinator. It holds no in‑memory state
2734
- * of its own beyond the TurnTree. All entity state is read from the
2735
- * kernel index on every call to guarantee freshness.
2618
+ * Session is a session‑scoped coordinator. It holds no in‑memory state
2619
+ * of its own beyond the TurnTree. All entity state is read from the
2620
+ * kernel index on every call to guarantee freshness.
2736
2621
  */
2737
2622
  declare class Session {
2738
2623
  readonly id: UUID;
@@ -2741,9 +2626,12 @@ declare class Session {
2741
2626
  private tree;
2742
2627
  private turnRepository;
2743
2628
  private context;
2629
+ private assistantContext;
2630
+ private _closed;
2744
2631
  constructor(userId: UUID, id: UUID, kernel: IKernel<any, any, any>, stores: {
2745
2632
  sessions: SessionStore;
2746
2633
  turns: TurnStore;
2634
+ content: ContentStore;
2747
2635
  });
2748
2636
  /**
2749
2637
  * Factory method to create a new Session instance.
@@ -2751,27 +2639,38 @@ declare class Session {
2751
2639
  static create(userId: UUID, sessionId: UUID, kernel: IKernel<any, any, any>, stores: {
2752
2640
  sessions: SessionStore;
2753
2641
  turns: TurnStore;
2642
+ content: ContentStore;
2754
2643
  }): Promise<Session>;
2755
2644
  /**
2756
2645
  * Synchronises the session's in‑memory state with the persistent stores.
2757
2646
  */
2758
2647
  sync(): Promise<void>;
2759
2648
  /**
2760
- * Closes the session and cleans up subscriptions.
2649
+ * Closes the session and marks it inactive.
2650
+ * Extend this method when subscriptions or external resources are added.
2761
2651
  */
2762
2652
  close(): void;
2653
+ /** Whether the session has been closed. */
2654
+ get isClosed(): boolean;
2763
2655
  /** Returns the session's unique identifier. */
2764
2656
  sessionId(): UUID;
2765
2657
  /** Returns the session metadata from the kernel index. */
2766
- meta(): SessionSummary | undefined;
2658
+ index(): SessionSummary | undefined;
2767
2659
  /** Returns the session's label. */
2768
2660
  label(): string | undefined;
2769
2661
  /** Returns the current role. */
2770
- role(): Promise<Role | undefined>;
2662
+ role(): Role | undefined;
2771
2663
  /** Returns the list of topics. */
2772
2664
  topics(): string[];
2773
- /** Returns the list of active preferences. */
2774
- preferences(): Promise<Content<"preference", any>[]>;
2665
+ /**
2666
+ * Returns the list of active preferences.
2667
+ *
2668
+ * Resolves each ref from the session index against the content key map
2669
+ * before falling back to treating it as a direct ID. Refs that resolve
2670
+ * to a non-preference type are silently skipped (they were never valid
2671
+ * preferences for this session).
2672
+ */
2673
+ preferences(): Promise<PreferenceContent[]>;
2775
2674
  /** Returns the current head (last turn) or null if empty. */
2776
2675
  head(): TurnRef | null;
2777
2676
  /** Returns the active chain of turns as an array of TurnNode. */
@@ -2782,10 +2681,12 @@ declare class Session {
2782
2681
  branchInfo(turnId: UUID): BranchInfo;
2783
2682
  /** Retrieves a TurnNode by its ID. */
2784
2683
  turn(turnId: UUID): TurnNode | undefined;
2785
- /** Retrieves the full turn history. */
2684
+ /** Retrieves the full turn history from the store. */
2786
2685
  transcript(): Promise<Turn[]>;
2787
2686
  /** Fetches the full Session entity. */
2788
2687
  data(): Promise<Session$1 | null>;
2688
+ /** Returns the current model identifier. */
2689
+ model(): string | undefined;
2789
2690
  /** Changes the session's display label. */
2790
2691
  rename(label: string): Promise<Result<void, any>>;
2791
2692
  /** Replaces the session's topic list. */
@@ -2800,18 +2701,24 @@ declare class Session {
2800
2701
  updateMetadata(metadata: Record<string, any>): Promise<Result<void, any>>;
2801
2702
  /** Replaces the session's preference list. */
2802
2703
  setPreferences(preferenceIds: UUID[]): Promise<Result<void, any>>;
2803
- /** Replaces the session's context list. */
2804
- private setContents;
2805
2704
  /** Adds context keys to the session. */
2806
2705
  linkContent(keys: string[] | string): Promise<Result<void, any>>;
2807
2706
  /** Removes context keys from the session. */
2808
2707
  unlinkContent(keys: string | string[]): Promise<Result<void, any>>;
2809
- /** Adds a turn to the session. */
2810
- private addTurn;
2811
2708
  /** Records a user turn. */
2812
2709
  recordUserTurn(turn: Turn): Promise<Result<void, any>>;
2813
- /** Records an assistant turn, processing tool calls. */
2814
- recordAssistantTurn(context: AuthContext<SystemActor>, turn: Turn): Promise<Result<void, any>>;
2710
+ /** Records a system turn. */
2711
+ recordSystemTurn(turn: Turn): Promise<Result<void, any>>;
2712
+ /** Records an assistant turn. */
2713
+ recordAssistantTurn(turn: Turn): Promise<Result<void, any>>;
2714
+ /**
2715
+ * Runs all assistant effect commands, dispatching each independently.
2716
+ *
2717
+ * Uses `Promise.allSettled` so a failure in one effect does not prevent
2718
+ * subsequent effects from running. Each outcome is returned alongside its
2719
+ * originating command so callers can inspect per-effect failures.
2720
+ */
2721
+ runAssistantEffects(effects: Array<Command<any>>): Promise<EffectResult[]>;
2815
2722
  /** Edits an existing turn, creating a new version. */
2816
2723
  editTurn(turnId: UUID, newBlocks: Content<any>[], role?: string, model?: string): Promise<Result<void, any>>;
2817
2724
  /** Adds a branch turn. */
@@ -2828,10 +2735,38 @@ declare class Session {
2828
2735
  switchVersionRight(turnId: UUID): Promise<Result<void, any>>;
2829
2736
  /**
2830
2737
  * Assembles a SessionSnapshot for prompt building.
2738
+ *
2739
+ * Returns a typed `Result` rather than `undefined` so callers can
2740
+ * distinguish between a missing session and a missing role — both of
2741
+ * which were previously silent `undefined` returns.
2742
+ *
2743
+ * @param target - Optional discriminated target to build the snapshot
2744
+ * against. Omit to use the current head of the active chain.
2745
+ */
2746
+ snapshot(target?: SnapshotTarget): Promise<Result<SessionSnapshot, SystemError>>;
2747
+ /**
2748
+ * Throws if the session has been closed, giving mutations a consistent
2749
+ * early-exit rather than propagating odd errors from the coordinator.
2750
+ */
2751
+ private assertActive;
2752
+ /**
2753
+ * Thin wrapper around `kernel.coordinator.dispatch` that stamps
2754
+ * the current timestamp, keeping call sites free of the boilerplate.
2831
2755
  */
2832
- snapshot(target?: UUID | Turn): Promise<SessionSnapshot | undefined>;
2756
+ private dispatch;
2757
+ /** Adds a turn to the session under the given auth context. */
2758
+ private addTurn;
2833
2759
  private refreshTurnTree;
2760
+ /**
2761
+ * Loads content items from the kernel index by the IDs stored in the
2762
+ * session summary. Stale references — IDs present in the session but
2763
+ * absent from the index — are logged as warnings rather than silently
2764
+ * dropped, since missing context items can degrade model output without
2765
+ * any visible signal.
2766
+ */
2834
2767
  private loadContent;
2768
+ /** Replaces the session's content key list. */
2769
+ private setContents;
2835
2770
  private switchVersion;
2836
2771
  private findSubtreeTip;
2837
2772
  }
@@ -2848,6 +2783,7 @@ declare class SessionManager {
2848
2783
  constructor(kernel: IKernel<any, any, any>, stores: {
2849
2784
  sessions: SessionStore;
2850
2785
  turns: TurnStore;
2786
+ content: ContentStore;
2851
2787
  });
2852
2788
  /**
2853
2789
  * Opens a session by ID. Deduplicates concurrent open requests.
@@ -2871,6 +2807,7 @@ declare class SessionManager {
2871
2807
  create(user: string, params: {
2872
2808
  label: string;
2873
2809
  role: string;
2810
+ model: string;
2874
2811
  topics?: string[];
2875
2812
  preferences?: UUID[];
2876
2813
  metadata?: Record<string, any>;
@@ -2886,74 +2823,484 @@ declare class SessionManager {
2886
2823
  }
2887
2824
 
2888
2825
  /**
2889
- * A fluent builder for creating Turn objects in the new architecture.
2826
+ * Agent Module Commands
2890
2827
  */
2891
- declare class TurnBuilder {
2892
- private _turn;
2893
- constructor(actor: SystemActor, session: UUID, initialTurn?: Turn);
2894
- private createBlock;
2895
- addText(text: string, options?: {
2896
- key?: string;
2897
- label?: string;
2898
- topics?: string[];
2899
- }): TurnBuilder;
2900
- addToolUse(name: string, input: Record<string, unknown>, options?: {
2901
- key?: string;
2902
- }): TurnBuilder;
2903
- addToolResult(useId: UUID, content: string | Record<string, unknown>, isError?: boolean, options?: {
2904
- key?: string;
2905
- }): TurnBuilder;
2906
- addThinking(thinking: string, options?: {
2907
- key?: string;
2908
- }): TurnBuilder;
2909
- addBlock(block: Content<any, any>): TurnBuilder;
2910
- deleteBlock(blockId: UUID): TurnBuilder;
2911
- withId(id: UUID): TurnBuilder;
2912
- withVersion(version: number): TurnBuilder;
2913
- withTimestamp(timestamp: Timestamp): TurnBuilder;
2914
- withParent(parent: TurnRef): TurnBuilder;
2915
- withRole(role: string): TurnBuilder;
2916
- withModel(model: string): TurnBuilder;
2917
- withMetadata(metadata: Record<string, any>): TurnBuilder;
2918
- build(): Turn;
2828
+ /** Adds a new role to the system. */
2829
+ type AddRoleCommand = Command<"role:add", Role>;
2830
+ /** Updates an existing role. */
2831
+ type UpdateRoleCommand = Command<"role:update", {
2832
+ name: string;
2833
+ updates: Partial<Omit<Role, "name">>;
2834
+ }>;
2835
+ /** Deletes a role from the system. */
2836
+ type DeleteRoleCommand = Command<"role:delete", {
2837
+ name: string;
2838
+ }>;
2839
+ /**
2840
+ * Executes a specific tool.
2841
+ * This is usually dispatched by the inference pipeline or a Saga
2842
+ * after identifying a tool-call block.
2843
+ */
2844
+ type ExecuteToolCommand = Command<"tool:execute", {
2845
+ name: string;
2846
+ parameters: Record<string, any>;
2847
+ key: string;
2848
+ }>;
2849
+ /**
2850
+ * Union of all Agent commands.
2851
+ */
2852
+ type AgentCommand = AddRoleCommand | UpdateRoleCommand | DeleteRoleCommand | ExecuteToolCommand;
2853
+
2854
+ /**
2855
+ * Registry for managing ToolDefinitions.
2856
+ * Enables the Kernel and Inference Pipeline to discover and execute tools.
2857
+ */
2858
+ declare class ToolRegistry extends Registry<ToolDefinition<any>> {
2919
2859
  /**
2920
- * Builds a `TurnNode` from the current turn.
2860
+ * Returns a token-optimized system-prompt section describing available tools
2861
+ * using a neutral, standardized example tool block blueprint.
2921
2862
  */
2922
- node(): TurnNode;
2863
+ description(): string;
2864
+ /**
2865
+ * Generates the strict structured array blocks for your response schema.
2866
+ * This is where the aggregation happens effortlessly!
2867
+ */
2868
+ schema(): any[];
2869
+ /**
2870
+ * Returns a JSON Schema array of all tool definitions.
2871
+ * Useful for providers that support native tool-calling (like OpenAI/Gemini).
2872
+ */
2873
+ schemas(): any[];
2923
2874
  }
2924
2875
 
2925
- declare class TurnRepository {
2926
- private readonly turnStore;
2927
- private readonly sessionStore;
2928
- constructor(turnStore: TurnStore, sessionStore: SessionStore);
2929
- loadAllTurns(sessionId: UUID): Promise<Turn[]>;
2930
- loadHead(sessionId: UUID): Promise<TurnRef | null>;
2876
+ /**
2877
+ * Durable storage for Role entities.
2878
+ */
2879
+ declare class RoleStore extends BaseStore<Role, "name", RoleSummary> {
2880
+ constructor(collection: Collection<Role>);
2881
+ /**
2882
+ * Distills a full Role entity into a lightweight summary for indexing.
2883
+ */
2884
+ summarize(role: Role): RoleSummary;
2931
2885
  }
2932
2886
 
2933
- declare class TurnTree {
2934
- private readonly nodes;
2935
- private readonly _head;
2936
- private constructor();
2937
- static build(sessionId: UUID, repository: TurnRepository, headOverride?: TurnRef | null): Promise<TurnTree>;
2938
- head(): TurnRef | null;
2939
- chain(): TurnNode[];
2887
+ /**
2888
+ * The AgentModule manages system personas (roles) and their constraints.
2889
+ */
2890
+ declare class AgentModule implements Module<"user" | "system", Record<string, any>, AgentIndex, AgentCommand, {
2891
+ roles: RoleStore;
2892
+ }> {
2893
+ readonly name = "agent";
2894
+ readonly schemas: _asaidimu_anansi.SchemaDefinition[];
2895
+ readonly registries: Record<string, ToolRegistry>;
2896
+ private _roleStore?;
2897
+ private readonly logger;
2898
+ constructor(opts: {
2899
+ logger: Logger$1;
2900
+ });
2901
+ stores: (db: any) => Promise<{
2902
+ roles: RoleStore;
2903
+ }>;
2904
+ actions: {
2905
+ "role:add": (_state: State<any, AgentIndex>, command: AddRoleCommand) => Promise<Result<{
2906
+ index: {
2907
+ roles: {
2908
+ [x: string]: RoleSummary | undefined;
2909
+ };
2910
+ };
2911
+ }, never>>;
2912
+ "role:update": (state: State<any, AgentIndex>, command: UpdateRoleCommand) => Promise<{
2913
+ readonly ok: false;
2914
+ readonly error: never;
2915
+ } | {
2916
+ readonly ok: true;
2917
+ readonly value: {};
2918
+ }>;
2919
+ "role:delete": (state: State<any, AgentIndex>, command: DeleteRoleCommand) => Promise<{
2920
+ readonly ok: false;
2921
+ readonly error: never;
2922
+ } | {
2923
+ readonly ok: true;
2924
+ readonly value: {};
2925
+ }>;
2926
+ "tool:execute": (_state: State<any, AgentIndex>, command: ExecuteToolCommand) => Promise<{
2927
+ readonly ok: false;
2928
+ readonly error: SystemError;
2929
+ } | {
2930
+ readonly ok: true;
2931
+ readonly value: {
2932
+ result: any;
2933
+ };
2934
+ }>;
2935
+ };
2940
2936
  /**
2941
- * Returns a chronological chain of TurnNodes ending at the specified turn.
2937
+ * Rebuilds the AgentIndex from durable storage.
2942
2938
  */
2943
- chainFrom(turnId: string): TurnNode[];
2944
- getTurnSiblings(turnId: string): TurnNode[];
2945
- branchInfo(turnId: UUID): BranchInfo;
2946
- graph(): Readonly<Record<UUID, TurnNode>>;
2939
+ index(_: State<any, AgentIndex>): Promise<DeepPartial<AgentIndex>>;
2940
+ }
2941
+
2942
+ /**
2943
+ * Hybrid BlobStore that coordinates between Anansi (metadata)
2944
+ * and BlobStorage (raw bytes).
2945
+ *
2946
+ * This implementation addresses the constraint that Anansi should
2947
+ * not store large binary payloads directly.
2948
+ */
2949
+ declare class BlobStore extends BaseStore<Blob$1, "id", Blob$1> {
2950
+ private readonly storage;
2951
+ constructor(collection: Collection<Blob$1>, storage: BlobStorage);
2952
+ /**
2953
+ * Overridden to hydrate the binary data from specialized storage.
2954
+ */
2955
+ get(id: UUID): Promise<Blob$1 | null>;
2956
+ /**
2957
+ * Overridden to separate metadata and binary data during creation.
2958
+ */
2959
+ add(entity: Blob$1): Promise<void>;
2960
+ /**
2961
+ * Overridden to ensure bytes are purged when the record is deleted.
2962
+ */
2963
+ delete(id: UUID): Promise<boolean>;
2964
+ /**
2965
+ * Finds a blob by its content checksum.
2966
+ */
2967
+ findByChecksum(checksum: SHA256): Promise<Blob$1 | null>;
2968
+ /**
2969
+ * Resolves a BlobRef to a ResolvedBlob (inline or remote) or null.
2970
+ *
2971
+ * Resolution precedence:
2972
+ * 1. provider provided and remote mapping exists for that provider → remote blob
2973
+ * 2. otherwise → local bytes
2974
+ */
2975
+ resolve(id: UUID, provider?: string): Promise<Result<ResolvedBlob | null, SystemError>>;
2976
+ /**
2977
+ * Resolves multiple blobs concurrently.
2978
+ */
2979
+ resolveMany(ids: UUID[], provider?: string): Promise<Result<Map<UUID, ResolvedBlob>, SystemError>>;
2980
+ }
2981
+
2982
+ /**
2983
+ * Content Module Commands
2984
+ */
2985
+ type AddContentCommand = Command<"content:add", Content<any, any>>;
2986
+ type UpdateContentCommand = Command<"content:update", {
2987
+ id: UUID;
2988
+ updates: Partial<Content<any, any>>;
2989
+ }>;
2990
+ type DeleteContentCommand = Command<"content:delete", {
2991
+ id: UUID;
2992
+ }>;
2993
+ /**
2994
+ * Blob Management Commands (Durable Registry)
2995
+ */
2996
+ /** Registers a new blob in the system. */
2997
+ type RegisterBlobCommand = Command<"blob:register", {
2998
+ id: UUID;
2999
+ checksum: SHA256;
3000
+ size: number;
3001
+ mime: string;
3002
+ data: Uint8Array;
3003
+ filename?: string;
3004
+ metadata?: Record<string, any>;
3005
+ }>;
3006
+ /** Increments the reference count of a blob to prevent garbage collection. */
3007
+ type RetainBlobCommand = Command<"blob:retain", {
3008
+ id: UUID;
3009
+ }>;
3010
+ /** Decrements the reference count of a blob. */
3011
+ type ReleaseBlobCommand = Command<"blob:release", {
3012
+ id: UUID;
3013
+ }>;
3014
+ /** Immediately removes a blob and its binary data. */
3015
+ type PurgeBlobCommand = Command<"blob:purge", {
3016
+ id: UUID;
3017
+ }>;
3018
+ /** Records a mapping between a local blob and an external provider's ID. */
3019
+ type RecordBlobRemoteIdCommand = Command<"blob:record_remote_id", {
3020
+ id: UUID;
3021
+ providerId: string;
3022
+ fileId: string;
3023
+ timestamp?: Timestamp;
3024
+ }>;
3025
+ /**
3026
+ * Union of all Content and Blob commands.
3027
+ */
3028
+ type ContentCommand = AddContentCommand | UpdateContentCommand | DeleteContentCommand | RegisterBlobCommand | RetainBlobCommand | ReleaseBlobCommand | PurgeBlobCommand | RecordBlobRemoteIdCommand;
3029
+
3030
+ /**
3031
+ * The ContentModule manages all durable content and binary assets.
3032
+ */
3033
+ declare class ContentModule implements Module<"user" | "system", ContentCoreState, ContentIndex, ContentCommand, {
3034
+ content: ContentStore;
3035
+ blobs: BlobStore;
3036
+ }> {
3037
+ readonly name = "content";
3038
+ readonly schemas: _asaidimu_anansi.SchemaDefinition[];
3039
+ registries: Record<string, Registry<any>>;
3040
+ private _contentStore?;
3041
+ private _blobStore?;
3042
+ private _blobStorage;
3043
+ constructor({ blobStorage, logger, }: {
3044
+ blobStorage: BlobStorage;
3045
+ logger: Logger$1;
3046
+ });
3047
+ stores: (db: any) => Promise<{
3048
+ content: ContentStore;
3049
+ blobs: BlobStore;
3050
+ }>;
3051
+ actions: {
3052
+ "content:add": (_: State<ContentCoreState, ContentIndex>, command: AddContentCommand) => Promise<Result<{
3053
+ index: {
3054
+ content: {
3055
+ items: {
3056
+ [x: string]: ContentSummary<any>;
3057
+ };
3058
+ keys: {
3059
+ [x: string]: string;
3060
+ };
3061
+ };
3062
+ };
3063
+ }, never>>;
3064
+ "content:update": (state: State<ContentCoreState, ContentIndex>, command: UpdateContentCommand) => Promise<{
3065
+ readonly ok: false;
3066
+ readonly error: never;
3067
+ } | {
3068
+ readonly ok: true;
3069
+ readonly value: {};
3070
+ }>;
3071
+ "content:delete": (state: State<ContentCoreState, ContentIndex>, command: DeleteContentCommand) => Promise<{
3072
+ readonly ok: false;
3073
+ readonly error: never;
3074
+ } | {
3075
+ readonly ok: true;
3076
+ readonly value: {};
3077
+ }>;
3078
+ "blob:register": (state: State<ContentCoreState, ContentIndex>, command: RegisterBlobCommand) => Promise<Result<{
3079
+ index: {
3080
+ content: {
3081
+ blobs: any;
3082
+ };
3083
+ };
3084
+ }, never>>;
3085
+ "blob:retain": (_state: State<ContentCoreState, ContentIndex>, command: RetainBlobCommand) => Promise<Result<{}, never>>;
3086
+ "blob:release": (_state: State<ContentCoreState, ContentIndex>, command: ReleaseBlobCommand) => Promise<Result<{}, never>>;
3087
+ "blob:purge": (state: State<ContentCoreState, ContentIndex>, command: PurgeBlobCommand) => Promise<{
3088
+ readonly ok: false;
3089
+ readonly error: never;
3090
+ } | {
3091
+ readonly ok: true;
3092
+ readonly value: {};
3093
+ }>;
3094
+ "blob:record_remote_id": (_state: State<ContentCoreState, ContentIndex>, command: RecordBlobRemoteIdCommand) => Promise<Result<{}, never>>;
3095
+ };
3096
+ /**
3097
+ * Rebuilds the ContentIndex from durable storage.
3098
+ */
3099
+ index(_: State<ContentCoreState, ContentIndex>): Promise<DeepPartial<ContentIndex>>;
3100
+ }
3101
+
3102
+ /**
3103
+ * Creates a new conversation session.
3104
+ */
3105
+ type CreateSessionCommand = Command<"session:create", Omit<Session$1, "created" | "updated">>;
3106
+ /**
3107
+ * Updates an existing session's metadata or state.
3108
+ * This covers role switches, topic updates, preference changes, and head pointers.
3109
+ */
3110
+ type UpdateSessionCommand = Command<"session:update", {
3111
+ id: UUID;
3112
+ updates: Partial<Session$1>;
3113
+ }>;
3114
+ /**
3115
+ * Creates a new session by forking an existing one at a specific point.
3116
+ */
3117
+ type ForkSessionCommand = Command<"session:fork", {
3118
+ id: UUID;
3119
+ newId: UUID;
3120
+ label: string;
3121
+ role?: string;
3122
+ topics?: string[];
3123
+ }>;
3124
+ /**
3125
+ * Deletes an entire conversation session and its history.
3126
+ */
3127
+ type DeleteSessionCommand = Command<"session:delete", {
3128
+ id: UUID;
3129
+ }>;
3130
+ /**
3131
+ * Appends a new turn to a session.
3132
+ */
3133
+ type AddTurnCommand = Command<"turn:add", Omit<Turn, "created" | "updated">>;
3134
+ /**
3135
+ * Updates an existing turn record (e.g., correcting content in place).
3136
+ */
3137
+ type UpdateTurnCommand = Command<"turn:update", Omit<Turn, "created" | "updated">>;
3138
+ /**
3139
+ * Creates a new version of an existing turn (e.g., when the user edits their message).
3140
+ */
3141
+ type EditTurnCommand = Command<"turn:edit", {
3142
+ id: UUID;
3143
+ session: UUID;
3144
+ version: number;
3145
+ content: Content<any>[];
3146
+ role?: string;
3147
+ model?: string;
3148
+ }>;
3149
+ /**
3150
+ * Creates a new branch in the conversation history from a specific turn.
3151
+ */
3152
+ type BranchTurnCommand = Command<"turn:branch", Turn>;
3153
+ /**
3154
+ * Removes a specific version of a turn.
3155
+ */
3156
+ type DeleteTurnCommand = Command<"turn:delete", {
3157
+ session: UUID;
3158
+ id: UUID;
3159
+ version: number;
3160
+ /** The fallback position if deleting the current head. */
3161
+ newHead?: TurnRef;
3162
+ }>;
3163
+ /**
3164
+ * Union of all Session and Turn commands.
3165
+ */
3166
+ type SessionCommand = CreateSessionCommand | UpdateSessionCommand | ForkSessionCommand | DeleteSessionCommand | AddTurnCommand | UpdateTurnCommand | EditTurnCommand | BranchTurnCommand | DeleteTurnCommand;
3167
+
3168
+ /**
3169
+ * The SessionModule manages conversation sessions and their turn history.
3170
+ */
3171
+ declare class SessionModule implements Module<"user" | "system", Record<string, any>, SessionIndex, SessionCommand, {
3172
+ sessions: SessionStore;
3173
+ turns: TurnStore;
3174
+ }> {
3175
+ readonly name = "sessions";
3176
+ readonly schemas: _asaidimu_anansi.SchemaDefinition[];
3177
+ private _sessionStore?;
3178
+ private _turnStore?;
3179
+ stores: (db: any) => Promise<{
3180
+ sessions: SessionStore;
3181
+ turns: TurnStore;
3182
+ }>;
3183
+ actions: {
3184
+ "session:create": (_: State<any, SessionIndex>, command: CreateSessionCommand) => Promise<Result<{
3185
+ index: {
3186
+ sessions: {
3187
+ [x: string]: SessionSummary;
3188
+ };
3189
+ };
3190
+ }, never>>;
3191
+ "session:update": (state: State<any, SessionIndex>, command: UpdateSessionCommand) => Promise<{
3192
+ readonly ok: false;
3193
+ readonly error: never;
3194
+ } | {
3195
+ readonly ok: true;
3196
+ readonly value: {};
3197
+ }>;
3198
+ "session:fork": (state: State<any, SessionIndex>, command: ForkSessionCommand) => Promise<{
3199
+ readonly ok: false;
3200
+ readonly error: never;
3201
+ } | {
3202
+ readonly ok: true;
3203
+ readonly value: {};
3204
+ }>;
3205
+ "session:delete": (state: State<any, SessionIndex>, command: DeleteSessionCommand) => Promise<{
3206
+ readonly ok: false;
3207
+ readonly error: never;
3208
+ } | {
3209
+ readonly ok: true;
3210
+ readonly value: {};
3211
+ }>;
3212
+ "turn:add": (state: State<any, SessionIndex>, command: AddTurnCommand) => Promise<{
3213
+ readonly ok: false;
3214
+ readonly error: never;
3215
+ } | {
3216
+ readonly ok: true;
3217
+ readonly value: {};
3218
+ }>;
3219
+ "turn:update": (state: State<any, SessionIndex>, command: UpdateTurnCommand) => Promise<{
3220
+ readonly ok: false;
3221
+ readonly error: never;
3222
+ } | {
3223
+ readonly ok: true;
3224
+ readonly value: {};
3225
+ }>;
3226
+ "turn:edit": (state: State<any, SessionIndex>, command: EditTurnCommand) => Promise<{
3227
+ readonly ok: false;
3228
+ readonly error: never;
3229
+ } | {
3230
+ readonly ok: true;
3231
+ readonly value: {};
3232
+ }>;
3233
+ "turn:branch": (state: State<any, SessionIndex>, command: BranchTurnCommand) => Promise<{
3234
+ readonly ok: false;
3235
+ readonly error: never;
3236
+ } | {
3237
+ readonly ok: true;
3238
+ readonly value: {};
3239
+ }>;
3240
+ "turn:delete": (state: State<any, SessionIndex>, command: DeleteTurnCommand) => Promise<{
3241
+ readonly ok: false;
3242
+ readonly error: never;
3243
+ } | {
3244
+ readonly ok: true;
3245
+ readonly value: {};
3246
+ }>;
3247
+ };
3248
+ /**
3249
+ * Rebuilds the SessionIndex from durable storage.
3250
+ */
3251
+ index(_: State<any, SessionIndex>): Promise<DeepPartial<SessionIndex>>;
3252
+ }
3253
+
3254
+ /**
3255
+ * Configuration parameters for creating a new Workspace.
3256
+ */
3257
+ interface CreateWorkspaceParams<T extends string, S extends Record<string, any>, I extends Index> {
3258
+ /** The reactive state manager for the Materialized Index. */
3259
+ state: StateManager<State<S, I>>;
3260
+ /** The durable database connection. */
3261
+ database: Omit<DatabaseConfig, "schemas">;
3262
+ /** Binary storage provider for content and assets. */
3263
+ storage: BlobStorage;
3264
+ /** Authorization logic for validating command execution. */
3265
+ authorizer: Authorizer<T, S, I>;
3266
+ /** Optional domain-specific modules to extend workspace functionality. */
3267
+ extensions?: Module<T, S, I, any, any, any>[];
3268
+ /** Optional logger instance for system-wide observability. */
3269
+ logger?: Logger$1;
2947
3270
  }
3271
+ /**
3272
+ * createWorkspace is the primary factory for the new architecture.
3273
+ *
3274
+ * It instantiates the "Base Workspace" by pre-wiring core modules
3275
+ * (Content, Session, Workspace) and allowing users to pass their own
3276
+ * extension modules.
3277
+ */
3278
+ declare function createWorkspace<T extends string, S extends Record<string, any>, I extends Index>(params: CreateWorkspaceParams<T, S, I>): Promise<{
3279
+ /** The core coordination engine. Entry point for mutations. */
3280
+ kernel: Kernel<T, S, I>;
3281
+ /** Map of all module-instantiated stores for downstream manager setup. */
3282
+ stores: Record<string, Store<any, any, any>>;
3283
+ /** The aggregated registry and indexing engine. */
3284
+ aggregator: ModuleAggregator<string, S, I>;
3285
+ }>;
2948
3286
 
3287
+ declare const ToolCallRegex: RegExp;
2949
3288
  /**
2950
3289
  * Registry for managing ContentDefinitions.
2951
3290
  * Enables the Kernel to delegate type-specific logic to registered handlers.
2952
3291
  */
2953
3292
  declare class ContentRegistry extends Registry<ContentDefinition<any>> {
3293
+ private readonly shortKeys;
2954
3294
  constructor(opts: {
2955
3295
  logger: Logger$1;
3296
+ empty?: boolean;
2956
3297
  });
3298
+ /**
3299
+ * Gets an item by its key.
3300
+ * @param key - The key of the item to retrieve
3301
+ * @returns The item if found, undefined otherwise
3302
+ */
3303
+ get(key: string): ContentDefinition<any> | undefined;
2957
3304
  /**
2958
3305
  * Returns the system-prompt section describing all emittable block types.
2959
3306
  */
@@ -2961,12 +3308,12 @@ declare class ContentRegistry extends Registry<ContentDefinition<any>> {
2961
3308
  /**
2962
3309
  * Returns a plain JSON Schema object scoped to emittable block definitions.
2963
3310
  */
2964
- schema(filter?: ContentFilter): Record<string, unknown>;
3311
+ schema(filter?: ContentFilter, extra?: Record<string, unknown>[]): Record<string, unknown>;
2965
3312
  /**
2966
- * Returns the default mode for a registered content type.
2967
- * @param type - The content type string (e.g., "text", "thinking")
2968
- * @returns The ContentMode if the type is registered, undefined otherwise.
3313
+ * Updates an existing item with new properties.
3314
+ * Special handling for 'mappings' to ensure provider mappings are merged rather than overwritten.
2969
3315
  */
3316
+ update(key: string, updates: Partial<ContentDefinition<any>>): Result$1<void, SystemError>;
2970
3317
  mode(type: string): ContentMode | undefined;
2971
3318
  /**
2972
3319
  * Converts a raw JSON object from a model response into a workspace content block.
@@ -2977,6 +3324,16 @@ declare class ContentRegistry extends Registry<ContentDefinition<any>> {
2977
3324
  type: string;
2978
3325
  [key: string]: any;
2979
3326
  }, providerId?: string): Content<any>;
3327
+ /**
3328
+ * Scans a list of content blocks for actionable side effects.
3329
+ * Aggregates all commands from blocks whose definitions have a parse function.
3330
+ */
3331
+ process(blocks: Content<any>[]): Command<any>[];
3332
+ /**
3333
+ * Convert a content block of this type into a human‑readable string.
3334
+ * Used for displaying context in prompts, logs, or debugging.
3335
+ */
3336
+ format(block: Content<any, any>): string | null;
2980
3337
  /**
2981
3338
  * Creates a fully compliant Content object from raw model output.
2982
3339
  * Assigns a new UUID, version 0, and current created/updated timestamps.
@@ -3040,6 +3397,13 @@ interface Prompt {
3040
3397
  role: Role;
3041
3398
  /** Model constraints to be merged by the adapter. */
3042
3399
  constraints: Record<string, ModelConstraint>;
3400
+ /**
3401
+ * Tool results for the most recent assistant turn that made tool calls.
3402
+ * Keyed by callId, only includes results that are present in the transcript
3403
+ * (i.e., the tool has already been executed).
3404
+ * Empty object if the last assistant turn has no tool calls or no results yet.
3405
+ */
3406
+ results: Array<ToolResultContent>;
3043
3407
  /**
3044
3408
  * Non-fatal warnings generated during the build phase.
3045
3409
  */
@@ -3074,7 +3438,7 @@ interface AssemblerExtension extends PromptSection {
3074
3438
  * Provider-agnostic system prompt assembler.
3075
3439
  */
3076
3440
  interface SystemPromptAssembler {
3077
- readonly registry: ContentRegistry;
3441
+ readonly content: ContentRegistry;
3078
3442
  build<P, C>(provider: string, prompt: Prompt, mapTurn: (args: {
3079
3443
  turn: Turn;
3080
3444
  parts: P[];
@@ -3082,11 +3446,8 @@ interface SystemPromptAssembler {
3082
3446
  system: string;
3083
3447
  transcript: C[];
3084
3448
  sections: PromptSection[];
3449
+ schema: any;
3085
3450
  }>;
3086
- parse(provider: string, raw: Array<{
3087
- type: string;
3088
- [key: string]: any;
3089
- }>): Content<any>[];
3090
3451
  join(sections: PromptSection[]): string;
3091
3452
  }
3092
3453
 
@@ -3148,6 +3509,8 @@ interface InferenceContext {
3148
3509
  /** Tokens remaining in the context window after this prompt. */
3149
3510
  remaining?: number;
3150
3511
  };
3512
+ /** the schema of the response structure */
3513
+ schema: Record<string, any>;
3151
3514
  /**
3152
3515
  * Sends this prompt to the model.
3153
3516
  * @returns The parsed assistant Turn plus any execution side-effects.
@@ -3158,14 +3521,25 @@ interface InferenceContext {
3158
3521
  thought?: {
3159
3522
  tokens: number;
3160
3523
  };
3161
- }): Promise<Result<PromptResult, SystemError>>;
3524
+ }): Promise<Result<InferenceResults, SystemError>>;
3162
3525
  }
3163
3526
  /**
3164
- * The result of `PreparedPrompt.execute()`.
3527
+ * The result of `InferenceContext.execute()`.
3165
3528
  */
3166
- interface PromptResult {
3529
+ interface InferenceResults {
3530
+ /** The assistant turn, fully parsed into content blocks. */
3167
3531
  turn: Turn;
3168
- effects: any[];
3532
+ /**
3533
+ * Discrete side effects (Commands) derived from the turn.
3534
+ * e.g. [AddTopicCommand, UpdateRoleCommand, RunToolCommand]
3535
+ */
3536
+ effects: Command<any>[];
3537
+ /**
3538
+ * Indicates the status of this inference step.
3539
+ * 'final': The model has provided a concluding response.
3540
+ * 'action': The model has requested actions (tools) that require execution.
3541
+ */
3542
+ status?: "final" | "action";
3169
3543
  }
3170
3544
  /**
3171
3545
  * Bridge between a Prompt and a specific LLM provider's SDK.
@@ -3272,10 +3646,11 @@ interface Logger {
3272
3646
  info?: (message: string, ...args: unknown[]) => void;
3273
3647
  }
3274
3648
  declare class PromptAssembler implements SystemPromptAssembler {
3649
+ readonly content: ContentRegistry;
3650
+ private readonly tools;
3275
3651
  private resolver;
3276
- readonly registry: ContentRegistry;
3277
3652
  private readonly logger;
3278
- constructor(registry: ContentRegistry, resolver: BlobResolver, logger?: Logger);
3653
+ constructor(content: ContentRegistry, tools: ToolRegistry, resolver: BlobResolver, logger?: Logger);
3279
3654
  build<P, C>(provider: string, prompt: Prompt, mapTurn: (args: {
3280
3655
  turn: Turn;
3281
3656
  parts: P[];
@@ -3283,89 +3658,241 @@ declare class PromptAssembler implements SystemPromptAssembler {
3283
3658
  system: string;
3284
3659
  sections: PromptSection[];
3285
3660
  transcript: C[];
3661
+ schema: any;
3286
3662
  }>;
3663
+ private buildSchema;
3287
3664
  private buildSections;
3288
- parse(provider: string, rawBlocks: Array<{
3289
- type: string;
3290
- [key: string]: any;
3291
- }>): Content<any>[];
3292
3665
  join(sections: PromptSection[]): string;
3293
3666
  }
3294
3667
 
3295
3668
  /**
3296
- * Agent Module Commands
3669
+ * ContentItem is an "active" model for a single content entry.
3670
+ * It provides methods for updating and deleting the content,
3671
+ * encapsulating the kernel dispatch logic.
3297
3672
  */
3298
- /** Adds a new role to the system. */
3299
- type AddRoleCommand = Command<"role:add", Role>;
3300
- /** Updates an existing role. */
3301
- type UpdateRoleCommand = Command<"role:update", {
3302
- name: string;
3303
- updates: Partial<Omit<Role, "name">>;
3304
- }>;
3305
- /** Deletes a role from the system. */
3306
- type DeleteRoleCommand = Command<"role:delete", {
3307
- name: string;
3308
- }>;
3673
+ declare class ContentItem<T extends string = string, D extends Record<string, any> = any> {
3674
+ private readonly kernel;
3675
+ private readonly context;
3676
+ readonly summary: ContentSummary<T>;
3677
+ constructor(kernel: IKernel<any, any, any>, context: AuthContext<SystemActor>, summary: ContentSummary<T>);
3678
+ get id(): UUID;
3679
+ get key(): string;
3680
+ get type(): T;
3681
+ get label(): string | undefined;
3682
+ get topics(): readonly string[];
3683
+ /**
3684
+ * Fetches the full entity data for this content item.
3685
+ */
3686
+ full(): Promise<Content<T, D> | null>;
3687
+ /**
3688
+ * Updates the content metadata or value.
3689
+ */
3690
+ update(updates: Partial<Content<T, D>>): Promise<Result<void, any>>;
3691
+ /**
3692
+ * Deletes the content from the workspace.
3693
+ */
3694
+ delete(): Promise<Result<void, any>>;
3695
+ }
3696
+
3697
+ type ContentSearchFilter = {
3698
+ type?: string;
3699
+ topics?: string[];
3700
+ search?: string;
3701
+ };
3702
+
3309
3703
  /**
3310
- * Union of all Agent commands.
3704
+ * Workspace is a model for global workspace operations like managing roles,
3705
+ * preferences, and context.
3311
3706
  */
3312
- type AgentCommand = AddRoleCommand | UpdateRoleCommand | DeleteRoleCommand;
3707
+ declare class Workspace {
3708
+ private readonly kernel;
3709
+ private readonly context;
3710
+ constructor(kernel: IKernel<any, any, any>, context: AuthContext<SystemActor>);
3711
+ roles(): Promise<Role[]>;
3712
+ role(name: string): Promise<Role | null>;
3713
+ createRole({ name, label, persona, description, preferences, topics, }: Pick<Role, "name" | "label" | "preferences" | "description" | "persona" | "topics">): Promise<Result<void, any>>;
3714
+ updateRole(name: string, updates: Partial<Pick<Role, "label" | "description" | "persona" | "preferences" | "topics">>): Promise<Result<void, any>>;
3715
+ deleteRole(name: string): Promise<Result<void, any>>;
3716
+ /**
3717
+ * Retrieves a specific content item by ID.
3718
+ */
3719
+ getContent(id: UUID): Promise<ContentItem | null>;
3720
+ /**
3721
+ * Lists and filters content across all types.
3722
+ */
3723
+ listContent(filter?: ContentSearchFilter): Promise<ContentItem[]>;
3724
+ /**
3725
+ * Discovers all unique topics across the library.
3726
+ */
3727
+ getTopics(): Promise<string[]>;
3728
+ addPreference({ key, instruction, topics, label, }: {
3729
+ key: string;
3730
+ instruction: string;
3731
+ topics: string[];
3732
+ label?: string;
3733
+ }): Promise<Result<void, any>>;
3734
+ addContent(key: string, content: any, topics: string[], label?: string): Promise<Result<void, any>>;
3735
+ registerBlob(data: Uint8Array, mime: string, filename?: string): Promise<Result<{
3736
+ id: UUID;
3737
+ ref: BlobRef;
3738
+ }, any>>;
3739
+ }
3313
3740
 
3314
3741
  /**
3315
- * Durable storage for Role entities.
3742
+ * A fluent builder for creating Turn objects, aligned with the ContentRegistry.
3316
3743
  */
3317
- declare class RoleStore extends BaseStore<Role, "name", RoleSummary> {
3318
- constructor(collection: Collection<Role>);
3744
+ declare class TurnBuilder {
3745
+ private _turn;
3746
+ private registry;
3747
+ constructor(registry: ContentRegistry, actor: SystemActor, session: UUID, initialTurn?: Turn);
3748
+ private createBlock;
3749
+ addText(text: string, options?: {
3750
+ key?: string;
3751
+ label?: string;
3752
+ topics?: string[];
3753
+ }): TurnBuilder;
3754
+ addPreference(instruction: string, options?: {
3755
+ key?: string;
3756
+ label?: string;
3757
+ topics?: string[];
3758
+ }): TurnBuilder;
3759
+ addJson(data: Record<string, unknown>, options?: {
3760
+ key?: string;
3761
+ label?: string;
3762
+ topics?: string[];
3763
+ }): TurnBuilder;
3764
+ addBlob(blob: BlobData, options?: {
3765
+ key?: string;
3766
+ label?: string;
3767
+ topics?: string[];
3768
+ }): TurnBuilder;
3769
+ addImage(ref: BlobRef, altText?: string, options?: {
3770
+ key?: string;
3771
+ label?: string;
3772
+ topics?: string[];
3773
+ }): TurnBuilder;
3774
+ addDocument(ref: BlobRef, title?: string, options?: {
3775
+ key?: string;
3776
+ label?: string;
3777
+ topics?: string[];
3778
+ }): TurnBuilder;
3779
+ addThinking(thinking: string, options?: {
3780
+ key?: string;
3781
+ label?: string;
3782
+ topics?: string[];
3783
+ }): TurnBuilder;
3784
+ addToolCall(name: string, parameters: Record<string, unknown>, options?: {
3785
+ key?: string;
3786
+ label?: string;
3787
+ topics?: string[];
3788
+ }): TurnBuilder;
3789
+ addToolResult(key: string, name: string, result: unknown, error?: string, options?: {
3790
+ key?: string;
3791
+ label?: string;
3792
+ topics?: string[];
3793
+ }): TurnBuilder;
3319
3794
  /**
3320
- * Distills a full Role entity into a lightweight summary for indexing.
3795
+ * Adds a historical tool report block (read‑only archival record).
3796
+ * @param key - Unique key linking to the original tool call.
3797
+ * @param name - Name of the tool that was invoked.
3798
+ * @param parameters - Arguments passed to the tool.
3799
+ * @param result - The result value (if successful). Provide only when `error` is omitted.
3800
+ * @param error - The error message (if failed). Provide only when `result` is omitted.
3801
+ * @param options - Optional block metadata (`label`, `topics`).
3321
3802
  */
3322
- summarize(role: Role): RoleSummary;
3803
+ addToolReport(key: string, name: string, parameters: Record<string, unknown>, result?: unknown, error?: string, options?: {
3804
+ label?: string;
3805
+ topics?: string[];
3806
+ }): TurnBuilder;
3807
+ addBlock(block: Content<any, any>): TurnBuilder;
3808
+ deleteBlock(blockId: UUID): TurnBuilder;
3809
+ withId(id: UUID): TurnBuilder;
3810
+ withVersion(version: number): TurnBuilder;
3811
+ withTimestamp(timestamp: Timestamp): TurnBuilder;
3812
+ withParent(parent: TurnRef): TurnBuilder;
3813
+ withRole(role: string): TurnBuilder;
3814
+ withModel(model: string): TurnBuilder;
3815
+ withMetadata(metadata: Record<string, any>): TurnBuilder;
3816
+ build(): Turn;
3817
+ node(): TurnNode;
3818
+ }
3819
+ /**
3820
+ * Factory for creating TurnBuilder instances with a shared registry.
3821
+ */
3822
+ declare class TurnBuilderFactory {
3823
+ private registry;
3824
+ constructor(registry: ContentRegistry);
3825
+ new(actor: SystemActor, session: UUID, initialTurn?: Turn): TurnBuilder;
3826
+ }
3827
+
3828
+ declare class TurnRepository {
3829
+ private readonly turnStore;
3830
+ private readonly sessionStore;
3831
+ constructor(turnStore: TurnStore, sessionStore: SessionStore);
3832
+ loadAllTurns(sessionId: UUID): Promise<Turn[]>;
3833
+ loadHead(sessionId: UUID): Promise<TurnRef | null>;
3834
+ }
3835
+
3836
+ declare class TurnTree {
3837
+ private readonly nodes;
3838
+ private readonly _head;
3839
+ private constructor();
3840
+ static build(sessionId: UUID, repository: TurnRepository, headOverride?: TurnRef | null): Promise<TurnTree>;
3841
+ head(): TurnRef | null;
3842
+ chain(): TurnNode[];
3843
+ /**
3844
+ * Returns a chronological chain of TurnNodes ending at the specified turn.
3845
+ */
3846
+ chainFrom(turnId: string): TurnNode[];
3847
+ getTurnSiblings(turnId: string): TurnNode[];
3848
+ branchInfo(turnId: UUID): BranchInfo;
3849
+ graph(): Readonly<Record<UUID, TurnNode>>;
3323
3850
  }
3324
3851
 
3325
3852
  /**
3326
- * The AgentModule manages system personas (roles) and their constraints.
3853
+ * Simplified bootstrap parameters for a quick-start workspace.
3327
3854
  */
3328
- declare class AgentModule implements Module<"user" | "system", Record<string, any>, AgentIndex, AgentCommand, {
3329
- roles: RoleStore;
3330
- }> {
3331
- readonly name = "agent";
3332
- readonly schemas: _asaidimu_anansi.SchemaDefinition[];
3333
- private _roleStore?;
3334
- stores: (db: any) => Promise<{
3335
- roles: RoleStore;
3336
- }>;
3337
- actions: {
3338
- "role:add": (_state: State<any, AgentIndex>, command: AddRoleCommand) => Promise<{
3339
- index: {
3340
- roles: {
3341
- [x: string]: RoleSummary | undefined;
3342
- };
3343
- };
3344
- }>;
3345
- "role:update": (state: State<any, AgentIndex>, command: UpdateRoleCommand) => Promise<{
3346
- index?: undefined;
3347
- } | {
3348
- index: {
3349
- roles: {
3350
- [name]: RoleSummary | undefined;
3351
- };
3352
- };
3353
- }>;
3354
- "role:delete": (state: State<any, AgentIndex>, command: DeleteRoleCommand) => Promise<{
3355
- index?: undefined;
3356
- } | {
3357
- index: {
3358
- roles: {
3359
- [name]: any;
3360
- };
3361
- };
3362
- }>;
3363
- };
3855
+ interface BootstrapParams<T extends string = any, S extends Record<string, any> = any, I extends Index = any> {
3856
+ database: Omit<DatabaseConfig, "schemas">;
3857
+ state: StateManager<State<S, I>>;
3858
+ authorizer?: Authorizer<T, S, I>;
3859
+ storage?: any;
3860
+ userId?: UUID;
3861
+ /** Custom content block definitions to register. */
3862
+ blocks?: ContentDefinition<any>[];
3863
+ /** Custom tools to register. */
3864
+ tools?: ToolDefinition<any>[];
3865
+ /** LLM adapters to register (e.g. { google: new GoogleAdapter() }). */
3866
+ adapters?: (services: {
3867
+ assembler: PromptAssembler;
3868
+ turns: TurnBuilderFactory;
3869
+ }, registry: DomainRegistry) => Promise<Record<string, LLMAdapter>>;
3870
+ /** Optional extension modules. */
3871
+ extensions?: Module<T, S, I, any, any, any>[];
3872
+ /** Optional logger instance for system-wide observability. */
3873
+ logger?: Logger$1;
3874
+ }
3875
+ /**
3876
+ * Bootstrapper provides a high-level API to quickly stand up a functional
3877
+ * workspace and session without manually wiring modules and stores.
3878
+ */
3879
+ declare class Bootstrapper {
3364
3880
  /**
3365
- * Rebuilds the AgentIndex from durable storage.
3881
+ * Quick-starts a workspace with core modules (Agent, Content, Session, Core).
3366
3882
  */
3367
- index(_: State<any, AgentIndex>): Promise<DeepPartial<AgentIndex>>;
3883
+ static workspace(params: BootstrapParams): Promise<{
3884
+ kernel: Kernel<any, any, any>;
3885
+ registries: Record<string, IRegistryReader<any>>;
3886
+ stores: Record<string, Store<any, any, any>>;
3887
+ workspace: Workspace;
3888
+ sessions: SessionManager;
3889
+ llm: LLM;
3890
+ assembler: PromptAssembler;
3891
+ userId: string;
3892
+ turns: TurnBuilderFactory;
3893
+ }>;
3368
3894
  }
3895
+ type BootstrappedWorkspace = Awaited<ReturnType<typeof Bootstrapper.workspace>>;
3369
3896
 
3370
3897
  declare const GOOGLE_MODELS: Array<ModelProfile>;
3371
3898
  /** Everyday workhorse models: Flash variants + larger Gemma 4s. */
@@ -3378,10 +3905,12 @@ declare const GOOGLE_MODELS_EMBEDDING: Array<ModelProfile>;
3378
3905
  declare class GoogleGenAIAdapter implements LLMAdapter {
3379
3906
  private readonly client;
3380
3907
  private readonly assembler;
3908
+ private readonly turns;
3381
3909
  private readonly registry;
3382
3910
  private readonly model;
3383
3911
  private readonly _models;
3384
- constructor(client: GoogleGenAI, assembler: SystemPromptAssembler, registry: ContentRegistry, options?: {
3912
+ private readonly logger;
3913
+ constructor(client: GoogleGenAI, assembler: SystemPromptAssembler, turns: TurnBuilderFactory, registry: ContentRegistry, logger: Logger$1, options?: {
3385
3914
  model: string;
3386
3915
  models: Array<ModelProfile>;
3387
3916
  });
@@ -3394,118 +3923,14 @@ declare class GoogleGenAIAdapter implements LLMAdapter {
3394
3923
  models(): ModelProfile[];
3395
3924
  }
3396
3925
 
3397
- declare const index$1_GOOGLE_MODELS: typeof GOOGLE_MODELS;
3398
- declare const index$1_GOOGLE_MODELS_COMMON: typeof GOOGLE_MODELS_COMMON;
3399
- declare const index$1_GOOGLE_MODELS_EMBEDDING: typeof GOOGLE_MODELS_EMBEDDING;
3400
- declare const index$1_GOOGLE_MODELS_PRO: typeof GOOGLE_MODELS_PRO;
3401
- type index$1_GoogleGenAIAdapter = GoogleGenAIAdapter;
3402
- declare const index$1_GoogleGenAIAdapter: typeof GoogleGenAIAdapter;
3403
- declare namespace index$1 {
3404
- export { index$1_GOOGLE_MODELS as GOOGLE_MODELS, index$1_GOOGLE_MODELS_COMMON as GOOGLE_MODELS_COMMON, index$1_GOOGLE_MODELS_EMBEDDING as GOOGLE_MODELS_EMBEDDING, index$1_GOOGLE_MODELS_PRO as GOOGLE_MODELS_PRO, index$1_GoogleGenAIAdapter as GoogleGenAIAdapter };
3405
- }
3406
-
3407
- /**
3408
- * VercelAIAdapter bridges the Workspace Prompt with Vercel's AI SDK.
3409
- * It uses a LanguageModel instance to perform inference.
3410
- *
3411
- * This adapter handles the mapping between Workspace ModelProfiles and Vercel's
3412
- * model instances, ensuring features like thinking/reasoning and streaming
3413
- * are correctly enabled based on profile capabilities.
3414
- */
3415
- declare class VercelAIAdapter implements LLMAdapter {
3416
- private readonly model;
3417
- private readonly assembler;
3418
- private readonly registry;
3419
- private readonly profile;
3420
- constructor(model: LanguageModel, assembler: SystemPromptAssembler, registry: ContentRegistry, profile: ModelProfile);
3421
- private registerMappings;
3422
- /**
3423
- * Returns the status of the model, merging static profile data with
3424
- * runtime readiness.
3425
- */
3426
- status(): Promise<ModelStatus>;
3427
- resolve(params: {
3428
- prompt: Prompt;
3429
- } & Record<string, any>): Promise<InferenceContext>;
3430
- private mapResponse;
3431
- static provider(): string;
3432
- models(): ModelProfile[];
3433
- }
3434
-
3435
- /**
3436
- * Mappings for Vercel AI SDK (ContentPart).
3437
- * Translates workspace blocks into Vercel's universal content part format.
3438
- */
3439
- declare const mappings: (registry: ContentRegistry) => {
3440
- text: {
3441
- to: ({ block, }: {
3442
- block: Content<"text", {
3443
- text: string;
3444
- }>;
3445
- }) => ContentPart<any>;
3446
- from: (raw: any) => Content<"text", {
3447
- text: any;
3448
- }>;
3449
- };
3450
- preference: {
3451
- to: ({ block, }: {
3452
- block: Content<"preference", {
3453
- instruction: string;
3454
- }>;
3455
- }) => ContentPart<any>;
3456
- from: (raw: any) => Content<"preference", {
3457
- instruction: any;
3458
- }>;
3459
- };
3460
- json: {
3461
- to: ({ block, }: {
3462
- block: Content<"json", Record<string, unknown>>;
3463
- }) => ContentPart<any>;
3464
- from: (raw: any) => Content<"json", any>;
3465
- };
3466
- image: {
3467
- to: ({ block, resolve, }: {
3468
- block: Content<"image", {
3469
- ref: any;
3470
- altText?: string;
3471
- }>;
3472
- resolve: (ref: any) => Promise<any>;
3473
- }) => Promise<ContentPart<any> | null>;
3474
- from: (raw: any) => Content<"image", {
3475
- ref: any;
3476
- altText: any;
3477
- }>;
3478
- };
3479
- document: {
3480
- to: ({ block, resolve, }: {
3481
- block: Content<"document", {
3482
- ref: any;
3483
- title?: string;
3484
- }>;
3485
- resolve: (ref: any) => Promise<any>;
3486
- }) => Promise<ContentPart<any> | null>;
3487
- from: (raw: any) => Content<"document", {
3488
- ref: any;
3489
- title: any;
3490
- }>;
3491
- };
3492
- thinking: {
3493
- to: ({ block, }: {
3494
- block: Content<"thinking", {
3495
- thinking: string;
3496
- }>;
3497
- }) => ContentPart<any> | null;
3498
- from: (raw: any) => Content<"thinking", {
3499
- thinking: any;
3500
- }>;
3501
- };
3502
- };
3503
-
3504
- type index_VercelAIAdapter = VercelAIAdapter;
3505
- declare const index_VercelAIAdapter: typeof VercelAIAdapter;
3506
- declare const index_mappings: typeof mappings;
3926
+ declare const index_GOOGLE_MODELS: typeof GOOGLE_MODELS;
3927
+ declare const index_GOOGLE_MODELS_COMMON: typeof GOOGLE_MODELS_COMMON;
3928
+ declare const index_GOOGLE_MODELS_EMBEDDING: typeof GOOGLE_MODELS_EMBEDDING;
3929
+ declare const index_GOOGLE_MODELS_PRO: typeof GOOGLE_MODELS_PRO;
3930
+ type index_GoogleGenAIAdapter = GoogleGenAIAdapter;
3931
+ declare const index_GoogleGenAIAdapter: typeof GoogleGenAIAdapter;
3507
3932
  declare namespace index {
3508
- export { index_VercelAIAdapter as VercelAIAdapter, index_mappings as mappings };
3933
+ export { index_GOOGLE_MODELS as GOOGLE_MODELS, index_GOOGLE_MODELS_COMMON as GOOGLE_MODELS_COMMON, index_GOOGLE_MODELS_EMBEDDING as GOOGLE_MODELS_EMBEDDING, index_GOOGLE_MODELS_PRO as GOOGLE_MODELS_PRO, index_GoogleGenAIAdapter as GoogleGenAIAdapter };
3509
3934
  }
3510
3935
 
3511
3936
  interface IndexedDBBlobConfig {
@@ -3554,4 +3979,4 @@ declare class MemoryBlobStorage implements BlobStorage {
3554
3979
  exportAllBytes(): Promise<Array<[SHA256, Uint8Array]>>;
3555
3980
  }
3556
3981
 
3557
- export { type Action, type ActionEntry, type AgentIndex, AgentModule, type AssemblerExtension, type AuthContext, AuthContextBuilder, type AuthorizationProvider, type Authorizer, BaseStore, type Blob, type BlobRef, type BlobResolver, type BlobStorage, type BranchInfo, Branded, type Command, type CommandCoordinator, type CommandRegistry, CommonErrors, ConsoleLogger, type Content, type ContentCoreState, type ContentDefinition, type ContentFilter, type ContentIndex, type ContentMapper, type ContentMode, ContentModule, ContentRegistry, type ContentRetriever, type ContentSummary, type CreateWorkspaceCommand, type CreateWorkspaceParams, DELETE_SYMBOL, type DeepPartial, type DomainRegistry, type Entity, type Event, index$1 as GoogleAdapter, type IKernel, type IRegistry, type IRegistryReader, type IWorkspaceDatabase, type Identifiable, type Index, type IndexedDBBlobConfig, IndexedDBBlobStorage, type InferenceContext, type Issue, Kernel, type KernelConfig, LLM, type LLMAdapter, type LLMAdapterStatic, type LogEntry, type LogLevel, type Logger$1 as Logger, MemoryBlobStorage, type Metadata, type Middleware, type ModelConstraint, type ModelConstraints, type ModelName, type ModelProfile, type ModelStatus, type Module, ModuleAggregator, type ProjectMetadata, type Prompt, PromptAssembler, type PromptBuilder, type PromptBuilderOptions, type PromptResult, type PromptSection, Registry, type ResolvedBlob, Result, type Role, type RoleSummary, type SHA256, type Selector, Session, type SessionIndex, SessionManager, SessionModule, type SessionSnapshot, type SessionSummary, type Severity, type State, type StateManager, type StateReader, type Store, type StoreKey, type SyncWorkspaceCommand, SystemActor$1 as SystemActor, SystemError, type SystemPromptAssembler, type Taggable, type Timestamp, type Timestamped, type TransactionStep, type Turn, TurnBuilder, type TurnNode, type TurnProcessor, TurnTree, type URI, type UUID, index as VercelAdapter, type Versioned, type WorkspaceCommand, WorkspaceDatabase, type WorkspaceIndex, WorkspaceModule, type WorkspaceSettings, type WorkspaceState, createAnonymousContext, createAuthContext, createError, createLogger, createUserContext, createWorkspace, deepClone, del, logger, merge };
3982
+ export { type Action, type ActionEntry, type ActionOutcome, type AgentIndex, AgentModule, type AssemblerExtension, type AuthContext, AuthContextBuilder, type AuthorizationProvider, type Authorizer, BaseStore, type Blob$1 as Blob, type BlobRef, type BlobResolver, type BlobStorage, BlobUtilities, type BootstrapParams, type BootstrappedWorkspace, Bootstrapper, type BranchInfo, Branded, type Command, type CommandCoordinator, type CommandRegistry, CommonErrors, ConsoleLogger, type Content, type ContentCoreState, type ContentDefinition, type ContentFilter, type ContentIndex, type ContentMapper, type ContentMode, ContentModule, ContentRegistry, type ContentRetriever, type ContentSummary, type CreateWorkspaceCommand, type CreateWorkspaceParams, DELETE_SYMBOL, type DatabaseConfig, type DeepPartial, type DomainRegistry, type EffectResult, type Entity, type Event, index as GoogleAdapter, type IKernel, type IRegistry, type IRegistryReader, type IWorkspaceDatabase, type Identifiable, type Index, type IndexedDBBlobConfig, IndexedDBBlobStorage, type InferenceContext, type InferenceResults, type Issue, Kernel, type KernelConfig, LLM, type LLMAdapter, type LLMAdapterStatic, type LogEntry, type LogLevel, type Logger$1 as Logger, MemoryBlobStorage, type Metadata, type Middleware, type ModelConstraint, type ModelConstraints, type ModelName, type ModelProfile, type ModelStatus, type Module, ModuleAggregator, type ProjectMetadata, type Prompt, PromptAssembler, type PromptBuilder, type PromptBuilderOptions, type PromptSection, Registry, type ResolvedBlob, Result, type Role, type RoleSummary, type SHA256, type Selector, Session, type SessionIndex, SessionManager, SessionModule, type SessionSnapshot, type SessionSummary, type Severity, ShortKeyRegistry, type SnapshotTarget, type State, type StateManager, type StateReader, type Store, type StoreKey, type SyncWorkspaceCommand, SystemAuth, SystemError, type SystemPromptAssembler, type Taggable, type Timestamp, type Timestamped, ToolCallRegex, type ToolDefinition, type TransactionStep, type Turn, TurnBuilderFactory, type TurnNode, type TurnProcessor, TurnTree, type URI, type UUID, type Versioned, type WorkspaceCommand, WorkspaceDatabase, type WorkspaceIndex, WorkspaceModule, type WorkspaceSettings, type WorkspaceState, createAnonymousContext, createAuthContext, createError, createLogger, createUserContext, createWorkspace, deepClone, del, logger, merge };