weaver-work-cli 0.1.50 → 0.1.52
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 +1 -1
- package/dist/chunks/{attachment-content-EJYIOJPH.js → attachment-content-MBYYSQIX.js} +3 -3
- package/dist/chunks/{chunk-RYFRGTUV.js → chunk-7UOXOGFL.js} +4 -4
- package/dist/chunks/{chunk-BFKLQLBK.js → chunk-D3TDNRFE.js} +7 -7
- package/dist/chunks/{chunk-3NCFFHB2.js → chunk-DZOC77ZD.js} +1 -1
- package/dist/chunks/{chunk-K67FODVC.js → chunk-IRMA3GVP.js} +1 -1
- package/dist/chunks/{chunk-WNJUGI2F.js → chunk-KLZ3ULQQ.js} +1 -1
- package/dist/chunks/{chunk-6T53BSWZ.js → chunk-LALWNK6M.js} +9 -0
- package/dist/chunks/{chunk-HARQF5IP.js → chunk-LM2H7SZI.js} +25 -25
- package/dist/chunks/{chunk-YB3AJYPY.js → chunk-LTRLF6MM.js} +4 -4
- package/dist/chunks/{chunk-7ECB22G3.js → chunk-RPRFIG6I.js} +23 -23
- package/dist/chunks/{chunk-MCZG6HPM.js → chunk-RWFRZSIP.js} +2 -2
- package/dist/chunks/{chunk-7AYQJSFY.js → chunk-ZRHKGQRQ.js} +2 -2
- package/dist/chunks/{conflict-C4UDHCWV.js → conflict-D2HYKBMH.js} +2 -2
- package/dist/chunks/{contract-VUC6JOPG.js → contract-MFOFMM2J.js} +3837 -262
- package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-7ZATJVTM.js} +6 -6
- package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
- package/dist/chunks/{env-WP57TF2S.js → env-5DO4YENS.js} +2 -2
- package/dist/chunks/{factory-VUXI7N5C.js → factory-3M7D7WJC.js} +1 -1
- package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-B2HT5NEO.js} +3 -3
- package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
- package/dist/chunks/{meeting-4BBLVAWM.js → meeting-HZOX3CBB.js} +10 -10
- package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
- package/dist/chunks/{registry-V4CHRQDI.js → registry-KYPFFQIH.js} +1 -1
- package/dist/chunks/{registry-5CRCN2TV.js → registry-SJHSBO5G.js} +10 -10
- package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-5AHR4YQV.js} +4 -4
- package/dist/chunks/{schedule-JZEFIXUS.js → schedule-KZPJUPC2.js} +4 -4
- package/dist/chunks/smart-extract-IXHCZE4R.js +2846 -0
- package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-UHKCZJMY.js} +1 -1
- package/dist/index.js +11 -6
- package/dist/shortcuts/contract/manifest.js +151 -0
- package/dist/shortcuts/contract/operations/card-action.js +585 -0
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +315 -0
- package/dist/shortcuts/contract/operations/card-plan.js +327 -0
- package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
- package/dist/shortcuts/contract/operations/elements-build.js +714 -0
- package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
- package/dist/shortcuts/contract/operations/first-screen.js +563 -0
- package/dist/shortcuts/contract/operations/flow.js +81 -25
- package/dist/shortcuts/contract/operations/modeltext.js +132 -0
- package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
- package/dist/shortcuts/contract/operations/quote.js +131 -25
- package/dist/shortcuts/contract/operations/registry.js +20 -0
- package/dist/shortcuts/contract/operations/review.js +73 -58
- package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
- package/dist/shortcuts/contract/operations/summary.js +4 -2
- package/dist/shortcuts/contract/operations/upload.js +48 -7
- package/dist/shortcuts/contract/prewarm-cache.js +90 -0
- package/dist/shortcuts/contract/prewarm.js +88 -0
- package/dist/shortcuts/contract/upload-cache.js +49 -4
- package/dist/shortcuts/data/index.js +1 -6
- package/dist/shortcuts/data/manifest.js +2 -2
- package/dist/shortcuts/data/operations/index.js +1 -1
- package/dist/shortcuts/data/operations/query.js +23 -46
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/index.js +0 -12
- package/dist/shortcuts/invoice/manifest.js +200 -49
- package/dist/shortcuts/invoice/operations/registry.js +4 -2
- package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
- package/dist/shortcuts/invoice/operations/shared.js +3 -19
- package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
- package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
- package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
- package/dist/shortcuts/recruit-stage/shared.js +5 -0
- package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
- package/dist/shortcuts/smart-extract/constants.js +79 -0
- package/dist/shortcuts/smart-extract/continuation.js +71 -0
- package/dist/shortcuts/smart-extract/errors.js +68 -0
- package/dist/shortcuts/smart-extract/host.js +191 -0
- package/dist/shortcuts/smart-extract/index.js +105 -0
- package/dist/shortcuts/smart-extract/ledger.js +70 -0
- package/dist/shortcuts/smart-extract/manifest.js +35 -0
- package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
- package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
- package/dist/shortcuts/smart-extract/operations/config.js +118 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +489 -0
- package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
- package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
- package/dist/shortcuts/smart-extract/operations/save.js +355 -0
- package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
- package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
- package/dist/shortcuts/smart-extract/operations/target.js +167 -0
- package/dist/shortcuts/smart-extract/operations/types.js +22 -0
- package/dist/shortcuts/smart-extract/operations/validate.js +408 -0
- package/dist/shortcuts/workflow/operations/read.js +19 -1
- package/docs/SKILL.md +1 -1
- package/docs/_catalog.md +3 -0
- package/docs/agent-invoice.md +5 -7
- package/docs/data.md +5 -1
- package/docs/fna.md +14 -1
- package/docs/invoice.md +7 -5
- package/docs/smart-extract.md +156 -0
- package/package.json +1 -1
- package/skill-template/business-info.json +16 -1
- package/skill-template/domains/qiyecheng.md +2 -0
- package/skill-template/domains/smart-extract.md +16 -0
- package/skill-template/domains/yepiaotong.md +2 -2
- package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
- package/skills/weaver-e10-jinchengda/SKILL.md +159 -11
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +8 -3
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +4 -3
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +8 -7
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +3 -1
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +90 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +124 -5
- package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +200 -0
- package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +572 -0
- package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +560 -0
- package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +894 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +10 -0
- package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
- package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
- package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
- package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
- package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +34 -27
- package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -42
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
- package/skills/weaver-e10-smart-extract/SKILL.md +169 -0
- package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
- package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
- package/skills/weaver-e10-smart-extract/references/troubleshooting.md +105 -0
- package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
- package/skills/weaver-e10-yepiaotong/SKILL.md +46 -33
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +12 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
- package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
- package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +0 -265
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { rsSuccess, schemaOf } from './types.js';
|
|
2
2
|
import { rsFail } from '../errors.js';
|
|
3
3
|
import { randHex32 } from '../shared.js';
|
|
4
|
+
import { resolveTags } from '../tag-lookup.js';
|
|
4
5
|
const ID_RE = /^\d+$/;
|
|
5
6
|
// 门户字段内联解析:正常实例 creator 直接返回 [{id,name,...}] / {name} / 字符串 JSON 数组
|
|
6
7
|
function parsePortalName(field) {
|
|
@@ -138,6 +139,336 @@ async function handler(args, env) {
|
|
|
138
139
|
});
|
|
139
140
|
return rsSuccess('recruit-stage.candidate.search', out);
|
|
140
141
|
}
|
|
142
|
+
/* ══════════ recruit-stage.candidate.searchByTag —— 按标签搜人才(2026-11-12 新增) ══════════
|
|
143
|
+
*
|
|
144
|
+
* 用户说法:「用小E搜 985 标签的人才列表有哪些」「按标签找人」「有哪些双一流的人」。
|
|
145
|
+
* 只读、无确认门;标签名→标签 id、标签列字段 id **全部运行时解析**,一个都不写死。
|
|
146
|
+
*
|
|
147
|
+
* 🔴 2026-11-12 自用真机实测(www.e-cology.com.cn,人才库 77 万行):
|
|
148
|
+
* - 标签条件必须放 `commonSearchFields` 的 `in` 条件:
|
|
149
|
+
* { field_11: [{ field_11: [tagId], field_11_condition_type: 'in' }] }
|
|
150
|
+
* 放 `groupFields: {"field_11":[tagId]}` 会被**静默忽略**(total 恒等于全库 770435)。
|
|
151
|
+
* - 单个条件对象里放多个 tagId = 并集(985 3405 ∪ 双一流 3604 = 3867);
|
|
152
|
+
* **多个条件对象** = 交集(3405 ∩ 3604 = 3142)→ 正好对应 match=any / all。
|
|
153
|
+
* - 标签列 fieldId 由 GET /api/ebuilder/form/listSearch/getListSearch/{listId} 运行时解析
|
|
154
|
+
* (自用实测返回 109 个字段,含「公共标签 field_11」「我的标签 field_12」);解析不到才回退常量。
|
|
155
|
+
* - 部分环境带 tableuid 会让 searchParamData 被整体忽略 → 通道自带/不带 tableuid 都试。
|
|
156
|
+
* - 101/188 相反:groupFields 生效而 commonSearchFields 被忽略(forge §19)→ 两类通道都保留。
|
|
157
|
+
*
|
|
158
|
+
* 取数纪律:优先服务端过滤 + getListDataCount 拿**全库真总数**(不扫全库、不谎报);
|
|
159
|
+
* 服务端通道全不生效时才退客户端扫描,且必须有显示层标签列;两者都没有 → 如实报错,不返回假 0。
|
|
160
|
+
*/
|
|
161
|
+
const FALLBACK_TAG_FIELDS = { public: 'field_11', private: 'field_12' };
|
|
162
|
+
const SCAN_PAGE_SIZE = 100;
|
|
163
|
+
const NO_SUCH_TAG = '__RT_TAG_NOT_EXIST__';
|
|
164
|
+
function clampInt(v, min, max, fallback) {
|
|
165
|
+
const n = Number(v);
|
|
166
|
+
if (!Number.isFinite(n))
|
|
167
|
+
return fallback;
|
|
168
|
+
return Math.min(max, Math.max(min, Math.trunc(n)));
|
|
169
|
+
}
|
|
170
|
+
function normTag(s) { return String(s == null ? '' : s).trim().toLowerCase(); }
|
|
171
|
+
/** 标签列字段 id:优先运行时解析搜索配置,失败才回退平台常量 */
|
|
172
|
+
async function resolveTagFields(host, listId) {
|
|
173
|
+
let publicKey = FALLBACK_TAG_FIELDS.public;
|
|
174
|
+
let privateKey = FALLBACK_TAG_FIELDS.private;
|
|
175
|
+
let fromConfig = false;
|
|
176
|
+
try {
|
|
177
|
+
const r = await host.request({
|
|
178
|
+
path: '/api/ebuilder/form/listSearch/getListSearch/' + encodeURIComponent(listId),
|
|
179
|
+
method: 'GET',
|
|
180
|
+
});
|
|
181
|
+
const d = r?.data || {};
|
|
182
|
+
for (const row of (Array.isArray(d.layout) ? d.layout : [])) {
|
|
183
|
+
for (const it of (Array.isArray(row) ? row : [])) {
|
|
184
|
+
if (!it || !it.id)
|
|
185
|
+
continue;
|
|
186
|
+
const raw = String(it.id);
|
|
187
|
+
const key = raw.indexOf('field_') === 0 ? raw : 'field_' + raw;
|
|
188
|
+
const label = String(it.label || '');
|
|
189
|
+
if (label === '公共标签') {
|
|
190
|
+
publicKey = key;
|
|
191
|
+
fromConfig = true;
|
|
192
|
+
}
|
|
193
|
+
else if (label === '我的标签') {
|
|
194
|
+
privateKey = key;
|
|
195
|
+
fromConfig = true;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch { /* 配置读不到就用平台常量,后面负样本仍会校验 */ }
|
|
201
|
+
return { publicKey, privateKey, fromConfig };
|
|
202
|
+
}
|
|
203
|
+
/** 构造标签条件:any = 单条件对象多值(并集);all = 多条件对象(交集) */
|
|
204
|
+
function buildTagCond(ids, keys, mode) {
|
|
205
|
+
const groups = [];
|
|
206
|
+
const pub = ids.filter((x) => (x.type ?? 0) === 0).map((x) => String(x.id));
|
|
207
|
+
const priv = ids.filter((x) => (x.type ?? 0) === 1).map((x) => String(x.id));
|
|
208
|
+
if (pub.length)
|
|
209
|
+
groups.push({ key: keys.publicKey, ids: pub });
|
|
210
|
+
if (priv.length)
|
|
211
|
+
groups.push({ key: keys.privateKey, ids: priv });
|
|
212
|
+
if (!groups.length)
|
|
213
|
+
groups.push({ key: keys.publicKey, ids: pub });
|
|
214
|
+
const csf = {};
|
|
215
|
+
const gf = {};
|
|
216
|
+
for (const g of groups) {
|
|
217
|
+
csf[g.key] = mode === 'all'
|
|
218
|
+
? g.ids.map((id) => ({ [g.key]: [id], [g.key + '_condition_type']: 'in' }))
|
|
219
|
+
: [{ [g.key]: g.ids, [g.key + '_condition_type']: 'in' }];
|
|
220
|
+
gf[g.key] = g.ids;
|
|
221
|
+
}
|
|
222
|
+
return { csf, gf };
|
|
223
|
+
}
|
|
224
|
+
/** 从 displayData 行里取标签名与标签 id(仅客户端扫描兜底时用) */
|
|
225
|
+
function tagsOfRow(disp) {
|
|
226
|
+
const names = [];
|
|
227
|
+
const ids = [];
|
|
228
|
+
for (const key of ['batchpubtags', 'batchmytags']) {
|
|
229
|
+
const arr = disp && disp[key];
|
|
230
|
+
if (Array.isArray(arr)) {
|
|
231
|
+
for (const t of arr) {
|
|
232
|
+
if (!t)
|
|
233
|
+
continue;
|
|
234
|
+
if (typeof t === 'object') {
|
|
235
|
+
const n = String(t.name || t.label || t.text || '').trim();
|
|
236
|
+
if (n)
|
|
237
|
+
names.push(n);
|
|
238
|
+
if (t.id != null)
|
|
239
|
+
ids.push(String(t.id));
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
const n = String(t).trim();
|
|
243
|
+
if (n)
|
|
244
|
+
names.push(n);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else if (typeof arr === 'string' && arr) {
|
|
249
|
+
for (const n of arr.split(/[、,,;;/\s|]+/))
|
|
250
|
+
if (n.trim())
|
|
251
|
+
names.push(n.trim());
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return { names, ids };
|
|
255
|
+
}
|
|
256
|
+
async function handlerSearchByTag(args, env) {
|
|
257
|
+
const host = env.host;
|
|
258
|
+
const session = await host.getSession();
|
|
259
|
+
const baseUrl = session.baseUrl.replace(/\/+$/, '');
|
|
260
|
+
const cache = await env.recruitContext();
|
|
261
|
+
const talent = cache.lists?.talent;
|
|
262
|
+
const listId = talent?.listId;
|
|
263
|
+
const objId = cache.forms?.talent_pool?.objId;
|
|
264
|
+
if (!listId || !objId) {
|
|
265
|
+
throw rsFail('当前环境未解析到「人才库」菜单或人才库表单,无法按标签搜索人才。请确认 CLI 已登录目标环境且该环境已部署招聘应用。');
|
|
266
|
+
}
|
|
267
|
+
// 入参:tags 支持字符串或数组;别名归一由技能侧负责(CLI 只接规范标签名)
|
|
268
|
+
const wanted = (Array.isArray(args.tags) ? args.tags : [args.tags])
|
|
269
|
+
.map((x) => String(x == null ? '' : x).trim()).filter(Boolean);
|
|
270
|
+
if (!wanted.length)
|
|
271
|
+
throw rsFail('请提供要搜索的标签名,例如:{"tags":["985"]}。');
|
|
272
|
+
const match = args.match === 'all' ? 'all' : 'any';
|
|
273
|
+
const pageSize = clampInt(args.pageSize, 1, 100, 20);
|
|
274
|
+
const current = clampInt(args.current, 1, 10000, 1);
|
|
275
|
+
const maxScan = clampInt(args.maxScan, 100, 10000, 2000);
|
|
276
|
+
// ① 标签名 → 运行时 tagId(不存在进 missing,不臆造、不改名凑命中)
|
|
277
|
+
const rt = await resolveTags(host, wanted);
|
|
278
|
+
const resolved = rt.resolved || [];
|
|
279
|
+
const missing = rt.missing || [];
|
|
280
|
+
// 环境里一个标签都没解析到:直接如实返回 0,不发负样本、不扫描、不假装「没有这样的人」
|
|
281
|
+
if (!resolved.length) {
|
|
282
|
+
return rsSuccess('recruit-stage.candidate.searchByTag', {
|
|
283
|
+
env: new URL(baseUrl).hostname, wanted, match, resolved: [], missing,
|
|
284
|
+
via: 'none', total: 0, countFrom: 'local', current, pageSize, rows: [],
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
const keys = await resolveTagFields(host, String(listId));
|
|
288
|
+
// getListDatas 的 passid/cid 必须是**台账视图 objId**(listInit.data.objid),不是表单 objId;
|
|
289
|
+
// 两者在某些环境不同,用错会查错台账(forge §19)。失败才回退 context 里的表单 objId。
|
|
290
|
+
let ledgerObjId = String(objId);
|
|
291
|
+
try {
|
|
292
|
+
const li = await host.request({ path: '/api/ebuilder/form/list/listInit', body: { listId: String(listId) } });
|
|
293
|
+
if (li?.data?.objid)
|
|
294
|
+
ledgerObjId = String(li.data.objid);
|
|
295
|
+
}
|
|
296
|
+
catch { /* 回退 */ }
|
|
297
|
+
const listPath = '/api/ebuilder/form/list/getListDatas?passid=' + ledgerObjId + '&cid=' + ledgerObjId;
|
|
298
|
+
const countPath = '/api/ebuilder/form/list/getListDataCount?passid=' + ledgerObjId + '&cid=' + ledgerObjId;
|
|
299
|
+
const headers = { ebBusinessId: listId };
|
|
300
|
+
const mkBody = (page, size, o) => {
|
|
301
|
+
const b = {
|
|
302
|
+
current: page, pageSize: size,
|
|
303
|
+
requiredMatch: 1, mapResult: '1', recheckQuery: '1',
|
|
304
|
+
searchParamData: {
|
|
305
|
+
type: o.type || 'and', searchType: '3',
|
|
306
|
+
commonSearchFields: o.csf || {}, groupFields: o.gf || {}, quickSearchFields: {},
|
|
307
|
+
},
|
|
308
|
+
listId,
|
|
309
|
+
cusMenuId: talent.cusMenuId, urlPageTitle: '人才库', menuName: talent.menuName || '人才管理',
|
|
310
|
+
isFollow: 0, isShareToMe: 0, filterCondition: {},
|
|
311
|
+
browser: 'Chrome', terminal: 'PC',
|
|
312
|
+
};
|
|
313
|
+
if (o.tableuid)
|
|
314
|
+
b.tableuid = o.tableuid;
|
|
315
|
+
return b;
|
|
316
|
+
};
|
|
317
|
+
const fetchList = (body) => host.request({ path: listPath, body, headers });
|
|
318
|
+
// ② 通道自适应:逐个用「不存在的标签 id」做负样本,筛成 0 行才敢信它。
|
|
319
|
+
// csf = commonSearchFields(自用生效,支持 any/all);gf = groupFields(101/188 生效,仅 any)。
|
|
320
|
+
const probeCond = buildTagCond([{ id: NO_SUCH_TAG, type: 0 }], keys, 'any');
|
|
321
|
+
const channels = [
|
|
322
|
+
{ kind: 'csf' },
|
|
323
|
+
{ kind: 'csf', tableuid: randHex32() },
|
|
324
|
+
...(match === 'any' ? [{ kind: 'gf', tableuid: randHex32() }, { kind: 'gf' }] : []),
|
|
325
|
+
];
|
|
326
|
+
let channel = null;
|
|
327
|
+
for (const ch of channels) {
|
|
328
|
+
const body = mkBody(1, 2, ch.kind === 'csf'
|
|
329
|
+
? { csf: probeCond.csf, tableuid: ch.tableuid }
|
|
330
|
+
: { gf: probeCond.gf, tableuid: ch.tableuid });
|
|
331
|
+
const r = await fetchList(body).catch(() => null);
|
|
332
|
+
if (r && ((r?.data?.data) || []).length === 0) {
|
|
333
|
+
channel = ch;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
// ③ 服务端通道:全库真总数 + 当前页,不扫全库
|
|
338
|
+
if (channel && resolved.length) {
|
|
339
|
+
const cond = buildTagCond(resolved, keys, match);
|
|
340
|
+
const type = match === 'all' ? 'and' : (Object.keys(cond.csf).length > 1 ? 'or' : 'and');
|
|
341
|
+
const body = mkBody(current, pageSize, channel.kind === 'csf'
|
|
342
|
+
? { csf: cond.csf, tableuid: channel.tableuid, type }
|
|
343
|
+
: { gf: cond.gf, tableuid: channel.tableuid, type: 'and' });
|
|
344
|
+
const cntBody = { ...body };
|
|
345
|
+
delete cntBody.current;
|
|
346
|
+
delete cntBody.pageSize;
|
|
347
|
+
const [resp, cnt] = await Promise.all([
|
|
348
|
+
fetchList(body),
|
|
349
|
+
host.request({ path: countPath, body: cntBody, headers }).catch(() => null),
|
|
350
|
+
]);
|
|
351
|
+
const raw = resp?.data?.data || [];
|
|
352
|
+
const dispRows = Array.isArray(resp?.data?.displayData) && resp.data.displayData.length
|
|
353
|
+
? resp.data.displayData : raw;
|
|
354
|
+
const serverTotal = Number(cnt?.data?.total);
|
|
355
|
+
const inlineNames = dispRows.map((d) => parsePortalName(d.creator));
|
|
356
|
+
const pureIds = [];
|
|
357
|
+
dispRows.forEach((d, i) => {
|
|
358
|
+
if (inlineNames[i] == null && d.creator != null && ID_RE.test(String(d.creator).trim())) {
|
|
359
|
+
pureIds.push(String(d.creator).trim());
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
const idNameMap = await resolvePureIds(host, pureIds);
|
|
363
|
+
const statusMap = (cache.options?.recruit_status || {});
|
|
364
|
+
const dictNameMap = {};
|
|
365
|
+
for (const item of cache.dict?.raw || []) {
|
|
366
|
+
if (item.option_id && item.selection_name)
|
|
367
|
+
dictNameMap[item.option_id] = item.selection_name;
|
|
368
|
+
}
|
|
369
|
+
const rows = dispRows.map((d, i) => {
|
|
370
|
+
let creator = inlineNames[i];
|
|
371
|
+
if (creator == null) {
|
|
372
|
+
const rawCreator = d.creator != null ? String(d.creator).trim() : null;
|
|
373
|
+
creator = (rawCreator != null && ID_RE.test(rawCreator) ? (idNameMap[rawCreator] || rawCreator) : rawCreator) || null;
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
talentId: d.form_data_id || d.id || raw[i]?.id || null,
|
|
377
|
+
name: d.candidate_name || d.name || null,
|
|
378
|
+
mobile: d.telephone || null,
|
|
379
|
+
channel: dictNameMap[d.channel] || d.channel || null,
|
|
380
|
+
status: statusMap[d.recruit_status] || d.recruit_status || null,
|
|
381
|
+
creator,
|
|
382
|
+
createTime: d.create_time || null,
|
|
383
|
+
tags: resolved.map((t) => t.name),
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
return rsSuccess('recruit-stage.candidate.searchByTag', {
|
|
387
|
+
env: new URL(baseUrl).hostname,
|
|
388
|
+
wanted, match,
|
|
389
|
+
resolved: resolved.map((t) => ({ name: t.name, type: (t.type ?? 0) === 0 ? '公共标签' : '我的标签' })),
|
|
390
|
+
missing,
|
|
391
|
+
via: channel.kind,
|
|
392
|
+
tagFieldsFromConfig: keys.fromConfig,
|
|
393
|
+
total: Number.isFinite(serverTotal) && serverTotal >= 0 ? serverTotal : rows.length,
|
|
394
|
+
countFrom: Number.isFinite(serverTotal) && serverTotal >= 0 ? 'server' : 'local',
|
|
395
|
+
current, pageSize,
|
|
396
|
+
rows,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
// ④ 兜底:客户端扫描(仅当显示层真的返回标签列;大库有 maxScan 硬上限)
|
|
400
|
+
// 🔴 必须重新拉「无过滤」基线,不能复用负样本响应(它带条件且只有 2 行,会让扫描一页就假停)
|
|
401
|
+
const baseline = await fetchList(mkBody(1, SCAN_PAGE_SIZE, {}));
|
|
402
|
+
const baseDisp = baseline?.data?.displayData || [];
|
|
403
|
+
const hasTagColumn = baseDisp.some((d) => Array.isArray(d?.batchpubtags) || Array.isArray(d?.batchmytags));
|
|
404
|
+
if (!hasTagColumn) {
|
|
405
|
+
throw rsFail(resolved.length
|
|
406
|
+
? '当前环境的服务端未启用按标签筛选,且人才库列表未返回标签列,无法按标签搜索。请在 E10 页面确认标签筛选能力,或改用姓名/手机号搜索。'
|
|
407
|
+
: '当前环境没有找到这些标签,无法按标签搜索。可先确认标签名称是否正确。');
|
|
408
|
+
}
|
|
409
|
+
const wantedNorm = new Set([...wanted, ...resolved.map((t) => t.name)].map(normTag));
|
|
410
|
+
const wantedIds = new Set(resolved.map((t) => String(t.id)));
|
|
411
|
+
const hits = [];
|
|
412
|
+
const tagPool = new Map();
|
|
413
|
+
let scanned = 0;
|
|
414
|
+
let truncated = false;
|
|
415
|
+
let page = 1;
|
|
416
|
+
let resp = baseline;
|
|
417
|
+
while (true) {
|
|
418
|
+
const raw = resp?.data?.data || [];
|
|
419
|
+
const dispRows = Array.isArray(resp?.data?.displayData) && resp.data.displayData.length
|
|
420
|
+
? resp.data.displayData : raw;
|
|
421
|
+
if (!raw.length)
|
|
422
|
+
break;
|
|
423
|
+
for (let i = 0; i < raw.length; i += 1) {
|
|
424
|
+
const d = dispRows[i] || {};
|
|
425
|
+
const t = tagsOfRow(d);
|
|
426
|
+
for (const n of t.names)
|
|
427
|
+
tagPool.set(n, (tagPool.get(n) || 0) + 1);
|
|
428
|
+
const byName = t.names.filter((n) => wantedNorm.has(normTag(n)));
|
|
429
|
+
const byId = t.ids.filter((id) => wantedIds.has(id));
|
|
430
|
+
const names = [...new Set([...byName, ...resolved.filter((r) => byId.includes(String(r.id))).map((r) => r.name)])];
|
|
431
|
+
const pass = match === 'all'
|
|
432
|
+
? [...wantedNorm].every((n) => names.some((x) => normTag(x) === n))
|
|
433
|
+
: names.length > 0;
|
|
434
|
+
if (pass)
|
|
435
|
+
hits.push({ row: raw[i], disp: d, names });
|
|
436
|
+
}
|
|
437
|
+
scanned += raw.length;
|
|
438
|
+
if (scanned >= maxScan) {
|
|
439
|
+
truncated = raw.length >= SCAN_PAGE_SIZE;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
if (raw.length < SCAN_PAGE_SIZE)
|
|
443
|
+
break;
|
|
444
|
+
page += 1;
|
|
445
|
+
resp = await fetchList(mkBody(page, SCAN_PAGE_SIZE, {}));
|
|
446
|
+
}
|
|
447
|
+
const slice = hits.slice((current - 1) * pageSize, current * pageSize);
|
|
448
|
+
return rsSuccess('recruit-stage.candidate.searchByTag', {
|
|
449
|
+
env: new URL(baseUrl).hostname,
|
|
450
|
+
wanted, match,
|
|
451
|
+
resolved: resolved.map((t) => ({ name: t.name, type: (t.type ?? 0) === 0 ? '公共标签' : '我的标签' })),
|
|
452
|
+
missing,
|
|
453
|
+
via: 'client',
|
|
454
|
+
tagFieldsFromConfig: keys.fromConfig,
|
|
455
|
+
total: hits.length,
|
|
456
|
+
countFrom: 'local',
|
|
457
|
+
scanned, truncated, maxScan,
|
|
458
|
+
availableHint: [...tagPool.entries()]
|
|
459
|
+
.sort((a, b) => b[1] - a[1] || String(a[0]).localeCompare(String(b[0])))
|
|
460
|
+
.slice(0, 10).map(([name, count]) => ({ name, count })),
|
|
461
|
+
current, pageSize,
|
|
462
|
+
rows: slice.map((h) => ({
|
|
463
|
+
talentId: h.disp.form_data_id || h.disp.id || h.row?.id || null,
|
|
464
|
+
name: h.disp.candidate_name || h.disp.name || null,
|
|
465
|
+
mobile: h.disp.telephone || null,
|
|
466
|
+
creator: null,
|
|
467
|
+
createTime: h.disp.create_time || null,
|
|
468
|
+
tags: h.names,
|
|
469
|
+
})),
|
|
470
|
+
});
|
|
471
|
+
}
|
|
141
472
|
export const searchOperations = [
|
|
142
473
|
{
|
|
143
474
|
name: 'recruit-stage.candidate.search',
|
|
@@ -155,4 +486,21 @@ export const searchOperations = [
|
|
|
155
486
|
}, {}),
|
|
156
487
|
handler,
|
|
157
488
|
},
|
|
489
|
+
{
|
|
490
|
+
name: 'recruit-stage.candidate.searchByTag',
|
|
491
|
+
resource: 'recruit.candidate',
|
|
492
|
+
method: 'query',
|
|
493
|
+
action: 'candidate.searchByTag',
|
|
494
|
+
summary: '按标签名搜索人才(支持多个标签、any/all 匹配);标签名运行时解析,服务端过滤先负样本判定、不生效退客户端扫描;带扫描上限与截断标记',
|
|
495
|
+
capability: 'recruit.candidate.searchByTag',
|
|
496
|
+
risk: 'read',
|
|
497
|
+
inputSchema: schemaOf({
|
|
498
|
+
tags: { type: 'array', items: { type: 'string' }, maxItems: 20, description: '规范标签名(别名归一由技能侧完成);如 ["985"]。代码同时兼容单个字符串' },
|
|
499
|
+
match: { type: 'string', enum: ['any', 'all'], description: '任一命中(默认 any)/ 全部命中(all,走客户端扫描保证交集语义)' },
|
|
500
|
+
pageSize: { type: 'integer', minimum: 1, maximum: 100, description: '返回每页条数,默认 20' },
|
|
501
|
+
current: { type: 'integer', minimum: 1, description: '返回页码,默认 1' },
|
|
502
|
+
maxScan: { type: 'integer', minimum: 100, maximum: 10000, description: '扫描行数硬上限,默认 2000;触顶 truncated=true,不谎报全库命中数' },
|
|
503
|
+
}, { required: ['tags'] }),
|
|
504
|
+
handler: handlerSearchByTag,
|
|
505
|
+
},
|
|
158
506
|
];
|
|
@@ -888,3 +888,8 @@ export function buildListUrl(baseUrl, listId) {
|
|
|
888
888
|
return null;
|
|
889
889
|
return String(baseUrl).replace(/\/+$/, '') + '/sp/ebdfpage/list/' + listId;
|
|
890
890
|
}
|
|
891
|
+
// 🔴 本文件**不放任何租户专属的页面 id / 路由常量**。
|
|
892
|
+
// CLI 是跨租户共享包,写死某个自用系统的 listId 会污染其他客户(他们下载后拿到别人的页面 id),
|
|
893
|
+
// 也违反本模块「字段值、枚举、表单 id 全部运行时解析,跨环境自适应」的设计前提。
|
|
894
|
+
// 租户专属的固定页面地址属于**部署期常量**,一律放技能侧(SKILL.md「固定参数表」),
|
|
895
|
+
// 由 Agent 按技能里的覆盖规则替换 CLI 产出的列表链接;改地址只改技能,不需要 CLI 发包。
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** 单名查询:并行 type0/type1;filtered=false 表示该 type 返回满页且 total 很大(疑似未按名过滤) */
|
|
2
|
+
async function queryTagByName(host, name) {
|
|
3
|
+
const pageSize = 100;
|
|
4
|
+
const bodyOf = (type) => ({ type, name, order: 8, pageSize, pageNo: 1, search: 1, tagGroup: 0, tagModules: ['ebuilderform'] });
|
|
5
|
+
const rs = await Promise.all([0, 1].map((type) => host.request({ path: '/api/my/tag/query', method: 'POST', body: bodyOf(type) }).catch(() => null)));
|
|
6
|
+
const items = [];
|
|
7
|
+
let filtered = true;
|
|
8
|
+
for (const r of rs) {
|
|
9
|
+
const d = r?.data || {};
|
|
10
|
+
const list = Array.isArray(d.data) ? d.data : [];
|
|
11
|
+
const total = Number(d.total || 0);
|
|
12
|
+
if (list.length >= pageSize && total >= pageSize)
|
|
13
|
+
filtered = false;
|
|
14
|
+
items.push(...list);
|
|
15
|
+
}
|
|
16
|
+
return { items, filtered };
|
|
17
|
+
}
|
|
18
|
+
// 单个 type 的全量标签:第 1 页拿 total → 剩余页按批并发(每批 5,上限 40 页防失控)
|
|
19
|
+
async function fetchTagsOfType(host, type) {
|
|
20
|
+
const pageSize = 100;
|
|
21
|
+
const bodyOf = (pageNo) => ({ type, name: '', order: 8, pageSize, pageNo, search: 1, tagGroup: 0, tagModules: ['ebuilderform'] });
|
|
22
|
+
const first = await host.request({ path: '/api/my/tag/query', method: 'POST', body: bodyOf(1) }).catch(() => null);
|
|
23
|
+
const d = first?.data || {};
|
|
24
|
+
const rows = Array.isArray(d.data) ? [...d.data] : [];
|
|
25
|
+
const total = Number(d.total || 0);
|
|
26
|
+
const pages = Math.min(40, Math.max(1, Math.ceil(total / pageSize)));
|
|
27
|
+
if (pages > 1 && rows.length) {
|
|
28
|
+
const rest = Array.from({ length: pages - 1 }, (_, i) => i + 2);
|
|
29
|
+
for (let i = 0; i < rest.length; i += 5) {
|
|
30
|
+
const batch = rest.slice(i, i + 5);
|
|
31
|
+
const rs = await Promise.all(batch.map((p) => host.request({ path: '/api/my/tag/query', method: 'POST', body: bodyOf(p) }).catch(() => null)));
|
|
32
|
+
for (const r of rs) {
|
|
33
|
+
const list = r?.data?.data;
|
|
34
|
+
if (Array.isArray(list))
|
|
35
|
+
rows.push(...list);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return rows;
|
|
40
|
+
}
|
|
41
|
+
async function listPlatformTags(host) {
|
|
42
|
+
const all = [];
|
|
43
|
+
for (const type of [0, 1]) {
|
|
44
|
+
try {
|
|
45
|
+
all.push(...await fetchTagsOfType(host, type));
|
|
46
|
+
}
|
|
47
|
+
catch { /* 单类型失败不影响另一类 */ }
|
|
48
|
+
}
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
return all.filter((t) => t && t.tagId && !seen.has(String(t.tagId)) && seen.add(String(t.tagId)));
|
|
51
|
+
}
|
|
52
|
+
/** 按名解析 → tagId(不存在进 missing,不臆造;同名优先公共标签)。 */
|
|
53
|
+
export async function resolveTags(host, names) {
|
|
54
|
+
const norm = (s) => String(s == null ? '' : s).trim().toLowerCase();
|
|
55
|
+
const byName = new Map();
|
|
56
|
+
const uniqNames = [...new Set((names || []).map((n) => String(n)).filter(Boolean))];
|
|
57
|
+
let availableCount;
|
|
58
|
+
if (!uniqNames.length)
|
|
59
|
+
return { resolved: [], found: [], missing: [], available: [], availableCount };
|
|
60
|
+
// ① 按名并发查询(N 个名字 → 1 轮)
|
|
61
|
+
const probes = await Promise.all(uniqNames.map((n) => queryTagByName(host, n).catch(() => ({ items: [], filtered: true }))));
|
|
62
|
+
const nameQueryUsable = probes.every((p) => p.filtered);
|
|
63
|
+
if (nameQueryUsable) {
|
|
64
|
+
for (const p of probes) {
|
|
65
|
+
for (const t of p.items) {
|
|
66
|
+
if (!t || !t.tagId)
|
|
67
|
+
continue;
|
|
68
|
+
const k = norm(t.name);
|
|
69
|
+
const prev = byName.get(k);
|
|
70
|
+
if (!prev)
|
|
71
|
+
byName.set(k, t);
|
|
72
|
+
else if ((prev.type ?? 0) !== 0 && t.type === 0)
|
|
73
|
+
byName.set(k, t);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// ② 回退:服务端疑似未按名过滤 → 全量并发(不落盘)
|
|
79
|
+
const dict = await listPlatformTags(host);
|
|
80
|
+
availableCount = dict.length;
|
|
81
|
+
for (const t of dict) {
|
|
82
|
+
const k = norm(t.name);
|
|
83
|
+
const prev = byName.get(k);
|
|
84
|
+
if (!prev)
|
|
85
|
+
byName.set(k, t);
|
|
86
|
+
else if ((prev.type ?? 0) !== 0 && t.type === 0)
|
|
87
|
+
byName.set(k, t);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const resolved = [];
|
|
91
|
+
const found = [];
|
|
92
|
+
const missing = [];
|
|
93
|
+
for (const n of names || []) {
|
|
94
|
+
const t = byName.get(norm(n));
|
|
95
|
+
if (!t) {
|
|
96
|
+
missing.push(n);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
resolved.push({ id: String(t.tagId), name: t.name, type: t.type ?? 0 });
|
|
100
|
+
found.push(t.name);
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
resolved, found, missing, availableCount,
|
|
104
|
+
available: [...byName.values()].map((t) => ({ tagId: String(t.tagId), name: t.name, type: t.type ?? 0 })),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** 写入实体标签(先确认存在再写;不存在不写) */
|
|
108
|
+
export async function addEntityTags(host, talentId, names) {
|
|
109
|
+
if (!names || !names.length)
|
|
110
|
+
return { applied: [], skipped: [] };
|
|
111
|
+
const { resolved, found, missing } = await resolveTags(host, names);
|
|
112
|
+
if (!resolved.length)
|
|
113
|
+
return { applied: [], skipped: missing };
|
|
114
|
+
const r = await host.request({
|
|
115
|
+
path: '/api/my/tag/common/batchAddEntityTag', method: 'POST',
|
|
116
|
+
body: { tags: resolved, batchDatas: [{ entityId: String(talentId), module: 'ebuilderform' }] },
|
|
117
|
+
});
|
|
118
|
+
if (r?.status === false)
|
|
119
|
+
return { applied: [], skipped: [...missing, ...found], error: r?.msg };
|
|
120
|
+
return { applied: found, skipped: missing };
|
|
121
|
+
}
|
|
122
|
+
/** 读回某人才当前标签(data[].content = 标签名) */
|
|
123
|
+
export async function queryEntityTags(host, talentId) {
|
|
124
|
+
const out = [];
|
|
125
|
+
for (const type of [0, 1]) {
|
|
126
|
+
try {
|
|
127
|
+
const r = await host.request({ path: '/api/my/tag/common/queryEntityTag', method: 'POST', body: { entityId: String(talentId), module: 'ebuilderform', type } });
|
|
128
|
+
const list = r?.data;
|
|
129
|
+
if (Array.isArray(list))
|
|
130
|
+
for (const t of list)
|
|
131
|
+
out.push(t.content || t.name || t.labelName || String(t.id || ''));
|
|
132
|
+
}
|
|
133
|
+
catch { /* 读标签失败不影响主流程 */ }
|
|
134
|
+
}
|
|
135
|
+
return [...new Set(out.filter(Boolean))];
|
|
136
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 智能抽取(smart-extract)模块常量。
|
|
3
|
+
*
|
|
4
|
+
* 模块只做「表单结构化数据抽取」:`fill` 取齐结构/规则/附件正文 → 模型抽取 → `fill.save` 校验并落库。
|
|
5
|
+
* 不写流程表单、不提交流程,只把抽取结果存成一条可回查的批次记录。
|
|
6
|
+
*/
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
/** 状态目录子名:`<stateRoot>/smart-extract/`。 */
|
|
9
|
+
export const STATE_SUBDIR = 'smart-extract';
|
|
10
|
+
/** 默认单次请求超时(毫秒)。 */
|
|
11
|
+
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
12
|
+
/** 附件下载超时;大附件比普通接口慢得多。 */
|
|
13
|
+
export const DOWNLOAD_TIMEOUT_MS = 180_000;
|
|
14
|
+
/** 单次最多下载的附件数量,避免一次把几十个附件全拉下来。 */
|
|
15
|
+
export const MAX_ATTACHMENTS = 20;
|
|
16
|
+
/** 单个附件大小上限(字节)。超过只返回元数据,不落地。 */
|
|
17
|
+
export const MAX_ATTACHMENT_BYTES = 200 * 1024 * 1024;
|
|
18
|
+
/**
|
|
19
|
+
* E10 附件下载路径。
|
|
20
|
+
*
|
|
21
|
+
* `/api/file/remotedownload/{fileId}/meeting/true` 返回原始字节;不带 `/meeting/true` 的同名接口是 404。
|
|
22
|
+
*/
|
|
23
|
+
export const FILE_DOWNLOAD_PATH = (fileId) => `/api/file/remotedownload/${encodeURIComponent(fileId)}/meeting/true`;
|
|
24
|
+
/** 服务端接口路径。 */
|
|
25
|
+
export const PATHS = {
|
|
26
|
+
configList: '/api/ai/application/smartfill/config/list',
|
|
27
|
+
creatableFlows: '/api/ai/application/smartfill/config/listCreatableFlows',
|
|
28
|
+
creatableFormIds: '/api/ai/application/smartfill/config/listCreatableFormIds',
|
|
29
|
+
flowStartNode: '/api/ai/application/smartfill/config/getFlowStartNode',
|
|
30
|
+
attachmentInfo: '/api/ai/application/smartfill/data/queryAttachmentInfo',
|
|
31
|
+
saveRecognizeRecord: '/api/ai/application/smartfill/data/saveRecognizeRecord',
|
|
32
|
+
batchInfoById: '/api/ai/application/smartfill/data/getBatchInfoById',
|
|
33
|
+
queryBatchInfo: '/api/ai/application/smartfill/data/queryBatchInfo',
|
|
34
|
+
/** 监管模块:EB / 指定节点的流程表单结构 */
|
|
35
|
+
governFormSimple: '/api/government/formStructure/getSimple',
|
|
36
|
+
governObjId: '/api/government/formStructure/getObjId',
|
|
37
|
+
governFormId: '/api/government/formStructure/getFormId',
|
|
38
|
+
};
|
|
39
|
+
/** 触发来源,与 AiSmartFillBatchInfoDTO.dataSource 对齐。 */
|
|
40
|
+
export const DATA_SOURCE = {
|
|
41
|
+
'wf-pre': '0',
|
|
42
|
+
'wf-manual': '1',
|
|
43
|
+
'eb-manual': '2',
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `ai_smart_fill_batch_info.request_id` 的列宽上限。
|
|
47
|
+
*
|
|
48
|
+
* 服务端必填只有 recognizeResult + workflowId;requestId 可选,Java 侧不读它,只被 ORM 原样入库。
|
|
49
|
+
* 超过 32 会触发 `MysqlDataTruncation: Data too long for column 'request_id'`(服务端不截断也不校验)。
|
|
50
|
+
*/
|
|
51
|
+
export const MAX_REQUEST_ID_LENGTH = 32;
|
|
52
|
+
/**
|
|
53
|
+
* 确认票据落盘目录(相对 `<stateRoot>/smart-extract/`),供 `save.prepare` / `save.apply` 使用。
|
|
54
|
+
*
|
|
55
|
+
* 票据里封的是完整请求体(含抽取结果全文),动辄几 KB;stdout 超预算时会把长字符串截成 `前 200 字…`,
|
|
56
|
+
* 被截过的票据无法通过签名校验。所以票据一律写成本地文件,`apply` 读文件而不是读 stdout 里的明文。
|
|
57
|
+
*/
|
|
58
|
+
export const TICKETS_SUBDIR = 'tickets';
|
|
59
|
+
/** stdout 里还能安全展示票据明文的最大长度;超过就只给文件路径。 */
|
|
60
|
+
export const MAX_INLINE_TICKET_CHARS = 512;
|
|
61
|
+
/** 票据文件路径。requestId 可能被调用方自定义,先做文件名安全化。 */
|
|
62
|
+
export function ticketPath(stateDir, requestId) {
|
|
63
|
+
const safe = requestId.replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 64) || 'ticket';
|
|
64
|
+
return join(stateDir, TICKETS_SUBDIR, `${safe}.ticket`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 一次抽取会话的上下文目录(相对 `<stateRoot>/smart-extract/`)。
|
|
68
|
+
*
|
|
69
|
+
* `fill` 把「结构 + 规则 + 附件路径」写到这里,返回一个短 ID;
|
|
70
|
+
* `fill.save` 只凭这个 ID 组装请求体,模型不需要在两次调用之间搬运任何大对象。
|
|
71
|
+
*/
|
|
72
|
+
export const SESSIONS_SUBDIR = 'sessions';
|
|
73
|
+
/** 会话文件路径;ID 由 CLI 生成(`sf` + 24 位十六进制),文件名天然安全。 */
|
|
74
|
+
export function sessionPath(stateDir, sessionId) {
|
|
75
|
+
const safe = sessionId.replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 64) || 'session';
|
|
76
|
+
return join(stateDir, SESSIONS_SUBDIR, `${safe}.json`);
|
|
77
|
+
}
|
|
78
|
+
/** 长文档落文件后,回给模型的开头字符数。 */
|
|
79
|
+
export const TEXT_PREVIEW_CHARS = 400;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CONTINUATION_TTL_MS } from '../../core/continuation-ttl.js';
|
|
2
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { smartExtractValidationError } from './errors.js';
|
|
8
|
+
function stateRoot(ctx) {
|
|
9
|
+
const configured = ctx?.config?.path();
|
|
10
|
+
if (configured)
|
|
11
|
+
return resolve(configured, '..');
|
|
12
|
+
return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), '.weaver-work-cli');
|
|
13
|
+
}
|
|
14
|
+
async function loadKey(ctx) {
|
|
15
|
+
const keysDir = resolve(stateRoot(ctx), 'keys');
|
|
16
|
+
const filename = resolve(keysDir, 'smart-extract-continuation.key');
|
|
17
|
+
await mkdir(keysDir, { recursive: true, mode: 0o700 });
|
|
18
|
+
if (existsSync(filename))
|
|
19
|
+
return readFile(filename);
|
|
20
|
+
const key = randomBytes(32);
|
|
21
|
+
try {
|
|
22
|
+
await writeFile(filename, key, { flag: 'wx', mode: 0o600 });
|
|
23
|
+
if (process.platform !== 'win32')
|
|
24
|
+
await chmod(filename, 0o600).catch(() => undefined);
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return readFile(filename);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function encode(value) {
|
|
32
|
+
return Buffer.from(JSON.stringify(value)).toString('base64url');
|
|
33
|
+
}
|
|
34
|
+
function signature(payload, key) {
|
|
35
|
+
return createHmac('sha256', key).update(payload).digest('base64url');
|
|
36
|
+
}
|
|
37
|
+
export function createSmartExtractContinuationSigner(ctx) {
|
|
38
|
+
return {
|
|
39
|
+
async issue(payload, ttlMs = CONTINUATION_TTL_MS) {
|
|
40
|
+
const issuedAt = Date.now();
|
|
41
|
+
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
|
|
42
|
+
const sig = signature(body, await loadKey(ctx));
|
|
43
|
+
return `${body}.${sig}`;
|
|
44
|
+
},
|
|
45
|
+
async verify(token, expectedOperation) {
|
|
46
|
+
if (typeof token !== 'string' || !token.includes('.')) {
|
|
47
|
+
throw smartExtractValidationError('continuation_invalid', 'continuation 无效');
|
|
48
|
+
}
|
|
49
|
+
const [body, provided] = token.split('.');
|
|
50
|
+
const expected = signature(body, await loadKey(ctx));
|
|
51
|
+
const valid = provided.length === expected.length
|
|
52
|
+
&& timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
|
|
53
|
+
if (!valid)
|
|
54
|
+
throw smartExtractValidationError('continuation_invalid', 'continuation 签名校验失败');
|
|
55
|
+
let value;
|
|
56
|
+
try {
|
|
57
|
+
value = JSON.parse(Buffer.from(body, 'base64url').toString('utf8'));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw smartExtractValidationError('continuation_invalid', 'continuation 内容无法解析');
|
|
61
|
+
}
|
|
62
|
+
if (value.operation !== expectedOperation) {
|
|
63
|
+
throw smartExtractValidationError('continuation_mismatch', 'continuation 不属于当前操作');
|
|
64
|
+
}
|
|
65
|
+
if (!Number.isSafeInteger(value.expiresAt) || value.expiresAt < Date.now()) {
|
|
66
|
+
throw smartExtractValidationError('continuation_expired', 'continuation 已过期,请重新执行 save.prepare');
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|