weaver-work-cli 0.1.6 → 0.1.7

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 (225) hide show
  1. package/README.md +14 -9
  2. package/dist/cmd/skills/index.js +60 -0
  3. package/dist/internal/e10/auth/commands.js +44 -31
  4. package/dist/internal/e10/auth/session.js +44 -3
  5. package/dist/internal/e10/auth/xiaoe.js +363 -11
  6. package/dist/internal/e10/context.js +4 -2
  7. package/dist/internal/skills/detector.js +42 -0
  8. package/dist/internal/skills/install.js +50 -3
  9. package/dist/shortcuts/archive/render/search-format.js +12 -3
  10. package/dist/shortcuts/ebuilder-form/continuation.js +70 -0
  11. package/dist/shortcuts/ebuilder-form/errors.js +54 -0
  12. package/dist/shortcuts/ebuilder-form/host.js +1238 -0
  13. package/dist/shortcuts/ebuilder-form/index.js +108 -0
  14. package/dist/shortcuts/ebuilder-form/manifest.js +347 -0
  15. package/dist/shortcuts/ebuilder-form/operations/read.js +157 -0
  16. package/dist/shortcuts/ebuilder-form/operations/registry.js +56 -0
  17. package/dist/shortcuts/ebuilder-form/operations/shared.js +132 -0
  18. package/dist/shortcuts/ebuilder-form/operations/types.js +19 -0
  19. package/dist/shortcuts/ebuilder-form/operations/write.js +277 -0
  20. package/dist/shortcuts/ebuilder-form/operations.js +8 -0
  21. package/dist/shortcuts/ehr/operations/salary.js +2 -140
  22. package/dist/shortcuts/im/continuation.js +70 -0
  23. package/dist/shortcuts/{yimiaoban → im}/errors.js +14 -14
  24. package/dist/shortcuts/{yimiaoban → im}/host.js +26 -26
  25. package/dist/shortcuts/{yimiaoban → im}/index.js +42 -42
  26. package/dist/shortcuts/{yimiaoban → im}/manifest.js +7 -6
  27. package/dist/shortcuts/{yimiaoban → im}/operations/file-user.js +54 -41
  28. package/dist/shortcuts/{yimiaoban → im}/operations/group-read.js +46 -44
  29. package/dist/shortcuts/{yimiaoban → im}/operations/group-write.js +113 -66
  30. package/dist/shortcuts/{yimiaoban → im}/operations/msg-sync.js +164 -141
  31. package/dist/shortcuts/{yimiaoban → im}/operations/msg-write.js +47 -47
  32. package/dist/shortcuts/{yimiaoban → im}/operations/person.js +10 -10
  33. package/dist/shortcuts/{yimiaoban → im}/operations/registry.js +10 -8
  34. package/dist/shortcuts/{yimiaoban → im}/operations/session.js +82 -83
  35. package/dist/shortcuts/im/operations/shared.js +442 -0
  36. package/dist/shortcuts/{yimiaoban → im}/operations/types.js +1 -1
  37. package/dist/shortcuts/im/operations/user-remind.js +201 -0
  38. package/dist/shortcuts/{yimiaoban → im}/operations/write-util.js +7 -7
  39. package/dist/shortcuts/{yimiaoban → im}/operations.js +3 -3
  40. package/dist/shortcuts/index.js +10 -2
  41. package/dist/shortcuts/invoice/manifest.js +113 -10
  42. package/dist/shortcuts/invoice/operations/import.js +39 -14
  43. package/dist/shortcuts/invoice/operations/reim.js +38 -18
  44. package/dist/shortcuts/invoice/operations/shared.js +35 -6
  45. package/dist/shortcuts/jiuchuanhui/manifest.js +3 -3
  46. package/dist/shortcuts/jiuchuanhui/operations/registry.js +2 -2
  47. package/dist/shortcuts/{yimiaoban → okr}/continuation.js +10 -10
  48. package/dist/shortcuts/okr/errors.js +70 -0
  49. package/dist/shortcuts/okr/host.js +169 -0
  50. package/dist/shortcuts/okr/index.js +155 -0
  51. package/dist/shortcuts/okr/manifest.js +70 -0
  52. package/dist/shortcuts/okr/operations/link.js +305 -0
  53. package/dist/shortcuts/okr/operations/read.js +481 -0
  54. package/dist/shortcuts/okr/operations/registry.js +31 -0
  55. package/dist/shortcuts/okr/operations/shared.js +381 -0
  56. package/dist/shortcuts/okr/operations/types.js +88 -0
  57. package/dist/shortcuts/okr/operations/write.js +838 -0
  58. package/dist/shortcuts/okr/operations.js +8 -0
  59. package/dist/shortcuts/project/continuation.js +70 -0
  60. package/dist/shortcuts/project/errors.js +53 -0
  61. package/dist/shortcuts/project/host.js +160 -0
  62. package/dist/shortcuts/project/index.js +106 -0
  63. package/dist/shortcuts/project/manifest.js +36 -0
  64. package/dist/shortcuts/project/operations/read.js +551 -0
  65. package/dist/shortcuts/project/operations/registry.js +31 -0
  66. package/dist/shortcuts/project/operations/shared.js +68 -0
  67. package/dist/shortcuts/project/operations/types.js +39 -0
  68. package/dist/shortcuts/project/operations/write.js +266 -0
  69. package/dist/shortcuts/project/operations.js +8 -0
  70. package/dist/shortcuts/workflow/continuation.js +508 -0
  71. package/dist/shortcuts/workflow/endpoints.js +149 -0
  72. package/dist/shortcuts/workflow/errors.js +112 -0
  73. package/dist/shortcuts/workflow/host.js +224 -0
  74. package/dist/shortcuts/workflow/index.js +116 -0
  75. package/dist/shortcuts/workflow/manifest.js +30 -0
  76. package/dist/shortcuts/workflow/operations/form.js +4159 -0
  77. package/dist/shortcuts/workflow/operations/read.js +3778 -0
  78. package/dist/shortcuts/workflow/operations/registry.js +33 -0
  79. package/dist/shortcuts/workflow/operations/shared.js +167 -0
  80. package/dist/shortcuts/workflow/operations/types.js +44 -0
  81. package/dist/shortcuts/workflow/operations/write.js +1991 -0
  82. package/dist/shortcuts/workflow/operations.js +119 -0
  83. package/dist/shortcuts/workflow/state.js +182 -0
  84. package/docs/SKILL.md +5 -3
  85. package/docs/_catalog.md +10 -1
  86. package/docs/agent-invoice.md +2 -2
  87. package/docs/agent-skill-install.md +2 -2
  88. package/docs/e10-auth.md +3 -1
  89. package/docs/ebuilder-form.md +38 -0
  90. package/docs/im.md +104 -0
  91. package/docs/invoice.md +5 -5
  92. package/docs/okr.md +122 -0
  93. package/docs/operation-manual.md +10 -7
  94. package/docs/project.md +69 -0
  95. package/docs/skill-review-2026-09-19.md +68 -0
  96. package/package.json +3 -2
  97. package/scripts/package-skill.mjs +38 -11
  98. package/scripts/sync-connector-skills.mjs +172 -0
  99. package/skill-template/business-info.json +357 -16
  100. package/skill-template/domains/ebuilder-form.md +5 -0
  101. package/skill-template/domains/okr.md +18 -0
  102. package/skill-template/domains/shijingran.md +3 -0
  103. package/skill-template/domains/skill-maker.md +4 -4
  104. package/skill-template/domains/workflow.md +22 -0
  105. package/skill-template/domains/yepiaotong.md +4 -2
  106. package/skill-template/domains/yimiaoban.md +13 -10
  107. package/skill-template/product.json +5 -0
  108. package/skill-template/skill-template.md +1 -0
  109. package/skills/weaver-e10-calendar/SKILL.md +5 -1
  110. package/skills/weaver-e10-calendar/references/calendar-query.md +7 -0
  111. package/skills/weaver-e10-calendar/references/source-manifest.json +314 -32
  112. package/skills/weaver-e10-ebuilder-form/SKILL.md +123 -0
  113. package/skills/weaver-e10-ebuilder-form/references/context-routing.md +90 -0
  114. package/skills/weaver-e10-ebuilder-form/references/custom-api.md +86 -0
  115. package/skills/weaver-e10-ebuilder-form/references/disabled-capabilities.md +50 -0
  116. package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +100 -0
  117. package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +91 -0
  118. package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +74 -0
  119. package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +86 -0
  120. package/skills/weaver-e10-ebuilder-form/references/source-manifest.json +107 -0
  121. package/skills/weaver-e10-esb/SKILL.md +1 -1
  122. package/skills/weaver-e10-esb/references/source-manifest.json +15 -14
  123. package/skills/weaver-e10-hrm/SKILL.md +1 -1
  124. package/skills/weaver-e10-hrm/references/source-manifest.json +357 -38
  125. package/skills/weaver-e10-jiuchuanhui/SKILL.md +22 -4
  126. package/skills/weaver-e10-jiuchuanhui/references/clue.md +4 -2
  127. package/skills/weaver-e10-jiuchuanhui/references/contact.md +1 -1
  128. package/skills/weaver-e10-jiuchuanhui/references/customer.md +3 -3
  129. package/skills/weaver-e10-jiuchuanhui/references/disabled-capabilities.md +1 -1
  130. package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +10 -10
  131. package/skills/weaver-e10-jiuchuanhui/references/general-helpers.md +3 -3
  132. package/skills/weaver-e10-jiuchuanhui/references/sale.md +7 -7
  133. package/skills/weaver-e10-jiuchuanhui/references/source-manifest.json +3 -3
  134. package/skills/weaver-e10-jucailin/SKILL.md +2 -2
  135. package/skills/weaver-e10-mail/SKILL.md +22 -6
  136. package/skills/weaver-e10-meeting/SKILL.md +22 -1
  137. package/skills/weaver-e10-okr/SKILL.md +139 -0
  138. package/skills/weaver-e10-okr/references/okr-align.md +59 -0
  139. package/skills/weaver-e10-okr/references/okr-keyresult.md +68 -0
  140. package/skills/weaver-e10-okr/references/okr-link-routing.md +67 -0
  141. package/skills/weaver-e10-okr/references/okr-query.md +105 -0
  142. package/skills/weaver-e10-okr/references/okr-write.md +94 -0
  143. package/skills/weaver-e10-okr/references/source-manifest.json +672 -0
  144. package/skills/weaver-e10-plan/SKILL.md +3 -3
  145. package/skills/weaver-e10-plan/references/plan-report-write.md +1 -1
  146. package/skills/weaver-e10-plan/references/source-manifest.json +20 -20
  147. package/skills/weaver-e10-qiyecheng/SKILL.md +21 -1
  148. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +17 -17
  149. package/skills/weaver-e10-shared/SKILL.md +79 -11
  150. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +41 -8
  151. package/skills/weaver-e10-shared/references/non-interactive-environment.md +78 -0
  152. package/skills/weaver-e10-shared/references/weaver-e10-installation.md +39 -0
  153. package/skills/weaver-e10-shijingran/SKILL.md +83 -0
  154. package/skills/weaver-e10-shijingran/references/field-resolution.md +105 -0
  155. package/skills/weaver-e10-shijingran/references/operations.md +154 -0
  156. package/skills/weaver-e10-shijingran/references/source-manifest.json +1380 -0
  157. package/skills/weaver-e10-shijingran/references/write-operations.md +90 -0
  158. package/skills/weaver-e10-skill-maker/SKILL.md +26 -9
  159. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +39 -8
  160. package/skills/weaver-e10-skill-maker/references/detector-validation.md +25 -8
  161. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +66 -5
  162. package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +86 -0
  163. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +59 -5
  164. package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +16 -8
  165. package/skills/weaver-e10-wenshuding/SKILL.md +28 -4
  166. package/skills/weaver-e10-wenshuding/references/archive-search.md +14 -0
  167. package/skills/weaver-e10-wenshuding/references/source-manifest.json +27 -26
  168. package/skills/weaver-e10-workflow/SKILL.md +250 -0
  169. package/skills/weaver-e10-workflow/references/source-manifest.json +1062 -0
  170. package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +96 -0
  171. package/skills/weaver-e10-workflow/references/workflow-batch.md +275 -0
  172. package/skills/weaver-e10-workflow/references/workflow-create.md +182 -0
  173. package/skills/weaver-e10-workflow/references/workflow-edit.md +106 -0
  174. package/skills/weaver-e10-workflow/references/workflow-memory.md +165 -0
  175. package/skills/weaver-e10-workflow/references/workflow-operate.md +153 -0
  176. package/skills/weaver-e10-workflow/references/workflow-query.md +821 -0
  177. package/skills/weaver-e10-workflow/references/workflow-share.md +117 -0
  178. package/skills/weaver-e10-workflow/references/workflow-view.md +189 -0
  179. package/skills/weaver-e10-yepiaotong/SKILL.md +28 -28
  180. package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +11 -5
  181. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +14 -8
  182. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +9 -43
  183. package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +8 -0
  184. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +13 -17
  185. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +6 -7
  186. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +2 -2
  187. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +1155 -553
  188. package/skills/weaver-e10-yimiaoban/SKILL.md +56 -38
  189. package/skills/weaver-e10-yimiaoban/references/ding-write.md +8 -8
  190. package/skills/weaver-e10-yimiaoban/references/error-codes.md +16 -0
  191. package/skills/weaver-e10-yimiaoban/references/field-resolution.md +10 -10
  192. package/skills/weaver-e10-yimiaoban/references/file-user-i18n.md +12 -12
  193. package/skills/weaver-e10-yimiaoban/references/group-read.md +16 -16
  194. package/skills/weaver-e10-yimiaoban/references/group-write.md +17 -15
  195. package/skills/weaver-e10-yimiaoban/references/msg-read.md +21 -17
  196. package/skills/weaver-e10-yimiaoban/references/msg-write.md +10 -10
  197. package/skills/weaver-e10-yimiaoban/references/person.md +6 -6
  198. package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +15 -11
  199. package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +11 -10
  200. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +2164 -154
  201. package/skills/weaver-e10-yimiaoban/references/user-remind.md +75 -0
  202. package/skills/weaver-e10-ziguanjia/SKILL.md +4 -2
  203. package/skills/weaver-e10-ziguanjia/references/source-manifest.json +99 -29
  204. package/tools/weaver-skill-detector-1.0.13/SKILL.md +253 -0
  205. package/tools/weaver-skill-detector-1.0.13/_meta.json +6 -0
  206. package/tools/weaver-skill-detector-1.0.13/references/checklist.md +298 -0
  207. package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +4190 -0
  208. package/dist/shortcuts/yimiaoban/operations/shared.js +0 -236
  209. package/docs/yimiaoban.md +0 -86
  210. package/skills/weaver-e10-calendar/product.json +0 -8
  211. package/skills/weaver-e10-esb/product.json +0 -8
  212. package/skills/weaver-e10-hrm/product.json +0 -8
  213. package/skills/weaver-e10-jiuchuanhui/product.json +0 -8
  214. package/skills/weaver-e10-jucailin/product.json +0 -8
  215. package/skills/weaver-e10-mail/product.json +0 -8
  216. package/skills/weaver-e10-meeting/product.json +0 -8
  217. package/skills/weaver-e10-plan/product.json +0 -8
  218. package/skills/weaver-e10-qiyecheng/product.json +0 -8
  219. package/skills/weaver-e10-skill-maker/product.json +0 -8
  220. package/skills/weaver-e10-wenshuding/product.json +0 -8
  221. package/skills/weaver-e10-yepiaotong/product.json +0 -8
  222. package/skills/weaver-e10-yepiaotong/references/invoice-red.md +0 -261
  223. package/skills/weaver-e10-yimiaoban/product.json +0 -8
  224. package/skills/weaver-e10-ziguanjia/product.json +0 -8
  225. /package/dist/shortcuts/{yimiaoban → im}/operations/msg-parse.js +0 -0
@@ -1,10 +1,10 @@
1
- import { ymbValidationError } from '../errors.js';
2
- import { READ, schemaOf, ymbSuccess, } from './types.js';
3
- import { assertImOk, formatFullTime, parseMsg, resolveAuthUid, str, toUint, unwrapInner, } from './shared.js';
1
+ import { imValidationError } from '../errors.js';
2
+ import { READ, schemaOf, imSuccess, } from './types.js';
3
+ import { assertImOk, clampTimeRangeTo7Days, DEFAULT_PAGE_SIZE, formatFullTime, makeMinMaxIdByTm, MAX_PAGE_SIZE, paginationMeta, parseTimeToSec, parseMsg, pullPaged, rangeShrinkMeta, resolveAuthUid, sortMessagesNewestFirst, str, todayRange, toUint, unwrapInner, } from './shared.js';
4
4
  import { collapseNewlines, escapePipe, extractFiles, extractImgs, extractVideos, parseContent, senderName, } from './msg-parse.js';
5
5
  const MAX_MSG_ID = String((1n << 63n) - 1n);
6
- const DEFAULT_PAGE_SIZE = 20;
7
- const MAX_PAGE_SIZE = 50;
6
+ /** 会话列表(getSessionContext)默认每页 20 条(不参与消息类自动翻页)。 */
7
+ const SESSION_DEFAULT_PAGE_SIZE = 20;
8
8
  /** 会话类型归类。 */
9
9
  export function sessionTypeName(type) {
10
10
  if ([1, 6, 9].includes(type))
@@ -17,10 +17,10 @@ export function sessionTypeName(type) {
17
17
  }
18
18
  /** 会话列表。 */
19
19
  const sessionList = {
20
- name: 'yimiaoban.session.list',
20
+ name: 'im.session.list',
21
21
  resource: 'session',
22
22
  method: 'session.list',
23
- action: 'yimiaoban.session.list',
23
+ action: 'im.session.list',
24
24
  summary: '拉取当前用户会话列表(单聊/群聊/系统消息,解析名称与副标题)',
25
25
  capability: 'session',
26
26
  risk: READ,
@@ -32,7 +32,7 @@ const sessionList = {
32
32
  around: { type: 'boolean', description: '附近语义(flag=0 且 up/down 各半)' },
33
33
  }, { description: '拉取会话列表' }),
34
34
  handler: async (args, { host }) => {
35
- const num = Math.min(toUint(args.num, 'num') ?? DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);
35
+ const num = Math.min(toUint(args.num, 'num') ?? SESSION_DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);
36
36
  const flag = args.flag !== undefined ? Number(args.flag) : 2;
37
37
  const around = args.around === true;
38
38
  const curAnchor = args.msgid !== undefined && args.msgid !== '' ? String(args.msgid) : MAX_MSG_ID;
@@ -57,7 +57,7 @@ const sessionList = {
57
57
  method: 'POST',
58
58
  path: '/api/em/msg/executeIm/data/getSessionContext',
59
59
  body,
60
- operation: 'yimiaoban.session.list',
60
+ operation: 'im.session.list',
61
61
  });
62
62
  assertImOk(res, '拉取会话列表');
63
63
  const inner = unwrapInner(res);
@@ -80,7 +80,7 @@ const sessionList = {
80
80
  }
81
81
  const [personMap, groupRes] = await Promise.all([
82
82
  host.resolveUsersByIds([...singleTargets.keys()]),
83
- groupIds.size ? host.request({ method: 'POST', path: '/api/em/msg/executeIm/group/queryGroupInfo', body: { trans_id: 0, type: 0, mask: 0, group_id: [...groupIds], flag: 0 }, operation: 'yimiaoban.session.list.groups' }) : Promise.resolve(null),
83
+ groupIds.size ? host.request({ method: 'POST', path: '/api/em/msg/executeIm/group/queryGroupInfo', body: { trans_id: 0, type: 0, mask: 0, group_id: [...groupIds], flag: 0 }, operation: 'im.session.list.groups' }) : Promise.resolve(null),
84
84
  ]);
85
85
  const groupInfoMap = new Map();
86
86
  if (groupRes) {
@@ -95,7 +95,7 @@ const sessionList = {
95
95
  method: 'POST',
96
96
  path: '/api/em/msg/executeIm/system-msg/syncGroupType',
97
97
  body: { gids: [...sysGroupIds], tids: [], lang: 'zh_CN', showdel: 1 },
98
- operation: 'yimiaoban.session.list.sysgroups',
98
+ operation: 'im.session.list.sysgroups',
99
99
  });
100
100
  const sg = unwrapInner(sysRes)?.groups || [];
101
101
  for (const g of sg)
@@ -172,7 +172,7 @@ const sessionList = {
172
172
  const filterType = args.type !== undefined ? Number(args.type) : undefined;
173
173
  const filtered = filterType !== undefined ? rows.filter((r) => r.sessionType === filterType) : rows;
174
174
  const minLast = filtered.length ? filtered[filtered.length - 1].lastMsgid : '';
175
- return ymbSuccess('yimiaoban.session.list', {
175
+ return imSuccess('im.session.list', {
176
176
  total: filtered.length,
177
177
  sessions: filtered,
178
178
  nextMsgid: minLast && BigInt(minLast) > 0n ? minLast : undefined,
@@ -183,10 +183,10 @@ const sessionList = {
183
183
  };
184
184
  /** 系统消息分组配置搜索。 */
185
185
  const sysmsgGroupSearch = {
186
- name: 'yimiaoban.sysmsg.groupSearch',
186
+ name: 'im.sysmsg.groupSearch',
187
187
  resource: 'sysmsg',
188
188
  method: 'sysmsg.groupSearch',
189
- action: 'yimiaoban.sysmsg.groupSearch',
189
+ action: 'im.sysmsg.groupSearch',
190
190
  summary: '按名称搜索系统消息分组/类型配置(供 querySysMsgInfo 使用)',
191
191
  capability: 'sysmsg',
192
192
  risk: READ,
@@ -208,7 +208,7 @@ const sysmsgGroupSearch = {
208
208
  method: 'POST',
209
209
  path: '/api/em/msg/executeIm/system-msg/searchSysMsgGroup',
210
210
  body,
211
- operation: 'yimiaoban.sysmsg.groupSearch',
211
+ operation: 'im.sysmsg.groupSearch',
212
212
  });
213
213
  assertImOk(res, '搜索系统消息分组');
214
214
  const inner = unwrapInner(res);
@@ -226,15 +226,15 @@ const sysmsgGroupSearch = {
226
226
  i18nName: t.i18nName,
227
227
  state: t.state,
228
228
  }));
229
- return ymbSuccess('yimiaoban.sysmsg.groupSearch', { groups, types, total: Math.max(groups.length, types.length) });
229
+ return imSuccess('im.sysmsg.groupSearch', { groups, types, total: Math.max(groups.length, types.length) });
230
230
  },
231
231
  };
232
232
  /** 系统消息分组/类型配置拉取。 */
233
233
  const sysmsgTypeSync = {
234
- name: 'yimiaoban.sysmsg.typeSync',
234
+ name: 'im.sysmsg.typeSync',
235
235
  resource: 'sysmsg',
236
236
  method: 'sysmsg.typeSync',
237
- action: 'yimiaoban.sysmsg.typeSync',
237
+ action: 'im.sysmsg.typeSync',
238
238
  summary: '按 gids/tids 拉取系统消息分组/类型配置',
239
239
  capability: 'sysmsg',
240
240
  risk: READ,
@@ -246,13 +246,13 @@ const sysmsgTypeSync = {
246
246
  const gids = Array.isArray(args.gids) ? args.gids.map((x) => Number(x)).filter((n) => Number.isInteger(n)) : [];
247
247
  const tids = Array.isArray(args.tids) ? args.tids.map((x) => Number(x)).filter((n) => Number.isInteger(n)) : [];
248
248
  if (!gids.length && !tids.length)
249
- throw ymbValidationError('target_required', 'gids 与 tids 至少其一');
249
+ throw imValidationError('target_required', 'gids 与 tids 至少其一');
250
250
  const body = { gids, tids, lang: 'zh_CN', showdel: 1 };
251
251
  const res = await host.request({
252
252
  method: 'POST',
253
253
  path: '/api/em/msg/executeIm/system-msg/syncGroupType',
254
254
  body,
255
- operation: 'yimiaoban.sysmsg.typeSync',
255
+ operation: 'im.sysmsg.typeSync',
256
256
  });
257
257
  assertImOk(res, '同步系统消息配置');
258
258
  const inner = unwrapInner(res);
@@ -271,80 +271,96 @@ const sysmsgTypeSync = {
271
271
  i18nName: t.i18nName,
272
272
  state: t.state,
273
273
  }));
274
- return ymbSuccess('yimiaoban.sysmsg.typeSync', { groups, types });
274
+ return imSuccess('im.sysmsg.typeSync', { groups, types });
275
275
  },
276
276
  };
277
277
  /** 系统消息内容拉取。 */
278
278
  const sysmsgQuery = {
279
- name: 'yimiaoban.sysmsg.query',
279
+ name: 'im.sysmsg.query',
280
280
  resource: 'sysmsg',
281
281
  method: 'sysmsg.query',
282
- action: 'yimiaoban.sysmsg.query',
283
- summary: '拉取系统消息(流程/任务/公文等),支持阅读维度/处理状态/时间范围/单页倒序',
282
+ action: 'im.sysmsg.query',
283
+ summary: '拉取系统消息(流程/任务/公文等),支持阅读维度/处理状态/时间范围,默认当天且有界区间自动翻页拉完',
284
284
  capability: 'sysmsg',
285
285
  risk: READ,
286
286
  inputSchema: schemaOf({
287
287
  group: { type: 'integer', minimum: 1, description: '系统分组 id' },
288
288
  type: { type: 'integer', description: '消息类型 id' },
289
- num: { type: 'integer', minimum: 1, maximum: 50, description: '单页条数(默认 20)' },
289
+ num: { type: 'integer', minimum: 1, maximum: 50, description: '每页条数(默认 50,最多 50)' },
290
290
  flag: { type: 'integer', enum: [0, 1, 2], description: '0 不分(默认)/1 已读/2 未读' },
291
291
  deal: { type: 'integer', enum: [0, 1, 2], description: '0 全部(默认)/1 未处理/2 已处理' },
292
- from: { type: 'string', description: '起始时间' },
293
- to: { type: 'string', description: '结束时间' },
294
- latest: { type: 'boolean', description: '拉最新不限日期' },
292
+ from: { type: 'string', description: '起始时间;跨度 > 7 天自动收敛为该范围最后 7 天' },
293
+ to: { type: 'string', description: '结束时间(同上)' },
294
+ latest: { type: 'boolean', description: '拉最新不限日期(无界区间,只拉一页)' },
295
295
  start: { type: 'string', description: '手动起始消息 id(最高优先)' },
296
296
  end: { type: 'string', description: '手动结束消息 id' },
297
297
  }, { required: ['group'], description: '拉取系统消息' }),
298
298
  handler: async (args, { host }) => {
299
299
  const group = toUint(args.group, 'group');
300
300
  if (group === undefined || group <= 0) {
301
- throw ymbValidationError('group_required', 'group(系统消息分组 id,来自 sysmsg.groupSearch 或会话列表)必填且为正整数');
301
+ throw imValidationError('group_required', 'group(系统消息分组 id,来自 sysmsg.groupSearch 或会话列表)必填且为正整数');
302
302
  }
303
303
  const hasType = args.type !== undefined && args.type !== null && args.type !== '';
304
304
  const msgType = { group };
305
305
  if (hasType)
306
306
  msgType.type = toUint(args.type, 'type');
307
- // start/end 计算
307
+ // start/end 计算(与源 skill 一致):显式 start > 时间范围(跨度 > 7 天自动收敛)> latest > 默认当天
308
308
  let start = MAX_MSG_ID;
309
309
  let end = '0';
310
+ let scope = 'today';
311
+ let shrink = null;
310
312
  if (args.start !== undefined && args.start !== null && args.start !== '') {
311
313
  start = String(args.start);
312
314
  end = args.end !== undefined && args.end !== '' ? String(args.end) : '0';
315
+ scope = 'explicit-id';
316
+ }
317
+ else if (args.latest === true) {
318
+ scope = 'latest';
313
319
  }
314
- else if (args.latest !== true && (args.from || args.to)) {
315
- const fromSec = args.from ? parseTs(args.from, false) : 0;
316
- const toSec = args.to ? parseTs(args.to, true) : 0;
317
- if (toSec > 0)
318
- start = idRange(toSec).max;
319
- if (fromSec > 0)
320
- end = idRange(fromSec).min;
320
+ else if (args.from || args.to) {
321
+ const clamp = clampTimeRangeTo7Days(parseTimeToSec(args.from, false), parseTimeToSec(args.to, true));
322
+ if (clamp.toSec > 0)
323
+ start = makeMinMaxIdByTm(clamp.toSec).max;
324
+ if (clamp.fromSec > 0)
325
+ end = makeMinMaxIdByTm(clamp.fromSec).min;
326
+ shrink = clamp.shrunk ? clamp : null;
327
+ scope = 'range';
321
328
  }
322
- else if (args.latest !== true) {
329
+ else {
323
330
  // 默认当天
324
- const now = new Date();
325
- const from = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);
326
- const to = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);
327
- start = idRange(Math.floor(to.getTime() / 1000)).max;
328
- end = idRange(Math.floor(from.getTime() / 1000)).min;
331
+ const range = todayRange();
332
+ start = makeMinMaxIdByTm(range.toSec).max;
333
+ end = makeMinMaxIdByTm(range.fromSec).min;
329
334
  }
330
- const num = Math.min(toUint(args.num, 'num') ?? 20, MAX_PAGE_SIZE);
331
- const body = {
332
- trans_id: 0,
333
- dev: 4,
334
- enc_type: 0,
335
- flag: Number(args.flag ?? 0),
336
- deal_status: Number(args.deal ?? 0),
337
- datas: [{ msg_type: msgType, max_num: num, start, end }],
338
- };
339
- const res = await host.request({
340
- method: 'POST',
341
- path: '/api/em/msg/executeIm/system-msg/querySysMsgInfo',
342
- body,
343
- operation: 'yimiaoban.sysmsg.query',
335
+ const num = Math.min(toUint(args.num, 'num') ?? DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE);
336
+ // 有界区间(end != 0:时间范围/默认当天/显式 end)自动循环翻页拉完;无界区间(latest)只拉一页
337
+ const autoLoop = end !== '0';
338
+ const pulled = await pullPaged({
339
+ num,
340
+ start,
341
+ end,
342
+ autoLoop,
343
+ requestOnePage: async (pageStart, pageEnd, maxNum) => {
344
+ const body = {
345
+ trans_id: 0,
346
+ dev: 4,
347
+ enc_type: 0,
348
+ flag: Number(args.flag ?? 0),
349
+ deal_status: Number(args.deal ?? 0),
350
+ datas: [{ msg_type: msgType, max_num: maxNum, start: pageStart, end: pageEnd }],
351
+ };
352
+ const res = await host.request({
353
+ method: 'POST',
354
+ path: '/api/em/msg/executeIm/system-msg/querySysMsgInfo',
355
+ body,
356
+ operation: 'im.sysmsg.query',
357
+ });
358
+ assertImOk(res, '拉取系统消息');
359
+ const inner = unwrapInner(res);
360
+ return Array.isArray(inner?.datas) ? inner.datas : [];
361
+ },
344
362
  });
345
- assertImOk(res, '拉取系统消息');
346
- const inner = unwrapInner(res);
347
- const rawRows = inner?.datas || [];
363
+ const rawRows = pulled.rows;
348
364
  // 状态模式:查 group 配置的 sunread(1=处理状态 / 0=阅读状态)
349
365
  let dealMode = false;
350
366
  try {
@@ -352,7 +368,7 @@ const sysmsgQuery = {
352
368
  method: 'POST',
353
369
  path: '/api/em/msg/executeIm/system-msg/syncGroupType',
354
370
  body: { gids: [group], tids: [], lang: 'zh_CN', showdel: 1 },
355
- operation: 'yimiaoban.sysmsg.query.cfg',
371
+ operation: 'im.sysmsg.query.cfg',
356
372
  });
357
373
  const cfg = unwrapInner(cfgRes)?.groups?.[0];
358
374
  dealMode = Number(cfg?.sunread) === 1;
@@ -399,36 +415,19 @@ const sysmsgQuery = {
399
415
  statusLabel,
400
416
  };
401
417
  });
402
- return ymbSuccess('yimiaoban.sysmsg.query', {
418
+ sortMessagesNewestFirst(messages);
419
+ return imSuccess('im.sysmsg.query', {
403
420
  group,
404
421
  type: hasType ? Number(args.type) : undefined,
405
422
  dealMode,
406
423
  total: messages.length,
407
424
  messages,
408
- start,
409
- end,
410
- hasMore: messages.length >= num,
425
+ range: { start, end, scope, autoPaged: autoLoop },
426
+ ...paginationMeta(pulled, num),
427
+ ...(shrink ? { rangeShrink: rangeShrinkMeta(shrink) } : {}),
411
428
  });
412
429
  },
413
430
  };
414
- function parseTs(value, isEnd) {
415
- const s = String(value ?? '').trim();
416
- if (/^\d{10}$/.test(s))
417
- return Number(s);
418
- const m = s.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T](\d{1,2}):(\d{1,2})(?::(\d{1,2}))?)?$/);
419
- if (!m)
420
- throw ymbValidationError('time_invalid', `无法解析时间参数: ${s}`);
421
- const hh = m[4] !== undefined ? Number(m[4]) : (isEnd ? 23 : 0);
422
- const mm = m[5] !== undefined ? Number(m[5]) : (isEnd ? 59 : 0);
423
- const ss = m[6] !== undefined ? Number(m[6]) : (isEnd ? 59 : 0);
424
- return Math.floor(new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]), hh, mm, ss).getTime() / 1000);
425
- }
426
- function idRange(tmSec) {
427
- if (!tmSec || tmSec <= 0)
428
- return { min: '0', max: '0' };
429
- const base = BigInt(Math.floor(tmSec)) * 1000000000n;
430
- return { min: base.toString(), max: (base + 999999999n).toString() };
431
- }
432
431
  export const sessionOperations = [
433
432
  sessionList,
434
433
  sysmsgGroupSearch,