fix: fix projection to TS when fetching agnet in MCP

This commit is contained in:
Abhishek Kumar 2026-05-23 14:45:50 +05:30
parent 3892b58486
commit bbb4f91a27
12 changed files with 392 additions and 63 deletions

View file

@ -25,8 +25,19 @@ import type {
WireNode,
} from "./types.ts";
export function parseCode(code: string, specs: NodeSpec[]): ParseResult {
export function parseCode(
code: string,
specs: NodeSpec[],
edgeFieldNames: string[] = [
"label",
"condition",
"transition_speech",
"transition_speech_type",
"transition_speech_recording_id",
],
): ParseResult {
const specByName = new Map(specs.map((s) => [s.name, s]));
const allowedEdgeFieldNames = new Set(edgeFieldNames);
const sourceFile = ts.createSourceFile(
"workflow.ts",
code,
@ -335,6 +346,12 @@ export function parseCode(code: string, specs: NodeSpec[]): ParseResult {
addError(stmt, "`edge` requires a non-empty `condition` string.");
return;
}
for (const key of Object.keys(optsObj)) {
if (!allowedEdgeFieldNames.has(key)) {
addError(stmt, `Unknown edge field: \`${key}\`.`);
return;
}
}
edges.push({
id: `${src.id}-${tgt.id}`,
source: src.id,