From 42d8b8e8e197bcc48a751306dab224bb90adeedf Mon Sep 17 00:00:00 2001 From: goulustis Date: Fri, 13 Mar 2026 13:57:00 +0800 Subject: [PATCH] bug fixes --- README.md | 2 +- docker/Dockerfile.frontend | 10 ++- docker/docker-compose.prod.yml | 8 +- frontend/src/App.tsx | 137 ++++++++++++++++++++++++++++----- frontend/src/styles.css | 2 + 5 files changed, 132 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 44a82af..52891b8 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ uvicorn fastapi_server.server_dashscope:app --reload --host 0.0.0.0 --port 8588 uvicorn fastapi_server.combined:app --reload --host 0.0.0.0 --port 8500 ``` -You can change the URL by setting `VITE_FRONT_API_BASE_URL` in `frontend/.env` (defaults to `http://127.0.0.1:8500`). +You can change the URL by setting `VITE_FRONT_API_BASE_URL` in `frontend/.env` (defaults to `/`, i.e. same-origin). ### Start the development server diff --git a/docker/Dockerfile.frontend b/docker/Dockerfile.frontend index 71eea0e..d025b2a 100644 --- a/docker/Dockerfile.frontend +++ b/docker/Dockerfile.frontend @@ -4,10 +4,16 @@ WORKDIR /app RUN npm config set registry https://registry.npmmirror.com +# Build-time API base for Vite (must be set before npm run build). +ARG VITE_FRONT_API_BASE_URL=/ +ENV VITE_FRONT_API_BASE_URL=${VITE_FRONT_API_BASE_URL} + COPY package*.json ./ RUN npm install COPY . . -RUN npm run build +RUN npm run build && \ + mkdir -p /opt/frontend_dist && \ + cp -r dist/. /opt/frontend_dist/ -CMD ["ls", "dist"] +CMD ["sh", "-c", "rm -rf /app/dist/* && cp -r /opt/frontend_dist/. /app/dist && ls /app/dist"] diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml index 3077e30..97a8f57 100644 --- a/docker/docker-compose.prod.yml +++ b/docker/docker-compose.prod.yml @@ -25,7 +25,7 @@ services: interval: 10s timeout: 5s retries: 5 - restart: unless-stopped + restart: no #unless-stopped # Backend API server backend: @@ -52,7 +52,7 @@ services: depends_on: postgres: condition: service_healthy - restart: unless-stopped + restart: no #unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8500/health"] interval: 30s @@ -65,6 +65,8 @@ services: build: context: ../frontend dockerfile: ../docker/Dockerfile.frontend + args: + VITE_FRONT_API_BASE_URL: ${VITE_FRONT_API_BASE_URL:-/} volumes: - frontend_dist:/app/dist networks: @@ -86,7 +88,7 @@ services: condition: service_completed_successfully backend: condition: service_started - restart: unless-stopped + restart: no #unless-stopped volumes: postgres_data: diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 7950b47..7cb948a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -41,6 +41,7 @@ type EditableAgent = { apiKey: string; llmName: string; actBackend: DeepAgentActBackend; + fileBackendConfig: FileBackendConfig; }; type AgentChatMessage = { @@ -51,6 +52,13 @@ type AgentChatMessage = { type ActiveTab = "agents" | "discussions" | "mcp"; type DeepAgentActBackend = "state_bk" | "local_shell" | "daytona_sandbox"; + +type FileBackendConfig = { + skills_dir: string; + rt_skills_dir: string; + workspace_dir?: string; + api_key?: string; +}; type McpTransport = "streamable_http" | "sse" | "stdio"; type McpEntry = { id: string; @@ -74,7 +82,24 @@ const DEEPAGENT_BACKEND_OPTIONS: Array<{ { value: "local_shell", label: "local_shell" }, { value: "daytona_sandbox", label: "daytona_sandbox" }, ]; -const LOCAL_DASHSCOPE_BASE = "http://127.0.0.1:8500/v1/apps"; + +const DEFAULT_FILE_BACKEND_CONFIG: Record = { + state_bk: { + skills_dir: "./assets/skills", + rt_skills_dir: "/skills", + }, + local_shell: { + skills_dir: "./workspace/skills", + rt_skills_dir: "/skills", + workspace_dir: "./workspace", + }, + daytona_sandbox: { + skills_dir: "./workspace/skills", + rt_skills_dir: "", + api_key: "", + }, +}; +const LOCAL_DASHSCOPE_BASE = "/v1/apps"; const MCP_TRANSPORT_OPTIONS: McpTransport[] = ["streamable_http", "sse", "stdio"]; const GRAPH_ARCH_IMAGE_MODULES = import.meta.glob( "../assets/images/graph_arch/*.{png,jpg,jpeg,webp,gif}", @@ -442,7 +467,10 @@ function normalizeDeepAgentActBackend(value: unknown): DeepAgentActBackend { function buildGraphParams(editor: EditableAgent): Record { if (editor.graphId === "deepagent") { - return { act_bkend: editor.actBackend }; + return { + act_bkend: editor.actBackend, + file_backend_config: editor.fileBackendConfig, + }; } return {}; } @@ -465,6 +493,7 @@ function toEditable( apiKey: config.api_key || DEFAULT_API_KEY, llmName: DEFAULT_LLM_NAME, actBackend: DEFAULT_DEEPAGENT_ACT_BACKEND, + fileBackendConfig: DEFAULT_FILE_BACKEND_CONFIG[DEFAULT_DEEPAGENT_ACT_BACKEND], }; } @@ -757,6 +786,10 @@ export default function App() { graphId === "deepagent" ? prev.actBackend || DEFAULT_DEEPAGENT_ACT_BACKEND : DEFAULT_DEEPAGENT_ACT_BACKEND, + fileBackendConfig: + graphId === "deepagent" + ? prev.fileBackendConfig || DEFAULT_FILE_BACKEND_CONFIG[DEFAULT_DEEPAGENT_ACT_BACKEND] + : DEFAULT_FILE_BACKEND_CONFIG[DEFAULT_DEEPAGENT_ACT_BACKEND], }; if (next.isDraft) { setDraftAgents((drafts) => drafts.map((draft) => (draft.id === next.id ? next : draft))); @@ -790,6 +823,24 @@ export default function App() { setEditorAndSyncDraft((prev) => ({ ...prev, [key]: value })); } + function updateActBackend(newBackend: DeepAgentActBackend): void { + setEditorAndSyncDraft((prev) => ({ + ...prev, + actBackend: newBackend, + fileBackendConfig: DEFAULT_FILE_BACKEND_CONFIG[newBackend], + })); + } + + function updateFileBackendConfig(key: keyof FileBackendConfig, value: string): void { + setEditorAndSyncDraft((prev) => ({ + ...prev, + fileBackendConfig: { + ...prev.fileBackendConfig, + [key]: value, + }, + })); + } + function updatePrompt(key: string, value: string): void { setEditorAndSyncDraft((prev) => ({ ...prev, @@ -1404,25 +1455,69 @@ export default function App() { {editor.graphId === "deepagent" ? ( - + <> + + +
+

File Backend Config

+ {editor.actBackend === "daytona_sandbox" ? ( + + ) : null} + {editor.actBackend === "local_shell" ? ( + + ) : null} + + +
+ ) : null}
diff --git a/frontend/src/styles.css b/frontend/src/styles.css index b5f8391..6c5aca5 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -224,6 +224,7 @@ button:disabled { } .prompt-section, +.file-backend-config, .run-info { border: 1px solid #dbe2ea; border-radius: 10px; @@ -232,6 +233,7 @@ button:disabled { } .prompt-section h3, +.file-backend-config h3, .run-info h3 { margin-top: 0; }