Skip to content

Commit 298f03b

Browse files
fix: update
1 parent 8f888f1 commit 298f03b

15 files changed

Lines changed: 147 additions & 57 deletions

File tree

src/components/AddWorker/index.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { INIT_PROVODERS } from '@/lib/llm';
3737
import { useAuthStore, useWorkerList } from '@/store/authStore';
3838
import {
3939
hasGlobalAgentTemplatesApi,
40+
sanitizeCustomModelConfigForPersistence,
4041
useGlobalAgentTemplatesStore,
4142
} from '@/store/globalAgentTemplatesStore';
4243
import {
@@ -105,6 +106,12 @@ function parseSelectedToolsSnapshot(raw: unknown): McpItem[] {
105106
return out;
106107
}
107108

109+
/** Safe download basename for agent JSON (matches GlobalAgents export pattern). */
110+
function sanitizeAgentExportFilenameStem(raw: string): string {
111+
const stem = raw?.trim() || 'config';
112+
return stem.replace(/[^a-z0-9-_]/gi, '-');
113+
}
114+
108115
export function AddWorker({
109116
edit = false,
110117
workerInfo = null,
@@ -218,13 +225,14 @@ export function AddWorker({
218225
(mcpLocal.mcpServers as Record<string, unknown>)[tool.key] = {};
219226
}
220227
});
221-
const custom_model_config =
228+
const custom_model_config = sanitizeCustomModelConfigForPersistence(
222229
!useWorkspaceCloudModel && useCustomModel && customModelPlatform
223230
? {
224231
model_platform: customModelPlatform,
225232
model_type: customModelType || undefined,
226233
}
227-
: undefined;
234+
: undefined
235+
);
228236
const blob = new Blob(
229237
[
230238
JSON.stringify(
@@ -245,7 +253,7 @@ export function AddWorker({
245253
const url = URL.createObjectURL(blob);
246254
const a = document.createElement('a');
247255
a.href = url;
248-
a.download = `agent-${workerName || 'config'}.json`;
256+
a.download = `agent-${sanitizeAgentExportFilenameStem(workerName)}.json`;
249257
a.click();
250258
URL.revokeObjectURL(url);
251259
toast.success(t('workforce.export-agent-success'));
@@ -257,7 +265,6 @@ export function AddWorker({
257265
customModelPlatform,
258266
customModelType,
259267
useWorkspaceCloudModel,
260-
selectedTools,
261268
t,
262269
]);
263270

@@ -541,13 +548,14 @@ export function AddWorker({
541548
}
542549

543550
if (saveAsGlobalTemplate && hasGlobalTemplatesApi) {
544-
const customModelConfig =
551+
const customModelConfig = sanitizeCustomModelConfigForPersistence(
545552
!useWorkspaceCloudModel && useCustomModel && customModelPlatform
546553
? {
547554
model_platform: customModelPlatform,
548555
model_type: customModelType || undefined,
549556
}
550-
: undefined;
557+
: undefined
558+
);
551559
await addGlobalTemplate({
552560
name: workerName,
553561
description: workerDescription,

src/components/WorkFlow/node.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { AddWorker } from '@/components/AddWorker';
1616
import { Button } from '@/components/ui/button';
1717
import useChatStoreAdapter from '@/hooks/useChatStoreAdapter';
1818
import { getToolkitIcon } from '@/lib/toolkitIcons';
19-
import { useAuthStore, useWorkerList } from '@/store/authStore';
19+
import { getWorkerList, useAuthStore, useWorkerList } from '@/store/authStore';
2020
import {
2121
AgentStatusValue,
2222
ChatTaskStatus,
@@ -58,7 +58,11 @@ function nextUniqueCustomWorkerName(
5858
workers: Agent[]
5959
): string {
6060
const used = new Set(
61-
workers.flatMap((w) => [w.type, w.name].filter(Boolean) as string[])
61+
workers.flatMap((w) =>
62+
[w.type, w.name, w.agent_id, w.workerInfo?.name].filter(
63+
(x): x is string => typeof x === 'string' && x.length > 0
64+
)
65+
)
6266
);
6367
let candidate = `${baseName} (copy)`;
6468
let i = 2;
@@ -495,9 +499,10 @@ export function Node({ id, data }: NodeProps) {
495499
const base = data.agent as Agent;
496500
const baseName =
497501
base.workerInfo?.name ?? base.name ?? 'Worker';
502+
const current = getWorkerList();
498503
const copyName = nextUniqueCustomWorkerName(
499504
baseName,
500-
workerList
505+
current
501506
);
502507
const newWorker: Agent = {
503508
tasks: [],
@@ -519,7 +524,7 @@ export function Node({ id, data }: NodeProps) {
519524
base.workerInfo?.selectedTools ?? [],
520525
},
521526
};
522-
setWorkerList([...workerList, newWorker]);
527+
setWorkerList([...current, newWorker]);
523528
}}
524529
>
525530
<Copy

src/i18n/locales/ar/agents.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
"custom-skill": "مهارة مخصصة",
4747
"delete-skill": "حذف المهارة",
4848
"delete-skill-confirmation": "هل أنت متأكد من أنك تريد حذف \"{{name}}\"؟ لا يمكن التراجع عن هذا الإجراء.",
49-
"skill-deleted-success": "تم حذف المهارة بنجاح!"
49+
"skill-deleted-success": "تم حذف المهارة بنجاح!",
50+
"delete-template": "حذف القالب",
51+
"delete-template-confirmation": "هل تريد بالتأكيد حذف القالب \"{{name}}\"؟ لا يمكن التراجع عن هذا الإجراء."
5052
}

src/i18n/locales/de/agents.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
"custom-skill": "Benutzerdefinierte Fähigkeit",
4747
"delete-skill": "Fähigkeit löschen",
4848
"delete-skill-confirmation": "Sind Sie sicher, dass Sie \"{{name}}\" löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",
49-
"skill-deleted-success": "Fähigkeit erfolgreich gelöscht!"
49+
"skill-deleted-success": "Fähigkeit erfolgreich gelöscht!",
50+
"delete-template": "Vorlage löschen",
51+
"delete-template-confirmation": "Möchten Sie die Vorlage \"{{name}}\" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden."
5052
}

src/i18n/locales/en-us/agents.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
"delete-skill": "Delete Skill",
4848
"delete-skill-confirmation": "Are you sure you want to delete \"{{name}}\"? This action cannot be undone.",
4949
"skill-deleted-success": "Skill deleted successfully!",
50+
"delete-template": "Delete template",
51+
"delete-template-confirmation": "Are you sure you want to delete the template \"{{name}}\"? This action cannot be undone.",
5052
"global-agents": "Global Agents",
5153
"global-agents-description": "Reusable Worker Agent templates available to all projects. Create once, use everywhere.",
5254
"global-agents-empty": "No global agent templates yet. Create one when adding a Worker Agent by checking \"Save as global template\", or import from a file.",

src/i18n/locales/es/agents.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
"custom-skill": "Habilidad personalizada",
4747
"delete-skill": "Eliminar habilidad",
4848
"delete-skill-confirmation": "¿Está seguro de que desea eliminar \"{{name}}\"? Esta acción no se puede deshacer.",
49-
"skill-deleted-success": "¡Habilidad eliminada exitosamente!"
49+
"skill-deleted-success": "¡Habilidad eliminada exitosamente!",
50+
"delete-template": "Eliminar plantilla",
51+
"delete-template-confirmation": "¿Seguro que desea eliminar la plantilla \"{{name}}\"? Esta acción no se puede deshacer."
5052
}

src/i18n/locales/fr/agents.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
"custom-skill": "Compétence personnalisée",
4747
"delete-skill": "Supprimer la compétence",
4848
"delete-skill-confirmation": "Êtes-vous sûr de vouloir supprimer \"{{name}}\" ? Cette action est irréversible.",
49-
"skill-deleted-success": "Compétence supprimée avec succès !"
49+
"skill-deleted-success": "Compétence supprimée avec succès !",
50+
"delete-template": "Supprimer le modèle",
51+
"delete-template-confirmation": "Voulez-vous vraiment supprimer le modèle « {{name}} » ? Cette action est irréversible."
5052
}

src/i18n/locales/it/agents.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
"custom-skill": "Competenza personalizzata",
4747
"delete-skill": "Elimina competenza",
4848
"delete-skill-confirmation": "Sei sicuro di voler eliminare \"{{name}}\"? Questa azione non può essere annullata.",
49-
"skill-deleted-success": "Competenza eliminata con successo!"
49+
"skill-deleted-success": "Competenza eliminata con successo!",
50+
"delete-template": "Elimina modello",
51+
"delete-template-confirmation": "Eliminare il modello \"{{name}}\"? Questa azione non può essere annullata."
5052
}

src/i18n/locales/ja/agents.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
"custom-skill": "カスタムスキル",
4747
"delete-skill": "スキルを削除",
4848
"delete-skill-confirmation": "\"{{name}}\" を削除してもよろしいですか?この操作は元に戻せません。",
49-
"skill-deleted-success": "スキルが正常に削除されました!"
49+
"skill-deleted-success": "スキルが正常に削除されました!",
50+
"delete-template": "テンプレートを削除",
51+
"delete-template-confirmation": "テンプレート「{{name}}」を削除してもよろしいですか?この操作は元に戻せません。"
5052
}

src/i18n/locales/ko/agents.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@
4646
"custom-skill": "사용자 정의 스킬",
4747
"delete-skill": "스킬 삭제",
4848
"delete-skill-confirmation": "\"{{name}}\"을(를) 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.",
49-
"skill-deleted-success": "스킬이 성공적으로 삭제되었습니다!"
49+
"skill-deleted-success": "스킬이 성공적으로 삭제되었습니다!",
50+
"delete-template": "템플릿 삭제",
51+
"delete-template-confirmation": "\"{{name}}\" 템플릿을 삭제하시겠습니까? 이 작업은 취소할 수 없습니다."
5052
}

0 commit comments

Comments
 (0)