MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / SessionStore

Interface SessionStore

packages/opencode-atomic-hooks/src/session.ts:83–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 * method is pure with respect to the store instance — no global state.
82 */
83export interface SessionStore {
84 /**
85 * Get the session state for `id`, creating it if it doesn't exist.
86 *
87 * This is the primary access method. Callers never need to check
88 * existence before reading — `get` always returns a valid state.
89 */
90 get(id: string): SessionState
91
92 /**
93 * Check whether a session exists without creating it.
94 */
95 has(id: string): boolean
96
97 /**
98 * Remove a session from the store. No-op if it doesn't exist.
99 */
100 remove(id: string): void
101
102 /**
103 * Increment the turn count for a session.
104 *
105 * Called on `session.idle` events. Creates the session if needed.
106 *
107 * @returns The new turn count after incrementing
108 */
109 incrementTurn(id: string): number
110
111 /**
112 * Update the model and provider for a session.
113 *
114 * Called from the `chat.message` hook when model info is available.
115 * Only updates fields that are non-empty — passing `undefined`
116 * preserves the existing value.
117 *
118 * @param id - Session ID
119 * @param provider - Provider identifier (e.g., "anthropic")
120 * @param model - Model identifier (e.g., "claude-sonnet-4-20250514")
121 */
122 setModel(id: string, provider?: string, model?: string): void
123
124 /**
125 * Store the most recent user prompt for a session.
126 *
127 * Called from the `chat.message` hook. Only updates if `prompt`
128 * is a non-empty string.
129 */
130 setPrompt(id: string, prompt: string): void
131
132 /**
133 * Record the start time of a tool invocation for duration tracking.
134 *
135 * @param id - Session ID
136 * @param callId - Unique tool call identifier
137 * @param now - Optional timestamp override for testing
138 */
139 startTool(id: string, callId: string, now?: number): void
140

Callers 43

list_stashesMethod · 0.65
fetch_latestFunction · 0.65
varMethod · 0.65
resolve_workspaceFunction · 0.65
load_attestationFunction · 0.65
print_activity_chainFunction · 0.65
clean_up_local_configFunction · 0.65
walkFunction · 0.65
ensureFunction · 0.65
AtomicHooksPluginFunction · 0.65
hasFunction · 0.65

Calls

no outgoing calls

Tested by

no test coverage detected