refactor: retire discord bridge ownership
This commit is contained in:
parent
4390533672
commit
342d16404e
1
extensions/discord/account-api.ts
Normal file
1
extensions/discord/account-api.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./src/accounts.js";
|
||||
@ -1,12 +1,12 @@
|
||||
import {
|
||||
createAccountActionGate,
|
||||
createAccountListHelpers,
|
||||
normalizeAccountId,
|
||||
resolveAccountEntry,
|
||||
type OpenClawConfig,
|
||||
type DiscordAccountConfig,
|
||||
type DiscordActionConfig,
|
||||
} from "./runtime-api.js";
|
||||
import { createAccountActionGate } from "openclaw/plugin-sdk/account-action-gate";
|
||||
import { createAccountListHelpers } from "openclaw/plugin-sdk/account-helpers";
|
||||
import { normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
||||
import type {
|
||||
DiscordAccountConfig,
|
||||
DiscordActionConfig,
|
||||
OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/discord-core";
|
||||
import { resolveAccountEntry } from "openclaw/plugin-sdk/routing";
|
||||
import { resolveDiscordToken } from "./token.js";
|
||||
|
||||
export type ResolvedDiscordAccount = {
|
||||
|
||||
@ -362,6 +362,10 @@
|
||||
"types": "./dist/plugin-sdk/zalouser.d.ts",
|
||||
"default": "./dist/plugin-sdk/zalouser.js"
|
||||
},
|
||||
"./plugin-sdk/account-action-gate": {
|
||||
"types": "./dist/plugin-sdk/account-action-gate.d.ts",
|
||||
"default": "./dist/plugin-sdk/account-action-gate.js"
|
||||
},
|
||||
"./plugin-sdk/account-helpers": {
|
||||
"types": "./dist/plugin-sdk/account-helpers.d.ts",
|
||||
"default": "./dist/plugin-sdk/account-helpers.js"
|
||||
|
||||
@ -80,6 +80,7 @@
|
||||
"voice-call",
|
||||
"zalo",
|
||||
"zalouser",
|
||||
"account-action-gate",
|
||||
"account-helpers",
|
||||
"account-id",
|
||||
"account-resolution",
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
export type {
|
||||
DiscordPluralKitConfig,
|
||||
DiscordSendComponents,
|
||||
DiscordSendEmbeds,
|
||||
InspectedDiscordAccount,
|
||||
ResolvedDiscordAccount,
|
||||
} from "../../../extensions/discord/api.js";
|
||||
|
||||
export {
|
||||
inspectDiscordAccount,
|
||||
listDiscordAccountIds,
|
||||
resolveDiscordAccount,
|
||||
resolveDefaultDiscordAccountId,
|
||||
resolveDiscordGroupRequireMention,
|
||||
resolveDiscordGroupToolPolicy,
|
||||
} from "../../../extensions/discord/api.js";
|
||||
export {
|
||||
fetchVoiceStatusDiscord,
|
||||
getGateway,
|
||||
getPresence,
|
||||
hasAnyGuildPermissionDiscord,
|
||||
kickMemberDiscord,
|
||||
monitorDiscordProvider,
|
||||
unpinMessageDiscord,
|
||||
} from "../../../extensions/discord/runtime-api.js";
|
||||
1
src/plugin-sdk/account-action-gate.ts
Normal file
1
src/plugin-sdk/account-action-gate.ts
Normal file
@ -0,0 +1 @@
|
||||
export { createAccountActionGate } from "../channels/plugins/account-action-gate.js";
|
||||
@ -1,3 +1,8 @@
|
||||
import {
|
||||
resolveDiscordAccount as resolveDiscordAccountImpl,
|
||||
type ResolvedDiscordAccount as DiscordResolvedDiscordAccount,
|
||||
} from "../../extensions/discord/account-api.js";
|
||||
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
|
||||
export { createAccountActionGate } from "../channels/plugins/account-action-gate.js";
|
||||
@ -10,10 +15,6 @@ export {
|
||||
normalizeOptionalAccountId,
|
||||
} from "../routing/session-key.js";
|
||||
export { normalizeE164, pathExists, resolveUserPath } from "../utils.js";
|
||||
export {
|
||||
resolveDiscordAccount,
|
||||
type ResolvedDiscordAccount,
|
||||
} from "../channels/discord/plugin-sdk-bridge.js";
|
||||
export {
|
||||
resolveSlackAccount,
|
||||
type ResolvedSlackAccount,
|
||||
@ -27,6 +28,14 @@ export {
|
||||
type ResolvedSignalAccount,
|
||||
} from "../channels/signal/plugin-sdk-bridge.js";
|
||||
|
||||
export type ResolvedDiscordAccount = DiscordResolvedDiscordAccount;
|
||||
|
||||
export function resolveDiscordAccount(
|
||||
...args: Parameters<typeof resolveDiscordAccountImpl>
|
||||
): ReturnType<typeof resolveDiscordAccountImpl> {
|
||||
return resolveDiscordAccountImpl(...args);
|
||||
}
|
||||
|
||||
/** Resolve an account by id, then fall back to the default account when the primary lacks credentials. */
|
||||
export function resolveAccountWithDefaultFallback<TAccount>(params: {
|
||||
accountId?: string | null;
|
||||
|
||||
@ -444,6 +444,14 @@ describe("channel import guardrails", () => {
|
||||
expect(text).toMatch(/from\s+"..\/..\/extensions\/discord\/runtime-api\.js";/);
|
||||
});
|
||||
|
||||
it("keeps plugin-sdk/discord off the Discord bridge entirely", () => {
|
||||
const text = readSource("src/plugin-sdk/discord.ts");
|
||||
expect(text).not.toMatch(/plugin-sdk-bridge\.js/);
|
||||
expect(text).toMatch(/from\s+"..\/..\/extensions\/discord\/api\.js";/);
|
||||
expect(text).toMatch(/from\s+"..\/..\/extensions\/discord\/runtime-api\.js";/);
|
||||
expect(text).toMatch(/from\s+"..\/..\/extensions\/discord\/session-key-api\.js";/);
|
||||
});
|
||||
|
||||
it("keeps channel helper modules off their own SDK barrels", () => {
|
||||
for (const source of SAME_CHANNEL_SDK_GUARDS) {
|
||||
const text = readSource(source.path);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
export type { ChannelPlugin } from "./channel-plugin-common.js";
|
||||
export type { DiscordActionConfig } from "../config/types.js";
|
||||
export type { DiscordAccountConfig, DiscordActionConfig } from "../config/types.js";
|
||||
export { buildChannelConfigSchema, getChatChannelMeta } from "./channel-plugin-common.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export { withNormalizedTimestamp } from "../agents/date-time.js";
|
||||
|
||||
@ -1,13 +1,25 @@
|
||||
import {
|
||||
createDiscordActionGate,
|
||||
collectDiscordStatusIssues,
|
||||
inspectDiscordAccount,
|
||||
listDiscordDirectoryGroupsFromConfig,
|
||||
listDiscordDirectoryPeersFromConfig,
|
||||
listDiscordAccountIds,
|
||||
looksLikeDiscordTargetId,
|
||||
normalizeDiscordMessagingTarget,
|
||||
normalizeDiscordOutboundTarget,
|
||||
readDiscordComponentSpec,
|
||||
resolveDefaultDiscordAccountId,
|
||||
resolveDiscordChannelId,
|
||||
resolveDiscordGroupRequireMention,
|
||||
resolveDiscordGroupToolPolicy,
|
||||
} from "../../extensions/discord/api.js";
|
||||
import type {
|
||||
DiscordPluralKitConfig,
|
||||
DiscordSendComponents,
|
||||
DiscordSendEmbeds,
|
||||
InspectedDiscordAccount,
|
||||
ResolvedDiscordAccount,
|
||||
} from "../../extensions/discord/api.js";
|
||||
import type {
|
||||
ThreadBindingManager,
|
||||
@ -38,6 +50,8 @@ import {
|
||||
getGateway,
|
||||
getPresence,
|
||||
getThreadBindingManager,
|
||||
hasAnyGuildPermissionDiscord,
|
||||
kickMemberDiscord,
|
||||
listDiscordDirectoryGroupsLive,
|
||||
listDiscordDirectoryPeersLive,
|
||||
listThreadBindingsBySessionKey,
|
||||
@ -74,31 +88,13 @@ import {
|
||||
setChannelPermissionDiscord,
|
||||
timeoutMemberDiscord,
|
||||
unbindThreadBindingsBySessionKey,
|
||||
unpinMessageDiscord,
|
||||
uploadEmojiDiscord,
|
||||
uploadStickerDiscord,
|
||||
readMessagesDiscord,
|
||||
searchMessagesDiscord,
|
||||
} from "../../extensions/discord/runtime-api.js";
|
||||
import { normalizeExplicitDiscordSessionKey } from "../../extensions/discord/session-key-api.js";
|
||||
import type {
|
||||
DiscordPluralKitConfig,
|
||||
DiscordSendComponents,
|
||||
DiscordSendEmbeds,
|
||||
InspectedDiscordAccount,
|
||||
ResolvedDiscordAccount,
|
||||
} from "../channels/discord/plugin-sdk-bridge.js";
|
||||
import {
|
||||
inspectDiscordAccount,
|
||||
listDiscordAccountIds,
|
||||
resolveDefaultDiscordAccountId,
|
||||
resolveDiscordGroupRequireMention,
|
||||
resolveDiscordGroupToolPolicy,
|
||||
} from "../channels/discord/plugin-sdk-bridge.js";
|
||||
import {
|
||||
hasAnyGuildPermissionDiscord,
|
||||
kickMemberDiscord,
|
||||
unpinMessageDiscord,
|
||||
} from "../channels/discord/plugin-sdk-bridge.js";
|
||||
|
||||
export type {
|
||||
ChannelAccountSnapshot,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user