weaver-work-cli 0.1.1 → 0.1.4

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 (351) hide show
  1. package/README.md +187 -76
  2. package/dist/cmd/setup/index.js +5 -5
  3. package/dist/cmd/skills/index.js +1 -1
  4. package/dist/core/hooks.js +7 -0
  5. package/dist/index.js +0 -0
  6. package/dist/internal/e10/auth/commands.js +160 -55
  7. package/dist/internal/e10/auth/crypto.js +7 -22
  8. package/dist/internal/e10/auth/session.js +1 -1
  9. package/dist/internal/e10/auth/xiaoe.js +268 -0
  10. package/dist/internal/e10/context.js +16 -2
  11. package/dist/internal/e10/index.js +1 -0
  12. package/dist/internal/e10/request-runtime.js +344 -0
  13. package/dist/internal/skills/install.js +48 -6
  14. package/dist/internal/skills/reader.js +27 -0
  15. package/dist/shortcuts/archive/continuation.js +70 -0
  16. package/dist/shortcuts/archive/errors.js +53 -0
  17. package/dist/shortcuts/archive/host.js +197 -0
  18. package/dist/shortcuts/archive/index.js +363 -0
  19. package/dist/shortcuts/archive/manifest.js +45 -0
  20. package/dist/shortcuts/archive/operations/archive-info.js +55 -0
  21. package/dist/shortcuts/archive/operations/borrow-car.js +146 -0
  22. package/dist/shortcuts/archive/operations/borrow-list.js +200 -0
  23. package/dist/shortcuts/archive/operations/confirm.js +46 -0
  24. package/dist/shortcuts/archive/operations/download.js +238 -0
  25. package/dist/shortcuts/archive/operations/flow-url.js +240 -0
  26. package/dist/shortcuts/archive/operations/fonds.js +95 -0
  27. package/dist/shortcuts/archive/operations/getPageUrl.js +137 -0
  28. package/dist/shortcuts/archive/operations/registry.js +43 -0
  29. package/dist/shortcuts/archive/operations/search.js +88 -0
  30. package/dist/shortcuts/archive/operations/shared.js +120 -0
  31. package/dist/shortcuts/archive/operations/types.js +23 -0
  32. package/dist/shortcuts/archive/operations/upload.js +182 -0
  33. package/dist/shortcuts/archive/operations.js +13 -0
  34. package/dist/shortcuts/archive/render/search-format.js +276 -0
  35. package/dist/shortcuts/archive/render/search-view.js +125 -0
  36. package/dist/shortcuts/asset/continuation.js +70 -0
  37. package/dist/shortcuts/asset/errors.js +67 -0
  38. package/dist/shortcuts/asset/host.js +438 -0
  39. package/dist/shortcuts/asset/index.js +255 -0
  40. package/dist/shortcuts/asset/manifest.js +471 -0
  41. package/dist/shortcuts/asset/operations/query.js +249 -0
  42. package/dist/shortcuts/asset/operations/registry.js +85 -0
  43. package/dist/shortcuts/asset/operations/shared.js +100 -0
  44. package/dist/shortcuts/asset/operations/type-cache.js +49 -0
  45. package/dist/shortcuts/asset/operations/types.js +1 -0
  46. package/dist/shortcuts/asset/operations/viewlink.js +117 -0
  47. package/dist/shortcuts/asset/operations/write.js +435 -0
  48. package/dist/shortcuts/asset/operations.js +9 -0
  49. package/dist/shortcuts/calendar/continuation.js +70 -0
  50. package/dist/shortcuts/calendar/errors.js +53 -0
  51. package/dist/shortcuts/calendar/host.js +148 -0
  52. package/dist/shortcuts/calendar/index.js +125 -0
  53. package/dist/shortcuts/calendar/manifest.js +26 -0
  54. package/dist/shortcuts/calendar/operations/read.js +259 -0
  55. package/dist/shortcuts/calendar/operations/registry.js +31 -0
  56. package/dist/shortcuts/calendar/operations/shared.js +132 -0
  57. package/dist/shortcuts/calendar/operations/types.js +25 -0
  58. package/dist/shortcuts/calendar/operations/write.js +439 -0
  59. package/dist/shortcuts/calendar/operations.js +8 -0
  60. package/dist/shortcuts/ehr/continuation.js +70 -0
  61. package/dist/shortcuts/ehr/errors.js +53 -0
  62. package/dist/shortcuts/ehr/host.js +213 -0
  63. package/dist/shortcuts/ehr/index.js +205 -0
  64. package/dist/shortcuts/ehr/manifest.js +47 -0
  65. package/dist/shortcuts/ehr/operations/attend-read.js +373 -0
  66. package/dist/shortcuts/ehr/operations/attend-write.js +514 -0
  67. package/dist/shortcuts/ehr/operations/hr-contact.js +363 -0
  68. package/dist/shortcuts/ehr/operations/hr-ds.js +298 -0
  69. package/dist/shortcuts/ehr/operations/hr-report.js +386 -0
  70. package/dist/shortcuts/ehr/operations/recruit-write.js +1629 -0
  71. package/dist/shortcuts/ehr/operations/recruit.js +803 -0
  72. package/dist/shortcuts/ehr/operations/registry.js +43 -0
  73. package/dist/shortcuts/ehr/operations/salary.js +319 -0
  74. package/dist/shortcuts/ehr/operations/shared.js +246 -0
  75. package/dist/shortcuts/ehr/operations/types.js +25 -0
  76. package/dist/shortcuts/ehr/operations.js +25 -0
  77. package/dist/shortcuts/esb/continuation.js +70 -0
  78. package/dist/shortcuts/esb/errors.js +65 -0
  79. package/dist/shortcuts/esb/host.js +187 -0
  80. package/dist/shortcuts/esb/index.js +112 -0
  81. package/dist/shortcuts/esb/manifest.js +91 -0
  82. package/dist/shortcuts/esb/operations/input-format.js +31 -0
  83. package/dist/shortcuts/esb/operations/registry.js +48 -0
  84. package/dist/shortcuts/esb/operations/shared.js +152 -0
  85. package/dist/shortcuts/esb/operations/trigger.js +76 -0
  86. package/dist/shortcuts/esb/operations/types.js +21 -0
  87. package/dist/shortcuts/esb/operations.js +15 -0
  88. package/dist/shortcuts/fna/continuation.js +70 -0
  89. package/dist/shortcuts/fna/errors.js +59 -0
  90. package/dist/shortcuts/fna/host.js +146 -0
  91. package/dist/shortcuts/fna/index.js +111 -0
  92. package/dist/shortcuts/fna/manifest.js +41 -0
  93. package/dist/shortcuts/fna/operations/budget.js +124 -0
  94. package/dist/shortcuts/fna/operations/expense-center.js +148 -0
  95. package/dist/shortcuts/fna/operations/invoice-writeoff.js +212 -0
  96. package/dist/shortcuts/fna/operations/loan.js +195 -0
  97. package/dist/shortcuts/fna/operations/registry.js +35 -0
  98. package/dist/shortcuts/fna/operations/shared.js +210 -0
  99. package/dist/shortcuts/fna/operations/types.js +25 -0
  100. package/dist/shortcuts/fna/operations.js +19 -0
  101. package/dist/shortcuts/hrm/errors.js +38 -0
  102. package/dist/shortcuts/hrm/host.js +156 -0
  103. package/dist/shortcuts/hrm/index.js +111 -0
  104. package/dist/shortcuts/hrm/manifest.js +32 -0
  105. package/dist/shortcuts/hrm/operations/employee.js +338 -0
  106. package/dist/shortcuts/hrm/operations/org.js +110 -0
  107. package/dist/shortcuts/hrm/operations/position.js +176 -0
  108. package/dist/shortcuts/hrm/operations/registry.js +33 -0
  109. package/dist/shortcuts/hrm/operations/shared.js +143 -0
  110. package/dist/shortcuts/hrm/operations/types.js +23 -0
  111. package/dist/shortcuts/hrm/operations.js +19 -0
  112. package/dist/shortcuts/index.js +20 -0
  113. package/dist/shortcuts/invoice/host.js +99 -94
  114. package/dist/shortcuts/invoice/index.js +65 -61
  115. package/dist/shortcuts/invoice/manifest.js +222 -14
  116. package/dist/shortcuts/invoice/operations/browse-field.js +17 -0
  117. package/dist/shortcuts/invoice/operations/issuing.js +198 -0
  118. package/dist/shortcuts/invoice/operations/ocr-preview.js +6 -3
  119. package/dist/shortcuts/invoice/operations/registry.js +17 -0
  120. package/dist/shortcuts/invoice/operations/reim.js +401 -0
  121. package/dist/shortcuts/invoice/operations/shared.js +271 -6
  122. package/dist/shortcuts/invoice/operations/validate-preview.js +1 -1
  123. package/dist/shortcuts/jiuchuanhui/cache.js +441 -0
  124. package/dist/shortcuts/jiuchuanhui/continuation.js +70 -0
  125. package/dist/shortcuts/jiuchuanhui/errors.js +59 -0
  126. package/dist/shortcuts/jiuchuanhui/host.js +159 -0
  127. package/dist/shortcuts/jiuchuanhui/index.js +109 -0
  128. package/dist/shortcuts/jiuchuanhui/manifest.js +469 -0
  129. package/dist/shortcuts/jiuchuanhui/operations/datajson.js +214 -0
  130. package/dist/shortcuts/jiuchuanhui/operations/esb.js +157 -0
  131. package/dist/shortcuts/jiuchuanhui/operations/generic.js +146 -0
  132. package/dist/shortcuts/jiuchuanhui/operations/registry.js +133 -0
  133. package/dist/shortcuts/jiuchuanhui/operations/shared.js +158 -0
  134. package/dist/shortcuts/jiuchuanhui/operations/types.js +1 -0
  135. package/dist/shortcuts/jiuchuanhui/operations.js +8 -0
  136. package/dist/shortcuts/mail/continuation.js +70 -0
  137. package/dist/shortcuts/mail/errors.js +53 -0
  138. package/dist/shortcuts/mail/host.js +182 -0
  139. package/dist/shortcuts/mail/index.js +519 -0
  140. package/dist/shortcuts/mail/manifest.js +38 -0
  141. package/dist/shortcuts/mail/operations/mail-blacklist.js +79 -0
  142. package/dist/shortcuts/mail/operations/mail-contacts.js +195 -0
  143. package/dist/shortcuts/mail/operations/mail-manage.js +335 -0
  144. package/dist/shortcuts/mail/operations/mail-read.js +508 -0
  145. package/dist/shortcuts/mail/operations/mail-send.js +474 -0
  146. package/dist/shortcuts/mail/operations/mail-sign.js +203 -0
  147. package/dist/shortcuts/mail/operations/mail-template.js +170 -0
  148. package/dist/shortcuts/mail/operations/registry.js +41 -0
  149. package/dist/shortcuts/mail/operations/shared.js +64 -0
  150. package/dist/shortcuts/mail/operations/types.js +27 -0
  151. package/dist/shortcuts/mail/operations.js +19 -0
  152. package/dist/shortcuts/plan/continuation.js +70 -0
  153. package/dist/shortcuts/plan/errors.js +70 -0
  154. package/dist/shortcuts/plan/host.js +180 -0
  155. package/dist/shortcuts/plan/index.js +150 -0
  156. package/dist/shortcuts/plan/manifest.js +53 -0
  157. package/dist/shortcuts/plan/operations/link.js +256 -0
  158. package/dist/shortcuts/plan/operations/read.js +259 -0
  159. package/dist/shortcuts/plan/operations/registry.js +33 -0
  160. package/dist/shortcuts/plan/operations/shared.js +246 -0
  161. package/dist/shortcuts/plan/operations/types.js +49 -0
  162. package/dist/shortcuts/plan/operations/version.js +49 -0
  163. package/dist/shortcuts/plan/operations/write.js +710 -0
  164. package/dist/shortcuts/plan/operations.js +8 -0
  165. package/docs/SKILL.md +11 -7
  166. package/docs/_catalog.md +23 -5
  167. package/docs/agent-invoice.md +31 -10
  168. package/docs/agent-skill-install.md +211 -0
  169. package/docs/calendar.md +87 -0
  170. package/docs/e10-auth.md +28 -9
  171. package/docs/ehr.md +186 -0
  172. package/docs/esb.md +64 -0
  173. package/docs/fna.md +72 -0
  174. package/docs/hrm.md +89 -0
  175. package/docs/invoice.md +66 -20
  176. package/docs/jiuchuanhui.md +131 -0
  177. package/docs/operation-manual.md +443 -0
  178. package/docs/plan.md +82 -0
  179. package/docs/wenshuding.md +129 -0
  180. package/docs/ziguanjia.md +89 -0
  181. package/package.json +4 -4
  182. package/scripts/package-skill.mjs +127 -34
  183. package/scripts/postbuild.mjs +13 -0
  184. package/skill-template/business-info.json +13 -2
  185. package/skill-template/domains/calendar.md +15 -0
  186. package/skill-template/domains/esb.md +13 -0
  187. package/skill-template/domains/hrm.md +16 -0
  188. package/skill-template/domains/jiuchuanhui.md +23 -0
  189. package/skill-template/domains/jucailin.md +22 -0
  190. package/skill-template/domains/mail.md +21 -0
  191. package/skill-template/domains/plan.md +17 -0
  192. package/skill-template/domains/qiyecheng.md +17 -0
  193. package/skill-template/domains/shared.md +9 -3
  194. package/skill-template/domains/skill-maker.md +10 -0
  195. package/skill-template/domains/wenshuding.md +22 -0
  196. package/skill-template/domains/{invoice.md → yepiaotong.md} +4 -0
  197. package/skill-template/domains/ziguanjia.md +21 -0
  198. package/skill-template/master-skill-template.md +12 -6
  199. package/skill-template/skill-template.md +40 -9
  200. package/skills/weaver-e10-calendar/SKILL.md +101 -0
  201. package/skills/weaver-e10-calendar/product.json +8 -0
  202. package/skills/weaver-e10-calendar/references/calendar-app-check.md +65 -0
  203. package/skills/weaver-e10-calendar/references/calendar-dict.md +55 -0
  204. package/skills/weaver-e10-calendar/references/calendar-query.md +70 -0
  205. package/skills/weaver-e10-calendar/references/calendar-write.md +97 -0
  206. package/skills/weaver-e10-calendar/references/source-manifest.json +54 -0
  207. package/skills/weaver-e10-esb/SKILL.md +102 -0
  208. package/skills/weaver-e10-esb/product.json +8 -0
  209. package/skills/weaver-e10-esb/references/input-format.md +52 -0
  210. package/skills/weaver-e10-esb/references/source-manifest.json +242 -0
  211. package/skills/weaver-e10-esb/references/trigger.md +99 -0
  212. package/skills/weaver-e10-hrm/SKILL.md +87 -0
  213. package/skills/weaver-e10-hrm/product.json +8 -0
  214. package/skills/weaver-e10-hrm/references/employee.md +109 -0
  215. package/skills/weaver-e10-hrm/references/org.md +95 -0
  216. package/skills/weaver-e10-hrm/references/position.md +95 -0
  217. package/skills/weaver-e10-hrm/references/source-manifest.json +121 -0
  218. package/skills/weaver-e10-jiuchuanhui/SKILL.md +174 -0
  219. package/skills/weaver-e10-jiuchuanhui/product.json +8 -0
  220. package/skills/weaver-e10-jiuchuanhui/references/cache.md +110 -0
  221. package/skills/weaver-e10-jiuchuanhui/references/clue.md +61 -0
  222. package/skills/weaver-e10-jiuchuanhui/references/contact-plan.md +56 -0
  223. package/skills/weaver-e10-jiuchuanhui/references/contact-records.md +48 -0
  224. package/skills/weaver-e10-jiuchuanhui/references/contact.md +56 -0
  225. package/skills/weaver-e10-jiuchuanhui/references/customer.md +69 -0
  226. package/skills/weaver-e10-jiuchuanhui/references/disabled-capabilities.md +24 -0
  227. package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +60 -0
  228. package/skills/weaver-e10-jiuchuanhui/references/general-helpers.md +59 -0
  229. package/skills/weaver-e10-jiuchuanhui/references/jiuchuanhui-entry.md +60 -0
  230. package/skills/weaver-e10-jiuchuanhui/references/sale.md +72 -0
  231. package/skills/weaver-e10-jiuchuanhui/references/source-manifest.json +2632 -0
  232. package/skills/weaver-e10-jucailin/SKILL.md +101 -0
  233. package/skills/weaver-e10-jucailin/product.json +8 -0
  234. package/skills/weaver-e10-jucailin/references/attend-read.md +73 -0
  235. package/skills/weaver-e10-jucailin/references/attend-write.md +82 -0
  236. package/skills/weaver-e10-jucailin/references/hr-contact.md +92 -0
  237. package/skills/weaver-e10-jucailin/references/hr-datasource.md +104 -0
  238. package/skills/weaver-e10-jucailin/references/hr-report.md +76 -0
  239. package/skills/weaver-e10-jucailin/references/recruit-read.md +76 -0
  240. package/skills/weaver-e10-jucailin/references/recruit-write.md +70 -0
  241. package/skills/weaver-e10-jucailin/references/safety-boundaries.md +35 -0
  242. package/skills/weaver-e10-jucailin/references/salary.md +110 -0
  243. package/skills/weaver-e10-jucailin/references/source-manifest.json +152 -0
  244. package/skills/weaver-e10-mail/SKILL.md +151 -0
  245. package/skills/weaver-e10-mail/product.json +8 -0
  246. package/skills/weaver-e10-mail/references/mail-agent-entry.md +47 -0
  247. package/skills/weaver-e10-mail/references/mail-attachment.md +30 -0
  248. package/skills/weaver-e10-mail/references/mail-blacklist.md +27 -0
  249. package/skills/weaver-e10-mail/references/mail-contacts.md +33 -0
  250. package/skills/weaver-e10-mail/references/mail-manage.md +44 -0
  251. package/skills/weaver-e10-mail/references/mail-read.md +76 -0
  252. package/skills/weaver-e10-mail/references/mail-send.md +43 -0
  253. package/skills/weaver-e10-mail/references/mail-sign.md +33 -0
  254. package/skills/weaver-e10-mail/references/mail-template.md +31 -0
  255. package/skills/weaver-e10-mail/references/safety-boundaries.md +32 -0
  256. package/skills/weaver-e10-plan/SKILL.md +139 -0
  257. package/skills/weaver-e10-plan/product.json +8 -0
  258. package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +123 -0
  259. package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +138 -0
  260. package/skills/weaver-e10-plan/references/plan-report-query.md +154 -0
  261. package/skills/weaver-e10-plan/references/plan-report-remind.md +104 -0
  262. package/skills/weaver-e10-plan/references/plan-report-write.md +162 -0
  263. package/skills/weaver-e10-plan/references/source-manifest.json +858 -0
  264. package/skills/weaver-e10-qiyecheng/SKILL.md +118 -0
  265. package/skills/weaver-e10-qiyecheng/product.json +8 -0
  266. package/skills/weaver-e10-qiyecheng/references/budget.md +65 -0
  267. package/skills/weaver-e10-qiyecheng/references/catalog.md +56 -0
  268. package/skills/weaver-e10-qiyecheng/references/expense-center.md +51 -0
  269. package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +57 -0
  270. package/skills/weaver-e10-qiyecheng/references/loan-management.md +59 -0
  271. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +698 -0
  272. package/skills/weaver-e10-shared/SKILL.md +86 -0
  273. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +127 -0
  274. package/skills/weaver-e10-shared/references/json-output-contract.md +120 -0
  275. package/skills/weaver-e10-shared/references/weaver-e10-installation.md +110 -0
  276. package/skills/weaver-e10-skill-maker/SKILL.md +77 -0
  277. package/skills/weaver-e10-skill-maker/product.json +8 -0
  278. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +124 -0
  279. package/skills/weaver-e10-skill-maker/references/detector-validation.md +101 -0
  280. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +230 -0
  281. package/skills/weaver-e10-skill-maker/references/post-generation-install.md +105 -0
  282. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +261 -0
  283. package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +141 -0
  284. package/skills/weaver-e10-wenshuding/SKILL.md +157 -0
  285. package/skills/weaver-e10-wenshuding/product.json +8 -0
  286. package/skills/weaver-e10-wenshuding/references/archive-agent-entry.md +63 -0
  287. package/skills/weaver-e10-wenshuding/references/archive-borrow-car.md +52 -0
  288. package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +52 -0
  289. package/skills/weaver-e10-wenshuding/references/archive-disabled-capabilities.md +22 -0
  290. package/skills/weaver-e10-wenshuding/references/archive-download.md +48 -0
  291. package/skills/weaver-e10-wenshuding/references/archive-flow.md +46 -0
  292. package/skills/weaver-e10-wenshuding/references/archive-fonds.md +34 -0
  293. package/skills/weaver-e10-wenshuding/references/archive-info.md +33 -0
  294. package/skills/weaver-e10-wenshuding/references/archive-search.md +52 -0
  295. package/skills/weaver-e10-wenshuding/references/archive-upload.md +41 -0
  296. package/skills/weaver-e10-wenshuding/references/source-manifest.json +517 -0
  297. package/skills/weaver-e10-yepiaotong/SKILL.md +184 -0
  298. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-add.md +1 -1
  299. package/skills/weaver-e10-yepiaotong/references/invoice-agent-entry.md +47 -0
  300. package/skills/weaver-e10-yepiaotong/references/invoice-browse-field-data.md +204 -0
  301. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-delete.md +1 -1
  302. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-detail.md +13 -5
  303. package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +28 -0
  304. package/skills/weaver-e10-yepiaotong/references/invoice-download.md +31 -0
  305. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +45 -0
  306. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-file-upload.md +15 -4
  307. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +45 -0
  308. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +120 -0
  309. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-field-rules.md +161 -0
  310. package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +99 -0
  311. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-ocr-preview.md +14 -4
  312. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +58 -0
  313. package/skills/weaver-e10-yepiaotong/references/invoice-red.md +261 -0
  314. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +97 -0
  315. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-update.md +1 -1
  316. package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/references/invoice-validation-preview.md +10 -3
  317. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +1340 -0
  318. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +845 -0
  319. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +94 -0
  320. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +449 -0
  321. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +266 -0
  322. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +494 -0
  323. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +1103 -0
  324. package/skills/weaver-e10-ziguanjia/SKILL.md +162 -0
  325. package/skills/weaver-e10-ziguanjia/product.json +8 -0
  326. package/skills/weaver-e10-ziguanjia/references/source-manifest.json +147 -0
  327. package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +65 -0
  328. package/skills/weaver-e10-ziguanjia/references/ziguanjia-create.md +45 -0
  329. package/skills/weaver-e10-ziguanjia/references/ziguanjia-depre.md +48 -0
  330. package/skills/weaver-e10-ziguanjia/references/ziguanjia-disabled-capabilities.md +22 -0
  331. package/skills/weaver-e10-ziguanjia/references/ziguanjia-purch.md +57 -0
  332. package/skills/weaver-e10-ziguanjia/references/ziguanjia-query.md +62 -0
  333. package/skills/weaver-e10-ziguanjia/references/ziguanjia-repair.md +83 -0
  334. package/skills/weaver-e10-ziguanjia/references/ziguanjia-resolve.md +49 -0
  335. package/skills/weaver-e10-ziguanjia/references/ziguanjia-return.md +70 -0
  336. package/skills/weaver-e10-ziguanjia/references/ziguanjia-update.md +45 -0
  337. package/skills/weaver-e10-ziguanjia/references/ziguanjia-use.md +60 -0
  338. package/skills/weaver-e10-ziguanjia/references/ziguanjia-viewlink.md +81 -0
  339. package/skills/weaver-work-cli-invoice/SKILL.md +0 -103
  340. package/skills/weaver-work-cli-invoice/references/invoice-agent-entry.md +0 -38
  341. package/skills/weaver-work-cli-invoice/references/invoice-disabled-capabilities.md +0 -26
  342. package/skills/weaver-work-cli-invoice/references/invoice-download.md +0 -22
  343. package/skills/weaver-work-cli-invoice/references/invoice-enterprise-list.md +0 -35
  344. package/skills/weaver-work-cli-invoice/references/invoice-import.md +0 -28
  345. package/skills/weaver-work-cli-invoice/references/invoice-personal-list.md +0 -47
  346. package/skills/weaver-work-cli-shared/SKILL.md +0 -53
  347. package/skills/weaver-work-cli-shared/references/e10-auth-and-session.md +0 -83
  348. package/skills/weaver-work-cli-shared/references/json-output-contract.md +0 -61
  349. package/skills/weaver-work-cli-shared/references/weaver-work-cli-installation.md +0 -61
  350. /package/skills/{weaver-work-cli-shared → weaver-e10-shared}/references/high-risk-write.md +0 -0
  351. /package/skills/{weaver-work-cli-invoice → weaver-e10-yepiaotong}/product.json +0 -0
@@ -0,0 +1,156 @@
1
+ import { requireE10Session } from '../../internal/e10/context.js';
2
+ import { getActiveProfile } from '../../internal/e10/auth/session.js';
3
+ import { E10ApiError, createE10RequestRuntime } from '../../internal/e10/request-runtime.js';
4
+ import { HrmCliError, hrmAuthError, hrmNetworkError, hrmValidationError } from './errors.js';
5
+ function inferProfile(ctx) {
6
+ const options = ctx.getGlobalOptions();
7
+ return options.profile || getActiveProfile();
8
+ }
9
+ /**
10
+ * HRM 接口统一 WeaResult 响应契约:code=200 成功;403 未开启开关 / 400 参数错误 /
11
+ * 404 不存在即使 HTTP 200 也视为业务失败。
12
+ */
13
+ export function isBusinessSuccess(value) {
14
+ if (!value || typeof value !== 'object')
15
+ return false;
16
+ if (value.code !== undefined && value.code !== null)
17
+ return Number(value.code) === 200;
18
+ if (typeof value.status === 'boolean')
19
+ return value.status;
20
+ return false;
21
+ }
22
+ export function businessMessage(value) {
23
+ if (!value || typeof value !== 'object')
24
+ return '泛微接口返回业务失败';
25
+ const candidates = [value.msg, value.message, value.data?.message];
26
+ for (const item of candidates) {
27
+ if (typeof item === 'string' && item.trim())
28
+ return item;
29
+ }
30
+ return '泛微接口返回业务失败';
31
+ }
32
+ function businessCode(value) {
33
+ if (!value || typeof value !== 'object')
34
+ return undefined;
35
+ const code = value.code ?? value.status;
36
+ if (typeof code === 'string' || typeof code === 'number')
37
+ return code;
38
+ return undefined;
39
+ }
40
+ function assertPath(requestPath) {
41
+ if (typeof requestPath !== 'string' || !requestPath.startsWith('/') || requestPath.startsWith('//')) {
42
+ throw hrmValidationError('path_invalid', '请求路径必须是相对绝对路径');
43
+ }
44
+ if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes('/../')) {
45
+ throw hrmValidationError('path_invalid', '请求路径不允许跨域或路径逃逸');
46
+ }
47
+ if (!requestPath.startsWith('/api/')) {
48
+ throw hrmValidationError('path_not_allowed', '组织管理只能调用 /api/ 路径');
49
+ }
50
+ }
51
+ function omitEmptyQueryValues(query) {
52
+ if (!query)
53
+ return undefined;
54
+ return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== '' && value !== undefined));
55
+ }
56
+ function mapRuntimeNetworkError(error) {
57
+ if (error instanceof E10ApiError && error.type === 'network') {
58
+ throw hrmNetworkError(error.subtype, error.message, {
59
+ retryable: error.retryable,
60
+ details: error.details,
61
+ });
62
+ }
63
+ throw error;
64
+ }
65
+ export function createHrmHost(ctx, dependencies = {}) {
66
+ let e10Session = null;
67
+ let sessionContext = null;
68
+ const requireSession = dependencies.requireSession || requireE10Session;
69
+ async function ensureSession() {
70
+ if (!e10Session) {
71
+ e10Session = await requireSession(ctx);
72
+ sessionContext = {
73
+ baseUrl: e10Session.getBaseUrl(),
74
+ profile: inferProfile(ctx),
75
+ userId: e10Session.userId,
76
+ tenantKey: e10Session.tenantKey,
77
+ eteamsId: e10Session.eteamsId,
78
+ };
79
+ }
80
+ return e10Session;
81
+ }
82
+ async function getSession() {
83
+ await ensureSession();
84
+ return sessionContext;
85
+ }
86
+ async function runtime() {
87
+ return createE10RequestRuntime(ctx, await ensureSession(), {
88
+ interceptors: dependencies.interceptors,
89
+ fetch: dependencies.fetch,
90
+ });
91
+ }
92
+ async function request(request) {
93
+ const { method, path, query, body, operation, headers: extraHeaders = {}, timeoutMs = 30_000 } = request;
94
+ assertPath(path);
95
+ // HRM 接口必须带 HRM 页面上下文(Referer),否则网关长时间无响应(实测防坑 2026-08)。
96
+ // 默认 /hrm/main;orgCard/positionCard 等场景由 operation 通过 headers 覆盖。
97
+ const session = await getSession();
98
+ const referer = extraHeaders.Referer || `${session.baseUrl}/hrm/main`;
99
+ const resolvedMethod = method || (body === undefined ? 'GET' : 'POST');
100
+ let response;
101
+ try {
102
+ response = await (await runtime()).requestJson({
103
+ module: 'hrm',
104
+ operation,
105
+ method: resolvedMethod,
106
+ path,
107
+ query: omitEmptyQueryValues(query),
108
+ body,
109
+ headers: { 'X-Requested-With': 'XMLHttpRequest', Referer: referer, ...extraHeaders },
110
+ timeoutMs,
111
+ });
112
+ }
113
+ catch (error) {
114
+ mapRuntimeNetworkError(error);
115
+ }
116
+ if (response.status === 401 || response.status === 302) {
117
+ throw hrmAuthError('session_expired', 'E10 登录态已失效,请先向用户确认 E10 登录域名,再运行 weaver-work-cli auth login --base-url <域名> 完成登录', { httpStatus: response.status });
118
+ }
119
+ if (response.parseError) {
120
+ if (response.status < 200 || response.status >= 300) {
121
+ throw new HrmCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
122
+ code: response.status,
123
+ details: { status: response.status },
124
+ exitCode: 1,
125
+ });
126
+ }
127
+ throw hrmNetworkError('protocol', `接口返回不是合法 JSON(HTTP ${response.status})`, { retryable: false });
128
+ }
129
+ if (response.status < 200 || response.status >= 300) {
130
+ throw new HrmCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
131
+ code: response.status,
132
+ details: { status: response.status, message: businessMessage(response.value) },
133
+ exitCode: 1,
134
+ });
135
+ }
136
+ if (!isBusinessSuccess(response.value)) {
137
+ const code = businessCode(response.value);
138
+ const message = businessMessage(response.value);
139
+ // 403 = AI 开放接口 / HRM 读权限未开启,提示明确处置而非盲目重试。
140
+ if (code === 403) {
141
+ throw new HrmCliError('api', 'permission_denied', message || '当前租户未开启组织管理读接口,请联系管理员开启后再试', {
142
+ code,
143
+ details: { code, message },
144
+ exitCode: 1,
145
+ });
146
+ }
147
+ throw new HrmCliError('api', 'business_error', message, {
148
+ code,
149
+ details: { code, message },
150
+ exitCode: 1,
151
+ });
152
+ }
153
+ return response.value;
154
+ }
155
+ return { request, getSession };
156
+ }
@@ -0,0 +1,111 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
+ import { createHrmHost } from './host.js';
4
+ import { hrmManifest } from './manifest.js';
5
+ import { executeHrmOperation } from './operations.js';
6
+ import { hrmValidationError } from './errors.js';
7
+ function asOptions(value) {
8
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
9
+ }
10
+ async function readStdin() {
11
+ const chunks = [];
12
+ for await (const chunk of process.stdin) {
13
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
14
+ }
15
+ return Buffer.concat(chunks).toString('utf8');
16
+ }
17
+ /**
18
+ * Windows PowerShell 的管道与 Set-Content -Encoding utf8 会在内容前写入 UTF-8 BOM,
19
+ * 且可能重复写入多次;JSON.parse 不接受前导 BOM,必须先剥离。
20
+ */
21
+ function stripBom(value) {
22
+ return value.replace(/^\uFEFF+/, '');
23
+ }
24
+ export async function inputFrom(options, extra = {}) {
25
+ const opts = asOptions(options);
26
+ let input = {};
27
+ if (opts.input && opts.inputJson) {
28
+ throw hrmValidationError('input_conflict', '不能同时传 --input 和 --input-json');
29
+ }
30
+ if (opts.inputJson) {
31
+ input = parseJsonInput(String(opts.inputJson), '--input-json');
32
+ }
33
+ if (opts.input) {
34
+ let raw;
35
+ try {
36
+ raw = stripBom(opts.input === '-' ? await readStdin() : await readFile(String(opts.input), 'utf8'));
37
+ }
38
+ catch {
39
+ throw hrmValidationError('input_unreadable', `无法读取 --input:${String(opts.input)}`);
40
+ }
41
+ input = parseJsonInput(raw, '--input');
42
+ }
43
+ return {
44
+ ...input,
45
+ ...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== undefined && value !== '')),
46
+ };
47
+ }
48
+ function parseJsonInput(raw, label) {
49
+ try {
50
+ const parsed = JSON.parse(stripBom(raw));
51
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
52
+ throw new Error('input must be an object');
53
+ }
54
+ return parsed;
55
+ }
56
+ catch {
57
+ throw hrmValidationError('input_invalid', `${label} 不是合法 JSON 对象`);
58
+ }
59
+ }
60
+ export function successEnvelope(operation, result) {
61
+ return {
62
+ schemaVersion: 1,
63
+ ok: true,
64
+ operation,
65
+ data: result.data === undefined ? null : result.data,
66
+ ...(result.meta ? { meta: result.meta } : {}),
67
+ warnings: [],
68
+ };
69
+ }
70
+ function failureEnvelope(error) {
71
+ const structured = error;
72
+ return {
73
+ schemaVersion: 1,
74
+ ok: false,
75
+ error: toErrorEnvelope(error),
76
+ };
77
+ }
78
+ async function executeAndPrint(ctx, operation, input) {
79
+ try {
80
+ const result = await executeHrmOperation(operation, input, {
81
+ ctx,
82
+ host: createHrmHost(ctx),
83
+ });
84
+ ctx.output.write(successEnvelope(operation, result), { json: true });
85
+ }
86
+ catch (error) {
87
+ console.error(JSON.stringify(failureEnvelope(error), null, 2));
88
+ process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
89
+ }
90
+ }
91
+ export const hrmShortcut = {
92
+ name: 'hrm',
93
+ description: '泛微E10组织管理(员工/组织/岗位查询)CLI',
94
+ category: 'shortcut',
95
+ register({ program, action }) {
96
+ const hrm = program.command('hrm').description('泛微E10组织管理(员工查询/组织架构/岗位查询)');
97
+ hrm.command('schema')
98
+ .description('Print hrm operation manifest for agents')
99
+ .action(action((ctx) => {
100
+ ctx.output.write(hrmManifest, { json: true });
101
+ }));
102
+ hrm.command('run')
103
+ .description('Run an hrm operation with JSON input')
104
+ .argument('<operation>', 'operation name, e.g. hrm.employee.query')
105
+ .option('--input <path>', 'JSON input file, or - for stdin')
106
+ .option('--input-json <json>', 'inline JSON input object')
107
+ .action(action(async (ctx, operation, options) => {
108
+ await executeAndPrint(ctx, String(operation), await inputFrom(options));
109
+ }));
110
+ },
111
+ };
@@ -0,0 +1,32 @@
1
+ import { hrmOperationDefinitions } from './operations/registry.js';
2
+ /**
3
+ * 代理商查询(containsDls=true)禁用边界:仅泛微自用系统域名支持(自用域名白名单),
4
+ * 客户/其他环境禁止触发。未实现,不得编造或绕过。
5
+ */
6
+ const DLS_WITHHELD = ['hrm.employee.dls'];
7
+ function buildOperations() {
8
+ return hrmOperationDefinitions().map((definition) => ({
9
+ name: definition.name,
10
+ resource: definition.resource,
11
+ summary: definition.summary,
12
+ risk: definition.risk,
13
+ inputSchema: definition.inputSchema,
14
+ }));
15
+ }
16
+ export const hrmManifest = {
17
+ schemaVersion: 1,
18
+ name: 'hrm',
19
+ title: '泛微E10组织管理(员工/组织/岗位查询)',
20
+ version: '0.1.0',
21
+ host: 'e10-hrm',
22
+ status: 'builtin',
23
+ sourceSkill: 'weaver-e10-hrm',
24
+ capabilities: ['employee', 'org', 'position'],
25
+ operations: buildOperations(),
26
+ withheldOperations: [
27
+ ...DLS_WITHHELD.map((name) => ({
28
+ name,
29
+ reason: '代理商查询(containsDls=true)仅泛微自用系统域名支持(自用域名白名单),客户/其他环境禁止触发;未实现,不得编造或绕过。',
30
+ })),
31
+ ],
32
+ };
@@ -0,0 +1,338 @@
1
+ import { hrmValidationError } from '../errors.js';
2
+ import { READ, SCHEMA_ID, SCHEMA_ID_LIST, SCHEMA_PAGE, hrmSuccess, schemaOf, } from './types.js';
3
+ import { browserBaseBody, inferEmployeeField, orgLink, personLink, resolveDepartmentIdByName, toNumber, toPositiveInt, toStringIdList, } from './shared.js';
4
+ const EMPLOYEE_STATUS = ['normal', '6'];
5
+ const SUBORDINATE_SCOPE = ['direct', 'indirect', 'all'];
6
+ const SUBORDINATE_BYID_SCOPE = ['direct', 'indirect'];
7
+ /** 手机号脱敏:3 位前缀 + **** + 末 4 位(与 hrm-cli.mjs 一致)。 */
8
+ function maskPhone(p) {
9
+ const s = p ? String(p) : '';
10
+ return (s && s.length >= 7) ? s.slice(0, 3) + '****' + s.slice(-4) : s;
11
+ }
12
+ /** 列表接口行 → 精简人员行(附人员卡片 link + 部门卡片 deptLink)。 */
13
+ function formatMember(r, baseUrl) {
14
+ const deptId = r.departmentId != null && r.departmentId !== '' ? String(r.departmentId) : '';
15
+ return {
16
+ name: r.name,
17
+ id: r.id,
18
+ userid: r.userid,
19
+ cid: r.cid,
20
+ department: r.department,
21
+ departmentId: deptId,
22
+ position: r.position,
23
+ mobile: maskPhone(r.mobile),
24
+ statusCode: r.statusCode,
25
+ link: personLink(baseUrl, r.id),
26
+ deptLink: deptId ? orgLink(baseUrl, deptId) : '',
27
+ };
28
+ }
29
+ /** 批量详情行 → 精简人员行。 */
30
+ function formatBatch(u, baseUrl) {
31
+ const deptId = u.departmentId != null && u.departmentId !== '' ? String(u.departmentId) : '';
32
+ return {
33
+ name: u.name,
34
+ id: u.id,
35
+ jobNum: u.jobNum,
36
+ department: u.department,
37
+ departmentId: deptId,
38
+ subCompany: u.subCompany,
39
+ position: u.position,
40
+ mobile: maskPhone(u.mobile),
41
+ imCid: u.imCid,
42
+ link: personLink(baseUrl, u.id),
43
+ deptLink: deptId ? orgLink(baseUrl, deptId) : '',
44
+ };
45
+ }
46
+ /** 员工浏览收敛条件解析:显式字段优先,其次 keyword 自动推断;空条件抛 empty_condition。 */
47
+ function resolveEmployeeCondition(args) {
48
+ const explicit = ['email', 'mobile', 'job_num', 'username'].find((k) => {
49
+ const v = args[k];
50
+ return v !== undefined && v !== null && String(v).trim() !== '';
51
+ });
52
+ if (explicit)
53
+ return { field: explicit, value: String(args[explicit]).trim() };
54
+ const keyword = args.keyword === undefined ? '' : String(args.keyword).trim();
55
+ if (!keyword) {
56
+ throw hrmValidationError('empty_condition', '员工查询必须携带至少一个收敛条件:keyword(自动推断)或 username/job_num/mobile/email 之一');
57
+ }
58
+ const inferred = inferEmployeeField(keyword);
59
+ return { field: inferred.key, value: inferred.value };
60
+ }
61
+ /** 员工浏览 / 下属查询的 formDatas 组织键空算子占位。 */
62
+ function memberFormDatasBase() {
63
+ return {
64
+ subcompany: [{ subcompanyOpt: 'in' }],
65
+ department: [{ departmentOpt: 'in' }],
66
+ role: [{ roleOpt: 'in' }],
67
+ position: [{ positionOpt: 'in' }],
68
+ superior: [{ superiorOpt: 'in' }],
69
+ };
70
+ }
71
+ const employeeQuery = {
72
+ name: 'hrm.employee.query',
73
+ resource: 'employee',
74
+ method: 'employee.query',
75
+ action: 'hrm.employee.query',
76
+ summary: '按工号/姓名/手机/邮箱(keyword 自动推断或显式字段)查询员工;默认在职,status 传 ["6"] 查离职',
77
+ risk: READ,
78
+ inputSchema: schemaOf({
79
+ keyword: { type: 'string', description: '查询关键词,自动推断:含 @→邮箱;11 位纯数字→手机;纯数字或字母开头含数字→工号;其余→姓名(模糊)' },
80
+ username: { type: 'string', description: '姓名(模糊匹配)' },
81
+ job_num: { type: 'string', description: '工号(模糊匹配)' },
82
+ mobile: { type: 'string', description: '手机号(模糊匹配)' },
83
+ email: { type: 'string', description: '邮箱(模糊匹配)' },
84
+ status: { type: 'array', items: { type: 'string', enum: [...EMPLOYEE_STATUS] }, description: '默认 ["normal"] 在职;["6"] 离职。不能单独作为收敛条件' },
85
+ ...SCHEMA_PAGE,
86
+ }),
87
+ handler: async (args, { host }) => {
88
+ const { field, value } = resolveEmployeeCondition(args);
89
+ const status = Array.isArray(args.status) && args.status.length > 0 ? args.status : ['normal'];
90
+ const statusText = status.map((s) => {
91
+ const text = String(s);
92
+ if (!EMPLOYEE_STATUS.includes(text)) {
93
+ throw hrmValidationError('enum_invalid', `status 取值必须是 ${EMPLOYEE_STATUS.join(' / ')} 之一`);
94
+ }
95
+ return text;
96
+ });
97
+ const formDatas = {
98
+ ...memberFormDatasBase(),
99
+ status: [{ statusSelect: statusText }],
100
+ [field]: [{ [`${field}Opt`]: 'in', [`${field}Input`]: value }],
101
+ };
102
+ const body = {
103
+ ...browserBaseBody(),
104
+ cmd: 'all',
105
+ formDatas,
106
+ quickSearchDatas: {},
107
+ type: 'and',
108
+ containsNoneAccount: false,
109
+ containsPartTimeEmployee: false,
110
+ containsDls: false,
111
+ };
112
+ const current = toPositiveInt(args.current, 'current');
113
+ const pageSize = toNumber(args.pageSize, 'pageSize');
114
+ if (current !== undefined)
115
+ body.current = current;
116
+ if (pageSize !== undefined)
117
+ body.pageSize = pageSize;
118
+ const session = await host.getSession();
119
+ const baseUrl = session.baseUrl.replace(/\/+$/, '');
120
+ const countResp = await host.request({ method: 'POST', path: '/api/hrm/common/browser/count/resource', body });
121
+ const dataResp = await host.request({ method: 'POST', path: '/api/hrm/common/browser/data/resource', body });
122
+ const total = Number(countResp?.data?.total ?? 0);
123
+ const rawRows = dataResp?.data?.data ?? [];
124
+ const rows = rawRows.map((r) => formatMember(r, baseUrl));
125
+ const lookingNormal = statusText.includes('normal');
126
+ const hint = lookingNormal && rows.length === 0
127
+ ? `在职员工未查到「${value}」;若为离职人员,请用 status=["6"] 再查`
128
+ : undefined;
129
+ return hrmSuccess('hrm.employee.query', {
130
+ rows,
131
+ total,
132
+ ...(hint ? { hint } : {}),
133
+ }, { current: current ?? 1, pageSize: pageSize ?? 200 });
134
+ },
135
+ };
136
+ const employeeBatch = {
137
+ name: 'hrm.employee.batch',
138
+ resource: 'employee',
139
+ method: 'employee.batch',
140
+ action: 'hrm.employee.batch',
141
+ summary: '按人员 id 列表批量查询精简详情(每批 ≤100 自动分批,不含部门/岗位/上级名称)',
142
+ risk: READ,
143
+ inputSchema: schemaOf({
144
+ ids: { ...SCHEMA_ID_LIST, description: '人员 id 列表(长整型按字符串)' },
145
+ }, { required: ['ids'] }),
146
+ handler: async (args, { host }) => {
147
+ const ids = toStringIdList(args.ids, 'ids');
148
+ if (!ids || ids.length === 0) {
149
+ throw hrmValidationError('ids_required', 'ids 必填且不能为空');
150
+ }
151
+ const session = await host.getSession();
152
+ const baseUrl = session.baseUrl.replace(/\/+$/, '');
153
+ const collected = [];
154
+ for (let i = 0; i < ids.length; i += 100) {
155
+ const resp = await host.request({
156
+ method: 'POST',
157
+ path: '/api/hrm/common/getEmployeeByIds',
158
+ body: { userIdList: ids.slice(i, i + 100), externalIdList: [] },
159
+ headers: { devtype: '5' },
160
+ });
161
+ const userList = resp?.data?.userList ?? [];
162
+ collected.push(...userList);
163
+ }
164
+ const rows = collected.map((r) => formatBatch(r, baseUrl));
165
+ return hrmSuccess('hrm.employee.batch', { rows, total: rows.length });
166
+ },
167
+ };
168
+ const employeeDetail = {
169
+ name: 'hrm.employee.detail',
170
+ resource: 'employee',
171
+ method: 'employee.detail',
172
+ action: 'hrm.employee.detail',
173
+ summary: '按人员 id 取资料名片(头像/是否管理员/管理者类型/在线状态);不含姓名/工号/部门/手机',
174
+ risk: READ,
175
+ inputSchema: schemaOf({ id: SCHEMA_ID }, { required: ['id'] }),
176
+ handler: async (args, { host }) => {
177
+ const id = String(args.id).trim();
178
+ if (!id)
179
+ throw hrmValidationError('id_required', 'id 必填');
180
+ const resp = await host.request({ method: 'GET', path: '/api/hrm/profile/get', query: { id } });
181
+ const data = resp?.data ?? {};
182
+ const session = await host.getSession();
183
+ const baseUrl = session.baseUrl.replace(/\/+$/, '');
184
+ return hrmSuccess('hrm.employee.detail', { ...data, link: personLink(baseUrl, id) });
185
+ },
186
+ };
187
+ const subordinateMine = {
188
+ name: 'hrm.subordinate.mine',
189
+ resource: 'employee',
190
+ method: 'subordinate.mine',
191
+ action: 'hrm.subordinate.mine',
192
+ summary: '查当前登录人的下属(all 所有/direct 直接/indirect 间接),基于当前会话身份',
193
+ risk: READ,
194
+ inputSchema: schemaOf({
195
+ scope: { type: 'string', enum: [...SUBORDINATE_SCOPE], description: '默认 all;direct 直接 / indirect 间接 / all 所有' },
196
+ ...SCHEMA_PAGE,
197
+ }),
198
+ handler: async (args, { host }) => {
199
+ const scope = args.scope === undefined ? 'all' : String(args.scope);
200
+ const subSelected = { direct: 'directSubordinate', indirect: 'indirectSubordinate', all: 'allSubordinate' }[scope] ?? 'allSubordinate';
201
+ const body = {
202
+ ...browserBaseBody(),
203
+ cmd: 'mySubordinate',
204
+ subSelected,
205
+ companyId: '1',
206
+ formDatas: {},
207
+ quickSearchDatas: {},
208
+ type: 'and',
209
+ containsNoneAccount: true,
210
+ containsPartTimeEmployee: false,
211
+ };
212
+ const current = toPositiveInt(args.current, 'current');
213
+ const pageSize = toNumber(args.pageSize, 'pageSize');
214
+ if (current !== undefined)
215
+ body.current = current;
216
+ if (pageSize !== undefined)
217
+ body.pageSize = pageSize;
218
+ const session = await host.getSession();
219
+ const baseUrl = session.baseUrl.replace(/\/+$/, '');
220
+ const countResp = await host.request({ method: 'POST', path: '/api/hrm/common/browser/count/resource', body });
221
+ const dataResp = await host.request({ method: 'POST', path: '/api/hrm/common/browser/data/resource', body });
222
+ const total = Number(countResp?.data?.total ?? 0);
223
+ const rawRows = dataResp?.data?.data ?? [];
224
+ const rows = rawRows.map((r) => formatMember(r, baseUrl));
225
+ return hrmSuccess('hrm.subordinate.mine', { rows, total, scope }, { current: current ?? 1, pageSize: pageSize ?? 200 });
226
+ },
227
+ };
228
+ const subordinateById = {
229
+ name: 'hrm.subordinate.by-id',
230
+ resource: 'employee',
231
+ method: 'subordinate.by-id',
232
+ action: 'hrm.subordinate.by-id',
233
+ summary: '按目标人员 id 查其直接/间接下属(无需切换会话);所有下属 = direct + indirect 两次并集',
234
+ risk: READ,
235
+ inputSchema: schemaOf({
236
+ id: SCHEMA_ID,
237
+ scope: { type: 'string', enum: [...SUBORDINATE_BYID_SCOPE], description: '默认 direct;direct 直接 / indirect 间接' },
238
+ pageNo: SCHEMA_ID,
239
+ pageSize: SCHEMA_ID,
240
+ }, { required: ['id'] }),
241
+ handler: async (args, { host }) => {
242
+ const id = String(args.id).trim();
243
+ if (!id)
244
+ throw hrmValidationError('id_required', 'id 必填');
245
+ const scope = args.scope === undefined ? 'direct' : String(args.scope);
246
+ const path = scope === 'indirect'
247
+ ? `/api/bs/hrm/user/myIndirectSubordinates/${id}`
248
+ : `/api/bs/hrm/user/myDirectSubordinates/${id}`;
249
+ const pageNo = toPositiveInt(args.pageNo, 'pageNo') ?? 1;
250
+ const pageSize = toNumber(args.pageSize, 'pageSize') ?? 10;
251
+ const session = await host.getSession();
252
+ const baseUrl = session.baseUrl.replace(/\/+$/, '');
253
+ const resp = await host.request({
254
+ method: 'GET',
255
+ path,
256
+ query: { id, pageNo, pageSize, virtualId: '', isMobile: 'false' },
257
+ headers: { Referer: `${baseUrl}/hrm/addressbook/department` },
258
+ });
259
+ const page = resp?.data?.page ?? {};
260
+ const rawRows = Array.isArray(page.result) ? page.result : [];
261
+ const rows = rawRows.map((r) => ({
262
+ id: r.id ?? r.employeeId,
263
+ name: r.name ?? r.username,
264
+ pinyin: r.pinyin,
265
+ telephone: r.telephone,
266
+ sex: r.sex,
267
+ personnelStatus: r.personnelStatus,
268
+ department: r.department,
269
+ position: r.position,
270
+ superior: r.superior,
271
+ link: personLink(baseUrl, r.id ?? r.employeeId),
272
+ }));
273
+ return hrmSuccess('hrm.subordinate.by-id', {
274
+ rows,
275
+ total: Number(page.totalCount ?? rows.length),
276
+ scope,
277
+ page: {
278
+ pageNo,
279
+ pageSize,
280
+ hasNext: page.hasNext ?? false,
281
+ totalPages: page.totalPages ?? 1,
282
+ },
283
+ });
284
+ },
285
+ };
286
+ const deptMembers = {
287
+ name: 'hrm.dept.members',
288
+ resource: 'employee',
289
+ method: 'dept.members',
290
+ action: 'hrm.dept.members',
291
+ summary: '查某部门/分部下的直接成员(部门名或 id;部门名需唯一,重名改用 id)',
292
+ risk: READ,
293
+ inputSchema: schemaOf({
294
+ dept: { type: 'string', description: '部门/分部名称(需唯一)或组织节点 id' },
295
+ ...SCHEMA_PAGE,
296
+ }, { required: ['dept'] }),
297
+ handler: async (args, { host }) => {
298
+ const raw = args.dept === undefined ? '' : String(args.dept).trim();
299
+ if (!raw)
300
+ throw hrmValidationError('dept_required', 'dept 必填');
301
+ // 纯数字视为组织 id,否则按部门名称精确定位(重名报 dept_ambiguous)。
302
+ const deptId = /^\d+$/.test(raw) ? raw : String((await resolveDepartmentIdByName(host, raw)).id);
303
+ const body = {
304
+ ...browserBaseBody(),
305
+ secretLevel: '',
306
+ cmd: 'teams',
307
+ leftTreeSelectedId: deptId,
308
+ formDatas: {
309
+ username: [{ usernameOpt: 'in' }],
310
+ status: [{ statusSelect: ['normal'] }],
311
+ subcompany: [{ subcompanyOpt: 'in' }],
312
+ department: [{ departmentOpt: 'in' }],
313
+ role: [{ roleOpt: 'in' }],
314
+ position: [{ positionOpt: 'in' }],
315
+ },
316
+ };
317
+ const current = toPositiveInt(args.current, 'current');
318
+ const pageSize = toNumber(args.pageSize, 'pageSize') ?? 200;
319
+ if (current !== undefined)
320
+ body.current = current;
321
+ if (pageSize !== undefined)
322
+ body.pageSize = pageSize;
323
+ const resp = await host.request({ method: 'POST', path: '/api/mail/base/common/browser/data/resource', body });
324
+ const rawRows = resp?.data?.data ?? [];
325
+ const session = await host.getSession();
326
+ const baseUrl = session.baseUrl.replace(/\/+$/, '');
327
+ const rows = rawRows.map((r) => formatMember(r, baseUrl));
328
+ return hrmSuccess('hrm.dept.members', { dept: { id: deptId }, rows, total: rows.length }, { current: current ?? 1, pageSize: pageSize ?? 200 });
329
+ },
330
+ };
331
+ export const hrmEmployeeOperations = [
332
+ employeeQuery,
333
+ employeeBatch,
334
+ employeeDetail,
335
+ subordinateMine,
336
+ subordinateById,
337
+ deptMembers,
338
+ ];