@openclaw/twitch 2026.7.2-beta.3 → 2026.7.2-beta.4
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/api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{monitor-8jPqCs8-.js → monitor-CQidEQhp.js} +214 -15
- package/dist/{plugin-D1zR5fBz.js → plugin-B31l1oaD.js} +15 -22
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CxAa0pLj.js → setup-surface-CVAaMigx.js} +8 -1
- package/node_modules/@types/ws/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/ws/node_modules/@types/node/fs/promises.d.ts +16 -6
- package/node_modules/@types/ws/node_modules/@types/node/package.json +2 -2
- package/node_modules/ws/lib/receiver.js +15 -32
- package/node_modules/ws/lib/websocket-server.js +4 -4
- package/node_modules/ws/lib/websocket.js +4 -4
- package/node_modules/ws/package.json +5 -1
- package/npm-shrinkwrap.json +8 -8
- package/openclaw.plugin.json +0 -5
- package/package.json +18 -5
package/dist/api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as twitchPlugin } from "./plugin-
|
|
1
|
+
import { t as twitchPlugin } from "./plugin-B31l1oaD.js";
|
|
2
2
|
export { twitchPlugin };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as normalizeTwitchChannel } from "./setup-surface-CVAaMigx.js";
|
|
2
|
+
import { n as stripMarkdownForTwitch, r as getOrCreateClientManager } from "./plugin-B31l1oaD.js";
|
|
2
3
|
import { t as getTwitchRuntime } from "./runtime-B5If4b0g.js";
|
|
4
|
+
import { createChannelIngressMonitor } from "openclaw/plugin-sdk/channel-outbound";
|
|
3
5
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
4
6
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { HttpStatusCodeError } from "@twurple/api-call";
|
|
5
8
|
import { createChannelInboundEnvelopeBuilder } from "openclaw/plugin-sdk/channel-inbound";
|
|
6
9
|
import { createChannelIngressResolver, defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
7
10
|
//#region extensions/twitch/src/access-control.ts
|
|
@@ -126,6 +129,186 @@ function mentionsBot(message, botUsername) {
|
|
|
126
129
|
return false;
|
|
127
130
|
}
|
|
128
131
|
//#endregion
|
|
132
|
+
//#region extensions/twitch/src/twitch-ingress.ts
|
|
133
|
+
const TWITCH_INGRESS_PAYLOAD_VERSION = 1;
|
|
134
|
+
const TWITCH_INGRESS_DRAIN_INTERVAL_MS = 1e3;
|
|
135
|
+
const TWITCH_INGRESS_PRUNE_INTERVAL_MS = 3600 * 1e3;
|
|
136
|
+
const TWITCH_INGRESS_COMPLETED_TTL_MS = 720 * 60 * 60 * 1e3;
|
|
137
|
+
const TWITCH_INGRESS_COMPLETED_MAX_ENTRIES = 1e3;
|
|
138
|
+
const TWITCH_INGRESS_FAILED_TTL_MS = 720 * 60 * 60 * 1e3;
|
|
139
|
+
const TWITCH_INGRESS_FAILED_MAX_ENTRIES = 1e3;
|
|
140
|
+
var TwitchIngressPermanentError = class extends Error {
|
|
141
|
+
constructor(message, options) {
|
|
142
|
+
super(message, options);
|
|
143
|
+
this.name = "TwitchIngressPermanentError";
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
function nonEmptyString(value) {
|
|
147
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
148
|
+
}
|
|
149
|
+
function inspectTwitchIngressEvent(event) {
|
|
150
|
+
if (!event || typeof event !== "object" || Array.isArray(event)) throw new TwitchIngressPermanentError("Twitch ingress event must be an object.");
|
|
151
|
+
const candidate = event;
|
|
152
|
+
const eventId = nonEmptyString(candidate.id);
|
|
153
|
+
if (!eventId) throw new TwitchIngressPermanentError("Twitch ingress event is missing its message id.");
|
|
154
|
+
const rawChannel = nonEmptyString(candidate.channel);
|
|
155
|
+
const channel = rawChannel ? normalizeTwitchChannel(rawChannel) : "";
|
|
156
|
+
if (!channel) throw new TwitchIngressPermanentError("Twitch ingress event is missing its channel.");
|
|
157
|
+
return {
|
|
158
|
+
eventId,
|
|
159
|
+
laneKey: `channel:${channel}`
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function deserializeTwitchIngressEvent(rawEvent) {
|
|
163
|
+
let parsed;
|
|
164
|
+
try {
|
|
165
|
+
parsed = JSON.parse(rawEvent);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
throw new TwitchIngressPermanentError("Twitch ingress event JSON is invalid.", { cause: error });
|
|
168
|
+
}
|
|
169
|
+
return parsed;
|
|
170
|
+
}
|
|
171
|
+
function normalizeClaimedTwitchMessage(event, claimedId) {
|
|
172
|
+
const candidate = event;
|
|
173
|
+
const username = nonEmptyString(candidate.username);
|
|
174
|
+
const rawChannel = nonEmptyString(candidate.channel);
|
|
175
|
+
if (!username || typeof candidate.message !== "string" || !rawChannel) throw new TwitchIngressPermanentError("Twitch ingress event shape is invalid.");
|
|
176
|
+
return {
|
|
177
|
+
...candidate,
|
|
178
|
+
id: claimedId,
|
|
179
|
+
username,
|
|
180
|
+
message: candidate.message,
|
|
181
|
+
channel: normalizeTwitchChannel(rawChannel)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function isTwitchAuthenticationFailure(error) {
|
|
185
|
+
let current = error;
|
|
186
|
+
for (let depth = 0; depth < 8 && current && typeof current === "object"; depth += 1) {
|
|
187
|
+
if (current instanceof HttpStatusCodeError && (current.statusCode === 401 || current.statusCode === 403)) return true;
|
|
188
|
+
current = current.cause;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
function stoppedError() {
|
|
193
|
+
return /* @__PURE__ */ new Error("Twitch ingress stopped before dispatch.");
|
|
194
|
+
}
|
|
195
|
+
function createTwitchIngress(options) {
|
|
196
|
+
const queue = options.queue ?? getTwitchRuntime().state.openChannelIngressQueue({ accountId: options.accountId });
|
|
197
|
+
const shutdown = new AbortController();
|
|
198
|
+
let stopped = false;
|
|
199
|
+
const deferredClaims = /* @__PURE__ */ new Map();
|
|
200
|
+
const monitor = createChannelIngressMonitor({
|
|
201
|
+
queue,
|
|
202
|
+
inspect: (message) => inspectTwitchIngressEvent(message),
|
|
203
|
+
payload: {
|
|
204
|
+
storage: "raw-event",
|
|
205
|
+
version: TWITCH_INGRESS_PAYLOAD_VERSION,
|
|
206
|
+
serialize: (message) => JSON.stringify(message),
|
|
207
|
+
deserialize: (rawEvent) => deserializeTwitchIngressEvent(rawEvent),
|
|
208
|
+
createClaimError: (kind) => new TwitchIngressPermanentError(kind === "invalid-version" ? "Twitch ingress payload is invalid." : "Twitch ingress event identity changed after durable admission.")
|
|
209
|
+
},
|
|
210
|
+
deliver: async (rawEvent, lifecycle, claim) => {
|
|
211
|
+
const message = normalizeClaimedTwitchMessage(rawEvent, claim.id);
|
|
212
|
+
let handedOff = false;
|
|
213
|
+
let resolveDeferredClaim;
|
|
214
|
+
const deferredClaim = new Promise((resolve) => {
|
|
215
|
+
resolveDeferredClaim = resolve;
|
|
216
|
+
});
|
|
217
|
+
let deferredClaimSettled = false;
|
|
218
|
+
const settleDeferredClaim = () => {
|
|
219
|
+
if (deferredClaimSettled) return;
|
|
220
|
+
deferredClaimSettled = true;
|
|
221
|
+
if (deferredClaims.get(claim.id) === deferredClaim) deferredClaims.delete(claim.id);
|
|
222
|
+
resolveDeferredClaim();
|
|
223
|
+
};
|
|
224
|
+
const deliveryAbortSignal = AbortSignal.any([lifecycle.abortSignal, shutdown.signal]);
|
|
225
|
+
try {
|
|
226
|
+
await options.deliver(message, {
|
|
227
|
+
admission: lifecycle.admission,
|
|
228
|
+
abortSignal: deliveryAbortSignal,
|
|
229
|
+
onAdopted: async () => {
|
|
230
|
+
handedOff = true;
|
|
231
|
+
try {
|
|
232
|
+
await lifecycle.onAdopted();
|
|
233
|
+
} finally {
|
|
234
|
+
settleDeferredClaim();
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
onDeferred: () => {
|
|
238
|
+
handedOff = true;
|
|
239
|
+
if (!deferredClaimSettled) deferredClaims.set(claim.id, deferredClaim);
|
|
240
|
+
lifecycle.onDeferred();
|
|
241
|
+
},
|
|
242
|
+
onAbandoned: async () => {
|
|
243
|
+
handedOff = true;
|
|
244
|
+
try {
|
|
245
|
+
await lifecycle.onAbandoned();
|
|
246
|
+
} finally {
|
|
247
|
+
settleDeferredClaim();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (stopped || deliveryAbortSignal.aborted) return {
|
|
253
|
+
kind: "failed-retryable",
|
|
254
|
+
error
|
|
255
|
+
};
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
if (!handedOff && (stopped || deliveryAbortSignal.aborted)) return {
|
|
259
|
+
kind: "failed-retryable",
|
|
260
|
+
error: stoppedError()
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
pollIntervalMs: options.pollIntervalMs ?? TWITCH_INGRESS_DRAIN_INTERVAL_MS,
|
|
264
|
+
retention: {
|
|
265
|
+
pruneIntervalMs: TWITCH_INGRESS_PRUNE_INTERVAL_MS,
|
|
266
|
+
completedTtlMs: TWITCH_INGRESS_COMPLETED_TTL_MS,
|
|
267
|
+
completedMaxEntries: TWITCH_INGRESS_COMPLETED_MAX_ENTRIES,
|
|
268
|
+
failedTtlMs: TWITCH_INGRESS_FAILED_TTL_MS,
|
|
269
|
+
failedMaxEntries: TWITCH_INGRESS_FAILED_MAX_ENTRIES
|
|
270
|
+
},
|
|
271
|
+
drain: {
|
|
272
|
+
resolveNonRetryableFailure: (error) => {
|
|
273
|
+
if (error instanceof TwitchIngressPermanentError) return {
|
|
274
|
+
reason: "invalid-event",
|
|
275
|
+
message: error.message
|
|
276
|
+
};
|
|
277
|
+
if (isTwitchAuthenticationFailure(error)) return {
|
|
278
|
+
reason: "authentication-failed",
|
|
279
|
+
message: formatErrorMessage(error)
|
|
280
|
+
};
|
|
281
|
+
return null;
|
|
282
|
+
},
|
|
283
|
+
onLog: (message) => options.runtime.error?.(`twitch ingress: ${message}`)
|
|
284
|
+
},
|
|
285
|
+
abortSignal: shutdown.signal,
|
|
286
|
+
createStoppedError: stoppedError,
|
|
287
|
+
onError: (error) => options.runtime.error?.(`Twitch ingress drain failed: ${formatErrorMessage(error)}`)
|
|
288
|
+
});
|
|
289
|
+
let stopTask;
|
|
290
|
+
return {
|
|
291
|
+
accept: (message) => {
|
|
292
|
+
if (stopped) return Promise.reject(stoppedError());
|
|
293
|
+
return monitor.admit(message).then(() => void 0);
|
|
294
|
+
},
|
|
295
|
+
start: () => {
|
|
296
|
+
if (!stopped) monitor.start();
|
|
297
|
+
},
|
|
298
|
+
stop: () => {
|
|
299
|
+
stopTask ??= (async () => {
|
|
300
|
+
stopped = true;
|
|
301
|
+
shutdown.abort(stoppedError());
|
|
302
|
+
await monitor.pause();
|
|
303
|
+
await monitor.waitForIdle();
|
|
304
|
+
await Promise.allSettled(deferredClaims.values());
|
|
305
|
+
await monitor.stop();
|
|
306
|
+
})();
|
|
307
|
+
return stopTask;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
129
312
|
//#region extensions/twitch/src/monitor.ts
|
|
130
313
|
/**
|
|
131
314
|
* Twitch message monitor - processes incoming messages and routes to agents.
|
|
@@ -137,16 +320,17 @@ function mentionsBot(message, botUsername) {
|
|
|
137
320
|
* Process an incoming Twitch message and dispatch to agent.
|
|
138
321
|
*/
|
|
139
322
|
async function processTwitchMessage(params) {
|
|
140
|
-
const { message, account, accountId, config, runtime, core, statusSink } = params;
|
|
323
|
+
const { message, account, accountId, config, runtime, core, turnAdoptionLifecycle, statusSink } = params;
|
|
141
324
|
const cfg = config;
|
|
142
325
|
await core.channel.inbound.run({
|
|
143
326
|
channel: "twitch",
|
|
144
327
|
accountId,
|
|
145
328
|
raw: message,
|
|
329
|
+
turnAdoptionLifecycle,
|
|
146
330
|
adapter: {
|
|
147
331
|
ingest: (incoming) => ({
|
|
148
|
-
id: incoming.id
|
|
149
|
-
timestamp: incoming.timestamp
|
|
332
|
+
id: incoming.id,
|
|
333
|
+
timestamp: incoming.timestamp,
|
|
150
334
|
rawText: incoming.message,
|
|
151
335
|
textForAgent: incoming.message,
|
|
152
336
|
textForCommands: incoming.message,
|
|
@@ -282,6 +466,7 @@ async function monitorTwitchProvider(options) {
|
|
|
282
466
|
const { account, accountId, config, runtime, abortSignal, statusSink } = options;
|
|
283
467
|
const core = getTwitchRuntime();
|
|
284
468
|
let stopped = false;
|
|
469
|
+
let stopTask;
|
|
285
470
|
const coreLogger = core.logging.getChildLogger({ module: "twitch" });
|
|
286
471
|
const logVerboseMessage = (message) => {
|
|
287
472
|
if (!core.logging.shouldLogVerbose()) return;
|
|
@@ -300,17 +485,17 @@ async function monitorTwitchProvider(options) {
|
|
|
300
485
|
runtime.error?.(`Failed to connect: ${errorMsg}`);
|
|
301
486
|
throw error;
|
|
302
487
|
}
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
488
|
+
const ingress = createTwitchIngress({
|
|
489
|
+
accountId,
|
|
490
|
+
runtime,
|
|
491
|
+
deliver: async (message, turnAdoptionLifecycle) => {
|
|
306
492
|
const botUsername = normalizeLowercaseStringOrEmpty(account.username);
|
|
307
493
|
if (normalizeLowercaseStringOrEmpty(message.username) === botUsername) return;
|
|
308
|
-
|
|
494
|
+
if (!(await checkTwitchAccessControl({
|
|
309
495
|
message,
|
|
310
496
|
account,
|
|
311
497
|
botUsername
|
|
312
|
-
});
|
|
313
|
-
if (stopped || !access.allowed) return;
|
|
498
|
+
})).allowed) return;
|
|
314
499
|
statusSink?.({ lastInboundAt: Date.now() });
|
|
315
500
|
await processTwitchMessage({
|
|
316
501
|
message,
|
|
@@ -319,17 +504,31 @@ async function monitorTwitchProvider(options) {
|
|
|
319
504
|
config,
|
|
320
505
|
runtime,
|
|
321
506
|
core,
|
|
507
|
+
turnAdoptionLifecycle,
|
|
322
508
|
statusSink
|
|
323
509
|
});
|
|
324
|
-
}
|
|
325
|
-
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
ingress.start();
|
|
513
|
+
const unregisterHandler = clientManager.onMessage(account, (message) => {
|
|
514
|
+
if (stopped) return;
|
|
515
|
+
ingress.accept(message).catch((err) => {
|
|
516
|
+
runtime.error?.(`Message durable admission failed: ${String(err)}`);
|
|
326
517
|
});
|
|
327
518
|
});
|
|
328
519
|
const stop = () => {
|
|
329
|
-
|
|
330
|
-
|
|
520
|
+
stopTask ??= (async () => {
|
|
521
|
+
stopped = true;
|
|
522
|
+
unregisterHandler();
|
|
523
|
+
await ingress.stop();
|
|
524
|
+
})();
|
|
525
|
+
return stopTask;
|
|
331
526
|
};
|
|
332
|
-
abortSignal.addEventListener("abort",
|
|
527
|
+
abortSignal.addEventListener("abort", () => {
|
|
528
|
+
stop().catch((error) => {
|
|
529
|
+
runtime.error?.(`Twitch ingress stop failed: ${String(error)}`);
|
|
530
|
+
});
|
|
531
|
+
}, { once: true });
|
|
333
532
|
return { stop };
|
|
334
533
|
}
|
|
335
534
|
//#endregion
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as DEFAULT_ACCOUNT_ID, c as resolveDefaultTwitchAccountId, d as generateMessageId, f as isAccountConfigured, g as resolveTwitchToken, h as normalizeTwitchChannel, i as twitchSetupWizard, l as resolveTwitchAccountContext, m as normalizeToken, n as twitchSetupContract, o as getAccountConfig, p as missingTargetError, s as listAccountIds, t as twitchSetupAdapter, u as resolveTwitchSnapshotAccountId } from "./setup-surface-CVAaMigx.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";
|
|
5
|
+
import { createMessageReceiptFromOutboundResults, defineChannelMessageAdapter, runPassiveAccountLifecycle } from "openclaw/plugin-sdk/channel-outbound";
|
|
5
6
|
import { createLoggedPairingApprovalNotifier, createPairingPrefixStripper } from "openclaw/plugin-sdk/channel-pairing";
|
|
6
|
-
import { buildPassiveProbedChannelStatusSummary
|
|
7
|
+
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
|
7
8
|
import { createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
8
9
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
9
10
|
import { normalizeLowercaseStringOrEmpty, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
|
-
import {
|
|
11
|
-
import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
|
|
11
|
+
import { chunkTextForOutbound, sanitizeAssistantVisibleText, stripMarkdown } from "openclaw/plugin-sdk/text-chunking";
|
|
12
12
|
import { RefreshingAuthProvider, StaticAuthProvider } from "@twurple/auth";
|
|
13
13
|
import { ChatClient, LogLevel } from "@twurple/chat";
|
|
14
14
|
import { sliceUtf16Safe, withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -186,18 +186,17 @@ var TwitchClientManager = class {
|
|
|
186
186
|
client.onMessage((channelName, _user, messageText, msg) => {
|
|
187
187
|
const handler = this.messageHandlers.get(key);
|
|
188
188
|
if (handler) {
|
|
189
|
-
const normalizedChannel = channelName.startsWith("#") ? channelName.slice(1) : channelName;
|
|
190
189
|
const from = `twitch:${msg.userInfo.userName}`;
|
|
191
190
|
const preview = sliceUtf16Safe(messageText, 0, 100).replace(/\n/g, "\\n");
|
|
192
|
-
this.logger.debug?.(`twitch inbound: channel=${
|
|
191
|
+
this.logger.debug?.(`twitch inbound: channel=${channelName} from=${from} len=${messageText.length} preview="${preview}"`);
|
|
193
192
|
handler({
|
|
194
193
|
username: msg.userInfo.userName,
|
|
195
194
|
displayName: msg.userInfo.displayName,
|
|
196
195
|
userId: msg.userInfo.userId,
|
|
197
196
|
message: messageText,
|
|
198
|
-
channel:
|
|
197
|
+
channel: channelName,
|
|
199
198
|
id: msg.id,
|
|
200
|
-
timestamp:
|
|
199
|
+
timestamp: Date.now(),
|
|
201
200
|
isMod: msg.userInfo.isMod,
|
|
202
201
|
isOwner: msg.userInfo.isBroadcaster,
|
|
203
202
|
isVip: msg.userInfo.isVip,
|
|
@@ -361,20 +360,10 @@ async function removeClientManager(accountId) {
|
|
|
361
360
|
* Markdown utilities for Twitch chat
|
|
362
361
|
*
|
|
363
362
|
* Twitch chat doesn't support markdown formatting, so we strip it before sending.
|
|
364
|
-
* Based on OpenClaw's markdownToText in src/agents/tools/web-fetch-utils.ts.
|
|
365
|
-
*/
|
|
366
|
-
/**
|
|
367
|
-
* Strip markdown formatting from text for Twitch compatibility.
|
|
368
|
-
*
|
|
369
|
-
* Removes images, links, bold, italic, strikethrough, code blocks, inline code,
|
|
370
|
-
* headers, and list formatting. Replaces newlines with spaces since Twitch
|
|
371
|
-
* is a single-line chat medium.
|
|
372
|
-
*
|
|
373
|
-
* @param markdown - The markdown text to strip
|
|
374
|
-
* @returns Plain text with markdown removed
|
|
375
363
|
*/
|
|
364
|
+
/** Strip markdown, then flatten newlines for Twitch's single-line chat. */
|
|
376
365
|
function stripMarkdownForTwitch(markdown) {
|
|
377
|
-
return markdown
|
|
366
|
+
return stripMarkdown(markdown, { linkStyle: "label-and-url" }).replace(/\r/g, "").replace(/[ \t]+\n/g, "\n").replace(/\n/g, " ").replace(/[ \t]{2,}/g, " ").trim();
|
|
378
367
|
}
|
|
379
368
|
/**
|
|
380
369
|
* Simple word-boundary chunker for Twitch (500 char limit).
|
|
@@ -1306,6 +1295,7 @@ const twitchPlugin = createChatChannelPlugin({
|
|
|
1306
1295
|
aliases: ["twitch-chat"]
|
|
1307
1296
|
},
|
|
1308
1297
|
setup: twitchSetupAdapter,
|
|
1298
|
+
setupContract: twitchSetupContract,
|
|
1309
1299
|
setupWizard: twitchSetupWizard,
|
|
1310
1300
|
capabilities: { chatTypes: ["group"] },
|
|
1311
1301
|
messaging: { resolveOutboundSessionRoute: ({ cfg, agentId, accountId, target }) => {
|
|
@@ -1400,10 +1390,10 @@ const twitchPlugin = createChatChannelPlugin({
|
|
|
1400
1390
|
});
|
|
1401
1391
|
ctx.log?.info(`Starting Twitch connection for ${account.username}`);
|
|
1402
1392
|
try {
|
|
1403
|
-
await
|
|
1393
|
+
await runPassiveAccountLifecycle({
|
|
1404
1394
|
abortSignal: ctx.abortSignal,
|
|
1405
1395
|
start: async () => {
|
|
1406
|
-
const { monitorTwitchProvider } = await import("./monitor-
|
|
1396
|
+
const { monitorTwitchProvider } = await import("./monitor-CQidEQhp.js");
|
|
1407
1397
|
return monitorTwitchProvider({
|
|
1408
1398
|
account,
|
|
1409
1399
|
accountId,
|
|
@@ -1411,6 +1401,9 @@ const twitchPlugin = createChatChannelPlugin({
|
|
|
1411
1401
|
runtime: ctx.runtime,
|
|
1412
1402
|
abortSignal: ctx.abortSignal
|
|
1413
1403
|
});
|
|
1404
|
+
},
|
|
1405
|
+
stop: async (monitor) => {
|
|
1406
|
+
await monitor.stop();
|
|
1414
1407
|
}
|
|
1415
1408
|
});
|
|
1416
1409
|
} catch (error) {
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as twitchSetupPlugin } from "./setup-surface-CVAaMigx.js";
|
|
2
2
|
export { twitchSetupPlugin };
|
|
@@ -2,6 +2,7 @@ import { DEFAULT_ACCOUNT_ID, listCombinedAccountIds, normalizeAccountId, resolve
|
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { normalizeLowercaseStringOrEmpty, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { normalizeOptionalAccountId } from "openclaw/plugin-sdk/account-id";
|
|
5
|
+
import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
|
|
5
6
|
import { getChatChannelMeta } from "openclaw/plugin-sdk/core";
|
|
6
7
|
import { createSetupTranslator, formatDocsLink, normalizeAccountId as normalizeAccountId$1, setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
|
|
7
8
|
//#region extensions/twitch/src/token.ts
|
|
@@ -427,9 +428,14 @@ const twitchGroupAccess = {
|
|
|
427
428
|
applyAllowlist: ({ cfg }) => cfg
|
|
428
429
|
};
|
|
429
430
|
const twitchSetupAdapter = {
|
|
431
|
+
singleAccountKeysToMove: ["accessToken"],
|
|
430
432
|
resolveAccountId: ({ cfg }) => resolveSetupAccountId(cfg),
|
|
431
433
|
applyAccountConfig: ({ cfg, accountId }) => setTwitchAccount(cfg, { enabled: true }, accountId)
|
|
432
434
|
};
|
|
435
|
+
const twitchSetupContract = defineChannelSetupContract({
|
|
436
|
+
fields: {},
|
|
437
|
+
legacyAdapter: twitchSetupAdapter
|
|
438
|
+
});
|
|
433
439
|
const twitchSetupWizard = {
|
|
434
440
|
channel,
|
|
435
441
|
resolveAccountIdForConfigure: ({ cfg, accountOverride }) => resolveSetupAccountId(cfg, accountOverride),
|
|
@@ -509,7 +515,8 @@ const twitchSetupPlugin = {
|
|
|
509
515
|
isEnabled: (account) => account.enabled !== false
|
|
510
516
|
},
|
|
511
517
|
setup: twitchSetupAdapter,
|
|
518
|
+
setupContract: twitchSetupContract,
|
|
512
519
|
setupWizard: twitchSetupWizard
|
|
513
520
|
};
|
|
514
521
|
//#endregion
|
|
515
|
-
export {
|
|
522
|
+
export { DEFAULT_ACCOUNT_ID$1 as a, resolveDefaultTwitchAccountId as c, generateMessageId as d, isAccountConfigured as f, resolveTwitchToken as g, normalizeTwitchChannel as h, twitchSetupWizard as i, resolveTwitchAccountContext as l, normalizeToken as m, twitchSetupContract as n, getAccountConfig as o, missingTargetError as p, twitchSetupPlugin as r, listAccountIds as s, twitchSetupAdapter as t, resolveTwitchSnapshotAccountId as u };
|
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated: Wed,
|
|
11
|
+
* Last updated: Wed, 08 Jul 2026 06:47:45 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
|
@@ -153,7 +153,11 @@ declare module "node:fs/promises" {
|
|
|
153
153
|
* @return Fulfills with `undefined` upon success.
|
|
154
154
|
*/
|
|
155
155
|
appendFile(
|
|
156
|
-
data:
|
|
156
|
+
data:
|
|
157
|
+
| string
|
|
158
|
+
| NodeJS.ArrayBufferView
|
|
159
|
+
| Iterable<string | NodeJS.ArrayBufferView>
|
|
160
|
+
| AsyncIterable<string | NodeJS.ArrayBufferView>,
|
|
157
161
|
options?:
|
|
158
162
|
| (ObjectEncodingOptions & Abortable)
|
|
159
163
|
| BufferEncoding
|
|
@@ -470,7 +474,11 @@ declare module "node:fs/promises" {
|
|
|
470
474
|
* @since v10.0.0
|
|
471
475
|
*/
|
|
472
476
|
writeFile(
|
|
473
|
-
data:
|
|
477
|
+
data:
|
|
478
|
+
| string
|
|
479
|
+
| NodeJS.ArrayBufferView
|
|
480
|
+
| Iterable<string | NodeJS.ArrayBufferView>
|
|
481
|
+
| AsyncIterable<string | NodeJS.ArrayBufferView>,
|
|
474
482
|
options?:
|
|
475
483
|
| (ObjectEncodingOptions & Abortable)
|
|
476
484
|
| BufferEncoding
|
|
@@ -1208,8 +1216,7 @@ declare module "node:fs/promises" {
|
|
|
1208
1216
|
| string
|
|
1209
1217
|
| NodeJS.ArrayBufferView
|
|
1210
1218
|
| Iterable<string | NodeJS.ArrayBufferView>
|
|
1211
|
-
| AsyncIterable<string | NodeJS.ArrayBufferView
|
|
1212
|
-
| Stream,
|
|
1219
|
+
| AsyncIterable<string | NodeJS.ArrayBufferView>,
|
|
1213
1220
|
options?:
|
|
1214
1221
|
| (ObjectEncodingOptions & {
|
|
1215
1222
|
mode?: Mode | undefined;
|
|
@@ -1240,7 +1247,11 @@ declare module "node:fs/promises" {
|
|
|
1240
1247
|
*/
|
|
1241
1248
|
function appendFile(
|
|
1242
1249
|
path: PathLike | FileHandle,
|
|
1243
|
-
data:
|
|
1250
|
+
data:
|
|
1251
|
+
| string
|
|
1252
|
+
| NodeJS.ArrayBufferView
|
|
1253
|
+
| Iterable<string | NodeJS.ArrayBufferView>
|
|
1254
|
+
| AsyncIterable<string | NodeJS.ArrayBufferView>,
|
|
1244
1255
|
options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null,
|
|
1245
1256
|
): Promise<void>;
|
|
1246
1257
|
/**
|
|
@@ -1432,7 +1443,6 @@ declare module "node:fs/promises" {
|
|
|
1432
1443
|
* When copying a directory to another directory, globs are not supported and
|
|
1433
1444
|
* behavior is similar to `cp dir1/ dir2/`.
|
|
1434
1445
|
* @since v16.7.0
|
|
1435
|
-
* @experimental
|
|
1436
1446
|
* @param src source path to copy.
|
|
1437
1447
|
* @param dest destination path to copy to.
|
|
1438
1448
|
* @return Fulfills with `undefined` upon success.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "26.1.
|
|
3
|
+
"version": "26.1.1",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -150,6 +150,6 @@
|
|
|
150
150
|
"undici-types": "~8.3.0"
|
|
151
151
|
},
|
|
152
152
|
"peerDependencies": {},
|
|
153
|
-
"typesPublisherContentHash": "
|
|
153
|
+
"typesPublisherContentHash": "a59119b073061829bc67a5bf6bc2b8ecb0a5a6196058e3c73172a00440f4e16d",
|
|
154
154
|
"typeScriptVersion": "5.6"
|
|
155
155
|
}
|
|
@@ -77,6 +77,7 @@ class Receiver extends Writable {
|
|
|
77
77
|
|
|
78
78
|
this._totalPayloadLength = 0;
|
|
79
79
|
this._messageLength = 0;
|
|
80
|
+
this._numFragments = 0;
|
|
80
81
|
this._fragments = [];
|
|
81
82
|
|
|
82
83
|
this._errored = false;
|
|
@@ -500,6 +501,19 @@ class Receiver extends Writable {
|
|
|
500
501
|
return;
|
|
501
502
|
}
|
|
502
503
|
|
|
504
|
+
if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
|
|
505
|
+
const error = this.createError(
|
|
506
|
+
RangeError,
|
|
507
|
+
'Too many message fragments',
|
|
508
|
+
false,
|
|
509
|
+
1008,
|
|
510
|
+
'WS_ERR_TOO_MANY_BUFFERED_PARTS'
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
cb(error);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
503
517
|
if (this._compressed) {
|
|
504
518
|
this._state = INFLATING;
|
|
505
519
|
this.decompress(data, cb);
|
|
@@ -507,22 +521,6 @@ class Receiver extends Writable {
|
|
|
507
521
|
}
|
|
508
522
|
|
|
509
523
|
if (data.length) {
|
|
510
|
-
if (
|
|
511
|
-
this._maxFragments > 0 &&
|
|
512
|
-
this._fragments.length >= this._maxFragments
|
|
513
|
-
) {
|
|
514
|
-
const error = this.createError(
|
|
515
|
-
RangeError,
|
|
516
|
-
'Too many message fragments',
|
|
517
|
-
false,
|
|
518
|
-
1008,
|
|
519
|
-
'WS_ERR_TOO_MANY_BUFFERED_PARTS'
|
|
520
|
-
);
|
|
521
|
-
|
|
522
|
-
cb(error);
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
524
|
//
|
|
527
525
|
// This message is not compressed so its length is the sum of the payload
|
|
528
526
|
// length of all fragments.
|
|
@@ -562,22 +560,6 @@ class Receiver extends Writable {
|
|
|
562
560
|
return;
|
|
563
561
|
}
|
|
564
562
|
|
|
565
|
-
if (
|
|
566
|
-
this._maxFragments > 0 &&
|
|
567
|
-
this._fragments.length >= this._maxFragments
|
|
568
|
-
) {
|
|
569
|
-
const error = this.createError(
|
|
570
|
-
RangeError,
|
|
571
|
-
'Too many message fragments',
|
|
572
|
-
false,
|
|
573
|
-
1008,
|
|
574
|
-
'WS_ERR_TOO_MANY_BUFFERED_PARTS'
|
|
575
|
-
);
|
|
576
|
-
|
|
577
|
-
cb(error);
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
563
|
this._fragments.push(buf);
|
|
582
564
|
}
|
|
583
565
|
|
|
@@ -604,6 +586,7 @@ class Receiver extends Writable {
|
|
|
604
586
|
this._totalPayloadLength = 0;
|
|
605
587
|
this._messageLength = 0;
|
|
606
588
|
this._fragmented = 0;
|
|
589
|
+
this._numFragments = 0;
|
|
607
590
|
this._fragments = [];
|
|
608
591
|
|
|
609
592
|
if (this._opcode === 2) {
|
|
@@ -43,9 +43,9 @@ class WebSocketServer extends EventEmitter {
|
|
|
43
43
|
* called
|
|
44
44
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
45
45
|
* @param {String} [options.host] The hostname where to bind the server
|
|
46
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
46
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
47
47
|
* buffered data chunks
|
|
48
|
-
* @param {Number} [options.maxFragments=
|
|
48
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
49
49
|
* fragments
|
|
50
50
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
51
51
|
* size
|
|
@@ -69,8 +69,8 @@ class WebSocketServer extends EventEmitter {
|
|
|
69
69
|
options = {
|
|
70
70
|
allowSynchronousEvents: true,
|
|
71
71
|
autoPong: true,
|
|
72
|
-
maxBufferedChunks:
|
|
73
|
-
maxFragments:
|
|
72
|
+
maxBufferedChunks: 256 * 1024,
|
|
73
|
+
maxFragments: 16 * 1024,
|
|
74
74
|
maxPayload: 100 * 1024 * 1024,
|
|
75
75
|
skipUTF8Validation: false,
|
|
76
76
|
perMessageDeflate: false,
|
|
@@ -646,9 +646,9 @@ module.exports = WebSocket;
|
|
|
646
646
|
* masking key
|
|
647
647
|
* @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
|
|
648
648
|
* handshake request
|
|
649
|
-
* @param {Number} [options.maxBufferedChunks=
|
|
649
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
650
650
|
* buffered data chunks
|
|
651
|
-
* @param {Number} [options.maxFragments=
|
|
651
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
652
652
|
* fragments
|
|
653
653
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
654
654
|
* size
|
|
@@ -670,8 +670,8 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
670
670
|
autoPong: true,
|
|
671
671
|
closeTimeout: CLOSE_TIMEOUT,
|
|
672
672
|
protocolVersion: protocolVersions[1],
|
|
673
|
-
maxBufferedChunks:
|
|
674
|
-
maxFragments:
|
|
673
|
+
maxBufferedChunks: 256 * 1024,
|
|
674
|
+
maxFragments: 16 * 1024,
|
|
675
675
|
maxPayload: 100 * 1024 * 1024,
|
|
676
676
|
skipUTF8Validation: false,
|
|
677
677
|
perMessageDeflate: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ws",
|
|
3
|
-
"version": "8.21.
|
|
3
|
+
"version": "8.21.1",
|
|
4
4
|
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"HyBi",
|
|
@@ -66,5 +66,9 @@
|
|
|
66
66
|
"nyc": "^15.0.0",
|
|
67
67
|
"prettier": "^3.0.0",
|
|
68
68
|
"utf-8-validate": "^6.0.0"
|
|
69
|
+
},
|
|
70
|
+
"allowScripts": {
|
|
71
|
+
"bufferutil": true,
|
|
72
|
+
"utf-8-validate": true
|
|
69
73
|
}
|
|
70
74
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/twitch",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/twitch",
|
|
9
|
-
"version": "2026.7.2-beta.
|
|
9
|
+
"version": "2026.7.2-beta.4",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@twurple/api-call": "8.1.4",
|
|
12
12
|
"@twurple/auth": "8.1.4",
|
|
@@ -212,9 +212,9 @@
|
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
"node_modules/@types/ws/node_modules/@types/node": {
|
|
215
|
-
"version": "26.1.
|
|
216
|
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.
|
|
217
|
-
"integrity": "sha512-
|
|
215
|
+
"version": "26.1.1",
|
|
216
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.1.tgz",
|
|
217
|
+
"integrity": "sha512-nxAkRSVkN1Y0JC1W8ky/fTfkGsMmcrRsbx+3XoZE+rMOX71kLYTV7fLXpqud1GpbpP5TuffXFqfX7fH2GgZREw==",
|
|
218
218
|
"license": "MIT",
|
|
219
219
|
"dependencies": {
|
|
220
220
|
"undici-types": "~8.3.0"
|
|
@@ -266,9 +266,9 @@
|
|
|
266
266
|
"license": "MIT"
|
|
267
267
|
},
|
|
268
268
|
"node_modules/ws": {
|
|
269
|
-
"version": "8.21.
|
|
270
|
-
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.
|
|
271
|
-
"integrity": "sha512
|
|
269
|
+
"version": "8.21.1",
|
|
270
|
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.1.tgz",
|
|
271
|
+
"integrity": "sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw==",
|
|
272
272
|
"license": "MIT",
|
|
273
273
|
"engines": {
|
|
274
274
|
"node": ">=10.0.0"
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/twitch",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.4",
|
|
4
4
|
"description": "OpenClaw Twitch channel plugin for chat and moderation workflows.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,26 +18,39 @@
|
|
|
18
18
|
"./index.ts"
|
|
19
19
|
],
|
|
20
20
|
"setupEntry": "./dist/setup-entry.js",
|
|
21
|
+
"setupFeatures": {
|
|
22
|
+
"configPromotion": true
|
|
23
|
+
},
|
|
21
24
|
"install": {
|
|
22
25
|
"npmSpec": "@openclaw/twitch",
|
|
23
26
|
"defaultChoice": "npm",
|
|
24
27
|
"minHostVersion": ">=2026.4.10"
|
|
25
28
|
},
|
|
26
29
|
"compat": {
|
|
27
|
-
"pluginApi": ">=2026.7.2-beta.
|
|
30
|
+
"pluginApi": ">=2026.7.2-beta.4"
|
|
28
31
|
},
|
|
29
32
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.7.2-beta.
|
|
33
|
+
"openclawVersion": "2026.7.2-beta.4"
|
|
31
34
|
},
|
|
32
35
|
"channel": {
|
|
33
36
|
"id": "twitch",
|
|
37
|
+
"configuredState": {
|
|
38
|
+
"env": {
|
|
39
|
+
"anyOf": [
|
|
40
|
+
"OPENCLAW_TWITCH_ACCESS_TOKEN"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
34
44
|
"label": "Twitch",
|
|
35
45
|
"selectionLabel": "Twitch (Chat)",
|
|
36
46
|
"docsPath": "/channels/twitch",
|
|
37
47
|
"blurb": "Twitch chat integration",
|
|
38
48
|
"aliases": [
|
|
39
49
|
"twitch-chat"
|
|
40
|
-
]
|
|
50
|
+
],
|
|
51
|
+
"setup": {
|
|
52
|
+
"fields": []
|
|
53
|
+
}
|
|
41
54
|
},
|
|
42
55
|
"release": {
|
|
43
56
|
"publishToClawHub": true,
|
|
@@ -55,7 +68,7 @@
|
|
|
55
68
|
"README.md"
|
|
56
69
|
],
|
|
57
70
|
"peerDependencies": {
|
|
58
|
-
"openclaw": ">=2026.7.2-beta.
|
|
71
|
+
"openclaw": ">=2026.7.2-beta.4"
|
|
59
72
|
},
|
|
60
73
|
"peerDependenciesMeta": {
|
|
61
74
|
"openclaw": {
|