(options: CreateSessionOptions)
| 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(); |
nothing calls this directly
no test coverage detected