refactor: 将 ekb-mcp 上移到根目录
项目结构重构: - 将 ekb-mcp/ 子目录内容上移到项目根目录 - 更新 AGENTS.md 反映新的 TS + MCP 架构 - 更新 README.md 为 ekb-mcp 项目说明 - 保留 docs/ 文档目录 新的项目结构: - src/core/ - 基础设施(auth, config, http) - src/domains/ - 业务域(sealai, platform) - src/server.ts - MCP Server 入口 - enterprises/ - 企业配置
This commit is contained in:
1 parent
955f56114f
commit
f9eb6a4844
30 files changed
+384
-422
No files matched your search
@@ -0,0 +1,79 @@
|
||||
import { z } from "zod";
|
||||
import { KyInstance } from "ky";
|
||||
import {
|
||||
PlatformSchema,
|
||||
WorkflowPageSchema,
|
||||
WorkflowStatsSchema,
|
||||
WorkflowChargeSchema,
|
||||
WorkflowDetailSchema,
|
||||
} from "./types";
|
||||
|
||||
// Helper to unwrap { data: T } response
|
||||
async function unwrap<T>(response: Response, schema: z.ZodType<T>): Promise<T> {
|
||||
const json = await response.json() as { data: unknown };
|
||||
return schema.parse(json.data);
|
||||
}
|
||||
|
||||
// ── 自建应用 ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function listPlatforms(
|
||||
client: KyInstance,
|
||||
corpId: string
|
||||
): Promise<import("./types").Platform[]> {
|
||||
const response = await client.get("api/v2/datalink/platform/search", {
|
||||
searchParams: { scope: "enable", corpId },
|
||||
});
|
||||
const json = (await response.json()) as { items: unknown[] };
|
||||
return z.array(PlatformSchema).parse(json.items);
|
||||
}
|
||||
|
||||
// ── 工作流(EASO)─────────────────────────────────────────────────────────────
|
||||
|
||||
export async function listWorkflows(
|
||||
client: KyInstance,
|
||||
corpId: string,
|
||||
platformId: string,
|
||||
page: number = 1,
|
||||
pageSize: number = 20
|
||||
): Promise<import("./types").WorkflowPage> {
|
||||
const response = await client.get("api/easo/pipelines/logs", {
|
||||
searchParams: {
|
||||
corpId,
|
||||
platformId,
|
||||
number: String(page),
|
||||
pageSize: String(pageSize),
|
||||
},
|
||||
});
|
||||
return unwrap(response, WorkflowPageSchema);
|
||||
}
|
||||
|
||||
export async function getWorkflowStats(
|
||||
client: KyInstance,
|
||||
corpId: string,
|
||||
platformId: string
|
||||
): Promise<import("./types").WorkflowStats> {
|
||||
const response = await client.get("api/easo/stats", {
|
||||
searchParams: { corpId, platformId },
|
||||
});
|
||||
return unwrap(response, WorkflowStatsSchema);
|
||||
}
|
||||
|
||||
export async function getWorkflowCharge(
|
||||
client: KyInstance,
|
||||
corpId: string
|
||||
): Promise<import("./types").WorkflowCharge> {
|
||||
const response = await client.get("api/easo/charge", {
|
||||
searchParams: { corpId },
|
||||
});
|
||||
return unwrap(response, WorkflowChargeSchema);
|
||||
}
|
||||
|
||||
// ── 工作流详情(Piper)────────────────────────────────────────────────────────
|
||||
|
||||
export async function getWorkflowDetail(
|
||||
client: KyInstance,
|
||||
pipelineId: string
|
||||
): Promise<import("./types").WorkflowDetail> {
|
||||
const response = await client.get(`api/easo/pipelines/${pipelineId}`);
|
||||
return unwrap(response, WorkflowDetailSchema);
|
||||
}
|
||||
Reference in new issue
Block a user