weaver-work-cli 0.1.40 → 0.1.42

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 (185) hide show
  1. package/dist/chunks/{archive-JHTONRST.js → archive-J4I6MCKF.js} +2 -2
  2. package/dist/chunks/{archive-oa-FCHLCPHC.js → archive-oa-BRZKKTO4.js} +2 -2
  3. package/dist/chunks/{asset-RLIHC7DB.js → asset-L7D4FAOZ.js} +2 -2
  4. package/dist/chunks/{asset-idle-KVOFTLCP.js → asset-idle-DADLLV75.js} +2 -2
  5. package/dist/chunks/{attachment-content-RZYDB3MB.js → attachment-content-K4C7VLWQ.js} +3 -3
  6. package/dist/chunks/{blog-42OZTJNP.js → blog-BVGQ7NZL.js} +2 -2
  7. package/dist/chunks/{caizhilian-KRK547K5.js → caizhilian-SAADNFD6.js} +2 -2
  8. package/dist/chunks/{calendar-RTWAMKHD.js → calendar-Q7NQY5Z2.js} +61 -23
  9. package/dist/chunks/{chunk-LFMSDBZN.js → chunk-3KTFS4IA.js} +308 -153
  10. package/dist/chunks/{chunk-G2JSIUWF.js → chunk-4PD5NWAX.js} +89 -0
  11. package/dist/chunks/{chunk-T6EGVBKU.js → chunk-4RAE6JXP.js} +1 -1
  12. package/dist/chunks/{chunk-7BRU4EFH.js → chunk-72CKAUAG.js} +29 -2
  13. package/dist/chunks/{chunk-NETCCARD.js → chunk-APVFJUQH.js} +2 -2
  14. package/dist/chunks/{chunk-CAQNBBQA.js → chunk-BBKDXQEC.js} +2 -2
  15. package/dist/chunks/{chunk-57IECMWX.js → chunk-BIPYLLVS.js} +26 -12
  16. package/dist/chunks/{chunk-LN447PY2.js → chunk-EKWAQSLU.js} +3 -2
  17. package/dist/chunks/{chunk-4TEDNCON.js → chunk-FOAA27U5.js} +338 -52
  18. package/dist/chunks/{chunk-7U577Q7U.js → chunk-G4UR6NXN.js} +2 -2
  19. package/dist/chunks/{chunk-NJKREDA3.js → chunk-GEWYMQME.js} +1 -1
  20. package/dist/chunks/{chunk-I566ZYNF.js → chunk-GHXCDPTM.js} +1 -1
  21. package/dist/chunks/{chunk-4CTESSKI.js → chunk-IZ7S7QUS.js} +4 -4
  22. package/dist/chunks/{chunk-VNBU55SL.js → chunk-JPRO6ER2.js} +57 -2432
  23. package/dist/chunks/{chunk-IZSSVYAG.js → chunk-LADPYOWC.js} +2 -2
  24. package/dist/chunks/chunk-LDZQPUIA.js +1238 -0
  25. package/dist/chunks/chunk-NKZRQXST.js +2546 -0
  26. package/dist/chunks/{chunk-JWRZM2H2.js → chunk-QKNKR4RH.js} +3 -3
  27. package/dist/chunks/{chunk-FLS4DPGP.js → chunk-R4CHUSKC.js} +28 -15
  28. package/dist/chunks/{chunk-WFFNM65B.js → chunk-SA6VBIHY.js} +73 -19
  29. package/dist/chunks/{chunk-SPRHHSVC.js → chunk-TTPJJJC4.js} +2 -2
  30. package/dist/chunks/{chunk-7E6MUOEK.js → chunk-W7BEHOSR.js} +2 -2
  31. package/dist/chunks/{chunk-CXRQWOZ5.js → chunk-YRSZQUD2.js} +2 -2
  32. package/dist/chunks/{conflict-VR55AOOO.js → conflict-F2OMZRTO.js} +2 -2
  33. package/dist/chunks/{contract-HI4FNPYE.js → contract-5BETHRSG.js} +2 -2
  34. package/dist/chunks/{cowork-HJLI353D.js → cowork-3MN6EQQO.js} +22 -12
  35. package/dist/chunks/create-flow-5FQNNMVO.js +55 -0
  36. package/dist/chunks/{ebuilder-form-HTGI63UU.js → ebuilder-form-SBHOYBUD.js} +3 -3
  37. package/dist/chunks/{ehr-GYXIYH3A.js → ehr-KMOJULKG.js} +432 -1234
  38. package/dist/chunks/{env-DW3G4HUO.js → env-LB7NBL2O.js} +2 -2
  39. package/dist/chunks/{esb-I5INCEFE.js → esb-W2PJCFCX.js} +4 -4
  40. package/dist/chunks/{factory-TKXGXS6L.js → factory-6ZFQXQ46.js} +1 -1
  41. package/dist/chunks/{fna-K2MHTQ24.js → fna-ZQPCUV4R.js} +2 -2
  42. package/dist/chunks/{group-chat-VYBNMJLG.js → group-chat-2HHAJN46.js} +5 -3
  43. package/dist/chunks/{host-ZUQTJYYK.js → host-4CBHGOHT.js} +3 -3
  44. package/dist/chunks/{host-D5SERMAJ.js → host-ATKVNZAT.js} +3 -3
  45. package/dist/chunks/{host-JM4YVHFM.js → host-BQH22NTQ.js} +3 -3
  46. package/dist/chunks/{host-L3VLITMT.js → host-X2CSLFM6.js} +3 -3
  47. package/dist/chunks/{host-256GVCAH.js → host-YTODKMSL.js} +3 -3
  48. package/dist/chunks/{hrm-VLRBKTZB.js → hrm-FFM4UJFS.js} +4 -4
  49. package/dist/chunks/{im-QK3VTLXK.js → im-VEHKDQPB.js} +7 -7
  50. package/dist/chunks/{invoice-T5JTA32H.js → invoice-LVIKSIIF.js} +3 -3
  51. package/dist/chunks/{jiuchuanhui-P2FNEQVZ.js → jiuchuanhui-X6DINO5P.js} +2 -2
  52. package/dist/chunks/{lazy-dispatch-XRRI46M6.js → lazy-dispatch-KSWTN5L6.js} +4 -4
  53. package/dist/chunks/{mail-3Y7MJ6PS.js → mail-VDKRGUD3.js} +2 -2
  54. package/dist/chunks/{meeting-M7LTXGJE.js → meeting-CLC6HP3Z.js} +12 -11
  55. package/dist/chunks/{okr-OBC6S67L.js → okr-CHG4OO3U.js} +2 -2
  56. package/dist/chunks/{plan-5H6I53SK.js → plan-XWR75667.js} +2 -2
  57. package/dist/chunks/{project-L75QZV4S.js → project-5BXOOKMG.js} +40 -23
  58. package/dist/chunks/recruit-stage-DGMFNNDE.js +4507 -0
  59. package/dist/chunks/{registry-RXPN6BBT.js → registry-7FFOXIAW.js} +4 -4
  60. package/dist/chunks/{registry-KMHCPAAD.js → registry-BKBZPBAJ.js} +10 -9
  61. package/dist/chunks/{registry-QGHFNUWS.js → registry-OZSMDVPP.js} +2 -2
  62. package/dist/chunks/{registry-UGRBCBHO.js → registry-RHMW6ANW.js} +2 -2
  63. package/dist/chunks/{registry-NYPYMZXG.js → registry-Z43434VG.js} +1 -1
  64. package/dist/chunks/{room-recommend-A3UDC3CA.js → room-recommend-62H7ZQQ6.js} +4 -4
  65. package/dist/chunks/{schedule-5GCACCK7.js → schedule-FNXKH3DQ.js} +4 -4
  66. package/dist/chunks/{workflow-M5ZJ7DWF.js → workflow-ADHKCAJK.js} +6 -6
  67. package/dist/index.js +33 -28
  68. package/dist/internal/e10/auth/commands.js +1 -0
  69. package/dist/internal/e10/auth/messages.js +6 -0
  70. package/dist/internal/e10/auth/session.js +17 -0
  71. package/dist/internal/e10/auth/xiaoe.js +286 -44
  72. package/dist/internal/e10/auth-recovery.js +36 -5
  73. package/dist/internal/e10/context.js +56 -12
  74. package/dist/internal/e10/index.js +1 -1
  75. package/dist/internal/e10/network-error.js +93 -0
  76. package/dist/internal/e10/request-runtime.js +6 -0
  77. package/dist/shortcuts/calendar/operations/read.js +31 -22
  78. package/dist/shortcuts/calendar/operations/write.js +45 -1
  79. package/dist/shortcuts/cowork/operations/discuss-write.js +5 -1
  80. package/dist/shortcuts/cowork/operations/item-write.js +1 -7
  81. package/dist/shortcuts/cowork/operations/member-write.js +3 -1
  82. package/dist/shortcuts/cowork/operations/permission-write.js +5 -1
  83. package/dist/shortcuts/cowork/operations/shared.js +7 -0
  84. package/dist/shortcuts/ehr/operations/attend-write.js +43 -1
  85. package/dist/shortcuts/ehr/operations/hr-contact.js +7 -4
  86. package/dist/shortcuts/ehr/operations/hr-report.js +13 -7
  87. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +134 -59
  88. package/dist/shortcuts/ehr/operations/recruit-write.js +262 -17
  89. package/dist/shortcuts/ehr/operations/recruit.js +10 -4
  90. package/dist/shortcuts/ehr/operations/shared.js +47 -0
  91. package/dist/shortcuts/hrm/operations/org.js +118 -0
  92. package/dist/shortcuts/index.js +5 -0
  93. package/dist/shortcuts/meeting/operations/eb/catalog.js +4 -1
  94. package/dist/shortcuts/meeting/operations/eb/create-flow.js +85 -28
  95. package/dist/shortcuts/meeting/operations/eb/factory.js +33 -0
  96. package/dist/shortcuts/meeting/operations/eb/group-chat.js +25 -3
  97. package/dist/shortcuts/meeting/operations/eb/person-cache.js +96 -0
  98. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +33 -11
  99. package/dist/shortcuts/project/operations/read.js +6 -25
  100. package/dist/shortcuts/project/operations/shared.js +22 -0
  101. package/dist/shortcuts/project/operations/write.js +28 -2
  102. package/dist/shortcuts/recruit-stage/context.js +119 -0
  103. package/dist/shortcuts/recruit-stage/continuation.js +73 -0
  104. package/dist/shortcuts/recruit-stage/errors.js +65 -0
  105. package/dist/shortcuts/recruit-stage/host.js +109 -0
  106. package/dist/shortcuts/recruit-stage/index.js +115 -0
  107. package/dist/shortcuts/recruit-stage/manifest.js +29 -0
  108. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +722 -0
  109. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +269 -0
  110. package/dist/shortcuts/recruit-stage/operations/jd-create.js +630 -0
  111. package/dist/shortcuts/recruit-stage/operations/list.js +431 -0
  112. package/dist/shortcuts/recruit-stage/operations/registry.js +38 -0
  113. package/dist/shortcuts/recruit-stage/operations/resume-import.js +1198 -0
  114. package/dist/shortcuts/recruit-stage/operations/search.js +158 -0
  115. package/dist/shortcuts/recruit-stage/operations/types.js +25 -0
  116. package/dist/shortcuts/recruit-stage/school-tiers.json +318 -0
  117. package/dist/shortcuts/recruit-stage/shared.js +608 -0
  118. package/dist/shortcuts/workflow/operations/todoSmartConvert/detailFieldRules.js +4 -2
  119. package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +13 -6
  120. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +17 -24
  121. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +14 -9
  122. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +50 -8
  123. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +2 -1
  124. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +17 -11
  125. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +7 -39
  126. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +3 -2
  127. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +51 -15
  128. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.pipeline.js +16 -1
  129. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +151 -63
  130. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.subGroup.js +56 -0
  131. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +39 -14
  132. package/docs/e10-auth.md +7 -1
  133. package/docs/operation-manual.md +8 -0
  134. package/package.json +1 -1
  135. package/scripts/install-skill-to-xiaoe.mjs +105 -0
  136. package/scripts/package-skill.mjs +4 -2
  137. package/skill-template/business-info.json +24 -0
  138. package/skill-template/domains/recruit-stage.md +29 -0
  139. package/skills/weaver-e10-calendar/SKILL.md +2 -1
  140. package/skills/weaver-e10-calendar/references/calendar-write.md +54 -0
  141. package/skills/weaver-e10-cowork/SKILL.md +1 -1
  142. package/skills/weaver-e10-cowork/references/cowork-write.md +3 -1
  143. package/skills/weaver-e10-jucailin/SKILL.md +1 -1
  144. package/skills/weaver-e10-jucailin/references/attend-write.md +8 -0
  145. package/skills/weaver-e10-jucailin/references/hr-contact.md +8 -0
  146. package/skills/weaver-e10-jucailin/references/hr-report.md +8 -0
  147. package/skills/weaver-e10-jucailin/references/recruit-create.md +2 -2
  148. package/skills/weaver-e10-jucailin/references/recruit-read.md +1 -1
  149. package/skills/weaver-e10-jucailin/references/recruit-write.md +4 -3
  150. package/skills/weaver-e10-mail/SKILL.md +1 -1
  151. package/skills/weaver-e10-meeting/SKILL.md +32 -2
  152. package/skills/weaver-e10-meeting.zip +0 -0
  153. package/skills/weaver-e10-recruit-stage/SKILL.md +226 -0
  154. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +119 -0
  155. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +188 -0
  156. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +322 -0
  157. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +127 -0
  158. package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +65 -0
  159. package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +63 -0
  160. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +142 -0
  161. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +73 -0
  162. package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +56 -0
  163. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +101 -0
  164. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +148 -0
  165. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +77 -0
  166. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +59 -0
  167. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +69 -0
  168. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +241 -0
  169. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +438 -0
  170. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +128 -0
  171. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +146 -0
  172. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +69 -0
  173. package/skills/weaver-e10-shared/SKILL.md +1 -1
  174. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
  175. package/skills/weaver-e10-shijingran/SKILL.md +3 -2
  176. package/skills/weaver-e10-shijingran/references/operations.md +3 -1
  177. package/skills/weaver-e10-shijingran/references/source-manifest.json +41 -40
  178. package/skills/weaver-e10-shijingran/references/write-operations.md +2 -0
  179. package/skills/weaver-e10-workflow/SKILL.md +4 -2
  180. package/skills/weaver-e10-workflow/aigroup/default.json +11 -9
  181. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +23 -13
  182. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +62 -20
  183. package/skills/weaver-e10-yepiaotong/SKILL.md +9 -10
  184. package/skills/weaver-e10-yepiaotong/references/invoice-agent-entry.md +6 -3
  185. package/dist/chunks/{chunk-E7OK5WD5.js → chunk-2LV74IWP.js} +5 -5
@@ -52,6 +52,75 @@ function writeWithRetry(path, data, options) {
52
52
  }
53
53
  }
54
54
 
55
+ // src/internal/e10/network-error.ts
56
+ var NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
57
+ "ECONNREFUSED",
58
+ "ECONNRESET",
59
+ "ECONNABORTED",
60
+ "EHOSTUNREACH",
61
+ "EHOSTDOWN",
62
+ "ENETUNREACH",
63
+ "ENETDOWN",
64
+ "ENETRESET",
65
+ "ENOTFOUND",
66
+ "EAI_AGAIN",
67
+ "EPIPE",
68
+ "ETIMEDOUT",
69
+ "ESOCKETTIMEDOUT",
70
+ "ERR_SOCKET_CONNECTION_TIMEOUT",
71
+ "UND_ERR_CONNECT_TIMEOUT",
72
+ "UND_ERR_HEADERS_TIMEOUT",
73
+ "UND_ERR_BODY_TIMEOUT",
74
+ "UND_ERR_SOCKET",
75
+ "UND_ERR_CLOSED",
76
+ "UND_ERR_ABORTED",
77
+ "CERT_HAS_EXPIRED",
78
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
79
+ "SELF_SIGNED_CERT_IN_CHAIN",
80
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
81
+ "ERR_TLS_CERT_ALTNAME_INVALID",
82
+ "ERR_SSL_WRONG_VERSION_NUMBER"
83
+ ]);
84
+ var ABORT_ERROR_CODE = "ABORT_ERR";
85
+ function asRecord(value) {
86
+ return value && typeof value === "object" ? value : null;
87
+ }
88
+ function readErrorCauseCode(error, maxDepth = 5) {
89
+ let current = error;
90
+ const seen = /* @__PURE__ */ new Set();
91
+ for (let depth = 0; depth < maxDepth; depth += 1) {
92
+ if (current === void 0 || current === null || seen.has(current)) return void 0;
93
+ seen.add(current);
94
+ if (current instanceof Error && current.name === "AbortError") return ABORT_ERROR_CODE;
95
+ const record = asRecord(current);
96
+ if (!record) return void 0;
97
+ if (record.name === "AbortError") return ABORT_ERROR_CODE;
98
+ const code = record.code;
99
+ if (typeof code === "string" && code) return code;
100
+ const errno = record.errno;
101
+ if (typeof errno === "string" && errno) return errno;
102
+ if (typeof errno === "number") return String(errno);
103
+ current = record.cause;
104
+ }
105
+ return void 0;
106
+ }
107
+ function isAbortError(error) {
108
+ if (error instanceof Error && error.name === "AbortError") return true;
109
+ return asRecord(error)?.name === "AbortError";
110
+ }
111
+ function isNetworkErrorCode(code) {
112
+ return typeof code === "string" && NETWORK_ERROR_CODES.has(code.toUpperCase());
113
+ }
114
+ var TRANSPORT_MESSAGE_PATTERN = /fetch failed|socket hang up|other side closed|network|connection (?:refused|reset|closed)|timed? ?out|timeout|certificate|getaddrinfo|dns lookup/i;
115
+ function looksLikeTransportMessage(message) {
116
+ return TRANSPORT_MESSAGE_PATTERN.test(message);
117
+ }
118
+ function createTimeoutSignal(timeoutMs) {
119
+ const controller = new AbortController();
120
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
121
+ return { signal: controller.signal, clear: () => clearTimeout(timer) };
122
+ }
123
+
55
124
  // src/internal/e10/auth/crypto.ts
56
125
  import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
57
126
  import { existsSync, mkdirSync, readFileSync } from "node:fs";
@@ -189,6 +258,7 @@ function parseAuthFile(raw) {
189
258
  }
190
259
 
191
260
  // src/internal/e10/auth/session.ts
261
+ var E10_TEAMS_CHECK_TIMEOUT_MS = 15e3;
192
262
  var RSA_PUBLIC_KEY_PEM = `-----BEGIN PUBLIC KEY-----
193
263
  MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCEOk/WyyJKdAHIfMODFnKg7MBoraFBnL3F18hhLx5n01J5g4hCkmpc5+KQFKIQIA/QWk9m7QBzI/OV9ZDFk54LaWm3xP8C+P1TPp7UVGz3iNDLdvgSxuGEYPmML3NaqkbVlvW7/NlNA3ED4Kao7rR5GUYSdFfbaBoxBFae638hzQIDAQAB
194
264
  -----END PUBLIC KEY-----`;
@@ -359,16 +429,16 @@ function findAuthFile(startDir = process.cwd(), options = {}) {
359
429
  if (existsSync2(activeProfileAuth)) return activeProfileAuth;
360
430
  return null;
361
431
  }
362
- function asRecord(value) {
432
+ function asRecord2(value) {
363
433
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
364
434
  }
365
435
  function readTeamsCheckUserInfo(resp, data) {
366
- const root = asRecord(data);
367
- const nested = asRecord(root.data);
368
- const currentUser = asRecord(root.currentUser || nested.currentUser);
369
- const currentTenant = asRecord(root.currentTenant || nested.currentTenant);
370
- const department = asRecord(currentUser.department);
371
- const position = asRecord(currentUser.position);
436
+ const root = asRecord2(data);
437
+ const nested = asRecord2(root.data);
438
+ const currentUser = asRecord2(root.currentUser || nested.currentUser);
439
+ const currentTenant = asRecord2(root.currentTenant || nested.currentTenant);
440
+ const department = asRecord2(currentUser.department);
441
+ const position = asRecord2(currentUser.position);
372
442
  const userId = resp.headers.get("employeeId") || currentUser.employeeId || currentUser.id || nested.employeeId || root.employeeId || "";
373
443
  const tenantKey = currentUser.tenantKey || currentTenant.tenantKey || nested.tenantKey || nested.tenantkey || root.tenantKey || root.tenantkey || "";
374
444
  return {
@@ -582,6 +652,7 @@ var E10AuthSession = class _E10AuthSession {
582
652
  return session;
583
653
  }
584
654
  async fetchEmployeeId() {
655
+ const { signal, clear } = createTimeoutSignal(E10_TEAMS_CHECK_TIMEOUT_MS);
585
656
  try {
586
657
  const resp = await fetch(
587
658
  `${this.getBaseUrl()}/api/baseserver/layout/teamsCheck?clientType=not_xinchuang&client=WEB&domainName=${encodeURIComponent(this.getBaseUrl())}`,
@@ -594,7 +665,8 @@ var E10AuthSession = class _E10AuthSession {
594
665
  cookie: this.cookieHeader(),
595
666
  "user-agent": this.uaHeader(),
596
667
  origin: this.getBaseUrl()
597
- }
668
+ },
669
+ signal
598
670
  }
599
671
  );
600
672
  const data = await resp.json().catch(() => ({}));
@@ -606,9 +678,12 @@ var E10AuthSession = class _E10AuthSession {
606
678
  if (userInfo.subcompany) this.data.subcompany = userInfo.subcompany;
607
679
  if (userInfo.position) this.data.position = userInfo.position;
608
680
  } catch {
681
+ } finally {
682
+ clear();
609
683
  }
610
684
  }
611
685
  async checkValid() {
686
+ const { signal, clear } = createTimeoutSignal(E10_TEAMS_CHECK_TIMEOUT_MS);
612
687
  try {
613
688
  const resp = await fetch(`${this.getBaseUrl()}/api/ecode/tree/list?parentId=0`, {
614
689
  headers: {
@@ -617,11 +692,14 @@ var E10AuthSession = class _E10AuthSession {
617
692
  cookie: this.cookieHeader(),
618
693
  "user-agent": this.uaHeader()
619
694
  },
620
- redirect: "manual"
695
+ redirect: "manual",
696
+ signal
621
697
  });
622
698
  return resp.status === 200;
623
699
  } catch {
624
700
  return false;
701
+ } finally {
702
+ clear();
625
703
  }
626
704
  }
627
705
  async ensureValid() {
@@ -722,6 +800,8 @@ var E10AuthSession = class _E10AuthSession {
722
800
  var E10_REAUTH_GUIDANCE = "\u8BF7\u7ED3\u5408\u5F53\u524D\u5BBF\u4E3B\u73AF\u5883\u9009\u62E9\u5408\u9002\u7684\u767B\u5F55\u65B9\u5F0F\uFF0C\u6062\u590D\u767B\u5F55\u540E\u91CD\u8BD5\u539F\u8BF7\u6C42\u3002";
723
801
  var E10_AUTH_REQUIRED_MESSAGE = `E10 \u767B\u5F55\u6001\u4E0D\u53EF\u7528\u3002${E10_REAUTH_GUIDANCE}`;
724
802
  var E10_XIAOE_RECOVERY_FAILED_MESSAGE = "E10 \u767B\u5F55\u6001\u4E0D\u53EF\u7528\u3002\u5DF2\u5C1D\u8BD5\u5C0F e \u81EA\u52A8\u91CD\u65B0\u83B7\u53D6\u767B\u5F55\u4FE1\u606F\uFF0C\u4F46\u672A\u53D6\u5F97\u53EF\u7528\u767B\u5F55\u6001\u3002\u8BF7\u5728\u5C0F e \u4E2D\u6062\u590D\u767B\u5F55\u540E\u91CD\u8BD5\u3002";
803
+ var E10_XIAOE_HOST_CREDENTIAL_MISSING_MESSAGE = "E10 \u767B\u5F55\u6001\u4E0D\u53EF\u7528\u3002\u5C0F e \u7F51\u9875\u7AEF\u672A\u5411\u5F53\u524D\u8FD0\u884C\u73AF\u5883\u6CE8\u5165\u7EDF\u4E00\u767B\u5F55\u51ED\u636E\uFF0C\u81EA\u52A8\u83B7\u53D6\u5DF2\u505C\u6B62\u3002\u8BF7\u68C0\u67E5\u7F51\u9875\u6280\u80FD\u6C99\u7BB1\u7684\u5BBF\u4E3B\u51ED\u636E\u900F\u4F20\u540E\u91CD\u8BD5\u3002";
804
+ var E10_XIAOE_NETWORK_UNAVAILABLE_MESSAGE = "\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5 E10\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5";
725
805
  var E10_SESSION_EXPIRED_MESSAGE = `E10 \u767B\u5F55\u6001\u5DF2\u5931\u6548\uFF0C\u672C\u6B21\u64CD\u4F5C\u5DF2\u505C\u6B62\u3002${E10_REAUTH_GUIDANCE}`;
726
806
 
727
807
  // src/core/package-paths.ts
@@ -836,6 +916,82 @@ var XIAOE_CLIENT_SETTINGS_SOURCE = "XiaoE/Robots/user_settings.json";
836
916
  var XIAOE_USER_TOKEN_SOURCE = "XIAOE_USER_TOKEN";
837
917
  var XIAOE_BUNDLED_ENV_SCRIPT_SOURCE = "bundled scripts/xiaoe_env.py";
838
918
  var XIAOE_ETEAMID_TTL_MS = 72e5;
919
+ var XIAOE_DIAGNOSTIC_MAX_LENGTH = 300;
920
+ function redactXiaoEDiagnostic(message, secrets) {
921
+ let text = message;
922
+ for (const secret of secrets) {
923
+ if (secret && secret.length >= 8 && text.includes(secret)) {
924
+ text = text.split(secret).join("<redacted>");
925
+ }
926
+ }
927
+ const normalized = text.replace(/\s+/gu, " ").trim();
928
+ return normalized.length > XIAOE_DIAGNOSTIC_MAX_LENGTH ? `${normalized.slice(0, XIAOE_DIAGNOSTIC_MAX_LENGTH)}\u2026` : normalized;
929
+ }
930
+ function noteXiaoEStep(diagnostics, step) {
931
+ diagnostics?.attemptedSteps.push(step);
932
+ }
933
+ function tagXiaoEError(message, tags) {
934
+ return Object.assign(new CliError(message, 3 /* AuthError */), tags);
935
+ }
936
+ function readTag(error, key, type) {
937
+ if (!error || typeof error !== "object") return void 0;
938
+ const value = error[key];
939
+ return typeof value === type ? value : void 0;
940
+ }
941
+ function classifyXiaoEHttpStatus(status) {
942
+ if (status === 401 || status === 403) return "credential";
943
+ if (status >= 300 && status < 400) return "credential";
944
+ return status >= 400 ? "http" : "credential";
945
+ }
946
+ function classifyXiaoEError(error) {
947
+ const taggedKind = readTag(error, "errorKind", "string");
948
+ const taggedStatus = readTag(error, "status", "number");
949
+ const taggedCause = readTag(error, "causeCode", "string");
950
+ const causeCode = taggedCause || readErrorCauseCode(error);
951
+ const withCause = causeCode ? { causeCode } : {};
952
+ const withStatus = taggedStatus === void 0 ? {} : { status: taggedStatus };
953
+ if (taggedKind) return { kind: taggedKind, ...withCause, ...withStatus };
954
+ const message = error instanceof Error ? error.message : String(error);
955
+ if (isAbortError(error)) return { kind: "network", causeCode: causeCode || "ETIMEDOUT" };
956
+ if (taggedStatus !== void 0) {
957
+ return { kind: classifyXiaoEHttpStatus(taggedStatus), ...withCause, status: taggedStatus };
958
+ }
959
+ if (causeCode && isNetworkErrorCode(causeCode)) return { kind: "network", causeCode };
960
+ const httpMatch = /\bHTTP (\d{3})\b/u.exec(message);
961
+ if (httpMatch) {
962
+ const status = Number(httpMatch[1]);
963
+ return { kind: classifyXiaoEHttpStatus(status), ...withCause, status };
964
+ }
965
+ if (looksLikeTransportMessage(message)) return { kind: "network", ...withCause };
966
+ return { kind: "credential", ...withCause };
967
+ }
968
+ function noteXiaoEError(diagnostics, error, secrets = [], stage = "e10_session") {
969
+ if (!diagnostics) return;
970
+ const message = error instanceof Error ? error.message : String(error);
971
+ const redacted = redactXiaoEDiagnostic(message, secrets);
972
+ if (redacted) diagnostics.lastError = redacted;
973
+ const { kind, causeCode, status } = classifyXiaoEError(error);
974
+ const failure = {
975
+ stage: readTag(error, "stage", "string") ?? stage,
976
+ kind,
977
+ message: redacted,
978
+ ...causeCode ? { causeCode } : {},
979
+ ...status === void 0 ? {} : { httpStatus: status }
980
+ };
981
+ if (!diagnostics.failures) diagnostics.failures = [];
982
+ diagnostics.failures.push(failure);
983
+ }
984
+ function summarizeXiaoEFailureKind(diagnostics) {
985
+ const failures = diagnostics?.failures || [];
986
+ if (!failures.length) return void 0;
987
+ if (failures.some((failure) => failure.kind === "credential")) return "credential";
988
+ if (failures.some((failure) => failure.kind === "http")) return "http";
989
+ return failures.every((failure) => failure.kind === "network") ? "network" : void 0;
990
+ }
991
+ function lastXiaoEFailure(diagnostics) {
992
+ const failures = diagnostics?.failures || [];
993
+ return failures.length ? failures[failures.length - 1] : void 0;
994
+ }
839
995
  function envString(env, ...keys) {
840
996
  for (const key of keys) {
841
997
  const value = env[key];
@@ -854,6 +1010,15 @@ function hasXiaoEEnv(env = process.env, options = {}) {
854
1010
  const explicitAgentType = envString(env, "WEAVER_AGENT_TYPE");
855
1011
  return explicitAgentType ? isXiaoERuntimeAgent(explicitAgentType) : false;
856
1012
  }
1013
+ function resolveXiaoEClientType(env = process.env) {
1014
+ const raw = envString(env, "XIAOE_CLIENT_TYPE").toLowerCase();
1015
+ if (raw === "client" || raw === "desktop" || raw === "pc") return "client";
1016
+ if (raw === "cloud" || raw === "web" || raw === "browser") return "cloud";
1017
+ return void 0;
1018
+ }
1019
+ function isXiaoECloudRuntime(env = process.env) {
1020
+ return resolveXiaoEClientType(env) === "cloud";
1021
+ }
857
1022
  function describeXiaoECredentialSource(source) {
858
1023
  if (source === XIAOE_USER_TOKEN_SOURCE || source === XIAOE_BUNDLED_ENV_SCRIPT_SOURCE) {
859
1024
  return {
@@ -1352,14 +1517,17 @@ function inspectXiaoEUnifiedLoginSources(options = {}) {
1352
1517
  });
1353
1518
  const platformCredential = hasXiaoEPlatformCredential(env);
1354
1519
  const allowLocalDiscovery = options.allowLocalDiscovery !== false;
1355
- const tokenScript = options.allowTokenScript !== false && hasXiaoETokenScript(env, allowLocalDiscovery);
1356
- const clientCredential = hasXiaoEClientCredential(env, allowLocalDiscovery);
1520
+ const clientType = resolveXiaoEClientType(env);
1521
+ const allowDesktopChannels = clientType !== "cloud";
1522
+ const tokenScript = allowDesktopChannels && options.allowTokenScript !== false && hasXiaoETokenScript(env, allowLocalDiscovery);
1523
+ const clientCredential = allowDesktopChannels && hasXiaoEClientCredential(env, allowLocalDiscovery);
1357
1524
  const environmentCredential = Boolean(baseUrl && resolveXiaoEUnifiedLoginCredential(baseUrl, env));
1358
1525
  return {
1359
1526
  platformCredential,
1360
1527
  tokenScript,
1361
1528
  clientCredential,
1362
1529
  environmentCredential,
1530
+ clientType,
1363
1531
  any: platformCredential || tokenScript || clientCredential || environmentCredential
1364
1532
  };
1365
1533
  }
@@ -1382,37 +1550,71 @@ async function fetchXiaoEClientEteamId(credential, domain) {
1382
1550
  });
1383
1551
  if (resp.status < 300 || resp.status >= 400) break;
1384
1552
  if (redirects === 5) {
1385
- throw new CliError("XiaoE client token endpoint redirected too many times.", 3 /* AuthError */);
1553
+ throw tagXiaoEError("XiaoE client token endpoint redirected too many times.", {
1554
+ errorKind: "http"
1555
+ });
1386
1556
  }
1387
1557
  const location = resp.headers.get("location");
1388
1558
  if (!location) {
1389
- throw new CliError("XiaoE client token endpoint returned a redirect without Location.", 3 /* AuthError */);
1559
+ throw tagXiaoEError("XiaoE client token endpoint returned a redirect without Location.", {
1560
+ errorKind: "http",
1561
+ status: resp.status
1562
+ });
1390
1563
  }
1391
1564
  const next = new URL(location, endpoint);
1392
1565
  const sameOrigin = next.origin === endpoint.origin;
1393
1566
  const sameHostHttpsUpgrade = endpoint.protocol === "http:" && next.protocol === "https:" && next.hostname === endpoint.hostname;
1394
1567
  const safeProtocol = next.protocol === "http:" || next.protocol === "https:";
1395
1568
  if (!safeProtocol || next.username || next.password || !sameOrigin && !sameHostHttpsUpgrade) {
1396
- throw new CliError("XiaoE client token endpoint attempted an unsafe cross-origin redirect.", 3 /* AuthError */);
1569
+ throw tagXiaoEError("XiaoE client token endpoint attempted an unsafe cross-origin redirect.", {
1570
+ errorKind: "http",
1571
+ status: resp.status
1572
+ });
1397
1573
  }
1398
1574
  await resp.body?.cancel().catch(() => void 0);
1399
1575
  endpoint = next;
1400
1576
  }
1401
1577
  if (!resp?.ok) {
1402
- throw new CliError(`XiaoE client token endpoint returned HTTP ${resp?.status || 0}.`, 3 /* AuthError */);
1578
+ const status = resp?.status || 0;
1579
+ throw tagXiaoEError(`XiaoE client token endpoint returned HTTP ${status}.`, {
1580
+ errorKind: classifyXiaoEHttpStatus(status),
1581
+ status
1582
+ });
1403
1583
  }
1404
- const data = await resp.json().catch(() => null);
1584
+ const data = await resp.json().catch((error) => {
1585
+ if (isAbortError(error)) throw error;
1586
+ return null;
1587
+ });
1405
1588
  if (!data || typeof data !== "object" || Array.isArray(data)) {
1406
- throw new CliError("XiaoE client token endpoint returned invalid JSON.", 3 /* AuthError */);
1589
+ throw tagXiaoEError("XiaoE client token endpoint returned invalid JSON.", {
1590
+ errorKind: "http",
1591
+ status: resp.status
1592
+ });
1407
1593
  }
1408
1594
  const payload = data;
1409
1595
  const businessCode = payload.code;
1410
1596
  const businessData = payload.data && typeof payload.data === "object" && !Array.isArray(payload.data) ? payload.data : {};
1411
1597
  if (businessCode !== "0000" && businessCode !== 0 && businessCode !== 200 || !readString(businessData, "eteamId")) {
1412
1598
  const codeText = businessCode === void 0 ? "missing" : String(businessCode);
1413
- throw new CliError(`XiaoE client token exchange failed with business code ${codeText}.`, 3 /* AuthError */);
1599
+ throw tagXiaoEError(`XiaoE client token exchange failed with business code ${codeText}.`, {
1600
+ errorKind: "credential"
1601
+ });
1414
1602
  }
1415
1603
  return payload;
1604
+ } catch (error) {
1605
+ if (isAbortError(error)) {
1606
+ throw tagXiaoEError(
1607
+ `XiaoE client token endpoint timed out after ${XIAOE_CLIENT_TOKEN_TIMEOUT_MS} ms.`,
1608
+ { errorKind: "network", causeCode: "ETIMEDOUT" }
1609
+ );
1610
+ }
1611
+ if (error instanceof CliError) throw error;
1612
+ const causeCode = readErrorCauseCode(error);
1613
+ const message = error instanceof Error ? error.message : String(error);
1614
+ throw tagXiaoEError(
1615
+ `XiaoE client token endpoint request failed${causeCode ? ` (${causeCode})` : ""}: ${message}`,
1616
+ { errorKind: "network", ...causeCode ? { causeCode } : {} }
1617
+ );
1416
1618
  } finally {
1417
1619
  clearTimeout(timer);
1418
1620
  }
@@ -1461,26 +1663,58 @@ function createXiaoEUnifiedLoginUnavailableError(baseUrl = "") {
1461
1663
  });
1462
1664
  }
1463
1665
  async function resolveUserInfo(baseUrl, eteamsId, rawCookie = "", agentType = "") {
1464
- const resp = await fetch(`${baseUrl}/api/baseserver/layout/teamsCheck?clientType=not_xinchuang&client=WEB&domainName=${encodeURIComponent(baseUrl)}`, {
1465
- method: "POST",
1466
- headers: {
1467
- accept: "application/json",
1468
- "content-type": "application/json",
1469
- eteamsid: eteamsId,
1470
- cookie: buildE10CookieHeader(rawCookie, eteamsId, agentType),
1471
- "user-agent": agentType ? `AgentType=${agentType},IsAgent=true` : "weaver-work-cli",
1472
- origin: baseUrl
1473
- },
1474
- redirect: "manual"
1475
- });
1476
- const data = await resp.json().catch(() => ({}));
1477
- return { userInfo: readTeamsCheckUserInfo(resp, data), setCookie: extractRawSetCookie(resp) };
1666
+ const { signal, clear } = createTimeoutSignal(E10_TEAMS_CHECK_TIMEOUT_MS);
1667
+ try {
1668
+ const resp = await fetch(`${baseUrl}/api/baseserver/layout/teamsCheck?clientType=not_xinchuang&client=WEB&domainName=${encodeURIComponent(baseUrl)}`, {
1669
+ method: "POST",
1670
+ headers: {
1671
+ accept: "application/json",
1672
+ "content-type": "application/json",
1673
+ eteamsid: eteamsId,
1674
+ cookie: buildE10CookieHeader(rawCookie, eteamsId, agentType),
1675
+ "user-agent": agentType ? `AgentType=${agentType},IsAgent=true` : "weaver-work-cli",
1676
+ origin: baseUrl
1677
+ },
1678
+ redirect: "manual",
1679
+ signal
1680
+ });
1681
+ const data = await resp.json().catch((error) => {
1682
+ if (isAbortError(error)) throw error;
1683
+ return {};
1684
+ });
1685
+ return { userInfo: readTeamsCheckUserInfo(resp, data), setCookie: extractRawSetCookie(resp), status: resp.status };
1686
+ } catch (error) {
1687
+ if (isAbortError(error)) {
1688
+ throw tagXiaoEError(
1689
+ `E10 teamsCheck timed out after ${E10_TEAMS_CHECK_TIMEOUT_MS} ms.`,
1690
+ { errorKind: "network", stage: "teams_check", causeCode: "ETIMEDOUT" }
1691
+ );
1692
+ }
1693
+ if (error instanceof CliError) throw error;
1694
+ const causeCode = readErrorCauseCode(error);
1695
+ const message = error instanceof Error ? error.message : String(error);
1696
+ throw tagXiaoEError(
1697
+ `E10 teamsCheck request failed${causeCode ? ` (${causeCode})` : ""}: ${message}`,
1698
+ { errorKind: "network", stage: "teams_check", ...causeCode ? { causeCode } : {} }
1699
+ );
1700
+ } finally {
1701
+ clear();
1702
+ }
1478
1703
  }
1479
1704
  async function saveXiaoEUnifiedLogin(input) {
1480
1705
  const baseUrl = normalizeUrl(input.baseUrl);
1481
- const { userInfo, setCookie } = await resolveUserInfo(baseUrl, input.eteamsId, input.rawCookie || "", XIAOE_AGENT_TYPE);
1706
+ const { userInfo, setCookie, status } = await resolveUserInfo(baseUrl, input.eteamsId, input.rawCookie || "", XIAOE_AGENT_TYPE);
1482
1707
  if (!userInfo.userId) {
1483
- throw new CliError("Could not resolve userId. Check whether XiaoE unified login is valid for this E10 domain.", 3 /* AuthError */);
1708
+ const statusText = status || 0;
1709
+ throw classifyXiaoEHttpStatus(statusText) === "http" ? tagXiaoEError(`E10 teamsCheck returned HTTP ${statusText}.`, {
1710
+ errorKind: "http",
1711
+ stage: "teams_check",
1712
+ status: statusText
1713
+ }) : tagXiaoEError("Could not resolve userId. Check whether XiaoE unified login is valid for this E10 domain.", {
1714
+ errorKind: "credential",
1715
+ stage: "teams_check",
1716
+ status: statusText
1717
+ });
1484
1718
  }
1485
1719
  const tenantKey = userInfo.tenantKey || input.tenantKeyFallback || "";
1486
1720
  const profile = input.profileHint || profileNameFromUrl(baseUrl);
@@ -1537,41 +1771,67 @@ async function tryXiaoEUnifiedLogin(options = {}) {
1537
1771
  profileBaseUrl: options.profileBaseUrl,
1538
1772
  env
1539
1773
  });
1540
- const mayUseTokenScript = options.allowTokenScript === true;
1541
- if (!baseUrl && !mayUseTokenScript) return null;
1774
+ const mayUseTokenScript = options.allowTokenScript === true && !isXiaoECloudRuntime(env);
1775
+ const diagnostics = options.diagnostics;
1776
+ const platformCredentialDetected = hasXiaoEPlatformCredential(env);
1777
+ const secrets = [envString(env, "XIAOE_USER_TOKEN")];
1778
+ if (diagnostics) {
1779
+ diagnostics.baseUrl = baseUrl;
1780
+ diagnostics.platformCredentialDetected = platformCredentialDetected;
1781
+ diagnostics.clientType = resolveXiaoEClientType(env);
1782
+ }
1783
+ if (!baseUrl && !mayUseTokenScript) {
1784
+ noteXiaoEStep(diagnostics, "base_url:missing");
1785
+ return null;
1786
+ }
1542
1787
  let credential = null;
1543
- if (hasXiaoEPlatformCredential(env)) {
1788
+ if (platformCredentialDetected) {
1544
1789
  options.logger?.info("Trying XiaoE platform credential from XIAOE_USER_TOKEN...");
1545
1790
  try {
1546
1791
  credential = await resolveXiaoEPlatformCredential(baseUrl || DEFAULT_E10_BASE_URL, env);
1547
1792
  } catch (error) {
1548
1793
  const message = error instanceof Error ? error.message : String(error);
1794
+ noteXiaoEError(diagnostics, error, secrets, "platform_token");
1549
1795
  options.logger?.warn("XiaoE platform credential failed. " + message);
1550
1796
  }
1551
1797
  if (!credential) {
1552
1798
  options.logger?.warn(options.allowBundledEnvScript ? "XiaoE platform credential did not return usable ETEAMSID; will try the CLI-bundled xiaoe_env.py compatibility path next." : "XiaoE platform credential did not return usable ETEAMSID; will try xiaoeUserData/tokens.py next.");
1553
1799
  }
1554
1800
  }
1555
- if (!credential && options.allowBundledEnvScript && hasXiaoEPlatformCredential(env)) {
1556
- const scriptPath = xiaoEBundledEnvScriptPath();
1557
- if (!scriptPath) {
1558
- options.logger?.warn("CLI-bundled xiaoe_env.py was not found; will try desktop XiaoE credential sources next.");
1801
+ noteXiaoEStep(
1802
+ diagnostics,
1803
+ credential ? "platform_token:ok" : `platform_token:${platformCredentialDetected ? "failed" : "missing"}`
1804
+ );
1805
+ if (!credential) {
1806
+ if (!options.allowBundledEnvScript) {
1807
+ noteXiaoEStep(diagnostics, "bundled_env_script:disabled");
1808
+ } else if (!platformCredentialDetected) {
1809
+ noteXiaoEStep(diagnostics, "bundled_env_script:missing");
1559
1810
  } else {
1560
- options.logger?.info("Trying CLI-bundled xiaoe_env.py compatibility credential...");
1561
- try {
1562
- credential = await resolveXiaoEBundledEnvScriptCredential(baseUrl || DEFAULT_E10_BASE_URL, env);
1563
- } catch (error) {
1564
- const message = error instanceof Error ? error.message : String(error);
1565
- options.logger?.warn("CLI-bundled xiaoe_env.py failed. " + message);
1566
- }
1567
- if (!credential) {
1568
- options.logger?.warn("CLI-bundled xiaoe_env.py did not return usable ETEAMSID; will try xiaoeUserData/tokens.py next.");
1811
+ const scriptPath = xiaoEBundledEnvScriptPath();
1812
+ if (!scriptPath) {
1813
+ noteXiaoEStep(diagnostics, "bundled_env_script:missing");
1814
+ options.logger?.warn("CLI-bundled xiaoe_env.py was not found; will try desktop XiaoE credential sources next.");
1815
+ } else {
1816
+ options.logger?.info("Trying CLI-bundled xiaoe_env.py compatibility credential...");
1817
+ try {
1818
+ credential = await resolveXiaoEBundledEnvScriptCredential(baseUrl || DEFAULT_E10_BASE_URL, env);
1819
+ } catch (error) {
1820
+ const message = error instanceof Error ? error.message : String(error);
1821
+ noteXiaoEError(diagnostics, error, secrets, "bundled_env_script");
1822
+ options.logger?.warn("CLI-bundled xiaoe_env.py failed. " + message);
1823
+ }
1824
+ if (!credential) {
1825
+ options.logger?.warn("CLI-bundled xiaoe_env.py did not return usable ETEAMSID; will try xiaoeUserData/tokens.py next.");
1826
+ }
1827
+ noteXiaoEStep(diagnostics, `bundled_env_script:${credential ? "ok" : "failed"}`);
1569
1828
  }
1570
1829
  }
1571
1830
  }
1572
1831
  if (!credential && mayUseTokenScript) {
1573
1832
  const tokenScriptPath = xiaoETokenScriptPath(env);
1574
1833
  if (!tokenScriptPath) {
1834
+ noteXiaoEStep(diagnostics, "token_script:missing");
1575
1835
  options.logger?.warn("XiaoE token script not found. Expected xiaoeUserData/tokens.py; will try the local XiaoE client session next.");
1576
1836
  } else {
1577
1837
  options.logger?.info("Trying XiaoE token script credential...");
@@ -1579,11 +1839,13 @@ async function tryXiaoEUnifiedLogin(options = {}) {
1579
1839
  credential = await resolveXiaoETokenScriptCredential(baseUrl || DEFAULT_E10_BASE_URL, env);
1580
1840
  } catch (error) {
1581
1841
  const message = error instanceof Error ? error.message : String(error);
1842
+ noteXiaoEError(diagnostics, error, secrets, "token_script");
1582
1843
  options.logger?.warn("XiaoE token script failed. " + message);
1583
1844
  }
1584
1845
  if (!credential) {
1585
1846
  options.logger?.warn("XiaoE token script did not return usable ETEAMSID; will try the local XiaoE client session next.");
1586
1847
  }
1848
+ noteXiaoEStep(diagnostics, `token_script:${credential ? "ok" : "failed"}`);
1587
1849
  }
1588
1850
  if (!credential && hasXiaoEClientCredential(env)) {
1589
1851
  options.logger?.info("Trying built-in XiaoE client session credential...");
@@ -1591,18 +1853,29 @@ async function tryXiaoEUnifiedLogin(options = {}) {
1591
1853
  credential = await resolveXiaoEClientCredential(baseUrl || DEFAULT_E10_BASE_URL, env);
1592
1854
  } catch (error) {
1593
1855
  const message = error instanceof Error ? error.message : String(error);
1856
+ noteXiaoEError(diagnostics, error, secrets, "client_session");
1594
1857
  options.logger?.warn("Built-in XiaoE client credential failed. " + message);
1595
1858
  }
1596
1859
  if (!credential) {
1597
1860
  options.logger?.warn("Built-in XiaoE client credential did not return usable ETEAMSID; will try WEAVER_XIAOE_* credentials next.");
1598
1861
  }
1862
+ noteXiaoEStep(diagnostics, `client_session:${credential ? "ok" : "failed"}`);
1863
+ } else if (!credential) {
1864
+ noteXiaoEStep(diagnostics, "client_session:missing");
1599
1865
  }
1866
+ } else if (!credential) {
1867
+ noteXiaoEStep(diagnostics, "token_script:disabled");
1868
+ noteXiaoEStep(diagnostics, "client_session:disabled");
1600
1869
  }
1601
1870
  if (!credential && baseUrl) credential = resolveXiaoEUnifiedLoginCredential(baseUrl, env);
1602
- if (!credential) return null;
1871
+ if (!credential) {
1872
+ noteXiaoEStep(diagnostics, "environment_map:empty");
1873
+ return null;
1874
+ }
1875
+ noteXiaoEStep(diagnostics, `credential_source:${credential.source}`);
1603
1876
  options.logger?.info("Detected XiaoE unified login for this E10 domain. Trying XiaoE auth...");
1604
1877
  try {
1605
- return await saveXiaoEUnifiedLogin({
1878
+ const login = await saveXiaoEUnifiedLogin({
1606
1879
  baseUrl: credential.baseUrl || baseUrl || DEFAULT_E10_BASE_URL,
1607
1880
  eteamsId: credential.eteamsId,
1608
1881
  rawCookie: credential.rawCookie,
@@ -1611,8 +1884,16 @@ async function tryXiaoEUnifiedLogin(options = {}) {
1611
1884
  profileHint: options.profileHint,
1612
1885
  credentialSource: describeXiaoECredentialSource(credential.source)
1613
1886
  });
1887
+ noteXiaoEStep(diagnostics, "e10_session:ok");
1888
+ if (diagnostics) {
1889
+ delete diagnostics.lastError;
1890
+ delete diagnostics.failures;
1891
+ }
1892
+ return login;
1614
1893
  } catch (error) {
1615
1894
  const message = error instanceof Error ? error.message : String(error);
1895
+ noteXiaoEError(diagnostics, error, secrets, "e10_session");
1896
+ noteXiaoEStep(diagnostics, "e10_session:failed");
1616
1897
  options.logger?.warn("XiaoE unified login failed. " + message);
1617
1898
  return null;
1618
1899
  }
@@ -1647,6 +1928,7 @@ export {
1647
1928
  packagePath,
1648
1929
  packageFileUrl,
1649
1930
  normalizeGlobalOptions,
1931
+ readErrorCauseCode,
1650
1932
  getE10AuthRoot,
1651
1933
  getActiveProfile,
1652
1934
  setActiveProfile,
@@ -1668,9 +1950,13 @@ export {
1668
1950
  E10_REAUTH_GUIDANCE,
1669
1951
  E10_AUTH_REQUIRED_MESSAGE,
1670
1952
  E10_XIAOE_RECOVERY_FAILED_MESSAGE,
1953
+ E10_XIAOE_HOST_CREDENTIAL_MISSING_MESSAGE,
1954
+ E10_XIAOE_NETWORK_UNAVAILABLE_MESSAGE,
1671
1955
  E10_SESSION_EXPIRED_MESSAGE,
1672
1956
  isXiaoERuntimeAgent,
1673
1957
  XIAOE_AGENT_TYPE,
1958
+ summarizeXiaoEFailureKind,
1959
+ lastXiaoEFailure,
1674
1960
  hasXiaoEEnv,
1675
1961
  inspectXiaoEUnifiedLoginSources,
1676
1962
  resolveXiaoEPreferredBaseUrl,
@@ -11,11 +11,11 @@ import {
11
11
  createE10RequestRuntime,
12
12
  isE10SessionExpiredResponse,
13
13
  requireE10Session
14
- } from "./chunk-WFFNM65B.js";
14
+ } from "./chunk-SA6VBIHY.js";
15
15
  import {
16
16
  E10_SESSION_EXPIRED_MESSAGE,
17
17
  getActiveProfile
18
- } from "./chunk-4TEDNCON.js";
18
+ } from "./chunk-FOAA27U5.js";
19
19
 
20
20
  // src/shortcuts/im/host.ts
21
21
  import { createHash } from "node:crypto";
@@ -5,7 +5,7 @@ import {
5
5
  ebBusinessSuccess,
6
6
  meetingSuccess,
7
7
  meetingValidationError
8
- } from "./chunk-7BRU4EFH.js";
8
+ } from "./chunk-72CKAUAG.js";
9
9
 
10
10
  // src/shortcuts/meeting/operations/env.ts
11
11
  import { existsSync } from "node:fs";
@@ -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-NJKREDA3.js";
5
+ } from "./chunk-GEWYMQME.js";
6
6
 
7
7
  // src/shortcuts/meeting/operations/eb/cache.ts
8
8
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -3,13 +3,13 @@ const require = __esbuildCreateRequire(import.meta.url);
3
3
  import {
4
4
  readCache,
5
5
  writeCache
6
- } from "./chunk-I566ZYNF.js";
6
+ } from "./chunk-GHXCDPTM.js";
7
7
  import {
8
8
  SCHEMA_DATETIME_MINUTE,
9
9
  meetingSuccess,
10
10
  meetingValidationError,
11
11
  schemaOf
12
- } from "./chunk-7BRU4EFH.js";
12
+ } from "./chunk-72CKAUAG.js";
13
13
 
14
14
  // src/shortcuts/meeting/operations/eb/schedule.ts
15
15
  var SCHEDULE_TYPE_PATH = "/api/ebuilder/form/formdata/v2/getFormDataList/queryAgendaType";
@@ -110,9 +110,9 @@ async function runScheduleConflictFlow(env, input) {
110
110
  if (!employeeId) {
111
111
  throw meetingValidationError("schedule_employee_required", "\u53D6\u4E0D\u5230\u5F53\u524D\u767B\u5F55\u7528\u6237 id\uFF0C\u65E0\u6CD5\u89E6\u53D1 ESB \u65E5\u7A0B\u67E5\u8BE2");
112
112
  }
113
- const { createEsbHost } = await import("./host-256GVCAH.js");
113
+ const { createEsbHost } = await import("./host-YTODKMSL.js");
114
114
  const { createEsbContinuationSigner } = await import("./continuation-NLECEJPX.js");
115
- const { getEsbOperation } = await import("./registry-RXPN6BBT.js");
115
+ const { getEsbOperation } = await import("./registry-7FFOXIAW.js");
116
116
  const esbEnv = {
117
117
  ctx: env.ctx,
118
118
  host: createEsbHost(env.ctx),