dsh-vod-devkit 0.2.1 → 0.4.3
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 +19 -5
- package/lib/client.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,24 +16,38 @@ VOD 用户声音采集插件 —— DeepSeek Harness (dsh) 薄壳。
|
|
|
16
16
|
## 安装
|
|
17
17
|
|
|
18
18
|
```
|
|
19
|
-
npx --yes vod-devkit install --target dsh --profile <name> --product <产品> #
|
|
20
|
-
dsh plugin --profile <name> add dsh-vod-devkit # 直装(装后须手工配 product,见下)
|
|
19
|
+
npx --yes vod-devkit install --target dsh --profile <name> --product <产品> # 推荐(安装期硬校验+幂等写配置,一条命令完成全部部署)
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
> ⚠️ 不要用 `dsh plugin add dsh-vod-devkit` 裸装:只装插件本体不写配置——
|
|
23
|
+
> product 缺失时反馈入口不激活(fail fast,宁可不装不可装错);apiBase/uiBase
|
|
24
|
+
> 缺失时工具半不可用、UI 提交会发往 dsh 同源(404 → 本地暂存发不出去,
|
|
25
|
+
> 嵌入方真机实锤)。裸装后补救:跑一次上面的 npx 命令即可(幂等)。
|
|
26
|
+
|
|
27
|
+
装后配置落在 profile 的 cordis.patch.yml(npx 包装命令自动写入):
|
|
24
28
|
|
|
25
29
|
```yaml
|
|
26
30
|
- id: vod-devkit
|
|
27
31
|
config:
|
|
28
32
|
product: codearts # 归因绑定(安装时定);无运行期传参通道
|
|
29
|
-
# apiBase: https://vod-dev.topxtopx.com #
|
|
33
|
+
# apiBase: https://vod-dev.topxtopx.com # 工具半(Node 服务端)用,缺省即此
|
|
34
|
+
# uiBase: https://vod-dev.topxtopx.com # 浏览器半(反馈按钮)直连用,缺省即此
|
|
30
35
|
```
|
|
31
36
|
|
|
37
|
+
### UI 半(反馈按钮)部署前提——二选一
|
|
38
|
+
|
|
39
|
+
- **uiBase 直连**(默认,本包形态):浏览器直接请求 uiBase 指向的引擎地址。
|
|
40
|
+
依赖:引擎侧 CORS 允许 dsh 页面源(本地 dsh 为 `http://127.0.0.1:<port>`)。
|
|
41
|
+
引擎 CORS 收敛(白名单制)落地时,白名单必须含 dsh 本地源,随其上线同步验证。
|
|
42
|
+
- **宿主代理**(嵌入方自建,可选):由 dsh 部署侧把 `/external/*` 反代到引擎,
|
|
43
|
+
此时 uiBase 可留空走同源。当前 dsh 不自带此代理,默认勿依赖。
|
|
44
|
+
|
|
32
45
|
## 配置(dsh 插件设置)
|
|
33
46
|
|
|
34
47
|
| 字段 | 默认 | 说明 |
|
|
35
48
|
|---|---|---|
|
|
36
|
-
| apiBase | https://vod-dev.topxtopx.com | VOD external API
|
|
49
|
+
| apiBase | https://vod-dev.topxtopx.com | VOD external API 基址(工具半/服务端用) |
|
|
50
|
+
| uiBase | 同 apiBase | 浏览器半(反馈按钮)直连基址;同源代理形态可留空 |
|
|
37
51
|
| apiKey | (空) | 缺省走零字段匿名令牌;灰度期可用运营签发 key |
|
|
38
52
|
| product | (空) | 本机产品归因绑定(如 codearts);空且调用未传参时报错引导 |
|
|
39
53
|
| confirmWrites | true | 写操作走 dsh 审批通道(tools/pre-execute → ask) |
|
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 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";
|
|
6
|
+
var B=Object.create;var v=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)v(t,n,{get:e[n],enumerable:!0})},D=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of U(e))!j.call(t,o)&&o!==n&&v(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)):{},D(e||!t||!t.__esModule?v(n,"default",{value:t,enumerable:!0}):n,t)),J=t=>D(v({},"__esModule",{value:!0}),t);var nt={};H(nt,{apply:()=>rt,inject:()=>et,name:()=>ot});module.exports=J(nt);var s=require("react/jsx-runtime"),d=N(require("react"),1);const w="/rest/developer/manager/hdvodmngservice/v1";let m=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_BASE__||"";const F=`${w}/external/token`,E=`${w}/external/voices`,K=`${w}/external/meta`,S="vod_dshui_token",O="vod_dshui_device",h="vod_dshui_ledger",_="vod_dshui_draft",I="vod_dshui_recovered",T=200,G=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_LEDGER_DISABLED__===!0,x=typeof globalThis<"u"&&globalThis.__VOD_DSH_UI_PRODUCT__||"",R={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 b(){let t=localStorage.getItem(O);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(O,t)),t}async function A(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 A(b())).slice(0,8)}_${(await A(t)).slice(0,12)}`}function k(t){if(G)return;const e=JSON.parse(localStorage.getItem(h)||"[]");e.unshift(t),localStorage.setItem(h,JSON.stringify(e.slice(0,T)))}async function C(){let t=localStorage.getItem(S);if(t)return t;const e=await fetch(m+F,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":b()},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(S,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 L=!1;async function Y(){if(L)return;L=!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 C(),l=await fetch(m+E,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":b(),authorization:`Bearer ${o}`},body:JSON.stringify({voices:[{title:r.title,content:r.content}],product:x})});if(l.status===200||l.status===201){r.status="accepted";try{localStorage.removeItem(_)}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(I,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,T)))}}function Z({onClose:t}){const e=(()=>{try{return JSON.parse(localStorage.getItem(_)||"null")||{}}catch{return{}}})(),[n,r]=(0,d.useState)(e.content||"");(0,d.useEffect)(()=>{try{localStorage.setItem(_,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(I)||"null")}catch{}if(a&&a.n>0){try{localStorage.removeItem(I)}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 z(a,c){if(/^\d+$/.test(a))return a;try{if(!y){const f=await fetch(m+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 $(){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 C(),f=await fetch(m+E,{method:"POST",headers:{"content-type":"application/json","X-Vod-Device-Id":b(),authorization:`Bearer ${u}`},body:JSON.stringify({voices:[{title:a.slice(0,60),content:a}],product:await z(x,u)})});if(f.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(f.status===401&&localStorage.removeItem(S),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]||"",k(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),k(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:$,children:o?"\u63D0\u4EA4\u4E2D\u2026":"\u63D0\u4EA4"}),children:[(0,s.jsx)("textarea",{id:"vod-fb-content",style:R.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:R.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();i.offsetWidth!==0&&(i.style.left="auto",i.style.right=Math.round(window.innerWidth-y.right+8)+"px",i.style.top=Math.round(y.top-30)+"px",i.style.height="24px")};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)})]})}const et=["slots"];function rt(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},tt)})}const ot="vod-devkit-ui";
|
|
7
7
|
module.exports.inject = ["slots"];
|
|
8
8
|
return module.exports;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vod-devkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.3",
|
|
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
|
+
}
|