修改了conf.json的读取路径

This commit is contained in:
lik
2026-09-13 11:40:42 +08:00
parent 41bf2ce638
commit cd284e3459
7 changed files with 37 additions and 22 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ import { createDeepAgent } from "deepagents";
import { AIMessageChunk, ToolMessage, todoListMiddleware } from "langchain";
import { HumanMessage } from "@langchain/core/messages";
import { ChatDeepSeek } from "@langchain/deepseek";
import config from '../../../conf.json' with { type: 'json' };
import config from '../../../config.js';
import logger from '../../../utils/logger.js';
import { createRestrictedBackend } from "../../infra/restricted_fs_backend.js";
+14 -17
View File
@@ -6,7 +6,7 @@ import { ChatOpenAI } from "@langchain/openai";
import { AIMessageChunk, ToolMessage } from "langchain";
import { HumanMessage } from "@langchain/core/messages";
import { ChatDeepSeek } from "@langchain/deepseek";
import config from '../../../conf.json' with { type: 'json' };
import config from '../../../config.js';
import logger from '../../../utils/logger.js';
// 密钥由 conf.json 统一提供;百度地图 skill 通过 env_get 读环境变量,此处桥接
@@ -160,22 +160,19 @@ export default class EscortAgent {
return this.agent;
}
// 受限后端:锁定沙箱根并禁止读取 conf.json/.env/logs 及用户数据目录
let backend = createRestrictedBackend({ rootDir, dataDir });
if (userInfo) {
// 挂载根为用户数据目录:/memories/memory.txt ↔ data/users/{userId}/memory.txt
const userMemoryRoot = path.join(dataDir, "users", userInfo._id);
backend = new CompositeBackend(
createRestrictedBackend({ rootDir, dataDir }),
{
"/memories/": new FilesystemBackend({
rootDir: userMemoryRoot,
virtualMode: true
})
},
)
}
// 受限后端:锁定沙箱根并禁止读取 conf.json/.env/logs 及用户数据目录
// 登录用户挂载 /memories/ ↔ data/users/{userId}//memories/memory.txt ↔ .../memory.txt
const backend = userInfo
? new CompositeBackend(
createRestrictedBackend({ rootDir, dataDir }),
{
"/memories/": new FilesystemBackend({
rootDir: path.join(dataDir, "users", userInfo._id),
virtualMode: true
})
},
)
: createRestrictedBackend({ rootDir, dataDir });
this.flashModel = new ChatDeepSeek({
model: config.agent.deepseek.flashModel,
+1 -1
View File
@@ -1,6 +1,6 @@
import fs from "fs";
import path from "path";
import config from "../../../conf.json" with { type: 'json' };
import config from "../../../config.js";
import services from "../../../resource/services.js";
import agreement from "../../../resource/agreement.js";
import logger from "../../../utils/logger.js";
+1 -1
View File
@@ -1,7 +1,7 @@
import { TavilyExtract } from "@langchain/tavily";
import { tool } from "@langchain/core/tools";
import * as z from "zod"
import config from "../../../../conf.json" with { type: "json" };
import config from "../../../../config.js";
const webFetchTool = tool(
async ({
+1 -1
View File
@@ -1,7 +1,7 @@
import { TavilySearch } from "@langchain/tavily";
import { tool } from "@langchain/core/tools";
import * as z from "zod"
import config from "../../../../conf.json" with { type: "json" };
import config from "../../../../config.js";
const webSearchTool = tool(
async ({
+18
View File
@@ -0,0 +1,18 @@
import { existsSync, readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// 优先读取系统级配置,其次读取项目目录下的配置
const SYSTEM_CONF = '/etc/ehason/conf.json';
const LOCAL_CONF = path.join(__dirname, 'conf.json');
function loadConfig() {
const file = existsSync(SYSTEM_CONF) ? SYSTEM_CONF : LOCAL_CONF;
return JSON.parse(readFileSync(file, 'utf-8'));
}
const config = loadConfig();
export default config;
+1 -1
View File
@@ -5,7 +5,7 @@ import { EscortRecordSchema } from "./schema/escort_record.js"
import { HealthProfileSchema } from "./schema/health_profile.js"
import { OrganizationSchema } from "./schema/organization.js"
import { EmployeeSchema } from "./schema/employee.js"
import config from '../conf.json' with { type: 'json' };
import config from '../config.js';
import logger from '../utils/logger.js';
class MongoDBSchema {