MCPcopy
hub / github.com/coder/mux / resolve

Function resolve

src/node/services/agentDefinitions/agentDefinitionsService.ts:472–508  ·  view source on GitHub ↗
(
    id: AgentId,
    depth: number,
    skipScopesAbove?: AgentDefinitionScope
  )

Source from the content-addressed store, hash-verified

470 }
471
472 async function resolve(
473 id: AgentId,
474 depth: number,
475 skipScopesAbove?: AgentDefinitionScope
476 ): Promise<string> {
477 if (depth > MAX_INHERITANCE_DEPTH) {
478 throw new Error(
479 `Agent inheritance depth exceeded for '${id}' (max: ${MAX_INHERITANCE_DEPTH})`
480 );
481 }
482
483 const pkg = await readAgentDefinition(runtime, workspacePath, id, {
484 roots: options?.roots,
485 skipScopesAbove,
486 });
487
488 const visitKey = agentVisitKey(pkg.id, pkg.scope);
489 if (visited.has(visitKey)) {
490 throw new Error(`Circular agent inheritance detected: ${pkg.id} (${pkg.scope})`);
491 }
492 visited.add(visitKey);
493
494 const baseId = pkg.frontmatter.base;
495 const shouldAppend = pkg.frontmatter.prompt?.append !== false;
496
497 if (!baseId || !shouldAppend) {
498 return pkg.body;
499 }
500
501 const baseBody = await resolve(
502 baseId,
503 depth + 1,
504 mergeSkipScopesAbove(skipScopesAbove, computeBaseSkipScope(baseId, id, pkg.scope))
505 );
506 const separator = baseBody.trim() && pkg.body.trim() ? "\n\n" : "";
507 return `${baseBody}${separator}${pkg.body}`;
508 }
509
510 return resolve(agentId, 0, options?.skipScopesAbove);
511}

Callers 15

resolveAgentBodyFunction · 0.70
resolveAgentFrontmatterFunction · 0.70
finishFunction · 0.50
finishFunction · 0.50
finishMethod · 0.50
closeServerFunction · 0.50
listenOnUnixSocketFunction · 0.50
listenUpstreamServerFunction · 0.50
listenUpgradeServerFunction · 0.50
onOpenFunction · 0.50

Calls 8

readAgentDefinitionFunction · 0.85
agentVisitKeyFunction · 0.85
mergeSkipScopesAboveFunction · 0.85
computeBaseSkipScopeFunction · 0.85
addMethod · 0.80
formatZodIssuesFunction · 0.70
hasMethod · 0.45

Tested by 15

closeServerFunction · 0.40
listenOnUnixSocketFunction · 0.40
listenUpstreamServerFunction · 0.40
listenUpgradeServerFunction · 0.40
onOpenFunction · 0.40
closeClientWebSocketFunction · 0.40
onMessageFunction · 0.40
listenTcpServerFunction · 0.40
closeTcpServerFunction · 0.40
listenUpgradeServerFunction · 0.40
onOpenFunction · 0.40
onCloseFunction · 0.40