@@ -37,9 +37,14 @@ import {
3737 createGetWorkflowCompilationStateTool ,
3838 createExecuteWorkflowTool ,
3939 createGetExecutionStateTool ,
40+ createKillWorkflowTool ,
4041 createHasOperatorResultTool ,
41- createGetOperatorResultSnapshotTool ,
42+ createGetOperatorResultPageTool ,
4243 createGetOperatorResultInfoTool ,
44+ createGetWorkflowValidationErrorsTool ,
45+ createValidateOperatorTool ,
46+ createGetValidOperatorsTool ,
47+ toolWithTimeout ,
4348} from "./workflow-tools" ;
4449import { OperatorMetadataService } from "../operator-metadata/operator-metadata.service" ;
4550import { createOpenAI } from "@ai-sdk/openai" ;
@@ -51,10 +56,12 @@ import { ExecuteWorkflowService } from "../execute-workflow/execute-workflow.ser
5156import { WorkflowResultService } from "../workflow-result/workflow-result.service" ;
5257import { CopilotCoeditorService } from "./copilot-coeditor.service" ;
5358import { WorkflowCompilingService } from "../compile-workflow/workflow-compiling.service" ;
59+ import { ValidationWorkflowService } from "../validation/validation-workflow.service" ;
60+ import { COPILOT_SYSTEM_PROMPT } from "./copilot-prompts" ;
5461
5562// API endpoints as constants
5663export const COPILOT_MCP_URL = "mcp" ;
57- export const AGENT_MODEL_ID = "claude-3.7 " ;
64+ export const AGENT_MODEL_ID = "claude-4 " ;
5865
5966/**
6067 * Agent response structure for streaming intermediate and final results
@@ -100,7 +107,8 @@ export class TexeraCopilot {
100107 private executeWorkflowService : ExecuteWorkflowService ,
101108 private workflowResultService : WorkflowResultService ,
102109 private copilotCoeditorService : CopilotCoeditorService ,
103- private workflowCompilingService : WorkflowCompilingService
110+ private workflowCompilingService : WorkflowCompilingService ,
111+ private validationWorkflowService : ValidationWorkflowService
104112 ) {
105113 // Don't auto-initialize, wait for user to enable
106114 }
@@ -208,18 +216,7 @@ export class TexeraCopilot {
208216 messages : this . messages , // full history
209217 tools,
210218 abortSignal : this . currentAbortController . signal ,
211- system :
212- "You are Texera Copilot, an AI assistant for building and modifying data workflows. " +
213- "Your task is helping user explore the data using operators. " +
214- "Common operators would be Limit to limit the size of data; " +
215- "Aggregate to do some aggregation; and some visualization operator. " +
216- "A good generation style is, " +
217- "1. listing what operators are available" +
218- "2. add the operator" +
219- "3. retrieve the OperatorSchema" +
220- "4. Configuring its property based on the schema" +
221- "5. executing it to make sure each editing is valid. " +
222- "Generate 3-5 operators is enough for every round of generation" ,
219+ system : COPILOT_SYSTEM_PROMPT ,
223220 stopWhen : stepCountIs ( 50 ) ,
224221
225222 // optional: observe every completed step (tool calls + results available)
@@ -287,52 +284,70 @@ export class TexeraCopilot {
287284 }
288285
289286 /**
290- * Create workflow manipulation tools
287+ * Create workflow manipulation tools with timeout protection
291288 */
292289 private createWorkflowTools ( ) : Record < string , any > {
293- const addOperatorTool = createAddOperatorTool (
294- this . workflowActionService ,
295- this . workflowUtilService ,
296- this . operatorMetadataService ,
297- this . copilotCoeditorService
290+ const addOperatorTool = toolWithTimeout (
291+ createAddOperatorTool (
292+ this . workflowActionService ,
293+ this . workflowUtilService ,
294+ this . operatorMetadataService ,
295+ this . copilotCoeditorService
296+ )
298297 ) ;
299- const addLinkTool = createAddLinkTool ( this . workflowActionService ) ;
300- const listOperatorsTool = createListOperatorsTool ( this . workflowActionService , this . copilotCoeditorService ) ;
301- const listLinksTool = createListLinksTool ( this . workflowActionService ) ;
302- const listOperatorTypesTool = createListOperatorTypesTool ( this . workflowUtilService ) ;
303- const getOperatorTool = createGetOperatorTool ( this . workflowActionService , this . copilotCoeditorService ) ;
304- const deleteOperatorTool = createDeleteOperatorTool ( this . workflowActionService , this . copilotCoeditorService ) ;
305- const deleteLinkTool = createDeleteLinkTool ( this . workflowActionService ) ;
306- const setOperatorPropertyTool = createSetOperatorPropertyTool (
307- this . workflowActionService ,
308- this . copilotCoeditorService
298+ const addLinkTool = toolWithTimeout ( createAddLinkTool ( this . workflowActionService ) ) ;
299+ const listOperatorsTool = toolWithTimeout (
300+ createListOperatorsTool ( this . workflowActionService , this . copilotCoeditorService )
309301 ) ;
310- const getOperatorSchemaTool = createGetOperatorSchemaTool (
311- this . workflowActionService ,
312- this . operatorMetadataService ,
313- this . copilotCoeditorService
302+ const listLinksTool = toolWithTimeout ( createListLinksTool ( this . workflowActionService ) ) ;
303+ const listOperatorTypesTool = toolWithTimeout ( createListOperatorTypesTool ( this . workflowUtilService ) ) ;
304+ const getOperatorTool = toolWithTimeout (
305+ createGetOperatorTool ( this . workflowActionService , this . copilotCoeditorService )
314306 ) ;
315- const getOperatorInputSchemaTool = createGetOperatorInputSchemaTool (
316- this . workflowCompilingService ,
317- this . copilotCoeditorService
307+ const deleteOperatorTool = toolWithTimeout (
308+ createDeleteOperatorTool ( this . workflowActionService , this . copilotCoeditorService )
318309 ) ;
319- const getWorkflowCompilationStateTool = createGetWorkflowCompilationStateTool ( this . workflowCompilingService ) ;
320- const executeWorkflowTool = createExecuteWorkflowTool ( this . executeWorkflowService ) ;
321- const getExecutionStateTool = createGetExecutionStateTool ( this . executeWorkflowService ) ;
322- const hasOperatorResultTool = createHasOperatorResultTool (
323- this . workflowResultService ,
324- this . workflowActionService ,
325- this . copilotCoeditorService
310+ const deleteLinkTool = toolWithTimeout ( createDeleteLinkTool ( this . workflowActionService ) ) ;
311+ const setOperatorPropertyTool = toolWithTimeout (
312+ createSetOperatorPropertyTool ( this . workflowActionService , this . copilotCoeditorService )
326313 ) ;
327- const getOperatorResultSnapshotTool = createGetOperatorResultSnapshotTool (
328- this . workflowResultService ,
329- this . workflowActionService ,
330- this . copilotCoeditorService
314+ const getOperatorSchemaTool = toolWithTimeout (
315+ createGetOperatorSchemaTool ( this . workflowActionService , this . operatorMetadataService , this . copilotCoeditorService )
331316 ) ;
332- const getOperatorResultInfoTool = createGetOperatorResultInfoTool (
333- this . workflowResultService ,
334- this . workflowActionService ,
335- this . copilotCoeditorService
317+ const getOperatorInputSchemaTool = toolWithTimeout (
318+ createGetOperatorInputSchemaTool ( this . workflowCompilingService , this . copilotCoeditorService )
319+ ) ;
320+ const getWorkflowCompilationStateTool = toolWithTimeout (
321+ createGetWorkflowCompilationStateTool ( this . workflowCompilingService )
322+ ) ;
323+ const executeWorkflowTool = toolWithTimeout ( createExecuteWorkflowTool ( this . executeWorkflowService ) ) ;
324+ const getExecutionStateTool = toolWithTimeout ( createGetExecutionStateTool ( this . executeWorkflowService ) ) ;
325+ const killWorkflowTool = toolWithTimeout ( createKillWorkflowTool ( this . executeWorkflowService ) ) ;
326+ const hasOperatorResultTool = toolWithTimeout (
327+ createHasOperatorResultTool ( this . workflowResultService , this . workflowActionService , this . copilotCoeditorService )
328+ ) ;
329+ const getOperatorResultPageTool = toolWithTimeout (
330+ createGetOperatorResultPageTool (
331+ this . workflowResultService ,
332+ this . workflowActionService ,
333+ this . copilotCoeditorService
334+ )
335+ ) ;
336+ const getOperatorResultInfoTool = toolWithTimeout (
337+ createGetOperatorResultInfoTool (
338+ this . workflowResultService ,
339+ this . workflowActionService ,
340+ this . copilotCoeditorService
341+ )
342+ ) ;
343+ const getWorkflowValidationErrorsTool = toolWithTimeout (
344+ createGetWorkflowValidationErrorsTool ( this . validationWorkflowService )
345+ ) ;
346+ const validateOperatorTool = toolWithTimeout (
347+ createValidateOperatorTool ( this . validationWorkflowService , this . copilotCoeditorService )
348+ ) ;
349+ const getValidOperatorsTool = toolWithTimeout (
350+ createGetValidOperatorsTool ( this . validationWorkflowService , this . workflowActionService )
336351 ) ;
337352
338353 // Get MCP tools in AI SDK format
@@ -353,10 +368,13 @@ export class TexeraCopilot {
353368 getOperatorInputSchema : getOperatorInputSchemaTool ,
354369 getWorkflowCompilationState : getWorkflowCompilationStateTool ,
355370 executeWorkflow : executeWorkflowTool ,
356- getExecutionState : getExecutionStateTool ,
357- hasOperatorResult : hasOperatorResultTool ,
358- getOperatorResultSnapshot : getOperatorResultSnapshotTool ,
371+ // killWorkflow: killWorkflowTool ,
372+ // hasOperatorResult: hasOperatorResultTool,
373+ // getOperatorResultPage: getOperatorResultPageTool ,
359374 getOperatorResultInfo : getOperatorResultInfoTool ,
375+ getWorkflowValidationErrors : getWorkflowValidationErrorsTool ,
376+ validateOperator : validateOperatorTool ,
377+ getValidOperators : getValidOperatorsTool ,
360378 } ;
361379 }
362380
0 commit comments