weaver-work-cli 0.1.45 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/chunks/{attachment-content-CE3GMWTS.js → attachment-content-MCXQBD6N.js} +3 -3
  2. package/dist/chunks/{chunk-VIMCY4DI.js → chunk-4RWS2YYL.js} +2 -2
  3. package/dist/chunks/{chunk-4EXOIQDI.js → chunk-6AXKWFKG.js} +4 -14
  4. package/dist/chunks/{chunk-JWWTI63L.js → chunk-6V5ZPKHV.js} +2 -8
  5. package/dist/chunks/{chunk-3ZMAQQ3W.js → chunk-76H3IKH6.js} +39 -26
  6. package/dist/chunks/{chunk-LGKWL4OH.js → chunk-AD46OMQK.js} +86 -25
  7. package/dist/chunks/{chunk-3WBIQLMB.js → chunk-GSZTA43P.js} +2 -2
  8. package/dist/chunks/{chunk-OAE3AZBQ.js → chunk-IP4CWQCF.js} +6 -6
  9. package/dist/chunks/{chunk-77YP6I52.js → chunk-IRMIEDXN.js} +1 -1
  10. package/dist/chunks/{chunk-LRCPNDZA.js → chunk-J2VEB5K3.js} +11 -9
  11. package/dist/chunks/{chunk-T4MWQAQB.js → chunk-JFAWZX53.js} +128 -9
  12. package/dist/chunks/{chunk-GR76ZDDX.js → chunk-LIEQJIGM.js} +3 -0
  13. package/dist/chunks/{chunk-DGMYACGJ.js → chunk-OXHHJWNC.js} +1 -1
  14. package/dist/chunks/{chunk-LXFVWZLM.js → chunk-PSOMGA3U.js} +3 -3
  15. package/dist/chunks/{conflict-IYJETSGT.js → conflict-H7EHQXYY.js} +2 -2
  16. package/dist/chunks/{create-flow-7JLC7UID.js → create-flow-VRVJEOBX.js} +6 -6
  17. package/dist/chunks/{ehr-MYRDCHZ4.js → ehr-SH2LM3NK.js} +528 -40
  18. package/dist/chunks/{env-3MBHAWBL.js → env-66FPSJDV.js} +2 -2
  19. package/dist/chunks/{factory-TZEVU4DU.js → factory-UH2TZBVA.js} +1 -1
  20. package/dist/chunks/{group-chat-KL3HFKRM.js → group-chat-CAKMMV7K.js} +3 -3
  21. package/dist/chunks/{invoice-OQP3TMKQ.js → invoice-UEAHSYAE.js} +279 -1
  22. package/dist/chunks/{lazy-dispatch-UH6HGK2I.js → lazy-dispatch-25XGTXLM.js} +2 -2
  23. package/dist/chunks/{meeting-C67EHQ4Z.js → meeting-VTBFW4HI.js} +10 -10
  24. package/dist/chunks/{recruit-stage-AHY5QAMF.js → recruit-stage-CAKZTUA7.js} +917 -85
  25. package/dist/chunks/{registry-XPWPGHYE.js → registry-JVQBLFQ5.js} +10 -10
  26. package/dist/chunks/{room-recommend-CNWE5WQK.js → room-recommend-5U55FMXZ.js} +4 -4
  27. package/dist/chunks/{schedule-YYNYBQIE.js → schedule-IDETODCA.js} +4 -4
  28. package/dist/cmd/action.js +14 -10
  29. package/dist/index.js +7 -7
  30. package/dist/shortcuts/ehr/host.js +2 -2
  31. package/dist/shortcuts/ehr/index.js +14 -3
  32. package/dist/shortcuts/ehr/manifest.js +5 -1
  33. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +40 -10
  34. package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
  35. package/dist/shortcuts/ehr/operations/recruit-position.js +10 -8
  36. package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
  37. package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
  38. package/dist/shortcuts/ehr/operations/recruit-write.js +137 -18
  39. package/dist/shortcuts/ehr/operations/recruit.js +180 -8
  40. package/dist/shortcuts/ehr/operations/registry.js +4 -0
  41. package/dist/shortcuts/ehr/operations.js +24 -0
  42. package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
  43. package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
  44. package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
  45. package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
  46. package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
  47. package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
  48. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
  49. package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
  50. package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
  51. package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
  52. package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
  53. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
  54. package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
  55. package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
  56. package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
  57. package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
  58. package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
  59. package/dist/shortcuts/invoice/host.js +3 -0
  60. package/dist/shortcuts/invoice/manifest.js +61 -0
  61. package/dist/shortcuts/invoice/operations/registry.js +2 -0
  62. package/dist/shortcuts/invoice/operations/reim-subsidy.js +233 -0
  63. package/dist/shortcuts/meeting/operations/eb/create-flow.js +93 -18
  64. package/dist/shortcuts/meeting/operations/eb/factory.js +5 -8
  65. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +2 -13
  66. package/dist/shortcuts/meeting/operations/invitation.js +27 -4
  67. package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
  68. package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
  69. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +277 -20
  70. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +31 -7
  71. package/dist/shortcuts/recruit-stage/operations/jd-create.js +106 -16
  72. package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
  73. package/dist/shortcuts/recruit-stage/operations/resume-import.js +273 -6
  74. package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
  75. package/dist/shortcuts/recruit-stage/shared.js +60 -6
  76. package/docs/invoice.md +1 -0
  77. package/package.json +1 -1
  78. package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +2 -2
  79. package/skills/weaver-e10-jucailin/SKILL.md +12 -3
  80. package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
  81. package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
  82. package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
  83. package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
  84. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
  85. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
  86. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
  87. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
  88. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
  89. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
  90. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
  91. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
  92. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
  93. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
  94. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
  95. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
  96. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
  97. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
  98. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
  99. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
  100. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
  101. package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
  102. package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
  103. package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -93
  104. package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
  105. package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
  106. package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
  107. package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
  108. package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
  109. package/skills/weaver-e10-jucailin/references/recruit-write.md +53 -9
  110. package/skills/weaver-e10-meeting/SKILL.md +48 -4
  111. package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
  112. package/skills/weaver-e10-recruit-stage/SKILL.md +8 -5
  113. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +16 -6
  114. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
  115. package/skills/weaver-e10-recruit-stage/references/position-templates.md +20 -1
  116. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +21 -0
  117. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +4 -0
  118. package/skills/weaver-e10-yepiaotong/SKILL.md +7 -5
  119. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +1 -1
  120. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +9 -2
  121. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +2 -0
  122. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +2 -0
  123. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +68 -6
  124. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +3 -3
  125. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +8 -15
  126. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +6 -5
  127. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +206 -92
  128. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +26 -21
  129. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +35 -0
@@ -369,5 +369,8 @@ export function createInvoiceHost(ctx, dependencies = {}) {
369
369
  invoiceToken = null;
370
370
  void clearCachedInvoiceToken();
371
371
  },
372
+ debug(message) {
373
+ ctx.logger?.debug?.(message);
374
+ },
372
375
  };
373
376
  }
@@ -931,6 +931,67 @@ export const invoiceOperations = [
931
931
  },
932
932
  outputSchema: reimCandidatesOutputSchema,
933
933
  },
934
+ {
935
+ name: 'invoice.reim.subsidy.submit',
936
+ risk: 'high-risk-write',
937
+ fixed: {
938
+ path: '/api/secondev/fna/expense/reimbursement/aiCreateWf',
939
+ autoCommit: '1',
940
+ currentEmpId: 'session.userId',
941
+ detailList: 'invoices 每张一行 {relatedProcessId, relatedInvoiceId, reimbursedAmount},relatedProcessId 全部相同;reimbursedAmount 取该发票 total,合计不超过 monthlyAllowance,超额那行报「额度 − 前面行累加」,额度用完后剩下的发票不进明细',
942
+ },
943
+ inputSchema: {
944
+ type: 'object',
945
+ additionalProperties: false,
946
+ required: ['processTitle', 'reason', 'relatedProcessId', 'invoices'],
947
+ properties: {
948
+ processTitle: { type: 'string', minLength: 1, description: '报销流程标题,如「龚为明10月话费报销」' },
949
+ reason: { type: 'string', minLength: 1, description: '报销事由,如「10月话费」' },
950
+ relatedProcessId: { ...positiveId, description: '话费 / 油费事前申请的 requestId' },
951
+ invoices: {
952
+ type: 'array',
953
+ minItems: 1,
954
+ maxItems: 100,
955
+ description: '本次报销的发票,每张生成一行明细;顺序即额度扣减顺序',
956
+ items: {
957
+ type: 'object',
958
+ additionalProperties: false,
959
+ required: ['fid', 'total'],
960
+ properties: {
961
+ fid: { ...positiveId, description: '票夹发票 fid' },
962
+ total: { type: 'string', pattern: '^\\d+(\\.\\d{1,2})?$', description: '这张发票的价税合计(invoice.list 的 total)' },
963
+ },
964
+ },
965
+ },
966
+ monthlyAllowance: { type: 'string', pattern: '^\\d+(\\.\\d{1,2})?$', description: '事前申请的「月补贴额度」;不传表示不封顶' },
967
+ customerId: { ...positiveId, default: '100504500000311504', description: '相关客户 ID;不传默认泛微上海 100504500000311504' },
968
+ projectId: { type: 'string', pattern: '^([1-9]\\d*)?$', default: '', description: '相关项目 ID;没有指定时不传或传空字符串' },
969
+ },
970
+ },
971
+ outputSchema: objectSchema({
972
+ requestId: { type: 'string', description: '创建并提交成功的报销流程 requestId' },
973
+ url: { type: 'string', description: '报销流程详情页:{baseUrl}/sp/workflow/flowpage/view/{requestId}' },
974
+ processTitle: { type: 'string' },
975
+ invoiceCount: { type: 'integer', description: '实际进入明细的发票张数' },
976
+ reimbursedAmount: { type: 'string', description: '各行 reimbursedAmount 之和' },
977
+ invoiceTotal: { type: 'string', description: '传入的全部发票 total 之和(含没进明细的)' },
978
+ monthlyAllowance: { type: ['string', 'null'] },
979
+ capped: { type: 'boolean', description: '是否按月补贴额度封顶' },
980
+ details: arrayOf(objectSchema({
981
+ relatedInvoiceId: { type: 'string' },
982
+ invoiceTotal: { type: 'string' },
983
+ reimbursedAmount: { type: 'string' },
984
+ }, ['relatedInvoiceId', 'invoiceTotal', 'reimbursedAmount'])),
985
+ skippedInvoices: arrayOf(objectSchema({
986
+ relatedInvoiceId: { type: 'string' },
987
+ invoiceTotal: { type: 'string' },
988
+ }, ['relatedInvoiceId', 'invoiceTotal']), { description: '额度用完后没进明细、留在票夹的发票' }),
989
+ debugTrace: { type: 'array', description: '排查用:入参、每行金额分摊、请求体、接口返回' },
990
+ finalMarkdown: { type: 'string', description: '[processTitle](url),直接展示给用户' },
991
+ result: rawObject,
992
+ workflow: workflowSchema,
993
+ }, ['requestId', 'url', 'processTitle', 'invoiceCount', 'reimbursedAmount', 'invoiceTotal', 'monthlyAllowance', 'capped', 'details', 'skippedInvoices', 'finalMarkdown', 'result', 'workflow']),
994
+ },
934
995
  {
935
996
  name: 'invoice.issuing.contracts.list',
936
997
  risk: 'read',
@@ -12,6 +12,7 @@ import { InvoiceListOperation } from './list.js';
12
12
  import { InvoiceOcrPreviewOperation } from './ocr-preview.js';
13
13
  import { InvoiceReimEmployeeSuperiorsOperation, InvoiceReimFieldSearchOperation, InvoiceReimFileOcrPreviewOperation, InvoiceReimRequestsListOperation, InvoiceReimWorkflowResolveOperation, } from './reim.js';
14
14
  import { InvoiceReimCandidatesListOperation } from './reim-auto.js';
15
+ import { InvoiceReimSubsidySubmitOperation } from './reim-subsidy.js';
15
16
  import { InvoiceUpdateApplyOperation, InvoiceUpdatePrepareOperation } from './update.js';
16
17
  import { InvoiceUploadOperation } from './upload.js';
17
18
  import { InvoiceUploadAndValidateOperation } from './upload-and-validate.js';
@@ -42,6 +43,7 @@ function buildRegistry() {
42
43
  new InvoiceReimCandidatesListOperation(),
43
44
  new InvoiceReimEmployeeSuperiorsOperation(),
44
45
  new InvoiceReimFieldSearchOperation(),
46
+ new InvoiceReimSubsidySubmitOperation(),
45
47
  new InvoiceIssuingContractsListOperation(),
46
48
  new InvoiceIssuingContractDetailOperation(),
47
49
  ];
@@ -0,0 +1,233 @@
1
+ import { InvoiceCliError, invoicePartialError, invoiceValidationError, isInvoiceNetworkError } from '../errors.js';
2
+ import { asNonEmptyString, asPositiveString, workflow } from './shared.js';
3
+ const SUBSIDY_SUBMIT_PATH = '/api/secondev/fna/expense/reimbursement/aiCreateWf';
4
+ /** 泛微上海 */
5
+ const DEFAULT_CUSTOMER_ID = '100504500000311504';
6
+ /** 雪花 ID 超出 JS 安全整数:运行时支持 JSON.rawJSON 时按数字原样发出,否则退回字符串。 */
7
+ function longId(id) {
8
+ const rawJSON = JSON.rawJSON;
9
+ return typeof rawJSON === 'function' ? rawJSON(id) : id;
10
+ }
11
+ function optionalId(value, name) {
12
+ return value === undefined || value === null || value === '' ? '' : asPositiveString(value, name);
13
+ }
14
+ /** 金额按「分」取整比较,避免浮点误差。 */
15
+ function amountCents(value, name) {
16
+ if (value === undefined || value === null || value === '')
17
+ return null;
18
+ const text = typeof value === 'number' ? String(value) : value;
19
+ const match = typeof text === 'string' ? /^(\d+)(?:\.(\d{1,2}))?$/u.exec(text.trim()) : null;
20
+ const cents = match ? Number(match[1]) * 100 + Number((match[2] ?? '').padEnd(2, '0')) : NaN;
21
+ if (!Number.isSafeInteger(cents) || cents <= 0) {
22
+ throw invoiceValidationError('input_invalid', `${name} 必须是大于 0、最多两位小数的金额`);
23
+ }
24
+ return cents;
25
+ }
26
+ function formatCents(cents) {
27
+ return cents % 100 === 0 ? String(cents / 100) : (cents / 100).toFixed(2);
28
+ }
29
+ function normalizeInvoices(value) {
30
+ if (!Array.isArray(value) || value.length === 0)
31
+ throw invoiceValidationError('input_invalid', 'invoices 必须是非空数组');
32
+ if (value.length > 100)
33
+ throw invoiceValidationError('input_invalid', 'invoices 单次最多支持 100 张');
34
+ const invoices = value.map((item, index) => {
35
+ if (!item || typeof item !== 'object')
36
+ throw invoiceValidationError('input_invalid', `invoices[${index}] 必须是 {fid,total}`);
37
+ const fid = asPositiveString(String(item.fid ?? ''), `invoices[${index}].fid`);
38
+ const cents = amountCents(item.total, `invoices[${index}].total`);
39
+ if (cents === null)
40
+ throw invoiceValidationError('input_invalid', `invoices[${index}].total 必填:这张发票的价税合计`);
41
+ return { fid, cents };
42
+ });
43
+ if (new Set(invoices.map((item) => item.fid)).size !== invoices.length) {
44
+ throw invoiceValidationError('input_invalid', 'invoices 不能包含重复 fid');
45
+ }
46
+ return invoices;
47
+ }
48
+ function formatRemaining(cents) {
49
+ return Number.isFinite(cents) ? formatCents(cents) : '不封顶';
50
+ }
51
+ function workflowViewUrl(baseUrl, requestId) {
52
+ return `${baseUrl.replace(/\/+$/, '')}/sp/workflow/flowpage/view/${requestId}`;
53
+ }
54
+ /**
55
+ * 话费 / 油费补贴报销:一次调用直接创建并提交报销流程(autoCommit 固定 "1")。
56
+ * 明细每行 = 一张发票 + 同一条事前申请;当前人员取登录会话。
57
+ * 明细报销金额合计不超过月补贴额度:每行取该发票价税合计,超额的那一行报「额度 − 前面行累加」,
58
+ * 额度用完后剩下的发票不进明细,留在票夹下次再报。
59
+ */
60
+ export class InvoiceReimSubsidySubmitOperation {
61
+ name = 'invoice.reim.subsidy.submit';
62
+ async execute(input, { host }) {
63
+ const debugTrace = [];
64
+ const debug = (step, detail) => {
65
+ debugTrace.push({ step, detail });
66
+ const message = `[${this.name}] ${step} ${typeof detail === 'string' ? detail : JSON.stringify(detail)}`;
67
+ host.debug?.(message);
68
+ // `--json` 时 logger.debug 会被关掉;单测环境不打 stderr,避免刷屏。
69
+ if (!process.env.NODE_TEST_CONTEXT)
70
+ console.error(message);
71
+ };
72
+ debugger; // 入口:核对入参
73
+ const processTitle = asNonEmptyString(input.processTitle, 'processTitle');
74
+ const reason = asNonEmptyString(input.reason, 'reason');
75
+ const relatedProcessId = asPositiveString(input.relatedProcessId, 'relatedProcessId');
76
+ const invoices = normalizeInvoices(input.invoices);
77
+ const customerId = optionalId(input.customerId, 'customerId') || DEFAULT_CUSTOMER_ID;
78
+ const projectId = optionalId(input.projectId, 'projectId');
79
+ const allowanceCents = amountCents(input.monthlyAllowance, 'monthlyAllowance');
80
+ debug('1/5 入参', {
81
+ processTitle,
82
+ reason,
83
+ relatedProcessId,
84
+ invoices: invoices.map((item) => ({ fid: item.fid, total: formatCents(item.cents) })),
85
+ monthlyAllowance: allowanceCents === null ? null : formatCents(allowanceCents),
86
+ customerId,
87
+ projectId,
88
+ });
89
+ let remainingCents = allowanceCents ?? Number.POSITIVE_INFINITY;
90
+ const details = [];
91
+ const skipped = [];
92
+ for (const item of invoices) {
93
+ if (remainingCents <= 0) {
94
+ skipped.push(item);
95
+ debug('2/5 额度已用完,不进明细', { fid: item.fid, total: formatCents(item.cents) });
96
+ continue;
97
+ }
98
+ const remainingBefore = remainingCents;
99
+ const reimbursedCents = Math.min(item.cents, remainingCents);
100
+ remainingCents -= reimbursedCents;
101
+ details.push({ ...item, reimbursedCents });
102
+ debug('2/5 明细行', {
103
+ fid: item.fid,
104
+ total: formatCents(item.cents),
105
+ remainingBefore: formatRemaining(remainingBefore),
106
+ reimbursedAmount: formatCents(reimbursedCents),
107
+ remainingAfter: formatRemaining(remainingCents),
108
+ });
109
+ }
110
+ const relatedInvoiceIds = details.map((item) => item.fid);
111
+ const invoiceTotalCents = invoices.reduce((sum, item) => sum + item.cents, 0);
112
+ const reimbursedTotalCents = details.reduce((sum, item) => sum + item.reimbursedCents, 0);
113
+ const capped = reimbursedTotalCents < invoiceTotalCents;
114
+ debug('2/5 金额汇总', {
115
+ invoiceTotal: formatCents(invoiceTotalCents),
116
+ reimbursedAmount: formatCents(reimbursedTotalCents),
117
+ capped,
118
+ detailCount: details.length,
119
+ skippedCount: skipped.length,
120
+ details: details.map((item) => ({
121
+ fid: item.fid,
122
+ total: formatCents(item.cents),
123
+ reimbursedAmount: formatCents(item.reimbursedCents),
124
+ })),
125
+ skipped: skipped.map((item) => ({ fid: item.fid, total: formatCents(item.cents) })),
126
+ });
127
+ debugger; // 金额分摊完成:看 details / skipped / remainingCents
128
+ const session = await host.getSession();
129
+ const currentEmpId = asPositiveString(session.userId, '当前人员 ID');
130
+ const body = {
131
+ autoCommit: '1',
132
+ projectId: projectId ? longId(projectId) : '',
133
+ customerId: longId(customerId),
134
+ currentEmpId: longId(currentEmpId),
135
+ processTitle,
136
+ reason,
137
+ detailList: details.map((item) => ({
138
+ relatedProcessId: longId(relatedProcessId),
139
+ relatedInvoiceId: longId(item.fid),
140
+ reimbursedAmount: formatCents(item.reimbursedCents),
141
+ })),
142
+ };
143
+ debug('3/5 请求体', {
144
+ path: SUBSIDY_SUBMIT_PATH,
145
+ autoCommit: body.autoCommit,
146
+ processTitle: body.processTitle,
147
+ reason: body.reason,
148
+ currentEmpId,
149
+ customerId,
150
+ projectId,
151
+ detailList: details.map((item) => ({
152
+ relatedProcessId,
153
+ relatedInvoiceId: item.fid,
154
+ reimbursedAmount: formatCents(item.reimbursedCents),
155
+ })),
156
+ });
157
+ debugger; // 即将发请求:看 body.detailList[].reimbursedAmount
158
+ let result;
159
+ try {
160
+ result = await host.invoiceRequest({
161
+ path: SUBSIDY_SUBMIT_PATH,
162
+ method: 'POST',
163
+ body,
164
+ operation: this.name,
165
+ timeoutMs: 90_000,
166
+ });
167
+ debug('4/5 接口返回', result);
168
+ debugger; // 接口已返回:看 result.data.requestId / data.code
169
+ }
170
+ catch (error) {
171
+ const failure = error;
172
+ debug('4/5 请求异常', { type: failure?.type, subtype: failure?.subtype, code: failure?.code, message: failure?.message });
173
+ debugger; // 请求异常:看 failure / debugTrace
174
+ if (isInvoiceNetworkError(error)) {
175
+ throw invoicePartialError('报销提交请求发出后连接中断,结果不确定,禁止自动重试', {
176
+ processTitle,
177
+ relatedProcessId,
178
+ relatedInvoiceIds,
179
+ debugTrace,
180
+ workflow: workflow(this.name, 'EXECUTING'),
181
+ }, { stage: 'submit' });
182
+ }
183
+ throw error;
184
+ }
185
+ const data = result?.data && typeof result.data === 'object' ? result.data : {};
186
+ const dataCode = data.code;
187
+ if (result?.status === false || result?.fail === true || (dataCode !== undefined && Number(dataCode) !== 0)) {
188
+ debug('4/5 业务失败', { dataCode, msg: data.msg || result?.msg });
189
+ throw new InvoiceCliError('api', 'reim_subsidy_submit_failed', data.msg || result?.msg || '话费 / 油费报销提交失败', {
190
+ code: dataCode ?? result?.code,
191
+ details: { result, debugTrace },
192
+ exitCode: 1,
193
+ });
194
+ }
195
+ const requestId = String(data.requestId ?? '').trim();
196
+ if (!/^\d+$/u.test(requestId)) {
197
+ throw invoicePartialError('报销提交接口返回成功但没有流程 ID,结果不确定,禁止自动重试', {
198
+ processTitle,
199
+ result,
200
+ debugTrace,
201
+ workflow: workflow(this.name, 'VERIFYING'),
202
+ }, { stage: 'submit-response' });
203
+ }
204
+ const url = workflowViewUrl(session.baseUrl, requestId);
205
+ debug('5/5 完成', { requestId, url });
206
+ return {
207
+ status: 'COMPLETE',
208
+ data: {
209
+ requestId,
210
+ url,
211
+ processTitle,
212
+ invoiceCount: relatedInvoiceIds.length,
213
+ reimbursedAmount: formatCents(reimbursedTotalCents),
214
+ invoiceTotal: formatCents(invoiceTotalCents),
215
+ monthlyAllowance: allowanceCents === null ? null : formatCents(allowanceCents),
216
+ capped,
217
+ details: details.map((item) => ({
218
+ relatedInvoiceId: item.fid,
219
+ invoiceTotal: formatCents(item.cents),
220
+ reimbursedAmount: formatCents(item.reimbursedCents),
221
+ })),
222
+ skippedInvoices: skipped.map((item) => ({
223
+ relatedInvoiceId: item.fid,
224
+ invoiceTotal: formatCents(item.cents),
225
+ })),
226
+ debugTrace,
227
+ finalMarkdown: `[${processTitle}](${url})`,
228
+ result,
229
+ workflow: workflow(this.name, 'COMPLETE'),
230
+ },
231
+ };
232
+ }
233
+ }
@@ -1175,6 +1175,7 @@ const ebMeetingCreateFlowPrepare = {
1175
1175
  description: '结束时间(yyyy-MM-dd HH:mm);不传则按 durationMinutes 从开始时间推算(默认 60 分钟)',
1176
1176
  },
1177
1177
  mt_desc: { type: 'string', description: '会议内容/说明' },
1178
+ agenda: { type: 'string', description: '邀请函议程(AI 按会议名称+内容分析后生成):每行「议程安排|议程内容|议程时间」,换行分隔;不传则用会议议题或模板示例行' },
1178
1179
  address: { type: 'string', description: '会议室(名称或 id);也可直接写楼层("一楼/1F/3层"),CLI 会按楼层给候选' },
1179
1180
  floor: { type: 'number', description: '楼层(1=一楼):和 address 二选一,按名称推断楼层过滤候选(120会议室=1楼、1007=10楼)' },
1180
1181
  askRoom: { type: 'boolean', description: '默认 false:不指定地点时 CLI 直接按推荐算法定一间;传 true 才返回候选让用户挑' },
@@ -2170,7 +2171,76 @@ const ebMeetingCreateFlowPrepare = {
2170
2171
  const preferredFields = await readFlowFieldMap(env, workflowId);
2171
2172
  const { main, mapped, unmapped, resolved: resolvedFields } = mapFields(form.fields, shaped.values, preferredFields);
2172
2173
  await writeFlowFieldMap(env, workflowId, form.workflowName, resolvedFields);
2173
- const warnings = [...checkNotices];
2174
+ /**
2175
+ * 邀请函落成「文档」并写进表单(2026-11-08 用户要求:触发流程表单时就生成并代入)。
2176
+ * 表单里必须有 Document 组件的「邀请函」字段;同会议名 30 分钟内复用上次的文档,避免每次 prepare 都重复建。
2177
+ * 传 `invitation_doc: false` 可关闭(例如只想预览表单、不想产生文档)。
2178
+ */
2179
+ let invitationDocInfo = null;
2180
+ const inviteDocWarnings = [];
2181
+ if (args.invitation_doc !== false) {
2182
+ const inviteField = form.fields.find((field) => String(field?.name ?? '') === '邀请函');
2183
+ if (inviteField) {
2184
+ const existing = main[String(inviteField.id)];
2185
+ const cachedDoc = draft?.invitationDoc
2186
+ && Date.now() - Number(draft.invitationDoc.createdAt || 0) <= 30 * 60 * 1000
2187
+ ? draft.invitationDoc
2188
+ : null;
2189
+ if (Array.isArray(existing) && existing.length > 0) {
2190
+ invitationDocInfo = {
2191
+ docId: String(existing[0]?.id ?? ''),
2192
+ name: String(existing[0]?.name ?? ''),
2193
+ };
2194
+ }
2195
+ else if (cachedDoc?.docId) {
2196
+ invitationDocInfo = { docId: cachedDoc.docId, name: cachedDoc.name };
2197
+ }
2198
+ else {
2199
+ try {
2200
+ const { getMeetingOperation } = await import('../registry.js');
2201
+ const publish = getMeetingOperation('meeting.invitation.publish');
2202
+ // AI 生成的议程:调用方(智能体)按会议名称+内容分析后,按「议程安排|议程内容|议程时间」每行一条传入
2203
+ const renderExtra = {};
2204
+ if (String(args.guest_org ?? '').trim())
2205
+ renderExtra.guest_org = String(args.guest_org).trim();
2206
+ // 没显式传 guest_org 时,用「参会客户」的名字兜底 —— 否则模板里「尊敬的 ___」会落成【待补充】
2207
+ // (2026-11-08 用户实测:明明关联了客户,邀请函开头还是【待补充】)
2208
+ if (!renderExtra.guest_org) {
2209
+ const crmLabel = String(shaped.readable?.crm_members ?? '').trim();
2210
+ if (crmLabel)
2211
+ renderExtra.guest_org = crmLabel;
2212
+ }
2213
+ if (String(args.agenda ?? '').trim())
2214
+ renderExtra.agenda = String(args.agenda).trim();
2215
+ const published = await publish.handler({
2216
+ mt_name: String(args.mt_name ?? ''),
2217
+ begin_datetime: beginText,
2218
+ end_datetime: endText,
2219
+ ...(confirmedAddressLabel ? { address: confirmedAddressLabel } : {}),
2220
+ ...(String(shaped.readable.hrm_members ?? '') ? { hrm_members: String(shaped.readable.hrm_members) } : {}),
2221
+ ...(String(args.mt_desc ?? '') ? { mt_desc: String(args.mt_desc) } : {}),
2222
+ ...(String(shaped.readable.caller ?? '') ? { caller: String(shaped.readable.caller) } : {}),
2223
+ ...(String(args.total_member ?? '') ? { total_member: String(args.total_member) } : {}),
2224
+ ...(Object.keys(renderExtra).length > 0 ? { extra: renderExtra } : {}),
2225
+ confirm: true,
2226
+ }, env);
2227
+ const docId = String(published?.data?.docId ?? '');
2228
+ const docName = String(published?.data?.docName ?? '邀请函');
2229
+ if (docId) {
2230
+ invitationDocInfo = { docId, name: docName, ...(published?.data?.filePath ? { filePath: String(published.data.filePath) } : {}), ...(published?.data?.text ? { text: String(published.data.text) } : {}) };
2231
+ }
2232
+ }
2233
+ catch (error) {
2234
+ inviteDocWarnings.push(`邀请函文档没生成成功(${String(error?.message ?? error).slice(0, 120)}):表单「邀请函」字段会留空,可稍后重跑 publish 补。`);
2235
+ }
2236
+ }
2237
+ if (invitationDocInfo?.docId) {
2238
+ main[String(inviteField.id)] = [{ id: invitationDocInfo.docId, name: invitationDocInfo.name }];
2239
+ inviteDocWarnings.push(`邀请函已生成文档并写入表单:${invitationDocInfo.name}(docId ${invitationDocInfo.docId})。`);
2240
+ }
2241
+ }
2242
+ }
2243
+ const warnings = [...checkNotices, ...inviteDocWarnings];
2174
2244
  if (autoFilledPerson.length > 0) {
2175
2245
  const labels = autoFilledPerson.map((one) => `「${PERSON_FIELD_LABELS[one.field]}」`).join('');
2176
2246
  warnings.push(`${labels}没有传值,已按**当前登录人**补齐:${autoFilledPerson[0].name}(${autoFilledPerson[0].id})。`
@@ -2384,23 +2454,25 @@ const ebMeetingCreateFlowPrepare = {
2384
2454
  ? { crmPatch: { ids: crmPatchIds, count: crmMemberCount === undefined ? crmPatchIds.length : crmMemberCount } }
2385
2455
  : {}),
2386
2456
  // 建群要素:apply 拿到会议 id 后先建群、再把群 id 回写 imchat_groupid
2387
- groupChat: {
2388
- memberIds: groupMemberIds,
2389
- // ⛔ 2026-11-04 修:用户只说"明天上午"(time_slot)时,begin_datetime 是 CLI 展开出来的,
2390
- // `shaped.values` 里**没有**这个键 —— 直接取会得到空串,群消息里"开始时间/结束时间"就空着。
2391
- // 这里统一用展开后的 beginText/endText。
2392
- beginDatetime: beginText,
2393
- endDatetime: endText,
2394
- // ⛔ 2026-11-04 修:shaped.address 在这之前已被解析成 `{id,name}` 对象,
2395
- // 直接 String() 会变成 "[object Object]" 打进群消息(用户实测看到的就是这个)。
2396
- // 群消息要的是人话名称,这里优先取 name。
2397
- address: (() => {
2398
- const value = shaped.values.address;
2399
- if (value && typeof value === 'object')
2400
- return String(value.name ?? value.id ?? '');
2401
- return String(value ?? '');
2402
- })(),
2403
- },
2457
+ // ⛔ 2026-11-08 用户明确:ESB 已在流程提交时建群并发提醒,CLI **不要再建群**。
2458
+ // 只有显式传 createGroupChat: true 才保留(老链路/没有 ESB 的环境)。
2459
+ ...(args.createGroupChat === true ? { groupChat: {
2460
+ memberIds: groupMemberIds,
2461
+ // ⛔ 2026-11-04 修:用户只说"明天上午"(time_slot)时,begin_datetime 是 CLI 展开出来的,
2462
+ // `shaped.values` 里**没有**这个键 —— 直接取会得到空串,群消息里"开始时间/结束时间"就空着。
2463
+ // 这里统一用展开后的 beginText/endText。
2464
+ beginDatetime: beginText,
2465
+ endDatetime: endText,
2466
+ // ⛔ 2026-11-04 修:shaped.address 在这之前已被解析成 `{id,name}` 对象,
2467
+ // 直接 String() 会变成 "[object Object]" 打进群消息(用户实测看到的就是这个)。
2468
+ // 群消息要的是人话名称,这里优先取 name。
2469
+ address: (() => {
2470
+ const value = shaped.values.address;
2471
+ if (value && typeof value === 'object')
2472
+ return String(value.name ?? value.id ?? '');
2473
+ return String(value ?? '');
2474
+ })(),
2475
+ } } : {}),
2404
2476
  },
2405
2477
  fingerprint: JSON.stringify({ workflowId, main, ...(detailPayload ? { details: detailPayload } : {}) }),
2406
2478
  }, CONTINUATION_TTL_MS);
@@ -2411,6 +2483,7 @@ const ebMeetingCreateFlowPrepare = {
2411
2483
  end: endText,
2412
2484
  ...(addressId !== '' ? { addressId, addressName: confirmedAddressLabel } : {}),
2413
2485
  memberIds,
2486
+ ...(invitationDocInfo?.docId ? { invitationDoc: { docId: invitationDocInfo.docId, name: invitationDocInfo.name, createdAt: Date.now() } } : {}),
2414
2487
  // 校验结论一并记住:下一轮同样时间/参会人直接复用(3 分钟内)
2415
2488
  checks: cachedChecks ?? {
2416
2489
  key: checksKey,
@@ -2449,6 +2522,8 @@ const ebMeetingCreateFlowPrepare = {
2449
2522
  ? { detailRows: { subFormId: Object.keys(detailPayload)[0], count: crmDetailRows.length, rows: crmDetailRows } }
2450
2523
  : {}),
2451
2524
  formFieldCount: form.fields.length,
2525
+ // 邀请函文档(含对话内正文):上层直接把 text 贴出来,别只让用户看表单
2526
+ ...(invitationDocInfo ? { invitationDoc: invitationDocInfo } : {}),
2452
2527
  ...(Object.keys(decisions).length > 0 ? { decisions } : {}),
2453
2528
  },
2454
2529
  continuation,
@@ -241,12 +241,9 @@ function buildReadInputSchema(endpoint) {
241
241
  if (endpoint.countPk) {
242
242
  properties.withCount = { type: 'boolean', description: '是否先查总数(默认 true,条件与列表一致)' };
243
243
  }
244
- if ((endpoint.mainTableParams ?? []).length > 0) {
245
- properties.noFallback = {
246
- type: 'boolean',
247
- description: '跳过「模糊兜底」:服务端精确匹配不到时,不再翻页扫全量(默认 false=会扫,保证部分词也能查到)',
248
- };
249
- }
244
+ // ⛔ 2026-11-08 用户明确:**只支持会议室名称查询**。`noFallback` 是我们内部的调试开关,
245
+ // 一旦被调用方传 true 就会把「服务端精确匹配不到→翻页本地包含匹配」的兜底关掉,
246
+ // 表现为"按 317 查 0 条"。已从对外 schema 移除,只保留默认行为(总是兜底)。
250
247
  }
251
248
  return {
252
249
  type: 'object',
@@ -445,8 +442,8 @@ function buildReadOperation(endpoint) {
445
442
  // room_name=测试会议室1 → 1 条 ✅;room_name=测试 / 重庆 → 0 条 ❌,
446
443
  // 但全量里明明有「重庆会议室一/二」)。
447
444
  // 传了筛选却一条没命中时,回退:不带过滤翻页拉全量,在客户端按 contains 再筛一遍。
448
- // 只在首轮 0 条时触发(精确命中时零额外开销);`noFallback:true` 可关。
449
- if (filterKeys.length > 0 && rows.length === 0 && args.noFallback !== true) {
445
+ // 只在首轮 0 条时触发(精确命中时零额外开销);**总是兜底**(2026-11-08 起不再接受 noFallback 开关)
446
+ if (filterKeys.length > 0 && rows.length === 0) {
450
447
  const maxPages = readFallbackMaxPages();
451
448
  const collected = [];
452
449
  let pages = 0;
@@ -271,17 +271,8 @@ export async function recommendRooms(env, input) {
271
271
  continue;
272
272
  if (input.floor !== undefined && input.floor !== null && room.floor !== input.floor)
273
273
  continue;
274
- // 「一楼」「1F」这类说法:调用方可能塞进 placeKeyword,这里按楼层解释一次
275
- if (requirement.placeKeyword) {
276
- const floorHint = inferRoomFloor(String(requirement.placeKeyword));
277
- if (floorHint !== null && /楼|层|F/iu.test(String(requirement.placeKeyword))) {
278
- if (room.floor !== floorHint)
279
- continue;
280
- }
281
- else if (!room.place.includes(requirement.placeKeyword)) {
282
- continue;
283
- }
284
- }
274
+ // ⛔ 2026-11-08:只支持按**会议室名称**筛选(nameKeyword)。原来的 placeKeyword 匹配的是
275
+ // 「地点/园区」字段,传房间号必然 0 条,已从对外入参移除。
285
276
  if (requirement.nameKeyword && !room.name.includes(requirement.nameKeyword))
286
277
  continue;
287
278
  if (requirement.equipmentsKeyword && !room.equipments.includes(requirement.equipmentsKeyword))
@@ -423,7 +414,6 @@ export const ebRoomRecommendOperation = {
423
414
  type: 'string',
424
415
  description: '参会人 id 逗号分隔(可选):不传 memberCount 时按它的人数推算',
425
416
  },
426
- placeKeyword: { type: 'string', description: '地点/楼层关键词(模糊匹配会议室 place)' },
427
417
  nameKeyword: { type: 'string', description: '会议室名称关键词' },
428
418
  mrType: { type: 'string', description: '会议室类型 id(mr_type)' },
429
419
  roomAttr: { type: 'string', enum: ['0', '1', '2'], description: '会议室属性:0 实体 / 1 虚拟 / 2 组合' },
@@ -445,7 +435,6 @@ export const ebRoomRecommendOperation = {
445
435
  endDatetime: String(args.endDatetime),
446
436
  ...(Number.isFinite(memberCount) && memberCount > 0 ? { memberCount } : {}),
447
437
  requirement: {
448
- ...(args.placeKeyword ? { placeKeyword: String(args.placeKeyword) } : {}),
449
438
  ...(args.nameKeyword ? { nameKeyword: String(args.nameKeyword) } : {}),
450
439
  ...(args.mrType ? { mrType: String(args.mrType) } : {}),
451
440
  ...(args.roomAttr ? { roomAttr: String(args.roomAttr) } : {}),
@@ -177,16 +177,39 @@ function parseAgendaFromExtra(raw) {
177
177
  const text = String(raw ?? '').trim();
178
178
  if (!text)
179
179
  return [];
180
+ // 时间样式:「15分钟」「2小时」「14:00」「14:00-14:15」
181
+ const isTimeLike = (part) => /^\d{1,2}:\d{2}(\s*[-~至]\s*\d{1,2}:\d{2})?$/u.test(part)
182
+ || /^\d+(\.\d+)?\s*(分钟|分|min|minutes?|小时|h|hours?)$/iu.test(part);
180
183
  return text
181
184
  .split(/[\r\n;;]+/u)
182
185
  .map((line) => line.trim())
183
186
  .filter(Boolean)
184
187
  .map((line) => {
185
- const parts = line.split('|').map((part) => part.trim());
186
- const [name = '', content = '', timeRange = ''] = parts.length > 1 ? parts : [parts[0], '', ''];
187
- return [name, content, timeRange];
188
+ const parts = line.split('|').map((part) => part.trim()).filter((part) => part !== '');
189
+ if (parts.length >= 3) {
190
+ // 三段:按「安排|内容|时间」;如果时间被写在第一段(常见误传),换回去
191
+ const [name, content, timeRange] = parts;
192
+ if (!isTimeLike(timeRange) && isTimeLike(name))
193
+ return ['', content, name];
194
+ return [name, content, timeRange];
195
+ }
196
+ if (parts.length === 2) {
197
+ const [a, b] = parts;
198
+ // ⛔ 2026-11-08 真机:模型传「15 分钟|泛微公司介绍」,旧解析把时长当成了「议程安排」,
199
+ // 结果时间列空着、安排列写着"15 分钟"。时长/时间一律归到第三列,正文进「议程安排」。
200
+ if (isTimeLike(a) && !isTimeLike(b))
201
+ return [b, '', a];
202
+ if (isTimeLike(b) && !isTimeLike(a))
203
+ return [a, '', b];
204
+ return [a, b, ''];
205
+ }
206
+ // 只有一段:可能是「14:00-14:15 泛微公司介绍」这种连写,拆出时间;否则当作安排名
207
+ const inline = line.match(/^(\d{1,2}:\d{2}\s*[-~至]\s*\d{1,2}:\d{2})\s*(.+)$/u);
208
+ if (inline)
209
+ return [inline[2].trim(), '', inline[1].trim()];
210
+ return [parts[0] ?? '', '', ''];
188
211
  })
189
- .filter((row) => row[0] !== '');
212
+ .filter((row) => row[0] !== '' || row[2] !== '');
190
213
  }
191
214
  /**
192
215
  * 把会议接口返回的任意字段值压成可渲染文本。