MCPcopy Create free account
hub / github.com/apache/maka / createImportedSession

Method createImportedSession

packages/storage/src/session-store.ts:403–428  ·  view source on GitHub ↗
(
    input: CreateSessionInput,
    messages: readonly StoredMessage[],
  )

Source from the content-addressed store, hash-verified

401 }
402
403 async createImportedSession(
404 input: CreateSessionInput,
405 messages: readonly StoredMessage[],
406 ): Promise<SessionHeader> {
407 await this.ensureReady();
408 assertNoConversationCopyMetadata(input);
409 if (input.subagentSpawn) {
410 throw new Error('Subagent spawn metadata requires createSubagent()');
411 }
412 const canonicalMessages = messages.map((message) =>
413 decodeStoredMessage(JSON.parse(JSON.stringify(message)) as unknown),
414 );
415 const header: SessionHeader = {
416 ...buildSessionHeader(this.workspaceRoot, input),
417 transcriptLedgerVersion: 0,
418 };
419 const outcome = await this.metadata.importSession(
420 header,
421 canonicalMessages,
422 projectSessionCatalogMessages(canonicalMessages),
423 );
424 if (outcome !== 'imported') {
425 throw new Error(`Generated Session id already exists: ${header.id}`);
426 }
427 return (await this.metadata.read(header.id)).header;
428 }
429
430 async probeStableSessionCreate(
431 sessionId: string,

Callers

nothing calls this directly

Calls 7

ensureReadyMethod · 0.95
decodeStoredMessageFunction · 0.90
buildSessionHeaderFunction · 0.85
readMethod · 0.65
importSessionMethod · 0.45

Tested by

no test coverage detected