MCPcopy Create free account
hub / github.com/codeaashu/claude-code / readPendingPermissions

Function readPendingPermissions

src/utils/swarm/permissionSync.ts:256–312  ·  view source on GitHub ↗
(
  teamName?: string,
)

Source from the content-addressed store, hash-verified

254 * Called by the team leader to see what requests need attention
255 */
256export async function readPendingPermissions(
257 teamName?: string,
258): Promise<SwarmPermissionRequest[]> {
259 const team = teamName || getTeamName()
260 if (!team) {
261 logForDebugging('[PermissionSync] No team name available')
262 return []
263 }
264
265 const pendingDir = getPendingDir(team)
266
267 let files: string[]
268 try {
269 files = await readdir(pendingDir)
270 } catch (e: unknown) {
271 const code = getErrnoCode(e)
272 if (code === 'ENOENT') {
273 return []
274 }
275 logForDebugging(`[PermissionSync] Failed to read pending requests: ${e}`)
276 logError(e)
277 return []
278 }
279
280 const jsonFiles = files.filter(f => f.endsWith('.json') && f !== '.lock')
281
282 const results = await Promise.all(
283 jsonFiles.map(async file => {
284 const filePath = join(pendingDir, file)
285 try {
286 const content = await readFile(filePath, 'utf-8')
287 const parsed = SwarmPermissionRequestSchema().safeParse(
288 jsonParse(content),
289 )
290 if (parsed.success) {
291 return parsed.data
292 }
293 logForDebugging(
294 `[PermissionSync] Invalid request file ${file}: ${parsed.error.message}`,
295 )
296 return null
297 } catch (err) {
298 logForDebugging(
299 `[PermissionSync] Failed to read request file ${file}: ${err}`,
300 )
301 return null
302 }
303 }),
304 )
305
306 const requests = results.filter(r => r !== null)
307
308 // Sort by creation time (oldest first)
309 requests.sort((a, b) => a.createdAt - b.createdAt)
310
311 return requests
312}
313

Callers

nothing calls this directly

Calls 8

getTeamNameFunction · 0.85
logForDebuggingFunction · 0.85
getPendingDirFunction · 0.85
readdirFunction · 0.85
getErrnoCodeFunction · 0.85
readFileFunction · 0.85
jsonParseFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected