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

Function addFunction

ts/workflow-builder/src/utils/functionOperations.ts:56–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54
55/** Create a new (empty) function + its body canvas. Returns the new definition. */
56export function addFunction(): FunctionDeclaration {
57 const id = generateId();
58 const existing = Object.values(useEditorStore.getState().functions).map((f) => f.name);
59 const fn: FunctionDeclaration = {
60 id,
61 version: 1,
62 name: uniqueName("function", existing),
63 arguments: [],
64 outputs: [],
65 };
66 useEditorStore.getState().setFunctions((fns) => ({ ...fns, [id]: fn }));
67 // Create the body canvas (seeds an OnFunctionCall node) and watch it.
68 getOrCreateCanvasStore(id);
69 notifyCanvasRegistryChange();
70 return fn;
71}
72
73/** Delete a function: its declaration, its body canvas, and any selection of it. */
74export function deleteFunction(id: string): void {

Callers 1

useFunctionsFunction · 0.90

Calls 4

generateIdFunction · 0.90
uniqueNameFunction · 0.90
getOrCreateCanvasStoreFunction · 0.90

Tested by

no test coverage detected