From 340dfbf993a0736d3f539277029ae0d2ea69c1b3 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Fri, 5 Jun 2026 16:05:11 +0800 Subject: [PATCH] docs: add seal probe workflow --- README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/probe.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 README.md create mode 100644 src/probe.ts diff --git a/README.md b/README.md new file mode 100644 index 0000000..0703851 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# seal-home + +Bun + TypeScript MCP server for pulling Seal enterprise approval context from provider credentials. + +The first provider is Hose/合思: `key`, `password`, `corpId`, `staffId`, and an optional Hose domain. The provider exchanges those credentials for a Seal enterprise session, then the Seal domain tools can read and maintain approval rules, approval documents, and approval style preferences. + +`direct` is also available for later sources that already provide a Seal Bearer token. + +## Setup + +```bash +bun install +cp enterprises/example.hose.json enterprises/local.json +bun run check +bun run probe +bun run start +``` + +For an already-authenticated Seal source, copy `enterprises/example.direct.json` instead. + +## Enterprise Config + +```json +{ + "id": "corp-id", + "name": "企业名称", + "seal": { + "url": "https://corp-id.sealai.cc", + "endpoints": { + "approvalStylePreferences": "api/v1/approval/style-preferences" + } + }, + "source": { + "type": "hose", + "domain": "https://app.ekuaibao.com", + "key": "hose-app-key", + "password": "hose-app-security", + "staffId": "hose-staff-id", + "corpId": "hose-corp-id" + }, + "auth": { + "refreshTtl": 300 + } +} +``` + +## Tools + +- `seal_source_config`: resolve current Seal enterprise config from the configured source. +- `seal_whoami`: current Seal user and tenant. +- `seal_approval_context_get`: read current approval rules, approval documents, and approval style preferences in one call. +- `seal_approval_rules_list`: current draft approval rules. +- `seal_approval_rule_create`, `seal_approval_rule_update`, `seal_approval_rule_delete`: maintain approval rules. +- `seal_approval_rule_versions_list`, `seal_approval_rule_version_publish`: read and publish rule versions. +- `seal_approval_documents_list`, `seal_approval_document_get`, `seal_approval_document_create`, `seal_approval_document_update`: maintain approval documents. +- `seal_approval_style_preferences_get`, `seal_approval_style_preferences_update`: read and update approval style preferences. diff --git a/src/probe.ts b/src/probe.ts new file mode 100644 index 0000000..1018f1b --- /dev/null +++ b/src/probe.ts @@ -0,0 +1,48 @@ +import { loadCorpConfigs } from "./core/config/loader.js"; +import { createSealClient } from "./core/http/factory.js"; +import { resolveLiveSealEnterpriseConfig } from "./domains/seal/source.js"; +import { getApprovalContext } from "./domains/seal/api.js"; + +async function main() { + const corpId = Bun.argv[2]; + const corps = loadCorpConfigs(); + const corp = corpId + ? corps.find((item) => item.id === corpId) + : corps[0]; + + if (!corp) { + throw new Error( + corpId + ? `No enterprise config found for ${corpId}` + : "No enterprise config found. Add enterprises/local.json first." + ); + } + + console.log(`[probe] corp=${corp.id} source=${corp.source.type}`); + + const enterprise = await resolveLiveSealEnterpriseConfig(corp); + console.log("[probe] seal enterprise"); + console.log(JSON.stringify(enterprise, null, 2)); + + const client = await createSealClient(corp); + const context = await getApprovalContext(client, { + documentLimit: 20, + stylePreferencesEndpoint: corp.seal.endpoints.approvalStylePreferences + }); + + console.log("[probe] approval context summary"); + console.log(JSON.stringify({ + rules: context.rules.rules.length, + hasPendingRuleDeletes: context.rules.hasPendingDeletes, + documents: context.documents.articles.length, + documentsTotal: context.documents.total, + stylePreferences: context.stylePreferences.ok + ? "ok" + : `error: ${context.stylePreferences.error}` + }, null, 2)); +} + +main().catch((error) => { + console.error(error instanceof Error ? error.message : error); + process.exit(1); +});