fix(bridge): HTTP 工具入口注入 retriever/verification/client(search_kb 等不再 not_configured)+ 记录最新代码运行方式
This commit is contained in:
+14
-3
@@ -7,6 +7,9 @@ const { createTools, resolveSiteProfile } = require('./tools');
|
||||
const { createIdentity } = require('./identity');
|
||||
const { createLibreDeskWebhook } = require('./libredesk-webhook');
|
||||
const { createAgent } = require('./agent');
|
||||
const { createVerification } = require('./verification');
|
||||
const { createLibreDeskClient } = require('./libredesk');
|
||||
const { createRetriever } = require('./rag');
|
||||
const { ToolError } = require('./errors');
|
||||
|
||||
const MAX_BODY_BYTES = 256 * 1024;
|
||||
@@ -82,9 +85,14 @@ function contextFromHeaders(headers = {}) {
|
||||
function createServer(options = {}) {
|
||||
const cfg = options.config || loadConfig();
|
||||
const auther = createAuther(cfg.toolsSharedKey);
|
||||
const tools = options.tools || createTools(cfg);
|
||||
// HTTP 工具入口(LibreDesk 直接调用)也必须带上 retriever/verification/client,
|
||||
// 否则 search_kb / send_verification_code / handoff_to_human 会一直是 not_configured。
|
||||
const verification = options.verification || createVerification(cfg);
|
||||
const client = options.client || createLibreDeskClient(cfg);
|
||||
const retriever = options.retriever || (cfg.ragPgUrl ? createRetriever(cfg) : null);
|
||||
const tools = options.tools || createTools(cfg, { verification, retriever, client });
|
||||
const identity = options.identity || createIdentity(cfg);
|
||||
const agent = options.agent || createAgent(cfg);
|
||||
const agent = options.agent || createAgent(cfg, { verification, client, retriever });
|
||||
const libredeskWebhook = options.libredeskWebhook || createLibreDeskWebhook(cfg, { agent });
|
||||
const byName = new Map(tools.map((t) => [t.name, t]));
|
||||
const startedAt = Date.now();
|
||||
@@ -252,7 +260,10 @@ if (require.main === module) {
|
||||
if (!cfg.toolsSharedKey) console.warn('[crm-tools] TOOLS_SHARED_KEY is not set — all /tools/* calls will return 503');
|
||||
if (cfg.devBypassVerification) console.warn('[crm-tools] TOOLS_DEV_BYPASS=true — verification checks are BYPASSED (local development only)');
|
||||
});
|
||||
const shutdown = () => server.close(() => process.exit(0));
|
||||
const shutdown = () => server.close(() => {
|
||||
if (retriever && retriever.pool) retriever.pool.end().catch(() => {});
|
||||
process.exit(0);
|
||||
});
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGTERM', shutdown);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user