dsh-bat-think 1.0.1 → 1.0.2

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
@@ -3,7 +3,7 @@
3
3
  ![Batman at his laptop with a thought bubble](https://raw.githubusercontent.com/kuoci/dsh-bat-think/main/assets/screenshots/preview.png)
4
4
 
5
5
  点击人物有随机对话
6
- 点击电脑有用量信息
6
+ 点击电脑有用量信息和余额
7
7
  点击骰子可以产生装扮,点击装扮可以去掉
8
8
  可以放大缩小
9
9
  可以拖动
package/client.js CHANGED
@@ -61,6 +61,26 @@ window.__ModuleLoader__.load({
61
61
  let bridgeTarget = null
62
62
  let bridgeDispose = null
63
63
  let modelDirectories = null
64
+ let pluginCtx = null
65
+
66
+ /** Platform wallet balance through the account Remote namespace, if present. */
67
+ async function readAccountBalance() {
68
+ try {
69
+ const remote = pluginCtx && pluginCtx.remote
70
+ const account = remote && remote.account
71
+ if (!account || typeof account.getBalance !== 'function') return null
72
+ const result = await account.getBalance()
73
+ if (!result || result.status !== 'ready' || !Array.isArray(result.value) || result.value.length === 0) return null
74
+ const wallet = result.value[0]
75
+ if (!wallet || (wallet.currency !== 'CNY' && wallet.currency !== 'USD') || typeof wallet.balance !== 'string') return null
76
+ const bonus = Array.isArray(result.bonusWallets)
77
+ ? result.bonusWallets.find((item) => item && item.currency === wallet.currency && Number(item.balance) > 0)
78
+ : null
79
+ return { currency: wallet.currency, balance: wallet.balance, bonus: bonus ? bonus.balance : '' }
80
+ } catch {
81
+ return null
82
+ }
83
+ }
64
84
  const modelListeners = new Set()
65
85
  function setModelDirectories(next) {
66
86
  if (modelDirectories === next) return
@@ -613,6 +633,7 @@ window.__ModuleLoader__.load({
613
633
  setModelService(modelDirectories)
614
634
  return () => { modelListeners.delete(listener) }
615
635
  }, [])
636
+ const [balance, setBalance] = useState(null)
616
637
  const [modelLabel, setModelLabel] = useState('')
617
638
  useEffect(() => {
618
639
  setModelLabel('')
@@ -1130,6 +1151,12 @@ window.__ModuleLoader__.load({
1130
1151
  modelLabel
1131
1152
  ? h('div', { className: 'dsh-bat-think-usage-row' }, h('span', null, '模型'), h('b', { title: modelLabel }, modelLabel))
1132
1153
  : null,
1154
+ balance
1155
+ ? h('div', { className: 'dsh-bat-think-usage-row' },
1156
+ h('span', null, '余额'),
1157
+ h('b', { title: balance.bonus ? `赠送余额 ${balance.bonus}` : '' },
1158
+ `${balance.currency === 'USD' ? '$' : '¥'}${balance.balance}${balance.bonus ? `(含赠 ${balance.bonus})` : ''}`))
1159
+ : null,
1133
1160
  hasUsage
1134
1161
  ? [
1135
1162
  h('div', { key: 'out', className: 'dsh-bat-think-usage-row' }, h('span', null, '输出'), h('b', null, formatCount(usage && usage.outputTokens))),
@@ -1231,6 +1258,8 @@ window.__ModuleLoader__.load({
1231
1258
  return {
1232
1259
  inject: ['slots'],
1233
1260
  apply(ctx) {
1261
+ pluginCtx = ctx
1262
+ ctx.effect(() => () => { pluginCtx = null }, 'dsh-bat-think: context handle')
1234
1263
  const softGet = typeof ctx.get === 'function' ? ctx.get.bind(ctx) : undefined
1235
1264
  try {
1236
1265
  const soft = softGet ? softGet('sessions') : ctx.sessions
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Batman desktop pet",
4
- "description": "Shows a draggable Batman in the bottom-right corner of the DSH window: it works at its laptop, switches to a mouse-in-hand frame with a thought bubble while an Agent runs, and blinks naturally in the bare-face variant (triple-click to take the helmet off or put it back). Clicking it while idle says one of three lines; clicking the laptop opens an API usage card; the dice puts a random sticker on the current variant — each variant has its own stickers, placed by the artwork's canvas coordinates and following its breathing, drag and scale."
4
+ "description": "Shows a draggable Batman in the bottom-right corner of the DSH window: it works at its laptop, switches to a mouse-in-hand frame with a thought bubble while an Agent runs, and blinks naturally in the bare-face variant (triple-click to take the helmet off or put it back). Clicking it while idle says one of three lines; clicking the laptop opens an API usage card with the platform wallet balance; the dice puts a random sticker on the current variant — each variant has its own stickers, placed by the artwork's canvas coordinates and following its breathing, drag and scale."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "蝙蝠侠桌宠",
4
- "description": "在 DSH 窗口右下角放一只可拖动的蝙蝠侠:平时敲电脑,Agent 在跑的时候换成拿鼠标的工作图并冒出三点跳动的思考气泡。快速连点三下可以切换「戴面罩 / 摘面罩」——摘下面罩后会自然眨眼(三帧)。空闲时点击随机说「阿尔弗雷德!」「正在归档……」「我要夜巡了」;点脚边的电脑弹出 API 用量面板;悬停工具栏的骰子会随机戴一个贴纸,戴面罩和不戴面罩各有自己的贴纸,按画布原坐标贴合,会跟着呼吸、拖动、缩放,点图案即可摘掉。"
4
+ "description": "在 DSH 窗口右下角放一只可拖动的蝙蝠侠:平时敲电脑,Agent 在跑的时候换成拿鼠标的工作图并冒出三点跳动的思考气泡。快速连点三下可以切换「戴面罩 / 摘面罩」——摘下面罩后会自然眨眼(三帧)。空闲时点击随机说「阿尔弗雷德!」「正在归档……」「我要夜巡了」;点脚边的电脑弹出 API 用量面板(含平台余额);悬停工具栏的骰子会随机戴一个贴纸,戴面罩和不戴面罩各有自己的贴纸,按画布原坐标贴合,会跟着呼吸、拖动、缩放,点图案即可摘掉。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-bat-think",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Batman desktop pet for DeepSeek Harness: it works at a laptop, switches to a mouse-in-hand pose with a thought bubble while an Agent runs, blinks in the bare-face variant (triple-click to swap the helmet), rolls a dice for stickers, and shows an API usage card when you click the laptop.",
5
5
  "type": "module",
6
6
  "license": "MIT",