diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..ef2943d6
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,9 @@
+node_modules
+dist
+build
+coverage
+.git
+.gitignore
+.env
+.env.local
+*.log
diff --git a/.env.example b/.env.example
index 7a550fe7..18e5d42c 100644
--- a/.env.example
+++ b/.env.example
@@ -1,9 +1,15 @@
-# GEMINI_API_KEY: Required for Gemini AI API calls.
-# AI Studio automatically injects this at runtime from user secrets.
-# Users configure this via the Secrets panel in the AI Studio UI.
-GEMINI_API_KEY="MY_GEMINI_API_KEY"
-
-# APP_URL: The URL where this applet is hosted.
-# AI Studio automatically injects this at runtime with the Cloud Run service URL.
-# Used for self-referential links, OAuth callbacks, and API endpoints.
-APP_URL="MY_APP_URL"
+PORT=3001
+WORKER_PORT=3002
+MONGO_URI=mongodb://127.0.0.1:27017
+MONGO_DB=droboticflow
+MONGO_CONNECT_RETRIES=30
+MONGO_CONNECT_RETRY_DELAY_MS=2000
+WORKER_POLL_INTERVAL_MS=2000
+K8S_ENABLED=false
+K8S_NAMESPACE=droboticflow
+K8S_IMAGE_PULL_SECRET_NAME=droboticflow-registry
+OPERATOR_RUNNER_IMAGE=ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-operator-runner:latest
+VITE_API_BASE_URL=
+AI_API_BASE_URL=https://coding.dashscope.aliyuncs.com/v1
+AI_MODEL=glm-5
+AI_API_KEY=
diff --git a/Dockerfile.api b/Dockerfile.api
new file mode 100644
index 00000000..9fdf0219
--- /dev/null
+++ b/Dockerfile.api
@@ -0,0 +1,32 @@
+FROM node:22-alpine AS web-build
+WORKDIR /app
+
+COPY package*.json ./
+RUN npm ci
+
+COPY index.html metadata.json package.json tsconfig.json vite.config.ts ./
+COPY src ./src
+RUN npm run build:web
+
+FROM golang:1.24-bookworm AS go-build
+WORKDIR /src
+
+COPY go.mod go.sum ./
+RUN go mod download
+
+COPY cmd ./cmd
+COPY internal ./internal
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/droboticflow-api ./cmd/api
+
+FROM debian:bookworm-slim AS runtime
+WORKDIR /app
+ENV PORT=3001
+ENV DIST_DIR=/app/dist
+
+RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
+
+COPY --from=web-build /app/dist ./dist
+COPY --from=go-build /out/droboticflow-api /usr/local/bin/droboticflow-api
+
+EXPOSE 3001
+CMD ["droboticflow-api"]
diff --git a/Dockerfile.operator-runner b/Dockerfile.operator-runner
new file mode 100644
index 00000000..8f9fd242
--- /dev/null
+++ b/Dockerfile.operator-runner
@@ -0,0 +1,7 @@
+FROM python:3.11-slim AS runtime
+WORKDIR /app
+ENV PYTHONUNBUFFERED=1
+
+COPY backend/operator-runner/main.py ./main.py
+
+CMD ["python", "/app/main.py"]
diff --git a/Dockerfile.worker b/Dockerfile.worker
new file mode 100644
index 00000000..c8efc514
--- /dev/null
+++ b/Dockerfile.worker
@@ -0,0 +1,20 @@
+FROM golang:1.24-bookworm AS build
+WORKDIR /src
+
+COPY go.mod go.sum ./
+RUN go mod download
+
+COPY cmd ./cmd
+COPY internal ./internal
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/droboticflow-worker ./cmd/worker
+
+FROM debian:bookworm-slim AS runtime
+WORKDIR /app
+ENV WORKER_PORT=3002
+
+RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
+
+COPY --from=build /out/droboticflow-worker /usr/local/bin/droboticflow-worker
+
+EXPOSE 3002
+CMD ["droboticflow-worker"]
diff --git a/README.md b/README.md
index 87d6a68e..74509c38 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,174 @@
-
-

-
+# DRoboticFlow
-# Run and deploy your AI Studio app
+DRoboticFlow is a workflow orchestration platform for embodied AI and vision pipelines. This repository now contains:
-This contains everything you need to run your app locally.
+- a React/Vite frontend
+- a Go-based MongoDB-backed REST API
+- a Go-based worker service that executes workflow DAGs
+- a Python-based Kubernetes Job operator runner
+- deployment assets for MongoDB, Kubernetes, and Baidu Cloud Container Registry
-View your app in AI Studio: https://ai.studio/apps/0006ee57-f2f7-45cb-b325-2830a8f19364
+## Architecture
-## Run Locally
+- `cmd/api`: Go API entrypoint and SPA host
+- `cmd/worker`: Go worker entrypoint and worker control API
+- `internal/api`: REST handlers and request validation
+- `internal/worker`: run scheduler, DAG executor, audit pause/resume, worker control API
+- `internal/store`: Mongo-backed repositories plus in-memory test store
+- `internal/k8s`: Kubernetes Job launcher for operator nodes
+- `backend/operator-runner`: Python entrypoint used by Kubernetes Jobs
+- `src`: existing frontend, now wired to real APIs
+- `k8s`: Kubernetes manifest template
+- `scripts`: build, render, deploy, and smoke test scripts
+- `docs`: API, deployment, operations, and design documents
-**Prerequisites:** Node.js
+## Local Development
+### Prerequisites
+
+- Node.js 22+
+- Go 1.24+
+- Python 3.9+
+- MongoDB 7+ reachable at `MONGO_URI`
+
+### Setup
1. Install dependencies:
- `npm install`
-2. Set the `GEMINI_API_KEY` in [.env.local](.env.local) to your Gemini API key
-3. Run the app:
- `npm run dev`
+
+ ```bash
+ npm install
+ ```
+
+2. Copy the example environment file and adjust values:
+
+ ```bash
+ cp .env.example .env.local
+ ```
+
+3. Start the Go API and frontend:
+
+ ```bash
+ npm run dev
+ ```
+
+4. Start the full stack including Go worker:
+
+ ```bash
+ npm run dev:full
+ ```
+
+### Useful Scripts
+
+- `npm run lint`: type-check frontend and verify Go formatting
+- `npm test`: Go unit and integration tests
+- `npm run build`: build frontend assets and Go binaries
+- `npm run verify`: lint + test + build
+- `npm run smoke`: local smoke test against the running API and worker
+- `npm run reconcile:data -- `: remove legacy demo data, reset settings, and bootstrap built-in operators through the real API
+
+## Runtime Configuration
+
+Key environment variables:
+
+- `PORT`: API port, default `3001`
+- `WORKER_PORT`: worker port, default `3002`
+- `MONGO_URI`: MongoDB connection string
+- `MONGO_DB`: Mongo database name
+- `MONGO_CONNECT_RETRIES`: startup retry count for API and worker Mongo connections
+- `MONGO_CONNECT_RETRY_DELAY_MS`: delay between Mongo connection retries
+- `WORKER_POLL_INTERVAL_MS`: worker polling interval
+- `K8S_ENABLED`: enable Kubernetes Job execution in the worker
+- `K8S_NAMESPACE`: namespace used for Jobs
+- `K8S_IMAGE_PULL_SECRET_NAME`: image pull secret injected into operator-runner Jobs
+- `OPERATOR_RUNNER_IMAGE`: container image used for node execution Jobs
+- `AI_API_BASE_URL`: OpenAI-compatible DashScope endpoint used by server-side AI generation, default `https://coding.dashscope.aliyuncs.com/v1`
+- `AI_MODEL`: server-side model name, default `glm-5`
+- `AI_API_KEY`: server-side DashScope-compatible API key used for workflow/operator generation
+- `VITE_API_BASE_URL`: optional frontend API base URL override
+
+The frontend never reads the AI key directly. Workflow generation and operator generation are proxied through the Go API so secrets stay on the server side.
+The settings page can update K8s access details, the worker defaults, the global `timezone`, `provider`, `baseURL`, `model`, and the server-side AI key. `GET /api/settings` only returns whether secrets exist via `k8s.hasKubeconfig` / `ai.hasAPIKey`; it does not echo plaintext kubeconfig or API keys back to the browser. Timestamps in the UI are rendered in the configured IANA timezone with compact minute-level formatting for cards, lists, and summaries, while logs keep finer granularity when needed. OSS-related bucket and path settings belong on OSS operators in workflows, not in the global system settings page. The OSS browser APIs also now require the current node `SOURCE_PATH` and only list content inside that node-scoped root.
+
+Workflow execution concurrency now has two levels:
+
+- system default: `settings.worker.maxConcurrentRuns`
+- workflow override: `workflow.maxConcurrentRuns`
+
+The worker enforces both. A workflow value of `0` means "inherit the global default". Dispatch only starts queued runs while the global active run count is below the system limit and the active count for that workflow is below its effective limit.
+
+Workflow-level execution safeguards are configured alongside the other top-bar workflow settings in the editor:
+
+- `workflow.nodeTimeoutSeconds`
+ - `0`: disable workflow-level per-node timeout
+ - `1+`: fail an operator execution once a single node exceeds the configured seconds
+- `workflow.runTimeoutSeconds`
+ - `0`: disable workflow-level timeout
+ - `1+`: fail the current run once total execution time exceeds the configured seconds
+- `workflow.maxRetryAttempts`
+ - `0`: disable automatic retry
+ - `1+`: automatically enqueue a new retry run after a failure, up to the configured count
+- `workflow.retryBackoffSeconds`
+ - `0`: retry immediately
+ - `1+`: keep the retry run queued until its backoff window expires
+
+Automatic retries create real follow-up runs with `trigger=retry`, `attempt=2+`, `parentRunId` pointing at the failed attempt, and `availableAt` marking the first dispatchable time after backoff. Monitoring and history stay auditable because the original run is never mutated into the retry attempt.
+
+Workflow templates now carry the same workflow-level defaults as project workflows. When you save a workflow as a template, duplicate a template, edit a template, or instantiate a template into a project, the workflow `type`, `schedule`, and execution-safeguard fields move across with it instead of being dropped or reset.
+
+Artifact previews are persisted with the run artifacts themselves. JSON artifacts keep their structured payload in `artifact.data`, while non-JSON artifacts can attach a compact `artifact.data.preview` block for text, CSV/TSV, JSONL, images, audio/video metadata, PDF/document hints, SQLite/rosbag summaries, and LeRobot dataset summaries. Artifacts also carry `portId` / `portName`, which lets the worker route multi-output operators by edge handle instead of mixing all outputs together.
+
+The built-in operator catalog now includes real data-processing and robotics helpers on top of the original source/merge/upload/audit flow: `目录扫描`, `CSV 转 JSON`, `JSON 转 CSV`, `JSON 字段提取`, `JSON 过滤`, `JSON 映射重命名`, `文本模板渲染`, `条件分流`, `LeRobot 数据集概览`, `ROSBag 数据概览`, and `Shell 命令执行`.
+
+## Deployment
+
+The repository includes three container images:
+
+- `droboticflow-api`
+- `droboticflow-worker`
+- `droboticflow-operator-runner`
+
+The API image builds the Vite frontend and a Go binary into one container. The worker image contains a Go binary. The operator-runner image is Python-only and is launched by the worker as a Kubernetes Job.
+
+Build and push images:
+
+```bash
+./scripts/build-and-push-images.sh
+```
+
+If the target cluster cannot pull the upstream `mongo:7` image from Docker Hub, mirror it into the same Baidu registry and set `MONGO_IMAGE` during deployment.
+
+Render Kubernetes manifests:
+
+```bash
+./scripts/render-manifests.sh
+```
+
+Deploy to Kubernetes:
+
+```bash
+./scripts/deploy-k8s.sh
+```
+
+Reconcile persistent API data after deployment:
+
+```bash
+./scripts/reconcile-system-data.sh http://:30080
+```
+
+Run a smoke test locally:
+
+```bash
+npm run smoke
+```
+
+Run a smoke test against a deployed cluster:
+
+```bash
+./scripts/smoke-test.sh http://:30080
+```
+
+See the detailed guides:
+
+- [`docs/api.md`](/Users/longtaowu/workspace/droboticflow/docs/api.md)
+- [`docs/deployment.md`](/Users/longtaowu/workspace/droboticflow/docs/deployment.md)
+- [`docs/operations.md`](/Users/longtaowu/workspace/droboticflow/docs/operations.md)
diff --git a/backend/operator-runner/main.py b/backend/operator-runner/main.py
new file mode 100644
index 00000000..24198b4e
--- /dev/null
+++ b/backend/operator-runner/main.py
@@ -0,0 +1,1470 @@
+#!/usr/bin/env python3
+from __future__ import annotations
+
+import datetime as dt
+import fnmatch
+import hashlib
+import json
+import mimetypes
+import os
+import pathlib
+import base64
+import csv
+import re
+import resource
+import shutil
+import sqlite3
+import subprocess
+import sys
+import time
+from typing import Any
+
+
+RESULT_PREFIX = "DROBOTICFLOW_RESULT="
+TEXT_FILE_SUFFIXES = {
+ ".txt",
+ ".log",
+ ".md",
+ ".yaml",
+ ".yml",
+ ".xml",
+ ".html",
+ ".htm",
+}
+TABULAR_FILE_SUFFIXES = {".csv": ",", ".tsv": "\t"}
+IMAGE_FILE_SUFFIXES = {".jpg", ".jpeg", ".png", ".bmp", ".webp", ".gif"}
+VIDEO_FILE_SUFFIXES = {".mp4", ".mov", ".avi", ".mkv", ".webm"}
+AUDIO_FILE_SUFFIXES = {".wav", ".mp3", ".aac", ".m4a", ".ogg", ".flac"}
+ROSBAG_FILE_SUFFIXES = {".bag", ".db3", ".mcap"}
+PREVIEW_TEXT_LIMIT = 12_000
+PREVIEW_TEXT_LINE_LIMIT = 240
+PREVIEW_TABLE_ROW_LIMIT = 24
+PREVIEW_FILE_LIST_LIMIT = 40
+PREVIEW_INLINE_BINARY_LIMIT = 512 * 1024
+
+
+def now_iso() -> str:
+ return dt.datetime.now(dt.timezone.utc).isoformat().replace("+00:00", "Z")
+
+
+def log(message: str) -> None:
+ print(message, flush=True)
+
+
+def load_json_env(name: str, default: Any) -> Any:
+ value = os.getenv(name, "").strip()
+ if not value:
+ return default
+ return json.loads(value)
+
+
+def resource_snapshot() -> tuple[float, int]:
+ usage = resource.getrusage(resource.RUSAGE_SELF)
+ cpu_seconds = usage.ru_utime + usage.ru_stime
+ if sys.platform == "darwin":
+ memory_mib = max(1, int(usage.ru_maxrss / (1024 * 1024)))
+ else:
+ memory_mib = max(1, int(usage.ru_maxrss / 1024))
+ return cpu_seconds, memory_mib
+
+
+def resource_series(start_cpu: float, start_memory: int, started_at: str) -> list[dict[str, Any]]:
+ end_cpu, end_memory = resource_snapshot()
+ ended_at = now_iso()
+ started = dt.datetime.fromisoformat(started_at.replace("Z", "+00:00"))
+ ended = dt.datetime.fromisoformat(ended_at.replace("Z", "+00:00"))
+ elapsed = max((ended - started).total_seconds(), 0.001)
+ cpu_percent = max(0, min(100, int(((end_cpu - start_cpu) / elapsed) * 100)))
+ return [
+ {"timestamp": started_at, "cpu": 0, "memory": start_memory, "gpu": 0},
+ {"timestamp": ended_at, "cpu": cpu_percent, "memory": end_memory, "gpu": 0},
+ ]
+
+
+def format_size(num_bytes: int) -> str:
+ if num_bytes < 1024:
+ return f"{num_bytes} B"
+ if num_bytes < 1024 * 1024:
+ return f"{num_bytes / 1024:.1f} KiB"
+ if num_bytes < 1024 * 1024 * 1024:
+ return f"{num_bytes / (1024 * 1024):.1f} MiB"
+ return f"{num_bytes / (1024 * 1024 * 1024):.2f} GiB"
+
+
+def sha256_file(path: pathlib.Path) -> str:
+ digest = hashlib.sha256()
+ with path.open("rb") as handle:
+ for chunk in iter(lambda: handle.read(65536), b""):
+ digest.update(chunk)
+ return digest.hexdigest()
+
+
+def artifact_slug(value: str) -> str:
+ normalized = re.sub(r"[^a-zA-Z0-9_.-]+", "-", value).strip("-")
+ return normalized or "artifact"
+
+
+def infer_port_type(path: pathlib.Path, fallback: str = "file") -> str:
+ suffix = path.suffix.lower()
+ if suffix == ".json":
+ return "json"
+ if suffix in VIDEO_FILE_SUFFIXES:
+ return "video"
+ if suffix in IMAGE_FILE_SUFFIXES:
+ return "image"
+ return fallback
+
+
+def clean_metadata(metadata: dict[str, Any]) -> dict[str, Any] | None:
+ cleaned = {key: value for key, value in metadata.items() if value not in ("", None, [], {})}
+ return cleaned or None
+
+
+def load_payload_from_file(path: pathlib.Path) -> dict[str, Any] | None:
+ if not path.exists() or path.suffix.lower() != ".json":
+ return None
+ try:
+ with path.open("r", encoding="utf-8") as handle:
+ value = json.load(handle)
+ except Exception:
+ return None
+ if isinstance(value, dict):
+ return value
+ if isinstance(value, list):
+ return {"items": value, "itemCount": len(value)}
+ return {"value": value}
+
+
+def output_binding(node_data: dict[str, Any], index: int = 0, name: str = "") -> dict[str, Any] | None:
+ outputs = node_data.get("outputs", []) or []
+ if name:
+ for output in outputs:
+ if str(output.get("name", "")).strip() == name or str(output.get("id", "")).strip() == name:
+ return output
+ if 0 <= index < len(outputs):
+ return outputs[index]
+ return None
+
+
+def read_text_sample(path: pathlib.Path) -> tuple[str, bool, int]:
+ with path.open("rb") as handle:
+ raw = handle.read(PREVIEW_TEXT_LIMIT + 1)
+ truncated = len(raw) > PREVIEW_TEXT_LIMIT
+ text = raw[:PREVIEW_TEXT_LIMIT].decode("utf-8", errors="replace")
+ lines = text.splitlines()
+ if len(lines) > PREVIEW_TEXT_LINE_LIMIT:
+ text = "\n".join(lines[:PREVIEW_TEXT_LINE_LIMIT])
+ truncated = True
+ line_count = max(1, text.count("\n") + 1) if text else 0
+ return text, truncated, line_count
+
+
+def preview_text_payload(path: pathlib.Path, format_name: str) -> dict[str, Any]:
+ text, truncated, line_count = read_text_sample(path)
+ return {
+ "preview": {
+ "kind": "text",
+ "format": format_name,
+ "text": text,
+ "truncated": truncated,
+ "lineCount": line_count,
+ }
+ }
+
+
+def preview_tabular_payload(path: pathlib.Path, delimiter: str, format_name: str) -> dict[str, Any]:
+ columns: list[str] = []
+ rows: list[dict[str, Any]] = []
+ total_rows = 0
+ with path.open("r", encoding="utf-8", errors="replace", newline="") as handle:
+ reader = csv.reader(handle, delimiter=delimiter)
+ for index, row in enumerate(reader):
+ if index == 0:
+ columns = [cell or f"column_{col_index + 1}" for col_index, cell in enumerate(row)]
+ continue
+ total_rows += 1
+ if len(rows) >= PREVIEW_TABLE_ROW_LIMIT:
+ continue
+ width = max(len(columns), len(row))
+ row_payload: dict[str, Any] = {}
+ for column_index in range(width):
+ column_name = columns[column_index] if column_index < len(columns) else f"column_{column_index + 1}"
+ row_payload[column_name] = row[column_index] if column_index < len(row) else ""
+ rows.append(row_payload)
+ return {
+ "preview": {
+ "kind": "table",
+ "format": format_name,
+ "columns": columns,
+ "rows": rows,
+ "rowCount": total_rows,
+ "truncated": total_rows > len(rows),
+ }
+ }
+
+
+def load_tabular_rows(path: pathlib.Path, delimiter: str) -> tuple[list[str], list[dict[str, Any]]]:
+ columns: list[str] = []
+ rows: list[dict[str, Any]] = []
+ with path.open("r", encoding="utf-8", errors="replace", newline="") as handle:
+ reader = csv.reader(handle, delimiter=delimiter)
+ for index, row in enumerate(reader):
+ if index == 0:
+ columns = [cell or f"column_{col_index + 1}" for col_index, cell in enumerate(row)]
+ continue
+ width = max(len(columns), len(row))
+ row_payload: dict[str, Any] = {}
+ for column_index in range(width):
+ column_name = columns[column_index] if column_index < len(columns) else f"column_{column_index + 1}"
+ row_payload[column_name] = row[column_index] if column_index < len(row) else ""
+ rows.append(row_payload)
+ return columns, rows
+
+
+def preview_jsonl_payload(path: pathlib.Path) -> dict[str, Any]:
+ rows: list[Any] = []
+ line_count = 0
+ with path.open("r", encoding="utf-8", errors="replace") as handle:
+ for raw_line in handle:
+ line = raw_line.strip()
+ if not line:
+ continue
+ line_count += 1
+ if len(rows) >= PREVIEW_TABLE_ROW_LIMIT:
+ continue
+ try:
+ rows.append(json.loads(line))
+ except Exception:
+ rows.append({"value": line})
+ columns: list[str] = []
+ for row in rows:
+ if isinstance(row, dict):
+ for key in row.keys():
+ if key not in columns:
+ columns.append(key)
+ return {
+ "preview": {
+ "kind": "table",
+ "format": "jsonl",
+ "columns": columns,
+ "rows": rows,
+ "rowCount": line_count,
+ "truncated": line_count > len(rows),
+ }
+ }
+
+
+def preview_image_payload(path: pathlib.Path, mime_type: str) -> dict[str, Any]:
+ payload: dict[str, Any] = {
+ "preview": {
+ "kind": "image",
+ "format": path.suffix.lower().lstrip(".") or "image",
+ }
+ }
+ size_bytes = path.stat().st_size if path.exists() else 0
+ if size_bytes and size_bytes <= PREVIEW_INLINE_BINARY_LIMIT and mime_type:
+ encoded = base64.b64encode(path.read_bytes()).decode("ascii")
+ payload["preview"]["url"] = f"data:{mime_type};base64,{encoded}"
+ return payload
+
+
+def sample_file_entries(paths: list[pathlib.Path], root: pathlib.Path) -> list[dict[str, Any]]:
+ items: list[dict[str, Any]] = []
+ for candidate in paths[:PREVIEW_FILE_LIST_LIMIT]:
+ try:
+ relative = candidate.relative_to(root).as_posix()
+ except ValueError:
+ relative = candidate.name
+ items.append({"path": relative, "sizeBytes": candidate.stat().st_size})
+ return items
+
+
+def summarize_directory_tree(root: pathlib.Path) -> dict[str, Any]:
+ files = [candidate for candidate in sorted(root.rglob("*")) if candidate.is_file()]
+ extensions: dict[str, int] = {}
+ total_bytes = 0
+ for candidate in files:
+ extension = candidate.suffix.lower() or ""
+ extensions[extension] = extensions.get(extension, 0) + 1
+ total_bytes += candidate.stat().st_size
+ ranked_extensions = sorted(extensions.items(), key=lambda item: (-item[1], item[0]))
+ return {
+ "root": str(root),
+ "fileCount": len(files),
+ "totalBytes": total_bytes,
+ "topExtensions": [{"extension": extension, "count": count} for extension, count in ranked_extensions[:12]],
+ "files": sample_file_entries(files, root),
+ "truncated": len(files) > PREVIEW_FILE_LIST_LIMIT,
+ }
+
+
+def optional_json_file(path: pathlib.Path) -> Any:
+ if not path.exists():
+ return None
+ try:
+ with path.open("r", encoding="utf-8") as handle:
+ return json.load(handle)
+ except Exception:
+ return None
+
+
+def optional_jsonl_rows(path: pathlib.Path) -> list[Any]:
+ rows: list[Any] = []
+ if not path.exists():
+ return rows
+ try:
+ with path.open("r", encoding="utf-8", errors="replace") as handle:
+ for raw_line in handle:
+ line = raw_line.strip()
+ if not line:
+ continue
+ rows.append(json.loads(line))
+ if len(rows) >= PREVIEW_TABLE_ROW_LIMIT:
+ break
+ except Exception:
+ return []
+ return rows
+
+
+def find_lerobot_root(path: pathlib.Path) -> pathlib.Path | None:
+ candidates = [path] if path.is_dir() else [path.parent]
+ candidates.extend(list((path if path.is_dir() else path.parent).parents))
+ for candidate in candidates:
+ meta_dir = candidate / "meta"
+ if meta_dir.is_dir() and any((meta_dir / name).exists() for name in ("info.json", "stats.json", "tasks.jsonl")):
+ return candidate
+ return None
+
+
+def summarize_lerobot_root(root: pathlib.Path) -> dict[str, Any]:
+ tree = summarize_directory_tree(root)
+ meta_dir = root / "meta"
+ info = optional_json_file(meta_dir / "info.json")
+ stats = optional_json_file(meta_dir / "stats.json")
+ tasks = optional_jsonl_rows(meta_dir / "tasks.jsonl")
+ episodes = optional_jsonl_rows(meta_dir / "episodes.jsonl")
+ parquet_files = [candidate for candidate in root.rglob("*.parquet") if candidate.is_file()]
+ video_files = [candidate for candidate in root.rglob("*") if candidate.is_file() and candidate.suffix.lower() in VIDEO_FILE_SUFFIXES]
+ return {
+ "preview": {
+ "kind": "dataset",
+ "format": "lerobot",
+ "root": str(root),
+ "summary": tree,
+ "info": info,
+ "stats": stats,
+ "tasks": tasks,
+ "episodes": episodes,
+ "parquetFiles": sample_file_entries(parquet_files, root),
+ "parquetCount": len(parquet_files),
+ "videoCount": len(video_files),
+ }
+ }
+
+
+def sqlite_table_names(connection: sqlite3.Connection) -> list[str]:
+ rows = connection.execute(
+ "select name from sqlite_master where type='table' and name not like 'sqlite_%' order by name"
+ ).fetchall()
+ return [str(row[0]) for row in rows]
+
+
+def summarize_sqlite_payload(path: pathlib.Path) -> dict[str, Any]:
+ connection = sqlite3.connect(f"file:{path}?mode=ro", uri=True)
+ try:
+ tables = sqlite_table_names(connection)
+ table_summaries: list[dict[str, Any]] = []
+ for table_name in tables[:12]:
+ count = connection.execute(f"select count(*) from \"{table_name}\"").fetchone()[0]
+ table_summaries.append({"name": table_name, "rowCount": int(count)})
+ payload: dict[str, Any] = {
+ "preview": {
+ "kind": "dataset",
+ "format": "sqlite",
+ "tables": table_summaries,
+ "tableCount": len(tables),
+ }
+ }
+ if "topics" in tables and "messages" in tables:
+ topic_rows = connection.execute(
+ "select id, name, type, serialization_format from topics order by id"
+ ).fetchall()
+ message_counts = {
+ int(topic_id): int(count)
+ for topic_id, count in connection.execute(
+ "select topic_id, count(*) from messages group by topic_id order by topic_id"
+ ).fetchall()
+ }
+ payload["preview"]["format"] = "rosbag2"
+ payload["preview"]["topics"] = [
+ {
+ "id": int(topic_id),
+ "name": str(name),
+ "type": str(topic_type),
+ "serialization": str(serialization),
+ "messageCount": message_counts.get(int(topic_id), 0),
+ }
+ for topic_id, name, topic_type, serialization in topic_rows[:PREVIEW_TABLE_ROW_LIMIT]
+ ]
+ payload["preview"]["messageCount"] = int(sum(message_counts.values()))
+ return payload
+ finally:
+ connection.close()
+
+
+def summarize_rosbag_file(path: pathlib.Path) -> dict[str, Any]:
+ suffix = path.suffix.lower()
+ if suffix == ".db3":
+ return summarize_sqlite_payload(path)
+ header = ""
+ with path.open("rb") as handle:
+ header = handle.read(32).decode("utf-8", errors="replace")
+ format_name = "mcap" if suffix == ".mcap" else "rosbag1"
+ return {
+ "preview": {
+ "kind": "dataset",
+ "format": format_name,
+ "header": header.strip(),
+ "note": "文件已识别,但深度解析依赖外部运行时;当前展示真实文件摘要和元数据。",
+ }
+ }
+
+
+def resolve_source_path(params: dict[str, str], inputs: list[dict[str, Any]]) -> pathlib.Path | None:
+ direct = params.get("SOURCE_PATH", "").strip()
+ if direct and pathlib.Path(direct).exists():
+ return pathlib.Path(direct)
+ for artifact in inputs:
+ payload = artifact.get("data")
+ if isinstance(payload, dict):
+ candidate = payload.get("sourcePath")
+ if isinstance(candidate, str) and candidate and pathlib.Path(candidate).exists():
+ return pathlib.Path(candidate)
+ source_path = artifact.get("path")
+ if isinstance(source_path, str) and source_path and pathlib.Path(source_path).exists():
+ return pathlib.Path(source_path)
+ return None
+
+
+def artifact_preview_payload(artifact: dict[str, Any]) -> dict[str, Any] | None:
+ data = artifact.get("data")
+ if not isinstance(data, dict):
+ return None
+ preview = data.get("preview")
+ if isinstance(preview, dict):
+ return preview
+ return None
+
+
+def summarize_input_artifacts(inputs: list[dict[str, Any]]) -> dict[str, Any]:
+ extensions: dict[str, int] = {}
+ files: list[dict[str, Any]] = []
+ for artifact in inputs:
+ name = str(artifact.get("name", "") or artifact.get("path", "")).strip()
+ extension = pathlib.Path(name).suffix.lower() or ""
+ extensions[extension] = extensions.get(extension, 0) + 1
+ files.append(
+ {
+ "path": str(artifact.get("path", "")).strip() or name,
+ "name": name,
+ "size": str(artifact.get("size", "")),
+ }
+ )
+ ranked_extensions = sorted(extensions.items(), key=lambda item: (-item[1], item[0]))
+ return {
+ "fileCount": len(files),
+ "topExtensions": [{"extension": extension, "count": count} for extension, count in ranked_extensions[:12]],
+ "files": files[:PREVIEW_FILE_LIST_LIMIT],
+ "truncated": len(files) > PREVIEW_FILE_LIST_LIMIT,
+ }
+
+
+def infer_lerobot_root_from_inputs(inputs: list[dict[str, Any]]) -> str:
+ for artifact in inputs:
+ raw_path = str(artifact.get("path", "")).strip()
+ if not raw_path:
+ continue
+ parts = pathlib.PurePosixPath(raw_path).parts
+ for marker in ("meta", "data", "videos"):
+ if marker in parts:
+ index = parts.index(marker)
+ if index > 0:
+ return str(pathlib.PurePosixPath(*parts[:index]))
+ return ""
+
+
+def summarize_lerobot_from_inputs(inputs: list[dict[str, Any]]) -> dict[str, Any]:
+ info = None
+ stats = None
+ tasks: list[Any] = []
+ episodes: list[Any] = []
+ parquet_files: list[dict[str, Any]] = []
+ video_count = 0
+ for artifact in inputs:
+ name = str(artifact.get("name", "")).strip()
+ path = str(artifact.get("path", "")).strip()
+ data = artifact.get("data") if isinstance(artifact.get("data"), dict) else {}
+ preview = artifact_preview_payload(artifact) or {}
+ if name == "info.json" and isinstance(data, dict):
+ info = data
+ elif name == "stats.json" and isinstance(data, dict):
+ stats = data
+ elif name.endswith("tasks.jsonl") and isinstance(preview.get("rows"), list):
+ tasks = preview["rows"]
+ elif name.endswith("episodes.jsonl") and isinstance(preview.get("rows"), list):
+ episodes = preview["rows"]
+ if name.endswith(".parquet"):
+ parquet_files.append({"path": path or name, "size": str(artifact.get("size", ""))})
+ if pathlib.Path(name).suffix.lower() in VIDEO_FILE_SUFFIXES or str(artifact.get("type", "")) == "video":
+ video_count += 1
+ return {
+ "preview": {
+ "kind": "dataset",
+ "format": "lerobot",
+ "root": infer_lerobot_root_from_inputs(inputs),
+ "summary": summarize_input_artifacts(inputs),
+ "info": info,
+ "stats": stats,
+ "tasks": tasks,
+ "episodes": episodes,
+ "parquetFiles": parquet_files[:PREVIEW_FILE_LIST_LIMIT],
+ "parquetCount": len(parquet_files),
+ "videoCount": video_count,
+ }
+ }
+
+
+def extract_preview_data(path: pathlib.Path, artifact_type: str, mime_type: str) -> dict[str, Any] | None:
+ suffix = path.suffix.lower()
+ if suffix in TABULAR_FILE_SUFFIXES:
+ return preview_tabular_payload(path, TABULAR_FILE_SUFFIXES[suffix], suffix.lstrip("."))
+ if suffix == ".jsonl":
+ return preview_jsonl_payload(path)
+ if suffix in TEXT_FILE_SUFFIXES:
+ format_name = "html" if suffix in {".html", ".htm"} else suffix.lstrip(".")
+ return preview_text_payload(path, format_name)
+ if suffix in IMAGE_FILE_SUFFIXES:
+ return preview_image_payload(path, mime_type)
+ if suffix in ROSBAG_FILE_SUFFIXES:
+ return summarize_rosbag_file(path)
+ if suffix == ".pdf":
+ return {"preview": {"kind": "document", "format": "pdf"}}
+ if artifact_type == "video" or suffix in VIDEO_FILE_SUFFIXES:
+ return {"preview": {"kind": "video", "format": suffix.lstrip(".") or "video"}}
+ if suffix in AUDIO_FILE_SUFFIXES or mime_type.startswith("audio/"):
+ return {"preview": {"kind": "audio", "format": suffix.lstrip(".") or "audio"}}
+ return None
+
+
+def build_artifact(
+ run_id: str,
+ node_id: str,
+ path: pathlib.Path,
+ artifact_type: str,
+ data: dict[str, Any] | None = None,
+ metadata: dict[str, Any] | None = None,
+ output: dict[str, Any] | None = None,
+) -> dict[str, Any]:
+ mime_type, _ = mimetypes.guess_type(path.name)
+ artifact_metadata = clean_metadata(
+ {
+ **(metadata or {}),
+ "sha256": sha256_file(path) if path.exists() else "",
+ "mimeType": mime_type or "",
+ }
+ )
+ size_bytes = path.stat().st_size if path.exists() else len(json.dumps(data or {}, ensure_ascii=False).encode("utf-8"))
+ artifact = {
+ "id": f"{run_id}-{node_id}-{artifact_slug(str(output.get('id', '')) if output else path.stem)}-{artifact_slug(path.name)}",
+ "runId": run_id,
+ "nodeId": node_id,
+ "name": path.name,
+ "type": artifact_type,
+ "size": format_size(size_bytes),
+ "path": str(path),
+ }
+ if output:
+ if str(output.get("id", "")).strip():
+ artifact["portId"] = str(output.get("id", "")).strip()
+ if str(output.get("name", "")).strip():
+ artifact["portName"] = str(output.get("name", "")).strip()
+ if artifact_metadata:
+ artifact["metadata"] = artifact_metadata
+ if data:
+ artifact["data"] = data
+ return artifact
+
+
+def write_json_artifact(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ filename: str,
+ payload: dict[str, Any],
+ artifact_type: str = "json",
+ output: dict[str, Any] | None = None,
+) -> dict[str, Any]:
+ path = output_dir / filename
+ path.parent.mkdir(parents=True, exist_ok=True)
+ with path.open("w", encoding="utf-8") as handle:
+ json.dump(payload, handle, ensure_ascii=False, indent=2)
+ return build_artifact(run_id, node_id, path, artifact_type, data=payload, output=output)
+
+
+def summarize_json_like(value: Any) -> dict[str, Any]:
+ if isinstance(value, dict):
+ return {"kind": "object", "keys": sorted(value.keys())}
+ if isinstance(value, list):
+ return {"kind": "list", "length": len(value)}
+ return {"kind": type(value).__name__, "value": value}
+
+
+def load_artifact_payload(artifact: dict[str, Any]) -> dict[str, Any]:
+ data = artifact.get("data")
+ if isinstance(data, dict):
+ return data
+ path_value = artifact.get("path")
+ if isinstance(path_value, str) and path_value:
+ payload = load_payload_from_file(pathlib.Path(path_value))
+ if payload is not None:
+ return payload
+ summary = {
+ "name": artifact.get("name", ""),
+ "type": artifact.get("type", ""),
+ "path": artifact.get("path", ""),
+ "size": artifact.get("size", ""),
+ }
+ return {key: value for key, value in summary.items() if value}
+
+
+def merge_dicts(values: list[dict[str, Any]]) -> dict[str, Any]:
+ merged: dict[str, Any] = {}
+ for value in values:
+ merged.update(value)
+ return merged
+
+
+def list_source_entries(base_path: pathlib.Path, pattern: str) -> list[dict[str, Any]]:
+ entries: list[dict[str, Any]] = []
+ if not base_path.exists():
+ return entries
+ if base_path.is_file():
+ relative = base_path.name
+ if pattern and not fnmatch.fnmatch(relative, pattern):
+ return entries
+ return [
+ {
+ "path": relative,
+ "sizeBytes": base_path.stat().st_size,
+ "sha256": sha256_file(base_path),
+ }
+ ]
+ for candidate in sorted(base_path.rglob("*")):
+ if candidate.is_dir():
+ continue
+ relative = candidate.relative_to(base_path).as_posix()
+ if pattern and not fnmatch.fnmatch(relative, pattern):
+ continue
+ entries.append(
+ {
+ "path": relative,
+ "sizeBytes": candidate.stat().st_size,
+ "sha256": sha256_file(candidate),
+ }
+ )
+ return entries
+
+
+def collect_output_artifacts(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any] | None = None,
+ output: dict[str, Any] | None = None,
+) -> list[dict[str, Any]]:
+ artifacts: list[dict[str, Any]] = []
+ for path in sorted(output_dir.rglob("*")):
+ if path.is_dir():
+ continue
+ artifact_type = infer_port_type(path)
+ mime_type, _ = mimetypes.guess_type(path.name)
+ if artifact_type == "json":
+ payload = load_payload_from_file(path)
+ else:
+ payload = extract_preview_data(path, artifact_type, mime_type or "")
+ binding = output
+ if binding is None and node_data is not None:
+ binding = output_binding(node_data)
+ artifacts.append(build_artifact(run_id, node_id, path, artifact_type, data=payload, output=binding))
+ return artifacts
+
+
+def hyperparams(node_data: dict[str, Any]) -> dict[str, str]:
+ values: dict[str, str] = {}
+ for item in node_data.get("hyperparams", []) or []:
+ key = str(item.get("key", "")).strip()
+ if not key:
+ continue
+ values[key] = str(item.get("value", ""))
+ return values
+
+
+def parse_json_param(params: dict[str, str], key: str, default: Any) -> Any:
+ raw = params.get(key, "").strip()
+ if not raw:
+ return default
+ try:
+ return json.loads(raw)
+ except Exception:
+ return default
+
+
+def payloads_from_inputs(inputs: list[dict[str, Any]]) -> list[dict[str, Any]]:
+ return [load_artifact_payload(item) for item in inputs]
+
+
+def collect_items(payloads: list[dict[str, Any]]) -> list[Any]:
+ items: list[Any] = []
+ for payload in payloads:
+ if isinstance(payload.get("items"), list):
+ items.extend(payload["items"])
+ elif isinstance(payload.get("entries"), list):
+ items.extend(payload["entries"])
+ elif isinstance(payload.get("rows"), list):
+ items.extend(payload["rows"])
+ else:
+ items.append(payload)
+ return items
+
+
+def get_field_value(value: Any, field_path: str) -> Any:
+ current = value
+ for token in [part for part in field_path.split(".") if part]:
+ if isinstance(current, dict):
+ current = current.get(token)
+ continue
+ if isinstance(current, list) and token.isdigit():
+ index = int(token)
+ if 0 <= index < len(current):
+ current = current[index]
+ continue
+ return None
+ return current
+
+
+def compare_values(actual: Any, operator: str, expected: Any) -> bool:
+ if operator == "exists":
+ return actual is not None
+ if operator == "missing":
+ return actual is None
+ if operator == "contains":
+ if isinstance(actual, list):
+ return expected in actual
+ return str(expected) in str(actual)
+ if operator == "in":
+ if isinstance(expected, list):
+ return actual in expected
+ return str(actual) in str(expected)
+ if operator in {"gt", "gte", "lt", "lte"}:
+ try:
+ actual_number = float(actual)
+ expected_number = float(expected)
+ except Exception:
+ return False
+ if operator == "gt":
+ return actual_number > expected_number
+ if operator == "gte":
+ return actual_number >= expected_number
+ if operator == "lt":
+ return actual_number < expected_number
+ return actual_number <= expected_number
+ if operator == "ne":
+ return actual != expected
+ return actual == expected
+
+
+def flatten_context(value: Any, prefix: str = "") -> dict[str, str]:
+ context: dict[str, str] = {}
+ if isinstance(value, dict):
+ for key, item in value.items():
+ next_prefix = f"{prefix}.{key}" if prefix else str(key)
+ context.update(flatten_context(item, next_prefix))
+ if prefix:
+ context[prefix] = json.dumps(value, ensure_ascii=False)
+ return context
+ if isinstance(value, list):
+ for index, item in enumerate(value[:8]):
+ next_prefix = f"{prefix}.{index}" if prefix else str(index)
+ context.update(flatten_context(item, next_prefix))
+ if prefix:
+ context[prefix] = json.dumps(value, ensure_ascii=False)
+ return context
+ if prefix:
+ context[prefix] = "" if value is None else str(value)
+ return context
+
+
+def render_template_text(template_text: str, context: dict[str, str]) -> str:
+ rendered = template_text
+ for key, value in context.items():
+ rendered = rendered.replace("{{" + key + "}}", value)
+ safe_context = {key: value for key, value in context.items()}
+
+ class SafeDict(dict):
+ def __missing__(self, key: str) -> str:
+ return "{" + key + "}"
+
+ try:
+ rendered = rendered.format_map(SafeDict(safe_context))
+ except Exception:
+ pass
+ return rendered
+
+
+def rows_from_payloads(payloads: list[dict[str, Any]]) -> list[dict[str, Any]]:
+ rows: list[dict[str, Any]] = []
+ for item in collect_items(payloads):
+ if isinstance(item, dict):
+ rows.append(item)
+ else:
+ rows.append({"value": item})
+ return rows
+
+
+def write_text_artifact(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ filename: str,
+ content: str,
+ output: dict[str, Any] | None = None,
+) -> dict[str, Any]:
+ path = output_dir / filename
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(content, encoding="utf-8")
+ mime_type, _ = mimetypes.guess_type(path.name)
+ preview = extract_preview_data(path, infer_port_type(path), mime_type or "")
+ return build_artifact(run_id, node_id, path, infer_port_type(path), data=preview, output=output)
+
+
+def write_csv_artifact(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ filename: str,
+ rows: list[dict[str, Any]],
+ output: dict[str, Any] | None = None,
+) -> dict[str, Any]:
+ path = output_dir / filename
+ path.parent.mkdir(parents=True, exist_ok=True)
+ columns: list[str] = []
+ for row in rows:
+ for key in row.keys():
+ if key not in columns:
+ columns.append(key)
+ with path.open("w", encoding="utf-8", newline="") as handle:
+ writer = csv.DictWriter(handle, fieldnames=columns or ["value"])
+ writer.writeheader()
+ if rows:
+ writer.writerows(rows)
+ preview = preview_tabular_payload(path, ",", "csv")
+ return build_artifact(run_id, node_id, path, "file", data=preview, output=output)
+
+
+def builtin_source(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ source_path = params.get("SOURCE_PATH") or os.getenv("SOURCE_PATH", "").strip()
+ prefix = str(node_data.get("prefix", "") or os.getenv("STORAGE_PREFIX", "")).strip()
+ bucket = str(node_data.get("bucket", "") or os.getenv("STORAGE_BUCKET", "")).strip()
+ pattern = str(node_data.get("pattern", "") or os.getenv("STORAGE_PATTERN", "")).strip()
+
+ entries: list[dict[str, Any]] = []
+ if source_path:
+ entries = list_source_entries(pathlib.Path(source_path), pattern)
+ elif prefix and pathlib.Path(prefix).exists():
+ entries = list_source_entries(pathlib.Path(prefix), pattern)
+ elif params.get("SOURCE_JSON"):
+ parsed = json.loads(params["SOURCE_JSON"])
+ if isinstance(parsed, list):
+ entries = [{"value": item} for item in parsed]
+ else:
+ entries = [{"value": parsed}]
+ elif params.get("SOURCE_TEXT"):
+ entries = [{"text": params["SOURCE_TEXT"]}]
+ elif inputs:
+ entries = [load_artifact_payload(item) for item in inputs]
+
+ payload = {
+ "bucket": bucket,
+ "prefix": prefix,
+ "pattern": pattern,
+ "sourcePath": source_path,
+ "entries": entries,
+ }
+ return [write_json_artifact(run_id, node_id, output_dir, "source-manifest.json", payload, output=output_binding(node_data))]
+
+
+def builtin_merge(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ payloads = payloads_from_inputs(inputs)
+ merged = merge_dicts(payloads)
+ merged["inputCount"] = len(payloads)
+ return [write_json_artifact(run_id, node_id, output_dir, "merged.json", merged, output=output_binding(node_data))]
+
+
+def builtin_intersection(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ payloads = payloads_from_inputs(inputs)
+ if not payloads:
+ return [
+ write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ "intersection.json",
+ {"keys": [], "inputCount": 0},
+ output=output_binding(node_data),
+ )
+ ]
+ key_sets = [set(payload.keys()) for payload in payloads]
+ common_keys = sorted(set.intersection(*key_sets)) if key_sets else []
+ payload = {"keys": common_keys, "values": {key: payloads[0].get(key) for key in common_keys}}
+ return [write_json_artifact(run_id, node_id, output_dir, "intersection.json", payload, output=output_binding(node_data))]
+
+
+def builtin_distribution(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ payloads = payloads_from_inputs(inputs)
+ items = collect_items(payloads)
+ outputs = node_data.get("outputs", []) or [{"name": "queue-a", "type": "json"}]
+ partitions: list[list[Any]] = [[] for _ in outputs]
+ for index, item in enumerate(items):
+ partitions[index % len(outputs)].append(item)
+ artifacts: list[dict[str, Any]] = []
+ for index, output in enumerate(outputs):
+ filename = f"{output.get('name', f'queue-{index}')}.json"
+ payload = {"items": partitions[index], "count": len(partitions[index])}
+ artifacts.append(
+ write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ filename,
+ payload,
+ str(output.get("type", "json")),
+ output=output,
+ )
+ )
+ return artifacts
+
+
+def builtin_upload(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ copied_paths: list[str] = []
+ bundle_inputs: list[dict[str, Any]] = []
+ staging_dir = output_dir / "uploaded"
+ staging_dir.mkdir(parents=True, exist_ok=True)
+
+ for artifact in inputs:
+ payload = load_artifact_payload(artifact)
+ bundle_inputs.append(payload)
+ source_path = artifact.get("path")
+ if isinstance(source_path, str) and source_path and os.path.exists(source_path):
+ source = pathlib.Path(source_path)
+ destination = staging_dir / source.name
+ if source.resolve() != destination.resolve():
+ shutil.copy2(source, destination)
+ copied_paths.append(str(destination))
+
+ payload = {"copiedPaths": copied_paths, "items": bundle_inputs, "inputCount": len(inputs)}
+ artifacts = [write_json_artifact(run_id, node_id, output_dir, "uploaded-results.json", payload, output=output_binding(node_data))]
+ artifacts.extend(collect_output_artifacts(run_id, node_id, staging_dir))
+ return artifacts
+
+
+def builtin_json_extract(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ field_path = params.get("FIELD_PATH", "").strip()
+ payloads = payloads_from_inputs(inputs)
+ payload = payloads[0] if payloads else {}
+ extracted = get_field_value(payload, field_path) if field_path else payload
+ result = {"fieldPath": field_path, "value": extracted}
+ return [write_json_artifact(run_id, node_id, output_dir, "extracted.json", result, output=output_binding(node_data))]
+
+
+def builtin_json_filter(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ field_path = params.get("FIELD_PATH", "").strip()
+ operator = params.get("OPERATOR", "eq").strip().lower() or "eq"
+ expected = parse_json_param(params, "EXPECTED_JSON", params.get("EXPECTED", ""))
+ rows = collect_items(payloads_from_inputs(inputs))
+ filtered = [row for row in rows if compare_values(get_field_value(row, field_path), operator, expected)]
+ payload = {
+ "fieldPath": field_path,
+ "operator": operator,
+ "expected": expected,
+ "items": filtered,
+ "count": len(filtered),
+ }
+ return [write_json_artifact(run_id, node_id, output_dir, "filtered.json", payload, output=output_binding(node_data))]
+
+
+def builtin_json_map(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ field_map = parse_json_param(params, "FIELD_MAP_JSON", {})
+ rows = rows_from_payloads(payloads_from_inputs(inputs))
+ mapped = [{str(field_map.get(key, key)): value for key, value in row.items()} for row in rows]
+ payload = {"fieldMap": field_map, "items": mapped, "count": len(mapped)}
+ return [write_json_artifact(run_id, node_id, output_dir, "mapped.json", payload, output=output_binding(node_data))]
+
+
+def builtin_text_template(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ template_text = params.get("TEMPLATE_TEXT", "").strip()
+ output_name = params.get("OUTPUT_NAME", "").strip() or "rendered.txt"
+ payloads = payloads_from_inputs(inputs)
+ context = flatten_context(payloads[0] if payloads else {})
+ rendered = render_template_text(template_text, context)
+ binding = output_binding(node_data)
+ manifest = write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ "rendered-template.json",
+ {"template": template_text, "context": context, "outputName": output_name},
+ output=binding,
+ )
+ return [manifest, write_text_artifact(run_id, node_id, output_dir, output_name, rendered, output=binding)]
+
+
+def builtin_csv_to_json(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ source_path = resolve_source_path(params, inputs)
+ payload: dict[str, Any]
+ if source_path is not None and source_path.suffix.lower() in TABULAR_FILE_SUFFIXES:
+ delimiter = TABULAR_FILE_SUFFIXES[source_path.suffix.lower()]
+ columns, rows = load_tabular_rows(source_path, delimiter)
+ payload = {
+ "sourcePath": str(source_path),
+ "columns": columns,
+ "items": rows,
+ "rowCount": len(rows),
+ }
+ else:
+ for artifact in inputs:
+ preview = artifact_preview_payload(artifact) or {}
+ if preview.get("kind") == "table":
+ payload = {
+ "sourcePath": str(artifact.get("path", "")),
+ "columns": preview.get("columns", []),
+ "items": preview.get("rows", []),
+ "rowCount": preview.get("rowCount", len(preview.get("rows", []))),
+ "previewTruncated": preview.get("truncated", False),
+ }
+ return [
+ write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ "table.json",
+ payload,
+ output=output_binding(node_data),
+ )
+ ]
+ raise RuntimeError("CSV 转 JSON 需要 SOURCE_PATH 或上游 artifact 指向真实 csv/tsv 文件")
+ return [write_json_artifact(run_id, node_id, output_dir, "table.json", payload, output=output_binding(node_data))]
+
+
+def builtin_json_to_csv(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ rows = rows_from_payloads(payloads_from_inputs(inputs))
+ binding = output_binding(node_data)
+ summary = write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ "csv-export-summary.json",
+ {"rowCount": len(rows), "columns": sorted({key for row in rows for key in row.keys()})},
+ output=binding,
+ )
+ return [summary, write_csv_artifact(run_id, node_id, output_dir, "rows.csv", rows, output=binding)]
+
+
+def builtin_directory_scan(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ source_path = resolve_source_path(params, inputs)
+ if source_path is not None:
+ root = source_path if source_path.is_dir() else source_path.parent
+ payload = {
+ "sourcePath": str(source_path),
+ "scanRoot": str(root),
+ "summary": summarize_directory_tree(root),
+ }
+ elif inputs:
+ payload = {
+ "sourcePath": "",
+ "scanRoot": "",
+ "summary": summarize_input_artifacts(inputs),
+ }
+ else:
+ raise RuntimeError("目录扫描需要 SOURCE_PATH 或上游 artifact 指向真实目录")
+ return [write_json_artifact(run_id, node_id, output_dir, "directory-scan.json", payload, output=output_binding(node_data))]
+
+
+def builtin_condition_router(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ field_path = params.get("FIELD_PATH", "").strip()
+ operator = params.get("OPERATOR", "eq").strip().lower() or "eq"
+ expected = parse_json_param(params, "EXPECTED_JSON", params.get("EXPECTED", ""))
+ rows = collect_items(payloads_from_inputs(inputs))
+ matched = [row for row in rows if compare_values(get_field_value(row, field_path), operator, expected)]
+ unmatched = [row for row in rows if not compare_values(get_field_value(row, field_path), operator, expected)]
+ outputs = node_data.get("outputs", []) or [
+ {"id": "matched", "name": "matched", "type": "json"},
+ {"id": "unmatched", "name": "unmatched", "type": "json"},
+ ]
+ return [
+ write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ f"{str(outputs[0].get('name', 'matched')).strip() or 'matched'}.json",
+ {"fieldPath": field_path, "operator": operator, "expected": expected, "items": matched, "count": len(matched)},
+ str(outputs[0].get("type", "json")),
+ output=outputs[0],
+ ),
+ write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ f"{str(outputs[1].get('name', 'unmatched')).strip() or 'unmatched'}.json",
+ {"fieldPath": field_path, "operator": operator, "expected": expected, "items": unmatched, "count": len(unmatched)},
+ str(outputs[1].get("type", "json")),
+ output=outputs[1],
+ ),
+ ]
+
+
+def builtin_lerobot_summary(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ source_path = resolve_source_path(params, inputs)
+ if source_path is not None:
+ root = find_lerobot_root(source_path) or (source_path if source_path.is_dir() else source_path.parent)
+ payload = summarize_lerobot_root(root)
+ payload["sourcePath"] = str(source_path)
+ elif inputs:
+ payload = summarize_lerobot_from_inputs(inputs)
+ payload["sourcePath"] = ""
+ else:
+ raise RuntimeError("LeRobot 数据集概览需要 SOURCE_PATH 或上游 artifact 指向真实数据集目录")
+ payload["datasetType"] = "lerobot"
+ return [write_json_artifact(run_id, node_id, output_dir, "lerobot-summary.json", payload, output=output_binding(node_data))]
+
+
+def builtin_rosbag_summary(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ params = hyperparams(node_data)
+ source_path = resolve_source_path(params, inputs)
+ if source_path is not None:
+ if source_path.is_dir():
+ payload = {
+ "datasetType": "rosbag2",
+ "sourcePath": str(source_path),
+ "summary": summarize_directory_tree(source_path),
+ }
+ metadata_yaml = source_path / "metadata.yaml"
+ if metadata_yaml.exists():
+ payload["metadata"] = preview_text_payload(metadata_yaml, "yaml")["preview"]
+ db3_files = [candidate for candidate in source_path.rglob("*.db3") if candidate.is_file()]
+ if db3_files:
+ payload["databasePreview"] = summarize_sqlite_payload(db3_files[0])["preview"]
+ return [write_json_artifact(run_id, node_id, output_dir, "rosbag-summary.json", payload, output=output_binding(node_data))]
+ payload = summarize_rosbag_file(source_path)
+ payload["datasetType"] = payload.get("preview", {}).get("format", "rosbag")
+ payload["sourcePath"] = str(source_path)
+ else:
+ for artifact in inputs:
+ preview = artifact_preview_payload(artifact) or {}
+ if preview.get("kind") == "dataset" and preview.get("format") in {"rosbag2", "rosbag1", "mcap", "sqlite"}:
+ payload = {
+ "datasetType": preview.get("format", "rosbag"),
+ "sourcePath": str(artifact.get("path", "")),
+ "preview": preview,
+ }
+ return [write_json_artifact(run_id, node_id, output_dir, "rosbag-summary.json", payload, output=output_binding(node_data))]
+ raise RuntimeError("ROS bag 概览需要 SOURCE_PATH 或上游 artifact 指向真实 bag/db3/mcap 文件")
+ return [write_json_artifact(run_id, node_id, output_dir, "rosbag-summary.json", payload, output=output_binding(node_data))]
+
+
+def builtin_generic(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_label: str,
+ node_data: dict[str, Any],
+ inputs: list[dict[str, Any]],
+) -> list[dict[str, Any]]:
+ payloads = [load_artifact_payload(item) for item in inputs]
+ summary = {
+ "nodeLabel": node_label,
+ "inputCount": len(inputs),
+ "inputs": [summarize_json_like(item) for item in payloads],
+ "config": {
+ "bucket": node_data.get("bucket", ""),
+ "prefix": node_data.get("prefix", ""),
+ "pattern": node_data.get("pattern", ""),
+ },
+ }
+ outputs = node_data.get("outputs", []) or [{"name": "result", "type": "json"}]
+ artifacts: list[dict[str, Any]] = []
+ for index, output in enumerate(outputs):
+ output_name = str(output.get("name", f"output-{index}")).strip() or f"output-{index}"
+ filename = f"{output_name}.json"
+ payload = {**summary, "outputName": output_name}
+ artifacts.append(
+ write_json_artifact(
+ run_id,
+ node_id,
+ output_dir,
+ filename,
+ payload,
+ str(output.get("type", "json")),
+ output=output,
+ )
+ )
+ return artifacts
+
+
+def execute_command(
+ run_id: str,
+ node_id: str,
+ output_dir: pathlib.Path,
+ node_data: dict[str, Any],
+ command: str,
+) -> list[dict[str, Any]]:
+ completed = subprocess.run(
+ command,
+ cwd=output_dir,
+ shell=True,
+ text=True,
+ capture_output=True,
+ env=os.environ.copy(),
+ check=False,
+ )
+ for stream_name, content in (("stdout", completed.stdout), ("stderr", completed.stderr)):
+ for line in content.splitlines():
+ if line.strip():
+ log(f"[operator-runner][command][{stream_name}] {line}")
+ if completed.returncode != 0:
+ raise RuntimeError(f"command failed with exit code {completed.returncode}")
+ artifacts = collect_output_artifacts(run_id, node_id, output_dir, node_data=node_data)
+ if artifacts:
+ return artifacts
+ payload = {"stdout": completed.stdout, "stderr": completed.stderr}
+ return [write_json_artifact(run_id, node_id, output_dir, "command-output.json", payload, output=output_binding(node_data))]
+
+
+def select_handler(node_label: str) -> str:
+ normalized = node_label.lower()
+ if "lerobot" in normalized:
+ return "lerobot"
+ if any(token in normalized for token in ("rosbag", "mcap", "ros bag")):
+ return "rosbag"
+ if any(token in normalized for token in ("csv 转 json", "csv转json", "csv to json", "tsv 转 json", "tsv转json", "tsv to json")):
+ return "csv_to_json"
+ if any(token in normalized for token in ("json 转 csv", "json转csv", "json to csv")):
+ return "json_to_csv"
+ if any(token in normalized for token in ("字段提取", "json提取", "json 提取", "extract")):
+ return "json_extract"
+ if any(token in normalized for token in ("json过滤", "json 过滤", "filter")):
+ return "json_filter"
+ if any(token in normalized for token in ("json映射", "json 映射", "rename", "映射重命名")):
+ return "json_map"
+ if any(token in normalized for token in ("模板渲染", "template")):
+ return "text_template"
+ if any(token in normalized for token in ("条件分流", "conditional", "router", "route")):
+ return "condition_router"
+ if any(token in normalized for token in ("目录扫描", "directory", "browse", "browse dir")):
+ return "directory_scan"
+ if any(token in normalized for token in ("merge", "合并")):
+ return "merge"
+ if any(token in normalized for token in ("intersect", "交集")):
+ return "intersection"
+ if any(token in normalized for token in ("distribution", "分配")):
+ return "distribution"
+ if any(token in normalized for token in ("upload", "export", "上传", "导出")):
+ return "upload"
+ if any(token in normalized for token in ("source", "scanner", "oss", "scan", "扫描")):
+ return "source"
+ return "generic"
+
+
+def main() -> int:
+ run_id = os.getenv("RUN_ID", "").strip()
+ workflow_id = os.getenv("WORKFLOW_ID", "").strip()
+ node_id = os.getenv("NODE_ID", "").strip()
+ node_label = os.getenv("NODE_LABEL", "").strip() or node_id
+ output_dir = pathlib.Path(os.getenv("OUTPUT_DIR", tempfile_dir(run_id, node_id)))
+ output_dir.mkdir(parents=True, exist_ok=True)
+
+ node_data = load_json_env("NODE_DATA_JSON", {})
+ inputs = load_json_env("INPUT_ARTIFACTS_JSON", [])
+ started_at = now_iso()
+ start_cpu, start_memory = resource_snapshot()
+
+ logs: list[dict[str, Any]] = []
+
+ def append_log(level: str, message: str) -> None:
+ logs.append({"timestamp": now_iso(), "level": level, "message": message, "operator": node_label})
+ log(f"[operator-runner][{level.lower()}] {message}")
+
+ append_log("INFO", f"run={run_id} workflow={workflow_id} node={node_id} output_dir={output_dir}")
+ append_log("INFO", "Preparing operator execution context")
+
+ params = hyperparams(node_data)
+ command = params.get("COMMAND") or params.get("SCRIPT")
+ artifacts: list[dict[str, Any]]
+ if command:
+ append_log("INFO", f"Executing explicit command: {command}")
+ artifacts = execute_command(run_id, node_id, output_dir, node_data, command)
+ else:
+ handler = select_handler(node_label)
+ append_log("INFO", f"Selected built-in handler: {handler}")
+ if handler == "source":
+ artifacts = builtin_source(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "merge":
+ artifacts = builtin_merge(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "intersection":
+ artifacts = builtin_intersection(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "distribution":
+ artifacts = builtin_distribution(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "json_extract":
+ artifacts = builtin_json_extract(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "json_filter":
+ artifacts = builtin_json_filter(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "json_map":
+ artifacts = builtin_json_map(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "text_template":
+ artifacts = builtin_text_template(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "csv_to_json":
+ artifacts = builtin_csv_to_json(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "json_to_csv":
+ artifacts = builtin_json_to_csv(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "directory_scan":
+ artifacts = builtin_directory_scan(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "condition_router":
+ artifacts = builtin_condition_router(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "lerobot":
+ artifacts = builtin_lerobot_summary(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "rosbag":
+ artifacts = builtin_rosbag_summary(run_id, node_id, output_dir, node_data, inputs)
+ elif handler == "upload":
+ artifacts = builtin_upload(run_id, node_id, output_dir, node_data, inputs)
+ else:
+ artifacts = builtin_generic(run_id, node_id, output_dir, node_label, node_data, inputs)
+
+ append_log("INFO", f"Produced {len(artifacts)} artifact(s)")
+ result = {
+ "logs": logs,
+ "artifacts": artifacts,
+ "resourceSeries": resource_series(start_cpu, start_memory, started_at),
+ }
+ print(RESULT_PREFIX + json.dumps(result, ensure_ascii=False), flush=True)
+ return 0
+
+
+def tempfile_dir(run_id: str, node_id: str) -> str:
+ base = pathlib.Path("/tmp/droboticflow")
+ return str(base / (run_id or "run") / (node_id or "node"))
+
+
+if __name__ == "__main__":
+ try:
+ sys.exit(main())
+ except Exception as error: # pragma: no cover
+ log(f"[operator-runner][error] {error}")
+ sys.exit(1)
diff --git a/cmd/api/main.go b/cmd/api/main.go
new file mode 100644
index 00000000..68fe2ef1
--- /dev/null
+++ b/cmd/api/main.go
@@ -0,0 +1,86 @@
+package main
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "os"
+ "path/filepath"
+ "strings"
+ "time"
+
+ "droboticflow/internal/ai"
+ "droboticflow/internal/api"
+ "droboticflow/internal/config"
+ "droboticflow/internal/retry"
+ "droboticflow/internal/store"
+
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/mongo/options"
+)
+
+func connectMongo(ctx context.Context, mongoURI string, attempts int, delay time.Duration) (*mongo.Client, error) {
+ return retry.Do(ctx, attempts, delay, "mongodb connection", func(ctx context.Context, _ int) (*mongo.Client, error) {
+ client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoURI))
+ if err != nil {
+ return nil, err
+ }
+ if err := client.Ping(ctx, nil); err != nil {
+ _ = client.Disconnect(ctx)
+ return nil, err
+ }
+ return client, nil
+ })
+}
+
+func spaHandler(apiHandler http.Handler, distDir string) http.Handler {
+ fileServer := http.FileServer(http.Dir(distDir))
+ indexPath := filepath.Join(distDir, "index.html")
+
+ return http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
+ if strings.HasPrefix(request.URL.Path, "/api/") || strings.HasPrefix(request.URL.Path, "/worker-api/") {
+ apiHandler.ServeHTTP(writer, request)
+ return
+ }
+ if request.URL.Path == "/" {
+ fileServer.ServeHTTP(writer, request)
+ return
+ }
+ targetPath := filepath.Join(distDir, filepath.Clean(request.URL.Path))
+ if _, err := os.Stat(targetPath); err == nil {
+ fileServer.ServeHTTP(writer, request)
+ return
+ }
+ http.ServeFile(writer, request, indexPath)
+ })
+}
+
+func main() {
+ ctx := context.Background()
+ cfg := config.Load()
+ client, err := connectMongo(ctx, cfg.MongoURI, cfg.MongoConnectRetries, time.Duration(cfg.MongoConnectRetryDelayMS)*time.Millisecond)
+ if err != nil {
+ fmt.Printf("[api] failed to connect mongo: %v\n", err)
+ os.Exit(1)
+ }
+ defer func() {
+ _ = client.Disconnect(context.Background())
+ }()
+
+ dataStore := store.NewMongoStore(client.Database(cfg.MongoDB))
+
+ aiService := ai.NewService(cfg.AIAPIBaseURL, cfg.AIAPIKey, cfg.AIModel)
+ handler := spaHandler(api.NewHandler(dataStore, aiService), cfg.DistDir)
+ server := &http.Server{
+ Addr: fmt.Sprintf("0.0.0.0:%d", cfg.Port),
+ Handler: handler,
+ ReadHeaderTimeout: 10 * time.Second,
+ }
+
+ fmt.Printf("[api] listening on http://0.0.0.0:%d\n", cfg.Port)
+ if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
+ fmt.Printf("[api] failed to start: %v\n", err)
+ os.Exit(1)
+ }
+}
diff --git a/cmd/worker/main.go b/cmd/worker/main.go
new file mode 100644
index 00000000..6579d5dc
--- /dev/null
+++ b/cmd/worker/main.go
@@ -0,0 +1,78 @@
+package main
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "net/http"
+ "os"
+ "time"
+
+ "droboticflow/internal/config"
+ "droboticflow/internal/retry"
+ "droboticflow/internal/store"
+ "droboticflow/internal/worker"
+
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/mongo/options"
+)
+
+func connectMongo(ctx context.Context, mongoURI string, attempts int, delay time.Duration) (*mongo.Client, error) {
+ return retry.Do(ctx, attempts, delay, "mongodb connection", func(ctx context.Context, _ int) (*mongo.Client, error) {
+ client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoURI))
+ if err != nil {
+ return nil, err
+ }
+ if err := client.Ping(ctx, nil); err != nil {
+ _ = client.Disconnect(ctx)
+ return nil, err
+ }
+ return client, nil
+ })
+}
+
+func main() {
+ ctx := context.Background()
+ cfg := config.Load()
+ client, err := connectMongo(ctx, cfg.MongoURI, cfg.MongoConnectRetries, time.Duration(cfg.MongoConnectRetryDelayMS)*time.Millisecond)
+ if err != nil {
+ fmt.Printf("[worker] failed to connect mongo: %v\n", err)
+ os.Exit(1)
+ }
+ defer func() {
+ _ = client.Disconnect(context.Background())
+ }()
+
+ dataStore := store.NewMongoStore(client.Database(cfg.MongoDB))
+ mode := "local"
+ if cfg.K8sEnabled {
+ mode = "k8s"
+ }
+ runtime, err := worker.NewRuntime(dataStore, mode, cfg.K8sNamespace, cfg.K8sImagePullSecretName, cfg.OperatorRunnerImage, cfg.LocalOperatorRunnerCmd)
+ if err != nil {
+ fmt.Printf("[worker] failed to initialize runtime: %v\n", err)
+ os.Exit(1)
+ }
+
+ go func() {
+ ticker := time.NewTicker(time.Duration(cfg.PollIntervalMS) * time.Millisecond)
+ defer ticker.Stop()
+ for range ticker.C {
+ if err := runtime.ProcessAvailable(context.Background()); err != nil {
+ fmt.Printf("[worker] processAvailable failed: %v\n", err)
+ }
+ }
+ }()
+
+ server := &http.Server{
+ Addr: fmt.Sprintf("0.0.0.0:%d", cfg.WorkerPort),
+ Handler: worker.NewHTTPHandler(dataStore, runtime),
+ ReadHeaderTimeout: 10 * time.Second,
+ }
+
+ fmt.Printf("[worker] listening on http://0.0.0.0:%d\n", cfg.WorkerPort)
+ if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
+ fmt.Printf("[worker] failed to start: %v\n", err)
+ os.Exit(1)
+ }
+}
diff --git a/docs/api.md b/docs/api.md
new file mode 100644
index 00000000..6b847a1c
--- /dev/null
+++ b/docs/api.md
@@ -0,0 +1,261 @@
+# API Reference
+
+## REST API
+
+Base path: `/api`
+
+### Health and Dashboard
+
+- `GET /api/health`: service health check
+- `GET /api/ai/status`: returns whether server-side AI generation is enabled and which model is configured
+- `POST /api/ai/operators/generate`: generate a custom operator definition from natural language
+- `POST /api/ai/workflows/generate`: generate a workflow graph from natural language and the current operator catalog
+- `GET /api/dashboard`: aggregate counts for projects, operators, jobs, and audits
+
+`POST /api/ai/operators/generate`
+
+```json
+{
+ "description": "生成一个算子,用于接收视频输入,抽取关键帧并输出图片列表。"
+}
+```
+
+`POST /api/ai/workflows/generate`
+
+```json
+{
+ "description": "从对象存储读取视频,抽帧后调用目标检测算子,再把检测结果回传到对象存储。"
+}
+```
+
+### Projects
+
+- `GET /api/projects`
+- `POST /api/projects`
+- `GET /api/projects/:id`
+- `PUT /api/projects/:id`
+- `DELETE /api/projects/:id`
+- `GET /api/projects/:id/workflows`
+- `POST /api/projects/:id/workflows`
+
+`POST /api/projects`
+
+```json
+{
+ "name": "自动驾驶新项目",
+ "description": "处理多摄像头感知数据"
+}
+```
+
+### Workflows
+
+- `GET /api/workflows/:id`
+- `PUT /api/workflows/:id`
+- `DELETE /api/workflows/:id`
+- `POST /api/workflows/:id/run`
+
+`PUT /api/workflows/:id`
+
+```json
+{
+ "name": "视觉处理流程",
+ "description": "包含扫描、推理、上传",
+ "type": "batch",
+ "maxConcurrentRuns": 2,
+ "nodeTimeoutSeconds": 120,
+ "runTimeoutSeconds": 300,
+ "maxRetryAttempts": 1,
+ "retryBackoffSeconds": 30,
+ "nodes": [],
+ "edges": []
+}
+```
+
+`POST /api/workflows/:id/run`
+
+```json
+{
+ "trigger": "manual"
+}
+```
+
+### Templates
+
+- `GET /api/templates`
+- `POST /api/templates`
+- `GET /api/templates/:id`
+- `PUT /api/templates/:id`
+- `DELETE /api/templates/:id`
+
+Templates now persist the same workflow-level defaults used by project workflows, including `type`, `schedule`, `maxConcurrentRuns`, `nodeTimeoutSeconds`, `runTimeoutSeconds`, `maxRetryAttempts`, and `retryBackoffSeconds`.
+
+### Operators
+
+- `GET /api/operators`
+- `POST /api/operators`
+- `GET /api/operators/:id`
+- `PUT /api/operators/:id`
+- `DELETE /api/operators/:id`
+
+The reconciled built-in catalog includes the original workflow primitives plus:
+
+- `目录扫描`
+- `CSV 转 JSON`
+- `JSON 转 CSV`
+- `JSON 字段提取`
+- `JSON 过滤`
+- `JSON 映射重命名`
+- `文本模板渲染`
+- `条件分流`
+- `LeRobot 数据集概览`
+- `ROSBag 数据概览`
+- `Shell 命令执行`
+
+`POST /api/operators`
+
+```json
+{
+ "name": "自定义分割算子",
+ "type": "custom",
+ "category": "AI",
+ "description": "执行图像分割",
+ "inputs": [{ "id": "in-1", "name": "图像", "type": "image" }],
+ "outputs": [{ "id": "out-1", "name": "结果", "type": "json" }],
+ "image": "ccr.example.com/dataflow/custom-seg:latest"
+}
+```
+
+### Runs and Monitoring
+
+- `GET /api/runs`
+- `GET /api/runs/:id`
+- `GET /api/runs/:id/logs`
+- `GET /api/runs/:id/resources`
+- `GET /api/runs/:id/artifacts`
+
+`GET /api/runs/:id/artifacts`
+
+Each artifact item can now include:
+
+- `portId` / `portName`: the originating output port so downstream edges can route multi-output operators correctly
+- `metadata.mimeType` / `metadata.sha256`: persisted file metadata
+- `data`: the real JSON payload for JSON artifacts
+- `data.preview`: a compact preview object for non-JSON artifacts such as text, CSV/TSV, JSONL, image thumbnails, audio/video metadata, PDF hints, SQLite/rosbag summaries, and LeRobot dataset summaries
+
+### Audit
+
+- `GET /api/audit-tasks`
+- `POST /api/audit-tasks/:id/approve`
+- `POST /api/audit-tasks/:id/reject`
+
+### Users and Settings
+
+- `GET /api/users`
+- `PUT /api/users/:id`
+- `GET /api/settings`
+- `PUT /api/settings`
+
+`GET /api/settings`
+
+```json
+{
+ "id": "system",
+ "k8s": {
+ "enabled": true,
+ "endpoint": "https://120.48.161.230:6443",
+ "namespace": "droboticflow",
+ "hasKubeconfig": true
+ },
+ "worker": {
+ "pollIntervalMs": 2000,
+ "maxConcurrentRuns": 2
+ },
+ "ai": {
+ "provider": "dashscope-openai-compatible",
+ "baseURL": "https://coding.dashscope.aliyuncs.com/v1",
+ "model": "glm-5",
+ "hasAPIKey": true
+ },
+ "timezone": "Asia/Shanghai"
+}
+```
+
+`PUT /api/settings`
+
+```json
+{
+ "timezone": "Asia/Shanghai",
+ "worker": {
+ "maxConcurrentRuns": 2
+ },
+ "ai": {
+ "provider": "dashscope-openai-compatible",
+ "baseURL": "https://coding.dashscope.aliyuncs.com/v1",
+ "model": "glm-5",
+ "apiKey": "sk-..."
+ }
+}
+```
+
+Workflow create/update payloads also accept workflow-level execution settings:
+
+- `0`: inherit the global worker default
+- `1+`: workflow-specific maximum active runs
+
+Dispatch enforces both the global worker limit and the workflow-specific limit.
+
+- `runTimeoutSeconds`
+ - `0`: disable workflow-level timeout
+ - `1+`: fail the current run if total execution time exceeds this many seconds
+- `nodeTimeoutSeconds`
+ - `0`: disable workflow-level per-node timeout
+ - `1+`: fail the current node if a single operator execution exceeds this many seconds
+- `maxRetryAttempts`
+ - `0`: disable automatic retry
+ - `1+`: automatically enqueue up to N retry runs after a failed attempt
+- `retryBackoffSeconds`
+ - `0`: enqueue retry runs immediately
+ - `1+`: delay retry dispatch by the configured number of seconds
+
+Run responses may also include:
+
+- `attempt`: current attempt number, starting from `1`
+- `parentRunId`: the failed run that spawned this retry run
+- `availableAt`: when this queued run becomes eligible for dispatch; retry backoff uses this field
+
+### Storage
+
+- `GET /api/storage/buckets?sourcePath=`
+- `GET /api/storage/objects?sourcePath=&bucket=&prefix=`
+
+## Worker API
+
+Base path: `/worker-api`
+
+- `GET /worker-api/health`: worker health check
+- `GET /worker-api/stats`: current queue/running/audit counts
+- `POST /worker-api/process-once`: process one queued run immediately
+- `POST /worker-api/runs/:id/retry`: reset a run to `queued` and clear prior execution state
+
+## Response Shape Notes
+
+- list endpoints return `{ "items": [...] }`
+- delete endpoints return `204 No Content`
+- validation failures return `400`
+- missing resources return `404`
+- AI service unavailable returns `503`
+- upstream AI gateway failures return `502`
+- unhandled server errors return `500`
+
+## Implementation Notes
+
+- `/api/*` is served by the Go API binary in [`cmd/api`](/Users/longtaowu/workspace/droboticflow/cmd/api).
+- `/worker-api/*` is served by the Go worker binary in [`cmd/worker`](/Users/longtaowu/workspace/droboticflow/cmd/worker).
+- Workflow execution and storage models are defined in [`internal/domain`](/Users/longtaowu/workspace/droboticflow/internal/domain) and [`internal/store`](/Users/longtaowu/workspace/droboticflow/internal/store).
+- AI generation is implemented by [`internal/ai`](/Users/longtaowu/workspace/droboticflow/internal/ai) and is called only from the Go API, never directly from the browser.
+- `GET /api/settings` never returns the saved AI key in plaintext. It only exposes `ai.hasAPIKey` so the browser can show whether a server-side key is already configured.
+- `timezone` uses IANA timezone identifiers such as `Asia/Shanghai` or `America/Los_Angeles`. The frontend formats timestamps with second precision in that timezone.
+- Monitoring previews are rendered from the persisted artifact payload itself, so text/table/robotics previews keep working after the Kubernetes Job has exited and its local filesystem is gone.
+- OSS 相关配置不通过 `/api/settings` 管理。系统设置页只维护 K8s、worker、AI 和默认资源;OSS bucket/prefix 等参数由具体工作流节点维护。
+- `/api/storage/*` 也不再读取系统级存储根目录。浏览请求必须显式传入当前 OSS 节点超参里的 `SOURCE_PATH`,API 只在这个节点上下文内列 bucket 和对象。
+- Kubernetes Jobs launched for operator nodes use the Python entrypoint at [`backend/operator-runner/main.py`](/Users/longtaowu/workspace/droboticflow/backend/operator-runner/main.py).
diff --git a/docs/deployment.md b/docs/deployment.md
new file mode 100644
index 00000000..2d85f742
--- /dev/null
+++ b/docs/deployment.md
@@ -0,0 +1,141 @@
+# Deployment Guide
+
+## Images
+
+This project deploys three images:
+
+- `droboticflow-api`
+- `droboticflow-worker`
+- `droboticflow-operator-runner`
+
+Default Baidu registry naming:
+
+- `ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-api:`
+- `ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-worker:`
+- `ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-operator-runner:`
+
+## 1. Log In to the Registry
+
+Use the public endpoint unless you are deploying from the same VPC as the registry:
+
+```bash
+docker login ccr-29eug8s3-pub.cnc.bj.baidubce.com --username
+```
+
+## 2. Build and Push Images
+
+```bash
+IMAGE_TAG=20260408 ./scripts/build-and-push-images.sh
+```
+
+Image contents:
+
+- `droboticflow-api`: Vite frontend assets + Go API binary
+- `droboticflow-worker`: Go worker binary
+- `droboticflow-operator-runner`: Python runtime + `backend/operator-runner/main.py`
+
+The script prints the exact image URLs. Reuse those values for deployment:
+
+```bash
+API_IMAGE=...
+WORKER_IMAGE=...
+OPERATOR_RUNNER_IMAGE=...
+```
+
+If the target cluster cannot pull `mongo:7` directly from Docker Hub, mirror it to the same Baidu registry:
+
+```bash
+docker buildx build \
+ --platform linux/amd64 \
+ -t ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-mongo:7-amd64 \
+ --push \
+ - <<'EOF'
+FROM mongo:7
+EOF
+```
+
+## 3. Prepare Kubernetes Access
+
+Point `kubectl` at the target cluster before deploying. The deployment scripts do not store kubeconfig in the repository.
+
+Recommended environment variables:
+
+```bash
+export K8S_NAMESPACE=droboticflow
+export API_IMAGE=ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-api:20260408
+export WORKER_IMAGE=ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-worker:20260408
+export OPERATOR_RUNNER_IMAGE=ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-operator-runner:20260408
+export MONGO_IMAGE=ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-mongo:7-amd64
+export REGISTRY_SERVER=ccr-29eug8s3-pub.cnc.bj.baidubce.com
+export REGISTRY_USERNAME=
+export REGISTRY_PASSWORD=
+export K8S_IMAGE_PULL_SECRET_NAME=droboticflow-registry
+export AI_API_BASE_URL=https://coding.dashscope.aliyuncs.com/v1
+export AI_MODEL=glm-5
+export AI_API_KEY=
+```
+
+## 4. Deploy
+
+```bash
+./scripts/deploy-k8s.sh
+```
+
+The deploy script performs these actions:
+
+1. creates the namespace if it does not exist
+2. creates or updates the image pull secret
+3. creates or updates MongoDB credentials, reusing the existing Secret values when present
+4. creates or updates the `droboticflow-ai-secret` Secret for server-side AI generation
+5. renders `k8s/droboticflow.template.yaml`
+6. applies the manifest to the cluster
+7. waits for MongoDB, API, and worker rollouts
+
+## 5. Services Created
+
+- `mongodb`: ClusterIP service for MongoDB
+- `droboticflow-api`: NodePort service that exposes the frontend and API
+- `droboticflow-worker`: ClusterIP service for worker health/debugging
+
+Default API NodePort:
+
+- `30080`
+
+If the cluster node IP is reachable, the UI and API are exposed at:
+
+```text
+http://:30080
+```
+
+## 6. Manifest Variables
+
+`scripts/render-manifests.sh` accepts:
+
+- `K8S_NAMESPACE`
+- `MONGO_DB`
+- `MONGO_CONNECT_RETRIES`
+- `MONGO_CONNECT_RETRY_DELAY_MS`
+- `WORKER_POLL_INTERVAL_MS`
+- `API_NODE_PORT`
+- `API_REPLICAS`
+- `WORKER_REPLICAS`
+- `K8S_IMAGE_PULL_SECRET_NAME`
+- `AI_API_BASE_URL`
+- `AI_MODEL`
+- `API_IMAGE`
+- `WORKER_IMAGE`
+- `OPERATOR_RUNNER_IMAGE`
+- `MONGO_IMAGE`
+
+## 7. Notes
+
+- The provided manifest uses a single-replica MongoDB Deployment with `emptyDir` storage so it can run on clusters that do not expose a default `StorageClass`.
+- MongoDB should be mirrored to the Baidu registry as an `amd64` image when the cluster cannot pull from Docker Hub.
+- For production, replace the `emptyDir` volume with a PVC-backed deployment or StatefulSet.
+- API and worker entrypoints are Go binaries with Mongo startup retry, so they tolerate the database becoming ready after the Deployments start.
+- The worker runs with Kubernetes RBAC that allows creating and watching Jobs in the namespace.
+- The operator-runner Job template inherits the private registry pull secret name from `K8S_IMAGE_PULL_SECRET_NAME`.
+- The operator-runner is not a standalone Deployment. It is launched on demand as a Python Job container.
+- AI generation runs through the API Deployment. `AI_API_KEY` is mounted through the `droboticflow-ai-secret` Secret and must not be baked into frontend env vars.
+- If you use DashScope-compatible models, prefer a backend-allowed API key. Do not deploy tool-only Coding Plan keys into the cluster.
+- Production hardening still depends on the target cluster policy: TLS ingress, network policies, backup strategy, and secret rotation.
diff --git a/docs/operations.md b/docs/operations.md
new file mode 100644
index 00000000..788d9006
--- /dev/null
+++ b/docs/operations.md
@@ -0,0 +1,125 @@
+# Operations Guide
+
+## Service Responsibilities
+
+### API
+
+- validates incoming payloads
+- persists projects, workflows, operators, templates, settings, runs, and audit tasks
+- serves the built SPA in production
+- runs as a single Go binary
+
+### Worker
+
+- polls MongoDB for queued runs
+- auto-enqueues streaming workflows based on `schedule.interval`
+- executes workflow nodes in topological order
+- pauses runs on human-review nodes
+- resumes approved or rejected audit branches
+- creates Kubernetes Jobs when `K8S_ENABLED=true`
+- runs as a single Go binary
+
+### Operator Runner
+
+- receives `RUN_ID`, `WORKFLOW_ID`, `NODE_ID`, and `NODE_LABEL`
+- executes a generic Python operator contract
+- emits logs for the worker to associate with the run
+
+## MongoDB Collections
+
+- `projects`
+- `operators`
+- `workflows`
+- `templates`
+- `runs`
+- `auditTasks`
+- `users`
+- `settings`
+
+## Run Lifecycle
+
+1. frontend calls `POST /api/workflows/:id/run`
+2. API inserts a `queued` run document
+3. worker claims the run and marks it `running`
+4. worker executes start nodes and records logs, resource samples, and artifacts
+5. if a node requires review, the run moves to `waiting_for_audit`
+6. audit action updates the task to `approved` or `rejected`
+7. worker resumes the graph from the appropriate edge
+8. run ends in `completed` or `failed`
+
+## Local Verification
+
+Run the full verification loop:
+
+```bash
+npm run verify
+```
+
+Start the stack locally:
+
+```bash
+npm run dev:full
+```
+
+Smoke test the API and worker:
+
+```bash
+./scripts/smoke-test.sh
+```
+
+Reconcile persistent system data and remove legacy demo records:
+
+```bash
+./scripts/reconcile-system-data.sh http://127.0.0.1:3001
+```
+
+## Kubernetes Verification
+
+Check workloads:
+
+```bash
+kubectl -n droboticflow get pods
+kubectl -n droboticflow get jobs
+kubectl -n droboticflow get svc
+```
+
+Inspect logs:
+
+```bash
+kubectl -n droboticflow logs deploy/droboticflow-api
+kubectl -n droboticflow logs deploy/droboticflow-worker
+kubectl -n droboticflow logs job/
+```
+
+## Common Failure Modes
+
+### API starts but returns Mongo errors
+
+- confirm `mongodb` pod is healthy
+- confirm the app secret and database name match the Mongo init script
+- inspect `kubectl logs deploy/mongodb`
+
+### Worker cannot launch Jobs
+
+- confirm the worker pod is running with service account `droboticflow-worker`
+- confirm Role and RoleBinding exist in the namespace
+- inspect worker logs for Kubernetes API errors
+- confirm the operator-runner image pull secret name matches `K8S_IMAGE_PULL_SECRET_NAME`
+
+### Image pull failure
+
+- recreate `droboticflow-registry` secret with valid registry credentials
+- confirm the image tags pushed to the registry match the deployment values
+- confirm operator-runner Jobs inherit the same pull secret via the rendered Job manifest
+
+### UI cannot load data
+
+- confirm the API pod is healthy at `/api/health`
+- confirm the NodePort is reachable from the target network
+- inspect browser network traffic for failing endpoints
+
+### Old demo data still appears after an upgrade
+
+- run `./scripts/reconcile-system-data.sh http://:30080`
+- confirm `/api/users`, `/api/projects`, and `/api/templates` no longer return legacy seeded records
+- confirm `/api/operators` only returns the current built-in operator catalog with the active operator-runner image tag
diff --git a/docs/plans/2026-04-08-droboticflow-design.md b/docs/plans/2026-04-08-droboticflow-design.md
new file mode 100644
index 00000000..8b7f6d03
--- /dev/null
+++ b/docs/plans/2026-04-08-droboticflow-design.md
@@ -0,0 +1,301 @@
+# DRoboticFlow Full-Stack Design
+
+## Goal
+
+Turn the current frontend prototype into a deployable workflow platform with:
+
+- a real backend API for all existing pages
+- a real worker API and execution engine
+- MongoDB persistence
+- Kubernetes-based operator execution
+- Baidu Cloud Container Registry compatible image build and deployment flow
+
+## Current State
+
+The repository currently contains:
+
+- a Vite/React frontend that started as a local-state prototype
+- a single `server.ts` demo file that mixed API placeholders, in-memory storage, and a non-production worker loop
+- no persistent database model
+- no real worker service
+- no deployment manifests, registry flow, or operations documentation
+
+## Target Architecture
+
+### Services
+
+1. `api`
+ - Go HTTP service for frontend-facing REST APIs
+ - serves the built SPA in production
+ - owns validation, CRUD operations, run creation, audit actions, settings, and dashboard aggregation
+
+2. `worker`
+ - Go HTTP service for worker health and control APIs
+ - background polling loop for queued runs and scheduled streaming workflows
+ - executes workflow DAGs node-by-node
+ - integrates with Kubernetes Jobs when enabled
+
+3. `operator-runner`
+ - lightweight Python container entrypoint used by Kubernetes Jobs
+ - executes a generic operator task contract for built-in operators
+ - produces logs and artifacts back into Mongo-backed run records
+
+4. `mongodb`
+ - persistent document store for projects, operators, workflows, templates, runs, audit tasks, users, settings, and logs
+
+### Runtime Modes
+
+- `local`
+ - used for tests and local development
+ - worker executes the real Python operator runner or a real local Docker image without requiring a Kubernetes cluster
+
+- `k8s`
+ - worker creates Kubernetes Jobs for workflow nodes
+ - jobs run container images pulled from Baidu Cloud Container Registry
+
+## Data Model
+
+### `projects`
+
+- `id`
+- `name`
+- `description`
+- `status`: `active | archived`
+- `createdAt`
+- `updatedAt`
+
+### `operators`
+
+- `id`
+- `name`
+- `type`: `builtin | custom`
+- `category`
+- `description`
+- `inputs`
+- `outputs`
+- `image`
+- `skillDefinition`
+- `hyperparams`
+- `resources`: cpu and memory defaults
+- `createdAt`
+- `updatedAt`
+
+### `workflows`
+
+- `id`
+- `projectId`
+- `name`
+- `description`
+- `type`: `batch | streaming`
+- `nodes`
+- `edges`
+- `schedule`
+- `status`: `draft | ready | running | completed | failed`
+- `lastRunId`
+- `lastRunAt`
+- `createdAt`
+- `updatedAt`
+
+### `templates`
+
+- `id`
+- `name`
+- `description`
+- `nodes`
+- `edges`
+- `createdAt`
+- `updatedAt`
+
+### `runs`
+
+- `id`
+- `workflowId`
+- `projectId`
+- `workflowName`
+- `projectName`
+- `trigger`: `manual | scheduled | retry`
+- `status`: `queued | running | waiting_for_audit | completed | failed | cancelled`
+- `startedAt`
+- `endedAt`
+- `durationMs`
+- `currentNodeId`
+- `nodeExecutions`
+- `resourceSeries`
+- `artifacts`
+- `k8sRefs`
+- `error`
+- `createdAt`
+- `updatedAt`
+
+### `auditTasks`
+
+- `id`
+- `runId`
+- `workflowId`
+- `projectId`
+- `nodeId`
+- `workflowName`
+- `projectName`
+- `operatorName`
+- `status`: `pending | approved | rejected`
+- `data`
+- `createdAt`
+- `updatedAt`
+
+### `users`
+
+- `id`
+- `name`
+- `email`
+- `role`: `admin | auditor | operator`
+- `createdAt`
+- `updatedAt`
+
+### `settings`
+
+- singleton document keyed by `system`
+- `k8s.namespace`
+- `k8s.endpoint`
+- `k8s.enabled`
+- `worker.pollIntervalMs`
+- `worker.maxConcurrentRuns`
+- `storage.buckets`
+- `defaults.cpuRequest`
+- `defaults.cpuLimit`
+- `defaults.memoryRequest`
+- `defaults.memoryLimit`
+- `updatedAt`
+
+## API Surface
+
+### Frontend API
+
+- `GET /api/health`
+- `GET /api/dashboard`
+- `GET /api/projects`
+- `POST /api/projects`
+- `GET /api/projects/:id`
+- `PUT /api/projects/:id`
+- `DELETE /api/projects/:id`
+- `GET /api/projects/:id/workflows`
+- `POST /api/projects/:id/workflows`
+- `GET /api/workflows/:id`
+- `PUT /api/workflows/:id`
+- `DELETE /api/workflows/:id`
+- `POST /api/workflows/:id/run`
+- `GET /api/templates`
+- `POST /api/templates`
+- `GET /api/templates/:id`
+- `PUT /api/templates/:id`
+- `DELETE /api/templates/:id`
+- `GET /api/operators`
+- `POST /api/operators`
+- `GET /api/operators/:id`
+- `PUT /api/operators/:id`
+- `DELETE /api/operators/:id`
+- `GET /api/runs`
+- `GET /api/runs/:id`
+- `GET /api/runs/:id/logs`
+- `GET /api/runs/:id/resources`
+- `GET /api/runs/:id/artifacts`
+- `GET /api/audit-tasks`
+- `POST /api/audit-tasks/:id/approve`
+- `POST /api/audit-tasks/:id/reject`
+- `GET /api/users`
+- `PUT /api/users/:id`
+- `GET /api/settings`
+- `PUT /api/settings`
+- `GET /api/storage/buckets`
+- `GET /api/storage/objects`
+
+### Worker API
+
+- `GET /worker-api/health`
+- `GET /worker-api/stats`
+- `POST /worker-api/process-once`
+- `POST /worker-api/runs/:id/retry`
+
+## Workflow Execution Model
+
+### Queueing
+
+1. API validates a workflow.
+2. API creates a `run` with `status=queued`.
+3. Worker atomically claims the run.
+
+### Execution
+
+1. Worker builds a DAG from workflow `nodes` and `edges`.
+2. Start nodes with no incoming edges are scheduled first.
+3. Each node transitions through:
+ - `queued`
+ - `running`
+ - `completed`
+ - `failed`
+ - `waiting_for_audit` when the operator requires manual review
+4. Downstream nodes run only after all dependencies complete.
+
+### Audit Gate
+
+If a node is a human review operator:
+
+1. Worker creates an `auditTask`.
+2. Run status becomes `waiting_for_audit`.
+3. Approve/reject API updates the task.
+4. Worker resumes the run on the corresponding branch.
+
+### Kubernetes Launch
+
+When Kubernetes execution is enabled:
+
+1. Worker resolves the node image.
+2. Worker creates a namespaced Job with run and node metadata as env vars.
+3. Worker watches Job completion and collects pod/job references.
+4. Worker stores status, logs, and basic resource samples in Mongo.
+
+When disabled, the same state machine runs through the local execution path for deterministic tests and development.
+
+## Frontend Integration Strategy
+
+The existing UI is kept, but local prototype state is replaced with:
+
+- shared API client utilities
+- fetch-based page loading and mutation handlers
+- run, monitoring, audit, settings, and storage views backed by real endpoints
+
+The visual design stays intact; only data flow changes.
+
+## Deployment Topology
+
+### Containers
+
+- `droboticflow-api`
+- `droboticflow-worker`
+- `droboticflow-operator-runner`
+
+### Registry
+
+Baidu Cloud Container Registry namespace:
+
+- `ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow`
+
+### Kubernetes Resources
+
+- namespace
+- MongoDB secret, PVC, service, deployment/statefulset
+- API configmap, secret, deployment, service
+- Worker configmap, secret, deployment, service
+- image pull secret for Baidu registry
+
+## Acceptance Criteria
+
+The project is considered aligned when:
+
+- frontend pages read and write real backend data
+- workflow runs are persisted in MongoDB
+- worker processes queued runs and updates monitoring data
+- audit tasks can pause and resume runs
+- settings are persisted and exposed via API
+- Docker images can be built and tagged for Baidu registry
+- Kubernetes manifests can deploy MongoDB, API, and worker
+- repo docs explain local development, deployment, and operations
diff --git a/docs/plans/2026-04-08-droboticflow-implementation.md b/docs/plans/2026-04-08-droboticflow-implementation.md
new file mode 100644
index 00000000..0897b8b7
--- /dev/null
+++ b/docs/plans/2026-04-08-droboticflow-implementation.md
@@ -0,0 +1,122 @@
+# DRoboticFlow Full-Stack Implementation Plan
+
+**Goal:** Replace the prototype backend with a Go-based MongoDB-backed API and worker stack, wire the frontend to it, and add Kubernetes plus Baidu registry deployment assets.
+
+**Architecture:** Keep the existing React frontend, add shared Go domain modules plus separate API and worker entrypoints, and use a Kubernetes launcher abstraction with a real local runner for development plus Kubernetes Jobs in cluster mode. Use a Python operator-runner container for Kubernetes Jobs. Update docs and deployment assets in the same change set so runtime assumptions stay aligned.
+
+**Tech Stack:** React, Vite, Go, MongoDB, Go test, client-go, Python, Docker, Kubernetes YAML
+
+---
+
+### Task 1: Scaffold backend structure and shared models
+
+**Files:**
+- Create: `cmd/api/main.go`
+- Create: `cmd/worker/main.go`
+- Create: `backend/operator-runner/main.py`
+- Create: `internal/domain/*.go`
+- Create: `internal/config/*.go`
+- Modify: `package.json`
+- Modify: `tsconfig.json`
+- Modify: `README.md`
+
+**Steps:**
+1. Create Go entrypoints for the API and worker services.
+2. Add shared domain types, config loading, and identifier helpers.
+3. Add the Python operator-runner entrypoint used inside Kubernetes Jobs.
+4. Verify the binaries compile and the runtime contract is stable.
+
+### Task 2: Add Mongo repositories and default settings
+
+**Files:**
+- Create: `internal/store/*.go`
+- Test: `internal/store/*_test.go`
+
+**Steps:**
+1. Add a store interface plus in-memory and Mongo implementations.
+2. Port CRUD behavior, dashboard aggregation, default settings, and queue-claim logic.
+3. Keep runtime bootstrap explicit so projects, operators, templates, users, runs, and audits are created through real APIs.
+4. Re-run store tests until green.
+
+### Task 3: Implement API routes
+
+**Files:**
+- Create: `internal/api/*.go`
+- Test: `internal/api/*_test.go`
+
+**Steps:**
+1. Write failing tests for dashboard, CRUD, run creation, audit actions, and storage endpoints.
+2. Implement REST handlers with validation and consistent JSON responses.
+3. Register `/api/*` routes and SPA fallback handling.
+4. Re-run API tests until green.
+
+### Task 4: Implement worker run lifecycle
+
+**Files:**
+- Create: `internal/worker/*.go`
+- Create: `internal/retry/*.go`
+- Test: `internal/worker/*_test.go`
+- Test: `internal/retry/*_test.go`
+
+**Steps:**
+1. Write failing tests for run claiming, DAG ordering, audit pause/resume, and streaming scheduling.
+2. Implement queue claiming, topological execution, node logging, artifact/resource updates, and run status transitions.
+3. Add worker control endpoints and polling loop.
+4. Re-run worker and retry tests until green.
+
+### Task 5: Implement Kubernetes launcher and operator runner
+
+**Files:**
+- Create: `internal/k8s/*.go`
+- Create: `backend/operator-runner/main.py`
+- Test: `internal/k8s/*_test.go`
+
+**Steps:**
+1. Write failing tests for job spec generation and local execution fallback.
+2. Implement launcher abstraction for local and Kubernetes modes using `client-go`.
+3. Implement the Python operator-runner contract for generic built-in operators.
+4. Re-run launcher tests until green.
+
+### Task 6: Refactor frontend to real API clients
+
+**Files:**
+- Create: `src/services/api/client.ts`
+- Create: `src/services/api/*.ts`
+- Modify: `src/pages/*.tsx`
+- Modify: `src/context/UserContext.tsx`
+
+**Steps:**
+1. Replace local prototype state with fetch-backed hooks or page effects.
+2. Wire project, workflow, operator, template, monitoring, audit, users, settings, and dashboard pages to the backend.
+3. Re-run the frontend type-check and build.
+4. Verify the existing UI still loads against the real API.
+
+### Task 7: Add Docker and Kubernetes deployment assets
+
+**Files:**
+- Create: `Dockerfile.api`
+- Create: `Dockerfile.worker`
+- Create: `Dockerfile.operator-runner`
+- Create: `k8s/*.yaml`
+- Create: `scripts/*.sh`
+
+**Steps:**
+1. Add image build definitions, k8s manifests, and deploy scripts for MongoDB, API, worker, registry secret, and config.
+2. Ensure manifest env vars match the Go/Python runtime settings.
+3. Preserve cluster-specific fixes for Mongo startup retry, secret reuse, image tag propagation, `jobs/status` RBAC, and operator-runner `imagePullSecrets`.
+4. Re-run manifest rendering and local container build commands.
+
+### Task 8: Update documentation and verification assets
+
+**Files:**
+- Modify: `README.md`
+- Create: `docs/api.md`
+- Create: `docs/deployment.md`
+- Create: `docs/operations.md`
+- Modify: `.env.example`
+
+**Steps:**
+1. Document local development, environment variables, worker behavior, deployment, and acceptance checks.
+2. Add Baidu registry and Kubernetes setup instructions without committing secrets.
+3. Run doc/code sync review and fix any drift.
+4. Run final verification loop: build, type check, tests, security grep, diff review.
diff --git a/go.mod b/go.mod
new file mode 100644
index 00000000..c9c591d0
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,61 @@
+module droboticflow
+
+go 1.24.0
+
+require (
+ github.com/go-chi/chi/v5 v5.2.3
+ go.mongodb.org/mongo-driver v1.17.6
+ k8s.io/api v0.34.1
+ k8s.io/apimachinery v0.34.1
+ k8s.io/client-go v0.34.1
+)
+
+require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/emicklei/go-restful/v3 v3.12.2 // indirect
+ github.com/fxamacker/cbor/v2 v2.9.0 // indirect
+ github.com/go-logr/logr v1.4.2 // indirect
+ github.com/go-openapi/jsonpointer v0.21.0 // indirect
+ github.com/go-openapi/jsonreference v0.20.2 // indirect
+ github.com/go-openapi/swag v0.23.0 // indirect
+ github.com/gogo/protobuf v1.3.2 // indirect
+ github.com/golang/snappy v0.0.4 // indirect
+ github.com/google/gnostic-models v0.7.0 // indirect
+ github.com/google/uuid v1.6.0 // indirect
+ github.com/josharian/intern v1.0.0 // indirect
+ github.com/json-iterator/go v1.1.12 // indirect
+ github.com/klauspost/compress v1.16.7 // indirect
+ github.com/mailru/easyjson v0.7.7 // indirect
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
+ github.com/montanaflynn/stats v0.7.1 // indirect
+ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
+ github.com/pkg/errors v0.9.1 // indirect
+ github.com/spf13/pflag v1.0.6 // indirect
+ github.com/x448/float16 v0.8.4 // indirect
+ github.com/xdg-go/pbkdf2 v1.0.0 // indirect
+ github.com/xdg-go/scram v1.1.2 // indirect
+ github.com/xdg-go/stringprep v1.0.4 // indirect
+ github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
+ go.yaml.in/yaml/v2 v2.4.2 // indirect
+ go.yaml.in/yaml/v3 v3.0.4 // indirect
+ golang.org/x/crypto v0.36.0 // indirect
+ golang.org/x/net v0.38.0 // indirect
+ golang.org/x/oauth2 v0.27.0 // indirect
+ golang.org/x/sync v0.12.0 // indirect
+ golang.org/x/sys v0.31.0 // indirect
+ golang.org/x/term v0.30.0 // indirect
+ golang.org/x/text v0.23.0 // indirect
+ golang.org/x/time v0.9.0 // indirect
+ google.golang.org/protobuf v1.36.5 // indirect
+ gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
+ gopkg.in/inf.v0 v0.9.1 // indirect
+ gopkg.in/yaml.v3 v3.0.1 // indirect
+ k8s.io/klog/v2 v2.130.1 // indirect
+ k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
+ k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
+ sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
+ sigs.k8s.io/randfill v1.0.0 // indirect
+ sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
+ sigs.k8s.io/yaml v1.6.0 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 00000000..f7aa3606
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,193 @@
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
+github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
+github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
+github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
+github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE=
+github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
+github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
+github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
+github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
+github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
+github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
+github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
+github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
+github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
+github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
+github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
+github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
+github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
+github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
+github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
+github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
+github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo=
+github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
+github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
+github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
+github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
+github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
+github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
+github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
+github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
+github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8=
+github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
+github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
+github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
+github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
+github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
+github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM=
+github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
+github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4=
+github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
+github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
+github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
+github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
+github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
+github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
+github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
+github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
+github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
+github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
+github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
+github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
+github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
+github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
+github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
+github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
+github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
+github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
+go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
+go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
+go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
+golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
+golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
+golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
+golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
+golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
+golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
+golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
+golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
+golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
+golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
+golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
+golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
+golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
+golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
+golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
+golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
+google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
+gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4=
+gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
+gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
+gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM=
+k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk=
+k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4=
+k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
+k8s.io/client-go v0.34.1 h1:ZUPJKgXsnKwVwmKKdPfw4tB58+7/Ik3CrjOEhsiZ7mY=
+k8s.io/client-go v0.34.1/go.mod h1:kA8v0FP+tk6sZA0yKLRG67LWjqufAoSHA2xVGKw9Of8=
+k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
+k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
+k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA=
+k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts=
+k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y=
+k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
+sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE=
+sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
+sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
+sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
+sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco=
+sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE=
+sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
+sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=
diff --git a/index.html b/index.html
index 21dfe690..9742593b 100644
--- a/index.html
+++ b/index.html
@@ -3,11 +3,10 @@
- My Google AI Studio App
+ DroboticFlow