mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-26 20:27:13 +00:00
refactor(agent): remove enabled state
This commit is contained in:
@@ -24,7 +24,6 @@ import DynamicFormComponent from '@/app/home/components/dynamic-form/DynamicForm
|
||||
import { extractI18nObject } from '@/i18n/I18nProvider';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import {
|
||||
Card,
|
||||
@@ -141,7 +140,6 @@ function AgentFormComponent(
|
||||
name: z.string().min(1, { message: t('agents.nameRequired') }),
|
||||
description: z.string().optional(),
|
||||
emoji: z.string().optional(),
|
||||
enabled: z.boolean().optional(),
|
||||
}),
|
||||
runner: z.record(z.string(), z.any()),
|
||||
runner_config: z.record(z.string(), z.any()),
|
||||
@@ -156,7 +154,6 @@ function AgentFormComponent(
|
||||
name: '',
|
||||
description: '',
|
||||
emoji: '🤖',
|
||||
enabled: true,
|
||||
},
|
||||
runner: {},
|
||||
runner_config: {},
|
||||
@@ -190,7 +187,6 @@ function AgentFormComponent(
|
||||
name: agent.name ?? '',
|
||||
description: agent.description ?? '',
|
||||
emoji: agent.emoji || '🤖',
|
||||
enabled: agent.enabled ?? true,
|
||||
},
|
||||
runner: (config.runner as Record<string, unknown>) ?? {},
|
||||
runner_config:
|
||||
@@ -287,12 +283,12 @@ function AgentFormComponent(
|
||||
: t('pipelines.configuration'),
|
||||
icon: SlidersHorizontal,
|
||||
},
|
||||
{
|
||||
name: 'basic',
|
||||
label: t('common.management'),
|
||||
icon: Power,
|
||||
},
|
||||
];
|
||||
const managementSection = {
|
||||
name: 'basic' as const,
|
||||
label: t('common.management'),
|
||||
icon: Power,
|
||||
};
|
||||
|
||||
const runnerStatus = useMemo<AgentRunnerStatus>(() => {
|
||||
if (pluginStatusLoading) {
|
||||
@@ -465,7 +461,6 @@ function AgentFormComponent(
|
||||
name: values.basic.name,
|
||||
description: values.basic.description ?? '',
|
||||
emoji: values.basic.emoji,
|
||||
enabled: values.basic.enabled ?? true,
|
||||
component_ref: (runner.id as string) || null,
|
||||
supported_event_patterns: normalizeEventPatterns(
|
||||
values.supported_event_patterns_text,
|
||||
@@ -568,11 +563,19 @@ function AgentFormComponent(
|
||||
}
|
||||
>
|
||||
<div className="overflow-x-auto">
|
||||
<TabsList className="grid min-w-[34rem] w-full grid-cols-3">
|
||||
<TabsList className="grid min-w-[42rem] w-full grid-cols-[repeat(3,minmax(0,1fr))_auto]">
|
||||
{primarySections.map((section) => {
|
||||
const Icon = section.icon;
|
||||
return (
|
||||
<TabsTrigger key={section.name} value={section.name}>
|
||||
<TabsTrigger
|
||||
key={section.name}
|
||||
value={section.name}
|
||||
className={
|
||||
section.name === 'basic'
|
||||
? 'px-4 text-muted-foreground data-[state=active]:text-foreground'
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Icon />
|
||||
{section.label}
|
||||
</TabsTrigger>
|
||||
@@ -580,21 +583,6 @@ function AgentFormComponent(
|
||||
})}
|
||||
</TabsList>
|
||||
</div>
|
||||
<div className="flex justify-end pt-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant={
|
||||
activeSection === managementSection.name
|
||||
? 'secondary'
|
||||
: 'ghost'
|
||||
}
|
||||
size="sm"
|
||||
onClick={() => setActiveSection(managementSection.name)}
|
||||
>
|
||||
<Power />
|
||||
{managementSection.label}
|
||||
</Button>
|
||||
</div>
|
||||
</Tabs>
|
||||
</nav>
|
||||
|
||||
@@ -671,40 +659,6 @@ function AgentFormComponent(
|
||||
|
||||
{activeSection === 'basic' && (
|
||||
<div className="space-y-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t('agents.availability')}</CardTitle>
|
||||
<CardDescription>
|
||||
{t('agents.availabilityDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="basic.enabled"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex items-center justify-between rounded-lg border p-4">
|
||||
<div className="space-y-0.5">
|
||||
<FormLabel className="flex items-center gap-2">
|
||||
<Power className="size-4" />
|
||||
{t('agents.enabled')}
|
||||
</FormLabel>
|
||||
<FormDescription>
|
||||
{t('agents.enabledDescription')}
|
||||
</FormDescription>
|
||||
</div>
|
||||
<FormControl>
|
||||
<Switch
|
||||
checked={field.value ?? true}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card className="border-destructive/50">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-destructive">
|
||||
|
||||
@@ -177,7 +177,6 @@ export interface Agent {
|
||||
kind: AgentKind;
|
||||
component_ref?: string | null;
|
||||
config?: Record<string, unknown>;
|
||||
enabled?: boolean;
|
||||
supported_event_patterns?: string[];
|
||||
capability?: AgentCapability;
|
||||
created_at?: string;
|
||||
|
||||
@@ -839,7 +839,6 @@ export default function WizardPage() {
|
||||
runner: { id: selectedRunner, 'expire-time': 0 },
|
||||
runner_config: { [selectedRunner]: runnerConfig },
|
||||
},
|
||||
enabled: true,
|
||||
supported_event_patterns: [selectedScenarioDefinition.eventType],
|
||||
});
|
||||
processorUuid = agentResp.uuid;
|
||||
|
||||
@@ -469,7 +469,6 @@ const enUS = {
|
||||
processor_incompatible:
|
||||
'The selected processor cannot handle this event.',
|
||||
processor_not_found: 'The selected processor is unavailable.',
|
||||
processor_disabled: 'The selected processor is disabled.',
|
||||
bot_runtime_unavailable:
|
||||
'The bot is not running. Check its platform settings and enable it before running a full test.',
|
||||
runner_failed: 'The Agent runner failed while processing the event.',
|
||||
@@ -691,10 +690,7 @@ const enUS = {
|
||||
allEvents: 'Supports all events',
|
||||
messageEventsOnly: 'Message events only',
|
||||
basicInfo: 'Basic Information',
|
||||
basicInfoDescription: 'Set the name, icon, description and enabled state',
|
||||
availability: 'Availability',
|
||||
availabilityDescription:
|
||||
'Control whether this Agent can receive and process events.',
|
||||
basicInfoDescription: 'Set the name, icon and description',
|
||||
runnerSettings: 'Runner',
|
||||
advanced: 'Advanced',
|
||||
bindableEvents: 'Bindable Event Range',
|
||||
@@ -703,9 +699,6 @@ const enUS = {
|
||||
supportedEvents: 'Event Range',
|
||||
supportedEventsDescription:
|
||||
'Use one event pattern per line, for example *, message.received, group.*. Pipelines are fixed to message.*.',
|
||||
enabled: 'Enable Agent',
|
||||
enabledDescription:
|
||||
'When disabled, this Agent should not be selected by event routing.',
|
||||
nameRequired: 'Name cannot be empty',
|
||||
createSuccess: 'Created successfully',
|
||||
createError: 'Creation failed: ',
|
||||
|
||||
@@ -525,8 +525,7 @@ const esES = {
|
||||
allEvents: 'Compatible con todos los eventos',
|
||||
messageEventsOnly: 'Solo eventos de mensaje',
|
||||
basicInfo: 'Información básica',
|
||||
basicInfoDescription:
|
||||
'Establece el nombre, icono, descripción y estado de habilitación',
|
||||
basicInfoDescription: 'Establece el nombre, icono y descripción',
|
||||
runnerSettings: 'Runner',
|
||||
advanced: 'Avanzado',
|
||||
bindableEvents: 'Rango de eventos vinculables',
|
||||
@@ -535,9 +534,6 @@ const esES = {
|
||||
supportedEvents: 'Rango de eventos',
|
||||
supportedEventsDescription:
|
||||
'Usa un patrón de evento por línea, por ejemplo *, message.received, group.*. Los Pipelines están fijos en message.*.',
|
||||
enabled: 'Habilitar Agent',
|
||||
enabledDescription:
|
||||
'Cuando está deshabilitado, este Agent no debe ser seleccionado por el enrutamiento de eventos.',
|
||||
nameRequired: 'El nombre no puede estar vacío',
|
||||
createSuccess: 'Creado correctamente',
|
||||
createError: 'Error al crear: ',
|
||||
|
||||
@@ -476,7 +476,6 @@ const jaJP = {
|
||||
processor_incompatible:
|
||||
'選択したプロセッサーはこのイベントを処理できません。',
|
||||
processor_not_found: '選択したプロセッサーを利用できません。',
|
||||
processor_disabled: '選択したプロセッサーは無効です。',
|
||||
bot_runtime_unavailable:
|
||||
'ボットが実行されていません。プラットフォーム設定を確認してボットを有効にした後、完全テストを実行してください。',
|
||||
runner_failed: 'Agent Runner がイベント処理中に失敗しました。',
|
||||
@@ -706,10 +705,7 @@ const jaJP = {
|
||||
allEvents: 'すべてのイベントに対応',
|
||||
messageEventsOnly: 'メッセージイベントのみ',
|
||||
basicInfo: '基本情報',
|
||||
basicInfoDescription: '名前、アイコン、説明、有効状態を設定します',
|
||||
availability: '有効状態',
|
||||
availabilityDescription:
|
||||
'この Agent がイベントを受信して処理できるかを制御します。',
|
||||
basicInfoDescription: '名前、アイコン、説明を設定します',
|
||||
runnerSettings: 'Runner',
|
||||
advanced: '詳細',
|
||||
bindableEvents: '紐付け可能なイベント範囲',
|
||||
@@ -718,9 +714,6 @@ const jaJP = {
|
||||
supportedEvents: 'イベント範囲',
|
||||
supportedEventsDescription:
|
||||
'1 行に 1 つのイベントパターンを指定します。例: *、message.received、group.*。Pipeline は message.* 固定です。',
|
||||
enabled: 'Agent を有効化',
|
||||
enabledDescription:
|
||||
'無効化すると、この Agent はイベントルーティングで選択されません。',
|
||||
nameRequired: '名前は必須です',
|
||||
createSuccess: '作成に成功しました',
|
||||
createError: '作成に失敗しました:',
|
||||
|
||||
@@ -522,7 +522,7 @@ const ruRU = {
|
||||
allEvents: 'Поддерживает все события',
|
||||
messageEventsOnly: 'Только события сообщений',
|
||||
basicInfo: 'Основная информация',
|
||||
basicInfoDescription: 'Задайте имя, иконку, описание и статус активации',
|
||||
basicInfoDescription: 'Задайте имя, иконку и описание',
|
||||
runnerSettings: 'Runner',
|
||||
advanced: 'Дополнительно',
|
||||
bindableEvents: 'Диапазон привязываемых событий',
|
||||
@@ -531,9 +531,6 @@ const ruRU = {
|
||||
supportedEvents: 'Диапазон событий',
|
||||
supportedEventsDescription:
|
||||
'Один шаблон события в строке, например *, message.received, group.*. Pipeline фиксирован на message.*.',
|
||||
enabled: 'Включить Agent',
|
||||
enabledDescription:
|
||||
'При отключении этот Agent не должен выбираться маршрутизацией событий.',
|
||||
nameRequired: 'Имя не может быть пустым',
|
||||
createSuccess: 'Успешно создано',
|
||||
createError: 'Ошибка создания: ',
|
||||
|
||||
@@ -508,7 +508,7 @@ const thTH = {
|
||||
allEvents: 'รองรับทุกเหตุการณ์',
|
||||
messageEventsOnly: 'เฉพาะเหตุการณ์ข้อความ',
|
||||
basicInfo: 'ข้อมูลพื้นฐาน',
|
||||
basicInfoDescription: 'ตั้งชื่อ ไอคอน คำอธิบาย และสถานะการเปิดใช้งาน',
|
||||
basicInfoDescription: 'ตั้งชื่อ ไอคอน และคำอธิบาย',
|
||||
runnerSettings: 'Runner',
|
||||
advanced: 'ขั้นสูง',
|
||||
bindableEvents: 'ช่วงเหตุการณ์ที่ผูกได้',
|
||||
@@ -517,9 +517,6 @@ const thTH = {
|
||||
supportedEvents: 'ช่วงเหตุการณ์',
|
||||
supportedEventsDescription:
|
||||
'หนึ่งรูปแบบเหตุการณ์ต่อบรรทัด เช่น *, message.received, group.* Pipeline ถูกกำหนดไว้ที่ message.*',
|
||||
enabled: 'เปิดใช้งาน Agent',
|
||||
enabledDescription:
|
||||
'เมื่อปิดใช้งาน Agent นี้จะไม่ถูกเลือกโดยการกำหนดเส้นทางเหตุการณ์',
|
||||
nameRequired: 'ชื่อต้องไม่ว่างเปล่า',
|
||||
createSuccess: 'สร้างสำเร็จ',
|
||||
createError: 'สร้างล้มเหลว: ',
|
||||
|
||||
@@ -518,7 +518,7 @@ const viVN = {
|
||||
allEvents: 'Hỗ trợ tất cả sự kiện',
|
||||
messageEventsOnly: 'Chỉ sự kiện tin nhắn',
|
||||
basicInfo: 'Thông tin cơ bản',
|
||||
basicInfoDescription: 'Đặt tên, biểu tượng, mô tả và trạng thái kích hoạt',
|
||||
basicInfoDescription: 'Đặt tên, biểu tượng và mô tả',
|
||||
runnerSettings: 'Runner',
|
||||
advanced: 'Nâng cao',
|
||||
bindableEvents: 'Phạm vi sự kiện có thể gắn',
|
||||
@@ -527,9 +527,6 @@ const viVN = {
|
||||
supportedEvents: 'Phạm vi sự kiện',
|
||||
supportedEventsDescription:
|
||||
'Mỗi dòng một mẫu sự kiện, ví dụ *, message.received, group.*. Pipeline cố định ở message.*.',
|
||||
enabled: 'Kích hoạt Agent',
|
||||
enabledDescription:
|
||||
'Khi bị tắt, Agent này sẽ không được định tuyến sự kiện chọn.',
|
||||
nameRequired: 'Tên không được để trống',
|
||||
createSuccess: 'Tạo thành công',
|
||||
createError: 'Tạo thất bại: ',
|
||||
|
||||
@@ -447,7 +447,6 @@ const zhHans = {
|
||||
route_not_found: '没有路由命中此事件。',
|
||||
processor_incompatible: '所选处理器无法处理此事件。',
|
||||
processor_not_found: '所选处理器不可用。',
|
||||
processor_disabled: '所选处理器已禁用。',
|
||||
bot_runtime_unavailable:
|
||||
'机器人尚未运行。请检查平台配置并启用机器人,再运行完整测试。',
|
||||
runner_failed: 'Agent Runner 处理事件时失败。',
|
||||
@@ -661,9 +660,7 @@ const zhHans = {
|
||||
allEvents: '支持全部事件',
|
||||
messageEventsOnly: '仅支持消息事件',
|
||||
basicInfo: '基础信息',
|
||||
basicInfoDescription: '设置名称、图标、描述和启用状态',
|
||||
availability: '启用状态',
|
||||
availabilityDescription: '控制此 Agent 是否可以接收并处理事件。',
|
||||
basicInfoDescription: '设置名称、图标和描述',
|
||||
runnerSettings: '运行器',
|
||||
advanced: '高级',
|
||||
bindableEvents: '可绑定事件范围',
|
||||
@@ -672,8 +669,6 @@ const zhHans = {
|
||||
supportedEvents: '事件范围',
|
||||
supportedEventsDescription:
|
||||
'每行一个事件模式,例如 *、message.received、group.*。Pipeline 固定仅支持 message.*。',
|
||||
enabled: '启用 Agent',
|
||||
enabledDescription: '禁用后,此 Agent 不应被事件路由选中。',
|
||||
nameRequired: '名称不能为空',
|
||||
createSuccess: '创建成功',
|
||||
createError: '创建失败:',
|
||||
|
||||
@@ -491,7 +491,7 @@ const zhHant = {
|
||||
allEvents: '支援全部事件',
|
||||
messageEventsOnly: '僅支援訊息事件',
|
||||
basicInfo: '基本資訊',
|
||||
basicInfoDescription: '設定名稱、圖示、描述和啟用狀態',
|
||||
basicInfoDescription: '設定名稱、圖示和描述',
|
||||
runnerSettings: '執行器',
|
||||
advanced: '進階',
|
||||
bindableEvents: '可綁定事件範圍',
|
||||
@@ -500,8 +500,6 @@ const zhHant = {
|
||||
supportedEvents: '事件範圍',
|
||||
supportedEventsDescription:
|
||||
'每行一個事件模式,例如 *、message.received、group.*。Pipeline 固定僅支援 message.*。',
|
||||
enabled: '啟用 Agent',
|
||||
enabledDescription: '停用後,此 Agent 不應被事件路由選中。',
|
||||
nameRequired: '名稱不能為空',
|
||||
createSuccess: '建立成功',
|
||||
createError: '建立失敗:',
|
||||
|
||||
Reference in New Issue
Block a user