MCPcopy Create free account
hub / github.com/cursor/plugins / findActiveRootPlanner

Function findActiveRootPlanner

orchestrate/skills/orchestrate/scripts/cli/task.ts:478–508  ·  view source on GitHub ↗
(
  agentApi: AgentListApi,
  rootSlug: string,
  nowMs: number = Date.now()
)

Source from the content-addressed store, hash-verified

476}
477
478export async function findActiveRootPlanner(
479 agentApi: AgentListApi,
480 rootSlug: string,
481 nowMs: number = Date.now()
482): Promise<ActiveRootPlanner | null> {
483 const list = await agentApi.list({ runtime: "cloud", limit: 50 });
484 // Exact match, not startsWith: a prefix slug would otherwise adopt another
485 // goal's `<slug>-root` planner (e.g. "auth" adopting "auth-ui-root").
486 const rootPlannerName = `${rootSlug}-root`;
487 for (const item of listItems(list)) {
488 const name = stringField(item, "name");
489 if (!name) continue;
490 if (name !== rootPlannerName) continue;
491 const createdAt = timeMs(field(item, "createdAt"));
492 if (createdAt === null || nowMs - createdAt > MAX_BOOT_MS) continue;
493 const agentId =
494 stringField(item, "agentId") ?? stringField(item, "id") ?? null;
495 if (!agentId) continue;
496 const embeddedRun = latestRunFromItem(item);
497 const run = embeddedRun ?? (await latestRunForAgent(agentApi, agentId));
498 const status = runStatus(run);
499 if (!ACTIVE_ROOT_RUN_STATUSES.has(status)) continue;
500 return {
501 agentId,
502 runId: stringField(run, "id") ?? null,
503 status,
504 name,
505 };
506 }
507 return null;
508}
509
510export function inferKickoffRootSlug(goal: string): string {
511 const firstLine = goal.split("\n")[0]?.trim() ?? "";

Callers 2

registerTaskCommandsFunction · 0.85

Calls 7

listItemsFunction · 0.85
timeMsFunction · 0.85
fieldFunction · 0.85
latestRunFromItemFunction · 0.85
latestRunForAgentFunction · 0.85
runStatusFunction · 0.85
stringFieldFunction · 0.70

Tested by

no test coverage detected