TypeScript: add extensions to tsconfig and fix type errors (#12781)

* TypeScript: add extensions to tsconfig and fix type errors

- Add extensions/**/* to tsconfig.json includes
- Export ProviderAuthResult, AnyAgentTool from plugin-sdk
- Fix optional chaining for messageActions across channels
- Add missing type imports (MSTeamsConfig, GroupPolicy, etc.)
- Add type annotations for provider auth handlers
- Fix undici/fetch type compatibility in zalo proxy
- Correct ChannelAccountSnapshot property usage
- Add type casts for tool registrations
- Extract usage view styles and types to separate files

* TypeScript: fix optional debug calls and handleAction guards
This commit is contained in:
max
2026-02-09 10:05:38 -08:00
committed by GitHub
parent 2e4334c32c
commit 40b11db80e
87 changed files with 2947 additions and 2706 deletions

View File

@@ -15,7 +15,7 @@ function errorResponse(error: string) {
return {
content: [
{
type: "text",
type: "text" as const,
text: JSON.stringify({ ok: false, error }),
},
],
@@ -120,11 +120,12 @@ export const twitchMessageActions: ChannelMessageActionAdapter = {
* accountId: "default",
* });
*/
handleAction: async (
ctx: ChannelMessageActionContext,
): Promise<{ content: Array<{ type: string; text: string }> } | null> => {
handleAction: async (ctx: ChannelMessageActionContext) => {
if (ctx.action !== "send") {
return null;
return {
content: [{ type: "text" as const, text: "Unsupported action" }],
details: { ok: false, error: "Unsupported action" },
};
}
const message = readStringParam(ctx.params, "message", { required: true });
@@ -159,7 +160,7 @@ export const twitchMessageActions: ChannelMessageActionAdapter = {
return {
content: [
{
type: "text",
type: "text" as const,
text: JSON.stringify(result),
},
],

View File

@@ -104,7 +104,8 @@ export const twitchOutbound: ChannelOutboundAdapter = {
* });
*/
sendText: async (params: ChannelOutboundContext): Promise<OutboundDeliveryResult> => {
const { cfg, to, text, accountId, signal } = params;
const { cfg, to, text, accountId } = params;
const signal = (params as { signal?: AbortSignal }).signal;
if (signal?.aborted) {
throw new Error("Outbound delivery aborted");
@@ -142,7 +143,6 @@ export const twitchOutbound: ChannelOutboundAdapter = {
channel: "twitch",
messageId: result.messageId,
timestamp: Date.now(),
to: normalizeTwitchChannel(channel),
};
},
@@ -165,7 +165,8 @@ export const twitchOutbound: ChannelOutboundAdapter = {
* });
*/
sendMedia: async (params: ChannelOutboundContext): Promise<OutboundDeliveryResult> => {
const { text, mediaUrl, signal } = params;
const { text, mediaUrl } = params;
const signal = (params as { signal?: AbortSignal }).signal;
if (signal?.aborted) {
throw new Error("Outbound delivery aborted");

View File

@@ -27,16 +27,16 @@ export async function probeTwitch(
): Promise<ProbeTwitchResult> {
const started = Date.now();
if (!account.token || !account.username) {
if (!account.accessToken || !account.username) {
return {
ok: false,
error: "missing credentials (token, username)",
error: "missing credentials (accessToken, username)",
username: account.username,
elapsedMs: Date.now() - started,
};
}
const rawToken = normalizeToken(account.token.trim());
const rawToken = normalizeToken(account.accessToken.trim());
let client: ChatClient | undefined;

View File

@@ -51,8 +51,8 @@ export async function resolveTwitchTargets(
): Promise<ChannelResolveResult[]> {
const log = createLogger(logger);
if (!account.clientId || !account.token) {
log.error("Missing Twitch client ID or token");
if (!account.clientId || !account.accessToken) {
log.error("Missing Twitch client ID or accessToken");
return inputs.map((input) => ({
input,
resolved: false,
@@ -60,7 +60,7 @@ export async function resolveTwitchTargets(
}));
}
const normalizedToken = normalizeToken(account.token);
const normalizedToken = normalizeToken(account.accessToken);
const authProvider = new StaticAuthProvider(account.clientId, normalizedToken);
const apiClient = new ApiClient({ authProvider });

View File

@@ -4,7 +4,8 @@
* Detects and reports configuration issues for Twitch accounts.
*/
import type { ChannelAccountSnapshot, ChannelStatusIssue } from "./types.js";
import type { ChannelStatusIssue } from "openclaw/plugin-sdk";
import type { ChannelAccountSnapshot } from "./types.js";
import { getAccountConfig } from "./config.js";
import { resolveTwitchToken } from "./token.js";
import { isAccountConfigured } from "./utils/twitch.js";