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.
- package/README.md +14 -9
- package/dist/cmd/skills/index.js +60 -0
- package/dist/internal/e10/auth/commands.js +44 -31
- package/dist/internal/e10/auth/session.js +44 -3
- package/dist/internal/e10/auth/xiaoe.js +363 -11
- package/dist/internal/e10/context.js +4 -2
- package/dist/internal/skills/detector.js +42 -0
- package/dist/internal/skills/install.js +50 -3
- package/dist/shortcuts/archive/render/search-format.js +12 -3
- package/dist/shortcuts/ebuilder-form/continuation.js +70 -0
- package/dist/shortcuts/ebuilder-form/errors.js +54 -0
- package/dist/shortcuts/ebuilder-form/host.js +1238 -0
- package/dist/shortcuts/ebuilder-form/index.js +108 -0
- package/dist/shortcuts/ebuilder-form/manifest.js +347 -0
- package/dist/shortcuts/ebuilder-form/operations/read.js +157 -0
- package/dist/shortcuts/ebuilder-form/operations/registry.js +56 -0
- package/dist/shortcuts/ebuilder-form/operations/shared.js +132 -0
- package/dist/shortcuts/ebuilder-form/operations/types.js +19 -0
- package/dist/shortcuts/ebuilder-form/operations/write.js +277 -0
- package/dist/shortcuts/ebuilder-form/operations.js +8 -0
- package/dist/shortcuts/ehr/operations/salary.js +2 -140
- package/dist/shortcuts/im/continuation.js +70 -0
- package/dist/shortcuts/{yimiaoban → im}/errors.js +14 -14
- package/dist/shortcuts/{yimiaoban → im}/host.js +26 -26
- package/dist/shortcuts/{yimiaoban → im}/index.js +42 -42
- package/dist/shortcuts/{yimiaoban → im}/manifest.js +7 -6
- package/dist/shortcuts/{yimiaoban → im}/operations/file-user.js +54 -41
- package/dist/shortcuts/{yimiaoban → im}/operations/group-read.js +46 -44
- package/dist/shortcuts/{yimiaoban → im}/operations/group-write.js +113 -66
- package/dist/shortcuts/{yimiaoban → im}/operations/msg-sync.js +164 -141
- package/dist/shortcuts/{yimiaoban → im}/operations/msg-write.js +47 -47
- package/dist/shortcuts/{yimiaoban → im}/operations/person.js +10 -10
- package/dist/shortcuts/{yimiaoban → im}/operations/registry.js +10 -8
- package/dist/shortcuts/{yimiaoban → im}/operations/session.js +82 -83
- package/dist/shortcuts/im/operations/shared.js +442 -0
- package/dist/shortcuts/{yimiaoban → im}/operations/types.js +1 -1
- package/dist/shortcuts/im/operations/user-remind.js +201 -0
- package/dist/shortcuts/{yimiaoban → im}/operations/write-util.js +7 -7
- package/dist/shortcuts/{yimiaoban → im}/operations.js +3 -3
- package/dist/shortcuts/index.js +10 -2
- package/dist/shortcuts/invoice/manifest.js +113 -10
- package/dist/shortcuts/invoice/operations/import.js +39 -14
- package/dist/shortcuts/invoice/operations/reim.js +38 -18
- package/dist/shortcuts/invoice/operations/shared.js +35 -6
- package/dist/shortcuts/jiuchuanhui/manifest.js +3 -3
- package/dist/shortcuts/jiuchuanhui/operations/registry.js +2 -2
- package/dist/shortcuts/{yimiaoban → okr}/continuation.js +10 -10
- package/dist/shortcuts/okr/errors.js +70 -0
- package/dist/shortcuts/okr/host.js +169 -0
- package/dist/shortcuts/okr/index.js +155 -0
- package/dist/shortcuts/okr/manifest.js +70 -0
- package/dist/shortcuts/okr/operations/link.js +305 -0
- package/dist/shortcuts/okr/operations/read.js +481 -0
- package/dist/shortcuts/okr/operations/registry.js +31 -0
- package/dist/shortcuts/okr/operations/shared.js +381 -0
- package/dist/shortcuts/okr/operations/types.js +88 -0
- package/dist/shortcuts/okr/operations/write.js +838 -0
- package/dist/shortcuts/okr/operations.js +8 -0
- package/dist/shortcuts/project/continuation.js +70 -0
- package/dist/shortcuts/project/errors.js +53 -0
- package/dist/shortcuts/project/host.js +160 -0
- package/dist/shortcuts/project/index.js +106 -0
- package/dist/shortcuts/project/manifest.js +36 -0
- package/dist/shortcuts/project/operations/read.js +551 -0
- package/dist/shortcuts/project/operations/registry.js +31 -0
- package/dist/shortcuts/project/operations/shared.js +68 -0
- package/dist/shortcuts/project/operations/types.js +39 -0
- package/dist/shortcuts/project/operations/write.js +266 -0
- package/dist/shortcuts/project/operations.js +8 -0
- package/dist/shortcuts/workflow/continuation.js +508 -0
- package/dist/shortcuts/workflow/endpoints.js +149 -0
- package/dist/shortcuts/workflow/errors.js +112 -0
- package/dist/shortcuts/workflow/host.js +224 -0
- package/dist/shortcuts/workflow/index.js +116 -0
- package/dist/shortcuts/workflow/manifest.js +30 -0
- package/dist/shortcuts/workflow/operations/form.js +4159 -0
- package/dist/shortcuts/workflow/operations/read.js +3778 -0
- package/dist/shortcuts/workflow/operations/registry.js +33 -0
- package/dist/shortcuts/workflow/operations/shared.js +167 -0
- package/dist/shortcuts/workflow/operations/types.js +44 -0
- package/dist/shortcuts/workflow/operations/write.js +1991 -0
- package/dist/shortcuts/workflow/operations.js +119 -0
- package/dist/shortcuts/workflow/state.js +182 -0
- package/docs/SKILL.md +5 -3
- package/docs/_catalog.md +10 -1
- package/docs/agent-invoice.md +2 -2
- package/docs/agent-skill-install.md +2 -2
- package/docs/e10-auth.md +3 -1
- package/docs/ebuilder-form.md +38 -0
- package/docs/im.md +104 -0
- package/docs/invoice.md +5 -5
- package/docs/okr.md +122 -0
- package/docs/operation-manual.md +10 -7
- package/docs/project.md +69 -0
- package/docs/skill-review-2026-09-19.md +68 -0
- package/package.json +3 -2
- package/scripts/package-skill.mjs +38 -11
- package/scripts/sync-connector-skills.mjs +172 -0
- package/skill-template/business-info.json +357 -16
- package/skill-template/domains/ebuilder-form.md +5 -0
- package/skill-template/domains/okr.md +18 -0
- package/skill-template/domains/shijingran.md +3 -0
- package/skill-template/domains/skill-maker.md +4 -4
- package/skill-template/domains/workflow.md +22 -0
- package/skill-template/domains/yepiaotong.md +4 -2
- package/skill-template/domains/yimiaoban.md +13 -10
- package/skill-template/product.json +5 -0
- package/skill-template/skill-template.md +1 -0
- package/skills/weaver-e10-calendar/SKILL.md +5 -1
- package/skills/weaver-e10-calendar/references/calendar-query.md +7 -0
- package/skills/weaver-e10-calendar/references/source-manifest.json +314 -32
- package/skills/weaver-e10-ebuilder-form/SKILL.md +123 -0
- package/skills/weaver-e10-ebuilder-form/references/context-routing.md +90 -0
- package/skills/weaver-e10-ebuilder-form/references/custom-api.md +86 -0
- package/skills/weaver-e10-ebuilder-form/references/disabled-capabilities.md +50 -0
- package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +100 -0
- package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +91 -0
- package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +74 -0
- package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +86 -0
- package/skills/weaver-e10-ebuilder-form/references/source-manifest.json +107 -0
- package/skills/weaver-e10-esb/SKILL.md +1 -1
- package/skills/weaver-e10-esb/references/source-manifest.json +15 -14
- package/skills/weaver-e10-hrm/SKILL.md +1 -1
- package/skills/weaver-e10-hrm/references/source-manifest.json +357 -38
- package/skills/weaver-e10-jiuchuanhui/SKILL.md +22 -4
- package/skills/weaver-e10-jiuchuanhui/references/clue.md +4 -2
- package/skills/weaver-e10-jiuchuanhui/references/contact.md +1 -1
- package/skills/weaver-e10-jiuchuanhui/references/customer.md +3 -3
- package/skills/weaver-e10-jiuchuanhui/references/disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +10 -10
- package/skills/weaver-e10-jiuchuanhui/references/general-helpers.md +3 -3
- package/skills/weaver-e10-jiuchuanhui/references/sale.md +7 -7
- package/skills/weaver-e10-jiuchuanhui/references/source-manifest.json +3 -3
- package/skills/weaver-e10-jucailin/SKILL.md +2 -2
- package/skills/weaver-e10-mail/SKILL.md +22 -6
- package/skills/weaver-e10-meeting/SKILL.md +22 -1
- package/skills/weaver-e10-okr/SKILL.md +139 -0
- package/skills/weaver-e10-okr/references/okr-align.md +59 -0
- package/skills/weaver-e10-okr/references/okr-keyresult.md +68 -0
- package/skills/weaver-e10-okr/references/okr-link-routing.md +67 -0
- package/skills/weaver-e10-okr/references/okr-query.md +105 -0
- package/skills/weaver-e10-okr/references/okr-write.md +94 -0
- package/skills/weaver-e10-okr/references/source-manifest.json +672 -0
- package/skills/weaver-e10-plan/SKILL.md +3 -3
- package/skills/weaver-e10-plan/references/plan-report-write.md +1 -1
- package/skills/weaver-e10-plan/references/source-manifest.json +20 -20
- package/skills/weaver-e10-qiyecheng/SKILL.md +21 -1
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +17 -17
- package/skills/weaver-e10-shared/SKILL.md +79 -11
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +41 -8
- package/skills/weaver-e10-shared/references/non-interactive-environment.md +78 -0
- package/skills/weaver-e10-shared/references/weaver-e10-installation.md +39 -0
- package/skills/weaver-e10-shijingran/SKILL.md +83 -0
- package/skills/weaver-e10-shijingran/references/field-resolution.md +105 -0
- package/skills/weaver-e10-shijingran/references/operations.md +154 -0
- package/skills/weaver-e10-shijingran/references/source-manifest.json +1380 -0
- package/skills/weaver-e10-shijingran/references/write-operations.md +90 -0
- package/skills/weaver-e10-skill-maker/SKILL.md +26 -9
- package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +39 -8
- package/skills/weaver-e10-skill-maker/references/detector-validation.md +25 -8
- package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +66 -5
- package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +86 -0
- package/skills/weaver-e10-skill-maker/references/source-update-detection.md +59 -5
- package/skills/weaver-e10-skill-maker/references/weaver-skill-style.md +16 -8
- package/skills/weaver-e10-wenshuding/SKILL.md +28 -4
- package/skills/weaver-e10-wenshuding/references/archive-search.md +14 -0
- package/skills/weaver-e10-wenshuding/references/source-manifest.json +27 -26
- package/skills/weaver-e10-workflow/SKILL.md +250 -0
- package/skills/weaver-e10-workflow/references/source-manifest.json +1062 -0
- package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +96 -0
- package/skills/weaver-e10-workflow/references/workflow-batch.md +275 -0
- package/skills/weaver-e10-workflow/references/workflow-create.md +182 -0
- package/skills/weaver-e10-workflow/references/workflow-edit.md +106 -0
- package/skills/weaver-e10-workflow/references/workflow-memory.md +165 -0
- package/skills/weaver-e10-workflow/references/workflow-operate.md +153 -0
- package/skills/weaver-e10-workflow/references/workflow-query.md +821 -0
- package/skills/weaver-e10-workflow/references/workflow-share.md +117 -0
- package/skills/weaver-e10-workflow/references/workflow-view.md +189 -0
- package/skills/weaver-e10-yepiaotong/SKILL.md +28 -28
- package/skills/weaver-e10-yepiaotong/references/invoice-disabled-capabilities.md +11 -5
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +14 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +9 -43
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing.md +8 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +13 -17
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +6 -7
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +2 -2
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +1155 -553
- package/skills/weaver-e10-yimiaoban/SKILL.md +56 -38
- package/skills/weaver-e10-yimiaoban/references/ding-write.md +8 -8
- package/skills/weaver-e10-yimiaoban/references/error-codes.md +16 -0
- package/skills/weaver-e10-yimiaoban/references/field-resolution.md +10 -10
- package/skills/weaver-e10-yimiaoban/references/file-user-i18n.md +12 -12
- package/skills/weaver-e10-yimiaoban/references/group-read.md +16 -16
- package/skills/weaver-e10-yimiaoban/references/group-write.md +17 -15
- package/skills/weaver-e10-yimiaoban/references/msg-read.md +21 -17
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +10 -10
- package/skills/weaver-e10-yimiaoban/references/person.md +6 -6
- package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +15 -11
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +11 -10
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +2164 -154
- package/skills/weaver-e10-yimiaoban/references/user-remind.md +75 -0
- package/skills/weaver-e10-ziguanjia/SKILL.md +4 -2
- package/skills/weaver-e10-ziguanjia/references/source-manifest.json +99 -29
- package/tools/weaver-skill-detector-1.0.13/SKILL.md +253 -0
- package/tools/weaver-skill-detector-1.0.13/_meta.json +6 -0
- package/tools/weaver-skill-detector-1.0.13/references/checklist.md +298 -0
- package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +4190 -0
- package/dist/shortcuts/yimiaoban/operations/shared.js +0 -236
- package/docs/yimiaoban.md +0 -86
- package/skills/weaver-e10-calendar/product.json +0 -8
- package/skills/weaver-e10-esb/product.json +0 -8
- package/skills/weaver-e10-hrm/product.json +0 -8
- package/skills/weaver-e10-jiuchuanhui/product.json +0 -8
- package/skills/weaver-e10-jucailin/product.json +0 -8
- package/skills/weaver-e10-mail/product.json +0 -8
- package/skills/weaver-e10-meeting/product.json +0 -8
- package/skills/weaver-e10-plan/product.json +0 -8
- package/skills/weaver-e10-qiyecheng/product.json +0 -8
- package/skills/weaver-e10-skill-maker/product.json +0 -8
- package/skills/weaver-e10-wenshuding/product.json +0 -8
- package/skills/weaver-e10-yepiaotong/product.json +0 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-red.md +0 -261
- package/skills/weaver-e10-yimiaoban/product.json +0 -8
- package/skills/weaver-e10-ziguanjia/product.json +0 -8
- /package/dist/shortcuts/{yimiaoban → im}/operations/msg-parse.js +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { READ, schemaOf,
|
|
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
|
-
|
|
7
|
-
const
|
|
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: '
|
|
20
|
+
name: 'im.session.list',
|
|
21
21
|
resource: 'session',
|
|
22
22
|
method: 'session.list',
|
|
23
|
-
action: '
|
|
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') ??
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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
|
|
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: '
|
|
186
|
+
name: 'im.sysmsg.groupSearch',
|
|
187
187
|
resource: 'sysmsg',
|
|
188
188
|
method: 'sysmsg.groupSearch',
|
|
189
|
-
action: '
|
|
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: '
|
|
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
|
|
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: '
|
|
234
|
+
name: 'im.sysmsg.typeSync',
|
|
235
235
|
resource: 'sysmsg',
|
|
236
236
|
method: 'sysmsg.typeSync',
|
|
237
|
-
action: '
|
|
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
|
|
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: '
|
|
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
|
|
274
|
+
return imSuccess('im.sysmsg.typeSync', { groups, types });
|
|
275
275
|
},
|
|
276
276
|
};
|
|
277
277
|
/** 系统消息内容拉取。 */
|
|
278
278
|
const sysmsgQuery = {
|
|
279
|
-
name: '
|
|
279
|
+
name: 'im.sysmsg.query',
|
|
280
280
|
resource: 'sysmsg',
|
|
281
281
|
method: 'sysmsg.query',
|
|
282
|
-
action: '
|
|
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: '
|
|
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
|
|
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.
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
|
329
|
+
else {
|
|
323
330
|
// 默认当天
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
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') ??
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
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: '
|
|
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
|
-
|
|
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
|
-
|
|
410
|
-
|
|
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,
|