weaver-work-cli 0.1.44 → 0.1.45

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.
Files changed (179) hide show
  1. package/README.md +9 -5
  2. package/dist/chunks/{archive-P6TBQGKL.js → archive-ZQ4A4TV6.js} +388 -44
  3. package/dist/chunks/{archive-oa-7TQ2NXOH.js → archive-oa-BBDP7AKJ.js} +2 -2
  4. package/dist/chunks/{asset-3ELRG37G.js → asset-ZOJVBWZH.js} +2 -2
  5. package/dist/chunks/{asset-idle-WIGMUFMD.js → asset-idle-XGB5IPGT.js} +2 -2
  6. package/dist/chunks/{attachment-content-E3276UOV.js → attachment-content-CE3GMWTS.js} +3 -3
  7. package/dist/chunks/{blog-C5NMZAAC.js → blog-QSHLZSFW.js} +2 -2
  8. package/dist/chunks/caizhilian-KCQYFH72.js +204 -0
  9. package/dist/chunks/{calendar-FI2WNSBO.js → calendar-DLGMRJQA.js} +2 -2
  10. package/dist/chunks/{chunk-CWYGFU5B.js → chunk-3WBIQLMB.js} +2 -2
  11. package/dist/chunks/{chunk-PUQS5MWL.js → chunk-3YV7PKRL.js} +1 -1
  12. package/dist/chunks/{chunk-PC7VKEB5.js → chunk-3ZMAQQ3W.js} +161 -33
  13. package/dist/chunks/{chunk-GM6J7Q4B.js → chunk-4EXOIQDI.js} +40 -10
  14. package/dist/chunks/{chunk-ETNJSKMM.js → chunk-6NXT4ICB.js} +148 -21
  15. package/dist/chunks/chunk-762M5XJS.js +215 -0
  16. package/dist/chunks/{chunk-GAMZLAG2.js → chunk-77YP6I52.js} +1 -1
  17. package/dist/chunks/{chunk-WSF4NNMR.js → chunk-CZNZKOHR.js} +2 -2
  18. package/dist/chunks/{chunk-Z7VYWPZV.js → chunk-DGMYACGJ.js} +1 -1
  19. package/dist/chunks/{chunk-TA7FXXJD.js → chunk-DLY5GUXX.js} +1 -1
  20. package/dist/chunks/{chunk-BCVYBYYT.js → chunk-GR76ZDDX.js} +2 -2
  21. package/dist/chunks/{chunk-GRDRG6HP.js → chunk-HFXK54M4.js} +2 -2
  22. package/dist/chunks/{chunk-XNIK66I4.js → chunk-JB34OE7R.js} +790 -77
  23. package/dist/chunks/{chunk-QVSWRLLU.js → chunk-JWWTI63L.js} +55 -5
  24. package/dist/chunks/{chunk-FRZKBMSW.js → chunk-LGKWL4OH.js} +176 -39
  25. package/dist/chunks/{chunk-XHK4MDR5.js → chunk-LRCPNDZA.js} +38 -6
  26. package/dist/chunks/{chunk-OF4S23UB.js → chunk-LXFVWZLM.js} +4 -4
  27. package/dist/chunks/{chunk-D4ADSZ7H.js → chunk-O6CMPO65.js} +24 -1
  28. package/dist/chunks/{chunk-N4M2DDFE.js → chunk-OAE3AZBQ.js} +11 -11
  29. package/dist/chunks/chunk-P5GQRWDC.js +60 -0
  30. package/dist/chunks/{caizhilian-5XSM2DFP.js → chunk-PGO4ILMQ.js} +41 -521
  31. package/dist/chunks/{chunk-HIT4Y6OI.js → chunk-T4MWQAQB.js} +7 -5
  32. package/dist/chunks/{chunk-F4E4EM35.js → chunk-TGAGQV4I.js} +2 -2
  33. package/dist/chunks/{chunk-UFIT2UU3.js → chunk-U6R6FZHD.js} +168 -14
  34. package/dist/chunks/{chunk-FAZTGX7S.js → chunk-VIMCY4DI.js} +5 -5
  35. package/dist/chunks/chunk-VRPH24IC.js +76 -0
  36. package/dist/chunks/{chunk-3YBDYOC4.js → chunk-YIKSL36S.js} +2 -2
  37. package/dist/chunks/{chunk-IAZ3UPY6.js → chunk-Z6UUBY37.js} +2 -2
  38. package/dist/chunks/{conflict-ARLSZJ6V.js → conflict-IYJETSGT.js} +2 -2
  39. package/dist/chunks/continuation-GW6PRWK3.js +12 -0
  40. package/dist/chunks/{contract-DNIIW5VJ.js → contract-3QLAGYQL.js} +5793 -4591
  41. package/dist/chunks/{cowork-GMLRGVIW.js → cowork-3ACICHDQ.js} +2 -2
  42. package/dist/chunks/{create-flow-J22BO65E.js → create-flow-7JLC7UID.js} +6 -6
  43. package/dist/chunks/{ebuilder-form-ANV2FHYV.js → ebuilder-form-GWDTKEI2.js} +5 -5
  44. package/dist/chunks/{ehr-GSTGAIY3.js → ehr-MYRDCHZ4.js} +121 -49
  45. package/dist/chunks/{employee-22BGJ3QS.js → employee-NOHNXC46.js} +1 -1
  46. package/dist/chunks/{env-BX3VRFS7.js → env-3MBHAWBL.js} +2 -2
  47. package/dist/chunks/{esb-ATAIASX2.js → esb-4BQHNP5C.js} +4 -4
  48. package/dist/chunks/{factory-PETTFME6.js → factory-TZEVU4DU.js} +1 -1
  49. package/dist/chunks/{fna-YEKBSFSX.js → fna-ZVB2IILI.js} +2 -2
  50. package/dist/chunks/{group-chat-BFVXAYFX.js → group-chat-KL3HFKRM.js} +3 -3
  51. package/dist/chunks/{host-WIKN2EJ5.js → host-3TNBMDTR.js} +3 -3
  52. package/dist/chunks/host-7NTIBSPK.js +25 -0
  53. package/dist/chunks/{host-SZGV4UNT.js → host-7OWWPLM4.js} +3 -3
  54. package/dist/chunks/{host-HRBXEPDQ.js → host-G3VU7SDW.js} +3 -3
  55. package/dist/chunks/{host-LR55CTHP.js → host-M4XP5URR.js} +3 -3
  56. package/dist/chunks/{host-SUOY6VYQ.js → host-TUOIOEMC.js} +3 -3
  57. package/dist/chunks/{hrm-NRDO4W5G.js → hrm-UNKCCCGP.js} +5 -5
  58. package/dist/chunks/{im-IQ2HN23S.js → im-NJB7ZYMH.js} +3 -3
  59. package/dist/chunks/{invoice-MNRW76PP.js → invoice-OQP3TMKQ.js} +3 -3
  60. package/dist/chunks/{jiuchuanhui-DTRBAX4N.js → jiuchuanhui-ASFZBMPU.js} +2 -2
  61. package/dist/chunks/{lazy-dispatch-ZVWAI25B.js → lazy-dispatch-UH6HGK2I.js} +4 -4
  62. package/dist/chunks/{mail-ZVAUXOJA.js → mail-M3HJF5ER.js} +2 -2
  63. package/dist/chunks/{meeting-FEVPZ67S.js → meeting-C67EHQ4Z.js} +12 -12
  64. package/dist/chunks/{okr-SDH3E5RA.js → okr-EVX7FB5G.js} +2 -2
  65. package/dist/chunks/operations-J7PUIVWZ.js +15 -0
  66. package/dist/chunks/{plan-E35JFDI7.js → plan-2QJQEPBO.js} +2 -2
  67. package/dist/chunks/{project-73QXBAB2.js → project-XELELW2T.js} +2 -2
  68. package/dist/chunks/{reception-UWZVACBN.js → reception-5WITA44R.js} +2 -2
  69. package/dist/chunks/{recruit-stage-4MAOCKFY.js → recruit-stage-AHY5QAMF.js} +450 -117
  70. package/dist/chunks/{registry-JDUS4E7D.js → registry-AQVGHUM6.js} +2 -2
  71. package/dist/chunks/{registry-KNKSCJNT.js → registry-QJCZ2GVG.js} +4 -4
  72. package/dist/chunks/{registry-PO7SI256.js → registry-VWXWPVAG.js} +2 -2
  73. package/dist/chunks/{registry-IM5G23LS.js → registry-XPWPGHYE.js} +10 -10
  74. package/dist/chunks/{room-recommend-H7KLXA5R.js → room-recommend-CNWE5WQK.js} +6 -4
  75. package/dist/chunks/{schedule-ESZIBAUO.js → schedule-YYNYBQIE.js} +4 -4
  76. package/dist/chunks/{workflow-CWJFJLQU.js → workflow-BSYT5TGL.js} +6 -4
  77. package/dist/index.js +30 -30
  78. package/dist/internal/e10/auth/commands.js +32 -0
  79. package/dist/internal/e10/auth/error-log.js +156 -26
  80. package/dist/internal/e10/auth/xiaoe.js +176 -13
  81. package/dist/internal/e10/context.js +12 -1
  82. package/dist/shortcuts/archive/operations/borrow-list.js +105 -14
  83. package/dist/shortcuts/archive/operations/flow-url.js +182 -22
  84. package/dist/shortcuts/archive/operations/getPageUrl.js +75 -0
  85. package/dist/shortcuts/archive/operations/prelib.js +33 -4
  86. package/dist/shortcuts/archive/operations/shared.js +52 -0
  87. package/dist/shortcuts/contract/host.js +111 -4
  88. package/dist/shortcuts/contract/index.js +19 -0
  89. package/dist/shortcuts/contract/manifest.js +125 -0
  90. package/dist/shortcuts/contract/ooxml/clause-insert.js +249 -0
  91. package/dist/shortcuts/contract/operations/clause-insert.js +56 -0
  92. package/dist/shortcuts/contract/operations/customer.js +192 -0
  93. package/dist/shortcuts/contract/operations/file-download.js +75 -0
  94. package/dist/shortcuts/contract/operations/flow.js +44 -2
  95. package/dist/shortcuts/contract/operations/form-info.js +162 -62
  96. package/dist/shortcuts/contract/operations/registry.js +8 -0
  97. package/dist/shortcuts/contract/operations/review.js +116 -1
  98. package/dist/shortcuts/contract/operations/summary.js +177 -0
  99. package/dist/shortcuts/contract/operations/upload.js +64 -4
  100. package/dist/shortcuts/contract/upload-cache.js +104 -0
  101. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +4 -2
  102. package/dist/shortcuts/ehr/operations/recruit-position.js +136 -35
  103. package/dist/shortcuts/ehr/operations/recruit-write.js +17 -18
  104. package/dist/shortcuts/ehr/operations/recruit.js +17 -5
  105. package/dist/shortcuts/hrm/operations/employee.js +29 -1
  106. package/dist/shortcuts/meeting/operations/eb/create-flow.js +182 -58
  107. package/dist/shortcuts/meeting/operations/eb/draft-memory.js +56 -0
  108. package/dist/shortcuts/meeting/operations/eb/factory.js +58 -3
  109. package/dist/shortcuts/meeting/operations/eb/person-cache.js +2 -2
  110. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +47 -5
  111. package/dist/shortcuts/meeting/operations/invitation-publish.js +132 -0
  112. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  113. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +86 -16
  114. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +6 -4
  115. package/dist/shortcuts/recruit-stage/operations/jd-create.js +208 -56
  116. package/dist/shortcuts/recruit-stage/operations/resume-import.js +42 -16
  117. package/dist/shortcuts/recruit-stage/shared.js +161 -18
  118. package/dist/shortcuts/workflow/index.js +2 -0
  119. package/dist/shortcuts/workflow/operations/read.js +8 -3
  120. package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +92 -5
  121. package/dist/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.js +509 -0
  122. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +22 -1
  123. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +32 -6
  124. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +57 -11
  125. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +165 -52
  126. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +57 -14
  127. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +44 -18
  128. package/docs/contract.md +1 -0
  129. package/docs/e10-auth.md +4 -2
  130. package/docs/todo-smart-convert/data-contract.md +7 -0
  131. package/package.json +1 -1
  132. package/skill-template/domains/jinchengda.md +2 -0
  133. package/skills/weaver-e10-jinchengda/SKILL.md +198 -205
  134. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +759 -0
  135. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +250 -0
  136. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +146 -7
  137. package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +178 -0
  138. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +75 -0
  139. package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +137 -0
  140. package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +163 -0
  141. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +52 -3
  142. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +92 -5
  143. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +602 -0
  144. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +209 -0
  145. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +126 -0
  146. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +312 -0
  147. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +555 -0
  148. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +47 -12
  149. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +469 -0
  150. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +154 -1
  151. package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +224 -0
  152. package/skills/weaver-e10-jinchengda/references/orchestration.md +355 -0
  153. package/skills/weaver-e10-jucailin/references/recruit-create.md +5 -3
  154. package/skills/weaver-e10-jucailin/references/recruit-write.md +2 -2
  155. package/skills/weaver-e10-meeting/SKILL.md +57 -9
  156. package/skills/weaver-e10-recruit-stage/SKILL.md +11 -6
  157. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +10 -2
  158. package/skills/weaver-e10-recruit-stage/references/position-templates.md +3 -1
  159. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +13 -1
  160. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +19 -18
  161. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +27 -14
  162. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +7 -1
  163. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
  164. package/skills/weaver-e10-wenshuding/SKILL.md +17 -7
  165. package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +28 -0
  166. package/skills/weaver-e10-wenshuding/references/archive-flow.md +24 -8
  167. package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +3 -0
  168. package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +4 -0
  169. package/skills/weaver-e10-wenshuding/references/archive-search.md +3 -1
  170. package/skills/weaver-e10-workflow/SKILL.md +19 -17
  171. package/skills/weaver-e10-workflow/aigroup/default.json +10 -6
  172. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +36 -3
  173. package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
  174. package/skills/weaver-e10-workflow/references/workflow-query.md +9 -6
  175. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +152 -1
  176. package/skills/weaver-e10-yimiaoban/SKILL.md +17 -5
  177. package/skills/weaver-e10-yimiaoban/references/msg-write.md +30 -0
  178. package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +72 -0
  179. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
@@ -17,7 +17,7 @@ import {
17
17
  startFetchTiming,
18
18
  summarizeXiaoEFailureKind,
19
19
  tryXiaoEUnifiedLogin
20
- } from "./chunk-UFIT2UU3.js";
20
+ } from "./chunk-U6R6FZHD.js";
21
21
  import {
22
22
  CliError,
23
23
  toErrorEnvelope
@@ -25,14 +25,101 @@ import {
25
25
 
26
26
  // src/internal/e10/auth/error-log.ts
27
27
  import { randomUUID } from "node:crypto";
28
- import { appendFile, chmod, mkdir, readFile, unlink } from "node:fs/promises";
28
+ import { appendFile, chmod, mkdir, readFile, rmdir, stat, unlink, writeFile } from "node:fs/promises";
29
29
  import { dirname, resolve } from "node:path";
30
30
  var XIAOE_AUTH_ERROR_LOG_NAME = "xiaoe-auth-errors.ndjson";
31
31
  var DEFAULT_LOG_LIMIT = 50;
32
+ var XIAOE_AUTH_ERROR_LOG_LOCK_SUFFIX = ".lock";
33
+ var XIAOE_AUTH_ERROR_LOG_LOCK_RETRY_MS = 25;
34
+ var XIAOE_AUTH_ERROR_LOG_LOCK_TIMEOUT_MS = 5e3;
35
+ var XIAOE_AUTH_ERROR_LOG_STALE_LOCK_MS = 3e4;
32
36
  var MAX_XIAOE_AUTH_ERROR_LOG_LIMIT = 500;
37
+ var XIAOE_AUTH_ERROR_LOG_RETENTION_DAYS = 15;
38
+ var XIAOE_AUTH_ERROR_LOG_RETENTION_MS = XIAOE_AUTH_ERROR_LOG_RETENTION_DAYS * 24 * 60 * 60 * 1e3;
33
39
  function getXiaoEAuthErrorLogPath() {
34
40
  return resolve(getE10AuthRoot(), "logs", XIAOE_AUTH_ERROR_LOG_NAME);
35
41
  }
42
+ function waitForXiaoEAuthLogLock() {
43
+ return new Promise((resolveWait) => setTimeout(resolveWait, XIAOE_AUTH_ERROR_LOG_LOCK_RETRY_MS));
44
+ }
45
+ async function acquireXiaoEAuthLogLock(path) {
46
+ const lockPath = `${path}${XIAOE_AUTH_ERROR_LOG_LOCK_SUFFIX}`;
47
+ const startedAt = Date.now();
48
+ for (; ; ) {
49
+ try {
50
+ await mkdir(lockPath, { mode: 448 });
51
+ return async () => {
52
+ await rmdir(lockPath).catch((error) => {
53
+ if (error?.code !== "ENOENT") throw error;
54
+ });
55
+ };
56
+ } catch (error) {
57
+ if (error?.code !== "EEXIST") throw error;
58
+ }
59
+ try {
60
+ const lockStat = await stat(lockPath);
61
+ if (Date.now() - lockStat.mtimeMs > XIAOE_AUTH_ERROR_LOG_STALE_LOCK_MS) {
62
+ await rmdir(lockPath);
63
+ continue;
64
+ }
65
+ } catch (error) {
66
+ if (error?.code === "ENOENT") continue;
67
+ throw error;
68
+ }
69
+ if (Date.now() - startedAt >= XIAOE_AUTH_ERROR_LOG_LOCK_TIMEOUT_MS) {
70
+ throw new Error(`Timed out waiting for XiaoE auth error log lock: ${lockPath}`);
71
+ }
72
+ await waitForXiaoEAuthLogLock();
73
+ }
74
+ }
75
+ async function withXiaoEAuthLogLock(path, action) {
76
+ await mkdir(dirname(path), { recursive: true, mode: 448 });
77
+ await chmod(dirname(path), 448).catch(() => void 0);
78
+ const release = await acquireXiaoEAuthLogLock(path);
79
+ try {
80
+ return await action();
81
+ } finally {
82
+ await release();
83
+ }
84
+ }
85
+ async function readXiaoEAuthErrorLogContent(path) {
86
+ try {
87
+ return await readFile(path, "utf8");
88
+ } catch (error) {
89
+ if (error?.code === "ENOENT") return "";
90
+ throw error;
91
+ }
92
+ }
93
+ function pruneExpiredXiaoEAuthErrorLogContent(content, now = Date.now()) {
94
+ const cutoff = now - XIAOE_AUTH_ERROR_LOG_RETENTION_MS;
95
+ const keptLines = [];
96
+ let expiredRemoved = 0;
97
+ for (const line of content.split(/\r?\n/u)) {
98
+ if (!line.trim()) continue;
99
+ try {
100
+ const value = JSON.parse(line);
101
+ if (isLogEntry(value)) {
102
+ const timestamp = Date.parse(value.timestamp);
103
+ if (Number.isFinite(timestamp) && timestamp < cutoff) {
104
+ expiredRemoved += 1;
105
+ continue;
106
+ }
107
+ }
108
+ } catch {
109
+ }
110
+ keptLines.push(line);
111
+ }
112
+ return {
113
+ content: keptLines.length ? `${keptLines.join("\n")}
114
+ ` : "",
115
+ expiredRemoved
116
+ };
117
+ }
118
+ async function persistPrunedXiaoEAuthErrorLog(path, content, expiredRemoved) {
119
+ if (!expiredRemoved) return;
120
+ await writeFile(path, content, { encoding: "utf8", mode: 384 });
121
+ await chmod(path, 384).catch(() => void 0);
122
+ }
36
123
  function xiaoEAuthLogSecrets(env) {
37
124
  return Object.entries(env).filter(([key, value]) => Boolean(
38
125
  value && (key.startsWith("XIAOE_") || key.startsWith("WEAVER_XIAOE_")) && /(?:TOKEN|AUTH|ETEAMSID|COOKIE|SESSION|SECRET|PASSWORD)/iu.test(key)
@@ -70,7 +157,31 @@ function sanitizeFailure(failure, secrets) {
70
157
  kind: failure.kind,
71
158
  message: redactSensitiveText(failure.message, secrets),
72
159
  ...failure.causeCode ? { causeCode: redactSensitiveText(failure.causeCode, secrets) } : {},
73
- ...failure.httpStatus === void 0 ? {} : { httpStatus: failure.httpStatus }
160
+ ...failure.httpStatus === void 0 ? {} : { httpStatus: failure.httpStatus },
161
+ ...failure.request ? { request: sanitizeExchangeRequest(failure.request, secrets) } : {}
162
+ };
163
+ }
164
+ function sanitizeExchangeRequest(request, secrets) {
165
+ const endpoint = sanitizeBaseUrl(request.endpoint, secrets) || redactSensitiveText(request.endpoint, secrets);
166
+ const finalEndpoint = request.finalEndpoint ? sanitizeBaseUrl(request.finalEndpoint, secrets) || redactSensitiveText(request.finalEndpoint, secrets) : void 0;
167
+ const domain = sanitizeBaseUrl(request.body.domain, secrets) || redactSensitiveText(request.body.domain, secrets);
168
+ return {
169
+ transport: request.transport,
170
+ method: "POST",
171
+ endpoint,
172
+ ...finalEndpoint && finalEndpoint !== endpoint ? { finalEndpoint } : {},
173
+ redirect: request.redirect,
174
+ headers: {
175
+ "content-type": "application/json",
176
+ authorization: "<redacted>"
177
+ },
178
+ authorizationPresent: request.authorizationPresent,
179
+ authorizationLength: request.authorizationLength,
180
+ body: { domain },
181
+ bodyBytes: request.bodyBytes,
182
+ timeoutMs: request.timeoutMs,
183
+ elapsedMs: request.elapsedMs,
184
+ ...request.redirectCount ? { redirectCount: request.redirectCount } : {}
74
185
  };
75
186
  }
76
187
  function sanitizeError(error, secrets) {
@@ -109,12 +220,15 @@ function createEntry(input) {
109
220
  }
110
221
  async function appendXiaoEAuthErrorLog(input) {
111
222
  const path = getXiaoEAuthErrorLogPath();
112
- await mkdir(dirname(path), { recursive: true, mode: 448 });
113
- await chmod(dirname(path), 448).catch(() => void 0);
114
223
  const entry = createEntry(input);
115
- await appendFile(path, `${JSON.stringify(entry)}
224
+ await withXiaoEAuthLogLock(path, async () => {
225
+ const current = await readXiaoEAuthErrorLogContent(path);
226
+ const pruned = pruneExpiredXiaoEAuthErrorLogContent(current);
227
+ await persistPrunedXiaoEAuthErrorLog(path, pruned.content, pruned.expiredRemoved);
228
+ await appendFile(path, `${JSON.stringify(entry)}
116
229
  `, { encoding: "utf8", mode: 384 });
117
- await chmod(path, 384).catch(() => void 0);
230
+ await chmod(path, 384).catch(() => void 0);
231
+ });
118
232
  return entry;
119
233
  }
120
234
  function isLogEntry(value) {
@@ -133,12 +247,12 @@ function normalizeXiaoEAuthErrorLogLimit(value) {
133
247
  async function readXiaoEAuthErrorLog(limit = DEFAULT_LOG_LIMIT) {
134
248
  const normalizedLimit = normalizeXiaoEAuthErrorLogLimit(limit);
135
249
  const path = getXiaoEAuthErrorLogPath();
136
- let content = "";
137
- try {
138
- content = await readFile(path, "utf8");
139
- } catch (error) {
140
- if (error?.code !== "ENOENT") throw error;
141
- }
250
+ const { content, expiredRemoved } = await withXiaoEAuthLogLock(path, async () => {
251
+ const current = await readXiaoEAuthErrorLogContent(path);
252
+ const pruned = pruneExpiredXiaoEAuthErrorLogContent(current);
253
+ await persistPrunedXiaoEAuthErrorLog(path, pruned.content, pruned.expiredRemoved);
254
+ return pruned;
255
+ });
142
256
  let invalidLines = 0;
143
257
  const entries = [];
144
258
  for (const line of content.split(/\r?\n/u)) {
@@ -157,18 +271,21 @@ async function readXiaoEAuthErrorLog(limit = DEFAULT_LOG_LIMIT) {
157
271
  total: entries.length,
158
272
  returned: recent.length,
159
273
  invalidLines,
274
+ expiredRemoved,
160
275
  entries: recent
161
276
  };
162
277
  }
163
278
  async function clearXiaoEAuthErrorLog() {
164
279
  const path = getXiaoEAuthErrorLogPath();
165
- try {
166
- await unlink(path);
167
- return { path, cleared: true };
168
- } catch (error) {
169
- if (error?.code === "ENOENT") return { path, cleared: false };
170
- throw error;
171
- }
280
+ return withXiaoEAuthLogLock(path, async () => {
281
+ try {
282
+ await unlink(path);
283
+ return { path, cleared: true };
284
+ } catch (error) {
285
+ if (error?.code === "ENOENT") return { path, cleared: false };
286
+ throw error;
287
+ }
288
+ });
172
289
  }
173
290
 
174
291
  // src/internal/e10/auth-recovery.ts
@@ -408,9 +525,19 @@ function sameE10SessionIdentity(current, recovered) {
408
525
  }
409
526
 
410
527
  // src/internal/e10/context.ts
528
+ function xiaoEFailureForErrorDetails(failure) {
529
+ return {
530
+ stage: failure.stage,
531
+ kind: failure.kind,
532
+ message: failure.message,
533
+ ...failure.causeCode ? { causeCode: failure.causeCode } : {},
534
+ ...failure.httpStatus === void 0 ? {} : { httpStatus: failure.httpStatus }
535
+ };
536
+ }
411
537
  function xiaoERecoveryFailedError(diagnostics, resultSessionExpired = false) {
412
538
  const failureKind = summarizeXiaoEFailureKind(diagnostics);
413
539
  const lastFailure = lastXiaoEFailure(diagnostics);
540
+ const publicFailures = diagnostics?.failures?.map(xiaoEFailureForErrorDetails);
414
541
  const networkUnavailable = failureKind === "network";
415
542
  const hostCredentialMissing = diagnostics?.clientType === "cloud" && diagnostics.platformCredentialDetected === false && diagnostics.attemptedSteps.includes("platform_token:missing") && diagnostics.attemptedSteps.includes("environment_map:empty");
416
543
  const details = diagnostics ? {
@@ -421,7 +548,7 @@ function xiaoERecoveryFailedError(diagnostics, resultSessionExpired = false) {
421
548
  ...diagnostics.lastError ? { lastError: diagnostics.lastError } : {},
422
549
  ...failureKind ? { errorKind: failureKind } : {},
423
550
  ...lastFailure ? { failureStage: lastFailure.stage } : {},
424
- ...diagnostics.failures?.length ? { failures: diagnostics.failures } : {},
551
+ ...publicFailures?.length ? { failures: publicFailures } : {},
425
552
  ...hostCredentialMissing ? { reason: "host_credential_not_injected" } : {},
426
553
  ...resultSessionExpired ? { resultSessionExpired: true } : {}
427
554
  } : void 0;
@@ -0,0 +1,215 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ CaizhilianCliError,
5
+ caizhilianAuthError,
6
+ caizhilianNetworkError,
7
+ caizhilianValidationError
8
+ } from "./chunk-P5GQRWDC.js";
9
+ import {
10
+ E10ApiError,
11
+ createE10RequestRuntime,
12
+ isE10SessionExpiredResponse,
13
+ requireE10Session
14
+ } from "./chunk-6NXT4ICB.js";
15
+ import {
16
+ E10_SESSION_EXPIRED_MESSAGE,
17
+ getActiveProfile
18
+ } from "./chunk-U6R6FZHD.js";
19
+
20
+ // src/shortcuts/caizhilian/host.ts
21
+ var CAIZHILAN_TIMEOUT_MS = 12e3;
22
+ var CAIZHILAN_TRANSFER_TIMEOUT_MS = 12e4;
23
+ var CAIZHILAN_MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
24
+ function inferProfile(ctx) {
25
+ const options = ctx.getGlobalOptions();
26
+ return options.profile || getActiveProfile();
27
+ }
28
+ function isCaizhilianBusinessSuccess(value) {
29
+ if (!value || typeof value !== "object") return false;
30
+ if (value.code !== void 0 && value.code !== null) return Number(value.code) === 200;
31
+ if (typeof value.success === "boolean") return value.success;
32
+ if (typeof value.status === "boolean") return value.status;
33
+ return false;
34
+ }
35
+ function caizhilianBusinessMessage(value) {
36
+ if (!value || typeof value !== "object") return "\u91C7\u77E5\u8FDE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
37
+ const candidates = [value.msg, value.message, value.errMsg, value.data?.msg, value.data?.message];
38
+ for (const item of candidates) {
39
+ if (typeof item === "string" && item.trim()) return item;
40
+ }
41
+ return "\u91C7\u77E5\u8FDE\u63A5\u53E3\u8FD4\u56DE\u4E1A\u52A1\u5931\u8D25";
42
+ }
43
+ function caizhilianBusinessCode(value) {
44
+ if (!value || typeof value !== "object") return void 0;
45
+ const code = value.code ?? value.status;
46
+ if (typeof code === "string" || typeof code === "number") return code;
47
+ return void 0;
48
+ }
49
+ function assertCaizhilianPath(requestPath) {
50
+ if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
51
+ throw caizhilianValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
52
+ }
53
+ if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
54
+ throw caizhilianValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
55
+ }
56
+ if (!requestPath.startsWith("/api/")) {
57
+ throw caizhilianValidationError("path_not_allowed", "\u91C7\u77E5\u8FDE\u6A21\u5757\u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
58
+ }
59
+ }
60
+ function formBody(form) {
61
+ if (!form) return void 0;
62
+ const params = new URLSearchParams();
63
+ for (const [key, value] of Object.entries(form)) {
64
+ if (value === void 0 || value === null) continue;
65
+ params.set(key, typeof value === "string" ? value : JSON.stringify(value));
66
+ }
67
+ return params;
68
+ }
69
+ function omitEmptyQueryValues(query) {
70
+ if (!query) return void 0;
71
+ return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== ""));
72
+ }
73
+ function mapRuntimeNetworkError(error) {
74
+ if (error instanceof E10ApiError && error.type === "network") {
75
+ throw caizhilianNetworkError(error.subtype, error.message, {
76
+ retryable: error.retryable,
77
+ details: error.details
78
+ });
79
+ }
80
+ throw error;
81
+ }
82
+ function createCaizhilianHost(ctx, dependencies = {}) {
83
+ let e10Session = null;
84
+ let sessionContext = null;
85
+ const requireSession = dependencies.requireSession || requireE10Session;
86
+ async function ensureSession() {
87
+ if (!e10Session) {
88
+ e10Session = await requireSession(ctx);
89
+ sessionContext = {
90
+ baseUrl: e10Session.getBaseUrl(),
91
+ profile: inferProfile(ctx),
92
+ userId: e10Session.userId,
93
+ tenantKey: e10Session.tenantKey,
94
+ eteamsId: e10Session.eteamsId
95
+ };
96
+ }
97
+ return e10Session;
98
+ }
99
+ async function getSession() {
100
+ await ensureSession();
101
+ return sessionContext;
102
+ }
103
+ async function runtime() {
104
+ return createE10RequestRuntime(ctx, await ensureSession(), {
105
+ interceptors: dependencies.interceptors,
106
+ fetch: dependencies.fetch
107
+ });
108
+ }
109
+ async function doRequest(request2, binary) {
110
+ const {
111
+ method,
112
+ path,
113
+ query,
114
+ body,
115
+ operation,
116
+ form,
117
+ multipart,
118
+ streamMultipart,
119
+ maxResponseBytes,
120
+ headers: extraHeaders = {},
121
+ timeoutMs = CAIZHILAN_TIMEOUT_MS
122
+ } = request2;
123
+ assertCaizhilianPath(path);
124
+ const resolvedMethod = method || (body === void 0 && form === void 0 && multipart === void 0 && streamMultipart === void 0 ? "GET" : "POST");
125
+ const headers = { "X-Requested-With": "XMLHttpRequest", ...extraHeaders, ...streamMultipart ? {
126
+ "Content-Type": streamMultipart.contentType,
127
+ "Content-Length": String(streamMultipart.contentLength)
128
+ } : {} };
129
+ const rt = await runtime();
130
+ const response = binary ? await rt.requestBinary({
131
+ module: "caizhilian",
132
+ operation,
133
+ method: resolvedMethod,
134
+ path,
135
+ query: omitEmptyQueryValues(query),
136
+ body: multipart === void 0 ? body : void 0,
137
+ form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
138
+ formData: multipart,
139
+ streamBody: streamMultipart?.body,
140
+ maxResponseBytes,
141
+ headers,
142
+ timeoutMs
143
+ }) : await rt.requestJson({
144
+ module: "caizhilian",
145
+ operation,
146
+ method: resolvedMethod,
147
+ path,
148
+ query: omitEmptyQueryValues(query),
149
+ body: multipart === void 0 ? body : void 0,
150
+ form: multipart === void 0 && form === void 0 ? void 0 : formBody(form ?? {}),
151
+ formData: multipart,
152
+ streamBody: streamMultipart?.body,
153
+ maxResponseBytes,
154
+ headers,
155
+ timeoutMs
156
+ });
157
+ return response;
158
+ }
159
+ async function request(request2) {
160
+ const response = await doRequest(request2, false).catch((error) => mapRuntimeNetworkError(error));
161
+ if (isE10SessionExpiredResponse(response)) {
162
+ throw caizhilianAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
163
+ }
164
+ if (response.parseError) {
165
+ if (response.status < 200 || response.status >= 300) {
166
+ throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u63A5\u53E3 HTTP ${response.status}`, {
167
+ code: response.status,
168
+ details: { status: response.status },
169
+ exitCode: 1
170
+ });
171
+ }
172
+ throw caizhilianNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
173
+ }
174
+ if (response.status < 200 || response.status >= 300 || request2.requireHttp200 && response.status !== 200) {
175
+ throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u63A5\u53E3 HTTP ${response.status}`, {
176
+ code: response.status,
177
+ details: { status: response.status, message: caizhilianBusinessMessage(response.value) },
178
+ exitCode: 1
179
+ });
180
+ }
181
+ if (!request2.tolerateBusinessError && !isCaizhilianBusinessSuccess(response.value)) {
182
+ throw new CaizhilianCliError("api", "business_error", caizhilianBusinessMessage(response.value), {
183
+ code: caizhilianBusinessCode(response.value),
184
+ details: { code: caizhilianBusinessCode(response.value), message: caizhilianBusinessMessage(response.value) },
185
+ exitCode: 1
186
+ });
187
+ }
188
+ return response.value;
189
+ }
190
+ async function requestBinary(request2) {
191
+ const response = await doRequest(request2, true).catch((error) => mapRuntimeNetworkError(error));
192
+ if (isE10SessionExpiredResponse(response)) {
193
+ throw caizhilianAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
194
+ }
195
+ if (response.status < 200 || response.status >= 300) {
196
+ throw new CaizhilianCliError("api", "http_error", `\u91C7\u77E5\u8FDE\u4E0B\u8F7D HTTP ${response.status}`, {
197
+ code: response.status,
198
+ details: { status: response.status },
199
+ exitCode: 1
200
+ });
201
+ }
202
+ return { status: response.status, contentType: response.contentType, content: response.content, headers: response.headers };
203
+ }
204
+ return { request, requestBinary, getSession };
205
+ }
206
+
207
+ export {
208
+ CAIZHILAN_TIMEOUT_MS,
209
+ CAIZHILAN_TRANSFER_TIMEOUT_MS,
210
+ CAIZHILAN_MAX_DOWNLOAD_BYTES,
211
+ isCaizhilianBusinessSuccess,
212
+ caizhilianBusinessMessage,
213
+ assertCaizhilianPath,
214
+ createCaizhilianHost
215
+ };
@@ -5,7 +5,7 @@ import {
5
5
  ebBusinessSuccess,
6
6
  meetingSuccess,
7
7
  meetingValidationError
8
- } from "./chunk-QVSWRLLU.js";
8
+ } from "./chunk-JWWTI63L.js";
9
9
 
10
10
  // src/shortcuts/meeting/operations/env.ts
11
11
  import { existsSync } from "node:fs";
@@ -11,11 +11,11 @@ import {
11
11
  createE10RequestRuntime,
12
12
  isE10SessionExpiredResponse,
13
13
  requireE10Session
14
- } from "./chunk-ETNJSKMM.js";
14
+ } from "./chunk-6NXT4ICB.js";
15
15
  import {
16
16
  E10_SESSION_EXPIRED_MESSAGE,
17
17
  getActiveProfile
18
- } from "./chunk-UFIT2UU3.js";
18
+ } from "./chunk-U6R6FZHD.js";
19
19
 
20
20
  // src/shortcuts/im/host.ts
21
21
  import { createHash } from "node:crypto";
@@ -2,7 +2,7 @@ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
2
  const require = __esbuildCreateRequire(import.meta.url);
3
3
  import {
4
4
  meetingStateDir
5
- } from "./chunk-GAMZLAG2.js";
5
+ } from "./chunk-77YP6I52.js";
6
6
 
7
7
  // src/shortcuts/meeting/operations/eb/cache.ts
8
8
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -2,7 +2,7 @@ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
2
  const require = __esbuildCreateRequire(import.meta.url);
3
3
  import {
4
4
  isEsbFlowUnavailable
5
- } from "./chunk-F4E4EM35.js";
5
+ } from "./chunk-TGAGQV4I.js";
6
6
  import {
7
7
  esbValidationError
8
8
  } from "./chunk-TXUG266F.js";
@@ -4,12 +4,12 @@ import {
4
4
  createE10RequestRuntime,
5
5
  isE10SessionExpiredResponse,
6
6
  requireE10Session
7
- } from "./chunk-ETNJSKMM.js";
7
+ } from "./chunk-6NXT4ICB.js";
8
8
  import {
9
9
  E10_REAUTH_GUIDANCE,
10
10
  E10_SESSION_EXPIRED_MESSAGE,
11
11
  getActiveProfile
12
- } from "./chunk-UFIT2UU3.js";
12
+ } from "./chunk-U6R6FZHD.js";
13
13
  import {
14
14
  CliError
15
15
  } from "./chunk-UG5G54VL.js";
@@ -9,11 +9,11 @@ import {
9
9
  createE10RequestRuntime,
10
10
  isE10AuthenticationRequired,
11
11
  requireE10Session
12
- } from "./chunk-ETNJSKMM.js";
12
+ } from "./chunk-6NXT4ICB.js";
13
13
  import {
14
14
  E10_SESSION_EXPIRED_MESSAGE,
15
15
  getActiveProfile
16
- } from "./chunk-UFIT2UU3.js";
16
+ } from "./chunk-U6R6FZHD.js";
17
17
 
18
18
  // src/shortcuts/workflow/host.ts
19
19
  var DEFAULT_TIMEOUT_MS = 3e4;