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,450 +0,0 @@
|
|
|
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())
|