@asaidimu/utils-workspace 6.5.5 → 6.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +126 -15
- package/index.d.ts +126 -15
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1769,9 +1769,7 @@ interface ContentBlockDefinition {
|
|
|
1769
1769
|
* - `false` → workspace-internal only; invisible to the model
|
|
1770
1770
|
*/
|
|
1771
1771
|
emittable: boolean;
|
|
1772
|
-
/**
|
|
1773
|
-
* Whether this block should be included in input to models
|
|
1774
|
-
*/
|
|
1772
|
+
/** Whether this block should be included in input to models */
|
|
1775
1773
|
consumable?: boolean;
|
|
1776
1774
|
/**
|
|
1777
1775
|
* Ordered list of behavioural rules for this block type.
|
|
@@ -2690,10 +2688,17 @@ declare class Session {
|
|
|
2690
2688
|
private tree;
|
|
2691
2689
|
private unsubscribe?;
|
|
2692
2690
|
private constructor();
|
|
2691
|
+
/**
|
|
2692
|
+
* Factory method to create a new Session instance.
|
|
2693
|
+
* @param sessionId - Unique identifier for the session.
|
|
2694
|
+
* @param manager - Workspace manager for dispatching commands.
|
|
2695
|
+
* @param processor - Turn processor for handling tool calls.
|
|
2696
|
+
* @returns A fully initialised Session.
|
|
2697
|
+
*/
|
|
2693
2698
|
static create(sessionId: UUID, manager: WorkspaceManager, processor: TurnProcessor): Promise<Session>;
|
|
2694
2699
|
/**
|
|
2695
|
-
*
|
|
2696
|
-
* Useful after a workspace
|
|
2700
|
+
* Synchronises the session's in‑memory state with the persistent stores.
|
|
2701
|
+
* Useful after a workspace‑wide sync or if state becomes stale.
|
|
2697
2702
|
*/
|
|
2698
2703
|
sync(): Promise<void>;
|
|
2699
2704
|
/**
|
|
@@ -2702,57 +2707,163 @@ declare class Session {
|
|
|
2702
2707
|
close(): void;
|
|
2703
2708
|
private _setRole;
|
|
2704
2709
|
private _setPreference;
|
|
2710
|
+
/** Returns the session’s unique identifier. */
|
|
2705
2711
|
id(): UUID;
|
|
2706
2712
|
private ws;
|
|
2713
|
+
/** Returns the session metadata from the workspace index. */
|
|
2707
2714
|
meta(): SessionMetadata | undefined;
|
|
2715
|
+
/** Returns the session’s label (display name). */
|
|
2708
2716
|
label(): string | undefined;
|
|
2717
|
+
/** Returns the session’s current Role object. */
|
|
2709
2718
|
role(): Role | undefined;
|
|
2719
|
+
/** Returns the list of topic strings associated with the session. */
|
|
2710
2720
|
topics(): string[];
|
|
2721
|
+
/** Returns the list of preferences active for this session. */
|
|
2711
2722
|
preferences(): Preference[];
|
|
2723
|
+
/** Returns the current head (last turn) of the session, or null if empty. */
|
|
2712
2724
|
head(): TurnRef | null;
|
|
2725
|
+
/** Returns the active chain of turns as an array of TurnNode. */
|
|
2713
2726
|
turns(): TurnNode[];
|
|
2727
|
+
/**
|
|
2728
|
+
* Returns all sibling turns of a given turn (other children of the same parent).
|
|
2729
|
+
* @param turnId - ID of the turn.
|
|
2730
|
+
*/
|
|
2714
2731
|
siblings(turnId: UUID): Promise<TurnNode[]>;
|
|
2732
|
+
/**
|
|
2733
|
+
* Returns branching information for a turn (versions, navigation).
|
|
2734
|
+
* @param turnId - ID of the turn.
|
|
2735
|
+
*/
|
|
2715
2736
|
branchInfo(turnId: UUID): Promise<BranchInfo>;
|
|
2737
|
+
/**
|
|
2738
|
+
* Retrieves a TurnNode by its ID.
|
|
2739
|
+
* @param turnId - ID of the turn.
|
|
2740
|
+
*/
|
|
2716
2741
|
getTurn(turnId: UUID): Promise<TurnNode | undefined>;
|
|
2742
|
+
/**
|
|
2743
|
+
* Changes the session’s display label.
|
|
2744
|
+
* @param newLabel - New label for the session.
|
|
2745
|
+
*/
|
|
2717
2746
|
rename(newLabel: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2747
|
+
/**
|
|
2748
|
+
* Replaces the session’s topic list.
|
|
2749
|
+
* @param topics - New array of topic strings.
|
|
2750
|
+
*/
|
|
2718
2751
|
setTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2719
2752
|
/**
|
|
2720
|
-
* Updates the session
|
|
2753
|
+
* Updates the session’s model identifier (e.g., "gpt-4").
|
|
2754
|
+
* @param model - New model string.
|
|
2721
2755
|
*/
|
|
2722
2756
|
setModel(model: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2723
2757
|
/**
|
|
2724
|
-
* Merges
|
|
2758
|
+
* Merges arbitrary metadata into the session’s metadata object.
|
|
2759
|
+
* @param metadata - Key‑value pairs to merge.
|
|
2725
2760
|
*/
|
|
2726
2761
|
updateMetadata(metadata: Record<string, any>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2762
|
+
/**
|
|
2763
|
+
* Adds topics to the session (does not replace existing ones).
|
|
2764
|
+
* @param topics - Topics to add.
|
|
2765
|
+
*/
|
|
2727
2766
|
addTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2767
|
+
/**
|
|
2768
|
+
* Replaces the session’s preference list with the given IDs.
|
|
2769
|
+
* @param preferenceIds - Array of preference UUIDs.
|
|
2770
|
+
*/
|
|
2728
2771
|
setPreferences(preferenceIds: UUID[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2772
|
+
/**
|
|
2773
|
+
* Creates a new session as a fork of this one.
|
|
2774
|
+
* @param newSessionId - ID for the new session.
|
|
2775
|
+
* @param label - Label for the new session.
|
|
2776
|
+
* @param role - Optional role ID (defaults to current role).
|
|
2777
|
+
* @param topics - Optional topics (defaults to current topics).
|
|
2778
|
+
*/
|
|
2729
2779
|
fork(newSessionId: UUID, label: string, role?: string, topics?: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2780
|
+
/**
|
|
2781
|
+
* Dispatches a raw command to the workspace manager.
|
|
2782
|
+
* @param command - BaseCommand to dispatch.
|
|
2783
|
+
*/
|
|
2730
2784
|
dispatch(command: BaseCommand): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2785
|
+
/**
|
|
2786
|
+
* Switches the session to a different role.
|
|
2787
|
+
* @param newRole - ID of the new role (or EMPTY_SYSTEM_ROLE).
|
|
2788
|
+
*/
|
|
2731
2789
|
switchRole(newRole: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2790
|
+
/**
|
|
2791
|
+
* Adds a turn to the session. The turn’s parent, version, role, and model
|
|
2792
|
+
* are automatically filled if missing.
|
|
2793
|
+
* @param turn - The turn to add (may be incomplete).
|
|
2794
|
+
* @returns Result with the workspace patch and updates the in‑memory tree.
|
|
2795
|
+
*/
|
|
2732
2796
|
addTurn(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2797
|
+
/**
|
|
2798
|
+
* Records a user turn (alias for addTurn).
|
|
2799
|
+
* @param turn - The user turn.
|
|
2800
|
+
*/
|
|
2733
2801
|
recordUserTurn(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2802
|
+
/**
|
|
2803
|
+
* Records an assistant turn, processes any tool calls, and optionally records denial turns.
|
|
2804
|
+
* @param turn - The assistant turn (may contain tool calls).
|
|
2805
|
+
* @param recordDenial - If true, adds a user turn explaining denied tool calls.
|
|
2806
|
+
* @returns Result with the merged workspace patches.
|
|
2807
|
+
*/
|
|
2734
2808
|
recordAssistantTurn(turn: Turn, recordDenial?: boolean): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2735
2809
|
private buildDenialTurn;
|
|
2736
2810
|
private describeCommand;
|
|
2811
|
+
/**
|
|
2812
|
+
* Edits an existing turn, creating a new version. The session head is moved to this new version.
|
|
2813
|
+
* @param turnId - ID of the turn to edit.
|
|
2814
|
+
* @param newBlocks - New content blocks for the turn.
|
|
2815
|
+
* @param roleSnapshot - Optional role to associate (defaults to current active version's role).
|
|
2816
|
+
* @param modelSnapshot - Optional model to associate (defaults to current active version's model).
|
|
2817
|
+
*/
|
|
2737
2818
|
editTurn(turnId: UUID, newBlocks: ContentBlock[], roleSnapshot?: string, modelSnapshot?: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2819
|
+
/**
|
|
2820
|
+
* Adds a branch turn (a turn that shares a parent with an existing turn).
|
|
2821
|
+
* @param turn - The turn to branch (must have parent set).
|
|
2822
|
+
*/
|
|
2738
2823
|
branch(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2824
|
+
/**
|
|
2825
|
+
* Deletes a specific version of a turn and optionally updates the session head.
|
|
2826
|
+
* @param turnId - ID of the turn.
|
|
2827
|
+
* @param version - Version number to delete.
|
|
2828
|
+
* @param newHead - New head reference after deletion (or null to keep current head if still valid).
|
|
2829
|
+
*/
|
|
2739
2830
|
deleteTurn(turnId: UUID, version: number, newHead: TurnRef | null): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2740
2831
|
/**
|
|
2741
|
-
* Updates the status of a specific turn
|
|
2832
|
+
* Updates the status (success/unsuccessful) of a specific turn version.
|
|
2833
|
+
* @param turnId - ID of the turn.
|
|
2834
|
+
* @param version - Version number of the turn to update.
|
|
2835
|
+
* @param status - Result indicating success or failure.
|
|
2836
|
+
*/
|
|
2837
|
+
updateTurnStatus(turnId: UUID, version: number, status: Result<undefined, WorkspaceError>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2838
|
+
/**
|
|
2839
|
+
* Switches to the previous version of a turn (if available).
|
|
2840
|
+
* @param turnId - ID of the turn.
|
|
2742
2841
|
*/
|
|
2743
|
-
updateTurnStatus(turnId: UUID, status: Result<undefined, WorkspaceError>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2744
2842
|
switchVersionLeft(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Switches to the next version of a turn (if available).
|
|
2845
|
+
* @param turnId - ID of the turn.
|
|
2846
|
+
*/
|
|
2745
2847
|
switchVersionRight(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2746
2848
|
private switchVersion;
|
|
2747
2849
|
/**
|
|
2748
|
-
* Assembles a SessionSnapshot for PromptBuilder.
|
|
2749
|
-
*
|
|
2750
|
-
* If a UUID is provided,
|
|
2751
|
-
* If a Turn object is provided,
|
|
2752
|
-
*
|
|
2850
|
+
* Assembles a SessionSnapshot for the PromptBuilder.
|
|
2851
|
+
* @param target - Optional target:
|
|
2852
|
+
* - If a UUID is provided, snapshots history ending at that turn.
|
|
2853
|
+
* - If a Turn object is provided, snapshots a "potential" state where
|
|
2854
|
+
* this turn is appended to its parent (or current head) without committing it.
|
|
2753
2855
|
*/
|
|
2754
2856
|
snapshot(target?: UUID | Turn): Promise<SessionSnapshot | undefined>;
|
|
2857
|
+
/**
|
|
2858
|
+
* Rebuilds the in‑memory TurnTree.
|
|
2859
|
+
* @param headOverride - If provided, use this as the session head instead of reading from the store.
|
|
2860
|
+
* This avoids stale reads after mutations that change the head.
|
|
2861
|
+
*/
|
|
2755
2862
|
private refreshTurnTree;
|
|
2863
|
+
/**
|
|
2864
|
+
* Finds the deepest descendant (tip) of a given turn version.
|
|
2865
|
+
* Used when switching versions to determine the new session head.
|
|
2866
|
+
*/
|
|
2756
2867
|
private findSubtreeTip;
|
|
2757
2868
|
}
|
|
2758
2869
|
|
|
@@ -2865,7 +2976,7 @@ declare class TurnTree {
|
|
|
2865
2976
|
private readonly nodes;
|
|
2866
2977
|
private readonly _head;
|
|
2867
2978
|
private constructor();
|
|
2868
|
-
static build(sessionId: UUID, repository: TurnRepository): Promise<TurnTree>;
|
|
2979
|
+
static build(sessionId: UUID, repository: TurnRepository, headOverride?: TurnRef | null): Promise<TurnTree>;
|
|
2869
2980
|
head(): TurnRef | null;
|
|
2870
2981
|
chain(): TurnNode[];
|
|
2871
2982
|
/**
|
package/index.d.ts
CHANGED
|
@@ -1769,9 +1769,7 @@ interface ContentBlockDefinition {
|
|
|
1769
1769
|
* - `false` → workspace-internal only; invisible to the model
|
|
1770
1770
|
*/
|
|
1771
1771
|
emittable: boolean;
|
|
1772
|
-
/**
|
|
1773
|
-
* Whether this block should be included in input to models
|
|
1774
|
-
*/
|
|
1772
|
+
/** Whether this block should be included in input to models */
|
|
1775
1773
|
consumable?: boolean;
|
|
1776
1774
|
/**
|
|
1777
1775
|
* Ordered list of behavioural rules for this block type.
|
|
@@ -2690,10 +2688,17 @@ declare class Session {
|
|
|
2690
2688
|
private tree;
|
|
2691
2689
|
private unsubscribe?;
|
|
2692
2690
|
private constructor();
|
|
2691
|
+
/**
|
|
2692
|
+
* Factory method to create a new Session instance.
|
|
2693
|
+
* @param sessionId - Unique identifier for the session.
|
|
2694
|
+
* @param manager - Workspace manager for dispatching commands.
|
|
2695
|
+
* @param processor - Turn processor for handling tool calls.
|
|
2696
|
+
* @returns A fully initialised Session.
|
|
2697
|
+
*/
|
|
2693
2698
|
static create(sessionId: UUID, manager: WorkspaceManager, processor: TurnProcessor): Promise<Session>;
|
|
2694
2699
|
/**
|
|
2695
|
-
*
|
|
2696
|
-
* Useful after a workspace
|
|
2700
|
+
* Synchronises the session's in‑memory state with the persistent stores.
|
|
2701
|
+
* Useful after a workspace‑wide sync or if state becomes stale.
|
|
2697
2702
|
*/
|
|
2698
2703
|
sync(): Promise<void>;
|
|
2699
2704
|
/**
|
|
@@ -2702,57 +2707,163 @@ declare class Session {
|
|
|
2702
2707
|
close(): void;
|
|
2703
2708
|
private _setRole;
|
|
2704
2709
|
private _setPreference;
|
|
2710
|
+
/** Returns the session’s unique identifier. */
|
|
2705
2711
|
id(): UUID;
|
|
2706
2712
|
private ws;
|
|
2713
|
+
/** Returns the session metadata from the workspace index. */
|
|
2707
2714
|
meta(): SessionMetadata | undefined;
|
|
2715
|
+
/** Returns the session’s label (display name). */
|
|
2708
2716
|
label(): string | undefined;
|
|
2717
|
+
/** Returns the session’s current Role object. */
|
|
2709
2718
|
role(): Role | undefined;
|
|
2719
|
+
/** Returns the list of topic strings associated with the session. */
|
|
2710
2720
|
topics(): string[];
|
|
2721
|
+
/** Returns the list of preferences active for this session. */
|
|
2711
2722
|
preferences(): Preference[];
|
|
2723
|
+
/** Returns the current head (last turn) of the session, or null if empty. */
|
|
2712
2724
|
head(): TurnRef | null;
|
|
2725
|
+
/** Returns the active chain of turns as an array of TurnNode. */
|
|
2713
2726
|
turns(): TurnNode[];
|
|
2727
|
+
/**
|
|
2728
|
+
* Returns all sibling turns of a given turn (other children of the same parent).
|
|
2729
|
+
* @param turnId - ID of the turn.
|
|
2730
|
+
*/
|
|
2714
2731
|
siblings(turnId: UUID): Promise<TurnNode[]>;
|
|
2732
|
+
/**
|
|
2733
|
+
* Returns branching information for a turn (versions, navigation).
|
|
2734
|
+
* @param turnId - ID of the turn.
|
|
2735
|
+
*/
|
|
2715
2736
|
branchInfo(turnId: UUID): Promise<BranchInfo>;
|
|
2737
|
+
/**
|
|
2738
|
+
* Retrieves a TurnNode by its ID.
|
|
2739
|
+
* @param turnId - ID of the turn.
|
|
2740
|
+
*/
|
|
2716
2741
|
getTurn(turnId: UUID): Promise<TurnNode | undefined>;
|
|
2742
|
+
/**
|
|
2743
|
+
* Changes the session’s display label.
|
|
2744
|
+
* @param newLabel - New label for the session.
|
|
2745
|
+
*/
|
|
2717
2746
|
rename(newLabel: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2747
|
+
/**
|
|
2748
|
+
* Replaces the session’s topic list.
|
|
2749
|
+
* @param topics - New array of topic strings.
|
|
2750
|
+
*/
|
|
2718
2751
|
setTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2719
2752
|
/**
|
|
2720
|
-
* Updates the session
|
|
2753
|
+
* Updates the session’s model identifier (e.g., "gpt-4").
|
|
2754
|
+
* @param model - New model string.
|
|
2721
2755
|
*/
|
|
2722
2756
|
setModel(model: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2723
2757
|
/**
|
|
2724
|
-
* Merges
|
|
2758
|
+
* Merges arbitrary metadata into the session’s metadata object.
|
|
2759
|
+
* @param metadata - Key‑value pairs to merge.
|
|
2725
2760
|
*/
|
|
2726
2761
|
updateMetadata(metadata: Record<string, any>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2762
|
+
/**
|
|
2763
|
+
* Adds topics to the session (does not replace existing ones).
|
|
2764
|
+
* @param topics - Topics to add.
|
|
2765
|
+
*/
|
|
2727
2766
|
addTopics(topics: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2767
|
+
/**
|
|
2768
|
+
* Replaces the session’s preference list with the given IDs.
|
|
2769
|
+
* @param preferenceIds - Array of preference UUIDs.
|
|
2770
|
+
*/
|
|
2728
2771
|
setPreferences(preferenceIds: UUID[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2772
|
+
/**
|
|
2773
|
+
* Creates a new session as a fork of this one.
|
|
2774
|
+
* @param newSessionId - ID for the new session.
|
|
2775
|
+
* @param label - Label for the new session.
|
|
2776
|
+
* @param role - Optional role ID (defaults to current role).
|
|
2777
|
+
* @param topics - Optional topics (defaults to current topics).
|
|
2778
|
+
*/
|
|
2729
2779
|
fork(newSessionId: UUID, label: string, role?: string, topics?: string[]): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2780
|
+
/**
|
|
2781
|
+
* Dispatches a raw command to the workspace manager.
|
|
2782
|
+
* @param command - BaseCommand to dispatch.
|
|
2783
|
+
*/
|
|
2730
2784
|
dispatch(command: BaseCommand): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2785
|
+
/**
|
|
2786
|
+
* Switches the session to a different role.
|
|
2787
|
+
* @param newRole - ID of the new role (or EMPTY_SYSTEM_ROLE).
|
|
2788
|
+
*/
|
|
2731
2789
|
switchRole(newRole: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2790
|
+
/**
|
|
2791
|
+
* Adds a turn to the session. The turn’s parent, version, role, and model
|
|
2792
|
+
* are automatically filled if missing.
|
|
2793
|
+
* @param turn - The turn to add (may be incomplete).
|
|
2794
|
+
* @returns Result with the workspace patch and updates the in‑memory tree.
|
|
2795
|
+
*/
|
|
2732
2796
|
addTurn(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2797
|
+
/**
|
|
2798
|
+
* Records a user turn (alias for addTurn).
|
|
2799
|
+
* @param turn - The user turn.
|
|
2800
|
+
*/
|
|
2733
2801
|
recordUserTurn(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2802
|
+
/**
|
|
2803
|
+
* Records an assistant turn, processes any tool calls, and optionally records denial turns.
|
|
2804
|
+
* @param turn - The assistant turn (may contain tool calls).
|
|
2805
|
+
* @param recordDenial - If true, adds a user turn explaining denied tool calls.
|
|
2806
|
+
* @returns Result with the merged workspace patches.
|
|
2807
|
+
*/
|
|
2734
2808
|
recordAssistantTurn(turn: Turn, recordDenial?: boolean): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2735
2809
|
private buildDenialTurn;
|
|
2736
2810
|
private describeCommand;
|
|
2811
|
+
/**
|
|
2812
|
+
* Edits an existing turn, creating a new version. The session head is moved to this new version.
|
|
2813
|
+
* @param turnId - ID of the turn to edit.
|
|
2814
|
+
* @param newBlocks - New content blocks for the turn.
|
|
2815
|
+
* @param roleSnapshot - Optional role to associate (defaults to current active version's role).
|
|
2816
|
+
* @param modelSnapshot - Optional model to associate (defaults to current active version's model).
|
|
2817
|
+
*/
|
|
2737
2818
|
editTurn(turnId: UUID, newBlocks: ContentBlock[], roleSnapshot?: string, modelSnapshot?: string): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2819
|
+
/**
|
|
2820
|
+
* Adds a branch turn (a turn that shares a parent with an existing turn).
|
|
2821
|
+
* @param turn - The turn to branch (must have parent set).
|
|
2822
|
+
*/
|
|
2738
2823
|
branch(turn: Turn): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2824
|
+
/**
|
|
2825
|
+
* Deletes a specific version of a turn and optionally updates the session head.
|
|
2826
|
+
* @param turnId - ID of the turn.
|
|
2827
|
+
* @param version - Version number to delete.
|
|
2828
|
+
* @param newHead - New head reference after deletion (or null to keep current head if still valid).
|
|
2829
|
+
*/
|
|
2739
2830
|
deleteTurn(turnId: UUID, version: number, newHead: TurnRef | null): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2740
2831
|
/**
|
|
2741
|
-
* Updates the status of a specific turn
|
|
2832
|
+
* Updates the status (success/unsuccessful) of a specific turn version.
|
|
2833
|
+
* @param turnId - ID of the turn.
|
|
2834
|
+
* @param version - Version number of the turn to update.
|
|
2835
|
+
* @param status - Result indicating success or failure.
|
|
2836
|
+
*/
|
|
2837
|
+
updateTurnStatus(turnId: UUID, version: number, status: Result<undefined, WorkspaceError>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2838
|
+
/**
|
|
2839
|
+
* Switches to the previous version of a turn (if available).
|
|
2840
|
+
* @param turnId - ID of the turn.
|
|
2742
2841
|
*/
|
|
2743
|
-
updateTurnStatus(turnId: UUID, status: Result<undefined, WorkspaceError>): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2744
2842
|
switchVersionLeft(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2843
|
+
/**
|
|
2844
|
+
* Switches to the next version of a turn (if available).
|
|
2845
|
+
* @param turnId - ID of the turn.
|
|
2846
|
+
*/
|
|
2745
2847
|
switchVersionRight(turnId: UUID): Promise<Result<DeepPartial<Workspace>, WorkspaceError>>;
|
|
2746
2848
|
private switchVersion;
|
|
2747
2849
|
/**
|
|
2748
|
-
* Assembles a SessionSnapshot for PromptBuilder.
|
|
2749
|
-
*
|
|
2750
|
-
* If a UUID is provided,
|
|
2751
|
-
* If a Turn object is provided,
|
|
2752
|
-
*
|
|
2850
|
+
* Assembles a SessionSnapshot for the PromptBuilder.
|
|
2851
|
+
* @param target - Optional target:
|
|
2852
|
+
* - If a UUID is provided, snapshots history ending at that turn.
|
|
2853
|
+
* - If a Turn object is provided, snapshots a "potential" state where
|
|
2854
|
+
* this turn is appended to its parent (or current head) without committing it.
|
|
2753
2855
|
*/
|
|
2754
2856
|
snapshot(target?: UUID | Turn): Promise<SessionSnapshot | undefined>;
|
|
2857
|
+
/**
|
|
2858
|
+
* Rebuilds the in‑memory TurnTree.
|
|
2859
|
+
* @param headOverride - If provided, use this as the session head instead of reading from the store.
|
|
2860
|
+
* This avoids stale reads after mutations that change the head.
|
|
2861
|
+
*/
|
|
2755
2862
|
private refreshTurnTree;
|
|
2863
|
+
/**
|
|
2864
|
+
* Finds the deepest descendant (tip) of a given turn version.
|
|
2865
|
+
* Used when switching versions to determine the new session head.
|
|
2866
|
+
*/
|
|
2756
2867
|
private findSubtreeTip;
|
|
2757
2868
|
}
|
|
2758
2869
|
|
|
@@ -2865,7 +2976,7 @@ declare class TurnTree {
|
|
|
2865
2976
|
private readonly nodes;
|
|
2866
2977
|
private readonly _head;
|
|
2867
2978
|
private constructor();
|
|
2868
|
-
static build(sessionId: UUID, repository: TurnRepository): Promise<TurnTree>;
|
|
2979
|
+
static build(sessionId: UUID, repository: TurnRepository, headOverride?: TurnRef | null): Promise<TurnTree>;
|
|
2869
2980
|
head(): TurnRef | null;
|
|
2870
2981
|
chain(): TurnNode[];
|
|
2871
2982
|
/**
|