@openclaw/twitch 2026.8.2 → 2026.9.1

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
@@ -74,7 +74,7 @@ Multi-account config (advanced):
74
74
  1. Create a dedicated Twitch account for the bot, then generate credentials: [Twitch Token Generator](https://twitchtokengenerator.com/)
75
75
  - Select **Bot Token**
76
76
  - Verify scopes `chat:read` and `chat:write` are selected
77
- - Copy the **Access Token** to `token` property
77
+ - Copy the **Access Token** to `accessToken` property
78
78
  - Copy the **Client ID** to `clientId` property
79
79
  2. Start the gateway
80
80
 
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as twitchPlugin } from "./plugin--Ji1Tvw0.js";
1
+ import { t as twitchPlugin } from "./plugin-DwymE1gC.js";
2
2
  import { n as setTwitchRuntime } from "./runtime-B5If4b0g.js";
3
3
  export { setTwitchRuntime, twitchPlugin };
@@ -1,2 +1,2 @@
1
- import { t as twitchPlugin } from "./plugin--Ji1Tvw0.js";
1
+ import { t as twitchPlugin } from "./plugin-DwymE1gC.js";
2
2
  export { twitchPlugin };
@@ -1,5 +1,5 @@
1
- import { n as stripMarkdownForTwitch, r as getOrCreateClientManager } from "./plugin--Ji1Tvw0.js";
2
- import { m as normalizeTwitchChannel } from "./setup-surface-CPpsDfR8.js";
1
+ import { n as sendMessageTwitchInternal, r as getOrCreateClientManager } from "./plugin-DwymE1gC.js";
2
+ import { p as normalizeTwitchChannel } from "./setup-surface-BZ2FXBoo.js";
3
3
  import { t as getTwitchRuntime } from "./runtime-B5If4b0g.js";
4
4
  import { createChannelIngressError, createChannelIngressMonitor } from "openclaw/plugin-sdk/channel-outbound";
5
5
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
@@ -366,11 +366,6 @@ async function processTwitchMessage(params) {
366
366
  commandBody: input.textForCommands
367
367
  }
368
368
  });
369
- const tableMode = channelRuntime.text.resolveMarkdownTableMode({
370
- cfg,
371
- channel: "twitch",
372
- accountId
373
- });
374
369
  return {
375
370
  cfg,
376
371
  channel: "twitch",
@@ -390,7 +385,6 @@ async function processTwitchMessage(params) {
390
385
  account,
391
386
  accountId,
392
387
  config,
393
- tableMode,
394
388
  runtime
395
389
  });
396
390
  },
@@ -422,13 +416,17 @@ async function deliverTwitchReply(params) {
422
416
  error: (msg) => runtime.error?.(msg),
423
417
  debug: (msg) => runtime.log?.(msg)
424
418
  });
425
- const textToSend = stripMarkdownForTwitch([payload.text, ...resolveOutboundMediaUrls(payload)].filter(Boolean).join(" "));
426
- if (!textToSend) {
419
+ if ((await sendMessageTwitchInternal({
420
+ channel,
421
+ text: [payload.text, ...resolveOutboundMediaUrls(payload)].filter(Boolean).join(" "),
422
+ cfg: config,
423
+ account,
424
+ accountId,
425
+ clientManager
426
+ })).outcome === "not_sent") {
427
427
  runtime.error?.(`No text to send in reply payload`);
428
428
  return { visibleReplySent: false };
429
429
  }
430
- const result = await clientManager.sendMessage(account, channel, textToSend, config, accountId);
431
- if (!result.ok) throw new Error(result.error ?? "Send failed");
432
430
  return { visibleReplySent: true };
433
431
  } catch (err) {
434
432
  runtime.error?.(`Failed to send reply: ${String(err)}`);
@@ -1,4 +1,4 @@
1
- import { a as getAccountConfig, c as resolveTwitchSnapshotAccountId, d as isAccountConfigured, f as missingTargetError, h as resolveTwitchToken, i as DEFAULT_ACCOUNT_ID, l as twitchConfigAdapter, m as normalizeTwitchChannel, o as resolveDefaultTwitchAccountId, p as normalizeToken, r as twitchSetupWizard, s as resolveTwitchAccountContext, t as twitchSetupContract, u as generateMessageId } from "./setup-surface-CPpsDfR8.js";
1
+ import { a as getAccountConfig, c as resolveTwitchSnapshotAccountId, d as missingTargetError, f as normalizeToken, i as DEFAULT_ACCOUNT_ID, l as twitchConfigAdapter, m as resolveTwitchToken, o as resolveDefaultTwitchAccountId, p as normalizeTwitchChannel, r as twitchSetupWizard, s as resolveTwitchAccountContext, t as twitchSetupContract, u as isAccountConfigured } from "./setup-surface-BZ2FXBoo.js";
2
2
  import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
3
3
  import { MarkdownConfigSchema, buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
4
4
  import { buildChannelOutboundSessionRoute, createChatChannelPlugin, stripChannelTargetPrefix } from "openclaw/plugin-sdk/channel-core";
@@ -364,10 +364,11 @@ var TwitchClientManager = class {
364
364
  messageId
365
365
  };
366
366
  } catch (error) {
367
- this.logger.error(`Failed to send message: ${formatErrorMessage(error)}`);
367
+ const errorMessage = formatErrorMessage(error);
368
+ this.logger.error(`Failed to send message: ${errorMessage}`);
368
369
  return {
369
370
  ok: false,
370
- error: formatErrorMessage(error)
371
+ error: errorMessage
371
372
  };
372
373
  }
373
374
  }
@@ -377,15 +378,6 @@ var TwitchClientManager = class {
377
378
  getAccountKey(account) {
378
379
  return `${account.username}:${account.channel}`;
379
380
  }
380
- /**
381
- * Clear all clients and handlers (for testing)
382
- */
383
- clearForTest() {
384
- this.clients.clear();
385
- this.pendingClients.clear();
386
- this.connectionPromises.clear();
387
- this.messageHandlers.clear();
388
- }
389
381
  };
390
382
  //#endregion
391
383
  //#region extensions/twitch/src/client-manager-registry.ts
@@ -549,12 +541,6 @@ function stripMarkdownForTwitch(markdown) {
549
541
  }
550
542
  //#endregion
551
543
  //#region extensions/twitch/src/send.ts
552
- /**
553
- * Twitch message sending functions with dependency injection support.
554
- *
555
- * These functions are the primary interface for sending messages to Twitch.
556
- * They support dependency injection via the `deps` parameter for testability.
557
- */
558
544
  function createTwitchSendReceipt(messageId, channel) {
559
545
  return createMessageReceiptFromOutboundResults({
560
546
  results: messageId ? [{
@@ -565,91 +551,21 @@ function createTwitchSendReceipt(messageId, channel) {
565
551
  kind: "text"
566
552
  });
567
553
  }
568
- /**
569
- * Internal send function used by the outbound adapter.
570
- *
571
- * This function has access to the full OpenClaw config and handles
572
- * account resolution, markdown stripping, and actual message sending.
573
- *
574
- * @param channel - The channel name
575
- * @param text - The message text
576
- * @param cfg - Full OpenClaw configuration
577
- * @param accountId - Account ID to use
578
- * @param stripMarkdown - Whether to strip markdown (default: true)
579
- * @param logger - Logger instance
580
- * @returns Result with message ID and status
581
- *
582
- * @example
583
- * const result = await sendMessageTwitchInternal(
584
- * "#mychannel",
585
- * "Hello Twitch!",
586
- * openclawConfig,
587
- * "default",
588
- * true,
589
- * console,
590
- * );
591
- */
592
- async function sendMessageTwitchInternal(channel, text, cfg, accountId, stripMarkdown = true, logger = console) {
593
- const { account, configured, availableAccountIds, accountId: resolvedAccountId } = resolveTwitchAccountContext(cfg, accountId);
594
- if (!account) return {
595
- ok: false,
596
- messageId: generateMessageId(),
597
- receipt: createTwitchSendReceipt(),
598
- error: `Account not found: ${accountId ?? "(default)"}. Available accounts: ${availableAccountIds.join(", ") || "none"}`
599
- };
600
- if (!configured) return {
601
- ok: false,
602
- messageId: generateMessageId(),
603
- receipt: createTwitchSendReceipt(),
604
- error: `Account ${resolvedAccountId} is not properly configured. Required: username, clientId, and token (config or env for default account).`
605
- };
606
- const normalizedChannel = channel || account.channel;
607
- if (!normalizedChannel) return {
608
- ok: false,
609
- messageId: generateMessageId(),
610
- receipt: createTwitchSendReceipt(),
611
- error: "No channel specified and no default channel in account config"
612
- };
613
- const deliveryChannel = normalizeTwitchChannel(normalizedChannel);
614
- const cleanedText = stripMarkdown ? stripMarkdownForTwitch(text) : text;
554
+ async function sendMessageTwitchInternal(params) {
555
+ const cleanedText = stripMarkdownForTwitch(params.text);
615
556
  if (!cleanedText) return {
616
- ok: true,
617
557
  outcome: "not_sent",
618
558
  messageId: "",
619
559
  receipt: createTwitchSendReceipt()
620
560
  };
621
- const clientManager = getClientManager(resolvedAccountId);
622
- if (!clientManager) return {
623
- ok: false,
624
- messageId: generateMessageId(),
625
- receipt: createTwitchSendReceipt(),
626
- error: `Client manager not found for account: ${resolvedAccountId}. Please start the Twitch gateway first.`
561
+ if (!params.clientManager) throw new Error(`Client manager not found for account: ${params.accountId}. Please start the Twitch gateway first.`);
562
+ const result = await params.clientManager.sendMessage(params.account, params.channel, cleanedText, params.cfg, params.accountId);
563
+ if (!result.ok) throw new Error(result.error);
564
+ const { messageId } = result;
565
+ return {
566
+ messageId,
567
+ receipt: createTwitchSendReceipt(messageId, params.channel)
627
568
  };
628
- try {
629
- const result = await clientManager.sendMessage(account, deliveryChannel, cleanedText, cfg, resolvedAccountId);
630
- if (!result.ok) return {
631
- ok: false,
632
- messageId: result.messageId ?? generateMessageId(),
633
- receipt: createTwitchSendReceipt(),
634
- error: result.error ?? "Send failed"
635
- };
636
- const messageId = result.messageId ?? generateMessageId();
637
- return {
638
- ok: true,
639
- messageId,
640
- receipt: createTwitchSendReceipt(messageId, deliveryChannel)
641
- };
642
- } catch (error) {
643
- const errorMsg = formatErrorMessage(error);
644
- const messageId = generateMessageId();
645
- logger.error(`Failed to send message: ${errorMsg}`);
646
- return {
647
- ok: false,
648
- messageId,
649
- receipt: createTwitchSendReceipt(),
650
- error: errorMsg
651
- };
652
- }
653
569
  }
654
570
  //#endregion
655
571
  //#region extensions/twitch/src/outbound.ts
@@ -723,7 +639,7 @@ const twitchOutbound = {
723
639
  /**
724
640
  * Send a text message to a Twitch channel.
725
641
  *
726
- * Strips markdown if enabled, validates account configuration,
642
+ * Strips Markdown, validates account configuration,
727
643
  * and sends the message via the Twitch client.
728
644
  *
729
645
  * @param params - Send parameters including target, text, and config
@@ -741,12 +657,21 @@ const twitchOutbound = {
741
657
  const { cfg, to, text, accountId } = params;
742
658
  if (params.signal?.aborted) throw new Error("Outbound delivery aborted");
743
659
  const resolvedAccountId = accountId ?? resolveTwitchAccountContext(cfg).accountId;
744
- const { account, availableAccountIds } = resolveTwitchAccountContext(cfg, resolvedAccountId);
660
+ const { account, accountId: normalizedAccountId, availableAccountIds, configured } = resolveTwitchAccountContext(cfg, resolvedAccountId);
745
661
  if (!account) throw new Error(`Twitch account not found: ${resolvedAccountId}. Available accounts: ${availableAccountIds.join(", ") || "none"}`);
746
662
  const channel = to || account.channel;
747
663
  if (!channel) throw new Error("No channel specified and no default channel in account config");
748
- const result = await sendMessageTwitchInternal(normalizeTwitchChannel(channel), text, cfg, resolvedAccountId, true, console);
749
- if (!result.ok) throw new Error(result.error ?? "Send failed");
664
+ if (!configured) throw new Error(`Account ${normalizedAccountId} is not properly configured. Required: username, clientId, and accessToken (config or env for default account).`);
665
+ const deliveryChannel = normalizeTwitchChannel(channel) || account.channel;
666
+ if (!deliveryChannel) throw new Error("No channel specified and no default channel in account config");
667
+ const result = await sendMessageTwitchInternal({
668
+ channel: normalizeTwitchChannel(deliveryChannel),
669
+ text,
670
+ cfg,
671
+ account,
672
+ accountId: normalizedAccountId,
673
+ clientManager: getClientManager(normalizedAccountId)
674
+ });
750
675
  return {
751
676
  channel: "twitch",
752
677
  ...result.outcome ? { outcome: result.outcome } : {},
@@ -1260,7 +1185,7 @@ const twitchPlugin = createChatChannelPlugin({
1260
1185
  await runPassiveAccountLifecycle({
1261
1186
  abortSignal: ctx.abortSignal,
1262
1187
  start: async () => {
1263
- const { monitorTwitchProvider } = await import("./monitor-DwOuh3Ah.js");
1188
+ const { monitorTwitchProvider } = await import("./monitor-dCA7_7aW.js");
1264
1189
  return monitorTwitchProvider({
1265
1190
  account,
1266
1191
  accountId,
@@ -1299,4 +1224,4 @@ const twitchPlugin = createChatChannelPlugin({
1299
1224
  }
1300
1225
  });
1301
1226
  //#endregion
1302
- export { stripMarkdownForTwitch as n, getOrCreateClientManager as r, twitchPlugin as t };
1227
+ export { sendMessageTwitchInternal as n, getOrCreateClientManager as r, twitchPlugin as t };
@@ -1,2 +1,2 @@
1
- import { n as twitchSetupPlugin } from "./setup-surface-CPpsDfR8.js";
1
+ import { n as twitchSetupPlugin } from "./setup-surface-BZ2FXBoo.js";
2
2
  export { twitchSetupPlugin };
@@ -1,6 +1,5 @@
1
1
  import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
2
2
  import { DEFAULT_ACCOUNT_ID, DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId, resolveNormalizedAccountEntry } from "openclaw/plugin-sdk/account-resolution";
3
- import { randomUUID } from "node:crypto";
4
3
  import { normalizeLowercaseStringOrEmpty, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
5
4
  import { normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
6
5
  import { createChannelDmPolicy } from "openclaw/plugin-sdk/channel-dm-policy";
@@ -96,17 +95,6 @@ function missingTargetError(provider, hint) {
96
95
  return /* @__PURE__ */ new Error(`Delivering to ${provider} requires target${hint ? ` ${hint}` : ""}`);
97
96
  }
98
97
  /**
99
- * Generate a unique message ID for Twitch messages.
100
- *
101
- * Twurple's say() doesn't return the message ID, so we generate one
102
- * for tracking purposes.
103
- *
104
- * @returns A unique message ID
105
- */
106
- function generateMessageId() {
107
- return `${Date.now()}-${randomUUID()}`;
108
- }
109
- /**
110
98
  * Normalize OAuth token by removing the "oauth:" prefix if present.
111
99
  *
112
100
  * Twurple doesn't require the "oauth:" prefix, so we strip it for consistency.
@@ -522,4 +510,4 @@ const twitchSetupPlugin = {
522
510
  setupWizard: twitchSetupWizard
523
511
  };
524
512
  //#endregion
525
- export { getAccountConfig as a, resolveTwitchSnapshotAccountId as c, isAccountConfigured as d, missingTargetError as f, resolveTwitchToken as h, DEFAULT_ACCOUNT_ID$1 as i, twitchConfigAdapter as l, normalizeTwitchChannel as m, twitchSetupPlugin as n, resolveDefaultTwitchAccountId as o, normalizeToken as p, twitchSetupWizard as r, resolveTwitchAccountContext as s, twitchSetupContract as t, generateMessageId as u };
513
+ export { getAccountConfig as a, resolveTwitchSnapshotAccountId as c, missingTargetError as d, normalizeToken as f, DEFAULT_ACCOUNT_ID$1 as i, twitchConfigAdapter as l, resolveTwitchToken as m, twitchSetupPlugin as n, resolveDefaultTwitchAccountId as o, normalizeTwitchChannel as p, twitchSetupWizard as r, resolveTwitchAccountContext as s, twitchSetupContract as t, isAccountConfigured as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/twitch",
3
- "version": "2026.8.2",
3
+ "version": "2026.9.1",
4
4
  "description": "OpenClaw Twitch channel plugin for chat and moderation workflows.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,10 +30,10 @@
30
30
  "minHostVersion": ">=2026.4.10"
31
31
  },
32
32
  "compat": {
33
- "pluginApi": ">=2026.8.2"
33
+ "pluginApi": ">=2026.9.1"
34
34
  },
35
35
  "build": {
36
- "openclawVersion": "2026.8.2"
36
+ "openclawVersion": "2026.9.1"
37
37
  },
38
38
  "channel": {
39
39
  "id": "twitch",
@@ -71,7 +71,7 @@
71
71
  "README.md"
72
72
  ],
73
73
  "peerDependencies": {
74
- "openclaw": ">=2026.8.2"
74
+ "openclaw": ">=2026.9.1"
75
75
  },
76
76
  "peerDependenciesMeta": {
77
77
  "openclaw": {