本地部署:顶层 docker-compose/config,域名 agent.ai.foresh.com(nginx-proxy VIRTUAL_HOST + external my-app-network,仅内网 expose 8080,config 只读挂载);配置后缀统一 .yaml→.yml(文件与全部引用,含 Dockerfile/AGENT_CONFIG/config.js/smoke)。smoke 25/25 通过
This commit is contained in:
+2
-2
@@ -11,9 +11,9 @@ COPY package.json package-lock.json ./
|
||||
RUN npm install --omit=dev --no-audit --no-fund
|
||||
|
||||
COPY server ./server
|
||||
COPY config.example.yaml ./
|
||||
COPY config.example.yml ./
|
||||
|
||||
EXPOSE 8080
|
||||
ENV AGENT_CONFIG=/app/config.yaml
|
||||
ENV AGENT_CONFIG=/app/config.yml
|
||||
|
||||
CMD ["node", "server/server.js"]
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@
|
||||
app/
|
||||
├── server/
|
||||
│ ├── server.js # 入口:装配配置/DB/总线/路由/静态资源
|
||||
│ ├── config.js # config.yaml 加载与校验
|
||||
│ ├── config.js # config.yml 加载与校验
|
||||
│ ├── db.js # SQLite(better-sqlite3,WAL)
|
||||
│ ├── engine.js # 会话管理 + 模型池 FIFO 调度 + Agent 主循环
|
||||
│ ├── llm.js # OpenAI 兼容上游流式调用(SSE 解析/工具分片合并)
|
||||
@@ -24,7 +24,7 @@ app/
|
||||
│ └── public/ # H5 前端(Vanilla JS + SSE)
|
||||
├── test/ # mock 上游 + 端到端冒烟测试
|
||||
├── scripts(在上层仓库根目录)gen-from-readme.js # README → 提示词/工具 schema
|
||||
├── config.example.yaml
|
||||
├── config.example.yml
|
||||
├── Dockerfile / docker-compose.yml
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ app/
|
||||
```bash
|
||||
cd app
|
||||
npm install
|
||||
cp config.example.yaml config.yaml # 修改 upstream_url / models
|
||||
cp config.example.yml config.yml # 修改 upstream_url / models
|
||||
npm start # http://localhost:8080
|
||||
```
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 自用通用 Agent 系统配置示例
|
||||
# 复制为 config.yaml 后按需修改;容器内通过 AGENT_CONFIG 指定路径。
|
||||
# 复制为 config.yml 后按需修改;容器内通过 AGENT_CONFIG 指定路径。
|
||||
|
||||
# 模型池:多个 ID 共用同一个上游 URL(cli-proxy-api 按 ID 路由到不同账号)。
|
||||
# 同时活跃会话数上限 = 模型数量。
|
||||
@@ -1,11 +0,0 @@
|
||||
services:
|
||||
agent:
|
||||
build: .
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./data:/workspace/tasks
|
||||
- ./config.yaml:/app/config.yaml:ro
|
||||
environment:
|
||||
- AGENT_CONFIG=/app/config.yaml
|
||||
restart: unless-stopped
|
||||
@@ -1,4 +1,4 @@
|
||||
// 配置加载:AGENT_CONFIG 指向 config.yaml(见 config.example.yaml)
|
||||
// 配置加载:AGENT_CONFIG 指向 config.yml(见 config.example.yml)
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const YAML = require('yaml');
|
||||
@@ -33,7 +33,7 @@ function deepMerge(base, extra) {
|
||||
}
|
||||
|
||||
function loadConfig(configPath) {
|
||||
const p = configPath || process.env.AGENT_CONFIG || path.join(__dirname, '..', 'config.yaml');
|
||||
const p = configPath || process.env.AGENT_CONFIG || path.join(__dirname, '..', 'config.yml');
|
||||
let raw = {};
|
||||
if (fs.existsSync(p)) {
|
||||
raw = YAML.parse(fs.readFileSync(p, 'utf8')) || {};
|
||||
|
||||
@@ -619,7 +619,7 @@ function strip(s) { return s.replace(/<[^>]+>/g, ''); }
|
||||
// web_search:调用内网 MCP 服务(JSON-RPC over HTTP,无状态,响应为 SSE 帧包裹的 JSON)。
|
||||
async function toolWebSearch(ctx, args) {
|
||||
const ws = ctx.cfg.web_search || {};
|
||||
if (!ws.url) return 'web_search 未配置:请在 config.yaml 的 web_search.url 中填写 MCP 服务地址';
|
||||
if (!ws.url) return 'web_search 未配置:请在 config.yml 的 web_search.url 中填写 MCP 服务地址';
|
||||
const query = args.query;
|
||||
if (!query) return 'web_search 缺少参数 query';
|
||||
const callId = Date.now();
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ async function main() {
|
||||
const mock = spawn('node', [path.join(ROOT, 'test/mock-upstream.js')], { stdio: 'inherit' });
|
||||
const server = spawn('node', [path.join(ROOT, 'server/server.js')], {
|
||||
cwd: ROOT,
|
||||
env: Object.assign({}, process.env, { AGENT_CONFIG: path.join(ROOT, 'test/config.test.yaml') }),
|
||||
env: Object.assign({}, process.env, { AGENT_CONFIG: path.join(ROOT, 'test/config.test.yml') }),
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
let serverLog = '';
|
||||
|
||||
Reference in New Issue
Block a user