@wendongfly/myhi 1.3.77 → 1.3.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -400,7 +400,7 @@ Content-Length: `+C+`\r
400
400
  helper = store --file ${l.replace(/\\/g,"/")}
401
401
  [user]
402
402
  name = ${o}
403
- `,{mode:384})}catch{}console.log(`[\u7BA1\u7406] \u6DFB\u52A0\u7528\u6237 ${o} (\u76EE\u5F55: ${t})`),w.json({ok:!0})})),app.delete("/api/admin/user",checkAdminAuth,express.json(),((A,w)=>{const{name:d}=A.body||{};if(!d)return w.json({ok:!1,error:"\u8BF7\u6307\u5B9A\u7528\u6237\u540D\u79F0"});if(loadUsers(),!listUsers().find((o=>o.name===d)))return w.json({ok:!1,error:"\u7528\u6237\u4E0D\u5B58\u5728"});try{const o=(0,external_path_.join)(configDir,"users.json"),t=JSON.parse((0,external_fs_.readFileSync)(o,"utf8"));for(const[c,l]of Object.entries(t.users||{}))if(l.name===d){delete t.users[c];break}(0,external_fs_.writeFileSync)(o,JSON.stringify(t,null,2),{mode:384}),loadUsers(),console.log(`[\u7BA1\u7406] \u5220\u9664\u7528\u6237 ${d}`),w.json({ok:!0})}catch(o){w.json({ok:!1,error:o.message})}})),app.post("/api/admin/user/password",checkAdminAuth,express.json(),((A,w)=>{const{name:d,password:o}=A.body||{};if(!d||!o)return w.json({ok:!1,error:"\u540D\u79F0\u548C\u65B0\u5BC6\u7801\u5FC5\u586B"});try{const t=(0,external_path_.join)(configDir,"users.json"),c=JSON.parse((0,external_fs_.readFileSync)(t,"utf8"));let l=null;for(const[m,s]of Object.entries(c.users||{}))if(s.name===d){l=s,delete c.users[m];break}if(!l)return w.json({ok:!1,error:"\u7528\u6237\u4E0D\u5B58\u5728"});c.users[o]=l,(0,external_fs_.writeFileSync)(t,JSON.stringify(c,null,2),{mode:384}),loadUsers(),console.log(`[\u7BA1\u7406] \u4FEE\u6539\u7528\u6237 ${d} \u7684\u5BC6\u7801`),w.json({ok:!0})}catch(t){w.json({ok:!1,error:t.message})}})),app.post("/api/admin/password",checkAdminAuth,express.json(),((A,w)=>{const{password:d}=A.body||{};if(!d||d.length<4)return w.json({ok:!1,error:"\u5BC6\u7801\u81F3\u5C114\u4F4D"});try{(0,external_fs_.writeFileSync)((0,external_path_.join)(configDir,"password"),d,{mode:384}),PASSWORD=d,w.json({ok:!0}),console.log("[\u7BA1\u7406] \u7BA1\u7406\u5BC6\u7801\u5DF2\u4FEE\u6539")}catch(o){w.json({ok:!1,error:o.message})}})),app.post("/upload",checkAuth,((A,w)=>{const d=A.query.sessionId,o=d?manager.get(d):null,t=o?.cwd?(0,external_path_.join)(o.cwd,"upload"):uploadDir;(0,external_fs_.mkdirSync)(t,{recursive:!0}),multer({storage:multer.diskStorage({destination:t,filename:(c,l,m)=>{const s=l.originalname.match(/\.[^.]+$/)?.[0]||".jpg";m(null,`${Date.now()}-${(0,external_crypto_.randomBytes)(3).toString("hex")}${s}`)}}),limits:{fileSize:20*1024*1024},fileFilter:(c,l,m)=>m(null,l.mimetype.startsWith("image/"))}).single("image")(A,w,(c=>{if(c)return w.status(400).json({error:c.message});if(!A.file)return w.status(400).json({error:"\u6CA1\u6709\u56FE\u7247"});w.json({path:(0,external_path_.resolve)(A.file.path).replace(/\\/g,"/")})}))})),app.post("/api/voice-transcribe",checkAuth,multer({storage:multer.memoryStorage(),limits:{fileSize:200*1024*1024}}).single("audio"),(async(A,w)=>{if(!A.file)return w.status(400).json({error:"\u65E0\u97F3\u9891\u6570\u636E"});const d=process.env.ASR_URL||(()=>{try{return JSON.parse((0,external_fs_.readFileSync)((0,external_path_.join)((0,external_os_.homedir)(),".myhi","asr.json"),"utf8")).url}catch{return null}})();if(!d)return w.status(503).json({error:"\u672A\u914D\u7F6E ASR \u670D\u52A1\uFF0C\u8BF7\u8BBE\u7F6E ASR_URL \u73AF\u5883\u53D8\u91CF\u6216 ~/.myhi/asr.json"});try{const o=new FormData,t=A.file.mimetype||"audio/webm",c=A.file.originalname||"audio.webm";o.append("audio",new Blob([A.file.buffer],{type:t}),c);const m=await(await fetch(d+"/transcribe",{method:"POST",body:o})).json();w.json({text:m.text||"",error:m.error})}catch(o){const t=o.cause?.message||o.cause?.code||"";w.status(500).json({error:t?`${o.message} (${t})`:o.message})}})),app.post("/api/voice-assist/organize",checkAuth,express.json(),(async(A,w)=>{const{transcript:d}=A.body||{};if(!d?.trim())return w.status(400).json({error:"\u65E0\u8F6C\u5F55\u5185\u5BB9"});const o=`\u7528\u6237\u901A\u8FC7\u8BED\u97F3\u53E3\u8FF0\u4E86\u4EE5\u4E0B\u5185\u5BB9\uFF0C\u539F\u6587\u5982\u4E0B\uFF1A
403
+ `,{mode:384})}catch{}console.log(`[\u7BA1\u7406] \u6DFB\u52A0\u7528\u6237 ${o} (\u76EE\u5F55: ${t})`),w.json({ok:!0})})),app.delete("/api/admin/user",checkAdminAuth,express.json(),((A,w)=>{const{name:d}=A.body||{};if(!d)return w.json({ok:!1,error:"\u8BF7\u6307\u5B9A\u7528\u6237\u540D\u79F0"});if(loadUsers(),!listUsers().find((o=>o.name===d)))return w.json({ok:!1,error:"\u7528\u6237\u4E0D\u5B58\u5728"});try{const o=(0,external_path_.join)(configDir,"users.json"),t=JSON.parse((0,external_fs_.readFileSync)(o,"utf8"));for(const[c,l]of Object.entries(t.users||{}))if(l.name===d){delete t.users[c];break}(0,external_fs_.writeFileSync)(o,JSON.stringify(t,null,2),{mode:384}),loadUsers(),console.log(`[\u7BA1\u7406] \u5220\u9664\u7528\u6237 ${d}`),w.json({ok:!0})}catch(o){w.json({ok:!1,error:o.message})}})),app.post("/api/admin/user/password",checkAdminAuth,express.json(),((A,w)=>{const{name:d,password:o}=A.body||{};if(!d||!o)return w.json({ok:!1,error:"\u540D\u79F0\u548C\u65B0\u5BC6\u7801\u5FC5\u586B"});try{const t=(0,external_path_.join)(configDir,"users.json"),c=JSON.parse((0,external_fs_.readFileSync)(t,"utf8"));let l=null;for(const[m,s]of Object.entries(c.users||{}))if(s.name===d){l=s,delete c.users[m];break}if(!l)return w.json({ok:!1,error:"\u7528\u6237\u4E0D\u5B58\u5728"});c.users[o]=l,(0,external_fs_.writeFileSync)(t,JSON.stringify(c,null,2),{mode:384}),loadUsers(),console.log(`[\u7BA1\u7406] \u4FEE\u6539\u7528\u6237 ${d} \u7684\u5BC6\u7801`),w.json({ok:!0})}catch(t){w.json({ok:!1,error:t.message})}})),app.post("/api/admin/password",checkAdminAuth,express.json(),((A,w)=>{const{password:d}=A.body||{};if(!d||d.length<4)return w.json({ok:!1,error:"\u5BC6\u7801\u81F3\u5C114\u4F4D"});try{(0,external_fs_.writeFileSync)((0,external_path_.join)(configDir,"password"),d,{mode:384}),PASSWORD=d,w.json({ok:!0}),console.log("[\u7BA1\u7406] \u7BA1\u7406\u5BC6\u7801\u5DF2\u4FEE\u6539")}catch(o){w.json({ok:!1,error:o.message})}})),app.post("/upload",checkAuth,((A,w)=>{const d=A.query.sessionId,o=d?manager.get(d):null,t=o?.cwd?(0,external_path_.join)(o.cwd,"upload"):uploadDir;(0,external_fs_.mkdirSync)(t,{recursive:!0}),multer({storage:multer.diskStorage({destination:t,filename:(c,l,m)=>{const s=l.originalname.match(/\.[^.]+$/)?.[0]||".jpg";m(null,`${Date.now()}-${(0,external_crypto_.randomBytes)(3).toString("hex")}${s}`)}}),limits:{fileSize:20*1024*1024},fileFilter:(c,l,m)=>m(null,l.mimetype.startsWith("image/"))}).single("image")(A,w,(c=>{if(c)return w.status(400).json({error:c.message});if(!A.file)return w.status(400).json({error:"\u6CA1\u6709\u56FE\u7247"});w.json({path:(0,external_path_.resolve)(A.file.path).replace(/\\/g,"/")})}))})),app.post("/api/voice-transcribe",checkAuth,multer({storage:multer.memoryStorage(),limits:{fileSize:200*1024*1024}}).single("audio"),(async(A,w)=>{if(!A.file)return w.status(400).json({error:"\u65E0\u97F3\u9891\u6570\u636E"});const d=process.env.ASR_URL||(()=>{try{return JSON.parse((0,external_fs_.readFileSync)((0,external_path_.join)((0,external_os_.homedir)(),".myhi","asr.json"),"utf8")).url}catch{return null}})();if(!d)return w.status(503).json({error:"\u672A\u914D\u7F6E ASR \u670D\u52A1\uFF0C\u8BF7\u8BBE\u7F6E ASR_URL \u73AF\u5883\u53D8\u91CF\u6216 ~/.myhi/asr.json"});try{const o=new FormData,t=A.file.mimetype||"audio/webm",c=A.file.originalname||"audio.webm";o.append("audio",new Blob([A.file.buffer],{type:t}),c);const m=await(await fetch(d+"/transcribe",{method:"POST",body:o})).json();w.json({text:m.text||"",error:m.error})}catch(o){const t=o.cause?.message||o.cause?.code||"",c=t?`${o.message} (${t})`:o.message;console.error(`[myhi] ASR fetch \u5931\u8D25 url=${d} file=${filename} mime=${mime} size=${A.file.buffer.length}:`,c,o.cause),w.status(500).json({error:c})}})),app.post("/api/voice-assist/organize",checkAuth,express.json(),(async(A,w)=>{const{transcript:d}=A.body||{};if(!d?.trim())return w.status(400).json({error:"\u65E0\u8F6C\u5F55\u5185\u5BB9"});const o=`\u7528\u6237\u901A\u8FC7\u8BED\u97F3\u53E3\u8FF0\u4E86\u4EE5\u4E0B\u5185\u5BB9\uFF0C\u539F\u6587\u5982\u4E0B\uFF1A
404
404
 
405
405
  ---
406
406
  ${d}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wendongfly/myhi",
3
- "version": "1.3.77",
3
+ "version": "1.3.78",
4
4
  "description": "Web-based terminal sharing with chat UI — control your terminal from phone via LAN/Tailscale",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",