(
request: CreateStableSessionRequest,
initialBoundary?: ExecutionBoundary,
)
| 438 | } |
| 439 | |
| 440 | async createStableSession( |
| 441 | request: CreateStableSessionRequest, |
| 442 | initialBoundary?: ExecutionBoundary, |
| 443 | ): Promise<CreateStableSessionResult> { |
| 444 | await this.ensureReady(); |
| 445 | if ( |
| 446 | request.input.conversationCopy && |
| 447 | request.input.conversationCopy.requestFingerprint !== request.requestFingerprint |
| 448 | ) { |
| 449 | throw new Error('Conversation copy fingerprint does not match the stable create request'); |
| 450 | } |
| 451 | if (request.input.subagentSpawn) { |
| 452 | throw new Error('Subagent spawn metadata requires createSubagent()'); |
| 453 | } |
| 454 | const probe = await this.metadata.claimStableSessionCreate( |
| 455 | request.sessionId, |
| 456 | request.requestFingerprint, |
| 457 | ); |
| 458 | if (probe.kind === 'existing') { |
| 459 | return { kind: 'existing', record: projectHeaderSnapshot(probe.record) }; |
| 460 | } |
| 461 | if (probe.kind === 'conflict') return probe; |
| 462 | |
| 463 | const result = await this.metadata.createStableSession( |
| 464 | buildSessionHeader( |
| 465 | this.workspaceRoot, |
| 466 | request.input, |
| 467 | request.sessionId, |
| 468 | request.input.conversationCopy, |
| 469 | ), |
| 470 | request.requestFingerprint, |
| 471 | initialBoundary, |
| 472 | ); |
| 473 | return result.kind === 'created' || result.kind === 'existing' |
| 474 | ? { kind: result.kind, record: projectHeaderSnapshot(result.record) } |
| 475 | : result; |
| 476 | } |
| 477 | |
| 478 | async discardStableConversationCopy( |
| 479 | sessionId: string, |
nothing calls this directly
no test coverage detected