Twitch: add bundled setup entry

This commit is contained in:
Gustavo Madeira Santana
2026-04-17 02:14:53 -04:00
parent aaf9064a75
commit 57bb717daf
3 changed files with 45 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
"extensions": [
"./index.ts"
],
"setupEntry": "./setup-entry.ts",
"install": {
"minHostVersion": ">=2026.4.10"
},

View File

@@ -0,0 +1,9 @@
import { defineBundledChannelSetupEntry } from "openclaw/plugin-sdk/channel-entry-contract";
export default defineBundledChannelSetupEntry({
importMetaUrl: import.meta.url,
plugin: {
specifier: "./src/setup-surface.js",
exportName: "twitchSetupPlugin",
},
});

View File

@@ -2,6 +2,7 @@
* Twitch setup wizard surface for CLI setup.
*/
import { getChatChannelMeta, type ChannelPlugin } from "openclaw/plugin-sdk/core";
import {
formatDocsLink,
type ChannelSetupAdapter,
@@ -426,3 +427,37 @@ export const twitchSetupWizard: ChannelSetupWizard = {
};
},
};
type ResolvedTwitchAccount = TwitchAccountConfig & { accountId?: string | null };
export const twitchSetupPlugin: ChannelPlugin<ResolvedTwitchAccount> = {
id: channel,
meta: getChatChannelMeta(channel),
capabilities: {
chatTypes: ["group"],
},
config: {
listAccountIds: (cfg) => {
const accountId = resolveSetupAccountId(cfg);
return getAccountConfig(cfg, accountId) ? [accountId] : [];
},
resolveAccount: (cfg, accountId) => {
const resolvedAccountId = accountId ?? resolveSetupAccountId(cfg);
const account = getAccountConfig(cfg, resolvedAccountId);
const fallback = {
accountId: resolvedAccountId,
username: "",
accessToken: "",
clientId: "",
channel: "",
enabled: false,
};
return account ? { ...fallback, ...account } : fallback;
},
defaultAccountId: (cfg) => resolveSetupAccountId(cfg),
isConfigured: (account) => isAccountConfigured(account),
isEnabled: (account) => account.enabled !== false,
},
setup: twitchSetupAdapter,
setupWizard: twitchSetupWizard,
};