|
|
@ -864,27 +864,25 @@ const SuperAgent = () => { |
|
|
runtimeTask.sessionStatus || |
|
|
runtimeTask.sessionStatus || |
|
|
"" |
|
|
"" |
|
|
).toLowerCase(); |
|
|
).toLowerCase(); |
|
|
|
|
|
const hasLocalRunSignal = stream.isLocalRunActive === true; |
|
|
const runtimeTaskType = String( |
|
|
const runtimeTaskType = String( |
|
|
runtimeTask?.task_type || runtimeTask?.taskType || "" |
|
|
runtimeTask?.task_type || runtimeTask?.taskType || "" |
|
|
).toLowerCase(); |
|
|
).toLowerCase(); |
|
|
const runtimeTaskTotal = Number(runtimeTask?.total || 0); |
|
|
const runtimeTaskTotal = Number(runtimeTask?.total || 0); |
|
|
const hasPersistedActiveThread = |
|
|
const hasPersistedActiveThread = |
|
|
streamReadyForActiveSession && stream.isPersistedThreadActive === true; |
|
|
streamReadyForActiveSession && stream.isPersistedThreadActive === true; |
|
|
const hasRuntimeExecutionSignal = |
|
|
|
|
|
!hasPendingInterruptSignal && |
|
|
|
|
|
( |
|
|
|
|
|
stream.isBusinessRunning || |
|
|
|
|
|
stream.isLocalRunActive || |
|
|
|
|
|
["running", "resuming"].includes(String(stream.runPhase || "").toLowerCase()) |
|
|
|
|
|
); |
|
|
|
|
|
const displayTaskStatus = |
|
|
const displayTaskStatus = |
|
|
hasRuntimeExecutionSignal && taskStatus === "suspended" |
|
|
hasLocalRunSignal && ["failed", "error"].includes(taskStatus) |
|
|
? "running" |
|
|
? "running" |
|
|
: taskStatus; |
|
|
: taskStatus; |
|
|
const displayRuntimeSessionStatus = |
|
|
const displayRuntimeSessionStatus = |
|
|
hasRuntimeExecutionSignal && runtimeSessionStatus === "suspended" |
|
|
hasLocalRunSignal && ["failed", "error"].includes(runtimeSessionStatus) |
|
|
? "running" |
|
|
? "running" |
|
|
: runtimeSessionStatus; |
|
|
: runtimeSessionStatus; |
|
|
|
|
|
const isFailedTask = |
|
|
|
|
|
["failed", "error"].includes(displayTaskStatus) || |
|
|
|
|
|
["failed", "error"].includes(displayRuntimeSessionStatus) || |
|
|
|
|
|
(stream.runPhase === "failed" && !hasPendingInterruptSignal && !hasLocalRunSignal); |
|
|
const hasSuspendedRuntimeStatus = |
|
|
const hasSuspendedRuntimeStatus = |
|
|
displayTaskStatus === "suspended" || displayRuntimeSessionStatus === "suspended"; |
|
|
displayTaskStatus === "suspended" || displayRuntimeSessionStatus === "suspended"; |
|
|
const displayActiveStreamTask = activeStreamTask |
|
|
const displayActiveStreamTask = activeStreamTask |
|
|
@ -902,7 +900,7 @@ const SuperAgent = () => { |
|
|
hasPendingInterruptSignal && |
|
|
hasPendingInterruptSignal && |
|
|
(taskStatus === "suspended" || runtimeSessionStatus === "suspended"); |
|
|
(taskStatus === "suspended" || runtimeSessionStatus === "suspended"); |
|
|
const hasPersistedRunningThread = |
|
|
const hasPersistedRunningThread = |
|
|
hasPersistedActiveThread && !hasSuspendedRuntimeStatus; |
|
|
hasPersistedActiveThread && !hasSuspendedRuntimeStatus && !isFailedTask; |
|
|
const isTerminalRuntimeSession = [ |
|
|
const isTerminalRuntimeSession = [ |
|
|
"failed", |
|
|
"failed", |
|
|
"completed", |
|
|
"completed", |
|
|
@ -933,10 +931,6 @@ const SuperAgent = () => { |
|
|
(displayRuntimeSessionStatus |
|
|
(displayRuntimeSessionStatus |
|
|
? displayRuntimeSessionStatus === "running" |
|
|
? displayRuntimeSessionStatus === "running" |
|
|
: ["running", "resuming"].includes(stream.runPhase)); |
|
|
: ["running", "resuming"].includes(stream.runPhase)); |
|
|
const isFailedTask = |
|
|
|
|
|
["failed", "error"].includes(displayTaskStatus) || |
|
|
|
|
|
["failed", "error"].includes(displayRuntimeSessionStatus) || |
|
|
|
|
|
(stream.runPhase === "failed" && !hasPendingInterruptSignal); |
|
|
|
|
|
const hasTerminalTaskStatus = [ |
|
|
const hasTerminalTaskStatus = [ |
|
|
"completed", |
|
|
"completed", |
|
|
"done", |
|
|
"done", |
|
|
@ -949,6 +943,7 @@ const SuperAgent = () => { |
|
|
"suspended", |
|
|
"suspended", |
|
|
].includes(displayTaskStatus) && !isSuspendedByInterrupt; |
|
|
].includes(displayTaskStatus) && !isSuspendedByInterrupt; |
|
|
const isTerminalTask = |
|
|
const isTerminalTask = |
|
|
|
|
|
isFailedTask || |
|
|
(hasSuspendedRuntimeStatus && !isSuspendedByInterrupt) || |
|
|
(hasSuspendedRuntimeStatus && !isSuspendedByInterrupt) || |
|
|
(!hasPersistedActiveThread && !isBodyGenerationRuntimeActive && hasTerminalTaskStatus) || |
|
|
(!hasPersistedActiveThread && !isBodyGenerationRuntimeActive && hasTerminalTaskStatus) || |
|
|
isTerminalRuntimeSession || |
|
|
isTerminalRuntimeSession || |
|
|
@ -994,11 +989,12 @@ const SuperAgent = () => { |
|
|
["running", "awaiting_interrupt", "resuming"].includes(stream.runPhase) && |
|
|
["running", "awaiting_interrupt", "resuming"].includes(stream.runPhase) && |
|
|
(!isTerminalTask || stream.isLocalRunActive); |
|
|
(!isTerminalTask || stream.isLocalRunActive); |
|
|
const isStreamRunning = |
|
|
const isStreamRunning = |
|
|
hasPersistedRunningThread || |
|
|
!isFailedTask && |
|
|
|
|
|
(hasPersistedRunningThread || |
|
|
isBodyGenerationRuntimeActive || |
|
|
isBodyGenerationRuntimeActive || |
|
|
hasActiveStreamRunPhase || |
|
|
hasActiveStreamRunPhase || |
|
|
(hasStreamExecutionSignal && |
|
|
(hasStreamExecutionSignal && |
|
|
(!isTerminalTask || hasRunningTaskStatus || hasActiveToolCallSignal)); |
|
|
(!isTerminalTask || hasRunningTaskStatus || hasActiveToolCallSignal))); |
|
|
const projectedStreamMessages = stream.messages; |
|
|
const projectedStreamMessages = stream.messages; |
|
|
const streamConversationMessages = streamReadyForActiveSession |
|
|
const streamConversationMessages = streamReadyForActiveSession |
|
|
? buildStreamConversationMessages( |
|
|
? buildStreamConversationMessages( |
|
|
@ -1517,12 +1513,17 @@ const SuperAgent = () => { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const respondCheckpointToAgent = ({ response, interruptId, namespace, respondBody = {} }) => { |
|
|
const respondCheckpointToAgent = async ({ |
|
|
|
|
|
response, |
|
|
|
|
|
interruptId, |
|
|
|
|
|
namespace, |
|
|
|
|
|
respondBody = {}, |
|
|
|
|
|
}) => { |
|
|
const matchingInterrupt = activeStreamInterrupts.find((item) => { |
|
|
const matchingInterrupt = activeStreamInterrupts.find((item) => { |
|
|
const payload = item?.value || item?.payload || {}; |
|
|
const payload = item?.value || item?.payload || {}; |
|
|
return payload.checkpoint_id === respondBody.checkpoint_id; |
|
|
return payload.checkpoint_id === respondBody.checkpoint_id; |
|
|
}); |
|
|
}); |
|
|
return stream.respondInterrupt(response || { |
|
|
const result = await stream.respondInterrupt(response || { |
|
|
type: respondBody.action || "respond", |
|
|
type: respondBody.action || "respond", |
|
|
edits: respondBody.edits, |
|
|
edits: respondBody.edits, |
|
|
display_content: respondBody.display_content, |
|
|
display_content: respondBody.display_content, |
|
|
@ -1530,6 +1531,15 @@ const SuperAgent = () => { |
|
|
interruptId: interruptId || matchingInterrupt?.id, |
|
|
interruptId: interruptId || matchingInterrupt?.id, |
|
|
namespace: namespace || matchingInterrupt?.namespace, |
|
|
namespace: namespace || matchingInterrupt?.namespace, |
|
|
}); |
|
|
}); |
|
|
|
|
|
try { |
|
|
|
|
|
await stream.refreshState(); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
superAgentError("container.interrupt", "state.refresh_failed", { |
|
|
|
|
|
sessionId: activeSessionId, |
|
|
|
|
|
error, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const handleStopAndCancel = async () => { |
|
|
const handleStopAndCancel = async () => { |
|
|
|