MCPcopy Index your code
hub / github.com/freecodexyz/free-code / persistToRemote

Method persistToRemote

src/utils/sessionStorage.ts:1302–1343  ·  view source on GitHub ↗
(sessionId: UUID, entry: TranscriptMessage)

Source from the content-addressed store, hash-verified

1300 }
1301
1302 private async persistToRemote(sessionId: UUID, entry: TranscriptMessage) {
1303 if (isShuttingDown()) {
1304 return
1305 }
1306
1307 // CCR v2 path: write as internal worker event
1308 if (this.internalEventWriter) {
1309 try {
1310 await this.internalEventWriter(
1311 'transcript',
1312 entry as unknown as Record<string, unknown>,
1313 {
1314 ...(isCompactBoundaryMessage(entry) && { isCompaction: true }),
1315 ...(entry.agentId && { agentId: entry.agentId }),
1316 },
1317 )
1318 } catch {
1319 logEvent('tengu_session_persistence_failed', {})
1320 logForDebugging('Failed to write transcript as internal event')
1321 }
1322 return
1323 }
1324
1325 // v1 Session Ingress path
1326 if (
1327 !isEnvTruthy(process.env.ENABLE_SESSION_PERSISTENCE) ||
1328 !this.remoteIngressUrl
1329 ) {
1330 return
1331 }
1332
1333 const success = await sessionIngress.appendSessionLog(
1334 sessionId,
1335 entry,
1336 this.remoteIngressUrl,
1337 )
1338
1339 if (!success) {
1340 logEvent('tengu_session_persistence_failed', {})
1341 gracefulShutdownSync(1, 'other')
1342 }
1343 }
1344
1345 setRemoteIngressUrl(url: string): void {
1346 this.remoteIngressUrl = url

Callers 1

appendEntryMethod · 0.95

Calls 6

isShuttingDownFunction · 0.85
isCompactBoundaryMessageFunction · 0.85
logEventFunction · 0.85
logForDebuggingFunction · 0.85
isEnvTruthyFunction · 0.85
gracefulShutdownSyncFunction · 0.85

Tested by

no test coverage detected