MCPcopy Create free account
hub / github.com/apache/maka / withInvocationQueue

Function withInvocationQueue

packages/runtime/src/computer-use-tools.ts:1241–1263  ·  view source on GitHub ↗
(
    sessionId: string,
    signal: AbortSignal,
    operation: () => Promise<T>,
  )

Source from the content-addressed store, hash-verified

1239 }
1240
1241 async function withInvocationQueue<T>(
1242 sessionId: string,
1243 signal: AbortSignal,
1244 operation: () => Promise<T>,
1245 ): Promise<T> {
1246 const previous = invocationQueues.get(sessionId) ?? Promise.resolve();
1247 let release!: () => void;
1248 const gate = new Promise<void>((resolve) => {
1249 release = resolve;
1250 });
1251 const current = previous.then(() => gate);
1252 invocationQueues.set(sessionId, current);
1253 await previous;
1254 try {
1255 if (signal.aborted) throw new Error('aborted');
1256 return await operation();
1257 } finally {
1258 release();
1259 if (invocationQueues.get(sessionId) === current) {
1260 invocationQueues.delete(sessionId);
1261 }
1262 }
1263 }
1264
1265 function presentationScreenPoint(boundAction: CuaBoundAction | undefined): CuPoint | undefined {
1266 // An element action is aimed at an element, not at a coordinate, so it

Callers 1

buildComputerUseToolsFunction · 0.85

Calls 5

getMethod · 0.65
resolveMethod · 0.65
setMethod · 0.65
deleteMethod · 0.65
releaseFunction · 0.50

Tested by

no test coverage detected