Add system configuration endpoints support and bump version to 0.3.8
This commit is contained in:
1 parent
8b070cf956
commit
e7ebfcd16a
6 files changed
+175
-2
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "seal-home",
|
||||
"version": "0.3.7",
|
||||
"version": "0.3.8",
|
||||
"type": "module",
|
||||
"module": "src/server.ts",
|
||||
"bin": {
|
||||
|
||||
+42
@@ -191,6 +191,41 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "llm" && (action === "config" || action === "get")) {
|
||||
await runTool("seal_llm_config_get", client, corp, {}, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "llm" && (action === "providers" || action === "list")) {
|
||||
await runTool("seal_llm_providers_list", client, corp, {}, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "permissions" && action === "available") {
|
||||
await runTool("seal_permissions_available_list", client, corp, {}, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "permissions" && (action === "configs" || action === "list")) {
|
||||
await runTool("seal_permissions_configs_list", client, corp, {}, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "billing" && (action === "status" || action === "get")) {
|
||||
await runTool("seal_billing_status_get", client, corp, {}, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "billing" && action === "plans") {
|
||||
await runTool("seal_billing_plans_list", client, corp, {}, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "billing" && action === "features") {
|
||||
await runTool("seal_billing_features_list", client, corp, {}, outputOptions(args.options));
|
||||
return;
|
||||
}
|
||||
|
||||
if (area === "context") {
|
||||
await runTool("seal_approval_context_get", client, corp, {
|
||||
documentLimit: numberOption(args.options.documentLimit),
|
||||
@@ -1294,6 +1329,13 @@ Usage:
|
||||
seal-home users reset-password <userId> [--corp <corpId>]
|
||||
seal-home users get <userId> [--corp <corpId>]
|
||||
seal-home users delete <userId> [--corp <corpId>]
|
||||
seal-home llm config [--corp <corpId>]
|
||||
seal-home llm providers [--corp <corpId>]
|
||||
seal-home permissions available [--corp <corpId>]
|
||||
seal-home permissions configs [--corp <corpId>]
|
||||
seal-home billing status [--corp <corpId>]
|
||||
seal-home billing plans [--corp <corpId>]
|
||||
seal-home billing features [--corp <corpId>]
|
||||
seal-home source config [--corp <corpId>]
|
||||
seal-home tool <toolName> [--corp <corpId>] [--json '{"key":"value"}']
|
||||
seal-home rules count [--corp <corpId>]
|
||||
|
||||
+44
-1
@@ -30,7 +30,17 @@ import {
|
||||
SealUserResetPasswordResult,
|
||||
SealUserResetPasswordResultSchema,
|
||||
SealUserDetail,
|
||||
SealUserDetailSchema
|
||||
SealUserDetailSchema,
|
||||
LlmConfig,
|
||||
LlmConfigSchema,
|
||||
LlmProvider,
|
||||
LlmProviderSchema,
|
||||
AvailablePermissionsData,
|
||||
AvailablePermissionsDataSchema,
|
||||
PermissionConfigsData,
|
||||
PermissionConfigsDataSchema,
|
||||
BillingStatusData,
|
||||
BillingStatusDataSchema
|
||||
} from "./types.js";
|
||||
|
||||
async function unwrap<T>(response: Response, schema: z.ZodType<T>): Promise<T> {
|
||||
@@ -395,4 +405,37 @@ export async function deleteLocalUser(
|
||||
return json.data?.success ?? response.ok;
|
||||
}
|
||||
|
||||
export async function getLlmConfig(client: KyInstance): Promise<LlmConfig> {
|
||||
return unwrap(await client.get("api/v1/llm/config"), LlmConfigSchema);
|
||||
}
|
||||
|
||||
export async function listLlmProviders(client: KyInstance): Promise<LlmProvider[]> {
|
||||
return unwrap(await client.get("api/v1/llm/providers"), z.array(LlmProviderSchema));
|
||||
}
|
||||
|
||||
export async function listAvailablePermissions(client: KyInstance): Promise<AvailablePermissionsData> {
|
||||
return unwrap(await client.get("api/v1/permissions/available"), AvailablePermissionsDataSchema);
|
||||
}
|
||||
|
||||
export async function listPermissionConfigs(client: KyInstance): Promise<PermissionConfigsData> {
|
||||
return unwrap(await client.get("api/v1/permissions/configs"), PermissionConfigsDataSchema);
|
||||
}
|
||||
|
||||
export async function getBillingStatus(client: KyInstance): Promise<BillingStatusData> {
|
||||
return unwrap(await client.get("api/v1/billing/status"), BillingStatusDataSchema);
|
||||
}
|
||||
|
||||
export async function listBillingPlans(client: KyInstance): Promise<unknown> {
|
||||
const response = await client.get("api/v1/billing/plans");
|
||||
const json = (await response.json()) as { data?: unknown };
|
||||
return json.data ?? json;
|
||||
}
|
||||
|
||||
export async function listBillingFeatures(client: KyInstance): Promise<unknown> {
|
||||
const response = await client.get("api/v1/billing/features");
|
||||
const json = (await response.json()) as { data?: unknown };
|
||||
return json.data ?? json;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -78,6 +78,16 @@ describe("sealTools", () => {
|
||||
expect(deleteTool).toBeDefined();
|
||||
});
|
||||
|
||||
test("includes system configuration tools", () => {
|
||||
expect(sealTools.find((item) => item.name === "seal_llm_config_get")).toBeDefined();
|
||||
expect(sealTools.find((item) => item.name === "seal_llm_providers_list")).toBeDefined();
|
||||
expect(sealTools.find((item) => item.name === "seal_permissions_available_list")).toBeDefined();
|
||||
expect(sealTools.find((item) => item.name === "seal_permissions_configs_list")).toBeDefined();
|
||||
expect(sealTools.find((item) => item.name === "seal_billing_status_get")).toBeDefined();
|
||||
expect(sealTools.find((item) => item.name === "seal_billing_plans_list")).toBeDefined();
|
||||
expect(sealTools.find((item) => item.name === "seal_billing_features_list")).toBeDefined();
|
||||
});
|
||||
|
||||
test("includes the approval search tool", () => {
|
||||
const tool = sealTools.find((item) => item.name === "seal_approval_search");
|
||||
expect(tool).toBeDefined();
|
||||
|
||||
@@ -95,6 +95,48 @@ export const sealTools = [
|
||||
handler: async (client: KyInstance, params: { userId: string }) =>
|
||||
api.deleteLocalUser(client, params.userId)
|
||||
},
|
||||
{
|
||||
name: "seal_llm_config_get",
|
||||
description: "查询当前 Seal 租户的大模型 (LLM) 配置",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.getLlmConfig(client)
|
||||
},
|
||||
{
|
||||
name: "seal_llm_providers_list",
|
||||
description: "查询支持的大模型 (LLM) 供应商与配置属性字段",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.listLlmProviders(client)
|
||||
},
|
||||
{
|
||||
name: "seal_permissions_available_list",
|
||||
description: "查询系统可选权限清单(如超级管理员、智能审核管理、数据管理等)",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.listAvailablePermissions(client)
|
||||
},
|
||||
{
|
||||
name: "seal_permissions_configs_list",
|
||||
description: "查询当前租户已绑定的权限配置",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.listPermissionConfigs(client)
|
||||
},
|
||||
{
|
||||
name: "seal_billing_status_get",
|
||||
description: "查询当前 Seal 租户的订阅状态与各功能额度(AI审批、审核规则、知识文档等)",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.getBillingStatus(client)
|
||||
},
|
||||
{
|
||||
name: "seal_billing_plans_list",
|
||||
description: "查询系统支持的订阅套餐列表",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.listBillingPlans(client)
|
||||
},
|
||||
{
|
||||
name: "seal_billing_features_list",
|
||||
description: "查询系统支持的功能特性定义列表",
|
||||
parameters: z.object({}),
|
||||
handler: async (client: KyInstance) => api.listBillingFeatures(client)
|
||||
},
|
||||
{
|
||||
name: "seal_approval_rules_list",
|
||||
description: "列出 Seal 当前草稿审批规则;支持 countOnly、fields、limit 以避免返回规则正文",
|
||||
|
||||
@@ -256,6 +256,36 @@ export const SealUserDetailSchema = z.object({
|
||||
updatedAt: z.string().optional()
|
||||
}).passthrough();
|
||||
|
||||
export const LlmConfigSchema = z.object({
|
||||
provider: z.string(),
|
||||
config: z.record(z.string(), z.unknown()).default({})
|
||||
}).passthrough();
|
||||
|
||||
export const LlmProviderSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string().optional(),
|
||||
available: z.boolean().default(true),
|
||||
fields: z.array(z.record(z.string(), z.unknown())).default([])
|
||||
}).passthrough();
|
||||
|
||||
export const AvailablePermissionsDataSchema = z.object({
|
||||
permissions: z.array(z.object({
|
||||
key: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string().optional()
|
||||
}).passthrough()).default([])
|
||||
}).passthrough();
|
||||
|
||||
export const PermissionConfigsDataSchema = z.object({
|
||||
configs: z.array(z.record(z.string(), z.unknown())).default([])
|
||||
}).passthrough();
|
||||
|
||||
export const BillingStatusDataSchema = z.object({
|
||||
subscriptions: z.array(z.record(z.string(), z.unknown())).default([]),
|
||||
features: z.array(z.record(z.string(), z.unknown())).default([])
|
||||
}).passthrough();
|
||||
|
||||
export type MeData = z.infer<typeof MeDataSchema>;
|
||||
export type SealSessionData = z.infer<typeof SealSessionDataSchema>;
|
||||
export type ApprovalRule = z.infer<typeof ApprovalRuleSchema>;
|
||||
@@ -273,5 +303,11 @@ export type SealDelegationCreateResult = z.infer<typeof SealDelegationCreateResu
|
||||
export type SealUserCreateResult = z.infer<typeof SealUserCreateResultSchema>;
|
||||
export type SealUserResetPasswordResult = z.infer<typeof SealUserResetPasswordResultSchema>;
|
||||
export type SealUserDetail = z.infer<typeof SealUserDetailSchema>;
|
||||
export type LlmConfig = z.infer<typeof LlmConfigSchema>;
|
||||
export type LlmProvider = z.infer<typeof LlmProviderSchema>;
|
||||
export type AvailablePermissionsData = z.infer<typeof AvailablePermissionsDataSchema>;
|
||||
export type PermissionConfigsData = z.infer<typeof PermissionConfigsDataSchema>;
|
||||
export type BillingStatusData = z.infer<typeof BillingStatusDataSchema>;
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user