refactor(core): 统一 HTTP 工厂与认证模块,支持 401 自动重试
- factory.ts 只负责创建 HTTP client 和 401 retry 逻辑 - auth 模块(ekb/easo/piper/sealai)只负责 token/header 获取 - ekb.ts 新增 createEkbClient - sealai.ts 新增 createSealaiClient,内部使用 createAuthClient - easo.ts/piper.ts 改用 createAuthClient,token 交换失败抛 AuthenticationError - server.ts 使用 createEkbClient / createSealaiClient / getEasoClient
This commit is contained in:
1 parent
62afd6906e
commit
c9e0fba265
6 files changed
+151
-62
No files matched your search
+4
-4
@@ -6,9 +6,9 @@ import {
|
||||
} from "@modelcontextprotocol/sdk/types.js";
|
||||
import { loadCorpConfigs } from "./core/config/loader.js";
|
||||
import { CorpContext } from "./core/config/manager.js";
|
||||
import { createClient } from "./core/http/factory.js";
|
||||
import { createEkbClient } from "./core/auth/ekb.js";
|
||||
import { getEasoClient } from "./core/auth/easo.js";
|
||||
import { getPiperClient } from "./core/auth/piper.js";
|
||||
import { createSealaiClient } from "./core/auth/sealai.js";
|
||||
import { sealaiTools } from "./domains/sealai/tools.js";
|
||||
import { platformTools } from "./domains/platform/tools.js";
|
||||
|
||||
@@ -102,7 +102,7 @@ async function main() {
|
||||
// SealAI 工具
|
||||
const sealaiTool = sealaiTools.find((t) => t.name === name);
|
||||
if (sealaiTool) {
|
||||
const client = await createClient(currentCorp, "sealai");
|
||||
const client = await createSealaiClient(currentCorp);
|
||||
const result = await sealaiTool.handler(client, args as never);
|
||||
return {
|
||||
content: [
|
||||
@@ -117,7 +117,7 @@ async function main() {
|
||||
// Platform 工具
|
||||
const platformTool = platformTools.find((t) => t.name === name);
|
||||
if (platformTool) {
|
||||
const ekbClient = await createClient(currentCorp, "ekb");
|
||||
const ekbClient = await createEkbClient(currentCorp);
|
||||
const { client: easoClient } = await getEasoClient(currentCorp);
|
||||
const result = await platformTool.handler(
|
||||
{ corp: currentCorp, ekbClient, easoClient },
|
||||
|
||||
Reference in new issue
Block a user