mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 10:40:20 +00:00
fix(ci): restore extension runtime seams
This commit is contained in:
@@ -98,6 +98,22 @@ function resolveRuntimeDiscordMessageActions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveOptionalDiscordRuntime() {
|
||||||
|
try {
|
||||||
|
return getDiscordRuntime();
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveDiscordSend(deps?: { [channelId: string]: unknown }): DiscordSendFn {
|
||||||
|
return (
|
||||||
|
resolveOutboundSendDep<DiscordSendFn>(deps, "discord") ??
|
||||||
|
resolveOptionalDiscordRuntime()?.channel?.discord?.sendMessageDiscord ??
|
||||||
|
sendMessageDiscord
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const discordMessageActions = {
|
const discordMessageActions = {
|
||||||
describeMessageTool: (
|
describeMessageTool: (
|
||||||
ctx: Parameters<NonNullable<typeof discordMessageActionsImpl.describeMessageTool>>[0],
|
ctx: Parameters<NonNullable<typeof discordMessageActionsImpl.describeMessageTool>>[0],
|
||||||
@@ -685,7 +701,7 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount, DiscordProbe>
|
|||||||
attachedResults: {
|
attachedResults: {
|
||||||
channel: "discord",
|
channel: "discord",
|
||||||
sendText: async ({ cfg, to, text, accountId, deps, replyToId, silent }) => {
|
sendText: async ({ cfg, to, text, accountId, deps, replyToId, silent }) => {
|
||||||
const send = resolveOutboundSendDep<DiscordSendFn>(deps, "discord") ?? sendMessageDiscord;
|
const send = resolveDiscordSend(deps);
|
||||||
return await send(to, text, {
|
return await send(to, text, {
|
||||||
verbose: false,
|
verbose: false,
|
||||||
cfg,
|
cfg,
|
||||||
@@ -705,7 +721,7 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount, DiscordProbe>
|
|||||||
replyToId,
|
replyToId,
|
||||||
silent,
|
silent,
|
||||||
}) => {
|
}) => {
|
||||||
const send = resolveOutboundSendDep<DiscordSendFn>(deps, "discord") ?? sendMessageDiscord;
|
const send = resolveDiscordSend(deps);
|
||||||
return await send(to, text, {
|
return await send(to, text, {
|
||||||
verbose: false,
|
verbose: false,
|
||||||
cfg,
|
cfg,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
|||||||
|
|
||||||
type DiscordChannelRuntime = {
|
type DiscordChannelRuntime = {
|
||||||
messageActions?: typeof import("./channel-actions.js").discordMessageActions;
|
messageActions?: typeof import("./channel-actions.js").discordMessageActions;
|
||||||
|
sendMessageDiscord?: typeof import("./send.js").sendMessageDiscord;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DiscordRuntime = PluginRuntime & {
|
export type DiscordRuntime = PluginRuntime & {
|
||||||
|
|||||||
@@ -1,2 +1,7 @@
|
|||||||
export type { ClawdbotConfig, OutboundIdentity, ReplyPayload, RuntimeEnv } from "../runtime-api.js";
|
export {
|
||||||
export { createReplyPrefixContext } from "openclaw/plugin-sdk/feishu";
|
createReplyPrefixContext,
|
||||||
|
type ClawdbotConfig,
|
||||||
|
type OutboundIdentity,
|
||||||
|
type ReplyPayload,
|
||||||
|
type RuntimeEnv,
|
||||||
|
} from "../runtime-api.js";
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ import {
|
|||||||
type ChannelPlugin,
|
type ChannelPlugin,
|
||||||
type OpenClawConfig,
|
type OpenClawConfig,
|
||||||
} from "./runtime-api.js";
|
} from "./runtime-api.js";
|
||||||
import { getSlackRuntime } from "./runtime.js";
|
import { getOptionalSlackRuntime, getSlackRuntime } from "./runtime.js";
|
||||||
import { fetchSlackScopes } from "./scopes.js";
|
import { fetchSlackScopes } from "./scopes.js";
|
||||||
import { sendMessageSlack } from "./send.js";
|
import { sendMessageSlack } from "./send.js";
|
||||||
import { slackSetupAdapter } from "./setup-core.js";
|
import { slackSetupAdapter } from "./setup-core.js";
|
||||||
@@ -96,6 +96,10 @@ function resolveSlackProbe() {
|
|||||||
return probeSlack;
|
return probeSlack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveSlackHandleAction() {
|
||||||
|
return getOptionalSlackRuntime()?.channel?.slack?.handleSlackAction ?? handleSlackAction;
|
||||||
|
}
|
||||||
|
|
||||||
// Select the appropriate Slack token for read/write operations.
|
// Select the appropriate Slack token for read/write operations.
|
||||||
function getTokenForOperation(
|
function getTokenForOperation(
|
||||||
account: ResolvedSlackAccount,
|
account: ResolvedSlackAccount,
|
||||||
@@ -364,7 +368,7 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount, SlackProbe> = crea
|
|||||||
},
|
},
|
||||||
actions: createSlackActions(SLACK_CHANNEL, {
|
actions: createSlackActions(SLACK_CHANNEL, {
|
||||||
invoke: async (action, cfg, toolContext) =>
|
invoke: async (action, cfg, toolContext) =>
|
||||||
await handleSlackAction(
|
await resolveSlackHandleAction()(
|
||||||
action,
|
action,
|
||||||
cfg as OpenClawConfig,
|
cfg as OpenClawConfig,
|
||||||
toolContext as SlackActionContext | undefined,
|
toolContext as SlackActionContext | undefined,
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
import type { PluginRuntime } from "openclaw/plugin-sdk/core";
|
import type { PluginRuntime } from "openclaw/plugin-sdk/core";
|
||||||
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
||||||
|
|
||||||
|
type SlackChannelRuntime = {
|
||||||
|
handleSlackAction?: typeof import("./action-runtime.js").handleSlackAction;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SlackRuntime = PluginRuntime & {
|
||||||
|
channel: PluginRuntime["channel"] & {
|
||||||
|
slack?: SlackChannelRuntime;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
setRuntime: setSlackRuntime,
|
setRuntime: setSlackRuntime,
|
||||||
clearRuntime: clearSlackRuntime,
|
clearRuntime: clearSlackRuntime,
|
||||||
|
tryGetRuntime: getOptionalSlackRuntime,
|
||||||
getRuntime: getSlackRuntime,
|
getRuntime: getSlackRuntime,
|
||||||
} = createPluginRuntimeStore<PluginRuntime>("Slack runtime not initialized");
|
} = createPluginRuntimeStore<SlackRuntime>("Slack runtime not initialized");
|
||||||
export { clearSlackRuntime, getSlackRuntime, setSlackRuntime };
|
export { clearSlackRuntime, getOptionalSlackRuntime, getSlackRuntime, setSlackRuntime };
|
||||||
|
|||||||
Reference in New Issue
Block a user