Make Hose command boundaries explicit

This commit is contained in:
gitea committed 2026-09-22 12:00:45 +08:00
1 parent f3134a59b3
commit c71979cde2
8 files changed
+53 -35

No files matched your search

+16 -12
View File
@@ -913,10 +913,10 @@ export default lintRule;
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:W?I:Z?V:G,type:X,mode:Z?"auto_login":"direct",sealResultUrl:G,hoseDocumentUrl:I,documentUrl:I,ssoUrl:V,expiresIn:Z?q:void 0,identity:F,warning:w,hoseDomain:J.type==="hose"?pS1(J.domain):void 0,recordId:Q.id,sourceDocumentSN:Q.sourceDocumentSN,sourceDocumentId:Q.sourceDocumentId,sourceSystem:Q.sourceSystem,missing:{hoseDocumentUrl:!I?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:L.object({query:L.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:L.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:L.string().optional().describe("模拟批次 ID"),latest:L.boolean().optional().describe("只返回最新一条匹配记录"),fields:L.union([L.string(),L.array(L.string())]).optional().describe("限制返回字段"),limit:L.number().int().positive().max(100).optional(),maxScan:L.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:L.boolean().optional()}),handler:async($,Y,z)=>{let U=Y.sn??Y.query;if(!U)throw Error("query or sn is required");let Q=await dS1($,{query:U,sn:Y.sn,batchId:Y.batchId,latest:Y.latest,limit:Y.latest?1:Y.limit??20,maxScan:Y.maxScan??1000}),J=await Promise.all(Q.records.map((X)=>H4($,X.id))),I=A_0(Y.fields),K=J.map((X)=>iS1(X,I)),G=J.find((X)=>X.ruleSetVersionNumber!==void 0)?.ruleSetVersionNumber,H=G===void 0?"latest":String(G),W=G===void 0?'"latestRuleVersion":true':`"ruleVersionNumber":${G}`;return{query:U,sourceDocumentSN:Y.sn,simulationBatchId:Y.batchId,latest:Y.latest??!1,total:Q.total,scanned:Q.scanned,matched:K.length,records:K,next:{getSummary:`seal-use approval-runs get <recordId> --summary --corp ${z.corp.id}`,getRuleVersion:`seal-use rules version ${H} --corp ${z.corp.id}`,searchRuleVersion:`seal-use tool seal_approval_search --corp ${z.corp.id} --json '{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version",${W}}'`,getVersionContext:`seal-use tool seal_approval_context_get --corp ${z.corp.id} --json '{${W}}'`},...Y.includeBridge?{bridge:wj(J)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:L.object({batchId:L.string().describe("simulation batch ID"),query:L.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,Y)=>{let z=yl(await Wg($,Y.batchId),Y.query);return{batchId:Y.batchId,count:z.length,records:z.map(fU),bridge:wj(z)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:L.object({mode:L.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:L.array(L.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:L.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:L.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:L.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:L.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:L.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:L.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:L.array(L.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:L.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:L.record(L.string(),L.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:L.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:L.record(L.string(),L.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,Y)=>{let z=Y.mode??"hosecloud",U=Y.signKey;if(z==="hosecloud"&&!U){if(U=(await Zg($)).find((K)=>K.signKey)?.signKey,!U)throw Error(" Line truncated
`)}function Yg1($){let Y=[];if(Y.push(`seal-use ${$.area} - ${$.title}`),$.description)Y.push($.description);Y.push(""),Y.push("Usage:");let z=new Map;for(let Q of $.commands){let J=Q.group??"",I=z.get(J)??[];I.push(Q),z.set(J,I)}let U=[...$.groupOrder??[],...[...z.keys()].filter((Q)=>!$.groupOrder?.includes(Q))];for(let Q of U){let J=z.get(Q);if(!J)continue;if(Q)Y.push(""),Y.push(`${Q}:`);for(let I of J)for(let K of I.usage)Y.push(` ${K}`)}if($.commands.some((Q)=>Q.name))Y.push(""),Y.push(`Run 'seal-use ${$.area} <command> --help' for details on a specific command.`);return Y.join(`
`)}function i_0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let Y of n_0)for(let z of Y.commands)for(let U of z.usage)$.push(` ${U}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var n_0;var nl=m(()=>{F$();n_0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",groupOrder:["企业接入","发现与选择","企业配置","测试配对与验证","Hose 专属能力"],commands:[{name:"list",group:"发现与选择",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],group:"发现与选择",summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],group:"发现与选择",summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",group:"发现与选择",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",group:"发现与选择",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",group:"企业配置",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"rename",group:"企业配置",summary:"Rename an enterprise display name",usage:["seal-use corps rename <corpId> --name <newName>"],options:[{flag:"--name <newName>",description:"New human-readable enterprise name (required)"}],description:"Safely updates the display name of a configured enterprise without modifying underlying files manually."},{name:"bind-test",group:"测试配对与验证",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",group:"测试配对与验证",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",group:"测试配对与验证",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new versi Line truncated
`)}var n_0;var nl=m(()=>{F$();n_0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",groupOrder:["企业接入","发现与选择","企业配置","测试配对与验证","Hose 专属能力"],commands:[{name:"list",group:"发现与选择",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],group:"发现与选择",summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],group:"发现与选择",summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",group:"发现与选择",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",group:"发现与选择",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",group:"企业配置",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"rename",group:"企业配置",summary:"Rename an enterprise display name",usage:["seal-use corps rename <corpId> --name <newName>"],options:[{flag:"--name <newName>",description:"New human-readable enterprise name (required)"}],description:"Safely updates the display name of a configured enterprise without modifying underlying files manually."},{name:"bind-test",group:"测试配对与验证",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",group:"测试配对与验证",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",group:"测试配对与验证",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new versi Line truncated
`)}
`}function Tq($){return $.replace(/([?&](?:accessToken|token|returnToken)=)[^&\s]+/gi,"$1<redacted>").replace(/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi,"$1<redacted>")}function x0($,Y={}){Ig1($,Y);let z=`${JSON.stringify($,null,2)}
`;if(Y.outputFile){zg1(Y.outputFile,z),console.log(JSON.stringify({outputFile:Y.outputFile,bytes:Buffer.byteLength(z,"utf-8")},null,2));return}console.log(z.trimEnd())}function Ig1($,Y={}){if(Y.allowFull||Y.outputFile)return;let z=Buffer.byteLength(JSON.stringify($),"utf-8");if(z>Jg1)throw new eB(`Output is large (${z} bytes). Use --summary, --fields, --count, or --output-file; pass --full only when you really need the full response.`)}function m_0($,Y){if(Y)return;let z=$&&typeof $==="object"?$:{},U=typeof z.count==="number"?z.count:void 0,Q=Array.isArray(z.rules)?z.rules.length:void 0,J=Buffer.byteLength(JSON.stringify($),"utf-8"),I=U??Q??0;if(I>Ug1||J>Qg1)throw new eB(`Rule list is large (${I} rules, ${J} bytes). Use "seal-use rules list --summary", "seal-use rules count", or --output-file; pass --full only when you really need full descriptions.`,"seal-use rules list --summary")}function E0($){return{allowFull:Z0($.full)===!0,outputFile:h($.outputFile)??h($["output-file"])}}function l_0($=[]){console.log(p_0($))}var Ug1=100,Qg1=120000,d_0,Jg1=200000;var K4=m(()=>{A4();F$();nl();d_0=["code","status","strictness","scope","updatedAt"]});var pl={};D8(pl,{selectCorp:()=>T1,runToolResult:()=>O$,runTool:()=>k0,globalConfigSummary:()=>a2});function T1($){let Y=a8(),z=v4(),U=n2(Y,{stateful:z.stateful,defaultCorpId:z.defaultCorpId,corpId:$},g3());return kA0(U.id),U}function a2($=v4()){return{mode:$.stateful?"stateful":"stateless",stateful:$.stateful,...$.stateful&&$.defaultCorpId?{defaultCorpId:$.defaultCorpId}:{},...$.testEnterprisesDir?{testEnterprisesDir:$.testEnterprisesDir}:{},lint:$.lint,configFile:ZU()}}async function k0($,Y,z,U,Q={}){x0(await O$($,Y,z,U),Q)}async function O$($,Y,z,U){let Q=Dq.find((K)=>K.name===$);if(!Q)throw Error(`Unknown Seal tool: ${$}`);let J=Object.fromEntries(Object.entries(U).filter(([,K])=>K!==void 0)),I=Q.handler;return I(Y,J,{corp:z})}var f4=m(()=>{k3();rB();Bq();K4()});import{existsSync as o_0}from"node:fs";async function r_0($,Y){if(!o_0($))throw Error(`File not found: ${$}`);let z=xU($);console.log(JSON.stringify(await kU(z.fileBuffer,z.fileName,Y),null,2))}async function Cj($,Y,z,U,Q){if($==="ready"||$==="status"){let J=Y??h(Q.options.file)??h(Q.options.input),I=await qj(z,U,{filePath:J,webhook:h(Q.options.webhook)??h(Q.options.selector)});if(console.error(`[webhook-ready] 企业环境: ${I.corp.name} (${I.corp.id}) [${I.stateMode}]`),I.corp.tenant?.name)console.error(`[webhook-ready] 租户信息: ${I.corp.tenant.name} (${I.corp.tenant.id})`);console.error(`[webhook-ready] 凭证状态: ${I.authStatus==="ok"?"OK":`异常 (${I.authError})`}`),console.error(`[webhook-ready] Webhook 通道: ${I.activeWebhooks.length} 个可用`);for(let K of I.activeWebhooks){let G=K.isDefault?" [默认通道]":"";console.error(` - ${K.name} (${K.id}) mode=${K.mode}${G}`)}if(I.materialPack)console.error(`[webhook-ready] 材料包预检: ${I.materialPack.valid?`通过 (${I.materialPack.documentCount} 单)`:`失败 (${I.materialPack.errors?.join("; ")})`}`);if(I.ready)console.error(`\uD83D\uDFE2 ${I.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${I.nextAction}`);else console.error(`\uD83D\uDD34 准备阶段未通过: ${I.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${I.nextAction}`);console.log(JSON.stringify(I,null,2));return}if($==="replay"){let J=Y??h(Q.options.recordId)??h(Q.options["record-id"])??h(Q.options.id),I=h(Q.options.recordIds)??h(Q.options["record-ids"]),K=I?I.split(",").map((n)=>n.trim()).filter(Boolean):void 0,G=h(Q.options.sn)??h(Q.options.documentSn)??h(Q.options["document-sn"]),H=h(Q.options.sns)??h(Q.options["document-sns"]),W=H?H.split(",").map((n)=>n.trim()).filter(Boolean):void 0,X=s0(Q.options.limit),Z=h(Q.options.status),q=h(Q.options.startDate)??h(Q.options["start-date"]),V=h(Q.options.endDate)??h(Q.options["end-date"]);if(!J&&!K&&!G&&!W&&X===void 0)throw Error("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");let F=h(Q.options.sourceCorp)??h(Q.options["source-corp"])??h(Q.options.prodCorp)??h(Q.options["prod-corp"]),w=h(Q.options.targetCorp)??h(Q.options["target-corp"])??h(Q.options.testCorp)??h(Q.options["test-corp"]),O=Z0(Q.options.force)===!0,{sourceCorp:N,targetCorp:M}=$P({sourceCorpId:F,targetCorpId:w,activeCorp:U,force:O},T1),D=N.id===U.id?z:await P1(N),P=M.id===U.id?z:await P1(M),j=h(Q.options.webhook)??h(Q.options.selector),A=h(Q.options.snSuffix)??h(Q.options["sn-suffix"]),T=h(Q.options.snPrefix)??h(Q.options["sn-prefix"]),C=h(Q.options.docIdSuffix)??h(Q.options["doc-id-suffix"]),b=h(Q.options.docIdPrefix)??h(Q.options["doc-id-prefix"]),k=Z0(Q.options.dryRun)??Z0(Q.options["dry-run"]),i=await zK({query:{recordId:J,recordIds:K,sn:G,sns:W,limit:X,status:Z,startDate:q,endDate:V},sourceClient:D,targetClient:P,sourceCorp:N,targetCorp:M,webhookSelector:j,snPrefix:T,snSuffix:A,docIdPrefix:b,docIdSuffix:C,dr Line truncated
`;if(Y.outputFile){zg1(Y.outputFile,z),console.log(JSON.stringify({outputFile:Y.outputFile,bytes:Buffer.byteLength(z,"utf-8")},null,2));return}console.log(z.trimEnd())}function Ig1($,Y={}){if(Y.allowFull||Y.outputFile)return;let z=Buffer.byteLength(JSON.stringify($),"utf-8");if(z>Jg1)throw new eB(`Output is large (${z} bytes). Use --summary, --fields, --count, or --output-file; pass --full only when you really need the full response.`)}function m_0($,Y){if(Y)return;let z=$&&typeof $==="object"?$:{},U=typeof z.count==="number"?z.count:void 0,Q=Array.isArray(z.rules)?z.rules.length:void 0,J=Buffer.byteLength(JSON.stringify($),"utf-8"),I=U??Q??0;if(I>Ug1||J>Qg1)throw new eB(`Rule list is large (${I} rules, ${J} bytes). Use "seal-use rules list --summary", "seal-use rules count", or --output-file; pass --full only when you really need full descriptions.`,"seal-use rules list --summary")}function E0($){return{allowFull:Z0($.full)===!0,outputFile:h($.outputFile)??h($["output-file"])}}function l_0($=[]){console.log(p_0($))}var Ug1=100,Qg1=120000,d_0,Jg1=200000;var K4=m(()=>{A4();F$();nl();d_0=["code","status","strictness","scope","updatedAt"]});var pl={};D8(pl,{selectCorp:()=>T1,runToolResult:()=>O$,runTool:()=>k0,globalConfigSummary:()=>a2});function T1($){let Y=a8(),z=v4(),U=n2(Y,{stateful:z.stateful,defaultCorpId:z.defaultCorpId,corpId:$},g3());return kA0(U.id),U}function a2($=v4()){return{mode:$.stateful?"stateful":"stateless",stateful:$.stateful,...$.stateful&&$.defaultCorpId?{defaultCorpId:$.defaultCorpId}:{},...$.testEnterprisesDir?{testEnterprisesDir:$.testEnterprisesDir}:{},lint:$.lint,configFile:ZU()}}async function k0($,Y,z,U,Q={}){x0(await O$($,Y,z,U),Q)}async function O$($,Y,z,U){let Q=Dq.find((K)=>K.name===$);if(!Q)throw Error(`Unknown Seal tool: ${$}`);let J=Object.fromEntries(Object.entries(U).filter(([,K])=>K!==void 0)),I=Q.handler;return I(Y,J,{corp:z})}var f4=m(()=>{k3();rB();Bq();K4()});import{existsSync as o_0}from"node:fs";async function r_0($,Y){if(!o_0($))throw Error(`File not found: ${$}`);let z=xU($);console.log(JSON.stringify(await kU(z.fileBuffer,z.fileName,Y),null,2))}async function Cj($,Y,z,U,Q){if($==="ready"||$==="status"){let J=Y??h(Q.options.file)??h(Q.options.input),I=await qj(z,U,{filePath:J,webhook:h(Q.options.webhook)??h(Q.options.selector)});if(console.error(`[webhook-ready] 企业环境: ${I.corp.name} (${I.corp.id}) [${I.stateMode}]`),I.corp.tenant?.name)console.error(`[webhook-ready] 租户信息: ${I.corp.tenant.name} (${I.corp.tenant.id})`);console.error(`[webhook-ready] 凭证状态: ${I.authStatus==="ok"?"OK":`异常 (${I.authError})`}`),console.error(`[webhook-ready] Webhook 通道: ${I.activeWebhooks.length} 个可用`);for(let K of I.activeWebhooks){let G=K.isDefault?" [默认通道]":"";console.error(` - ${K.name} (${K.id}) mode=${K.mode}${G}`)}if(I.materialPack)console.error(`[webhook-ready] 材料包预检: ${I.materialPack.valid?`通过 (${I.materialPack.documentCount} 单)`:`失败 (${I.materialPack.errors?.join("; ")})`}`);if(I.ready)console.error(`\uD83D\uDFE2 ${I.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${I.nextAction}`);else console.error(`\uD83D\uDD34 准备阶段未通过: ${I.statusMessage}`),console.error(`\uD83D\uDC49 Next action: ${I.nextAction}`);console.log(JSON.stringify(I,null,2));return}if($==="replay"){let J=Y??h(Q.options.recordId)??h(Q.options["record-id"])??h(Q.options.id),I=h(Q.options.recordIds)??h(Q.options["record-ids"]),K=I?I.split(",").map((n)=>n.trim()).filter(Boolean):void 0,G=h(Q.options.sn)??h(Q.options.documentSn)??h(Q.options["document-sn"]),H=h(Q.options.sns)??h(Q.options["document-sns"]),W=H?H.split(",").map((n)=>n.trim()).filter(Boolean):void 0,X=s0(Q.options.limit),Z=h(Q.options.status),q=h(Q.options.startDate)??h(Q.options["start-date"]),V=h(Q.options.endDate)??h(Q.options["end-date"]);if(!J&&!K&&!G&&!W&&X===void 0)throw Error("Usage: seal-use webhook replay <recordId> [--sn <documentSN>] [--limit <n>] [--status <status>] [--webhook <idOrName>] [--source-corp <corpId>] [--target-corp <corpId>] [--dry-run]");let F=h(Q.options.sourceCorp)??h(Q.options["source-corp"])??h(Q.options.prodCorp)??h(Q.options["prod-corp"]),w=h(Q.options.targetCorp)??h(Q.options["target-corp"])??h(Q.options.testCorp)??h(Q.options["test-corp"]),O=Z0(Q.options.force)===!0,{sourceCorp:N,targetCorp:M}=$P({sourceCorpId:F,targetCorpId:w,activeCorp:U,force:O},T1),D=N.id===U.id?z:await P1(N),P=M.id===U.id?z:await P1(M),j=h(Q.options.webhook)??h(Q.options.selector),A=h(Q.options.snSuffix)??h(Q.options["sn-suffix"]),T=h(Q.options.snPrefix)??h(Q.options["sn-prefix"]),C=h(Q.options.docIdSuffix)??h(Q.options["doc-id-suffix"]),b=h(Q.options.docIdPrefix)??h(Q.options["doc-id-prefix"]),k=Z0(Q.options.dryRun)??Z0(Q.options["dry-run"]),i=await zK({query:{recordId:J,recordIds:K,sn:G,sns:W,limit:X,status:Z,startDate:q,endDate:V},sourceClient:D,targetClient:P,sourceCorp:N,targetCorp:M,webhookSelector:j,snPrefix:T,snSuffix:A,docIdPrefix:b,docIdSuffix:C,dr Line truncated
`+`\uD83D\uDC49 查看全部请添加: seal-use corps list --all
`+"\uD83D\uDC49 检索指定企业请使用: seal-use corps search <keyword>")}x0(O.map((N)=>({id:N.id,name:N.name,environment:N.environment??"production",sourceType:N.source.type,provider:N.source.provider??N.source.type,staffId:N.source.staffId,testCorpId:N.testCorpId,prodCorpId:N.prodCorpId,current:N.id===H})));return}if($==="get"||$==="show"){let U=Y??h(z.options.corp);if(!U)throw m4("Usage: seal-use corps get <corpId>");let Q=T1(U),J=Vp(Q.id),I=yg1(Q);x0({id:Q.id,name:Q.name,environment:Q.environment??"production",configFile:J,seal:{url:I,tenantSlug:Q.seal.tenantSlug??Q.source.tenantSlug,customHeaderNames:Q.seal.headers?Object.keys(Q.seal.headers):[],customCookieNames:Q.seal.cookies?Object.keys(Q.seal.cookies):[],endpoints:Q.seal.endpoints},source:kg1(Q.source),relations:{testCorpId:Q.testCorpId,prodCorpId:Q.prodCorpId},auth:{refreshTtl:Q.auth.refreshTtl}});return}if($==="current"){let U=T1(h(z.options.corp));x0({id:U.id,name:U.name,environment:U.environment??"production",sourceType:U.source.type,provider:U.source.provider??U.source.type,staffId:U.source.staffId,testCorpId:U.testCorpId,prodCorpId:U.prodCorpId});return}if($==="mark"||$==="mark-test"||$==="mark-prod"){let U=Y??h(z.options.corp);if(!U)throw m4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");let Q=T1(U),J=$==="mark-test"?"test":$==="mark-prod"?"production":h(z.options.env)??h(z.options.environment);if(J!=="production"&&J!=="test")throw m4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");if(!(Z0(z.options.confirm)===!0||Z0(z.options.yes)===!0))throw A5(`Refusing to change environment tag of enterprise '${Q.name}' (${Q.id}) to '${J}' without --confirm. Marking alters synchronization safety guards.`,`seal-use corps mark ${Q.id} --env ${J} --confirm`);let K=y3(Q.id,{environment:J});x0({id:K.id,name:K.name,environment:K.environment,testCorpId:K.testCorpId,prodCorpId:K.prodCorpId});return}if($==="rename"){let U=Y??h(z.options.corp)??h(z.options.id),Q=h(z.options.name)??h(z.options.to)??(z.command[3]&&!z.command[3].startsWith("-")?z.command[3]:void 0);if(!U||!Q)throw Error("Usage: seal-use corps rename <corpId> --name <newName>");let J=T1(U),I=y3(J.id,{name:Q});x0({success:!0,id:I.id,name:I.name,previousName:J.name});return}if($==="bind-test"){let U,Q;if(Y&&z.command[3])U=Y,Q=z.command[3];else if(Y){let X=h(z.options.corp),Z=h(z.options["test-corp"])??h(z.options.testCorp);if(X)U=X,Q=Y;else if(Z)U=Y,Q=Z}if(!U||!Q)throw m4(`Usage: seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]
or: seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]`);let J=T1(U),I=T1(Q);if(J.id===I.id)throw m4(`Cannot bind enterprise '${J.id}' to itself.`);if(J.prodCorpId&&J.prodCorpId!==I.id)throw m4(`Cannot use '${J.id}' as a production enterprise because it is already registered as a test enterprise for '${J.prodCorpId}'. Multi-tier chaining is not permitted.`);if(I.testCorpId&&I.testCorpId!==J.id)throw m4(`Cannot bind '${I.id}' as a test enterprise because it already has a bound test enterprise '${I.testCorpId}'. Multi-tier chaining is not permitted.`);let K=Z0(z.options.force)===!0;if(J.testCorpId&&J.testCorpId!==I.id||I.prodCorpId&&I.prodCorpId!==J.id){if(!K)throw A5(`Enterprise binding conflict: production enterprise '${J.id}' is bound to '${J.testCorpId??"none"}', and test enterprise '${I.id}' is bound to '${I.prodCorpId??"none"}'. Overwriting an existing binding requires --force and --confirm.`,`seal-use corps bind-test ${J.id} ${I.id} --confirm --force`)}if(!(Z0(z.options.confirm)===!0||Z0(z.options.yes)===!0)){let X=K?" --force":"";throw A5(`Refusing to bind test enterprise '${I.name}' (${I.id}) to production enterprise '${J.name}' (${J.id}) without --confirm. Enterprise binding establishes 1-to-1 sync pairing and marks '${I.id}' as a test environment.`,`seal-use corps bind-test ${J.id} ${I.id} --confirm${X}`)}if(J.testCorpId&&J.testCorpId!==I.id)try{y3(J.testCorpId,{prodCorpId:void 0})}catch{}if(I.prodCorpId&&I.prodCorpId!==J.id)try{y3(I.prodCorpId,{testCorpId:void 0})}catch{}let H=y3(J.id,{environment:"production",testCorpId:I.id}),W=y3(I.id,{environment:"test",prodCorpId:J.id});x0({success:!0,productionEnterprise:{id:H.id,name:H.name,environment:H.environment,testCorpId:H.testCorpId},testEnterprise:{id:W.id,name:W.name,environment:W.environment,prodCorpId:W.prodCorpId}});return}if($==="unbind-test"){let U=Y??h(z.options.corp),Q=T1(U);if(!Q.testCorpId&&!Q.prodCorpId){x0({unbound:!1,message:`Enterprise '${Q.name}' (${Q.id}) does not have an active test enterprise binding.`});return}let J=Q.testCorpId?Q.id:Q.prodCorpId,I=Q.testCorpId?Q.testCorpId:Q.id;if(!(Z0(z.options.confirm)===!0||Z0(z.options.yes)===!0))throw A5(`Refusing to unbind production enterprise '${J}' and test enterprise '${I}' without --confirm.`,`seal-use corps unbind-test ${Q.id} --confirm`);y3(J,{testCorpId:void 0});try{y3(I,{prodCorpId:void 0})}catch{}x0({success:!0,unboundProduction:J,unboundTest:I});return}if($==="sync-test"){let U=Y??h(z.options.corp),Q=T1(U);if(!Q.testCorpId)throw m4(`Production enterprise '${Q.name}' (${Q.id}) has no bound test enterprise.
@@ -942,7 +942,7 @@ or add '--force' (or use 'seal-use webhook replay <recordId> --force') if you ex
`+"OpenAPI 密钥查询与提权能力专属于合思生态租户(用于从合思协助链接或合思凭据中提取开发者密钥提升权限等级),非合思渠道企业不支持此能力。",2);let Q=z.source.appKey??z.source.key,J=z.source.appSecurity??z.source.password;if(!U)console.error(`\uD83D\uDCA1 [合思子域] 接入密码默认脱敏,附加 --reveal (或 -r) 可查看完整 appSecurity 明文。
`);else console.error(`⚠️ [合思子域] 正在以明文展示合思 appSecurity 接入密码,请妥善保管敏感凭据。
`);x0({provider:"hose",capability:"privilege-elevation",corpId:z.id,corpName:z.name,domain:z.source.domain,staffId:z.source.staffId,appKey:Q??"-",appSecurity:J?U?J:Ww(J):"-",active:!0})}function Ko($,Y){let{token:z,sealUrl:U,expiresIn:Q,verify:J,remote:I}=Y,K=Y.custom??kh0($),G=I?.user,H=I?.tenant,W=X4($,"tenantSlug")??e2(H?.tenantSlug),X=X4($,"tenantId")??e2(H?.id),Z=X4($,"tenantName")??e2(H?.name),q=X4($,"id")??W??X;if(!q)throw Error("Missing required JSON field: id. Seal whoami did not return tenantSlug or tenantId.");let V=X4($,"staffId")??e2(G?.providerUserId)??e2(G?.id)??"seal",F=X4($,"provider")??e2(G?.provider)??e2(H?.providerConfig?.provider),w=X4($,"corpId")??W??X??q,O={id:q,name:X4($,"name")??Z??q,environment:"production",seal:{url:U,tenantSlug:W,headers:K.headers,cookies:K.cookies,endpoints:{approvalStylePreferences:"api/v1/agent/ai-approval/config"}},source:{type:"seal",token:z,sealUrl:U,expiresIn:Q,staffId:V,corpId:w,tenantId:X,tenantSlug:W,tenantName:Z,providerUserId:e2(G?.providerUserId),provider:F},auth:{refreshTtl:300}},N=qp();_h0(N,{recursive:!0,mode:448});let M=hh0(N,`${Pj(q)}.json`);if(Rh0(M)&&$.overwrite!==!0)throw Error(`Enterprise config already exists: ${M}. Pass "overwrite": true to replace it.`);vh0(M,`${JSON.stringify(O,null,2)}
`,{mode:384}),x0({id:q,name:O.name,tenantId:X,tenantSlug:W,verified:J,path:M})}async function cg1($,Y,z={}){let U=y6($,Y,z),Q=await T8(U);return{user:Q.user??{},tenant:Q.tenant??{}}}function e2($){return typeof $==="string"&&$?$:void 0}var Wo=m(()=>{g7();Qv0();CH();i8();k3();Nh0();rB();Xp();B6();B6();Jo();Np();fZ();fj();f4();F$();A4();K4()});var bh0={};D8(bh0,{handleAuthExtractKeysCommand:()=>qo,handleAuthCommand:()=>ij,formatBeijingIso:()=>Zo});async function qo($,Y){let z=$??h(Y.options.link)??h(Y.options.url);if(!z)throw Error("Usage: seal-use auth extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]");let U=Z0(Y.options.reveal)===!0||Z0(Y.options.r)===!0||Z0(Y.options.plain)===!0,Q=Z0(Y.options.save)===!0||Z0(Y.options.add)===!0;await uj(z,{reveal:U,save:Q,name:h(Y.options.name),overwrite:Z0(Y.options.overwrite)===!0,force:Z0(Y.options.force)===!0,appKey:h(Y.options["app-key"])??h(Y.options.appKey),keyId:h(Y.options["key-id"])??h(Y.options.keyId)})}async function ij($,Y,z){if($==="check"||$==="diagnose"||$==="status"||$==="test"||$==="doctor"){x0(await pg1(Y));return}if($==="seal-link"||$==="link"||$==="hose-link"&&Y?.source?.type==="seal"){let U=z.command[2]?.toLowerCase(),Q=h(z.options["from-link"])??(U==="from-link"?z.command[3]:void 0);if(Q){let X=h(z.options.note),Z=await Jw(Q),q=y6(Z.sealUrl,Z.token),V=await T8(q);Iw(Z.corpId,V.tenant);let F=await aQ(q,{note:X});x0({tenant:{id:V.tenant.id,name:V.tenant.name,tenantSlug:V.tenant.tenantSlug,corpId:Z.corpId},user:{id:V.user.id,name:V.user.name,providerUserId:V.user.providerUserId,isAdmin:V.user.isAdmin},delegation:F,expiresIn:Z.expiresIn});return}let J=await P1(Y);if(U==="list"){await k0("seal_delegation_list",J,Y,{},E0(z.options));return}if(U==="revoke"){let X=z.command[3]??h(z.options.tokenId)??h(z.options.id);if(!X)throw Error("Usage: seal-use auth link revoke <tokenId>");await k0("seal_delegation_revoke",J,Y,{tokenId:X},E0(z.options));return}let I=h(z.options.note)??"CLI generated provisional access link",K=await O$("seal_delegation_create",J,Y,{note:I});if($==="hose-link")console.error(`\uD83D\uDC49 提示: 企业「${Y.name}」源类型为 Seal 原生测试环境,已自动为您生成委托免登直达链接。`);let G=K,H="staffName"in Y.source&&typeof Y.source.staffName==="string"?Y.source.staffName:void 0,W=Zo(Date.now()+86400000);x0({id:G.id,corpId:Y.source.corpId??Y.id,corpName:Y.name,staffId:Y.source.staffId,...H?{staffName:H}:{},link:G.link,expiresAt:W,token:G.token});return}if($==="hose-link"){let U=z.options.expire,Q=U!==void 0?s0(U):7200;if(Q===void 0||Q<=0)throw Error(`Invalid --expire: ${String(U)}. Must be a positive number of seconds (e.g. --expire 7200 or --expire 86400).`);let J=Z0(z.options.force)===!0||Z0(z.options.refresh)===!0||Z0(z.options.f)===!0,I=await m00(Y,Q,{force:J}),K="staffName"in Y.source&&typeof Y.source.staffName==="string"?Y.source.staffName:void 0,G=Zo(Date.now()+Q*1000);x0({corpId:Y.source.corpId??Y.id,corpName:Y.name,staffId:Y.source.staffId,...K?{staffName:K}:{},link:I.url,expiresAt:G,token:I.token});return}if($==="keys"||$==="hose-keys"){let U=Z0(z.options.reveal)===!0||Z0(z.options.r)===!0||Z0(z.options.plain)===!0;await Ho(Y.id,{reveal:U});return}throw Error(`Unknown auth command: ${$??""}. Run 'seal-use help' for available commands.`)}async function pg1($){if($.source.type!=="hose"){let F=await P1($),w=await T8(F);return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!0,stages:[{name:"seal.whoami",ok:!0,user:w.user,tenant:w.tenant}]}}Qw($.id);let Y=$.source,z=Y.appKey??Y.key,U=Y.appSecurity??Y.password,Q=($.seal.url??Y.sealUrl??`https://${Y.corpId.toLowerCase()}.sealai.cc`).replace(/\/+$/,""),J=Y.staffId.includes(":")?Y.staffId:`${Y.corpId}:${Y.staffId}`,I=[];if(!z||!U)return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!1,stages:[{name:"hose.openapi",ok:!1,error:"Hose source requires appKey/key and appSecurity/password"}]};let K=await bj("hose.openapi",async()=>{let F=await fh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1/auth/getAccessToken`,{appKey:z,appSecurity:U}),w=o3(F.value),O=n6(w.accessToken)??n6(F.accessToken)??n6(F.token);if(!O)throw Error("Hose login did not return an access token");return{token:O,public:{corporationId:n6(w.corporationId)??n6(o3(w.corporation).id),expireTime:vq(w.expireTime)}}});I.push(K.public);let G=K.private?.token,H=G?await bj("hose.provisional",async()=>{let F=await fh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=${encodeURIComponent(G)}`,{uid:J,pageType:"home",expireDate:7200}),w=n6(o3(F.value).message);if(!w)throw Error("Hose CloseAPI did not return a provisional auth URL");let O=new URL(w).searchParams.get("accessToken");if(!O)throw Error("Hose provisional auth URL did not include accessToken");return{token:O,public:{uid:J,enterpriseUrl:Tq(w)}}}):Xo("hose.provisional");I.push(H.public);let W=A6($.seal),X=H.private?.token,Z=X?await bj("seal.sso" Line truncated
`,{mode:384}),x0({id:q,name:O.name,tenantId:X,tenantSlug:W,verified:J,path:M})}async function cg1($,Y,z={}){let U=y6($,Y,z),Q=await T8(U);return{user:Q.user??{},tenant:Q.tenant??{}}}function e2($){return typeof $==="string"&&$?$:void 0}var Wo=m(()=>{g7();Qv0();CH();i8();k3();Nh0();rB();Xp();B6();B6();Jo();Np();fZ();fj();f4();F$();A4();K4()});var bh0={};D8(bh0,{handleAuthExtractKeysCommand:()=>qo,handleAuthCommand:()=>ij,formatBeijingIso:()=>Zo});async function qo($,Y){let z=$??h(Y.options.link)??h(Y.options.url);if(!z)throw Error("Usage: seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]");let U=Z0(Y.options.reveal)===!0||Z0(Y.options.r)===!0||Z0(Y.options.plain)===!0,Q=Z0(Y.options.save)===!0||Z0(Y.options.add)===!0;await uj(z,{reveal:U,save:Q,name:h(Y.options.name),overwrite:Z0(Y.options.overwrite)===!0,force:Z0(Y.options.force)===!0,appKey:h(Y.options["app-key"])??h(Y.options.appKey),keyId:h(Y.options["key-id"])??h(Y.options.keyId)})}async function ij($,Y,z){if($==="check"||$==="diagnose"||$==="status"||$==="test"||$==="doctor"){x0(await pg1(Y));return}if($==="seal-link"||$==="link"||$==="hose-link"&&Y?.source?.type==="seal"){let U=z.command[2]?.toLowerCase(),Q=h(z.options["from-link"])??(U==="from-link"?z.command[3]:void 0);if(Q){let X=h(z.options.note),Z=await Jw(Q),q=y6(Z.sealUrl,Z.token),V=await T8(q);Iw(Z.corpId,V.tenant);let F=await aQ(q,{note:X});x0({tenant:{id:V.tenant.id,name:V.tenant.name,tenantSlug:V.tenant.tenantSlug,corpId:Z.corpId},user:{id:V.user.id,name:V.user.name,providerUserId:V.user.providerUserId,isAdmin:V.user.isAdmin},delegation:F,expiresIn:Z.expiresIn});return}let J=await P1(Y);if(U==="list"){await k0("seal_delegation_list",J,Y,{},E0(z.options));return}if(U==="revoke"){let X=z.command[3]??h(z.options.tokenId)??h(z.options.id);if(!X)throw Error("Usage: seal-use auth link revoke <tokenId>");await k0("seal_delegation_revoke",J,Y,{tokenId:X},E0(z.options));return}let I=h(z.options.note)??"CLI generated provisional access link",K=await O$("seal_delegation_create",J,Y,{note:I});if($==="hose-link")console.error(`\uD83D\uDC49 提示: 企业「${Y.name}」源类型为 Seal 原生测试环境,已自动为您生成委托免登直达链接。`);let G=K,H="staffName"in Y.source&&typeof Y.source.staffName==="string"?Y.source.staffName:void 0,W=Zo(Date.now()+86400000);x0({id:G.id,corpId:Y.source.corpId??Y.id,corpName:Y.name,staffId:Y.source.staffId,...H?{staffName:H}:{},link:G.link,expiresAt:W,token:G.token});return}if($==="hose-link"){let U=z.options.expire,Q=U!==void 0?s0(U):7200;if(Q===void 0||Q<=0)throw Error(`Invalid --expire: ${String(U)}. Must be a positive number of seconds (e.g. --expire 7200 or --expire 86400).`);let J=Z0(z.options.force)===!0||Z0(z.options.refresh)===!0||Z0(z.options.f)===!0,I=await m00(Y,Q,{force:J}),K="staffName"in Y.source&&typeof Y.source.staffName==="string"?Y.source.staffName:void 0,G=Zo(Date.now()+Q*1000);x0({corpId:Y.source.corpId??Y.id,corpName:Y.name,staffId:Y.source.staffId,...K?{staffName:K}:{},link:I.url,expiresAt:G,token:I.token});return}if($==="keys"||$==="hose-keys"){let U=Z0(z.options.reveal)===!0||Z0(z.options.r)===!0||Z0(z.options.plain)===!0;await Ho(Y.id,{reveal:U});return}throw Error(`Unknown auth command: ${$??""}. Run 'seal-use help' for available commands.`)}async function pg1($){if($.source.type!=="hose"){let F=await P1($),w=await T8(F);return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!0,stages:[{name:"seal.whoami",ok:!0,user:w.user,tenant:w.tenant}]}}Qw($.id);let Y=$.source,z=Y.appKey??Y.key,U=Y.appSecurity??Y.password,Q=($.seal.url??Y.sealUrl??`https://${Y.corpId.toLowerCase()}.sealai.cc`).replace(/\/+$/,""),J=Y.staffId.includes(":")?Y.staffId:`${Y.corpId}:${Y.staffId}`,I=[];if(!z||!U)return{corp:{id:$.id,name:$.name,sourceType:$.source.type},ok:!1,stages:[{name:"hose.openapi",ok:!1,error:"Hose source requires appKey/key and appSecurity/password"}]};let K=await bj("hose.openapi",async()=>{let F=await fh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1/auth/getAccessToken`,{appKey:z,appSecurity:U}),w=o3(F.value),O=n6(w.accessToken)??n6(F.accessToken)??n6(F.token);if(!O)throw Error("Hose login did not return an access token");return{token:O,public:{corporationId:n6(w.corporationId)??n6(o3(w.corporation).id),expireTime:vq(w.expireTime)}}});I.push(K.public);let G=K.private?.token,H=G?await bj("hose.provisional",async()=>{let F=await fh0(`${Y.domain.replace(/\/+$/,"")}/api/openapi/v1.1/provisional/getProvisionalAuth?accessToken=${encodeURIComponent(G)}`,{uid:J,pageType:"home",expireDate:7200}),w=n6(o3(F.value).message);if(!w)throw Error("Hose CloseAPI did not return a provisional auth URL");let O=new URL(w).searchParams.get("accessToken");if(!O)throw Error("Hose provisional auth URL did not include accessToken");return{token:O,public:{uid:J,enterpriseUrl:Tq(w)}}}):Xo("hose.provisional");I.push(H.public);let W=A6($.seal),X=H.private?.token,Z=X?await bj("seal Line truncated
`+`支持的审批系统与发布目标:
`+` • hosecloud (合思费控): seal-use deploy hosecloud <requirements|list|get|status|configure|sync> --corp <corpId>
@@ -1037,12 +1037,16 @@ metadata:
命令保持扁平兼容以避免破坏现有脚本;\`seal-use corps --help\` 会按上述业务组展示,不代表这些命令属于同一风险等级。涉及本地配置或测试数据写入的操作仍须遵守确认与预览规则。
Hose 专属命令必须从命令名上显式可见:认证入口使用 \`auth hose-*\`,合思原生审批流使用 \`approval-runs hose-flow\`,部署入口使用 \`deploy hosecloud ...\`,模拟入口使用 \`simulation --mode hosecloud\`。跨 Seal/Hose 的混合命令保留通用名称,但必须通过 \`--as-hose\`、\`--with-flow\` 或 \`--type hose-document\` 明确选择 Hose 能力。
### 2.1 企业定位与直达访问
- 关键字智能搜索(支持同音字/拼音/简拼/容错):\`seal-use corps search <keyword>\`
- 常用企业列表(默认展示 7 天使用频次最高的 10 家):\`seal-use corps list\`
- 查看企业详情(富属性安全脱敏查看):\`seal-use corps get <corpId>\`
- 生成 Seal AI 审核后台免密直达链接(输出签发人与北京时间截止期,时效 24h):\`seal-use auth link [--corp <corpId>]\`
- 生成合思主系统工作台免密链接(输出签发人与北京时间截止期,默认时效 2h):\`seal-use auth hose-link [--corp <corpId>]\`
- 合思密钥提取与查看:\`seal-use auth hose-extract-keys <url> [--save]\`、\`seal-use auth hose-keys [--corp <corpId>]\`
- 合思原生审批流:\`seal-use approval-runs hose-flow <recordId|SN> [--corp <corpId>]\`
### 2.2 规则查验(遵循术语契约,使用规则编号 #xxxx)
- 规则总数快速感知:\`seal-use rules count --corp <corpId>\`
@@ -1371,7 +1375,7 @@ Important nuance:
- This is a bad-case pattern, not a general rule that every amount-total dispute is caused by \`pre_analysis\`.
- Use it when the current trace shows recognized amounts being excluded downstream or duplicate attachments producing inconsistent conclusions.
`;var JS0=()=>{};var GS0="# Approval Run Lightweight Queries\n\nUse this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.\n\n## Locate A Run By Document Number\n\nPrefer `pick` before broad search + bridge + get.\n\n```bash\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --batch <batchId> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest --fields recordId,sourceDocumentSN,status,aiDecision,aiSummary\n```\n\nDefault output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.\n\nIf there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.\n\n## Read Compact Run Detail\n\nUse `--summary` for most diagnosis and support questions.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --fields metadata\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.fields,result.summary\nseal-use approval-runs get <recordId> --corp <corpId> --fields result.summary,result.decision,result.riskPoints\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runs get <recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.\n\n## Understand The Case First\n\nBefore pulling the full document, use:\n\n```bash\nseal-use approval-runs document-summary <recordId> --corp <corpId>\n```\n\nThis is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.\n\n## Extract AI-Cited Rules\n\nUse this when the user asks \"AI 用了哪条规则\", \"为什么命中这条\", or needs the rule evidence for a specific run.\n\n```bash\nseal-use approval-runs cited-rules <recordId> --corp <corpId>\n```\n\nReturn and discuss `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule, use `rules get --record-id <recordId> --runtime-id rule-205` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\n# 查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-use approval-runs attachments <recordId> --corp <corpId> --summary\n\n# 下载全部附件到本地目录(优先使用 ossSignedUrl 签名直链)\nseal-use approval-runs attachments download <recordId> --all --out-dir ./downloads --corp <corpId>\n\n# 按名称或 fileId 过滤下载单个附件\nseal-use approval-runs attachments download <recordId> --name 发票 --corp <corpId>\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-use approval-runs result <recordId> --corp <corpId> --summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Approval Run Web Links & Auto-Login Links\n\nUse this when the user asks for a link to an approval run or wants to open the run directly in their browser:\n\n```bash\n# 默认推荐:生成 Seal AI 审核详情直达链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-use approval-runs link <recordId> --corp <corpId>\nseal-use approval-runs link --sn <sourceDocumentSN> --corp <corpId>\n\n# 生成合思主系统原始单据页面链接\nseal-use approval-runs link <recordId> --type hose-document --corp <corpId>\n\n# 仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带合思单次临时票据的免登直达链接\nseal-use approval-runs link <recordId> --auto-login [--expire 7200] --corp <corpId>\n```\n\n### 返回字段说明与语义规范\n- `sealResultUrl`: Seal AI 单据智能审核结果页\n- `hoseDocumentUrl`: 合思费控主系统原始报销/借款单详情页\n- `type`: 链接类型,默认为 `seal_result`,指定时可为 `hose_document`\n- `mode`: 鉴权模式,`direct`(原生直接打开)或 `auto_login`(免密换票)\n\n### 免登链接安全与声明规范\n当向用户返回 `--auto-login` 链接时 Line truncated
`;var JS0=()=>{};var GS0="# Approval Run Lightweight Queries\n\nUse this reference when the user gives a 合思/易快报单号, source document SN, record ID, simulation batch ID, or asks for an approval decision without needing the full raw run payload.\n\n## Locate A Run By Document Number\n\nPrefer `pick` before broad search + bridge + get.\n\n```bash\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --batch <batchId> --latest\nseal-use approval-runs pick --corp <corpId> --sn <sourceDocumentSN> --latest --fields recordId,sourceDocumentSN,status,aiDecision,aiSummary\n```\n\nDefault output is intentionally small: `recordId`, `sourceDocumentSN`, `sourceDocumentId`, `simulationBatchId`, `status`, `taskMode`, `ruleSetVersionNumber`, `langfuseTraceId`, `manualResult`, `aiDecision`, and `aiSummary`.\n\nIf there are multiple candidates and `--latest` was not used, report the candidates and ask which one to inspect.\n\n## Read Compact Run Detail\n\nUse `--summary` for most diagnosis and support questions.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --summary\n```\n\nUse `--fields` when the user needs a particular slice.\n\n```bash\nseal-use approval-runs get <recordId> --corp <corpId> --fields metadata\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.fields,result.summary\nseal-use approval-runs get <recordId> --corp <corpId> --fields result.summary,result.decision,result.riskPoints\nseal-use approval-runs get <recordId> --corp <corpId> --fields document.keyFields,result,manualApprovalRecord,ruleSetVersionNumber\n```\n\nAvoid full `approval-runs get <recordId>` unless the user specifically needs raw document fields, pipeline logs, invoice rawData, or signed URLs. Prefer `--output-file` for full payloads.\n\n## Understand The Case First\n\nBefore pulling the full document, use:\n\n```bash\nseal-use approval-runs document-summary <recordId> --corp <corpId>\n```\n\nThis is for quick case reading: template/title, key fields, amount, expense type, cost company, payee, invoice summary, attachment names, AI result, and manual result.\n\n## Extract AI-Cited Rules\n\nUse this when the user asks \"AI 用了哪条规则\", \"为什么命中这条\", or needs the rule evidence for a specific run.\n\n```bash\nseal-use approval-runs cited-rules <recordId> --corp <corpId>\n```\n\nReturn and discuss `runtimeRuleId`, `ruleCode`, `versionNumber`, `scope`, `strictness`, `appliedAnalysis`, `checkResult`, and `findings` when present.\n\nIf the user then wants the full text of one cited rule, use `rules get --record-id <recordId> --runtime-id rule-205` from `rule-lightweight.md`.\n\n## Attachments Without Raw Payloads\n\nUse:\n\n```bash\n# 查看附件列表摘要(包含文件名、类型、大小及直链可用性)\nseal-use approval-runs attachments <recordId> --corp <corpId> --summary\n\n# 下载全部附件到本地目录(优先使用 ossSignedUrl 签名直链)\nseal-use approval-runs attachments download <recordId> --all --out-dir ./downloads --corp <corpId>\n\n# 按名称或 fileId 过滤下载单个附件\nseal-use approval-runs attachments download <recordId> --name 发票 --corp <corpId>\n```\n\nThis should be enough for file names, file IDs, mime types, positions, invoice/attachment grouping, and links when available. For customer disputes about OCR, receipt/invoice classification, or image content, switch to `approval-attachment-trace.md`.\n\n## Result Summary\n\nUse:\n\n```bash\nseal-use approval-runs result <recordId> --corp <corpId> --summary\n```\n\nThis is for decision, summary, risk point count, matched rule count, trace ID, and record ID.\n\n## Approval Run Web Links & Auto-Login Links\n\nUse this when the user asks for a link to an approval run or wants to open the run directly in their browser:\n\n```bash\n# 默认推荐:生成 Seal AI 审核详情直达链接(无凭证、无越权风险,用户在已有登录状态的浏览器中直接打开)\nseal-use approval-runs link <recordId> --corp <corpId>\nseal-use approval-runs link --sn <sourceDocumentSN> --corp <corpId>\n\n# 生成合思主系统原始单据页面链接\nseal-use approval-runs link <recordId> --type hose-document --corp <corpId>\n\n# 仅当用户明确要求免密/跨浏览器/无登录直达且确认知晓安全风险时:生成携带合思单次临时票据的免登直达链接\nseal-use approval-runs link <recordId> --auto-login [--expire 7200] --corp <corpId>\n```\n\n### 返回字段说明与语义规范\n- `sealResultUrl`: Seal AI 单据智能审核结果页\n- `hoseDocumentUrl`: 合思费控主系统原始报销/借款单详情页\n- `type`: 链接类型,默认为 `seal_result`,指定时可为 `hose_document`\n- `mode`: 鉴权模式,`direct`(原生直接打开)或 `auto_login`(免密换票)\n\n### 免登链接安全与声明规范\n当向用户返回 `--auto-login` 链接时 Line truncated
Use this low-freedom workflow when the user provides packaged customer feedback from WeChat, screenshots, rejection notifications, a document number, or expected business behavior and wants diagnosis or an approval-rule change.
@@ -1725,7 +1729,7 @@ First distinguish the link by its host, purpose, and identity origin:
- **Seal-Native Delegation Link (默认第一公民)**: \`https://<tenant>.sealai.cc/delegate?token=...\` grants delegated access directly on a Seal tenant. Running \`seal-use corps add-link <url>\` automatically exchanges the delegation token via \`/api/v1/delegation/consume\`, receives the session, retrieves tenant and user info via \`/api/v1/auth/me\`, and registers a native Seal enterprise (\`provider: "seal"\`). Supports \`--dry-run\` to preview metadata without mutating local config.
- **Hose/合思 Assistance Link**: \`https://<domain>/web/thirdparty.html?...\` opens an upstream Hose session and continues through Seal SSO. Running standard \`seal-use corps add-link <url>\` exchanges that temporary token for a short-lived Seal Bearer token.
- **Hose Subdomain Boundary (合思子域专属提权)**: \`seal-use\` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session \`accessToken\`. To elevate to permanent Hose OpenAPI developer credentials, use \`corps extract-keys <url> --save\` or \`corps add-link <url> --as-hose\`. (Note: \`--as-hose\` cannot be used on Seal-native delegation links).
- **Hose Subdomain Boundary (合思子域专属提权)**: \`seal-use\` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session \`accessToken\`. To elevate to permanent Hose OpenAPI developer credentials, use \`corps hose-extract-keys <url> --save\` or \`corps add-link <url> --as-hose\`. (Note: \`--as-hose\` cannot be used on Seal-native delegation links).
- **Multi-Key Disambiguation (多套密钥明确抉择)**: If the Hose enterprise owns multiple application keys, the CLI will not guess or silently pick the first key. Instead, it terminates with an informative candidate list and requires the user to specify \`--app-key <key>\` or \`--key-id <id>\`. If only one key exists, it is selected automatically.
- **Non-Hose Tenants Blocked**: Calling \`keys\` on native Seal enterprises (\`corp.source.type !== "hose"\`) is strictly rejected with exit code 2, explaining that this capability belongs exclusively to the Hose ecosystem.
@@ -1738,20 +1742,20 @@ seal-use corps add-link "https://<tenant>.sealai.cc/delegate?token=..." [--name
# 2. 接入合思协助链接并提权为标准持久化合思企业配置:
seal-use corps add-link "<url>" --as-hose [--name "企业名称"]
# 或通过 extract-keys 提取保存:
seal-use corps extract-keys "<url>" --save [--name "企业名称"]
seal-use corps hose-extract-keys "<url>" --save [--name "企业名称"]
# 3. 提取密钥并脱敏查看(合思子域能力):
seal-use corps extract-keys "https://wx2.ekuaibao.com/web/thirdparty.html?accessToken=...&ekbCorpId=..."
seal-use corps hose-extract-keys "https://wx2.ekuaibao.com/web/thirdparty.html?accessToken=...&ekbCorpId=..."
# 4. 显式完整查看密钥明文(--reveal / -r):
seal-use corps extract-keys "<url>" --reveal
seal-use corps hose-extract-keys "<url>" --reveal
# 5. 多套密钥存在时,显式指定具体应用密钥:
seal-use corps extract-keys "<url>" --save --app-key "ekb_app_..."
seal-use corps hose-extract-keys "<url>" --save --app-key "ekb_app_..."
# 6. 查看已配置合思企业当前使用的应用密钥:
seal-use corps keys <corpId> [--reveal]
seal-use auth keys --corp <corpId> [--reveal]
seal-use corps hose-keys <corpId> [--reveal]
seal-use auth hose-keys --corp <corpId> [--reveal]
\`\`\`
When using standard \`add-link\` with a Seal delegate link, it consumes the token directly against the Seal tenant and persists the verified Seal session. When using standard \`add-link\` with a Hose link (without \`--as-hose\`), it exchanges the temporary Hose token at the target Seal tenant and stores the short-lived Seal session. When \`--as-hose\` is used on a Hose link, the CLI executes Hose subdomain privilege elevation to register a durable standard Hose configuration.
@@ -1780,7 +1784,7 @@ This is functionally equivalent to a Hose assistance link. Both carry the same u
1. Treat the entire cURL as a secret. Do not echo it, execute it blindly, paste it into another service, or store it in repository files.
2. Extract: the request hostname (determines \`baseUrl\`), \`accesstoken\` header (session token), \`corpid\` header or cookie, and any other Hose session headers.
3. **Privilege elevation path (preferred)**: Use extracted \`accesstoken\`, \`corpid\`, and \`baseUrl\` to call \`/api/innerapi/v1/key\`, exactly as \`corps extract-keys\` does for assistance links. This retrieves permanent \`appKey\`/\`appSecurity\` to register a durable Hose enterprise configuration — do not skip this step just because the input is a cURL instead of a URL.
3. **Privilege elevation path (preferred)**: Use extracted \`accesstoken\`, \`corpid\`, and \`baseUrl\` to call \`/api/innerapi/v1/key\`, exactly as \`corps hose-extract-keys\` does for assistance links. This retrieves permanent \`appKey\`/\`appSecurity\` to register a durable Hose enterprise configuration — do not skip this step just because the input is a cURL instead of a URL.
4. **Fallback short-term path**: If the session user is not an administrator and the key interface returns no keys, fall back to the Seal SSO bridge to register a temporary Seal session.
5. If key extraction succeeds, inform the user that credentials have been permanently elevated; if it fails, explain the limitation and suggest the administrator copy a dedicated cURL or provide an assistance link or \`appKey\`/\`appSecurity\`.
+4
View File
@@ -78,12 +78,16 @@ metadata:
命令保持扁平兼容以避免破坏现有脚本;`seal-use corps --help` 会按上述业务组展示,不代表这些命令属于同一风险等级。涉及本地配置或测试数据写入的操作仍须遵守确认与预览规则。
Hose 专属命令必须从命令名上显式可见:认证入口使用 `auth hose-*`,合思原生审批流使用 `approval-runs hose-flow`,部署入口使用 `deploy hosecloud ...`,模拟入口使用 `simulation --mode hosecloud`。跨 Seal/Hose 的混合命令保留通用名称,但必须通过 `--as-hose`、`--with-flow` 或 `--type hose-document` 明确选择 Hose 能力。
### 2.1 企业定位与直达访问
- 关键字智能搜索(支持同音字/拼音/简拼/容错):`seal-use corps search <keyword>`
- 常用企业列表(默认展示 7 天使用频次最高的 10 家):`seal-use corps list`
- 查看企业详情(富属性安全脱敏查看):`seal-use corps get <corpId>`
- 生成 Seal AI 审核后台免密直达链接(输出签发人与北京时间截止期,时效 24h):`seal-use auth link [--corp <corpId>]`
- 生成合思主系统工作台免密链接(输出签发人与北京时间截止期,默认时效 2h):`seal-use auth hose-link [--corp <corpId>]`
- 合思密钥提取与查看:`seal-use auth hose-extract-keys <url> [--save]`、`seal-use auth hose-keys [--corp <corpId>]`
- 合思原生审批流:`seal-use approval-runs hose-flow <recordId|SN> [--corp <corpId>]`
### 2.2 规则查验(遵循术语契约,使用规则编号 #xxxx)
- 规则总数快速感知:`seal-use rules count --corp <corpId>`
+4 -3
View File
@@ -94,8 +94,8 @@ seal-use corps probe-hose --json '{"appKey":"...","appSecurity":"...","domain":"
seal-use corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}'
seal-use corps hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--app-key <key>] [--key-id <id>] [--overwrite]
seal-use corps hose-keys [<url> | <corpId>] [--reveal] [--save] [--app-key <key>] [--key-id <id>]
seal-use auth extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--app-key <key>] [--key-id <id>] [--overwrite]
seal-use auth keys [--corp <corpId>] [--reveal]
seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--app-key <key>] [--key-id <id>] [--overwrite]
seal-use auth hose-keys [--corp <corpId>] [--reveal]
seal-use auth check [--corp <corpId>]
seal-use auth link [--corp <corpId>] [--note <note>]
seal-use auth link --from-link <url> [--note <note>]
@@ -227,7 +227,7 @@ Use the command groups in this order for normal work: **enterprise onboarding**
- `seal-use corps hose-staffs --json '{"appKey":"...","appSecurity":"...","role":"admin"}'` discovers role-based staff candidates; cellphones are masked by default.
- `seal-use corps hose-extract-keys <url> [--reveal] [--save] [--name <name>] [--app-key <key>] [--key-id <id>] [--overwrite]` extracts OpenAPI keys (`appKey` and `appSecurity`) from a Hose assistance link (`thirdparty.html`). The old `extract-keys`/`extract-key`/`extract-hose-keys` forms remain aliases. **Hose Subdomain Privilege Elevation**: elevates a short-lived session token to permanent Hose OpenAPI developer credentials. If `--save` is specified, registers the enterprise as a durable Hose tenant. If the enterprise has multiple keys, execution halts and candidates are listed unless `--app-key` or `--key-id` is passed.
- `seal-use corps hose-keys [<url> | <corpId>] [--reveal] [--save]` reads/displays OpenAPI keys for a Hose assistance link or configured Hose enterprise (masked by default, `--reveal` displays plaintext). The old `keys` form remains an alias. Rejects non-Hose/native-Seal tenants with exit code 2.
- `seal-use auth extract-keys <url>` and `seal-use auth keys [--corp <corpId>]` provide auth-domain aliases for key extraction and inspection.
- `seal-use auth hose-extract-keys <url>` and `seal-use auth hose-keys [--corp <corpId>]` are the explicit Hose auth-domain commands. The old `extract-keys`/`extract-key`/`extract-hose-keys` and `keys` forms remain aliases.
Read-only discovery:
@@ -332,6 +332,7 @@ Approval runs, simulations, and Langfuse bridge:
- `seal-use approval-runs search --corp <corpId> [--query <text>] [--limit 20]`
- `seal-use approval-runs summary --corp <corpId> [--date YYYY-MM-DD] [--timezone Asia/Shanghai]`
- `seal-use approval-runs hose-flow <recordId|SN> --corp <corpId>` (合思原生审批流时间线、员工意见、驳回原因与 AI 运行记录对齐;旧名 `flow` 兼容)
- `seal-use approval-runs bridge --corp <corpId> [--sourceDocumentSN <sn>]`
- `seal-use simulation create --mode hosecloud --flow-ids ... --no-wait --corp <corpId>` returns immediately with an `asyncTicket` (creation is non-blocking by default for compatibility).
- `seal-use simulation status <batchId> --corp <corpId>` performs one non-blocking status check and returns `QUEUED`/`RUNNING`/`COMPLETED`/`FAILED`-style state plus counters.
@@ -84,7 +84,7 @@ First distinguish the link by its host, purpose, and identity origin:
- **Seal-Native Delegation Link (默认第一公民)**: `https://<tenant>.sealai.cc/delegate?token=...` grants delegated access directly on a Seal tenant. Running `seal-use corps add-link <url>` automatically exchanges the delegation token via `/api/v1/delegation/consume`, receives the session, retrieves tenant and user info via `/api/v1/auth/me`, and registers a native Seal enterprise (`provider: "seal"`). Supports `--dry-run` to preview metadata without mutating local config.
- **Hose/合思 Assistance Link**: `https://<domain>/web/thirdparty.html?...` opens an upstream Hose session and continues through Seal SSO. Running standard `seal-use corps add-link <url>` exchanges that temporary token for a short-lived Seal Bearer token.
- **Hose Subdomain Boundary (合思子域专属提权)**: `seal-use` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session `accessToken`. To elevate to permanent Hose OpenAPI developer credentials, use `corps extract-keys <url> --save` or `corps add-link <url> --as-hose`. (Note: `--as-hose` cannot be used on Seal-native delegation links).
- **Hose Subdomain Boundary (合思子域专属提权)**: `seal-use` primarily manages Seal tenants. Tenants sourced from the Hose ecosystem have an upstream Hose enterprise backing them. A received Hose assistance link contains only a temporary session `accessToken`. To elevate to permanent Hose OpenAPI developer credentials, use `corps hose-extract-keys <url> --save` or `corps add-link <url> --as-hose`. (Note: `--as-hose` cannot be used on Seal-native delegation links).
- **Multi-Key Disambiguation (多套密钥明确抉择)**: If the Hose enterprise owns multiple application keys, the CLI will not guess or silently pick the first key. Instead, it terminates with an informative candidate list and requires the user to specify `--app-key <key>` or `--key-id <id>`. If only one key exists, it is selected automatically.
- **Non-Hose Tenants Blocked**: Calling `keys` on native Seal enterprises (`corp.source.type !== "hose"`) is strictly rejected with exit code 2, explaining that this capability belongs exclusively to the Hose ecosystem.
@@ -97,20 +97,20 @@ seal-use corps add-link "https://<tenant>.sealai.cc/delegate?token=..." [--name
# 2. 接入合思协助链接并提权为标准持久化合思企业配置:
seal-use corps add-link "<url>" --as-hose [--name "企业名称"]
# 或通过 extract-keys 提取保存:
seal-use corps extract-keys "<url>" --save [--name "企业名称"]
seal-use corps hose-extract-keys "<url>" --save [--name "企业名称"]
# 3. 提取密钥并脱敏查看(合思子域能力):
seal-use corps extract-keys "https://wx2.ekuaibao.com/web/thirdparty.html?accessToken=...&ekbCorpId=..."
seal-use corps hose-extract-keys "https://wx2.ekuaibao.com/web/thirdparty.html?accessToken=...&ekbCorpId=..."
# 4. 显式完整查看密钥明文(--reveal / -r):
seal-use corps extract-keys "<url>" --reveal
seal-use corps hose-extract-keys "<url>" --reveal
# 5. 多套密钥存在时,显式指定具体应用密钥:
seal-use corps extract-keys "<url>" --save --app-key "ekb_app_..."
seal-use corps hose-extract-keys "<url>" --save --app-key "ekb_app_..."
# 6. 查看已配置合思企业当前使用的应用密钥:
seal-use corps keys <corpId> [--reveal]
seal-use auth keys --corp <corpId> [--reveal]
seal-use corps hose-keys <corpId> [--reveal]
seal-use auth hose-keys --corp <corpId> [--reveal]
```
When using standard `add-link` with a Seal delegate link, it consumes the token directly against the Seal tenant and persists the verified Seal session. When using standard `add-link` with a Hose link (without `--as-hose`), it exchanges the temporary Hose token at the target Seal tenant and stores the short-lived Seal session. When `--as-hose` is used on a Hose link, the CLI executes Hose subdomain privilege elevation to register a durable standard Hose configuration.
@@ -139,7 +139,7 @@ This is functionally equivalent to a Hose assistance link. Both carry the same u
1. Treat the entire cURL as a secret. Do not echo it, execute it blindly, paste it into another service, or store it in repository files.
2. Extract: the request hostname (determines `baseUrl`), `accesstoken` header (session token), `corpid` header or cookie, and any other Hose session headers.
3. **Privilege elevation path (preferred)**: Use extracted `accesstoken`, `corpid`, and `baseUrl` to call `/api/innerapi/v1/key`, exactly as `corps extract-keys` does for assistance links. This retrieves permanent `appKey`/`appSecurity` to register a durable Hose enterprise configuration — do not skip this step just because the input is a cURL instead of a URL.
3. **Privilege elevation path (preferred)**: Use extracted `accesstoken`, `corpid`, and `baseUrl` to call `/api/innerapi/v1/key`, exactly as `corps hose-extract-keys` does for assistance links. This retrieves permanent `appKey`/`appSecurity` to register a durable Hose enterprise configuration — do not skip this step just because the input is a cURL instead of a URL.
4. **Fallback short-term path**: If the session user is not an administrator and the key interface returns no keys, fall back to the Seal SSO bridge to register a temporary Seal session.
5. If key extraction succeeds, inform the user that credentials have been permanently elevated; if it fails, explain the limitation and suggest the administrator copy a dedicated cURL or provide an assistance link or `appKey`/`appSecurity`.
+2 -2
View File
@@ -345,7 +345,7 @@ export async function handleApprovalRunsCommand(
return;
}
if (action === "flow") {
if (action === "flow" || action === "hose-flow") {
const target =
maybeName ??
args.command[2] ??
@@ -353,7 +353,7 @@ export async function handleApprovalRunsCommand(
stringOption(args.options.id) ??
stringOption(args.options.recordId);
if (!target) {
throw new Error("Usage: seal-use approval-runs flow <recordId|SN>");
throw new Error("Usage: seal-use approval-runs hose-flow <recordId|SN>");
}
await runTool(
+1 -1
View File
@@ -14,7 +14,7 @@ export async function handleAuthExtractKeysCommand(maybeName: string | undefined
const link = maybeName ?? stringOption(args.options.link) ?? stringOption(args.options.url);
if (!link) {
throw new Error(
"Usage: seal-use auth extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]"
"Usage: seal-use auth hose-extract-keys <https://.../web/thirdparty.html?...> [--reveal] [--save] [--name <customName>] [--overwrite]"
);
}
const reveal =
+8
View File
@@ -85,6 +85,14 @@ describe("renderHelp", () => {
expect(help).not.toContain("seal-use billing");
});
test("renders Hose-specific auth and approval flow command names", () => {
const authHelp = renderHelp(["auth"]);
const approvalHelp = renderHelp(["approval-runs"]);
expect(authHelp).toContain("seal-use auth hose-extract-keys");
expect(authHelp).toContain("seal-use auth hose-keys");
expect(approvalHelp).toContain("seal-use approval-runs hose-flow");
});
test("renders focused subcommand help with usage, options, and description", () => {
const help = renderHelp(["corps", "bind-test"]);
expect(help).toContain("seal-use corps bind-test");
+10 -9
View File
@@ -465,9 +465,10 @@ export const HELP_REGISTRY: AreaHelp[] = [
]
},
{
name: "flow",
summary: "Get Hose approval flow timeline, staff opinions, and align with AI runs",
usage: ["seal-use approval-runs flow <recordId|SN> [--corp <corpId>]"]
name: "hose-flow",
aliases: ["flow"],
summary: "【合思专属】Get Hose approval flow timeline, staff opinions, and align with AI runs",
usage: ["seal-use approval-runs hose-flow <recordId|SN> [--corp <corpId>]"]
},
{
name: "list",
@@ -786,11 +787,11 @@ export const HELP_REGISTRY: AreaHelp[] = [
"专用于合思 (Hose) 来源企业。向合思申请临时 ticket,生成直达外部合思/易快报主站 (https://app.ekuaibao.com/web/thirdparty.html) 的免密登录链接。若需生成 Seal 自身的审核后台访问链接,请使用 'seal-use auth link'。"
},
{
name: "extract-keys",
aliases: ["extract-key", "extract-hose-keys", "hose-extract-keys"],
name: "hose-extract-keys",
aliases: ["extract-keys", "extract-key", "extract-hose-keys"],
summary: "【合思子域提权】从合思协助链接提取 OpenAPI 开发者密钥并可选升级配置",
usage: [
"seal-use auth extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]"
"seal-use auth hose-extract-keys <url> [--reveal] [--save] [--app-key <key>] [--key-id <id>] [--name <customName>] [--overwrite]"
],
options: [
{ flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" },
@@ -801,10 +802,10 @@ export const HELP_REGISTRY: AreaHelp[] = [
description: "专属于合思 (Hose/合思云/易快报) 子域的能力。非合思渠道企业不支持。"
},
{
name: "keys",
aliases: ["hose-keys"],
name: "hose-keys",
aliases: ["keys"],
summary: "【合思子域】查看当前企业已配置的合思 OpenAPI 开发者密钥",
usage: ["seal-use auth keys [--corp <corpId>] [--reveal]"],
usage: ["seal-use auth hose-keys [--corp <corpId>] [--reveal]"],
options: [
{ flag: "--reveal, -r", description: "显式揭示完整 appSecurity 明文(默认脱敏保护)" }
],