weaver-work-cli 0.1.39 → 0.1.42
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 +4 -2
- package/dist/chunks/{archive-ENZYBBME.js → archive-J4I6MCKF.js} +2 -2
- package/dist/chunks/{archive-oa-YWLEC5V4.js → archive-oa-BRZKKTO4.js} +2 -2
- package/dist/chunks/{asset-OOV6DWPA.js → asset-L7D4FAOZ.js} +2 -2
- package/dist/chunks/{asset-idle-RE632MY5.js → asset-idle-DADLLV75.js} +2 -2
- package/dist/chunks/{attachment-content-RWN2FCLL.js → attachment-content-K4C7VLWQ.js} +3 -3
- package/dist/chunks/{blog-PEPOJAL7.js → blog-BVGQ7NZL.js} +2 -2
- package/dist/chunks/{caizhilian-WYIQDVPJ.js → caizhilian-SAADNFD6.js} +2 -2
- package/dist/chunks/{calendar-CIARBAOX.js → calendar-Q7NQY5Z2.js} +61 -23
- package/dist/chunks/{chunk-F2EQXUEE.js → chunk-3KTFS4IA.js} +397 -159
- package/dist/chunks/{chunk-G2JSIUWF.js → chunk-4PD5NWAX.js} +89 -0
- package/dist/chunks/{chunk-HJYVHXUQ.js → chunk-4RAE6JXP.js} +1 -1
- package/dist/chunks/{chunk-CQHGNCK2.js → chunk-72CKAUAG.js} +41 -8
- package/dist/chunks/{chunk-K3RUEEOL.js → chunk-APVFJUQH.js} +2 -2
- package/dist/chunks/{chunk-BJGXMFGD.js → chunk-BBKDXQEC.js} +2 -2
- package/dist/chunks/chunk-BIPYLLVS.js +501 -0
- package/dist/chunks/{chunk-GVPJZXJ2.js → chunk-EKWAQSLU.js} +92 -50
- package/dist/chunks/{chunk-XXJOSZTQ.js → chunk-FOAA27U5.js} +381 -57
- package/dist/chunks/{chunk-I2HB737U.js → chunk-G4UR6NXN.js} +2 -2
- package/dist/chunks/{chunk-YS5DPN4T.js → chunk-GEWYMQME.js} +1 -1
- package/dist/chunks/{chunk-P2DAISYW.js → chunk-GHXCDPTM.js} +1 -1
- package/dist/chunks/{chunk-L4N7B7ZD.js → chunk-IZ7S7QUS.js} +4 -4
- package/dist/chunks/{chunk-NLK2RZKG.js → chunk-JPRO6ER2.js} +122 -2214
- package/dist/chunks/{chunk-36DIFZAH.js → chunk-LADPYOWC.js} +2 -2
- package/dist/chunks/chunk-LDZQPUIA.js +1238 -0
- package/dist/chunks/chunk-NKZRQXST.js +2546 -0
- package/dist/chunks/{chunk-EINRJHQ3.js → chunk-QKNKR4RH.js} +3 -3
- package/dist/chunks/{chunk-T7JDJJ7H.js → chunk-R4CHUSKC.js} +126 -19
- package/dist/chunks/{chunk-EZGFHJFW.js → chunk-SA6VBIHY.js} +88 -15
- package/dist/chunks/{chunk-ZXRNHZTE.js → chunk-TTPJJJC4.js} +2 -2
- package/dist/chunks/{chunk-KTCB5R5H.js → chunk-W7BEHOSR.js} +2 -2
- package/dist/chunks/{chunk-MUQUHKPG.js → chunk-YRSZQUD2.js} +2 -2
- package/dist/chunks/{conflict-DRMDOL56.js → conflict-F2OMZRTO.js} +2 -2
- package/dist/chunks/{contract-73MERZWN.js → contract-5BETHRSG.js} +2 -2
- package/dist/chunks/{cowork-HNGBPD7A.js → cowork-3MN6EQQO.js} +27 -10
- package/dist/chunks/create-flow-5FQNNMVO.js +55 -0
- package/dist/chunks/{ebuilder-form-OY6DVNRK.js → ebuilder-form-SBHOYBUD.js} +3 -3
- package/dist/chunks/{ehr-RAQNEQO7.js → ehr-KMOJULKG.js} +432 -1234
- package/dist/chunks/env-LB7NBL2O.js +19 -0
- package/dist/chunks/{esb-6XV7C7YV.js → esb-W2PJCFCX.js} +4 -4
- package/dist/chunks/factory-6ZFQXQ46.js +30 -0
- package/dist/chunks/{fna-XTSRB7G7.js → fna-ZQPCUV4R.js} +2 -2
- package/dist/chunks/group-chat-2HHAJN46.js +20 -0
- package/dist/chunks/{host-YMBXWFWX.js → host-4CBHGOHT.js} +3 -3
- package/dist/chunks/{host-A7J6GDUP.js → host-ATKVNZAT.js} +3 -3
- package/dist/chunks/{host-3F5UM5GN.js → host-BQH22NTQ.js} +3 -3
- package/dist/chunks/{host-YAQAPYNP.js → host-X2CSLFM6.js} +3 -3
- package/dist/chunks/{host-VGPVP7YF.js → host-YTODKMSL.js} +3 -3
- package/dist/chunks/{hrm-TLHKC545.js → hrm-FFM4UJFS.js} +4 -4
- package/dist/chunks/{im-YOUCFMUK.js → im-VEHKDQPB.js} +8 -8
- package/dist/chunks/{invoice-WNBS2B4C.js → invoice-LVIKSIIF.js} +3 -3
- package/dist/chunks/{jiuchuanhui-XABWS5RN.js → jiuchuanhui-X6DINO5P.js} +2 -2
- package/dist/chunks/{lazy-dispatch-NLZ5UQQI.js → lazy-dispatch-KSWTN5L6.js} +4 -4
- package/dist/chunks/{mail-LRYMBFNL.js → mail-VDKRGUD3.js} +9 -4
- package/dist/chunks/{meeting-ESXL6MFI.js → meeting-CLC6HP3Z.js} +12 -10
- package/dist/chunks/{okr-EOV65SSF.js → okr-CHG4OO3U.js} +2 -2
- package/dist/chunks/{plan-YFPVKW6Y.js → plan-XWR75667.js} +2 -2
- package/dist/chunks/{project-MDVZUYQW.js → project-5BXOOKMG.js} +40 -23
- package/dist/chunks/recruit-stage-DGMFNNDE.js +4507 -0
- package/dist/chunks/{registry-VT5Y2HLA.js → registry-7FFOXIAW.js} +4 -4
- package/dist/chunks/{registry-QCLZEDAP.js → registry-BKBZPBAJ.js} +10 -8
- package/dist/chunks/{registry-YX4CSEMD.js → registry-RHMW6ANW.js} +2 -2
- package/dist/chunks/{registry-NYPYMZXG.js → registry-Z43434VG.js} +1 -1
- package/dist/chunks/{room-recommend-L3MWH4JW.js → room-recommend-62H7ZQQ6.js} +4 -4
- package/dist/chunks/{schedule-UASAVDVD.js → schedule-FNXKH3DQ.js} +4 -4
- package/dist/chunks/{workflow-KDGIUCNW.js → workflow-ADHKCAJK.js} +4 -4
- package/dist/index.js +33 -28
- package/dist/internal/e10/auth/commands.js +110 -56
- package/dist/internal/e10/auth/messages.js +6 -0
- package/dist/internal/e10/auth/session.js +28 -1
- package/dist/internal/e10/auth/xiaoe.js +315 -48
- package/dist/internal/e10/auth-recovery.js +36 -5
- package/dist/internal/e10/client.js +13 -0
- package/dist/internal/e10/context.js +61 -9
- package/dist/internal/e10/index.js +1 -1
- package/dist/internal/e10/network-error.js +93 -0
- package/dist/internal/e10/request-runtime.js +15 -0
- package/dist/shortcuts/calendar/operations/read.js +31 -22
- package/dist/shortcuts/calendar/operations/write.js +45 -1
- package/dist/shortcuts/cowork/operations/discuss-write.js +5 -1
- package/dist/shortcuts/cowork/operations/item-write.js +5 -3
- package/dist/shortcuts/cowork/operations/member-write.js +3 -1
- package/dist/shortcuts/cowork/operations/permission-write.js +5 -1
- package/dist/shortcuts/cowork/operations/shared.js +7 -0
- package/dist/shortcuts/ehr/operations/attend-write.js +43 -1
- package/dist/shortcuts/ehr/operations/hr-contact.js +7 -4
- package/dist/shortcuts/ehr/operations/hr-report.js +13 -7
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +134 -59
- package/dist/shortcuts/ehr/operations/recruit-write.js +262 -17
- package/dist/shortcuts/ehr/operations/recruit.js +10 -4
- package/dist/shortcuts/ehr/operations/shared.js +47 -0
- package/dist/shortcuts/hrm/operations/org.js +118 -0
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/mail/operations/mail-send.js +8 -2
- package/dist/shortcuts/meeting/operations/eb/catalog.js +9 -2
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +461 -127
- package/dist/shortcuts/meeting/operations/eb/crm-search.js +87 -5
- package/dist/shortcuts/meeting/operations/eb/factory.js +33 -0
- package/dist/shortcuts/meeting/operations/eb/flow-memory.js +49 -0
- package/dist/shortcuts/meeting/operations/eb/group-chat.js +605 -0
- package/dist/shortcuts/meeting/operations/eb/index.js +2 -0
- package/dist/shortcuts/meeting/operations/eb/person-cache.js +96 -0
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +44 -6
- package/dist/shortcuts/meeting/operations/eb/room-summary.js +2 -0
- package/dist/shortcuts/meeting/operations/eb/usage-cache.js +99 -0
- package/dist/shortcuts/meeting/operations/from-group-chat.js +35 -12
- package/dist/shortcuts/project/operations/read.js +6 -25
- package/dist/shortcuts/project/operations/shared.js +22 -0
- package/dist/shortcuts/project/operations/write.js +28 -2
- package/dist/shortcuts/recruit-stage/context.js +119 -0
- package/dist/shortcuts/recruit-stage/continuation.js +73 -0
- package/dist/shortcuts/recruit-stage/errors.js +65 -0
- package/dist/shortcuts/recruit-stage/host.js +109 -0
- package/dist/shortcuts/recruit-stage/index.js +115 -0
- package/dist/shortcuts/recruit-stage/manifest.js +29 -0
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +722 -0
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +269 -0
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +630 -0
- package/dist/shortcuts/recruit-stage/operations/list.js +431 -0
- package/dist/shortcuts/recruit-stage/operations/registry.js +38 -0
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +1198 -0
- package/dist/shortcuts/recruit-stage/operations/search.js +158 -0
- package/dist/shortcuts/recruit-stage/operations/types.js +25 -0
- package/dist/shortcuts/recruit-stage/school-tiers.json +318 -0
- package/dist/shortcuts/recruit-stage/shared.js +608 -0
- package/dist/shortcuts/workflow/operations/form.js +21 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +52 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/detailFieldRules.js +4 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +19 -11
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +17 -24
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +14 -9
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +78 -10
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +3 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +17 -11
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +16 -40
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +3 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +52 -15
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.pipeline.js +16 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +151 -63
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.subGroup.js +56 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +53 -16
- package/docs/e10-auth.md +22 -1
- package/docs/operation-manual.md +8 -0
- package/package.json +1 -1
- package/scripts/install-skill-to-xiaoe.mjs +105 -0
- package/scripts/mcp-meeting.mjs +234 -0
- package/scripts/package-skill.mjs +4 -2
- package/skill-template/business-info.json +24 -0
- package/skill-template/domains/recruit-stage.md +29 -0
- package/skills/weaver-e10-calendar/SKILL.md +2 -1
- package/skills/weaver-e10-calendar/references/calendar-write.md +54 -0
- package/skills/weaver-e10-cowork/SKILL.md +1 -1
- package/skills/weaver-e10-cowork/references/cowork-write.md +3 -1
- package/skills/weaver-e10-jucailin/SKILL.md +1 -1
- package/skills/weaver-e10-jucailin/references/attend-write.md +8 -0
- package/skills/weaver-e10-jucailin/references/hr-contact.md +8 -0
- package/skills/weaver-e10-jucailin/references/hr-report.md +8 -0
- package/skills/weaver-e10-jucailin/references/recruit-create.md +2 -2
- package/skills/weaver-e10-jucailin/references/recruit-read.md +1 -1
- package/skills/weaver-e10-jucailin/references/recruit-write.md +4 -3
- package/skills/weaver-e10-mail/SKILL.md +1 -1
- package/skills/weaver-e10-mail/references/mail-send.md +2 -0
- package/skills/weaver-e10-meeting/SKILL.md +119 -26
- package/skills/weaver-e10-meeting/references/meeting-minute-file.md +25 -11
- package/skills/weaver-e10-meeting.zip +0 -0
- package/skills/weaver-e10-recruit-stage/SKILL.md +226 -0
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +119 -0
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +188 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +322 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +127 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +65 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +63 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +142 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +73 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +56 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +101 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +148 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +77 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +59 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +69 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +241 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +438 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +128 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +146 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +69 -0
- package/skills/weaver-e10-shared/SKILL.md +2 -2
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
- package/skills/weaver-e10-shijingran/SKILL.md +3 -2
- package/skills/weaver-e10-shijingran/references/operations.md +3 -1
- package/skills/weaver-e10-shijingran/references/source-manifest.json +41 -40
- package/skills/weaver-e10-shijingran/references/write-operations.md +2 -0
- package/skills/weaver-e10-workflow/SKILL.md +7 -1
- package/skills/weaver-e10-workflow/aigroup/default.json +23 -9
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +37 -21
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +135 -43
- package/skills/weaver-e10-yepiaotong/SKILL.md +9 -10
- package/skills/weaver-e10-yepiaotong/references/invoice-agent-entry.md +6 -3
|
@@ -0,0 +1,2546 @@
|
|
|
1
|
+
import { createRequire as __esbuildCreateRequire } from 'node:module';
|
|
2
|
+
const require = __esbuildCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
dayOf,
|
|
5
|
+
filterUsages,
|
|
6
|
+
invalidateDayUsages,
|
|
7
|
+
loadDayUsages,
|
|
8
|
+
loadRooms,
|
|
9
|
+
recommendRooms
|
|
10
|
+
} from "./chunk-R4CHUSKC.js";
|
|
11
|
+
import {
|
|
12
|
+
cacheScopeSuffix,
|
|
13
|
+
readCache,
|
|
14
|
+
writeCache
|
|
15
|
+
} from "./chunk-GHXCDPTM.js";
|
|
16
|
+
import {
|
|
17
|
+
fetchEbAppSettings,
|
|
18
|
+
findCommonFreeSlots
|
|
19
|
+
} from "./chunk-QKNKR4RH.js";
|
|
20
|
+
import {
|
|
21
|
+
EB_BASE,
|
|
22
|
+
SCHEMA_DATETIME_MINUTE,
|
|
23
|
+
ebBusinessSuccess,
|
|
24
|
+
meetingSuccess,
|
|
25
|
+
meetingValidationError,
|
|
26
|
+
schemaOf,
|
|
27
|
+
writeBody
|
|
28
|
+
} from "./chunk-72CKAUAG.js";
|
|
29
|
+
|
|
30
|
+
// src/shortcuts/meeting/operations/eb/create-flow.ts
|
|
31
|
+
import { existsSync } from "node:fs";
|
|
32
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
33
|
+
import { homedir } from "node:os";
|
|
34
|
+
import { resolve } from "node:path";
|
|
35
|
+
|
|
36
|
+
// src/shortcuts/meeting/operations/eb/flow-memory.ts
|
|
37
|
+
var FLOW_PICK_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
38
|
+
function flowPickKey(scope) {
|
|
39
|
+
return `flow-pick-${scope}`;
|
|
40
|
+
}
|
|
41
|
+
async function readFlowPick(env) {
|
|
42
|
+
const scope = await cacheScopeSuffix(env);
|
|
43
|
+
const hit = await readCache(env, flowPickKey(scope), { ttlMs: FLOW_PICK_TTL_MS });
|
|
44
|
+
if (!hit?.data?.workflowId) return null;
|
|
45
|
+
try {
|
|
46
|
+
const session = await env.host.getSession();
|
|
47
|
+
const userId = String(session?.userId ?? "");
|
|
48
|
+
if (hit.data.userId && userId && hit.data.userId !== userId) return null;
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
return hit.data;
|
|
52
|
+
}
|
|
53
|
+
async function rememberFlowPick(env, workflowId, name) {
|
|
54
|
+
const id = String(workflowId ?? "").trim();
|
|
55
|
+
if (id === "") return;
|
|
56
|
+
let userId = "";
|
|
57
|
+
try {
|
|
58
|
+
const session = await env.host.getSession();
|
|
59
|
+
userId = String(session?.userId ?? "");
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
const scope = await cacheScopeSuffix(env);
|
|
63
|
+
await writeCache(env, flowPickKey(scope), {
|
|
64
|
+
workflowId: id,
|
|
65
|
+
...name ? { name: String(name) } : {},
|
|
66
|
+
...userId ? { userId } : {},
|
|
67
|
+
savedAt: Date.now()
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function pickRememberedFlow(launchable, remembered) {
|
|
71
|
+
if (!remembered?.workflowId) return null;
|
|
72
|
+
return launchable.find((probe) => probe.workflowId === remembered.workflowId) ?? null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/shortcuts/meeting/operations/eb/person-cache.ts
|
|
76
|
+
var PERSON_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
77
|
+
var BATCH_MAX = 100;
|
|
78
|
+
function personKey(scope) {
|
|
79
|
+
return `person-v1-${scope}`;
|
|
80
|
+
}
|
|
81
|
+
async function readAll(env) {
|
|
82
|
+
const scope = await cacheScopeSuffix(env);
|
|
83
|
+
const hit = await readCache(env, personKey(scope), { ttlMs: PERSON_TTL_MS * 30 });
|
|
84
|
+
if (!hit) return {};
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
const fresh = {};
|
|
87
|
+
for (const [id, record] of Object.entries(hit.data ?? {})) {
|
|
88
|
+
if (record && now - Number(record.savedAt || 0) <= PERSON_TTL_MS) fresh[id] = record;
|
|
89
|
+
}
|
|
90
|
+
return fresh;
|
|
91
|
+
}
|
|
92
|
+
async function writeAll(env, all) {
|
|
93
|
+
const scope = await cacheScopeSuffix(env);
|
|
94
|
+
await writeCache(env, personKey(scope), all);
|
|
95
|
+
}
|
|
96
|
+
async function resolvePersonsCached(env, ids, options = {}) {
|
|
97
|
+
const wanted = [...new Set(ids.map((id) => String(id ?? "").trim()).filter((id) => id !== ""))];
|
|
98
|
+
const persons = /* @__PURE__ */ new Map();
|
|
99
|
+
if (wanted.length === 0) return { persons, requests: 0, fromCache: 0 };
|
|
100
|
+
const all = options.refresh === true ? {} : await readAll(env);
|
|
101
|
+
const missing = [];
|
|
102
|
+
let fromCache = 0;
|
|
103
|
+
for (const id of wanted) {
|
|
104
|
+
const hit = all[id];
|
|
105
|
+
if (hit) {
|
|
106
|
+
persons.set(id, hit);
|
|
107
|
+
fromCache += 1;
|
|
108
|
+
} else missing.push(id);
|
|
109
|
+
}
|
|
110
|
+
if (missing.length === 0) return { persons, requests: 0, fromCache };
|
|
111
|
+
let requests = 0;
|
|
112
|
+
for (let index = 0; index < missing.length; index += BATCH_MAX) {
|
|
113
|
+
const chunk = missing.slice(index, index + BATCH_MAX);
|
|
114
|
+
try {
|
|
115
|
+
const { hrmEmployeeOperations } = await import("./employee-SAK2QYXX.js");
|
|
116
|
+
const batch = hrmEmployeeOperations.find((operation) => operation.name === "hrm.employee.batch");
|
|
117
|
+
if (!batch) break;
|
|
118
|
+
const result = await batch.handler({ ids: chunk }, env);
|
|
119
|
+
requests += 1;
|
|
120
|
+
const rows = result?.data?.rows ?? result?.data?.userList ?? [];
|
|
121
|
+
for (const row of rows) {
|
|
122
|
+
const id = String(row?.id ?? "").trim();
|
|
123
|
+
if (!id) continue;
|
|
124
|
+
const record = {
|
|
125
|
+
id,
|
|
126
|
+
name: String(row?.name ?? "").trim(),
|
|
127
|
+
...row?.department ? { department: String(row.department) } : {},
|
|
128
|
+
...row?.departmentId ? { departmentId: String(row.departmentId) } : {},
|
|
129
|
+
...row?.subCompany ? { subCompany: String(row.subCompany) } : {},
|
|
130
|
+
...row?.position ? { position: String(row.position) } : {},
|
|
131
|
+
...row?.mobile ? { mobile: String(row.mobile) } : {},
|
|
132
|
+
...row?.jobNum ? { jobNum: String(row.jobNum) } : {},
|
|
133
|
+
...row?.imCid ? { imCid: String(row.imCid) } : {},
|
|
134
|
+
savedAt: Date.now()
|
|
135
|
+
};
|
|
136
|
+
persons.set(id, record);
|
|
137
|
+
all[id] = record;
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (requests > 0) await writeAll(env, all);
|
|
143
|
+
return { persons, requests, fromCache };
|
|
144
|
+
}
|
|
145
|
+
async function resolveNamesCached(env, ids) {
|
|
146
|
+
const { persons } = await resolvePersonsCached(env, ids);
|
|
147
|
+
const map = /* @__PURE__ */ new Map();
|
|
148
|
+
for (const [id, person] of persons) {
|
|
149
|
+
if (person.name) map.set(id, person.name);
|
|
150
|
+
}
|
|
151
|
+
return map;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/shortcuts/meeting/operations/eb/create-flow.ts
|
|
155
|
+
var FIELD_ALIASES = {
|
|
156
|
+
mt_name: ["\u4F1A\u8BAE\u540D\u79F0", "\u4F1A\u8BAE\u4E3B\u9898", "\u4E3B\u9898"],
|
|
157
|
+
begin_datetime: ["\u5F00\u59CB\u65F6\u95F4", "\u4F1A\u8BAE\u5F00\u59CB\u65F6\u95F4"],
|
|
158
|
+
end_datetime: ["\u7ED3\u675F\u65F6\u95F4", "\u4F1A\u8BAE\u7ED3\u675F\u65F6\u95F4"],
|
|
159
|
+
mt_desc: ["\u4F1A\u8BAE\u5185\u5BB9", "\u4F1A\u8BAE\u8BF4\u660E", "\u4F1A\u8BAE\u63CF\u8FF0"],
|
|
160
|
+
address: ["\u4F1A\u8BAE\u5730\u70B9", "\u4F1A\u8BAE\u5BA4"],
|
|
161
|
+
customize_address: ["\u81EA\u5B9A\u4E49\u4F1A\u8BAE\u5730\u70B9", "\u81EA\u5B9A\u4E49\u5730\u70B9"],
|
|
162
|
+
hrm_members: ["\u53C2\u4F1A\u4EBA\u5458", "\u53C2\u4F1A\u4EBA"],
|
|
163
|
+
total_member: ["\u53C2\u4F1A\u4EBA\u6570", "\u4EBA\u6570"],
|
|
164
|
+
/** 参会客户(CustomerComponent 客户浏览按钮):值是客户 id 列表,不是客户名称文本。 */
|
|
165
|
+
crm_members: ["\u53C2\u4F1A\u5BA2\u6237", "\u5BA2\u6237"],
|
|
166
|
+
crm_member_count: ["\u5E94\u5230\u5BA2\u6237\u6570", "\u5BA2\u6237\u6570"],
|
|
167
|
+
caller: ["\u53EC\u96C6\u4EBA", "\u53D1\u8D77\u4EBA"],
|
|
168
|
+
contacter: ["\u8054\u7CFB\u4EBA"],
|
|
169
|
+
mt_type: ["\u4F1A\u8BAE\u7C7B\u578B"],
|
|
170
|
+
other_remark: ["\u5907\u6CE8", "\u5176\u4ED6\u8BF4\u660E"]
|
|
171
|
+
};
|
|
172
|
+
var PERSON_FIELD_LABELS = { caller: "\u53EC\u96C6\u4EBA", contacter: "\u8054\u7CFB\u4EBA" };
|
|
173
|
+
function workflowEnv(env) {
|
|
174
|
+
return env;
|
|
175
|
+
}
|
|
176
|
+
async function loadCreateForm(env, workflowId) {
|
|
177
|
+
const { createWorkflowHost } = await import("./host-X2CSLFM6.js");
|
|
178
|
+
const { createWorkflowContinuationSigner } = await import("./continuation-HZIZRZBX.js");
|
|
179
|
+
const { getWorkflowOperation } = await import("./registry-RHMW6ANW.js");
|
|
180
|
+
const wfEnv = {
|
|
181
|
+
...workflowEnv(env),
|
|
182
|
+
host: createWorkflowHost(env.ctx),
|
|
183
|
+
continuation: createWorkflowContinuationSigner(env.ctx)
|
|
184
|
+
};
|
|
185
|
+
const operation = getWorkflowOperation("workflow.createForm");
|
|
186
|
+
const result = await operation.handler({ workflow: [workflowId] }, wfEnv);
|
|
187
|
+
const data = result?.data ?? {};
|
|
188
|
+
if (data.status !== "FORM_READY") {
|
|
189
|
+
throw meetingValidationError(
|
|
190
|
+
"flow_form_unavailable",
|
|
191
|
+
`\u5EFA\u4F1A\u6D41\u7A0B\u8868\u5355\u8F7D\u5165\u5931\u8D25\uFF08status=${String(data.status)}\uFF09\uFF1A${String(data.clarificationQuestion ?? data.note ?? "").slice(0, 200)}`,
|
|
192
|
+
{ workflowId }
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
const wf = data.workflow ?? {};
|
|
196
|
+
return {
|
|
197
|
+
fields: data.fields ?? [],
|
|
198
|
+
continuation: data.continuation,
|
|
199
|
+
requestName: data.requestName,
|
|
200
|
+
contextId: data.contextId,
|
|
201
|
+
workflowName: String(wf.name ?? wf.workflowName ?? "").trim() || void 0
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
async function resolveEmployeeNames(env, ids) {
|
|
205
|
+
const unique = [...new Set(ids.map((id) => String(id).trim()).filter((id) => id !== ""))];
|
|
206
|
+
if (unique.length === 0) return /* @__PURE__ */ new Map();
|
|
207
|
+
return resolveNamesCached(env, unique);
|
|
208
|
+
}
|
|
209
|
+
async function resolvePersonTokens(env, tokens) {
|
|
210
|
+
const map = /* @__PURE__ */ new Map();
|
|
211
|
+
const unique = [...new Set(tokens.map((token) => String(token).trim()).filter((token) => token !== ""))];
|
|
212
|
+
if (unique.length === 0) return map;
|
|
213
|
+
const idLike = unique.filter((token) => /^\d{8,}$/.test(token));
|
|
214
|
+
const nameLike = unique.filter((token) => !/^\d{8,}$/.test(token));
|
|
215
|
+
if (idLike.length > 0) {
|
|
216
|
+
const names = await resolveEmployeeNames(env, idLike);
|
|
217
|
+
for (const id of idLike) map.set(id, { id, name: names.get(id) ?? id });
|
|
218
|
+
}
|
|
219
|
+
if (nameLike.length > 0) {
|
|
220
|
+
try {
|
|
221
|
+
const { hrmEmployeeOperations } = await import("./employee-SAK2QYXX.js");
|
|
222
|
+
const query = hrmEmployeeOperations.find((operation) => operation.name === "hrm.employee.query");
|
|
223
|
+
for (const name of nameLike) {
|
|
224
|
+
if (!query) break;
|
|
225
|
+
const found = await query.handler({ keyword: name, pageSize: 10 }, env).catch(() => null);
|
|
226
|
+
const rows = found?.data?.rows ?? [];
|
|
227
|
+
const exact = rows.find((row) => String(row.name ?? "").trim() === name);
|
|
228
|
+
const hit = exact ?? (rows.length === 1 ? rows[0] : void 0);
|
|
229
|
+
const id = String(hit?.id ?? "").trim();
|
|
230
|
+
if (id === "") continue;
|
|
231
|
+
map.set(name, { id, name: String(hit?.name ?? name) });
|
|
232
|
+
}
|
|
233
|
+
} catch {
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return map;
|
|
237
|
+
}
|
|
238
|
+
async function resolveSelfPerson(env) {
|
|
239
|
+
let session = null;
|
|
240
|
+
try {
|
|
241
|
+
session = await env.host?.getSession?.();
|
|
242
|
+
} catch {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
const id = String(session?.userId ?? "").trim();
|
|
246
|
+
if (id === "" || id === "unknown") return null;
|
|
247
|
+
const names = await resolveEmployeeNames(env, [id]);
|
|
248
|
+
const name = String(names.get(id) ?? "").trim();
|
|
249
|
+
if (name === "") return null;
|
|
250
|
+
return { id, name };
|
|
251
|
+
}
|
|
252
|
+
function applySelfPersonDefaults(args, self) {
|
|
253
|
+
const filled = [];
|
|
254
|
+
const missing = ["caller", "contacter"].filter((field) => String(args[field] ?? "").trim() === "");
|
|
255
|
+
if (missing.length === 0) return { filled, warning: "" };
|
|
256
|
+
if (!self) {
|
|
257
|
+
return {
|
|
258
|
+
filled,
|
|
259
|
+
warning: missing.length === 2 ? "\u26A0\uFE0F \u6CA1\u80FD\u786E\u8BA4\u5F53\u524D\u767B\u5F55\u7528\u6237\u5BF9\u5E94\u7684\u5458\u5DE5 \u2014\u2014\u300C\u53EC\u96C6\u4EBA\u300D\u300C\u8054\u7CFB\u4EBA\u300D\u4F1A\u7559\u7A7A\uFF0C\u8BF7\u663E\u5F0F\u4F20 caller / contacter\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002" : ""
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
for (const field of missing) {
|
|
263
|
+
args[field] = self.id;
|
|
264
|
+
filled.push({ field, id: self.id, name: self.name });
|
|
265
|
+
}
|
|
266
|
+
return { filled, warning: "" };
|
|
267
|
+
}
|
|
268
|
+
function parseRoomRef(input) {
|
|
269
|
+
const text = String(input ?? "").trim();
|
|
270
|
+
if (!text) return {};
|
|
271
|
+
const withId = /^(.*?)[((]\s*(\d{4,})\s*[))]$/.exec(text);
|
|
272
|
+
if (withId) {
|
|
273
|
+
const name = withId[1].trim();
|
|
274
|
+
const id = withId[2];
|
|
275
|
+
return name ? { id, name } : { id };
|
|
276
|
+
}
|
|
277
|
+
if (/^\d+$/.test(text)) return { id: text };
|
|
278
|
+
return { name: text };
|
|
279
|
+
}
|
|
280
|
+
async function resolveAddressRoom(env, input) {
|
|
281
|
+
const text = String(input ?? "").trim();
|
|
282
|
+
if (!text) return null;
|
|
283
|
+
const ref = parseRoomRef(text);
|
|
284
|
+
const { loadRooms: loadRooms2 } = await import("./room-recommend-62H7ZQQ6.js");
|
|
285
|
+
let rooms = [];
|
|
286
|
+
try {
|
|
287
|
+
rooms = (await loadRooms2(env, {})).rooms;
|
|
288
|
+
} catch {
|
|
289
|
+
return { id: ref.id ?? "", name: ref.name ?? text, status: "unknown", lookupFailed: true };
|
|
290
|
+
}
|
|
291
|
+
const hit = (ref.id ? rooms.find((room) => room.id === ref.id) : void 0) ?? (ref.name ? rooms.find((room) => room.name === ref.name) : void 0);
|
|
292
|
+
if (hit) return { id: hit.id, name: hit.name, status: hit.status, statusText: hit.statusText };
|
|
293
|
+
if (ref.id) return { id: ref.id, name: ref.name ?? "", status: "unknown" };
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
async function resolveRoomValue(env, input) {
|
|
297
|
+
const text = String(input ?? "").trim();
|
|
298
|
+
if (!text) return null;
|
|
299
|
+
const resolved = await resolveAddressRoom(env, text).catch(() => null);
|
|
300
|
+
if (resolved?.id && !resolved.lookupFailed) {
|
|
301
|
+
return { id: resolved.id, name: resolved.name || resolved.id };
|
|
302
|
+
}
|
|
303
|
+
const ref = parseRoomRef(text);
|
|
304
|
+
if (ref.id) {
|
|
305
|
+
try {
|
|
306
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
307
|
+
const detail = await getMeetingOperation("meeting.eb.room.detail").handler({ id: ref.id }, env);
|
|
308
|
+
const main = detail?.data?.mainTable ?? detail?.data?.data?.mainTable ?? {};
|
|
309
|
+
const name = String(main.room_name ?? "").trim() || ref.name || "";
|
|
310
|
+
if (name) return { id: ref.id, name };
|
|
311
|
+
} catch {
|
|
312
|
+
}
|
|
313
|
+
return { id: ref.id, name: ref.name || ref.id };
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
async function shapeBrowserValues(env, values) {
|
|
318
|
+
const notes = [];
|
|
319
|
+
const shaped = { ...values };
|
|
320
|
+
const readable = {};
|
|
321
|
+
if (shaped.address !== void 0 && shaped.address !== "") {
|
|
322
|
+
const room = await resolveRoomValue(env, String(shaped.address));
|
|
323
|
+
if (room) {
|
|
324
|
+
shaped.address = room;
|
|
325
|
+
readable.address = room.name;
|
|
326
|
+
notes.push(`\u4F1A\u8BAE\u5730\u70B9\u6309\u6D4F\u89C8\u6309\u94AE\u683C\u5F0F\u63D0\u4EA4\uFF1A${room.name}(${room.id})`);
|
|
327
|
+
} else {
|
|
328
|
+
readable.address = String(shaped.address);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const personFields = ["hrm_members", "caller", "contacter"];
|
|
332
|
+
const idPool = [];
|
|
333
|
+
for (const key of personFields) {
|
|
334
|
+
const raw = shaped[key];
|
|
335
|
+
if (raw === void 0 || raw === "") continue;
|
|
336
|
+
const ids = String(raw).split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
|
|
337
|
+
idPool.push(...ids);
|
|
338
|
+
}
|
|
339
|
+
if (idPool.length > 0) {
|
|
340
|
+
const people = await resolvePersonTokens(env, idPool);
|
|
341
|
+
const toObject = (token) => people.get(token) ?? { id: token, name: token };
|
|
342
|
+
const toName = (token) => people.get(token)?.name ?? token;
|
|
343
|
+
if (shaped.hrm_members !== void 0 && shaped.hrm_members !== "") {
|
|
344
|
+
const ids = String(shaped.hrm_members).split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
|
|
345
|
+
shaped.hrm_members = ids.map(toObject);
|
|
346
|
+
readable.hrm_members = ids.map(toName).join("\u3001");
|
|
347
|
+
notes.push(`\u53C2\u4F1A\u4EBA\u5458\u6309\u6D4F\u89C8\u6309\u94AE\u683C\u5F0F\u63D0\u4EA4\uFF1A${ids.length} \u4EBA`);
|
|
348
|
+
}
|
|
349
|
+
if (shaped.caller !== void 0 && shaped.caller !== "") {
|
|
350
|
+
const id = String(shaped.caller).trim();
|
|
351
|
+
shaped.caller = toObject(id);
|
|
352
|
+
readable.caller = toName(id);
|
|
353
|
+
}
|
|
354
|
+
if (shaped.contacter !== void 0 && shaped.contacter !== "") {
|
|
355
|
+
const id = String(shaped.contacter).trim();
|
|
356
|
+
shaped.contacter = toObject(id);
|
|
357
|
+
readable.contacter = toName(id);
|
|
358
|
+
}
|
|
359
|
+
const unresolved = [...new Set(idPool)].filter((token) => !people.has(token));
|
|
360
|
+
if (unresolved.length > 0) {
|
|
361
|
+
notes.push(
|
|
362
|
+
`\u26A0\uFE0F \u6709 ${unresolved.length} \u4E2A\u4EBA\u5458\u6CA1\u89E3\u6790\u5230\u5458\u5DE5\uFF1A${unresolved.join("\u3001")} \u2014\u2014 \u8868\u5355\u91CC\u7684\u300C\u53C2\u4F1A\u4EBA\u5458/\u53EC\u96C6\u4EBA/\u8054\u7CFB\u4EBA\u300D\u53EF\u80FD\u663E\u793A\u4E0D\u51FA\u6765\u3002\u8BF7\u6539\u4F20\u5458\u5DE5 id\uFF0C\u6216\u786E\u8BA4\u59D3\u540D\u4E0E\u82B1\u540D\u518C\u5B8C\u5168\u4E00\u81F4\u3002`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (shaped.crm_members !== void 0 && shaped.crm_members !== "") {
|
|
367
|
+
const rows = [];
|
|
368
|
+
const push = (idRaw, nameRaw) => {
|
|
369
|
+
const id = String(idRaw ?? "").trim();
|
|
370
|
+
const name = String(nameRaw ?? "").trim();
|
|
371
|
+
if (id === "" && name === "") return;
|
|
372
|
+
rows.push({ id, name });
|
|
373
|
+
};
|
|
374
|
+
const pushToken = (tokenRaw) => {
|
|
375
|
+
const token = String(tokenRaw ?? "").trim();
|
|
376
|
+
if (token === "") return;
|
|
377
|
+
const matched = token.match(/^(.*?)[((]\s*([0-9A-Za-z_-]+)\s*[))]$/);
|
|
378
|
+
if (matched) {
|
|
379
|
+
push(matched[2], matched[1]);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (/^\d{8,}$/.test(token)) {
|
|
383
|
+
push(token, "");
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
push("", token);
|
|
387
|
+
};
|
|
388
|
+
const raw = shaped.crm_members;
|
|
389
|
+
if (Array.isArray(raw)) {
|
|
390
|
+
for (const item of raw) {
|
|
391
|
+
if (item && typeof item === "object") {
|
|
392
|
+
const obj = item;
|
|
393
|
+
push(obj.id ?? obj.sjID ?? obj.customerId, obj.name ?? obj.mc);
|
|
394
|
+
} else {
|
|
395
|
+
for (const token of String(item).split(/[,;,;]+/).map((one) => one.trim()).filter((one) => one !== "")) {
|
|
396
|
+
pushToken(token);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} else if (typeof raw === "object") {
|
|
401
|
+
const obj = raw;
|
|
402
|
+
push(obj.id ?? obj.sjID ?? obj.customerId, obj.name ?? obj.mc);
|
|
403
|
+
} else {
|
|
404
|
+
for (const token of String(raw).split(/[,;,;]+/).map((item) => item.trim()).filter((item) => item !== "")) {
|
|
405
|
+
pushToken(token);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (rows.length > 0) {
|
|
409
|
+
const nameOnly = rows.filter((row) => row.id === "" && row.name !== "");
|
|
410
|
+
if (nameOnly.length > 0) {
|
|
411
|
+
try {
|
|
412
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
413
|
+
const search = getMeetingOperation("meeting.eb.crm.search");
|
|
414
|
+
for (const row of nameOnly) {
|
|
415
|
+
const found = await search.handler({ keyword: row.name, limit: 5 }, env).catch(() => null);
|
|
416
|
+
const items = found?.data?.items ?? [];
|
|
417
|
+
const hit = items.find((item) => String(item?.name ?? "").trim() === row.name) ?? items[0];
|
|
418
|
+
const id = String(hit?.customerId ?? "").trim();
|
|
419
|
+
if (id === "") continue;
|
|
420
|
+
row.id = id;
|
|
421
|
+
const fullName = String(hit?.name ?? "").trim();
|
|
422
|
+
if (fullName !== "") row.name = fullName;
|
|
423
|
+
}
|
|
424
|
+
} catch {
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const unresolved = rows.filter((row) => row.id === "");
|
|
428
|
+
if (unresolved.length > 0) {
|
|
429
|
+
throw meetingValidationError(
|
|
430
|
+
"crm_not_found",
|
|
431
|
+
`\u53C2\u4F1A\u5BA2\u6237\u6709 ${unresolved.length} \u4E2A\u5728 CRM \u91CC\u67E5\u4E0D\u5230\uFF1A${unresolved.map((row) => row.name).join("\u3001")}\u3002\u8BF7\u786E\u8BA4\u5BA2\u6237\u540D\u79F0\uFF0C\u6216\u5148\u5230\u5BA2\u6237\u8868\u5EFA\u6863\uFF1B\u4E5F\u53EF\u4EE5\u6539\u7528\u300C\u5BA2\u6237\u540D(\u5BA2\u6237id)\u300D\u6216 \`[{id,name}]\` \u4F20 crm_members\u3002`
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
shaped.crm_members = rows;
|
|
435
|
+
readable.crm_members = rows.map((row) => row.name || row.id).join("\u3001");
|
|
436
|
+
notes.push(`\u53C2\u4F1A\u5BA2\u6237\u6309\u5BA2\u6237\u6D4F\u89C8\u6309\u94AE\u683C\u5F0F\u63D0\u4EA4\uFF1A${rows.length} \u4E2A\u5BA2\u6237`);
|
|
437
|
+
const missingNames = rows.filter((row) => row.name === "");
|
|
438
|
+
if (missingNames.length > 0) {
|
|
439
|
+
throw meetingValidationError(
|
|
440
|
+
"crm_name_required",
|
|
441
|
+
`\u53C2\u4F1A\u5BA2\u6237\u6709 ${missingNames.length} \u4E2A\u53EA\u7ED9\u4E86 id\u3001\u6CA1\u6709\u5BA2\u6237\u540D\u79F0\uFF1A${missingNames.map((row) => row.id).join("\u3001")}\u3002\u5BA2\u6237\u6D4F\u89C8\u6309\u94AE\u5FC5\u987B\u5E26\u540D\u79F0\u624D\u80FD\u5199\u5165\uFF08\u53EA\u7ED9 id \u4F1A\u88AB\u670D\u52A1\u7AEF\u9759\u9ED8\u5B58\u6210\u7A7A\u503C\uFF09\u3002\u8BF7\u5148\u7528 \`meeting.eb.crm.search\` \u6309\u5BA2\u6237\u540D\u67E5\u5230 \`{ customerId, name }\`\uFF0C\u518D\u4EE5 \`[{id,name}]\` \u6216\u300C\u5BA2\u6237\u540D(\u5BA2\u6237id)\u300D\u7684\u5F62\u5F0F\u4F20 \`crm_members\`\u3002`
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
delete shaped.crm_members;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
for (const [key, raw] of Object.entries(values)) {
|
|
449
|
+
if (readable[key] !== void 0) continue;
|
|
450
|
+
if (raw === void 0 || raw === null || raw === "") continue;
|
|
451
|
+
if (typeof raw === "object") continue;
|
|
452
|
+
readable[key] = String(raw);
|
|
453
|
+
}
|
|
454
|
+
return { values: shaped, notes, readable };
|
|
455
|
+
}
|
|
456
|
+
function normalizeFieldName(name) {
|
|
457
|
+
return String(name ?? "").replace(/[((][^(())]*[))]/g, "").replace(/[\s\u3000]+/g, "").trim();
|
|
458
|
+
}
|
|
459
|
+
var CRM_DETAIL_COLUMNS = {
|
|
460
|
+
xm: ["\u59D3\u540D", "\u5BA2\u6237\u59D3\u540D", "\u53C2\u4F1A\u4EBA", "\u53C2\u4F1A\u4EBA\u59D3\u540D"],
|
|
461
|
+
xb: ["\u6027\u522B"],
|
|
462
|
+
zw: ["\u804C\u4F4D", "\u804C\u52A1"],
|
|
463
|
+
sjhm: ["\u624B\u673A\u53F7\u7801", "\u624B\u673A\u53F7", "\u624B\u673A", "\u7535\u8BDD", "\u8054\u7CFB\u7535\u8BDD"],
|
|
464
|
+
bz: ["\u5907\u6CE8", "\u8BF4\u660E"]
|
|
465
|
+
};
|
|
466
|
+
function resolveCrmDetailTarget(fields) {
|
|
467
|
+
const groups = /* @__PURE__ */ new Map();
|
|
468
|
+
for (const field of fields) {
|
|
469
|
+
const sid = String(field.subFormId ?? "").trim();
|
|
470
|
+
if (!sid) continue;
|
|
471
|
+
const list = groups.get(sid);
|
|
472
|
+
if (list) list.push(field);
|
|
473
|
+
else groups.set(sid, [field]);
|
|
474
|
+
}
|
|
475
|
+
let best = null;
|
|
476
|
+
for (const [subFormId, list] of groups) {
|
|
477
|
+
const columns = {};
|
|
478
|
+
const labels = {};
|
|
479
|
+
for (const [semantic, aliases] of Object.entries(CRM_DETAIL_COLUMNS)) {
|
|
480
|
+
const hit = list.find((field) => aliases.includes(normalizeFieldName(field.name)));
|
|
481
|
+
if (!hit) continue;
|
|
482
|
+
columns[semantic] = hit.id;
|
|
483
|
+
labels[semantic] = hit.name;
|
|
484
|
+
}
|
|
485
|
+
if (!columns.xm) continue;
|
|
486
|
+
const score = Object.keys(columns).length + (columns.sjhm ? 1 : 0) + (columns.zw ? 1 : 0);
|
|
487
|
+
if (!best || score > best.score) best = { subFormId, columns, labels, score };
|
|
488
|
+
}
|
|
489
|
+
return best ? { subFormId: best.subFormId, columns: best.columns, labels: best.labels } : null;
|
|
490
|
+
}
|
|
491
|
+
function detectCrmMentionInText(...texts) {
|
|
492
|
+
for (const text of texts) {
|
|
493
|
+
if (typeof text !== "string") continue;
|
|
494
|
+
const value = text.trim();
|
|
495
|
+
if (value === "") continue;
|
|
496
|
+
const hit = /(?:参会|拜访|来访)?客户\s*(?:名称)?\s*(?:是|为|[::])\s*([^\s,,。;;、))]{2,40})/.exec(value);
|
|
497
|
+
if (hit?.[1]) return hit[1].trim();
|
|
498
|
+
}
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
function normalizeCrmDetailRows(raw) {
|
|
502
|
+
if (raw === void 0 || raw === null || raw === "") return [];
|
|
503
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
504
|
+
const keyAlias = {
|
|
505
|
+
xm: "xm",
|
|
506
|
+
name: "xm",
|
|
507
|
+
customername: "xm",
|
|
508
|
+
\u59D3\u540D: "xm",
|
|
509
|
+
\u5BA2\u6237\u59D3\u540D: "xm",
|
|
510
|
+
xb: "xb",
|
|
511
|
+
gender: "xb",
|
|
512
|
+
sex: "xb",
|
|
513
|
+
\u6027\u522B: "xb",
|
|
514
|
+
zw: "zw",
|
|
515
|
+
title: "zw",
|
|
516
|
+
position: "zw",
|
|
517
|
+
job: "zw",
|
|
518
|
+
\u804C\u4F4D: "zw",
|
|
519
|
+
\u804C\u52A1: "zw",
|
|
520
|
+
sjhm: "sjhm",
|
|
521
|
+
mobile: "sjhm",
|
|
522
|
+
phone: "sjhm",
|
|
523
|
+
tel: "sjhm",
|
|
524
|
+
\u624B\u673A\u53F7\u7801: "sjhm",
|
|
525
|
+
\u624B\u673A\u53F7: "sjhm",
|
|
526
|
+
\u7535\u8BDD: "sjhm",
|
|
527
|
+
\u8054\u7CFB\u7535\u8BDD: "sjhm",
|
|
528
|
+
bz: "bz",
|
|
529
|
+
remark: "bz",
|
|
530
|
+
note: "bz",
|
|
531
|
+
\u5907\u6CE8: "bz",
|
|
532
|
+
\u8BF4\u660E: "bz"
|
|
533
|
+
};
|
|
534
|
+
const rows = [];
|
|
535
|
+
for (const item of list) {
|
|
536
|
+
if (item === void 0 || item === null || typeof item !== "object") continue;
|
|
537
|
+
const row = {};
|
|
538
|
+
for (const [key, value] of Object.entries(item)) {
|
|
539
|
+
const semantic = keyAlias[String(key).trim().toLowerCase()] ?? keyAlias[String(key).trim()];
|
|
540
|
+
if (!semantic) continue;
|
|
541
|
+
if (value === void 0 || value === null) continue;
|
|
542
|
+
const text = String(value).trim();
|
|
543
|
+
if (text === "") continue;
|
|
544
|
+
row[semantic] = text;
|
|
545
|
+
}
|
|
546
|
+
if (!row.xm && !row.sjhm) continue;
|
|
547
|
+
rows.push(row);
|
|
548
|
+
}
|
|
549
|
+
return rows;
|
|
550
|
+
}
|
|
551
|
+
function crmMemberEntriesFromArgs(raw) {
|
|
552
|
+
const list = Array.isArray(raw) ? raw : raw === void 0 || raw === null || raw === "" ? [] : [raw];
|
|
553
|
+
const out = [];
|
|
554
|
+
const push = (idRaw, nameRaw, contactsRaw) => {
|
|
555
|
+
const id = String(idRaw ?? "").trim();
|
|
556
|
+
const name = String(nameRaw ?? "").trim();
|
|
557
|
+
if (id === "" && name === "") return;
|
|
558
|
+
const contacts = (Array.isArray(contactsRaw) ? contactsRaw : []).map((item) => {
|
|
559
|
+
const row = item ?? {};
|
|
560
|
+
return {
|
|
561
|
+
name: String(row.name ?? row.xm ?? "").trim(),
|
|
562
|
+
mobile: String(row.mobile ?? row.sjhm ?? row.phone ?? "").trim(),
|
|
563
|
+
...String(row.dept ?? row.bm ?? "").trim() === "" ? {} : { dept: String(row.dept ?? row.bm).trim() }
|
|
564
|
+
};
|
|
565
|
+
}).filter((one) => one.name !== "" || one.mobile !== "");
|
|
566
|
+
out.push({ id: id === "" ? name : id, name, contacts });
|
|
567
|
+
};
|
|
568
|
+
for (const item of list) {
|
|
569
|
+
if (item && typeof item === "object") {
|
|
570
|
+
const obj = item;
|
|
571
|
+
push(obj.customerId ?? obj.sjID ?? obj.id, obj.name ?? obj.mc, obj.contacts ?? obj.lxr);
|
|
572
|
+
} else {
|
|
573
|
+
const token = String(item).trim();
|
|
574
|
+
if (token === "") continue;
|
|
575
|
+
const matched = token.match(/^(.*?)[((]\s*([0-9A-Za-z_-]+)\s*[))]$/);
|
|
576
|
+
if (matched) push(matched[2], matched[1], void 0);
|
|
577
|
+
else push(token, "", void 0);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return out;
|
|
581
|
+
}
|
|
582
|
+
function crmContactsToDetailRows(entries) {
|
|
583
|
+
const rows = [];
|
|
584
|
+
const seen = /* @__PURE__ */ new Set();
|
|
585
|
+
for (const entry of entries) {
|
|
586
|
+
for (const contact of entry.contacts) {
|
|
587
|
+
const xm = contact.name.trim();
|
|
588
|
+
const sjhm = contact.mobile.trim();
|
|
589
|
+
if (xm === "" && sjhm === "") continue;
|
|
590
|
+
const key = `${xm}|${sjhm}`;
|
|
591
|
+
if (seen.has(key)) continue;
|
|
592
|
+
seen.add(key);
|
|
593
|
+
const row = { xm: xm === "" ? sjhm : xm };
|
|
594
|
+
if (sjhm !== "") row.sjhm = sjhm;
|
|
595
|
+
if (contact.dept && contact.dept.trim() !== "") row.bz = `\u90E8\u95E8\uFF1A${contact.dept.trim()}`;
|
|
596
|
+
rows.push(row);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return rows;
|
|
600
|
+
}
|
|
601
|
+
async function resolveAutoCrmDetailRows(env, raw) {
|
|
602
|
+
const entries = crmMemberEntriesFromArgs(raw);
|
|
603
|
+
const missing = [];
|
|
604
|
+
if (entries.length > 0) {
|
|
605
|
+
try {
|
|
606
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
607
|
+
const search = getMeetingOperation("meeting.eb.crm.search");
|
|
608
|
+
for (const entry of entries) {
|
|
609
|
+
if (entry.contacts.length > 0) continue;
|
|
610
|
+
const keyword = (entry.name || entry.id).trim();
|
|
611
|
+
if (keyword === "") {
|
|
612
|
+
missing.push(entry.id);
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
const shortBase = keyword.split("--")[0].trim();
|
|
616
|
+
const stripped = shortBase.replace(/[((][^))]*[))]/gu, "").replace(/(股份有限公司|有限责任公司|集团有限公司|有限公司|集团|公司)$/u, "").trim();
|
|
617
|
+
const candidates = [...new Set([keyword, shortBase, stripped, shortBase.slice(0, 4)].filter((one) => one !== ""))];
|
|
618
|
+
let live = [];
|
|
619
|
+
for (const candidate of candidates) {
|
|
620
|
+
const found = await search.handler({ keyword: candidate, limit: 50 }, env).catch(() => null);
|
|
621
|
+
const items = found?.data?.items ?? [];
|
|
622
|
+
const hit = entry.id !== "" ? items.find((item) => String(item?.customerId ?? "") === entry.id) : void 0;
|
|
623
|
+
const contacts = hit?.contacts ?? [];
|
|
624
|
+
if (contacts.length > live.length) live = contacts;
|
|
625
|
+
}
|
|
626
|
+
if (live.length === 0) {
|
|
627
|
+
missing.push(entry.name || entry.id);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
entry.contacts = live;
|
|
631
|
+
}
|
|
632
|
+
} catch {
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return {
|
|
636
|
+
rows: crmContactsToDetailRows(entries),
|
|
637
|
+
customers: entries.map((entry) => entry.name || entry.id).filter((one) => one !== ""),
|
|
638
|
+
missing
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function mapFields(fields, values, preferred = {}) {
|
|
642
|
+
const byName = new Map(fields.map((field) => [field.name.trim(), field]));
|
|
643
|
+
const byId = new Map(fields.map((field) => [field.id, field]));
|
|
644
|
+
const byNormalized = /* @__PURE__ */ new Map();
|
|
645
|
+
for (const field of fields) {
|
|
646
|
+
const key = normalizeFieldName(field.name);
|
|
647
|
+
if (key && !byNormalized.has(key)) byNormalized.set(key, field);
|
|
648
|
+
}
|
|
649
|
+
const main = {};
|
|
650
|
+
const mapped = {};
|
|
651
|
+
const unmapped = [];
|
|
652
|
+
const resolved = {};
|
|
653
|
+
const findField = (aliases) => {
|
|
654
|
+
for (const name of aliases) {
|
|
655
|
+
const field = byName.get(name);
|
|
656
|
+
if (field) return field;
|
|
657
|
+
}
|
|
658
|
+
for (const name of aliases) {
|
|
659
|
+
const field = byNormalized.get(normalizeFieldName(name));
|
|
660
|
+
if (field) return field;
|
|
661
|
+
}
|
|
662
|
+
for (const name of aliases) {
|
|
663
|
+
const needle = normalizeFieldName(name);
|
|
664
|
+
if (needle.length < 2) continue;
|
|
665
|
+
for (const [key, field] of byNormalized) {
|
|
666
|
+
if (key.includes(needle)) return field;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
return void 0;
|
|
670
|
+
};
|
|
671
|
+
for (const [key, raw] of Object.entries(values)) {
|
|
672
|
+
if (raw === void 0 || raw === null || raw === "") continue;
|
|
673
|
+
const aliases = FIELD_ALIASES[key] ?? [key];
|
|
674
|
+
const prefId = preferred[key];
|
|
675
|
+
const hit = (prefId ? byId.get(prefId) : void 0) ?? findField(aliases);
|
|
676
|
+
if (!hit) {
|
|
677
|
+
unmapped.push(key);
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
main[hit.id] = raw;
|
|
681
|
+
mapped[key] = `${hit.name}(${hit.id})`;
|
|
682
|
+
resolved[key] = hit.id;
|
|
683
|
+
}
|
|
684
|
+
return { main, mapped, unmapped, resolved };
|
|
685
|
+
}
|
|
686
|
+
var PREVIEW_PERSON_FIELD_RE = /^(召集人|联系人|参会人员|会议创建人|主讲人|负责人|费用承担人)$/;
|
|
687
|
+
async function decoratePreviewPersonNames(env, main, fields, known = /* @__PURE__ */ new Map()) {
|
|
688
|
+
const targets = fields.filter((field) => PREVIEW_PERSON_FIELD_RE.test(String(field?.name ?? "").trim()));
|
|
689
|
+
if (targets.length === 0) return main;
|
|
690
|
+
const ID_ONLY_RE = /^\d{8,}$/;
|
|
691
|
+
const missingNameId = (value) => {
|
|
692
|
+
if (typeof value === "string") return ID_ONLY_RE.test(value.trim()) ? value.trim() : null;
|
|
693
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
694
|
+
const obj = value;
|
|
695
|
+
const id = String(obj.id ?? "").trim();
|
|
696
|
+
const name = String(obj.name ?? "").trim();
|
|
697
|
+
if (id !== "" && (name === "" || name === id)) return id;
|
|
698
|
+
}
|
|
699
|
+
return null;
|
|
700
|
+
};
|
|
701
|
+
const ids = /* @__PURE__ */ new Set();
|
|
702
|
+
for (const field of targets) {
|
|
703
|
+
const value = main[field.id];
|
|
704
|
+
const one = missingNameId(value);
|
|
705
|
+
if (one) ids.add(one);
|
|
706
|
+
else if (Array.isArray(value)) for (const item of value) {
|
|
707
|
+
const hit = missingNameId(item);
|
|
708
|
+
if (hit) ids.add(hit);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (ids.size === 0) return main;
|
|
712
|
+
let names = new Map(known);
|
|
713
|
+
const unknown = [...ids].filter((id) => !names.has(id));
|
|
714
|
+
if (unknown.length > 0) {
|
|
715
|
+
try {
|
|
716
|
+
const resolved = await resolveEmployeeNames(env, unknown);
|
|
717
|
+
for (const [id, name] of resolved) names.set(id, name);
|
|
718
|
+
} catch {
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (names.size === 0) return main;
|
|
722
|
+
const rename = (value) => {
|
|
723
|
+
const one = missingNameId(value);
|
|
724
|
+
if (one) return names.get(one) ?? value;
|
|
725
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
726
|
+
const obj = value;
|
|
727
|
+
const id = String(obj.id ?? "").trim();
|
|
728
|
+
const name = names.get(id);
|
|
729
|
+
if (name) return { ...obj, name };
|
|
730
|
+
}
|
|
731
|
+
return value;
|
|
732
|
+
};
|
|
733
|
+
const decorated = { ...main };
|
|
734
|
+
for (const field of targets) {
|
|
735
|
+
const value = decorated[field.id];
|
|
736
|
+
decorated[field.id] = Array.isArray(value) ? value.map(rename) : rename(value);
|
|
737
|
+
}
|
|
738
|
+
return decorated;
|
|
739
|
+
}
|
|
740
|
+
function renderFormPreview(fields, main) {
|
|
741
|
+
const fmt = (value) => {
|
|
742
|
+
if (value === void 0 || value === null) return "\u2014";
|
|
743
|
+
if (Array.isArray(value)) {
|
|
744
|
+
const parts = value.map((one) => fmt(one)).filter((one) => one !== "\u2014");
|
|
745
|
+
return parts.length > 0 ? parts.join("\u3001") : "\u2014";
|
|
746
|
+
}
|
|
747
|
+
if (typeof value === "object") {
|
|
748
|
+
const obj = value;
|
|
749
|
+
const name = String(obj.name ?? obj.mc ?? "").trim();
|
|
750
|
+
if (name !== "") return name.replace(/\|/gu, "/");
|
|
751
|
+
const id = String(obj.id ?? obj.customerId ?? obj.sjID ?? "").trim();
|
|
752
|
+
return id === "" ? "\u2014" : id;
|
|
753
|
+
}
|
|
754
|
+
const text = String(value).trim();
|
|
755
|
+
return text === "" ? "\u2014" : text.replace(/\|/gu, "/").replace(/\r?\n/gu, " ");
|
|
756
|
+
};
|
|
757
|
+
const lines = ["| \u5B57\u6BB5 | \u503C |", "| --- | --- |"];
|
|
758
|
+
const known = /* @__PURE__ */ new Set();
|
|
759
|
+
for (const field of fields) {
|
|
760
|
+
known.add(field.id);
|
|
761
|
+
if (!(field.id in main)) continue;
|
|
762
|
+
lines.push(`| ${String(field.name).replace(/\|/gu, "/")} | ${fmt(main[field.id])} |`);
|
|
763
|
+
}
|
|
764
|
+
for (const [id, value] of Object.entries(main)) {
|
|
765
|
+
if (known.has(id)) continue;
|
|
766
|
+
lines.push(`| ${id} | ${fmt(value)} |`);
|
|
767
|
+
}
|
|
768
|
+
return lines.join("\n");
|
|
769
|
+
}
|
|
770
|
+
function flowFieldCacheDir(env) {
|
|
771
|
+
const configured = env?.ctx?.config?.path?.();
|
|
772
|
+
const root = configured ? resolve(String(configured), "..") : process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
|
|
773
|
+
return resolve(root, "meeting", "cache");
|
|
774
|
+
}
|
|
775
|
+
function flowFieldCacheFile(env, workflowId) {
|
|
776
|
+
return resolve(flowFieldCacheDir(env), `flow-fields-${workflowId}.json`);
|
|
777
|
+
}
|
|
778
|
+
async function readFlowFieldMap(env, workflowId) {
|
|
779
|
+
try {
|
|
780
|
+
const file = flowFieldCacheFile(env, workflowId);
|
|
781
|
+
if (!existsSync(file)) return {};
|
|
782
|
+
const parsed = JSON.parse(await readFile(file, "utf8"));
|
|
783
|
+
return parsed && typeof parsed.mapping === "object" && parsed.mapping ? parsed.mapping : {};
|
|
784
|
+
} catch {
|
|
785
|
+
return {};
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
async function writeFlowFieldMap(env, workflowId, workflowName, mapping) {
|
|
789
|
+
if (Object.keys(mapping).length === 0) return;
|
|
790
|
+
try {
|
|
791
|
+
const file = flowFieldCacheFile(env, workflowId);
|
|
792
|
+
await mkdir(resolve(file, ".."), { recursive: true });
|
|
793
|
+
const cache = {
|
|
794
|
+
workflowId,
|
|
795
|
+
...workflowName ? { workflowName } : {},
|
|
796
|
+
savedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
797
|
+
mapping
|
|
798
|
+
};
|
|
799
|
+
await writeFile(file, JSON.stringify(cache, null, 2), "utf8");
|
|
800
|
+
} catch {
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function normalizeWorkflowIds(raw) {
|
|
804
|
+
if (raw === void 0 || raw === null) return [];
|
|
805
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
806
|
+
const ids = [];
|
|
807
|
+
for (const item of list) {
|
|
808
|
+
for (const piece of String(item ?? "").split(/[,;,;\s]+/)) {
|
|
809
|
+
const term = piece.trim();
|
|
810
|
+
if (!term) continue;
|
|
811
|
+
const matched = term.match(/[((](\d{6,})[))]$/);
|
|
812
|
+
const id = matched ? matched[1] : term;
|
|
813
|
+
if (!ids.includes(id)) ids.push(id);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return ids;
|
|
817
|
+
}
|
|
818
|
+
var FIXED_FLOW_IDS = ["1326190634427154474", "1325677244111462606"];
|
|
819
|
+
var FIXED_FLOW_PROFILES = [
|
|
820
|
+
{
|
|
821
|
+
host: "www.e-cology.com.cn",
|
|
822
|
+
tenantKey: "t7akvdnf84",
|
|
823
|
+
label: "\u6CDB\u5FAE\u751F\u4EA7\uFF08\u6CDB\u5FAE\u7F51\u7EDC\uFF09",
|
|
824
|
+
ids: [...FIXED_FLOW_IDS]
|
|
825
|
+
}
|
|
826
|
+
];
|
|
827
|
+
function fixedFlowFlagOn() {
|
|
828
|
+
const flag = String(process.env.WEAVER_MEETING_FIXED_FLOW ?? "1").trim().toLowerCase();
|
|
829
|
+
return !(flag === "0" || flag === "false" || flag === "off");
|
|
830
|
+
}
|
|
831
|
+
function fixedFlowOverride() {
|
|
832
|
+
const override = String(process.env.WEAVER_MEETING_FIXED_FLOW_IDS ?? "").trim();
|
|
833
|
+
if (!override) return [];
|
|
834
|
+
return override.split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
|
|
835
|
+
}
|
|
836
|
+
function fixedFlowIds() {
|
|
837
|
+
if (!fixedFlowFlagOn()) return [];
|
|
838
|
+
const override = fixedFlowOverride();
|
|
839
|
+
return override.length > 0 ? override : [...FIXED_FLOW_IDS];
|
|
840
|
+
}
|
|
841
|
+
async function fixedFlowIdsForEnv(env) {
|
|
842
|
+
if (!fixedFlowFlagOn()) return { ids: [] };
|
|
843
|
+
const override = fixedFlowOverride();
|
|
844
|
+
if (override.length > 0) return { ids: override, label: "\u73AF\u5883\u53D8\u91CF\u6307\u5B9A" };
|
|
845
|
+
let baseUrl = "";
|
|
846
|
+
let tenantKey = "";
|
|
847
|
+
try {
|
|
848
|
+
const session = await env?.host?.getSession?.();
|
|
849
|
+
baseUrl = String(session?.baseUrl ?? "");
|
|
850
|
+
tenantKey = String(session?.tenantKey ?? session?.tenantId ?? "");
|
|
851
|
+
} catch {
|
|
852
|
+
}
|
|
853
|
+
if (!baseUrl) return { ids: [...FIXED_FLOW_IDS], label: "\u9ED8\u8BA4\u56FA\u5316\u914D\u7F6E\uFF08\u672A\u53D6\u5230\u767B\u5F55\u73AF\u5883\uFF09" };
|
|
854
|
+
const host = baseUrl.replace(/^https?:\/\//i, "").replace(/\/.*$/, "").toLowerCase();
|
|
855
|
+
const hit = FIXED_FLOW_PROFILES.find((profile) => profile.host === host && (!profile.tenantKey || !tenantKey || profile.tenantKey === tenantKey));
|
|
856
|
+
return hit ? { ids: [...hit.ids], label: hit.label } : { ids: [] };
|
|
857
|
+
}
|
|
858
|
+
function shouldAutoPickFlow(args) {
|
|
859
|
+
if (args.flowChoice === "auto") return true;
|
|
860
|
+
return String(process.env.WEAVER_MEETING_FLOW_CHOICE ?? "").trim().toLowerCase() === "auto";
|
|
861
|
+
}
|
|
862
|
+
async function sendInvitationToGroup(env, groupId, filePath, warnings) {
|
|
863
|
+
const started = Date.now();
|
|
864
|
+
try {
|
|
865
|
+
const { buildImEnv } = await import("./group-chat-2HHAJN46.js");
|
|
866
|
+
const { getImOperation } = await import("./registry-OZSMDVPP.js");
|
|
867
|
+
const imEnv = await buildImEnv(env);
|
|
868
|
+
const prepared = await getImOperation("im.msg.send.group.prepare").handler(
|
|
869
|
+
{ groupId, file: filePath },
|
|
870
|
+
imEnv
|
|
871
|
+
);
|
|
872
|
+
const continuation = String(prepared?.data?.continuation ?? "");
|
|
873
|
+
const applied = continuation ? await getImOperation("im.msg.send.group.apply").handler({ continuation, confirm: true }, imEnv) : null;
|
|
874
|
+
const ok = applied?.ok === true;
|
|
875
|
+
if (!ok) {
|
|
876
|
+
warnings.push(
|
|
877
|
+
`\u9080\u8BF7\u51FD\u6CA1\u80FD\u53D1\u5230\u7FA4\u91CC\uFF08${String(applied?.error?.message ?? prepared?.error?.message ?? "\u672A\u77E5\u539F\u56E0").slice(0, 150)}\uFF09\uFF1B\u6587\u4EF6\u5DF2\u751F\u6210\uFF0C\u53EF\u624B\u52A8\u8F6C\u53D1\u3002`
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
return { ok, ms: Date.now() - started };
|
|
881
|
+
} catch (error) {
|
|
882
|
+
warnings.push(`\u9080\u8BF7\u51FD\u53D1\u7FA4\u5F02\u5E38\uFF08\u4E0D\u5F71\u54CD\u5EFA\u4F1A\uFF09\uFF1A${String(error?.message ?? error).slice(0, 150)}`);
|
|
883
|
+
return { ok: false, ms: Date.now() - started };
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
async function resolveWorkflowId(env, args) {
|
|
887
|
+
const explicitList = normalizeWorkflowIds(args.workflowId);
|
|
888
|
+
if (explicitList.length > 0) {
|
|
889
|
+
return {
|
|
890
|
+
workflowId: explicitList.length === 1 ? explicitList[0] : "",
|
|
891
|
+
candidates: explicitList,
|
|
892
|
+
source: "argument"
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
const fixed = await fixedFlowIdsForEnv(env);
|
|
896
|
+
if (fixed.ids.length > 0) {
|
|
897
|
+
return {
|
|
898
|
+
workflowId: fixed.ids.length === 1 ? fixed.ids[0] : "",
|
|
899
|
+
candidates: fixed.ids,
|
|
900
|
+
source: "fixed",
|
|
901
|
+
...fixed.label ? { label: fixed.label } : {}
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
const settings = await fetchEbAppSettings(env, "meeting.eb.meeting.create.flow.prepare");
|
|
905
|
+
const candidates = String(settings.mtNewWf ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
|
|
906
|
+
if (candidates.length === 0) {
|
|
907
|
+
throw meetingValidationError(
|
|
908
|
+
"flow_not_configured",
|
|
909
|
+
"\u5E94\u7528\u8BBE\u7F6E\u91CC\u6CA1\u6709\u914D\u7F6E\u300C\u65B0\u5EFA\u4F1A\u8BAE\u5DE5\u4F5C\u6D41\u300D\uFF08mt_new_wf \u4E3A\u7A7A\uFF09\uFF0C\u4E5F\u6CA1\u6709\u542F\u7528\u56FA\u5316\u6D41\u7A0B\uFF0C\u65E0\u6CD5\u8D70\u6D41\u7A0B\u5EFA\u4F1A\uFF1B\u8BF7\u7BA1\u7406\u5458\u5728\u4F1A\u8BAE\u5E94\u7528\u8BBE\u7F6E\u91CC\u914D\u7F6E\uFF0C\u6216\u7528 WEAVER_MEETING_FIXED_FLOW_IDS \u6307\u5B9A\u9ED8\u8BA4\u6D41\u7A0B"
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
return { workflowId: candidates.length === 1 ? candidates[0] : "", candidates, source: "settings" };
|
|
913
|
+
}
|
|
914
|
+
function pad2(value) {
|
|
915
|
+
return String(value).padStart(2, "0");
|
|
916
|
+
}
|
|
917
|
+
function tomorrowIso() {
|
|
918
|
+
const date = new Date(Date.now() + 24 * 60 * 60 * 1e3);
|
|
919
|
+
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`;
|
|
920
|
+
}
|
|
921
|
+
function formatMinute(date) {
|
|
922
|
+
return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${pad2(date.getHours())}:${pad2(date.getMinutes())}`;
|
|
923
|
+
}
|
|
924
|
+
async function probeWorkflowCandidates(env, ids) {
|
|
925
|
+
const probed = await Promise.all(ids.map(async (id) => {
|
|
926
|
+
try {
|
|
927
|
+
const probeForm = await loadCreateForm(env, id);
|
|
928
|
+
return {
|
|
929
|
+
id,
|
|
930
|
+
probeForm,
|
|
931
|
+
probe: {
|
|
932
|
+
workflowId: id,
|
|
933
|
+
...probeForm.workflowName ? { name: probeForm.workflowName } : {},
|
|
934
|
+
launchable: true
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
} catch (error) {
|
|
938
|
+
return {
|
|
939
|
+
id,
|
|
940
|
+
probeForm: null,
|
|
941
|
+
probe: {
|
|
942
|
+
workflowId: id,
|
|
943
|
+
launchable: false,
|
|
944
|
+
reason: String(error?.message ?? error).slice(0, 160)
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
}));
|
|
949
|
+
const probes = [];
|
|
950
|
+
const loadedForms = /* @__PURE__ */ new Map();
|
|
951
|
+
for (const item of probed) {
|
|
952
|
+
if (item.probeForm) loadedForms.set(item.id, item.probeForm);
|
|
953
|
+
probes.push(item.probe);
|
|
954
|
+
}
|
|
955
|
+
return { probes, loadedForms };
|
|
956
|
+
}
|
|
957
|
+
var ebMeetingCreateFlowPrepare = {
|
|
958
|
+
name: "meeting.eb.meeting.create.flow.prepare",
|
|
959
|
+
resource: "eb",
|
|
960
|
+
method: "meeting.eb.meeting.create.flow.prepare",
|
|
961
|
+
action: "meeting.eb.meeting.create.flow.prepare",
|
|
962
|
+
summary: '\u6D41\u7A0B\u5EFA\u4F1A\uFF08\u51C6\u5907\uFF09\uFF1A\u7528\u56FA\u5316\u6D41\u7A0B\u5019\u9009\u9010\u4E2A\u63A2\u6D4B\u53D1\u8D77\u6743\u9650 \u2014\u2014 \u4EC5 1 \u4E2A\u53EF\u53D1\u8D77\u5C31\u81EA\u52A8\u7528\u5B83\u3001\u591A\u4E2A\u90FD\u53EF\u53D1\u8D77\u5219\u8FD4\u56DE\u9009\u9879\u8BA9\u7528\u6237\u9009\u3001\u90FD\u4E0D\u53EF\u53D1\u8D77\u62A5\u300C\u6CA1\u6709\u53D1\u8D77\u6743\u9650\u300D\uFF1B\u4E0D\u4F20 begin_datetime \u65F6\u81EA\u52A8\u63A8\u8350\u300C\u4EBA+\u4F1A\u8BAE\u5BA4\u90FD\u7A7A\u95F2\u300D\u7684\u65F6\u6BB5\u3002\u53EA\u51FA\u9884\u89C8\u4E0E\u786E\u8BA4\u7968\u636E\uFF0C\u4E0D\u63D0\u4EA4\u3002\u26A0\uFE0F \u7528\u6237\u63D0\u5230\u5BA2\u6237\u540D\uFF08\u300C\u5BA2\u6237\u662F X\u300D\uFF09\u65F6**\u5FC5\u987B\u5148** meeting.eb.crm.search {"keyword":"X"} \u62FF customerId\uFF0C\u518D\u4F20 crm_members:[{id,name}]\uFF1B\u53EA\u628A\u5BA2\u6237\u540D\u5199\u8FDB\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\uFF0C\u8868\u5355\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5C31\u662F\u7A7A\u7684',
|
|
963
|
+
capability: "eb.meeting",
|
|
964
|
+
risk: "read-before-write",
|
|
965
|
+
requiresConfirmation: true,
|
|
966
|
+
inputSchema: schemaOf(
|
|
967
|
+
{
|
|
968
|
+
mt_name: { type: "string", description: "\u4F1A\u8BAE\u540D\u79F0\uFF08\u5FC5\u586B\uFF09" },
|
|
969
|
+
begin_datetime: {
|
|
970
|
+
...SCHEMA_DATETIME_MINUTE,
|
|
971
|
+
description: "\u5F00\u59CB\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\u3002**\u53EF\u4EE5\u4E0D\u4F20**\uFF1A\u4E0D\u4F20\u4F1A\u6309\u53C2\u4F1A\u4EBA\u4E0E\u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u60C5\u51B5\u63A8\u8350 3 \u4E2A\u65F6\u6BB5\u8BA9\u4F60\u9009\uFF1B\u53EA\u4F20\u5F00\u59CB\u65F6\u95F4\u3001\u4E0D\u4F20\u7ED3\u675F\u65F6\u95F4\u65F6\uFF0C\u6309 durationMinutes\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09\u81EA\u52A8\u7B97\u7ED3\u675F\u65F6\u95F4"
|
|
972
|
+
},
|
|
973
|
+
end_datetime: {
|
|
974
|
+
...SCHEMA_DATETIME_MINUTE,
|
|
975
|
+
description: "\u7ED3\u675F\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309 durationMinutes \u4ECE\u5F00\u59CB\u65F6\u95F4\u63A8\u7B97\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09"
|
|
976
|
+
},
|
|
977
|
+
mt_desc: { type: "string", description: "\u4F1A\u8BAE\u5185\u5BB9/\u8BF4\u660E" },
|
|
978
|
+
address: { type: "string", description: "\u4F1A\u8BAE\u5BA4\uFF08\u540D\u79F0\u6216 id\uFF0C\u6309\u6D41\u7A0B\u8868\u5355\u5B57\u6BB5\u8981\u6C42\uFF09" },
|
|
979
|
+
customize_address: { type: "string", description: "\u81EA\u5B9A\u4E49\u4F1A\u8BAE\u5730\u70B9" },
|
|
980
|
+
hrm_members: { type: "string", description: "\u53C2\u4F1A\u4EBA\u5458\uFF08\u9017\u53F7\u5206\u9694\u5458\u5DE5 id \u6216\u59D3\u540D\uFF0C\u6309\u6D41\u7A0B\u8868\u5355\u8981\u6C42\uFF09" },
|
|
981
|
+
total_member: { type: "number", description: "\u53C2\u4F1A\u4EBA\u6570" },
|
|
982
|
+
crm_members: {
|
|
983
|
+
oneOf: [{ type: "string" }, { type: "array", items: { oneOf: [{ type: "string" }, { type: "object" }] } }],
|
|
984
|
+
description: "\u53C2\u4F1A\u5BA2\u6237\uFF1A**\u5FC5\u987B\u5E26\u5BA2\u6237\u540D\u79F0**\uFF0C\u5199\u6CD5 `[{id,name}]` \u6216\u300C\u5BA2\u6237\u540D(\u5BA2\u6237id)\u300D\u6216\u9017\u53F7\u5206\u9694\u7684\u8FD9\u4E24\u79CD\u3002\u5BA2\u6237\u5148\u4ECE `meeting.eb.crm.search` \u6309\u5BA2\u6237\u540D\u67E5\u51FA\uFF08\u5165\u53C2 custom_name\uFF0C\u51FA\u53C2 items[].customerId / name\uFF09\uFF0C\u8BE5\u67E5\u8BE2**\u4E00\u6B21\u53EA\u56DE\u9996\u4E2A\u5339\u914D** \u21D2 exact=false \u65F6\u5FC5\u987B\u5148\u8BA9\u7528\u6237\u786E\u8BA4\u5BA2\u6237\u540D\u518D\u5199\u8FD9\u4E2A\u5B57\u6BB5\u3002\u26D4 \u53EA\u7ED9 id \u4E0D\u7ED9\u540D\u79F0\u4F1A\u88AB\u62D2\u7EDD\uFF08\u5BA2\u6237\u6D4F\u89C8\u6309\u94AE\u6309\u540D\u79F0\u843D\u503C\uFF0C\u53EA\u7ED9 id \u4F1A\u9759\u9ED8\u5B58\u6210\u7A7A\uFF09"
|
|
985
|
+
},
|
|
986
|
+
crm_member_count: { type: "number", description: "\u5E94\u5230\u5BA2\u6237\u6570\uFF1B\u4E0D\u4F20\u5219\u6309 crm_members \u6761\u6570\u81EA\u52A8\u7B97" },
|
|
987
|
+
crm_member_details: {
|
|
988
|
+
type: "array",
|
|
989
|
+
description: '\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\uFF08\u5BBF\u4E3B\u8868\u5355\u91CC\u7684\u660E\u7EC6\u8868\uFF0C\u5217 \u59D3\u540D/\u6027\u522B/\u804C\u4F4D/\u624B\u673A\u53F7\u7801/\u5907\u6CE8\uFF09\uFF1A\u6BCF\u884C `{"xm":"\u5F20\u4E09","xb":"\u7537","zw":"\u7ECF\u7406","sjhm":"138...","bz":""}`\uFF0C\u4E5F\u63A5\u53D7\u4E2D\u6587\u952E\uFF08\u59D3\u540D/\u6027\u522B/\u804C\u4F4D/\u624B\u673A\u53F7\u7801/\u5907\u6CE8\uFF09\u3002\u5217\u5B57\u6BB5 id \u7531 CLI \u4ECE\u8868\u5355\u91CC\u6309\u5217\u540D\u53CD\u67E5\uFF0C\u4E0D\u7528\u4F20\u3002\u26A0\uFE0F \u8BE5\u660E\u7EC6\u8868\u5FC5\u987B\u5728\u53D1\u8D77\u8282\u70B9\u5E03\u5C40\u91CC\uFF08\u5426\u5219 CLI \u4F1A\u63D0\u793A"\u8868\u5355\u91CC\u6CA1\u6709\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6"\u5E76\u5FFD\u7565\u8FD9\u4E9B\u884C\uFF09\u26D4 \u9ED8\u8BA4\u4E0D\u751F\u6548\uFF1A\u5BA2\u6237\u8054\u7CFB\u4EBA\u7531 CLI \u6309 CRM \u5168\u91CF\u81EA\u52A8\u5E26\u5165\uFF0C\u8FD9\u91CC\u53EA\u5728 crm_detail_mode:"only" \u65F6\u624D\u7528\u6765"\u53EA\u5199\u8FD9\u51E0\u4F4D"',
|
|
990
|
+
items: { type: "object" }
|
|
991
|
+
},
|
|
992
|
+
crm_detail_mode: {
|
|
993
|
+
type: "string",
|
|
994
|
+
description: '\u660E\u7EC6\u884C\u53E3\u5F84\uFF1A\u4E0D\u4F20\uFF08\u9ED8\u8BA4\uFF09= \u6309 CRM \u628A\u8BE5\u5BA2\u6237**\u5168\u90E8**\u8054\u7CFB\u4EBA\u81EA\u52A8\u5199\u5165\u300C\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\u300D\uFF08\u4E00\u4EBA\u4E00\u884C\uFF0C\u4E0D\u7528\u95EE\u7528\u6237\u9009\u54EA\u4F4D\uFF09\uFF1B\u4F20 "only" = \u53EA\u5199 crm_member_details \u91CC\u70B9\u540D\u7684\u8FD9\u51E0\u4F4D'
|
|
995
|
+
},
|
|
996
|
+
caller: { type: "string", description: "\u53EC\u96C6\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u53EC\u96C6\u4EBA\u624D\u4F20" },
|
|
997
|
+
contacter: { type: "string", description: "\u8054\u7CFB\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u8054\u7CFB\u4EBA\u624D\u4F20" },
|
|
998
|
+
mt_type: {
|
|
999
|
+
type: "string",
|
|
1000
|
+
description: "\u4F1A\u8BAE\u7C7B\u578B\uFF1A\u53EF\u4F20\u7C7B\u578B\u540D\u79F0\u6216 id\uFF08\u5148\u7528 `meeting.eb.type.list` \u67E5\u6709\u54EA\u4E9B\uFF09\u3002**\u5F88\u591A\u79DF\u6237\u7684\u6D41\u7A0B\u8868\u5355\u628A\u300C\u4F1A\u8BAE\u7C7B\u578B\u300D\u8BBE\u4E3A\u5FC5\u586B**\uFF0C\u4E0D\u4F20\u4F1A\u88AB `workflow.createRequest` \u6253\u56DE\u7F3A\u5B57\u6BB5"
|
|
1001
|
+
},
|
|
1002
|
+
other_remark: { type: "string", description: "\u5907\u6CE8" },
|
|
1003
|
+
workflowId: {
|
|
1004
|
+
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
|
|
1005
|
+
description: "\u6307\u5B9A\u5EFA\u4F1A\u6D41\u7A0B id\uFF1A\u5355\u4E2A id\u3001id \u6570\u7EC4\u6216\u9017\u53F7\u5206\u9694\u90FD\u53EF\u4EE5\uFF0C\u4E5F\u63A5\u53D7\u300C\u6D41\u7A0B\u540D(123456)\u300D\u5199\u6CD5\u3002**\u4F20\u591A\u4E2A\u65F6 CLI \u540C\u6837\u4E0D\u4F1A\u66FF\u4F60\u9009**\u2014\u2014\u4F1A\u9010\u4E2A\u63A2\u6D4B\u53EF\u53D1\u8D77\u6027\uFF0C\u591A\u4E2A\u53EF\u7528\u5219\u8FD4\u56DE NEEDS_SELECTION \u8BA9\u7528\u6237\u6311\uFF1B\u4E0D\u4F20\u5219\u7528\u5E94\u7528\u8BBE\u7F6E mt_new_wf \u914D\u7F6E\u7684\u6D41\u7A0B\uFF08\u914D\u4E86\u591A\u4E2A\u65F6\u540C\u6837\u8BA9\u7528\u6237\u9009\uFF09"
|
|
1006
|
+
},
|
|
1007
|
+
autoRoom: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\u65F6\u8FD4\u56DE\u5019\u9009\u8BA9\u7528\u6237\u9009\uFF1B\u4F20 true \u624D\u81EA\u52A8\u91C7\u7528\u63A8\u8350" },
|
|
1008
|
+
allowNoRoom: { type: "boolean", description: "\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\uFF08\u7EBF\u4E0A\u4F1A\u7B49\uFF09\u65F6\u4F20 true\uFF0C\u907F\u514D\u88AB\u201C\u8BF7\u9009\u62E9\u4F1A\u8BAE\u5BA4\u201D\u62E6\u4F4F" },
|
|
1009
|
+
timeConfirmed: {
|
|
1010
|
+
type: "boolean",
|
|
1011
|
+
description: '\u26D4 **\u65F6\u95F4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0**\u3002\u53EA\u6709\u4EE5\u4E0B\u4E24\u79CD\u60C5\u51B5\u624D\u4F20 true\uFF1A\u2460 \u7528\u6237\u539F\u8BDD\u91CC\u660E\u786E\u7ED9\u51FA\u4E86\u65F6\u95F4\uFF08\u5982"\u660E\u5929 9 \u70B9\u5230 10 \u70B9"\uFF09\uFF1B\u2461 \u7528\u6237\u5728\u65F6\u6BB5\u9009\u9879\u91CC\u70B9\u9009\u540E\uFF0C\u628A `options[].value` **\u6574\u4F53**\u539F\u6837\u56DE\u4F20\uFF08value \u81EA\u5E26\u8BE5\u6807\u8BB0\uFF09\u3002\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF1A\u5373\u4F7F\u4F60\u4F20\u4E86 begin_datetime\uFF0CCLI \u4E5F**\u4E0D\u4F1A**\u5F53\u6210\u5DF2\u5B9A\uFF0C\u800C\u662F\u8FD4\u56DE\u65F6\u6BB5\u9009\u9879\u8BA9\u7528\u6237\u70B9\u9009\u3002\u26D4 \u7528\u6237\u53EA\u8BF4"\u660E\u5929/\u4E0A\u5348/\u4E0B\u5348"\u8FD9\u7C7B\u6A21\u7CCA\u8BF4\u6CD5\u65F6\uFF0C**\u5FC5\u987B\u4E0D\u4F20**\uFF0C\u8BA9 CLI \u7ED9\u5019\u9009'
|
|
1012
|
+
},
|
|
1013
|
+
roomConfirmed: {
|
|
1014
|
+
type: "boolean",
|
|
1015
|
+
description: '\u26D4 **\u4F1A\u8BAE\u5BA4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0**\u3002\u53EA\u6709\u4EE5\u4E0B\u4E24\u79CD\u60C5\u51B5\u624D\u4F20 true\uFF1A\u2460 \u7528\u6237\u539F\u8BDD\u660E\u786E\u6307\u5B9A\u4E86\u67D0\u95F4\u4F1A\u8BAE\u5BA4\uFF1B\u2461 \u7528\u6237\u5728\u623F\u95F4\u9009\u9879\u91CC\u70B9\u9009\u540E\u628A `options[].value` \u6574\u4F53\u539F\u6837\u56DE\u4F20\u3002\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF1A\u5373\u4F7F\u4F20\u4E86 address\uFF0CCLI \u4E5F\u4F1A\u628A"\u4F60\u6307\u5B9A\u7684\u8FD9\u95F4"\u548C\u63A8\u8350\u5019\u9009\u4E00\u8D77\u5217\u51FA\u6765\u8BA9\u7528\u6237\u70B9\u9009\u3002\u26D4 \u4E0D\u8981\u81EA\u5DF1\u4ECE room.list / room.recommend \u91CC\u6311\u4E00\u95F4\u585E\u8FDB address \u2014\u2014 \u90A3\u662F\u66FF\u7528\u6237\u62CD\u677F'
|
|
1016
|
+
},
|
|
1017
|
+
extraFields: {
|
|
1018
|
+
type: "object",
|
|
1019
|
+
description: '\u6309**\u6D41\u7A0B\u8868\u5355\u91CC\u7684\u5B57\u6BB5\u540D**\u586B\u989D\u5916\u5B57\u6BB5\uFF0C\u5F62\u5982 {"\u53C2\u4F1A\u5BA2\u6237": "xx\u516C\u53F8", "\u8054\u7CFB\u65B9\u5F0F": "138xxxx"}\uFF1A\u7528\u4E8E\u79DF\u6237\u5728\u6D41\u7A0B\u8868\u5355\u4E0A\u81EA\u5EFA\u3001CLI \u5185\u7F6E\u522B\u540D\u91CC\u6CA1\u6709\u7684\u5B57\u6BB5\u3002\u952E\u5FC5\u987B\u4E0E\u8BE5\u6D41\u7A0B\u8868\u5355\u7684\u5B57\u6BB5\u540D\u5B8C\u5168\u4E00\u81F4\uFF08prepare \u7684 warnings \u4F1A\u5217\u51FA\u8868\u5355\u73B0\u6709\u5168\u90E8\u5B57\u6BB5\u540D\uFF09\uFF1B\u5339\u914D\u4E0D\u5230\u7684\u4F1A\u8FDB unmapped \u63D0\u793A\uFF0C\u4E0D\u4F1A\u778E\u586B\u3002\u26D4 **\u4F1A\u8BAE\u5730\u70B9 / \u53C2\u4F1A\u4EBA\u5458 / \u53EC\u96C6\u4EBA / \u8054\u7CFB\u4EBA / \u4F1A\u8BAE\u7C7B\u578B \u4E0D\u8981\u585E\u8FD9\u91CC** \u2014\u2014 \u5B83\u4EEC\u6709\u4E13\u7528\u5165\u53C2\uFF08address / hrm_members / caller / contacter / mt_type\uFF09\uFF0CCLI \u4F1A\u628A\u503C\u8865\u6210\u6D4F\u89C8\u6309\u94AE\u8981\u7684 `{id,name}` \u5BF9\u8C61\uFF1B\u585E\u8FDB extraFields \u4F1A\u6309\u7EAF\u6587\u672C\u63D0\u4EA4\uFF0C\u670D\u52A1\u7AEF\u4F1A\u6253\u56DE\u300C\u8BF7\u6309\u540D\u79F0\u9009\u62E9\u300D'
|
|
1020
|
+
},
|
|
1021
|
+
dateFrom: {
|
|
1022
|
+
type: "string",
|
|
1023
|
+
description: "\u6CA1\u7ED9\u5177\u4F53\u65F6\u95F4\u65F6\u6309\u54EA\u4E00\u5929\u63A8\u8350\u65F6\u6BB5\uFF08yyyy-MM-dd\uFF1B\u4E0D\u4F20\u9ED8\u8BA4\u660E\u5929\uFF09\u3002\u26A0\uFE0F \u7528\u6237\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u5C31\u5FC5\u987B\u540C\u65F6\u4F20 time_slot \u2014\u2014 \u53EA\u4F20 dateFrom \u4F1A\u5F39\u65F6\u6BB5\u9009\u62E9\u5668\u8BA9\u7528\u6237\u518D\u9009\u4E00\u6B21"
|
|
1024
|
+
},
|
|
1025
|
+
time_slot: {
|
|
1026
|
+
type: "string",
|
|
1027
|
+
enum: ["\u4E0A\u5348", "\u65E9\u4E0A", "\u4E0B\u5348", "\u665A\u4E0A"],
|
|
1028
|
+
description: '\u7528\u6237\u53EA\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u65F6\u4F20\u8FD9\u4E2A\uFF08\u914D\u5408 dateFrom\uFF09\uFF1A\u4E0A\u5348/\u65E9\u4E0A=09:00\u201312:00\u3001\u4E0B\u5348=13:00\u201318:00\u3001\u665A\u4E0A=18:00\u201321:00\uFF0CCLI \u76F4\u63A5\u5B9A\u4E0B\u6765\u3001\u4E0D\u518D\u8FD4\u56DE\u65F6\u6BB5\u5019\u9009\u3002\u26D4 \u4E0D\u8981\u53EA\u4F20 dateFrom \u5C31\u671F\u5F85"\u8BA9\u7528\u6237\u9009\u65F6\u6BB5"\u2014\u2014\u7528\u6237\u5DF2\u7ECF\u8BF4\u4E86\u65F6\u6BB5\u5C31\u522B\u518D\u95EE'
|
|
1029
|
+
},
|
|
1030
|
+
durationMinutes: {
|
|
1031
|
+
type: "number",
|
|
1032
|
+
description: "\u4F1A\u8BAE\u65F6\u957F\uFF08\u5206\u949F\uFF0C\u9ED8\u8BA4 60\uFF09\uFF1A\u53EA\u7ED9\u4E86\u5F00\u59CB\u65F6\u95F4\u65F6\u7528\u6765\u7B97\u7ED3\u675F\u65F6\u95F4\uFF1B\u63A8\u8350\u65F6\u6BB5\u65F6\u4E5F\u6309\u8FD9\u4E2A\u65F6\u957F\u627E"
|
|
1033
|
+
},
|
|
1034
|
+
workStartHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u65E9\u5C0F\u65F6\uFF08\u9ED8\u8BA4 9\uFF09" },
|
|
1035
|
+
workEndHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u665A\u5C0F\u65F6\uFF08\u9ED8\u8BA4 18\uFF09" },
|
|
1036
|
+
fieldValues: {
|
|
1037
|
+
type: "object",
|
|
1038
|
+
additionalProperties: true,
|
|
1039
|
+
description: '\u6309**\u8868\u5355\u5B57\u6BB5 datakey\uFF08fieldId\uFF09**\u76F4\u63A5\u7ED9\u503C\uFF0C\u5F62\u5982 {"1325677252711735881": "\u7814\u8BA8\u4F1A"}\u3002\u4F18\u5148\u7EA7\u6700\u9AD8\uFF08\u540C\u540D\u5B57\u6BB5\u4EE5\u5B83\u4E3A\u51C6\uFF09\uFF1A\u9002\u5408\u5B57\u6BB5\u540D\u5E26\u63D0\u793A\u8BED\u3001\u6216\u79DF\u6237\u81EA\u5EFA\u5B57\u6BB5\u8FD9\u7C7B\u6309\u4E2D\u6587\u540D\u731C\u4E0D\u5230\u7684\u60C5\u51B5\u3002datakey \u4ECE prepare \u8FD4\u56DE\u7684 preview.mapped\uFF08\u5F62\u5982 "\u4F1A\u8BAE\u540D\u79F0(1325677252711735881)"\uFF09\u91CC\u53D6\uFF1B\u6BCF\u4E2A\u6D41\u7A0B\u7684 datakey \u56FA\u5B9A\u4E0D\u53D8\uFF0C\u53EF\u957F\u671F\u786C\u7F16\u7801\u3002'
|
|
1040
|
+
},
|
|
1041
|
+
flowChoice: {
|
|
1042
|
+
type: "string",
|
|
1043
|
+
enum: ["auto", "ask"],
|
|
1044
|
+
description: '\u591A\u4E2A\u5EFA\u4F1A\u6D41\u7A0B**\u90FD\u6709\u53D1\u8D77\u6743\u9650**\u65F6\u600E\u4E48\u529E\uFF1A\u9ED8\u8BA4\uFF08\u4E0D\u4F20 / ask\uFF09= \u8FD4\u56DE\u9009\u9879\u8BA9\u7528\u6237\u6311\uFF1Bauto = \u81EA\u52A8\u53D6\u4F18\u5148\u7EA7\u6700\u9AD8\u7684\u90A3\u4E2A\uFF08\u7701\u4E00\u8F6E\uFF0C\u4F46\u9009\u9519\u6D41\u7A0B\u4F1A\u6F0F\u5B57\u6BB5\uFF0C\u614E\u7528\uFF09\u3002\u6709**\u6D41\u7A0B\u8BB0\u5FC6**\uFF08\u8BE5\u8D26\u53F7\u4E0A\u6B21\u6210\u529F\u7528\u8FC7\u7684\u6D41\u7A0B\uFF09\u4E14\u672C\u6B21\u4ECD\u53EF\u53D1\u8D77\u65F6\uFF0C\u9ED8\u8BA4\u76F4\u63A5\u6CBF\u7528\u4E0A\u6B21\u9009\u62E9\u5E76\u7559\u75D5\uFF0C\u4E0D\u518D\u5F39\u9009\u9879\uFF1B\u8981\u5F3A\u5236\u56DE\u5230"\u6BCF\u6B21\u90FD\u95EE"\u624D\u4F20 ask\u3002\u53EA\u6709 1 \u4E2A\u6709\u6743\u9650\u65F6\u4E0D\u53D7\u6B64\u53C2\u6570\u5F71\u54CD\uFF0CCLI \u76F4\u63A5\u53D1\u8D77'
|
|
1045
|
+
}
|
|
1046
|
+
},
|
|
1047
|
+
{ required: ["mt_name"] }
|
|
1048
|
+
),
|
|
1049
|
+
handler: async (args, env) => {
|
|
1050
|
+
let workflowId = "";
|
|
1051
|
+
let flowPickNote = null;
|
|
1052
|
+
const decisions = {};
|
|
1053
|
+
const enrich = args.enrich !== false;
|
|
1054
|
+
let beginText = String(args.begin_datetime ?? "").trim();
|
|
1055
|
+
let endText = String(args.end_datetime ?? "").trim();
|
|
1056
|
+
const TIME_SLOT_RANGES = {
|
|
1057
|
+
\u4E0A\u5348: ["09:00", "12:00"],
|
|
1058
|
+
\u65E9\u4E0A: ["09:00", "12:00"],
|
|
1059
|
+
\u4E0B\u5348: ["13:00", "18:00"],
|
|
1060
|
+
\u665A\u4E0A: ["18:00", "21:00"]
|
|
1061
|
+
};
|
|
1062
|
+
let slotConfirmed = false;
|
|
1063
|
+
const slotArg = String(args.time_slot ?? "").trim();
|
|
1064
|
+
if (slotArg !== "" && !/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(beginText)) {
|
|
1065
|
+
const range = TIME_SLOT_RANGES[slotArg];
|
|
1066
|
+
const day2 = String(args.dateFrom ?? "").trim().slice(0, 10) || beginText.slice(0, 10) || tomorrowIso();
|
|
1067
|
+
if (range && /^\d{4}-\d{2}-\d{2}$/.test(day2)) {
|
|
1068
|
+
beginText = `${day2} ${range[0]}`;
|
|
1069
|
+
endText = `${day2} ${range[1]}`;
|
|
1070
|
+
slotConfirmed = true;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
if (!slotConfirmed && !/\d{1,2}:\d{2}/.test(beginText)) {
|
|
1074
|
+
const workStart = Number(args.workStartHour);
|
|
1075
|
+
const workEnd = Number(args.workEndHour);
|
|
1076
|
+
if (Number.isFinite(workStart) && Number.isFinite(workEnd) && workEnd > workStart) {
|
|
1077
|
+
const slotName = workEnd <= 12 && workStart < 12 ? "\u4E0A\u5348" : workStart >= 13 && workEnd <= 18 ? "\u4E0B\u5348" : workStart >= 18 ? "\u665A\u4E0A" : "";
|
|
1078
|
+
const range = slotName ? TIME_SLOT_RANGES[slotName] : void 0;
|
|
1079
|
+
const day2 = String(args.dateFrom ?? "").trim().slice(0, 10) || beginText.slice(0, 10) || tomorrowIso();
|
|
1080
|
+
if (range && /^\d{4}-\d{2}-\d{2}$/.test(day2)) {
|
|
1081
|
+
beginText = `${day2} ${range[0]}`;
|
|
1082
|
+
endText = `${day2} ${range[1]}`;
|
|
1083
|
+
slotConfirmed = true;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
const slotHit = beginText.match(/(\d{4}-\d{2}-\d{2})?\s*(上午|早上|下午|晚上)/u);
|
|
1088
|
+
if (slotHit) {
|
|
1089
|
+
const range = TIME_SLOT_RANGES[slotHit[2]];
|
|
1090
|
+
const day2 = slotHit[1] || beginText.slice(0, 10) || String(args.dateFrom ?? "").trim().slice(0, 10) || tomorrowIso();
|
|
1091
|
+
const rest = beginText.replace(slotHit[0], "");
|
|
1092
|
+
if (range && /^\d{4}-\d{2}-\d{2}$/.test(day2) && !/\d{1,2}:\d{2}/.test(rest)) {
|
|
1093
|
+
beginText = `${day2} ${range[0]}`;
|
|
1094
|
+
endText = `${day2} ${range[1]}`;
|
|
1095
|
+
slotConfirmed = true;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
const rawMembers = String(args.hrm_members ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
|
|
1099
|
+
let membersDefaulted = false;
|
|
1100
|
+
if (rawMembers.length === 0) {
|
|
1101
|
+
const self = await resolveSelfPerson(env);
|
|
1102
|
+
if (self) {
|
|
1103
|
+
rawMembers.push(self.id);
|
|
1104
|
+
membersDefaulted = true;
|
|
1105
|
+
args.hrm_members = rawMembers.join(",");
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
const nameLike = rawMembers.filter((item) => !/^\d+$/.test(item));
|
|
1109
|
+
const nameToId = nameLike.length > 0 ? await import("./schedule-FNXKH3DQ.js").then((m) => m.resolveMemberIdsByName(env, nameLike)).catch(() => /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
|
|
1110
|
+
const memberIds = rawMembers.map((item) => nameToId.get(item) ?? item);
|
|
1111
|
+
const timeConfirmed = args.timeConfirmed === true || slotConfirmed;
|
|
1112
|
+
const callerWorkflowId = String(args.workflowId ?? "").trim();
|
|
1113
|
+
const earlyWorkflowNote = callerWorkflowId === "" ? "" : `\u26D4 \u4F60\u4F20\u4E86 workflowId=${callerWorkflowId}\uFF0C\u4F46**\u6D41\u7A0B\u8FD8\u6CA1\u5230\u786E\u8BA4\u6B65\u9AA4**\uFF08\u987A\u5E8F\u662F \u540D\u79F0\u2192\u65F6\u95F4\u2192\u53C2\u4F1A\u4EBA\u2192\u5730\u70B9\u2192\u6D41\u7A0B\uFF09\u3002\u672C\u6B21\u53EA\u5904\u7406\u65F6\u95F4/\u5730\u70B9\uFF1B\u26D4 \u4E0D\u8981\u5728\u56DE\u590D\u91CC\u8BF4"\u6309 X \u6D41\u7A0B\u53D1\u8D77"\u2014\u2014\u56DB\u8981\u7D20\u5B9A\u5B8C\u540E CLI \u4F1A\u8FD4\u56DE\u6D41\u7A0B\u9009\u9879\u8BA9\u7528\u6237\u70B9\u3002`;
|
|
1114
|
+
const beginHasTime = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(beginText);
|
|
1115
|
+
const endHasTime = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(endText);
|
|
1116
|
+
if (beginHasTime && !endHasTime) {
|
|
1117
|
+
const duration = Number(args.durationMinutes) > 0 ? Math.round(Number(args.durationMinutes)) : 60;
|
|
1118
|
+
const startMs = Date.parse(beginText.slice(0, 16).replace(" ", "T"));
|
|
1119
|
+
if (Number.isFinite(startMs)) endText = formatMinute(new Date(startMs + duration * 6e4));
|
|
1120
|
+
}
|
|
1121
|
+
if (!beginHasTime || !timeConfirmed) {
|
|
1122
|
+
const day2 = /^\d{4}-\d{2}-\d{2}/.test(beginText) ? beginText.slice(0, 10) : String(args.dateFrom ?? "").trim().slice(0, 10) || tomorrowIso();
|
|
1123
|
+
const duration = Number(args.durationMinutes) > 0 ? Math.round(Number(args.durationMinutes)) : 60;
|
|
1124
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
1125
|
+
const suggested = await getMeetingOperation("meeting.eb.meeting.create.suggest").handler(
|
|
1126
|
+
{
|
|
1127
|
+
dateFrom: day2,
|
|
1128
|
+
durationMinutes: duration,
|
|
1129
|
+
hrm_members: memberIds.join(","),
|
|
1130
|
+
maxSlots: 3,
|
|
1131
|
+
topN: 3,
|
|
1132
|
+
...Number(args.total_member) > 0 ? { memberCount: Number(args.total_member) } : {},
|
|
1133
|
+
...args.workStartHour !== void 0 ? { workStartHour: Number(args.workStartHour) } : {},
|
|
1134
|
+
...args.workEndHour !== void 0 ? { workEndHour: Number(args.workEndHour) } : {}
|
|
1135
|
+
},
|
|
1136
|
+
env
|
|
1137
|
+
).catch((error) => ({ data: { slots: [] }, slotError: String(error?.message ?? error).slice(0, 160) }));
|
|
1138
|
+
const slotOptions2 = suggested?.data?.slots ?? [];
|
|
1139
|
+
const slotWarnings = [
|
|
1140
|
+
...suggested?.warnings ?? [],
|
|
1141
|
+
...suggested?.slotError ? [`\u65F6\u6BB5\u63A8\u8350\u672A\u8DD1\u6210\u529F\uFF1A${suggested.slotError}`] : [],
|
|
1142
|
+
...memberIds.length === 0 ? ['\u26A0\uFE0F \u6CA1\u6709\u53C2\u4F1A\u4EBA\u5458\uFF0C\u65E0\u6CD5\u6838\u9A8C"\u4EBA\u662F\u5426\u7A7A\u95F2" \u2014\u2014 \u4E0B\u9762\u53EA\u662F**\u4F1A\u8BAE\u5BA4\u6709\u7A7A**\u7684\u65F6\u6BB5\uFF0C\u8BF7\u5982\u5B9E\u8BF4\u660E\u3002'] : []
|
|
1143
|
+
];
|
|
1144
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1145
|
+
status: "NEEDS_SELECTION",
|
|
1146
|
+
selectionType: "slot",
|
|
1147
|
+
ui: { component: "choice", multiple: false, recommendedKey: "T1" },
|
|
1148
|
+
message: slotOptions2.length > 0 ? `${beginHasTime ? `\u4F60\u4F20\u5165\u7684\u65F6\u95F4 ${beginText}~${endText} **\u672A\u7ECF\u7528\u6237\u786E\u8BA4**\uFF08\u6CA1\u5E26 timeConfirmed\uFF09` : "\u6CA1\u6709\u7ED9\u51FA\u5177\u4F53\u65F6\u95F4"}\uFF0C\u5DF2\u6309\u53C2\u4F1A\u4EBA\u4E0E\u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u60C5\u51B5\u63A8\u8350 ${slotOptions2.length} \u4E2A\u65F6\u6BB5\uFF08${day2}\uFF0C\u65F6\u957F ${duration} \u5206\u949F\uFF09\u2014\u2014 \u26D4 \u5FC5\u987B\u8BA9\u7528\u6237\u5728\u9009\u9879\u91CC\u70B9\u9009\uFF0C**\u4E0D\u8981**\u628A\u4EFB\u4F55\u4E00\u4E2A\u5019\u9009\u5199\u6210"\u5DF2\u5B9A"\u6216\u653E\u8FDB\u786E\u8BA4\u6458\u8981` : `${beginHasTime ? `\u4F60\u4F20\u5165\u7684\u65F6\u95F4 ${beginText}~${endText} \u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF08\u6CA1\u5E26 timeConfirmed\uFF09` : "\u6CA1\u6709\u7ED9\u51FA\u5177\u4F53\u65F6\u95F4"}\uFF0C\u4E14 ${day2} \u6CA1\u80FD\u627E\u5230\u300C\u53C2\u4F1A\u4EBA\u7A7A\u95F2 + \u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u300D\u7684\u65F6\u6BB5\uFF0C\u8BF7\u8BA9\u7528\u6237\u6362\u4E2A\u65E5\u671F\u6216\u6307\u5B9A\u65F6\u95F4`,
|
|
1149
|
+
options: slotOptions2.map((slot, index) => ({
|
|
1150
|
+
key: `T${index + 1}`,
|
|
1151
|
+
label: String(slot.label ?? ""),
|
|
1152
|
+
// ⛔ 时间不在 slot 顶层,而在 slot.value 里(suggest 的返回结构)—— 取错会让调用方
|
|
1153
|
+
// 拿不到 begin/end,只能再问用户一次时间(2026-10-30 冒烟实测踩到)。
|
|
1154
|
+
// `timeConfirmed: true` 在这里是**关键**:用户点选后 value 原样回传,下一轮才被认作"已确认";
|
|
1155
|
+
// agent 自己编的时间不带这个标记,就永远停在选项这一步。
|
|
1156
|
+
value: {
|
|
1157
|
+
begin_datetime: String(slot.value?.begin ?? slot.begin ?? "").trim(),
|
|
1158
|
+
end_datetime: String(slot.value?.end ?? slot.end ?? "").trim(),
|
|
1159
|
+
address: slot.value?.address ?? null,
|
|
1160
|
+
timeConfirmed: true
|
|
1161
|
+
},
|
|
1162
|
+
reason: String(slot.reason ?? ""),
|
|
1163
|
+
rooms: slot.rooms ?? []
|
|
1164
|
+
})),
|
|
1165
|
+
day: day2,
|
|
1166
|
+
durationMinutes: duration,
|
|
1167
|
+
memberIds,
|
|
1168
|
+
// ⛔ 这里**不能**出现 workflowId:流程确认在四要素之后(2026-10-30 顺序调整)。
|
|
1169
|
+
// 返回 workflowId 会让 agent 误以为"流程已定",于是在回复里先讲流程、再问时间。
|
|
1170
|
+
workflowPending: true,
|
|
1171
|
+
hint: "\u9009\u5B9A\u540E\u628A value **\u6574\u4F53**\u539F\u6837\u5E26\u56DE\u91CD\u65B0\u8C03\u7528\uFF08\u542B timeConfirmed: true\uFF09\uFF1Baddress \u5DF2\u81EA\u52A8\u5E26\u4E0A\u8BE5\u65F6\u6BB5\u53EF\u7528\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u4ECD\u9700\u8BA9\u7528\u6237\u5355\u72EC\u786E\u8BA4\u6216\u7528 roomConfirmed: true"
|
|
1172
|
+
}, {
|
|
1173
|
+
warnings: [
|
|
1174
|
+
`${beginHasTime ? `\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\uFF1A\u4F60\u4F20\u5165\u7684\u65F6\u95F4 ${beginText}~${endText} \u6CA1\u6709\u7528\u6237\u786E\u8BA4\u6807\u8BB0\uFF08timeConfirmed\uFF09\uFF0C\u5DF2\u6539\u4E3A\u7ED9\u5019\u9009\u3002` : "\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\uFF1A\u65F6\u95F4\u672A\u786E\u5B9A\uFF08\u7F3A begin_datetime\uFF09\u3002"}\u5DF2\u6309 ${day2} \u63A8\u8350\u65F6\u6BB5\uFF0C\u8BF7\u7528\u9009\u9879\u8BA9\u7528\u6237\u6311\u4E00\u4E2A\u3002`,
|
|
1175
|
+
...slotWarnings,
|
|
1176
|
+
...earlyWorkflowNote ? [earlyWorkflowNote] : []
|
|
1177
|
+
]
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
let addressInput = args.address;
|
|
1181
|
+
const hadAddressInput = String(args.address ?? "").trim() !== "";
|
|
1182
|
+
const day = beginText.slice(0, 10);
|
|
1183
|
+
const durationMinutes = beginText && endText ? Math.max(15, Math.round((Date.parse(endText.replace(" ", "T")) - Date.parse(beginText.replace(" ", "T"))) / 6e4) || 60) : 60;
|
|
1184
|
+
const timings = {};
|
|
1185
|
+
const startedAt = Date.now();
|
|
1186
|
+
const enrichFailures = [];
|
|
1187
|
+
const noteFailure = (label) => (error) => {
|
|
1188
|
+
enrichFailures.push(`${label}\u672A\u5B8C\u6210\uFF1A${String(error?.message ?? error).slice(0, 120)}`);
|
|
1189
|
+
return null;
|
|
1190
|
+
};
|
|
1191
|
+
const needSelfPerson = String(args.caller ?? "").trim() === "" || String(args.contacter ?? "").trim() === "";
|
|
1192
|
+
const autoPerson = applySelfPersonDefaults(
|
|
1193
|
+
args,
|
|
1194
|
+
needSelfPerson ? await resolveSelfPerson(env) : null
|
|
1195
|
+
);
|
|
1196
|
+
const autoFilledPerson = autoPerson.filled;
|
|
1197
|
+
const selfPersonWarning = autoPerson.warning;
|
|
1198
|
+
const declaredTotal = Number(args.total_member) > 0 ? Number(args.total_member) : null;
|
|
1199
|
+
const callerToken = String(args.caller ?? "").trim();
|
|
1200
|
+
const callerInMembers = callerToken !== "" && (rawMembers.includes(callerToken) || memberIds.includes(callerToken));
|
|
1201
|
+
const roomMemberCount = declaredTotal ?? (memberIds.length > 0 ? memberIds.length + (callerInMembers ? 0 : 1) : void 0);
|
|
1202
|
+
const crmMentionedInText = detectCrmMentionInText(
|
|
1203
|
+
String(args.mt_name ?? ""),
|
|
1204
|
+
String(args.mt_desc ?? ""),
|
|
1205
|
+
String(args.other_remark ?? "")
|
|
1206
|
+
);
|
|
1207
|
+
const customerWords = /(接待|招待|客户|贵宾|来访)/u.test(
|
|
1208
|
+
`${String(args.mt_name ?? "")} ${String(args.mt_desc ?? "")} ${String(args.other_remark ?? "")}`
|
|
1209
|
+
);
|
|
1210
|
+
const hasCustomer = (Array.isArray(args.crm_members) ? args.crm_members.length > 0 : String(args.crm_members ?? "").trim() !== "") || Boolean(crmMentionedInText) || customerWords;
|
|
1211
|
+
const dayUsagesTask = enrich && beginText && endText ? loadDayUsages(env, day) : Promise.resolve(null);
|
|
1212
|
+
const roomTask = enrich && beginText && endText ? (async () => {
|
|
1213
|
+
const usageData = await dayUsagesTask;
|
|
1214
|
+
return recommendRooms(env, {
|
|
1215
|
+
beginDatetime: beginText,
|
|
1216
|
+
endDatetime: endText,
|
|
1217
|
+
...roomMemberCount ? { memberCount: roomMemberCount } : {},
|
|
1218
|
+
// 带客户时优先接待类会议室(2026-11-02 用户口径:加了客户就推接待类)
|
|
1219
|
+
...hasCustomer ? { hasCustomer: true } : {},
|
|
1220
|
+
// 2026-11-03 用户批准松绑:不再每次强制重拉台账(省 ~1s + 2 请求)。
|
|
1221
|
+
// 兜底在 recommendRooms 内部:24h 缓存凑不出候选时自动强制重拉一次再算;
|
|
1222
|
+
// 代价是刚导入的会议室在缓存期可能按名称查不到(按 id 指定不受影响)。
|
|
1223
|
+
topN: 3,
|
|
1224
|
+
// 占用走全天缓存(usageData 为 null 时 recommendRooms 内部自己查,行为不变)
|
|
1225
|
+
...usageData ? { dayUsages: usageData.rows } : {}
|
|
1226
|
+
});
|
|
1227
|
+
})().catch(noteFailure("\u4F1A\u8BAE\u5BA4\u63A8\u8350")) : Promise.resolve(null);
|
|
1228
|
+
const addressId = String(addressInput ?? "").trim();
|
|
1229
|
+
const roomConfirmed = args.roomConfirmed === true;
|
|
1230
|
+
const roomConflictTask = enrich && beginText && endText && addressId !== "" ? (async () => {
|
|
1231
|
+
const room = await resolveAddressRoom(env, addressId);
|
|
1232
|
+
if (!room) return { unresolved: true, input: addressId };
|
|
1233
|
+
if (!room.id || room.lookupFailed || room.status !== "0") return { room };
|
|
1234
|
+
const usageData = await dayUsagesTask.catch(() => null);
|
|
1235
|
+
if (usageData) {
|
|
1236
|
+
const conflicts = filterUsages(usageData.rows, { roomId: room.id, begin: beginText, end: endText }).map((usage) => ({ mtId: usage.mtId, begin: usage.start, end: usage.end }));
|
|
1237
|
+
return {
|
|
1238
|
+
room,
|
|
1239
|
+
hasConflict: conflicts.length > 0,
|
|
1240
|
+
conflicts,
|
|
1241
|
+
verdict: conflicts.length > 0 ? "warn" : "ok",
|
|
1242
|
+
requests: usageData.requests,
|
|
1243
|
+
usageFromCache: usageData.fromCache
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
1247
|
+
const result = await getMeetingOperation("meeting.eb.conflict.room").handler(
|
|
1248
|
+
{ beginDatetime: beginText, endDatetime: endText, address: room.id },
|
|
1249
|
+
env
|
|
1250
|
+
);
|
|
1251
|
+
return { room, ...result?.data ?? {} };
|
|
1252
|
+
})().catch(noteFailure("\u4F1A\u8BAE\u5BA4**\u5360\u7528**\u68C0\u6D4B")) : Promise.resolve(null);
|
|
1253
|
+
const conflictTask = enrich && beginText && endText && memberIds.length > 0 ? (async () => {
|
|
1254
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
1255
|
+
return getMeetingOperation("meeting.eb.conflict.member").handler(
|
|
1256
|
+
{ beginDatetime: beginText, endDatetime: endText, hrmMembers: memberIds.join(",") },
|
|
1257
|
+
env
|
|
1258
|
+
);
|
|
1259
|
+
})().catch(noteFailure("\u53C2\u4F1A\u4EBA**\u4F1A\u8BAE\u5360\u7528**\u68C0\u6D4B")) : Promise.resolve(null);
|
|
1260
|
+
const availabilityTask = enrich && beginText && endText && memberIds.length > 0 ? findCommonFreeSlots(env, {
|
|
1261
|
+
rangeStart: `${day} 00:00`,
|
|
1262
|
+
rangeEnd: `${day} 23:59`,
|
|
1263
|
+
durationMinutes,
|
|
1264
|
+
members: memberIds,
|
|
1265
|
+
maxSlots: 3,
|
|
1266
|
+
maxDays: 1,
|
|
1267
|
+
includeSchedule: true
|
|
1268
|
+
}).catch(noteFailure("\u53C2\u4F1A\u4EBA**\u65E5\u7A0B\u7A7A\u95F2**\u68C0\u6D4B")) : Promise.resolve(null);
|
|
1269
|
+
const [roomRec, memberConflict, free, roomConflict] = await Promise.all([
|
|
1270
|
+
roomTask,
|
|
1271
|
+
conflictTask,
|
|
1272
|
+
availabilityTask,
|
|
1273
|
+
roomConflictTask
|
|
1274
|
+
]);
|
|
1275
|
+
timings.parallelMs = Date.now() - startedAt;
|
|
1276
|
+
const memberConflicts = memberConflict?.data?.conflicts ?? [];
|
|
1277
|
+
if (memberConflicts.length > 0) decisions.memberConflicts = memberConflicts;
|
|
1278
|
+
const freeSlots = free?.slots ?? [];
|
|
1279
|
+
if (free) {
|
|
1280
|
+
decisions.scheduleItems = free.scheduleItems;
|
|
1281
|
+
decisions.availabilityCost = free.cost;
|
|
1282
|
+
if (freeSlots.length > 0) {
|
|
1283
|
+
decisions.suggestedSlots = freeSlots;
|
|
1284
|
+
decisions.slotOptions = freeSlots.map((slot, index) => ({
|
|
1285
|
+
key: `T${index + 1}`,
|
|
1286
|
+
label: `${slot.begin.slice(11)}~${slot.end.slice(11)}\uFF08${day}\uFF09 \xB7 \u5168\u90E8\u53C2\u4F1A\u4EBA\u7A7A\u95F2`,
|
|
1287
|
+
value: { begin: slot.begin, end: slot.end },
|
|
1288
|
+
reason: "\u8BE5\u65F6\u6BB5\u6240\u6709\u53C2\u4F1A\u4EBA\u90FD\u6CA1\u6709\u4F1A\u8BAE\u4E0E\u65E5\u7A0B\u5360\u7528\uFF08\u5DF2\u540C\u65F6\u6838\u5BF9\u4F1A\u8BAE\u56DE\u6267\u4E0E\u65E5\u7A0B\uFF09"
|
|
1289
|
+
}));
|
|
1290
|
+
} else if (free.blockingSummary) {
|
|
1291
|
+
decisions.dayBlocked = { day, summary: free.blockingSummary };
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
const conflictBrief = {
|
|
1295
|
+
memberConflicts,
|
|
1296
|
+
suggestedSlots: freeSlots,
|
|
1297
|
+
...enrichFailures.length > 0 ? { enrichFailures } : {}
|
|
1298
|
+
};
|
|
1299
|
+
const failureWarnings = enrichFailures.map(
|
|
1300
|
+
(failure) => `\u26A0\uFE0F ${failure} \u2014\u2014 **\u8FD9\u4E0D\u4EE3\u8868\u6CA1\u6709\u51B2\u7A81**\uFF0C\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\u8BE5\u9879\u672A\u6838\u9A8C\uFF0C\u4E0D\u8981\u58F0\u79F0"\u65F6\u95F4\u5DF2\u786E\u8BA4\u7A7A\u95F2"`
|
|
1301
|
+
);
|
|
1302
|
+
const roomOptions = (roomRec?.candidates ?? []).map((candidate, index) => ({
|
|
1303
|
+
key: `R${index + 1}`,
|
|
1304
|
+
label: `${candidate.name}${candidate.capacity.max > 0 ? `\uFF08\u53EF\u5BB9 ${candidate.capacity.max} \u4EBA\uFF09` : ""}${index === 0 ? " \xB7 \u63A8\u8350" : ""}`,
|
|
1305
|
+
// roomConfirmed: true = 用户点选该选项即代表"确认用这间",原样回传后下一轮才被认。
|
|
1306
|
+
value: { id: candidate.id, name: candidate.name, roomConfirmed: true },
|
|
1307
|
+
reason: candidate.reasons.join("\uFF1B")
|
|
1308
|
+
}));
|
|
1309
|
+
const roomConflictData = roomConflict;
|
|
1310
|
+
const resolvedAddress = roomConflictData?.room ?? null;
|
|
1311
|
+
const resolvedAddressId = resolvedAddress?.id || addressId;
|
|
1312
|
+
const addressDisplay = resolvedAddress?.name || addressId;
|
|
1313
|
+
if (roomConflictData?.unresolved === true) {
|
|
1314
|
+
decisions.roomNotFound = { input: addressId, candidates: roomOptions.length };
|
|
1315
|
+
if (roomOptions.length > 0) decisions.roomOptions = roomOptions;
|
|
1316
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1317
|
+
status: "NEEDS_SELECTION",
|
|
1318
|
+
selectionType: "room",
|
|
1319
|
+
ui: { component: "choice", multiple: false, recommendedKey: "R1" },
|
|
1320
|
+
message: `\u6CA1\u627E\u5230\u540D\u4E3A\u300C${addressId}\u300D\u7684\u4F1A\u8BAE\u5BA4\uFF08\u4F1A\u8BAE\u5BA4\u53F0\u8D26\u91CC\u6CA1\u6709\u8FD9\u4E2A\u540D\u5B57\uFF09\uFF0C\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002` + (roomOptions.length > 0 ? `\u8BF7\u4ECE\u4E0B\u9762 ${roomOptions.length} \u4E2A\u5728\u8BE5\u65F6\u6BB5\u7A7A\u95F2\u7684\u4F1A\u8BAE\u5BA4\u91CC\u9009\u4E00\u95F4\uFF0C\u6216\u6838\u5BF9\u4E00\u4E0B\u4F1A\u8BAE\u5BA4\u540D\u79F0` : "\u8BE5\u65F6\u6BB5\u4E5F\u6CA1\u6709\u53EF\u7528\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\uFF0C\u8BF7\u6539\u4F1A\u8BAE\u65F6\u95F4\u6216\u6539\u7EBF\u4E0A\u4F1A\u8BAE\uFF08allowNoRoom: true\uFF09"),
|
|
1321
|
+
workflowPending: true,
|
|
1322
|
+
options: roomOptions,
|
|
1323
|
+
recommended: roomOptions[0]?.value ?? null,
|
|
1324
|
+
roomNotFound: decisions.roomNotFound,
|
|
1325
|
+
hint: "\u9009\u5B9A\u540E\u628A value **\u6574\u4F53**\u539F\u6837\u5E26\u56DE\uFF08\u542B roomConfirmed: true\uFF09\uFF1B\u6838\u5BF9\u540D\u79F0\u53EF\u7528 `meeting.eb.room.list` \u770B\u5168\u91CF\u6E05\u5355"
|
|
1326
|
+
}, {
|
|
1327
|
+
warnings: [
|
|
1328
|
+
`\u4F1A\u8BAE\u5BA4\u300C${addressId}\u300D\u5728\u53F0\u8D26\u91CC\u4E0D\u5B58\u5728\uFF0C\u5DF2\u62E6\u4E0B\u672A\u63D0\u4EA4\u3002`,
|
|
1329
|
+
'\u26D4 \u4E0D\u8981\u628A\u5B83\u5F53\u6210"\u7528\u6237\u6307\u5B9A\u7684\u623F\u95F4"\u5199\u8FDB\u786E\u8BA4\u6458\u8981 \u2014\u2014 \u8FD9\u95F4\u623F\u6839\u672C\u6CA1\u6709\u88AB\u89E3\u6790\u51FA\u6765\u3002'
|
|
1330
|
+
]
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
if (resolvedAddress && resolvedAddress.status === "1") {
|
|
1334
|
+
decisions.roomSealed = { id: resolvedAddress.id, name: resolvedAddress.name };
|
|
1335
|
+
if (roomOptions.length > 0) decisions.roomOptions = roomOptions;
|
|
1336
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1337
|
+
status: "NEEDS_SELECTION",
|
|
1338
|
+
selectionType: "room",
|
|
1339
|
+
ui: { component: "choice", multiple: false, recommendedKey: "R1" },
|
|
1340
|
+
message: `\u4F1A\u8BAE\u5BA4\u300C${resolvedAddress.name}\u300D\u5F53\u524D\u662F**\u5C01\u5B58**\u72B6\u6001\uFF08\u4E0D\u53EF\u9884\u7EA6\uFF09\uFF0C\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002` + (roomOptions.length > 0 ? "\u8BF7\u6539\u7528\u4E0B\u9762\u7A7A\u95F2\u7684\u4F1A\u8BAE\u5BA4" : "\u8BE5\u65F6\u6BB5\u6CA1\u6709\u5176\u5B83\u53EF\u7528\u4F1A\u8BAE\u5BA4\uFF0C\u8BF7\u6539\u4F1A\u8BAE\u65F6\u95F4"),
|
|
1341
|
+
workflowPending: true,
|
|
1342
|
+
options: roomOptions,
|
|
1343
|
+
recommended: roomOptions[0]?.value ?? null,
|
|
1344
|
+
roomSealed: decisions.roomSealed
|
|
1345
|
+
}, {
|
|
1346
|
+
warnings: [`\u4F1A\u8BAE\u5BA4\u300C${resolvedAddress.name}\u300D\uFF08${resolvedAddress.id}\uFF09\u5DF2\u5C01\u5B58\uFF0C\u4E0D\u53EF\u9884\u7EA6\uFF0C\u5DF2\u62E6\u4E0B\u672A\u63D0\u4EA4\u3002`]
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
if (addressInput && roomConfirmed && roomConflictData?.hasConflict === true) {
|
|
1350
|
+
const busy = Array.isArray(roomConflictData.conflicts) ? roomConflictData.conflicts : [];
|
|
1351
|
+
decisions.roomConflict = {
|
|
1352
|
+
address: resolvedAddressId,
|
|
1353
|
+
addressName: addressDisplay,
|
|
1354
|
+
hasConflict: true,
|
|
1355
|
+
conflicts: busy,
|
|
1356
|
+
verdict: roomConflictData.verdict ?? "conflict"
|
|
1357
|
+
};
|
|
1358
|
+
if (roomOptions.length > 0) decisions.roomOptions = roomOptions;
|
|
1359
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1360
|
+
status: "NEEDS_SELECTION",
|
|
1361
|
+
selectionType: "room_conflict",
|
|
1362
|
+
ui: { component: "choice", multiple: false, recommendedKey: "R1" },
|
|
1363
|
+
message: `\u4F60\u6307\u5B9A\u7684\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D\u5728 ${beginText}~${endText} \u5DF2\u88AB\u5360\u7528\uFF08${busy.length} \u6761\u5360\u7528\u8BB0\u5F55\uFF09\uFF0C\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002\u8BF7\u6539\u7528\u4E0B\u9762\u7A7A\u95F2\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u6216\u8C03\u6574\u4F1A\u8BAE\u65F6\u95F4`,
|
|
1364
|
+
workflowPending: true,
|
|
1365
|
+
options: roomOptions,
|
|
1366
|
+
recommended: roomOptions[0]?.value ?? null,
|
|
1367
|
+
conflicts: busy,
|
|
1368
|
+
roomConflict: decisions.roomConflict,
|
|
1369
|
+
hint: "\u9009\u5B9A\u540E\u628A value.id \u4F5C\u4E3A address \u91CD\u65B0\u8C03\u7528\uFF1B\u8981\u6539\u65F6\u95F4\u5C31\u540C\u65F6\u4F20\u65B0\u7684 begin_datetime/end_datetime"
|
|
1370
|
+
}, {
|
|
1371
|
+
warnings: [
|
|
1372
|
+
`\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D\uFF08${resolvedAddressId}\uFF09\u5728\u8BE5\u65F6\u6BB5\u5DF2\u6709 ${busy.length} \u6761\u5360\u7528\uFF0C\u5DF2\u62E6\u4E0B\u672A\u63D0\u4EA4\u3002`,
|
|
1373
|
+
roomOptions.length > 0 ? `\u5DF2\u6309\u4EBA\u6570/\u5E38\u7528/\u7A7A\u95F2\u7ED9\u51FA ${roomOptions.length} \u4E2A\u66FF\u4EE3\u4F1A\u8BAE\u5BA4\uFF08R1 \u4E3A\u9996\u9009\uFF09\u3002` : "\u8BE5\u65F6\u6BB5\u6CA1\u6709\u53EF\u66FF\u4EE3\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\uFF0C\u5EFA\u8BAE\u8C03\u6574\u4F1A\u8BAE\u65F6\u95F4\u6216\u6539\u7EBF\u4E0A\u4F1A\u8BAE\uFF08allowNoRoom: true\uFF09\u3002"
|
|
1374
|
+
]
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
if (roomRec) {
|
|
1378
|
+
decisions.roomOptions = roomOptions;
|
|
1379
|
+
decisions.autoRoom = {
|
|
1380
|
+
picked: roomRec.best ? { id: roomRec.best.id, name: roomRec.best.name, score: roomRec.best.score, reasons: roomRec.best.reasons } : null,
|
|
1381
|
+
candidates: roomRec.candidates,
|
|
1382
|
+
meta: roomRec.meta
|
|
1383
|
+
};
|
|
1384
|
+
const autoRoom = args.autoRoom === true;
|
|
1385
|
+
const needRoomPick = !addressInput || !roomConfirmed;
|
|
1386
|
+
let pickOptions = roomOptions;
|
|
1387
|
+
if (addressInput && !roomConfirmed) {
|
|
1388
|
+
const hit = roomOptions.find((item) => String(item.value?.id) === resolvedAddressId);
|
|
1389
|
+
const specified = hit ? { ...hit, label: `${hit.label}\uFF08\u4F60\u6307\u5B9A\u7684\uFF0C\u5F85\u786E\u8BA4\uFF09`, value: { ...hit.value, roomConfirmed: true } } : {
|
|
1390
|
+
key: "R0",
|
|
1391
|
+
label: `${addressDisplay}\uFF08\u4F60\u6307\u5B9A\u7684\uFF0C\u5F85\u786E\u8BA4\uFF09`,
|
|
1392
|
+
value: { ...resolvedAddressId ? { id: resolvedAddressId } : {}, name: addressDisplay, roomConfirmed: true },
|
|
1393
|
+
reason: "\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u672A\u63D0\u4EA4\u3001\u672A\u786E\u8BA4"
|
|
1394
|
+
};
|
|
1395
|
+
pickOptions = [specified, ...roomOptions.filter((item) => String(item.value?.id) !== resolvedAddressId)].map((item, index) => ({ ...item, key: `R${index + 1}` }));
|
|
1396
|
+
}
|
|
1397
|
+
if (needRoomPick && !autoRoom && pickOptions.length > 0 && args.allowNoRoom !== true) {
|
|
1398
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1399
|
+
status: "NEEDS_SELECTION",
|
|
1400
|
+
selectionType: "room",
|
|
1401
|
+
ui: { component: "choice", multiple: false, recommendedKey: "R1" },
|
|
1402
|
+
message: addressInput ? `\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D**\u672A\u7ECF\u7528\u6237\u786E\u8BA4**\uFF08\u6CA1\u5E26 roomConfirmed\uFF09\uFF0C\u5DF2\u628A\u5B83\u548C\u5176\u5B83\u5019\u9009\u4E00\u8D77\u5217\u51FA\u6765 \u2014\u2014 \u26D4 \u5FC5\u987B\u8BA9\u7528\u6237\u5728\u9009\u9879\u91CC\u70B9\u9009\uFF0C\u4E0D\u8981\u76F4\u63A5\u63D0\u4EA4` : `\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\uFF0C\u8BF7\u4ECE ${pickOptions.length} \u4E2A\u5019\u9009\u91CC\u9009\u62E9\uFF08\u5DF2\u6309\u4EBA\u6570/\u5E38\u7528/\u65F6\u6BB5\u5360\u7528\u6392\u5E8F\uFF09`,
|
|
1403
|
+
// 固化自动选的流程要带出来:调用方下一轮带 address 重调时不用再猜用的是哪条流程。
|
|
1404
|
+
workflowPending: true,
|
|
1405
|
+
options: pickOptions,
|
|
1406
|
+
recommended: pickOptions[0]?.value ?? null,
|
|
1407
|
+
hint: "\u9009\u5B9A\u540E\u628A value **\u6574\u4F53**\u539F\u6837\u5E26\u56DE\uFF08\u542B roomConfirmed: true\uFF09\uFF1B\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\u8BF7\u4F20 allowNoRoom: true",
|
|
1408
|
+
...conflictBrief
|
|
1409
|
+
}, {
|
|
1410
|
+
warnings: [
|
|
1411
|
+
addressInput ? `\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D\u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF1A\u672C\u6B21**\u6CA1\u6709**\u63D0\u4EA4\u3002` : "\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\uFF1A\u672C\u6B21**\u6CA1\u6709**\u63D0\u4EA4\uFF0C\u4E5F\u6CA1\u6709\u66FF\u7528\u6237\u6311\u623F\u95F4\u3002",
|
|
1412
|
+
"\u5982\u9700\u76F4\u63A5\u5EFA\u4F1A\u5E76\u6CBF\u7528\u63A8\u8350\uFF0C\u53EF\u4F20 autoRoom: true\uFF1B\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\u5219\u4F20 allowNoRoom: true\u3002",
|
|
1413
|
+
...earlyWorkflowNote ? [earlyWorkflowNote] : [],
|
|
1414
|
+
...memberConflicts.length > 0 ? [`\u26A0\uFE0F \u6CE8\u610F\uFF1A\u53C2\u4F1A\u4EBA\u5728\u8BE5\u65F6\u6BB5\u5DF2\u6709 ${memberConflicts.length} \u573A\u4F1A\u8BAE\u51B2\u7A81 \u2014\u2014 \u9009\u623F\u524D\u5148\u628A\u8FD9\u6761\u544A\u8BC9\u7528\u6237\uFF0C\u522B\u8BA9\u4ED6\u9009\u5B8C\u624D\u53D1\u73B0\u3002`] : [],
|
|
1415
|
+
...freeSlots.length > 0 ? [`\u5F53\u5929\u5168\u90E8\u53C2\u4F1A\u4EBA\u90FD\u7A7A\u95F2\u7684\u65F6\u6BB5\uFF1A${freeSlots.map((s) => `${s.begin.slice(11)}~${s.end.slice(11)}`).join("\u3001")}`] : [],
|
|
1416
|
+
...failureWarnings
|
|
1417
|
+
]
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
if (addressInput) {
|
|
1421
|
+
} else if (autoRoom && roomRec.best) {
|
|
1422
|
+
addressInput = roomRec.best.id;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
if (enrich && !addressInput && args.allowNoRoom !== true) {
|
|
1426
|
+
decisions.roomUnavailable = {
|
|
1427
|
+
reason: roomRec ? `\u8BE5\u65F6\u6BB5\u6CA1\u6709\u6EE1\u8DB3\u6761\u4EF6\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\uFF08\u5171 ${roomRec.meta?.roomsTotal ?? 0} \u95F4\uFF0C\u53EF\u7528 ${roomRec.meta?.roomsUsable ?? 0} \u95F4\uFF0C\u88AB\u5360\u7528 ${roomRec.meta?.roomsBusy ?? 0} \u95F4\uFF09` : "\u4F1A\u8BAE\u5BA4\u63A8\u8350\u6CA1\u6709\u8FD4\u56DE\u7ED3\u679C\uFF08\u4F1A\u8BAE\u5BA4\u5217\u8868\u63A5\u53E3\u8BFB\u4E0D\u5230\uFF0C\u6216\u63A8\u8350\u8FC7\u7A0B\u51FA\u9519\uFF09",
|
|
1428
|
+
meta: roomRec?.meta ?? null
|
|
1429
|
+
};
|
|
1430
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1431
|
+
status: "NEEDS_SELECTION",
|
|
1432
|
+
selectionType: "room_unavailable",
|
|
1433
|
+
ui: { component: "choice", multiple: false, recommendedKey: "C2" },
|
|
1434
|
+
message: "\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\uFF0C\u4E14\u6309\u4EBA\u6570/\u65F6\u6BB5\u6CA1\u80FD\u63A8\u8350\u51FA\u53EF\u7528\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\u3002\u8BF7\u8BA9\u7528\u6237\u4ECE\u4E0B\u9762\u4E09\u6761\u91CC\u9009\u4E00\u6761\uFF0C**\u4E0D\u8981**\u76F4\u63A5\u63D0\u4EA4\u4E00\u4E2A\u6CA1\u6709\u5730\u70B9\u7684\u4F1A\u8BAE",
|
|
1435
|
+
workflowPending: true,
|
|
1436
|
+
options: [
|
|
1437
|
+
{ key: "C1", label: "\u6211\u6307\u5B9A\u5177\u4F53\u4F1A\u8BAE\u5BA4\uFF08\u8868\u5355\u91CC\u70B9\u9009\uFF0C\u6216\u544A\u8BC9\u6211\u4F1A\u8BAE\u5BA4\u540D\u79F0/id\uFF09", value: { action: "specify" } },
|
|
1438
|
+
{ key: "C2", label: "\u6539\u7528\u7EBF\u4E0A\u4F1A\u8BAE\uFF08\u817E\u8BAF\u4F1A\u8BAE/\u89C6\u9891\uFF09", value: { action: "no_room" } },
|
|
1439
|
+
{ key: "C3", label: '\u5148\u6309"\u5730\u70B9\u5F85\u5B9A"\u63D0\u4EA4', value: { action: "allow_no_room" } }
|
|
1440
|
+
],
|
|
1441
|
+
roomUnavailable: decisions.roomUnavailable,
|
|
1442
|
+
...conflictBrief
|
|
1443
|
+
}, {
|
|
1444
|
+
warnings: [
|
|
1445
|
+
`\u4F1A\u8BAE\u5BA4\u63A8\u8350\u65E0\u7ED3\u679C\uFF1A${String(decisions.roomUnavailable.reason)}\u3002\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002`,
|
|
1446
|
+
"\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\uFF08\u7EBF\u4E0A\u4F1A\uFF09\u5C31\u5E26 allowNoRoom: true \u91CD\u65B0\u8C03\u7528\uFF1B\u8981\u6307\u5B9A\u623F\u95F4\u5C31\u5E26 address\u3002",
|
|
1447
|
+
...memberConflicts.length > 0 ? [`\u26A0\uFE0F \u53E6\u5916\uFF1A\u53C2\u4F1A\u4EBA\u5728\u8BE5\u65F6\u6BB5\u5DF2\u6709 ${memberConflicts.length} \u573A\u4F1A\u8BAE\u51B2\u7A81 \u2014\u2014 \u6362\u65F6\u95F4\u53EF\u80FD\u6BD4\u6362\u623F\u95F4\u66F4\u5212\u7B97\u3002`] : [],
|
|
1448
|
+
...freeSlots.length > 0 ? [`\u5F53\u5929\u5168\u90E8\u53C2\u4F1A\u4EBA\u90FD\u7A7A\u95F2\u7684\u65F6\u6BB5\uFF1A${freeSlots.map((s) => `${s.begin.slice(11)}~${s.end.slice(11)}`).join("\u3001")}`] : [],
|
|
1449
|
+
...failureWarnings
|
|
1450
|
+
]
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
if (enrich && addressInput && !roomConfirmed && roomOptions.length === 0 && args.allowNoRoom !== true) {
|
|
1454
|
+
const specified = {
|
|
1455
|
+
key: "R1",
|
|
1456
|
+
label: `${addressDisplay}\uFF08\u4F60\u6307\u5B9A\u7684\uFF0C\u5F85\u786E\u8BA4\uFF09`,
|
|
1457
|
+
value: { ...resolvedAddressId ? { id: resolvedAddressId } : {}, name: addressDisplay, roomConfirmed: true },
|
|
1458
|
+
reason: "\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u672A\u63D0\u4EA4\u3001\u672A\u786E\u8BA4"
|
|
1459
|
+
};
|
|
1460
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1461
|
+
status: "NEEDS_SELECTION",
|
|
1462
|
+
selectionType: "room",
|
|
1463
|
+
ui: { component: "choice", multiple: false, recommendedKey: "R1" },
|
|
1464
|
+
message: "\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF0C\u4E14\u672C\u6B21\u6CA1\u80FD\u63A8\u8350\u51FA\u5176\u5B83\u5019\u9009 \u2014\u2014 \u8BF7\u8BA9\u7528\u6237\u786E\u8BA4\u8FD9\u4E00\u95F4\uFF0C\u6216\u6362\u4E00\u95F4 / \u6539\u65F6\u6BB5",
|
|
1465
|
+
workflowPending: true,
|
|
1466
|
+
options: [specified],
|
|
1467
|
+
recommended: specified.value,
|
|
1468
|
+
hint: "\u7528\u6237\u786E\u8BA4\u7528\u8FD9\u95F4\u5C31\u628A value \u539F\u6837\u5E26\u56DE\uFF08\u542B roomConfirmed: true\uFF09"
|
|
1469
|
+
}, {
|
|
1470
|
+
warnings: ["\u4F1A\u8BAE\u5BA4\u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF0C\u672C\u6B21**\u6CA1\u6709**\u63D0\u4EA4\u3002", ...failureWarnings]
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
const resolved = await resolveWorkflowId(env, args);
|
|
1474
|
+
const confirmedAddressId = resolvedAddressId;
|
|
1475
|
+
const confirmedAddressLabel = addressId === "" ? "" : resolvedAddress?.name || String(roomOptions.find((item) => String(item.value?.id ?? "") === confirmedAddressId)?.value?.name ?? "") || addressId;
|
|
1476
|
+
const confirmedWhen = `${beginText}~${String(endText).slice(11) || endText}`;
|
|
1477
|
+
let candidates = resolved.candidates;
|
|
1478
|
+
workflowId = resolved.workflowId;
|
|
1479
|
+
let sourceLabel = resolved.source === "argument" ? "\u8C03\u7528\u65B9\u4F20\u5165" : resolved.source === "fixed" ? `\u56FA\u5316\u914D\u7F6E\uFF08${resolved.label ?? "\u9ED8\u8BA4"}\uFF09` : "\u5E94\u7528\u8BBE\u7F6E\u914D\u7F6E";
|
|
1480
|
+
let probes = [];
|
|
1481
|
+
let loadedForms = /* @__PURE__ */ new Map();
|
|
1482
|
+
const autoPick = shouldAutoPickFlow(args);
|
|
1483
|
+
if (!workflowId && candidates.length > 1) {
|
|
1484
|
+
let probed = await probeWorkflowCandidates(env, candidates);
|
|
1485
|
+
probes = probed.probes;
|
|
1486
|
+
loadedForms = probed.loadedForms;
|
|
1487
|
+
let launchable = probes.filter((probe) => probe.launchable);
|
|
1488
|
+
if (launchable.length === 0 && resolved.source === "fixed") {
|
|
1489
|
+
const settings = await fetchEbAppSettings(env, "meeting.eb.meeting.create.flow.prepare");
|
|
1490
|
+
const fallbackIds = String(settings.mtNewWf ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
|
|
1491
|
+
if (fallbackIds.length > 0) {
|
|
1492
|
+
probed = await probeWorkflowCandidates(env, fallbackIds);
|
|
1493
|
+
probes = probed.probes;
|
|
1494
|
+
loadedForms = probed.loadedForms;
|
|
1495
|
+
candidates = fallbackIds;
|
|
1496
|
+
sourceLabel = "\u5E94\u7528\u8BBE\u7F6E\u914D\u7F6E";
|
|
1497
|
+
launchable = probes.filter((probe) => probe.launchable);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
if (launchable.length === 0) {
|
|
1501
|
+
throw meetingValidationError(
|
|
1502
|
+
"flow_not_launchable",
|
|
1503
|
+
`\u5F53\u524D\u8D26\u53F7**\u6CA1\u6709\u53D1\u8D77\u5EFA\u4F1A\u6D41\u7A0B\u7684\u6743\u9650**\uFF1A${sourceLabel}\u7684 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\u90FD\u53D1\u8D77\u4E0D\u4E86\uFF08\u65E0\u53D1\u8D77\u6743\u9650\u6216\u6D41\u7A0B\u5DF2\u505C\u7528\uFF09\u2014\u2014${probes.map((probe) => `${probe.workflowId}\uFF08${probe.reason ?? "\u4E0D\u53EF\u53D1\u8D77"}\uFF09`).join("\uFF1B")}\u3002\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\uFF1A\u9700\u8981\u627E\u7BA1\u7406\u5458\u5F00\u901A\u8BE5\u6D41\u7A0B\u7684\u53D1\u8D77\u6743\u9650\uFF0C\u6216\u8BF7\u6709\u6743\u9650\u7684\u540C\u4E8B\u4EE3\u4E3A\u53D1\u8D77\uFF1B**\u4E0D\u8981**\u6539\u7528\u76F4\u8FDE\u5EFA\u4F1A\u7ED5\u8FC7\u6D41\u7A0B\u7BA1\u63A7\u3002`,
|
|
1504
|
+
{ probes }
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
if (launchable.length > 1 && !autoPick) {
|
|
1508
|
+
const remembered = args.flowChoice === "ask" ? null : await readFlowPick(env).catch(() => null);
|
|
1509
|
+
const rememberedHit = pickRememberedFlow(launchable, remembered);
|
|
1510
|
+
if (rememberedHit) {
|
|
1511
|
+
workflowId = rememberedHit.workflowId;
|
|
1512
|
+
const others = launchable.filter((probe) => probe.workflowId !== rememberedHit.workflowId).map((probe) => probe.name ? `${probe.name}\uFF08${probe.workflowId}\uFF09` : probe.workflowId);
|
|
1513
|
+
flowPickNote = `${sourceLabel}\uFF1A\u5F53\u524D\u8D26\u53F7\u53EF\u53D1\u8D77 ${launchable.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5DF2\u6CBF\u7528\u4F60\u4E0A\u6B21\u9009\u7684\u300C${rememberedHit.name ?? rememberedHit.workflowId}\u300D\uFF08${rememberedHit.workflowId}\uFF09\u53D1\u8D77 \u2014\u2014 \u8981\u6362\u7684\u8BDD\u8BF4\u4E00\u58F0${others.length > 0 ? `\uFF08\u5176\u4ED6\u53EF\u7528\uFF1A${others.join("\u3001")}\uFF09` : ""}\u3002`;
|
|
1514
|
+
} else {
|
|
1515
|
+
return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
|
|
1516
|
+
status: "NEEDS_SELECTION",
|
|
1517
|
+
// ⚠️ 以前漏了这个字段(agent 拿到 undefined 无法判断是哪类选择,2026-10-30 真机发现)。
|
|
1518
|
+
selectionType: "flow",
|
|
1519
|
+
// 明确告诉调用方"这是一道选择题,请用选项控件呈现",不要降级成文本列表
|
|
1520
|
+
// (2026-10-30 用户反馈:agent 把会议室候选写成文本 + "需要你指定一间",没给选项卡)。
|
|
1521
|
+
ui: { component: "choice", multiple: false, recommendedKey: "W1" },
|
|
1522
|
+
// 四要素已经确认到这一步了:摘要一起给出去,用户只需点一下流程,就能直接提交。
|
|
1523
|
+
confirmed: {
|
|
1524
|
+
mt_name: String(args.mt_name ?? ""),
|
|
1525
|
+
begin_datetime: beginText,
|
|
1526
|
+
end_datetime: endText,
|
|
1527
|
+
address: confirmedAddressId || null,
|
|
1528
|
+
addressName: confirmedAddressLabel || null,
|
|
1529
|
+
hrm_members: memberIds
|
|
1530
|
+
},
|
|
1531
|
+
message: `\u4F1A\u8BAE\u8981\u7D20\u5DF2\u786E\u8BA4\uFF08${String(args.mt_name ?? "")} \xB7 ${confirmedWhen}${confirmedAddressLabel ? ` \xB7 ${confirmedAddressLabel}` : " \xB7 \u65E0\u4F1A\u8BAE\u5BA4"}\uFF09\uFF1B\u5F53\u524D\u8D26\u53F7\u5BF9 ${sourceLabel}\u7684 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B**\u90FD\u6709\u53D1\u8D77\u6743\u9650**\uFF0C\u8BF7\u8BA9\u7528\u6237\u6700\u540E\u9009\u4E00\u4E0B\u300C\u7528\u54EA\u6761\u6D41\u7A0B\u53D1\u8D77\u300D\u2014\u2014 **\u4E0D\u8981\u9ED8\u8BA4\u53D6\u7B2C\u4E00\u4E2A**\uFF08\u5404\u6D41\u7A0B\u8868\u5355\u5B57\u6BB5\u53EF\u80FD\u5B8C\u5168\u4E0D\u540C\uFF0C\u9009\u9519\u4F1A\u6F0F\u5B57\u6BB5\uFF1B2026-10-29 \u771F\u5B9E\u4E8B\u6545\uFF1A\u53D6\u7B2C\u4E00\u4E2A\u5BFC\u81F4\u5B57\u6BB5\u5168\u586B\u4E0D\u8FDB\u53E6\u4E00\u6761\u6D41\u7A0B\uFF0C\u7528\u6237\u4EE5\u4E3A"\u7CFB\u7EDF\u53EA\u652F\u6301\u4E00\u6761\u6D41\u7A0B"\uFF09\u3002\u26A0\uFE0F \u53EA\u6709\u5176\u4E2D 1 \u4E2A\u6709\u6743\u9650\u65F6 CLI \u4F1A\u76F4\u63A5\u53D1\u8D77\uFF0C\u4E0D\u4F1A\u8D70\u5230\u8FD9\u4E00\u6B65`,
|
|
1532
|
+
options: launchable.map((probe, index) => ({
|
|
1533
|
+
key: `W${index + 1}`,
|
|
1534
|
+
label: probe.name ? `${probe.name}\uFF08${probe.workflowId}\uFF09` : probe.workflowId,
|
|
1535
|
+
// ⛔ 把已确认的四要素一起带回去:用户点选流程后**原样回传 value** 就能直接出确认摘要,
|
|
1536
|
+
// 不用再走一遍时间/房间闸门(否则"先定四要素再选流程"会多出一轮无效往返)。
|
|
1537
|
+
value: {
|
|
1538
|
+
workflowId: probe.workflowId,
|
|
1539
|
+
begin_datetime: beginText,
|
|
1540
|
+
end_datetime: endText,
|
|
1541
|
+
timeConfirmed: true,
|
|
1542
|
+
...confirmedAddressId ? { address: confirmedAddressId, roomConfirmed: true } : {}
|
|
1543
|
+
},
|
|
1544
|
+
reason: "\u5F53\u524D\u8D26\u53F7\u6709\u53D1\u8D77\u6743\u9650",
|
|
1545
|
+
// 把该流程的字段名如实带出来:不同流程字段差异很大(有的有设备需求/涉密项目,有的没有),
|
|
1546
|
+
// 用户要靠这个才能选对(2026-10-29 用户反馈:选错方式后字段全填不进去)。
|
|
1547
|
+
fields: (loadedForms.get(probe.workflowId)?.fields ?? []).map((f) => f.name).filter(Boolean)
|
|
1548
|
+
})),
|
|
1549
|
+
probes
|
|
1550
|
+
}, {
|
|
1551
|
+
warnings: [
|
|
1552
|
+
`${sourceLabel}\uFF1A\u5171 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5176\u4E2D ${launchable.length} \u4E2A\u5F53\u524D\u8D26\u53F7\u53EF\u53D1\u8D77\uFF1B**\u5FC5\u987B\u628A\u8FD9\u51E0\u4E2A\u6D41\u7A0B\u505A\u6210\u9009\u9879\u8BA9\u7528\u6237\u6311\u4E00\u4E2A\uFF0C\u7981\u6B62\u81EA\u5DF1\u66FF\u7528\u6237\u9009**\uFF1B\u9009\u5B9A\u540E\u5E26\u5355\u4E2A workflowId \u91CD\u65B0 prepare\u3002`,
|
|
1553
|
+
...probes.filter((probe) => !probe.launchable).map((probe) => `\u6D41\u7A0B ${probe.workflowId} \u5F53\u524D\u8D26\u53F7\u65E0\u6CD5\u53D1\u8D77\uFF08${probe.reason ?? "\u65E0\u6743\u9650"}\uFF09\uFF0C\u5DF2\u6392\u9664`)
|
|
1554
|
+
]
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
if (workflowId === "") workflowId = launchable[0].workflowId;
|
|
1559
|
+
if (launchable.length === 1 && candidates.length > 1 && flowPickNote === null) {
|
|
1560
|
+
const only = launchable[0];
|
|
1561
|
+
flowPickNote = `${sourceLabel}\uFF1A\u5171 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5F53\u524D\u8D26\u53F7\u53EA\u6709\u300C${only.name ?? only.workflowId}\u300D\uFF08${only.workflowId}\uFF09\u6709\u53D1\u8D77\u6743\u9650\uFF0C\u5DF2\u76F4\u63A5\u7528\u5B83\u53D1\u8D77`;
|
|
1562
|
+
}
|
|
1563
|
+
if (launchable.length > 1 && flowPickNote === null) {
|
|
1564
|
+
const picked2 = launchable[0];
|
|
1565
|
+
const others = launchable.slice(1).map((probe) => probe.name ? `${probe.name}\uFF08${probe.workflowId}\uFF09` : probe.workflowId);
|
|
1566
|
+
flowPickNote = `${sourceLabel}\uFF1A\u5171 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5F53\u524D\u8D26\u53F7\u53EF\u53D1\u8D77 ${launchable.length} \u4E2A\uFF0C\u5DF2\u6309\u4F18\u5148\u7EA7\u81EA\u52A8\u9009\u7528\u300C${picked2.name ?? picked2.workflowId}\u300D\uFF08${picked2.workflowId}\uFF09\uFF1B\u5176\u4ED6\u53EF\u7528\u6D41\u7A0B\uFF1A${others.join("\u3001")} \u2014\u2014 \u8981\u7528\u5B83\u4EEC\u8BF7\u663E\u5F0F\u4F20 workflowId\u3002`;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
let form = loadedForms.get(workflowId);
|
|
1570
|
+
if (!form) {
|
|
1571
|
+
try {
|
|
1572
|
+
form = await loadCreateForm(env, workflowId);
|
|
1573
|
+
} catch (error) {
|
|
1574
|
+
throw meetingValidationError(
|
|
1575
|
+
"flow_not_launchable",
|
|
1576
|
+
`\u5F53\u524D\u8D26\u53F7**\u6CA1\u6709\u53D1\u8D77\u5EFA\u4F1A\u6D41\u7A0B\u7684\u6743\u9650**\uFF08\u6216\u6D41\u7A0B\u5DF2\u505C\u7528\uFF09\uFF1A\u5EFA\u4F1A\u6D41\u7A0B ${workflowId} \u7684\u8868\u5355\u8F7D\u5165\u5931\u8D25 \u2014\u2014 ${String(error?.message ?? error).slice(0, 200)}\u3002\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\uFF1A\u9700\u8981\u627E\u7BA1\u7406\u5458\u5F00\u901A\u8BE5\u6D41\u7A0B\u7684\u53D1\u8D77\u6743\u9650\uFF0C\u6216\u8BF7\u6709\u6743\u9650\u7684\u540C\u4E8B\u4EE3\u4E3A\u53D1\u8D77\uFF1B**\u4E0D\u8981**\u6539\u7528\u76F4\u8FDE\u5EFA\u4F1A\u7ED5\u8FC7\u6D41\u7A0B\u7BA1\u63A7\u3002`,
|
|
1577
|
+
{ workflowId }
|
|
1578
|
+
);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
if (!form.continuation) {
|
|
1582
|
+
throw meetingValidationError("flow_context_missing", "\u5EFA\u4F1A\u6D41\u7A0B\u8868\u5355\u6CA1\u6709\u8FD4\u56DE continuation\uFF0C\u65E0\u6CD5\u7EE7\u7EED\u63D0\u4EA4");
|
|
1583
|
+
}
|
|
1584
|
+
decisions.timings = timings;
|
|
1585
|
+
const crmMemberCount = (() => {
|
|
1586
|
+
if (args.crm_member_count !== void 0 && args.crm_member_count !== "") return args.crm_member_count;
|
|
1587
|
+
const raw = args.crm_members;
|
|
1588
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
1589
|
+
if (Array.isArray(raw)) return raw.length > 0 ? raw.length : void 0;
|
|
1590
|
+
const text = String(raw).trim();
|
|
1591
|
+
if (!text) return void 0;
|
|
1592
|
+
const count = text.split(/[,;,;]+/).map((item) => item.trim()).filter((item) => item !== "").length;
|
|
1593
|
+
return count > 0 ? count : void 0;
|
|
1594
|
+
})();
|
|
1595
|
+
const shaped = await shapeBrowserValues(env, {
|
|
1596
|
+
mt_name: args.mt_name,
|
|
1597
|
+
begin_datetime: args.begin_datetime,
|
|
1598
|
+
end_datetime: args.end_datetime,
|
|
1599
|
+
mt_desc: args.mt_desc,
|
|
1600
|
+
address: addressInput,
|
|
1601
|
+
customize_address: args.customize_address,
|
|
1602
|
+
hrm_members: args.hrm_members,
|
|
1603
|
+
total_member: args.total_member,
|
|
1604
|
+
crm_members: args.crm_members,
|
|
1605
|
+
...crmMemberCount === void 0 ? {} : { crm_member_count: crmMemberCount },
|
|
1606
|
+
caller: args.caller,
|
|
1607
|
+
contacter: args.contacter,
|
|
1608
|
+
other_remark: args.other_remark,
|
|
1609
|
+
mt_type: args.mt_type,
|
|
1610
|
+
...args.extraFields && typeof args.extraFields === "object" && !Array.isArray(args.extraFields) ? args.extraFields : {}
|
|
1611
|
+
});
|
|
1612
|
+
const preferredFields = await readFlowFieldMap(env, workflowId);
|
|
1613
|
+
const { main, mapped, unmapped, resolved: resolvedFields } = mapFields(form.fields, shaped.values, preferredFields);
|
|
1614
|
+
await writeFlowFieldMap(env, workflowId, form.workflowName, resolvedFields);
|
|
1615
|
+
const warnings = [];
|
|
1616
|
+
if (autoFilledPerson.length > 0) {
|
|
1617
|
+
const labels = autoFilledPerson.map((one) => `\u300C${PERSON_FIELD_LABELS[one.field]}\u300D`).join("");
|
|
1618
|
+
warnings.push(
|
|
1619
|
+
`${labels}\u6CA1\u6709\u4F20\u503C\uFF0C\u5DF2\u6309**\u5F53\u524D\u767B\u5F55\u4EBA**\u8865\u9F50\uFF1A${autoFilledPerson[0].name}\uFF08${autoFilledPerson[0].id}\uFF09\u3002\u8981\u6362\u6210\u522B\u4EBA\uFF08\u4F8B\u5982\u66FF\u4ED6\u4EBA\u5EFA\u4F1A\u3001\u6307\u5B9A\u522B\u7684\u8054\u7CFB\u4EBA\uFF09\u8BF7\u663E\u5F0F\u4F20 caller / contacter\u3002`
|
|
1620
|
+
);
|
|
1621
|
+
} else if (selfPersonWarning) {
|
|
1622
|
+
warnings.push(selfPersonWarning);
|
|
1623
|
+
}
|
|
1624
|
+
if (flowPickNote) warnings.push(flowPickNote);
|
|
1625
|
+
for (const note of shaped.notes) warnings.push(note);
|
|
1626
|
+
const crmMentioned = detectCrmMentionInText(args.mt_name, args.mt_desc, args.other_remark);
|
|
1627
|
+
if (crmMentioned && !args.crm_members) {
|
|
1628
|
+
const hasCrmField = form.fields.some((field) => /参会客户/.test(String(field?.label ?? field?.name ?? field?.fieldName ?? "")));
|
|
1629
|
+
warnings.push(
|
|
1630
|
+
`\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u91CC\u63D0\u5230\u5BA2\u6237\u300C${crmMentioned}\u300D\uFF0C\u4F46\u672C\u6B21\u6CA1\u4F20 crm_members` + (hasCrmField ? `\uFF0C\u8BE5\u6D41\u7A0B\u8868\u5355**\u6709\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5B57\u6BB5\uFF0C\u73B0\u5728\u4F1A\u662F\u7A7A\u7684**\u3002\u8BF7\u5148 meeting.eb.crm.search {"keyword":"${crmMentioned}"} \u62FF items[].customerId\uFF0C\u518D\u7528 crm_members:[{id,name}] \u91CD\u65B0\u63D0\u4EA4\uFF08\u5FC5\u987B\u5E26\u5BA2\u6237\u540D\u79F0\uFF09\u3002` : "\uFF08\u8BE5\u6D41\u7A0B\u8868\u5355\u91CC\u6CA1\u6709\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5B57\u6BB5\uFF0C\u672C\u6761\u53EF\u5FFD\u7565\uFF09\u3002")
|
|
1631
|
+
);
|
|
1632
|
+
}
|
|
1633
|
+
const crmMembersGiven = Array.isArray(args.crm_members) ? args.crm_members.length > 0 : String(args.crm_members ?? "").trim() !== "";
|
|
1634
|
+
if (crmMembersGiven) {
|
|
1635
|
+
const crmFieldId = String(resolvedFields.crm_members ?? "").trim();
|
|
1636
|
+
const crmField = form.fields.find((field) => String(field?.id ?? "") === crmFieldId);
|
|
1637
|
+
const componentKey = String(crmField?.componentKey ?? "").toLowerCase();
|
|
1638
|
+
if (crmField && componentKey !== "" && componentKey !== "customer" && componentKey !== "customercomponent") {
|
|
1639
|
+
warnings.push(
|
|
1640
|
+
`\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5B57\u6BB5\uFF08${crmFieldId}\uFF09\u662F ${crmField.componentKey} \u7EC4\u4EF6\uFF1A\u5BA2\u6237 id \u4E0E\u540D\u79F0\u7167\u5E38\u5199\u8FDB\u6D41\u7A0B\u5355\u636E\uFF0C\u518D\u7531 ESB \u7684\u5B57\u6BB5\u6620\u5C04\u540C\u6B65\u5230\u4F1A\u8BAE\u8868 \u2014\u2014 \u6B63\u5E38\u914D\u7F6E\uFF0C\u4E0D\u9700\u8981\u6539\u8868\u5355\u3002`
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
const providedCrmDetailRows = normalizeCrmDetailRows(args.crm_member_details);
|
|
1645
|
+
const onlyDetailMode = String(args.crm_detail_mode ?? "").trim().toLowerCase() === "only";
|
|
1646
|
+
let crmDetailRows = onlyDetailMode ? providedCrmDetailRows : [];
|
|
1647
|
+
if (crmMembersGiven && !onlyDetailMode) {
|
|
1648
|
+
const detailTarget = resolveCrmDetailTarget(form.fields);
|
|
1649
|
+
if (detailTarget) {
|
|
1650
|
+
const auto = await resolveAutoCrmDetailRows(env, shaped.values.crm_members ?? args.crm_members);
|
|
1651
|
+
if (auto.rows.length > 0) {
|
|
1652
|
+
crmDetailRows = auto.rows;
|
|
1653
|
+
if (providedCrmDetailRows.length > 0) {
|
|
1654
|
+
const byName = new Map(providedCrmDetailRows.map((row) => [String(row.xm ?? "").trim(), row]));
|
|
1655
|
+
crmDetailRows = crmDetailRows.map((row) => {
|
|
1656
|
+
const given = byName.get(String(row.xm ?? "").trim());
|
|
1657
|
+
if (!given) return row;
|
|
1658
|
+
const merged = { ...row };
|
|
1659
|
+
for (const [key, value] of Object.entries(given)) {
|
|
1660
|
+
if (String(value ?? "").trim() !== "") merged[key] = String(value);
|
|
1661
|
+
}
|
|
1662
|
+
return merged;
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
warnings.push(
|
|
1666
|
+
`\u5DF2\u81EA\u52A8\u628A\u300C${auto.customers.join("\u3001")}\u300D\u7684 ${auto.rows.length} \u4F4D\u8054\u7CFB\u4EBA\u5199\u8FDB\u300C\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\u300D\uFF1A${auto.rows.map((row) => `${row.xm}${row.sjhm ? ` ${row.sjhm}` : ""}`).join("\u3001")}\uFF08\u660E\u7EC6\u8868\u672C\u6765\u5C31\u4E00\u4EBA\u4E00\u884C\uFF0C\u4E0D\u9700\u8981\u8BA9\u7528\u6237\u6311\uFF09\u3002\u786E\u5B9E\u53EA\u60F3\u8981\u5176\u4E2D\u51E0\u4F4D\u65F6\uFF0C\u4F20 crm_detail_mode:"only" \u518D\u914D crm_member_details \u624D\u8986\u76D6\u672C\u6B21\u81EA\u52A8\u5E26\u5165\u3002`
|
|
1667
|
+
);
|
|
1668
|
+
} else if (auto.missing.length > 0) {
|
|
1669
|
+
warnings.push(
|
|
1670
|
+
`\u5DF2\u5199\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\uFF0C\u4F46\u6CA1\u80FD\u81EA\u52A8\u5E26\u51FA\u300C${auto.missing.join("\u3001")}\u300D\u7684\u8054\u7CFB\u4EBA\uFF08CRM \u91CC\u67E5\u4E0D\u5230\uFF09\u3002\u8BF7\u628A\u5DF2\u67E5\u5230\u7684\u8054\u7CFB\u4EBA\u76F4\u63A5\u544A\u7ED9\u7528\u6237\u6838\u5BF9\uFF1B\u786E\u5B9E\u6CA1\u6709\u8054\u7CFB\u4EBA\u65F6\u95EE\u4E00\u6B21\u59D3\u540D+\u624B\u673A\u53F7\uFF0C\u518D\u4EE5 crm_member_details:[{"xm":"\u5F20\u4E09","sjhm":"13800000000"}] \u91CD\u65B0 prepare\u3002`
|
|
1671
|
+
);
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
let detailPayload;
|
|
1676
|
+
if (crmDetailRows.length > 0) {
|
|
1677
|
+
const target = resolveCrmDetailTarget(form.fields);
|
|
1678
|
+
if (!target) {
|
|
1679
|
+
warnings.push(
|
|
1680
|
+
`\u4F20\u4E86 crm_member_details\uFF08${crmDetailRows.length} \u884C\uFF09\uFF0C\u4F46\u8BE5\u5EFA\u4F1A\u6D41\u7A0B\u7684**\u53D1\u8D77\u8282\u70B9\u8868\u5355\u91CC\u6CA1\u6709\u300C\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\u300D\u660E\u7EC6\u8868**\uFF08\u6216\u5B83\u88AB\u6446\u5728\u9690\u85CF\u884C\u4E0A\uFF09\uFF0C\u660E\u7EC6\u65E0\u6CD5\u5199\u5165\uFF0C\u5DF2\u5FFD\u7565\u8FD9\u4E9B\u884C\uFF1B\u4E3B\u8868\u7684\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u7167\u5E38\u5199\u5165\u3002`
|
|
1681
|
+
);
|
|
1682
|
+
} else {
|
|
1683
|
+
detailPayload = {
|
|
1684
|
+
[target.subFormId]: crmDetailRows.map((row) => {
|
|
1685
|
+
const line = {};
|
|
1686
|
+
for (const [semantic, fieldId] of Object.entries(target.columns)) {
|
|
1687
|
+
const value = row[semantic];
|
|
1688
|
+
if (value !== void 0 && value !== "") line[fieldId] = value;
|
|
1689
|
+
}
|
|
1690
|
+
return line;
|
|
1691
|
+
})
|
|
1692
|
+
};
|
|
1693
|
+
warnings.push(
|
|
1694
|
+
`\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\uFF1A${crmDetailRows.length} \u884C\u5199\u5165\u660E\u7EC6\u8868 ${target.subFormId}\uFF08\u5217\uFF1A${Object.values(target.labels).join("/")}\uFF09`
|
|
1695
|
+
);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
if (args.fieldValues && typeof args.fieldValues === "object" && !Array.isArray(args.fieldValues)) {
|
|
1699
|
+
const knownIds = new Set(form.fields.map((field) => field.id));
|
|
1700
|
+
for (const [fieldId, raw] of Object.entries(args.fieldValues)) {
|
|
1701
|
+
if (raw === void 0 || raw === null || raw === "") continue;
|
|
1702
|
+
if (!knownIds.has(fieldId)) {
|
|
1703
|
+
warnings.push(`fieldValues \u91CC\u7684 datakey\u300C${fieldId}\u300D\u4E0D\u5728\u8BE5\u6D41\u7A0B\u8868\u5355\u91CC\uFF0C\u5DF2\u5FFD\u7565\uFF08\u5148\u7528 prepare \u4E0D\u5E26 fieldValues \u8DD1\u4E00\u6B21\uFF0C\u770B unmapped/\u8868\u5355\u5B57\u6BB5\u6E05\u5355\uFF09`);
|
|
1704
|
+
continue;
|
|
1705
|
+
}
|
|
1706
|
+
main[fieldId] = raw;
|
|
1707
|
+
mapped[`datakey:${fieldId}`] = fieldId;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
if (enrichFailures.length > 0) {
|
|
1711
|
+
decisions.enrichFailures = enrichFailures;
|
|
1712
|
+
for (const failure of enrichFailures) {
|
|
1713
|
+
warnings.push(`\u26A0\uFE0F ${failure} \u2014\u2014 **\u8FD9\u4E0D\u4EE3\u8868\u6CA1\u6709\u51B2\u7A81**\uFF0C\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\u8BE5\u9879\u672A\u6838\u9A8C\uFF0C\u4E0D\u8981\u58F0\u79F0"\u65F6\u95F4\u5DF2\u786E\u8BA4\u7A7A\u95F2"`);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
const picked = decisions.autoRoom?.picked;
|
|
1717
|
+
if (picked && !hadAddressInput) {
|
|
1718
|
+
warnings.push(
|
|
1719
|
+
`\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4 \u2192 \u5DF2\u81EA\u52A8\u9009\u62E9\u300C${picked.name}\u300D\uFF08${(picked.reasons ?? []).join("\uFF1B")}\uFF09\uFF1B\u53E6\u6709\u5019\u9009 ${(decisions.roomOptions ?? []).slice(1).map((item) => item.label).join(" / ") || "\u65E0"}`
|
|
1720
|
+
);
|
|
1721
|
+
}
|
|
1722
|
+
const slotOptions = decisions.slotOptions ?? [];
|
|
1723
|
+
const memberConflictCount = decisions.memberConflicts?.length ?? 0;
|
|
1724
|
+
if (memberConflictCount > 0 && slotOptions.length > 0) {
|
|
1725
|
+
warnings.push(
|
|
1726
|
+
`\u53C2\u4F1A\u4EBA\u65F6\u95F4\u6709\u51B2\u7A81\uFF08${memberConflictCount} \u6761\u5360\u7528\uFF09\uFF1B\u5F53\u5929\u6240\u6709\u4EBA\u90FD\u7A7A\u7684\u65F6\u6BB5\uFF1A` + slotOptions.map((item) => `[${item.key}] ${item.label}`).join("\uFF1B") + "\u2014\u2014\u8BF7\u7528\u9009\u9879\u65B9\u5F0F\u8BA9\u7528\u6237\u6311\uFF08\u9009\u5B9A\u540E\u91CD\u65B0 prepare \u5E76\u6539\u65F6\u95F4\uFF09\u3002"
|
|
1727
|
+
);
|
|
1728
|
+
} else if (memberConflictCount === 0 && slotOptions.length > 0) {
|
|
1729
|
+
warnings.push(
|
|
1730
|
+
`\u8BE5\u65F6\u6BB5\u53C2\u4F1A\u4EBA\u6CA1\u6709\u4F1A\u8BAE/\u65E5\u7A0B\u5360\u7528\uFF08\u5DF2\u6838\u5BF9\u4F1A\u8BAE\u56DE\u6267\u4E0E\u65E5\u7A0B\uFF09\u3002\u5F53\u5929\u5176\u4ED6\u5171\u540C\u7A7A\u95F2\u65F6\u6BB5\uFF1A${slotOptions.map((item) => `[${item.key}] ${item.label}`).join("\uFF1B")}`
|
|
1731
|
+
);
|
|
1732
|
+
} else if (decisions.dayBlocked?.summary) {
|
|
1733
|
+
warnings.push(String(decisions.dayBlocked.summary));
|
|
1734
|
+
}
|
|
1735
|
+
const unmappedReal = unmapped.filter((name) => name !== "mt_name" && name !== "crm_member_count");
|
|
1736
|
+
if (unmappedReal.length > 0) {
|
|
1737
|
+
warnings.push(
|
|
1738
|
+
`\u4EE5\u4E0B\u5B57\u6BB5\u6CA1\u6709\u5728\u5EFA\u4F1A\u6D41\u7A0B\u8868\u5355\u91CC\u627E\u5230\u540C\u540D\u5B57\u6BB5\uFF0C\u672A\u81EA\u52A8\u586B\u5199\uFF1A${unmappedReal.join("\u3001")}\uFF08\u8868\u5355\u73B0\u6709\u5B57\u6BB5\uFF1A${form.fields.map((field) => field.name).join("\u3001")}\uFF09`
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
if (!main[form.fields.find((field) => field.name === "\u4F1A\u8BAE\u540D\u79F0")?.id ?? ""] && !mapped.mt_name) {
|
|
1742
|
+
warnings.push(
|
|
1743
|
+
"\u8BE5\u5EFA\u4F1A\u6D41\u7A0B\u7684\u8868\u5355\u6CA1\u6709\u300C\u4F1A\u8BAE\u540D\u79F0\u300D\u5B57\u6BB5\uFF08\u90E8\u5206\u6D41\u7A0B\u7528\u6D41\u7A0B\u6807\u9898\u4EE3\u66FF\u4F1A\u8BAE\u540D\u79F0\uFF0C\u5C5E\u6B63\u5E38\u914D\u7F6E\uFF0C\u4E0D\u662F\u6D41\u7A0B\u914D\u9519\uFF09\u3002\u5982\u9700\u4F1A\u8BAE\u540D\u79F0\u72EC\u7ACB\u6210\u5B57\u6BB5\uFF0C\u8BF7\u6539\u9009\u5E26\u8BE5\u5B57\u6BB5\u7684\u6D41\u7A0B\uFF08\u5982\u300C\u4F1A\u8BAE\u7533\u8BF7\u6D41\u7A0B\uFF08NEW\uFF09\u300D\uFF09\u3002"
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
const crmPatchIds = (Array.isArray(shaped.values.crm_members) ? shaped.values.crm_members : []).map((row) => String(row?.id ?? "").trim()).filter((id) => id !== "");
|
|
1747
|
+
const groupMemberIds = (Array.isArray(shaped.values.hrm_members) ? shaped.values.hrm_members : []).map((one) => String(one?.id ?? one ?? "").trim()).filter((id) => id !== "");
|
|
1748
|
+
const session = await env.host.getSession();
|
|
1749
|
+
const continuation = await env.continuation.issue(
|
|
1750
|
+
{
|
|
1751
|
+
operation: "meeting.eb.meeting.create.flow.apply",
|
|
1752
|
+
baseUrl: session.baseUrl,
|
|
1753
|
+
profile: session.profile,
|
|
1754
|
+
userId: session.userId,
|
|
1755
|
+
payload: {
|
|
1756
|
+
workflowId,
|
|
1757
|
+
requestName: String(args.mt_name ?? args.mt_subject ?? ""),
|
|
1758
|
+
mtName: String(args.mt_name ?? args.mt_subject ?? ""),
|
|
1759
|
+
workflowName: String(form.workflowName ?? ""),
|
|
1760
|
+
data: { main, ...detailPayload ? { details: detailPayload } : {} },
|
|
1761
|
+
surfaceContinuation: form.continuation,
|
|
1762
|
+
// 供 apply 在「会议还没生成」时按申请单信息预生成邀请函(预置函)
|
|
1763
|
+
invitationFields: shaped.readable,
|
|
1764
|
+
// 提交后回显要用「字段名 → 值」,字段清单先存下来(apply 阶段拿不到 createForm 结果)
|
|
1765
|
+
fieldLabels: form.fields.map((field) => ({ id: String(field.id), name: String(field.name) })),
|
|
1766
|
+
// 已确认的「人员 id → 姓名」,供 apply 回显时把裸 id 换成姓名
|
|
1767
|
+
...autoFilledPerson.length > 0 ? { personLabels: Object.fromEntries(autoFilledPerson.map((one) => [one.id, one.name])) } : {},
|
|
1768
|
+
// 会议记录的客户要靠 apply 补写(表单「参会客户」是 Ebuilder,单据↔会议表不同步)
|
|
1769
|
+
...crmPatchIds.length > 0 ? { crmPatch: { ids: crmPatchIds, count: crmMemberCount === void 0 ? crmPatchIds.length : crmMemberCount } } : {},
|
|
1770
|
+
// 建群要素:apply 拿到会议 id 后先建群、再把群 id 回写 imchat_groupid
|
|
1771
|
+
groupChat: {
|
|
1772
|
+
memberIds: groupMemberIds,
|
|
1773
|
+
// ⛔ 2026-11-04 修:用户只说"明天上午"(time_slot)时,begin_datetime 是 CLI 展开出来的,
|
|
1774
|
+
// `shaped.values` 里**没有**这个键 —— 直接取会得到空串,群消息里"开始时间/结束时间"就空着。
|
|
1775
|
+
// 这里统一用展开后的 beginText/endText。
|
|
1776
|
+
beginDatetime: beginText,
|
|
1777
|
+
endDatetime: endText,
|
|
1778
|
+
// ⛔ 2026-11-04 修:shaped.address 在这之前已被解析成 `{id,name}` 对象,
|
|
1779
|
+
// 直接 String() 会变成 "[object Object]" 打进群消息(用户实测看到的就是这个)。
|
|
1780
|
+
// 群消息要的是人话名称,这里优先取 name。
|
|
1781
|
+
address: (() => {
|
|
1782
|
+
const value = shaped.values.address;
|
|
1783
|
+
if (value && typeof value === "object") return String(value.name ?? value.id ?? "");
|
|
1784
|
+
return String(value ?? "");
|
|
1785
|
+
})()
|
|
1786
|
+
}
|
|
1787
|
+
},
|
|
1788
|
+
fingerprint: JSON.stringify({ workflowId, main, ...detailPayload ? { details: detailPayload } : {} })
|
|
1789
|
+
},
|
|
1790
|
+
10 * 60 * 1e3
|
|
1791
|
+
);
|
|
1792
|
+
return meetingSuccess(
|
|
1793
|
+
"meeting.eb.meeting.create.flow.prepare",
|
|
1794
|
+
{
|
|
1795
|
+
status: "AWAITING_CONFIRMATION",
|
|
1796
|
+
preview: {
|
|
1797
|
+
workflowId,
|
|
1798
|
+
workflowCandidates: candidates,
|
|
1799
|
+
...probes.length > 0 ? { workflowProbes: probes } : {},
|
|
1800
|
+
...flowPickNote ? { workflowAutoPicked: { workflowId, source: resolved.source, note: flowPickNote } } : {},
|
|
1801
|
+
requestName: String(args.mt_name ?? args.mt_subject ?? ""),
|
|
1802
|
+
fieldMapping: mapped,
|
|
1803
|
+
formData: { main },
|
|
1804
|
+
// 人话版「即将提交的内容」—— 提交前必须先贴给用户核对(见 SKILL 建会章节)。
|
|
1805
|
+
formPreview: renderFormPreview(
|
|
1806
|
+
form.fields,
|
|
1807
|
+
await decoratePreviewPersonNames(
|
|
1808
|
+
env,
|
|
1809
|
+
main,
|
|
1810
|
+
form.fields,
|
|
1811
|
+
new Map(autoFilledPerson.map((one) => [one.id, one.name]))
|
|
1812
|
+
)
|
|
1813
|
+
),
|
|
1814
|
+
// 召集人/联系人是不是"替用户默认填的"要说清楚,用户才知道能不能改。
|
|
1815
|
+
...autoFilledPerson.length > 0 ? {
|
|
1816
|
+
autoFilled: Object.fromEntries(
|
|
1817
|
+
autoFilledPerson.map((one) => [PERSON_FIELD_LABELS[one.field], `${one.name}(${one.id})`])
|
|
1818
|
+
)
|
|
1819
|
+
} : {},
|
|
1820
|
+
...detailPayload ? { detailRows: { subFormId: Object.keys(detailPayload)[0], count: crmDetailRows.length, rows: crmDetailRows } } : {},
|
|
1821
|
+
formFieldCount: form.fields.length,
|
|
1822
|
+
...Object.keys(decisions).length > 0 ? { decisions } : {}
|
|
1823
|
+
},
|
|
1824
|
+
continuation,
|
|
1825
|
+
expiresInSeconds: 600
|
|
1826
|
+
},
|
|
1827
|
+
warnings.length > 0 ? { warnings } : {}
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
var CRM_PATCH_SETTLE_MS = [4e3, 6e3];
|
|
1832
|
+
async function patchMeetingCrmMembers(env, meetingId, ids, count, settleMsList = CRM_PATCH_SETTLE_MS) {
|
|
1833
|
+
const list = ids.map((id) => String(id ?? "").trim()).filter((id) => id !== "");
|
|
1834
|
+
if (String(meetingId).trim() === "" || list.length === 0) {
|
|
1835
|
+
return { ok: false, error: "\u6CA1\u6709\u4F1A\u8BAE id \u6216\u5BA2\u6237 id" };
|
|
1836
|
+
}
|
|
1837
|
+
const mainTable = {
|
|
1838
|
+
id: String(meetingId).trim(),
|
|
1839
|
+
operate_type: "UPDATE",
|
|
1840
|
+
crm_members: list.join(",")
|
|
1841
|
+
};
|
|
1842
|
+
const total = Number(count);
|
|
1843
|
+
if (Number.isFinite(total) && total > 0) mainTable.crm_total_member = String(total);
|
|
1844
|
+
const write = async () => {
|
|
1845
|
+
const session = await env.host.getSession();
|
|
1846
|
+
await env.host.request({
|
|
1847
|
+
method: "POST",
|
|
1848
|
+
path: `${EB_BASE}/updateFormData/change_meeting`,
|
|
1849
|
+
query: { id: String(meetingId).trim() },
|
|
1850
|
+
operation: "meeting.eb.meeting.create.flow.apply",
|
|
1851
|
+
body: writeBody(String(session.userId), { mainTable, details: {}, operateType: {} }),
|
|
1852
|
+
acceptBusiness: ebBusinessSuccess
|
|
1853
|
+
});
|
|
1854
|
+
};
|
|
1855
|
+
const readBack = async () => {
|
|
1856
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
1857
|
+
const detail = getMeetingOperation("meeting.eb.meeting.detail");
|
|
1858
|
+
const read = await detail.handler({ id: String(meetingId).trim() }, env);
|
|
1859
|
+
return String(read?.data?.data?.crm_members ?? "").trim();
|
|
1860
|
+
};
|
|
1861
|
+
let lastError = "";
|
|
1862
|
+
for (const settleMs of settleMsList) {
|
|
1863
|
+
try {
|
|
1864
|
+
await write();
|
|
1865
|
+
} catch (error) {
|
|
1866
|
+
return { ok: false, error: String(error?.message ?? error).slice(0, 160) };
|
|
1867
|
+
}
|
|
1868
|
+
await new Promise((resolve2) => setTimeout(resolve2, settleMs));
|
|
1869
|
+
try {
|
|
1870
|
+
const value = await readBack();
|
|
1871
|
+
if (value !== "") return { ok: true, value };
|
|
1872
|
+
lastError = "\u8865\u5199\u540E\u56DE\u8BFB crm_members \u4ECD\u4E3A\u7A7A\uFF08\u591A\u534A\u88AB\u4F1A\u8BAE\u521D\u59CB\u5316\u7684\u540E\u7EED\u5199\u5165\u8986\u76D6\u4E86\uFF09";
|
|
1873
|
+
} catch (error) {
|
|
1874
|
+
lastError = `\u8865\u5199\u6210\u529F\u4F46\u56DE\u8BFB\u5931\u8D25\uFF1A${String(error?.message ?? error).slice(0, 120)}`;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
return { ok: false, error: lastError };
|
|
1878
|
+
}
|
|
1879
|
+
async function renderPreInvitation(payload, env) {
|
|
1880
|
+
const fields = payload?.invitationFields ?? {};
|
|
1881
|
+
const started = Date.now();
|
|
1882
|
+
try {
|
|
1883
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
1884
|
+
const render = getMeetingOperation("meeting.invitation.render");
|
|
1885
|
+
const rendered = await render.handler(
|
|
1886
|
+
{
|
|
1887
|
+
mt_name: String(fields.mt_name ?? payload?.mtName ?? "").trim(),
|
|
1888
|
+
begin_datetime: String(fields.begin_datetime ?? "").trim(),
|
|
1889
|
+
end_datetime: String(fields.end_datetime ?? "").trim(),
|
|
1890
|
+
address: String(fields.address ?? fields.customize_address ?? "").trim(),
|
|
1891
|
+
hrm_members: String(fields.hrm_members ?? "").trim(),
|
|
1892
|
+
mt_desc: String(fields.mt_desc ?? "").trim(),
|
|
1893
|
+
org_members: String(fields.org_members ?? "").trim(),
|
|
1894
|
+
caller: String(fields.caller ?? "").trim(),
|
|
1895
|
+
contacter: String(fields.contacter ?? "").trim(),
|
|
1896
|
+
total_member: String(fields.total_member ?? "").trim(),
|
|
1897
|
+
// 客户单位(邀请函开头「尊敬的 XXX」):建会时填了参会客户就直接带过去,
|
|
1898
|
+
// 否则整句永远是【待补充】—— 用户看到的就是"客户明明填了,邀请函里却没有"。
|
|
1899
|
+
extra: { guest_org: String(fields.crm_members ?? "").trim() }
|
|
1900
|
+
},
|
|
1901
|
+
env
|
|
1902
|
+
);
|
|
1903
|
+
return {
|
|
1904
|
+
invitation: { pending: true, preRendered: true, ...rendered?.data ?? {} },
|
|
1905
|
+
ms: Date.now() - started
|
|
1906
|
+
};
|
|
1907
|
+
} catch (error) {
|
|
1908
|
+
return {
|
|
1909
|
+
invitation: {
|
|
1910
|
+
pending: true,
|
|
1911
|
+
preRendered: false,
|
|
1912
|
+
ok: false,
|
|
1913
|
+
error: String(error?.message ?? error).slice(0, 200)
|
|
1914
|
+
},
|
|
1915
|
+
ms: Date.now() - started
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
var ebMeetingCreateFlowApply = {
|
|
1920
|
+
name: "meeting.eb.meeting.create.flow.apply",
|
|
1921
|
+
resource: "eb",
|
|
1922
|
+
method: "meeting.eb.meeting.create.flow.apply",
|
|
1923
|
+
action: "meeting.eb.meeting.create.flow.apply",
|
|
1924
|
+
summary: "\u6D41\u7A0B\u5EFA\u4F1A\uFF08\u63D0\u4EA4\uFF09\uFF1A\u7528\u786E\u8BA4\u7968\u636E\u63D0\u4EA4\u5EFA\u4F1A\u6D41\u7A0B\uFF1B\u63D0\u4EA4\u540E\u8F6E\u8BE2\u4F1A\u8BAE\u5217\u8868\u786E\u8BA4\u4F1A\u8BAE\u662F\u5426\u5DF2\u751F\u6210\uFF0C\u751F\u6210\u5219\u81EA\u52A8\u51FA\u9080\u8BF7\u51FD",
|
|
1925
|
+
capability: "eb.meeting",
|
|
1926
|
+
risk: "high-risk-write",
|
|
1927
|
+
requiresConfirmation: true,
|
|
1928
|
+
inputSchema: schemaOf(
|
|
1929
|
+
{
|
|
1930
|
+
continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E\uFF08\u5FC5\u586B\uFF09" },
|
|
1931
|
+
confirm: { type: "boolean", description: "\u5FC5\u987B\u663E\u5F0F\u4F20 true" },
|
|
1932
|
+
submit_mode: {
|
|
1933
|
+
type: "string",
|
|
1934
|
+
enum: ["direct", "browser"],
|
|
1935
|
+
description: '\u63D0\u4EA4\u65B9\u5F0F\uFF0C\u9ED8\u8BA4 browser\uFF1A\u5728\u5C0Fe \u91CC**\u5F39\u51FA\u6D41\u7A0B\u8868\u5355**\uFF0C\u5B57\u6BB5\u5DF2\u9884\u586B\uFF0C\u7528\u6237\u6838\u5BF9/\u4FEE\u6539\u540E\u81EA\u5DF1\u70B9\u63D0\u4EA4\u3002direct = \u76F4\u63A5\u5199\u670D\u52A1\u7AEF\uFF08\u4F1A\u8BAE\u5F53\u573A\u751F\u6210\u3001\u9080\u8BF7\u51FD\u7528\u771F\u5B9E\u6570\u636E\uFF0C\u4F46\u6CA1\u6709\u4EBA\u5DE5\u6838\u5BF9\u8868\u5355\u8FD9\u4E00\u6B65\uFF09\uFF1B\u53EA\u6709\u7528\u6237\u660E\u786E\u8BF4"\u4E0D\u7528\u6211\u786E\u8BA4\uFF0C\u76F4\u63A5\u5EFA"\u65F6\u624D\u4F20 direct'
|
|
1936
|
+
},
|
|
1937
|
+
waitSeconds: { type: "number", description: "\u63D0\u4EA4\u540E\u7B49\u5F85\u4F1A\u8BAE\u751F\u6210\u7684\u6700\u957F\u79D2\u6570\uFF08\u9ED8\u8BA4 60\uFF0C0 = \u4E0D\u7B49\u5F85\uFF09" }
|
|
1938
|
+
},
|
|
1939
|
+
{ required: ["continuation", "confirm"] }
|
|
1940
|
+
),
|
|
1941
|
+
handler: async (args, env) => {
|
|
1942
|
+
if (args.confirm !== true) {
|
|
1943
|
+
throw meetingValidationError("confirmation_required", "\u6D41\u7A0B\u5EFA\u4F1A\u5C5E\u4E8E\u9AD8\u5F71\u54CD\u5199\u64CD\u4F5C\uFF0C\u5FC5\u987B\u663E\u5F0F\u4F20 confirm=true");
|
|
1944
|
+
}
|
|
1945
|
+
const lease = await env.continuation.verify(
|
|
1946
|
+
String(args.continuation ?? ""),
|
|
1947
|
+
"meeting.eb.meeting.create.flow.apply"
|
|
1948
|
+
);
|
|
1949
|
+
const session = await env.host.getSession();
|
|
1950
|
+
if (lease.baseUrl !== session.baseUrl || lease.userId !== session.userId) {
|
|
1951
|
+
throw meetingValidationError("context_mismatch", "\u786E\u8BA4\u4E0A\u4E0B\u6587\u5DF2\u53D8\u5316\uFF08\u79DF\u6237\u6216\u767B\u5F55\u8D26\u53F7\u4E0D\u540C\uFF09\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C prepare");
|
|
1952
|
+
}
|
|
1953
|
+
const payload = lease?.payload ?? {};
|
|
1954
|
+
const { createWorkflowHost } = await import("./host-X2CSLFM6.js");
|
|
1955
|
+
const { createWorkflowContinuationSigner } = await import("./continuation-HZIZRZBX.js");
|
|
1956
|
+
const { getWorkflowOperation } = await import("./registry-RHMW6ANW.js");
|
|
1957
|
+
const wfEnv = {
|
|
1958
|
+
...workflowEnv(env),
|
|
1959
|
+
host: createWorkflowHost(env.ctx),
|
|
1960
|
+
continuation: createWorkflowContinuationSigner(env.ctx)
|
|
1961
|
+
};
|
|
1962
|
+
const submitStartedAt = Date.now();
|
|
1963
|
+
const submit = getWorkflowOperation("workflow.createRequest");
|
|
1964
|
+
const submitMode = String(args.submit_mode ?? "browser").trim();
|
|
1965
|
+
const submitted = await submit.handler(
|
|
1966
|
+
{
|
|
1967
|
+
// 工作流的入参名是 context(createForm 返回的 continuation 就是它的 context 句柄)
|
|
1968
|
+
context: payload.surfaceContinuation,
|
|
1969
|
+
data: payload.data,
|
|
1970
|
+
action: "submit",
|
|
1971
|
+
requestName: payload.requestName,
|
|
1972
|
+
confirm: true,
|
|
1973
|
+
...submitMode === "browser" ? {} : { forceServerSubmit: true }
|
|
1974
|
+
},
|
|
1975
|
+
wfEnv
|
|
1976
|
+
);
|
|
1977
|
+
const submittedData = submitted?.data ?? {};
|
|
1978
|
+
const requestId = String(submittedData.requestId ?? submittedData.id ?? "").trim();
|
|
1979
|
+
if (!requestId && String(submittedData.status ?? "") === "NEEDS_CONFIRMATION") {
|
|
1980
|
+
return meetingSuccess(
|
|
1981
|
+
"meeting.eb.meeting.create.flow.apply",
|
|
1982
|
+
{
|
|
1983
|
+
status: "NEEDS_CONFIRMATION",
|
|
1984
|
+
workflowId: payload.workflowId,
|
|
1985
|
+
requestName: payload.requestName,
|
|
1986
|
+
message: String(submittedData.message ?? ""),
|
|
1987
|
+
resolvedValues: submittedData.resolvedValues ?? [],
|
|
1988
|
+
unresolved: submittedData.unresolved ?? submittedData.candidates ?? [],
|
|
1989
|
+
submit: submittedData
|
|
1990
|
+
},
|
|
1991
|
+
{
|
|
1992
|
+
warnings: [
|
|
1993
|
+
"\u5EFA\u4F1A\u6D41\u7A0B\u672A\u63D0\u4EA4\uFF1A\u670D\u52A1\u7AEF\u6709\u5B57\u6BB5\u65E0\u6CD5\u552F\u4E00\u89E3\u6790\uFF08\u591A\u4E3A\u4F1A\u8BAE\u5730\u70B9/\u53C2\u4F1A\u4EBA\u5458/\u53EC\u96C6\u4EBA\u7B49\u6D4F\u89C8\u6309\u94AE\u5B57\u6BB5\uFF09\uFF0C\u8BF7\u6309 message / unresolved \u4E0E\u7528\u6237\u786E\u8BA4\u53D6\u503C\u540E\u91CD\u65B0 prepare\uFF08\u628A\u8FD9\u4E9B\u5B57\u6BB5\u6539\u6210\u670D\u52A1\u7AEF\u8BA4\u5F97\u7684\u683C\u5F0F\uFF0C\u5982\u300C\u540D\u79F0(ID)\u300D\uFF09\u3002"
|
|
1994
|
+
]
|
|
1995
|
+
}
|
|
1996
|
+
);
|
|
1997
|
+
}
|
|
1998
|
+
if (!requestId) {
|
|
1999
|
+
const submitStatus = String(submittedData.status ?? submitted?.status ?? "");
|
|
2000
|
+
if (submitStatus === "BROWSER_FILL") {
|
|
2001
|
+
const pre = await renderPreInvitation(payload, env);
|
|
2002
|
+
let groupChat2;
|
|
2003
|
+
const groupPayload2 = payload?.groupChat;
|
|
2004
|
+
if (groupPayload2) {
|
|
2005
|
+
try {
|
|
2006
|
+
const { ensureMeetingGroupChat } = await import("./group-chat-2HHAJN46.js");
|
|
2007
|
+
groupChat2 = {
|
|
2008
|
+
...await ensureMeetingGroupChat(env, {
|
|
2009
|
+
meetingName: String(payload.mtName ?? ""),
|
|
2010
|
+
beginDatetime: String(groupPayload2.beginDatetime ?? ""),
|
|
2011
|
+
endDatetime: String(groupPayload2.endDatetime ?? ""),
|
|
2012
|
+
memberIds: Array.isArray(groupPayload2.memberIds) ? groupPayload2.memberIds : [],
|
|
2013
|
+
...groupPayload2.address ? { address: String(groupPayload2.address) } : {}
|
|
2014
|
+
})
|
|
2015
|
+
};
|
|
2016
|
+
} catch (error) {
|
|
2017
|
+
groupChat2 = { ok: false, error: String(error?.message ?? error).slice(0, 200) };
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
if (groupChat2 && groupChat2.ok) {
|
|
2021
|
+
try {
|
|
2022
|
+
const { savePendingForm } = await import("./group-chat-2HHAJN46.js");
|
|
2023
|
+
await savePendingForm(env, {
|
|
2024
|
+
workflowId: String(payload.workflowId ?? ""),
|
|
2025
|
+
workflowName: String(payload.workflowName ?? ""),
|
|
2026
|
+
mtName: String(payload.mtName ?? ""),
|
|
2027
|
+
groupId: String(groupChat2.groupId ?? ""),
|
|
2028
|
+
groupName: String(groupChat2.groupName ?? "")
|
|
2029
|
+
});
|
|
2030
|
+
} catch {
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
const browserWarnings = [];
|
|
2034
|
+
let browserInvitation = pre.invitation;
|
|
2035
|
+
const browserGroupId = String(groupChat2?.groupId ?? "").trim();
|
|
2036
|
+
const browserInvitePath = String(pre.invitation?.filePath ?? "").trim();
|
|
2037
|
+
if (browserGroupId && browserInvitePath) {
|
|
2038
|
+
const sent = await sendInvitationToGroup(env, browserGroupId, browserInvitePath, browserWarnings);
|
|
2039
|
+
browserInvitation = { ...pre.invitation, sentToGroup: { groupId: browserGroupId, ok: sent.ok } };
|
|
2040
|
+
}
|
|
2041
|
+
return meetingSuccess(
|
|
2042
|
+
"meeting.eb.meeting.create.flow.apply",
|
|
2043
|
+
{
|
|
2044
|
+
status: "BROWSER_FILL",
|
|
2045
|
+
workflowId: payload.workflowId,
|
|
2046
|
+
requestName: payload.requestName,
|
|
2047
|
+
requestId: null,
|
|
2048
|
+
meetingId: null,
|
|
2049
|
+
contextId: submittedData.contextId ?? null,
|
|
2050
|
+
// 宿主要靠这段 <browsertool> 才能把表单拉到浏览器里填,必须原样透出
|
|
2051
|
+
finalMarkdown: submittedData.finalMarkdown ?? null,
|
|
2052
|
+
// 与 finalMarkdown 相邻的硬提示:模型「以为 CLI 已经打开了表单」是这次翻车的直接原因
|
|
2053
|
+
finalMarkdownHint: '\u628A finalMarkdown \u539F\u6837\u8D34\u5728\u56DE\u590D\u6700\u540E\uFF08\u4ECE <browsertool> \u5230 </browsertool>\uFF0C\u4E0D\u5305\u4EE3\u7801\u5757\uFF09\uFF1B\u4E0D\u8D34\u8FD9\u6BB5\uFF1D\u7528\u6237\u770B\u4E0D\u5230\u8868\u5355\uFF0C\u4E5F\u4E0D\u80FD\u8BF4"\u8868\u5355\u5DF2\u6253\u5F00"\u3002',
|
|
2054
|
+
message: String(submittedData.message ?? ""),
|
|
2055
|
+
invitation: browserInvitation,
|
|
2056
|
+
...groupChat2 ? { groupChat: groupChat2 } : {},
|
|
2057
|
+
timings: { submitMs: Date.now() - submitStartedAt, invitationMs: pre.ms }
|
|
2058
|
+
},
|
|
2059
|
+
{
|
|
2060
|
+
warnings: [
|
|
2061
|
+
'\u5F53\u524D\u662F\u5C0Fe \u73AF\u5883\uFF1A\u672C\u6B21**\u6CA1\u6709\u5411\u670D\u52A1\u7AEF\u5199\u5165**\uFF0C\u5EFA\u4F1A\u6D41\u7A0B\u6539\u7531\u6D4F\u89C8\u5668\u9875\u9762\u5B8C\u6210\u586B\u5355\uFF08\u89C1 finalMarkdown\uFF09\u3002\u56E0\u6B64\u8FD8\u6CA1\u6709 requestId / \u4F1A\u8BAE id\uFF0C\u4E5F**\u4E0D\u80FD\u8BF4"\u6D41\u7A0B\u5DF2\u63D0\u4EA4"**\u3002',
|
|
2062
|
+
...groupChat2 && groupChat2.ok ? [`\u7FA4\u804A\u5DF2\u540C\u6B65\u5EFA\u597D\uFF08\u7FA4 id ${String(groupChat2.groupId)}\uFF0C\u7FA4\u540D ${String(groupChat2.groupName)}\uFF09\uFF1A\u6D41\u7A0B\u8FD8\u6CA1\u63D0\u4EA4\u3001\u6CA1\u6709\u4F1A\u8BAE id\uFF0C\u6240\u4EE5 imchat_groupid \u6682\u65F6\u6CA1\u56DE\u5199\uFF1B\u4F1A\u8BAE\u751F\u6210\u540E\u518D\u8DD1\u4E00\u6B21 meeting.eb.meeting.group.ensure\uFF08\u4F20 meetingId + groupId\uFF09\u7ED1\u5B9A\u3002`] : groupChat2 ? [`\u7FA4\u804A\u6CA1\u5EFA\u6210\u529F\uFF08${String(groupChat2.error ?? "\u672A\u77E5\u539F\u56E0")}\uFF09\uFF1A\u4F1A\u8BAE\u7167\u5E38\u53EF\u4EE5\u5728\u9875\u9762\u91CC\u63D0\u4EA4\uFF0C\u7FA4\u9700\u8981\u624B\u5DE5\u5EFA\u6216\u7A0D\u540E\u91CD\u8BD5\u3002`] : [],
|
|
2063
|
+
`\u9080\u8BF7\u51FD\u5DF2\u6309\u7533\u8BF7\u5355\u4FE1\u606F**\u9884\u751F\u6210**\uFF08\u9884\u7F6E\u51FD\uFF0C${String(pre.invitation.filePath ?? "\u89C1 filePath")}\uFF09\uFF1A` + (browserInvitation.sentToGroup?.ok ? "\u5DF2\u628A docx \u53D1\u5230\u4F1A\u8BAE\u7FA4\uFF1B\u5B57\u6BB5\u53EF\u80FD\u542B\u3010\u5F85\u8865\u5145\u3011\uFF0C\u5BA1\u6279\u901A\u8FC7\u3001\u4F1A\u8BAE\u751F\u6210\u540E\u53EF\u7528 mtId \u518D\u8DD1\u4E00\u6B21 meeting.invitation.render \u62FF\u5B8C\u6574\u7248\u672C\u3002" : "\u8BF7\u4E0B\u8F7D\u540E\u4EBA\u5DE5\u6838\u5BF9\u3001\u81EA\u884C\u53D1\u9001\uFF1B\u6D41\u7A0B\u5BA1\u6279\u901A\u8FC7\u3001\u4F1A\u8BAE\u751F\u6210\u540E\u53EF\u7528 mtId \u518D\u8DD1\u4E00\u6B21 meeting.invitation.render \u62FF\u5B8C\u6574\u5B57\u6BB5\u7248\u672C\u3002"),
|
|
2064
|
+
'\u26D4 \u4E0D\u8981\u56E0\u4E3A"\u6CA1\u6709 requestId / \u6CA1\u6709\u4F1A\u8BAE id"\u91CD\u590D apply \u2014\u2014 \u586B\u5355\u8981\u5728\u90A3\u4E2A\u6D4F\u89C8\u5668\u9875\u9762\u91CC\u70B9\u63D0\u4EA4\u3002',
|
|
2065
|
+
...browserWarnings
|
|
2066
|
+
]
|
|
2067
|
+
}
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
const missing = submittedData.missingFields ?? submittedData.requiredMissing ?? submittedData.missing ?? [];
|
|
2071
|
+
throw meetingValidationError(
|
|
2072
|
+
"flow_submit_incomplete",
|
|
2073
|
+
`\u5EFA\u4F1A\u6D41\u7A0B\u672A\u63D0\u4EA4\u6210\u529F\uFF08status=${String(submittedData.status ?? submitted?.status ?? "\u672A\u77E5")}\uFF09\uFF1A` + (Array.isArray(missing) && missing.length > 0 ? `\u7F3A\u5C11\u5FC5\u586B\u9879 ${missing.map((item) => item?.name ?? item).join("\u3001")}` : "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE requestId\uFF0C\u8BF7\u67E5\u770B result \u6392\u67E5"),
|
|
2074
|
+
{ submit: submittedData, missing }
|
|
2075
|
+
);
|
|
2076
|
+
}
|
|
2077
|
+
const warnings = [];
|
|
2078
|
+
const submitDay = dayOf(String(payload?.groupChat?.beginDatetime ?? ""));
|
|
2079
|
+
if (submitDay !== "") void invalidateDayUsages(env, submitDay).catch(() => void 0);
|
|
2080
|
+
void rememberFlowPick(
|
|
2081
|
+
env,
|
|
2082
|
+
String(payload?.workflowId ?? ""),
|
|
2083
|
+
typeof payload?.workflowName === "string" ? payload.workflowName : void 0
|
|
2084
|
+
).catch(() => void 0);
|
|
2085
|
+
const waitSeconds = args.waitSeconds === void 0 ? 20 : Math.max(0, Math.min(180, Number(args.waitSeconds)));
|
|
2086
|
+
let meetingId = "";
|
|
2087
|
+
const timings = { submitMs: Date.now() - submitStartedAt };
|
|
2088
|
+
if (waitSeconds > 0) {
|
|
2089
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
2090
|
+
const list = getMeetingOperation("meeting.eb.meeting.list");
|
|
2091
|
+
const deadline = Date.now() + Math.min(waitSeconds, 30) * 1e3;
|
|
2092
|
+
const pollStart = Date.now();
|
|
2093
|
+
let waited = 0;
|
|
2094
|
+
let stepIndex = 0;
|
|
2095
|
+
const pollSteps = [500, 1e3, 2e3, 4e3];
|
|
2096
|
+
while (Date.now() <= deadline) {
|
|
2097
|
+
try {
|
|
2098
|
+
const page = await list.handler({ mt_name: payload.mtName, pageSize: 5 }, env);
|
|
2099
|
+
const rows = page?.data?.rows ?? [];
|
|
2100
|
+
const hit = rows.map((row) => row?.mainTable ?? row ?? {}).find((main) => String(main.mt_name ?? "").trim() === String(payload.mtName).trim());
|
|
2101
|
+
if (hit) {
|
|
2102
|
+
meetingId = String(hit.id ?? "").trim();
|
|
2103
|
+
if (meetingId) break;
|
|
2104
|
+
}
|
|
2105
|
+
} catch {
|
|
2106
|
+
}
|
|
2107
|
+
if (waited >= 7500) break;
|
|
2108
|
+
const step = pollSteps[Math.min(stepIndex, pollSteps.length - 1)];
|
|
2109
|
+
stepIndex += 1;
|
|
2110
|
+
await new Promise((resolve2) => setTimeout(resolve2, step));
|
|
2111
|
+
waited += step;
|
|
2112
|
+
}
|
|
2113
|
+
timings.pollMs = Date.now() - pollStart;
|
|
2114
|
+
}
|
|
2115
|
+
let crmLinked;
|
|
2116
|
+
const crmPatch = payload?.crmPatch;
|
|
2117
|
+
const crmPatchEnabled = process.env.WEAVER_MEETING_CRM_PATCH === "1";
|
|
2118
|
+
if (meetingId && crmPatchEnabled && Array.isArray(crmPatch?.ids) && crmPatch.ids.length > 0) {
|
|
2119
|
+
const patched = await patchMeetingCrmMembers(env, meetingId, crmPatch.ids, crmPatch.count);
|
|
2120
|
+
crmLinked = {
|
|
2121
|
+
ok: patched.ok,
|
|
2122
|
+
requested: crmPatch.ids.length,
|
|
2123
|
+
...patched.value ? { readBack: patched.value } : {},
|
|
2124
|
+
...patched.error ? { error: patched.error } : {}
|
|
2125
|
+
};
|
|
2126
|
+
if (patched.ok) {
|
|
2127
|
+
warnings.push(`\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5DF2\u8865\u5199\u5230\u4F1A\u8BAE\u8BB0\u5F55\uFF08crm_members=${patched.value}\uFF09\u3002`);
|
|
2128
|
+
} else {
|
|
2129
|
+
warnings.push(
|
|
2130
|
+
`\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u6CA1\u6709\u56DE\u8BFB\u5230\uFF08${patched.error ?? "\u672A\u77E5\u539F\u56E0"}\uFF09\uFF1A\u5F53\u524D\u8D70\u7684\u662F CLI \u624B\u5DE5\u8865\u5199\uFF08WEAVER_MEETING_CRM_PATCH=1\uFF09\uFF0C\u4E0D\u4F9D\u8D56 ESB \u5B57\u6BB5\u6620\u5C04\u65F6\u624D\u9700\u8981\u5B83\u3002`
|
|
2131
|
+
);
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
let groupChat;
|
|
2135
|
+
const groupPayload = payload?.groupChat;
|
|
2136
|
+
if (groupPayload) {
|
|
2137
|
+
const groupStart = Date.now();
|
|
2138
|
+
try {
|
|
2139
|
+
const { ensureMeetingGroupChat } = await import("./group-chat-2HHAJN46.js");
|
|
2140
|
+
const group = await ensureMeetingGroupChat(env, {
|
|
2141
|
+
meetingName: String(payload.mtName ?? ""),
|
|
2142
|
+
beginDatetime: String(groupPayload.beginDatetime ?? ""),
|
|
2143
|
+
endDatetime: String(groupPayload.endDatetime ?? ""),
|
|
2144
|
+
memberIds: Array.isArray(groupPayload.memberIds) ? groupPayload.memberIds : [],
|
|
2145
|
+
...groupPayload.address ? { address: String(groupPayload.address) } : {},
|
|
2146
|
+
...meetingId ? { meetingId } : {}
|
|
2147
|
+
});
|
|
2148
|
+
groupChat = { ...group };
|
|
2149
|
+
if (group.ok && group.bound) {
|
|
2150
|
+
warnings.push(
|
|
2151
|
+
`\u5DF2\u6309\u4F1A\u8BAE\u540C\u6B65\u5EFA\u7FA4\u300C${group.groupName ?? payload.mtName}\u300D\uFF08\u7FA4 id ${group.groupId}\uFF09\uFF0C\u5E76\u56DE\u5199\u5230\u4F1A\u8BAE\u8BB0\u5F55 imchat_groupid${group.readBack ? `\uFF08\u56DE\u8BFB ${group.readBack}\uFF09` : ""}\u3002`
|
|
2152
|
+
);
|
|
2153
|
+
} else if (group.ok) {
|
|
2154
|
+
warnings.push(
|
|
2155
|
+
`\u7FA4\u5DF2\u5EFA\u597D\uFF08\u7FA4 id ${group.groupId}\uFF09\uFF0C\u4F46\u4F1A\u8BAE\u8FD8\u6CA1\u751F\u6210\uFF0C\u6682\u65F6\u6CA1\u6CD5\u56DE\u5199 imchat_groupid\uFF1B\u4F1A\u8BAE\u751F\u6210\u540E\u4F20 meetingId+groupId \u8DD1\u4E00\u6B21 meeting.eb.meeting.group.ensure \u7ED1\u5B9A\u5373\u53EF\u3002`
|
|
2156
|
+
);
|
|
2157
|
+
} else {
|
|
2158
|
+
warnings.push(
|
|
2159
|
+
`\u7FA4\u804A\u6CA1\u5EFA\u6210\u529F/\u6CA1\u7ED1\u4E0A\uFF08${group.error ?? "\u672A\u77E5\u539F\u56E0"}\uFF09\uFF1A\u4F1A\u8BAE\u672C\u8EAB\u5DF2\u5EFA\u597D\uFF0C\u7FA4\u53EF\u5728 IM \u91CC\u624B\u5DE5\u5EFA\uFF0C\u518D\u628A\u7FA4 id \u4F20\u5230 meeting.eb.meeting.group.ensure \u7684 groupId \u7ED1\u5B9A\u3002`
|
|
2160
|
+
);
|
|
2161
|
+
}
|
|
2162
|
+
} catch (error) {
|
|
2163
|
+
warnings.push(`\u5EFA\u7FA4\u5F02\u5E38\uFF08\u4E0D\u5F71\u54CD\u5EFA\u4F1A\uFF09\uFF1A${String(error?.message ?? error).slice(0, 200)}`);
|
|
2164
|
+
}
|
|
2165
|
+
timings.groupMs = Date.now() - groupStart;
|
|
2166
|
+
}
|
|
2167
|
+
let invitation = { pending: true };
|
|
2168
|
+
if (meetingId) {
|
|
2169
|
+
const invitationStart = Date.now();
|
|
2170
|
+
try {
|
|
2171
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
2172
|
+
const render = getMeetingOperation("meeting.invitation.render");
|
|
2173
|
+
const rendered = await render.handler(
|
|
2174
|
+
{
|
|
2175
|
+
mtId: meetingId,
|
|
2176
|
+
// 同理:会议主表不存客户名,用建会时填的参会客户补「客户单位」
|
|
2177
|
+
extra: { guest_org: String(payload?.invitationFields?.crm_members ?? "").trim() }
|
|
2178
|
+
},
|
|
2179
|
+
env
|
|
2180
|
+
);
|
|
2181
|
+
invitation = { pending: false, ...rendered?.data ?? {} };
|
|
2182
|
+
timings.invitationMs = Date.now() - invitationStart;
|
|
2183
|
+
} catch (error) {
|
|
2184
|
+
invitation = {
|
|
2185
|
+
pending: false,
|
|
2186
|
+
ok: false,
|
|
2187
|
+
error: String(error?.message ?? error).slice(0, 200)
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
} else {
|
|
2191
|
+
const pre = await renderPreInvitation(payload, env);
|
|
2192
|
+
invitation = pre.invitation;
|
|
2193
|
+
timings.invitationMs = pre.ms;
|
|
2194
|
+
warnings.push(
|
|
2195
|
+
`\u6D41\u7A0B\u5DF2\u63D0\u4EA4\uFF08requestId=${requestId || "\u672A\u8FD4\u56DE"}\uFF09\uFF0C\u4F46 ${waitSeconds}s \u5185\u6CA1\u5728\u4F1A\u8BAE\u8868\u91CC\u67E5\u5230\u300C${payload.mtName}\u300D\u2014\u2014\u591A\u6570\u60C5\u51B5\u662F\u8FD8\u5728\u5BA1\u6279\u4E2D\u3002\u5DF2\u6309\u7533\u8BF7\u5355\u4FE1\u606F**\u9884\u751F\u6210**\u9080\u8BF7\u51FD\uFF08\u5C5E\u9884\u7F6E\u51FD\uFF0C\u8BF7\u4EBA\u5DE5\u6838\u5BF9\u540E\u81EA\u884C\u53D1\u9001\uFF09\uFF1B\u5BA1\u6279\u901A\u8FC7\u3001\u4F1A\u8BAE\u751F\u6210\u540E\u53EF\u7528 mtId \u518D\u8DD1\u4E00\u6B21 meeting.invitation.render \u62FF\u5230\u5B8C\u6574\u5B57\u6BB5\u7248\u672C\u3002\u26D4 \u672C operation \u4E0D\u91CD\u590D\u63D0\u4EA4\u6D41\u7A0B \u2014\u2014 \u4E0D\u8981\u56E0\u4E3A"\u6CA1\u6709\u4F1A\u8BAE id"\u5C31\u91CD\u590D apply\u3002`
|
|
2196
|
+
);
|
|
2197
|
+
}
|
|
2198
|
+
const inviteGroupId = String(groupChat?.groupId ?? "").trim();
|
|
2199
|
+
const inviteFilePath = String(invitation?.filePath ?? "").trim();
|
|
2200
|
+
if (inviteGroupId && inviteFilePath) {
|
|
2201
|
+
const sent = await sendInvitationToGroup(env, inviteGroupId, inviteFilePath, warnings);
|
|
2202
|
+
invitation.sentToGroup = { groupId: inviteGroupId, ok: sent.ok };
|
|
2203
|
+
timings.invitationSendMs = sent.ms;
|
|
2204
|
+
}
|
|
2205
|
+
return meetingSuccess(
|
|
2206
|
+
"meeting.eb.meeting.create.flow.apply",
|
|
2207
|
+
{
|
|
2208
|
+
status: "COMPLETE",
|
|
2209
|
+
timings,
|
|
2210
|
+
workflowId: payload.workflowId,
|
|
2211
|
+
requestId,
|
|
2212
|
+
requestName: payload.requestName,
|
|
2213
|
+
meetingId: meetingId || null,
|
|
2214
|
+
// 参会客户有没有真的写进会议记录(表单侧是 Ebuilder,需 apply 补写;回读确认才算 ok)
|
|
2215
|
+
...crmLinked ? { crmLinked } : {},
|
|
2216
|
+
// 同步建的群(群 id / 群名 / 有没有回写 imchat_groupid)
|
|
2217
|
+
...groupChat ? { groupChat } : {},
|
|
2218
|
+
// 提交后回显「实际提交了什么」:字段名 → 值(人员/客户显示姓名,不显示 id)。
|
|
2219
|
+
// 用户要的就是"能看见内容",替代走不通的浏览器填单核对。
|
|
2220
|
+
submittedPreview: renderFormPreview(
|
|
2221
|
+
payload?.fieldLabels ?? [],
|
|
2222
|
+
await decoratePreviewPersonNames(
|
|
2223
|
+
env,
|
|
2224
|
+
payload?.data?.main ?? {},
|
|
2225
|
+
payload?.fieldLabels ?? [],
|
|
2226
|
+
new Map(Object.entries(payload?.personLabels ?? {}))
|
|
2227
|
+
)
|
|
2228
|
+
),
|
|
2229
|
+
invitation,
|
|
2230
|
+
result: submitted?.data ?? null
|
|
2231
|
+
},
|
|
2232
|
+
warnings.length > 0 ? { warnings } : {}
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
2235
|
+
};
|
|
2236
|
+
var ebMeetingCreateFlowQuick = {
|
|
2237
|
+
name: "meeting.eb.meeting.create.flow.quick",
|
|
2238
|
+
resource: "eb",
|
|
2239
|
+
method: "meeting.eb.meeting.create.flow.quick",
|
|
2240
|
+
action: "meeting.eb.meeting.create.flow.quick",
|
|
2241
|
+
summary: '\u4E00\u6B65\u6D41\u7A0B\u5EFA\u4F1A\uFF08prepare+apply \u5408\u5E76\uFF09\uFF1A\u5185\u90E8\u5E76\u884C\u505A\u4F1A\u8BAE\u5BA4\u63A8\u8350/\u51B2\u7A81\u68C0\u6D4B/\u7A7A\u95F2\u65F6\u6BB5\uFF0C\u9ED8\u8BA4**\u5F39\u6D4F\u89C8\u5668\u8868\u5355**\u7ED9\u7528\u6237\u6838\u5BF9\u63D0\u4EA4\uFF08submit_mode=browser\uFF0C\u5C0Fe \u91CC\u9884\u586B\u4EBA\u5458/\u5BA2\u6237\u540E\u7531\u7528\u6237\u70B9\u63D0\u4EA4\uFF1B\u975E\u5C0Fe \u73AF\u5883\u4F1A\u81EA\u52A8\u5199\u670D\u52A1\u7AEF\uFF09\uFF1B\u4F20 submit_mode=direct \u624D\u662F\u670D\u52A1\u7AEF\u76F4\u63D0\uFF08\u62FF requestId + meetingId\uFF0C\u4F1A\u8BAE\u5F53\u573A\u751F\u6210\u3001\u9080\u8BF7\u51FD\u7528\u771F\u5B9E\u6570\u636E\uFF09\u3002\u591A\u6D41\u7A0B\u6216\u9700\u9009\u62E9\u65F6\u4E0D\u63D0\u4EA4\uFF0C\u8FD4\u56DE\u9009\u9879\u3002\u26A0\uFE0F \u7528\u6237\u63D0\u5230\u5BA2\u6237\u540D\u65F6**\u5FC5\u987B\u5148** meeting.eb.crm.search {"keyword":"X"} \u62FF customerId \u518D\u4F20 crm_members:[{id,name}]\uFF1B\u53EA\u628A\u5BA2\u6237\u540D\u5199\u8FDB\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u800C\u4E0D\u4F20 crm_members \u4F1A\u88AB\u76F4\u63A5\u62D2\u7EDD\uFF08crm_member_required\uFF09\u3002\u26D4 \u4E0D\u8981\u7528 submit_mode=browser \u2014\u2014 \u5C0Fe \u586B\u5355\u9875\u4E0D\u7ED9\u6D4F\u89C8\u6309\u94AE\u8D4B\u503C\uFF0C\u53C2\u4F1A\u4EBA\u5458/\u53C2\u4F1A\u5BA2\u6237\u4F1A\u6574\u6BB5\u4E22\u5931',
|
|
2242
|
+
capability: "eb.meeting",
|
|
2243
|
+
risk: "high-risk-write",
|
|
2244
|
+
requiresConfirmation: true,
|
|
2245
|
+
inputSchema: schemaOf(
|
|
2246
|
+
{
|
|
2247
|
+
mt_name: { type: "string", description: "\u4F1A\u8BAE\u540D\u79F0\uFF08\u5FC5\u586B\uFF09" },
|
|
2248
|
+
begin_datetime: {
|
|
2249
|
+
...SCHEMA_DATETIME_MINUTE,
|
|
2250
|
+
description: "\u5F00\u59CB\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\u3002**\u53EF\u4EE5\u4E0D\u4F20**\uFF1A\u4E0D\u4F20\u4F1A\u6309\u53C2\u4F1A\u4EBA\u4E0E\u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u60C5\u51B5\u63A8\u8350 3 \u4E2A\u65F6\u6BB5\u8BA9\u4F60\u9009\uFF1B\u53EA\u4F20\u5F00\u59CB\u65F6\u95F4\u3001\u4E0D\u4F20\u7ED3\u675F\u65F6\u95F4\u65F6\uFF0C\u6309 durationMinutes\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09\u81EA\u52A8\u7B97\u7ED3\u675F\u65F6\u95F4"
|
|
2251
|
+
},
|
|
2252
|
+
end_datetime: {
|
|
2253
|
+
...SCHEMA_DATETIME_MINUTE,
|
|
2254
|
+
description: "\u7ED3\u675F\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309 durationMinutes \u4ECE\u5F00\u59CB\u65F6\u95F4\u63A8\u7B97\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09"
|
|
2255
|
+
},
|
|
2256
|
+
mt_desc: { type: "string", description: "\u4F1A\u8BAE\u5185\u5BB9/\u8BF4\u660E" },
|
|
2257
|
+
address: { type: "string", description: "\u4F1A\u8BAE\u5BA4\uFF08id \u6216\u540D\u79F0\uFF1B\u4E0D\u4F20\u5219\u8FD4\u56DE\u5019\u9009\u8BA9\u7528\u6237\u9009\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u51B3\u5B9A\uFF09" },
|
|
2258
|
+
customize_address: { type: "string", description: "\u81EA\u5B9A\u4E49\u4F1A\u8BAE\u5730\u70B9" },
|
|
2259
|
+
hrm_members: { type: "string", description: "\u53C2\u4F1A\u4EBA\u5458 id\uFF0C\u9017\u53F7\u5206\u9694" },
|
|
2260
|
+
total_member: { type: "number", description: "\u53C2\u4F1A\u4EBA\u6570" },
|
|
2261
|
+
caller: { type: "string", description: "\u53EC\u96C6\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u53EC\u96C6\u4EBA\u624D\u4F20" },
|
|
2262
|
+
contacter: { type: "string", description: "\u8054\u7CFB\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u8054\u7CFB\u4EBA\u624D\u4F20" },
|
|
2263
|
+
mt_type: {
|
|
2264
|
+
type: "string",
|
|
2265
|
+
description: "\u4F1A\u8BAE\u7C7B\u578B\uFF1A\u53EF\u4F20\u7C7B\u578B\u540D\u79F0\u6216 id\uFF08\u5148\u7528 `meeting.eb.type.list` \u67E5\u6709\u54EA\u4E9B\uFF09\u3002**\u5F88\u591A\u79DF\u6237\u7684\u6D41\u7A0B\u8868\u5355\u628A\u300C\u4F1A\u8BAE\u7C7B\u578B\u300D\u8BBE\u4E3A\u5FC5\u586B**\uFF0C\u4E0D\u4F20\u4F1A\u88AB `workflow.createRequest` \u6253\u56DE\u7F3A\u5B57\u6BB5"
|
|
2266
|
+
},
|
|
2267
|
+
other_remark: { type: "string", description: "\u5907\u6CE8" },
|
|
2268
|
+
workflowId: {
|
|
2269
|
+
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
|
|
2270
|
+
description: "\u6307\u5B9A\u5EFA\u4F1A\u6D41\u7A0B id\uFF08\u5355\u4E2A / \u6570\u7EC4 / \u9017\u53F7\u5206\u9694\uFF09\u3002\u4F20\u591A\u4E2A\u65F6\u4E0D\u4F1A\u66FF\u4F60\u9009\uFF1A\u4F1A\u8FD4\u56DE NEEDS_SELECTION \u8BA9\u7528\u6237\u6311"
|
|
2271
|
+
},
|
|
2272
|
+
autoRoom: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u4E0D\u6307\u5B9A\u4F1A\u8BAE\u5BA4\u65F6\u8FD4\u56DE\u5019\u9009\u8BA9\u7528\u6237\u9009\uFF1B\u4F20 true \u624D\u81EA\u52A8\u91C7\u7528\u63A8\u8350\u4F1A\u8BAE\u5BA4" },
|
|
2273
|
+
allowNoRoom: { type: "boolean", description: "\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\uFF08\u7EBF\u4E0A\u4F1A\u7B49\uFF09\u65F6\u4F20 true" },
|
|
2274
|
+
timeConfirmed: {
|
|
2275
|
+
type: "boolean",
|
|
2276
|
+
description: '\u65F6\u95F4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0\uFF1A\u7528\u6237\u539F\u8BDD\u660E\u786E\u7ED9\u4E86\u65F6\u95F4\u3001\u6216\u5728\u65F6\u6BB5\u9009\u9879\u91CC\u70B9\u9009\u540E\u539F\u6837\u56DE\u4F20 value\uFF08\u81EA\u5E26\u6807\u8BB0\uFF09\u65F6\u624D\u4F20 true\uFF1B\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF0CCLI \u4F1A\u8FD4\u56DE\u65F6\u6BB5\u9009\u9879\u8BA9\u7528\u6237\u70B9\u9009'
|
|
2277
|
+
},
|
|
2278
|
+
roomConfirmed: {
|
|
2279
|
+
type: "boolean",
|
|
2280
|
+
description: '\u4F1A\u8BAE\u5BA4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0\uFF1A\u7528\u6237\u539F\u8BDD\u660E\u786E\u6307\u5B9A\u3001\u6216\u5728\u623F\u95F4\u9009\u9879\u91CC\u70B9\u9009\u540E\u539F\u6837\u56DE\u4F20 value\uFF08\u81EA\u5E26\u6807\u8BB0\uFF09\u65F6\u624D\u4F20 true\uFF1B\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF0CCLI \u4F1A\u628A\u6307\u5B9A\u623F\u95F4\u548C\u5019\u9009\u4E00\u8D77\u5217\u51FA\u6765\u8BA9\u7528\u6237\u70B9\u9009'
|
|
2281
|
+
},
|
|
2282
|
+
confirm: { type: "boolean", description: "\u5FC5\u987B\u663E\u5F0F true \u624D\u4F1A\u771F\u6B63\u63D0\u4EA4" },
|
|
2283
|
+
waitSeconds: { type: "number", description: "\u63D0\u4EA4\u540E\u7B49\u5F85\u4F1A\u8BAE\u751F\u6210\u7684\u79D2\u6570\uFF08\u9ED8\u8BA4 20\uFF1B\u7B97\u6CD5\u662F\u7ACB\u5373\u67E5\u4E00\u6B21 + 5s \u518D\u67E5\u4E00\u6B21\uFF0C\u4ECD\u672A\u751F\u6210\u5C31\u8FD4\u56DE pending\uFF09" },
|
|
2284
|
+
enrich: { type: "boolean", description: "\u662F\u5426\u987A\u5E26\u505A\u4F1A\u8BAE\u5BA4\u63A8\u8350/\u51B2\u7A81\u68C0\u6D4B/\u7A7A\u95F2\u65F6\u6BB5\uFF08\u9ED8\u8BA4 true\uFF1B\u4EBA\u3001\u65F6\u95F4\u3001\u623F\u95F4\u90FD\u5DF2\u786E\u5B9A\u65F6\u4F20 false \u53EF\u663E\u8457\u52A0\u5FEB\uFF09" },
|
|
2285
|
+
extraFields: {
|
|
2286
|
+
type: "object",
|
|
2287
|
+
description: '\u6309\u6D41\u7A0B\u8868\u5355\u5B57\u6BB5\u540D\u586B\u989D\u5916\u5B57\u6BB5\uFF08\u79DF\u6237\u81EA\u5EFA\u5B57\u6BB5\u7528\u8FD9\u4E2A\u53E3\u5B50\u5E26\u8FDB\u53BB\uFF09\uFF0C\u5F62\u5982 {"\u53C2\u4F1A\u5BA2\u6237": "xx\u516C\u53F8"}'
|
|
2288
|
+
},
|
|
2289
|
+
dateFrom: {
|
|
2290
|
+
type: "string",
|
|
2291
|
+
description: "\u6CA1\u7ED9\u5177\u4F53\u65F6\u95F4\u65F6\u6309\u54EA\u4E00\u5929\u63A8\u8350\u65F6\u6BB5\uFF08yyyy-MM-dd\uFF1B\u4E0D\u4F20\u9ED8\u8BA4\u660E\u5929\uFF09\u3002\u26A0\uFE0F \u7528\u6237\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u5C31\u5FC5\u987B\u540C\u65F6\u4F20 time_slot \u2014\u2014 \u53EA\u4F20 dateFrom \u4F1A\u5F39\u65F6\u6BB5\u9009\u62E9\u5668\u8BA9\u7528\u6237\u518D\u9009\u4E00\u6B21"
|
|
2292
|
+
},
|
|
2293
|
+
time_slot: {
|
|
2294
|
+
type: "string",
|
|
2295
|
+
enum: ["\u4E0A\u5348", "\u65E9\u4E0A", "\u4E0B\u5348", "\u665A\u4E0A"],
|
|
2296
|
+
description: '\u7528\u6237\u53EA\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u65F6\u4F20\u8FD9\u4E2A\uFF08\u914D\u5408 dateFrom\uFF09\uFF1A\u4E0A\u5348/\u65E9\u4E0A=09:00\u201312:00\u3001\u4E0B\u5348=13:00\u201318:00\u3001\u665A\u4E0A=18:00\u201321:00\uFF0CCLI \u76F4\u63A5\u5B9A\u4E0B\u6765\u3001\u4E0D\u518D\u8FD4\u56DE\u65F6\u6BB5\u5019\u9009\u3002\u26D4 \u4E0D\u8981\u53EA\u4F20 dateFrom \u5C31\u671F\u5F85"\u8BA9\u7528\u6237\u9009\u65F6\u6BB5"\u2014\u2014\u7528\u6237\u5DF2\u7ECF\u8BF4\u4E86\u65F6\u6BB5\u5C31\u522B\u518D\u95EE'
|
|
2297
|
+
},
|
|
2298
|
+
durationMinutes: {
|
|
2299
|
+
type: "number",
|
|
2300
|
+
description: "\u4F1A\u8BAE\u65F6\u957F\uFF08\u5206\u949F\uFF0C\u9ED8\u8BA4 60\uFF09\uFF1A\u53EA\u7ED9\u4E86\u5F00\u59CB\u65F6\u95F4\u65F6\u7528\u6765\u7B97\u7ED3\u675F\u65F6\u95F4\uFF1B\u63A8\u8350\u65F6\u6BB5\u65F6\u4E5F\u6309\u8FD9\u4E2A\u65F6\u957F\u627E"
|
|
2301
|
+
},
|
|
2302
|
+
workStartHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u65E9\u5C0F\u65F6\uFF08\u9ED8\u8BA4 9\uFF09" },
|
|
2303
|
+
workEndHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u665A\u5C0F\u65F6\uFF08\u9ED8\u8BA4 18\uFF09" },
|
|
2304
|
+
fieldValues: {
|
|
2305
|
+
type: "object",
|
|
2306
|
+
additionalProperties: true,
|
|
2307
|
+
description: '\u6309**\u8868\u5355\u5B57\u6BB5 datakey\uFF08fieldId\uFF09**\u76F4\u63A5\u7ED9\u503C\uFF0C\u5F62\u5982 {"1325677252711735881": "\u7814\u8BA8\u4F1A"}\uFF1B\u4F18\u5148\u7EA7\u6700\u9AD8\uFF0C\u9002\u5408\u5B57\u6BB5\u540D\u5E26\u63D0\u793A\u8BED\u6216\u79DF\u6237\u81EA\u5EFA\u5B57\u6BB5\u3002datakey \u89C1 prepare \u7684 preview.mapped'
|
|
2308
|
+
},
|
|
2309
|
+
flowChoice: {
|
|
2310
|
+
type: "string",
|
|
2311
|
+
enum: ["auto", "ask"],
|
|
2312
|
+
description: "\u591A\u4E2A\u5EFA\u4F1A\u6D41\u7A0B**\u90FD\u6709\u53D1\u8D77\u6743\u9650**\u65F6\uFF1A\u9ED8\u8BA4\uFF08\u4E0D\u4F20 / ask\uFF09= \u8FD4\u56DE\u9009\u9879\u8BA9\u7528\u6237\u6311\uFF1Bauto = \u81EA\u52A8\u53D6\u4F18\u5148\u7EA7\u6700\u9AD8\u7684\u3002\u6709\u6D41\u7A0B\u8BB0\u5FC6\uFF08\u4E0A\u6B21\u6210\u529F\u7528\u8FC7\u7684\u6D41\u7A0B\uFF09\u4E14\u4ECD\u53EF\u53D1\u8D77\u65F6\u9ED8\u8BA4\u6CBF\u7528\u4E0A\u6B21\u9009\u62E9\uFF0C\u4F20 ask \u5F3A\u5236\u6BCF\u6B21\u90FD\u95EE\u3002\u53EA\u6709 1 \u4E2A\u6709\u6743\u9650\u65F6\u76F4\u63A5\u53D1\u8D77"
|
|
2313
|
+
},
|
|
2314
|
+
crm_skip: {
|
|
2315
|
+
type: "boolean",
|
|
2316
|
+
description: "\u663E\u5F0F\u58F0\u660E\u300C\u8FD9\u6B21\u4E0D\u586B\u53C2\u4F1A\u5BA2\u6237\u300D\u3002\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u91CC\u51FA\u73B0 `\u5BA2\u6237\uFF1AX`\u3001`\u5BA2\u6237\u662FX` \u8FD9\u7C7B\u5B57\u6837\u5374**\u6CA1\u4F20 `crm_members`**\u65F6\uFF0C\u4E00\u6B65\u5EFA\u4F1A\u4F1A\u76F4\u63A5\u62D2\u7EDD\uFF08crm_member_required\uFF09\u2014\u2014\u786E\u8BA4\u8FD9\u4E9B\u5B57\u6837\u4E0D\u662F\u8981\u4E0A\u4F1A\u8868\u7684\u5BA2\u6237\uFF0C\u624D\u4F20 true"
|
|
2317
|
+
},
|
|
2318
|
+
submit_mode: {
|
|
2319
|
+
type: "string",
|
|
2320
|
+
enum: ["direct", "browser"],
|
|
2321
|
+
description: '\u63D0\u4EA4\u65B9\u5F0F\uFF0C\u9ED8\u8BA4 browser\uFF1A\u5728\u5C0Fe \u91CC**\u5F39\u51FA\u6D41\u7A0B\u8868\u5355**\uFF08\u5B57\u6BB5\u5DF2\u9884\u586B\u542B\u4EBA\u5458/\u5BA2\u6237\uFF09\uFF0C\u7528\u6237\u6838\u5BF9\u4FEE\u6539\u540E\u81EA\u5DF1\u70B9\u63D0\u4EA4\u3002direct = \u76F4\u63A5\u5199\u670D\u52A1\u7AEF\uFF08\u4F1A\u8BAE\u5F53\u573A\u751F\u6210\u3001\u9080\u8BF7\u51FD\u7528\u771F\u5B9E\u6570\u636E\uFF0C\u4F46\u6CA1\u6709\u4EBA\u5DE5\u6838\u5BF9\u8868\u5355\u8FD9\u4E00\u6B65\uFF09\uFF1B\u53EA\u6709\u7528\u6237\u660E\u786E\u8BF4"\u4E0D\u7528\u6211\u786E\u8BA4\uFF0C\u76F4\u63A5\u5EFA"\u65F6\u624D\u4F20 direct'
|
|
2322
|
+
}
|
|
2323
|
+
},
|
|
2324
|
+
{ required: ["mt_name", "confirm"] }
|
|
2325
|
+
),
|
|
2326
|
+
handler: async (args, env) => {
|
|
2327
|
+
if (args.confirm !== true) {
|
|
2328
|
+
throw meetingValidationError(
|
|
2329
|
+
"confirmation_required",
|
|
2330
|
+
"\u4E00\u6B65\u5EFA\u4F1A\u4F1A\u76F4\u63A5\u63D0\u4EA4\u6D41\u7A0B\uFF0C\u5FC5\u987B\u663E\u5F0F\u4F20 confirm=true\uFF1B\u5982\u53EA\u60F3\u770B\u65B9\u6848\uFF0C\u8BF7\u7528 meeting.eb.meeting.create.flow.prepare"
|
|
2331
|
+
);
|
|
2332
|
+
}
|
|
2333
|
+
const crmMentioned = detectCrmMentionInText(args.mt_name, args.mt_desc, args.other_remark);
|
|
2334
|
+
const crmSkipped = args.crm_skip === true;
|
|
2335
|
+
if (crmMentioned && !args.crm_members && !crmSkipped) {
|
|
2336
|
+
throw meetingValidationError(
|
|
2337
|
+
"crm_member_required",
|
|
2338
|
+
`\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u91CC\u63D0\u5230\u5BA2\u6237\u300C${crmMentioned}\u300D\uFF0C\u4F46\u6CA1\u4F20 crm_members \u2014\u2014 \u63D0\u4EA4\u540E\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u4F1A\u662F\u7A7A\u7684\u3002\u5148 meeting.eb.crm.search {"keyword":"${crmMentioned}"} \u62FF items[].customerId\uFF0C\u518D\u628A crm_members:[{"id":"<customerId>","name":"<\u5B8C\u6574\u5BA2\u6237\u540D>"}] \u4E00\u8D77\u4F20\uFF08\u5FC5\u987B\u5E26\u540D\u79F0\uFF0C\u53EA\u7ED9 id \u4F1A\u88AB\u9759\u9ED8\u5B58\u7A7A\uFF09\uFF1B\u786E\u5B9E\u4E0D\u9700\u8981\u586B\u53C2\u4F1A\u5BA2\u6237\u5C31\u4F20 crm_skip:true\u3002`
|
|
2339
|
+
);
|
|
2340
|
+
}
|
|
2341
|
+
const { getMeetingOperation } = await import("./registry-BKBZPBAJ.js");
|
|
2342
|
+
const prepareStartedAt = Date.now();
|
|
2343
|
+
const { submit_mode: _submitMode, confirm: _confirm, ...prepareArgs } = args;
|
|
2344
|
+
const prepared = await getMeetingOperation("meeting.eb.meeting.create.flow.prepare").handler(
|
|
2345
|
+
// submit_mode 只属于提交阶段,prepare 的 schema 不接受它(additionalProperties:false)
|
|
2346
|
+
prepareArgs,
|
|
2347
|
+
env
|
|
2348
|
+
);
|
|
2349
|
+
if (prepared?.data?.status === "NEEDS_SELECTION") {
|
|
2350
|
+
return prepared;
|
|
2351
|
+
}
|
|
2352
|
+
const continuation = String(prepared?.data?.continuation ?? "");
|
|
2353
|
+
if (!continuation) {
|
|
2354
|
+
throw meetingValidationError("flow_prepare_failed", "\u5EFA\u4F1A\u6D41\u7A0B\u51C6\u5907\u9636\u6BB5\u6CA1\u6709\u8FD4\u56DE\u786E\u8BA4\u7968\u636E\uFF0C\u672A\u63D0\u4EA4");
|
|
2355
|
+
}
|
|
2356
|
+
const prepareMs = Date.now() - prepareStartedAt;
|
|
2357
|
+
const applyStartedAt = Date.now();
|
|
2358
|
+
const applied = await getMeetingOperation("meeting.eb.meeting.create.flow.apply").handler(
|
|
2359
|
+
{
|
|
2360
|
+
continuation,
|
|
2361
|
+
confirm: true,
|
|
2362
|
+
...args.submit_mode ? { submit_mode: args.submit_mode } : {},
|
|
2363
|
+
...args.waitSeconds !== void 0 ? { waitSeconds: args.waitSeconds } : {}
|
|
2364
|
+
},
|
|
2365
|
+
env
|
|
2366
|
+
);
|
|
2367
|
+
const warnings = [
|
|
2368
|
+
...prepared?.warnings ?? [],
|
|
2369
|
+
...applied?.warnings ?? []
|
|
2370
|
+
];
|
|
2371
|
+
return meetingSuccess(
|
|
2372
|
+
"meeting.eb.meeting.create.flow.quick",
|
|
2373
|
+
{
|
|
2374
|
+
status: applied?.data?.status ?? "COMPLETE",
|
|
2375
|
+
workflowId: applied?.data?.workflowId,
|
|
2376
|
+
requestId: applied?.data?.requestId,
|
|
2377
|
+
meetingId: applied?.data?.meetingId ?? null,
|
|
2378
|
+
invitation: applied?.data?.invitation ?? null,
|
|
2379
|
+
// 同步建的群(群 id / 群名 / 有没有回写 imchat_groupid)
|
|
2380
|
+
...applied?.data?.groupChat ? { groupChat: (applied?.data).groupChat } : {},
|
|
2381
|
+
// 已提交内容回显(字段名 → 值),提交后可直接贴给用户看"到底填进去了什么"
|
|
2382
|
+
submittedPreview: applied?.data?.submittedPreview ?? null,
|
|
2383
|
+
// 小e 环境(BROWSER_FILL)不写服务端,表单靠这段 <browsertool> 在浏览器里填 —— 必须一起透出,
|
|
2384
|
+
// 否则宿主拿不到表单,用户看到的就是"提交了但没反应"。
|
|
2385
|
+
...applied?.data?.contextId ? { contextId: (applied?.data).contextId } : {},
|
|
2386
|
+
...applied?.data?.finalMarkdown ? { finalMarkdown: (applied?.data).finalMarkdown } : {},
|
|
2387
|
+
...applied?.data?.finalMarkdownHint ? { finalMarkdownHint: (applied?.data).finalMarkdownHint } : {},
|
|
2388
|
+
decisions: prepared?.data?.preview?.decisions ?? null,
|
|
2389
|
+
timings: {
|
|
2390
|
+
...prepared?.data?.preview?.decisions?.timings ?? {},
|
|
2391
|
+
// apply 侧的分段耗时(提交/轮询/邀请函)也要带出来,否则"到底慢在哪"还是看不清
|
|
2392
|
+
...applied?.data?.timings ?? {},
|
|
2393
|
+
prepareMs,
|
|
2394
|
+
applyMs: Date.now() - applyStartedAt,
|
|
2395
|
+
totalMs: Date.now() - prepareStartedAt
|
|
2396
|
+
}
|
|
2397
|
+
},
|
|
2398
|
+
warnings.length > 0 ? { warnings } : {}
|
|
2399
|
+
);
|
|
2400
|
+
}
|
|
2401
|
+
};
|
|
2402
|
+
var ebMeetingCreateSuggest = {
|
|
2403
|
+
name: "meeting.eb.meeting.create.suggest",
|
|
2404
|
+
resource: "eb",
|
|
2405
|
+
method: "meeting.eb.meeting.create.suggest",
|
|
2406
|
+
action: "meeting.eb.meeting.create.suggest",
|
|
2407
|
+
summary: "\u5EFA\u4F1A\u5EFA\u8BAE\uFF1A\u7ED9\u5B9A\u65E5\u671F\u8303\u56F4\u4E0E\u53C2\u4F1A\u4EBA\uFF0C\u63A8\u8350\u300C\u6240\u6709\u4EBA\u90FD\u7A7A\u95F2 + \u8BE5\u65F6\u6BB5\u6709\u53EF\u7528\u4F1A\u8BAE\u5BA4\u300D\u7684\u65F6\u95F4\u5019\u9009\uFF08\u53EA\u8BFB\uFF0C\u4E0D\u5EFA\u4F1A\uFF09",
|
|
2408
|
+
capability: "eb.meeting",
|
|
2409
|
+
risk: "read",
|
|
2410
|
+
inputSchema: schemaOf(
|
|
2411
|
+
{
|
|
2412
|
+
dateFrom: { type: "string", description: "\u8D77\u59CB\u65E5\u671F\uFF08\u5FC5\u586B\uFF0Cyyyy-MM-dd\uFF09" },
|
|
2413
|
+
dateTo: { type: "string", description: "\u7ED3\u675F\u65E5\u671F\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u540C dateFrom\uFF1B\u6700\u591A\u8DE8 14 \u5929\uFF09" },
|
|
2414
|
+
durationMinutes: { type: "number", description: "\u4F1A\u8BAE\u65F6\u957F\uFF08\u5206\u949F\uFF0C\u9ED8\u8BA4 60\uFF09" },
|
|
2415
|
+
hrm_members: { type: "string", description: "\u53C2\u4F1A\u4EBA\u5458\uFF08\u5FC5\u586B\uFF0C\u5458\u5DE5 id \u6216\u59D3\u540D\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u59D3\u540D\u4F1A\u81EA\u52A8\u53CD\u67E5 id\uFF09" },
|
|
2416
|
+
memberCount: { type: "number", description: "\u53C2\u4F1A\u4EBA\u6570\uFF08\u53EF\u9009\uFF0C\u7528\u4E8E\u4F1A\u8BAE\u5BA4\u5BB9\u91CF\u7B5B\u9009\uFF1B\u4E0D\u4F20\u5219\u6309 hrm_members \u4E2A\u6570\uFF09" },
|
|
2417
|
+
workStartHour: { type: "number", description: "\u53EA\u5728\u51E0\u70B9\u4EE5\u540E\u627E\uFF08\u9ED8\u8BA4 9\uFF09" },
|
|
2418
|
+
workEndHour: { type: "number", description: "\u53EA\u5728\u51E0\u70B9\u4EE5\u524D\u627E\uFF08\u9ED8\u8BA4 18\uFF09" },
|
|
2419
|
+
maxSlots: { type: "number", description: "\u6700\u591A\u7ED9\u51E0\u4E2A\u65F6\u95F4\u5019\u9009\uFF08\u9ED8\u8BA4 3\uFF0C\u6700\u5927 8\uFF09" },
|
|
2420
|
+
topN: { type: "number", description: "\u6BCF\u4E2A\u65F6\u95F4\u5019\u9009\u6700\u591A\u5E26\u51E0\u95F4\u4F1A\u8BAE\u5BA4\uFF08\u9ED8\u8BA4 3\uFF09" },
|
|
2421
|
+
includeSchedule: { type: "boolean", description: "\u662F\u5426\u628A\u65E5\u7A0B\uFF08ESB\uFF09\u4E5F\u7B97\u8FDB\u5360\u7528\uFF08\u9ED8\u8BA4 true\uFF09" }
|
|
2422
|
+
},
|
|
2423
|
+
{ required: ["dateFrom", "hrm_members"] }
|
|
2424
|
+
),
|
|
2425
|
+
handler: async (args, env) => {
|
|
2426
|
+
const dateFrom = String(args.dateFrom ?? "").trim().slice(0, 10);
|
|
2427
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateFrom)) {
|
|
2428
|
+
throw meetingValidationError("datetime_invalid", `dateFrom \u5FC5\u987B\u662F yyyy-MM-dd\uFF0C\u6536\u5230\u300C${String(args.dateFrom ?? "")}\u300D`);
|
|
2429
|
+
}
|
|
2430
|
+
const dateTo = String(args.dateTo ?? "").trim().slice(0, 10) || dateFrom;
|
|
2431
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateTo)) {
|
|
2432
|
+
throw meetingValidationError("datetime_invalid", `dateTo \u5FC5\u987B\u662F yyyy-MM-dd\uFF0C\u6536\u5230\u300C${String(args.dateTo ?? "")}\u300D`);
|
|
2433
|
+
}
|
|
2434
|
+
const durationMinutes = Number(args.durationMinutes) > 0 ? Number(args.durationMinutes) : 60;
|
|
2435
|
+
const maxSlots = Math.max(1, Math.min(8, Number(args.maxSlots) || 3));
|
|
2436
|
+
const topN = Math.max(1, Math.min(5, Number(args.topN) || 3));
|
|
2437
|
+
const rawMembers = String(args.hrm_members ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
|
|
2438
|
+
const nameLike = rawMembers.filter((item) => !/^\d+$/.test(item));
|
|
2439
|
+
const nameToId = nameLike.length > 0 ? await import("./schedule-FNXKH3DQ.js").then((m) => m.resolveMemberIdsByName(env, nameLike)).catch(() => /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
|
|
2440
|
+
const memberIds = rawMembers.map((item) => nameToId.get(item) ?? item);
|
|
2441
|
+
const unresolved = rawMembers.filter((item) => nameToId.get(item) === void 0 && !/^\d+$/.test(item));
|
|
2442
|
+
const selfId = await env.host.getSession().then((s) => String(s?.userId ?? "")).catch(() => "");
|
|
2443
|
+
const selfIncluded = selfId !== "" && memberIds.includes(selfId);
|
|
2444
|
+
const memberCount = Number(args.memberCount) > 0 ? Number(args.memberCount) : memberIds.length > 0 ? memberIds.length + (selfIncluded ? 0 : 1) : void 0;
|
|
2445
|
+
const warnings = [];
|
|
2446
|
+
if (unresolved.length > 0) {
|
|
2447
|
+
warnings.push(`\u26A0\uFE0F \u8FD9\u4E9B\u53C2\u4F1A\u4EBA\u6CA1\u67E5\u5230\u5458\u5DE5 id\uFF1A${unresolved.join("\u3001")} \u2014\u2014 \u5DF2\u8DF3\u8FC7\uFF0C\u5176\u7A7A\u95F2\u60C5\u51B5**\u672A\u6838\u9A8C**`);
|
|
2448
|
+
}
|
|
2449
|
+
const free = await findCommonFreeSlots(env, {
|
|
2450
|
+
rangeStart: `${dateFrom} 00:00`,
|
|
2451
|
+
rangeEnd: `${dateTo} 23:59`,
|
|
2452
|
+
durationMinutes,
|
|
2453
|
+
members: memberIds,
|
|
2454
|
+
maxSlots,
|
|
2455
|
+
maxDays: 14,
|
|
2456
|
+
includeSchedule: args.includeSchedule !== false,
|
|
2457
|
+
...args.workStartHour !== void 0 ? { workStartHour: Number(args.workStartHour) } : {},
|
|
2458
|
+
...args.workEndHour !== void 0 ? { workEndHour: Number(args.workEndHour) } : {}
|
|
2459
|
+
});
|
|
2460
|
+
await loadRooms(env, { refresh: true }).catch(() => null);
|
|
2461
|
+
const withRooms = await Promise.all((free.slots ?? []).map(async (slot) => {
|
|
2462
|
+
try {
|
|
2463
|
+
const rec = await recommendRooms(env, {
|
|
2464
|
+
beginDatetime: slot.begin,
|
|
2465
|
+
endDatetime: slot.end,
|
|
2466
|
+
...memberCount ? { memberCount } : {},
|
|
2467
|
+
topN
|
|
2468
|
+
});
|
|
2469
|
+
return {
|
|
2470
|
+
begin: slot.begin,
|
|
2471
|
+
end: slot.end,
|
|
2472
|
+
rooms: rec.candidates.map((candidate) => ({
|
|
2473
|
+
id: candidate.id,
|
|
2474
|
+
name: candidate.name,
|
|
2475
|
+
capacityMax: candidate.capacity.max,
|
|
2476
|
+
reasons: candidate.reasons
|
|
2477
|
+
}))
|
|
2478
|
+
};
|
|
2479
|
+
} catch {
|
|
2480
|
+
return { begin: slot.begin, end: slot.end, rooms: [] };
|
|
2481
|
+
}
|
|
2482
|
+
}));
|
|
2483
|
+
const usable = withRooms.filter((slot) => slot.rooms.length > 0);
|
|
2484
|
+
if (usable.length === 0) {
|
|
2485
|
+
const why = (free.slots ?? []).length === 0 ? "\u8BE5\u8303\u56F4\u5185\u6240\u6709\u53C2\u4F1A\u4EBA\u6CA1\u6709\u5171\u540C\u7684\u7A7A\u95F2\u65F6\u6BB5" : `${(free.slots ?? []).length} \u4E2A\u300C\u4EBA\u7A7A\u95F2\u300D\u7684\u65F6\u6BB5\u91CC\uFF0C\u6CA1\u6709\u4E00\u4E2A\u8FD8\u80FD\u8BA2\u5230\u4F1A\u8BAE\u5BA4`;
|
|
2486
|
+
warnings.push(
|
|
2487
|
+
`\u6CA1\u627E\u5230\u540C\u65F6\u6EE1\u8DB3\u300C\u4EBA\u5458\u7A7A\u95F2 + \u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u300D\u7684\u65F6\u95F4\u5019\u9009\uFF1A${why}\u3002\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\uFF0C\u5E76\u5EFA\u8BAE\u6362\u4E2A\u65E5\u671F\u8303\u56F4\u3001\u7F29\u77ED\u65F6\u957F\uFF0C\u6216\u6539\u4E3A\u7EBF\u4E0A\u4F1A\u8BAE\uFF08allowNoRoom: true\uFF09\u3002`
|
|
2488
|
+
);
|
|
2489
|
+
if (free.blockingSummary) warnings.push(`\u5F53\u5929\u5360\u7528\u6982\u51B5\uFF1A${free.blockingSummary}`);
|
|
2490
|
+
}
|
|
2491
|
+
return meetingSuccess(
|
|
2492
|
+
"meeting.eb.meeting.create.suggest",
|
|
2493
|
+
{
|
|
2494
|
+
dateFrom,
|
|
2495
|
+
dateTo,
|
|
2496
|
+
durationMinutes,
|
|
2497
|
+
// 同样是"让用户点一下":时段候选用选项控件呈现,别写成文本列表
|
|
2498
|
+
ui: { component: "choice", multiple: false, recommendedKey: "T1" },
|
|
2499
|
+
slots: usable.map((slot, index) => ({
|
|
2500
|
+
key: `T${index + 1}`,
|
|
2501
|
+
label: `${slot.begin.slice(5, 10)} ${slot.begin.slice(11)}~${slot.end.slice(11)}`,
|
|
2502
|
+
value: { begin: slot.begin, end: slot.end, address: slot.rooms[0]?.id ?? null },
|
|
2503
|
+
reason: `${memberCount ? `${memberCount} \u4EBA\u5168\u90E8\u7A7A\u95F2\uFF08\u4F1A\u8BAE\u56DE\u6267 + \u65E5\u7A0B\u5DF2\u6838\uFF09\uFF1B` : ""}${slot.rooms.length} \u95F4\u4F1A\u8BAE\u5BA4\u53EF\u7528\uFF1A${slot.rooms.map((room) => room.name).join("\u3001")}`,
|
|
2504
|
+
rooms: slot.rooms
|
|
2505
|
+
})),
|
|
2506
|
+
// 把"人空闲但没房间"的时段也带出来,方便调用方解释为什么被剔除
|
|
2507
|
+
skippedSlots: withRooms.filter((slot) => slot.rooms.length === 0),
|
|
2508
|
+
memberIds,
|
|
2509
|
+
scheduleItems: free.scheduleItems,
|
|
2510
|
+
idle: free.idle,
|
|
2511
|
+
cost: free.cost
|
|
2512
|
+
},
|
|
2513
|
+
warnings.length > 0 ? { warnings } : {}
|
|
2514
|
+
);
|
|
2515
|
+
}
|
|
2516
|
+
};
|
|
2517
|
+
var meetingEbCreateFlowOperations = [
|
|
2518
|
+
ebMeetingCreateSuggest,
|
|
2519
|
+
ebMeetingCreateFlowPrepare,
|
|
2520
|
+
ebMeetingCreateFlowApply,
|
|
2521
|
+
ebMeetingCreateFlowQuick
|
|
2522
|
+
];
|
|
2523
|
+
|
|
2524
|
+
export {
|
|
2525
|
+
resolveSelfPerson,
|
|
2526
|
+
applySelfPersonDefaults,
|
|
2527
|
+
parseRoomRef,
|
|
2528
|
+
resolveAddressRoom,
|
|
2529
|
+
shapeBrowserValues,
|
|
2530
|
+
resolveCrmDetailTarget,
|
|
2531
|
+
detectCrmMentionInText,
|
|
2532
|
+
normalizeCrmDetailRows,
|
|
2533
|
+
crmMemberEntriesFromArgs,
|
|
2534
|
+
crmContactsToDetailRows,
|
|
2535
|
+
mapFields,
|
|
2536
|
+
renderFormPreview,
|
|
2537
|
+
readFlowFieldMap,
|
|
2538
|
+
normalizeWorkflowIds,
|
|
2539
|
+
fixedFlowIds,
|
|
2540
|
+
fixedFlowIdsForEnv,
|
|
2541
|
+
shouldAutoPickFlow,
|
|
2542
|
+
resolveWorkflowId,
|
|
2543
|
+
patchMeetingCrmMembers,
|
|
2544
|
+
renderPreInvitation,
|
|
2545
|
+
meetingEbCreateFlowOperations
|
|
2546
|
+
};
|