MCPcopy
hub / github.com/continuedev/continue / resolveBlock

Function resolveBlock

packages/config-yaml/src/load/unroll.ts:719–766  ·  view source on GitHub ↗
(
  id: PackageIdentifier,
  inputs: Record<string, string | undefined> | undefined,
  registry: Registry,
)

Source from the content-addressed store, hash-verified

717}
718
719export async function resolveBlock(
720 id: PackageIdentifier,
721 inputs: Record<string, string | undefined> | undefined,
722 registry: Registry,
723): Promise<AssistantUnrolled> {
724 // Retrieve block raw yaml
725 const rawYaml = await registry.getContent(id);
726
727 if (rawYaml === undefined) {
728 throw new Error(`Block ${packageIdentifierToShorthandSlug(id)} not found`);
729 }
730
731 // Convert any input secrets to FQSNs (they get FQSNs as if they are in the block. This is so that we know when to use models add-on / free trial secrets)
732 const renderedInputs = inputsToFQSNs(inputs || {}, id);
733
734 // Render template variables
735 const templatedYaml = renderTemplateData(rawYaml, {
736 inputs: renderedInputs,
737 secrets: extractFQSNMap(rawYaml, [id]),
738 });
739
740 // Check for unresolved input template variables (missing required inputs)
741 const unresolvedInputs = getTemplateVariables(templatedYaml).filter((v) =>
742 v.startsWith("inputs."),
743 );
744 if (unresolvedInputs.length > 0) {
745 const missingInputNames = unresolvedInputs.map((v) =>
746 v.replace("inputs.", ""),
747 );
748 const blockName = packageIdentifierToShorthandSlug(id);
749 throw new Error(
750 `Missing required input(s) for block "${blockName}": ${missingInputNames.join(", ")}. ` +
751 `Please provide these values in the "with" block.`,
752 );
753 }
754
755 // Add source slug for mcp servers
756 const parsed = parseMarkdownRuleOrAssistantUnrolled(templatedYaml, id);
757 if (
758 id.uriType === "slug" &&
759 "mcpServers" in parsed &&
760 parsed.mcpServers?.[0]
761 ) {
762 parsed.mcpServers[0].sourceSlug = `${id.fullSlug.ownerSlug}/${id.fullSlug.packageSlug}`;
763 }
764
765 return parsed;
766}
767
768export function parseMarkdownRuleOrAssistantUnrolled(
769 content: string,

Callers 1

unrollBlocksFunction · 0.85

Calls 8

inputsToFQSNsFunction · 0.85
renderTemplateDataFunction · 0.85
extractFQSNMapFunction · 0.85
getTemplateVariablesFunction · 0.85
getContentMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected