MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / buildFunctionNodeDef

Function buildFunctionNodeDef

ts/workflow-core/src/node/FunctionNode.ts:43–79  ·  view source on GitHub ↗
(
  fn: FunctionInfo,
  t: (key: string, params?: Record<string, unknown>) => string = (key) => key,
)

Source from the content-addressed store, hash-verified

41 * translator is supplied; validation logic ignores description strings.
42 */
43export function buildFunctionNodeDef(
44 fn: FunctionInfo,
45 t: (key: string, params?: Record<string, unknown>) => string = (key) => key,
46): FunctionNodeDefinition {
47 return {
48 type: "FunctionCall",
49 functionInfo: fn,
50 label: fn.name,
51 category: NodeCategory.Function,
52 description: t("builder.functionCallDesc", { name: fn.name }),
53 parameters: [
54 ...fn.arguments.map((param) => ({
55 id: paramKey(param),
56 label: param.name,
57 description: t("builder.functionParamDesc", { name: param.name }),
58 type: "expression" as const,
59 expressionType: param.dataType as DataType,
60 default: { expression: "", references: [], dataType: param.dataType as DataType },
61 activationRules: [{ type: "isControlFlow" as const }],
62 })),
63 {
64 id: "toolDescription",
65 label: "Tool Description",
66 description: "Description shown to the agent when this function is wired as a tool",
67 type: "string" as const,
68 multiline: true,
69 activationRules: [{ type: "isToolInput" as const }],
70 },
71 ],
72 outputs: fn.returns.map((ret) => ({
73 id: paramKey(ret),
74 label: ret.name,
75 type: "static" as const,
76 dataType: ret.dataType as DataType,
77 })),
78 };
79}

Callers 2

useNodeDefinitionsFunction · 0.90
validateWorkflowStateFunction · 0.90

Calls 1

paramKeyFunction · 0.90

Tested by

no test coverage detected