Skip to content

Commit 2016ce9

Browse files
authored
⭐️ Agent Market phase 2
2 parents bf6a8db + efbf522 commit 2016ce9

File tree

20 files changed

+2813
-130
lines changed

20 files changed

+2813
-130
lines changed

doc/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ node_modules/
22
pnpm-lock.yaml
33
package-lock.json
44
docs/.vitepress/cache
5-
docs/.vitepress/dist
5+
docs/.vitepress/dist

docker/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,6 @@ PROMETHEUS_PORT=8000
151151
TELEMETRY_SAMPLE_RATE=1.0
152152
LLM_SLOW_REQUEST_THRESHOLD_SECONDS=5.0
153153
LLM_SLOW_TOKEN_RATE_THRESHOLD=10.0
154+
155+
# Market Backend Address
156+
MARKET_BACKEND=http://localhost:8010

frontend/app/[locale]/agents/components/AgentSetupOrchestrator.tsx

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import { TooltipProvider } from "@/components/ui/tooltip";
1111
import {
1212
fetchAgentList,
1313
updateAgent,
14-
importAgent,
1514
deleteAgent,
1615
exportAgent,
1716
searchAgentInfo,
1817
searchToolConfig,
1918
updateToolConfig,
2019
} from "@/services/agentConfigService";
20+
import { useAgentImport } from "@/hooks/useAgentImport";
2121
import {
2222
Agent,
2323
AgentSetupOrchestratorProps,
@@ -1541,6 +1541,31 @@ export default function AgentSetupOrchestrator({
15411541
}
15421542
};
15431543

1544+
// Use unified import hooks - one for normal import, one for force import
1545+
const { importFromData: runNormalImport } = useAgentImport({
1546+
onSuccess: () => {
1547+
message.success(t("businessLogic.config.error.agentImportSuccess"));
1548+
refreshAgentList(t, false);
1549+
},
1550+
onError: (error) => {
1551+
log.error(t("agentConfig.agents.importFailed"), error);
1552+
message.error(t("businessLogic.config.error.agentImportFailed"));
1553+
},
1554+
forceImport: false,
1555+
});
1556+
1557+
const { importFromData: runForceImport } = useAgentImport({
1558+
onSuccess: () => {
1559+
message.success(t("businessLogic.config.error.agentImportSuccess"));
1560+
refreshAgentList(t, false);
1561+
},
1562+
onError: (error) => {
1563+
log.error(t("agentConfig.agents.importFailed"), error);
1564+
message.error(t("businessLogic.config.error.agentImportFailed"));
1565+
},
1566+
forceImport: true,
1567+
});
1568+
15441569
const runAgentImport = useCallback(
15451570
async (
15461571
agentPayload: any,
@@ -1549,31 +1574,19 @@ export default function AgentSetupOrchestrator({
15491574
) => {
15501575
setIsImporting(true);
15511576
try {
1552-
const result = await importAgent(agentPayload, options);
1553-
1554-
if (result.success) {
1555-
message.success(
1556-
translationFn("businessLogic.config.error.agentImportSuccess")
1557-
);
1558-
// Don't clear tools when importing to avoid triggering false unsaved changes indicator
1559-
await refreshAgentList(translationFn, false);
1560-
return true;
1577+
if (options?.forceImport) {
1578+
await runForceImport(agentPayload);
1579+
} else {
1580+
await runNormalImport(agentPayload);
15611581
}
1562-
1563-
message.error(
1564-
result.message ||
1565-
translationFn("businessLogic.config.error.agentImportFailed")
1566-
);
1567-
return false;
1582+
return true;
15681583
} catch (error) {
1569-
log.error(translationFn("agentConfig.agents.importFailed"), error);
1570-
message.error(translationFn("businessLogic.config.error.agentImportFailed"));
15711584
return false;
15721585
} finally {
15731586
setIsImporting(false);
15741587
}
15751588
},
1576-
[message, refreshAgentList]
1589+
[runNormalImport, runForceImport]
15771590
);
15781591

15791592
// Handle importing agent

0 commit comments

Comments
 (0)