1- import { createLogger } from '@sim/logger'
2- import { ASYNC_TOOL_CONFIRMATION_STATUS } from '@/lib/mothership/async-runs/lifecycle'
1+ import {
2+ ASYNC_TOOL_CONFIRMATION_STATUS ,
3+ isTerminalAsyncStatus ,
4+ } from '@/lib/mothership/async-runs/lifecycle'
35import {
46 completeClientWorkflowToolCall ,
57 detachAsyncToolCall ,
@@ -10,12 +12,7 @@ import {
1012 getWorkflowToolCompletionMessage ,
1113 getWorkflowToolConfirmationStatus ,
1214} from '@/lib/mothership/tools/workflow-tools'
13- import {
14- getTrustedWorkflowToolExecution ,
15- hasWorkflowExecutionLog ,
16- } from '@/lib/workflows/executor/execution-state'
17-
18- const logger = createLogger ( 'CopilotWorkflowClientSettlement' )
15+ import { getWorkflowExecutionLogStatus } from '@/lib/workflows/executor/execution-state'
1916
2017interface ReportClientWorkflowToolParams {
2118 toolCallId : string
@@ -40,17 +37,10 @@ export async function reportSettledClientWorkflowTool({
4037 executionId,
4138 workflowId,
4239} : ReportClientWorkflowToolParams ) : Promise < void > {
43- const execution = await getTrustedWorkflowToolExecution ( executionId , workflowId , toolCallId )
44- if ( ! execution && ( await hasWorkflowExecutionLog ( executionId , workflowId ) ) ) {
45- logger . warn ( 'Settled client workflow execution has no trusted log; leaving it to the client' , {
46- toolCallId,
47- executionId,
48- workflowId,
49- } )
50- return
51- }
40+ const logStatus = await getWorkflowExecutionLogStatus ( executionId , workflowId )
41+ if ( logStatus !== undefined && ! isTerminalAsyncStatus ( logStatus ) ) return
5242
53- const executionStatus = execution ?. status ?? 'failed'
43+ const executionStatus = logStatus ?? 'failed'
5444 const status = getWorkflowToolConfirmationStatus ( executionStatus )
5545 const message = getWorkflowToolCompletionMessage ( status )
5646 const data = createStructuralWorkflowToolCompletionData ( status , workflowId , executionId )
0 commit comments