Task Summary
agent-service/src/agent/tools/workflow-crud-tools.ts (codecov ~22%) exports createAddOperatorTool, createModifyOperatorTool, createDeleteOperatorTool — factories returning AI-SDK tools whose execute(args) mutate an in-memory WorkflowState. Unit-testable with bun test: construct a real WorkflowState, build the tool, call tool.execute(args), assert the state change + returned result. Only mock is context.metadataStore.validateOperatorProperties for the validation branches — no network. See tools/tools-utility.spec.ts for the pattern.
Behavior to cover
createDeleteOperatorTool
- operator exists -> removes it (and connected links); returns
"Deleted operator: {operatorId}"
- operator absent ->
createErrorResult("Operator {operatorId} not found")
createAddOperatorTool
- unknown
operatorType (no schema entry) -> error
operatorId not matching /^op\d+$/ -> error
operatorId already present -> error ("... already exists. Use modifyOperator ...")
properties failing validation -> error carrying the validation messages
inputOperatorIds referencing a missing source operator -> error ("Source operator ... not found")
- target port index
NaN / negative / >= inputPorts.length -> error
- valid args -> adds operator + creates links; returns success
createModifyOperatorTool
- operator not found ->
createErrorResult("Operator {operatorId} not found ...")
- merged properties failing validation -> error via
formatValidationErrors(validation)
- valid args -> updates the operator's properties; returns success
Task Type
Task Summary
agent-service/src/agent/tools/workflow-crud-tools.ts(codecov ~22%) exportscreateAddOperatorTool,createModifyOperatorTool,createDeleteOperatorTool— factories returning AI-SDK tools whoseexecute(args)mutate an in-memoryWorkflowState. Unit-testable withbun test: construct a realWorkflowState, build the tool, calltool.execute(args), assert the state change + returned result. Only mock iscontext.metadataStore.validateOperatorPropertiesfor the validation branches — no network. Seetools/tools-utility.spec.tsfor the pattern.Behavior to cover
createDeleteOperatorTool
"Deleted operator: {operatorId}"createErrorResult("Operator {operatorId} not found")createAddOperatorTool
operatorType(no schema entry) -> erroroperatorIdnot matching/^op\d+$/-> erroroperatorIdalready present -> error ("... already exists. Use modifyOperator ...")propertiesfailing validation -> error carrying the validation messagesinputOperatorIdsreferencing a missing source operator -> error ("Source operator ... not found")NaN/ negative />= inputPorts.length-> errorcreateModifyOperatorTool
createErrorResult("Operator {operatorId} not found ...")formatValidationErrors(validation)Task Type