weaver-work-cli 0.1.76 → 0.1.78
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/{attachment-content-24RL44SE.js → attachment-content-TFOC3Y3X.js} +3 -3
- package/dist/chunks/{chunk-FEZK536Z.js → chunk-4PBN7NJY.js} +353 -43
- package/dist/chunks/{chunk-SQFKBWTR.js → chunk-5VQ7JHV4.js} +132 -47
- package/dist/chunks/{chunk-KJA7CRES.js → chunk-7SQN5IZR.js} +1 -1
- package/dist/chunks/{chunk-MS7MKBGJ.js → chunk-BP7BONZO.js} +664 -75
- package/dist/chunks/{chunk-L5SCNJKX.js → chunk-DACQKJ6O.js} +1 -1
- package/dist/chunks/{chunk-T7HVQ2WP.js → chunk-E2EY3DMS.js} +2 -2
- package/dist/chunks/{chunk-WJQJ7YEX.js → chunk-FAC4IFGQ.js} +2 -2
- package/dist/chunks/{minute-doc-4BA2R5EA.js → chunk-IBTGXLOT.js} +99 -16
- package/dist/chunks/{chunk-OJ4JPD25.js → chunk-LQLIXBJF.js} +6 -8
- package/dist/chunks/{chunk-H6N6U2D6.js → chunk-SWFTWNWL.js} +7 -7
- package/dist/chunks/{chunk-SU6IJD6D.js → chunk-TD5IOEGN.js} +1 -1
- package/dist/chunks/{chunk-Q7RXCK2Y.js → chunk-USYFVIUR.js} +22 -7
- package/dist/chunks/{chunk-WHI6YAUE.js → chunk-UZ2E3VNI.js} +1 -1
- package/dist/chunks/{chunk-AZC53XSQ.js → chunk-VNEU7OUN.js} +1 -1
- package/dist/chunks/{chunk-5QUTQHXF.js → chunk-WNFDR5PC.js} +198 -80
- package/dist/chunks/{chunk-NZQRW4KL.js → chunk-Z44YFIN6.js} +2 -2
- package/dist/chunks/{chunk-R4PN3OFK.js → chunk-ZOTXXGUM.js} +7 -7
- package/dist/chunks/{cli-DFLV57LO.js → cli-WA7FOQKC.js} +10 -10
- package/dist/chunks/{conflict-72Q6DM4I.js → conflict-D4GVAURN.js} +2 -2
- package/dist/chunks/{contract-IRNRQ5FY.js → contract-GW7US3UF.js} +4399 -3547
- package/dist/chunks/{create-flow-UGTDI7SP.js → create-flow-ERDGW3FZ.js} +10 -6
- package/dist/chunks/{ehr-PHIBBUIG.js → ehr-P6T7OAAV.js} +1 -1
- package/dist/chunks/{entry-mode-5WOXFE67.js → entry-mode-SQU5WTX6.js} +3 -3
- package/dist/chunks/{env-H4ALHESA.js → env-DASBNSEM.js} +2 -2
- package/dist/chunks/{factory-COX6AVK7.js → factory-A3NAKZAA.js} +1 -1
- package/dist/chunks/{group-chat-ZIWQQO4G.js → group-chat-7SEAVAJR.js} +3 -3
- package/dist/chunks/{lazy-dispatch-MZ3EZYDL.js → lazy-dispatch-ZDKLS5MR.js} +3 -3
- package/dist/chunks/{meeting-XE6CTXYA.js → meeting-7AEQGBAT.js} +18 -12
- package/dist/chunks/minute-doc-REI6RUE4.js +20 -0
- package/dist/chunks/{project-XREEXFU2.js → project-6PRGBLO2.js} +38 -14
- package/dist/chunks/{recruit-stage-TSQWOGQD.js → recruit-stage-TLZJUFHD.js} +543 -463
- package/dist/chunks/{registry-F4YFZLOD.js → registry-KQ4TNUWO.js} +1 -1
- package/dist/chunks/{registry-7UDUWYB5.js → registry-UVTI323K.js} +12 -11
- package/dist/chunks/{room-recommend-FO3HLPNB.js → room-recommend-ELEJUYBN.js} +4 -4
- package/dist/chunks/{schedule-DHNNOHVS.js → schedule-XBKY7VEA.js} +4 -4
- package/dist/chunks/{update-AV5VOXGY.js → update-77ZUIYSG.js} +2 -2
- package/dist/chunks/{workflow-MAGCHWYZ.js → workflow-SYCBS5XD.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/internal/update/service.js +9 -8
- package/dist/shortcuts/contract/data/collection-ledger-html.js +109 -33
- package/dist/shortcuts/contract/data/collection-node-catalog.js +26 -2
- package/dist/shortcuts/contract/data/report-renderers.js +75 -31
- package/dist/shortcuts/contract/data/report-spec.js +17 -3
- package/dist/shortcuts/contract/manifest.js +20 -3
- package/dist/shortcuts/contract/operations/bizreview-report.js +23 -2
- package/dist/shortcuts/contract/operations/collection-node.js +116 -1
- package/dist/shortcuts/contract/operations/compare-report.js +27 -5
- package/dist/shortcuts/contract/operations/credit-page.js +11 -2
- package/dist/shortcuts/contract/operations/docx-slots.js +27 -2
- package/dist/shortcuts/contract/operations/draft-submit.js +9 -6
- package/dist/shortcuts/contract/operations/elements-build.js +162 -30
- package/dist/shortcuts/contract/operations/elements-spec.js +50 -0
- package/dist/shortcuts/contract/operations/generated-submit.js +35 -0
- package/dist/shortcuts/contract/operations/ledger-card.js +32 -2
- package/dist/shortcuts/contract/operations/ledger-stat.js +17 -5
- package/dist/shortcuts/contract/operations/ledger.js +88 -16
- package/dist/shortcuts/contract/operations/metrics.js +16 -3
- package/dist/shortcuts/contract/operations/ops-draft.js +359 -27
- package/dist/shortcuts/contract/operations/page.js +23 -0
- package/dist/shortcuts/contract/operations/quote-recognize.js +91 -13
- package/dist/shortcuts/contract/operations/quote-submit.js +16 -0
- package/dist/shortcuts/contract/operations/review-report.js +11 -3
- package/dist/shortcuts/contract/operations/save-recognize.js +62 -1
- package/dist/shortcuts/contract/operations/triage.js +18 -3
- package/dist/shortcuts/contract/operations/viewlink.js +17 -1
- package/dist/shortcuts/ehr/operations/recruit.js +255 -90
- package/dist/shortcuts/meeting/confirm-gate.js +42 -0
- package/dist/shortcuts/meeting/continuation.js +6 -2
- package/dist/shortcuts/meeting/minute-doc.js +119 -12
- package/dist/shortcuts/meeting/operations/attachment.js +19 -0
- package/dist/shortcuts/meeting/operations/compose-outcome.js +24 -2
- package/dist/shortcuts/meeting/operations/eb/conflict.js +2 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +162 -19
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +22 -3
- package/dist/shortcuts/meeting/operations/group-share.js +268 -0
- package/dist/shortcuts/meeting/operations/minute-content.js +58 -1
- package/dist/shortcuts/meeting/operations/minute-export.js +295 -0
- package/dist/shortcuts/meeting/operations/registry.js +4 -0
- package/dist/shortcuts/project/operations/read.js +40 -15
- package/dist/shortcuts/recruit-stage/context.js +16 -81
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +89 -53
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +15 -5
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +46 -108
- package/dist/shortcuts/recruit-stage/operations/list.js +203 -74
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -85
- package/dist/shortcuts/recruit-stage/operations/search.js +113 -53
- package/dist/shortcuts/recruit-stage/shared.js +153 -4
- package/dist/shortcuts/workflow/endpoints.js +2 -0
- package/dist/shortcuts/workflow/operations/form.js +11 -0
- package/dist/shortcuts/workflow/operations/read.js +24 -5
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +2 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +2 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +28 -4
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.node.js +198 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.subordinate.js +70 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/workflowClarification.js +15 -5
- package/docs/project.md +1 -1
- package/package.json +1 -1
- 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
- package/skills/weaver-e10-jinchengda/SKILL.md +64 -28
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-bizreview-report-template.html +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-bizreview.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-collection-node.md +26 -2
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +9 -8
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +47 -52
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +5 -5
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +7 -1
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -12
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +44 -1
- package/skills/weaver-e10-jinchengda/references/contract-firstscreen-guide.md +5 -4
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +8 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +33 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-report.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-material-gap.md +17 -3
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +12 -12
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +18 -10
- package/skills/weaver-e10-jinchengda/references/contract-ops-draft.md +77 -37
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +7 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +55 -12
- package/skills/weaver-e10-jinchengda/references/contract-review-todo.md +102 -0
- package/skills/weaver-e10-jinchengda/references/contract-sign-launch.md +1 -17
- package/skills/weaver-e10-jinchengda/references/contract-smart-draft.md +11 -8
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +2 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +6 -6
- package/skills/weaver-e10-meeting/SKILL.md +203 -80
- package/skills/weaver-e10-meeting/references/create-quickstart.md +98 -0
- package/skills/weaver-e10-meeting/references/delivery-checklist.md +34 -0
- package/skills/weaver-e10-meeting/references/error-codes.md +44 -0
- package/skills/weaver-e10-meeting/references/minutes-pipeline.md +56 -3
- package/skills/weaver-e10-meeting/references/room-recommend.md +2 -0
- package/skills/weaver-e10-recruit-stage/SKILL.md +61 -58
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +28 -25
- package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +20 -14
- package/skills/weaver-e10-recruit-stage/lib/recruit-attach-probe.mjs +127 -0
- package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +71 -25
- package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +39 -7
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +2 -2
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +10 -10
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +8 -5
- package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +29 -31
- package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +4 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +6 -6
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +4 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +3 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +10 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +2 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +1 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +10 -28
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +2 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +1 -1
- package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +2 -2
- package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +1 -1
- package/skills/weaver-e10-recruit-stage/templates/match-report.html +14 -10
- package/skills/weaver-e10-shijingran/SKILL.md +2 -2
- package/skills/weaver-e10-shijingran/references/operations.md +5 -2
- package/skills/weaver-e10-shijingran/references/source-manifest.json +41 -40
- package/skills/weaver-e10-workflow/SKILL.md +13 -9
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +33 -8
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +19 -14
- package/skills/weaver-e10-workflow/references/workflow-create.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +4 -2
- package/skills/weaver-e10-workflow/references/workflow-view.md +3 -3
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +132 -42
- package/templates/meeting/minute.docx +0 -0
- package/skills/weaver-e10-yepiaotong.zip +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会议侧「建群 + 把纪要和待办发进群 + @人」。
|
|
3
|
+
*
|
|
4
|
+
* 为什么放在会议模块而不是 im 模块:
|
|
5
|
+
* IM 侧其实**早就有**建群和群发能力(`im.group.create` / `im.msg.send.group` 的两段式),
|
|
6
|
+
* 但它们没挂在 `im group` / `im send` 的子命令上(`im group --help` 只有 search/info/users),
|
|
7
|
+
* 模型按 help 摸能力时完全看不到,于是得出"CLI 不能建群、不能群发"的错误结论(实测白烧 168 秒)。
|
|
8
|
+
* 按"只改会议域"的约束,这里不碰 im 的注册表,而是在会议侧包一层业务语义:
|
|
9
|
+
* 会议名 → 群名、参会人 → 群成员、纪要 docx → 群文件、待办 → 带 @ 的文本消息。
|
|
10
|
+
*
|
|
11
|
+
* 内部固定四步(每步都是 im 的两段式 prepare → apply):
|
|
12
|
+
* ① im.group.create 建群(传 group_id 则跳过)
|
|
13
|
+
* ② im.msg.send.group 发纪要文件(⛔ 只传 file,不带 txt:同传时服务端会丢文件)
|
|
14
|
+
* ③ im.msg.send.group 发待办文本 + @(atUids 必须是群成员,否则 prepare 会拒)
|
|
15
|
+
*/
|
|
16
|
+
import { basename } from 'node:path';
|
|
17
|
+
import { meetingValidationError } from '../errors.js';
|
|
18
|
+
import { meetingSuccess } from './types.js';
|
|
19
|
+
/** 分隔成员:中英文逗号、顿号、分号、空白都认 */
|
|
20
|
+
function splitList(raw) {
|
|
21
|
+
return String(raw ?? '')
|
|
22
|
+
.split(/[,,、;;\s]+/)
|
|
23
|
+
.map((item) => item.trim())
|
|
24
|
+
.filter((item) => item !== '');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 跑一次 IM 两段式(prepare → apply),返回 apply 的结果。
|
|
28
|
+
* 失败不抛,交给调用方决定是"整体失败"还是"只留 warning"。
|
|
29
|
+
*/
|
|
30
|
+
async function runImWrite(imEnv, prepareName, applyName, input) {
|
|
31
|
+
const { getImOperation } = await import('../../im/operations/registry.js');
|
|
32
|
+
const prepared = await getImOperation(prepareName).handler(input, imEnv);
|
|
33
|
+
const continuation = String(prepared?.continuation ?? prepared?.data?.continuation ?? '');
|
|
34
|
+
if (!continuation) {
|
|
35
|
+
return {
|
|
36
|
+
ok: false,
|
|
37
|
+
data: {},
|
|
38
|
+
error: String(prepared?.error?.message ?? '未拿到 continuation(prepare 未通过)').slice(0, 200),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const applied = await getImOperation(applyName).handler({ continuation, confirm: true }, imEnv);
|
|
42
|
+
return {
|
|
43
|
+
ok: applied?.ok === true,
|
|
44
|
+
data: (applied?.data ?? {}),
|
|
45
|
+
error: String(applied?.error?.message ?? '').slice(0, 200),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export const groupShareOperations = [
|
|
49
|
+
{
|
|
50
|
+
name: 'meeting.group.shareMinutes',
|
|
51
|
+
resource: 'meeting',
|
|
52
|
+
method: 'group.shareMinutes',
|
|
53
|
+
action: 'meeting.group.shareMinutes',
|
|
54
|
+
summary: '建会议群并把纪要文档 + 待办发进群(可 @ 具体人):按会议名建群,成员用姓名/工号;'
|
|
55
|
+
+ '已有群时传 group_id 跳过建群。写操作,发送前先让用户确认群名与成员',
|
|
56
|
+
capability: 'minute',
|
|
57
|
+
risk: 'high-risk-write',
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
additionalProperties: false,
|
|
61
|
+
properties: {
|
|
62
|
+
mt_name: { type: 'string', description: '会议名(群名默认用它,如「AI 趋势讨论会」)' },
|
|
63
|
+
group_name: { type: 'string', description: '群名;不传则用 mt_name 或「会议群-MMDD」' },
|
|
64
|
+
members: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: '群成员:姓名或员工 id,逗号/顿号分隔(如「鲁云聪、王丹丹」);至少要传当前登录人以外的人',
|
|
67
|
+
},
|
|
68
|
+
message: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: '发到群里的开头语(一两句话,如「会议纪要与待办已上传,请按分工推进」)。'
|
|
71
|
+
+ '⛔ 待办不要塞在这串里 —— 用 tasks,否则一堆任务被「;」连成一行,群里看着没有换行',
|
|
72
|
+
},
|
|
73
|
+
tasks: {
|
|
74
|
+
type: 'array',
|
|
75
|
+
description: '待办清单:CLI 拼成「@责任人:事项(期限)」,**一行一条**,并自动把这些责任人加入 @ 列表',
|
|
76
|
+
items: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
owner: { type: 'string', description: '责任人姓名(应在 members 里,否则 @ 不生效)' },
|
|
80
|
+
content: { type: 'string', description: '要做的事' },
|
|
81
|
+
due: { type: 'string', description: '期限或交付物,可省略' },
|
|
82
|
+
},
|
|
83
|
+
required: ['content'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
file_path: { type: 'string', description: '要发进群的本地文件(通常是纪要 docx 的 filePath)' },
|
|
87
|
+
at_members: {
|
|
88
|
+
type: 'string',
|
|
89
|
+
description: '@ 谁:姓名或 id,逗号分隔;默认 = members。⛔ 必须是群成员,否则发送会被拒',
|
|
90
|
+
},
|
|
91
|
+
at_all: { type: 'boolean', description: 'true 时 @全体成员(仅文本消息生效)' },
|
|
92
|
+
group_id: { type: 'string', description: '已有群 id:传了就不再建群,直接往里发' },
|
|
93
|
+
dry_run: { type: 'boolean', description: 'true 时只校验成员、返回将要执行的步骤,不真的建群/发送' },
|
|
94
|
+
},
|
|
95
|
+
required: [],
|
|
96
|
+
},
|
|
97
|
+
handler: async (args, env) => {
|
|
98
|
+
const startedAt = Date.now();
|
|
99
|
+
const warnings = [];
|
|
100
|
+
const mtName = String(args.mt_name ?? '').trim();
|
|
101
|
+
let groupName = String(args.group_name ?? '').trim() || mtName;
|
|
102
|
+
const memberTokens = splitList(args.members);
|
|
103
|
+
const filePath = String(args.file_path ?? '').trim();
|
|
104
|
+
const rawMessage = String(args.message ?? '').trim();
|
|
105
|
+
let groupId = String(args.group_id ?? '').trim();
|
|
106
|
+
// 待办按"人 - 事 - 期限"结构化传入,由 CLI 拼成**一行一条**。
|
|
107
|
+
// ⛔ 不能让调用方自己在 message 里拼:模型拼出来的往往是用「;」连成的一整段,
|
|
108
|
+
// IM 里就是一大坨没有换行(用户实测:"任务没有换行,看不清谁负责什么")。
|
|
109
|
+
const rawTasks = Array.isArray(args.tasks) ? args.tasks : [];
|
|
110
|
+
const taskItems = [];
|
|
111
|
+
const taskOwners = [];
|
|
112
|
+
for (const task of rawTasks) {
|
|
113
|
+
const owner = String(task?.owner ?? '').trim();
|
|
114
|
+
const content = String(task?.content ?? task?.task ?? '').trim();
|
|
115
|
+
const due = String(task?.due ?? '').trim();
|
|
116
|
+
if (content === '')
|
|
117
|
+
continue;
|
|
118
|
+
if (owner !== '')
|
|
119
|
+
taskOwners.push(owner);
|
|
120
|
+
taskItems.push({ owner, content, due });
|
|
121
|
+
}
|
|
122
|
+
if (memberTokens.length === 0 && groupId === '') {
|
|
123
|
+
throw meetingValidationError('members_required', '建群至少要给 members(群成员姓名或 id)。只想发消息到已有群就传 group_id');
|
|
124
|
+
}
|
|
125
|
+
if (groupName === '') {
|
|
126
|
+
const now = new Date();
|
|
127
|
+
const mm = String(now.getMonth() + 1).padStart(2, '0');
|
|
128
|
+
const dd = String(now.getDate()).padStart(2, '0');
|
|
129
|
+
groupName = `会议群-${mm}${dd}`;
|
|
130
|
+
}
|
|
131
|
+
// 姓名 → 员工 id(IM 的 uid 就是员工 id)。待办责任人也要解析,否则 @ 不生效
|
|
132
|
+
const { resolvePersonTokens } = await import('./eb/create-flow.js');
|
|
133
|
+
const allTokens = [...new Set([...memberTokens, ...taskOwners])];
|
|
134
|
+
const peopleMap = allTokens.length > 0
|
|
135
|
+
? await resolvePersonTokens(env, allTokens)
|
|
136
|
+
: new Map();
|
|
137
|
+
const resolved = memberTokens.map((token) => peopleMap.get(token)).filter(Boolean);
|
|
138
|
+
const unresolved = memberTokens.filter((token) => !peopleMap.get(token));
|
|
139
|
+
if (unresolved.length > 0) {
|
|
140
|
+
warnings.push(`这些成员没解析到员工 id,已跳过:${unresolved.join('、')}(请核对姓名或直接传 id)`);
|
|
141
|
+
}
|
|
142
|
+
const memberIds = [...new Set(resolved.map((one) => one.id))];
|
|
143
|
+
const memberNames = resolved.map((one) => one.name);
|
|
144
|
+
// ⛔ @ 必须用**解析后的真实姓名**(如「王丹丹(上海)」),不能用调用方传的「王丹丹」:
|
|
145
|
+
// IM 的提及是按姓名精确匹配写进 aus 的,名字差一个字就退化成纯文本「@王丹丹」——
|
|
146
|
+
// 在群里看是一行黑字、点不到人,而且开头还会被补一个孤零零的蓝 @(2026-11-30 实测截图)。
|
|
147
|
+
const displayNameOf = (token) => peopleMap.get(token)?.name ?? token;
|
|
148
|
+
const taskLines = taskItems.map((item) => (`@${item.owner ? displayNameOf(item.owner) : '(未指定)'}:${item.content}${item.due ? `(${item.due})` : ''}`));
|
|
149
|
+
// 开头语里手写的 @原文 也换成真实姓名(模型常写 @王丹丹,组织里实际叫 王丹丹(上海))。
|
|
150
|
+
// 用占位符中转,避免「王丹丹」替换成「王丹丹(上海)」后又被「王丹丹(上海)」那条规则二次替换。
|
|
151
|
+
let headMessage = rawMessage;
|
|
152
|
+
const atSlots = [];
|
|
153
|
+
allTokens.forEach((token, index) => {
|
|
154
|
+
const person = peopleMap.get(token);
|
|
155
|
+
if (!person || person.name === token)
|
|
156
|
+
return;
|
|
157
|
+
if (!headMessage.includes(`@${token}`))
|
|
158
|
+
return;
|
|
159
|
+
const slot = `\u0000AT${index}\u0000`;
|
|
160
|
+
headMessage = headMessage.split(`@${token}`).join(slot);
|
|
161
|
+
atSlots.push({ slot, name: person.name });
|
|
162
|
+
});
|
|
163
|
+
for (const { slot, name } of atSlots)
|
|
164
|
+
headMessage = headMessage.split(slot).join(`@${name}`);
|
|
165
|
+
const message = [headMessage, ...taskLines].filter((line) => line !== '').join('\n');
|
|
166
|
+
// ⛔ IM 侧规则:不准建"不含自己"的群(实测报 `self_not_included`)——
|
|
167
|
+
// 建群成员里自动补上当前登录人,@ 列表不补(不 @ 自己)。
|
|
168
|
+
let selfId = '';
|
|
169
|
+
let selfName = '';
|
|
170
|
+
try {
|
|
171
|
+
const session = await env.host.getSession();
|
|
172
|
+
selfId = String(session?.userId ?? '').trim();
|
|
173
|
+
selfName = String(session?.employeeName ?? session?.name ?? session?.userName ?? '').trim();
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
selfId = '';
|
|
177
|
+
selfName = '';
|
|
178
|
+
}
|
|
179
|
+
const addSelf = selfId !== '' && !memberIds.includes(selfId);
|
|
180
|
+
const createUsers = addSelf ? [selfId, ...memberIds] : memberIds;
|
|
181
|
+
// ⛔ names 必须与 users 一一对应(实测 `names_mismatch`):补了自己就把名字也补在前面
|
|
182
|
+
const createNames = addSelf ? [selfName, ...memberNames] : memberNames;
|
|
183
|
+
const { buildImEnv } = await import('./eb/group-chat.js');
|
|
184
|
+
const imEnv = await buildImEnv(env);
|
|
185
|
+
const steps = [];
|
|
186
|
+
if (args.dry_run === true) {
|
|
187
|
+
return meetingSuccess('meeting.group.shareMinutes', {
|
|
188
|
+
dryRun: true,
|
|
189
|
+
groupName,
|
|
190
|
+
groupId: groupId || null,
|
|
191
|
+
members: memberNames,
|
|
192
|
+
willSendFile: filePath || null,
|
|
193
|
+
willSendText: message || null,
|
|
194
|
+
steps: [
|
|
195
|
+
groupId ? '跳过建群(已给 group_id)' : `建群「${groupName}」,成员 ${memberNames.join('、') || '(空)'}`,
|
|
196
|
+
filePath ? `发纪要文件:${basename(filePath)}` : '不发文件(未传 file_path)',
|
|
197
|
+
message ? '发文本(含 @ 提及)' : '不发文本(未传 message)',
|
|
198
|
+
],
|
|
199
|
+
}, { warnings });
|
|
200
|
+
}
|
|
201
|
+
// ① 建群(没给 group_id 才建)
|
|
202
|
+
if (!groupId) {
|
|
203
|
+
const created = await runImWrite(imEnv, 'im.group.create.prepare', 'im.group.create.apply', {
|
|
204
|
+
users: createUsers,
|
|
205
|
+
...(createNames.length > 0 ? { names: createNames } : {}),
|
|
206
|
+
name: groupName,
|
|
207
|
+
});
|
|
208
|
+
const newId = String(created.data?.groupId ?? created.data?.id ?? '');
|
|
209
|
+
if (!created.ok || newId === '') {
|
|
210
|
+
throw meetingValidationError('group_create_failed', `建群失败:${created.error || '未返回群 id'}。`
|
|
211
|
+
+ '这类失败通常是租户没开 IM 建群权限或成员不在同一组织 —— 如实告诉用户,不要改口说"已建群"');
|
|
212
|
+
}
|
|
213
|
+
groupId = newId;
|
|
214
|
+
steps.push({ step: 'createGroup', ok: true, detail: `群 id ${groupId}(${groupName})` });
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
steps.push({ step: 'createGroup', ok: true, detail: `复用已有群 ${groupId}` });
|
|
218
|
+
}
|
|
219
|
+
// ② 发纪要文件:⛔ 只传 file,不带 txt —— 同传时服务端只落文本、文件被丢
|
|
220
|
+
if (filePath) {
|
|
221
|
+
const sent = await runImWrite(imEnv, 'im.msg.send.group.prepare', 'im.msg.send.group.apply', {
|
|
222
|
+
groupId,
|
|
223
|
+
file: filePath,
|
|
224
|
+
});
|
|
225
|
+
steps.push({ step: 'sendFile', ok: sent.ok, detail: sent.ok ? basename(filePath) : sent.error });
|
|
226
|
+
if (!sent.ok)
|
|
227
|
+
warnings.push(`纪要文件没发进群(${sent.error});文件在本地,可手动转发`);
|
|
228
|
+
}
|
|
229
|
+
// ③ 发文本 + @:atUids 只取"确实是群成员"的人,否则 prepare 会拒发
|
|
230
|
+
if (message) {
|
|
231
|
+
// @ 候选:显式 at_members > 待办责任人 + 群成员(责任人排前面,保证任务那几行都能真 @ 到)
|
|
232
|
+
// 显式 at_members 一律尊重;否则只 @ 文本里**真正出现**的人 ——
|
|
233
|
+
// 文本里没提的人被前置成「@某某」会显得莫名其妙(IM 会把未匹配的 aus 条目补到开头)。
|
|
234
|
+
const explicitAt = splitList(args.at_members);
|
|
235
|
+
const atTokens = explicitAt.length > 0
|
|
236
|
+
? explicitAt
|
|
237
|
+
: [...new Set([...taskOwners, ...memberTokens].filter((token) => message.includes(`@${displayNameOf(token)}`)))];
|
|
238
|
+
const atResolved = atTokens
|
|
239
|
+
.map((token) => peopleMap.get(token))
|
|
240
|
+
.filter(Boolean);
|
|
241
|
+
const atIds = [...new Set(atResolved.map((one) => one.id))].filter((id) => memberIds.includes(id));
|
|
242
|
+
const dropped = atResolved.filter((one) => !memberIds.includes(one.id)).map((one) => one.name);
|
|
243
|
+
if (dropped.length > 0) {
|
|
244
|
+
warnings.push(`这些人不在群里,@ 不生效(已从 atUids 去掉):${dropped.join('、')}`);
|
|
245
|
+
}
|
|
246
|
+
const sent = await runImWrite(imEnv, 'im.msg.send.group.prepare', 'im.msg.send.group.apply', {
|
|
247
|
+
groupId,
|
|
248
|
+
txt: message,
|
|
249
|
+
...(args.at_all === true ? { atAll: true } : {}),
|
|
250
|
+
...(atIds.length > 0 ? { atUids: atIds } : {}),
|
|
251
|
+
});
|
|
252
|
+
steps.push({ step: 'sendText', ok: sent.ok, detail: sent.ok ? `@ ${atIds.length} 人` : sent.error });
|
|
253
|
+
if (!sent.ok)
|
|
254
|
+
warnings.push(`文本没发进群(${sent.error})`);
|
|
255
|
+
}
|
|
256
|
+
const failed = steps.filter((step) => !step.ok);
|
|
257
|
+
return meetingSuccess('meeting.group.shareMinutes', {
|
|
258
|
+
groupId,
|
|
259
|
+
groupName,
|
|
260
|
+
members: memberNames,
|
|
261
|
+
atCount: steps.find((step) => step.step === 'sendText')?.detail ?? '',
|
|
262
|
+
steps,
|
|
263
|
+
durationMs: Date.now() - startedAt,
|
|
264
|
+
...(failed.length === 0 ? { status: 'SENT' } : { status: 'PARTIAL' }),
|
|
265
|
+
}, { warnings });
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
];
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
* 触发解析后立刻返回 `pending`,让调用方 1 分钟后再来查(`parseStatus`)。
|
|
24
24
|
*/
|
|
25
25
|
import { meetingValidationError } from '../errors.js';
|
|
26
|
+
import { requireDestructiveConfirm } from '../confirm-gate.js';
|
|
26
27
|
import { meetingSuccess, SCHEMA_ID } from './types.js';
|
|
27
28
|
/** minutes_status 枚举(接口文档口径)。 */
|
|
28
29
|
const MINUTE_STATUS = {
|
|
@@ -95,6 +96,11 @@ const meetingMinuteWriteContent = {
|
|
|
95
96
|
description: '写完内容后是否生成 docx 并挂到 doc_file(默认 true)。系统不会根据正文自动出文档,'
|
|
96
97
|
+ '不生成纪要文件字段就一直空着;传 false 可跳过',
|
|
97
98
|
},
|
|
99
|
+
confirm: {
|
|
100
|
+
type: 'boolean',
|
|
101
|
+
description: '只有"要覆盖已有正文/纪要文案"时才需要:原字段非空且内容不同 → 不传会被拒绝(confirm_required)。'
|
|
102
|
+
+ '首次写入(原字段为空)或内容相同不需要',
|
|
103
|
+
},
|
|
98
104
|
},
|
|
99
105
|
required: ['id', 'mt_id'],
|
|
100
106
|
},
|
|
@@ -122,6 +128,35 @@ const meetingMinuteWriteContent = {
|
|
|
122
128
|
patch.minutes_content = minutesContent;
|
|
123
129
|
if (parseContent !== undefined)
|
|
124
130
|
patch.parse_content = parseContent;
|
|
131
|
+
// 覆盖已有正文/纪要文案 = 破坏性写入。判断依据是 CLI 读到的现状,不是调用方的声明:
|
|
132
|
+
// 原字段非空且内容不同才拦;首次写入(原字段为空)或内容相同直接放行 —— 日常路径不多一轮确认。
|
|
133
|
+
const willWriteText = minutesContent !== undefined && minutesContent.trim() !== '';
|
|
134
|
+
const willWriteMinutes = parseContent !== undefined && parseContent.trim() !== '';
|
|
135
|
+
if (args.confirm !== true && (willWriteText || willWriteMinutes)) {
|
|
136
|
+
if (!current)
|
|
137
|
+
current = await readMinute(env, id);
|
|
138
|
+
const details = [];
|
|
139
|
+
if (willWriteText) {
|
|
140
|
+
const oldText = textOf(current.minutes_content);
|
|
141
|
+
const nextText = minutesContent;
|
|
142
|
+
if (oldText.trim() !== '' && oldText.trim() !== nextText.trim()) {
|
|
143
|
+
details.push(`纪要原文:现有 ${oldText.length} 字 → 将替换为 ${nextText.length} 字`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (willWriteMinutes) {
|
|
147
|
+
const oldMinute = textOf(current.parse_content);
|
|
148
|
+
const nextMinute = parseContent;
|
|
149
|
+
if (oldMinute.trim() !== '' && oldMinute.trim() !== nextMinute.trim()) {
|
|
150
|
+
details.push(`纪要文案:现有 ${oldMinute.length} 字 → 将替换为 ${nextMinute.length} 字`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
requireDestructiveConfirm({
|
|
154
|
+
confirm: args.confirm,
|
|
155
|
+
destructive: details.length > 0,
|
|
156
|
+
action: '覆盖这条纪要的已有内容',
|
|
157
|
+
details,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
125
160
|
let statusReason;
|
|
126
161
|
if (args.minutes_status !== undefined) {
|
|
127
162
|
patch.minutes_status = textOf(args.minutes_status);
|
|
@@ -159,6 +194,28 @@ const meetingMinuteWriteContent = {
|
|
|
159
194
|
// 导致"正文有内容、纪要文件字段空"(2026-11-16 真机)。
|
|
160
195
|
let minuteDoc = null;
|
|
161
196
|
if (args.with_doc !== false) {
|
|
197
|
+
// ⛔ 优先走 ESB「保存解析并生成文档」(与群聊链路同一条动作流):服务端生成标准文档并回写 mt_minutes。
|
|
198
|
+
// 以前这条路径直接本地拼 docx → 文档中心失败就只剩「文档附件」,纪要文件永远空着。
|
|
199
|
+
try {
|
|
200
|
+
const { generateMinuteDocViaEsb } = await import('../minute-doc.js');
|
|
201
|
+
const esbBody = textOf(after.parse_content) || textOf(after.minutes_content);
|
|
202
|
+
const esb = await generateMinuteDocViaEsb(env, { id, content: esbBody });
|
|
203
|
+
if (esb.docId) {
|
|
204
|
+
const check = await readMinute(env, id);
|
|
205
|
+
const attached = textOf(check.mt_minutes).includes(esb.docId);
|
|
206
|
+
minuteDoc = { docId: esb.docId, source: 'esb', attached };
|
|
207
|
+
if (!attached)
|
|
208
|
+
warnings.push('ESB 已生成纪要文档,但 mt_minutes 回读为空,请稍后复查');
|
|
209
|
+
}
|
|
210
|
+
else if (esb.error) {
|
|
211
|
+
warnings.push(`ESB 生成纪要文档未成功(${esb.error}),改用本地 docx 兜底`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
warnings.push(`ESB 生成纪要文档异常(${String(error?.message ?? error).slice(0, 100)}),改用本地 docx 兜底`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (args.with_doc !== false && !minuteDoc) {
|
|
162
219
|
try {
|
|
163
220
|
const { buildMinuteDocx } = await import('../minute-doc.js');
|
|
164
221
|
const { meetingStateDir } = await import('./env.js');
|
|
@@ -192,7 +249,7 @@ const meetingMinuteWriteContent = {
|
|
|
192
249
|
}
|
|
193
250
|
// 统一走 ensureMinuteDoc:它会把 docx 同时发成"文档中心文档"并写 mt_minutes
|
|
194
251
|
// (mt_minutes 是文档组件,只认文档 id;塞附件 fileId 会被静默丢弃)。
|
|
195
|
-
if (args.with_doc !== false) {
|
|
252
|
+
if (args.with_doc !== false && !minuteDoc) {
|
|
196
253
|
try {
|
|
197
254
|
const { ensureMinuteDoc } = await import('../minute-doc.js');
|
|
198
255
|
const better = await ensureMinuteDoc(env, {
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会议纪要「按模板出文档」——不绑定任何会议记录。
|
|
3
|
+
*
|
|
4
|
+
* 为什么单独一个 op:`meeting.minute.writeContent` 那条链路以「纪要 id + 会议 id」为入口,
|
|
5
|
+
* 会议不存在时 `ensureMinuteDoc` 直接返回 null,于是"没有会议就出不了文档"。
|
|
6
|
+
* 这里只做三件事:模板渲染 → 落 docx → 传文档中心(folder 300),**不碰任何会议/纪要字段**,
|
|
7
|
+
* 所以对现有建会、纪要、任务链路零影响。
|
|
8
|
+
*
|
|
9
|
+
* 模板:templates/meeting/minute.docx(可用 WEAVER_MEETING_MINUTE_TEMPLATE 覆盖)。
|
|
10
|
+
* 样式(半磅):大标题 52 / 抬头栏 22 / 正文与标题沿用 buildBodyParagraphsXml 的字号(22 / 32)。
|
|
11
|
+
*/
|
|
12
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
13
|
+
import { dirname, join, resolve } from 'node:path';
|
|
14
|
+
import { existsSync } from 'node:fs';
|
|
15
|
+
import { fileURLToPath } from 'node:url';
|
|
16
|
+
import { meetingValidationError } from '../errors.js';
|
|
17
|
+
import { meetingSuccess } from './types.js';
|
|
18
|
+
import { buildBodyParagraphsXml, buildMinuteDocx } from '../minute-doc.js';
|
|
19
|
+
import { readDocxEntries, renderDocx, writeDocxEntries } from '../invitation/docx.js';
|
|
20
|
+
import { meetingStateDir } from './env.js';
|
|
21
|
+
/** 正文插入点:模板里这一整段会被替换成渲染好的正文 */
|
|
22
|
+
const BODY_MARK = '@@正文@@';
|
|
23
|
+
/** 模板默认位置:CLI 包根目录下的 templates/meeting/minute.docx */
|
|
24
|
+
function templatePath() {
|
|
25
|
+
const override = process.env.WEAVER_MEETING_MINUTE_TEMPLATE;
|
|
26
|
+
if (override && override.trim() !== '')
|
|
27
|
+
return resolve(override);
|
|
28
|
+
// 打包后位置会变(dist/index.js 或 dist/chunks/*.js),所以不用固定层级,改为向上找
|
|
29
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
30
|
+
for (let i = 0; i < 8; i += 1) {
|
|
31
|
+
const candidate = join(dir, 'templates/meeting/minute.docx');
|
|
32
|
+
if (existsSync(candidate))
|
|
33
|
+
return candidate;
|
|
34
|
+
const parent = dirname(dir);
|
|
35
|
+
if (parent === dir)
|
|
36
|
+
break;
|
|
37
|
+
dir = parent;
|
|
38
|
+
}
|
|
39
|
+
return join(dir, 'templates/meeting/minute.docx');
|
|
40
|
+
}
|
|
41
|
+
/** 目录 id → 目录类型(100=系统 / 200=公共 / 300=个人)。未知目录沿用 company,与旧行为一致。 */
|
|
42
|
+
export function inferFolderType(folderId) {
|
|
43
|
+
if (folderId === '100')
|
|
44
|
+
return 'sys';
|
|
45
|
+
if (folderId === '200')
|
|
46
|
+
return 'company';
|
|
47
|
+
if (folderId === '300')
|
|
48
|
+
return 'privy';
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
/** 目录类型 → 可见范围说明 */
|
|
52
|
+
export function visibilityOf(folderType) {
|
|
53
|
+
if (folderType === 'privy')
|
|
54
|
+
return '仅本人可见(个人知识库)';
|
|
55
|
+
if (folderType === 'company')
|
|
56
|
+
return '本租户可见(公共知识库)';
|
|
57
|
+
if (folderType === 'sys')
|
|
58
|
+
return '系统知识库';
|
|
59
|
+
return '未知';
|
|
60
|
+
}
|
|
61
|
+
function safeName(input) {
|
|
62
|
+
return String(input || '会议纪要').replace(/[\\/:*?"<>|]+/g, '-').replace(/\s+/g, ' ').trim().slice(0, 80)
|
|
63
|
+
|| '会议纪要';
|
|
64
|
+
}
|
|
65
|
+
/** 把模板里 @@正文@@ 所在段落换成正文段落(正文不参与占位符替换,避免内容里的 {} 被误填) */
|
|
66
|
+
export function injectMinuteBody(documentXml, content) {
|
|
67
|
+
const bodyXml = buildBodyParagraphsXml(content, { body: 22, heading: 32, cell: 20 });
|
|
68
|
+
const paragraphs = documentXml.split(/(?=<w:p[ >])/);
|
|
69
|
+
let replaced = false;
|
|
70
|
+
const out = paragraphs.map((chunk) => {
|
|
71
|
+
if (replaced || !chunk.includes(BODY_MARK))
|
|
72
|
+
return chunk;
|
|
73
|
+
replaced = true;
|
|
74
|
+
// 丢掉标记所在段落,换成正文段落(保留结尾的 </w:body> 等尾部由切片自然携带)
|
|
75
|
+
const tail = chunk.slice(chunk.indexOf('</w:p>') + '</w:p>'.length);
|
|
76
|
+
return bodyXml + tail;
|
|
77
|
+
});
|
|
78
|
+
return replaced ? out.join('') : documentXml;
|
|
79
|
+
}
|
|
80
|
+
export const minuteExportOperations = [
|
|
81
|
+
{
|
|
82
|
+
name: 'meeting.minute.exportDoc',
|
|
83
|
+
resource: 'minute',
|
|
84
|
+
method: 'exportDoc',
|
|
85
|
+
action: 'meeting.minute.exportDoc',
|
|
86
|
+
summary: '把会议记录整理成标准版式纪要文档并上传:按模板 templates/meeting/minute.docx 渲染(标题/抬头栏/正文分级),'
|
|
87
|
+
+ '生成 docx 并传文档中心 300 目录,返回文档 id 与本地路径。**不需要会议 id**——系统里没有这场会也能出文档',
|
|
88
|
+
capability: 'minute',
|
|
89
|
+
risk: 'read-before-write',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
properties: {
|
|
94
|
+
subject: { type: 'string', minLength: 1, description: '纪要标题(=文档名),如「东航项目沟通会会议纪要」' },
|
|
95
|
+
content: { type: 'string', minLength: 1, description: '正文(markdown):## 讨论与结论 / ## 会议决议 / ## 待办事项' },
|
|
96
|
+
mt_name: { type: 'string', description: '抬头「会议主题」;不传则用 subject' },
|
|
97
|
+
begin_datetime: { type: 'string', description: '抬头「会议时间」起(yyyy-MM-dd HH:mm);只在记录里有时才传' },
|
|
98
|
+
end_datetime: { type: 'string', description: '抬头「会议时间」止' },
|
|
99
|
+
address: { type: 'string', description: '抬头「会议地点」' },
|
|
100
|
+
host: { type: 'string', description: '抬头「主持人」' },
|
|
101
|
+
recorder: { type: 'string', description: '抬头「记录人」,默认当前登录人' },
|
|
102
|
+
hrm_members: { type: 'string', description: '抬头「参会人员」,逗号分隔' },
|
|
103
|
+
crm_members: { type: 'string', description: '抬头「参会客户」' },
|
|
104
|
+
folder_id: { type: 'string', description: '文档中心目录 id,默认 300(个人知识库);200=公共知识库、100=系统知识库' },
|
|
105
|
+
folder_type: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
enum: ['company', 'privy', 'sys'],
|
|
108
|
+
description: '目录类型;省略时按 folder_id 推断(300→privy、200→company、100→sys)',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
required: ['subject', 'content'],
|
|
112
|
+
},
|
|
113
|
+
handler: async (args, env) => {
|
|
114
|
+
const startedAt = Date.now();
|
|
115
|
+
const subject = String(args.subject ?? '').trim();
|
|
116
|
+
const content = String(args.content ?? '').trim();
|
|
117
|
+
if (!subject)
|
|
118
|
+
throw meetingValidationError('subject_required', '必须提供纪要标题(subject)');
|
|
119
|
+
if (!content)
|
|
120
|
+
throw meetingValidationError('content_required', '必须提供正文(content)');
|
|
121
|
+
const session = await env.host.getSession().catch(() => null);
|
|
122
|
+
let loginName = String(session?.userName ?? session?.name ?? '').trim();
|
|
123
|
+
const warnings = [];
|
|
124
|
+
// 记录人:显式传 > 会话里的姓名 > 文档中心当前用户 > 「未记录」
|
|
125
|
+
// (小E 的会话常常只有 userId,没有姓名,直接写「未记录」在正式文档里很难看)
|
|
126
|
+
let recorder = String(args.recorder ?? '').trim() || loginName;
|
|
127
|
+
if (!recorder) {
|
|
128
|
+
try {
|
|
129
|
+
const { executeCaizhilianOperation } = await import('../../caizhilian/operations.js');
|
|
130
|
+
const { createCaizhilianHost } = await import('../../caizhilian/host.js');
|
|
131
|
+
const { createCaizhilianContinuationSigner } = await import('../../caizhilian/continuation.js');
|
|
132
|
+
const probeEnv = {
|
|
133
|
+
...env,
|
|
134
|
+
host: createCaizhilianHost(env.ctx),
|
|
135
|
+
continuation: createCaizhilianContinuationSigner(env.ctx),
|
|
136
|
+
};
|
|
137
|
+
const who = await executeCaizhilianOperation('caizhilian.user.current', {}, probeEnv);
|
|
138
|
+
const name = String(who?.data?.employeeName ?? who?.data?.name ?? who?.data?.userName ?? '').trim();
|
|
139
|
+
if (name) {
|
|
140
|
+
recorder = name;
|
|
141
|
+
loginName = name;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// 取不到就继续走兜底,不阻断出文档
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!recorder) {
|
|
149
|
+
recorder = '未记录';
|
|
150
|
+
warnings.push('记录人未取到当前登录人姓名,已填「未记录」;要写具体人请显式传 recorder');
|
|
151
|
+
}
|
|
152
|
+
const tplPath = templatePath();
|
|
153
|
+
let template = null;
|
|
154
|
+
try {
|
|
155
|
+
template = await readFile(tplPath);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// ⛔ 不要在这里抛错:模板丢了(CLI 安装不完整 / 升级只覆盖了 dist)时,
|
|
159
|
+
// 报错会让模型自己去满盘 `Get-ChildItem -Recurse -Filter minute.docx` 找模板,
|
|
160
|
+
// 实测白烧 30 秒以上,最后还得用环境变量指过去。这里退回内置版式,照样出文档。
|
|
161
|
+
template = null;
|
|
162
|
+
warnings.push(`纪要模板未随 CLI 包找到(${tplPath}),本次用内置版式生成;`
|
|
163
|
+
+ '重新安装 CLI 可恢复标准模板版式。');
|
|
164
|
+
}
|
|
165
|
+
const values = {
|
|
166
|
+
mt_name: String(args.mt_name ?? '').trim() || subject,
|
|
167
|
+
begin_datetime: String(args.begin_datetime ?? '').trim() || '未记录',
|
|
168
|
+
end_datetime: String(args.end_datetime ?? '').trim() || '未记录',
|
|
169
|
+
address: String(args.address ?? '').trim() || '未记录',
|
|
170
|
+
host: String(args.host ?? '').trim() || '未记录',
|
|
171
|
+
recorder,
|
|
172
|
+
hrm_members: String(args.hrm_members ?? '').trim() || '未记录',
|
|
173
|
+
crm_members: String(args.crm_members ?? '').trim() || '无',
|
|
174
|
+
};
|
|
175
|
+
// 1) 渲染抬头栏占位符(正文此时还没插入,不会误替换用户内容里的 {})
|
|
176
|
+
// 2) 插入正文
|
|
177
|
+
let buffer;
|
|
178
|
+
let filledKeys = [];
|
|
179
|
+
if (template) {
|
|
180
|
+
const rendered = renderDocx(template, (key) => ({ text: values[key] ?? '' }));
|
|
181
|
+
filledKeys = rendered.filled;
|
|
182
|
+
const entries = readDocxEntries(rendered.buffer).map((entry) => (entry.name === 'word/document.xml'
|
|
183
|
+
? { name: entry.name, data: Buffer.from(injectMinuteBody(entry.data.toString('utf8'), content), 'utf8') }
|
|
184
|
+
: entry));
|
|
185
|
+
buffer = writeDocxEntries(entries);
|
|
186
|
+
if (rendered.pending.length > 0) {
|
|
187
|
+
warnings.push(`模板里有未填充的占位符:${rendered.pending.join('、')}(已留空,检查模板是否新增了字段)`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// 内置版式兜底:结构与模板一致(标题 / 抬头栏 / 正文分级),只是字号走默认
|
|
192
|
+
buffer = buildMinuteDocx({
|
|
193
|
+
title: subject,
|
|
194
|
+
meta: [
|
|
195
|
+
`会议主题:${values.mt_name}`,
|
|
196
|
+
`会议时间:${values.begin_datetime} ~ ${values.end_datetime}`,
|
|
197
|
+
`会议地点:${values.address}`,
|
|
198
|
+
`主持人:${values.host}`,
|
|
199
|
+
`记录人:${values.recorder}`,
|
|
200
|
+
`参会人员:${values.hrm_members}`,
|
|
201
|
+
`参会客户:${values.crm_members}`,
|
|
202
|
+
],
|
|
203
|
+
content,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// 3) 落本地 docx
|
|
207
|
+
const fileName = safeName(subject);
|
|
208
|
+
const dir = join(meetingStateDir(env.ctx), 'minute-docs');
|
|
209
|
+
await mkdir(dir, { recursive: true });
|
|
210
|
+
const filePath = join(dir, `${fileName}.docx`);
|
|
211
|
+
await writeFile(filePath, buffer);
|
|
212
|
+
// 4) 传文档中心(folder 默认 300)——与纪要文件同一套动作流,不绑会议
|
|
213
|
+
let docId = '';
|
|
214
|
+
let docError = '';
|
|
215
|
+
let targetFolderId = '300';
|
|
216
|
+
let targetFolderType = 'company';
|
|
217
|
+
let caizhilianEnvRef = null;
|
|
218
|
+
try {
|
|
219
|
+
const { executeCaizhilianOperation } = await import('../../caizhilian/operations.js');
|
|
220
|
+
const { createCaizhilianHost } = await import('../../caizhilian/host.js');
|
|
221
|
+
const { createCaizhilianContinuationSigner } = await import('../../caizhilian/continuation.js');
|
|
222
|
+
const caizhilianEnv = {
|
|
223
|
+
...env,
|
|
224
|
+
host: createCaizhilianHost(env.ctx),
|
|
225
|
+
continuation: createCaizhilianContinuationSigner(env.ctx),
|
|
226
|
+
};
|
|
227
|
+
const folderId = String(args.folder_id ?? '').trim() || '300';
|
|
228
|
+
const folderType = String(args.folder_type ?? '').trim() || inferFolderType(folderId) || 'company';
|
|
229
|
+
targetFolderId = folderId;
|
|
230
|
+
targetFolderType = folderType;
|
|
231
|
+
caizhilianEnvRef = caizhilianEnv;
|
|
232
|
+
const base = {
|
|
233
|
+
file_path: (await import('node:path')).win32.normalize(filePath),
|
|
234
|
+
name: fileName,
|
|
235
|
+
folder_id: folderId,
|
|
236
|
+
folder_type: folderType,
|
|
237
|
+
author_id: String(session?.userId ?? '').trim(),
|
|
238
|
+
};
|
|
239
|
+
const prepared = await executeCaizhilianOperation('caizhilian.document.create-office.prepare', base, caizhilianEnv);
|
|
240
|
+
const continuation = String(prepared?.data?.continuation ?? '');
|
|
241
|
+
if (continuation) {
|
|
242
|
+
const applied = await executeCaizhilianOperation('caizhilian.document.create-office.apply', { ...base, continuation, confirm: true }, caizhilianEnv);
|
|
243
|
+
docId = String(applied?.data?.doc_id ?? '').trim();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
docError = String(error?.message ?? error).slice(0, 200);
|
|
248
|
+
}
|
|
249
|
+
if (!docId) {
|
|
250
|
+
warnings.push(`文档中心未返回文档 id${docError ? `(${docError})` : ''};docx 已落本地,文件名可直接用于上传`);
|
|
251
|
+
}
|
|
252
|
+
// 5) 回查落地结果:目录名 / 类型 / 状态 —— 防止"创建接口说成功、实际落在别处"
|
|
253
|
+
let docFolder = null;
|
|
254
|
+
let docStatus = null;
|
|
255
|
+
let contentType = '';
|
|
256
|
+
if (docId && caizhilianEnvRef) {
|
|
257
|
+
try {
|
|
258
|
+
const { executeCaizhilianOperation } = await import('../../caizhilian/operations.js');
|
|
259
|
+
const got = await executeCaizhilianOperation('caizhilian.document.get', { doc_id: docId }, caizhilianEnvRef);
|
|
260
|
+
const info = got?.data ?? {};
|
|
261
|
+
docStatus = typeof info.docStatus === 'number' ? info.docStatus : null;
|
|
262
|
+
contentType = String(info.contentType ?? '');
|
|
263
|
+
const first = Array.isArray(info.parentFolders) ? info.parentFolders[0] : null;
|
|
264
|
+
if (first) {
|
|
265
|
+
docFolder = { id: String(first.id ?? ''), name: String(first.name ?? ''), type: String(first.type ?? '') };
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
warnings.push(`文档已创建(${docId}),但回查目录失败:${String(error?.message ?? error).slice(0, 120)}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (docFolder && docFolder.id !== targetFolderId) {
|
|
273
|
+
warnings.push(`目标目录是 ${targetFolderId},实际落在 ${docFolder.id}(${docFolder.name})——请确认是否有权限`);
|
|
274
|
+
}
|
|
275
|
+
return meetingSuccess('meeting.minute.exportDoc', {
|
|
276
|
+
subject,
|
|
277
|
+
fileName: `${fileName}.docx`,
|
|
278
|
+
filePath,
|
|
279
|
+
size: buffer.length,
|
|
280
|
+
docId,
|
|
281
|
+
docError,
|
|
282
|
+
folderId: targetFolderId,
|
|
283
|
+
folderType: docFolder?.type || targetFolderType,
|
|
284
|
+
folderName: docFolder?.name ?? '',
|
|
285
|
+
folderPath: docFolder?.name ?? '',
|
|
286
|
+
visibility: visibilityOf(docFolder?.type || targetFolderType),
|
|
287
|
+
docStatus,
|
|
288
|
+
contentType,
|
|
289
|
+
templatePath: tplPath,
|
|
290
|
+
filled: filledKeys,
|
|
291
|
+
durationMs: Date.now() - startedAt,
|
|
292
|
+
}, { warnings });
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
];
|