MCPcopy Index your code
hub / github.com/codeaashu/claude-code / resolvePermission

Function resolvePermission

src/utils/swarm/permissionSync.ts:360–443  ·  view source on GitHub ↗
(
  requestId: string,
  resolution: PermissionResolution,
  teamName?: string,
)

Source from the content-addressed store, hash-verified

358 * Writes the resolution to resolved/, removes from pending/
359 */
360export async function resolvePermission(
361 requestId: string,
362 resolution: PermissionResolution,
363 teamName?: string,
364): Promise<boolean> {
365 const team = teamName || getTeamName()
366 if (!team) {
367 logForDebugging('[PermissionSync] No team name available')
368 return false
369 }
370
371 await ensurePermissionDirsAsync(team)
372
373 const pendingPath = getPendingRequestPath(team, requestId)
374 const resolvedPath = getResolvedRequestPath(team, requestId)
375 const lockFilePath = join(getPendingDir(team), '.lock')
376
377 await writeFile(lockFilePath, '', 'utf-8')
378
379 let release: (() => Promise<void>) | undefined
380 try {
381 release = await lockfile.lock(lockFilePath)
382
383 // Read the pending request
384 let content: string
385 try {
386 content = await readFile(pendingPath, 'utf-8')
387 } catch (e: unknown) {
388 const code = getErrnoCode(e)
389 if (code === 'ENOENT') {
390 logForDebugging(
391 `[PermissionSync] Pending request not found: ${requestId}`,
392 )
393 return false
394 }
395 throw e
396 }
397
398 const parsed = SwarmPermissionRequestSchema().safeParse(jsonParse(content))
399 if (!parsed.success) {
400 logForDebugging(
401 `[PermissionSync] Invalid pending request ${requestId}: ${parsed.error.message}`,
402 )
403 return false
404 }
405
406 const request = parsed.data
407
408 // Update the request with resolution data
409 const resolvedRequest: SwarmPermissionRequest = {
410 ...request,
411 status: resolution.decision === 'approved' ? 'approved' : 'rejected',
412 resolvedBy: resolution.resolvedBy,
413 resolvedAt: Date.now(),
414 feedback: resolution.feedback,
415 updatedInput: resolution.updatedInput,
416 permissionUpdates: resolution.permissionUpdates,
417 }

Callers

nothing calls this directly

Calls 13

getTeamNameFunction · 0.85
logForDebuggingFunction · 0.85
getPendingRequestPathFunction · 0.85
getResolvedRequestPathFunction · 0.85
getPendingDirFunction · 0.85
readFileFunction · 0.85
getErrnoCodeFunction · 0.85
jsonParseFunction · 0.85
jsonStringifyFunction · 0.85
unlinkFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected