(input: ForkSessionPayload)
| 478 | } |
| 479 | |
| 480 | async forkSession(input: ForkSessionPayload): Promise<ResumeSessionResult> { |
| 481 | const source = await this.sessionStore.get(input.sessionId); |
| 482 | const active = this.sessions.get(source.id); |
| 483 | if (active?.hasActiveTurn === true) { |
| 484 | throw new KimiError( |
| 485 | ErrorCodes.SESSION_FORK_ACTIVE_TURN, |
| 486 | `Session "${source.id}" cannot be forked while a turn is running`, |
| 487 | { details: { sessionId: source.id } }, |
| 488 | ); |
| 489 | } |
| 490 | |
| 491 | if (active !== undefined) { |
| 492 | await active.flushMetadata(); |
| 493 | } |
| 494 | |
| 495 | const id = input.id ?? createSessionId(); |
| 496 | await this.sessionStore.fork({ |
| 497 | sourceId: source.id, |
| 498 | targetId: id, |
| 499 | title: input.title, |
| 500 | metadata: input.metadata, |
| 501 | }); |
| 502 | return this.resumeSession({ sessionId: id }); |
| 503 | } |
| 504 | |
| 505 | async listSessions(input: ListSessionsPayload = {}): Promise<readonly SessionSummary[]> { |
| 506 | return this.sessionStore.list(input); |
nothing calls this directly
no test coverage detected