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

Function mutate

ts/workflow-builder/src/utils/functionOperations.ts:43–53  ·  view source on GitHub ↗

* Apply an update to one function. `bumpVersion` is true for signature changes * (name/arguments/outputs declaration) so call sites detect staleness, and false for * pure output-expression edits. Version-bumping changes re-sync the body's fnargs.

(id: string, updater: (fn: FunctionDeclaration) => FunctionDeclaration, bumpVersion: boolean)

Source from the content-addressed store, hash-verified

41 * pure output-expression edits. Version-bumping changes re-sync the body's fnargs.
42 */
43function mutate(id: string, updater: (fn: FunctionDeclaration) => FunctionDeclaration, bumpVersion: boolean): void {
44 let next: FunctionDeclaration | undefined;
45 useEditorStore.getState().setFunctions((fns) => {
46 const fn = fns[id];
47 if (!fn) return fns;
48 const updated = updater(fn);
49 next = bumpVersion ? { ...updated, version: fn.version + 1 } : updated;
50 return { ...fns, [id]: next };
51 });
52 if (next && bumpVersion) syncBody(next);
53}
54
55/** Create a new (empty) function + its body canvas. Returns the new definition. */
56export function addFunction(): FunctionDeclaration {

Callers 8

renameFunctionFunction · 0.85
addArgumentFunction · 0.85
updateArgumentFunction · 0.85
removeArgumentFunction · 0.85
addOutputFunction · 0.85
updateOutputFunction · 0.85
removeOutputFunction · 0.85
setOutputExpressionFunction · 0.85

Calls 1

syncBodyFunction · 0.85

Tested by

no test coverage detected