mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 18:33:37 +00:00
refactor: converge plugin sdk channel helpers
This commit is contained in:
@@ -51,15 +51,9 @@ export type {
|
||||
ChannelMessageActionName,
|
||||
} from "../channels/plugins/types.js";
|
||||
export type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
export { createReplyPrefixOptions } from "../channels/reply-prefix.js";
|
||||
export { createChannelReplyPipeline } from "./channel-reply-pipeline.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export type { DmPolicy, GroupPolicy } from "../config/types.js";
|
||||
export {
|
||||
hasConfiguredSecretInput,
|
||||
normalizeResolvedSecretInputString,
|
||||
normalizeSecretInputString,
|
||||
} from "../config/types.secrets.js";
|
||||
export { buildSecretInputSchema } from "./secret-input-schema.js";
|
||||
export { ToolPolicySchema } from "../config/zod-schema.agent-runtime.js";
|
||||
export { MarkdownConfigSchema } from "../config/zod-schema.core.js";
|
||||
export type { ParsedChatTarget } from "../../extensions/imessage/api.js";
|
||||
@@ -85,23 +79,19 @@ export type { WizardPrompter } from "../wizard/prompts.js";
|
||||
export { isAllowedParsedChatSender } from "./allow-from.js";
|
||||
export { readBooleanParam } from "./boolean-param.js";
|
||||
export { mapAllowFromEntries } from "./channel-config-helpers.js";
|
||||
export { createScopedPairingAccess } from "./pairing-access.js";
|
||||
export { issuePairingChallenge } from "../pairing/pairing-challenge.js";
|
||||
export { createChannelPairingController } from "./channel-pairing.js";
|
||||
export { resolveRequestUrl } from "./request-url.js";
|
||||
export {
|
||||
buildComputedAccountStatusSnapshot,
|
||||
buildProbeChannelStatusSummary,
|
||||
} from "./status-helpers.js";
|
||||
export { extractToolSend } from "./tool-send.js";
|
||||
export { normalizeWebhookPath } from "./webhook-path.js";
|
||||
export {
|
||||
beginWebhookRequestPipelineOrReject,
|
||||
createWebhookInFlightLimiter,
|
||||
normalizeWebhookPath,
|
||||
readWebhookBodyOrReject,
|
||||
} from "./webhook-request-guards.js";
|
||||
export {
|
||||
registerWebhookTargetWithPluginRoute,
|
||||
resolveWebhookTargets,
|
||||
resolveWebhookTargetWithAuthOrRejectSync,
|
||||
withResolvedWebhookRequestPipeline,
|
||||
} from "./webhook-targets.js";
|
||||
} from "./webhook-ingress.js";
|
||||
|
||||
@@ -36,4 +36,24 @@ describe("createChannelReplyPipeline", () => {
|
||||
expect(start).toHaveBeenCalled();
|
||||
expect(stop).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves explicit typing callbacks when a channel needs custom lifecycle hooks", async () => {
|
||||
const onReplyStart = vi.fn(async () => {});
|
||||
const onIdle = vi.fn(() => {});
|
||||
const pipeline = createChannelReplyPipeline({
|
||||
cfg: {},
|
||||
agentId: "main",
|
||||
channel: "bluebubbles",
|
||||
typingCallbacks: {
|
||||
onReplyStart,
|
||||
onIdle,
|
||||
},
|
||||
});
|
||||
|
||||
await pipeline.typingCallbacks?.onReplyStart();
|
||||
pipeline.typingCallbacks?.onIdle?.();
|
||||
|
||||
expect(onReplyStart).toHaveBeenCalledTimes(1);
|
||||
expect(onIdle).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,6 +25,7 @@ export function createChannelReplyPipeline(params: {
|
||||
channel?: string;
|
||||
accountId?: string;
|
||||
typing?: CreateTypingCallbacksParams;
|
||||
typingCallbacks?: TypingCallbacks;
|
||||
}): ChannelReplyPipeline {
|
||||
return {
|
||||
...createReplyPrefixOptions({
|
||||
@@ -33,6 +34,10 @@ export function createChannelReplyPipeline(params: {
|
||||
channel: params.channel,
|
||||
accountId: params.accountId,
|
||||
}),
|
||||
...(params.typing ? { typingCallbacks: createTypingCallbacks(params.typing) } : {}),
|
||||
...(params.typingCallbacks
|
||||
? { typingCallbacks: params.typingCallbacks }
|
||||
: params.typing
|
||||
? { typingCallbacks: createTypingCallbacks(params.typing) }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ export type {
|
||||
} from "../channels/plugins/types.js";
|
||||
export type { ChannelDirectoryEntry } from "../channels/plugins/types.core.js";
|
||||
export type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
export { createReplyPrefixOptions } from "../channels/reply-prefix.js";
|
||||
export { createTypingCallbacks } from "../channels/typing.js";
|
||||
export { createChannelReplyPipeline } from "./channel-reply-pipeline.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export { isDangerousNameMatchingEnabled } from "../config/dangerous-name-matching.js";
|
||||
export { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
||||
@@ -61,13 +60,6 @@ export {
|
||||
warnMissingProviderGroupPolicyFallbackOnce,
|
||||
} from "../config/runtime-group-policy.js";
|
||||
export type { BlockStreamingCoalesceConfig, DmPolicy, GroupPolicy } from "../config/types.js";
|
||||
export type { SecretInput } from "../config/types.secrets.js";
|
||||
export {
|
||||
hasConfiguredSecretInput,
|
||||
normalizeResolvedSecretInputString,
|
||||
normalizeSecretInputString,
|
||||
} from "../config/types.secrets.js";
|
||||
export { buildSecretInputSchema } from "./secret-input-schema.js";
|
||||
export {
|
||||
BlockStreamingCoalesceSchema,
|
||||
DmPolicySchema,
|
||||
@@ -100,5 +92,5 @@ export type { WizardPrompter } from "../wizard/prompts.js";
|
||||
export { buildAgentMediaPayload } from "./agent-media-payload.js";
|
||||
export { getAgentScopedMediaLocalRoots } from "../media/local-roots.js";
|
||||
export { loadOutboundMediaFromUrl } from "./outbound-media.js";
|
||||
export { createScopedPairingAccess } from "./pairing-access.js";
|
||||
export { createChannelPairingController } from "./channel-pairing.js";
|
||||
export { isRequestBodyLimitError, readRequestBodyWithLimit } from "../infra/http-body.js";
|
||||
|
||||
@@ -52,8 +52,7 @@ export type {
|
||||
ChannelOutboundAdapter,
|
||||
} from "../channels/plugins/types.js";
|
||||
export type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
export { createChannelReplyPipeline, createReplyPrefixOptions } from "./channel-reply-pipeline.js";
|
||||
export { createTypingCallbacks } from "./channel-reply-pipeline.js";
|
||||
export { createChannelReplyPipeline } from "./channel-reply-pipeline.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export { isDangerousNameMatchingEnabled } from "../config/dangerous-name-matching.js";
|
||||
export { resolveToolsBySender } from "../config/group-policy.js";
|
||||
@@ -106,7 +105,7 @@ export { withFileLock } from "./file-lock.js";
|
||||
export { dispatchReplyFromConfigWithSettledDispatcher } from "./inbound-reply-dispatch.js";
|
||||
export { readJsonFileWithFallback, writeJsonFileAtomically } from "./json-store.js";
|
||||
export { loadOutboundMediaFromUrl } from "./outbound-media.js";
|
||||
export { createChannelPairingController, createScopedPairingAccess } from "./channel-pairing.js";
|
||||
export { createChannelPairingController } from "./channel-pairing.js";
|
||||
export { resolveInboundSessionEnvelopeContext } from "../channels/session-envelope.js";
|
||||
export {
|
||||
buildHostnameAllowlistPolicyFromSuffixAllowlist,
|
||||
|
||||
Reference in New Issue
Block a user