@weibaohui/dsh-plugin-kit 0.1.0 → 0.2.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/README.md CHANGED
@@ -14,8 +14,8 @@ dsh 插件共享工具箱。把系列插件中重复的「AI 动作按钮」能
14
14
  ## 消费方式
15
15
 
16
16
  ```jsonc
17
- // 插件 package.json
18
- "dependencies": { "@weibaohui/dsh-plugin-kit": "github:weibaohui/dsh-plugin-kit" }
17
+ // 插件 package.json(npm 源;dsh plugin add 时作为传递依赖一次性装上)
18
+ "dependencies": { "@weibaohui/dsh-plugin-kit": "^0.1.0" }
19
19
  ```
20
20
 
21
21
  `dsh plugin add` 安装插件时作为传递依赖一次性装上。
package/client/source.js CHANGED
@@ -9,7 +9,8 @@
9
9
  * title / hint / rows: [[label, value], ...] / initialPrompt
10
10
  * run: async (prompt) => { jobId } — 发起执行
11
11
  * poll: async (jobId) => { status, output, code }
12
- * labels: { copy, copied, run, running, done, failed, outputLabel, close }
12
+ * labels: { copy, copied, run, running, done, failed, outputLabel, openSession, close }
13
+ * onOpenSession: (sessionId) => void — 可选;job 出现 sessionId 时渲染「打开会话」
13
14
  * onClose
14
15
  *
15
16
  * 全部样式内联(主题 token + 回退值),消费者无需自带 CSS。
@@ -70,6 +71,8 @@ var PluginKit = (function () {
70
71
  setJob({ jobId: r.jobId, status: 'running', output: '', code: null })
71
72
  }).catch(function (e) { setError(String(e && e.message)) }).finally(function () { setBusy(false) })
72
73
  }
74
+ var canOpenSession = typeof props.onOpenSession === 'function' && job !== null && job.sessionId
75
+ var openSession = function () { props.onOpenSession(job.sessionId) }
73
76
  var copy = function () {
74
77
  if (typeof navigator !== 'undefined' && navigator.clipboard && navigator.clipboard.writeText) {
75
78
  navigator.clipboard.writeText(prompt).then(function () { setCopied(true); setTimeout(function () { setCopied(false) }, 1500) }).catch(function () {})
@@ -93,6 +96,7 @@ var PluginKit = (function () {
93
96
  h('div', { style: { fontSize: 12, opacity: .7, margin: '4px 0' } }, (labels.outputLabel || 'Output') + ' · ' + statusText),
94
97
  h('pre', { style: { maxHeight: 220, margin: 0, overflow: 'auto', whiteSpace: 'pre-wrap', fontSize: 12, background: 'var(--dsw-alias-bg-layer-2,transparent)', border: '1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.2))', borderRadius: '8px', padding: '8px' } }, job.output || '…')) : null,
95
98
  h('div', { style: { display: 'flex', gap: 8 } },
99
+ canOpenSession ? h('button', { onClick: openSession, style: btnStyle }, labels.openSession || 'Open chat') : null,
96
100
  h('button', { onClick: copy, style: btnStyle }, copied ? (labels.copied || 'Copied') : (labels.copy || 'Copy')),
97
101
  h('button', { onClick: doRun, disabled: busy || (job !== null && job.status === 'running'), style: primaryStyle }, job !== null && job.status === 'running' ? (labels.running || 'Running…') : (labels.run || 'Run')))))
98
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weibaohui/dsh-plugin-kit",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "dsh 插件共享工具箱:AI 动作分享抽屉(ntd ActionButton 同款交互)+ 宿主任务执行器,供系列插件复用",
5
5
  "license": "MIT",
6
6
  "main": "src/index.js",