refactor: consolidate bot event routing

This commit is contained in:
Junyan Qin
2026-07-01 21:04:21 +08:00
committed by huanghuoguoguo
parent 662627142e
commit 7fb393b85b
26 changed files with 408 additions and 365 deletions
@@ -84,8 +84,8 @@ export default function AgentCreateContent({
{
kind: 'agent',
icon: Bot,
title: t('agents.agentOrchestration'),
description: t('agents.agentOrchestrationDescription'),
title: t('agents.agentType'),
description: t('agents.agentTypeDescription'),
badge: t('agents.allEvents'),
},
{
@@ -148,7 +148,7 @@ export default function AgentFormComponent({
const sections: SectionItem[] = [
{ label: t('agents.basicInfo'), name: 'basic', icon: Info },
{ label: t('agents.runnerSettings'), name: 'runner', icon: Brain },
{ label: t('agents.eventCapability'), name: 'events', icon: FileJson2 },
{ label: t('agents.advanced'), name: 'events', icon: FileJson2 },
];
const currentRunner = (form.watch('runner') as Record<string, any>)?.id;
@@ -450,9 +450,9 @@ export default function AgentFormComponent({
{activeSection === 'events' && (
<Card>
<CardHeader>
<CardTitle>{t('agents.eventCapability')}</CardTitle>
<CardTitle>{t('agents.bindableEvents')}</CardTitle>
<CardDescription>
{t('agents.eventCapabilityDescription')}
{t('agents.bindableEventsDescription')}
</CardDescription>
</CardHeader>
<CardContent>
@@ -448,13 +448,13 @@ export default function BotForm({
</CardContent>
</Card>
{/* Card 2: Event Orchestration (edit mode only) */}
{/* Card 2: Event Routing (edit mode only) */}
{initBotId && (
<Card>
<CardHeader>
<CardTitle>{t('bots.eventOrchestration')}</CardTitle>
<CardTitle>{t('bots.eventRouting')}</CardTitle>
<CardDescription>
{t('bots.eventOrchestrationDescription')}
{t('bots.eventRoutingDescription')}
</CardDescription>
</CardHeader>
<CardContent>
@@ -59,7 +59,7 @@ import {
} from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
import { Input } from '@/components/ui/input';
import { EventBinding, Agent, AgentKind } from '@/app/infra/entities/api';
import { EventBinding, Agent } from '@/app/infra/entities/api';
export const PIPELINE_DISCARD = '__discard__';
@@ -496,18 +496,6 @@ function BindingCardContent({
const isExpanded = expandedIds.has(id);
const filterCount = (binding.filters as FilterRow[] | undefined)?.length ?? 0;
const pipelineAllowed = isMessageEventPattern(binding.event_pattern);
const targetType = binding.target_type || 'agent';
function getTargetOptions(kind: AgentKind): Agent[] {
return agentOptions.filter((agent) => {
if (agent.kind !== kind) return false;
if (kind === 'pipeline')
return isMessageEventPattern(binding.event_pattern);
if (kind === 'agent')
return agentSupportsEventPattern(agent, binding.event_pattern);
return true;
});
}
return (
<div className="rounded-lg border bg-card">
@@ -29,7 +29,7 @@ export interface SidebarEntityItem {
debug?: boolean;
// Set when this item appears in the unified extensions list
extensionType?: 'plugin' | 'mcp' | 'skill';
// Agent-specific: distinguishes Agent orchestration from legacy Pipeline
// Agent-specific: distinguishes Agent processors from Pipelines
kind?: 'agent' | 'pipeline';
}
-22
View File
@@ -228,34 +228,12 @@ export interface Bot {
enable?: boolean;
adapter: string;
adapter_config: object;
use_pipeline_name?: string;
use_pipeline_uuid?: string;
pipeline_routing_rules?: PipelineRoutingRule[];
event_bindings?: EventBinding[];
created_at?: string;
updated_at?: string;
adapter_runtime_values?: object;
}
export type RoutingRuleOperator =
| 'eq'
| 'neq'
| 'contains'
| 'not_contains'
| 'starts_with'
| 'regex';
export interface PipelineRoutingRule {
type:
| 'launcher_type'
| 'launcher_id'
| 'message_content'
| 'message_has_element';
operator: RoutingRuleOperator;
value: string;
pipeline_uuid: string;
}
export interface EventBinding {
id?: string;
event_pattern: string;
+11 -1
View File
@@ -486,7 +486,17 @@ export default function WizardPage() {
adapter: existingBot.adapter,
adapter_config: existingBot.adapter_config,
enable: existingBot.enable,
use_pipeline_uuid: pipelineResp.uuid,
event_bindings: [
{
event_pattern: 'message.received',
target_type: 'pipeline',
target_uuid: pipelineResp.uuid,
filters: [],
priority: 0,
enabled: true,
description: '',
},
],
});
setCurrentStep(3);