diff --git a/extensions/twitch/package.json b/extensions/twitch/package.json index 2412de1b605..a47e9cb9238 100644 --- a/extensions/twitch/package.json +++ b/extensions/twitch/package.json @@ -15,6 +15,7 @@ "extensions": [ "./index.ts" ], + "setupEntry": "./setup-entry.ts", "install": { "minHostVersion": ">=2026.4.10" }, diff --git a/extensions/twitch/setup-entry.ts b/extensions/twitch/setup-entry.ts new file mode 100644 index 00000000000..c4f4957c76c --- /dev/null +++ b/extensions/twitch/setup-entry.ts @@ -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", + }, +}); diff --git a/extensions/twitch/src/setup-surface.ts b/extensions/twitch/src/setup-surface.ts index 45e60372be1..d432666fc7a 100644 --- a/extensions/twitch/src/setup-surface.ts +++ b/extensions/twitch/src/setup-surface.ts @@ -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 = { + 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, +};