MCPcopy Create free account
hub / github.com/Noumena-Network/code / persistToRemote

Method persistToRemote

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

Source from the content-addressed store, hash-verified

1382 }
1383
1384 private async persistToRemote(sessionId: UUID, entry: TranscriptMessage) {
1385 if (isShuttingDown()) {
1386 return
1387 }
1388
1389 // CCR v2 path: write as internal worker event
1390 if (this.internalEventWriter) {
1391 try {
1392 await this.internalEventWriter(
1393 'transcript',
1394 entry as unknown as Record<string, unknown>,
1395 {
1396 ...(isCompactBoundaryMessage(entry) && { isCompaction: true }),
1397 ...(entry.agentId && { agentId: entry.agentId }),
1398 },
1399 )
1400 } catch {
1401 logEvent('ncode_session_persistence_failed', {})
1402 logForDebugging('Failed to write transcript as internal event')
1403 }
1404 return
1405 }
1406
1407 // v1 Session Ingress path
1408 if (
1409 !isEnvTruthy(process.env.ENABLE_SESSION_PERSISTENCE) ||
1410 !this.remoteIngressUrl
1411 ) {
1412 return
1413 }
1414
1415 const success = await sessionIngress.appendSessionLog(
1416 sessionId,
1417 entry,
1418 this.remoteIngressUrl,
1419 )
1420
1421 if (!success) {
1422 logEvent('ncode_session_persistence_failed', {})
1423 gracefulShutdownSync(1, 'other')
1424 }
1425 }
1426
1427 setRemoteIngressUrl(url: string): void {
1428 this.remoteIngressUrl = url

Callers 1

appendEntryMethod · 0.95

Calls 6

isEnvTruthyFunction · 0.90
isShuttingDownFunction · 0.85
gracefulShutdownSyncFunction · 0.85
isCompactBoundaryMessageFunction · 0.70
logForDebuggingFunction · 0.70
logEventFunction · 0.50

Tested by

no test coverage detected