Feat: Display error messages from intermediate nodes of the webhook. #10427 (#11954)

### What problem does this PR solve?

Feat: Remove HMAC from the webhook #10427

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-12-19 12:56:56 +08:00
committed by GitHub
parent 6cd1824a77
commit 4cbe470089
27 changed files with 737 additions and 359 deletions

View File

@ -9,8 +9,12 @@ import {
IFlowTemplate,
IPipeLineListRequest,
ITraceData,
IWebhookTrace,
} from '@/interfaces/database/agent';
import { IDebugSingleRequestBody } from '@/interfaces/request/agent';
import {
IAgentWebhookTraceRequest,
IDebugSingleRequestBody,
} from '@/interfaces/request/agent';
import i18n from '@/locales/config';
import { BeginId } from '@/pages/agent/constant';
import { IInputs } from '@/pages/agent/interface';
@ -19,6 +23,7 @@ import agentService, {
fetchAgentLogsByCanvasId,
fetchPipeLineList,
fetchTrace,
fetchWebhookTrace,
} from '@/services/agent-service';
import api from '@/utils/api';
import { buildMessageListWithUuid } from '@/utils/chat';
@ -55,6 +60,7 @@ export const enum AgentApiAction {
FetchPrompt = 'fetchPrompt',
CancelDataflow = 'cancelDataflow',
CancelCanvas = 'cancelCanvas',
FetchWebhookTrace = 'fetchWebhookTrace',
}
export const EmptyDsl = {
@ -786,3 +792,70 @@ export const useFetchFlowSSE = (): {
return { data, loading, refetch };
};
export const useFetchWebhookTrace = (autoStart: boolean = true) => {
const { id } = useParams();
const [currentWebhookId, setCurrentWebhookId] = useState<string>('');
const [currentNextSinceTs, setCurrentNextSinceTs] = useState<number>(0);
const [shouldPoll, setShouldPoll] = useState(autoStart);
const {
data,
isFetching: loading,
refetch,
} = useQuery<IWebhookTrace>({
queryKey: [AgentApiAction.FetchWebhookTrace, id],
refetchOnReconnect: false,
refetchOnMount: false,
refetchOnWindowFocus: false,
refetchIntervalInBackground: false,
gcTime: 0,
enabled: !!id && shouldPoll,
queryFn: async () => {
if (!id) return {};
const payload: IAgentWebhookTraceRequest =
{} as IAgentWebhookTraceRequest;
if (currentNextSinceTs) {
payload['since_ts'] = currentNextSinceTs;
}
if (currentWebhookId) {
payload['webhook_id'] = currentWebhookId;
}
const { data } = await fetchWebhookTrace(id, payload);
const result = data.data ?? {};
if (result.webhook_id && result.webhook_id !== currentWebhookId) {
setCurrentWebhookId(result.webhook_id);
}
if (
currentNextSinceTs === 0 &&
result.next_since_ts &&
result.next_since_ts !== currentNextSinceTs
) {
setCurrentNextSinceTs(result.next_since_ts);
}
if (result.finished) {
setShouldPoll(false);
}
return result;
},
refetchInterval: shouldPoll ? 3000 : false,
});
return {
data,
loading,
refetch,
isPolling: shouldPoll,
currentWebhookId,
currentNextSinceTs,
};
};