weaver-work-cli 0.1.80 → 0.1.81
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 +3 -1
- package/dist/chunks/{archive-ENBSUMHV.js → archive-KVV4SM7J.js} +3 -3
- package/dist/chunks/{archive-oa-7BFPQ6M5.js → archive-oa-VRSPNLY4.js} +3 -3
- package/dist/chunks/{asset-V5SUD3PW.js → asset-JZ5MN6OL.js} +306 -10
- package/dist/chunks/{asset-idle-3CEL7WFX.js → asset-idle-B4SAL43V.js} +3 -3
- package/dist/chunks/{attachment-content-SHXZUE3N.js → attachment-content-7W4XQTA7.js} +3 -3
- package/dist/chunks/{blog-FLI4SS3P.js → blog-XCBM467O.js} +3 -3
- package/dist/chunks/{caizhilian-7WCTKCCP.js → caizhilian-NZVUKCZD.js} +5 -5
- package/dist/chunks/{calendar-G726HUUH.js → calendar-OVM2SGYJ.js} +3 -3
- package/dist/chunks/{chunk-XNN5PZTI.js → chunk-3WZMDOI3.js} +1 -1
- package/dist/chunks/{chunk-TM2G7DNT.js → chunk-56F2GGE4.js} +5 -5
- package/dist/chunks/{chunk-LCM5SSGJ.js → chunk-5MM2IZ27.js} +423 -36
- package/dist/chunks/{chunk-BWFCTE43.js → chunk-5NQZO3CO.js} +48 -5
- package/dist/chunks/{chunk-KVCDZ2FX.js → chunk-5RIK6OLF.js} +7 -7
- package/dist/chunks/{chunk-5E2FDXBU.js → chunk-64RYQOXA.js} +1 -1
- package/dist/chunks/{chunk-44ZWNC7A.js → chunk-7BP3HU74.js} +2 -2
- package/dist/chunks/{chunk-3Q5F4C5B.js → chunk-AW3HQUOC.js} +5 -5
- package/dist/chunks/{chunk-7M5OYRK2.js → chunk-BD3M2YVN.js} +3 -3
- package/dist/chunks/{chunk-JEQHNNSS.js → chunk-BFVUBCYO.js} +14 -0
- package/dist/chunks/{chunk-PAWXVT6H.js → chunk-CLVEXDEJ.js} +4 -5
- package/dist/chunks/{chunk-TBCKK6LH.js → chunk-DWCMKEMO.js} +2 -2
- package/dist/chunks/{chunk-AVDEZLEB.js → chunk-E3XUYWYA.js} +4 -4
- package/dist/chunks/{chunk-3IX6L74V.js → chunk-FIPTUAOW.js} +2 -2
- package/dist/chunks/{chunk-4MAQALTM.js → chunk-GQEIHXY5.js} +6 -6
- package/dist/chunks/{chunk-TD5IOEGN.js → chunk-JUPKXW4P.js} +1 -1
- package/dist/chunks/{chunk-HYNOKFYJ.js → chunk-KZ3JR3GE.js} +3 -3
- package/dist/chunks/{chunk-4PBN7NJY.js → chunk-L2PKMZIU.js} +1 -1
- package/dist/chunks/{chunk-DACQKJ6O.js → chunk-LXWWOHM6.js} +4 -4
- package/dist/chunks/{chunk-7DE3VMZD.js → chunk-LYFPWZBD.js} +6 -1
- package/dist/chunks/{chunk-2UV4IZIT.js → chunk-MTIV6JEN.js} +2 -2
- package/dist/chunks/{chunk-WXV5FIKA.js → chunk-MWFKLXVU.js} +38 -38
- package/dist/chunks/{chunk-PMRNIGKZ.js → chunk-RVVRTW4P.js} +2 -2
- package/dist/chunks/{chunk-FPWCCRKT.js → chunk-UASZW22U.js} +3 -3
- package/dist/chunks/{chunk-RVEKGVZU.js → chunk-VMUVVTT4.js} +2 -2
- package/dist/chunks/{chunk-JQPKSQAK.js → chunk-W4BGNYKR.js} +1 -1
- package/dist/chunks/{chunk-OVTCWLNQ.js → chunk-W4R3SXJV.js} +15 -7
- package/dist/chunks/{chunk-UDBQJLQF.js → chunk-WF5G5SV3.js} +2 -2
- package/dist/chunks/{chunk-EGHRA2E3.js → chunk-WM5ZE67G.js} +1 -1
- package/dist/chunks/{chunk-QVKRNL7L.js → chunk-WQ4ZHAEZ.js} +10 -2
- package/dist/chunks/{chunk-JFZM3ZRU.js → chunk-X7OZKI6F.js} +12 -12
- package/dist/chunks/{chunk-YKTVK6XM.js → chunk-Y6HRTEDD.js} +1 -1
- package/dist/chunks/{chunk-2KW7AI6P.js → chunk-YFDKTTYX.js} +8 -5
- package/dist/chunks/{chunk-HKW5FYZR.js → chunk-YLPGCOAM.js} +76 -69
- package/dist/chunks/{chunk-LQLIXBJF.js → chunk-YXIPZFMX.js} +1 -1
- package/dist/chunks/{cli-JDTWQDDR.js → cli-VCQIDBDQ.js} +37 -37
- package/dist/chunks/{commands-J52MJ6NF.js → commands-THGXVOEL.js} +9 -5
- package/dist/chunks/{conflict-O4FXUTIX.js → conflict-T7URCNS6.js} +2 -2
- package/dist/chunks/{contract-GW7US3UF.js → contract-ZLGLQ45G.js} +3 -3
- package/dist/chunks/{cowork-GZDODGKF.js → cowork-2MBNOUYS.js} +21 -8
- package/dist/chunks/{create-flow-YIFMKM2C.js → create-flow-OFZC36MV.js} +6 -6
- package/dist/chunks/{data-HTQZRPPI.js → data-6O7ANJVT.js} +3 -3
- package/dist/chunks/{ebuilder-form-GHNIZ7ET.js → ebuilder-form-OJ3KJVQI.js} +4 -4
- package/dist/chunks/{ehr-7TGZTZR3.js → ehr-NWMI5Q7S.js} +4 -4
- package/dist/chunks/{employee-QX57HEWS.js → employee-O2EPUYIH.js} +2 -2
- package/dist/chunks/{entry-mode-X3KKRN36.js → entry-mode-TVACGU7K.js} +3 -3
- package/dist/chunks/{env-MCVDVISU.js → env-EWG4ZAWP.js} +2 -2
- package/dist/chunks/{esb-ATRKVHCD.js → esb-56FV2PIA.js} +5 -5
- package/dist/chunks/{factory-ALB7DMVY.js → factory-GQSEJRDY.js} +1 -1
- package/dist/chunks/{fna-IKYI3SST.js → fna-YLA3RKRW.js} +3 -3
- package/dist/chunks/{group-chat-GGPL2EBF.js → group-chat-5R6L3LCG.js} +3 -3
- package/dist/chunks/{host-UY4LQPN4.js → host-42MLO4KX.js} +4 -4
- package/dist/chunks/{host-XXGDQM7D.js → host-J72VEDW5.js} +4 -4
- package/dist/chunks/{host-EJSJSLVK.js → host-QKCRQS2C.js} +4 -4
- package/dist/chunks/{host-EYNLB6S4.js → host-W3BVEATN.js} +4 -4
- package/dist/chunks/{host-OT4KNR3G.js → host-YJINI5GG.js} +4 -4
- package/dist/chunks/{host-6UOXYOOY.js → host-ZVGBZOHY.js} +4 -4
- package/dist/chunks/{hrm-5JQ7QZ6A.js → hrm-3JFZNB42.js} +66 -26
- package/dist/chunks/{im-2YJW3EI5.js → im-HKIRPCGD.js} +5 -5
- package/dist/chunks/{invoice-36BCXKOX.js → invoice-4PREIOTG.js} +80 -17
- package/dist/chunks/{jiuchuanhui-KBWUZ7WT.js → jiuchuanhui-K3PLNENZ.js} +3 -3
- package/dist/chunks/{lazy-dispatch-ZDKLS5MR.js → lazy-dispatch-MKGEWZNM.js} +8 -8
- package/dist/chunks/{mail-YBKUM6HM.js → mail-6QPVWKXM.js} +3 -3
- package/dist/chunks/{meeting-MU3RHAEX.js → meeting-QPPEPBSN.js} +15 -15
- package/dist/chunks/{minute-doc-NHIEZEHU.js → minute-doc-JMIDZK5D.js} +1 -1
- package/dist/chunks/{okr-HW7IULIR.js → okr-67C5LQYD.js} +3 -3
- package/dist/chunks/{operations-4P2UYVLH.js → operations-YLKRNAPI.js} +5 -5
- package/dist/chunks/{org-MWWIFNAO.js → org-L5XDM2RQ.js} +2 -2
- package/dist/chunks/{performance-PM2G6L3E.js → performance-33QZZR4I.js} +3 -3
- package/dist/chunks/{plan-3YYGZ7ZM.js → plan-W4BPONRL.js} +3 -3
- package/dist/chunks/{project-6PRGBLO2.js → project-OKSEH6AF.js} +3 -3
- package/dist/chunks/{reception-7G3J2MA6.js → reception-H5M7SPHT.js} +3 -3
- package/dist/chunks/{recruit-stage-5KK7R37U.js → recruit-stage-O2JGNVMO.js} +12 -8
- package/dist/chunks/{registry-4S3RXXWS.js → registry-45VEUYTC.js} +4 -4
- package/dist/chunks/{registry-3VTB3KLV.js → registry-BMTQ55G5.js} +5 -5
- package/dist/chunks/{registry-KQ4TNUWO.js → registry-PYONXFUF.js} +3 -3
- package/dist/chunks/{registry-HWUNNXDU.js → registry-SAMJ4VH2.js} +14 -14
- package/dist/chunks/{registry-AC33ZZVH.js → registry-YY62OFKQ.js} +1 -1
- package/dist/chunks/{room-recommend-V4BSHR2M.js → room-recommend-NRLAZJCI.js} +4 -4
- package/dist/chunks/{schedule-T7W357TN.js → schedule-LNBOCBP5.js} +4 -4
- package/dist/chunks/{smart-extract-T5Z4AULN.js → smart-extract-JOTX6UZC.js} +3 -3
- package/dist/chunks/{update-77ZUIYSG.js → update-BERR64TI.js} +3 -3
- package/dist/chunks/{workflow-SYCBS5XD.js → workflow-ZDQY3TI7.js} +5 -5
- package/dist/core/runtime-agent.js +19 -3
- package/dist/index.js +4 -4
- package/dist/internal/e10/auth/agent-host-key.js +10 -1
- package/dist/internal/e10/auth/commands.js +20 -4
- package/dist/internal/e10/auth/xiaoe.js +15 -3
- package/dist/shortcuts/asset/host.js +39 -1
- package/dist/shortcuts/asset/index.js +16 -2
- package/dist/shortcuts/asset/manifest.js +115 -1
- package/dist/shortcuts/asset/operations/audit-report.js +144 -0
- package/dist/shortcuts/asset/operations/registry.js +4 -0
- package/dist/shortcuts/asset/operations/write.js +7 -1
- package/dist/shortcuts/cowork/operations/read.js +13 -6
- package/dist/shortcuts/cowork/operations/shared.js +15 -0
- package/dist/shortcuts/hrm/host.js +51 -4
- package/dist/shortcuts/hrm/index.js +45 -26
- package/dist/shortcuts/hrm/manifest.js +17 -0
- package/dist/shortcuts/hrm/operations/employee.js +3 -7
- package/dist/shortcuts/hrm/operations/org.js +2 -4
- package/dist/shortcuts/hrm/operations/position.js +2 -4
- package/dist/shortcuts/hrm/operations/shared.js +21 -0
- package/dist/shortcuts/hrm/operations.js +34 -0
- package/dist/shortcuts/im/constants.js +163 -0
- package/dist/shortcuts/im/host.js +12 -5
- package/dist/shortcuts/im/operations/at-mention.js +4 -2
- package/dist/shortcuts/im/operations/file-user.js +3 -1
- package/dist/shortcuts/im/operations/msg-sync.js +219 -2
- package/dist/shortcuts/im/operations/msg-write.js +70 -30
- package/dist/shortcuts/invoice/invoice-record.js +4 -0
- package/dist/shortcuts/invoice/manifest.js +1 -1
- package/dist/shortcuts/invoice/operations/reim-auto.js +10 -7
- package/dist/shortcuts/invoice/read-enrichment.js +74 -7
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +1 -1
- package/dist/shortcuts/meeting/operations/rooms.js +7 -0
- package/dist/shortcuts/recruit-stage/operations/list.js +3 -2
- package/dist/shortcuts/recruit-stage/operations/profile.js +3 -2
- package/dist/shortcuts/recruit-stage/operations/search.js +2 -2
- package/dist/shortcuts/recruit-stage/operations/shortlist.js +3 -2
- package/dist/shortcuts/recruit-stage/operations/tag.js +5 -0
- package/dist/shortcuts/workflow/operations/form.js +2 -1
- package/docs/agent-invoice.md +1 -1
- package/docs/e10-auth.md +14 -1
- package/docs/hrm.md +5 -1
- package/docs/invoice.md +1 -1
- package/docs/ziguanjia.md +5 -1
- package/package.json +1 -1
- package/skill-template/business-info.json +6 -1
- package/skill-template/domains/hrm.md +1 -1
- package/skill-template/domains/yepiaotong.md +1 -1
- package/skill-template/domains/ziguanjia.md +7 -2
- package/skills/weaver-e10-cowork/SKILL.md +13 -1
- package/skills/weaver-e10-hrm/SKILL.md +16 -2
- package/skills/weaver-e10-hrm/references/org.md +1 -1
- package/skills/weaver-e10-meeting/SKILL.md +1 -1
- package/skills/weaver-e10-recruit-stage/SKILL.md +24 -15
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +14 -7
- package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +12 -1
- package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +18 -1
- package/skills/weaver-e10-recruit-stage/lib/resume-import-once.mjs +308 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +9 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +54 -15
- package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +456 -93
- package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +2 -2
- package/skills/weaver-e10-shared/SKILL.md +1 -1
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +1 -1
- package/skills/weaver-e10-shared-report.html +874 -0
- package/skills/weaver-e10-workflow/SKILL.md +4 -4
- package/skills/weaver-e10-workflow/aiDeepRead/config.json +138 -142
- package/skills/weaver-e10-workflow/references/workflow-deep-read.md +7 -7
- package/skills/weaver-e10-yepiaotong/SKILL.md +2 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +5 -3
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +34 -32
- package/skills/weaver-e10-yepiaotong.zip +0 -0
- package/skills/weaver-e10-yimiaoban/SKILL.md +12 -9
- package/skills/weaver-e10-yimiaoban/references/constants.md +291 -0
- package/skills/weaver-e10-yimiaoban/references/ding-write.md +1 -0
- package/skills/weaver-e10-yimiaoban/references/group-read.md +1 -0
- package/skills/weaver-e10-yimiaoban/references/group-write.md +1 -0
- package/skills/weaver-e10-yimiaoban/references/msg-read.md +10 -1
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +3 -1
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +1 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +175 -36
- package/skills/weaver-e10-ziguanjia/SKILL.md +26 -6
- package/skills/weaver-e10-ziguanjia/references/source-manifest.json +1373 -96
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-audit.md +63 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-disabled-capabilities.md +5 -1
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-idle.md +52 -0
- package/skills/weaver-e10-ziguanjia/references/ziguanjia-report.md +59 -0
- package/scripts/pysite/__pycache__/sitecustomize.cpython-312.pyc +0 -0
- package/scripts/pysite/__pycache__/sitecustomize.cpython-313.pyc +0 -0
- package/scripts/pysite/__pycache__/sitecustomize.cpython-314.pyc +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hrmValidationError } from '../errors.js';
|
|
2
2
|
import { READ, SCHEMA_ID, SCHEMA_PAGE, hrmSuccess, schemaOf, } from './types.js';
|
|
3
|
-
import { browserBaseBody, orgLink, pickDefined, toNumber, toPositiveInt, toStringIdList, } from './shared.js';
|
|
3
|
+
import { browserBaseBody, orgLink, pickDefined, requireId, toNumber, toPositiveInt, toStringIdList, } from './shared.js';
|
|
4
4
|
const ORG_TYPES = ['subcompany', 'department'];
|
|
5
5
|
/**
|
|
6
6
|
* 组织浏览接口(分部 subcompany / 部门 department)统一入口。
|
|
@@ -98,9 +98,7 @@ const orgDetail = {
|
|
|
98
98
|
risk: READ,
|
|
99
99
|
inputSchema: schemaOf({ id: SCHEMA_ID }, { required: ['id'] }),
|
|
100
100
|
handler: async (args, { host }) => {
|
|
101
|
-
const id =
|
|
102
|
-
if (!id)
|
|
103
|
-
throw hrmValidationError('id_required', 'id 必填');
|
|
101
|
+
const id = requireId(args.id);
|
|
104
102
|
const session = await host.getSession();
|
|
105
103
|
const baseUrl = session.baseUrl.replace(/\/+$/, '');
|
|
106
104
|
const resp = await host.request({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hrmValidationError } from '../errors.js';
|
|
2
2
|
import { READ, SCHEMA_ID, hrmSuccess, schemaOf, } from './types.js';
|
|
3
|
-
import { positionLink, toNumber, } from './shared.js';
|
|
3
|
+
import { positionLink, requireId, toNumber, } from './shared.js';
|
|
4
4
|
/** 岗位浏览按钮 formDatas 7 字段默认算子声明(录制原样;快捷搜索时保持占位)。 */
|
|
5
5
|
function positionFormDatas() {
|
|
6
6
|
const d = {};
|
|
@@ -92,9 +92,7 @@ const positionDetail = {
|
|
|
92
92
|
risk: READ,
|
|
93
93
|
inputSchema: schemaOf({ id: SCHEMA_ID }, { required: ['id'] }),
|
|
94
94
|
handler: async (args, { host }) => {
|
|
95
|
-
const id =
|
|
96
|
-
if (!id)
|
|
97
|
-
throw hrmValidationError('id_required', 'id 必填');
|
|
95
|
+
const id = requireId(args.id);
|
|
98
96
|
const session = await host.getSession();
|
|
99
97
|
const baseUrl = session.baseUrl.replace(/\/+$/, '');
|
|
100
98
|
const resp = await host.request({
|
|
@@ -36,6 +36,27 @@ export function toPositiveInt(value, field) {
|
|
|
36
36
|
}
|
|
37
37
|
return truncated;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* 必填 ID 归一化:缺失 / 空白 → `${field}_required`,非纯数字 → `${field}_invalid`。
|
|
41
|
+
*
|
|
42
|
+
* 禁止再写 `String(args.id).trim()` 后判空——`String(undefined)` 得到的是字符串
|
|
43
|
+
* `"undefined"`(truthy),判空永远不触发,最终把 `.../undefined` 打到上游拿到 500
|
|
44
|
+
* 「系统内部错误」,把「用户没传参数」误报成「系统故障」。
|
|
45
|
+
* 长整型 id 一律按字符串返回,避免精度丢失。
|
|
46
|
+
*/
|
|
47
|
+
export function requireId(value, field = 'id') {
|
|
48
|
+
if (value === undefined || value === null) {
|
|
49
|
+
throw hrmValidationError(`${field}_required`, `${field} 必填(E10 长整型 id,按字符串传递)`);
|
|
50
|
+
}
|
|
51
|
+
const text = typeof value === 'string' ? value.trim() : String(value).trim();
|
|
52
|
+
if (text === '') {
|
|
53
|
+
throw hrmValidationError(`${field}_required`, `${field} 必填(E10 长整型 id,按字符串传递)`);
|
|
54
|
+
}
|
|
55
|
+
if (!/^\d+$/.test(text)) {
|
|
56
|
+
throw hrmValidationError(`${field}_invalid`, `${field} 必须是数字 id,收到 ${JSON.stringify(text)}`);
|
|
57
|
+
}
|
|
58
|
+
return text;
|
|
59
|
+
}
|
|
39
60
|
/** ID 归一化为字符串数组。长整型 id 一律按字符串传递,避免精度丢失。 */
|
|
40
61
|
export function toStringIdList(value, field) {
|
|
41
62
|
if (value === undefined || value === null)
|
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
import { getHrmOperation } from './operations/registry.js';
|
|
2
2
|
import { assertNoForbiddenKeys, asObject } from './operations/shared.js';
|
|
3
|
+
import { hrmValidationError } from './errors.js';
|
|
4
|
+
/** 值是否「等于没传」:undefined / null / 纯空白字符串。 */
|
|
5
|
+
function isMissing(value) {
|
|
6
|
+
if (value === undefined || value === null)
|
|
7
|
+
return true;
|
|
8
|
+
return typeof value === 'string' && value.trim() === '';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 入口层必填校验。
|
|
12
|
+
*
|
|
13
|
+
* `inputSchema` 只是给 Agent / `hrm schema` 看的文档,**不参与运行时校验**
|
|
14
|
+
* (见 operations/types.ts 的注释)。此前所有参数校验都靠各 handler 自己写,
|
|
15
|
+
* 一旦写成 `String(args.id).trim()`,`String(undefined) === 'undefined'` 就会
|
|
16
|
+
* 绕过判空、把 `/api/.../undefined` 打到上游并换回 500「系统内部错误」(E-9999),
|
|
17
|
+
* 让「参数缺失」伪装成「系统故障」(2026-12-01 审计反馈的 4 个 detail 类操作)。
|
|
18
|
+
*
|
|
19
|
+
* 这里按 schema 的 `required` 兜一层:缺参在任何 HTTP 请求发出前就以
|
|
20
|
+
* validation 错误(E-0003 / 退出码 2)拒绝。`anyOf`「至少一个收敛条件」仍由
|
|
21
|
+
* 各 handler 给出更具体的提示(如 empty_condition),不在入口重复判定。
|
|
22
|
+
*/
|
|
23
|
+
function assertRequiredInput(definition, input) {
|
|
24
|
+
const required = definition.inputSchema.required;
|
|
25
|
+
if (!Array.isArray(required) || required.length === 0)
|
|
26
|
+
return;
|
|
27
|
+
const missing = required
|
|
28
|
+
.filter((key) => typeof key === 'string')
|
|
29
|
+
.filter((key) => isMissing(input[key]));
|
|
30
|
+
if (missing.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
// 单字段缺失沿用 `id_required` / `dept_required` 这种既有口径,多字段缺失用 required_missing。
|
|
33
|
+
const subtype = missing.length === 1 ? `${missing[0]}_required` : 'required_missing';
|
|
34
|
+
throw hrmValidationError(subtype, `缺少必填参数:${missing.join('、')}(用 weaver-work-cli hrm schema --operation ${definition.name} 查看完整入参)`, { operation: definition.name, missing });
|
|
35
|
+
}
|
|
3
36
|
export async function executeHrmOperation(operation, rawInput, context) {
|
|
4
37
|
const definition = getHrmOperation(operation);
|
|
5
38
|
const input = asObject(rawInput);
|
|
6
39
|
assertNoForbiddenKeys(input);
|
|
40
|
+
assertRequiredInput(definition, input);
|
|
7
41
|
const host = {
|
|
8
42
|
request(request) {
|
|
9
43
|
return context.host.request({
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 易秒办常量与位定义(具名化,消除散落在 operation 里的魔法数字)。
|
|
3
|
+
*
|
|
4
|
+
* 这些常量来自原始 skill 的纯知识文档(im-msg-kind-mkind.md / im-searchGroup.md /
|
|
5
|
+
* im-group-onoff-bits.md / im-sysmsg-fields.md)与服务端 path.go,权威说明见
|
|
6
|
+
* skills/weaver-e10-yimiaoban/references/constants.md。
|
|
7
|
+
*
|
|
8
|
+
* 🔴 只定义常量、不改变任何 operation 现有行为;引用方按需取用。
|
|
9
|
+
*/
|
|
10
|
+
/** 消息 kind(具体类型,单一值,5 位编码)。 */
|
|
11
|
+
export const MSG_KIND = {
|
|
12
|
+
TXT_NORMAL: 1001,
|
|
13
|
+
TXT_LINK: 1002,
|
|
14
|
+
TXT_AT: 1003,
|
|
15
|
+
HISTORY: 1004,
|
|
16
|
+
TXT_GRAY: 1005,
|
|
17
|
+
ANNOUNCE: 1006,
|
|
18
|
+
PIC: 2001,
|
|
19
|
+
EMOJI: 2002,
|
|
20
|
+
VOICE: 3001,
|
|
21
|
+
FILE: 4001,
|
|
22
|
+
LOCAL: 5001,
|
|
23
|
+
VIDEO: 6001,
|
|
24
|
+
TOPIC: 6002,
|
|
25
|
+
BIDA: 6003,
|
|
26
|
+
NOTICE: 7000,
|
|
27
|
+
ITEM: 8000,
|
|
28
|
+
IMG_TXT: 9000,
|
|
29
|
+
SEQUENCE: 9001,
|
|
30
|
+
RICH_TXT: 9002,
|
|
31
|
+
};
|
|
32
|
+
/** 消息 kind → 中文名(ByKind 过滤接口输出用)。 */
|
|
33
|
+
export const MSG_KIND_NAME = {
|
|
34
|
+
1001: '文字', 1002: '链接', 1003: '@消息', 1004: '聊天记录', 1005: '灰色消息', 1006: '公告',
|
|
35
|
+
2001: '图片', 2002: '表情', 3001: '语音', 4001: '文件', 5001: '位置',
|
|
36
|
+
6001: '视频', 6002: '话题', 6003: '必达', 7000: '通知提醒', 8000: '事项',
|
|
37
|
+
9000: '图文链接', 9001: '群接龙', 9002: '富文本',
|
|
38
|
+
};
|
|
39
|
+
/** 消息 mkind(按位消息类型掩码,可组合)。 */
|
|
40
|
+
export const MKIND = {
|
|
41
|
+
TXT_NORMAL: 1, // 1<<0
|
|
42
|
+
TXT_LINK: 2, // 1<<1
|
|
43
|
+
TXT_AT: 4, // 1<<2
|
|
44
|
+
HISTORY: 8, // 1<<3
|
|
45
|
+
TXT_GRAY: 16, // 1<<4
|
|
46
|
+
ANNOUNCE: 32, // 1<<5
|
|
47
|
+
PIC: 64, // 1<<6
|
|
48
|
+
EMOJI: 128, // 1<<7
|
|
49
|
+
VOICE: 256, // 1<<8
|
|
50
|
+
FILE: 512, // 1<<9
|
|
51
|
+
LOCAL: 1024, // 1<<10
|
|
52
|
+
VIDEO: 2048, // 1<<11
|
|
53
|
+
TOPIC: 4096, // 1<<12
|
|
54
|
+
BIDA: 8192, // 1<<13
|
|
55
|
+
NOTICE: 16384, // 1<<14
|
|
56
|
+
ITEM: 32768, // 1<<15
|
|
57
|
+
IMG_TXT: 65536, // 1<<16
|
|
58
|
+
SEQUENCE: 131072, // 1<<17
|
|
59
|
+
RICH_TXT: 262144, // 1<<18
|
|
60
|
+
};
|
|
61
|
+
/** mkind 掩码 → kind 对应表(mkindToKindList 顺序)。 */
|
|
62
|
+
export const MKIND_TO_KIND = [
|
|
63
|
+
[MKIND.TXT_NORMAL, MSG_KIND.TXT_NORMAL],
|
|
64
|
+
[MKIND.TXT_LINK, MSG_KIND.TXT_LINK],
|
|
65
|
+
[MKIND.TXT_AT, MSG_KIND.TXT_AT],
|
|
66
|
+
[MKIND.HISTORY, MSG_KIND.HISTORY],
|
|
67
|
+
[MKIND.TXT_GRAY, MSG_KIND.TXT_GRAY],
|
|
68
|
+
[MKIND.ANNOUNCE, MSG_KIND.ANNOUNCE],
|
|
69
|
+
[MKIND.PIC, MSG_KIND.PIC],
|
|
70
|
+
[MKIND.EMOJI, MSG_KIND.EMOJI],
|
|
71
|
+
[MKIND.VOICE, MSG_KIND.VOICE],
|
|
72
|
+
[MKIND.FILE, MSG_KIND.FILE],
|
|
73
|
+
[MKIND.LOCAL, MSG_KIND.LOCAL],
|
|
74
|
+
[MKIND.VIDEO, MSG_KIND.VIDEO],
|
|
75
|
+
[MKIND.TOPIC, MSG_KIND.TOPIC],
|
|
76
|
+
[MKIND.BIDA, MSG_KIND.BIDA],
|
|
77
|
+
[MKIND.NOTICE, MSG_KIND.NOTICE],
|
|
78
|
+
[MKIND.ITEM, MSG_KIND.ITEM],
|
|
79
|
+
[MKIND.IMG_TXT, MSG_KIND.IMG_TXT],
|
|
80
|
+
[MKIND.SEQUENCE, MSG_KIND.SEQUENCE],
|
|
81
|
+
[MKIND.RICH_TXT, MSG_KIND.RICH_TXT],
|
|
82
|
+
];
|
|
83
|
+
/** 按位解析 mkind → kind 列表。mkind 为 0/空返回空数组。 */
|
|
84
|
+
export function mkindToKindList(mkind) {
|
|
85
|
+
const out = [];
|
|
86
|
+
if (!mkind)
|
|
87
|
+
return out;
|
|
88
|
+
for (const [mask, kind] of MKIND_TO_KIND) {
|
|
89
|
+
if ((mkind & mask) === mask)
|
|
90
|
+
out.push(kind);
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 转必达(createDing):源消息体 type → { mkind, tag }。
|
|
96
|
+
* 与源脚本 sendDing.js analyzeSourceMsg 一致:文件/图片/视频各有专用 mkind+tag,
|
|
97
|
+
* 其余类型(文本及原脚本未细分的链接/公告/语音/位置/话题/富文本等)落文本兜底 tag='3'、mkind=1。
|
|
98
|
+
* 🔴 保持源脚本行为,不擅自扩展 tag 语义(tag 仅 0图/1视频/2文件/3文本 四种)。
|
|
99
|
+
*/
|
|
100
|
+
export const DING_SOURCE_TYPE = {
|
|
101
|
+
4: { mkind: MKIND.FILE, tag: '2' }, // 文件
|
|
102
|
+
2: { mkind: MKIND.PIC, tag: '0' }, // 图片
|
|
103
|
+
7: { mkind: MKIND.VIDEO, tag: '1' }, // 视频
|
|
104
|
+
};
|
|
105
|
+
export const DING_SOURCE_DEFAULT = { mkind: MKIND.TXT_NORMAL, tag: '3' };
|
|
106
|
+
/** 群搜索 cond.mask(SEARCH_GROUP_COND,17 位)。CLI 已实现前 7 类,其余为源文档定义。 */
|
|
107
|
+
export const SEARCH_GROUP_MASK = {
|
|
108
|
+
TYPE: 1, // 1<<0
|
|
109
|
+
KEY: 2, // 1<<1
|
|
110
|
+
LABELS: 4, // 1<<2
|
|
111
|
+
MEMBERS: 8, // 1<<3
|
|
112
|
+
PRECISE: 16, // 1<<4
|
|
113
|
+
OWNER: 32, // 1<<5
|
|
114
|
+
CREATOR: 64, // 1<<6
|
|
115
|
+
MANAGER: 128, // 1<<7
|
|
116
|
+
CREATE_RANGE: 256, // 1<<8
|
|
117
|
+
ACTIVE_RANGE: 512, // 1<<9
|
|
118
|
+
TOP: 1024, // 1<<10
|
|
119
|
+
NORMAL: 2048, // 1<<11
|
|
120
|
+
SHARE_JOIN: 4096, // 1<<12
|
|
121
|
+
ID: 8192, // 1<<13
|
|
122
|
+
SORT: 16384, // 1<<14
|
|
123
|
+
TOPIC: 32768, // 1<<15
|
|
124
|
+
GTID: 65536, // 1<<16
|
|
125
|
+
};
|
|
126
|
+
/** 群 mark(MASK_GROUP_MARK,响应字段按位)。 */
|
|
127
|
+
export const GROUP_MARK = {
|
|
128
|
+
ALL: 1, // 1<<0 全员群
|
|
129
|
+
DEPT: 2, // 1<<1 部门群
|
|
130
|
+
EXTERNAL: 4, // 1<<2 外部群
|
|
131
|
+
ITEM: 8, // 1<<3 事项群
|
|
132
|
+
TOPIC: 16, // 1<<4 话题群
|
|
133
|
+
CROSS_SYSTEM: 64, // 1<<6 跨系统群
|
|
134
|
+
};
|
|
135
|
+
/** 群 on_off 开关位:第 N 位 = flag N,值 = 1<<(N-1)。位 15/26 语义反向。 */
|
|
136
|
+
export const GROUP_ONOFF_NAMES = {
|
|
137
|
+
1: '群匿名', 2: '群搜索', 3: '申请加入', 4: '内部群搜索', 5: '仅管理员邀请',
|
|
138
|
+
6: '仅管理员改资料', 7: '仅管理员@全体', 8: '群禁言', 9: '群分享', 10: '新人看历史',
|
|
139
|
+
11: '外部人员加入', 12: '群组广场显示', 13: '群密聊', 14: '群动态规则', 15: '私密话题(反向)',
|
|
140
|
+
16: '仅管理员置顶', 17: '群存在置顶', 18: '按群身份@', 19: '仅管理员按身份@', 20: '仅管理员管事项',
|
|
141
|
+
21: '群设置只读', 22: '触发人数过多禁言(只读)', 23: '设置过成员禁言(只读)', 24: '存在群身份(只读)',
|
|
142
|
+
25: '仅管理员配机器人', 26: '启用机器人(反向)', 27: '话题群定时提醒',
|
|
143
|
+
};
|
|
144
|
+
/** 读取群 on_off 需要的 queryGroupInfo mask 位。 */
|
|
145
|
+
export const MASK_GROUP_ONOFF = 262144; // 1<<18
|
|
146
|
+
/** 系统消息 group 字段的「按位修改」位(modSysMsgGroup 用)。 */
|
|
147
|
+
export const SYSMSG_GROUP_BITS = {
|
|
148
|
+
groupName: 1 << 1, imgid: 1 << 3, ext: 1 << 8, i18nName: 1 << 11,
|
|
149
|
+
enable: 1 << 12, top: 1 << 13, remind: 1 << 14, clear: 1 << 15, unread: 1 << 16,
|
|
150
|
+
sunread: 1 << 18, action: 1 << 19, describe: 1 << 20, link: 1 << 21,
|
|
151
|
+
terminal: 1 << 22, subscript: 1 << 23, ssource: 1 << 24, saddr: 1 << 25,
|
|
152
|
+
scycle: 1 << 26, sshow: 1 << 27, mark: 1 << 28, defmark: 1 << 29,
|
|
153
|
+
id18nDesc: 1 << 30, application: 1 << 31, markSeq: 1 << 32, pcLink: 1 << 33,
|
|
154
|
+
pageOpen: 1 << 34, viewScope: 1 << 35, order: 1 << 36, ignore: 1 << 37,
|
|
155
|
+
jumpAll: 1 << 38, showType: 1 << 39, moduleTag: 1 << 40, delSession: 1 << 44,
|
|
156
|
+
initSession: 1 << 45, location: 1 << 46, locInfo: 1 << 47, pcLocInfo: 1 << 48,
|
|
157
|
+
hideSender: 1 << 49,
|
|
158
|
+
};
|
|
159
|
+
/** 系统消息 type 字段的「按位修改」位(modSysMsgType 用)。 */
|
|
160
|
+
export const SYSMSG_TYPE_BITS = {
|
|
161
|
+
typeName: 1 << 1, imgid: 1 << 2, lt: 1 << 3, lu: 1 << 4,
|
|
162
|
+
ht: 1 << 5, url: 1 << 6, ext: 1 << 7, i18nName: 1 << 8, tab: 1 << 9,
|
|
163
|
+
};
|
|
@@ -476,10 +476,12 @@ export function createImHost(ctx, dependencies = {}) {
|
|
|
476
476
|
params.set('weappAuthStr', weappAuthStr);
|
|
477
477
|
return `${(sessionContext?.baseUrl || '').replace(/\/+$/, '')}/api/file/preview?${params.toString()}`;
|
|
478
478
|
}
|
|
479
|
-
/**
|
|
479
|
+
/** 构造媒体/文件下载 URL(/api/file/remotedownload/{fileId}/im/true;绝对地址)。
|
|
480
|
+
* 🔴 kind='file' 走原文下载语义:**不带 type=imgs / imgFormat**(这两项是图片预览参数,
|
|
481
|
+
* 会让部分环境(如 e-cology)返回 HTML 图片预览页而非文件原文);图片/视频沿用媒体参数不变。 */
|
|
480
482
|
async function buildDownloadUrl(options) {
|
|
481
483
|
await ensureSession();
|
|
482
|
-
const kind = options.kind
|
|
484
|
+
const kind = options.kind ?? 'img';
|
|
483
485
|
const payload = { tag: kind === 'video' ? '1' : '0', msgid: String(options.msgid) };
|
|
484
486
|
if (options.groupId !== undefined && options.groupId !== null && String(options.groupId) !== '') {
|
|
485
487
|
payload.flag = 1;
|
|
@@ -491,9 +493,14 @@ export function createImHost(ctx, dependencies = {}) {
|
|
|
491
493
|
}
|
|
492
494
|
const weappAuthStr = Buffer.from(JSON.stringify(payload), 'utf-8').toString('base64');
|
|
493
495
|
const params = new URLSearchParams();
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
496
|
+
if (kind === 'file') {
|
|
497
|
+
// 文件原文下载:不设 type / imgFormat(e-cology 等环境带 type=imgs 会返回图片预览页)
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
params.set('type', kind === 'video' ? 'video' : 'imgs');
|
|
501
|
+
if (kind !== 'video')
|
|
502
|
+
params.set('imgFormat', options.imgFormat || 'small');
|
|
503
|
+
}
|
|
497
504
|
params.set('authModule', 'im');
|
|
498
505
|
params.set('weappAuthStr', weappAuthStr);
|
|
499
506
|
return `${(sessionContext?.baseUrl || '').replace(/\/+$/, '')}/api/file/remotedownload/${String(options.fileId)}/im/true?${params.toString()}`;
|
|
@@ -108,13 +108,15 @@ export function buildAtText(text, entries) {
|
|
|
108
108
|
/** 组装 sendGroupMsg/sendSingleMsg 的 `msg` 字段值(完整原生 msg JSON 字符串)。 */
|
|
109
109
|
export function buildAtMsgJson(v, aus, self, extra = {},
|
|
110
110
|
/** txt 段附加字段(与 v 同级),如 markdown 的 `{ vt: '1' }`。 */
|
|
111
|
-
txtExtra = {}
|
|
111
|
+
txtExtra = {},
|
|
112
|
+
/** 追加到 dt 的媒体段({img:...} / {file:...}),用于 txt+媒体同发的 type=26 富文本消息。 */
|
|
113
|
+
mediaSegs = []) {
|
|
112
114
|
return JSON.stringify({
|
|
113
115
|
bgc: '',
|
|
114
116
|
cnt: '0',
|
|
115
117
|
dev: 5,
|
|
116
118
|
display: '',
|
|
117
|
-
dt: [{ txt: { aus, ft: 'china', next: '0', v, ...txtExtra } }],
|
|
119
|
+
dt: [{ txt: { aus, ft: 'china', next: '0', v, ...txtExtra } }, ...mediaSegs],
|
|
118
120
|
guid: '0',
|
|
119
121
|
idx: '0',
|
|
120
122
|
opb: ['received', 'reply'],
|
|
@@ -150,7 +150,9 @@ const fileDownload = {
|
|
|
150
150
|
const fileId = String(args.fileId ?? '');
|
|
151
151
|
const msgid = String(args.msgid ?? '');
|
|
152
152
|
const kindRaw = String(args.kind ?? 'img');
|
|
153
|
-
|
|
153
|
+
// kind='file' 必须保留(走文件原文下载 URL),不可折叠成 img——否则 URL 带 type=imgs/imgFormat,
|
|
154
|
+
// 部分环境(如 e-cology)会返回 HTML 图片预览页而非文件原文,导致无法取回/校验文件。
|
|
155
|
+
const kind = kindRaw === 'video' ? 'video' : kindRaw === 'file' ? 'file' : 'img';
|
|
154
156
|
const output = String(args.output ?? '').trim();
|
|
155
157
|
if (!output)
|
|
156
158
|
throw imValidationError('output_required', 'output 必须是明确的本地文件路径');
|
|
@@ -3,6 +3,7 @@ import { READ, schemaOf, imSuccess, } from './types.js';
|
|
|
3
3
|
import { assertImOk, clampTimeRangeTo7Days, compact, DEFAULT_PAGE_SIZE, formatFullTime, makeMinMaxIdByTm, paginationMeta, parseMsg, parseTimeToSec, pullPaged, rangeShrinkMeta, resolveAuthUid, sortMessagesNewestFirst, str, todayRange, unwrapInner, } from './shared.js';
|
|
4
4
|
import { collapseNewlines, collectI18nIds, collectPersonIds, extractFiles, extractImgs, extractVideos, parseContent, senderName, } from './msg-parse.js';
|
|
5
5
|
import { extractQuoteSummary } from './quote-mention.js';
|
|
6
|
+
import { MSG_KIND_NAME, mkindToKindList } from '../constants.js';
|
|
6
7
|
const MAX_MSG_ID = String((1n << 63n) - 1n);
|
|
7
8
|
/**
|
|
8
9
|
* 时间/最新/显式 id 计算 start/end(与源 skill 一致):
|
|
@@ -141,11 +142,11 @@ async function enrichMessages(rawRows, host, options = {}) {
|
|
|
141
142
|
fileId: f.fileId,
|
|
142
143
|
name: f.name,
|
|
143
144
|
size: f.size,
|
|
145
|
+
// 文件原文下载:kind='file'(不带 type=imgs/imgFormat),否则 e-cology 等环境会返回图片预览页而非原文
|
|
144
146
|
downloadUrl: await host.buildDownloadUrl({
|
|
145
147
|
fileId: f.fileId,
|
|
146
148
|
msgid: String(row.ser_msgid ?? ''),
|
|
147
|
-
kind: '
|
|
148
|
-
imgFormat: imgFormat,
|
|
149
|
+
kind: 'file',
|
|
149
150
|
...(options.groupId ? { groupId: options.groupId } : {}),
|
|
150
151
|
...(options.user ? { user: options.user } : {}),
|
|
151
152
|
}),
|
|
@@ -171,6 +172,12 @@ async function enrichMessages(rawRows, host, options = {}) {
|
|
|
171
172
|
must: parsed.must,
|
|
172
173
|
fileName: parsed.fileName,
|
|
173
174
|
media,
|
|
175
|
+
...(row.kind !== undefined && row.kind !== null && Number(row.kind) > 0
|
|
176
|
+
? { kind: Number(row.kind), kindName: MSG_KIND_NAME[Number(row.kind)] }
|
|
177
|
+
: {}),
|
|
178
|
+
...(row.mkind !== undefined && row.mkind !== null && Number(row.mkind) > 0
|
|
179
|
+
? { mkind: Number(row.mkind), mkindKinds: mkindToKindList(Number(row.mkind)).map((k) => ({ kind: k, name: MSG_KIND_NAME[k] })) }
|
|
180
|
+
: {}),
|
|
174
181
|
...(msgObj ? { msg: msgObj } : {}),
|
|
175
182
|
});
|
|
176
183
|
}
|
|
@@ -338,6 +345,214 @@ const msgSyncGroup = {
|
|
|
338
345
|
});
|
|
339
346
|
},
|
|
340
347
|
};
|
|
348
|
+
/**
|
|
349
|
+
* 按 kind 过滤拉取群消息(服务端 /group/syncGroupMsgByKind)。
|
|
350
|
+
*
|
|
351
|
+
* 🔴 kind 是单值(如 2001 图片、4001 文件、1001 文本),不是 mkind 掩码;
|
|
352
|
+
* 转换表见 references/constants.md。响应每条消息带 kind/mkind,已在此透出。
|
|
353
|
+
* 🔴 该接口依赖消息落库时的 mkind;若发送端未带 kind/mKind 导致落库 mkind=0,
|
|
354
|
+
* 按非文本 kind 过滤可能拿不到数据(服务端 ParseMsgMkind 解析为空)。
|
|
355
|
+
*/
|
|
356
|
+
const msgSyncGroupByKind = {
|
|
357
|
+
name: 'im.msg.sync.groupByKind',
|
|
358
|
+
resource: 'msg',
|
|
359
|
+
method: 'msg.sync.groupByKind',
|
|
360
|
+
action: 'im.msg.sync.groupByKind',
|
|
361
|
+
summary: '按消息 kind 过滤拉取某群消息(如图片/文件/文本;服务端按 kind 过滤,响应带 kind/mkind)',
|
|
362
|
+
capability: 'msg',
|
|
363
|
+
risk: READ,
|
|
364
|
+
inputSchema: schemaOf({
|
|
365
|
+
groupId: { type: 'string', pattern: '^\\d+$', description: '群 id(必填)' },
|
|
366
|
+
kind: { type: 'integer', minimum: 1, description: '消息 kind 单值(必填),如 1001 文本/2001 图片/4001 文件/6001 视频;见 constants.md' },
|
|
367
|
+
num: { type: 'integer', minimum: 1, maximum: 50, description: '每页数量(默认 50,最多 50)' },
|
|
368
|
+
latest: { type: 'boolean', description: '拉最新不限日期(无界区间,只拉一页)' },
|
|
369
|
+
from: { type: 'string', description: '起始时间;跨度 > 7 天自动收敛为该范围最后 7 天' },
|
|
370
|
+
to: { type: 'string', description: '结束时间(同上)' },
|
|
371
|
+
startId: { type: 'string', description: '显式起始消息 id(最高优先)' },
|
|
372
|
+
endId: { type: 'string', description: '显式结束消息 id' },
|
|
373
|
+
imgFormat: { type: 'string', enum: ['small', 'large', 'original'], description: '预览规格(默认 small)' },
|
|
374
|
+
}, { required: ['groupId', 'kind'], description: '按 kind 过滤拉取群消息' }),
|
|
375
|
+
handler: async (args, { host }) => {
|
|
376
|
+
const groupId = String(args.groupId);
|
|
377
|
+
if (!groupId || groupId === '0')
|
|
378
|
+
throw imValidationError('id_invalid', 'groupId 必须非 0');
|
|
379
|
+
const kind = Number(args.kind);
|
|
380
|
+
if (!Number.isInteger(kind) || kind <= 0)
|
|
381
|
+
throw imValidationError('kind_invalid', 'kind 必须是正整数(如 2001 图片)');
|
|
382
|
+
const { start, end, scope, shrink } = resolveRange(args, { start: 'startId', end: 'endId' });
|
|
383
|
+
const num = pageSizeOf(args);
|
|
384
|
+
const autoLoop = end !== '0';
|
|
385
|
+
let actCode = 0;
|
|
386
|
+
const pulled = await pullPaged({
|
|
387
|
+
num,
|
|
388
|
+
start,
|
|
389
|
+
end,
|
|
390
|
+
autoLoop,
|
|
391
|
+
requestOnePage: async (pageStart, pageEnd, maxNum) => {
|
|
392
|
+
// 群 ByKind 走 proto 下划线字段;type/group_id 必传(对应 SyncKindGroupMsgRequest)
|
|
393
|
+
const body = {
|
|
394
|
+
trans_id: 0,
|
|
395
|
+
dev: 4,
|
|
396
|
+
type: 0,
|
|
397
|
+
enc_type: 0,
|
|
398
|
+
group_id: groupId,
|
|
399
|
+
start: pageStart,
|
|
400
|
+
end: pageEnd,
|
|
401
|
+
max_num: maxNum,
|
|
402
|
+
kind,
|
|
403
|
+
history: false,
|
|
404
|
+
};
|
|
405
|
+
const res = await host.request({
|
|
406
|
+
method: 'POST',
|
|
407
|
+
path: '/api/em/msg/executeIm/group/syncGroupMsgByKind',
|
|
408
|
+
body,
|
|
409
|
+
operation: 'im.msg.sync.groupByKind',
|
|
410
|
+
});
|
|
411
|
+
actCode = Number(res?.data?.actionMsg?.code ?? -1);
|
|
412
|
+
if (actCode === 1303)
|
|
413
|
+
return [];
|
|
414
|
+
assertImOk(res, '按 kind 拉取群消息');
|
|
415
|
+
const inner = unwrapInner(res);
|
|
416
|
+
// ByKind 响应 datas 为扁平数组;兼容嵌套 datas/datas 两层
|
|
417
|
+
const flat = inner?.datas;
|
|
418
|
+
if (Array.isArray(flat)) {
|
|
419
|
+
// 若元素是含 datas 的分组则展开,否则直接是消息行
|
|
420
|
+
if (flat.length && Array.isArray(flat[0]?.datas))
|
|
421
|
+
return flat.flatMap((g) => g.datas ?? []);
|
|
422
|
+
return flat;
|
|
423
|
+
}
|
|
424
|
+
const outerDatas = inner?.data?.datas ?? [];
|
|
425
|
+
const rows = [];
|
|
426
|
+
for (const g of outerDatas) {
|
|
427
|
+
const list = g?.datas ?? g?.data ?? [];
|
|
428
|
+
if (Array.isArray(list))
|
|
429
|
+
rows.push(...list);
|
|
430
|
+
}
|
|
431
|
+
return rows;
|
|
432
|
+
},
|
|
433
|
+
});
|
|
434
|
+
const authUid = await resolveAuthUid(host);
|
|
435
|
+
const messages = await enrichMessages(pulled.rows, host, {
|
|
436
|
+
authUid,
|
|
437
|
+
groupId,
|
|
438
|
+
imgFormat: args.imgFormat,
|
|
439
|
+
});
|
|
440
|
+
sortMessagesNewestFirst(messages);
|
|
441
|
+
return imSuccess('im.msg.sync.groupByKind', {
|
|
442
|
+
groupId,
|
|
443
|
+
kind,
|
|
444
|
+
kindName: MSG_KIND_NAME[kind],
|
|
445
|
+
total: messages.length,
|
|
446
|
+
messages,
|
|
447
|
+
range: { from: args.from, to: args.to, start, end, scope, autoPaged: autoLoop },
|
|
448
|
+
...paginationMeta(pulled, num),
|
|
449
|
+
...(shrink ? { rangeShrink: rangeShrinkMeta(shrink) } : {}),
|
|
450
|
+
...(actCode === 1303 ? { empty: true, emptyReason: emptyPageNote(args) } : {}),
|
|
451
|
+
});
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
/**
|
|
455
|
+
* 按 kind 过滤拉取单聊消息(服务端 /single/syncSingleMsgByKind)。
|
|
456
|
+
*
|
|
457
|
+
* 🔴 对方字段为 tuser({cid,uid});操作者由 header eteamsid 注入,不传 body。
|
|
458
|
+
* 🔴 kind 为单值(非 mkind 掩码),见 references/constants.md。
|
|
459
|
+
*/
|
|
460
|
+
const msgSyncSingleByKind = {
|
|
461
|
+
name: 'im.msg.sync.singleByKind',
|
|
462
|
+
resource: 'msg',
|
|
463
|
+
method: 'msg.sync.singleByKind',
|
|
464
|
+
action: 'im.msg.sync.singleByKind',
|
|
465
|
+
summary: '按消息 kind 过滤拉取与某人的单聊消息(如图片/文件/文本;响应带 kind/mkind)',
|
|
466
|
+
capability: 'msg',
|
|
467
|
+
risk: READ,
|
|
468
|
+
inputSchema: schemaOf({
|
|
469
|
+
fromUid: { type: 'string', pattern: '^\\d+$', description: '对方 uid(必填)' },
|
|
470
|
+
fromCid: { type: 'string', pattern: '^\\d+$', description: '对方 cid(必填)' },
|
|
471
|
+
kind: { type: 'integer', minimum: 1, description: '消息 kind 单值(必填),如 1001 文本/2001 图片/4001 文件/6001 视频;见 constants.md' },
|
|
472
|
+
num: { type: 'integer', minimum: 1, maximum: 50, description: '每页数量(默认 50,最多 50)' },
|
|
473
|
+
latest: { type: 'boolean', description: '拉最新不限日期(无界区间,只拉一页)' },
|
|
474
|
+
from: { type: 'string', description: '起始时间;跨度 > 7 天自动收敛为该范围最后 7 天' },
|
|
475
|
+
to: { type: 'string', description: '结束时间(同上)' },
|
|
476
|
+
start: { type: 'string', description: '显式起始消息 id(最高优先)' },
|
|
477
|
+
end: { type: 'string', description: '显式结束消息 id' },
|
|
478
|
+
imgFormat: { type: 'string', enum: ['small', 'large', 'original'], description: '预览规格(默认 small)' },
|
|
479
|
+
}, { required: ['fromUid', 'fromCid', 'kind'], description: '按 kind 过滤拉取单聊消息' }),
|
|
480
|
+
handler: async (args, { host }) => {
|
|
481
|
+
const fromUid = String(args.fromUid);
|
|
482
|
+
const fromCid = String(args.fromCid);
|
|
483
|
+
if (!fromUid || !fromCid || fromUid === '0' || fromCid === '0') {
|
|
484
|
+
throw imValidationError('id_invalid', 'fromUid/fromCid 必须非 0');
|
|
485
|
+
}
|
|
486
|
+
const kind = Number(args.kind);
|
|
487
|
+
if (!Number.isInteger(kind) || kind <= 0)
|
|
488
|
+
throw imValidationError('kind_invalid', 'kind 必须是正整数(如 2001 图片)');
|
|
489
|
+
const { start, end, scope, shrink } = resolveRange(args);
|
|
490
|
+
const num = pageSizeOf(args);
|
|
491
|
+
const autoLoop = end !== '0';
|
|
492
|
+
let actCode = 0;
|
|
493
|
+
const pulled = await pullPaged({
|
|
494
|
+
num,
|
|
495
|
+
start,
|
|
496
|
+
end,
|
|
497
|
+
autoLoop,
|
|
498
|
+
requestOnePage: async (pageStart, pageEnd, maxNum) => {
|
|
499
|
+
// 单聊 ByKind model 用驼峰字段:tuser/start/end/kind/maxNum/encType(对方=tuser,操作者走 header)
|
|
500
|
+
const body = {
|
|
501
|
+
trans_id: 0,
|
|
502
|
+
dev: 4,
|
|
503
|
+
tuser: { cid: fromCid, uid: fromUid },
|
|
504
|
+
start: pageStart,
|
|
505
|
+
end: pageEnd,
|
|
506
|
+
kind,
|
|
507
|
+
maxNum: maxNum,
|
|
508
|
+
encType: 0,
|
|
509
|
+
};
|
|
510
|
+
const res = await host.request({
|
|
511
|
+
method: 'POST',
|
|
512
|
+
path: '/api/em/msg/executeIm/single/syncSingleMsgByKind',
|
|
513
|
+
body,
|
|
514
|
+
operation: 'im.msg.sync.singleByKind',
|
|
515
|
+
});
|
|
516
|
+
actCode = Number(res?.data?.actionMsg?.code ?? -1);
|
|
517
|
+
if (actCode === 1303)
|
|
518
|
+
return [];
|
|
519
|
+
assertImOk(res, '按 kind 拉取单聊消息');
|
|
520
|
+
const inner = unwrapInner(res);
|
|
521
|
+
const flat = inner?.datas;
|
|
522
|
+
if (Array.isArray(flat)) {
|
|
523
|
+
if (flat.length && Array.isArray(flat[0]?.datas))
|
|
524
|
+
return flat.flatMap((g) => g.datas ?? []);
|
|
525
|
+
return flat;
|
|
526
|
+
}
|
|
527
|
+
const outerDatas = inner?.data?.datas ?? [];
|
|
528
|
+
const rows = [];
|
|
529
|
+
for (const g of outerDatas) {
|
|
530
|
+
const list = g?.datas ?? g?.data ?? [];
|
|
531
|
+
if (Array.isArray(list))
|
|
532
|
+
rows.push(...list);
|
|
533
|
+
}
|
|
534
|
+
return rows;
|
|
535
|
+
},
|
|
536
|
+
});
|
|
537
|
+
const authUid = await resolveAuthUid(host);
|
|
538
|
+
const messages = await enrichMessages(pulled.rows, host, {
|
|
539
|
+
authUid,
|
|
540
|
+
user: { cid: fromCid, uid: fromUid },
|
|
541
|
+
imgFormat: args.imgFormat,
|
|
542
|
+
});
|
|
543
|
+
sortMessagesNewestFirst(messages);
|
|
544
|
+
return imSuccess('im.msg.sync.singleByKind', {
|
|
545
|
+
total: messages.length,
|
|
546
|
+
kind,
|
|
547
|
+
kindName: MSG_KIND_NAME[kind],
|
|
548
|
+
messages,
|
|
549
|
+
range: { from: args.from, to: args.to, start, end, scope, autoPaged: autoLoop },
|
|
550
|
+
...paginationMeta(pulled, num),
|
|
551
|
+
...(shrink ? { rangeShrink: rangeShrinkMeta(shrink) } : {}),
|
|
552
|
+
...(actCode === 1303 ? { empty: true, emptyReason: emptyPageNote(args) } : {}),
|
|
553
|
+
});
|
|
554
|
+
},
|
|
555
|
+
};
|
|
341
556
|
/** 群置顶消息同步。 */
|
|
342
557
|
const msgTopSync = {
|
|
343
558
|
name: 'im.msg.top.sync',
|
|
@@ -541,6 +756,8 @@ const msgReadGroupDetail = {
|
|
|
541
756
|
export const msgReadOperations = [
|
|
542
757
|
msgSyncSingle,
|
|
543
758
|
msgSyncGroup,
|
|
759
|
+
msgSyncGroupByKind,
|
|
760
|
+
msgSyncSingleByKind,
|
|
544
761
|
msgTopSync,
|
|
545
762
|
msgReadSingle,
|
|
546
763
|
msgReadGroup,
|