MCPcopy Create free account
hub / github.com/backnotprop/plannotator / forkSession

Method forkSession

packages/ai/providers/opencode-sdk.ts:158–182  ·  view source on GitHub ↗
(options: CreateSessionOptions)

Source from the content-addressed store, hash-verified

156 }
157
158 async forkSession(options: CreateSessionOptions): Promise<AISession> {
159 await this.ensureServer();
160 const client = this.getClient();
161
162 const parentId = options.context.parent?.sessionId;
163 if (!parentId) {
164 throw new Error("Fork requires a parent session ID.");
165 }
166
167 const result = await client.session.fork({
168 path: { id: parentId },
169 });
170 const sessionData = result.data;
171 if (!sessionData) {
172 throw new Error("OpenCode did not return forked session data.");
173 }
174
175 return new OpenCodeSession({
176 sessionId: sessionData.id,
177 systemPrompt: buildSystemPrompt(options.context),
178 client,
179 model: options.model,
180 parentSessionId: parentId,
181 });
182 }
183
184 async resumeSession(sessionId: string): Promise<AISession> {
185 await this.ensureServer();

Callers

nothing calls this directly

Calls 3

ensureServerMethod · 0.95
getClientMethod · 0.95
buildSystemPromptFunction · 0.90

Tested by

no test coverage detected