@openclaw/twitch 2026.10.2 → 2026.10.5-beta.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/dist/.setup/{monitor-DXLeJigj.mjs → monitor-CsdDBmJ4.mjs} +134 -172
- package/dist/.setup/{plugin-BXWHdWMb.mjs → plugin-q9M3RXni.mjs} +35 -32
- package/dist/.setup/{setup-plugin-api-f4_tNl5M.mjs → setup-plugin-api-BC-Kt0o_.mjs} +1 -1
- package/dist/.setup/{setup-surface-CUV7j7dX.mjs → setup-surface-BHuTmMZL.mjs} +11 -13
- package/dist/api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/package.json +4 -4
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { n as sendMessageTwitchInternal, r as getOrCreateClientManager } from "./plugin-
|
|
2
|
-
import { l as normalizeTwitchChannel } from "./setup-surface-
|
|
1
|
+
import { n as sendMessageTwitchInternal, r as getOrCreateClientManager } from "./plugin-q9M3RXni.mjs";
|
|
2
|
+
import { l as normalizeTwitchChannel } from "./setup-surface-BHuTmMZL.mjs";
|
|
3
3
|
import { t as getTwitchRuntime } from "./runtime-B5If4b0g.mjs";
|
|
4
4
|
import { createChannelIngressError, createChannelIngressMonitor } from "openclaw/plugin-sdk/channel-outbound";
|
|
5
|
+
import { createChannelInboundEnvelopeBuilderAsync } from "openclaw/plugin-sdk/channel-inbound";
|
|
5
6
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
6
7
|
import { normalizeLowercaseStringOrEmpty, normalizeNullableString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
8
|
import { HttpStatusCodeError } from "@twurple/api-call";
|
|
8
|
-
import { createChannelInboundEnvelopeBuilder } from "openclaw/plugin-sdk/channel-inbound";
|
|
9
9
|
import { resolveOutboundMediaUrls } from "openclaw/plugin-sdk/reply-payload";
|
|
10
10
|
import { defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
11
11
|
//#region extensions/twitch/src/access-control.ts
|
|
@@ -62,24 +62,10 @@ async function checkTwitchAccessControl(params) {
|
|
|
62
62
|
allowed: false,
|
|
63
63
|
reason: "message does not mention the bot (requireMention is enabled)"
|
|
64
64
|
};
|
|
65
|
-
if (decision.admission === "dispatch") {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
matchKey: params.message.userId,
|
|
70
|
-
matchSource: "allowlist"
|
|
71
|
-
};
|
|
72
|
-
if (policyKind === "role") return {
|
|
73
|
-
allowed: true,
|
|
74
|
-
channelIngress: resolved,
|
|
75
|
-
matchKey: params.account.allowedRoles?.join(","),
|
|
76
|
-
matchSource: "role"
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
allowed: true,
|
|
80
|
-
channelIngress: resolved
|
|
81
|
-
};
|
|
82
|
-
}
|
|
65
|
+
if (decision.admission === "dispatch") return {
|
|
66
|
+
allowed: true,
|
|
67
|
+
channelIngress: resolved
|
|
68
|
+
};
|
|
83
69
|
if (policyKind === "allowFrom") {
|
|
84
70
|
if (!params.message.userId) return {
|
|
85
71
|
allowed: false,
|
|
@@ -280,152 +266,6 @@ function createTwitchIngress(options) {
|
|
|
280
266
|
}
|
|
281
267
|
//#endregion
|
|
282
268
|
//#region extensions/twitch/src/monitor.ts
|
|
283
|
-
async function processTwitchMessage(params) {
|
|
284
|
-
const { message, account, accountId, config, runtime, channelRuntime, turnAdoptionLifecycle, statusSink } = params;
|
|
285
|
-
const cfg = config;
|
|
286
|
-
const route = channelRuntime.routing.resolveAgentRoute({
|
|
287
|
-
cfg,
|
|
288
|
-
channel: "twitch",
|
|
289
|
-
accountId,
|
|
290
|
-
peer: {
|
|
291
|
-
kind: "group",
|
|
292
|
-
id: message.channel
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
const exactAccess = await checkTwitchAccessControl({
|
|
296
|
-
message,
|
|
297
|
-
account,
|
|
298
|
-
accountId,
|
|
299
|
-
botUsername: normalizeLowercaseStringOrEmpty(account.username),
|
|
300
|
-
contextBinding: {
|
|
301
|
-
agentId: route.agentId,
|
|
302
|
-
sessionKey: route.sessionKey,
|
|
303
|
-
messageId: message.id,
|
|
304
|
-
inboundEventKind: "user_request"
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
if (!exactAccess.allowed) return;
|
|
308
|
-
await channelRuntime.inbound.run({
|
|
309
|
-
channel: "twitch",
|
|
310
|
-
accountId,
|
|
311
|
-
raw: message,
|
|
312
|
-
turnAdoptionLifecycle,
|
|
313
|
-
adapter: {
|
|
314
|
-
ingest: (incoming) => ({
|
|
315
|
-
id: incoming.id,
|
|
316
|
-
timestamp: incoming.timestamp,
|
|
317
|
-
rawText: incoming.message,
|
|
318
|
-
textForAgent: incoming.message,
|
|
319
|
-
textForCommands: incoming.message,
|
|
320
|
-
raw: incoming
|
|
321
|
-
}),
|
|
322
|
-
resolveTurn: async (input) => {
|
|
323
|
-
const senderId = message.userId ?? message.username;
|
|
324
|
-
const fromLabel = message.displayName ?? message.username;
|
|
325
|
-
const body = createChannelInboundEnvelopeBuilder({
|
|
326
|
-
cfg,
|
|
327
|
-
route
|
|
328
|
-
})({
|
|
329
|
-
channel: "Twitch",
|
|
330
|
-
from: fromLabel,
|
|
331
|
-
timestamp: input.timestamp,
|
|
332
|
-
body: input.rawText
|
|
333
|
-
});
|
|
334
|
-
const ctxPayload = channelRuntime.inbound.buildContext({
|
|
335
|
-
channelIngress: exactAccess.channelIngress,
|
|
336
|
-
channel: "twitch",
|
|
337
|
-
accountId,
|
|
338
|
-
messageId: input.id,
|
|
339
|
-
timestamp: input.timestamp,
|
|
340
|
-
from: `twitch:user:${senderId}`,
|
|
341
|
-
sender: {
|
|
342
|
-
id: senderId,
|
|
343
|
-
name: fromLabel,
|
|
344
|
-
username: message.username
|
|
345
|
-
},
|
|
346
|
-
conversation: {
|
|
347
|
-
kind: "group",
|
|
348
|
-
id: message.channel,
|
|
349
|
-
label: message.channel
|
|
350
|
-
},
|
|
351
|
-
route: {
|
|
352
|
-
agentId: route.agentId,
|
|
353
|
-
dmScope: route.dmScope,
|
|
354
|
-
accountId: route.accountId,
|
|
355
|
-
routeSessionKey: route.sessionKey
|
|
356
|
-
},
|
|
357
|
-
reply: { to: `twitch:channel:${message.channel}` },
|
|
358
|
-
message: {
|
|
359
|
-
body,
|
|
360
|
-
rawBody: input.rawText,
|
|
361
|
-
bodyForAgent: input.textForAgent,
|
|
362
|
-
commandBody: input.textForCommands
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
return {
|
|
366
|
-
cfg,
|
|
367
|
-
channel: "twitch",
|
|
368
|
-
accountId,
|
|
369
|
-
route: {
|
|
370
|
-
agentId: route.agentId,
|
|
371
|
-
dmScope: route.dmScope,
|
|
372
|
-
sessionKey: route.sessionKey
|
|
373
|
-
},
|
|
374
|
-
ctxPayload,
|
|
375
|
-
delivery: {
|
|
376
|
-
durable: () => ({ to: `twitch:channel:${message.channel}` }),
|
|
377
|
-
deliver: async (payload) => {
|
|
378
|
-
return await deliverTwitchReply({
|
|
379
|
-
payload,
|
|
380
|
-
channel: message.channel,
|
|
381
|
-
account,
|
|
382
|
-
accountId,
|
|
383
|
-
config,
|
|
384
|
-
runtime
|
|
385
|
-
});
|
|
386
|
-
},
|
|
387
|
-
onDelivered: (_payload, _info, result) => {
|
|
388
|
-
if (result?.visibleReplySent !== false) statusSink?.({ lastOutboundAt: Date.now() });
|
|
389
|
-
},
|
|
390
|
-
onError: (err, info) => {
|
|
391
|
-
runtime.error?.(`Twitch ${info.kind} reply failed: ${String(err)}`);
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
replyPipeline: {},
|
|
395
|
-
record: { onRecordError: (err) => {
|
|
396
|
-
runtime.error?.(`Failed updating session meta: ${String(err)}`);
|
|
397
|
-
} }
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
async function deliverTwitchReply(params) {
|
|
404
|
-
const { payload, channel, account, accountId, config, runtime } = params;
|
|
405
|
-
try {
|
|
406
|
-
const clientManager = getOrCreateClientManager(accountId, {
|
|
407
|
-
info: (msg) => runtime.log?.(msg),
|
|
408
|
-
warn: (msg) => runtime.log?.(msg),
|
|
409
|
-
error: (msg) => runtime.error?.(msg),
|
|
410
|
-
debug: (msg) => runtime.log?.(msg)
|
|
411
|
-
});
|
|
412
|
-
if ((await sendMessageTwitchInternal({
|
|
413
|
-
channel,
|
|
414
|
-
text: [payload.text, ...resolveOutboundMediaUrls(payload)].filter(Boolean).join(" "),
|
|
415
|
-
cfg: config,
|
|
416
|
-
account,
|
|
417
|
-
accountId,
|
|
418
|
-
clientManager
|
|
419
|
-
})).outcome === "not_sent") {
|
|
420
|
-
runtime.error?.(`No text to send in reply payload`);
|
|
421
|
-
return { visibleReplySent: false };
|
|
422
|
-
}
|
|
423
|
-
return { visibleReplySent: true };
|
|
424
|
-
} catch (err) {
|
|
425
|
-
runtime.error?.(`Failed to send reply: ${String(err)}`);
|
|
426
|
-
return { visibleReplySent: false };
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
269
|
async function monitorTwitchProvider(options) {
|
|
430
270
|
const { account, accountId, channelRuntime, config, runtime, abortSignal, statusSink } = options;
|
|
431
271
|
const core = getTwitchRuntime();
|
|
@@ -462,15 +302,137 @@ async function monitorTwitchProvider(options) {
|
|
|
462
302
|
botUsername
|
|
463
303
|
})).allowed) return;
|
|
464
304
|
statusSink?.({ lastInboundAt: Date.now() });
|
|
465
|
-
|
|
305
|
+
const cfg = config;
|
|
306
|
+
const route = channelRuntime.routing.resolveAgentRoute({
|
|
307
|
+
cfg,
|
|
308
|
+
channel: "twitch",
|
|
309
|
+
accountId,
|
|
310
|
+
peer: {
|
|
311
|
+
kind: "group",
|
|
312
|
+
id: message.channel
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
const exactAccess = await checkTwitchAccessControl({
|
|
466
316
|
message,
|
|
467
317
|
account,
|
|
468
318
|
accountId,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
319
|
+
botUsername: normalizeLowercaseStringOrEmpty(account.username),
|
|
320
|
+
contextBinding: {
|
|
321
|
+
agentId: route.agentId,
|
|
322
|
+
sessionKey: route.sessionKey,
|
|
323
|
+
messageId: message.id,
|
|
324
|
+
inboundEventKind: "user_request"
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
if (!exactAccess.allowed) return;
|
|
328
|
+
await channelRuntime.inbound.run({
|
|
329
|
+
channel: "twitch",
|
|
330
|
+
accountId,
|
|
331
|
+
raw: message,
|
|
472
332
|
turnAdoptionLifecycle,
|
|
473
|
-
|
|
333
|
+
adapter: {
|
|
334
|
+
ingest: (incoming) => ({
|
|
335
|
+
id: incoming.id,
|
|
336
|
+
timestamp: incoming.timestamp,
|
|
337
|
+
rawText: incoming.message,
|
|
338
|
+
textForAgent: incoming.message,
|
|
339
|
+
textForCommands: incoming.message,
|
|
340
|
+
raw: incoming
|
|
341
|
+
}),
|
|
342
|
+
resolveTurn: async (input) => {
|
|
343
|
+
const senderId = message.userId ?? message.username;
|
|
344
|
+
const fromLabel = message.displayName ?? message.username;
|
|
345
|
+
const body = (await createChannelInboundEnvelopeBuilderAsync({
|
|
346
|
+
cfg,
|
|
347
|
+
route
|
|
348
|
+
}))({
|
|
349
|
+
channel: "Twitch",
|
|
350
|
+
from: fromLabel,
|
|
351
|
+
timestamp: input.timestamp,
|
|
352
|
+
body: input.rawText
|
|
353
|
+
});
|
|
354
|
+
const ctxPayload = channelRuntime.inbound.buildContext({
|
|
355
|
+
channelIngress: exactAccess.channelIngress,
|
|
356
|
+
channel: "twitch",
|
|
357
|
+
accountId,
|
|
358
|
+
messageId: input.id,
|
|
359
|
+
timestamp: input.timestamp,
|
|
360
|
+
from: `twitch:user:${senderId}`,
|
|
361
|
+
sender: {
|
|
362
|
+
id: senderId,
|
|
363
|
+
name: fromLabel,
|
|
364
|
+
username: message.username
|
|
365
|
+
},
|
|
366
|
+
conversation: {
|
|
367
|
+
kind: "group",
|
|
368
|
+
id: message.channel,
|
|
369
|
+
label: message.channel
|
|
370
|
+
},
|
|
371
|
+
route: {
|
|
372
|
+
agentId: route.agentId,
|
|
373
|
+
dmScope: route.dmScope,
|
|
374
|
+
accountId: route.accountId,
|
|
375
|
+
routeSessionKey: route.sessionKey
|
|
376
|
+
},
|
|
377
|
+
reply: { to: `twitch:channel:${message.channel}` },
|
|
378
|
+
message: {
|
|
379
|
+
body,
|
|
380
|
+
rawBody: input.rawText,
|
|
381
|
+
bodyForAgent: input.textForAgent,
|
|
382
|
+
commandBody: input.textForCommands
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
return {
|
|
386
|
+
cfg,
|
|
387
|
+
channel: "twitch",
|
|
388
|
+
accountId,
|
|
389
|
+
route: {
|
|
390
|
+
agentId: route.agentId,
|
|
391
|
+
dmScope: route.dmScope,
|
|
392
|
+
sessionKey: route.sessionKey
|
|
393
|
+
},
|
|
394
|
+
ctxPayload,
|
|
395
|
+
delivery: {
|
|
396
|
+
durable: () => ({ to: `twitch:channel:${message.channel}` }),
|
|
397
|
+
deliver: async (payload) => {
|
|
398
|
+
try {
|
|
399
|
+
const replyClientManager = getOrCreateClientManager(accountId, {
|
|
400
|
+
info: (msg) => runtime.log?.(msg),
|
|
401
|
+
warn: (msg) => runtime.log?.(msg),
|
|
402
|
+
error: (msg) => runtime.error?.(msg),
|
|
403
|
+
debug: (msg) => runtime.log?.(msg)
|
|
404
|
+
});
|
|
405
|
+
if ((await sendMessageTwitchInternal({
|
|
406
|
+
channel: message.channel,
|
|
407
|
+
text: [payload.text, ...resolveOutboundMediaUrls(payload)].filter(Boolean).join(" "),
|
|
408
|
+
cfg: config,
|
|
409
|
+
account,
|
|
410
|
+
accountId,
|
|
411
|
+
clientManager: replyClientManager
|
|
412
|
+
})).outcome === "not_sent") {
|
|
413
|
+
runtime.error?.(`No text to send in reply payload`);
|
|
414
|
+
return { visibleReplySent: false };
|
|
415
|
+
}
|
|
416
|
+
return { visibleReplySent: true };
|
|
417
|
+
} catch (err) {
|
|
418
|
+
runtime.error?.(`Failed to send reply: ${String(err)}`);
|
|
419
|
+
return { visibleReplySent: false };
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
onDelivered: (_payload, _info, result) => {
|
|
423
|
+
if (result?.visibleReplySent !== false) statusSink?.({ lastOutboundAt: Date.now() });
|
|
424
|
+
},
|
|
425
|
+
onError: (err, info) => {
|
|
426
|
+
runtime.error?.(`Twitch ${info.kind} reply failed: ${String(err)}`);
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
replyPipeline: {},
|
|
430
|
+
record: { onRecordError: (err) => {
|
|
431
|
+
runtime.error?.(`Failed updating session meta: ${String(err)}`);
|
|
432
|
+
} }
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
}
|
|
474
436
|
});
|
|
475
437
|
}
|
|
476
438
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveTwitchAccountContext, c as normalizeToken, i as resolveDefaultTwitchAccountId, l as normalizeTwitchChannel, n as DEFAULT_ACCOUNT_ID$1, o as twitchConfigAdapter, r as getAccountConfig, s as isAccountConfigured, t as twitchSetupPlugin, u as resolveTwitchToken } from "./setup-surface-
|
|
1
|
+
import { a as resolveTwitchAccountContext, c as normalizeToken, i as resolveDefaultTwitchAccountId, l as normalizeTwitchChannel, n as DEFAULT_ACCOUNT_ID$1, o as twitchConfigAdapter, r as getAccountConfig, s as isAccountConfigured, t as twitchSetupPlugin, u as resolveTwitchToken } from "./setup-surface-BHuTmMZL.mjs";
|
|
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";
|
|
@@ -9,7 +9,9 @@ import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState }
|
|
|
9
9
|
import { RefreshingAuthProvider, StaticAuthProvider } from "@twurple/auth";
|
|
10
10
|
import { ChatClient, LogLevel } from "@twurple/chat";
|
|
11
11
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-resolution";
|
|
12
|
+
import { createChannelPartialDeliveryError, isChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
|
|
12
13
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
14
|
+
import { captureEffectAuthority } from "openclaw/plugin-sdk/fetch-runtime";
|
|
13
15
|
import { channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
14
16
|
import { chunkTextForOutbound, sanitizeAssistantVisibleText, stripMarkdown } from "openclaw/plugin-sdk/text-chunking";
|
|
15
17
|
import { runChannelProbe, sliceUtf16Safe, withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -25,16 +27,12 @@ const twitchMessageActions = {
|
|
|
25
27
|
describeMessageTool: () => ({ actions: ["send"] }),
|
|
26
28
|
supportsAction: ({ action }) => action === "send",
|
|
27
29
|
extractToolSend: ({ args }) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} : null;
|
|
35
|
-
} catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
30
|
+
const to = readSendValue(args.to);
|
|
31
|
+
const message = readSendValue(args.message);
|
|
32
|
+
return to && message ? {
|
|
33
|
+
to,
|
|
34
|
+
message
|
|
35
|
+
} : null;
|
|
38
36
|
}
|
|
39
37
|
};
|
|
40
38
|
//#endregion
|
|
@@ -272,15 +270,31 @@ var TwitchClientManager = class {
|
|
|
272
270
|
this.logger.info(" Disconnected all clients");
|
|
273
271
|
}
|
|
274
272
|
async sendMessage(account, channel, message, cfg, accountId) {
|
|
273
|
+
const effect = captureEffectAuthority();
|
|
274
|
+
let preparingUse = false;
|
|
275
275
|
try {
|
|
276
276
|
const client = await this.getClient(account, cfg, accountId);
|
|
277
277
|
const messageId = crypto.randomUUID();
|
|
278
|
-
|
|
278
|
+
const chunks = chunkTextForOutbound(message, 500);
|
|
279
|
+
preparingUse = true;
|
|
280
|
+
const results = await effect.initiate(() => {
|
|
281
|
+
preparingUse = false;
|
|
282
|
+
return Promise.allSettled(chunks.map(async (chunk) => client.say(channel, chunk)));
|
|
283
|
+
});
|
|
284
|
+
const failure = results.find((result) => result.status === "rejected");
|
|
285
|
+
if (failure) {
|
|
286
|
+
if (results.some((result) => result.status === "fulfilled")) throw createChannelPartialDeliveryError(failure.reason, {
|
|
287
|
+
messageIds: [messageId],
|
|
288
|
+
visibleReplySent: true
|
|
289
|
+
});
|
|
290
|
+
throw failure.reason;
|
|
291
|
+
}
|
|
279
292
|
return {
|
|
280
293
|
ok: true,
|
|
281
294
|
messageId
|
|
282
295
|
};
|
|
283
296
|
} catch (error) {
|
|
297
|
+
if (preparingUse || isChannelPartialDeliveryError(error)) throw error;
|
|
284
298
|
const errorMessage = formatErrorMessage(error);
|
|
285
299
|
this.logger.error(`Failed to send message: ${errorMessage}`);
|
|
286
300
|
return {
|
|
@@ -377,17 +391,6 @@ const MultiAccountSchema = z.object({
|
|
|
377
391
|
}).refine((val) => Object.keys(val.accounts).length > 0, { message: "accounts must contain at least one entry" });
|
|
378
392
|
const TwitchConfigSchema = z.union([SimplifiedSchema, MultiAccountSchema]);
|
|
379
393
|
//#endregion
|
|
380
|
-
//#region extensions/twitch/src/utils/markdown.ts
|
|
381
|
-
/**
|
|
382
|
-
* Markdown utilities for Twitch chat
|
|
383
|
-
*
|
|
384
|
-
* Twitch chat doesn't support markdown formatting, so we strip it before sending.
|
|
385
|
-
*/
|
|
386
|
-
/** Strip markdown, then flatten newlines for Twitch's single-line chat. */
|
|
387
|
-
function stripMarkdownForTwitch(markdown) {
|
|
388
|
-
return stripMarkdown(markdown, { linkStyle: "label-and-url" }).replace(/\r/g, "").replace(/[ \t]+\n/g, "\n").replace(/\n/g, " ").replace(/[ \t]{2,}/g, " ").trim();
|
|
389
|
-
}
|
|
390
|
-
//#endregion
|
|
391
394
|
//#region extensions/twitch/src/send.ts
|
|
392
395
|
function createTwitchSendReceipt(messageId, channel) {
|
|
393
396
|
return createMessageReceiptFromOutboundResults({
|
|
@@ -400,7 +403,7 @@ function createTwitchSendReceipt(messageId, channel) {
|
|
|
400
403
|
});
|
|
401
404
|
}
|
|
402
405
|
async function sendMessageTwitchInternal(params) {
|
|
403
|
-
const cleanedText =
|
|
406
|
+
const cleanedText = stripMarkdown(params.text, { linkStyle: "label-and-url" }).replace(/\r/g, "").replace(/[ \t]+\n/g, "\n").replace(/\n/g, " ").replace(/[ \t]{2,}/g, " ").trim();
|
|
404
407
|
if (!cleanedText) return {
|
|
405
408
|
outcome: "not_sent",
|
|
406
409
|
messageId: "",
|
|
@@ -501,19 +504,19 @@ async function probeTwitch(account, timeoutMs) {
|
|
|
501
504
|
const cleanup = () => {
|
|
502
505
|
if (settled) return;
|
|
503
506
|
settled = true;
|
|
504
|
-
connectListener
|
|
505
|
-
disconnectListener
|
|
506
|
-
authFailListener
|
|
507
|
+
connectListener.unbind();
|
|
508
|
+
disconnectListener.unbind();
|
|
509
|
+
authFailListener.unbind();
|
|
507
510
|
};
|
|
508
|
-
const connectListener =
|
|
511
|
+
const connectListener = probeClient.onConnect(() => {
|
|
509
512
|
cleanup();
|
|
510
513
|
resolve();
|
|
511
514
|
});
|
|
512
|
-
const disconnectListener =
|
|
515
|
+
const disconnectListener = probeClient.onDisconnect((_manually, reason) => {
|
|
513
516
|
cleanup();
|
|
514
517
|
reject(reason || /* @__PURE__ */ new Error("Disconnected"));
|
|
515
518
|
});
|
|
516
|
-
const authFailListener =
|
|
519
|
+
const authFailListener = probeClient.onAuthenticationFailure(() => {
|
|
517
520
|
cleanup();
|
|
518
521
|
reject(/* @__PURE__ */ new Error("Authentication failed"));
|
|
519
522
|
});
|
|
@@ -673,7 +676,7 @@ function collectTwitchStatusIssues(accounts) {
|
|
|
673
676
|
message: `Last error: ${entry.lastError}`,
|
|
674
677
|
fix: "Check your token validity and network connection. Ensure the bot has the required OAuth scopes."
|
|
675
678
|
});
|
|
676
|
-
if (
|
|
679
|
+
if (!entry.running && !entry.lastStartAt && !entry.lastInboundAt && !entry.lastOutboundAt) issues.push({
|
|
677
680
|
channel: "twitch",
|
|
678
681
|
accountId,
|
|
679
682
|
kind: "runtime",
|
|
@@ -817,7 +820,7 @@ const twitchPlugin = createChatChannelPlugin({
|
|
|
817
820
|
await runPassiveAccountLifecycle({
|
|
818
821
|
abortSignal: ctx.abortSignal,
|
|
819
822
|
start: async () => {
|
|
820
|
-
const { monitorTwitchProvider } = await import("./monitor-
|
|
823
|
+
const { monitorTwitchProvider } = await import("./monitor-CsdDBmJ4.mjs");
|
|
821
824
|
return monitorTwitchProvider({
|
|
822
825
|
account,
|
|
823
826
|
accountId,
|
|
@@ -152,7 +152,7 @@ function resolveSetupAccountId(cfg, requestedAccountId) {
|
|
|
152
152
|
return preferred ? normalizeAccountId$1(preferred) : resolveDefaultTwitchAccountId(cfg);
|
|
153
153
|
}
|
|
154
154
|
function setTwitchAccount(cfg, account, accountId = resolveSetupAccountId(cfg)) {
|
|
155
|
-
const resolvedAccountId = resolveSetupAccountId(cfg, accountId
|
|
155
|
+
const resolvedAccountId = resolveSetupAccountId(cfg, accountId);
|
|
156
156
|
const existing = getAccountConfig(cfg, resolvedAccountId);
|
|
157
157
|
const merged = {
|
|
158
158
|
username: account.username ?? existing?.username ?? "",
|
|
@@ -249,7 +249,7 @@ async function promptRefreshTokenSetup(prompter, account) {
|
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
251
|
async function configureWithEnvToken(cfg, prompter, account, envToken, forceAllowFrom, dmPolicy, accountId = resolveSetupAccountId(cfg)) {
|
|
252
|
-
const resolvedAccountId = resolveSetupAccountId(cfg, accountId
|
|
252
|
+
const resolvedAccountId = resolveSetupAccountId(cfg, accountId);
|
|
253
253
|
if (resolvedAccountId !== DEFAULT_ACCOUNT_ID$1) return null;
|
|
254
254
|
if (!await prompter.confirm({
|
|
255
255
|
message: t("wizard.twitch.envPrompt"),
|
|
@@ -268,16 +268,6 @@ async function configureWithEnvToken(cfg, prompter, account, envToken, forceAllo
|
|
|
268
268
|
}) };
|
|
269
269
|
return { cfg: cfgWithAccount };
|
|
270
270
|
}
|
|
271
|
-
function setTwitchAccessControl(cfg, allowedRoles, requireMention, accountId) {
|
|
272
|
-
const resolvedAccountId = resolveSetupAccountId(cfg, accountId);
|
|
273
|
-
const account = getAccountConfig(cfg, resolvedAccountId);
|
|
274
|
-
if (!account) return cfg;
|
|
275
|
-
return setTwitchAccount(cfg, {
|
|
276
|
-
...account,
|
|
277
|
-
allowedRoles,
|
|
278
|
-
requireMention
|
|
279
|
-
}, resolvedAccountId);
|
|
280
|
-
}
|
|
281
271
|
function resolveTwitchGroupPolicy(cfg, accountId) {
|
|
282
272
|
const account = getAccountConfig(cfg, resolveSetupAccountId(cfg, accountId));
|
|
283
273
|
if (!account) return "disabled";
|
|
@@ -343,7 +333,15 @@ const twitchDmPolicy = createChannelDmPolicy({
|
|
|
343
333
|
buildPatch: ({ policy }) => {
|
|
344
334
|
return { allowedRoles: policy === "open" ? ["all"] : policy === "allowlist" ? [] : ["moderator"] };
|
|
345
335
|
},
|
|
346
|
-
applyPatch: ({ cfg, account, patch }) =>
|
|
336
|
+
applyPatch: ({ cfg, account, patch }) => {
|
|
337
|
+
const accountId = resolveSetupAccountId(cfg, account.accountId);
|
|
338
|
+
const existing = getAccountConfig(cfg, accountId);
|
|
339
|
+
return existing ? setTwitchAccount(cfg, {
|
|
340
|
+
...existing,
|
|
341
|
+
allowedRoles: patch.allowedRoles,
|
|
342
|
+
requireMention: true
|
|
343
|
+
}, accountId) : cfg;
|
|
344
|
+
},
|
|
347
345
|
promptAllowFrom: async ({ cfg, prompter, accountId }) => {
|
|
348
346
|
const resolvedAccountId = resolveSetupAccountId(cfg, accountId);
|
|
349
347
|
const account = getAccountConfig(cfg, resolvedAccountId);
|
package/dist/api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as twitchPlugin } from "./.setup/plugin-
|
|
1
|
+
import { t as twitchPlugin } from "./.setup/plugin-q9M3RXni.mjs";
|
|
2
2
|
export { twitchPlugin };
|
package/dist/setup-entry.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
var setup_entry_default = defineBundledChannelSetupEntry({
|
|
5
5
|
importMetaUrl: import.meta.url,
|
|
6
6
|
plugin: {
|
|
7
|
-
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-
|
|
7
|
+
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-BC-Kt0o_.mjs", import.meta.url).href),
|
|
8
8
|
exportName: "twitchSetupPlugin"
|
|
9
9
|
}
|
|
10
10
|
});
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as twitchSetupPlugin } from "./.setup/setup-surface-
|
|
1
|
+
import { t as twitchSetupPlugin } from "./.setup/setup-surface-BHuTmMZL.mjs";
|
|
2
2
|
export { twitchSetupPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/twitch",
|
|
3
|
-
"version": "2026.10.2",
|
|
3
|
+
"version": "2026.10.5-beta.2",
|
|
4
4
|
"description": "OpenClaw Twitch channel plugin for chat and moderation workflows.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"minHostVersion": ">=2026.4.10"
|
|
32
32
|
},
|
|
33
33
|
"compat": {
|
|
34
|
-
"pluginApi": ">=2026.10.2"
|
|
34
|
+
"pluginApi": ">=2026.10.5-beta.2"
|
|
35
35
|
},
|
|
36
36
|
"build": {
|
|
37
|
-
"openclawVersion": "2026.10.2"
|
|
37
|
+
"openclawVersion": "2026.10.5-beta.2"
|
|
38
38
|
},
|
|
39
39
|
"channel": {
|
|
40
40
|
"id": "twitch",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"assets/activity.svg"
|
|
75
75
|
],
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"openclaw": ">=2026.10.2"
|
|
77
|
+
"openclaw": ">=2026.10.5-beta.2"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
80
80
|
"openclaw": {
|