mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
refactor(channels): remove internal compatibility aliases
This commit is contained in:
@@ -179,7 +179,7 @@ rules:
|
|||||||
- patterns:
|
- patterns:
|
||||||
- pattern-either:
|
- pattern-either:
|
||||||
- pattern: getChannelPluginCatalogEntry(...)
|
- pattern: getChannelPluginCatalogEntry(...)
|
||||||
- pattern: listChannelPluginCatalogEntries(...)
|
- pattern: listRawChannelPluginCatalogEntries(...)
|
||||||
- pattern-not-regex: \bexcludeWorkspace\s*:\s*true\b
|
- pattern-not-regex: \bexcludeWorkspace\s*:\s*true\b
|
||||||
pattern-sanitizers:
|
pattern-sanitizers:
|
||||||
- patterns:
|
- patterns:
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export function normalizeReplyPayloadDirectives(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const mediaUrls = params.payload.mediaUrls ?? parsed?.mediaUrls;
|
const mediaUrls = params.payload.mediaUrls ?? parsed?.mediaUrls;
|
||||||
const mediaUrl = params.payload.mediaUrl ?? parsed?.mediaUrl ?? mediaUrls?.[0];
|
const mediaUrl = params.payload.mediaUrl ?? mediaUrls?.[0];
|
||||||
|
|
||||||
const channelData = mergeReactionDirectiveChannelData(
|
const channelData = mergeReactionDirectiveChannelData(
|
||||||
params.payload.channelData,
|
params.payload.channelData,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { isSilentReplyPayloadText, SILENT_REPLY_TOKEN } from "../tokens.js";
|
|||||||
export type ReplyDirectiveParseResult = {
|
export type ReplyDirectiveParseResult = {
|
||||||
text: string;
|
text: string;
|
||||||
mediaUrls?: string[];
|
mediaUrls?: string[];
|
||||||
mediaUrl?: string;
|
|
||||||
reaction?: {
|
reaction?: {
|
||||||
emoji: string;
|
emoji: string;
|
||||||
replyToCurrent?: boolean;
|
replyToCurrent?: boolean;
|
||||||
@@ -109,7 +108,6 @@ export function parseReplyDirectives(
|
|||||||
return {
|
return {
|
||||||
text,
|
text,
|
||||||
mediaUrls: split.mediaUrls,
|
mediaUrls: split.mediaUrls,
|
||||||
mediaUrl: split.mediaUrl,
|
|
||||||
reaction: reactionParsed.reaction,
|
reaction: reactionParsed.reaction,
|
||||||
replyToId: replyParsed.replyToId ?? reactionParsed.reaction?.replyToId,
|
replyToId: replyParsed.replyToId ?? reactionParsed.reaction?.replyToId,
|
||||||
replyToCurrent:
|
replyToCurrent:
|
||||||
|
|||||||
@@ -531,17 +531,6 @@ export function listRawChannelPluginCatalogEntries(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use `listTrustedChannelPluginCatalogEntries` for execution-facing
|
|
||||||
* paths, or `listRawChannelPluginCatalogEntries` for internal plumbing
|
|
||||||
* that applies its own trust filtering.
|
|
||||||
*/
|
|
||||||
export function listChannelPluginCatalogEntries(
|
|
||||||
options: CatalogOptions = {},
|
|
||||||
): ChannelPluginCatalogEntry[] {
|
|
||||||
return listRawChannelPluginCatalogEntries(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getChannelPluginCatalogEntry(
|
export function getChannelPluginCatalogEntry(
|
||||||
id: string,
|
id: string,
|
||||||
options: CatalogOptions = {},
|
options: CatalogOptions = {},
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import fs from "node:fs";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
|
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
|
||||||
import { getChannelPluginCatalogEntry, listChannelPluginCatalogEntries } from "../../catalog.js";
|
import { getChannelPluginCatalogEntry, listRawChannelPluginCatalogEntries } from "../../catalog.js";
|
||||||
|
|
||||||
type CatalogEntryMeta = {
|
type CatalogEntryMeta = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -48,7 +48,7 @@ export function describeChannelCatalogEntryContract(params: {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("appears in the channel catalog listing", () => {
|
it("appears in the channel catalog listing", () => {
|
||||||
const ids = listChannelPluginCatalogEntries().map((entry) => entry.id);
|
const ids = listRawChannelPluginCatalogEntries().map((entry) => entry.id);
|
||||||
expect(ids).toContain(params.channelId);
|
expect(ids).toContain(params.channelId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -96,7 +96,7 @@ export function describeBundledMetadataOnlyChannelCatalogContract(params: {
|
|||||||
"utf8",
|
"utf8",
|
||||||
);
|
);
|
||||||
|
|
||||||
const entry = listChannelPluginCatalogEntries({
|
const entry = listRawChannelPluginCatalogEntries({
|
||||||
workspaceDir,
|
workspaceDir,
|
||||||
env: createCatalogFixtureEnv({ OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1" }),
|
env: createCatalogFixtureEnv({ OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1" }),
|
||||||
}).find((item) => item.id === params.meta.id);
|
}).find((item) => item.id === params.meta.id);
|
||||||
@@ -141,7 +141,7 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const entry = listChannelPluginCatalogEntries({
|
const entry = listRawChannelPluginCatalogEntries({
|
||||||
env: createCatalogFallbackOnlyEnv(),
|
env: createCatalogFallbackOnlyEnv(),
|
||||||
officialCatalogPaths: [catalogPath],
|
officialCatalogPaths: [catalogPath],
|
||||||
}).find((item) => item.id === params.channelId);
|
}).find((item) => item.id === params.channelId);
|
||||||
@@ -216,7 +216,7 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
|
|||||||
"utf8",
|
"utf8",
|
||||||
);
|
);
|
||||||
|
|
||||||
const entry = listChannelPluginCatalogEntries({
|
const entry = listRawChannelPluginCatalogEntries({
|
||||||
catalogPaths: [externalCatalogPath],
|
catalogPaths: [externalCatalogPath],
|
||||||
officialCatalogPaths: [officialCatalogPath],
|
officialCatalogPaths: [officialCatalogPath],
|
||||||
env: createCatalogFallbackOnlyEnv(),
|
env: createCatalogFallbackOnlyEnv(),
|
||||||
@@ -252,7 +252,7 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
|
|||||||
"utf8",
|
"utf8",
|
||||||
);
|
);
|
||||||
|
|
||||||
const entry = listChannelPluginCatalogEntries({
|
const entry = listRawChannelPluginCatalogEntries({
|
||||||
catalogPaths: [catalogPath],
|
catalogPaths: [catalogPath],
|
||||||
officialCatalogPaths: [],
|
officialCatalogPaths: [],
|
||||||
env: createCatalogFallbackOnlyEnv(),
|
env: createCatalogFallbackOnlyEnv(),
|
||||||
|
|||||||
+3
-3
@@ -7,7 +7,7 @@ import fs from "node:fs";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
|
import { resolvePreferredOpenClawTmpDir } from "../../../../infra/tmp-openclaw-dir.js";
|
||||||
import { listChannelPluginCatalogEntries } from "../../catalog.js";
|
import { listRawChannelPluginCatalogEntries } from "../../catalog.js";
|
||||||
|
|
||||||
function createCatalogEntry(params: {
|
function createCatalogEntry(params: {
|
||||||
packageName: string;
|
packageName: string;
|
||||||
@@ -88,7 +88,7 @@ function expectCatalogIdsContain(params: {
|
|||||||
catalogPaths?: string[];
|
catalogPaths?: string[];
|
||||||
env?: NodeJS.ProcessEnv;
|
env?: NodeJS.ProcessEnv;
|
||||||
}) {
|
}) {
|
||||||
const ids = listChannelPluginCatalogEntries({
|
const ids = listRawChannelPluginCatalogEntries({
|
||||||
...(params.catalogPaths ? { catalogPaths: params.catalogPaths } : {}),
|
...(params.catalogPaths ? { catalogPaths: params.catalogPaths } : {}),
|
||||||
...(params.env ? { env: params.env } : {}),
|
...(params.env ? { env: params.env } : {}),
|
||||||
}).map((entry) => entry.id);
|
}).map((entry) => entry.id);
|
||||||
@@ -100,7 +100,7 @@ function findCatalogEntry(params: {
|
|||||||
catalogPaths?: string[];
|
catalogPaths?: string[];
|
||||||
env?: NodeJS.ProcessEnv;
|
env?: NodeJS.ProcessEnv;
|
||||||
}) {
|
}) {
|
||||||
return listChannelPluginCatalogEntries({
|
return listRawChannelPluginCatalogEntries({
|
||||||
...(params.catalogPaths ? { catalogPaths: params.catalogPaths } : {}),
|
...(params.catalogPaths ? { catalogPaths: params.catalogPaths } : {}),
|
||||||
...(params.env ? { env: params.env } : {}),
|
...(params.env ? { env: params.env } : {}),
|
||||||
}).find((entry) => entry.id === params.channelId);
|
}).find((entry) => entry.id === params.channelId);
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ function createOutboundPayloadPlanEntry(
|
|||||||
extractMarkdownImages: context.extractMarkdownImages,
|
extractMarkdownImages: context.extractMarkdownImages,
|
||||||
});
|
});
|
||||||
const explicitMediaUrls = payload.mediaUrls ?? parsed.mediaUrls;
|
const explicitMediaUrls = payload.mediaUrls ?? parsed.mediaUrls;
|
||||||
const explicitMediaUrl = payload.mediaUrl ?? parsed.mediaUrl;
|
const explicitMediaUrl = payload.mediaUrl ?? parsed.mediaUrls?.[0];
|
||||||
const mergedMedia = mergeMediaUrls(
|
const mergedMedia = mergeMediaUrls(
|
||||||
explicitMediaUrls,
|
explicitMediaUrls,
|
||||||
explicitMediaUrl ? [explicitMediaUrl] : undefined,
|
explicitMediaUrl ? [explicitMediaUrl] : undefined,
|
||||||
|
|||||||
@@ -21,10 +21,8 @@ describe("splitMediaFromOutput", () => {
|
|||||||
}
|
}
|
||||||
if ("mediaUrls" in expected) {
|
if ("mediaUrls" in expected) {
|
||||||
expect(result.mediaUrls).toEqual(expected.mediaUrls);
|
expect(result.mediaUrls).toEqual(expected.mediaUrls);
|
||||||
expect(result.mediaUrl).toBe(expected.mediaUrls?.[0]);
|
|
||||||
} else {
|
} else {
|
||||||
expect(result.mediaUrls).toBeUndefined();
|
expect(result.mediaUrls).toBeUndefined();
|
||||||
expect(result.mediaUrl).toBeUndefined();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -489,8 +489,6 @@ export function splitMediaFromOutput(
|
|||||||
): {
|
): {
|
||||||
text: string;
|
text: string;
|
||||||
mediaUrls?: string[];
|
mediaUrls?: string[];
|
||||||
/** @deprecated Use mediaUrls[0]. */
|
|
||||||
mediaUrl?: string;
|
|
||||||
audioAsVoice?: boolean; // true if [[audio_as_voice]] tag was found
|
audioAsVoice?: boolean; // true if [[audio_as_voice]] tag was found
|
||||||
segments?: ParsedMediaOutputSegment[];
|
segments?: ParsedMediaOutputSegment[];
|
||||||
} {
|
} {
|
||||||
@@ -718,7 +716,6 @@ export function splitMediaFromOutput(
|
|||||||
return {
|
return {
|
||||||
text: cleanedText,
|
text: cleanedText,
|
||||||
mediaUrls: media,
|
mediaUrls: media,
|
||||||
mediaUrl: media[0],
|
|
||||||
segments: segments.length > 0 ? segments : [{ type: "text", text: cleanedText }],
|
segments: segments.length > 0 ? segments : [{ type: "text", text: cleanedText }],
|
||||||
...(hasAudioAsVoice ? { audioAsVoice: true } : {}),
|
...(hasAudioAsVoice ? { audioAsVoice: true } : {}),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user