@asaidimu/utils-workspace 7.0.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/index.d.mts +1145 -923
  2. package/index.d.ts +1145 -923
  3. package/index.js +1 -1
  4. package/index.mjs +1 -1
  5. package/package.json +1 -1
package/index.d.mts CHANGED
@@ -2,7 +2,6 @@ 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';
6
5
 
7
6
  type SerializerResult<T> = {
8
7
  value: T | null;
@@ -405,17 +404,8 @@ interface StateManager<T extends Record<string, any>> {
405
404
  * @returns The new full state tree after the patch is applied.
406
405
  */
407
406
  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
407
  }
418
- type StateReader<T extends Record<string, any>> = Pick<StateManager<T>, "get" | "subscribe">;
408
+ type StateReader<T extends Record<string, any>> = Pick<StateManager<T>, "get">;
419
409
 
420
410
  /**
421
411
  * Buffers write operations across one or more stores and commits them atomically.
@@ -835,7 +825,7 @@ type TelemetryEvent = {
835
825
  } | null;
836
826
  };
837
827
  };
838
- interface DatabaseConfig {
828
+ interface DatabaseConfig$1 {
839
829
  database: string;
840
830
  keyPath?: string;
841
831
  schemasStoreName?: string;
@@ -843,7 +833,7 @@ interface DatabaseConfig {
843
833
  predicates?: PredicateMap;
844
834
  validate?: boolean;
845
835
  }
846
- type StoreConfig = DatabaseConfig & {
836
+ type StoreConfig = DatabaseConfig$1 & {
847
837
  collection: string;
848
838
  };
849
839
 
@@ -888,7 +878,7 @@ interface Store<T extends Metadata, K extends StoreKey<T>, S = T> {
888
878
  * Retrieves all entities from the store.
889
879
  * @returns Array of all entities (empty array if none exist)
890
880
  */
891
- list(): Promise<T[]>;
881
+ list(keys?: Array<T[K]>): Promise<T[]>;
892
882
  /**
893
883
  * Distills a full entity into a lightweight summary for indexing operations.
894
884
  * Used to optimize memory usage when working with large collections.
@@ -1527,7 +1517,7 @@ declare function createAuthContext<ActorType extends string, Meta extends Metada
1527
1517
  /**
1528
1518
  * Pre-built auth contexts for common scenarios.
1529
1519
  */
1530
- declare const SystemActor$1: {
1520
+ declare const SystemAuth: {
1531
1521
  /**
1532
1522
  * Create a system actor auth context with full permissions.
1533
1523
  * The system actor bypasses most authorization checks.
@@ -1557,6 +1547,13 @@ declare function createAnonymousContext(): AuthContext<"anonymous">;
1557
1547
  */
1558
1548
  declare function createUserContext(userId: UUID, scopes?: string[], metadata?: UUID): AuthContext<"user">;
1559
1549
 
1550
+ type DatabaseConfig = {
1551
+ factory: StoreFactory;
1552
+ database: string;
1553
+ validate?: boolean;
1554
+ predicates?: Record<string, any>;
1555
+ schemas: Array<SchemaDefinition>;
1556
+ };
1560
1557
  /**
1561
1558
  * Robust implementation of WorkspaceDatabase using @asaidimu/database.
1562
1559
  * Manages the complete lifecycle of database connections and handles
@@ -1582,13 +1579,7 @@ declare class WorkspaceDatabase implements IWorkspaceDatabase {
1582
1579
  * @param config.validate - Whether to validate schema definitions
1583
1580
  * @param config.schemas - Core schemas to register (always loaded)
1584
1581
  */
1585
- constructor(config: {
1586
- factory: StoreFactory;
1587
- database: string;
1588
- validate?: boolean;
1589
- predicates?: Record<string, any>;
1590
- schemas: Array<SchemaDefinition>;
1591
- });
1582
+ constructor(config: DatabaseConfig);
1592
1583
  /**
1593
1584
  * Opens the database connection and registers schemas.
1594
1585
  * Core schemas from config are always registered, followed by
@@ -1689,7 +1680,7 @@ declare abstract class BaseStore<T extends Metadata, K extends StoreKey<T>, S =
1689
1680
  *
1690
1681
  * @returns Array of entities (limited by this.limit)
1691
1682
  */
1692
- list(): Promise<T[]>;
1683
+ list(keys?: Array<T[K]>): Promise<T[]>;
1693
1684
  /**
1694
1685
  * Converts a full entity into a lightweight summary for indexing.
1695
1686
  * Default implementation returns the full entity as the summary.
@@ -1982,193 +1973,194 @@ interface ContentDefinition<ContentType extends string, Data extends Record<stri
1982
1973
  * Used for displaying context in prompts, logs, or debugging.
1983
1974
  */
1984
1975
  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
1976
  /**
2022
- * Resolves multiple blobs concurrently.
1977
+ * Scans a content block of this type for actionable side effects.
1978
+ * Returns a list of Commands to be dispatched against the workspace.
2023
1979
  */
2024
- resolveMany(ids: UUID[], provider?: string): Promise<Result<Map<UUID, ResolvedBlob>, SystemError>>;
1980
+ parse?: (value: Data) => Command<any>[];
2025
1981
  }
2026
1982
 
2027
1983
  /**
2028
- * Content Module Commands
2029
- */
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)
1984
+ * Data shape for preference (instructional) content.
2040
1985
  */
2041
- /** Registers a new blob in the system. */
2042
- type RegisterBlobCommand = Command<"blob:register", {
2043
- id: UUID;
1986
+ interface PreferenceData {
1987
+ instruction: string;
1988
+ }
1989
+ interface BlobData {
1990
+ id: string;
2044
1991
  checksum: SHA256;
2045
1992
  size: number;
2046
1993
  mime: string;
2047
- data: Uint8Array;
2048
1994
  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;
2074
-
2075
- /**
2076
- * Durable storage for Content entities.
2077
- */
2078
- declare class ContentStore extends BaseStore<Content<any>, "id", ContentSummary<any>> {
2079
- constructor(collection: Collection<Content<any>>);
2080
- /**
2081
- * Distills a full Content entity into a lightweight summary for indexing.
2082
- */
2083
- summarize(entity: Content<any>): ContentSummary<any>;
2084
1995
  }
1996
+ interface ToolResultData {
1997
+ /** Name of the tool that produced this result */
1998
+ name: string;
1999
+ /** The output returned by the tool (any JSON-serializable value) */
2000
+ result: unknown;
2001
+ /** Identifier that links this result to the original tool-call */
2002
+ callId: string;
2003
+ /** Optional error message if the tool execution failed */
2004
+ error?: string;
2005
+ }
2006
+ type PreferenceContent = Content<"preference", PreferenceData>;
2007
+ type ToolResultContent = Content<"tool:result", ToolResultData>;
2085
2008
 
2086
2009
  /**
2087
- * The ContentModule manages all durable content and binary assets.
2010
+ * Reflects the current state of the LLM adapter (limits, headroom, and readiness).
2088
2011
  */
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
- };
2012
+ interface ModelStatus {
2013
+ /** Provider name (e.g., "google", "anthropic", "openai"). */
2014
+ provider: string;
2015
+ /** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
2016
+ model: string;
2017
+ /** Whether the adapter is currently able to accept requests. */
2018
+ ready: boolean;
2019
+ /** Token window limits and current usage. */
2020
+ window: {
2021
+ /** Total context window size in tokens. */
2022
+ size: number;
2023
+ /** Maximum output tokens for this model. */
2024
+ out: number;
2025
+ /** Tokens remaining - estimated or as reported by the provider. */
2026
+ free?: number;
2027
+ };
2028
+ /** Capability flags for this model. */
2029
+ feature: {
2030
+ /** Whether the model can process image inputs. */
2031
+ vision: boolean;
2032
+ /** Whether the model supports tool/function calling. */
2033
+ tools: boolean;
2034
+ /** Whether the model supports structured JSON output mode. */
2035
+ json: boolean;
2036
+ /** Whether the provider supports prompt caching. */
2037
+ cache: boolean;
2038
+ /** Whether the adapter supports streaming. */
2039
+ streaming: boolean;
2040
+ /** Whether the model supports extended thinking/reasoning tokens. */
2041
+ thinking: boolean;
2042
+ };
2043
+ /** Pricing tiers for this model. */
2044
+ pricing: Array<{
2045
+ unit: "token" | "call" | "image";
2046
+ /** Exponent: price is per 10^scale units. */
2047
+ scale: number;
2048
+ /** Price per unit in USD. */
2049
+ cost: {
2050
+ input: number;
2051
+ output: number;
2052
+ cache?: {
2053
+ read: number;
2054
+ write: number;
2162
2055
  };
2056
+ };
2057
+ }>;
2058
+ /** Current rate limit state. */
2059
+ rate: {
2060
+ /** Current saturation as a fraction of the most constrained limit (0.0 to 1.0). */
2061
+ load: number;
2062
+ /** Milliseconds until the next request is permitted. */
2063
+ timeout?: number;
2064
+ /** The hard limits enforced by the provider. */
2065
+ capacity: Array<{
2066
+ unit: "token" | "call" | string;
2067
+ /** Maximum units allowed per period. */
2068
+ max: number;
2069
+ /** Period length in seconds. */
2070
+ period: number;
2163
2071
  }>;
2164
- "blob:record_remote_id": (_state: State<ContentCoreState, ContentIndex>, command: RecordBlobRemoteIdCommand) => Promise<{}>;
2165
2072
  };
2073
+ /** Adapter-level notes, e.g. model deprecation warnings. */
2074
+ notes?: string[];
2075
+ }
2076
+ interface ModelProfile {
2077
+ /** Provider identifier, e.g. "google". */
2078
+ provider: string;
2079
+ /** Canonical model string as accepted by the API, e.g. "gemini-2.0-flash". */
2080
+ name: string;
2081
+ /** Display friendly name for the model, e.g "Gemini-2-flash" */
2082
+ label: string;
2083
+ /** Context window and output limits. */
2084
+ window: ModelStatus["window"];
2085
+ /** Capability flags. */
2086
+ feature: ModelStatus["feature"];
2087
+ /** Pricing tiers. */
2088
+ pricing: ModelStatus["pricing"];
2166
2089
  /**
2167
- * Rebuilds the ContentIndex from durable storage.
2090
+ * Hard rate limit capacity as enforced by the provider.
2091
+ * Does not include runtime state (load, timeout).
2168
2092
  */
2169
- index(_: State<ContentCoreState, ContentIndex>): Promise<DeepPartial<ContentIndex>>;
2093
+ capacity: ModelStatus["rate"]["capacity"];
2170
2094
  }
2171
-
2095
+ /** Unique string identifier for a model (e.g., 'gemini-2.0-flash'). */
2096
+ type ModelName = string;
2097
+ /** Execution constraints applied to a specific model. */
2098
+ interface ModelConstraint {
2099
+ /** Sampling temperature. 0.0 = deterministic, higher = more creative. */
2100
+ temperature?: number;
2101
+ /** Limits and stop boundaries for token generation. */
2102
+ tokens: {
2103
+ /** Maximum output tokens for this request. Overrides adapter defaults. */
2104
+ max?: number;
2105
+ /** Stop sequences — generation halts immediately when any of these are produced. */
2106
+ stops?: string[];
2107
+ /** Thinking/reasoning budget in tokens. (For supported models only). */
2108
+ thought?: number;
2109
+ };
2110
+ }
2111
+ /** Map of model names to their explicit, active constraints. */
2112
+ type ModelConstraints = Record<ModelName, ModelConstraint>;
2113
+ /** A system persona containing specific instructions and associated preferences. */
2114
+ interface Role extends Timestamped, Versioned {
2115
+ /** Unique identifier name used system-wide (e.g. "software-architect"). */
2116
+ name: string;
2117
+ /** Human-readable display label shown in the UI. */
2118
+ label: string;
2119
+ /** Optional human-readable description of what this persona is intended for. */
2120
+ description?: string;
2121
+ /** The core instructions (system prompt base) establishing this persona's behavior. */
2122
+ persona: string;
2123
+ /** Array of Preference UUIDs explicitly bound to this role. */
2124
+ preferences: UUID[];
2125
+ /** Array of semantic Topics associated with this role to guide RAG retrieval. */
2126
+ topics: string[];
2127
+ /** Model constraints natively attached at the role level. */
2128
+ constraints?: ModelConstraints;
2129
+ }
2130
+ /**
2131
+ * Summary of a Role for indexing.
2132
+ */
2133
+ interface RoleSummary {
2134
+ readonly name: string;
2135
+ readonly label: string;
2136
+ readonly description?: string;
2137
+ readonly preferences: number;
2138
+ readonly topics: readonly string[];
2139
+ readonly constraints?: ModelConstraints;
2140
+ }
2141
+ /**
2142
+ * Agent Index (Read Model projection)
2143
+ */
2144
+ interface AgentIndex extends Index {
2145
+ readonly roles: Record<string, RoleSummary>;
2146
+ }
2147
+ /**
2148
+ * A tool that can be called by an agent.
2149
+ */
2150
+ interface ToolDefinition<Name extends string = string, Params extends Record<string, any> = any> {
2151
+ /** The unique name of the tool. Used in the model response to identify which tool to call. */
2152
+ name: Name;
2153
+ /** Human-readable description of what the tool does. */
2154
+ description: string;
2155
+ /** JSON Schema fragment defining the tool's parameters. */
2156
+ parameters: Record<string, unknown>;
2157
+ /**
2158
+ * The actual implementation function.
2159
+ * This is executed by the system when the model requests this tool.
2160
+ */
2161
+ execute: (params: Params) => Promise<any>;
2162
+ }
2163
+
2172
2164
  /**
2173
2165
  * Identifies whether a turn originated from the user, the assistant, a tool, or the system.
2174
2166
  */
@@ -2237,22 +2229,22 @@ type TurnKey = Pick<Turn, "version" | "id" | "session">;
2237
2229
  */
2238
2230
  interface Turn extends Identifiable, Versioned, Timestamped {
2239
2231
  /** The UUID of the chat session this turn belongs to. */
2240
- readonly session: UUID;
2232
+ session: UUID;
2241
2233
  /** The entity (user, model, system) that produced this turn's content. */
2242
- readonly actor: SystemActor;
2234
+ actor: SystemActor;
2243
2235
  /** An ordered array of content blocks comprising the payload of this turn. */
2244
- readonly blocks: Content<any>[];
2236
+ blocks: Content<any>[];
2245
2237
  /** Name of the role (persona) active at the exact time this turn occurred. */
2246
- readonly role?: string;
2238
+ role?: string;
2247
2239
  /** Name of the model that produced this turn. */
2248
- readonly model?: string;
2240
+ model?: string;
2249
2241
  /** Link to the preceding turn in the conversation tree, defining the DAG graph. */
2250
- readonly parent?: {
2242
+ parent?: {
2251
2243
  readonly id: UUID;
2252
2244
  readonly version: number;
2253
2245
  };
2254
2246
  /** Extensible key-value store for turn-specific metadata. */
2255
- readonly metadata?: Record<string, any>;
2247
+ metadata?: Record<string, any>;
2256
2248
  }
2257
2249
  /** Reference to a specific iteration of a turn. */
2258
2250
  type TurnRef = Pick<Turn, "id" | "version">;
@@ -2276,6 +2268,8 @@ interface Session$1 extends Identifiable, Timestamped {
2276
2268
  label: string;
2277
2269
  /** The active Role (persona) name guiding this specific session. */
2278
2270
  role: string;
2271
+ /** Name of the model being used for inference in this session. */
2272
+ model: string;
2279
2273
  /** Semantic topics governing what context and tools are active for this session. */
2280
2274
  topics: string[];
2281
2275
  /** Array of UUIDs pointing to explicitly active preferences for this session. */
@@ -2303,6 +2297,7 @@ interface SessionSummary {
2303
2297
  readonly id: UUID;
2304
2298
  readonly label: string;
2305
2299
  readonly role: string;
2300
+ readonly model: string;
2306
2301
  readonly topics: string[];
2307
2302
  readonly preferences: string[];
2308
2303
  readonly content: string[];
@@ -2315,72 +2310,6 @@ interface SessionSummary {
2315
2310
  readonly metadata?: Record<string, any>;
2316
2311
  }
2317
2312
 
2318
- /**
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
2313
  /**
2385
2314
  * Durable storage for Session metadata.
2386
2315
  */
@@ -2411,540 +2340,774 @@ declare class TurnStore extends BaseStore<Turn, "id"> {
2411
2340
  listBySession(sessionId: UUID): Promise<Turn[]>;
2412
2341
  }
2413
2342
 
2343
+ /** Complete snapshot of the session provided to the PromptBuilder. */
2344
+ interface SessionSnapshot {
2345
+ /** Session identifier. */
2346
+ id: UUID;
2347
+ /** Top-level session definition fields. */
2348
+ meta: SessionSummary;
2349
+ /** Model identifier (e.g., "claude-sonnet-4-6", "gemini-2.0-flash"). */
2350
+ model: string;
2351
+ /** The active role — persona, instructions, role-level constraints. */
2352
+ role: Role;
2353
+ /** Unfiltered, unranked preferences attached strictly to the role or session. */
2354
+ preferences: Content<any>[];
2355
+ /** All context entries whose topics overlap with the session's active topics. */
2356
+ content: Content<any>[];
2357
+ /** Full active chain from TurnTree — oldest to newest. Untruncated. */
2358
+ transcript: Turn[];
2359
+ /** The session's active semantic topic set. */
2360
+ topics: string[];
2361
+ /** Global workspace instructions from Settings.prompt, if set. */
2362
+ instructions?: string;
2363
+ /** Model constraints structured by their hierarchical application level. */
2364
+ constraints: {
2365
+ /** Broadest constraints explicitly linked to the active role. */
2366
+ role?: ModelConstraints;
2367
+ /** Overriding constraints attached to the active session. */
2368
+ session?: ModelConstraints;
2369
+ /** The most explicit constraints captured at the last user turn. */
2370
+ turn?: ModelConstraints;
2371
+ };
2372
+ }
2373
+ /** UI helper for navigating between different versions of a turn (e.g. "2 of 5"). */
2374
+ interface BranchInfo {
2375
+ /** Array of all available version numbers for a turn. */
2376
+ versions: number[];
2377
+ /** The array index currently being viewed. */
2378
+ currentIndex: number;
2379
+ /** The total count of available versions. */
2380
+ total: number;
2381
+ /** Indicates if an older version exists to navigate back to. */
2382
+ hasPrev: boolean;
2383
+ /** Indicates if a newer version exists to navigate forward to. */
2384
+ hasNext: boolean;
2385
+ }
2386
+
2414
2387
  /**
2415
- * The SessionModule manages conversation sessions and their turn history.
2388
+ * Durable storage for Content entities.
2416
2389
  */
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<{
2390
+ declare class ContentStore extends BaseStore<Content<any>, "id", ContentSummary<any>> {
2391
+ constructor(collection: Collection<Content<any>>);
2392
+ /**
2393
+ * Distills a full Content entity into a lightweight summary for indexing.
2394
+ */
2395
+ summarize(entity: Content<any>): ContentSummary<any>;
2396
+ }
2397
+
2398
+ /**
2399
+ * Discriminated union for snapshot targets, replacing the ambiguous
2400
+ * `UUID | Turn` overload. UUID and Turn both have string shapes that
2401
+ * make a runtime `typeof` guard unsound.
2402
+ */
2403
+ type SnapshotTarget = {
2404
+ kind: "turn-id";
2405
+ id: UUID;
2406
+ } | {
2407
+ kind: "turn";
2408
+ turn: Turn;
2409
+ };
2410
+ type SnapshotErrorKind = "session-not-found" | "role-not-found";
2411
+ declare class SnapshotError extends Error {
2412
+ readonly kind: SnapshotErrorKind;
2413
+ constructor(kind: SnapshotErrorKind, message: string);
2414
+ }
2415
+ /**
2416
+ * Wraps each effect dispatch outcome so callers can inspect per-effect
2417
+ * failures without the sequence being aborted by a throw.
2418
+ */
2419
+ type EffectResult = {
2420
+ effect: Command<any>;
2421
+ result: Result<any, any>;
2422
+ };
2423
+ /**
2424
+ * Session is a session‑scoped coordinator. It holds no in‑memory state
2425
+ * of its own beyond the TurnTree. All entity state is read from the
2426
+ * kernel index on every call to guarantee freshness.
2427
+ */
2428
+ declare class Session {
2429
+ readonly id: UUID;
2430
+ private readonly kernel;
2431
+ private readonly stores;
2432
+ private tree;
2433
+ private turnRepository;
2434
+ private context;
2435
+ private assistantContext;
2436
+ private _closed;
2437
+ constructor(userId: UUID, id: UUID, kernel: IKernel<any, any, any>, stores: {
2426
2438
  sessions: SessionStore;
2427
2439
  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
- } | {
2440
+ content: ContentStore;
2441
+ });
2442
+ /**
2443
+ * Factory method to create a new Session instance.
2444
+ */
2445
+ static create(userId: UUID, sessionId: UUID, kernel: IKernel<any, any, any>, stores: {
2446
+ sessions: SessionStore;
2447
+ turns: TurnStore;
2448
+ content: ContentStore;
2449
+ }): Promise<Session>;
2450
+ /**
2451
+ * Synchronises the session's in‑memory state with the persistent stores.
2452
+ */
2453
+ sync(): Promise<void>;
2454
+ /**
2455
+ * Closes the session and marks it inactive.
2456
+ * Extend this method when subscriptions or external resources are added.
2457
+ */
2458
+ close(): void;
2459
+ /** Whether the session has been closed. */
2460
+ get isClosed(): boolean;
2461
+ /** Returns the session's unique identifier. */
2462
+ sessionId(): UUID;
2463
+ /** Returns the session metadata from the kernel index. */
2464
+ index(): SessionSummary | undefined;
2465
+ /** Returns the session's label. */
2466
+ label(): string | undefined;
2467
+ /** Returns the current role. */
2468
+ role(): Role | undefined;
2469
+ /** Returns the list of topics. */
2470
+ topics(): string[];
2471
+ /**
2472
+ * Returns the list of active preferences.
2473
+ *
2474
+ * Resolves each ref from the session index against the content key map
2475
+ * before falling back to treating it as a direct ID. Refs that resolve
2476
+ * to a non-preference type are silently skipped (they were never valid
2477
+ * preferences for this session).
2478
+ */
2479
+ preferences(): Promise<PreferenceContent[]>;
2480
+ /** Returns the current head (last turn) or null if empty. */
2481
+ head(): TurnRef | null;
2482
+ /** Returns the active chain of turns as an array of TurnNode. */
2483
+ turns(): TurnNode[];
2484
+ /** Returns all sibling turns of a given turn. */
2485
+ siblings(turnId: UUID): TurnNode[];
2486
+ /** Returns branching information for a turn. */
2487
+ branchInfo(turnId: UUID): BranchInfo;
2488
+ /** Retrieves a TurnNode by its ID. */
2489
+ turn(turnId: UUID): TurnNode | undefined;
2490
+ /** Retrieves the full turn history from the store. */
2491
+ transcript(): Promise<Turn[]>;
2492
+ /** Fetches the full Session entity. */
2493
+ data(): Promise<Session$1 | null>;
2494
+ /** Returns the current model identifier. */
2495
+ model(): string | undefined;
2496
+ /** Changes the session's display label. */
2497
+ rename(label: string): Promise<Result<void, any>>;
2498
+ /** Replaces the session's topic list. */
2499
+ setTopics(topics: string[]): Promise<Result<void, any>>;
2500
+ /** Adds topics to the session (does not replace existing ones). */
2501
+ addTopics(topics: string[]): Promise<Result<void, any>>;
2502
+ /** Switches the active role for this session. */
2503
+ switchRole(roleName: string): Promise<Result<void, any>>;
2504
+ /** Updates the session's model identifier. */
2505
+ setModel(model: string): Promise<Result<void, any>>;
2506
+ /** Merges arbitrary metadata into the session's metadata object. */
2507
+ updateMetadata(metadata: Record<string, any>): Promise<Result<void, any>>;
2508
+ /** Replaces the session's preference list. */
2509
+ setPreferences(preferenceIds: UUID[]): Promise<Result<void, any>>;
2510
+ /** Adds context keys to the session. */
2511
+ linkContent(keys: string[] | string): Promise<Result<void, any>>;
2512
+ /** Removes context keys from the session. */
2513
+ unlinkContent(keys: string | string[]): Promise<Result<void, any>>;
2514
+ /** Records a user turn. */
2515
+ recordUserTurn(turn: Turn): Promise<Result<void, any>>;
2516
+ /** Records a system turn. */
2517
+ recordSystemTurn(turn: Turn): Promise<Result<void, any>>;
2518
+ /** Records an assistant turn. */
2519
+ recordAssistantTurn(turn: Turn): Promise<Result<void, any>>;
2520
+ /**
2521
+ * Runs all assistant effect commands, dispatching each independently.
2522
+ *
2523
+ * Uses `Promise.allSettled` so a failure in one effect does not prevent
2524
+ * subsequent effects from running. Each outcome is returned alongside its
2525
+ * originating command so callers can inspect per-effect failures.
2526
+ */
2527
+ runAssistantEffects(effects: Array<Command<any>>): Promise<EffectResult[]>;
2528
+ /** Edits an existing turn, creating a new version. */
2529
+ editTurn(turnId: UUID, newBlocks: Content<any>[], role?: string, model?: string): Promise<Result<void, any>>;
2530
+ /** Adds a branch turn. */
2531
+ branch(turn: Turn): Promise<Result<void, any>>;
2532
+ /** Deletes a specific version of a turn. */
2533
+ deleteTurn(turnId: UUID, version: number, newHead: TurnRef | null): Promise<Result<void, any>>;
2534
+ /** Updates the status (success/unsuccessful) of a specific turn version. */
2535
+ updateTurnStatus(turnId: UUID, version: number, status: Result<void, any>): Promise<Result<void, any>>;
2536
+ /** Creates a new session as a fork of this one. */
2537
+ fork(newSessionId: UUID, label: string, role?: string, topics?: string[]): Promise<Result<void, any>>;
2538
+ /** Switches to the previous version of a turn. */
2539
+ switchVersionLeft(turnId: UUID): Promise<Result<void, any>>;
2540
+ /** Switches to the next version of a turn. */
2541
+ switchVersionRight(turnId: UUID): Promise<Result<void, any>>;
2542
+ /**
2543
+ * Assembles a SessionSnapshot for prompt building.
2544
+ *
2545
+ * Returns a typed `Result` rather than `undefined` so callers can
2546
+ * distinguish between a missing session and a missing role — both of
2547
+ * which were previously silent `undefined` returns.
2548
+ *
2549
+ * @param target - Optional discriminated target to build the snapshot
2550
+ * against. Omit to use the current head of the active chain.
2551
+ */
2552
+ snapshot(target?: SnapshotTarget): Promise<Result<SessionSnapshot, SnapshotError>>;
2553
+ /**
2554
+ * Throws if the session has been closed, giving mutations a consistent
2555
+ * early-exit rather than propagating odd errors from the coordinator.
2556
+ */
2557
+ private assertActive;
2558
+ /**
2559
+ * Thin wrapper around `kernel.coordinator.dispatch` that stamps
2560
+ * the current timestamp, keeping call sites free of the boilerplate.
2561
+ */
2562
+ private dispatch;
2563
+ /** Adds a turn to the session under the given auth context. */
2564
+ private addTurn;
2565
+ private refreshTurnTree;
2566
+ /**
2567
+ * Loads content items from the kernel index by the IDs stored in the
2568
+ * session summary. Stale references — IDs present in the session but
2569
+ * absent from the index — are logged as warnings rather than silently
2570
+ * dropped, since missing context items can degrade model output without
2571
+ * any visible signal.
2572
+ */
2573
+ private loadContent;
2574
+ /** Replaces the session's content key list. */
2575
+ private setContents;
2576
+ private switchVersion;
2577
+ private findSubtreeTip;
2578
+ }
2579
+
2580
+ /**
2581
+ * SessionManager orchestrates the lifecycle of Session instances.
2582
+ * It provides methods for creating, opening, listing, and deleting sessions.
2583
+ * Uses deduplication for concurrent open requests.
2584
+ */
2585
+ declare class SessionManager {
2586
+ private readonly kernel;
2587
+ private readonly stores;
2588
+ private openOnce;
2589
+ constructor(kernel: IKernel<any, any, any>, stores: {
2590
+ sessions: SessionStore;
2591
+ turns: TurnStore;
2592
+ content: ContentStore;
2593
+ });
2594
+ /**
2595
+ * Opens a session by ID. Deduplicates concurrent open requests.
2596
+ */
2597
+ open(user: string, session: UUID): Promise<Session>;
2598
+ /**
2599
+ * Closes a session handle, removing it from the deduplication cache.
2600
+ */
2601
+ close(sessionId: UUID): void;
2602
+ /**
2603
+ * Deletes a session entirely.
2604
+ */
2605
+ delete(sessionId: UUID): Promise<Result<undefined, SystemError>>;
2606
+ /**
2607
+ * Checks if a session exists in the index.
2608
+ */
2609
+ has(sessionId: UUID): Promise<boolean>;
2610
+ /**
2611
+ * Creates a new conversation session and opens it.
2612
+ */
2613
+ create(user: string, params: {
2614
+ label: string;
2615
+ role: string;
2616
+ model: string;
2617
+ topics?: string[];
2618
+ preferences?: UUID[];
2619
+ metadata?: Record<string, any>;
2620
+ }): Promise<Session>;
2621
+ /**
2622
+ * Lists all session metadata from the index.
2623
+ */
2624
+ list(): SessionSummary[];
2625
+ /**
2626
+ * Returns metadata for a specific session.
2627
+ */
2628
+ metadata(id: UUID): SessionSummary | undefined;
2629
+ }
2630
+
2631
+ /**
2632
+ * Agent Module Commands
2633
+ */
2634
+ /** Adds a new role to the system. */
2635
+ type AddRoleCommand = Command<"role:add", Role>;
2636
+ /** Updates an existing role. */
2637
+ type UpdateRoleCommand = Command<"role:update", {
2638
+ name: string;
2639
+ updates: Partial<Omit<Role, "name">>;
2640
+ }>;
2641
+ /** Deletes a role from the system. */
2642
+ type DeleteRoleCommand = Command<"role:delete", {
2643
+ name: string;
2644
+ }>;
2645
+ /**
2646
+ * Executes a specific tool.
2647
+ * This is usually dispatched by the inference pipeline or a Saga
2648
+ * after identifying a tool-call block.
2649
+ */
2650
+ type ExecuteToolCommand = Command<"tool:execute", {
2651
+ name: string;
2652
+ parameters: Record<string, any>;
2653
+ }>;
2654
+ /**
2655
+ * Union of all Agent commands.
2656
+ */
2657
+ type AgentCommand = AddRoleCommand | UpdateRoleCommand | DeleteRoleCommand | ExecuteToolCommand;
2658
+
2659
+ /**
2660
+ * Registry for managing ToolDefinitions.
2661
+ * Enables the Kernel and Inference Pipeline to discover and execute tools.
2662
+ */
2663
+ declare class ToolRegistry extends Registry<ToolDefinition<any>> {
2664
+ /**
2665
+ * Returns a system-prompt section describing all available tools.
2666
+ */
2667
+ description(): string;
2668
+ /**
2669
+ * Returns a JSON Schema array of all tool definitions.
2670
+ * Useful for providers that support native tool-calling (like OpenAI/Gemini).
2671
+ */
2672
+ schemas(): any[];
2673
+ }
2674
+
2675
+ /**
2676
+ * Durable storage for Role entities.
2677
+ */
2678
+ declare class RoleStore extends BaseStore<Role, "name", RoleSummary> {
2679
+ constructor(collection: Collection<Role>);
2680
+ /**
2681
+ * Distills a full Role entity into a lightweight summary for indexing.
2682
+ */
2683
+ summarize(role: Role): RoleSummary;
2684
+ }
2685
+
2686
+ /**
2687
+ * The AgentModule manages system personas (roles) and their constraints.
2688
+ */
2689
+ declare class AgentModule implements Module<"user" | "system", Record<string, any>, AgentIndex, AgentCommand, {
2690
+ roles: RoleStore;
2691
+ }> {
2692
+ readonly name = "agent";
2693
+ readonly schemas: _asaidimu_anansi.SchemaDefinition[];
2694
+ readonly registries: Record<string, ToolRegistry>;
2695
+ private _roleStore?;
2696
+ private readonly logger;
2697
+ constructor(opts: {
2698
+ logger: Logger$1;
2699
+ });
2700
+ stores: (db: any) => Promise<{
2701
+ roles: RoleStore;
2702
+ }>;
2703
+ actions: {
2704
+ "role:add": (_state: State<any, AgentIndex>, command: AddRoleCommand) => Promise<{
2485
2705
  index: {
2486
- sessions: {
2487
- [x: string]: any;
2706
+ roles: {
2707
+ [x: string]: RoleSummary | undefined;
2488
2708
  };
2489
2709
  };
2490
2710
  }>;
2491
- "turn:branch": (state: State<any, SessionIndex>, command: BranchTurnCommand) => Promise<{
2711
+ "role:update": (state: State<any, AgentIndex>, command: UpdateRoleCommand) => Promise<{
2492
2712
  index?: undefined;
2493
2713
  } | {
2494
2714
  index: {
2495
- sessions: {
2496
- [x: string]: SessionSummary;
2715
+ roles: {
2716
+ [name]: RoleSummary | undefined;
2497
2717
  };
2498
2718
  };
2499
2719
  }>;
2500
- "turn:delete": (state: State<any, SessionIndex>, command: DeleteTurnCommand) => Promise<{
2720
+ "role:delete": (state: State<any, AgentIndex>, command: DeleteRoleCommand) => Promise<{
2501
2721
  index?: undefined;
2502
2722
  } | {
2503
2723
  index: {
2504
- sessions: {
2505
- [x: string]: SessionSummary;
2724
+ roles: {
2725
+ [name]: any;
2506
2726
  };
2507
2727
  };
2508
2728
  }>;
2729
+ "tool:execute": (_state: State<any, AgentIndex>, command: ExecuteToolCommand) => Promise<any>;
2509
2730
  };
2510
2731
  /**
2511
- * Rebuilds the SessionIndex from durable storage.
2732
+ * Rebuilds the AgentIndex from durable storage.
2512
2733
  */
2513
- index(_: State<any, SessionIndex>): Promise<DeepPartial<SessionIndex>>;
2734
+ index(_: State<any, AgentIndex>): Promise<DeepPartial<AgentIndex>>;
2514
2735
  }
2515
2736
 
2516
2737
  /**
2517
- * Configuration parameters for creating a new Workspace.
2738
+ * Hybrid BlobStore that coordinates between Anansi (metadata)
2739
+ * and BlobStorage (raw bytes).
2740
+ *
2741
+ * This implementation addresses the constraint that Anansi should
2742
+ * not store large binary payloads directly.
2518
2743
  */
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;
2744
+ declare class BlobStore extends BaseStore<Blob, "id", Blob> {
2745
+ private readonly storage;
2746
+ constructor(collection: Collection<Blob>, storage: BlobStorage);
2747
+ /**
2748
+ * Overridden to hydrate the binary data from specialized storage.
2749
+ */
2750
+ get(id: UUID): Promise<Blob | null>;
2751
+ /**
2752
+ * Overridden to separate metadata and binary data during creation.
2753
+ */
2754
+ add(entity: Blob): Promise<void>;
2755
+ /**
2756
+ * Overridden to ensure bytes are purged when the record is deleted.
2757
+ */
2758
+ delete(id: UUID): Promise<boolean>;
2759
+ /**
2760
+ * Finds a blob by its content checksum.
2761
+ */
2762
+ findByChecksum(checksum: SHA256): Promise<Blob | null>;
2763
+ /**
2764
+ * Resolves a BlobRef to a ResolvedBlob (inline or remote) or null.
2765
+ *
2766
+ * Resolution precedence:
2767
+ * 1. provider provided and remote mapping exists for that provider → remote blob
2768
+ * 2. otherwise → local bytes
2769
+ */
2770
+ resolve(id: UUID, provider?: string): Promise<Result<ResolvedBlob | null, SystemError>>;
2771
+ /**
2772
+ * Resolves multiple blobs concurrently.
2773
+ */
2774
+ resolveMany(ids: UUID[], provider?: string): Promise<Result<Map<UUID, ResolvedBlob>, SystemError>>;
2532
2775
  }
2776
+
2533
2777
  /**
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.
2778
+ * Content Module Commands
2539
2779
  */
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>;
2780
+ type AddContentCommand = Command<"content:add", Content<any, any>>;
2781
+ type UpdateContentCommand = Command<"content:update", {
2782
+ id: UUID;
2783
+ updates: Partial<Content<any, any>>;
2784
+ }>;
2785
+ type DeleteContentCommand = Command<"content:delete", {
2786
+ id: UUID;
2787
+ }>;
2788
+ /**
2789
+ * Blob Management Commands (Durable Registry)
2790
+ */
2791
+ /** Registers a new blob in the system. */
2792
+ type RegisterBlobCommand = Command<"blob:register", {
2793
+ id: UUID;
2794
+ checksum: SHA256;
2795
+ size: number;
2796
+ mime: string;
2797
+ data: Uint8Array;
2798
+ filename?: string;
2799
+ metadata?: Record<string, any>;
2800
+ }>;
2801
+ /** Increments the reference count of a blob to prevent garbage collection. */
2802
+ type RetainBlobCommand = Command<"blob:retain", {
2803
+ id: UUID;
2804
+ }>;
2805
+ /** Decrements the reference count of a blob. */
2806
+ type ReleaseBlobCommand = Command<"blob:release", {
2807
+ id: UUID;
2547
2808
  }>;
2809
+ /** Immediately removes a blob and its binary data. */
2810
+ type PurgeBlobCommand = Command<"blob:purge", {
2811
+ id: UUID;
2812
+ }>;
2813
+ /** Records a mapping between a local blob and an external provider's ID. */
2814
+ type RecordBlobRemoteIdCommand = Command<"blob:record_remote_id", {
2815
+ id: UUID;
2816
+ providerId: string;
2817
+ fileId: string;
2818
+ timestamp?: Timestamp;
2819
+ }>;
2820
+ /**
2821
+ * Union of all Content and Blob commands.
2822
+ */
2823
+ type ContentCommand = AddContentCommand | UpdateContentCommand | DeleteContentCommand | RegisterBlobCommand | RetainBlobCommand | ReleaseBlobCommand | PurgeBlobCommand | RecordBlobRemoteIdCommand;
2548
2824
 
2549
2825
  /**
2550
- * Reflects the current state of the LLM adapter (limits, headroom, and readiness).
2826
+ * The ContentModule manages all durable content and binary assets.
2551
2827
  */
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
- };
2828
+ declare class ContentModule implements Module<"user" | "system", ContentCoreState, ContentIndex, ContentCommand, {
2829
+ content: ContentStore;
2830
+ blobs: BlobStore;
2831
+ }> {
2832
+ readonly name = "content";
2833
+ readonly schemas: _asaidimu_anansi.SchemaDefinition[];
2834
+ registries: Record<string, Registry<any>>;
2835
+ private _contentStore?;
2836
+ private _blobStore?;
2837
+ private _blobStorage;
2838
+ constructor({ blobStorage, logger, }: {
2839
+ blobStorage: BlobStorage;
2840
+ logger: Logger$1;
2841
+ });
2842
+ stores: (db: any) => Promise<{
2843
+ content: ContentStore;
2844
+ blobs: BlobStore;
2597
2845
  }>;
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;
2846
+ actions: {
2847
+ "content:add": (_: State<ContentCoreState, ContentIndex>, command: AddContentCommand) => Promise<{
2848
+ index: {
2849
+ content: {
2850
+ items: {
2851
+ [x: string]: ContentSummary<any>;
2852
+ };
2853
+ keys: {
2854
+ [x: string]: string;
2855
+ };
2856
+ };
2857
+ };
2858
+ }>;
2859
+ "content:update": (state: State<ContentCoreState, ContentIndex>, command: UpdateContentCommand) => Promise<{
2860
+ index?: undefined;
2861
+ } | {
2862
+ index: {
2863
+ content: {
2864
+ items: {
2865
+ [x: string]: ContentSummary<any>;
2866
+ };
2867
+ keys: {};
2868
+ };
2869
+ };
2870
+ }>;
2871
+ "content:delete": (state: State<ContentCoreState, ContentIndex>, command: DeleteContentCommand) => Promise<{
2872
+ index?: undefined;
2873
+ } | {
2874
+ index: {
2875
+ content: {
2876
+ items: {
2877
+ [x: string]: any;
2878
+ };
2879
+ keys: {
2880
+ [x: number]: any;
2881
+ };
2882
+ };
2883
+ };
2884
+ }>;
2885
+ "blob:register": (state: State<ContentCoreState, ContentIndex>, command: RegisterBlobCommand) => Promise<{
2886
+ index: {
2887
+ content: {
2888
+ blobs: any;
2889
+ };
2890
+ };
2891
+ }>;
2892
+ "blob:retain": (_state: State<ContentCoreState, ContentIndex>, command: RetainBlobCommand) => Promise<{}>;
2893
+ "blob:release": (_state: State<ContentCoreState, ContentIndex>, command: ReleaseBlobCommand) => Promise<{}>;
2894
+ "blob:purge": (state: State<ContentCoreState, ContentIndex>, command: PurgeBlobCommand) => Promise<{
2895
+ index?: undefined;
2896
+ } | {
2897
+ index: {
2898
+ content: {
2899
+ blobs: any;
2900
+ };
2901
+ };
2611
2902
  }>;
2903
+ "blob:record_remote_id": (_state: State<ContentCoreState, ContentIndex>, command: RecordBlobRemoteIdCommand) => Promise<{}>;
2612
2904
  };
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
2905
  /**
2630
- * Hard rate limit capacity as enforced by the provider.
2631
- * Does not include runtime state (load, timeout).
2906
+ * Rebuilds the ContentIndex from durable storage.
2632
2907
  */
2633
- capacity: ModelStatus["rate"]["capacity"];
2908
+ index(_: State<ContentCoreState, ContentIndex>): Promise<DeepPartial<ContentIndex>>;
2634
2909
  }
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. */
2910
+
2911
+ /**
2912
+ * Creates a new conversation session.
2913
+ */
2914
+ type CreateSessionCommand = Command<"session:create", Omit<Session$1, "created" | "updated">>;
2915
+ /**
2916
+ * Updates an existing session's metadata or state.
2917
+ * This covers role switches, topic updates, preference changes, and head pointers.
2918
+ */
2919
+ type UpdateSessionCommand = Command<"session:update", {
2920
+ id: UUID;
2921
+ updates: Partial<Session$1>;
2922
+ }>;
2923
+ /**
2924
+ * Creates a new session by forking an existing one at a specific point.
2925
+ */
2926
+ type ForkSessionCommand = Command<"session:fork", {
2927
+ id: UUID;
2928
+ newId: UUID;
2658
2929
  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
- }
2930
+ role?: string;
2931
+ topics?: string[];
2932
+ }>;
2670
2933
  /**
2671
- * Summary of a Role for indexing.
2934
+ * Deletes an entire conversation session and its history.
2672
2935
  */
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
- }
2936
+ type DeleteSessionCommand = Command<"session:delete", {
2937
+ id: UUID;
2938
+ }>;
2681
2939
  /**
2682
- * Agent Index (Read Model projection)
2940
+ * Appends a new turn to a session.
2683
2941
  */
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. */
2942
+ type AddTurnCommand = Command<"turn:add", Omit<Turn, "created" | "updated">>;
2943
+ /**
2944
+ * Updates an existing turn record (e.g., correcting content in place).
2945
+ */
2946
+ type UpdateTurnCommand = Command<"turn:update", Omit<Turn, "created" | "updated">>;
2947
+ /**
2948
+ * Creates a new version of an existing turn (e.g., when the user edits their message).
2949
+ */
2950
+ type EditTurnCommand = Command<"turn:edit", {
2691
2951
  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. */
2952
+ session: UUID;
2953
+ version: number;
2701
2954
  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
-
2955
+ role?: string;
2956
+ model?: string;
2957
+ }>;
2732
2958
  /**
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.
2959
+ * Creates a new branch in the conversation history from a specific turn.
2736
2960
  */
2737
- declare class Session {
2738
- readonly id: UUID;
2739
- private readonly kernel;
2740
- private readonly stores;
2741
- private tree;
2742
- private turnRepository;
2743
- private context;
2744
- constructor(userId: UUID, id: UUID, kernel: IKernel<any, any, any>, stores: {
2745
- sessions: SessionStore;
2746
- turns: TurnStore;
2747
- });
2748
- /**
2749
- * Factory method to create a new Session instance.
2750
- */
2751
- static create(userId: UUID, sessionId: UUID, kernel: IKernel<any, any, any>, stores: {
2752
- sessions: SessionStore;
2753
- turns: TurnStore;
2754
- }): Promise<Session>;
2755
- /**
2756
- * Synchronises the session's in‑memory state with the persistent stores.
2757
- */
2758
- sync(): Promise<void>;
2759
- /**
2760
- * Closes the session and cleans up subscriptions.
2761
- */
2762
- close(): void;
2763
- /** Returns the session's unique identifier. */
2764
- sessionId(): UUID;
2765
- /** Returns the session metadata from the kernel index. */
2766
- meta(): SessionSummary | undefined;
2767
- /** Returns the session's label. */
2768
- label(): string | undefined;
2769
- /** Returns the current role. */
2770
- role(): Promise<Role | undefined>;
2771
- /** Returns the list of topics. */
2772
- topics(): string[];
2773
- /** Returns the list of active preferences. */
2774
- preferences(): Promise<Content<"preference", any>[]>;
2775
- /** Returns the current head (last turn) or null if empty. */
2776
- head(): TurnRef | null;
2777
- /** Returns the active chain of turns as an array of TurnNode. */
2778
- turns(): TurnNode[];
2779
- /** Returns all sibling turns of a given turn. */
2780
- siblings(turnId: UUID): TurnNode[];
2781
- /** Returns branching information for a turn. */
2782
- branchInfo(turnId: UUID): BranchInfo;
2783
- /** Retrieves a TurnNode by its ID. */
2784
- turn(turnId: UUID): TurnNode | undefined;
2785
- /** Retrieves the full turn history. */
2786
- transcript(): Promise<Turn[]>;
2787
- /** Fetches the full Session entity. */
2788
- data(): Promise<Session$1 | null>;
2789
- /** Changes the session's display label. */
2790
- rename(label: string): Promise<Result<void, any>>;
2791
- /** Replaces the session's topic list. */
2792
- setTopics(topics: string[]): Promise<Result<void, any>>;
2793
- /** Adds topics to the session (does not replace existing ones). */
2794
- addTopics(topics: string[]): Promise<Result<void, any>>;
2795
- /** Switches the active role for this session. */
2796
- switchRole(roleName: string): Promise<Result<void, any>>;
2797
- /** Updates the session's model identifier. */
2798
- setModel(model: string): Promise<Result<void, any>>;
2799
- /** Merges arbitrary metadata into the session's metadata object. */
2800
- updateMetadata(metadata: Record<string, any>): Promise<Result<void, any>>;
2801
- /** Replaces the session's preference list. */
2802
- setPreferences(preferenceIds: UUID[]): Promise<Result<void, any>>;
2803
- /** Replaces the session's context list. */
2804
- private setContents;
2805
- /** Adds context keys to the session. */
2806
- linkContent(keys: string[] | string): Promise<Result<void, any>>;
2807
- /** Removes context keys from the session. */
2808
- unlinkContent(keys: string | string[]): Promise<Result<void, any>>;
2809
- /** Adds a turn to the session. */
2810
- private addTurn;
2811
- /** Records a user turn. */
2812
- 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>>;
2815
- /** Edits an existing turn, creating a new version. */
2816
- editTurn(turnId: UUID, newBlocks: Content<any>[], role?: string, model?: string): Promise<Result<void, any>>;
2817
- /** Adds a branch turn. */
2818
- branch(turn: Turn): Promise<Result<void, any>>;
2819
- /** Deletes a specific version of a turn. */
2820
- deleteTurn(turnId: UUID, version: number, newHead: TurnRef | null): Promise<Result<void, any>>;
2821
- /** Updates the status (success/unsuccessful) of a specific turn version. */
2822
- updateTurnStatus(turnId: UUID, version: number, status: Result<void, any>): Promise<Result<void, any>>;
2823
- /** Creates a new session as a fork of this one. */
2824
- fork(newSessionId: UUID, label: string, role?: string, topics?: string[]): Promise<Result<void, any>>;
2825
- /** Switches to the previous version of a turn. */
2826
- switchVersionLeft(turnId: UUID): Promise<Result<void, any>>;
2827
- /** Switches to the next version of a turn. */
2828
- switchVersionRight(turnId: UUID): Promise<Result<void, any>>;
2829
- /**
2830
- * Assembles a SessionSnapshot for prompt building.
2831
- */
2832
- snapshot(target?: UUID | Turn): Promise<SessionSnapshot | undefined>;
2833
- private refreshTurnTree;
2834
- private loadContent;
2835
- private switchVersion;
2836
- private findSubtreeTip;
2837
- }
2838
-
2961
+ type BranchTurnCommand = Command<"turn:branch", Turn>;
2839
2962
  /**
2840
- * SessionManager orchestrates the lifecycle of Session instances.
2841
- * It provides methods for creating, opening, listing, and deleting sessions.
2842
- * Uses deduplication for concurrent open requests.
2963
+ * Removes a specific version of a turn.
2843
2964
  */
2844
- declare class SessionManager {
2845
- private readonly kernel;
2846
- private readonly stores;
2847
- private openOnce;
2848
- constructor(kernel: IKernel<any, any, any>, stores: {
2849
- sessions: SessionStore;
2850
- turns: TurnStore;
2851
- });
2852
- /**
2853
- * Opens a session by ID. Deduplicates concurrent open requests.
2854
- */
2855
- open(user: string, session: UUID): Promise<Session>;
2856
- /**
2857
- * Closes a session handle, removing it from the deduplication cache.
2858
- */
2859
- close(sessionId: UUID): void;
2860
- /**
2861
- * Deletes a session entirely.
2862
- */
2863
- delete(sessionId: UUID): Promise<Result<undefined, SystemError>>;
2864
- /**
2865
- * Checks if a session exists in the index.
2866
- */
2867
- has(sessionId: UUID): Promise<boolean>;
2868
- /**
2869
- * Creates a new conversation session and opens it.
2870
- */
2871
- create(user: string, params: {
2872
- label: string;
2873
- role: string;
2874
- topics?: string[];
2875
- preferences?: UUID[];
2876
- metadata?: Record<string, any>;
2877
- }): Promise<Session>;
2878
- /**
2879
- * Lists all session metadata from the index.
2880
- */
2881
- list(): SessionSummary[];
2882
- /**
2883
- * Returns metadata for a specific session.
2884
- */
2885
- metadata(id: UUID): SessionSummary | undefined;
2886
- }
2887
-
2965
+ type DeleteTurnCommand = Command<"turn:delete", {
2966
+ session: UUID;
2967
+ id: UUID;
2968
+ version: number;
2969
+ /** The fallback position if deleting the current head. */
2970
+ newHead?: TurnRef;
2971
+ }>;
2888
2972
  /**
2889
- * A fluent builder for creating Turn objects in the new architecture.
2973
+ * Union of all Session and Turn commands.
2890
2974
  */
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;
2919
- /**
2920
- * Builds a `TurnNode` from the current turn.
2921
- */
2922
- node(): TurnNode;
2923
- }
2924
-
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>;
2931
- }
2975
+ type SessionCommand = CreateSessionCommand | UpdateSessionCommand | ForkSessionCommand | DeleteSessionCommand | AddTurnCommand | UpdateTurnCommand | EditTurnCommand | BranchTurnCommand | DeleteTurnCommand;
2932
2976
 
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[];
2977
+ /**
2978
+ * The SessionModule manages conversation sessions and their turn history.
2979
+ */
2980
+ declare class SessionModule implements Module<"user" | "system", Record<string, any>, SessionIndex, SessionCommand, {
2981
+ sessions: SessionStore;
2982
+ turns: TurnStore;
2983
+ }> {
2984
+ readonly name = "sessions";
2985
+ readonly schemas: _asaidimu_anansi.SchemaDefinition[];
2986
+ private _sessionStore?;
2987
+ private _turnStore?;
2988
+ stores: (db: any) => Promise<{
2989
+ sessions: SessionStore;
2990
+ turns: TurnStore;
2991
+ }>;
2992
+ actions: {
2993
+ "session:create": (_: State<any, SessionIndex>, command: CreateSessionCommand) => Promise<{
2994
+ index: {
2995
+ sessions: {
2996
+ [x: string]: SessionSummary;
2997
+ };
2998
+ };
2999
+ }>;
3000
+ "session:update": (state: State<any, SessionIndex>, command: UpdateSessionCommand) => Promise<{
3001
+ index?: undefined;
3002
+ } | {
3003
+ index: {
3004
+ sessions: {
3005
+ [x: string]: SessionSummary;
3006
+ };
3007
+ };
3008
+ }>;
3009
+ "session:fork": (state: State<any, SessionIndex>, command: ForkSessionCommand) => Promise<{
3010
+ index?: undefined;
3011
+ } | {
3012
+ index: {
3013
+ sessions: {
3014
+ [x: string]: SessionSummary;
3015
+ };
3016
+ };
3017
+ }>;
3018
+ "session:delete": (state: State<any, SessionIndex>, command: DeleteSessionCommand) => Promise<{
3019
+ index?: undefined;
3020
+ } | {
3021
+ index: {
3022
+ sessions: {
3023
+ [x: string]: any;
3024
+ };
3025
+ };
3026
+ }>;
3027
+ "turn:add": (state: State<any, SessionIndex>, command: AddTurnCommand) => Promise<{
3028
+ index?: undefined;
3029
+ } | {
3030
+ index: {
3031
+ sessions: {
3032
+ [x: string]: SessionSummary;
3033
+ };
3034
+ };
3035
+ }>;
3036
+ "turn:update": (state: State<any, SessionIndex>, command: UpdateTurnCommand) => Promise<{
3037
+ index?: undefined;
3038
+ } | {
3039
+ index: {
3040
+ sessions: {
3041
+ [x: string]: SessionSummary;
3042
+ };
3043
+ };
3044
+ }>;
3045
+ "turn:edit": (state: State<any, SessionIndex>, command: EditTurnCommand) => Promise<{
3046
+ index?: undefined;
3047
+ } | {
3048
+ index: {
3049
+ sessions: {
3050
+ [x: string]: any;
3051
+ };
3052
+ };
3053
+ }>;
3054
+ "turn:branch": (state: State<any, SessionIndex>, command: BranchTurnCommand) => Promise<{
3055
+ index?: undefined;
3056
+ } | {
3057
+ index: {
3058
+ sessions: {
3059
+ [x: string]: SessionSummary;
3060
+ };
3061
+ };
3062
+ }>;
3063
+ "turn:delete": (state: State<any, SessionIndex>, command: DeleteTurnCommand) => Promise<{
3064
+ index?: undefined;
3065
+ } | {
3066
+ index: {
3067
+ sessions: {
3068
+ [x: string]: SessionSummary;
3069
+ };
3070
+ };
3071
+ }>;
3072
+ };
2940
3073
  /**
2941
- * Returns a chronological chain of TurnNodes ending at the specified turn.
3074
+ * Rebuilds the SessionIndex from durable storage.
2942
3075
  */
2943
- chainFrom(turnId: string): TurnNode[];
2944
- getTurnSiblings(turnId: string): TurnNode[];
2945
- branchInfo(turnId: UUID): BranchInfo;
2946
- graph(): Readonly<Record<UUID, TurnNode>>;
3076
+ index(_: State<any, SessionIndex>): Promise<DeepPartial<SessionIndex>>;
3077
+ }
3078
+
3079
+ /**
3080
+ * Configuration parameters for creating a new Workspace.
3081
+ */
3082
+ interface CreateWorkspaceParams<T extends string, S extends Record<string, any>, I extends Index> {
3083
+ /** The reactive state manager for the Materialized Index. */
3084
+ state: StateManager<State<S, I>>;
3085
+ /** The durable database connection. */
3086
+ database: Omit<DatabaseConfig, "schemas">;
3087
+ /** Binary storage provider for content and assets. */
3088
+ storage: BlobStorage;
3089
+ /** Authorization logic for validating command execution. */
3090
+ authorizer: Authorizer<T, S, I>;
3091
+ /** Optional domain-specific modules to extend workspace functionality. */
3092
+ extensions?: Module<T, S, I, any, any, any>[];
3093
+ /** Optional logger instance for system-wide observability. */
3094
+ logger?: Logger$1;
2947
3095
  }
3096
+ /**
3097
+ * createWorkspace is the primary factory for the new architecture.
3098
+ *
3099
+ * It instantiates the "Base Workspace" by pre-wiring core modules
3100
+ * (Content, Session, Workspace) and allowing users to pass their own
3101
+ * extension modules.
3102
+ */
3103
+ declare function createWorkspace<T extends string, S extends Record<string, any>, I extends Index>(params: CreateWorkspaceParams<T, S, I>): Promise<{
3104
+ /** The core coordination engine. Entry point for mutations. */
3105
+ kernel: Kernel<T, S, I>;
3106
+ /** Map of all module-instantiated stores for downstream manager setup. */
3107
+ stores: Record<string, Store<any, any, any>>;
3108
+ /** The aggregated registry and indexing engine. */
3109
+ aggregator: ModuleAggregator<string, S, I>;
3110
+ }>;
2948
3111
 
2949
3112
  /**
2950
3113
  * Registry for managing ContentDefinitions.
@@ -2977,6 +3140,16 @@ declare class ContentRegistry extends Registry<ContentDefinition<any>> {
2977
3140
  type: string;
2978
3141
  [key: string]: any;
2979
3142
  }, providerId?: string): Content<any>;
3143
+ /**
3144
+ * Scans a list of content blocks for actionable side effects.
3145
+ * Aggregates all commands from blocks whose definitions have a parse function.
3146
+ */
3147
+ process(blocks: Content<any>[]): Command<any>[];
3148
+ /**
3149
+ * Convert a content block of this type into a human‑readable string.
3150
+ * Used for displaying context in prompts, logs, or debugging.
3151
+ */
3152
+ format(block: Content<any, any>): string | null;
2980
3153
  /**
2981
3154
  * Creates a fully compliant Content object from raw model output.
2982
3155
  * Assigns a new UUID, version 0, and current created/updated timestamps.
@@ -3040,6 +3213,13 @@ interface Prompt {
3040
3213
  role: Role;
3041
3214
  /** Model constraints to be merged by the adapter. */
3042
3215
  constraints: Record<string, ModelConstraint>;
3216
+ /**
3217
+ * Tool results for the most recent assistant turn that made tool calls.
3218
+ * Keyed by callId, only includes results that are present in the transcript
3219
+ * (i.e., the tool has already been executed).
3220
+ * Empty object if the last assistant turn has no tool calls or no results yet.
3221
+ */
3222
+ tools: Array<ToolResultContent>;
3043
3223
  /**
3044
3224
  * Non-fatal warnings generated during the build phase.
3045
3225
  */
@@ -3083,10 +3263,6 @@ interface SystemPromptAssembler {
3083
3263
  transcript: C[];
3084
3264
  sections: PromptSection[];
3085
3265
  }>;
3086
- parse(provider: string, raw: Array<{
3087
- type: string;
3088
- [key: string]: any;
3089
- }>): Content<any>[];
3090
3266
  join(sections: PromptSection[]): string;
3091
3267
  }
3092
3268
 
@@ -3158,14 +3334,25 @@ interface InferenceContext {
3158
3334
  thought?: {
3159
3335
  tokens: number;
3160
3336
  };
3161
- }): Promise<Result<PromptResult, SystemError>>;
3337
+ }): Promise<Result<InferenceResults, SystemError>>;
3162
3338
  }
3163
3339
  /**
3164
- * The result of `PreparedPrompt.execute()`.
3340
+ * The result of `InferenceContext.execute()`.
3165
3341
  */
3166
- interface PromptResult {
3342
+ interface InferenceResults {
3343
+ /** The assistant turn, fully parsed into content blocks. */
3167
3344
  turn: Turn;
3168
- effects: any[];
3345
+ /**
3346
+ * Discrete side effects (Commands) derived from the turn.
3347
+ * e.g. [AddTopicCommand, UpdateRoleCommand, RunToolCommand]
3348
+ */
3349
+ effects: Command<any>[];
3350
+ /**
3351
+ * Indicates the status of this inference step.
3352
+ * 'final': The model has provided a concluding response.
3353
+ * 'action': The model has requested actions (tools) that require execution.
3354
+ */
3355
+ status?: "final" | "action";
3169
3356
  }
3170
3357
  /**
3171
3358
  * Bridge between a Prompt and a specific LLM provider's SDK.
@@ -3285,86 +3472,223 @@ declare class PromptAssembler implements SystemPromptAssembler {
3285
3472
  transcript: C[];
3286
3473
  }>;
3287
3474
  private buildSections;
3288
- parse(provider: string, rawBlocks: Array<{
3289
- type: string;
3290
- [key: string]: any;
3291
- }>): Content<any>[];
3292
3475
  join(sections: PromptSection[]): string;
3293
3476
  }
3294
3477
 
3295
3478
  /**
3296
- * Agent Module Commands
3479
+ * ContentItem is an "active" model for a single content entry.
3480
+ * It provides methods for updating and deleting the content,
3481
+ * encapsulating the kernel dispatch logic.
3297
3482
  */
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
- }>;
3483
+ declare class ContentItem<T extends string = string, D extends Record<string, any> = any> {
3484
+ private readonly kernel;
3485
+ private readonly context;
3486
+ readonly summary: ContentSummary<T>;
3487
+ constructor(kernel: IKernel<any, any, any>, context: AuthContext<SystemActor>, summary: ContentSummary<T>);
3488
+ get id(): UUID;
3489
+ get key(): string;
3490
+ get type(): T;
3491
+ get label(): string | undefined;
3492
+ get topics(): readonly string[];
3493
+ /**
3494
+ * Fetches the full entity data for this content item.
3495
+ */
3496
+ full(): Promise<Content<T, D> | null>;
3497
+ /**
3498
+ * Updates the content metadata or value.
3499
+ */
3500
+ update(updates: Partial<Content<T, D>>): Promise<Result<void, any>>;
3501
+ /**
3502
+ * Deletes the content from the workspace.
3503
+ */
3504
+ delete(): Promise<Result<void, any>>;
3505
+ }
3506
+
3507
+ type ContentSearchFilter = {
3508
+ type?: string;
3509
+ topics?: string[];
3510
+ search?: string;
3511
+ };
3512
+
3309
3513
  /**
3310
- * Union of all Agent commands.
3514
+ * Workspace is a model for global workspace operations like managing roles,
3515
+ * preferences, and context.
3311
3516
  */
3312
- type AgentCommand = AddRoleCommand | UpdateRoleCommand | DeleteRoleCommand;
3517
+ declare class Workspace {
3518
+ private readonly kernel;
3519
+ private readonly context;
3520
+ constructor(kernel: IKernel<any, any, any>, context: AuthContext<SystemActor>);
3521
+ roles(): Promise<Role[]>;
3522
+ role(name: string): Promise<Role | null>;
3523
+ createRole({ name, label, persona, description, preferences, topics, }: Pick<Role, "name" | "label" | "preferences" | "description" | "persona" | "topics">): Promise<Result<void, any>>;
3524
+ updateRole(name: string, updates: Partial<Pick<Role, "label" | "description" | "persona" | "preferences" | "topics">>): Promise<Result<void, any>>;
3525
+ deleteRole(name: string): Promise<Result<void, any>>;
3526
+ /**
3527
+ * Retrieves a specific content item by ID.
3528
+ */
3529
+ getContent(id: UUID): Promise<ContentItem | null>;
3530
+ /**
3531
+ * Lists and filters content across all types.
3532
+ */
3533
+ listContent(filter?: ContentSearchFilter): Promise<ContentItem[]>;
3534
+ /**
3535
+ * Discovers all unique topics across the library.
3536
+ */
3537
+ getTopics(): Promise<string[]>;
3538
+ addPreference({ key, instruction, topics, label, }: {
3539
+ key: string;
3540
+ instruction: string;
3541
+ topics: string[];
3542
+ label?: string;
3543
+ }): Promise<Result<void, any>>;
3544
+ addContent(key: string, content: any, topics: string[], label?: string): Promise<Result<void, any>>;
3545
+ registerBlob(data: Uint8Array, mime: string, filename?: string): Promise<Result<{
3546
+ id: UUID;
3547
+ ref: BlobRef;
3548
+ }, any>>;
3549
+ }
3313
3550
 
3314
3551
  /**
3315
- * Durable storage for Role entities.
3552
+ * A fluent builder for creating Turn objects, aligned with the ContentRegistry.
3316
3553
  */
3317
- declare class RoleStore extends BaseStore<Role, "name", RoleSummary> {
3318
- constructor(collection: Collection<Role>);
3554
+ declare class TurnBuilder {
3555
+ private _turn;
3556
+ private registry;
3557
+ constructor(registry: ContentRegistry, actor: SystemActor, session: UUID, initialTurn?: Turn);
3558
+ private createBlock;
3559
+ addText(text: string, options?: {
3560
+ key?: string;
3561
+ label?: string;
3562
+ topics?: string[];
3563
+ }): TurnBuilder;
3564
+ addPreference(instruction: string, options?: {
3565
+ key?: string;
3566
+ label?: string;
3567
+ topics?: string[];
3568
+ }): TurnBuilder;
3569
+ addJson(data: Record<string, unknown>, options?: {
3570
+ key?: string;
3571
+ label?: string;
3572
+ topics?: string[];
3573
+ }): TurnBuilder;
3574
+ addBlob(blob: BlobData, options?: {
3575
+ key?: string;
3576
+ label?: string;
3577
+ topics?: string[];
3578
+ }): TurnBuilder;
3579
+ addImage(ref: BlobRef, altText?: string, options?: {
3580
+ key?: string;
3581
+ label?: string;
3582
+ topics?: string[];
3583
+ }): TurnBuilder;
3584
+ addDocument(ref: BlobRef, title?: string, options?: {
3585
+ key?: string;
3586
+ label?: string;
3587
+ topics?: string[];
3588
+ }): TurnBuilder;
3589
+ addThinking(thinking: string, options?: {
3590
+ key?: string;
3591
+ label?: string;
3592
+ topics?: string[];
3593
+ }): TurnBuilder;
3594
+ addToolCall(name: string, parameters: Record<string, unknown>, options?: {
3595
+ key?: string;
3596
+ callId?: string;
3597
+ label?: string;
3598
+ topics?: string[];
3599
+ }): TurnBuilder;
3600
+ addToolResult(callId: string, name: string, result: unknown, error?: string, options?: {
3601
+ key?: string;
3602
+ label?: string;
3603
+ topics?: string[];
3604
+ }): TurnBuilder;
3605
+ addBlock(block: Content<any, any>): TurnBuilder;
3606
+ deleteBlock(blockId: UUID): TurnBuilder;
3607
+ withId(id: UUID): TurnBuilder;
3608
+ withVersion(version: number): TurnBuilder;
3609
+ withTimestamp(timestamp: Timestamp): TurnBuilder;
3610
+ withParent(parent: TurnRef): TurnBuilder;
3611
+ withRole(role: string): TurnBuilder;
3612
+ withModel(model: string): TurnBuilder;
3613
+ withMetadata(metadata: Record<string, any>): TurnBuilder;
3614
+ build(): Turn;
3615
+ node(): TurnNode;
3616
+ }
3617
+ /**
3618
+ * Factory for creating TurnBuilder instances with a shared registry.
3619
+ */
3620
+ declare class TurnBuilderFactory {
3621
+ private registry;
3622
+ constructor(registry: ContentRegistry);
3623
+ new(actor: SystemActor, session: UUID, initialTurn?: Turn): TurnBuilder;
3624
+ }
3625
+
3626
+ declare class TurnRepository {
3627
+ private readonly turnStore;
3628
+ private readonly sessionStore;
3629
+ constructor(turnStore: TurnStore, sessionStore: SessionStore);
3630
+ loadAllTurns(sessionId: UUID): Promise<Turn[]>;
3631
+ loadHead(sessionId: UUID): Promise<TurnRef | null>;
3632
+ }
3633
+
3634
+ declare class TurnTree {
3635
+ private readonly nodes;
3636
+ private readonly _head;
3637
+ private constructor();
3638
+ static build(sessionId: UUID, repository: TurnRepository, headOverride?: TurnRef | null): Promise<TurnTree>;
3639
+ head(): TurnRef | null;
3640
+ chain(): TurnNode[];
3319
3641
  /**
3320
- * Distills a full Role entity into a lightweight summary for indexing.
3642
+ * Returns a chronological chain of TurnNodes ending at the specified turn.
3321
3643
  */
3322
- summarize(role: Role): RoleSummary;
3644
+ chainFrom(turnId: string): TurnNode[];
3645
+ getTurnSiblings(turnId: string): TurnNode[];
3646
+ branchInfo(turnId: UUID): BranchInfo;
3647
+ graph(): Readonly<Record<UUID, TurnNode>>;
3323
3648
  }
3324
3649
 
3325
3650
  /**
3326
- * The AgentModule manages system personas (roles) and their constraints.
3651
+ * Simplified bootstrap parameters for a quick-start workspace.
3327
3652
  */
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
- };
3653
+ interface BootstrapParams<T extends string = any, S extends Record<string, any> = any, I extends Index = any> {
3654
+ database: Omit<DatabaseConfig, "schemas">;
3655
+ state: StateManager<State<S, I>>;
3656
+ authorizer?: Authorizer<T, S, I>;
3657
+ storage?: any;
3658
+ userId?: UUID;
3659
+ /** Custom content block definitions to register. */
3660
+ blocks?: ContentDefinition<any>[];
3661
+ /** Custom tools to register. */
3662
+ tools?: ToolDefinition<any>[];
3663
+ /** LLM adapters to register (e.g. { google: new GoogleAdapter() }). */
3664
+ adapters?: (services: {
3665
+ assembler: PromptAssembler;
3666
+ turns: TurnBuilderFactory;
3667
+ }, registry: DomainRegistry) => Promise<Record<string, LLMAdapter>>;
3668
+ /** Optional extension modules. */
3669
+ extensions?: Module<T, S, I, any, any, any>[];
3670
+ /** Optional logger instance for system-wide observability. */
3671
+ logger?: Logger$1;
3672
+ }
3673
+ /**
3674
+ * Bootstrapper provides a high-level API to quickly stand up a functional
3675
+ * workspace and session without manually wiring modules and stores.
3676
+ */
3677
+ declare class Bootstrapper {
3364
3678
  /**
3365
- * Rebuilds the AgentIndex from durable storage.
3679
+ * Quick-starts a workspace with core modules (Agent, Content, Session, Core).
3366
3680
  */
3367
- index(_: State<any, AgentIndex>): Promise<DeepPartial<AgentIndex>>;
3681
+ static workspace(params: BootstrapParams): Promise<{
3682
+ kernel: Kernel<any, any, any>;
3683
+ registries: Record<string, IRegistryReader<any>>;
3684
+ stores: Record<string, Store<any, any, any>>;
3685
+ workspace: Workspace;
3686
+ sessions: SessionManager;
3687
+ llm: LLM;
3688
+ assembler: PromptAssembler;
3689
+ userId: string;
3690
+ turns: TurnBuilderFactory;
3691
+ }>;
3368
3692
  }
3369
3693
 
3370
3694
  declare const GOOGLE_MODELS: Array<ModelProfile>;
@@ -3378,10 +3702,12 @@ declare const GOOGLE_MODELS_EMBEDDING: Array<ModelProfile>;
3378
3702
  declare class GoogleGenAIAdapter implements LLMAdapter {
3379
3703
  private readonly client;
3380
3704
  private readonly assembler;
3705
+ private readonly turns;
3381
3706
  private readonly registry;
3707
+ private readonly tools?;
3382
3708
  private readonly model;
3383
3709
  private readonly _models;
3384
- constructor(client: GoogleGenAI, assembler: SystemPromptAssembler, registry: ContentRegistry, options?: {
3710
+ constructor(client: GoogleGenAI, assembler: SystemPromptAssembler, turns: TurnBuilderFactory, registry: ContentRegistry, tools?: ToolRegistry | undefined, options?: {
3385
3711
  model: string;
3386
3712
  models: Array<ModelProfile>;
3387
3713
  });
@@ -3394,118 +3720,14 @@ declare class GoogleGenAIAdapter implements LLMAdapter {
3394
3720
  models(): ModelProfile[];
3395
3721
  }
3396
3722
 
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;
3723
+ declare const index_GOOGLE_MODELS: typeof GOOGLE_MODELS;
3724
+ declare const index_GOOGLE_MODELS_COMMON: typeof GOOGLE_MODELS_COMMON;
3725
+ declare const index_GOOGLE_MODELS_EMBEDDING: typeof GOOGLE_MODELS_EMBEDDING;
3726
+ declare const index_GOOGLE_MODELS_PRO: typeof GOOGLE_MODELS_PRO;
3727
+ type index_GoogleGenAIAdapter = GoogleGenAIAdapter;
3728
+ declare const index_GoogleGenAIAdapter: typeof GoogleGenAIAdapter;
3507
3729
  declare namespace index {
3508
- export { index_VercelAIAdapter as VercelAIAdapter, index_mappings as mappings };
3730
+ 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
3731
  }
3510
3732
 
3511
3733
  interface IndexedDBBlobConfig {
@@ -3554,4 +3776,4 @@ declare class MemoryBlobStorage implements BlobStorage {
3554
3776
  exportAllBytes(): Promise<Array<[SHA256, Uint8Array]>>;
3555
3777
  }
3556
3778
 
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 };
3779
+ 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 BootstrapParams, 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, SnapshotError, type SnapshotErrorKind, type SnapshotTarget, type State, type StateManager, type StateReader, type Store, type StoreKey, type SyncWorkspaceCommand, SystemAuth, SystemError, type SystemPromptAssembler, type Taggable, type Timestamp, type Timestamped, 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 };