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

Function listRemoteAgentMetadata

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 6

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

Tested by

no test coverage detected