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

Function updateBridgeSessionTitle

src/bridge/createSession.ts:312–354  ·  view source on GitHub ↗
(
  sessionId: string,
  title: string,
  opts?: { baseUrl?: string; getAccessToken?: () => string | undefined },
)

Source from the content-addressed store, hash-verified

310 * Errors are swallowed — title sync is best-effort.
311 */
312export async function updateBridgeSessionTitle(
313 sessionId: string,
314 title: string,
315 opts?: { baseUrl?: string; getAccessToken?: () => string | undefined },
316): Promise<void> {
317 const { default: axios } = await import('axios')
318
319 const headers = await resolveBridgeSessionHeaders({
320 accessTokenOverride: opts?.getAccessToken?.(),
321 operation: 'session title update',
322 })
323 if (!headers) {
324 return
325 }
326
327 // Compat gateway only accepts session_* (compat/convert.go:27). v2 callers
328 // pass raw cse_*; retag here so all callers can pass whatever they hold.
329 // Idempotent for v1's session_* and bridgeMain's pre-converted compatSessionId.
330 const compatId = toCompatSessionId(sessionId)
331 const url = `${opts?.baseUrl ?? getNoumenaPlatformBaseUrl()}/v1/sessions/${compatId}`
332 logForDebugging(`[bridge] Updating session title: ${compatId} → ${title}`)
333
334 try {
335 const response = await axios.patch(
336 url,
337 { title },
338 { headers, timeout: 10_000, validateStatus: s => s < 500 },
339 )
340
341 if (response.status === 200) {
342 logForDebugging(`[bridge] Session title updated successfully`)
343 } else {
344 const detail = extractErrorDetail(response.data)
345 logForDebugging(
346 `[bridge] Session title update failed with status ${response.status}${detail ? `: ${detail}` : ''}`,
347 )
348 }
349 } catch (err: unknown) {
350 logForDebugging(
351 `[bridge] Session title update request failed: ${errorMessage(err)}`,
352 )
353 }
354}

Callers 4

patchFunction · 0.85
runBridgeLoopFunction · 0.85
callFunction · 0.85

Calls 6

toCompatSessionIdFunction · 0.85
extractErrorDetailFunction · 0.85
logForDebuggingFunction · 0.50
errorMessageFunction · 0.50

Tested by

no test coverage detected