vod-devkit 0.2.2 → 0.3.0
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/CHANGELOG.md +70 -0
- package/bin/vod-devkit +379 -13
- package/contract/tools.schema.json +138 -4
- package/package.json +1 -1
- package/plugins/vod-devkit/.codex-plugin/plugin.json +1 -1
- package/plugins/vod-devkit/build-info.json +3 -3
- package/plugins/vod-devkit/skills/vod-feedback-collect/SKILL.md +87 -3
- package/plugins/vod-devkit/vod_mcp/__init__.py +1 -1
- package/plugins/vod-devkit/vod_mcp/packs.py +23 -2
- package/plugins/vod-devkit/vod_mcp/server.py +7 -0
- package/plugins/vod-devkit/vod_mcp/tools.py +203 -21
- package/skills/vod-feedback-collect/SKILL.md +87 -3
- package/vod_mcp/__init__.py +1 -1
- package/vod_mcp/packs.py +23 -2
- package/vod_mcp/server.py +7 -0
- package/vod_mcp/tools.py +203 -21
package/vod_mcp/tools.py
CHANGED
|
@@ -19,6 +19,25 @@ from pathlib import Path
|
|
|
19
19
|
from vod_mcp import provenance
|
|
20
20
|
from vod_mcp import DEFAULT_JAVA_BASE
|
|
21
21
|
|
|
22
|
+
# D-followup-impl-2:追问拒答语义词集(答"没有"类=两字段不上送)。
|
|
23
|
+
# 契约话术承诺了"不方便回复没有",客户端必须技术兜底——模型不守话术纪律时
|
|
24
|
+
# 键集合仍零漂移(test_followup_declined_or_blank_omitted 回归锁)。
|
|
25
|
+
_FOLLOWUP_DECLINES = frozenset({
|
|
26
|
+
"没有", "无", "没有。", "没了", "跳过", "不方便", "不用了", "不用",
|
|
27
|
+
"不补充", "算了", "没有了", "没有了。", "不方便说", "no", "none", "skip", "n/a",
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _followup_fields(voice: dict) -> dict:
|
|
32
|
+
"""D-followup-impl-2 单源提取(submit 主路径与 draft 暂存共用,禁双边漂移):
|
|
33
|
+
仅 trim 非空且非拒答词才含键;引擎同口径截 2000;内容永不回流 content。"""
|
|
34
|
+
out = {}
|
|
35
|
+
for _f in ("reproSteps", "expectedBehavior"):
|
|
36
|
+
_val = str(voice.get(_f) or "").strip()
|
|
37
|
+
if _val and _val.lower() not in _FOLLOWUP_DECLINES:
|
|
38
|
+
out[_f] = _val[:2000]
|
|
39
|
+
return out
|
|
40
|
+
|
|
22
41
|
_CONTRACT_PATH = Path(__file__).resolve().parent.parent / "contract" / "tools.schema.json"
|
|
23
42
|
|
|
24
43
|
|
|
@@ -151,27 +170,35 @@ _PRODUCT_MAP = {
|
|
|
151
170
|
}
|
|
152
171
|
|
|
153
172
|
|
|
154
|
-
def _resolve_product(params: dict) -> str | None:
|
|
155
|
-
"""
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
173
|
+
def _resolve_product(params: dict) -> tuple[str | None, str | None]:
|
|
174
|
+
"""归因(D-attrib-A:2026-11-06 负责人拍板,方案 A 收紧):
|
|
175
|
+
归因只由 install 绑定(runtime.json product)决定——运行期显式传参
|
|
176
|
+
仅当与绑定一致(忽略大小写)才采信;不一致=宿主模型自报,一律忽略
|
|
177
|
+
回退绑定值(实锤:hermes 会话模型传 product="hermes" 覆盖 CodeArts
|
|
178
|
+
绑定,[HERMES] 未注册错归)。无绑定 → None(引擎 UNKNOWN 档兜底)。
|
|
179
|
+
返回 (product, ignored_runtime_product)。
|
|
159
180
|
T7i(方案 A,2026-11-05 拍板):产品归因主键化——
|
|
160
181
|
①纯数字串=平台主键 id,原样透传(引擎 selectById 精确命中)
|
|
161
182
|
②名字→meta productCatalog 按名解析出平台 id 后提交(对账主键化,
|
|
162
183
|
归一化/改名漂移不进提交链路);_PRODUCT_MAP 先归一短码再查目录
|
|
163
184
|
③目录无此名/目录不可用→规范名原样上送(引擎 name 兼容通道,
|
|
164
185
|
命中同样补落 product_id)——不静默丢提交。"""
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if raw.
|
|
169
|
-
|
|
170
|
-
|
|
186
|
+
binding = str(_RT.get("product") or "").strip()
|
|
187
|
+
raw = str(params.get("product") or "").strip()
|
|
188
|
+
ignored = None
|
|
189
|
+
if raw and (not binding or raw.lower() != binding.lower()):
|
|
190
|
+
ignored = raw # 运行期自报≠绑定(或无绑定)→ 忽略留痕,不采信
|
|
191
|
+
raw = ""
|
|
192
|
+
product = raw or binding or None
|
|
193
|
+
if not product:
|
|
194
|
+
return None, ignored
|
|
195
|
+
if product.isdigit():
|
|
196
|
+
return product, ignored
|
|
197
|
+
name = _PRODUCT_MAP.get(product.lower(), product)
|
|
171
198
|
for item in (_load_meta().get("catalog") or []):
|
|
172
199
|
if str(item.get("name") or "").lower() == name.lower():
|
|
173
|
-
return str(item.get("id"))
|
|
174
|
-
return name
|
|
200
|
+
return str(item.get("id")), ignored
|
|
201
|
+
return name, ignored
|
|
175
202
|
|
|
176
203
|
|
|
177
204
|
_SUBMIT_HOARDING = "/rest/developer/manager/hdvodmngservice/v1/external/voices"
|
|
@@ -224,7 +251,8 @@ def _explicit_key() -> bool:
|
|
|
224
251
|
return bool(JAVA_KEY) and str(_RT.get("token_tier") or "") != "anonymous"
|
|
225
252
|
|
|
226
253
|
|
|
227
|
-
def submit_voices(params: dict, client_info: dict | None = None
|
|
254
|
+
def submit_voices(params: dict, client_info: dict | None = None,
|
|
255
|
+
ledger_extra: dict | None = None) -> dict:
|
|
228
256
|
"""V16 切换:主路径=囤积端点 POST /external/voices(Bearer,批式,不触发分析);
|
|
229
257
|
引擎未部署(404)自动回落老链 /external/voice/submit(提交即分析,过渡语义,
|
|
230
258
|
部署后 404 分支自然失效)。
|
|
@@ -237,7 +265,7 @@ def submit_voices(params: dict, client_info: dict | None = None) -> dict:
|
|
|
237
265
|
"""
|
|
238
266
|
import uuid
|
|
239
267
|
host = (client_info or {}).get("name") or "unknown-host"
|
|
240
|
-
product = _resolve_product(params)
|
|
268
|
+
product, ignored_runtime = _resolve_product(params)
|
|
241
269
|
accepted, voice_ids, task_ids, rejected = 0, [], [], []
|
|
242
270
|
global JAVA_KEY
|
|
243
271
|
voices_in = params.get("voices", [])
|
|
@@ -254,12 +282,28 @@ def submit_voices(params: dict, client_info: dict | None = None) -> dict:
|
|
|
254
282
|
if not items:
|
|
255
283
|
return {"accepted": 0, "voiceIds": [], "taskIds": [], "rejected": rejected}
|
|
256
284
|
|
|
285
|
+
def _echo(vids):
|
|
286
|
+
"""方案 A(2026-11-06 拍板):提交回执强制携带原话回显。
|
|
287
|
+
检测型防线——宿主模型改写用户原话(实锤:"体验不好"→"不友好")
|
|
288
|
+
在回执处当场可见;agent 必须原样转述,改写露馅。"""
|
|
289
|
+
ok = [(vid, items[min(i, len(items) - 1)][2])
|
|
290
|
+
for i, vid in enumerate(vids) if vid]
|
|
291
|
+
return {
|
|
292
|
+
"requiresUserEcho": bool(ok),
|
|
293
|
+
"instruction": ("请向用户原样转述已收录内容:每条以「已收录原话:」开头,"
|
|
294
|
+
"后接 content 全文。禁止改写、概括、增删字词。"),
|
|
295
|
+
"contents": [{"voiceId": vid, "content": c} for vid, c in ok],
|
|
296
|
+
}
|
|
297
|
+
|
|
257
298
|
def _ledger(vids, tids):
|
|
258
299
|
import time as _time
|
|
259
300
|
entries = [{"voiceId": vid, "taskId": tid,
|
|
260
301
|
"title": items[min(i, len(items) - 1)][2][:40],
|
|
261
302
|
"product": product, "at": _time.strftime("%Y-%m-%dT%H:%M:%S")}
|
|
262
303
|
for i, (vid, tid) in enumerate(zip(vids, tids))]
|
|
304
|
+
if ledger_extra:
|
|
305
|
+
for e in entries:
|
|
306
|
+
e.update(ledger_extra) # 两段式:stage=committed + draftId 关联(验收③)
|
|
263
307
|
_ledger_append(entries)
|
|
264
308
|
|
|
265
309
|
def _legacy_submit(i, v, content):
|
|
@@ -289,6 +333,9 @@ def submit_voices(params: dict, client_info: dict | None = None) -> dict:
|
|
|
289
333
|
ut = v.get("userType")
|
|
290
334
|
if ut:
|
|
291
335
|
hv["userType"] = ut
|
|
336
|
+
# D-followup-impl-2 追问补充透传:单源 _followup_fields(拒答词集兜底+
|
|
337
|
+
# 引擎同口径截 2000+禁回流 content;未追问/答"没有"=键集合零漂移)
|
|
338
|
+
hv.update(_followup_fields(v))
|
|
292
339
|
hoard_voices.append(hv)
|
|
293
340
|
body = {"voices": hoard_voices}
|
|
294
341
|
if product: # 无归因不带 product(引擎 UNKNOWN 档),不本地拦截
|
|
@@ -324,15 +371,32 @@ def submit_voices(params: dict, client_info: dict | None = None) -> dict:
|
|
|
324
371
|
if not fallback:
|
|
325
372
|
server_ids = (out.get("voiceIds") or out.get("data", {}).get("voiceIds")
|
|
326
373
|
or [])
|
|
327
|
-
|
|
328
|
-
|
|
374
|
+
# 引擎侧 rejected(产品校验拒绝等)透出,不吞(对齐 widget rejected 口径)
|
|
375
|
+
engine_rejected = ((out or {}).get("rejected")
|
|
376
|
+
or ((out or {}).get("data") or {}).get("rejected")
|
|
377
|
+
or [])
|
|
378
|
+
if server_ids:
|
|
379
|
+
accepted = len(server_ids)
|
|
380
|
+
voice_ids.extend(server_ids)
|
|
381
|
+
else:
|
|
382
|
+
# 回执缺失/整批被拒 → 不得兜底计成功(实锤缺陷:空 voiceId 记成功
|
|
383
|
+
# 且宿主模型据此谎报"已提交")。accepted 以真实回执为准。
|
|
384
|
+
accepted = 0
|
|
385
|
+
voice_ids.extend([""] * len(hoard_voices))
|
|
386
|
+
if not engine_rejected:
|
|
387
|
+
engine_rejected = [{"reason": "引擎回执未含 voiceIds(提交结果未知),请勿视为已收录"}]
|
|
329
388
|
task_ids.extend([None] * len(hoard_voices)) # 囤积语义:无即时任务
|
|
330
389
|
result = {"accepted": accepted, "voiceIds": voice_ids,
|
|
331
|
-
"taskIds": task_ids, "rejected": rejected,
|
|
390
|
+
"taskIds": task_ids, "rejected": rejected + engine_rejected,
|
|
332
391
|
"analysis": "deferred", # 囤积语义明示(V6 运营批量消费)
|
|
333
|
-
"path": "hoarding"
|
|
392
|
+
"path": "hoarding",
|
|
393
|
+
"echo": _echo(voice_ids)}
|
|
334
394
|
if out.get("productRegistered") is not None:
|
|
335
395
|
result["productRegistered"] = out.get("productRegistered")
|
|
396
|
+
# D-attrib-A 可观测:模型试图改归因留痕,不静默吞
|
|
397
|
+
result["productSource"] = "install_binding"
|
|
398
|
+
if ignored_runtime:
|
|
399
|
+
result["ignoredRuntimeProduct"] = ignored_runtime
|
|
336
400
|
_ledger(voice_ids, task_ids)
|
|
337
401
|
return result
|
|
338
402
|
# ---- 过渡回落:老链单条提交(仅囤积端点 404 触发) ----
|
|
@@ -371,7 +435,8 @@ def submit_voices(params: dict, client_info: dict | None = None) -> dict:
|
|
|
371
435
|
rejected.append({"index": i, "reason": msg[:120]})
|
|
372
436
|
result = {"accepted": accepted, "voiceIds": voice_ids,
|
|
373
437
|
"taskIds": task_ids, "rejected": rejected,
|
|
374
|
-
"path": "legacy-fallback"
|
|
438
|
+
"path": "legacy-fallback",
|
|
439
|
+
"echo": _echo(voice_ids)}
|
|
375
440
|
_ledger(voice_ids, task_ids)
|
|
376
441
|
return result
|
|
377
442
|
|
|
@@ -623,11 +688,128 @@ def devkit_info(params: dict, client_info: dict | None = None) -> dict:
|
|
|
623
688
|
|
|
624
689
|
|
|
625
690
|
# 工具名 → 处理器(是否接收 client_info)
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
# ---- 两段式提交(D-token-approval-2 极简形态:插件本地 draft→commit,引擎零改动)----
|
|
694
|
+
# 定性:最强摩擦+审计链,非人类确认硬保证(decisions 既有纠偏)。
|
|
695
|
+
# draft 暂存 runtime.json(cap 10 环形+TTL 600s),commit 单次消费后内部复用
|
|
696
|
+
# submit_voices 既有链——配额/幂等/归因/回显语义零新增。stage=draft/committed
|
|
697
|
+
# 入账本:绕过两段式的直接提交在账本层面可检测(验收③)。
|
|
698
|
+
|
|
699
|
+
_DRAFT_KEY = "drafts"
|
|
700
|
+
_DRAFT_CAP = 10
|
|
701
|
+
_DRAFT_TTL = 600 # 秒;过期 commit 拒收,草稿自动作废
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
def _drafts_purge(store: dict) -> dict:
|
|
705
|
+
"""过期草稿清除(读时惰性,无后台任务)。"""
|
|
706
|
+
import time as _time
|
|
707
|
+
now = _time.time()
|
|
708
|
+
return {k: v for k, v in store.items()
|
|
709
|
+
if v.get("expiresAt", 0) > now}
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
def draft_voices(params: dict, client_info: dict | None = None) -> dict:
|
|
713
|
+
"""两段式第一步:校验+暂存草稿+签发一次性令牌(不提交任何数据)。"""
|
|
714
|
+
import time as _time
|
|
715
|
+
product, ignored_runtime = _resolve_product(params)
|
|
716
|
+
voices_in = params.get("voices", [])
|
|
717
|
+
clean = []
|
|
718
|
+
for i, v in enumerate(voices_in):
|
|
719
|
+
content = str(v.get("content", "")).strip()
|
|
720
|
+
if not content:
|
|
721
|
+
raise ToolError(f"第 {i + 1} 条 content 为空", code=-32602)
|
|
722
|
+
if len(content) > 2000:
|
|
723
|
+
raise ToolError(f"第 {i + 1} 条 content 超 2000 字({len(content)})", code=-32602)
|
|
724
|
+
item = {"content": content}
|
|
725
|
+
if v.get("tags"):
|
|
726
|
+
item["tags"] = v["tags"]
|
|
727
|
+
if v.get("userType"):
|
|
728
|
+
item["userType"] = v["userType"]
|
|
729
|
+
# D-followup-impl-2:追问补充随 draft 暂存(commit 复用 payload 原样上送),
|
|
730
|
+
# 单源 _followup_fields 与主路径同口径
|
|
731
|
+
item.update(_followup_fields(v))
|
|
732
|
+
clean.append(item)
|
|
733
|
+
if not clean:
|
|
734
|
+
raise ToolError("voices 为必填且至少 1 条", code=-32602)
|
|
735
|
+
|
|
736
|
+
import secrets
|
|
737
|
+
draft_id = "draft_" + secrets.token_hex(8)
|
|
738
|
+
token = secrets.token_hex(16)
|
|
739
|
+
payload = {"voices": clean}
|
|
740
|
+
if product:
|
|
741
|
+
payload["product"] = product
|
|
742
|
+
# 载荷 sha(防 draft→commit 间改写:commit 校验插件侧重算值一致)
|
|
743
|
+
import hashlib
|
|
744
|
+
payload_sha = hashlib.sha256(
|
|
745
|
+
json.dumps(payload, sort_keys=True, ensure_ascii=False).encode()).hexdigest()
|
|
746
|
+
|
|
747
|
+
fresh = _runtime_cfg()
|
|
748
|
+
store = _drafts_purge(fresh.get(_DRAFT_KEY) or {})
|
|
749
|
+
store[draft_id] = {
|
|
750
|
+
"payload": payload, "payloadSha256": payload_sha, "tokenHash": _sha256(token),
|
|
751
|
+
"product": product, "createdAt": _time.strftime("%Y-%m-%dT%H:%M:%S"),
|
|
752
|
+
"expiresAt": _time.time() + _DRAFT_TTL,
|
|
753
|
+
}
|
|
754
|
+
while len(store) > _DRAFT_CAP: # 环形:最旧先淘汰
|
|
755
|
+
store.pop(next(iter(store)))
|
|
756
|
+
_save_runtime({_DRAFT_KEY: store})
|
|
757
|
+
|
|
758
|
+
if ignored_runtime: # D-attrib-A 可观测:模型试图改归因留痕
|
|
759
|
+
_warn(f"draft: runtime product 被忽略(绑定权威): {ignored_runtime}")
|
|
760
|
+
return {
|
|
761
|
+
"draftId": draft_id,
|
|
762
|
+
"approvalToken": token,
|
|
763
|
+
"payloadSha256": payload_sha,
|
|
764
|
+
"expiresInSeconds": _DRAFT_TTL,
|
|
765
|
+
"contents": [{"index": i, "content": it["content"]} for i, it in enumerate(clean)],
|
|
766
|
+
"instruction": ("把 contents 逐条原样展示给用户核对(禁止改写概括),明确问"
|
|
767
|
+
"「确认提交吗」。用户明确同意前禁止调用 vod_commit_voices;"
|
|
768
|
+
"不同意则停(草稿 10 分钟后自动作废)。"),
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
def commit_voices(params: dict, client_info: dict | None = None) -> dict:
|
|
773
|
+
"""两段式第二步:令牌校验→单次消费→复用 submit_voices 既有提交链。"""
|
|
774
|
+
draft_id = str(params.get("draftId", ""))
|
|
775
|
+
token = str(params.get("approvalToken", ""))
|
|
776
|
+
payload_sha = str(params.get("payloadSha256", ""))
|
|
777
|
+
if not draft_id or not token or not payload_sha:
|
|
778
|
+
raise ToolError("draftId/approvalToken/payloadSha256 为必填(取自 vod_draft_voices 返回原样透传)",
|
|
779
|
+
code=-32602)
|
|
780
|
+
|
|
781
|
+
fresh = _runtime_cfg()
|
|
782
|
+
store = _drafts_purge(fresh.get(_DRAFT_KEY) or {})
|
|
783
|
+
draft = store.get(draft_id)
|
|
784
|
+
if draft is None:
|
|
785
|
+
raise ToolError("草稿不存在或已过期(10 分钟 TTL),请重新 vod_draft_voices", code=-32011)
|
|
786
|
+
if draft["tokenHash"] != _sha256(token):
|
|
787
|
+
raise ToolError("审批令牌不匹配(draft 返回的 approvalToken 原样透传)", code=-32011)
|
|
788
|
+
if draft["payloadSha256"] != payload_sha:
|
|
789
|
+
raise ToolError("载荷校验不符(payloadSha256 与 draft 签发值不一致,禁止改写已确认内容)",
|
|
790
|
+
code=-32011)
|
|
791
|
+
# 单次消费:先摘除再提交——提交中途崩溃也不会二次提交(宁可丢一单重走流程)
|
|
792
|
+
store.pop(draft_id)
|
|
793
|
+
_save_runtime({_DRAFT_KEY: store})
|
|
794
|
+
|
|
795
|
+
out = submit_voices(dict(draft["payload"]), client_info,
|
|
796
|
+
ledger_extra={"stage": "committed", "draftId": draft_id})
|
|
797
|
+
out["twoPhase"] = True
|
|
798
|
+
out["draftId"] = draft_id
|
|
799
|
+
return out
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
def _sha256(s: str) -> str:
|
|
803
|
+
import hashlib
|
|
804
|
+
return hashlib.sha256(s.encode()).hexdigest()
|
|
805
|
+
|
|
626
806
|
_HANDLERS = {
|
|
627
807
|
"vod_submit_voices": submit_voices,
|
|
628
808
|
"vod_list_submitted": list_submitted,
|
|
629
809
|
"vod_devkit_info": devkit_info,
|
|
630
810
|
"vod_auth_status": auth_status,
|
|
811
|
+
"vod_draft_voices": draft_voices,
|
|
812
|
+
"vod_commit_voices": commit_voices,
|
|
631
813
|
}
|
|
632
814
|
|
|
633
815
|
|
|
@@ -635,5 +817,5 @@ def dispatch(name: str, params: dict, client_info: dict | None = None) -> dict:
|
|
|
635
817
|
handler = _HANDLERS.get(name)
|
|
636
818
|
if handler is None:
|
|
637
819
|
raise ToolError(f"未知工具: {name}", code=-32601)
|
|
638
|
-
needs_host = handler in (devkit_info, submit_voices, auth_status)
|
|
820
|
+
needs_host = handler in (devkit_info, submit_voices, auth_status, draft_voices, commit_voices)
|
|
639
821
|
return handler(params, client_info) if needs_host else handler(params)
|