weaver-work-cli 0.1.68 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{archive-SJTC5265.js → archive-VUTREF3P.js} +4 -4
- package/dist/chunks/{archive-oa-PN46RTI2.js → archive-oa-VXXO4RTB.js} +4 -4
- package/dist/chunks/{asset-XM3Y4FVU.js → asset-45U6TY7I.js} +32 -5
- package/dist/chunks/{asset-idle-DHGP3NYY.js → asset-idle-YCRBMTIT.js} +4 -4
- package/dist/chunks/{attachment-content-IXIBOET6.js → attachment-content-DMU7KNZ7.js} +3 -3
- package/dist/chunks/{blog-JC47AIXK.js → blog-5AML4WMG.js} +4 -4
- package/dist/chunks/{caizhilian-IKIHM77A.js → caizhilian-3P7BUNHT.js} +6 -6
- package/dist/chunks/{calendar-GZTSJ57Y.js → calendar-2HUXM3CZ.js} +4 -4
- package/dist/chunks/{chunk-6OK4LW76.js → chunk-4W6BSNIL.js} +6 -6
- package/dist/chunks/{chunk-3W5NMGDS.js → chunk-727VKJQK.js} +2 -2
- package/dist/chunks/{chunk-QHKY4WZA.js → chunk-7CINV2BU.js} +2 -2
- package/dist/chunks/{chunk-26FCCU5O.js → chunk-DSBV4GRK.js} +3 -3
- package/dist/chunks/{chunk-HWA2A25Y.js → chunk-E7VWE2XI.js} +3 -3
- package/dist/chunks/{chunk-C5IIIT4D.js → chunk-EHH363SP.js} +4 -4
- package/dist/chunks/{chunk-LXXR2RRE.js → chunk-GFOFUH6O.js} +50 -50
- package/dist/chunks/{chunk-TJN4PIYO.js → chunk-GTAFCAVP.js} +2 -0
- package/dist/chunks/{chunk-O7KPHPXQ.js → chunk-GWM5TLIK.js} +34 -34
- package/dist/chunks/{chunk-WSHIOSGM.js → chunk-H2NRTGZR.js} +3 -3
- package/dist/chunks/{chunk-YSEHTSHS.js → chunk-HAORST2G.js} +11 -11
- package/dist/chunks/{chunk-4WCVRDC5.js → chunk-HG6INLH6.js} +13 -0
- package/dist/chunks/{chunk-FDBAFANU.js → chunk-I5XB4MZT.js} +227 -23
- package/dist/chunks/{chunk-BJNSTCJK.js → chunk-IVCOZCAW.js} +1 -1
- package/dist/chunks/{chunk-Y7RGBRLG.js → chunk-KDOJW5LH.js} +1 -1
- package/dist/chunks/{chunk-QO6JYDIW.js → chunk-L2A3COWV.js} +4 -4
- package/dist/chunks/{chunk-X7ZTM4XG.js → chunk-LJE7RZNC.js} +1 -1
- package/dist/chunks/{chunk-FJUOUSV3.js → chunk-LRKKKO5A.js} +36 -9
- package/dist/chunks/{chunk-HLT6B26P.js → chunk-LSVA7QA6.js} +1 -1
- package/dist/chunks/{chunk-6N4JPNFL.js → chunk-MD5CW4B6.js} +1 -1
- package/dist/chunks/{chunk-Q6D6PSMH.js → chunk-QYDSTYGG.js} +3 -3
- package/dist/chunks/{chunk-AFZTMYGC.js → chunk-T24EBWAZ.js} +1 -1
- package/dist/chunks/{chunk-6T5X6YWX.js → chunk-U3OO3IZF.js} +3 -3
- package/dist/chunks/{chunk-VLY5RTVO.js → chunk-UVWW5ABZ.js} +3 -3
- package/dist/chunks/{chunk-NP3ZZFGI.js → chunk-VZUH3LKI.js} +16 -5
- package/dist/chunks/{chunk-OKUJY5YB.js → chunk-X6PMJQGO.js} +64 -21
- package/dist/chunks/{chunk-3NJQTG6X.js → chunk-XIBMZEDB.js} +2 -2
- package/dist/chunks/{conflict-CEXRX2KP.js → conflict-YW5BULJ3.js} +2 -2
- package/dist/chunks/{contract-PM3EUPZC.js → contract-3PMHUASH.js} +164 -5
- package/dist/chunks/{cowork-34CBYVQP.js → cowork-FZBTTBYX.js} +4 -4
- package/dist/chunks/{create-flow-DG6D7U2L.js → create-flow-5OBS3B3V.js} +6 -6
- package/dist/chunks/{data-3G4GQS5P.js → data-2YZ6A6TL.js} +19 -4
- package/dist/chunks/{ebuilder-form-5ENYH7IF.js → ebuilder-form-AWPTMZBZ.js} +5 -5
- package/dist/chunks/{ehr-2CONM7R6.js → ehr-MNPR4TE5.js} +4 -4
- package/dist/chunks/{entry-mode-KMP66KHE.js → entry-mode-L65OWPFM.js} +3 -3
- package/dist/chunks/{env-SW6CTETI.js → env-XW7LYIME.js} +2 -2
- package/dist/chunks/{esb-FQASCY2H.js → esb-GSB5QCEX.js} +6 -6
- package/dist/chunks/{factory-ETQAICPA.js → factory-MHFZZAGH.js} +1 -1
- package/dist/chunks/{fna-FCLVIWAS.js → fna-XBSNUS2V.js} +4 -4
- package/dist/chunks/{group-chat-GTYMCBYS.js → group-chat-EEOLO5NM.js} +3 -3
- package/dist/chunks/{host-P7G22WNM.js → host-2UMNXX5H.js} +4 -4
- package/dist/chunks/{host-XLCBLNJD.js → host-BD44ASOD.js} +4 -4
- package/dist/chunks/{host-2ED2KC4X.js → host-NVDG3NC6.js} +4 -4
- package/dist/chunks/{host-46NYKDQP.js → host-R7BP3CTI.js} +4 -4
- package/dist/chunks/{host-7IPZKIM4.js → host-SYPCA63D.js} +4 -4
- package/dist/chunks/{host-2UYZEY2V.js → host-XVWBOSEN.js} +4 -4
- package/dist/chunks/{hrm-5WSMSKPX.js → hrm-FZUDJAND.js} +17 -11
- package/dist/chunks/{im-P7GNBRG6.js → im-F5NENPD7.js} +4 -4
- package/dist/chunks/{invoice-2QCVNXBG.js → invoice-DS6FLU55.js} +42 -6
- package/dist/chunks/{jiuchuanhui-FHGFYAHU.js → jiuchuanhui-JCBUR563.js} +1332 -1037
- package/dist/chunks/{lazy-dispatch-K25LTKQY.js → lazy-dispatch-F6O2EPGR.js} +7 -7
- package/dist/chunks/{mail-P7VMUKQW.js → mail-ZEOSANEJ.js} +4 -4
- package/dist/chunks/{meeting-3PTTPUSG.js → meeting-PCD5EPBF.js} +15 -15
- package/dist/chunks/{minute-doc-3IMRJDJV.js → minute-doc-WTZJVCHG.js} +4 -4
- package/dist/chunks/{okr-OIWJRYWY.js → okr-OZUMTMCL.js} +4 -4
- package/dist/chunks/{operations-MI2BSKZX.js → operations-UTUWFJTX.js} +5 -5
- package/dist/chunks/{performance-OPEQNW7Y.js → performance-SMVTPK6T.js} +8 -7
- package/dist/chunks/{plan-TJAS4N5X.js → plan-C2NENH42.js} +4 -4
- package/dist/chunks/{project-CYBGU6K6.js → project-FAJ2P3UR.js} +4 -4
- package/dist/chunks/{reception-2VSWJQ5N.js → reception-NH6MJFPR.js} +16 -8
- package/dist/chunks/{recruit-stage-KHJYQE3I.js → recruit-stage-DPEFHLSE.js} +3 -3
- package/dist/chunks/{registry-FXBOGH2X.js → registry-3B3OAJYX.js} +4 -4
- package/dist/chunks/{registry-QRMXRSCT.js → registry-FTPUUHWC.js} +5 -5
- package/dist/chunks/{registry-PHPYTXS4.js → registry-ZQ7OONCB.js} +12 -12
- package/dist/chunks/{room-recommend-BKCPAXQG.js → room-recommend-73NBN3RU.js} +4 -4
- package/dist/chunks/{schedule-Q3MPSZV6.js → schedule-SDBOBBUQ.js} +4 -4
- package/dist/chunks/{smart-extract-TYYKC244.js → smart-extract-GTYKF5TJ.js} +4 -4
- package/dist/chunks/{workflow-GEDHALMY.js → workflow-OWHWLAOX.js} +81 -12
- package/dist/core/error-codes.js +1 -1
- package/dist/core/host-policy.js +56 -0
- package/dist/core/timing.js +227 -0
- package/dist/index.js +39 -36
- package/dist/internal/e10/auth/commands.js +11 -0
- package/dist/internal/e10/auth/error-log.js +13 -0
- package/dist/internal/e10/auth/messages.js +10 -0
- package/dist/internal/e10/auth/xiaoe.js +12 -2
- package/dist/internal/e10/context.js +39 -12
- package/dist/internal/e10/network-error.js +28 -0
- package/dist/internal/e10/tls-policy.js +260 -0
- package/dist/shortcuts/asset/manifest.js +34 -1
- package/dist/shortcuts/contract/manifest.js +166 -1
- package/dist/shortcuts/data/manifest.js +32 -1
- package/dist/shortcuts/hrm/index.js +20 -7
- package/dist/shortcuts/invoice/manifest.js +43 -1
- package/dist/shortcuts/jiuchuanhui/cache.js +49 -35
- package/dist/shortcuts/jiuchuanhui/host.js +109 -5
- package/dist/shortcuts/jiuchuanhui/index.js +43 -7
- package/dist/shortcuts/jiuchuanhui/manifest.js +138 -2
- package/dist/shortcuts/jiuchuanhui/operations/customer-quick.js +110 -0
- package/dist/shortcuts/jiuchuanhui/operations/datajson.js +11 -56
- package/dist/shortcuts/jiuchuanhui/operations/esb.js +9 -16
- package/dist/shortcuts/jiuchuanhui/operations/generic.js +8 -30
- package/dist/shortcuts/jiuchuanhui/operations/registry.js +8 -2
- package/dist/shortcuts/jiuchuanhui/operations/shared.js +0 -10
- package/dist/shortcuts/performance/operations/flow-detail.js +5 -4
- package/dist/shortcuts/reception/host.js +19 -5
- package/dist/shortcuts/workflow/index.js +55 -5
- package/dist/shortcuts/workflow/operations/aiDeepRead/collect.js +5 -2
- package/dist/shortcuts/workflow/operations/read.js +12 -2
- package/dist/shortcuts/workflow/operations/types.js +7 -1
- package/dist/shortcuts/workflow/operations/write.js +20 -2
- package/dist/shortcuts/workflow/operations.js +19 -1
- package/docs/e10-auth.md +48 -1
- package/docs/jiuchuanhui.md +17 -5
- package/package.json +1 -1
- package/scripts/xiaoe_env.py +18 -3
- package/skills/weaver-e10-asset-idle/SKILL.md +1 -1
- package/skills/weaver-e10-blog/SKILL.md +2 -2
- package/skills/weaver-e10-calendar/SKILL.md +1 -1
- package/skills/weaver-e10-data/SKILL.md +1 -1
- package/skills/weaver-e10-esb/SKILL.md +1 -1
- package/skills/weaver-e10-esb/references/source-manifest.json +3 -3
- package/skills/weaver-e10-hrm/SKILL.md +1 -1
- package/skills/weaver-e10-jiuchuanhui/SKILL.md +49 -90
- package/skills/weaver-e10-jiuchuanhui/references/cache.md +17 -13
- package/skills/weaver-e10-jiuchuanhui/references/customer.md +33 -4
- package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +3 -3
- package/skills/weaver-e10-jiuchuanhui/references/jiuchuanhui-entry.md +9 -7
- package/skills/weaver-e10-jucailin/SKILL.md +84 -17
- package/skills/weaver-e10-jucailin/agents/openai.yaml +2 -1
- package/skills/weaver-e10-jucailin/references/recruit-create.md +7 -8
- package/skills/weaver-e10-jucailin/references/recruit-implement-INDEX.md +41 -0
- package/skills/weaver-e10-jucailin/references/recruit-implement-consult-sop.md +77 -0
- package/skills/weaver-e10-jucailin/references/recruit-implement-guardrails.md +41 -0
- package/skills/weaver-e10-jucailin/references/recruit-implement-kb-data-update-channels.md +31 -0
- package/skills/weaver-e10-jucailin/references/recruit-implement-kb-form-external.md +43 -0
- package/skills/weaver-e10-jucailin/references/recruit-implement-kb-talent-base-form.md +32 -0
- package/skills/weaver-e10-jucailin/references/recruit-implement-pattern-external-collect-update-talent.md +93 -0
- package/skills/weaver-e10-jucailin/references/recruit-implement-pattern-external-share-edit.md +64 -0
- package/skills/weaver-e10-jucailin/references/recruit-read.md +1 -1
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +1 -1
- package/skills/weaver-e10-jucailin/references/recruit-write.md +4 -11
- package/skills/weaver-e10-jucailin/references/safety-boundaries.md +3 -3
- package/skills/weaver-e10-mail/SKILL.md +52 -10
- package/skills/weaver-e10-mail/references/mail-agent-entry.md +1 -2
- package/skills/weaver-e10-meeting/SKILL.md +1 -1
- package/skills/weaver-e10-meeting/references/meeting-verification.md +1 -1
- package/skills/weaver-e10-okr/SKILL.md +1 -1
- package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
- package/skills/weaver-e10-performance/SKILL.md +2 -2
- package/skills/weaver-e10-performance/agents/openai.yaml +4 -2
- package/skills/weaver-e10-performance/references/flow-assess.md +19 -6
- package/skills/weaver-e10-plan/SKILL.md +2 -2
- package/skills/weaver-e10-plan/references/source-manifest.json +3 -3
- package/skills/weaver-e10-qiyecheng/SKILL.md +2 -2
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +3 -3
- package/skills/weaver-e10-reception-flow/SKILL.md +53 -16
- package/skills/weaver-e10-shared/SKILL.md +4 -9
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +2 -2
- package/skills/weaver-e10-shijingran/SKILL.md +14 -6
- package/skills/weaver-e10-shijingran/references/source-manifest.json +5 -4
- package/skills/weaver-e10-workflow/SKILL.md +2 -2
- package/skills/weaver-e10-workflow/references/source-manifest.json +3 -3
- package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +1 -2
- package/skills/weaver-e10-workflow/references/workflow-deep-read.md +8 -3
- package/skills/weaver-e10-ziguanjia/SKILL.md +1 -1
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +1 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 宿主能力策略:按**进程环境变量**判断当前运行宿主,并对该宿主禁用指定 capability。
|
|
3
|
+
*
|
|
4
|
+
* ★ 判据只认环境变量,**不读 session / 已持久化的 agentType**,这是本模块的核心约束:
|
|
5
|
+
*
|
|
6
|
+
* - `auth init --agent_type doubao` 会把 agentType 固化进 session。若门禁读 session,
|
|
7
|
+
* 同一台机器上的**手动调用**也会被一起禁掉(用户要求「手动调用不受影响」);
|
|
8
|
+
* - 手动在终端调用时,进程环境里没有宿主注入的变量,一律放行;
|
|
9
|
+
* - 同一台机器上其他宿主注入的是各自的前缀(`WORKBUDDY_*` / `QWENWORK_*`),互不影响。
|
|
10
|
+
*
|
|
11
|
+
* 判据用「key 名是否包含宿主标识」而不是前缀匹配:宿主注入的变量名在版本间会变
|
|
12
|
+
* (`DOUBAO_OFFICE_AGENT_NAME`、`DOUBAO_HOME`…),包含匹配不会漏。
|
|
13
|
+
*
|
|
14
|
+
* 2026-11-26 豆包渠道要求:豆包连接器禁止调用记忆类 operation
|
|
15
|
+
* (`workflow.memoryExtract` 写记忆 / `workflow.memoryPrompt` 读记忆),
|
|
16
|
+
* 其他连接器与手动调用不受影响。
|
|
17
|
+
*/
|
|
18
|
+
/** 宿主识别:环境变量 key 名包含 marker(大小写不敏感)即判定为该宿主。 */
|
|
19
|
+
export const HOST_ENV_MARKERS = [
|
|
20
|
+
{ host: 'doubao', marker: 'DOUBAO' },
|
|
21
|
+
];
|
|
22
|
+
/** 按宿主禁用的 capability。用 capability 而非命令名:新增同类 operation 自动被禁。 */
|
|
23
|
+
export const HOST_DENIED_CAPABILITIES = {
|
|
24
|
+
doubao: ['memory'],
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 从进程环境推断宿主;识别不到返回 null(= 手动调用,一律放行)。
|
|
28
|
+
*
|
|
29
|
+
* 只看 key 名、不看 value:宿主注入的值在不同版本间不固定,key 名稳定得多。
|
|
30
|
+
*/
|
|
31
|
+
export function detectHostByEnv(env = process.env) {
|
|
32
|
+
const keys = Object.keys(env ?? {});
|
|
33
|
+
for (const { host, marker } of HOST_ENV_MARKERS) {
|
|
34
|
+
if (keys.some((key) => key.toUpperCase().includes(marker)))
|
|
35
|
+
return host;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 当前宿主是否禁用了该 capability;禁用时返回命中详情,否则 null。
|
|
41
|
+
*/
|
|
42
|
+
export function hostCapabilityDenial(capability, env = process.env) {
|
|
43
|
+
if (!capability)
|
|
44
|
+
return null;
|
|
45
|
+
const hostKey = detectHostByEnv(env);
|
|
46
|
+
if (!hostKey)
|
|
47
|
+
return null;
|
|
48
|
+
const denied = HOST_DENIED_CAPABILITIES[hostKey] ?? [];
|
|
49
|
+
if (!denied.includes(capability))
|
|
50
|
+
return null;
|
|
51
|
+
return { host: hostKey === 'doubao' ? '豆包' : hostKey, hostKey, capability };
|
|
52
|
+
}
|
|
53
|
+
/** 便捷判定,供 manifest / schema 过滤使用。 */
|
|
54
|
+
export function isCapabilityDeniedHere(capability, env = process.env) {
|
|
55
|
+
return hostCapabilityDenial(capability, env) !== null;
|
|
56
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
/**
|
|
5
|
+
* 分阶段耗时采集(排障用,默认完全关闭)。
|
|
6
|
+
*
|
|
7
|
+
* 背景:小e / 沙箱里「登录很慢」的抱怨无法归因——`--json` 模式下 `logger.debug` 与
|
|
8
|
+
* 登录过程的 `recoveryLogger` 全部静默,`E10_TRACE_REQ=1` 只能看到业务接口,看不到
|
|
9
|
+
* 「读 auth 文件、teamsCheck 富化、平台换票、Python 解释器探测」这些真正可能慢的环节。
|
|
10
|
+
* 更麻烦的是:**如果慢在 Agent 侧(读 Skill、模型回合),CLI 里连一行日志都不会出现**,
|
|
11
|
+
* 于是所有嫌疑都被算到 CLI 头上。本模块给出唯一的进程级时间轴:
|
|
12
|
+
*
|
|
13
|
+
* - `PROCESS_START_MS` 用 `process.uptime()` 反推进程真实起点,
|
|
14
|
+
* 因此 `cli.entry` 那一段就是「node 启动 + 模块求值」的本征开销;
|
|
15
|
+
* - 每个 span 记录相对起点的偏移与自身耗时,先发生的先输出,可直接看出串行链;
|
|
16
|
+
* - 退出时先写 JSONL(默认 `~/.weaver-work-cli/logs/timing-YYYY-MM-DD.jsonl`),
|
|
17
|
+
* 再按需在 stderr 打一份要点。**JSONL 是主通道**:`--json` 的 stderr 必须保持
|
|
18
|
+
* 「只有一个 JSON 对象」的契约,不能混入人类可读行。
|
|
19
|
+
*
|
|
20
|
+
* 开关(任一命中即开启):
|
|
21
|
+
* - 全局参数 `--timing`(`enableTimingFromArgv()` 在入口按 argv 预扫描,
|
|
22
|
+
* 不能等 commander 解析完再开,否则最贵的启动段已经过去了);
|
|
23
|
+
* - 环境变量 `WEAVER_WORK_CLI_TIMING=1|true|yes|on`:写文件,非 `--json` 时附带 stderr;
|
|
24
|
+
* - `WEAVER_WORK_CLI_TIMING=stderr`:连 `--json` 也打 stderr(人工排障专用,
|
|
25
|
+
* 不要让 Agent 带这个值跑业务命令);
|
|
26
|
+
* - `WEAVER_WORK_CLI_TIMING=file`:只写文件,stderr 一个字都不加。
|
|
27
|
+
*
|
|
28
|
+
* 约定:meta 只放**不含凭证、不含业务数据**的标量(阶段结果、来源类型、解释器名、
|
|
29
|
+
* 接口路径)。绝不记录 token、cookie、请求体、`--input-json` 的内容。
|
|
30
|
+
*/
|
|
31
|
+
const ENV_KEY = 'WEAVER_WORK_CLI_TIMING';
|
|
32
|
+
const MAX_SPANS = 500;
|
|
33
|
+
/** 进程真实起点:`uptime()` 是进程已存活毫秒数,反推回去即 node 被 exec 的时刻。 */
|
|
34
|
+
const PROCESS_START_MS = Date.now() - Math.round(process.uptime() * 1000);
|
|
35
|
+
let enabled = false;
|
|
36
|
+
let stderrForced = false;
|
|
37
|
+
let fileDisabled = false;
|
|
38
|
+
let exitHookRegistered = false;
|
|
39
|
+
let flushed = false;
|
|
40
|
+
let droppedSpans = 0;
|
|
41
|
+
const spans = [];
|
|
42
|
+
function offsetMs() {
|
|
43
|
+
return Date.now() - PROCESS_START_MS;
|
|
44
|
+
}
|
|
45
|
+
function normalizeFlag(raw) {
|
|
46
|
+
return String(raw ?? '').trim().toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
function wantsTiming(raw) {
|
|
49
|
+
return raw === '1' || raw === 'true' || raw === 'yes' || raw === 'on'
|
|
50
|
+
|| raw === 'file' || raw === 'stderr';
|
|
51
|
+
}
|
|
52
|
+
/** `--json` 下 stderr 只能有一个 JSON 对象,人类可读行必须让路。 */
|
|
53
|
+
function jsonModeFromArgv(argv) {
|
|
54
|
+
return argv.some((arg) => arg === '--json' || arg === '--json=true');
|
|
55
|
+
}
|
|
56
|
+
function timingHome(env) {
|
|
57
|
+
return env.WEAVER_WORK_CLI_HOME || env.WORK_CLI_HOME || resolve(homedir(), '.weaver-work-cli');
|
|
58
|
+
}
|
|
59
|
+
function timingLogPath(env = process.env) {
|
|
60
|
+
const now = new Date();
|
|
61
|
+
const day = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
|
62
|
+
return resolve(timingHome(env), 'logs', `timing-${day}.jsonl`);
|
|
63
|
+
}
|
|
64
|
+
function mergeMeta(base, extra) {
|
|
65
|
+
if (!base && !extra)
|
|
66
|
+
return undefined;
|
|
67
|
+
const merged = {};
|
|
68
|
+
for (const [key, value] of Object.entries(base || {})) {
|
|
69
|
+
if (value !== undefined)
|
|
70
|
+
merged[key] = value;
|
|
71
|
+
}
|
|
72
|
+
for (const [key, value] of Object.entries(extra || {})) {
|
|
73
|
+
if (value !== undefined)
|
|
74
|
+
merged[key] = value;
|
|
75
|
+
}
|
|
76
|
+
return Object.keys(merged).length ? merged : undefined;
|
|
77
|
+
}
|
|
78
|
+
function formatMeta(meta) {
|
|
79
|
+
if (!meta)
|
|
80
|
+
return '';
|
|
81
|
+
const text = Object.entries(meta)
|
|
82
|
+
.map(([key, value]) => `${key}=${String(value)}`)
|
|
83
|
+
.join(' ');
|
|
84
|
+
return text ? ` ${text}` : '';
|
|
85
|
+
}
|
|
86
|
+
function registerExitHook() {
|
|
87
|
+
if (exitHookRegistered)
|
|
88
|
+
return;
|
|
89
|
+
exitHookRegistered = true;
|
|
90
|
+
process.on('exit', (code) => finishTiming(typeof code === 'number' ? code : undefined));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 入口最早期调用一次。`--timing` 必须在这里就识别出来:commander 解析完再开,
|
|
94
|
+
* `cli.entry` / shortcut 加载这些最可能拖慢「一条命令几秒」的段落就全都记不到了。
|
|
95
|
+
*/
|
|
96
|
+
export function enableTimingFromArgv(argv = process.argv, env = process.env) {
|
|
97
|
+
if (enabled)
|
|
98
|
+
return true;
|
|
99
|
+
const raw = normalizeFlag(env[ENV_KEY]);
|
|
100
|
+
const byEnv = wantsTiming(raw);
|
|
101
|
+
const byArgv = argv.some((arg) => arg === '--timing' || arg === '--timing=true');
|
|
102
|
+
if (!byEnv && !byArgv)
|
|
103
|
+
return false;
|
|
104
|
+
enabled = true;
|
|
105
|
+
stderrForced = raw === 'stderr';
|
|
106
|
+
fileDisabled = raw === 'file';
|
|
107
|
+
registerExitHook();
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
/** 供程序内部显式开启(测试、嵌入式调用)用。 */
|
|
111
|
+
export function enableTiming(options = {}) {
|
|
112
|
+
enabled = true;
|
|
113
|
+
stderrForced = options.stderr === true;
|
|
114
|
+
fileDisabled = options.file === false;
|
|
115
|
+
registerExitHook();
|
|
116
|
+
}
|
|
117
|
+
export function isTimingEnabled() {
|
|
118
|
+
return enabled;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* 开始一个计时段。返回的结束函数可调用多次(幂等),关闭时返回 `null`,
|
|
122
|
+
* 调用方用 `?.()` 短路 ⇒ 未开启时除一次布尔判断外零开销。
|
|
123
|
+
*/
|
|
124
|
+
export function startTiming(name, meta) {
|
|
125
|
+
if (!enabled)
|
|
126
|
+
return null;
|
|
127
|
+
const startMs = offsetMs();
|
|
128
|
+
let closed = false;
|
|
129
|
+
return (extra) => {
|
|
130
|
+
if (closed)
|
|
131
|
+
return;
|
|
132
|
+
closed = true;
|
|
133
|
+
pushSpan({ name, startMs, ms: Math.max(0, offsetMs() - startMs), meta: mergeMeta(meta, extra) });
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** 瞬时标记(无耗时,只占一个时间点),用于「node 启动到入口求值完毕」这类边界。 */
|
|
137
|
+
export function markTiming(name, meta) {
|
|
138
|
+
if (!enabled)
|
|
139
|
+
return;
|
|
140
|
+
const at = offsetMs();
|
|
141
|
+
pushSpan({ name, startMs: at, ms: 0, meta });
|
|
142
|
+
}
|
|
143
|
+
function pushSpan(span) {
|
|
144
|
+
if (spans.length >= MAX_SPANS) {
|
|
145
|
+
droppedSpans += 1;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
spans.push(span);
|
|
149
|
+
}
|
|
150
|
+
/** 只取命令名,丢掉所有 `--flag` 与看起来像 JSON / 长文本的参数(避免把业务数据写进日志)。 */
|
|
151
|
+
function commandLabel(argv) {
|
|
152
|
+
const tokens = [];
|
|
153
|
+
for (const token of argv.slice(2)) {
|
|
154
|
+
if (token.startsWith('-'))
|
|
155
|
+
continue;
|
|
156
|
+
if (/^[[{]/.test(token) || token.length > 48)
|
|
157
|
+
continue;
|
|
158
|
+
tokens.push(token);
|
|
159
|
+
if (tokens.length >= 3)
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
return tokens.join(' ');
|
|
163
|
+
}
|
|
164
|
+
function shouldWriteStderr(argv) {
|
|
165
|
+
if (stderrForced)
|
|
166
|
+
return true;
|
|
167
|
+
if (fileDisabled && !stderrForced)
|
|
168
|
+
return !jsonModeFromArgv(argv) && !argv.includes('--quiet');
|
|
169
|
+
return !jsonModeFromArgv(argv);
|
|
170
|
+
}
|
|
171
|
+
function summaryLines(totalMs) {
|
|
172
|
+
const ordered = [...spans].sort((left, right) => left.startMs - right.startMs || right.ms - left.ms);
|
|
173
|
+
const lines = [`[timing] total=${totalMs}ms spans=${spans.length}${droppedSpans ? ` dropped=${droppedSpans}` : ''}`];
|
|
174
|
+
for (const span of ordered) {
|
|
175
|
+
const bar = span.ms > 0 ? `${String(span.ms).padStart(5)}ms` : ' mark';
|
|
176
|
+
lines.push(`[timing] +${String(span.startMs).padStart(6)}ms ${bar} ${span.name}${formatMeta(span.meta)}`);
|
|
177
|
+
}
|
|
178
|
+
return lines;
|
|
179
|
+
}
|
|
180
|
+
function writeJsonl(totalMs, exitCode) {
|
|
181
|
+
if (fileDisabled)
|
|
182
|
+
return;
|
|
183
|
+
const env = process.env;
|
|
184
|
+
const record = {
|
|
185
|
+
ts: new Date().toISOString(),
|
|
186
|
+
command: commandLabel(process.argv),
|
|
187
|
+
totalMs,
|
|
188
|
+
exitCode: exitCode ?? null,
|
|
189
|
+
pid: process.pid,
|
|
190
|
+
ppid: process.ppid,
|
|
191
|
+
node: process.version,
|
|
192
|
+
platform: process.platform,
|
|
193
|
+
spans: [...spans].sort((left, right) => left.startMs - right.startMs),
|
|
194
|
+
droppedSpans,
|
|
195
|
+
// 只记录「宿主标记是否存在」,绝不落值里的凭证。
|
|
196
|
+
host: {
|
|
197
|
+
xiaoeUserToken: Boolean(env.XIAOE_USER_TOKEN),
|
|
198
|
+
xiaoeClientType: env.XIAOE_CLIENT_TYPE || '',
|
|
199
|
+
runtimeAgent: env.WEAVER_RUNTIME_AGENT || '',
|
|
200
|
+
profile: env.WEAVER_PROFILE || '',
|
|
201
|
+
ci: Boolean(env.CI),
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
try {
|
|
205
|
+
const path = timingLogPath(env);
|
|
206
|
+
mkdirSync(resolve(path, '..'), { recursive: true, mode: 0o700 });
|
|
207
|
+
appendFileSync(path, `${JSON.stringify(record)}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
// 排障通道自身失败绝不能影响命令结果。
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** 命令结束时调用(`process.on('exit')` 也会兜底;重复调用只生效一次)。 */
|
|
214
|
+
export function finishTiming(exitCode) {
|
|
215
|
+
if (!enabled || flushed)
|
|
216
|
+
return;
|
|
217
|
+
flushed = true;
|
|
218
|
+
const totalMs = offsetMs();
|
|
219
|
+
writeJsonl(totalMs, exitCode);
|
|
220
|
+
if (shouldWriteStderr(process.argv)) {
|
|
221
|
+
process.stderr.write(`${summaryLines(totalMs).join('\n')}\n`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/** 供 `doctor` 等命令回报日志位置。 */
|
|
225
|
+
export function timingLogFile() {
|
|
226
|
+
return timingLogPath(process.env);
|
|
227
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -7,14 +7,16 @@ import {
|
|
|
7
7
|
firstPositionalToken,
|
|
8
8
|
registerCommands,
|
|
9
9
|
toCommandMetadata
|
|
10
|
-
} from "./chunks/chunk-
|
|
11
|
-
import "./chunks/chunk-
|
|
10
|
+
} from "./chunks/chunk-VZUH3LKI.js";
|
|
11
|
+
import "./chunks/chunk-HG6INLH6.js";
|
|
12
12
|
import "./chunks/chunk-AJ62BGAW.js";
|
|
13
|
-
import "./chunks/chunk-
|
|
14
|
-
import "./chunks/chunk-
|
|
15
|
-
import "./chunks/chunk-
|
|
16
|
-
import "./chunks/chunk-
|
|
17
|
-
import
|
|
13
|
+
import "./chunks/chunk-H2NRTGZR.js";
|
|
14
|
+
import "./chunks/chunk-MD5CW4B6.js";
|
|
15
|
+
import "./chunks/chunk-LRKKKO5A.js";
|
|
16
|
+
import "./chunks/chunk-GTAFCAVP.js";
|
|
17
|
+
import {
|
|
18
|
+
applyE10TlsPolicy
|
|
19
|
+
} from "./chunks/chunk-I5XB4MZT.js";
|
|
18
20
|
import "./chunks/chunk-UG5G54VL.js";
|
|
19
21
|
import "./chunks/chunk-BUSC6UAE.js";
|
|
20
22
|
|
|
@@ -31,7 +33,7 @@ function lazyShortcut(definition) {
|
|
|
31
33
|
placeholder.allowExcessArguments(true);
|
|
32
34
|
placeholder.helpOption(false);
|
|
33
35
|
placeholder.action(async () => {
|
|
34
|
-
const { dispatchLazyShortcut } = await import("./chunks/lazy-dispatch-
|
|
36
|
+
const { dispatchLazyShortcut } = await import("./chunks/lazy-dispatch-F6O2EPGR.js");
|
|
35
37
|
await dispatchLazyShortcut(definition, shortcutMetadata());
|
|
36
38
|
});
|
|
37
39
|
}
|
|
@@ -41,142 +43,142 @@ var builtinShortcuts = [
|
|
|
41
43
|
lazyShortcut({
|
|
42
44
|
name: "invoice",
|
|
43
45
|
description: "E10 \u4E1A\u7968\u901A\u53D1\u7968\u7BA1\u7406 CLI",
|
|
44
|
-
load: async () => (await import("./chunks/invoice-
|
|
46
|
+
load: async () => (await import("./chunks/invoice-DS6FLU55.js")).invoiceShortcut
|
|
45
47
|
}),
|
|
46
48
|
lazyShortcut({
|
|
47
49
|
name: "ehr",
|
|
48
50
|
description: "\u6CDB\u5FAEE10\u805A\u624D\u6797\uFF08\u4EBA\u4E8B/\u51FA\u52E4/\u85AA\u916C\uFF09CLI",
|
|
49
|
-
load: async () => (await import("./chunks/ehr-
|
|
51
|
+
load: async () => (await import("./chunks/ehr-MNPR4TE5.js")).ehrShortcut
|
|
50
52
|
}),
|
|
51
53
|
lazyShortcut({
|
|
52
54
|
name: "recruit-stage",
|
|
53
55
|
description: "\u6CDB\u5FAEE10\u62DB\u8058\u52A9\u624B\uFF08JD\u751F\u6210/\u7B80\u5386\u5EFA\u6863/AI\u9762\u8BD5\u9080\u7EA6\uFF09CLI",
|
|
54
|
-
load: async () => (await import("./chunks/recruit-stage-
|
|
56
|
+
load: async () => (await import("./chunks/recruit-stage-DPEFHLSE.js")).recruitStageShortcut
|
|
55
57
|
}),
|
|
56
58
|
lazyShortcut({
|
|
57
59
|
name: "performance",
|
|
58
60
|
description: "\u6CDB\u5FAEE10\u7EE9\u6548\u65B9\u6848\uFF08\u6587\u6863\u5BFC\u5165/\u5B9E\u4F53\u89E3\u6790/\u843D\u8349\u7A3F/\u786E\u8BA4\u53D1\u5E03\uFF09CLI",
|
|
59
|
-
load: async () => (await import("./chunks/performance-
|
|
61
|
+
load: async () => (await import("./chunks/performance-SMVTPK6T.js")).performanceShortcut
|
|
60
62
|
}),
|
|
61
63
|
lazyShortcut({
|
|
62
64
|
name: "cowork",
|
|
63
65
|
description: "\u6CDB\u5FAEE10\u534F\u4F5C\u533A\uFF08\u534F\u4F5C\u4E8B\u9879/\u8BA8\u8BBA/\u5BA1\u6279/\u5171\u4EAB\u6743\u9650\uFF09CLI",
|
|
64
|
-
load: async () => (await import("./chunks/cowork-
|
|
66
|
+
load: async () => (await import("./chunks/cowork-FZBTTBYX.js")).coworkShortcut
|
|
65
67
|
}),
|
|
66
68
|
lazyShortcut({
|
|
67
69
|
name: "archive",
|
|
68
70
|
description: "E10 \u6587\u4E66\u5B9A\u6863\u6848\u7BA1\u7406 CLI",
|
|
69
|
-
load: async () => (await import("./chunks/archive-
|
|
71
|
+
load: async () => (await import("./chunks/archive-VUTREF3P.js")).archiveShortcut
|
|
70
72
|
}),
|
|
71
73
|
lazyShortcut({
|
|
72
74
|
name: "archive-oa",
|
|
73
75
|
description: "E10 \u6863\u6848\u5B9A\u4F4D\u4E0E OA \u5546\u52A1\u5408\u540C\u501F\u9605 CLI",
|
|
74
|
-
load: async () => (await import("./chunks/archive-oa-
|
|
76
|
+
load: async () => (await import("./chunks/archive-oa-VXXO4RTB.js")).archiveOaShortcut
|
|
75
77
|
}),
|
|
76
78
|
lazyShortcut({
|
|
77
79
|
name: "calendar",
|
|
78
80
|
description: "\u6CDB\u5FAEE10\u65E5\u7A0B\u7BA1\u7406 CLI\uFF08\u521B\u5EFA/\u67E5\u8BE2/\u66F4\u65B0/\u5220\u9664/\u5B57\u5178\uFF09",
|
|
79
|
-
load: async () => (await import("./chunks/calendar-
|
|
81
|
+
load: async () => (await import("./chunks/calendar-2HUXM3CZ.js")).calendarShortcut
|
|
80
82
|
}),
|
|
81
83
|
lazyShortcut({
|
|
82
84
|
name: "fna",
|
|
83
85
|
description: "\u6CDB\u5FAEE10\u9F50\u4E1A\u6210\u8D39\u63A7\u4E2D\u5FC3\uFF08\u9884\u7B97/\u8D39\u7528\u4E2D\u5FC3/\u501F\u6B3E\u7BA1\u7406/\u53D1\u7968\u6838\u9500\uFF09CLI",
|
|
84
|
-
load: async () => (await import("./chunks/fna-
|
|
86
|
+
load: async () => (await import("./chunks/fna-XBSNUS2V.js")).fnaShortcut
|
|
85
87
|
}),
|
|
86
88
|
lazyShortcut({
|
|
87
89
|
name: "hrm",
|
|
88
90
|
description: "\u6CDB\u5FAEE10\u7EC4\u7EC7\u7BA1\u7406\uFF08\u5458\u5DE5/\u7EC4\u7EC7/\u5C97\u4F4D\u67E5\u8BE2\uFF09CLI",
|
|
89
|
-
load: async () => (await import("./chunks/hrm-
|
|
91
|
+
load: async () => (await import("./chunks/hrm-FZUDJAND.js")).hrmShortcut
|
|
90
92
|
}),
|
|
91
93
|
lazyShortcut({
|
|
92
94
|
name: "mail",
|
|
93
95
|
description: "\u6CDB\u5FAEE10\u90AE\u4EF6\u7BA1\u7406 CLI",
|
|
94
|
-
load: async () => (await import("./chunks/mail-
|
|
96
|
+
load: async () => (await import("./chunks/mail-ZEOSANEJ.js")).mailShortcut
|
|
95
97
|
}),
|
|
96
98
|
lazyShortcut({
|
|
97
99
|
name: "meeting",
|
|
98
100
|
description: "\u6CDB\u5FAEE10\u4F1A\u8BAE\u7BA1\u7406 CLI\uFF08\u6807\u51C6\u7248\uFF1A\u67E5\u8BE2/\u51B2\u7A81/\u9884\u7EA6/\u56DE\u6267/\u7B7E\u5230\uFF09",
|
|
99
|
-
load: async () => (await import("./chunks/meeting-
|
|
101
|
+
load: async () => (await import("./chunks/meeting-PCD5EPBF.js")).meetingShortcut
|
|
100
102
|
}),
|
|
101
103
|
lazyShortcut({
|
|
102
104
|
name: "okr",
|
|
103
105
|
description: "\u6CDB\u5FAEE10 OKR \u76EE\u6807\u7BA1\u7406 CLI\uFF08\u76EE\u6807\u67E5\u8BE2/\u65B0\u5EFA/\u7F16\u8F91\u3001\u5173\u952E\u6210\u679C\u3001\u76EE\u6807\u5BF9\u9F50\u3001\u8BC4\u8BBA\uFF09",
|
|
104
|
-
load: async () => (await import("./chunks/okr-
|
|
106
|
+
load: async () => (await import("./chunks/okr-OZUMTMCL.js")).okrShortcut
|
|
105
107
|
}),
|
|
106
108
|
lazyShortcut({
|
|
107
109
|
name: "plan",
|
|
108
110
|
description: "\u6CDB\u5FAEE10\u8BA1\u5212\u62A5\u544A CLI\uFF08\u67E5\u8BE2/\u65B0\u5EFA/\u4FEE\u6539/\u53D1\u5E03/\u64A4\u56DE/\u63D0\u4EA4\u63D0\u9192/\u8BC4\u8BBA\uFF09",
|
|
109
|
-
load: async () => (await import("./chunks/plan-
|
|
111
|
+
load: async () => (await import("./chunks/plan-C2NENH42.js")).planShortcut
|
|
110
112
|
}),
|
|
111
113
|
lazyShortcut({
|
|
112
114
|
name: "esb",
|
|
113
115
|
description: "\u6CDB\u5FAEE10 ESB \u4E2D\u5FC3\u81EA\u5B9A\u4E49\u89E6\u53D1\u52A8\u4F5C\u6D41 CLI",
|
|
114
|
-
load: async () => (await import("./chunks/esb-
|
|
116
|
+
load: async () => (await import("./chunks/esb-GSB5QCEX.js")).esbShortcut
|
|
115
117
|
}),
|
|
116
118
|
lazyShortcut({
|
|
117
119
|
name: "ebuilder-form",
|
|
118
120
|
description: "\u6CDB\u5FAEE10 eBuilder \u8868\u5355\u83DC\u5355\u3001\u5217\u8868\u548C\u8868\u5355\u6570\u636E CLI",
|
|
119
|
-
load: async () => (await import("./chunks/ebuilder-form-
|
|
121
|
+
load: async () => (await import("./chunks/ebuilder-form-AWPTMZBZ.js")).ebuilderFormShortcut
|
|
120
122
|
}),
|
|
121
123
|
lazyShortcut({
|
|
122
124
|
name: "jiuchuanhui",
|
|
123
125
|
description: "\u6CDB\u5FAEE10\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406 CLI\uFF08\u5BA2\u6237/\u8054\u7CFB\u4EBA/\u5546\u673A/\u7EBF\u7D22/\u8054\u7CFB\u8BA1\u5212/\u516C\u6D77\uFF09",
|
|
124
|
-
load: async () => (await import("./chunks/jiuchuanhui-
|
|
126
|
+
load: async () => (await import("./chunks/jiuchuanhui-JCBUR563.js")).jiuchuanhuiShortcut
|
|
125
127
|
}),
|
|
126
128
|
lazyShortcut({
|
|
127
129
|
name: "asset",
|
|
128
130
|
description: "E10 \u8D44\u4EA7\u7BA1\u7406\uFF08\u8D44\u7BA1\u5BB6\uFF09CLI",
|
|
129
|
-
load: async () => (await import("./chunks/asset-
|
|
131
|
+
load: async () => (await import("./chunks/asset-45U6TY7I.js")).assetShortcut
|
|
130
132
|
}),
|
|
131
133
|
lazyShortcut({
|
|
132
134
|
name: "asset-idle",
|
|
133
135
|
description: "E10 \u95F2\u7F6E\u8D44\u4EA7\u5224\u5B9A\u7ED3\u679C\u67E5\u8BE2 CLI\uFF08\u5206\u9875\u83B7\u53D6/\u805A\u5408\u7EDF\u8BA1\uFF09",
|
|
134
|
-
load: async () => (await import("./chunks/asset-idle-
|
|
136
|
+
load: async () => (await import("./chunks/asset-idle-YCRBMTIT.js")).assetIdleShortcut
|
|
135
137
|
}),
|
|
136
138
|
lazyShortcut({
|
|
137
139
|
name: "im",
|
|
138
140
|
description: "\u6CDB\u5FAEE10\u6613\u79D2\u529E\uFF08\u5373\u65F6\u901A\u8BAF\uFF09CLI",
|
|
139
|
-
load: async () => (await import("./chunks/im-
|
|
141
|
+
load: async () => (await import("./chunks/im-F5NENPD7.js")).imShortcut
|
|
140
142
|
}),
|
|
141
143
|
lazyShortcut({
|
|
142
144
|
name: "project",
|
|
143
145
|
description: "\u6CDB\u5FAEE10\u4E8B\u4E95\u7136\u9879\u76EE\u7BA1\u7406 CLI\uFF08\u9879\u76EE/\u4EFB\u52A1\u67E5\u8BE2\u4E0E\u786E\u8BA4\u5199\u5165\uFF09",
|
|
144
|
-
load: async () => (await import("./chunks/project-
|
|
146
|
+
load: async () => (await import("./chunks/project-FAJ2P3UR.js")).projectShortcut
|
|
145
147
|
}),
|
|
146
148
|
lazyShortcut({
|
|
147
149
|
name: "workflow",
|
|
148
150
|
description: "\u6CDB\u5FAEE10\u6D41\u7A0B\u667A\u80FD\u52A9\u624B CLI\uFF08\u67E5\u8BE2/\u67E5\u770B/\u64CD\u4F5C/\u6279\u91CF/\u53D1\u8D77/\u4FEE\u6539\uFF09",
|
|
149
|
-
load: async () => (await import("./chunks/workflow-
|
|
151
|
+
load: async () => (await import("./chunks/workflow-OWHWLAOX.js")).workflowShortcut
|
|
150
152
|
}),
|
|
151
153
|
lazyShortcut({
|
|
152
154
|
name: "blog",
|
|
153
155
|
description: "\u6CDB\u5FAEE10\u5DE5\u4F5C\u65E5\u62A5 CLI\uFF08\u67E5\u8BE2/\u53D1\u5E03/\u7F16\u8F91/\u8BC4\u8BBA/\u70B9\u8D5E/\u63D0\u9192/\u5BFC\u51FA\uFF09",
|
|
154
|
-
load: async () => (await import("./chunks/blog-
|
|
156
|
+
load: async () => (await import("./chunks/blog-5AML4WMG.js")).blogShortcut
|
|
155
157
|
}),
|
|
156
158
|
lazyShortcut({
|
|
157
159
|
name: "caizhilian",
|
|
158
160
|
description: "\u6CDB\u5FAEE10\u91C7\u77E5\u8FDE\uFF08\u6587\u6863\u4E2D\u5FC3\uFF09CLI",
|
|
159
|
-
load: async () => (await import("./chunks/caizhilian-
|
|
161
|
+
load: async () => (await import("./chunks/caizhilian-3P7BUNHT.js")).caizhilianShortcut
|
|
160
162
|
}),
|
|
161
163
|
lazyShortcut({
|
|
162
164
|
name: "contract",
|
|
163
165
|
description: "\u6CDB\u5FAEE10\u4ECA\u627F\u8FBE\u5408\u540C\u7BA1\u7406 CLI",
|
|
164
|
-
load: async () => (await import("./chunks/contract-
|
|
166
|
+
load: async () => (await import("./chunks/contract-3PMHUASH.js")).contractShortcut
|
|
165
167
|
}),
|
|
166
168
|
lazyShortcut({
|
|
167
169
|
name: "reception",
|
|
168
170
|
description: "\u6CDB\u5FAE\u5BA2\u6237\u53C2\u89C2\u63A5\u5F85\u6D41\u7A0B CLI\uFF08\u9762\u677F/\u884C\u7A0B\u5355\u4E0E\u5185\u90E8\u65B9\u6848/\u586B\u5355\u9875\u9884\u586B\uFF09",
|
|
169
|
-
load: async () => (await import("./chunks/reception-
|
|
171
|
+
load: async () => (await import("./chunks/reception-NH6MJFPR.js")).receptionShortcut
|
|
170
172
|
}),
|
|
171
173
|
lazyShortcut({
|
|
172
174
|
name: "smart-extract",
|
|
173
175
|
description: "\u6CDB\u5FAEE10\u667A\u80FD\u62BD\u53D6 CLI\uFF08\u8868\u5355\u7ED3\u6784 / \u9644\u4EF6\u6B63\u6587 / \u6821\u9A8C\u5E76\u843D\u5E93\uFF0C\u8FD4\u56DE aiExtraId\uFF09",
|
|
174
|
-
load: async () => (await import("./chunks/smart-extract-
|
|
176
|
+
load: async () => (await import("./chunks/smart-extract-GTYKF5TJ.js")).smartExtractShortcut
|
|
175
177
|
}),
|
|
176
178
|
lazyShortcut({
|
|
177
179
|
name: "data",
|
|
178
180
|
description: "\u6CDB\u5FAEE10\u6570\u636E\u52A9\u624B CLI\uFF08\u6570\u636E\u6E90\u67E5\u8BE2 / \u914D\u7F6E\u4E2D\u5FC3 / \u573A\u666F\u5B9A\u4F4D\uFF09",
|
|
179
|
-
load: async () => (await import("./chunks/data-
|
|
181
|
+
load: async () => (await import("./chunks/data-2YZ6A6TL.js")).dataShortcut
|
|
180
182
|
})
|
|
181
183
|
];
|
|
182
184
|
function shortcutMetadata() {
|
|
@@ -192,6 +194,7 @@ async function loadAllShortcuts() {
|
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
// src/index.ts
|
|
197
|
+
applyE10TlsPolicy();
|
|
195
198
|
var BUILTIN_NAMES = new Set(builtinCommands.map((command) => command.name));
|
|
196
199
|
async function selectShortcuts(wanted) {
|
|
197
200
|
if (!wanted) return builtinShortcuts;
|
|
@@ -1038,12 +1038,23 @@ function formatWhoami(title, data) {
|
|
|
1038
1038
|
'User-Agent: ' + (data.userAgent || ''),
|
|
1039
1039
|
].join('\n');
|
|
1040
1040
|
}
|
|
1041
|
+
function formatTlsPolicy(tls) {
|
|
1042
|
+
return [
|
|
1043
|
+
`mode=${tls.mode}`,
|
|
1044
|
+
`applied=${tls.applied}`,
|
|
1045
|
+
...(tls.caFiles.length ? [`caFiles=${tls.caFiles.join(',')}`] : []),
|
|
1046
|
+
...(tls.notAppliedReason ? [`notAppliedReason=${tls.notAppliedReason}`] : []),
|
|
1047
|
+
...(tls.insecureSource ? [`insecureSource=${tls.insecureSource}`] : []),
|
|
1048
|
+
...(tls.error ? [`error=${tls.error}`] : []),
|
|
1049
|
+
].join(' ');
|
|
1050
|
+
}
|
|
1041
1051
|
function formatXiaoEAuthErrorLogEntry(entry) {
|
|
1042
1052
|
const lines = [
|
|
1043
1053
|
`[${entry.timestamp}] ${entry.source} id=${entry.id}`,
|
|
1044
1054
|
...(entry.profile ? [`profile: ${entry.profile}`] : []),
|
|
1045
1055
|
...(entry.baseUrl ? [`baseUrl: ${entry.baseUrl}`] : []),
|
|
1046
1056
|
...(entry.clientType ? [`clientType: ${entry.clientType}`] : []),
|
|
1057
|
+
...(entry.tls ? [`tls: ${formatTlsPolicy(entry.tls)}`] : []),
|
|
1047
1058
|
...(entry.attemptedSteps.length ? [`attemptedSteps: ${entry.attemptedSteps.join(', ')}`] : []),
|
|
1048
1059
|
...(entry.lastError ? [`lastError: ${entry.lastError}`] : []),
|
|
1049
1060
|
...(entry.resultSessionExpired ? ['resultSessionExpired: true'] : []),
|
|
@@ -198,6 +198,17 @@ function sanitizeError(error, secrets) {
|
|
|
198
198
|
...(envelope.details === undefined ? {} : { details: '<omitted from persistent auth log>' }),
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
+
function sanitizeTlsPolicy(tls, secrets) {
|
|
202
|
+
const caFiles = tls.caFiles.map((file) => redactSensitiveText(file, secrets));
|
|
203
|
+
return {
|
|
204
|
+
mode: tls.mode,
|
|
205
|
+
caFiles,
|
|
206
|
+
applied: tls.applied,
|
|
207
|
+
...(tls.notAppliedReason ? { notAppliedReason: tls.notAppliedReason } : {}),
|
|
208
|
+
...(tls.error ? { error: redactSensitiveText(tls.error, secrets) } : {}),
|
|
209
|
+
...(tls.insecureSource ? { insecureSource: tls.insecureSource } : {}),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
201
212
|
function createEntry(input) {
|
|
202
213
|
const secrets = input.secrets || [];
|
|
203
214
|
const diagnostics = input.diagnostics;
|
|
@@ -206,6 +217,7 @@ function createEntry(input) {
|
|
|
206
217
|
? redactSensitiveText(diagnostics.lastError, secrets)
|
|
207
218
|
: undefined;
|
|
208
219
|
const failures = diagnostics?.failures?.map((failure) => sanitizeFailure(failure, secrets));
|
|
220
|
+
const tls = diagnostics?.tls ? sanitizeTlsPolicy(diagnostics.tls, secrets) : undefined;
|
|
209
221
|
const error = sanitizeError(input.error, secrets);
|
|
210
222
|
return {
|
|
211
223
|
schemaVersion: 1,
|
|
@@ -221,6 +233,7 @@ function createEntry(input) {
|
|
|
221
233
|
attemptedSteps: (diagnostics?.attemptedSteps || []).map((step) => redactSensitiveText(step, secrets)),
|
|
222
234
|
...(lastError ? { lastError } : {}),
|
|
223
235
|
...(failures?.length ? { failures } : {}),
|
|
236
|
+
...(tls ? { tls } : {}),
|
|
224
237
|
...(input.resultSessionExpired ? { resultSessionExpired: true } : {}),
|
|
225
238
|
...(error ? { error } : {}),
|
|
226
239
|
};
|
|
@@ -7,4 +7,14 @@ export const E10_XIAOE_HOST_CREDENTIAL_MISSING_MESSAGE = 'E10 登录态不可用
|
|
|
7
7
|
* 重新登录是误导——该做的是稍后重试。
|
|
8
8
|
*/
|
|
9
9
|
export const E10_XIAOE_NETWORK_UNAVAILABLE_MESSAGE = '暂时无法连接 E10,请稍后重试';
|
|
10
|
+
/**
|
|
11
|
+
* 网关证书不受信任的文案。这类错误也在「网络层没打通」里,但重试永远不会成功,
|
|
12
|
+
* 所以单独给一条可操作的出口,并说明为什么 CLI 不默认关掉校验。
|
|
13
|
+
*/
|
|
14
|
+
export const E10_XIAOE_TLS_UNTRUSTED_MESSAGE = 'E10 网关证书不受信任(自签名或私有 CA 签发的证书链),自动获取登录信息已停止。'
|
|
15
|
+
+ '请把网关 CA 证书(PEM)交给 CLI:设置 WEAVER_E10_CA_FILE=<CA PEM 路径> 后重试;'
|
|
16
|
+
+ 'Node 低于 22.15 时该变量无法在运行时生效,请改用 NODE_EXTRA_CA_CERTS=<CA PEM 路径> 启动 CLI。'
|
|
17
|
+
+ '仅在排查「是不是证书问题」时可显式设置 WEAVER_E10_TLS_INSECURE=1 临时跳过校验'
|
|
18
|
+
+ '(会关闭本进程全部证书校验,换票请求携带的平台票据可能被截获,确认后立刻去掉)。'
|
|
19
|
+
+ 'CLI 不会默认关闭证书校验。';
|
|
10
20
|
export const E10_SESSION_EXPIRED_MESSAGE = `E10 登录态已失效,本次操作已停止。${E10_REAUTH_GUIDANCE}`;
|
|
@@ -8,6 +8,7 @@ import { isXiaoERuntime, isXiaoERuntimeAgent } from '../../../core/runtime-agent
|
|
|
8
8
|
import { createTimeoutSignal, isAbortError, isNetworkErrorCode, looksLikeTransportMessage, readErrorCauseCode, } from '../network-error.js';
|
|
9
9
|
import { buildE10CookieHeader, E10_TEAMS_CHECK_TIMEOUT_MS, E10AuthSession, extractRawSetCookie, extractSessionTicket, profileNameFromUrl, readTeamsCheckUserInfo, saveAuthFile, saveProfileConfig, setActiveProfile, } from './session.js';
|
|
10
10
|
import { resolveLoginProfileName, upsertAgentHost } from './agent-hosts.js';
|
|
11
|
+
import { applyE10TlsPolicy, e10TlsChildEnv, summarizeE10TlsPolicy, } from '../tls-policy.js';
|
|
11
12
|
/**
|
|
12
13
|
* 通用登录(非 XiaoE 宿主)默认使用的 E10 域名。
|
|
13
14
|
* 登录、ETEAMSID 落盘与会话恢复在调用方没有显式指定域名时都走这里。
|
|
@@ -784,7 +785,9 @@ async function runXiaoETokenScriptOnce(pythonCommand, scriptPath, baseUrl, env)
|
|
|
784
785
|
].join('\n');
|
|
785
786
|
return await new Promise((resolve, reject) => {
|
|
786
787
|
execFile(pythonCommand, ['-c', wrapper], {
|
|
787
|
-
|
|
788
|
+
// Python 只认自己的信任链:把 CLI 里的 CA 配置翻译成它能读的变量,
|
|
789
|
+
// 否则同一个网关会呈现「Node 通了、脚本还在报自签名」的分裂状态。
|
|
790
|
+
env: e10TlsChildEnv(env),
|
|
788
791
|
timeout: XIAOE_TOKEN_SCRIPT_TIMEOUT_MS,
|
|
789
792
|
maxBuffer: 1024 * 1024,
|
|
790
793
|
}, (error, stdout, stderr) => {
|
|
@@ -1235,7 +1238,10 @@ async function resolveUserInfo(baseUrl, eteamsId, rawCookie = '', agentType = ''
|
|
|
1235
1238
|
throw error;
|
|
1236
1239
|
const causeCode = readErrorCauseCode(error);
|
|
1237
1240
|
const message = error instanceof Error ? error.message : String(error);
|
|
1238
|
-
|
|
1241
|
+
// undici 只给一句 `fetch failed`,真正原因(自签名证书、DNS、拒绝连接)都在
|
|
1242
|
+
// `cause` 链上。只留 `causeCode` 不够:证书类错误往往没有 errno,只有文案。
|
|
1243
|
+
const detail = xiaoEErrorChainDetail(error, []) || message;
|
|
1244
|
+
throw tagXiaoEError(`E10 teamsCheck request failed${causeCode ? ` (${causeCode})` : ''}: ${detail}`, { errorKind: 'network', stage: 'teams_check', ...(causeCode ? { causeCode } : {}) });
|
|
1239
1245
|
}
|
|
1240
1246
|
finally {
|
|
1241
1247
|
clear();
|
|
@@ -1316,6 +1322,9 @@ async function saveXiaoEUnifiedLogin(input) {
|
|
|
1316
1322
|
}
|
|
1317
1323
|
export async function tryXiaoEUnifiedLogin(options = {}) {
|
|
1318
1324
|
const env = options.env || process.env;
|
|
1325
|
+
// 必须在任何换票请求之前生效:`setDefaultCACertificates` 只影响之后创建的
|
|
1326
|
+
// TLS 上下文,晚一步注入,本次登录仍然会撞自签名证书。
|
|
1327
|
+
const tlsPolicy = applyE10TlsPolicy(env);
|
|
1319
1328
|
const explicitBaseUrl = normalizeUrl(options.baseUrl || '');
|
|
1320
1329
|
const baseUrl = resolveXiaoEPreferredBaseUrl({
|
|
1321
1330
|
explicitBaseUrl,
|
|
@@ -1332,6 +1341,7 @@ export async function tryXiaoEUnifiedLogin(options = {}) {
|
|
|
1332
1341
|
diagnostics.baseUrl = baseUrl;
|
|
1333
1342
|
diagnostics.platformCredentialDetected = platformCredentialDetected;
|
|
1334
1343
|
diagnostics.clientType = resolveXiaoEClientType(env);
|
|
1344
|
+
diagnostics.tls = summarizeE10TlsPolicy(tlsPolicy);
|
|
1335
1345
|
}
|
|
1336
1346
|
if (!baseUrl && !mayUseTokenScript) {
|
|
1337
1347
|
noteXiaoEStep(diagnostics, 'base_url:missing');
|