dsh-plugin-weapp-gateway 0.8.11 → 0.8.12

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 CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  # dsh-plugin-weapp-gateway
6
6
 
7
+ ### v0.8.12 · 显示插件升级失败详情
8
+
9
+ - 安装器返回结构化错误时提取可读信息,不再显示 `[object Object]`;错误序列化会省略凭据、令牌和堆栈字段。
10
+
7
11
  ### v0.8.11 · 小程序 ClawBot 私聊接线控制
8
12
 
9
13
  - 在已配对的小程序控制通道中增加受限的 ClawBot 控制 RPC,复用 `dsh-wechat-remote` 自身的访问授权、状态冲突检查和本地凭据存储。
package/lib/client.js CHANGED
@@ -578,7 +578,13 @@ window.__ModuleLoader__.load({
578
578
  setUpdateInfo({ ...result, currentVersion: result.latestVersion, updateAvailable: false })
579
579
  setUpdateNotice(`已安装 v${result.latestVersion},需要重启 DSH 后生效。`)
580
580
  } else if (application === 'failed' || application === 'cancelled' || application === 'refused') {
581
- setUpdateNotice(`安装未完成:${application}${result.installation?.error ? `(${result.installation.error})` : ''}`)
581
+ const installError = result.installation?.error
582
+ const detail = result.installation?.errorMessage
583
+ || (typeof installError === 'string' ? installError : '')
584
+ || (typeof installError?.message === 'string' ? installError.message : '')
585
+ || (typeof installError?.code === 'string' ? installError.code : '')
586
+ || '请在 DSH 插件管理中查看安装详情。'
587
+ setUpdateNotice(`安装未完成:${application}(${detail})`)
582
588
  } else {
583
589
  setUpdateInfo({ ...result, currentVersion: result.latestVersion, updateAvailable: false })
584
590
  setUpdateNotice(`已安装 v${result.latestVersion}。如界面尚未更新,请重启 DSH。`)
@@ -1,6 +1,37 @@
1
1
  export const PLUGIN_PACKAGE_NAME = 'dsh-plugin-weapp-gateway'
2
2
  const REGISTRY_LATEST_URL = `https://registry.npmjs.org/${PLUGIN_PACKAGE_NAME}/latest`
3
3
 
4
+ function errorField(value) {
5
+ return typeof value === 'string' && value.trim() ? value.trim() : ''
6
+ }
7
+
8
+ export function formatPluginInstallError(error, depth = 0) {
9
+ if (typeof error === 'string') return error.trim().slice(0, 1000)
10
+ if (!error || typeof error !== 'object' || depth > 4) return ''
11
+
12
+ const code = errorField(error.code)
13
+ const message = errorField(error.message)
14
+ || errorField(error.errorMessage)
15
+ || errorField(error.detail)
16
+ || errorField(error.reason)
17
+ || errorField(error.description)
18
+ if (message) return `${code && code !== message ? `${code}: ` : ''}${message}`.slice(0, 1000)
19
+
20
+ for (const nested of [error.error, error.cause, error.details]) {
21
+ const detail = formatPluginInstallError(nested, depth + 1)
22
+ if (detail) return `${code && code !== detail ? `${code}: ` : ''}${detail}`.slice(0, 1000)
23
+ }
24
+
25
+ try {
26
+ const serialized = JSON.stringify(error, (key, value) => {
27
+ if (/stack|authorization|cookie|password|secret|token|credential|api.?key/i.test(key)) return undefined
28
+ return value
29
+ })
30
+ if (serialized && serialized !== '{}') return serialized.slice(0, 1000)
31
+ } catch { /* use a generic message for cyclic or non-serializable errors */ }
32
+ return code || 'The plugin manager did not provide an error message'
33
+ }
34
+
4
35
  function parseVersion(value) {
5
36
  if (typeof value !== 'string') return null
6
37
  const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(value)
@@ -85,5 +116,12 @@ export async function installLatestPlugin({ api, currentVersion, fetchImpl = glo
85
116
  `${PLUGIN_PACKAGE_NAME}@${update.latestVersion}`,
86
117
  { requestId },
87
118
  )
88
- return { ...update, installed: true, installation }
119
+ const errorMessage = formatPluginInstallError(installation?.error)
120
+ return {
121
+ ...update,
122
+ installed: true,
123
+ installation: errorMessage && installation && typeof installation === 'object'
124
+ ? { ...installation, errorMessage }
125
+ : installation,
126
+ }
89
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-weapp-gateway",
3
- "version": "0.8.11",
3
+ "version": "0.8.12",
4
4
  "description": "Authenticated mobile gateway for dsh 0.1.7-rc.2 with Session V4 history, live permissions, inbox-based queue sync, plugin management (DSH 0.2.0 hosts), LAN and Cloudflare Tunnel access with public endpoint health checks, device pairing, per-session Agent preset selection, relay access for the WeChat mini-program, and the official speech-input bridge (speech-input-v1)",
5
5
  "main": "lib/index.mjs",
6
6
  "files": [