From 29ec2577880f5e6561b4533b706d4ad8e07d43d7 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Tue, 14 Apr 2026 16:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=20CLAUDE.md=20SealAI=20?= =?UTF-8?q?=E7=AB=A0=E8=8A=82=EF=BC=8C=E7=BB=86=E8=8A=82=E7=A7=BB=E5=85=A5?= =?UTF-8?q?=20commands/sealai/README.sealai.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 28 +------- src/ekb_cli/commands/sealai/README.sealai.md | 70 ++++++++++++++++++++ 2 files changed, 73 insertions(+), 25 deletions(-) create mode 100644 src/ekb_cli/commands/sealai/README.sealai.md diff --git a/CLAUDE.md b/CLAUDE.md index 328487a..2e9be9d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -165,33 +165,11 @@ ekb ## SealAI 子平台 -SealAI 是独立于快报主站的 Next.js 平台(`{corpId.lower()}.sealai.cc`),提供 AI 填单/审批功能。 -Kubernetes/Istio 后端,认证体系完全独立。 - -### SealAI 认证流程 - -``` -快报 accesstoken - → GET https://{corpId.lower()}.sealai.cc/api/auth/oauth2/session/oem-hosecloud - ?token={accesstoken}&returnToken=1 - → Bearer JWT(缓存到 ~/.config/ekb-cli/sealai_tokens.json,TTL 1小时) - → SealAiClient(corp_id, bearer_token) -``` - -- corpId 转小写作为子域名:`ID01Jdq2yIDnMr` → `id01jdq2yidnmr.sealai.cc` -- token 缓存格式:`{ "corpId": { "token": "...", "fetched_at": 1712345678 } }` -- 401 时自动清除缓存,下次调用触发重新换取 - -### 已知 SealAI API 路径 - -> 所有路径含完整前缀,`client.get(path)` 直接传完整路径。 - -``` -GET /api/v1/auth/me # 当前用户身份(user + tenant) -GET /api/v1/billing/status # 订阅状态 + 各功能配额 -``` +SealAI 是独立于快报主站的 Next.js 平台(`{corpId.lower()}.sealai.cc`),认证体系完全独立。 +> 认证机制、API 路径、功能说明详见 `commands/sealai/README.sealai.md` +## 已知快报 API 路径 > 所有路径前缀为 `/api`,后端框架:Spring Boot(com.hosecloud.habserver)。 > `client.get(path)` 会自动补 `/api` 前缀,路径写 `/engine/...` 即可。 diff --git a/src/ekb_cli/commands/sealai/README.sealai.md b/src/ekb_cli/commands/sealai/README.sealai.md new file mode 100644 index 0000000..21431ec --- /dev/null +++ b/src/ekb_cli/commands/sealai/README.sealai.md @@ -0,0 +1,70 @@ +# SealAI 模块说明 + +SealAI(`{corpId.lower()}.sealai.cc`)是独立于快报主站的 AI 填单/审批平台, +采用 Next.js App Router + Kubernetes/Istio 后端,认证体系与快报 HAB 完全独立。 + +## 目录分层 + +``` +api/sealai/ +├── client.py SealAiClient(httpx,Bearer JWT 认证) +├── schemas.py Pydantic 数据模型 +├── auth_api.py GET /api/v1/auth/me +└── billing_api.py GET /api/v1/billing/status + +services/sealai/ +├── auth_service.py SSO token 换取 + 本地缓存管理 +└── billing_service.py 订阅状态查询 + 单功能配额查询 + +commands/sealai/ +├── whoami.py ekb sealai whoami +└── billing.py ekb sealai billing + +server/sealai_router.py /sealai/me /sealai/billing +``` + +## 认证流程 + +``` +快报 accesstoken + → GET https://{corpId.lower()}.sealai.cc/api/auth/oauth2/session/oem-hosecloud + ?token={accesstoken}&returnToken=1 + → Bearer JWT + → 缓存到 ~/.config/ekb-cli/sealai_tokens.json(TTL 1小时) + → SealAiClient(corp_id, bearer_token) +``` + +- corpId 转小写作为子域名:`ID01Jdq2yIDnMr` → `id01jdq2yidnmr.sealai.cc` +- token 缓存格式:`{ "corpId": { "token": "...", "fetched_at": 1712345678 } }` +- 401 时自动清除缓存,下次调用重新换取(`invalidate_token(corp_id)` 手动触发) + +## 已知 API 路径 + +> `client.get(path)` 直接传完整路径(含 `/api` 前缀)。 + +``` +GET /api/v1/auth/me # 当前用户身份(user + tenant) +GET /api/v1/billing/status # 订阅状态 + 各功能配额 +``` + +## 功能项(Feature)说明 + +| code | 名称 | 类型 | 说明 | +|------|------|------|------| +| `ai-approval` | AI 审批 | 余额型 | balance/totalQuota/totalUsed | +| `approval-rules` | 审核规则 | 配额型 | quota/used/remaining | +| `financial-policies` | 财务制度 | 配额型 | quota/used/remaining | +| `knowledge-documents` | 知识文档 | 配额型 | quota/used/remaining | +| `webhook` | Webhook | 开关型 | enabled | +| `openapi` | Open API | 开关型 | enabled | +| `private-model` | 私有模型接入 | 开关型 | enabled | +| `ai-fill` | AI 智能填单 | 开关型 | enabled | + +## CLI 命令速查 + +```bash +ekb sealai whoami # 查看 SealAI 用户身份 + 租户信息 +ekb sealai whoami --refresh # 强制刷新 Bearer token 后查看 +ekb sealai billing # 查看订阅状态 + 功能配额表 +ekb sealai whoami --corp # 查看指定企业(不切换当前企业) +```