@wenbin_wb/dsh-bridge 2.1.1 → 2.1.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/lib/index.js CHANGED
@@ -545,6 +545,9 @@ function apply(ctx, config = {}) {
545
545
  accountId: cfg.accountId,
546
546
  });
547
547
  logger.info('dsh-bridge: loaded saved qq bot config, starting gateway');
548
+ await qq.start().catch((err) => {
549
+ logger.error('dsh-bridge: qq auto-start failed: %s', err?.message ?? err);
550
+ });
548
551
  }
549
552
  }
550
553
  }).catch(() => {});
package/lib/qq/gateway.js CHANGED
@@ -363,6 +363,7 @@ export class QqGateway extends Service {
363
363
  msg_type: 0,
364
364
  msg_id: opts.msgId,
365
365
  event_id: opts.eventId,
366
+ input_state: opts.inputState, // 0=结束输入, 1=输入中
366
367
  },
367
368
  })
368
369
  }
@@ -374,7 +375,22 @@ export class QqGateway extends Service {
374
375
  })
375
376
  }
376
377
 
377
- async sendTyping() { return { ok: false, unsupported: true } }
378
+ async sendTyping(peerId, opts = {}) {
379
+ // QQ Bot API v2 通过流式消息的 input_state 参数控制输入状态
380
+ // input_state: 0=结束输入, 1=输入中
381
+ // 参考:https://bot.q.qq.com/wiki/develop/api-v2/autogen/api/v2_users_user_openid_stream_messages.post.html
382
+ const endpoint = this.endpoint(peerId, opts.scope, 'stream-messages')
383
+ return this.api(endpoint, {
384
+ method: 'POST',
385
+ body: {
386
+ content: '', // 仅设置输入状态,不发送内容
387
+ msg_type: 0,
388
+ input_state: 1, // 1=输入中
389
+ msg_id: opts.msgId,
390
+ event_id: opts.eventId,
391
+ },
392
+ })
393
+ }
378
394
 
379
395
  setCredentials(values = {}) {
380
396
  for (const key of ['appId', 'clientSecret', 'accessToken', 'accessTokenExpiresAt', 'gatewayUrl', 'intents']) {
package/lib/qq/node.js CHANGED
@@ -19,7 +19,7 @@ function makePlatform(gateway) {
19
19
  get accountId() { return gateway.accountId ?? '' },
20
20
  get capabilities() { return gateway.capabilities },
21
21
  sendText: (peer, text) => gateway.sendText(peer, text, {}),
22
- sendTyping: (peer, state) => gateway.sendTyping(peer, state),
22
+ sendTyping: (peer, opts) => gateway.sendTyping(peer, opts),
23
23
  sendKeyboard: (peer, content, keyboard) => gateway.sendKeyboard(peer, content, keyboard, {}),
24
24
  }
25
25
  }
@@ -112,9 +112,12 @@ export class QqConversationNode extends ConversationBridge {
112
112
 
113
113
  // 逐段发送流式消息
114
114
  let firstMsgId = null
115
- for (const chunk of chunks) {
115
+ for (let i = 0; i < chunks.length; i++) {
116
+ const chunk = chunks[i]
117
+ const isLast = i === chunks.length - 1
116
118
  const result = await this.gateway.sendStream(peer, chunk, {
117
119
  msgId: firstMsgId, // 后续段关联到第一段
120
+ inputState: isLast ? 0 : 1, // 最后一段结束输入状态,其他段显示输入中
118
121
  })
119
122
  if (!firstMsgId && result?.data?.message_id) {
120
123
  firstMsgId = result.data.message_id
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wenbin_wb/dsh-bridge",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "手机扫码即可在移动端/公网继续用 DeepSeek Harness,人不在电脑前也能接着干。一键局域网二维码、Cloudflare 公网隧道、自建隧道与微信 Bot(多工作区/会话持久化/媒体/审批),无需自己搭公网服务器。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",