MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / forkSession

Method forkSession

packages/agent-core/src/rpc/core-impl.ts:480–503  ·  view source on GitHub ↗
(input: ForkSessionPayload)

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 5

resumeSessionMethod · 0.95
createSessionIdFunction · 0.85
flushMetadataMethod · 0.80
getMethod · 0.65
forkMethod · 0.65

Tested by

no test coverage detected