基于 Python 的多服务智能体开发平台脚手架。
当前仓库已经初始化为 Monorepo,包含:
services/:核心微服务libs/:共享领域模型、DSL、事件、数据库和公共组件deployments/:本地和集群部署占位docs/:规划和数据库设计文档api-gatewaysession-serviceworkflow-serviceruntime-servicetool-service每个服务都提供了最小 FastAPI 启动入口和健康检查接口,数据库相关服务也已经带上了 SQLAlchemy 模型骨架与 Alembic 目录。
core-domaincore-dslcore-eventscore-sharedcore-db建议使用 uv 或 pip 创建虚拟环境后安装各服务依赖。
cd D:\workspace\auto-platform
python -m venv .venv
.venv\Scripts\activate
pip install -e .\libs\core-shared
pip install -e .\libs\core-domain
pip install -e .\libs\core-dsl
pip install -e .\libs\core-events
pip install -e .\libs\core-db
pip install -e .\services\api-gateway
pip install -e .\services\session-service
pip install -e .\services\workflow-service
pip install -e .\services\runtime-service
pip install -e .\services\tool-service
运行示例:
cd D:\workspace\auto-platform\services\api-gateway
uvicorn app.main:app --reload --port 8000
数据库连接默认使用各服务目录下的 SQLite 文件,也可以通过环境变量覆盖:
$env:AGENT_PLATFORM_DATABASE_URL="postgresql+psycopg://user:password@localhost:5432/workflow_db"
本轮已经加入:
libs/core-db:统一 SQLAlchemy Base、通用 mixin、命名约定workflow-service:应用与流程定义模型session-service:会话与消息模型runtime-service:运行与节点执行模型tool-service:工具定义与绑定模型alembic.ini、env.py、versions/workflow-service:已接入 repository / application service / CRUD APIsession-service:已接入 repository / application service / CRUD API迁移执行示例:
cd D:\workspace\auto-platform\services\workflow-service
alembic upgrade head
其他服务同理:
services/session-serviceservices/runtime-serviceservices/tool-service接口示例:
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8002/workflows/apps `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","code":"sales_assistant","name":"Sales Assistant"}'
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8001/sessions `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","app_id":"app-1","user_id":"user-1","channel_type":"web"}'
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8002/workflows/versions `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","workflow_id":"wf-1","dsl_json":{"nodes":[],"edges":[]}}'
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8001/sessions/run-requests `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","session_id":"sess-1","app_version_id":"appv-1","workflow_version_id":"wfv-1"}'
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8003/runtime/runs `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","app_id":"app-1","app_version_id":"appv-1","workflow_id":"wf-1","workflow_version_id":"wfv-1","session_id":"sess-1","initial_node":{"node_id":"start","node_type":"llm"}}'
如果不传 initial_node,runtime-service 会调用 workflow-service 读取对应的 workflow version,并从 DSL 中自动推导首节点:
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8003/runtime/runs `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","app_id":"app-1","app_version_id":"appv-1","workflow_id":"wf-1","workflow_version_id":"wfv-1","session_id":"sess-1"}'
一条链直接派发到 runtime:
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8001/sessions/run-requests/dispatch `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","session_id":"sess-1","app_id":"app-1","app_version_id":"appv-1","workflow_id":"wf-1","workflow_version_id":"wfv-1","initial_node":{"node_id":"start","node_type":"llm"}}'
工具定义示例:
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8004/tools `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","code":"search_products","name":"Search Products","tool_type":"http"}'
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8004/tools/versions `
-ContentType "application/json" `
-Body '{"tenant_id":"t1","tool_id":"tool-1","input_schema_json":{"query":{"type":"string"}},"invoke_config_json":{"method":"GET","path":"/products/search"}}'
运行状态推进示例:
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8003/runtime/node-runs/node-run-id/status `
-ContentType "application/json" `
-Body '{"status":"running","worker_key":"runtime-worker-1"}'
Invoke-RestMethod -Method Post `
-Uri http://127.0.0.1:8003/runtime/runs/run-id/status `
-ContentType "application/json" `
-Body '{"status":"completed"}'
说明:
node-runs/{node_run_id}/status 更新节点状态时,runtime-service 会自动聚合当前运行下所有 node_run 的状态,并同步刷新 workflow_run.statusfailed 则运行 failed;有节点 running 则运行 running;全部节点都为 completed/skipped 则运行 completednode_run 被更新为 completed 时,runtime-service 还会基于 workflow version 的 DSL 自动查找后继节点,并创建新的 queued 状态 node_runservices/
api-gateway/
session-service/
workflow-service/
runtime-service/
tool-service/
libs/
core-domain/
core-dsl/
core-events/
core-shared/
core-db/
deployments/
docker/
k8s/
docs/
tests/
V0.1 的 repository / service 层