add credntials popup for run_block

This commit is contained in:
Swifty
2025-12-16 17:06:03 +01:00
parent 7d17e6c470
commit 1b352c479f
4 changed files with 10 additions and 10 deletions

View File

@@ -234,6 +234,7 @@ export function isSetupInfo(value: unknown): value is {
export function extractCredentialsNeeded(
parsedResult: Record<string, unknown>,
toolName: string = "run_agent",
): ChatMessageData | null {
try {
const setupInfo = parsedResult?.setup_info as
@@ -246,7 +247,7 @@ export function extractCredentialsNeeded(
| Record<string, Record<string, unknown>>
| undefined;
if (missingCreds && Object.keys(missingCreds).length > 0) {
const agentName = (setupInfo?.agent_name as string) || "this agent";
const agentName = (setupInfo?.agent_name as string) || "this block";
const credentials = Object.values(missingCreds).map((credInfo) => ({
provider: (credInfo.provider as string) || "unknown",
providerName:
@@ -266,7 +267,7 @@ export function extractCredentialsNeeded(
}));
return {
type: "credentials_needed",
toolName: "run_agent",
toolName,
credentials,
message: `To run ${agentName}, you need to add ${credentials.length === 1 ? "credentials" : `${credentials.length} credentials`}.`,
agentName,

View File

@@ -102,11 +102,14 @@ export function handleToolResponse(
parsedResult = null;
}
if (
chunk.tool_name === "run_agent" &&
(chunk.tool_name === "run_agent" || chunk.tool_name === "run_block") &&
chunk.success &&
parsedResult?.type === "setup_requirements"
) {
const credentialsMessage = extractCredentialsNeeded(parsedResult);
const credentialsMessage = extractCredentialsNeeded(
parsedResult,
chunk.tool_name,
);
if (credentialsMessage) {
deps.setMessages((prev) => [...prev, credentialsMessage]);
}

View File

@@ -191,15 +191,12 @@ export function useChatStream() {
}
const streamError =
err instanceof Error
? err
: new Error("Failed to read stream");
err instanceof Error ? err : new Error("Failed to read stream");
if (retryCountRef.current < MAX_RETRIES) {
retryCountRef.current += 1;
const retryDelay =
INITIAL_RETRY_DELAY *
Math.pow(2, retryCountRef.current - 1);
INITIAL_RETRY_DELAY * Math.pow(2, retryCountRef.current - 1);
toast.info("Connection interrupted", {
description: `Retrying in ${retryDelay / 1000} seconds...`,

View File

@@ -40,4 +40,3 @@ export function usePageContext() {
return { capturePageContext };
}