2025-06-06 17:14:15 -07:00
|
|
|
import { isAgentInboxInterruptSchema } from "@/lib/agent-inbox-interrupt";
|
|
|
|
|
import { ThreadView } from "../agent-inbox";
|
|
|
|
|
import { GenericInterruptView } from "./generic-interrupt";
|
2025-06-18 11:03:39 -07:00
|
|
|
import { useStream } from "@langchain/langgraph-sdk/react";
|
2025-06-06 17:14:15 -07:00
|
|
|
|
|
|
|
|
interface InterruptProps {
|
|
|
|
|
interruptValue?: unknown;
|
|
|
|
|
isLastMessage: boolean;
|
2025-07-09 14:38:15 -07:00
|
|
|
hasNoAIOrToolMessages?: boolean;
|
2025-06-06 17:14:15 -07:00
|
|
|
forceRenderInterrupt?: boolean;
|
2025-06-18 11:03:39 -07:00
|
|
|
thread: ReturnType<typeof useStream>;
|
2025-06-06 17:14:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Interrupt({
|
|
|
|
|
interruptValue,
|
|
|
|
|
isLastMessage,
|
|
|
|
|
hasNoAIOrToolMessages,
|
|
|
|
|
forceRenderInterrupt,
|
2025-06-18 11:03:39 -07:00
|
|
|
thread,
|
2025-06-06 17:14:15 -07:00
|
|
|
}: InterruptProps) {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{isAgentInboxInterruptSchema(interruptValue) &&
|
|
|
|
|
(isLastMessage || hasNoAIOrToolMessages || forceRenderInterrupt) && (
|
2025-06-18 11:03:39 -07:00
|
|
|
<ThreadView
|
|
|
|
|
interrupt={interruptValue}
|
|
|
|
|
thread={thread}
|
|
|
|
|
/>
|
2025-06-06 17:14:15 -07:00
|
|
|
)}
|
|
|
|
|
{interruptValue &&
|
|
|
|
|
!isAgentInboxInterruptSchema(interruptValue) &&
|
|
|
|
|
(isLastMessage || forceRenderInterrupt) ? (
|
|
|
|
|
<GenericInterruptView interrupt={interruptValue} />
|
|
|
|
|
) : null}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|