@asaidimu/utils-workspace 6.4.0 → 6.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @asaidimu/utils-workspace
2
2
 
3
- > **The Architectural Foundation for Production-Grade AI Workspaces.**
3
+ **The Architectural Foundation for Production-Grade AI Workspaces.**
4
4
 
5
5
  ---
6
6
 
package/index.d.mts CHANGED
@@ -784,6 +784,8 @@ interface Turn {
784
784
  timestamp: Timestamp;
785
785
  /** Name of the role (persona) active at the exact time this turn occurred. */
786
786
  role?: string;
787
+ /** Name of the model that produced this turn. */
788
+ model?: string;
787
789
  /** Link to the preceding turn in the conversation tree, defining the DAG graph. */
788
790
  parent?: {
789
791
  /** The ID of the parent turn. */
@@ -793,6 +795,8 @@ interface Turn {
793
795
  };
794
796
  /** Local model constraints applied explicitly at the time of this turn. */
795
797
  constraints?: ModelConstraintMap;
798
+ /** Extensible key-value store for turn-specific metadata (e.g., error logs). */
799
+ metadata?: Record<string, any>;
796
800
  }
797
801
  /** Unique composite key used to lookup a specific turn version. */
798
802
  type TurnKey = Pick<Turn, "version" | "id" | "session">;
@@ -815,6 +819,8 @@ interface TurnNode {
815
819
  timestamp: Timestamp;
816
820
  /** The role name active when this node was created. */
817
821
  roleSnapshot?: string;
822
+ /** The model name active when this node was created. */
823
+ modelSnapshot?: string;
818
824
  /** Reference to the preceding turn in the conversation DAG. */
819
825
  parent?: {
820
826
  /** Parent turn ID. */
@@ -1210,6 +1216,7 @@ interface EditTurn extends BaseCommand {
1210
1216
  newBlocks: ContentBlock[];
1211
1217
  newVersion: number;
1212
1218
  roleSnapshot?: string;
1219
+ modelSnapshot?: string;
1213
1220
  };
1214
1221
  }
1215
1222
  /** Creates a new branch in the conversation history from a specific turn. */
@@ -2544,6 +2551,29 @@ declare class WorkspaceManager {
2544
2551
  ctx(): WorkspaceContext;
2545
2552
  }
2546
2553
 
2554
+ /**
2555
+ * A lightweight registry for managing workspaces without full initialization.
2556
+ * Solves the 'chicken and egg' problem where you need a workspace to delete a workspace.
2557
+ */
2558
+ declare class WorkspaceRegistry {
2559
+ private readonly db;
2560
+ constructor(db: Database);
2561
+ /**
2562
+ * Lists all workspaces currently registered in the database.
2563
+ */
2564
+ list(): Promise<WorkspaceMetadata[]>;
2565
+ /**
2566
+ * Deletes a workspace record.
2567
+ * Note: This does not currently purge associated data (sessions, turns)
2568
+ * as they are not explicitly linked to the workspace ID in the flat schema.
2569
+ */
2570
+ delete(id: UUID): Promise<boolean>;
2571
+ /**
2572
+ * Purges ALL collections in the database.
2573
+ * Useful for a total reset. Use with extreme caution.
2574
+ */
2575
+ purge(): Promise<void>;
2576
+ }
2547
2577
  declare class WorkspaceApi {
2548
2578
  private readonly manager;
2549
2579
  constructor(manager: WorkspaceManager);
@@ -2601,6 +2631,14 @@ declare class Session {
2601
2631
  getTurn(turnId: UUID): Promise<TurnNode | undefined>;
2602
2632
  rename(newLabel: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2603
2633
  setTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2634
+ /**
2635
+ * Updates the session's model identifier.
2636
+ */
2637
+ setModel(model: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2638
+ /**
2639
+ * Merges the provided metadata into the session's current metadata.
2640
+ */
2641
+ updateMetadata(metadata: Record<string, any>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2604
2642
  addTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2605
2643
  setPreferences(preferenceIds: UUID[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2606
2644
  fork(newSessionId: UUID, label: string, role?: string, topics?: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
@@ -2611,9 +2649,13 @@ declare class Session {
2611
2649
  recordAssistantTurn(turn: Turn, recordDenial?: boolean): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2612
2650
  private buildDenialTurn;
2613
2651
  private describeCommand;
2614
- editTurn(turnId: UUID, newBlocks: ContentBlock[], roleSnapshot?: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2652
+ editTurn(turnId: UUID, newBlocks: ContentBlock[], roleSnapshot?: string, modelSnapshot?: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2615
2653
  branch(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2616
2654
  deleteTurn(turnId: UUID, version: number, newHead: TurnRef | null): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2655
+ /**
2656
+ * Updates the status of a specific turn using the Result pattern.
2657
+ */
2658
+ updateTurnStatus(turnId: UUID, status: Result<undefined, WorkspaceError>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2617
2659
  switchVersionLeft(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2618
2660
  switchVersionRight(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2619
2661
  private switchVersion;
@@ -2628,7 +2670,7 @@ declare class Session {
2628
2670
  *
2629
2671
  * Returns undefined if the session no longer exists in the workspace index.
2630
2672
  */
2631
- snapshot(): Promise<SessionSnapshot | undefined>;
2673
+ snapshot(turnId?: UUID): Promise<SessionSnapshot | undefined>;
2632
2674
  private refreshTurnTree;
2633
2675
  private findSubtreeTip;
2634
2676
  }
@@ -2676,9 +2718,52 @@ declare class TurnBuilder {
2676
2718
  withTimestamp(timestamp: Timestamp): TurnBuilder;
2677
2719
  withParent(parent: TurnRef): TurnBuilder;
2678
2720
  withRoleSnapshot(roleSnapshot: string): TurnBuilder;
2721
+ withRole(role: string): TurnBuilder;
2722
+ withModel(model: string): TurnBuilder;
2679
2723
  build(): Turn;
2680
2724
  }
2681
2725
 
2726
+ declare class DefaultPromptBuilder implements PromptBuilder {
2727
+ private readonly contextRegistry;
2728
+ private readonly retriever;
2729
+ private readonly summarizer?;
2730
+ constructor(contextRegistry: ContextRegistry, retriever: ContextRetriever, summarizer?: Summarizer | undefined);
2731
+ build(snapshot: SessionSnapshot, _: WorkspaceContext, options?: PromptBuilderOptions): Promise<Result<Prompt, WorkspaceError>>;
2732
+ }
2733
+ declare class JaccardContextRetriever implements ContextRetriever {
2734
+ private readonly contextRegistry;
2735
+ constructor(contextRegistry: ContextRegistry);
2736
+ rank(input: {
2737
+ entries: Context[];
2738
+ recentMessages: string[];
2739
+ topics: string[];
2740
+ config?: Record<string, any>;
2741
+ }): Context[];
2742
+ private tokenize;
2743
+ private jaccardSimilarity;
2744
+ private freshnessWeight;
2745
+ }
2746
+
2747
+ declare class DefaultSystemPromptAssembler implements SystemPromptAssembler {
2748
+ /**
2749
+ * Builds the ordered array of PromptSections from a Prompt plus extensions.
2750
+ *
2751
+ * Algorithm:
2752
+ * 1. Build the five candidate core sections from the Prompt.
2753
+ * 2. Drop any core section that has no meaningful content.
2754
+ * 3. Walk the extensions array and splice each one into the result at
2755
+ * its declared anchor position.
2756
+ * 4. Return the final ordered array.
2757
+ */
2758
+ build(prompt: Prompt, extensions?: AssemblerExtension[]): PromptSection[];
2759
+ /**
2760
+ * Joins an ordered array of PromptSections into a single string.
2761
+ * Uses a consistent separator that renders clearly across providers.
2762
+ */
2763
+ join(sections: PromptSection[]): string;
2764
+ }
2765
+ declare function createDefaultAssembler(): DefaultSystemPromptAssembler;
2766
+
2682
2767
  declare class TurnRepository {
2683
2768
  private readonly turnStore;
2684
2769
  private readonly sessionStore;
@@ -2694,6 +2779,10 @@ declare class TurnTree {
2694
2779
  static build(sessionId: UUID, repository: TurnRepository): Promise<TurnTree>;
2695
2780
  head(): TurnRef | null;
2696
2781
  chain(): TurnNode[];
2782
+ /**
2783
+ * Returns a chronological chain of TurnNodes ending at the specified turn.
2784
+ */
2785
+ chainFrom(turnId: UUID): TurnNode[];
2697
2786
  getTurnSiblings(turnId: UUID): TurnNode[];
2698
2787
  branchInfo(turnId: UUID): BranchInfo;
2699
2788
  graph(): Readonly<Record<UUID, TurnNode>>;
@@ -2826,6 +2915,8 @@ declare const GOOGLE_MODELS: Array<ModelProfile>;
2826
2915
  * - Block validation and construction is fully delegated to the registry.
2827
2916
  * Unknown block types returned by the model are silently dropped (registry
2828
2917
  * returns null for unregistered types) and logged by the registry itself.
2918
+ * - If the model ignores the structured JSON schema and returns raw text,
2919
+ * it automatically wraps the response in a TextBlock with markdown repair.
2829
2920
  */
2830
2921
  declare function parseModelResponse(response: GenerateContentResponse, registry: ContentBlockRegistry): Result<ContentBlock[], WorkspaceError>;
2831
2922
 
@@ -2918,4 +3009,4 @@ declare function createWorkspace(params: CreateWorkspaceParams): Promise<{
2918
3009
  bootstrap: (config: BootstrapConfig) => Promise<BootstrapResult>;
2919
3010
  }>;
2920
3011
 
2921
- export { type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BlobCommand, type BlobContextContent, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BootstrapConfig, type BootstrapResult, type BranchInfo, type BranchTurn, COLLECTIONS, type Collections, type Command, type ContentBlock, type Context, type ContextContent, type ContextDefinition, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DefaultContextContent, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTopic, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type DuplicateKeyError, EMPTY_SYSTEM_ROLE, type EditTurn, type ForkSession, index as GoogleAdapter, type ImageBlock, type ImageMediaType, type Index, type IndexExtensions, type IndexedDBBlobConfig, IndexedDBBlobStorage, type Indexer, type InvalidCommandError, type JsonContextContent, type LLMAdapter, type LLMAdapterStatic, LRUCache, MemoryBlobStorage, type MergeTopics, type ModelConstraint, type ModelConstraintMap, type ModelName, type ModelProfile, type ModelRegistry, type NotFoundError, type OverrideSessionPreferences, type PermissionDeniedError, type PermissionGuard, type Preference, type PreferenceSummary, type Project, type PromptBuilder, type PromptBuilderOptions, type PurgeBlob, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type RemoteContextContent, type ResolvedBlob, type ResolvedSession, type Result, type RetainBlob, type Role, type RoleSummary, type RoleTransitionBlock, type SHA256, Session, SessionManager, type SessionMetadata, type SessionSnapshot, type Settings, type Store, type Summarizer, type SummaryBlock, type SwitchSessionRole, type SyncWorkspace, type SystemActor, type TextBlock, type TextContextContent, type ThinkingBlock, type Timestamp, type ToolCall, type ToolCallCommand, type ToolRegistry, type ToolResultBlock, type ToolSummary, type ToolUseBlock, type Topic, type TopicIndex, type Turn, TurnBuilder, type TurnKey, type TurnNode, type TurnProcessor, type TurnRef, TurnTree, type URI, type UUID, type UpdateContext, type UpdatePreference, type UpdateRole, type UpdateSession, type UpdateTopic, type UpdateTurn, type Workspace, type WorkspaceBundle, type WorkspaceContext, type WorkspaceDatabase, type WorkspaceError, type WorkspaceEvents, type WorkspaceExtension, WorkspaceManager, type WorkspaceMiddleware, type WorkspaceReducer, bufferToBase64, computeSHA256, createEmptySession, createEmptyTurn, createEmptyWorkspace, createWorkspace, createWorkspaceDatabase, del, error, getExtension, merge, omitNullUndefined, shortHash, success };
3012
+ export { type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BlobCommand, type BlobContextContent, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BootstrapConfig, type BootstrapResult, type BranchInfo, type BranchTurn, COLLECTIONS, type Collections, type Command, type ContentBlock, type Context, type ContextContent, type ContextDefinition, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DefaultContextContent, DefaultPromptBuilder, DefaultSystemPromptAssembler, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTopic, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type DuplicateKeyError, EMPTY_SYSTEM_ROLE, type EditTurn, type ForkSession, index as GoogleAdapter, type ImageBlock, type ImageMediaType, type Index, type IndexExtensions, type IndexedDBBlobConfig, IndexedDBBlobStorage, type Indexer, type InvalidCommandError, JaccardContextRetriever, type JsonContextContent, type LLMAdapter, type LLMAdapterStatic, LRUCache, MemoryBlobStorage, type MergeTopics, type ModelConstraint, type ModelConstraintMap, type ModelName, type ModelProfile, type ModelRegistry, type NotFoundError, type OverrideSessionPreferences, type PermissionDeniedError, type PermissionGuard, type Preference, type PreferenceSummary, type Project, type PromptBuilder, type PromptBuilderOptions, type PurgeBlob, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type RemoteContextContent, type ResolvedBlob, type ResolvedSession, type Result, type RetainBlob, type Role, type RoleSummary, type RoleTransitionBlock, type SHA256, Session, SessionManager, type SessionMetadata, type SessionSnapshot, type Settings, type Store, type Summarizer, type SummaryBlock, type SwitchSessionRole, type SyncWorkspace, type SystemActor, type TextBlock, type TextContextContent, type ThinkingBlock, type Timestamp, type ToolCall, type ToolCallCommand, type ToolRegistry, type ToolResultBlock, type ToolSummary, type ToolUseBlock, type Topic, type TopicIndex, type Turn, TurnBuilder, type TurnKey, type TurnNode, type TurnProcessor, type TurnRef, TurnTree, type URI, type UUID, type UpdateContext, type UpdatePreference, type UpdateRole, type UpdateSession, type UpdateTopic, type UpdateTurn, type Workspace, WorkspaceApi, type WorkspaceBundle, type WorkspaceContext, type WorkspaceDatabase, type WorkspaceError, type WorkspaceEvents, type WorkspaceExtension, WorkspaceManager, type WorkspaceMiddleware, type WorkspaceReducer, WorkspaceRegistry, bufferToBase64, computeSHA256, createDefaultAssembler, createEmptySession, createEmptyTurn, createEmptyWorkspace, createWorkspace, createWorkspaceDatabase, del, error, getExtension, merge, omitNullUndefined, shortHash, success };
package/index.d.ts CHANGED
@@ -784,6 +784,8 @@ interface Turn {
784
784
  timestamp: Timestamp;
785
785
  /** Name of the role (persona) active at the exact time this turn occurred. */
786
786
  role?: string;
787
+ /** Name of the model that produced this turn. */
788
+ model?: string;
787
789
  /** Link to the preceding turn in the conversation tree, defining the DAG graph. */
788
790
  parent?: {
789
791
  /** The ID of the parent turn. */
@@ -793,6 +795,8 @@ interface Turn {
793
795
  };
794
796
  /** Local model constraints applied explicitly at the time of this turn. */
795
797
  constraints?: ModelConstraintMap;
798
+ /** Extensible key-value store for turn-specific metadata (e.g., error logs). */
799
+ metadata?: Record<string, any>;
796
800
  }
797
801
  /** Unique composite key used to lookup a specific turn version. */
798
802
  type TurnKey = Pick<Turn, "version" | "id" | "session">;
@@ -815,6 +819,8 @@ interface TurnNode {
815
819
  timestamp: Timestamp;
816
820
  /** The role name active when this node was created. */
817
821
  roleSnapshot?: string;
822
+ /** The model name active when this node was created. */
823
+ modelSnapshot?: string;
818
824
  /** Reference to the preceding turn in the conversation DAG. */
819
825
  parent?: {
820
826
  /** Parent turn ID. */
@@ -1210,6 +1216,7 @@ interface EditTurn extends BaseCommand {
1210
1216
  newBlocks: ContentBlock[];
1211
1217
  newVersion: number;
1212
1218
  roleSnapshot?: string;
1219
+ modelSnapshot?: string;
1213
1220
  };
1214
1221
  }
1215
1222
  /** Creates a new branch in the conversation history from a specific turn. */
@@ -2544,6 +2551,29 @@ declare class WorkspaceManager {
2544
2551
  ctx(): WorkspaceContext;
2545
2552
  }
2546
2553
 
2554
+ /**
2555
+ * A lightweight registry for managing workspaces without full initialization.
2556
+ * Solves the 'chicken and egg' problem where you need a workspace to delete a workspace.
2557
+ */
2558
+ declare class WorkspaceRegistry {
2559
+ private readonly db;
2560
+ constructor(db: Database);
2561
+ /**
2562
+ * Lists all workspaces currently registered in the database.
2563
+ */
2564
+ list(): Promise<WorkspaceMetadata[]>;
2565
+ /**
2566
+ * Deletes a workspace record.
2567
+ * Note: This does not currently purge associated data (sessions, turns)
2568
+ * as they are not explicitly linked to the workspace ID in the flat schema.
2569
+ */
2570
+ delete(id: UUID): Promise<boolean>;
2571
+ /**
2572
+ * Purges ALL collections in the database.
2573
+ * Useful for a total reset. Use with extreme caution.
2574
+ */
2575
+ purge(): Promise<void>;
2576
+ }
2547
2577
  declare class WorkspaceApi {
2548
2578
  private readonly manager;
2549
2579
  constructor(manager: WorkspaceManager);
@@ -2601,6 +2631,14 @@ declare class Session {
2601
2631
  getTurn(turnId: UUID): Promise<TurnNode | undefined>;
2602
2632
  rename(newLabel: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2603
2633
  setTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2634
+ /**
2635
+ * Updates the session's model identifier.
2636
+ */
2637
+ setModel(model: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2638
+ /**
2639
+ * Merges the provided metadata into the session's current metadata.
2640
+ */
2641
+ updateMetadata(metadata: Record<string, any>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2604
2642
  addTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2605
2643
  setPreferences(preferenceIds: UUID[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2606
2644
  fork(newSessionId: UUID, label: string, role?: string, topics?: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
@@ -2611,9 +2649,13 @@ declare class Session {
2611
2649
  recordAssistantTurn(turn: Turn, recordDenial?: boolean): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2612
2650
  private buildDenialTurn;
2613
2651
  private describeCommand;
2614
- editTurn(turnId: UUID, newBlocks: ContentBlock[], roleSnapshot?: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2652
+ editTurn(turnId: UUID, newBlocks: ContentBlock[], roleSnapshot?: string, modelSnapshot?: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2615
2653
  branch(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2616
2654
  deleteTurn(turnId: UUID, version: number, newHead: TurnRef | null): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2655
+ /**
2656
+ * Updates the status of a specific turn using the Result pattern.
2657
+ */
2658
+ updateTurnStatus(turnId: UUID, status: Result<undefined, WorkspaceError>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2617
2659
  switchVersionLeft(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2618
2660
  switchVersionRight(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
2619
2661
  private switchVersion;
@@ -2628,7 +2670,7 @@ declare class Session {
2628
2670
  *
2629
2671
  * Returns undefined if the session no longer exists in the workspace index.
2630
2672
  */
2631
- snapshot(): Promise<SessionSnapshot | undefined>;
2673
+ snapshot(turnId?: UUID): Promise<SessionSnapshot | undefined>;
2632
2674
  private refreshTurnTree;
2633
2675
  private findSubtreeTip;
2634
2676
  }
@@ -2676,9 +2718,52 @@ declare class TurnBuilder {
2676
2718
  withTimestamp(timestamp: Timestamp): TurnBuilder;
2677
2719
  withParent(parent: TurnRef): TurnBuilder;
2678
2720
  withRoleSnapshot(roleSnapshot: string): TurnBuilder;
2721
+ withRole(role: string): TurnBuilder;
2722
+ withModel(model: string): TurnBuilder;
2679
2723
  build(): Turn;
2680
2724
  }
2681
2725
 
2726
+ declare class DefaultPromptBuilder implements PromptBuilder {
2727
+ private readonly contextRegistry;
2728
+ private readonly retriever;
2729
+ private readonly summarizer?;
2730
+ constructor(contextRegistry: ContextRegistry, retriever: ContextRetriever, summarizer?: Summarizer | undefined);
2731
+ build(snapshot: SessionSnapshot, _: WorkspaceContext, options?: PromptBuilderOptions): Promise<Result<Prompt, WorkspaceError>>;
2732
+ }
2733
+ declare class JaccardContextRetriever implements ContextRetriever {
2734
+ private readonly contextRegistry;
2735
+ constructor(contextRegistry: ContextRegistry);
2736
+ rank(input: {
2737
+ entries: Context[];
2738
+ recentMessages: string[];
2739
+ topics: string[];
2740
+ config?: Record<string, any>;
2741
+ }): Context[];
2742
+ private tokenize;
2743
+ private jaccardSimilarity;
2744
+ private freshnessWeight;
2745
+ }
2746
+
2747
+ declare class DefaultSystemPromptAssembler implements SystemPromptAssembler {
2748
+ /**
2749
+ * Builds the ordered array of PromptSections from a Prompt plus extensions.
2750
+ *
2751
+ * Algorithm:
2752
+ * 1. Build the five candidate core sections from the Prompt.
2753
+ * 2. Drop any core section that has no meaningful content.
2754
+ * 3. Walk the extensions array and splice each one into the result at
2755
+ * its declared anchor position.
2756
+ * 4. Return the final ordered array.
2757
+ */
2758
+ build(prompt: Prompt, extensions?: AssemblerExtension[]): PromptSection[];
2759
+ /**
2760
+ * Joins an ordered array of PromptSections into a single string.
2761
+ * Uses a consistent separator that renders clearly across providers.
2762
+ */
2763
+ join(sections: PromptSection[]): string;
2764
+ }
2765
+ declare function createDefaultAssembler(): DefaultSystemPromptAssembler;
2766
+
2682
2767
  declare class TurnRepository {
2683
2768
  private readonly turnStore;
2684
2769
  private readonly sessionStore;
@@ -2694,6 +2779,10 @@ declare class TurnTree {
2694
2779
  static build(sessionId: UUID, repository: TurnRepository): Promise<TurnTree>;
2695
2780
  head(): TurnRef | null;
2696
2781
  chain(): TurnNode[];
2782
+ /**
2783
+ * Returns a chronological chain of TurnNodes ending at the specified turn.
2784
+ */
2785
+ chainFrom(turnId: UUID): TurnNode[];
2697
2786
  getTurnSiblings(turnId: UUID): TurnNode[];
2698
2787
  branchInfo(turnId: UUID): BranchInfo;
2699
2788
  graph(): Readonly<Record<UUID, TurnNode>>;
@@ -2826,6 +2915,8 @@ declare const GOOGLE_MODELS: Array<ModelProfile>;
2826
2915
  * - Block validation and construction is fully delegated to the registry.
2827
2916
  * Unknown block types returned by the model are silently dropped (registry
2828
2917
  * returns null for unregistered types) and logged by the registry itself.
2918
+ * - If the model ignores the structured JSON schema and returns raw text,
2919
+ * it automatically wraps the response in a TextBlock with markdown repair.
2829
2920
  */
2830
2921
  declare function parseModelResponse(response: GenerateContentResponse, registry: ContentBlockRegistry): Result<ContentBlock[], WorkspaceError>;
2831
2922
 
@@ -2918,4 +3009,4 @@ declare function createWorkspace(params: CreateWorkspaceParams): Promise<{
2918
3009
  bootstrap: (config: BootstrapConfig) => Promise<BootstrapResult>;
2919
3010
  }>;
2920
3011
 
2921
- export { type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BlobCommand, type BlobContextContent, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BootstrapConfig, type BootstrapResult, type BranchInfo, type BranchTurn, COLLECTIONS, type Collections, type Command, type ContentBlock, type Context, type ContextContent, type ContextDefinition, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DefaultContextContent, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTopic, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type DuplicateKeyError, EMPTY_SYSTEM_ROLE, type EditTurn, type ForkSession, index as GoogleAdapter, type ImageBlock, type ImageMediaType, type Index, type IndexExtensions, type IndexedDBBlobConfig, IndexedDBBlobStorage, type Indexer, type InvalidCommandError, type JsonContextContent, type LLMAdapter, type LLMAdapterStatic, LRUCache, MemoryBlobStorage, type MergeTopics, type ModelConstraint, type ModelConstraintMap, type ModelName, type ModelProfile, type ModelRegistry, type NotFoundError, type OverrideSessionPreferences, type PermissionDeniedError, type PermissionGuard, type Preference, type PreferenceSummary, type Project, type PromptBuilder, type PromptBuilderOptions, type PurgeBlob, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type RemoteContextContent, type ResolvedBlob, type ResolvedSession, type Result, type RetainBlob, type Role, type RoleSummary, type RoleTransitionBlock, type SHA256, Session, SessionManager, type SessionMetadata, type SessionSnapshot, type Settings, type Store, type Summarizer, type SummaryBlock, type SwitchSessionRole, type SyncWorkspace, type SystemActor, type TextBlock, type TextContextContent, type ThinkingBlock, type Timestamp, type ToolCall, type ToolCallCommand, type ToolRegistry, type ToolResultBlock, type ToolSummary, type ToolUseBlock, type Topic, type TopicIndex, type Turn, TurnBuilder, type TurnKey, type TurnNode, type TurnProcessor, type TurnRef, TurnTree, type URI, type UUID, type UpdateContext, type UpdatePreference, type UpdateRole, type UpdateSession, type UpdateTopic, type UpdateTurn, type Workspace, type WorkspaceBundle, type WorkspaceContext, type WorkspaceDatabase, type WorkspaceError, type WorkspaceEvents, type WorkspaceExtension, WorkspaceManager, type WorkspaceMiddleware, type WorkspaceReducer, bufferToBase64, computeSHA256, createEmptySession, createEmptyTurn, createEmptyWorkspace, createWorkspace, createWorkspaceDatabase, del, error, getExtension, merge, omitNullUndefined, shortHash, success };
3012
+ export { type AddContext, type AddPreference, type AddRole, type AddSessionTopics, type AddTopic, type AddTurn, type AuthRequest, type BackendError, type BaseCommand, type BaseContentBlock, type BlobCommand, type BlobContextContent, type BlobError, type BlobMediaType, type BlobRecord, type BlobRef, type BlobResolver, type BootstrapConfig, type BootstrapResult, type BranchInfo, type BranchTurn, COLLECTIONS, type Collections, type Command, type ContentBlock, type Context, type ContextContent, type ContextDefinition, type ContextRetriever, type ContextSummary, type CreateSession, type CreateWorkspace, type CreateWorkspaceParams, type DeepPartial, type DefaultContextContent, DefaultPromptBuilder, DefaultSystemPromptAssembler, type DeleteContext, type DeletePreference, type DeleteRole, type DeleteSession, type DeleteTopic, type DeleteTurn, type DocumentBlock, type DocumentMediaType, type DuplicateKeyError, EMPTY_SYSTEM_ROLE, type EditTurn, type ForkSession, index as GoogleAdapter, type ImageBlock, type ImageMediaType, type Index, type IndexExtensions, type IndexedDBBlobConfig, IndexedDBBlobStorage, type Indexer, type InvalidCommandError, JaccardContextRetriever, type JsonContextContent, type LLMAdapter, type LLMAdapterStatic, LRUCache, MemoryBlobStorage, type MergeTopics, type ModelConstraint, type ModelConstraintMap, type ModelName, type ModelProfile, type ModelRegistry, type NotFoundError, type OverrideSessionPreferences, type PermissionDeniedError, type PermissionGuard, type Preference, type PreferenceSummary, type Project, type PromptBuilder, type PromptBuilderOptions, type PurgeBlob, type RecordBlobRemoteId, type RegisterBlob, type ReleaseBlob, type RemoteContextContent, type ResolvedBlob, type ResolvedSession, type Result, type RetainBlob, type Role, type RoleSummary, type RoleTransitionBlock, type SHA256, Session, SessionManager, type SessionMetadata, type SessionSnapshot, type Settings, type Store, type Summarizer, type SummaryBlock, type SwitchSessionRole, type SyncWorkspace, type SystemActor, type TextBlock, type TextContextContent, type ThinkingBlock, type Timestamp, type ToolCall, type ToolCallCommand, type ToolRegistry, type ToolResultBlock, type ToolSummary, type ToolUseBlock, type Topic, type TopicIndex, type Turn, TurnBuilder, type TurnKey, type TurnNode, type TurnProcessor, type TurnRef, TurnTree, type URI, type UUID, type UpdateContext, type UpdatePreference, type UpdateRole, type UpdateSession, type UpdateTopic, type UpdateTurn, type Workspace, WorkspaceApi, type WorkspaceBundle, type WorkspaceContext, type WorkspaceDatabase, type WorkspaceError, type WorkspaceEvents, type WorkspaceExtension, WorkspaceManager, type WorkspaceMiddleware, type WorkspaceReducer, WorkspaceRegistry, bufferToBase64, computeSHA256, createDefaultAssembler, createEmptySession, createEmptyTurn, createEmptyWorkspace, createWorkspace, createWorkspaceDatabase, del, error, getExtension, merge, omitNullUndefined, shortHash, success };