weaver-work-cli 0.1.46 → 0.1.48
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/dist/chunks/{archive-oa-BBDP7AKJ.js → archive-oa-EDJDU3V4.js} +454 -5
- package/dist/chunks/{attachment-content-MCXQBD6N.js → attachment-content-4KSNBPRO.js} +3 -3
- package/dist/chunks/{chunk-UFIFZ4YC.js → chunk-2BQESR2U.js} +1 -1
- package/dist/chunks/{chunk-727FH2NI.js → chunk-2IGZUMNG.js} +15 -2
- package/dist/chunks/{chunk-76H3IKH6.js → chunk-5B5JXTY2.js} +35 -35
- package/dist/chunks/{chunk-Q4OYAQYH.js → chunk-72MI3MBX.js} +4 -0
- package/dist/chunks/{chunk-4RWS2YYL.js → chunk-BCACE6VV.js} +2 -2
- package/dist/chunks/{chunk-AD46OMQK.js → chunk-EFOUMXIX.js} +119 -44
- package/dist/chunks/{chunk-IRMIEDXN.js → chunk-FEP6ELMR.js} +1 -1
- package/dist/chunks/{chunk-JB34OE7R.js → chunk-NBEWUR7L.js} +1 -1
- package/dist/chunks/{chunk-6V5ZPKHV.js → chunk-NK74RE5F.js} +2 -2
- package/dist/chunks/{chunk-GSZTA43P.js → chunk-OCYRVZGN.js} +2 -2
- package/dist/chunks/{chunk-OXHHJWNC.js → chunk-PSPOFLSU.js} +1 -1
- package/dist/chunks/{chunk-6AXKWFKG.js → chunk-R2HHLJNN.js} +4 -4
- package/dist/chunks/{chunk-PSOMGA3U.js → chunk-SVFG6EMV.js} +35 -6
- package/dist/chunks/{chunk-IP4CWQCF.js → chunk-WMSAWAWZ.js} +8 -8
- package/dist/chunks/{conflict-H7EHQXYY.js → conflict-APGSD5E7.js} +2 -2
- package/dist/chunks/{contract-3QLAGYQL.js → contract-N6P2HIIE.js} +425 -187
- package/dist/chunks/{create-flow-VRVJEOBX.js → create-flow-5TXFOC7X.js} +6 -6
- package/dist/chunks/{ehr-SH2LM3NK.js → ehr-XI4BIVR2.js} +16 -5
- package/dist/chunks/{env-66FPSJDV.js → env-B6GKA2J3.js} +2 -2
- package/dist/chunks/{factory-UH2TZBVA.js → factory-MFCKLUT6.js} +1 -1
- package/dist/chunks/{group-chat-CAKMMV7K.js → group-chat-YE7WIBFO.js} +3 -3
- package/dist/chunks/{im-NJB7ZYMH.js → im-3RCNL5GT.js} +107 -1
- package/dist/chunks/{invoice-OQP3TMKQ.js → invoice-FXWH5GPO.js} +209 -0
- package/dist/chunks/{lazy-dispatch-DD6ULZ3I.js → lazy-dispatch-XSAHDK6Z.js} +2 -2
- package/dist/chunks/{meeting-VTBFW4HI.js → meeting-RYZV2JTQ.js} +10 -10
- package/dist/chunks/{reception-5WITA44R.js → reception-VL6TKVAW.js} +480 -26
- package/dist/chunks/{recruit-stage-CAKZTUA7.js → recruit-stage-ERZD3ZNB.js} +52 -16
- package/dist/chunks/{registry-JVQBLFQ5.js → registry-22O6UG4I.js} +10 -10
- package/dist/chunks/{registry-AQVGHUM6.js → registry-7VZ6YJUF.js} +2 -2
- package/dist/chunks/{registry-PVUZQDDQ.js → registry-BUTEDK3C.js} +1 -1
- package/dist/chunks/{room-recommend-5U55FMXZ.js → room-recommend-IMZPJMYB.js} +4 -4
- package/dist/chunks/{schedule-IDETODCA.js → schedule-SPPAHER2.js} +4 -4
- package/dist/chunks/{workflow-BSYT5TGL.js → workflow-WVEFJ6KC.js} +2 -2
- package/dist/core/refs.js +19 -2
- package/dist/index.js +13 -13
- package/dist/shortcuts/archive-oa/constants.js +42 -0
- package/dist/shortcuts/archive-oa/host.js +2 -2
- package/dist/shortcuts/archive-oa/index.js +38 -0
- package/dist/shortcuts/archive-oa/operations/borrow-car.js +117 -3
- package/dist/shortcuts/archive-oa/operations/my-borrow-contract.js +271 -0
- package/dist/shortcuts/archive-oa/operations/registry.js +5 -3
- package/dist/shortcuts/contract/index.js +9 -1
- package/dist/shortcuts/contract/manifest.js +14 -2
- package/dist/shortcuts/contract/operations/card.js +231 -0
- package/dist/shortcuts/contract/operations/registry.js +2 -0
- package/dist/shortcuts/contract/operations/review.js +16 -5
- package/dist/shortcuts/contract/operations/summary.js +25 -17
- package/dist/shortcuts/ehr/operations/recruit-write.js +22 -5
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +17 -8
- package/dist/shortcuts/ehr/recruit-stage/shared.js +33 -8
- package/dist/shortcuts/im/index.js +128 -0
- package/dist/shortcuts/im/operations/session.js +6 -0
- package/dist/shortcuts/invoice/manifest.js +60 -0
- package/dist/shortcuts/invoice/operations/registry.js +2 -0
- package/dist/shortcuts/invoice/operations/reim-subsidy.js +163 -0
- package/dist/shortcuts/meeting/operations/eb/conflict.js +26 -3
- package/dist/shortcuts/meeting/operations/eb/continuation-alias.js +63 -0
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +71 -12
- package/dist/shortcuts/meeting/operations/eb/factory.js +5 -3
- package/dist/shortcuts/reception/host.js +33 -1
- package/dist/shortcuts/reception/index.js +19 -0
- package/dist/shortcuts/reception/manifest.js +53 -1
- package/dist/shortcuts/reception/operations/ask.js +18 -0
- package/dist/shortcuts/reception/operations/compose.js +113 -3
- package/dist/shortcuts/reception/operations/leads.js +245 -0
- package/dist/shortcuts/reception/operations/markdown.js +22 -0
- package/dist/shortcuts/reception/operations/registry.js +2 -0
- package/dist/shortcuts/reception/operations/render.js +36 -3
- package/dist/shortcuts/reception/operations/restaurant-rooms.js +118 -0
- package/dist/shortcuts/reception/operations/restaurant.js +251 -0
- package/dist/shortcuts/reception/operations/restaurantrooms.js +42 -0
- package/dist/shortcuts/reception/operations/schedule.js +7 -1
- package/dist/shortcuts/reception/upload.js +22 -6
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +17 -8
- package/dist/shortcuts/recruit-stage/shared.js +42 -14
- package/docs/archive-oa.md +4 -2
- package/docs/invoice.md +1 -0
- package/package.json +1 -1
- package/skill-template/domains/archive-oa.md +2 -1
- package/skill-template/master-skill-template.md +1 -0
- package/skill-template/skill-template.md +1 -0
- package/skills/weaver-e10-archive-oa/SKILL.md +33 -6
- package/skills/weaver-e10-archive-oa/references/borrow-car.md +32 -7
- package/skills/weaver-e10-archive-oa/references/contract-search.md +32 -0
- package/skills/weaver-e10-archive-oa/references/disabled-capabilities.md +1 -1
- package/skills/weaver-e10-archive-oa/references/my-borrow-contract.md +97 -0
- package/skills/weaver-e10-archive-oa/references/my-borrow.md +6 -1
- package/skills/weaver-e10-archive-oa/references/qys-contract-search.md +22 -0
- package/skills/weaver-e10-calendar/SKILL.md +1 -1
- package/skills/weaver-e10-calendar/references/calendar-query.md +1 -1
- package/skills/weaver-e10-calendar/references/calendar-write.md +9 -9
- package/skills/weaver-e10-cowork/SKILL.md +9 -6
- package/skills/weaver-e10-jinchengda/SKILL.md +10 -7
- package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +17 -0
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +263 -35
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +8 -5
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +175 -22
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +124 -19
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-risk-report-template.html +178 -0
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +7 -7
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +279 -0
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +450 -0
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +358 -0
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +505 -0
- package/skills/weaver-e10-jucailin/SKILL.md +7 -4
- package/skills/weaver-e10-jucailin/references/recruit-create.md +3 -2
- package/skills/weaver-e10-jucailin/references/recruit-read.md +2 -1
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +3 -3
- package/skills/weaver-e10-jucailin/references/safety-boundaries.md +30 -2
- package/skills/weaver-e10-mail/SKILL.md +17 -4
- package/skills/weaver-e10-meeting/SKILL.md +94 -409
- package/skills/weaver-e10-meeting/references/create-flow.md +188 -0
- package/skills/weaver-e10-meeting/references/create-guardrails.md +234 -0
- package/skills/weaver-e10-meeting/references/pitfalls.md +40 -0
- package/skills/weaver-e10-reception-flow/SKILL.md +62 -18
- package/skills/weaver-e10-reception-flow/data/fields-snapshot.json +628 -26
- package/skills/weaver-e10-reception-flow/references/fields-snapshot.md +96 -26
- package/skills/weaver-e10-reception-flow/scripts/render.py +81 -2
- package/skills/weaver-e10-recruit-stage/SKILL.md +45 -12
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +58 -8
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +5 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -11
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +16 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +127 -0
- package/skills/weaver-e10-shijingran/SKILL.md +6 -2
- package/skills/weaver-e10-shijingran/references/source-manifest.json +5 -4
- package/skills/weaver-e10-workflow/SKILL.md +1 -1
- package/skills/weaver-e10-yepiaotong/SKILL.md +14 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +10 -3
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +69 -7
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +3 -3
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +9 -16
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +6 -5
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +206 -92
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +27 -21
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +35 -0
- package/skills/weaver-e10-yimiaoban/SKILL.md +2 -1
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +32 -0
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +3 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +11 -11
- package/dist/chunks/{ebuilder-form-GWDTKEI2.js → ebuilder-form-I5ZIX4WO.js} +3 -3
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-README.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-SKILL.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-openai.yaml +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-position-templates.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +0 -0
- /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +0 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
render_action_card.py — 行为卡片渲染器(2026-11-09 新增)
|
|
5
|
+
|
|
6
|
+
背景
|
|
7
|
+
----
|
|
8
|
+
此前 `contract-action-card-template.html` 只是「可照抄的样例」:卡片、handler、
|
|
9
|
+
按钮布局全部写死,没有卡片列表占位符。于是每次出卡片都由模型手工改写,
|
|
10
|
+
反复出现同一类偏差:
|
|
11
|
+
|
|
12
|
+
- sendQuestion 写成 plugin.sendQuestion(...) / 参数传字符串 → 点了不发消息
|
|
13
|
+
- e10Sdk 漏 params.compName → 面板打不开
|
|
14
|
+
- 只绑 click 没有 hover → 鼠标移入无边框变化
|
|
15
|
+
- width 沿用旧值 1300 → 与统一口径不符
|
|
16
|
+
- 摘要内嵌时引号/换行/</script> 未转义 → 整段脚本失效
|
|
17
|
+
|
|
18
|
+
本脚本把「算卡片 → 生成卡片 HTML → 绑定交互 → 组装外层 JSON → 自检」
|
|
19
|
+
全部固化,模型只提供数据,不再手写卡片。
|
|
20
|
+
|
|
21
|
+
用法
|
|
22
|
+
----
|
|
23
|
+
python scripts/render_action_card.py --context ctx.json --out card.json
|
|
24
|
+
python scripts/render_action_card.py --context-json '{"reviewed":true,...}' \
|
|
25
|
+
--file-id 1335753649799495690 --flow-key 常规二次销售 \
|
|
26
|
+
--company-name 宁海建新房地产有限公司 \
|
|
27
|
+
--summary-html sum.html --report-html report.html --out card.json
|
|
28
|
+
|
|
29
|
+
--dry 只打印计划,不写文件
|
|
30
|
+
|
|
31
|
+
产出
|
|
32
|
+
----
|
|
33
|
+
--out 指定时写入 `<browsertool>...</browsertool>` 整段(可直接裸输出);
|
|
34
|
+
未指定则打印到 stdout。渲染后自带自检:双引号、反斜杠、ES5、node --check。
|
|
35
|
+
|
|
36
|
+
退出码:0 成功;1 自检失败或参数缺失。
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
import argparse
|
|
40
|
+
import io
|
|
41
|
+
import json
|
|
42
|
+
import os
|
|
43
|
+
import re
|
|
44
|
+
import shutil
|
|
45
|
+
import subprocess
|
|
46
|
+
import sys
|
|
47
|
+
import tempfile
|
|
48
|
+
|
|
49
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
50
|
+
sys.path.insert(0, HERE)
|
|
51
|
+
|
|
52
|
+
from plan_actions import plan # noqa: E402
|
|
53
|
+
|
|
54
|
+
DEFAULT_BASE = 'https://www.e-cology.com.cn'
|
|
55
|
+
DEFAULT_AIID = '1326842382967570463'
|
|
56
|
+
WIDTH = 1200
|
|
57
|
+
|
|
58
|
+
# flowKey → workflowId(与 contract-flow-launch.md 保持一致)
|
|
59
|
+
FLOW_IDS = {
|
|
60
|
+
'契约锁': '100003460000002066',
|
|
61
|
+
'新客户': '1269716062340284522',
|
|
62
|
+
'老客户增值': '1283761429944369334',
|
|
63
|
+
'常规二次销售': '1283761687634100307',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# ── 图标(22px、stroke #7b8cf0、fill none,规范 §5.3)────────────────
|
|
67
|
+
SVG = {
|
|
68
|
+
'launch': "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M22 2 11 13'/><path d='M22 2 15 22l-4-9-9-4z'/></svg>",
|
|
69
|
+
'doc': "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/><path d='M14 3v5h5'/><path d='M9 13h6'/><path d='M9 17h4'/></svg>",
|
|
70
|
+
'eye': "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z'/><circle cx='12' cy='12' r='3'/></svg>",
|
|
71
|
+
'search': "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M16.5 16.5 21 21'/></svg>",
|
|
72
|
+
'list': "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='4' y='3' width='16' height='18' rx='2'/><path d='M8 8h8'/><path d='M8 12h8'/><path d='M8 16h5'/></svg>",
|
|
73
|
+
'swap': "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M7 4v16'/><path d='M4 17l3 3 3-3'/><path d='M17 20V4'/><path d='M14 7l3-3 3 3'/></svg>",
|
|
74
|
+
'edit': "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M12 20h9'/><path d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/></svg>",
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# action id → (dom 后缀, 图标, 走法)
|
|
78
|
+
ACTION_META = {
|
|
79
|
+
'launch-flow': ('launch', 'launch', 'e10Sdk'),
|
|
80
|
+
'generate-contract': ('gen', 'doc', 'sendQuestion'),
|
|
81
|
+
'review': ('review', 'doc', 'sendQuestion'),
|
|
82
|
+
'export-review': ('report', 'list', 'artifact'),
|
|
83
|
+
'view-review': ('detail', 'eye', 'e10Sdk'),
|
|
84
|
+
'credit': ('credit', 'search', 'e10Sdk'),
|
|
85
|
+
'view-compare': ('cmpview', 'eye', 'e10Sdk'),
|
|
86
|
+
'export-compare-report': ('cmpreport', 'list', 'artifact'),
|
|
87
|
+
'compare': ('cmp', 'swap', 'sendQuestion'),
|
|
88
|
+
'clause-rewrite': ('rewrite', 'edit', 'sendQuestion'),
|
|
89
|
+
'request-status': ('status', 'search', 'sendQuestion'),
|
|
90
|
+
'summary': ('summary', 'list', 'artifact'),
|
|
91
|
+
'element-extract': ('extract', 'doc', 'sendQuestion'),
|
|
92
|
+
'supervise': ('supervise', 'launch', 'sendQuestion'),
|
|
93
|
+
'template-recommend': ('tpl', 'doc', 'sendQuestion'),
|
|
94
|
+
'performance': ('perf', 'list', 'sendQuestion'),
|
|
95
|
+
'retry-upload': ('retry', 'doc', 'sendQuestion'),
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# 兜底 sendQuestion 指令
|
|
99
|
+
SEND_TEXT = {
|
|
100
|
+
'generate-contract': '按这份报价单生成合同',
|
|
101
|
+
'review': '对这份合同做合同预审,输出风险条款与修改建议',
|
|
102
|
+
'clause-rewrite': '按预审建议修改合同条款',
|
|
103
|
+
'request-status': '查一下这份合同的审批进度',
|
|
104
|
+
'compare': '比对这两份合同的差异',
|
|
105
|
+
'element-extract': '从这份合同里抽取要素',
|
|
106
|
+
'supervise': '催办一下当前合同的审批',
|
|
107
|
+
'template-recommend': '推荐几个适合的合同模板',
|
|
108
|
+
'performance': '查一下这份合同的业绩核算',
|
|
109
|
+
'retry-upload': '换一份文件重新解析',
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
CARD_TPL = (
|
|
113
|
+
"<div id='{dom_id}' role='button' tabindex='0' style='display:flex;align-items:center;gap:12px;"
|
|
114
|
+
"background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;{mb}cursor:pointer'>"
|
|
115
|
+
"<span style='flex:0 0 auto;width:44px;height:44px;border-radius:10px;background:#eef1fb;"
|
|
116
|
+
"display:flex;align-items:center;justify-content:center'>{icon}</span>"
|
|
117
|
+
"<span style='min-width:0'>"
|
|
118
|
+
"<span style='display:block;font-size:15px;font-weight:700;color:#1f2430;margin-bottom:6px'>{title}{badge}</span>"
|
|
119
|
+
"<span style='display:block;font-size:13px;color:#7a8497;line-height:1.5'>{desc}</span>"
|
|
120
|
+
"</span></div>"
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
BADGE = ("<span style='font-size:11px;color:#3b6fe0;background:#eaf0fe;border-radius:10px;"
|
|
124
|
+
"padding:2px 8px;line-height:1.4;margin-left:8px'>推荐</span>")
|
|
125
|
+
|
|
126
|
+
# ── 交互脚本基础件(ES5、零双引号)────────────────────────────
|
|
127
|
+
JS_BASE = (
|
|
128
|
+
"var P=window.xiaoePlugin||(window.rawWindow&&window.rawWindow.xiaoePlugin);"
|
|
129
|
+
"var tip=document.getElementById('tip');"
|
|
130
|
+
"function say(m){if(tip){tip.textContent=m;}}"
|
|
131
|
+
"function hasP(){if(!P||!P.rightPanel||typeof P.rightPanel.open!=='function'){"
|
|
132
|
+
"say('当前环境没有小e右侧面板');return false;}return true;}"
|
|
133
|
+
"function op(cfg){if(!hasP()){return;}try{P.rightPanel.open(cfg);say('已打开');}"
|
|
134
|
+
"catch(e){say('面板打开失败,请确认右侧面板已挂载');}}"
|
|
135
|
+
"function send(q){if(!P||!P.session||typeof P.session.sendQuestion!=='function'){"
|
|
136
|
+
"say('当前环境不支持发送会话消息');return;}"
|
|
137
|
+
"try{P.session.sendQuestion({question:q,files:[]});say('已发送,正在处理…');}"
|
|
138
|
+
"catch(e){say('发送失败,请重试');}}"
|
|
139
|
+
"function art(html,title,key){if(!hasP()){return;}if(!html){say('内容为空');return;}"
|
|
140
|
+
"try{P.rightPanel.open({type:'artifact',width:__W__,title:title,contentProps:{"
|
|
141
|
+
"artifacts:[{id:key,name:title,fileType:'html',raw:{html:html}}],"
|
|
142
|
+
"initialArtifactKeys:[key]}});}catch(e){say('面板打开失败,请确认右侧面板已挂载');}}"
|
|
143
|
+
"function bind(id,fn){var el=document.getElementById(id);if(!el){return;}el.onclick=fn;"
|
|
144
|
+
"el.onmouseenter=function(){el.style.borderColor='#1d6fd8';"
|
|
145
|
+
"el.style.boxShadow='0 2px 8px rgba(29,111,216,.12)';};"
|
|
146
|
+
"el.onmouseleave=function(){el.style.borderColor='#e8ebf2';el.style.boxShadow='none';};"
|
|
147
|
+
"el.onkeydown=function(e){if(e.key==='Enter'||e.key===' '){e.preventDefault();fn();}};}"
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def js_str(text):
|
|
152
|
+
"""把文本变成 JS 字符串字面量(单引号包裹),保证零双引号、无裸换行。"""
|
|
153
|
+
s = (text or '')
|
|
154
|
+
s = s.replace('\r\n', ' ').replace('\n', ' ').replace('\r', ' ')
|
|
155
|
+
s = re.sub(r' {2,}', ' ', s)
|
|
156
|
+
s = s.replace('</script>', '<\\/script>') # 防止外层 script 提前闭合
|
|
157
|
+
s = s.replace('"', "'") # 双引号归零
|
|
158
|
+
s = s.replace("\\", "\\\\") # 先转义已有反斜杠
|
|
159
|
+
s = s.replace("<\\\\/script>", "<\\/script>") # 恢复 script 转义
|
|
160
|
+
s = s.replace("'", "\\'") # 单引号转义
|
|
161
|
+
return "'" + s + "'"
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def build_handler(action, cfg):
|
|
165
|
+
"""按 action id 生成 handler 函数体。"""
|
|
166
|
+
aid = action['id']
|
|
167
|
+
dom = 'c-' + ACTION_META.get(aid, (aid, 'doc', 'sendQuestion'))[0]
|
|
168
|
+
|
|
169
|
+
if aid == 'launch-flow':
|
|
170
|
+
wid = FLOW_IDS.get(cfg.get('flow_key') or '')
|
|
171
|
+
if not wid:
|
|
172
|
+
return dom, None
|
|
173
|
+
src = ('%s/sp/workflow/flowpage/create/%s?workflowId=%s&isCreate=1'
|
|
174
|
+
% (cfg['base'], wid, wid))
|
|
175
|
+
if cfg.get('file_id'):
|
|
176
|
+
src += '&fileId=%s&automaticFormFilling=true' % cfg['file_id']
|
|
177
|
+
body = ("function(){op({type:'e10Sdk',width:__W__,contentProps:{src:'%s',"
|
|
178
|
+
"sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
|
|
179
|
+
"routerProps:{initialEntries:['/flowpage/create/%s']},"
|
|
180
|
+
"params:{app:'@weapp/workflow',compName:'Comp.WffpRoute'}}}});}" % (src, wid))
|
|
181
|
+
return dom, body
|
|
182
|
+
|
|
183
|
+
if aid == 'view-review':
|
|
184
|
+
body = ("function(){op({type:'e10Sdk',width:__W__,contentProps:{"
|
|
185
|
+
"src:'%s/sp/contract/business/ai-contract',"
|
|
186
|
+
"sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
|
|
187
|
+
"routerProps:{initialEntries:['/sp/contract/business/ai-contract']},"
|
|
188
|
+
"params:{app:'@weapp/contract',compName:'AIContractV2',"
|
|
189
|
+
"aiProps:{aiid:'%s',fileId:'%s',fileName:'%s'}}}}});}"
|
|
190
|
+
% (cfg['base'], cfg['aiid'], cfg.get('file_id') or '',
|
|
191
|
+
(cfg.get('file_name') or '').replace("'", '')))
|
|
192
|
+
return dom, body
|
|
193
|
+
|
|
194
|
+
if aid == 'credit':
|
|
195
|
+
company = cfg.get('company_name')
|
|
196
|
+
if not company:
|
|
197
|
+
return dom, None
|
|
198
|
+
body = ("function(){op({type:'e10Sdk',width:__W__,contentProps:{"
|
|
199
|
+
"src:'%s/sp/contract/business/credit',"
|
|
200
|
+
"sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
|
|
201
|
+
"routerProps:{initialEntries:['/sp/contract/business/credit']},"
|
|
202
|
+
"params:{app:'@weapp/contract',compName:'ContractCreditDetail',"
|
|
203
|
+
"companyName:['%s']}}}});}" % (cfg['base'], company.replace("'", '')))
|
|
204
|
+
return dom, body
|
|
205
|
+
|
|
206
|
+
if aid == 'view-compare':
|
|
207
|
+
body = ("function(){op({type:'e10Sdk',width:__W__,contentProps:{"
|
|
208
|
+
"src:'%s/sp/contract/business/doc-compare',"
|
|
209
|
+
"sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
|
|
210
|
+
"routerProps:{initialEntries:['/sp/contract/business/doc-compare']},"
|
|
211
|
+
"params:{app:'@weapp/contract',compName:'AIDocCompare'}}}});}" % cfg['base'])
|
|
212
|
+
return dom, body
|
|
213
|
+
|
|
214
|
+
if aid == 'export-review':
|
|
215
|
+
body = ("function(){art(R,'合同风险审查报告.html','report-1');}")
|
|
216
|
+
return dom, body
|
|
217
|
+
|
|
218
|
+
if aid == 'summary':
|
|
219
|
+
body = ("function(){art(S,'合同摘要.html','summary-1');}")
|
|
220
|
+
return dom, body
|
|
221
|
+
|
|
222
|
+
if aid == 'export-compare-report':
|
|
223
|
+
body = "function(){art(C,'合同比对报告.html','compare-1');}"
|
|
224
|
+
return dom, body
|
|
225
|
+
|
|
226
|
+
# 其余走 sendQuestion
|
|
227
|
+
text = SEND_TEXT.get(aid) or action['title']
|
|
228
|
+
body = "function(){send('%s');}" % text.replace("'", '')
|
|
229
|
+
return dom, body
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def render(ctx, cfg):
|
|
233
|
+
p = plan(ctx)
|
|
234
|
+
cards = p['cards']
|
|
235
|
+
|
|
236
|
+
# 卡片 HTML
|
|
237
|
+
parts = []
|
|
238
|
+
handlers = []
|
|
239
|
+
for i, c in enumerate(cards):
|
|
240
|
+
meta = ACTION_META.get(c['id'], (c['id'], 'doc', 'sendQuestion'))
|
|
241
|
+
dom_suffix, icon_key, _ = meta
|
|
242
|
+
dom = 'c-' + dom_suffix
|
|
243
|
+
h_dom, h_body = build_handler(c, cfg)
|
|
244
|
+
if h_body is None:
|
|
245
|
+
# 缺关键参数(如 flowKey 未映射、无企业全称)→ 该卡不进
|
|
246
|
+
continue
|
|
247
|
+
parts.append(CARD_TPL.format(
|
|
248
|
+
dom_id=dom,
|
|
249
|
+
mb=('' if i == len(cards) - 1 else 'margin-bottom:12px;'),
|
|
250
|
+
icon=SVG.get(icon_key, SVG['doc']),
|
|
251
|
+
title=c['title'],
|
|
252
|
+
badge=(BADGE if i == 0 else ''),
|
|
253
|
+
desc=c['desc'],
|
|
254
|
+
))
|
|
255
|
+
handlers.append((h_dom, h_body))
|
|
256
|
+
|
|
257
|
+
if not parts:
|
|
258
|
+
return None, p
|
|
259
|
+
|
|
260
|
+
body_js = JS_BASE.replace('__W__', str(WIDTH))
|
|
261
|
+
# hb 本身已是 function(){...},这里只做赋值,不要再包一层 function hN(){}
|
|
262
|
+
body_js += ''.join('var h%d=%s;' % (i, hb) for i, (_, hb) in enumerate(handlers))
|
|
263
|
+
body_js += ''.join("bind('%s',h%d);" % (d, i) for i, (d, _) in enumerate(handlers))
|
|
264
|
+
body_js += "say('就绪,共 %d 个动作');" % len(handlers)
|
|
265
|
+
|
|
266
|
+
# 摘要 / 报告常量
|
|
267
|
+
s_js = js_str(cfg.get('summary_html') or '')
|
|
268
|
+
r_js = js_str(cfg.get('report_html') or '')
|
|
269
|
+
c_js = js_str(cfg.get('compare_html') or '')
|
|
270
|
+
|
|
271
|
+
with io.open(os.path.join(HERE, '..', 'references', 'contract-action-card-template.html'),
|
|
272
|
+
encoding='utf-8') as f:
|
|
273
|
+
tpl = f.read()
|
|
274
|
+
# 只取正文起点:模板头部是说明注释,不能进 customParams.html。
|
|
275
|
+
# 必须按「section 开标签且带 id 属性」定位,不能用 find('<section')——
|
|
276
|
+
# 注释里只要出现该字样就会误命中,导致多出一个未闭合的开标签。
|
|
277
|
+
m_sec = re.search(r"<section\s+id=", tpl)
|
|
278
|
+
if not m_sec:
|
|
279
|
+
raise SystemExit('模板缺少带 id 的 section,无法渲染')
|
|
280
|
+
tpl = tpl[m_sec.start():]
|
|
281
|
+
|
|
282
|
+
html = (tpl.replace('{{CARD_ID}}', cfg['card_id'])
|
|
283
|
+
.replace('{{CARDS}}', '\n'.join(parts))
|
|
284
|
+
.replace('{{SUMMARY_JS}}', s_js)
|
|
285
|
+
.replace('{{COMPARE_JS}}', c_js)
|
|
286
|
+
.replace('{{REPORT_JS}}', r_js)
|
|
287
|
+
.replace('{{BODY}}', body_js))
|
|
288
|
+
|
|
289
|
+
count = len(handlers)
|
|
290
|
+
title = cfg.get('title') or ('可做的 %d 件事' % count)
|
|
291
|
+
title = re.sub(r'[\\/:*?"<>|]', ' ', title)
|
|
292
|
+
|
|
293
|
+
payload = {
|
|
294
|
+
"version": 1,
|
|
295
|
+
"callId": cfg['call_id'],
|
|
296
|
+
"toolId": "fill_form",
|
|
297
|
+
"arguments": {
|
|
298
|
+
"type": "e10",
|
|
299
|
+
"title": title,
|
|
300
|
+
"src": cfg['base'] + '/sp/contract/xiaoe-custom-page',
|
|
301
|
+
"width": WIDTH,
|
|
302
|
+
"sdkRenderType": "inline",
|
|
303
|
+
"sdkOptions": {
|
|
304
|
+
"compName": "ui.CorsComponent",
|
|
305
|
+
"routerType": "MemoryRouter",
|
|
306
|
+
"routerProps_pc": {"initialEntries": ["/sp/contract/xiaoe-custom-page"]},
|
|
307
|
+
"params_pc": {
|
|
308
|
+
"app": "@weapp/contract",
|
|
309
|
+
"compName": "xiaoeCustomPage",
|
|
310
|
+
"customParams": {"html": html},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
}
|
|
315
|
+
return payload, p
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def self_check(payload):
|
|
319
|
+
"""交付前自检:引号、反斜杠、ES5、node --check。"""
|
|
320
|
+
problems = []
|
|
321
|
+
html = payload['arguments']['sdkOptions']['params_pc']['customParams']['html']
|
|
322
|
+
|
|
323
|
+
dq = html.count('"')
|
|
324
|
+
if dq != 0:
|
|
325
|
+
problems.append('html 内双引号 %d 个(应为 0)' % dq)
|
|
326
|
+
|
|
327
|
+
unsafe = len(re.findall(r"\\(?!/script>|')", html))
|
|
328
|
+
if unsafe:
|
|
329
|
+
problems.append('非安全转义反斜杠 %d 处' % unsafe)
|
|
330
|
+
|
|
331
|
+
js = re.search(r'<script>(.*)</script>', html, re.S)
|
|
332
|
+
# ES5 只扫脚本正文:html 里可能有说明文字/属性,不能当语法看
|
|
333
|
+
js_code = js.group(1) if js else html
|
|
334
|
+
for pat, name in ((r"=>", 'arrow'), (r"\bconst\b", 'const'), (r"\blet\b", 'let'),
|
|
335
|
+
(r"\?\?", '??'), (r"\?\.", '?.')):
|
|
336
|
+
if re.search(pat, js_code):
|
|
337
|
+
problems.append('ES5 违规:%s' % name)
|
|
338
|
+
|
|
339
|
+
if 'mouseenter' not in js_code:
|
|
340
|
+
problems.append('缺少 hover 绑定(mouseenter)')
|
|
341
|
+
|
|
342
|
+
if not js:
|
|
343
|
+
problems.append('未找到 script')
|
|
344
|
+
else:
|
|
345
|
+
node = shutil.which('node')
|
|
346
|
+
if node:
|
|
347
|
+
fd, tmp = tempfile.mkstemp(suffix='.js')
|
|
348
|
+
try:
|
|
349
|
+
with io.open(fd, 'w', encoding='utf-8') as f:
|
|
350
|
+
f.write(js.group(1))
|
|
351
|
+
r = subprocess.run([node, '--check', tmp],
|
|
352
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
353
|
+
if r.returncode != 0:
|
|
354
|
+
err = r.stderr.decode('utf-8', 'replace').strip().splitlines()
|
|
355
|
+
problems.append('node --check 失败:' + (' / '.join(err[:3])))
|
|
356
|
+
finally:
|
|
357
|
+
try:
|
|
358
|
+
os.remove(tmp)
|
|
359
|
+
except Exception:
|
|
360
|
+
pass
|
|
361
|
+
return problems
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def main():
|
|
365
|
+
ap = argparse.ArgumentParser(description='行为卡片渲染器')
|
|
366
|
+
ap.add_argument('--context', help='上下文状态 JSON 文件')
|
|
367
|
+
ap.add_argument('--context-json', help='上下文状态 JSON 字符串')
|
|
368
|
+
ap.add_argument('--file-id', dest='file_id')
|
|
369
|
+
ap.add_argument('--file-name', dest='file_name')
|
|
370
|
+
ap.add_argument('--flow-key', dest='flow_key')
|
|
371
|
+
ap.add_argument('--company-name', dest='company_name')
|
|
372
|
+
ap.add_argument('--summary-html', dest='summary_html')
|
|
373
|
+
ap.add_argument('--report-html', dest='report_html')
|
|
374
|
+
ap.add_argument('--compare-html', dest='compare_html')
|
|
375
|
+
ap.add_argument('--base-url', dest='base', default=DEFAULT_BASE)
|
|
376
|
+
ap.add_argument('--aiid', default=DEFAULT_AIID)
|
|
377
|
+
ap.add_argument('--out')
|
|
378
|
+
ap.add_argument('--card-id', dest='card_id')
|
|
379
|
+
ap.add_argument('--call-id', dest='call_id')
|
|
380
|
+
ap.add_argument('--title')
|
|
381
|
+
ap.add_argument('--dry', action='store_true', help='只打印计划,不写文件')
|
|
382
|
+
a = ap.parse_args()
|
|
383
|
+
|
|
384
|
+
if a.context:
|
|
385
|
+
with io.open(a.context, encoding='utf-8-sig') as f:
|
|
386
|
+
ctx = json.load(f)
|
|
387
|
+
elif a.context_json:
|
|
388
|
+
ctx = json.loads(a.context_json)
|
|
389
|
+
else:
|
|
390
|
+
ap.error('必须提供 --context 或 --context-json')
|
|
391
|
+
|
|
392
|
+
if a.flow_key:
|
|
393
|
+
ctx.setdefault('flowKey', a.flow_key)
|
|
394
|
+
if a.company_name:
|
|
395
|
+
ctx.setdefault('hasCounterparty', True)
|
|
396
|
+
|
|
397
|
+
def rd(p):
|
|
398
|
+
if not p:
|
|
399
|
+
return ''
|
|
400
|
+
with io.open(p, encoding='utf-8') as f:
|
|
401
|
+
return f.read()
|
|
402
|
+
|
|
403
|
+
import datetime
|
|
404
|
+
stamp = datetime.datetime.now().strftime('%Y%m%d%H%M')
|
|
405
|
+
cfg = {
|
|
406
|
+
'file_id': a.file_id,
|
|
407
|
+
'file_name': a.file_name,
|
|
408
|
+
'flow_key': a.flow_key or ctx.get('flowKey'),
|
|
409
|
+
'company_name': a.company_name,
|
|
410
|
+
'summary_html': rd(a.summary_html),
|
|
411
|
+
'report_html': rd(a.report_html),
|
|
412
|
+
'compare_html': rd(a.compare_html),
|
|
413
|
+
'base': (a.base or DEFAULT_BASE).rstrip('/'),
|
|
414
|
+
'aiid': a.aiid,
|
|
415
|
+
'card_id': a.card_id or ('card-' + stamp),
|
|
416
|
+
'call_id': a.call_id or ('contract-card-%s-01' % stamp),
|
|
417
|
+
'title': a.title,
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
payload, p = render(ctx, cfg)
|
|
421
|
+
if payload is None:
|
|
422
|
+
print('NO_CARD: 过滤后无可用动作(按 contract-action-engine.md §7 处理)')
|
|
423
|
+
return 1
|
|
424
|
+
|
|
425
|
+
problems = self_check(payload)
|
|
426
|
+
shown = [c['id'] for c in p['cards']]
|
|
427
|
+
html_out = payload['arguments']['sdkOptions']['params_pc']['customParams']['html']
|
|
428
|
+
print('PLAN=%s' % ','.join(shown))
|
|
429
|
+
print('CARDS=%d' % len(re.findall(r"role='button'", html_out)))
|
|
430
|
+
if problems:
|
|
431
|
+
for x in problems:
|
|
432
|
+
print('[SELF_CHECK_FAIL] ' + x)
|
|
433
|
+
return 1
|
|
434
|
+
print('[SELF_CHECK_OK] 双引号 0、反斜杠仅安全转义、ES5、node --check 通过')
|
|
435
|
+
|
|
436
|
+
text = '<browsertool>\n' + json.dumps(payload, ensure_ascii=False, indent=1) + '\n</browsertool>'
|
|
437
|
+
if a.dry:
|
|
438
|
+
print('DRY_RUN, %d bytes' % len(text.encode('utf-8')))
|
|
439
|
+
return 0
|
|
440
|
+
if a.out:
|
|
441
|
+
with io.open(a.out, 'w', encoding='utf-8') as f:
|
|
442
|
+
f.write(text)
|
|
443
|
+
print('OUT=' + os.path.abspath(a.out))
|
|
444
|
+
else:
|
|
445
|
+
print(text)
|
|
446
|
+
return 0
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
if __name__ == '__main__':
|
|
450
|
+
sys.exit(main())
|