diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41ae2f1..f16baec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -91,12 +91,26 @@ jobs: fi echo "==> Uploading assets to Gitea release ID ${RELEASE_ID}..." - for file in dist/bin/seal-home-*; do + upload_asset() { + local file="$1" + local filename filename=$(basename "$file") - echo " Uploading ${filename} to Gitea..." - RESP=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X POST "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}/assets?name=${filename}" \ + echo " [start] Uploading ${filename} to Gitea..." + RESP=$(curl -s -m 120 -w "\nHTTP_STATUS:%{http_code}" -X POST "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/${RELEASE_ID}/assets?name=${filename}" \ -H "Authorization: token ${GITEA_TOKEN}" \ -F "attachment=@${file}") - echo " Upload response: $(echo "$RESP" | tail -n 1)" + STATUS=$(echo "$RESP" | tail -n 1) + echo " [done] ${filename} -> ${STATUS}" + } + + pids=() + for file in dist/bin/seal-home-*; do + upload_asset "$file" & + pids+=($!) + done + + # Wait for all parallel uploads to complete + for pid in "${pids[@]}"; do + wait "$pid" || true done echo "✓ Successfully published release assets to Gitea!" diff --git a/dist/mcp/server.js b/dist/mcp/server.js index 6f05aae..7016b1c 100644 --- a/dist/mcp/server.js +++ b/dist/mcp/server.js @@ -34868,7 +34868,6 @@ seal-home tool seal_approval_search --corp --json '{"keywords":["差旅 - \`references/approval-run-lightweight.md\`: 单号定位、字段裁剪、摘要、引用规则、单据摘要、附件摘要。 - \`references/rule-lightweight.md\`: 规则 count/list summary、按版本/编号取单条规则、规则搜索裁剪。 - \`references/customer-feedback-rule-remediation.md\`: 微信/截图反馈包到企业定位、审批追踪、根因分类、最小规则 diff、确认、发布与验收的固定闭环。 -- \`references/hose-enterprise-init.md\`: Hose 企业自动化初始化、多域名并发探测、OpenAPI 角色与人员发现、安全选人。 - \`references/hose-enterprise-auth.md\`: Hose 企业配置、认证诊断、授权链接。 - \`references/approval-attachment-trace.md\`: 附件/发票/OCR/图片争议的 Langfuse 追踪工作流。 - \`references/cli.md\`: 完整 CLI 命令清单。 @@ -35088,9 +35087,7 @@ seal-home tools list seal-home corps list [--corp ] seal-home corps current [--corp ] seal-home corps switch -seal-home corps probe-hose --json '{"appKey":"...","appSecurity":"..."}' -seal-home corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}' -seal-home corps add-hose --json '{"appKey":"...","appSecurity":"...","staffId":"corpId:staffId"}' +seal-home corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}' seal-home corps add-seal --json '{"sealUrl":"https://tenant.sealai.cc","token":"seal-bearer-token"}' seal-home auth diagnose [--corp ] seal-home auth hose-link [--corp ] [--expire 7200] @@ -35815,15 +35812,10 @@ Use this reference for Hose/合思 enterprise configuration and user-facing Hose ## Add or switch an enterprise -Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit \`~/.config/seal-home/enterprises/*.json\` unless the CLI fails or the user explicitly asks for low-level config debugging. For full automated multi-domain probing and role/staff discovery, read \`references/hose-enterprise-init.md\`. +Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit \`~/.config/seal-home/enterprises/*.json\` unless the CLI fails or the user explicitly asks for low-level config debugging. \`\`\`bash -# 1. Probing & discovery (auto-detects domain and roles) -seal-home corps probe-hose --json '{"appKey":"...","appSecurity":"..."}' -seal-home corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}' - -# 2. Add enterprise (supports domain auto-probing and staffName/staffPhone matching) -seal-home corps add-hose --json '{"appKey":"...","appSecurity":"...","staffId":"corpId:staffId"}' +seal-home corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}' seal-home corps list seal-home corps current --corp seal-home corps switch @@ -35877,6 +35869,115 @@ Important: - If the CLI later provides a dedicated command for this, prefer that command. `; +// skills/seal-home/references/hose-enterprise-init.md +var hose_enterprise_init_default = `# Hose Enterprise Initialization & Automated Discovery + +Use this reference for automated Hose/合思 enterprise onboarding, multi-domain probing (including dedicated private cloud domains like 美年大健康), OpenAPI role and staff discovery, and non-TUI safe administrator selection. + +--- + +## 1. Domain Tiering & Probing Strategy + +合思在不同公有云和专有云平台部署了不同的服务端域名。系统采用 **三级域名决策模型**: + +\`\`\`mermaid +flowchart TD + A["输入参数: appKey, appSecurity, [domain]"] --> B{"是否显式提供了 domain?
(如美年大健康等专有云/独立部署域名)"} + B -->|是 (专属域名优先)| C["直接针对该 domain 验证"] + B -->|否 (未指定)| D["并发探测 6 大标准公共 SaaS 域名"] + D --> E{"是否有且仅有 1 个域名验证成功?"} + E -->|是| F["自动锁定该域名为目标 domain"] + E -->|否 (全部返回 403 / 失败)| G["❌ 友好降级提示:
'在标准合思 SaaS 环境中未检测到有效凭证。
若是专属域名或私有化部署环境(如美年大健康),请显式提供企业专属 domain。'"] +\`\`\` + +### 预置 6 大标准公共 SaaS 域名池(仅作缺省探测使用): +1. \`https://app.ekuaibao.com\` (合思独立版 / 标准版) +2. \`https://dd2.hosecloud.com\` (钉钉版) +3. \`https://wx2.ekuaibao.com\` (企业微信版) +4. \`https://kdcloud2.ekuaibao.com\` (云之家版) +5. \`https://ddenterprise.ekuaibao.com\` (钉钉企业自建应用) +6. \`https://feishu.ekuaibao.com\` (飞书版) + +--- + +## 2. 核心 OpenAPI 接口契约 + +| 阶段 | 接口用途 | Method & URL 规范 | 关键参数 | 注意事项 | +| :---: | :--- | :--- | :--- | :--- | +| **1** | 获取开放凭证 | \`POST {domain}/api/openapi/v1/auth/getAccessToken\` | \`appKey\`, \`appSecurity\` | 确定有效 \`domain\`、\`corpId\` 与 \`accessToken\` | +| **2** | 查询角色组与角色 | \`GET {domain}/api/openapi/v1/roleDefGroups?accessToken=...\` | \`accessToken\` | 获取企业全部角色分组及 RoleDefId | +| **3** | 查询角色成员 ID 列表 | \`GET {domain}/api/openapi/v1/roledefs/\${roledefId}?accessToken=...&staffBy=id\` | \`accessToken\`, \`roledefId\` | **URL 中必须带有字面量 \`$\` 字符**(如 \`/roledefs/$ID01...:admin\`) | +| **4** | 批量查询人员详情 | \`POST {domain}/api/openapi/v1/staffs/getStaffIds?accessToken=...\` | \`{"type": "STAFFID", "conditionIds": [...]}\` | 批量单次上限 100,返回姓名、手机号、是否激活(\`authState\`)、第三方 ID | +| **5** | 生成临时免密凭据 | \`POST {domain}/api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=...\` | \`{"uid": "{corpId}:{staffId}", "pageType": "home", "expireDate": 7200}\` | 用于 Seal SSO 换取 Session 会话 | + +--- + +## 3. CLI 探测与人员发现命令 + +### 1) 企业探测与角色发现 (\`corps probe-hose\`) +\`\`\`bash +seal-home corps probe-hose --json '{ + "appKey": "...", + "appSecurity": "...", + "domain": "https://custom.ekuaibao.com" # 可选,未传时自动探测 6 域名 +}' +\`\`\` +* **输出**:自动探测匹配的 \`domain\`、企业 ID \`corpId\`、企业名称 \`name\`、角色总数以及完整的角色分组列表。 + +### 2) 按角色查询候选员工 (\`corps hose-staffs\`) +\`\`\`bash +# 默认查询主管理员角色 (admin) +seal-home corps hose-staffs --json '{ + "appKey": "...", + "appSecurity": "...", + "role": "admin" +}' + +# 查询指定业务角色 (如 "财务主管"、"采购申请权限" 或具体 roleDefId) +seal-home corps hose-staffs --json '{ + "appKey": "...", + "appSecurity": "...", + "role": "财务主管" +}' +\`\`\` +* **输出**:返回匹配角色下所有人员的详情列表,包含 \`id\` (\`corpId:staffId\`)、\`name\`、\`cellphone\`、\`active\`(是否在职)、\`authState\`(是否激活)。 + +--- + +## 4. 安全选人与防静默绑定规范 (Anti-Silent Guard) + +为了防止越权及未授权账号绑定,系统实施**严格的人员选定与安全确认机制**: + +1. **若用户在初始指令中已指名(姓名或手机号)**: + \`\`\`bash + seal-home corps add-hose --json '{ + "appKey": "...", + "appSecurity": "...", + "staffName": "于光泽" + }' + \`\`\` + * 系统通过角色人员列表匹配:若**唯一匹配且 \`active == true\`**,直接绑定该 \`staffId\` 完成接入。 +2. **若用户未指定且存在多位候选管理员**: + \`\`\`bash + seal-home corps add-hose --json '{ + "appKey": "...", + "appSecurity": "..." + }' + \`\`\` + * 系统**严禁静默默认挑选第一个管理员**; + * 命令会以错误形式退出,并列出所有候选管理员详情(姓名、手机号、ID、激活状态); + * Agent 应将候选人列表以结构化形式呈现给用户确认,待用户选定后,传入 \`staffId\` 或 \`staffName\` 再次执行。 +3. **若已知目标人员 ID**: + \`\`\`bash + seal-home corps add-hose --json '{ + "appKey": "...", + "appSecurity": "...", + "staffId": "ID01OZVhtzekb5:ID01K9vHULqNj1" + }' + \`\`\` + * 直接使用指定 ID 完成接入并进行连通性验证。 +`; + // src/core/embedded-skill.ts var EMBEDDED_SKILL_FILES = { "SKILL.md": SKILL_default, @@ -35887,7 +35988,8 @@ var EMBEDDED_SKILL_FILES = { "references/approval-run-lightweight.md": approval_run_lightweight_default, "references/approval-attachment-trace.md": approval_attachment_trace_default, "references/customer-feedback-rule-remediation.md": customer_feedback_rule_remediation_default, - "references/hose-enterprise-auth.md": hose_enterprise_auth_default + "references/hose-enterprise-auth.md": hose_enterprise_auth_default, + "references/hose-enterprise-init.md": hose_enterprise_init_default }; function getSkillContent() { return EMBEDDED_SKILL_FILES["SKILL.md"] || ""; diff --git a/scripts/bump-version.ts b/scripts/bump-version.ts index b95bce2..a849e7a 100644 --- a/scripts/bump-version.ts +++ b/scripts/bump-version.ts @@ -47,6 +47,7 @@ const skillPath = join(ROOT, "skills", "seal-home", "SKILL.md"); let skillContent = readFileSync(skillPath, "utf-8"); skillContent = skillContent.replace(/description: "v[\d.]+: /g, `description: "v${nextVersion}: `); skillContent = skillContent.replace(/version: [\d.]+/g, `version: ${nextVersion}`); +skillContent = skillContent.replace(/short-description: (.*)\(v[\d.]+\)/g, `short-description: $1(v${nextVersion})`); skillContent = skillContent.replace(/# Seal Home \(v[\d.]+\)/g, `# Seal Home (v${nextVersion})`); skillContent = skillContent.replace(/\(v[\d.]+\)/g, `(v${nextVersion})`); writeFileSync(skillPath, skillContent); @@ -59,10 +60,19 @@ openapiContent = openapiContent.replace(/version: [\d.]+/g, `version: ${nextVers writeFileSync(openapiPath, openapiContent); console.log("✓ Updated openapi/openapi.yaml"); -// 5. Rebuild bundles -console.log("==> Rebuilding OpenAPI and plugin bundles..."); +// 5. Sync to global ~/.agents/skills/seal-home/ if present +const globalSkillDir = join(process.env.HOME || "", ".agents", "skills", "seal-home"); +const { existsSync, cpSync } = await import("node:fs"); +if (existsSync(globalSkillDir)) { + cpSync(join(ROOT, "skills", "seal-home"), globalSkillDir, { recursive: true }); + console.log("✓ Synchronized ~/.agents/skills/seal-home/"); +} + +// 6. Rebuild bundles +console.log("==> Rebuilding OpenAPI, plugin, and binary bundles..."); execSync("bun run openapi:bundle", { cwd: ROOT, stdio: "inherit" }); execSync("bun run build:plugin", { cwd: ROOT, stdio: "inherit" }); +execSync("bun run build:binary", { cwd: ROOT, stdio: "inherit" }); console.log("\n🎉 Successfully bumped version to " + nextVersion + "!"); console.log("\nNext steps to publish:"); diff --git a/skills/seal-home/SKILL.md b/skills/seal-home/SKILL.md index a86a313..c41624e 100644 --- a/skills/seal-home/SKILL.md +++ b/skills/seal-home/SKILL.md @@ -93,7 +93,6 @@ seal-home tool seal_approval_search --corp --json '{"keywords":["差旅 - `references/approval-run-lightweight.md`: 单号定位、字段裁剪、摘要、引用规则、单据摘要、附件摘要。 - `references/rule-lightweight.md`: 规则 count/list summary、按版本/编号取单条规则、规则搜索裁剪。 - `references/customer-feedback-rule-remediation.md`: 微信/截图反馈包到企业定位、审批追踪、根因分类、最小规则 diff、确认、发布与验收的固定闭环。 -- `references/hose-enterprise-init.md`: Hose 企业自动化初始化、多域名并发探测、OpenAPI 角色与人员发现、安全选人。 - `references/hose-enterprise-auth.md`: Hose 企业配置、认证诊断、授权链接。 - `references/approval-attachment-trace.md`: 附件/发票/OCR/图片争议的 Langfuse 追踪工作流。 - `references/cli.md`: 完整 CLI 命令清单。 diff --git a/skills/seal-home/references/cli.md b/skills/seal-home/references/cli.md index 907bbfa..739ec66 100644 --- a/skills/seal-home/references/cli.md +++ b/skills/seal-home/references/cli.md @@ -39,9 +39,7 @@ seal-home tools list seal-home corps list [--corp ] seal-home corps current [--corp ] seal-home corps switch -seal-home corps probe-hose --json '{"appKey":"...","appSecurity":"..."}' -seal-home corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}' -seal-home corps add-hose --json '{"appKey":"...","appSecurity":"...","staffId":"corpId:staffId"}' +seal-home corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}' seal-home corps add-seal --json '{"sealUrl":"https://tenant.sealai.cc","token":"seal-bearer-token"}' seal-home auth diagnose [--corp ] seal-home auth hose-link [--corp ] [--expire 7200] diff --git a/skills/seal-home/references/hose-enterprise-auth.md b/skills/seal-home/references/hose-enterprise-auth.md index 9ed7aab..95e8498 100644 --- a/skills/seal-home/references/hose-enterprise-auth.md +++ b/skills/seal-home/references/hose-enterprise-auth.md @@ -4,15 +4,10 @@ Use this reference for Hose/合思 enterprise configuration and user-facing Hose ## Add or switch an enterprise -Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit `~/.config/seal-home/enterprises/*.json` unless the CLI fails or the user explicitly asks for low-level config debugging. For full automated multi-domain probing and role/staff discovery, read `references/hose-enterprise-init.md`. +Use the CLI for normal enterprise setup. Do not inspect source code or hand-edit `~/.config/seal-home/enterprises/*.json` unless the CLI fails or the user explicitly asks for low-level config debugging. ```bash -# 1. Probing & discovery (auto-detects domain and roles) -seal-home corps probe-hose --json '{"appKey":"...","appSecurity":"..."}' -seal-home corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}' - -# 2. Add enterprise (supports domain auto-probing and staffName/staffPhone matching) -seal-home corps add-hose --json '{"appKey":"...","appSecurity":"...","staffId":"corpId:staffId"}' +seal-home corps add-hose --json '{"name":"企业名称","domain":"https://app.ekuaibao.com","appKey":"...","appSecurity":"...","proxyStaffBizId":"corpId:staffId"}' seal-home corps list seal-home corps current --corp seal-home corps switch diff --git a/src/core/embedded-skill.ts b/src/core/embedded-skill.ts index d67cbbe..9ac22b9 100644 --- a/src/core/embedded-skill.ts +++ b/src/core/embedded-skill.ts @@ -11,6 +11,7 @@ import refApprovalRunLightweight from "../../skills/seal-home/references/approva import refApprovalAttachmentTrace from "../../skills/seal-home/references/approval-attachment-trace.md" with { type: "text" }; import refCustomerFeedbackRuleRemediation from "../../skills/seal-home/references/customer-feedback-rule-remediation.md" with { type: "text" }; import refHoseEnterpriseAuth from "../../skills/seal-home/references/hose-enterprise-auth.md" with { type: "text" }; +import refHoseEnterpriseInit from "../../skills/seal-home/references/hose-enterprise-init.md" with { type: "text" }; export const EMBEDDED_SKILL_FILES: Record = { "SKILL.md": skillMain, @@ -21,7 +22,8 @@ export const EMBEDDED_SKILL_FILES: Record = { "references/approval-run-lightweight.md": refApprovalRunLightweight, "references/approval-attachment-trace.md": refApprovalAttachmentTrace, "references/customer-feedback-rule-remediation.md": refCustomerFeedbackRuleRemediation, - "references/hose-enterprise-auth.md": refHoseEnterpriseAuth + "references/hose-enterprise-auth.md": refHoseEnterpriseAuth, + "references/hose-enterprise-init.md": refHoseEnterpriseInit }; export function getSkillContent(): string {