mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
Messaging: align adapter compile surfaces
This commit is contained in:
@@ -58,7 +58,7 @@ function resolveGoogleChatAccountImpl(params: { cfg: OpenClawConfig; accountId?:
|
||||
name: typeof config.name === "string" ? config.name : undefined,
|
||||
enabled: channelConfig.enabled !== false && scoped.enabled !== false,
|
||||
config,
|
||||
credentialSource: serviceAccount ? "inline" : "none",
|
||||
credentialSource: serviceAccount ? ("inline" as const) : ("none" as const),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -360,8 +360,6 @@ describe("googlechatPlugin outbound resolveTarget", () => {
|
||||
it("resolves valid chat targets", () => {
|
||||
const result = resolveTarget({
|
||||
to: "spaces/AAA",
|
||||
mode: "explicit",
|
||||
allowFrom: [],
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
@@ -374,8 +372,6 @@ describe("googlechatPlugin outbound resolveTarget", () => {
|
||||
it("resolves email targets", () => {
|
||||
const result = resolveTarget({
|
||||
to: "user@example.com",
|
||||
mode: "explicit",
|
||||
allowFrom: [],
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
@@ -388,8 +384,6 @@ describe("googlechatPlugin outbound resolveTarget", () => {
|
||||
it("errors on invalid targets", () => {
|
||||
const result = resolveTarget({
|
||||
to: " ",
|
||||
mode: "explicit",
|
||||
allowFrom: [],
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
@@ -402,8 +396,6 @@ describe("googlechatPlugin outbound resolveTarget", () => {
|
||||
it("errors when no target is provided", () => {
|
||||
const result = resolveTarget({
|
||||
to: undefined,
|
||||
mode: "explicit",
|
||||
allowFrom: [],
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(false);
|
||||
@@ -433,7 +425,7 @@ describe("googlechatPlugin outbound cfg threading", () => {
|
||||
const account = {
|
||||
accountId: "work",
|
||||
config: {},
|
||||
credentialSource: "inline",
|
||||
credentialSource: "inline" as const,
|
||||
};
|
||||
resolveGoogleChatAccountMock.mockReturnValue(account);
|
||||
resolveGoogleChatOutboundSpaceMock.mockResolvedValue("spaces/WORK");
|
||||
@@ -474,7 +466,7 @@ describe("googlechatPlugin outbound cfg threading", () => {
|
||||
const account = {
|
||||
accountId: "default",
|
||||
config: {},
|
||||
credentialSource: "inline",
|
||||
credentialSource: "inline" as const,
|
||||
};
|
||||
resolveGoogleChatAccountMock.mockReturnValue(account);
|
||||
resolveGoogleChatOutboundSpaceMock.mockResolvedValue("spaces/AAA");
|
||||
@@ -516,7 +508,7 @@ describe("googlechatPlugin outbound cfg threading", () => {
|
||||
const account = {
|
||||
accountId: "default",
|
||||
config: { mediaMaxMb: 20 },
|
||||
credentialSource: "inline",
|
||||
credentialSource: "inline" as const,
|
||||
};
|
||||
const { fetchRemoteMedia } = setupRuntimeMediaMocks({
|
||||
loadFileName: "unused.png",
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
formatAllowFromEntry,
|
||||
googlechatDirectoryAdapter,
|
||||
googlechatGroupsAdapter,
|
||||
loadGoogleChatChannelRuntime,
|
||||
googlechatOutboundAdapter,
|
||||
googlechatPairingTextAdapter,
|
||||
googlechatSecurityAdapter,
|
||||
|
||||
@@ -17,8 +17,6 @@ import type { ResolvedLineAccount } from "./types.js";
|
||||
type MessageEvent = webhook.MessageEvent;
|
||||
type PostbackEvent = webhook.PostbackEvent;
|
||||
|
||||
type AgentBinding = NonNullable<OpenClawConfig["bindings"]>[number];
|
||||
|
||||
const lineBindingsPlugin = {
|
||||
id: "line",
|
||||
bindings: lineBindingsAdapter,
|
||||
@@ -331,11 +329,6 @@ describe("buildLineMessageContext", () => {
|
||||
|
||||
it("normalizes LINE ACP binding conversation ids through the plugin bindings surface", async () => {
|
||||
const compiled = lineBindingsAdapter.compileConfiguredBinding({
|
||||
binding: {
|
||||
type: "acp",
|
||||
agentId: "codex",
|
||||
match: { channel: "line", accountId: "default", peer: { kind: "direct", id: "unused" } },
|
||||
} as AgentBinding,
|
||||
conversationId: "line:user:U1234567890abcdef1234567890abcdef",
|
||||
});
|
||||
|
||||
@@ -344,11 +337,6 @@ describe("buildLineMessageContext", () => {
|
||||
});
|
||||
expect(
|
||||
lineBindingsAdapter.matchInboundConversation({
|
||||
binding: {
|
||||
type: "acp",
|
||||
agentId: "codex",
|
||||
match: { channel: "line", accountId: "default", peer: { kind: "direct", id: "unused" } },
|
||||
} as AgentBinding,
|
||||
compiledBinding: compiled!,
|
||||
conversationId: "U1234567890abcdef1234567890abcdef",
|
||||
}),
|
||||
@@ -360,11 +348,6 @@ describe("buildLineMessageContext", () => {
|
||||
|
||||
it("normalizes canonical LINE targets through the plugin bindings surface", async () => {
|
||||
const compiled = lineBindingsAdapter.compileConfiguredBinding({
|
||||
binding: {
|
||||
type: "acp",
|
||||
agentId: "codex",
|
||||
match: { channel: "line", accountId: "default", peer: { kind: "direct", id: "unused" } },
|
||||
} as AgentBinding,
|
||||
conversationId: "line:U1234567890abcdef1234567890abcdef",
|
||||
});
|
||||
|
||||
@@ -373,7 +356,6 @@ describe("buildLineMessageContext", () => {
|
||||
});
|
||||
expect(
|
||||
lineBindingsAdapter.resolveCommandConversation({
|
||||
accountId: "default",
|
||||
originatingTo: "line:U1234567890abcdef1234567890abcdef",
|
||||
}),
|
||||
).toEqual({
|
||||
@@ -381,11 +363,6 @@ describe("buildLineMessageContext", () => {
|
||||
});
|
||||
expect(
|
||||
lineBindingsAdapter.matchInboundConversation({
|
||||
binding: {
|
||||
type: "acp",
|
||||
agentId: "codex",
|
||||
match: { channel: "line", accountId: "default", peer: { kind: "direct", id: "unused" } },
|
||||
} as AgentBinding,
|
||||
compiledBinding: compiled!,
|
||||
conversationId: "U1234567890abcdef1234567890abcdef",
|
||||
}),
|
||||
|
||||
@@ -276,28 +276,28 @@ describe("qqbot config", () => {
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toBe("QQBot --token must be in appId:clientSecret format");
|
||||
expect(
|
||||
lightweightSetup!.validateInput?.({
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toBe("QQBot --token must be in appId:clientSecret format");
|
||||
expect(
|
||||
runtimeSetup.applyAccountConfig?.({
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toEqual({});
|
||||
expect(
|
||||
lightweightSetup!.applyAccountConfig?.({
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toEqual({});
|
||||
});
|
||||
|
||||
@@ -314,7 +314,7 @@ describe("qqbot config", () => {
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toMatchObject({
|
||||
channels: {
|
||||
qqbot: {
|
||||
@@ -329,7 +329,7 @@ describe("qqbot config", () => {
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toMatchObject({
|
||||
channels: {
|
||||
qqbot: {
|
||||
@@ -375,28 +375,28 @@ describe("qqbot config", () => {
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: "bot2",
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toBe("QQBot --use-env only supports the default account");
|
||||
expect(
|
||||
lightweightSetup!.validateInput?.({
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: "bot2",
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toBe("QQBot --use-env only supports the default account");
|
||||
expect(
|
||||
runtimeSetup.applyAccountConfig?.({
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: "bot2",
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toEqual({});
|
||||
expect(
|
||||
lightweightSetup!.applyAccountConfig?.({
|
||||
cfg: {} as OpenClawConfig,
|
||||
accountId: "bot2",
|
||||
input,
|
||||
}),
|
||||
} as never),
|
||||
).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createChatChannelPlugin } from "openclaw/plugin-sdk/channel-core";
|
||||
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
||||
import { createAccountStatusSink } from "openclaw/plugin-sdk/channel-lifecycle";
|
||||
import { buildPassiveProbedChannelStatusSummary } from "openclaw/plugin-sdk/extension-shared";
|
||||
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
||||
import {
|
||||
createAsyncComputedAccountStatusAdapter,
|
||||
|
||||
@@ -90,6 +90,11 @@ type SetupWizardAdapterParams = Parameters<typeof buildChannelSetupWizardAdapter
|
||||
type SetupWizardPlugin = SetupWizardAdapterParams["plugin"];
|
||||
type SetupWizard = NonNullable<SetupWizardAdapterParams["wizard"]>;
|
||||
type SetupWizardCredentialValues = Record<string, string>;
|
||||
type SetupWizardTestPlugin = {
|
||||
id: string;
|
||||
setupWizard?: ChannelPlugin["setupWizard"];
|
||||
config: Record<string, unknown>;
|
||||
} & Record<string, unknown>;
|
||||
|
||||
function isDeclarativeSetupWizard(
|
||||
setupWizard: ChannelPlugin["setupWizard"],
|
||||
@@ -102,9 +107,7 @@ function isDeclarativeSetupWizard(
|
||||
);
|
||||
}
|
||||
|
||||
function requireDeclarativeSetupWizard(
|
||||
plugin: SetupWizardPlugin & Pick<ChannelPlugin, "setupWizard">,
|
||||
): SetupWizard {
|
||||
function requireDeclarativeSetupWizard(plugin: SetupWizardTestPlugin): SetupWizard {
|
||||
const { setupWizard } = plugin;
|
||||
if (!setupWizard) {
|
||||
throw new Error(`${plugin.id} is missing setupWizard`);
|
||||
@@ -148,25 +151,25 @@ export function createSetupWizardAdapter(params: SetupWizardAdapterParams) {
|
||||
return buildChannelSetupWizardAdapterFromSetupWizard(params);
|
||||
}
|
||||
|
||||
export function createPluginSetupWizardAdapter<
|
||||
TPlugin extends SetupWizardPlugin & Pick<ChannelPlugin, "setupWizard">,
|
||||
>(plugin: TPlugin) {
|
||||
export function createPluginSetupWizardAdapter<TPlugin extends SetupWizardTestPlugin>(
|
||||
plugin: TPlugin,
|
||||
) {
|
||||
const wizard = requireDeclarativeSetupWizard(plugin);
|
||||
return createSetupWizardAdapter({
|
||||
plugin,
|
||||
plugin: plugin as unknown as SetupWizardPlugin,
|
||||
wizard,
|
||||
});
|
||||
}
|
||||
|
||||
export function createPluginSetupWizardConfigure<
|
||||
TPlugin extends SetupWizardPlugin & Pick<ChannelPlugin, "setupWizard">,
|
||||
>(plugin: TPlugin) {
|
||||
export function createPluginSetupWizardConfigure<TPlugin extends SetupWizardTestPlugin>(
|
||||
plugin: TPlugin,
|
||||
) {
|
||||
return createPluginSetupWizardAdapter(plugin).configure;
|
||||
}
|
||||
|
||||
export function createPluginSetupWizardStatus<
|
||||
TPlugin extends SetupWizardPlugin & Pick<ChannelPlugin, "setupWizard">,
|
||||
>(plugin: TPlugin) {
|
||||
export function createPluginSetupWizardStatus<TPlugin extends SetupWizardTestPlugin>(
|
||||
plugin: TPlugin,
|
||||
) {
|
||||
return createPluginSetupWizardAdapter(plugin).getStatus;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user