MCPcopy
hub / github.com/codeaashu/claude-code / listRemoteAgentMetadata

Function listRemoteAgentMetadata

src/utils/sessionStorage.ts:373–399  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

371 * Used by restoreRemoteAgentTasks to reconnect to still-running CCR sessions.
372 */
373export async function listRemoteAgentMetadata(): Promise<
374 RemoteAgentMetadata[]
375> {
376 const dir = getRemoteAgentsDir()
377 let entries: Dirent[]
378 try {
379 entries = await readdir(dir, { withFileTypes: true })
380 } catch (e) {
381 if (isFsInaccessible(e)) return []
382 throw e
383 }
384 const results: RemoteAgentMetadata[] = []
385 for (const entry of entries) {
386 if (!entry.isFile() || !entry.name.endsWith('.meta.json')) continue
387 try {
388 const raw = await readFile(join(dir, entry.name), 'utf-8')
389 results.push(JSON.parse(raw) as RemoteAgentMetadata)
390 } catch (e) {
391 // Skip unreadable or corrupt files — a partial write from a crashed
392 // fire-and-forget persist shouldn't take down the whole restore.
393 logForDebugging(
394 `listRemoteAgentMetadata: skipping ${entry.name}: ${String(e)}`,
395 )
396 }
397 }
398 return results
399}
400
401export function sessionIdExists(sessionId: string): boolean {
402 const projectDir = getProjectDir(getOriginalCwd())

Callers 1

Calls 7

getRemoteAgentsDirFunction · 0.85
readdirFunction · 0.85
isFsInaccessibleFunction · 0.85
readFileFunction · 0.85
logForDebuggingFunction · 0.85
pushMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected