MCPcopy Create free account
hub / github.com/agentrpc/agentrpc / createAndPollJob

Function createAndPollJob

sdk-node/src/polling.ts:309–343  ·  view source on GitHub ↗
(
  client: ReturnType<typeof createApiClient>,
  clusterId: string,
  toolName: string,
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  input: any,
)

Source from the content-addressed store, hash-verified

307};
308
309export const createAndPollJob = async (
310 client: ReturnType<typeof createApiClient>,
311 clusterId: string,
312 toolName: string,
313 // eslint-disable-next-line @typescript-eslint/no-explicit-any
314 input: any,
315): Promise<{
316 status: string;
317 result: string;
318 resultType: string;
319}> => {
320 const createResult = await client.createJob({
321 body: {
322 tool: toolName,
323 input,
324 },
325 params: { clusterId },
326 query: {
327 waitTime: 20,
328 },
329 });
330
331 if (createResult.status !== 200) {
332 throw new AgentRPCError(`Failed to run tool: ${createResult.status}`);
333 }
334
335 return pollForJobCompletion(
336 client,
337 clusterId,
338 createResult.body.id,
339 createResult.body.status,
340 createResult.body.result || "",
341 createResult.body.resultType || "rejection",
342 );
343};

Callers 3

mainFunction · 0.90
AgentRPCClass · 0.90
polling.test.tsFile · 0.90

Calls 1

pollForJobCompletionFunction · 0.85

Tested by

no test coverage detected