refactor: 移除 SealAI 相关业务域、认证与文档
This commit is contained in:
1 parent
31c2a112de
commit
2085a97e34
13 files changed
-785
No files matched your search
@@ -7,7 +7,6 @@
|
||||
| 域 | 说明 | 详细文档 |
|
||||
|---|---|---|
|
||||
| `platform/` | 自建应用(DataLink Platform)与工作流(EASO/Piper) | [README.platform.md](./platform/README.platform.md) |
|
||||
| `sealai/` | SealAI 独立子域(AI 填单/审批) | [README.sealai.md](./sealai/README.sealai.md) |
|
||||
|
||||
## 分层规则
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# SealAI 域说明
|
||||
|
||||
SealAI 域负责 `{corpId.lower()}.sealai.cc` 独立子站的 AI 填单/审批能力。
|
||||
|
||||
## 代码结构
|
||||
|
||||
```text
|
||||
src/domains/sealai/
|
||||
├── types.ts # Zod schema 与类型定义
|
||||
├── api.ts # HTTP 传输层
|
||||
└── tools.ts # MCP tool 注册
|
||||
```
|
||||
|
||||
## 详细文档
|
||||
|
||||
完整认证说明、MCP tool 列表、数据模型见:
|
||||
|
||||
[docs/modules/sealai.md](../../../docs/modules/sealai.md)
|
||||
@@ -1,182 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import { KyInstance } from "ky";
|
||||
import {
|
||||
MeDataSchema,
|
||||
BillingStatusDataSchema,
|
||||
DraftRulesDataSchema,
|
||||
DraftRuleSchema,
|
||||
RuleSetVersionSchema,
|
||||
PublishVersionDataSchema,
|
||||
KnowledgeArticleListDataSchema,
|
||||
KnowledgeArticleSchema,
|
||||
} 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 getMe(client: KyInstance): Promise<import("./types").MeData> {
|
||||
const response = await client.get("api/v1/auth/me");
|
||||
return unwrap(response, MeDataSchema);
|
||||
}
|
||||
|
||||
// ── 计费 ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function getBillingStatus(
|
||||
client: KyInstance
|
||||
): Promise<import("./types").BillingStatusData> {
|
||||
const response = await client.get("api/v1/billing/status");
|
||||
return unwrap(response, BillingStatusDataSchema);
|
||||
}
|
||||
|
||||
// ── 审核规则 ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function listRules(
|
||||
client: KyInstance
|
||||
): Promise<import("./types").DraftRulesData> {
|
||||
const response = await client.get("api/v1/rules");
|
||||
return unwrap(response, DraftRulesDataSchema);
|
||||
}
|
||||
|
||||
export async function createRule(
|
||||
client: KyInstance,
|
||||
params: {
|
||||
description: string;
|
||||
scope: string;
|
||||
strictness: string;
|
||||
}
|
||||
): Promise<import("./types").DraftRule> {
|
||||
const response = await client.post("api/v1/rules", {
|
||||
json: params,
|
||||
});
|
||||
return unwrap(response, DraftRuleSchema);
|
||||
}
|
||||
|
||||
export async function updateRule(
|
||||
client: KyInstance,
|
||||
ruleId: string,
|
||||
params: {
|
||||
description?: string;
|
||||
scope?: string;
|
||||
strictness?: string;
|
||||
}
|
||||
): Promise<import("./types").DraftRule> {
|
||||
const response = await client.put(`api/v1/rules/${ruleId}`, {
|
||||
json: params,
|
||||
});
|
||||
return unwrap(response, DraftRuleSchema);
|
||||
}
|
||||
|
||||
export async function deleteRule(client: KyInstance, ruleId: string): Promise<void> {
|
||||
await client.delete(`api/v1/rules/${ruleId}`);
|
||||
}
|
||||
|
||||
export async function listRuleSetVersions(
|
||||
client: KyInstance
|
||||
): Promise<import("./types").RuleSetVersion[]> {
|
||||
const response = await client.get("api/v1/rule-set-versions");
|
||||
return unwrap(response, z.array(RuleSetVersionSchema));
|
||||
}
|
||||
|
||||
export async function publishRuleSetVersion(
|
||||
client: KyInstance,
|
||||
versionName: string
|
||||
): Promise<import("./types").PublishVersionData> {
|
||||
const response = await client.post("api/v1/rule-set-versions/publish", {
|
||||
json: { versionName },
|
||||
});
|
||||
return unwrap(response, PublishVersionDataSchema);
|
||||
}
|
||||
|
||||
// ── 知识文档 ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function listArticles(
|
||||
client: KyInstance,
|
||||
params: {
|
||||
scenarios?: string[];
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
sortBy?: string;
|
||||
sortOrder?: string;
|
||||
} = {}
|
||||
): Promise<import("./types").KnowledgeArticleListData> {
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.set("offset", String(params.offset ?? 0));
|
||||
searchParams.set("limit", String(params.limit ?? 20));
|
||||
searchParams.set("sortBy", params.sortBy ?? "createdAt");
|
||||
searchParams.set("sortOrder", params.sortOrder ?? "desc");
|
||||
|
||||
if (params.scenarios) {
|
||||
for (let i = 0; i < params.scenarios.length; i++) {
|
||||
searchParams.set(`filter[scenarios][${i}]`, params.scenarios[i]);
|
||||
}
|
||||
}
|
||||
|
||||
const response = await client.get("api/v1/knowledge/articles", {
|
||||
searchParams,
|
||||
});
|
||||
return unwrap(response, KnowledgeArticleListDataSchema);
|
||||
}
|
||||
|
||||
export async function getArticle(
|
||||
client: KyInstance,
|
||||
articleId: string
|
||||
): Promise<import("./types").KnowledgeArticle> {
|
||||
const response = await client.get(`api/v1/knowledge/articles/${articleId}`);
|
||||
return unwrap(response, KnowledgeArticleSchema);
|
||||
}
|
||||
|
||||
export async function createArticle(
|
||||
client: KyInstance,
|
||||
params: {
|
||||
title: string;
|
||||
purpose: string;
|
||||
content: string;
|
||||
contentType?: string;
|
||||
status?: string;
|
||||
scenarios?: string[];
|
||||
tags?: string[];
|
||||
}
|
||||
): Promise<import("./types").KnowledgeArticle> {
|
||||
const response = await client.post("api/v1/knowledge/articles", {
|
||||
json: {
|
||||
...params,
|
||||
contentType: params.contentType ?? "policy",
|
||||
status: params.status ?? "published",
|
||||
scenarios: params.scenarios ?? [],
|
||||
tags: params.tags ?? [],
|
||||
},
|
||||
});
|
||||
return unwrap(response, KnowledgeArticleSchema);
|
||||
}
|
||||
|
||||
export async function patchArticle(
|
||||
client: KyInstance,
|
||||
articleId: string,
|
||||
params: {
|
||||
title?: string;
|
||||
purpose?: string;
|
||||
content?: string;
|
||||
contentType?: string;
|
||||
status?: string;
|
||||
enabled?: boolean;
|
||||
scenarios?: string[];
|
||||
tags?: string[];
|
||||
}
|
||||
): Promise<import("./types").KnowledgeArticle> {
|
||||
const attributes: Record<string, unknown> = {};
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value !== undefined) {
|
||||
attributes[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
const response = await client.patch(`api/v1/knowledge/articles/${articleId}`, {
|
||||
json: { attributes },
|
||||
});
|
||||
return unwrap(response, KnowledgeArticleSchema);
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
import { z } from "zod";
|
||||
import { KyInstance } from "ky";
|
||||
import * as api from "./api";
|
||||
|
||||
// ── Tool 定义 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export const sealaiTools = [
|
||||
{
|
||||
name: "sealai_whoami",
|
||||
description: "查询当前 SealAI 用户身份及租户信息",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => {
|
||||
return await api.getMe(client);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_billing",
|
||||
description: "查询 SealAI 订阅状态及功能配额",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => {
|
||||
return await api.getBillingStatus(client);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_rules_list",
|
||||
description: "列出 SealAI 草稿区审核规则",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => {
|
||||
return await api.listRules(client);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_rule_create",
|
||||
description: "新建 SealAI 草稿审核规则",
|
||||
parameters: z.object({
|
||||
description: z.string().describe("规则描述"),
|
||||
scope: z.string().describe("适用场景"),
|
||||
strictness: z
|
||||
.enum(["MUST_FOLLOW", "SHOULD_FOLLOW", "SUGGESTION"])
|
||||
.describe("严格程度"),
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: { description: string; scope: string; strictness: string }
|
||||
) => {
|
||||
return await api.createRule(client, params);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_rule_update",
|
||||
description: "更新 SealAI 草稿审核规则",
|
||||
parameters: z.object({
|
||||
ruleId: z.string().describe("规则 ID"),
|
||||
description: z.string().optional().describe("规则描述"),
|
||||
scope: z.string().optional().describe("适用场景"),
|
||||
strictness: z
|
||||
.enum(["MUST_FOLLOW", "SHOULD_FOLLOW", "SUGGESTION"])
|
||||
.optional()
|
||||
.describe("严格程度"),
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: {
|
||||
ruleId: string;
|
||||
description?: string;
|
||||
scope?: string;
|
||||
strictness?: string;
|
||||
}
|
||||
) => {
|
||||
const { ruleId, ...rest } = params;
|
||||
return await api.updateRule(client, ruleId, rest);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_rule_delete",
|
||||
description: "删除 SealAI 草稿审核规则",
|
||||
parameters: z.object({
|
||||
ruleId: z.string().describe("规则 ID"),
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { ruleId: string }) => {
|
||||
await api.deleteRule(client, params.ruleId);
|
||||
return { success: true };
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_versions_list",
|
||||
description: "列出 SealAI 已发布规则集版本历史",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => {
|
||||
return await api.listRuleSetVersions(client);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_version_publish",
|
||||
description: "发布 SealAI 草稿规则为新版本",
|
||||
parameters: z.object({
|
||||
versionName: z.string().describe("版本名称"),
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { versionName: string }) => {
|
||||
return await api.publishRuleSetVersion(client, params.versionName);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_knowledge_list",
|
||||
description: "列出 SealAI 知识文档",
|
||||
parameters: z.object({
|
||||
scenarios: z
|
||||
.array(z.string())
|
||||
.optional()
|
||||
.describe("场景过滤,如 [\"audit\", \"fill\"]"),
|
||||
offset: z.number().optional().describe("分页偏移量"),
|
||||
limit: z.number().optional().describe("每页数量"),
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: {
|
||||
scenarios?: string[];
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
}
|
||||
) => {
|
||||
return await api.listArticles(client, params);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_knowledge_get",
|
||||
description: "获取 SealAI 知识文档详情",
|
||||
parameters: z.object({
|
||||
articleId: z.string().describe("文档 ID"),
|
||||
}),
|
||||
handler: async (client: KyInstance, params: { articleId: string }) => {
|
||||
return await api.getArticle(client, params.articleId);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_knowledge_create",
|
||||
description: "新建 SealAI 知识文档",
|
||||
parameters: z.object({
|
||||
title: z.string().describe("文档标题"),
|
||||
purpose: z.string().describe("适用说明"),
|
||||
content: z.string().describe("正文内容(Markdown)"),
|
||||
contentType: z.string().optional().describe("内容类型,默认 policy"),
|
||||
status: z.string().optional().describe("published 或 draft"),
|
||||
scenarios: z.array(z.string()).optional().describe("适用场景"),
|
||||
tags: z.array(z.string()).optional().describe("标签"),
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: {
|
||||
title: string;
|
||||
purpose: string;
|
||||
content: string;
|
||||
contentType?: string;
|
||||
status?: string;
|
||||
scenarios?: string[];
|
||||
tags?: string[];
|
||||
}
|
||||
) => {
|
||||
return await api.createArticle(client, params);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sealai_knowledge_update",
|
||||
description: "更新 SealAI 知识文档",
|
||||
parameters: z.object({
|
||||
articleId: z.string().describe("文档 ID"),
|
||||
title: z.string().optional(),
|
||||
purpose: z.string().optional(),
|
||||
content: z.string().optional(),
|
||||
contentType: z.string().optional(),
|
||||
status: z.string().optional(),
|
||||
enabled: z.boolean().optional(),
|
||||
scenarios: z.array(z.string()).optional(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
}),
|
||||
handler: async (
|
||||
client: KyInstance,
|
||||
params: {
|
||||
articleId: string;
|
||||
title?: string;
|
||||
purpose?: string;
|
||||
content?: string;
|
||||
contentType?: string;
|
||||
status?: string;
|
||||
enabled?: boolean;
|
||||
scenarios?: string[];
|
||||
tags?: string[];
|
||||
}
|
||||
) => {
|
||||
const { articleId, ...rest } = params;
|
||||
return await api.patchArticle(client, articleId, rest);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export type SealAiTool = (typeof sealaiTools)[number];
|
||||
@@ -1,159 +0,0 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// ── 认证 ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
export const HosecloudStaffSchema = z.object({
|
||||
staffId: z.string(),
|
||||
name: z.string(),
|
||||
code: z.string().default(""),
|
||||
bindTime: z.number(),
|
||||
});
|
||||
|
||||
export const SealAiUserSchema = z.object({
|
||||
id: z.string(),
|
||||
tenantId: z.string(),
|
||||
name: z.string(),
|
||||
isAdmin: z.boolean(),
|
||||
permissions: z.array(z.string()),
|
||||
providerUserId: z.string(),
|
||||
hosecloudStaff: HosecloudStaffSchema.optional(),
|
||||
});
|
||||
|
||||
export const HoseCorpConfigSchema = z.object({
|
||||
apiKey: z.string(),
|
||||
corporationId: z.string(),
|
||||
corporationName: z.string(),
|
||||
});
|
||||
|
||||
export const SealAiTenantSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
tenantSlug: z.string(),
|
||||
isDemo: z.boolean(),
|
||||
logoUrl: z.string().optional(),
|
||||
hoseCorpConfig: HoseCorpConfigSchema,
|
||||
});
|
||||
|
||||
export const MeDataSchema = z.object({
|
||||
user: SealAiUserSchema,
|
||||
tenant: SealAiTenantSchema,
|
||||
});
|
||||
|
||||
// ── 计费 ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
export const SubscriptionSchema = z.object({
|
||||
id: z.string(),
|
||||
tenantId: z.string(),
|
||||
planId: z.string(),
|
||||
status: z.string(), // "active" | "expired"
|
||||
startDate: z.string(),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
});
|
||||
|
||||
export const FeatureSchema = z.object({
|
||||
code: z.string(),
|
||||
name: z.string(),
|
||||
enabled: z.boolean().optional(),
|
||||
quota: z.number().optional(),
|
||||
used: z.number().optional(),
|
||||
remaining: z.number().optional(),
|
||||
balance: z.number().optional(),
|
||||
totalQuota: z.number().optional(),
|
||||
totalUsed: z.number().optional(),
|
||||
nextResetDate: z.string().optional(),
|
||||
});
|
||||
|
||||
export const BillingStatusDataSchema = z.object({
|
||||
subscriptions: z.array(SubscriptionSchema),
|
||||
features: z.array(FeatureSchema),
|
||||
});
|
||||
|
||||
// ── 审核规则草稿 ──────────────────────────────────────────────────────────────
|
||||
|
||||
export const DraftRuleSchema = z.object({
|
||||
id: z.string(),
|
||||
tenantId: z.string(),
|
||||
description: z.string(),
|
||||
scope: z.string(),
|
||||
strictness: z.string(), // MUST_FOLLOW / SHOULD_FOLLOW / SUGGESTION
|
||||
status: z.string(), // DRAFT
|
||||
createdAt: z.number(),
|
||||
updatedAt: z.number(),
|
||||
});
|
||||
|
||||
export const DraftRulesDataSchema = z.object({
|
||||
rules: z.array(DraftRuleSchema),
|
||||
hasPendingDeletes: z.boolean().default(false),
|
||||
});
|
||||
|
||||
// ── 已发布版本 ────────────────────────────────────────────────────────────────
|
||||
|
||||
export const PublishedRuleSnapshotSchema = z.object({
|
||||
description: z.string(),
|
||||
scope: z.string(),
|
||||
strictness: z.string(),
|
||||
});
|
||||
|
||||
export const RuleSetVersionSchema = z.object({
|
||||
id: z.string(),
|
||||
tenantId: z.string(),
|
||||
versionNumber: z.number(),
|
||||
versionName: z.string(),
|
||||
publishedBy: z.string(),
|
||||
publishedByName: z.string(),
|
||||
rules: z.array(PublishedRuleSnapshotSchema),
|
||||
publishedAt: z.number(),
|
||||
createdAt: z.number(),
|
||||
});
|
||||
|
||||
export const PublishVersionDataSchema = z.object({
|
||||
version: RuleSetVersionSchema,
|
||||
rulesCount: z.number(),
|
||||
});
|
||||
|
||||
// ── 知识文档 ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export const KnowledgeArticleSchema = z.object({
|
||||
id: z.string(),
|
||||
tenantId: z.string(),
|
||||
title: z.string(),
|
||||
purpose: z.string(),
|
||||
contentType: z.string(),
|
||||
content: z.string(),
|
||||
status: z.string(), // "published" | "draft"
|
||||
enabled: z.boolean().default(true),
|
||||
scenarios: z.array(z.string()).default([]),
|
||||
tags: z.array(z.string()).default([]),
|
||||
category: z.string().optional(),
|
||||
categoryTags: z.array(z.string()).default([]),
|
||||
createdBy: z.string().optional(),
|
||||
createdByName: z.string().optional(),
|
||||
createdAt: z.number().optional(),
|
||||
updatedAt: z.number().optional(),
|
||||
updatedBy: z.string().optional(),
|
||||
updatedByName: z.string().optional(),
|
||||
isDeleted: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export const KnowledgeArticleListDataSchema = z.object({
|
||||
articles: z.array(KnowledgeArticleSchema),
|
||||
total: z.number().optional(),
|
||||
});
|
||||
|
||||
// ── 类型导出 ──────────────────────────────────────────────────────────────────
|
||||
|
||||
export type HosecloudStaff = z.infer<typeof HosecloudStaffSchema>;
|
||||
export type SealAiUser = z.infer<typeof SealAiUserSchema>;
|
||||
export type SealAiTenant = z.infer<typeof SealAiTenantSchema>;
|
||||
export type MeData = z.infer<typeof MeDataSchema>;
|
||||
export type Subscription = z.infer<typeof SubscriptionSchema>;
|
||||
export type Feature = z.infer<typeof FeatureSchema>;
|
||||
export type BillingStatusData = z.infer<typeof BillingStatusDataSchema>;
|
||||
export type DraftRule = z.infer<typeof DraftRuleSchema>;
|
||||
export type DraftRulesData = z.infer<typeof DraftRulesDataSchema>;
|
||||
export type PublishedRuleSnapshot = z.infer<typeof PublishedRuleSnapshotSchema>;
|
||||
export type RuleSetVersion = z.infer<typeof RuleSetVersionSchema>;
|
||||
export type PublishVersionData = z.infer<typeof PublishVersionDataSchema>;
|
||||
export type KnowledgeArticle = z.infer<typeof KnowledgeArticleSchema>;
|
||||
export type KnowledgeArticleListData = z.infer<typeof KnowledgeArticleListDataSchema>;
|
||||
Reference in new issue
Block a user