weaver-work-cli 0.1.39 → 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 (197) hide show
  1. package/README.md +4 -2
  2. package/dist/chunks/{archive-ENZYBBME.js → archive-J4I6MCKF.js} +2 -2
  3. package/dist/chunks/{archive-oa-YWLEC5V4.js → archive-oa-BRZKKTO4.js} +2 -2
  4. package/dist/chunks/{asset-OOV6DWPA.js → asset-L7D4FAOZ.js} +2 -2
  5. package/dist/chunks/{asset-idle-RE632MY5.js → asset-idle-DADLLV75.js} +2 -2
  6. package/dist/chunks/{attachment-content-RWN2FCLL.js → attachment-content-K4C7VLWQ.js} +3 -3
  7. package/dist/chunks/{blog-PEPOJAL7.js → blog-BVGQ7NZL.js} +2 -2
  8. package/dist/chunks/{caizhilian-WYIQDVPJ.js → caizhilian-SAADNFD6.js} +2 -2
  9. package/dist/chunks/{calendar-CIARBAOX.js → calendar-Q7NQY5Z2.js} +61 -23
  10. package/dist/chunks/{chunk-F2EQXUEE.js → chunk-3KTFS4IA.js} +397 -159
  11. package/dist/chunks/{chunk-G2JSIUWF.js → chunk-4PD5NWAX.js} +89 -0
  12. package/dist/chunks/{chunk-HJYVHXUQ.js → chunk-4RAE6JXP.js} +1 -1
  13. package/dist/chunks/{chunk-CQHGNCK2.js → chunk-72CKAUAG.js} +41 -8
  14. package/dist/chunks/{chunk-K3RUEEOL.js → chunk-APVFJUQH.js} +2 -2
  15. package/dist/chunks/{chunk-BJGXMFGD.js → chunk-BBKDXQEC.js} +2 -2
  16. package/dist/chunks/chunk-BIPYLLVS.js +501 -0
  17. package/dist/chunks/{chunk-GVPJZXJ2.js → chunk-EKWAQSLU.js} +92 -50
  18. package/dist/chunks/{chunk-XXJOSZTQ.js → chunk-FOAA27U5.js} +381 -57
  19. package/dist/chunks/{chunk-I2HB737U.js → chunk-G4UR6NXN.js} +2 -2
  20. package/dist/chunks/{chunk-YS5DPN4T.js → chunk-GEWYMQME.js} +1 -1
  21. package/dist/chunks/{chunk-P2DAISYW.js → chunk-GHXCDPTM.js} +1 -1
  22. package/dist/chunks/{chunk-L4N7B7ZD.js → chunk-IZ7S7QUS.js} +4 -4
  23. package/dist/chunks/{chunk-NLK2RZKG.js → chunk-JPRO6ER2.js} +122 -2214
  24. package/dist/chunks/{chunk-36DIFZAH.js → chunk-LADPYOWC.js} +2 -2
  25. package/dist/chunks/chunk-LDZQPUIA.js +1238 -0
  26. package/dist/chunks/chunk-NKZRQXST.js +2546 -0
  27. package/dist/chunks/{chunk-EINRJHQ3.js → chunk-QKNKR4RH.js} +3 -3
  28. package/dist/chunks/{chunk-T7JDJJ7H.js → chunk-R4CHUSKC.js} +126 -19
  29. package/dist/chunks/{chunk-EZGFHJFW.js → chunk-SA6VBIHY.js} +88 -15
  30. package/dist/chunks/{chunk-ZXRNHZTE.js → chunk-TTPJJJC4.js} +2 -2
  31. package/dist/chunks/{chunk-KTCB5R5H.js → chunk-W7BEHOSR.js} +2 -2
  32. package/dist/chunks/{chunk-MUQUHKPG.js → chunk-YRSZQUD2.js} +2 -2
  33. package/dist/chunks/{conflict-DRMDOL56.js → conflict-F2OMZRTO.js} +2 -2
  34. package/dist/chunks/{contract-73MERZWN.js → contract-5BETHRSG.js} +2 -2
  35. package/dist/chunks/{cowork-HNGBPD7A.js → cowork-3MN6EQQO.js} +27 -10
  36. package/dist/chunks/create-flow-5FQNNMVO.js +55 -0
  37. package/dist/chunks/{ebuilder-form-OY6DVNRK.js → ebuilder-form-SBHOYBUD.js} +3 -3
  38. package/dist/chunks/{ehr-RAQNEQO7.js → ehr-KMOJULKG.js} +432 -1234
  39. package/dist/chunks/env-LB7NBL2O.js +19 -0
  40. package/dist/chunks/{esb-6XV7C7YV.js → esb-W2PJCFCX.js} +4 -4
  41. package/dist/chunks/factory-6ZFQXQ46.js +30 -0
  42. package/dist/chunks/{fna-XTSRB7G7.js → fna-ZQPCUV4R.js} +2 -2
  43. package/dist/chunks/group-chat-2HHAJN46.js +20 -0
  44. package/dist/chunks/{host-YMBXWFWX.js → host-4CBHGOHT.js} +3 -3
  45. package/dist/chunks/{host-A7J6GDUP.js → host-ATKVNZAT.js} +3 -3
  46. package/dist/chunks/{host-3F5UM5GN.js → host-BQH22NTQ.js} +3 -3
  47. package/dist/chunks/{host-YAQAPYNP.js → host-X2CSLFM6.js} +3 -3
  48. package/dist/chunks/{host-VGPVP7YF.js → host-YTODKMSL.js} +3 -3
  49. package/dist/chunks/{hrm-TLHKC545.js → hrm-FFM4UJFS.js} +4 -4
  50. package/dist/chunks/{im-YOUCFMUK.js → im-VEHKDQPB.js} +8 -8
  51. package/dist/chunks/{invoice-WNBS2B4C.js → invoice-LVIKSIIF.js} +3 -3
  52. package/dist/chunks/{jiuchuanhui-XABWS5RN.js → jiuchuanhui-X6DINO5P.js} +2 -2
  53. package/dist/chunks/{lazy-dispatch-NLZ5UQQI.js → lazy-dispatch-KSWTN5L6.js} +4 -4
  54. package/dist/chunks/{mail-LRYMBFNL.js → mail-VDKRGUD3.js} +9 -4
  55. package/dist/chunks/{meeting-ESXL6MFI.js → meeting-CLC6HP3Z.js} +12 -10
  56. package/dist/chunks/{okr-EOV65SSF.js → okr-CHG4OO3U.js} +2 -2
  57. package/dist/chunks/{plan-YFPVKW6Y.js → plan-XWR75667.js} +2 -2
  58. package/dist/chunks/{project-MDVZUYQW.js → project-5BXOOKMG.js} +40 -23
  59. package/dist/chunks/recruit-stage-DGMFNNDE.js +4507 -0
  60. package/dist/chunks/{registry-VT5Y2HLA.js → registry-7FFOXIAW.js} +4 -4
  61. package/dist/chunks/{registry-QCLZEDAP.js → registry-BKBZPBAJ.js} +10 -8
  62. package/dist/chunks/{registry-YX4CSEMD.js → registry-RHMW6ANW.js} +2 -2
  63. package/dist/chunks/{registry-NYPYMZXG.js → registry-Z43434VG.js} +1 -1
  64. package/dist/chunks/{room-recommend-L3MWH4JW.js → room-recommend-62H7ZQQ6.js} +4 -4
  65. package/dist/chunks/{schedule-UASAVDVD.js → schedule-FNXKH3DQ.js} +4 -4
  66. package/dist/chunks/{workflow-KDGIUCNW.js → workflow-ADHKCAJK.js} +4 -4
  67. package/dist/index.js +33 -28
  68. package/dist/internal/e10/auth/commands.js +110 -56
  69. package/dist/internal/e10/auth/messages.js +6 -0
  70. package/dist/internal/e10/auth/session.js +28 -1
  71. package/dist/internal/e10/auth/xiaoe.js +315 -48
  72. package/dist/internal/e10/auth-recovery.js +36 -5
  73. package/dist/internal/e10/client.js +13 -0
  74. package/dist/internal/e10/context.js +61 -9
  75. package/dist/internal/e10/index.js +1 -1
  76. package/dist/internal/e10/network-error.js +93 -0
  77. package/dist/internal/e10/request-runtime.js +15 -0
  78. package/dist/shortcuts/calendar/operations/read.js +31 -22
  79. package/dist/shortcuts/calendar/operations/write.js +45 -1
  80. package/dist/shortcuts/cowork/operations/discuss-write.js +5 -1
  81. package/dist/shortcuts/cowork/operations/item-write.js +5 -3
  82. package/dist/shortcuts/cowork/operations/member-write.js +3 -1
  83. package/dist/shortcuts/cowork/operations/permission-write.js +5 -1
  84. package/dist/shortcuts/cowork/operations/shared.js +7 -0
  85. package/dist/shortcuts/ehr/operations/attend-write.js +43 -1
  86. package/dist/shortcuts/ehr/operations/hr-contact.js +7 -4
  87. package/dist/shortcuts/ehr/operations/hr-report.js +13 -7
  88. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +134 -59
  89. package/dist/shortcuts/ehr/operations/recruit-write.js +262 -17
  90. package/dist/shortcuts/ehr/operations/recruit.js +10 -4
  91. package/dist/shortcuts/ehr/operations/shared.js +47 -0
  92. package/dist/shortcuts/hrm/operations/org.js +118 -0
  93. package/dist/shortcuts/index.js +5 -0
  94. package/dist/shortcuts/mail/operations/mail-send.js +8 -2
  95. package/dist/shortcuts/meeting/operations/eb/catalog.js +9 -2
  96. package/dist/shortcuts/meeting/operations/eb/create-flow.js +461 -127
  97. package/dist/shortcuts/meeting/operations/eb/crm-search.js +87 -5
  98. package/dist/shortcuts/meeting/operations/eb/factory.js +33 -0
  99. package/dist/shortcuts/meeting/operations/eb/flow-memory.js +49 -0
  100. package/dist/shortcuts/meeting/operations/eb/group-chat.js +605 -0
  101. package/dist/shortcuts/meeting/operations/eb/index.js +2 -0
  102. package/dist/shortcuts/meeting/operations/eb/person-cache.js +96 -0
  103. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +44 -6
  104. package/dist/shortcuts/meeting/operations/eb/room-summary.js +2 -0
  105. package/dist/shortcuts/meeting/operations/eb/usage-cache.js +99 -0
  106. package/dist/shortcuts/meeting/operations/from-group-chat.js +35 -12
  107. package/dist/shortcuts/project/operations/read.js +6 -25
  108. package/dist/shortcuts/project/operations/shared.js +22 -0
  109. package/dist/shortcuts/project/operations/write.js +28 -2
  110. package/dist/shortcuts/recruit-stage/context.js +119 -0
  111. package/dist/shortcuts/recruit-stage/continuation.js +73 -0
  112. package/dist/shortcuts/recruit-stage/errors.js +65 -0
  113. package/dist/shortcuts/recruit-stage/host.js +109 -0
  114. package/dist/shortcuts/recruit-stage/index.js +115 -0
  115. package/dist/shortcuts/recruit-stage/manifest.js +29 -0
  116. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +722 -0
  117. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +269 -0
  118. package/dist/shortcuts/recruit-stage/operations/jd-create.js +630 -0
  119. package/dist/shortcuts/recruit-stage/operations/list.js +431 -0
  120. package/dist/shortcuts/recruit-stage/operations/registry.js +38 -0
  121. package/dist/shortcuts/recruit-stage/operations/resume-import.js +1198 -0
  122. package/dist/shortcuts/recruit-stage/operations/search.js +158 -0
  123. package/dist/shortcuts/recruit-stage/operations/types.js +25 -0
  124. package/dist/shortcuts/recruit-stage/school-tiers.json +318 -0
  125. package/dist/shortcuts/recruit-stage/shared.js +608 -0
  126. package/dist/shortcuts/workflow/operations/form.js +21 -2
  127. package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +52 -1
  128. package/dist/shortcuts/workflow/operations/todoSmartConvert/detailFieldRules.js +4 -2
  129. package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +19 -11
  130. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +17 -24
  131. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +14 -9
  132. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +78 -10
  133. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +3 -1
  134. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +17 -11
  135. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +16 -40
  136. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +3 -2
  137. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +52 -15
  138. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.pipeline.js +16 -1
  139. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +151 -63
  140. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.subGroup.js +56 -0
  141. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +53 -16
  142. package/docs/e10-auth.md +22 -1
  143. package/docs/operation-manual.md +8 -0
  144. package/package.json +1 -1
  145. package/scripts/install-skill-to-xiaoe.mjs +105 -0
  146. package/scripts/mcp-meeting.mjs +234 -0
  147. package/scripts/package-skill.mjs +4 -2
  148. package/skill-template/business-info.json +24 -0
  149. package/skill-template/domains/recruit-stage.md +29 -0
  150. package/skills/weaver-e10-calendar/SKILL.md +2 -1
  151. package/skills/weaver-e10-calendar/references/calendar-write.md +54 -0
  152. package/skills/weaver-e10-cowork/SKILL.md +1 -1
  153. package/skills/weaver-e10-cowork/references/cowork-write.md +3 -1
  154. package/skills/weaver-e10-jucailin/SKILL.md +1 -1
  155. package/skills/weaver-e10-jucailin/references/attend-write.md +8 -0
  156. package/skills/weaver-e10-jucailin/references/hr-contact.md +8 -0
  157. package/skills/weaver-e10-jucailin/references/hr-report.md +8 -0
  158. package/skills/weaver-e10-jucailin/references/recruit-create.md +2 -2
  159. package/skills/weaver-e10-jucailin/references/recruit-read.md +1 -1
  160. package/skills/weaver-e10-jucailin/references/recruit-write.md +4 -3
  161. package/skills/weaver-e10-mail/SKILL.md +1 -1
  162. package/skills/weaver-e10-mail/references/mail-send.md +2 -0
  163. package/skills/weaver-e10-meeting/SKILL.md +119 -26
  164. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +25 -11
  165. package/skills/weaver-e10-meeting.zip +0 -0
  166. package/skills/weaver-e10-recruit-stage/SKILL.md +226 -0
  167. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +119 -0
  168. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +188 -0
  169. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +322 -0
  170. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +127 -0
  171. package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +65 -0
  172. package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +63 -0
  173. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +142 -0
  174. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +73 -0
  175. package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +56 -0
  176. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +101 -0
  177. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +148 -0
  178. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +77 -0
  179. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +59 -0
  180. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +69 -0
  181. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +241 -0
  182. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +438 -0
  183. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +128 -0
  184. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +146 -0
  185. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +69 -0
  186. package/skills/weaver-e10-shared/SKILL.md +2 -2
  187. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
  188. package/skills/weaver-e10-shijingran/SKILL.md +3 -2
  189. package/skills/weaver-e10-shijingran/references/operations.md +3 -1
  190. package/skills/weaver-e10-shijingran/references/source-manifest.json +41 -40
  191. package/skills/weaver-e10-shijingran/references/write-operations.md +2 -0
  192. package/skills/weaver-e10-workflow/SKILL.md +7 -1
  193. package/skills/weaver-e10-workflow/aigroup/default.json +23 -9
  194. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +37 -21
  195. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +135 -43
  196. package/skills/weaver-e10-yepiaotong/SKILL.md +9 -10
  197. package/skills/weaver-e10-yepiaotong/references/invoice-agent-entry.md +6 -3
@@ -19,7 +19,7 @@ import {
19
19
  } from "./chunk-AJ62BGAW.js";
20
20
  import {
21
21
  clearInvoiceTokenForSession
22
- } from "./chunk-ZXRNHZTE.js";
22
+ } from "./chunk-TTPJJJC4.js";
23
23
  import {
24
24
  E10AuthSession,
25
25
  XIAOE_AGENT_TYPE,
@@ -48,7 +48,7 @@ import {
48
48
  setActiveProfile,
49
49
  switchActiveProfile,
50
50
  tryXiaoEUnifiedLogin
51
- } from "./chunk-XXJOSZTQ.js";
51
+ } from "./chunk-FOAA27U5.js";
52
52
  import {
53
53
  CliError,
54
54
  isCliError,
@@ -3547,6 +3547,7 @@ var AGENT_RETURN_URL_ENV_KEY = "WEAVER_AGENT_RETURN_URL";
3547
3547
  var AGENT_RETURN_PATH = "/agent-return";
3548
3548
  var AGENT_RETURN_TOKEN_HEADER = "x-weaver-agent-return-token";
3549
3549
  var AGENT_RETURN_TIMEOUT_MS = 9e5;
3550
+ var OAUTH_CALLBACK_PROTOCOL_MISMATCH_GRACE_MS = 3e4;
3550
3551
  var UNSAFE_AGENT_RETURN_PROTOCOLS = /* @__PURE__ */ new Set([
3551
3552
  "about:",
3552
3553
  "blob:",
@@ -3698,7 +3699,8 @@ function formatAuthStatus(status) {
3698
3699
  ..."loginSource" in status && status.loginSource ? ["loginSource: " + status.loginSource] : [],
3699
3700
  ..."credentialSourceStep" in status && status.credentialSourceStep ? ["credentialSourceStep: " + status.credentialSourceStep] : [],
3700
3701
  ..."credentialSourceType" in status && status.credentialSourceType ? ["credentialSourceType: " + status.credentialSourceType] : [],
3701
- ..."credentialSourceLabel" in status && status.credentialSourceLabel ? ["credentialSourceLabel: " + status.credentialSourceLabel] : []
3702
+ ..."credentialSourceLabel" in status && status.credentialSourceLabel ? ["credentialSourceLabel: " + status.credentialSourceLabel] : [],
3703
+ ..."expiryTimes" in status && status.expiryTimes ? ["expiryTimes: " + status.expiryTimes] : []
3702
3704
  ];
3703
3705
  if ("valid" in status) {
3704
3706
  lines.push("valid: " + String(status.valid));
@@ -3717,7 +3719,8 @@ function formatLoginResult(result) {
3717
3719
  ...result.loginSource ? ["loginSource: " + result.loginSource] : [],
3718
3720
  ...result.credentialSourceStep ? ["credentialSourceStep: " + result.credentialSourceStep] : [],
3719
3721
  ...result.credentialSourceType ? ["credentialSourceType: " + result.credentialSourceType] : [],
3720
- ...result.credentialSourceLabel ? ["credentialSourceLabel: " + result.credentialSourceLabel] : []
3722
+ ...result.credentialSourceLabel ? ["credentialSourceLabel: " + result.credentialSourceLabel] : [],
3723
+ ...result.expiryTimes ? ["expiryTimes: " + result.expiryTimes] : []
3721
3724
  ].join("\n");
3722
3725
  }
3723
3726
  async function clearInvoiceTokenCache(profile, authData) {
@@ -3787,6 +3790,22 @@ function buildE10AuthorizeUrl(baseUrl, redirectUri, agentType) {
3787
3790
  });
3788
3791
  return `${baseUrl}/papi/sso/oauth2.0/authorize?${authorizeParams.toString()}`;
3789
3792
  }
3793
+ function isTlsClientHello(error) {
3794
+ if (!error || typeof error !== "object") return false;
3795
+ const rawPacket = error.rawPacket;
3796
+ return Buffer.isBuffer(rawPacket) && rawPacket.length >= 3 && rawPacket[0] === 22 && rawPacket[1] === 3;
3797
+ }
3798
+ function createOAuthCallbackProtocolMismatchError(port) {
3799
+ return Object.assign(new CliError(
3800
+ `OAuth callback protocol mismatch: the browser connected to https://127.0.0.1:${port}, but the CLI callback listener uses HTTP. Retry the login and, on the callback error page, change only the URL scheme to http:// before reloading; keep the path and query unchanged. The E10 authorization service should preserve HTTP loopback redirect URIs.`,
3801
+ 3 /* AuthError */
3802
+ ), {
3803
+ type: "authentication",
3804
+ subtype: "oauth_callback_protocol_mismatch",
3805
+ retryable: false,
3806
+ stage: "oauth_callback"
3807
+ });
3808
+ }
3790
3809
  async function readJsonObject(resp) {
3791
3810
  const data = await resp.json().catch(() => ({}));
3792
3811
  return data && typeof data === "object" && !Array.isArray(data) ? data : {};
@@ -3962,7 +3981,7 @@ function xiaoEUnifiedLoginUnavailableMessage(baseUrl, attempted) {
3962
3981
  "CLI \u4F1A\u4F18\u5148\u4F7F\u7528 XiaoE \u5BA2\u6237\u7AEF\u5185\u7F6E Python \u6267\u884C tokens.py\uFF1B\u81EA\u52A8\u53D1\u73B0\u4E0D\u53EF\u7528\u65F6\uFF0C\u53EF\u7528 WEAVER_XIAOE_TOKEN_SCRIPT_PYTHON \u6307\u5B9A\u517C\u5BB9\u89E3\u91CA\u5668\u3002"
3963
3982
  ].join(" ");
3964
3983
  }
3965
- async function runBrowserLogin(ctx, options, behavior = {}) {
3984
+ async function runXiaoELogin(ctx, options) {
3966
3985
  const commandOpts = asOptions(options);
3967
3986
  const globalOptions = ctx.getGlobalOptions();
3968
3987
  const profileFromGlobal = globalOptions.profile;
@@ -3973,52 +3992,49 @@ async function runBrowserLogin(ctx, options, behavior = {}) {
3973
3992
  profileBaseUrl: cfg.baseUrl,
3974
3993
  env: ctx.env
3975
3994
  });
3976
- const xiaoESources = behavior.tryXiaoEUnifiedLogin === true ? inspectXiaoEUnifiedLoginSources({
3995
+ const xiaoESources = inspectXiaoEUnifiedLoginSources({
3977
3996
  env: ctx.env,
3978
3997
  baseUrl: preferredXiaoEBaseUrl,
3979
3998
  profileBaseUrl: cfg.baseUrl,
3980
- allowTokenScript: behavior.allowXiaoETokenScript === true
3981
- }) : {
3982
- platformCredential: false,
3983
- tokenScript: false,
3984
- clientCredential: false,
3985
- environmentCredential: false,
3986
- any: false
3987
- };
3988
- const useXiaoELogin = behavior.tryXiaoEUnifiedLogin === true && xiaoESources.any;
3989
- const baseUrl = behavior.tryXiaoEUnifiedLogin ? preferredXiaoEBaseUrl : normalizeUrl(explicitBaseUrl || cfg.baseUrl || "");
3999
+ allowTokenScript: true
4000
+ });
4001
+ const useXiaoELogin = xiaoESources.any;
4002
+ const baseUrl = preferredXiaoEBaseUrl;
4003
+ const tenantKey = optionString(commandOpts, "tenantKey");
4004
+ ctx.logger.info([
4005
+ "XiaoE unified login preflight:",
4006
+ "authMode=xiaoe",
4007
+ `credentialSourceDetected=${String(xiaoESources.any)}`,
4008
+ `attempted=${String(useXiaoELogin)}`,
4009
+ `platformCredentialDetected=${String(xiaoESources.platformCredential)}`,
4010
+ `tokenScriptDetected=${String(xiaoESources.tokenScript)}`,
4011
+ `clientSettingsDetected=${String(xiaoESources.clientCredential)}`,
4012
+ `environmentCredentialDetected=${String(xiaoESources.environmentCredential)}`,
4013
+ `clientType=${xiaoESources.clientType || "(unset)"}`,
4014
+ `baseUrl=${baseUrl || "(unresolved)"}`
4015
+ ].join(" "));
4016
+ if (useXiaoELogin) {
4017
+ const xiaoEResult = await tryXiaoEUnifiedLogin2(ctx, baseUrl, tenantKey, profileFromGlobal, true);
4018
+ if (xiaoEResult) return xiaoEResult;
4019
+ }
4020
+ ctx.logger.warn(xiaoEUnifiedLoginUnavailableMessage(baseUrl, useXiaoELogin));
4021
+ throw createXiaoEUnifiedLoginUnavailableError(baseUrl);
4022
+ }
4023
+ async function runBrowserLogin(ctx, options) {
4024
+ const commandOpts = asOptions(options);
4025
+ const globalOptions = ctx.getGlobalOptions();
4026
+ const profileFromGlobal = globalOptions.profile;
4027
+ const cfg = readProfileConfig(profileFromGlobal || getActiveProfile());
4028
+ const explicitBaseUrl = optionString(commandOpts, "baseUrl") || globalOptions.baseUrl || "";
4029
+ const baseUrl = normalizeUrl(explicitBaseUrl || cfg.baseUrl || "");
3990
4030
  const tenantKey = optionString(commandOpts, "tenantKey");
3991
4031
  const portText = optionString(commandOpts, "port") || "19800";
3992
4032
  const port = Number.parseInt(portText, 10);
3993
4033
  const explicitAgentType = optionString(commandOpts, "agentType", "agent_type");
3994
- const agentType = useXiaoELogin ? optionString(commandOpts, "agentType", "agent_type") || XIAOE_AGENT_TYPE : resolveAgentType(commandOpts, ctx.env);
4034
+ const agentType = resolveAgentType(commandOpts, ctx.env);
3995
4035
  if (!Number.isInteger(port) || port <= 0 || port > 65535) {
3996
4036
  throw new CliError("Invalid --port value", 2 /* UsageError */);
3997
4037
  }
3998
- if (behavior.tryXiaoEUnifiedLogin) {
3999
- ctx.logger.info([
4000
- "XiaoE unified login preflight:",
4001
- "authMode=xiaoe",
4002
- `credentialSourceDetected=${String(xiaoESources.any)}`,
4003
- `attempted=${String(useXiaoELogin)}`,
4004
- `platformCredentialDetected=${String(xiaoESources.platformCredential)}`,
4005
- `tokenScriptDetected=${String(xiaoESources.tokenScript)}`,
4006
- `clientSettingsDetected=${String(xiaoESources.clientCredential)}`,
4007
- `environmentCredentialDetected=${String(xiaoESources.environmentCredential)}`,
4008
- `baseUrl=${baseUrl || "(unresolved)"}`
4009
- ].join(" "));
4010
- }
4011
- if (useXiaoELogin) {
4012
- const xiaoEResult = await tryXiaoEUnifiedLogin2(ctx, baseUrl, tenantKey, profileFromGlobal, behavior.allowXiaoETokenScript === true);
4013
- if (xiaoEResult) return xiaoEResult;
4014
- }
4015
- const willOpenBrowser = behavior.browserFallback !== "never";
4016
- if (behavior.tryXiaoEUnifiedLogin && behavior.explainXiaoEFallback) {
4017
- ctx.logger.warn(xiaoEUnifiedLoginUnavailableMessage(baseUrl, useXiaoELogin));
4018
- }
4019
- if (!willOpenBrowser) {
4020
- throw createXiaoEUnifiedLoginUnavailableError(baseUrl);
4021
- }
4022
4038
  if (!baseUrl) throw new CliError("Missing --base-url", 2 /* UsageError */);
4023
4039
  const agentReturnTarget = resolveAgentReturnTarget(commandOpts, ctx.env, agentType);
4024
4040
  const agentReturnToken = agentReturnTarget ? randomBytes(24).toString("base64url") : "";
@@ -4030,6 +4046,7 @@ async function runBrowserLogin(ctx, options, behavior = {}) {
4030
4046
  let settled = false;
4031
4047
  let timer = null;
4032
4048
  let pendingLoginResult = null;
4049
+ let tlsCallbackDetected = false;
4033
4050
  const finish = (error, result) => {
4034
4051
  if (settled) return;
4035
4052
  settled = true;
@@ -4100,6 +4117,10 @@ async function runBrowserLogin(ctx, options, behavior = {}) {
4100
4117
  finish(new CliError("No authorization code received.", 3 /* AuthError */));
4101
4118
  return;
4102
4119
  }
4120
+ if (tlsCallbackDetected && timer) {
4121
+ clearTimeout(timer);
4122
+ timer = null;
4123
+ }
4103
4124
  try {
4104
4125
  const result = await oidcExchange(code, redirectUri, baseUrl, tenantKey, redirectAgentType, profileFromGlobal);
4105
4126
  const responseHeaders = {
@@ -4130,6 +4151,25 @@ async function runBrowserLogin(ctx, options, behavior = {}) {
4130
4151
  const message = error.code === "EADDRINUSE" ? `Port ${port} is already in use. Retry with --port ${port + 1}.` : error.code === "EACCES" ? `Port ${port} is not accessible. Retry with another --port.` : error.message;
4131
4152
  finish(new CliError(message, 2 /* UsageError */));
4132
4153
  });
4154
+ server.on("clientError", (error, socket) => {
4155
+ if (isTlsClientHello(error)) {
4156
+ if (!tlsCallbackDetected) {
4157
+ tlsCallbackDetected = true;
4158
+ ctx.logger.warn([
4159
+ `OAuth callback protocol mismatch: the browser used HTTPS for 127.0.0.1:${port}, while the CLI listener is HTTP.`,
4160
+ "\u5728 30 \u79D2\u5185\u628A\u6D4F\u89C8\u5668\u5F53\u524D\u5730\u5740\u5F00\u5934\u660E\u786E\u6539\u4E3A http://\uFF0C\u4FDD\u7559\u540E\u9762\u7684\u5B8C\u6574\u8DEF\u5F84\u548C\u53C2\u6570\uFF0C\u7136\u540E\u56DE\u8F66\u91CD\u8BD5\u3002",
4161
+ "\u4E0D\u8981\u628A\u5730\u5740\u4E2D\u7684\u6388\u6743\u7801\u590D\u5236\u5230\u804A\u5929\u6216\u65E5\u5FD7\u3002"
4162
+ ].join(" "));
4163
+ if (timer) clearTimeout(timer);
4164
+ timer = setTimeout(() => {
4165
+ finish(createOAuthCallbackProtocolMismatchError(port));
4166
+ }, OAUTH_CALLBACK_PROTOCOL_MISMATCH_GRACE_MS);
4167
+ }
4168
+ socket.destroy();
4169
+ return;
4170
+ }
4171
+ socket.destroy();
4172
+ });
4133
4173
  server.listen(port, "127.0.0.1", () => {
4134
4174
  ctx.logger.info("Local callback server: " + redirectUri);
4135
4175
  openUrlInBrowser(loginUrl, ctx);
@@ -4173,10 +4213,16 @@ function formatWhoami(title, data) {
4173
4213
  "User-Agent: " + (data.userAgent || "")
4174
4214
  ].join("\n");
4175
4215
  }
4176
- function registerBrowserLoginCommand(auth, action, name, description, behavior = {}) {
4216
+ function registerBrowserLoginCommand(auth, action, name, description) {
4177
4217
  const command = auth.command(name).description(description).option("--base-url <url>", "E10 base URL").option("--tenant-key <key>", "Tenant key fallback after login").option("--port <n>", "Local OAuth callback port", "19800").option("--agent_type <value>", "Agent type sent to E10 authorize endpoint").option("--agent-type <value>", "Alias of --agent_type").option("--agent-return-url <url>", "Desktop application URL linked by the login success page");
4178
4218
  command.action(action(async (ctx, options) => {
4179
- const result = await runBrowserLogin(ctx, options, behavior);
4219
+ const result = await runBrowserLogin(ctx, options);
4220
+ ctx.output.write(result, { text: formatLoginResult(result) });
4221
+ }));
4222
+ }
4223
+ function registerXiaoELoginCommand(auth, action) {
4224
+ auth.command("xiaoe").description("Use XiaoE unified login without browser OAuth fallback").option("--base-url <url>", "E10 base URL").option("--tenant-key <key>", "Tenant key fallback after login").option("--port <n>", "Deprecated compatibility option; ignored by XiaoE unified login", "19800").option("--agent_type <value>", "Deprecated compatibility option; ignored by XiaoE unified login").option("--agent-type <value>", "Alias of --agent_type").option("--agent-return-url <url>", "Deprecated compatibility option; ignored by XiaoE unified login").action(action(async (ctx, options) => {
4225
+ const result = await runXiaoELogin(ctx, options);
4180
4226
  ctx.output.write(result, { text: formatLoginResult(result) });
4181
4227
  }));
4182
4228
  }
@@ -4191,7 +4237,7 @@ function registerE10AuthCommands(parent, action) {
4191
4237
  const commandOpts = asOptions(options);
4192
4238
  const authFile = findAuthFile(ctx.cwd, opts);
4193
4239
  const session = authFile ? E10AuthSession.fromFile(authFile, opts.baseUrl, opts.passportUrl) : null;
4194
- const valid = session && commandOpts.check !== false ? await session.checkValid() : void 0;
4240
+ const valid = session && commandOpts.check !== false ? session.isExpired() ? false : await session.checkValid() : void 0;
4195
4241
  const status = session ? {
4196
4242
  loggedIn: true,
4197
4243
  userId: session.userId,
@@ -4211,6 +4257,7 @@ function registerE10AuthCommands(parent, action) {
4211
4257
  ...session.credentialSourceStep ? { credentialSourceStep: session.credentialSourceStep } : {},
4212
4258
  ...session.credentialSourceType ? { credentialSourceType: session.credentialSourceType } : {},
4213
4259
  ...session.credentialSourceLabel ? { credentialSourceLabel: session.credentialSourceLabel } : {},
4260
+ ...session.expiryTimes ? { expiryTimes: session.expiryTimes } : {},
4214
4261
  valid
4215
4262
  } : {
4216
4263
  loggedIn: false,
@@ -4244,12 +4291,7 @@ function registerE10AuthCommands(parent, action) {
4244
4291
  }));
4245
4292
  registerBrowserLoginCommand(auth, action, "login", "Open browser OAuth2.0 login and save E10 auth");
4246
4293
  registerBrowserLoginCommand(auth, action, "oidc", "Alias of auth login for OAuth2.0 browser login");
4247
- registerBrowserLoginCommand(auth, action, "xiaoe", "Use XiaoE unified login without browser OAuth fallback", {
4248
- tryXiaoEUnifiedLogin: true,
4249
- allowXiaoETokenScript: true,
4250
- explainXiaoEFallback: true,
4251
- browserFallback: "never"
4252
- });
4294
+ registerXiaoELoginCommand(auth, action);
4253
4295
  auth.command("logout").alias("clear").description("Clear saved E10 auth for the current or selected profile").action(action(async (ctx) => {
4254
4296
  const opts = ctx.getGlobalOptions();
4255
4297
  const profile2 = opts.profile || getActiveProfile();