MCPcopy Index your code
hub / github.com/callstack/agent-device / resolveRequestExecutionLockKeys

Function resolveRequestExecutionLockKeys

src/daemon/request-binding.ts:14–38  ·  view source on GitHub ↗
(params: {
  req: DaemonRequest;
  sessionName: string;
  sessionStore: SessionStore;
})

Source from the content-addressed store, hash-verified

12};
13
14export async function resolveRequestExecutionLockKeys(params: {
15 req: DaemonRequest;
16 sessionName: string;
17 sessionStore: SessionStore;
18}): Promise<RequestExecutionLockKey[]> {
19 const { req, sessionName, sessionStore } = params;
20 const existingSession = sessionStore.get(sessionName);
21 if (existingSession) {
22 return [deviceExecutionLockKey(existingSession.device.id)];
23 }
24
25 const keys = new Set<RequestExecutionLockKey>([sessionExecutionLockKey(sessionName)]);
26 const bindingReq = resolveFreshSessionBindingRequest(req);
27 if (shouldResolveFreshSessionDeviceLock(bindingReq)) {
28 try {
29 // This is advisory lock selection before the request enters the lock; the
30 // locked request still resolves and binds the target device authoritatively.
31 const device = await resolveTargetDevice(bindingReq.flags ?? {});
32 keys.add(deviceExecutionLockKey(device.id));
33 } catch {
34 // Fall back to session scoping when device resolution is not yet available.
35 }
36 }
37 return orderRequestExecutionLockKeys(keys);
38}
39
40export function prepareLockedRequestBinding(params: {
41 req: DaemonRequest;

Callers 1

Calls 7

resolveTargetDeviceFunction · 0.90
deviceExecutionLockKeyFunction · 0.85
sessionExecutionLockKeyFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected