@nextclaw/channel-runtime 0.1.8 → 0.1.10

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.d.ts CHANGED
@@ -30,6 +30,7 @@ declare abstract class BaseChannel<TConfig extends Record<string, unknown>> {
30
30
  abstract start(): Promise<void>;
31
31
  abstract stop(): Promise<void>;
32
32
  abstract send(msg: OutboundMessage): Promise<void>;
33
+ handleControlMessage(_msg: OutboundMessage): Promise<boolean>;
33
34
  isAllowed(senderId: string): boolean;
34
35
  protected handleMessage(params: {
35
36
  senderId: string;
@@ -61,6 +62,7 @@ declare class DiscordChannel extends BaseChannel<Config["channels"]["discord"]>
61
62
  constructor(config: Config["channels"]["discord"], bus: MessageBus);
62
63
  start(): Promise<void>;
63
64
  stop(): Promise<void>;
65
+ handleControlMessage(msg: OutboundMessage): Promise<boolean>;
64
66
  send(msg: OutboundMessage): Promise<void>;
65
67
  private handleIncoming;
66
68
  private resolveProxyAgent;
@@ -202,6 +204,7 @@ declare class TelegramChannel extends BaseChannel<Config["channels"]["telegram"]
202
204
  constructor(config: Config["channels"]["telegram"], bus: MessageBus, groqApiKey?: string, sessionManager?: SessionManager | undefined);
203
205
  start(): Promise<void>;
204
206
  stop(): Promise<void>;
207
+ handleControlMessage(msg: OutboundMessage): Promise<boolean>;
205
208
  send(msg: OutboundMessage): Promise<void>;
206
209
  private handleIncoming;
207
210
  private dispatchToBus;
package/dist/index.js CHANGED
@@ -5,6 +5,9 @@ var BaseChannel = class {
5
5
  this.bus = bus;
6
6
  }
7
7
  running = false;
8
+ async handleControlMessage(_msg) {
9
+ return false;
10
+ }
8
11
  isAllowed(senderId) {
9
12
  const allowList = this.config.allowFrom ?? [];
10
13
  if (!allowList.length) {
@@ -224,10 +227,11 @@ var ChannelTypingController = class {
224
227
  };
225
228
 
226
229
  // src/channels/discord.ts
230
+ import { isTypingStopControlMessage } from "@nextclaw/core";
227
231
  var DEFAULT_MEDIA_MAX_MB = 8;
228
232
  var MEDIA_FETCH_TIMEOUT_MS = 15e3;
229
- var TYPING_HEARTBEAT_MS = 8e3;
230
- var TYPING_AUTO_STOP_MS = 45e3;
233
+ var TYPING_HEARTBEAT_MS = 6e3;
234
+ var TYPING_AUTO_STOP_MS = 12e4;
231
235
  var DISCORD_TEXT_LIMIT = 2e3;
232
236
  var DISCORD_MAX_LINES_PER_MESSAGE = 17;
233
237
  var FENCE_RE = /^( {0,3})(`{3,}|~{3,})(.*)$/;
@@ -278,7 +282,18 @@ var DiscordChannel = class extends BaseChannel {
278
282
  this.client = null;
279
283
  }
280
284
  }
285
+ async handleControlMessage(msg) {
286
+ if (!isTypingStopControlMessage(msg)) {
287
+ return false;
288
+ }
289
+ this.stopTyping(msg.chatId);
290
+ return true;
291
+ }
281
292
  async send(msg) {
293
+ if (isTypingStopControlMessage(msg)) {
294
+ this.stopTyping(msg.chatId);
295
+ return;
296
+ }
282
297
  if (!this.client) {
283
298
  return;
284
299
  }
@@ -376,8 +391,9 @@ var DiscordChannel = class extends BaseChannel {
376
391
  ...attachmentIssues.length ? { attachment_issues: attachmentIssues } : {}
377
392
  }
378
393
  });
379
- } finally {
394
+ } catch (error) {
380
395
  this.stopTyping(channelId);
396
+ throw error;
381
397
  }
382
398
  }
383
399
  resolveProxyAgent() {
@@ -2442,8 +2458,9 @@ var GroqTranscriptionProvider = class {
2442
2458
  // src/channels/telegram.ts
2443
2459
  import { join as join3 } from "path";
2444
2460
  import { mkdirSync as mkdirSync3 } from "fs";
2445
- var TYPING_HEARTBEAT_MS2 = 4e3;
2446
- var TYPING_AUTO_STOP_MS2 = 45e3;
2461
+ import { isTypingStopControlMessage as isTypingStopControlMessage2 } from "@nextclaw/core";
2462
+ var TYPING_HEARTBEAT_MS2 = 6e3;
2463
+ var TYPING_AUTO_STOP_MS2 = 12e4;
2447
2464
  var BOT_COMMANDS = [
2448
2465
  { command: "start", description: "Start the bot" },
2449
2466
  { command: "reset", description: "Reset conversation history" },
@@ -2565,7 +2582,18 @@ Just send me a text message to chat!`;
2565
2582
  this.bot = null;
2566
2583
  }
2567
2584
  }
2585
+ async handleControlMessage(msg) {
2586
+ if (!isTypingStopControlMessage2(msg)) {
2587
+ return false;
2588
+ }
2589
+ this.stopTyping(msg.chatId);
2590
+ return true;
2591
+ }
2568
2592
  async send(msg) {
2593
+ if (isTypingStopControlMessage2(msg)) {
2594
+ this.stopTyping(msg.chatId);
2595
+ return;
2596
+ }
2569
2597
  if (!this.bot) {
2570
2598
  return;
2571
2599
  }
@@ -2660,8 +2688,9 @@ Just send me a text message to chat!`;
2660
2688
  was_mentioned: mentionState.wasMentioned,
2661
2689
  require_mention: mentionState.requireMention
2662
2690
  });
2663
- } finally {
2691
+ } catch (error) {
2664
2692
  this.stopTyping(chatId);
2693
+ throw error;
2665
2694
  }
2666
2695
  }
2667
2696
  async dispatchToBus(senderId, chatId, content, attachments, metadata) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/channel-runtime",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "private": false,
5
5
  "description": "Runtime implementations for NextClaw builtin channel plugins.",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "dependencies": {
17
17
  "@larksuiteoapi/node-sdk": "^1.58.0",
18
- "@nextclaw/core": "^0.6.22",
18
+ "@nextclaw/core": "^0.6.24",
19
19
  "@slack/socket-mode": "^1.3.3",
20
20
  "@slack/web-api": "^7.6.0",
21
21
  "dingtalk-stream": "^2.1.4",