| 493 | } |
| 494 | |
| 495 | recordHistoryCompactCheckpoint(checkpoint: HistoryCompactCheckpoint): Promise<void> { |
| 496 | if (!this.input.runStore) return Promise.reject(new Error('AgentRun store is not configured')); |
| 497 | if (!this.runStoreAvailable) return Promise.reject(new Error('AgentRun store is unavailable')); |
| 498 | return this.enqueueRunStore( |
| 499 | 'append history compact checkpoint', |
| 500 | async () => { |
| 501 | await this.input.runStore?.appendEvent(this.sessionId, this.runId, { |
| 502 | type: 'history_compact_checkpoint_recorded', |
| 503 | id: this.input.newId(), |
| 504 | runId: this.runId, |
| 505 | sessionId: this.sessionId, |
| 506 | turnId: this.turnId, |
| 507 | ts: this.input.now(), |
| 508 | data: { |
| 509 | checkpointId: checkpoint.checkpointId, |
| 510 | highWaterName: checkpoint.highWaterName, |
| 511 | highWaterSeq: checkpoint.highWaterSeq, |
| 512 | boundaryKind: 'historyCompact', |
| 513 | checkpoint, |
| 514 | }, |
| 515 | }); |
| 516 | }, |
| 517 | { rethrow: true }, |
| 518 | ); |
| 519 | } |
| 520 | |
| 521 | /** |
| 522 | * Durable read of this run's RuntimeEvent ledger for the mid-turn capacity |