mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-25 00:42:24 +00:00
Move all Slack channel implementation files from src/slack/ to extensions/slack/src/ and replace originals with shim re-exports. This follows the extension migration pattern for channel plugins. - Copy all .ts files to extensions/slack/src/ (preserving directory structure: monitor/, http/, monitor/events/, monitor/message-handler/) - Transform import paths: external src/ imports use relative paths back to src/, internal slack imports stay relative within extension - Replace all src/slack/ files with shim re-exports pointing to the extension copies - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." so the DTS build can follow shim chains into extensions/ - Update write-plugin-sdk-entry-dts.ts re-export path accordingly - Preserve extensions/slack/index.ts, package.json, openclaw.plugin.json, src/channel.ts, src/runtime.ts, src/channel.test.ts (untouched)
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import type { BaseProbeResult } from "../../../src/channels/plugins/types.js";
|
|
import { withTimeout } from "../../../src/utils/with-timeout.js";
|
|
import { createSlackWebClient } from "./client.js";
|
|
|
|
export type SlackProbe = BaseProbeResult & {
|
|
status?: number | null;
|
|
elapsedMs?: number | null;
|
|
bot?: { id?: string; name?: string };
|
|
team?: { id?: string; name?: string };
|
|
};
|
|
|
|
export async function probeSlack(token: string, timeoutMs = 2500): Promise<SlackProbe> {
|
|
const client = createSlackWebClient(token);
|
|
const start = Date.now();
|
|
try {
|
|
const result = await withTimeout(client.auth.test(), timeoutMs);
|
|
if (!result.ok) {
|
|
return {
|
|
ok: false,
|
|
status: 200,
|
|
error: result.error ?? "unknown",
|
|
elapsedMs: Date.now() - start,
|
|
};
|
|
}
|
|
return {
|
|
ok: true,
|
|
status: 200,
|
|
elapsedMs: Date.now() - start,
|
|
bot: { id: result.user_id, name: result.user },
|
|
team: { id: result.team_id, name: result.team },
|
|
};
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : String(err);
|
|
const status =
|
|
typeof (err as { status?: number }).status === "number"
|
|
? (err as { status?: number }).status
|
|
: null;
|
|
return {
|
|
ok: false,
|
|
status,
|
|
error: message,
|
|
elapsedMs: Date.now() - start,
|
|
};
|
|
}
|
|
}
|