dsh-vod-devkit 0.1.1 → 0.2.1
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 +7 -6
- package/lib/client.js +1 -1
- package/lib/index.js +137 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,16 +16,17 @@ VOD 用户声音采集插件 —— DeepSeek Harness (dsh) 薄壳。
|
|
|
16
16
|
## 安装
|
|
17
17
|
|
|
18
18
|
```
|
|
19
|
-
|
|
20
|
-
dsh plugin --profile <name> add
|
|
19
|
+
npx --yes vod-devkit install --target dsh --profile <name> --product <产品> # 推荐(安装期硬校验+幂等写配置)
|
|
20
|
+
dsh plugin --profile <name> add dsh-vod-devkit # 直装(装后须手工配 product,见下)
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
装后产品归因必须落到 profile 的 cordis.patch.yml(npx 包装命令自动写入):
|
|
24
24
|
|
|
25
25
|
```yaml
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
- id: vod-devkit
|
|
27
|
+
config:
|
|
28
|
+
product: codearts # 归因绑定(安装时定);无运行期传参通道
|
|
29
|
+
# apiBase: https://vod-dev.topxtopx.com # 缺省即此
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
## 配置(dsh 插件设置)
|
package/lib/client.js
CHANGED
|
@@ -3,7 +3,7 @@ window.__ModuleLoader__.load({
|
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
|
-
var L=Object.create;var h=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var V=(t,r)=>{for(var e in r)h(t,e,{get:r[e],enumerable:!0})},E=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of M(r))!U.call(t,n)&&n!==e&&h(t,n,{get:()=>r[n],enumerable:!(o=B(r,n))||o.enumerable});return t};var H=(t,r,e)=>(e=t!=null?L(P(t)):{},E(r||!t||!t.__esModule?h(e,"default",{value:t,enumerable:!0}):e,t)),$=t=>E(h({},"__esModule",{value:!0}),t);var tt={};V(tt,{apply:()=>Y,name:()=>Z});module.exports=$(tt);var a=require("react/jsx-runtime"),u=H(require("react"),1);const O="/rest/developer/manager/hdvodmngservice/v1";let m=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_BASE__||"";const j=`${O}/external/token`,w=`${O}/external/voices`,S="vod_dshui_token",T="vod_dshui_device",y="vod_dshui_ledger",_="vod_dshui_draft",R=200,N=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_LEDGER_DISABLED__===!0,x=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_PRODUCT__||"",A={textarea:{width:"100%",boxSizing:"border-box",minHeight:96,borderRadius:"var(--dsw-radius-sm, 8px)",border:"1px solid var(--dsw-alias-border-l3, #ccc)",padding:"8px 10px",fontSize:13,resize:"vertical",background:"var(--dsw-alias-bg-layer-1, transparent)",color:"var(--dsw-alias-label-primary, #111)",outline:"none"},input:{width:"100%",boxSizing:"border-box",borderRadius:"var(--dsw-radius-sm, 8px)",border:"1px solid var(--dsw-alias-border-l3, #ccc)",padding:"7px 10px",fontSize:13,background:"var(--dsw-alias-bg-layer-1, transparent)",color:"var(--dsw-alias-label-primary, #111)",outline:"none"},hint:{fontSize:12,color:"var(--dsw-alias-label-caption, #999)",marginBottom:12},label:{fontSize:12,color:"var(--dsw-alias-label-secondary, #666)",margin:"10px 0 6px"},result:{fontSize:12,marginBottom:12,padding:"8px 10px",borderRadius:"var(--dsw-radius-sm, 8px)",background:"var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.05))",color:"var(--dsw-alias-label-primary, #111)"}};function I(){let t=localStorage.getItem(T);return t||(t=(crypto.randomUUID?crypto.randomUUID():Date.now().toString(16)+Math.random().toString(16).slice(2)+Math.random().toString(16).slice(2)).replace(/[^0-9a-f]/g,"").slice(0,32),localStorage.setItem(T,t)),t}async function z(t){if(typeof crypto<"u"&&crypto.subtle){const r=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(t));return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,"0")).join("")}return F(t)}function F(t){let o=2166136261,n=3752705916;for(let i=0;i<t.length;i++){const l=t.charCodeAt(i);o^=l,o=Math.imul(o,16777619)>>>0,n^=l<<3&65535,n=Math.imul(n,2246822507)>>>0}return o.toString(16).padStart(8,"0")+n.toString(16).padStart(8,"0")}async function J(t){return`ext_dshui_${(await z(I())).slice(0,8)}_${(await z(t)).slice(0,12)}`}function k(t){if(N)return;const r=JSON.parse(localStorage.getItem(y)||"[]");r.unshift(t),localStorage.setItem(y,JSON.stringify(r.slice(0,R)))}async function D(){let t=localStorage.getItem(S);if(t)return t;const r=await fetch(m+j,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":I()},body:"{}"});if(r.status!==200&&r.status!==201)throw new Error(`token ${r.status}`);const e=await r.json().catch(()=>({}));if(t=typeof e=="string"?e:e.token||e.data?.token||"",!t)throw new Error("token empty");return localStorage.setItem(S,t),t}function K({title:t,onClose:r,children:e,footer:o}){return(0,u.useEffect)(()=>{const n=i=>i.key==="Escape"&&r();return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[r]),(0,a.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9e3,background:"rgba(0,0,0,.35)",display:"flex",alignItems:"center",justifyContent:"center"},onMouseDown:n=>n.target===n.currentTarget&&r(),children:(0,a.jsxs)("div",{role:"dialog","aria-label":t,style:{width:"min(488px, 92vw)",borderRadius:"var(--dsw-radius-panel, 12px)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)",padding:"18px 20px",fontFamily:"inherit",boxShadow:"0 8px 40px rgba(0,0,0,.2)"},children:[(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[(0,a.jsx)("div",{style:{fontSize:15,fontWeight:600},children:t}),(0,a.jsx)("button",{onClick:r,"aria-label":"\u5173\u95ED",style:{border:"none",background:"transparent",cursor:"pointer",fontSize:16,lineHeight:1,padding:4,borderRadius:6,color:"var(--dsw-alias-label-tertiary, #888)"},children:"\u2715"})]}),e,o&&(0,a.jsx)("div",{style:{marginTop:14},children:o})]})})}function G({disabled:t,onClick:r,children:e}){return(0,a.jsx)("button",{disabled:t,onClick:r,style:{width:"100%",height:44,fontSize:14,fontWeight:500,border:"none",cursor:t?"not-allowed":"pointer",borderRadius:"var(--dsw-radius-lg, 10px)",background:t?"var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.06))":"var(--dsw-alias-button-primary-fill, #2563eb)",color:t?"var(--dsw-alias-label-tertiary, #999)":"var(--dsw-alias-label-primary-foreground, #fff)"},children:e})}async function W(t,r){try{const e=await D(),o=await fetch(m+w+"?limit=50",{headers:{authorization:`Bearer ${e}`}});if(o.status!==200)return null;const n=await o.json().catch(()=>({})),l=(n.voices||n.data?.voices||[]).find(g=>g.voiceId===t);return l&&l.issue_sync||null}catch{return null}}let C=!1;async function X(){if(C)return;C=!0;const t=JSON.parse(localStorage.getItem(y)||"[]").filter(e=>e.status==="pending-endpoint"||e.status==="failed");for(const e of t.slice(0,5))try{const o=await D(),n=await fetch(m+w,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${o}`},body:JSON.stringify({voices:[{title:e.title,content:e.content}],product:x})});if(n.status===200||n.status===201){e.status="accepted";try{localStorage.removeItem(_)}catch{}const i=await n.json().catch(()=>({}));e.serverVoiceId=(i.voiceIds||i.data?.voiceIds||[])[0]||"",e.retriedAt=new Date().toISOString()}else n.status!==404&&(e.error=`retry ${n.status}`)}catch(o){e.error=String(o&&o.message||o)}if(t.filter(e=>e.status!=="accepted").length!==t.length||t.length){const e=JSON.parse(localStorage.getItem(y)||"[]"),o=new Map(t.map(i=>[i.voiceKey,i])),n=e.map(i=>o.get(i.voiceKey)||i);localStorage.setItem(y,JSON.stringify(n.slice(0,R)))}}function q({onClose:t}){const r=(()=>{try{return JSON.parse(localStorage.getItem(_)||"null")||{}}catch{return{}}})(),[e,o]=(0,u.useState)(r.content||"");(0,u.useEffect)(()=>{try{localStorage.setItem(_,JSON.stringify({content:e}))}catch{}},[e]);const[n,i]=(0,u.useState)(!1),[l,g]=(0,u.useState)(null);async function v(s,c){if(s)for(let p=0;p<6;p++){await new Promise(f=>setTimeout(f,1e4));const d=await W(s);if(d){if(d.status==="CREATED"&&d.issue_url){c({ok:!0,msg:`\u5DF2\u5EFA\u6210 issue\uFF1A${d.issue_url}`});return}if(d.status==="REJECTED"){c({ok:!1,msg:"\u53CD\u9988\u7ECF\u5BA1\u6838\u672A\u91C7\u7EB3\uFF0C\u611F\u8C22\u4F60\u7684\u63D0\u4EA4\u3002"});return}}}}async function b(){const s=e.trim();if(!s){g({ok:!1,msg:"\u8BF7\u5148\u586B\u5199\u53CD\u9988\u5185\u5BB9"});return}if(s.length>2e3){g({ok:!1,msg:`\u5185\u5BB9\u8D85\u957F\uFF08${s.length}/2000\uFF09\uFF0C\u8BF7\u7CBE\u7B80`});return}i(!0),g(null);const c={title:s.slice(0,64),content:s,at:new Date().toISOString(),status:"failed",error:""};try{c.voiceKey=await J(s);try{const p=await D(),d=await fetch(m+w,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":I(),authorization:`Bearer ${p}`},body:JSON.stringify({voices:[{title:s.slice(0,60),content:s}],product:x})});if(d.status===404){c.status="pending-endpoint",k(c),g({ok:!1,msg:"\u56E4\u79EF\u7AEF\u70B9\u5C1A\u672A\u4E0A\u7EBF\uFF08\u5F15\u64CE\u90E8\u7F72\u540E\u81EA\u52A8\u53EF\u7528\uFF09\uFF1B\u53CD\u9988\u5DF2\u6682\u5B58\u672C\u673A\uFF0C\u7A0D\u540E\u91CD\u8BD5\u63D0\u4EA4\u3002"});return}if(d.status===401&&localStorage.removeItem(S),d.status!==200&&d.status!==201)throw new Error(`submit ${d.status}`);const f=await d.json().catch(()=>({}));c.status="accepted",c.serverVoiceId=f.voiceIds?.[0]||"",c.taskId=f.taskIds?.[0]||"",k(c),f.productRegistered===void 0||f.productRegistered||console.warn("[vod-devkit] product \u672A\u6CE8\u518C\uFF08\u90E8\u7F72\u65B9\u6838\u5BF9\u9879\uFF09:",c.product),g({ok:!0,msg:"\u611F\u8C22\u4F60\u7684\u53CD\u9988\uFF0C\u5DF2\u6536\u5F55\u3002"}),v(c.serverVoiceId,g)}catch(p){c.error=String(p&&p.message||p),k(c);const d=String(c.error||""),f=d.includes("429")?"\u63D0\u4EA4\u592A\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF08\u5DF2\u6682\u5B58\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\uFF09":d.includes("401")?"\u63D0\u4EA4\u901A\u9053\u9700\u8981\u91CD\u65B0\u9A8C\u8BC1\uFF08\u5DF2\u6682\u5B58\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5\uFF09":"\u63D0\u4EA4\u5931\u8D25\uFF0C\u5DF2\u6682\u5B58\u672C\u673A\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u8BD5";g({ok:!1,msg:f})}}finally{i(!1)}}return(0,a.jsxs)(K,{title:"\u63D0\u4EA4\u53CD\u9988",onClose:t,footer:(0,a.jsx)(G,{disabled:n||!e.trim(),onClick:b,children:n?"\u63D0\u4EA4\u4E2D\u2026":"\u63D0\u4EA4"}),children:[(0,a.jsx)("textarea",{style:A.textarea,value:e,maxLength:2e3,placeholder:"\u6BD4\u5982\uFF1A\u5BF9\u8BDD\u54CD\u5E94\u6162\u3001\u67D0\u4E2A\u529F\u80FD\u627E\u4E0D\u5230\u5165\u53E3",autoFocus:!0,onChange:s=>o(s.target.value)}),(0,a.jsxs)("div",{style:{fontSize:11,textAlign:"right",margin:"4px 0 0",color:"var(--dsw-alias-label-tertiary, #999)"},children:[e.length,"/2000"]}),l&&(0,a.jsx)("div",{style:A.result,children:l.msg})]})}function Q(){const[t,r]=(0,u.useState)(!1),e=(0,u.useRef)(null);return(0,u.useEffect)(()=>{X();const o=()=>{const l=e.current;if(!l)return;const g=document.querySelector("[contenteditable=true][role=textbox], [contenteditable=true]");if(!g)return;const v=g.getBoundingClientRect(),b=l.offsetWidth||24,s=24;l.style.left=Math.round(v.right-b-8)+"px",l.style.top=Math.round(v.top-s-6)+"px",l.style.width=b+"px",l.style.height=s+"px"};o();const n=new ResizeObserver(o);n.observe(document.documentElement),window.addEventListener("resize",o);const i=setInterval(o,800);return()=>{n.disconnect(),window.removeEventListener("resize",o),clearInterval(i)}},[]),(0,a.jsxs)(u.default.Fragment,{children:[(0,a.jsxs)("button",{ref:e,title:"\u53CD\u9988","aria-label":"\u53CD\u9988\u5F00\u53D1\u8005\u58F0\u97F3",style:{position:"fixed",zIndex:300,border:"none",background:"transparent",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",gap:4,borderRadius:"var(--dsw-radius-sm, 6px)",color:"var(--dsw-alias-label-tertiary, #888)",fontFamily:"inherit"},onMouseEnter:o=>o.currentTarget.style.color="var(--dsw-alias-label-primary, #111)",onMouseLeave:o=>o.currentTarget.style.color="var(--dsw-alias-label-tertiary, #888)",onClick:()=>r(!0),children:[(0,a.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,a.jsx)("path",{d:"M21.5 2.5 2.9 10.2c-.8.3-.8 1.5.1 1.7l4.6 1.4 1.7 5.5c.3.9 1.4 1 1.9.3l2.5-3.3 4.6 3.4c.7.5 1.7.1 1.9-.8l3.2-14.4c.2-.9-.7-1.7-1.5-1.4z"}),(0,a.jsx)("path",{d:"M7.3 13.5 21.5 2.5l-9.5 12.3"})]}),(0,a.jsx)("span",{style:{fontSize:12,lineHeight:1,whiteSpace:"nowrap"},children:"\u53CD\u9988"})]}),t&&(0,a.jsx)(q,{onClose:()=>r(!1)})]})}function Y(t){if(!x){console.error('[vod-devkit] \u5D4C\u5165\u65B9\u672A\u6CE8\u5165 __VOD_DSH_UI_PRODUCT__\uFF0C\u53CD\u9988\u5165\u53E3\u672A\u6FC0\u6D3B\u3002\u4EA7\u54C1\u5F52\u56E0\u662F\u5FC5\u914D\u9879\uFF1A\u5D4C\u5165\u65B9\u88C5\u524D\u8BBE\u7F6E window.__VOD_DSH_UI_PRODUCT__ = "<\u4EA7\u54C1\u540D>"\uFF08\u53D6\u503C=\u751F\u6001\u770B\u677F\u4EA7\u54C1\u540D\uFF1A\u9AD8\u6821AI\u5F00\u53D1\u8005\u5E73\u53F0/\u6210\u957F\u4E2D\u5FC3/AI\u4E91\u539F\u751F\u5F00\u53D1\u5B9E\u8DF5\u4E2D\u5FC3/\u9E3F\u8499\u5F00\u53D1\u5B9E\u8DF5\u4E2D\u5FC3/AI\u529E\u516C\u5B9E\u8DF5\u4E2D\u5FC3/IaC \u5B9E\u8DF5\u4E2D\u5FC3/AI \u5F00\u53D1\u8005\u7A7A\u95F4/AI Agent \u96C6\u6210/AI \u5DE5\u5177\u96C6\u6210/AI \u8FD0\u884C\u73AF\u5883/\u5F00\u653E\u80FD\u529B/Skills\u95E8\u6237/GTD/VOD\uFF09');return}t.slots.inject("conversation.composer.dock",function*(){yield t.slots.register({name:"conversation.composer.dock",id:"vod-feedback",order:20},Q)})}const Z="vod-devkit-ui";
|
|
6
|
+
var B=Object.create;var b=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var n in e)b(t,n,{get:e[n],enumerable:!0})},O=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of U(e))!j.call(t,o)&&o!==n&&b(t,o,{get:()=>e[o],enumerable:!(r=M(e,o))||r.enumerable});return t};var N=(t,e,n)=>(n=t!=null?B(V(t)):{},O(e||!t||!t.__esModule?b(n,"default",{value:t,enumerable:!0}):n,t)),J=t=>O(b({},"__esModule",{value:!0}),t);var ot={};H(ot,{apply:()=>et,name:()=>rt});module.exports=J(ot);var s=require("react/jsx-runtime"),d=N(require("react"),1);const _="/rest/developer/manager/hdvodmngservice/v1";let w=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_BASE__||"";const F=`${_}/external/token`,T=`${_}/external/voices`,K=`${_}/external/meta`,I="vod_dshui_token",R="vod_dshui_device",h="vod_dshui_ledger",x="vod_dshui_draft",k="vod_dshui_recovered",A=200,G=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_LEDGER_DISABLED__===!0,D=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_PRODUCT__||"",C={textarea:{width:"100%",boxSizing:"border-box",minHeight:96,borderRadius:"var(--dsw-radius-sm, 8px)",border:"1px solid var(--dsw-alias-border-l3, #ccc)",padding:"8px 10px",fontSize:13,resize:"none",background:"var(--dsw-alias-bg-layer-1, transparent)",color:"var(--dsw-alias-label-primary, #111)",outline:"none"},input:{width:"100%",boxSizing:"border-box",borderRadius:"var(--dsw-radius-sm, 8px)",border:"1px solid var(--dsw-alias-border-l3, #ccc)",padding:"7px 10px",fontSize:13,background:"var(--dsw-alias-bg-layer-1, transparent)",color:"var(--dsw-alias-label-primary, #111)",outline:"none"},hint:{fontSize:12,color:"var(--dsw-alias-label-caption, #999)",marginBottom:12},label:{fontSize:12,color:"var(--dsw-alias-label-secondary, #666)",margin:"10px 0 6px"},result:{fontSize:12,marginBottom:12,padding:"8px 10px",borderRadius:"var(--dsw-radius-sm, 8px)",background:"var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.05))",color:"var(--dsw-alias-label-primary, #111)"}};function S(){let t=localStorage.getItem(R);return t||(t=(crypto.randomUUID?crypto.randomUUID():Date.now().toString(16)+Math.random().toString(16).slice(2)+Math.random().toString(16).slice(2)).replace(/[^0-9a-f]/g,"").slice(0,32),localStorage.setItem(R,t)),t}async function L(t){if(typeof crypto<"u"&&crypto.subtle){const e=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(t));return[...new Uint8Array(e)].map(n=>n.toString(16).padStart(2,"0")).join("")}return W(t)}function W(t){let r=2166136261,o=3752705916;for(let l=0;l<t.length;l++){const i=t.charCodeAt(l);r^=i,r=Math.imul(r,16777619)>>>0,o^=i<<3&65535,o=Math.imul(o,2246822507)>>>0}return r.toString(16).padStart(8,"0")+o.toString(16).padStart(8,"0")}async function X(t){return`ext_dshui_${(await L(S())).slice(0,8)}_${(await L(t)).slice(0,12)}`}function E(t){if(G)return;const e=JSON.parse(localStorage.getItem(h)||"[]");e.unshift(t),localStorage.setItem(h,JSON.stringify(e.slice(0,A)))}async function z(){let t=localStorage.getItem(I);if(t)return t;const e=await fetch(w+F,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":S()},body:"{}"});if(e.status!==200&&e.status!==201)throw new Error(`token ${e.status}`);const n=await e.json().catch(()=>({}));if(t=typeof n=="string"?n:n.token||n.data?.token||"",!t)throw new Error("token empty");return localStorage.setItem(I,t),t}function q({title:t,onClose:e,children:n,footer:r}){return(0,d.useEffect)(()=>{const o=l=>l.key==="Escape"&&e();return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),(0,s.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9e3,background:"rgba(0,0,0,.35)",display:"flex",alignItems:"center",justifyContent:"center"},onMouseDown:o=>o.target===o.currentTarget&&e(),children:(0,s.jsxs)("div",{role:"dialog","aria-label":t,style:{width:"min(488px, 92vw)",borderRadius:"var(--dsw-radius-panel, 12px)",background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #111)",padding:"18px 20px",fontFamily:"inherit",boxShadow:"0 8px 40px rgba(0,0,0,.2)"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[(0,s.jsx)("div",{style:{fontSize:15,fontWeight:600},children:t}),(0,s.jsx)("button",{onClick:e,"aria-label":"\u5173\u95ED",style:{border:"none",background:"transparent",cursor:"pointer",fontSize:16,lineHeight:1,padding:4,borderRadius:6,color:"var(--dsw-alias-label-tertiary, #888)"},children:"\u2715"})]}),n,r&&(0,s.jsx)("div",{style:{marginTop:14},children:r})]})})}function Q({disabled:t,onClick:e,children:n}){return(0,s.jsx)("button",{disabled:t,onClick:e,style:{width:"100%",height:44,fontSize:14,fontWeight:500,border:"none",cursor:t?"not-allowed":"pointer",borderRadius:"var(--dsw-radius-lg, 10px)",background:t?"var(--dsw-alias-interactive-bg-hover, rgba(0,0,0,.06))":"var(--dsw-alias-button-primary-fill, #2563eb)",color:t?"var(--dsw-alias-label-tertiary, #999)":"var(--dsw-alias-label-primary-foreground, #fff)"},children:n})}let $=!1;async function Y(){if($)return;$=!0;let t=0;const e=JSON.parse(localStorage.getItem(h)||"[]").filter(r=>r.status==="pending-endpoint"||r.status==="failed");for(const r of e.slice(0,5))try{const o=await z(),l=await fetch(w+T,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":S(),authorization:`Bearer ${o}`},body:JSON.stringify({voices:[{title:r.title,content:r.content}],product:D})});if(l.status===200||l.status===201){r.status="accepted";try{localStorage.removeItem(x)}catch{}const i=await l.json().catch(()=>({}));r.serverVoiceId=(i.voiceIds||i.data?.voiceIds||[])[0]||"",r.retriedAt=new Date().toISOString(),t++}else l.status!==404&&(r.error=`retry ${l.status}`)}catch(o){r.error=String(o&&o.message||o)}const n=e.filter(r=>r.status!=="accepted");if(t>0){const r=e.filter(o=>o.status==="accepted"&&o.retriedAt).map(o=>`\u201C${(o.content||o.title||"").slice(0,60)}\u201D`).join("\u3001");try{localStorage.setItem(k,JSON.stringify({n:t,items:r}))}catch{}}if(n.length!==e.length||e.length){const r=JSON.parse(localStorage.getItem(h)||"[]"),o=new Map(e.map(i=>[i.voiceKey,i])),l=r.map(i=>o.get(i.voiceKey)||i);localStorage.setItem(h,JSON.stringify(l.slice(0,A)))}}function Z({onClose:t}){const e=(()=>{try{return JSON.parse(localStorage.getItem(x)||"null")||{}}catch{return{}}})(),[n,r]=(0,d.useState)(e.content||"");(0,d.useEffect)(()=>{try{localStorage.setItem(x,JSON.stringify({content:n}))}catch{}},[n]);const[o,l]=(0,d.useState)(!1),[i,g]=(0,d.useState)(null);(0,d.useEffect)(()=>{let a=null;try{a=JSON.parse(localStorage.getItem(k)||"null")}catch{}if(a&&a.n>0){try{localStorage.removeItem(k)}catch{}const c=a.items?`\uFF0C\u4EA7\u54C1\u56E2\u961F\u4F1A\u770B\u5230\uFF1A${a.items}`:"";g({ok:!0,msg:`\u4F60\u4E4B\u524D\u63D0\u4EA4\u7684 ${a.n} \u6761\u53CD\u9988\u5DF2\u81EA\u52A8\u91CD\u8BD5\u6210\u529F\uFF08\u5F53\u65F6\u63D0\u4EA4\u4E34\u65F6\u5931\u8D25\uFF09${c}`})}},[]);let y=null;async function v(a,c){if(/^\d+$/.test(a))return a;try{if(!y){const f=await fetch(w+K,{headers:{authorization:`Bearer ${c}`}});if(f.ok){const p=await f.json().catch(()=>({}));y=(p.data||p).productCatalog||[]}}const u=(y||[]).find(f=>String(f?.name||"").toLowerCase()===a.toLowerCase());if(u&&u.id!=null)return String(u.id)}catch{}return a}async function m(){const a=n.trim();if(!a){g({ok:!1,msg:"\u8BF7\u5148\u586B\u5199\u53CD\u9988\u5185\u5BB9"});return}if(a.length>2e3){g({ok:!1,msg:`\u5185\u5BB9\u8D85\u957F\uFF08${a.length}/2000\uFF09\uFF0C\u8BF7\u7CBE\u7B80`});return}l(!0),g(null);const c={title:a.slice(0,64),content:a,at:new Date().toISOString(),status:"failed",error:""};try{c.voiceKey=await X(a);try{const u=await z(),f=await fetch(w+T,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":S(),authorization:`Bearer ${u}`},body:JSON.stringify({voices:[{title:a.slice(0,60),content:a}],product:await v(D,u)})});if(f.status===404){c.status="pending-endpoint",E(c),g({ok:!1,msg:"\u56E4\u79EF\u7AEF\u70B9\u5C1A\u672A\u4E0A\u7EBF\uFF08\u5F15\u64CE\u90E8\u7F72\u540E\u81EA\u52A8\u53EF\u7528\uFF09\uFF1B\u53CD\u9988\u5DF2\u6682\u5B58\u672C\u673A\uFF0C\u7A0D\u540E\u91CD\u8BD5\u63D0\u4EA4\u3002"});return}if(f.status===401&&localStorage.removeItem(I),f.status!==200&&f.status!==201)throw new Error(`submit ${f.status}`);const p=await f.json().catch(()=>({}));c.status="accepted",c.serverVoiceId=p.voiceIds?.[0]||"",c.taskId=p.taskIds?.[0]||"",E(c);const P=p.productRegistered===void 0?!0:p.productRegistered;g(P?{ok:!0,msg:"\u5DF2\u6536\u5F55\uFF0C\u4EA7\u54C1\u56E2\u961F\u4F1A\u770B\u5230\u8FD9\u6761\u53CD\u9988\u3002"}:{ok:!0,msg:"\u5DF2\u6536\u5F55\u3002\u6CE8\u610F\uFF1A\u4EA7\u54C1\u540D\u5C1A\u672A\u5728\u5E73\u53F0\u6CE8\u518C\uFF0C\u8FD9\u6761\u53CD\u9988\u6682\u4E0D\u8FDB\u4EA7\u54C1\u5206\u6790\uFF0C\u8BF7\u8054\u7CFB\u90E8\u7F72\u65B9\u6838\u5BF9\u3002"})}catch(u){c.error=String(u&&u.message||u),E(c),g({ok:!1,msg:`\u63D0\u4EA4\u5931\u8D25\uFF08${c.error}\uFF09\uFF1B\u53CD\u9988\u5DF2\u6682\u5B58\u672C\u673A\uFF0C\u7A0D\u540E\u91CD\u8BD5\u3002`})}}finally{l(!1)}}return(0,s.jsxs)(q,{title:"\u63D0\u4EA4\u53CD\u9988",onClose:t,footer:(0,s.jsx)(Q,{disabled:o||!n.trim(),onClick:m,children:o?"\u63D0\u4EA4\u4E2D\u2026":"\u63D0\u4EA4"}),children:[(0,s.jsx)("textarea",{id:"vod-fb-content",style:C.textarea,value:n,maxLength:2e3,placeholder:"\u6BD4\u5982\uFF1A\u5BF9\u8BDD\u54CD\u5E94\u6162\u3001\u67D0\u4E2A\u529F\u80FD\u627E\u4E0D\u5230\u5165\u53E3",autoFocus:!0,onChange:a=>r(a.target.value)}),i&&(0,s.jsx)("div",{style:C.result,children:i.msg})]})}function tt(){const[t,e]=(0,d.useState)(!1),n=(0,d.useRef)(null);return(0,d.useEffect)(()=>{Y();const r=()=>{const i=n.current;if(!i)return;const g=document.querySelector("[contenteditable=true][role=textbox], [contenteditable=true]");if(!g)return;const y=g.getBoundingClientRect(),v=i.offsetWidth||24,m=24;i.style.left=Math.round(y.right-v-8)+"px",i.style.top=Math.round(y.top-m-6)+"px",i.style.width=v+"px",i.style.height=m+"px"};r();const o=new ResizeObserver(r);o.observe(document.documentElement),window.addEventListener("resize",r);const l=setInterval(r,800);return()=>{o.disconnect(),window.removeEventListener("resize",r),clearInterval(l)}},[]),(0,s.jsxs)(d.default.Fragment,{children:[(0,s.jsxs)("button",{ref:n,title:"\u53CD\u9988","aria-label":"\u53CD\u9988\u5F00\u53D1\u8005\u58F0\u97F3",style:{position:"fixed",zIndex:300,border:"none",background:"transparent",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",gap:4,borderRadius:"var(--dsw-radius-sm, 6px)",color:"var(--dsw-alias-label-tertiary, #888)",fontFamily:"inherit"},onMouseEnter:r=>r.currentTarget.style.color="var(--dsw-alias-label-primary, #111)",onMouseLeave:r=>r.currentTarget.style.color="var(--dsw-alias-label-tertiary, #888)",onClick:()=>e(!0),children:[(0,s.jsxs)("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,s.jsx)("path",{d:"M21.5 2.5 2.9 10.2c-.8.3-.8 1.5.1 1.7l4.6 1.4 1.7 5.5c.3.9 1.4 1 1.9.3l2.5-3.3 4.6 3.4c.7.5 1.7.1 1.9-.8l3.2-14.4c.2-.9-.7-1.7-1.5-1.4z"}),(0,s.jsx)("path",{d:"M7.3 13.5 21.5 2.5l-9.5 12.3"})]}),(0,s.jsx)("span",{style:{fontSize:12,lineHeight:1,whiteSpace:"nowrap"},children:"\u53CD\u9988"})]}),t&&(0,s.jsx)(Z,{onClose:()=>e(!1)})]})}function et(t){if(!D){console.error('[vod-devkit] \u5D4C\u5165\u65B9\u672A\u6CE8\u5165 __VOD_DSH_UI_PRODUCT__\uFF0C\u53CD\u9988\u5165\u53E3\u672A\u6FC0\u6D3B\u3002\u4EA7\u54C1\u5F52\u56E0\u662F\u5FC5\u914D\u9879\uFF1A\u5D4C\u5165\u65B9\u88C5\u524D\u8BBE\u7F6E window.__VOD_DSH_UI_PRODUCT__ = "<\u4EA7\u54C1\u540D>"\uFF08\u53D6\u503C=\u751F\u6001\u770B\u677F\u4EA7\u54C1\u540D\uFF1A\u9AD8\u6821AI\u5F00\u53D1\u8005\u5E73\u53F0/\u6210\u957F\u4E2D\u5FC3/AI\u4E91\u539F\u751F\u5F00\u53D1\u5B9E\u8DF5\u4E2D\u5FC3/\u9E3F\u8499\u5F00\u53D1\u5B9E\u8DF5\u4E2D\u5FC3/AI\u529E\u516C\u5B9E\u8DF5\u4E2D\u5FC3/IaC \u5B9E\u8DF5\u4E2D\u5FC3/AI \u5F00\u53D1\u8005\u7A7A\u95F4/AI Agent \u96C6\u6210/AI \u5DE5\u5177\u96C6\u6210/AI \u8FD0\u884C\u73AF\u5883/\u5F00\u653E\u80FD\u529B/Skills\u95E8\u6237/GTD/VOD\uFF09');return}t.slots.inject("conversation.composer.dock",function*(){yield t.slots.register({name:"conversation.composer.dock",id:"vod-feedback",order:20},tt)})}const rt="vod-devkit-ui";
|
|
7
7
|
module.exports.inject = ["slots"];
|
|
8
8
|
return module.exports;
|
|
9
9
|
}
|
package/lib/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export const Config = z.object({
|
|
|
33
33
|
product: z.string().default('').volatile(),
|
|
34
34
|
confirmWrites: z.boolean().default(true).volatile(),
|
|
35
35
|
timeoutSec: z.number().default(30).volatile(),
|
|
36
|
+
receiptGuard: z.string().default('report').volatile(), // D-rguard-1:off|report|enforce,默认 report(零危害只标注)
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
function readCfg(v, fallback) {
|
|
@@ -121,6 +122,27 @@ async function http(method, path, body, { base, key, timeoutSec, signal }) {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
// T7i(方案 A,2026-11-05 拍板):产品归因主键化——meta productCatalog
|
|
126
|
+
// ([{id,name}],t_vod_product 运营预置)按名解析平台 id 后提交;
|
|
127
|
+
// ①纯数字=平台 id 透传 ②目录无此名/不可达(含老引擎 404)→ 规范名兼容通道
|
|
128
|
+
// (引擎 name 命中同样补落 product_id)——不静默丢提交。进程内缓存一次。
|
|
129
|
+
const META_PATH = `${API_PREFIX}/external/meta`;
|
|
130
|
+
let _productCatalog = null;
|
|
131
|
+
async function resolveProductId(product, cfg, signal) {
|
|
132
|
+
if (/^\d+$/.test(product)) return product;
|
|
133
|
+
try {
|
|
134
|
+
if (!_productCatalog) {
|
|
135
|
+
const out = await http('GET', META_PATH, undefined, { ...cfg, signal });
|
|
136
|
+
_productCatalog = (out.ok && out.data && out.data.data?.productCatalog)
|
|
137
|
+
|| out.data?.productCatalog || [];
|
|
138
|
+
}
|
|
139
|
+
const hit = _productCatalog.find(
|
|
140
|
+
(x) => String(x?.name || '').toLowerCase() === product.toLowerCase());
|
|
141
|
+
if (hit && hit.id != null) return String(hit.id);
|
|
142
|
+
} catch (e) { /* 目录不可用 → 名字兼容通道 */ }
|
|
143
|
+
return product;
|
|
144
|
+
}
|
|
145
|
+
|
|
124
146
|
async function fetchAnonToken(cfg) {
|
|
125
147
|
const out = await http('POST', TOKEN_PATH, {}, cfg);
|
|
126
148
|
if (out.ok && out.data && (out.data.token || out.data.data?.token)) {
|
|
@@ -143,6 +165,79 @@ function voiceId(source, content, nonce) {
|
|
|
143
165
|
return `ext_${source}_${h}`;
|
|
144
166
|
}
|
|
145
167
|
|
|
168
|
+
// ── D-rguard-1 ReceiptGuard(提交侧原文比对,2026-11-09 验证立项)──
|
|
169
|
+
// 通道实测(dsh-tools 0.2.0 类型源):exec.agent.session.deriveMessages() 的
|
|
170
|
+
// user 轮消息 = 用户逐字原文(append-only 会话日志投影,不经模型)——模型改写
|
|
171
|
+
// 只发生在 args 侧,比对 args.content 与日志原文即可抓改写(dsh headless echo
|
|
172
|
+
// 改字两次实锤均在 args 侧,正是本闸覆盖面)。模型无往日志写用户轮的通道
|
|
173
|
+
// (ToolRunContext.deferContext 是插件自铸上下文,不产生用户轮)。
|
|
174
|
+
// 三档:off=不校验;report(默认)=只标注零危害;enforce=mismatch/unavailable 拒收。
|
|
175
|
+
export function normalizeForGuard(s) {
|
|
176
|
+
return String(s ?? '').replace(/\s+/g, '').toLowerCase();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function bigramSimilarity(a, b) {
|
|
180
|
+
if (!a || !b) return 0;
|
|
181
|
+
if (a === b) return 1;
|
|
182
|
+
const grams = (s) => {
|
|
183
|
+
const m = new Map();
|
|
184
|
+
for (let i = 0; i < s.length - 1; i++) {
|
|
185
|
+
const g = s.slice(i, i + 2);
|
|
186
|
+
m.set(g, (m.get(g) || 0) + 1);
|
|
187
|
+
}
|
|
188
|
+
return m;
|
|
189
|
+
};
|
|
190
|
+
const ga = grams(a), gb = grams(b);
|
|
191
|
+
let inter = 0, total = 0;
|
|
192
|
+
for (const v of ga.values()) total += v;
|
|
193
|
+
for (const [g, v] of gb) {
|
|
194
|
+
total += v;
|
|
195
|
+
if (ga.has(g)) inter += Math.min(v, ga.get(g));
|
|
196
|
+
}
|
|
197
|
+
return total ? (2 * inter) / total : 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** 从会话日志取全部用户轮逐字文本(text 块;tool_result 也是 user role,按块型过滤);不可得=null */
|
|
201
|
+
export function collectUserTurns(session) {
|
|
202
|
+
if (!session || typeof session.deriveMessages !== 'function') return null;
|
|
203
|
+
const msgs = session.deriveMessages();
|
|
204
|
+
const turns = [];
|
|
205
|
+
for (const m of Array.isArray(msgs) ? msgs : []) {
|
|
206
|
+
if (!m || m.role !== 'user' || !Array.isArray(m.content)) continue;
|
|
207
|
+
const text = m.content.filter((b) => b && b.type === 'text').map((b) => b.text).join('\n');
|
|
208
|
+
if (text) turns.push(text);
|
|
209
|
+
}
|
|
210
|
+
return turns.length ? turns : null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** 单条 content 判定:规范化整串命中任一用户轮=verified;跨轮忠实聚合按拼接语料命中;
|
|
214
|
+
* 字符二元组相似度 ≥0.5 且规范化长度 ≥10=fuzzy(短内容必须逐字,防止相似度阈值吞掉短改写);
|
|
215
|
+
* 否则 mismatch;原文不可得=unavailable。 */
|
|
216
|
+
export function evaluateVoiceGuard(userTurns, content) {
|
|
217
|
+
if (!Array.isArray(userTurns)) return 'unavailable';
|
|
218
|
+
const c = normalizeForGuard(content);
|
|
219
|
+
if (!c) return 'mismatch';
|
|
220
|
+
const corpus = normalizeForGuard(userTurns.join('\n'));
|
|
221
|
+
if (corpus.includes(c)) return 'verified';
|
|
222
|
+
if (c.length < 10) return 'mismatch'; // 短内容不享受相似度豁免('A问题。补充B' 型胶水词改写)
|
|
223
|
+
let best = 0;
|
|
224
|
+
for (const t of userTurns) best = Math.max(best, bigramSimilarity(c, normalizeForGuard(t)));
|
|
225
|
+
return best >= 0.5 ? 'fuzzy' : 'mismatch';
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export const RG_MODES = ['off', 'report', 'enforce'];
|
|
229
|
+
|
|
230
|
+
/** 回执汇总:mode + 逐条判定(对账主键=voiceId 顺序位;纯函数可单测) */
|
|
231
|
+
export function rgGuardSummary(verdictMap, total) {
|
|
232
|
+
const verdicts = [];
|
|
233
|
+
for (let i = 0; i < total; i++) verdicts.push(verdictMap.get(i) ?? 'unavailable');
|
|
234
|
+
return {
|
|
235
|
+
verdicts,
|
|
236
|
+
mismatch: verdicts.filter((v) => v === 'mismatch').length,
|
|
237
|
+
unavailable: verdicts.filter((v) => v === 'unavailable').length,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
146
241
|
function buildParameters(specs) {
|
|
147
242
|
const properties = {};
|
|
148
243
|
const required = [];
|
|
@@ -195,12 +290,16 @@ export function apply(ctx, config) {
|
|
|
195
290
|
product: readCfg(config?.product, '') || '',
|
|
196
291
|
confirmWrites: readCfg(config?.confirmWrites, true) !== false,
|
|
197
292
|
timeoutSec: readCfg(config?.timeoutSec, 30),
|
|
293
|
+
receiptGuard: RG_MODES.includes(readCfg(config?.receiptGuard, 'report'))
|
|
294
|
+
? readCfg(config?.receiptGuard, 'report') : 'report',
|
|
198
295
|
});
|
|
199
296
|
|
|
200
297
|
const tools = [
|
|
201
298
|
{
|
|
202
299
|
name: 'vod_submit_voices',
|
|
203
300
|
description: '[VOD-unique] Submit agent-product user feedback voices to VOD (write). '
|
|
301
|
+
+ 'PRECONDITION (overrides everything below): obtain the user\'s explicit consent to submit THIS feedback before calling; '
|
|
302
|
+
+ 'the user merely stating a complaint is NOT consent; never pass confirmed=true without it. '
|
|
204
303
|
+ 'ON FAILURE: tell the user in plain words only (e.g. 已暂存,稍后自动重试). '
|
|
205
304
|
+ 'NEVER expose HTTP status codes, apiKeyFingerprint, tokenTier, stack traces, '
|
|
206
305
|
+ 'tool names (say 提交反馈, never vod_submit_voices) or mechanism words '
|
|
@@ -212,14 +311,15 @@ export function apply(ctx, config) {
|
|
|
212
311
|
'Each voice = one user feedback (content ≤2000 chars). '
|
|
213
312
|
+ 'content MUST be a faithful transcription of the user\'s own words - '
|
|
214
313
|
+ 'NEVER invent sentiment (e.g. 体验不好) or fabricate content the user did not say. '
|
|
215
|
-
+
|
|
216
|
-
'Product attribution
|
|
217
|
-
'
|
|
314
|
+
+ 'A bare product name or a question is NOT feedback - ask what the user wants to report. ' +
|
|
315
|
+
'Product attribution is bound at install/deploy time (config product; no runtime product argument exists). ' +
|
|
316
|
+
'Fixed one-time follow-up at confirmation, verbatim: 「方便的话,补充一下遇到这个问题时的操作步骤或期望的表现吗?不方便回复"没有",我直接提交。」' +
|
|
317
|
+
'Answer → reproSteps/expectedBehavior verbatim excerpt, never into content; "没有/跳过"=omit both. ' +
|
|
218
318
|
'Batch ≤50. Returns voiceIds (reconciliation key) + taskIds.',
|
|
219
319
|
parameters: buildParameters({
|
|
220
320
|
voices: {
|
|
221
321
|
type: 'array', required: true,
|
|
222
|
-
description: 'Array of 1-50 voices: {content (required, ≤2000), userType (optional 企业|个人|未知)}',
|
|
322
|
+
description: 'Array of 1-50 voices: {content (required, ≤2000), userType (optional 企业|个人|未知), reproSteps/expectedBehavior (optional 用户追问补充, only when the fixed one-time follow-up got an answer; never merge into content)}',
|
|
223
323
|
},
|
|
224
324
|
}),
|
|
225
325
|
output: { schema: { type: 'object', additionalProperties: true }, render: renderText },
|
|
@@ -230,12 +330,18 @@ export function apply(ctx, config) {
|
|
|
230
330
|
const voices = Array.isArray(args.voices) ? args.voices : [];
|
|
231
331
|
if (!voices.length) return textResult({ error: 'voices 为空', code: -32001 });
|
|
232
332
|
if (voices.length > 50) return textResult({ error: '单批上限 50 条', code: -32001 });
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
333
|
+
// 归因(D-attrib-A,2026-11-06 拍板,方案 A):归因只由部署配置绑定
|
|
334
|
+
// 决定(安装时定),不读 args——宿主/模型传参自报不采信(对齐 vod_mcp
|
|
335
|
+
// effectiveBotPat 同款收紧;Python 侧实锤宽容口径被模型滥用后统一)
|
|
236
336
|
let product = String(c.product || '').trim(); // 部署配置权威(安装时定),无 args 覆盖
|
|
237
337
|
product = PRODUCT_MAP[product.toLowerCase()] || product;
|
|
338
|
+
product = await resolveProductId(product, c, exec?.signal); // T7i:主键化提交
|
|
238
339
|
const source = 'dsh';
|
|
340
|
+
// D-rguard-1:原文比对(whitelist 通道=会话日志 user 轮)。enforce 档
|
|
341
|
+
// mismatch/unavailable 拒收;report(默认)只标注;off 全跳过。
|
|
342
|
+
const rgMode = c.receiptGuard;
|
|
343
|
+
const userTurns = rgMode === 'off' ? null : collectUserTurns(exec?.agent?.session);
|
|
344
|
+
const rgVerdict = new Map(); // index → verified|fuzzy|mismatch|unavailable
|
|
239
345
|
const accepted = [], taskIds = [], rejected = [];
|
|
240
346
|
let key = c.key;
|
|
241
347
|
// V16 切换(囤积端点):批量一次 POST,title=原文截取、content=用户原话
|
|
@@ -246,7 +352,27 @@ export function apply(ctx, config) {
|
|
|
246
352
|
const content = String(v.content ?? '').trim();
|
|
247
353
|
if (!content) { rejected.push({ index: i, reason: 'content 为空' }); continue; }
|
|
248
354
|
if (content.length > 2000) { rejected.push({ index: i, reason: `content 超 2000 字(${content.length})` }); continue; }
|
|
249
|
-
|
|
355
|
+
if (rgMode !== 'off') {
|
|
356
|
+
const st = evaluateVoiceGuard(userTurns, content);
|
|
357
|
+
rgVerdict.set(i, st);
|
|
358
|
+
if (rgMode === 'enforce' && st !== 'verified' && st !== 'fuzzy') {
|
|
359
|
+
rejected.push({ index: i, reason: st === 'mismatch'
|
|
360
|
+
? 'ReceiptGuard: content 与会话用户原文不一致'
|
|
361
|
+
: 'ReceiptGuard: 会话原文不可得,无法校验' });
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const hv = { title: content.slice(0, 128), content }; // R3:title=用户原文
|
|
366
|
+
// D-followup-impl-2 追问补充透传:仅 trim 非空才含键(未追问/答"没有"=键集合与旧流程一致);引擎同口径截 2000
|
|
367
|
+
// followupStatus(评审八点 #3):三态白名单归一透传,白名单外省键(desc 无预算不宣讲,行为对齐 vod_mcp 单源)
|
|
368
|
+
const DECLINES = new Set(['没有', '无', '没有。', '没了', '跳过', '不方便', '不用了', '不用', '不补充', '算了', '没有了', '没有了。', '不方便说', 'no', 'none', 'skip', 'n/a']);
|
|
369
|
+
for (const f of ['reproSteps', 'expectedBehavior']) {
|
|
370
|
+
const val = String(v[f] ?? '').trim();
|
|
371
|
+
if (val && !DECLINES.has(val.toLowerCase())) hv[f] = val.slice(0, 2000);
|
|
372
|
+
}
|
|
373
|
+
const st = String(v.followupStatus ?? '').trim().toLowerCase();
|
|
374
|
+
if (['not_asked', 'declined', 'answered'].includes(st)) hv.followupStatus = st;
|
|
375
|
+
hoard.push(hv);
|
|
250
376
|
}
|
|
251
377
|
if (hoard.length) {
|
|
252
378
|
let out = await http('POST', HOARD_PATH, { voices: hoard, product },
|
|
@@ -286,6 +412,7 @@ export function apply(ctx, config) {
|
|
|
286
412
|
return textResult({
|
|
287
413
|
accepted: accepted.length, voiceIds: accepted,
|
|
288
414
|
taskIds, rejected, path: 'hoarding',
|
|
415
|
+
...(rgMode !== 'off' ? { receiptGuard: rgGuardSummary(rgVerdict, hoard.length) } : {}),
|
|
289
416
|
...(d.productRegistered !== undefined ? { productRegistered: d.productRegistered } : {}),
|
|
290
417
|
});
|
|
291
418
|
}
|
|
@@ -340,7 +467,8 @@ export function apply(ctx, config) {
|
|
|
340
467
|
title: String((voices[i] || {}).content ?? '').slice(0, 40),
|
|
341
468
|
product, at: now,
|
|
342
469
|
})));
|
|
343
|
-
return textResult({ accepted: accepted.length, voiceIds: accepted, taskIds, rejected
|
|
470
|
+
return textResult({ accepted: accepted.length, voiceIds: accepted, taskIds, rejected,
|
|
471
|
+
...(rgMode !== 'off' ? { receiptGuard: rgGuardSummary(rgVerdict, voices.length) } : {}) });
|
|
344
472
|
},
|
|
345
473
|
},
|
|
346
474
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vod-devkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "VOD user-voice collection tools for DeepSeek Harness (dsh). Thin shell over the VOD external HTTP API — mirrors vod-devkit (MCP) collect semantics.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -47,4 +47,4 @@
|
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build-client": "esbuild src/client.jsx --jsx=automatic --format=cjs --minify --outfile=/tmp/client-cjs.js && python3 scripts/wrap_client.py"
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|