Skip to content

Commit b05a7b1

Browse files
committed
refactor(channels): clarify raw catalog helper
1 parent a458bc7 commit b05a7b1

15 files changed

Lines changed: 34 additions & 32 deletions

src/channels/plugins/catalog.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,12 +416,15 @@ export function buildChannelUiCatalog(
416416
}
417417

418418
/**
419-
* Exported for trusted-catalog helpers that apply their own filtering.
420-
* Execution-facing callers should use `listTrustedChannelPluginCatalogEntries`.
419+
* Raw catalog primitive. This may include untrusted workspace entries and
420+
* workspace shadows. Security-sensitive or execution-facing callers should
421+
* prefer `listTrustedChannelPluginCatalogEntries`; use this primitive only when
422+
* the caller immediately applies trust filtering or explicitly excludes
423+
* workspace entries.
421424
*
422425
* @internal
423426
*/
424-
export function listChannelPluginCatalogEntriesUnfiltered(
427+
export function listRawChannelPluginCatalogEntries(
425428
options: CatalogOptions = {},
426429
): ChannelPluginCatalogEntry[] {
427430
const manifestEntries = listChannelCatalogEntries({
@@ -490,13 +493,13 @@ export function listChannelPluginCatalogEntriesUnfiltered(
490493

491494
/**
492495
* @deprecated Use `listTrustedChannelPluginCatalogEntries` for execution-facing
493-
* paths, or `listChannelPluginCatalogEntriesUnfiltered` for internal plumbing
496+
* paths, or `listRawChannelPluginCatalogEntries` for internal plumbing
494497
* that applies its own trust filtering.
495498
*/
496499
export function listChannelPluginCatalogEntries(
497500
options: CatalogOptions = {},
498501
): ChannelPluginCatalogEntry[] {
499-
return listChannelPluginCatalogEntriesUnfiltered(options);
502+
return listRawChannelPluginCatalogEntries(options);
500503
}
501504

502505
export function getChannelPluginCatalogEntry(
@@ -507,5 +510,5 @@ export function getChannelPluginCatalogEntry(
507510
if (!trimmed) {
508511
return undefined;
509512
}
510-
return listChannelPluginCatalogEntriesUnfiltered(options).find((entry) => entry.id === trimmed);
513+
return listRawChannelPluginCatalogEntries(options).find((entry) => entry.id === trimmed);
511514
}

src/cli/channel-auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ vi.mock("../agents/agent-scope.js", () => ({
3333
vi.mock("../channels/plugins/catalog.js", () => ({
3434
getChannelPluginCatalogEntry: mocks.getChannelPluginCatalogEntry,
3535
listChannelPluginCatalogEntries: mocks.listChannelPluginCatalogEntries,
36-
listChannelPluginCatalogEntriesUnfiltered: mocks.listChannelPluginCatalogEntries,
36+
listRawChannelPluginCatalogEntries: mocks.listChannelPluginCatalogEntries,
3737
}));
3838

3939
vi.mock("../channels/plugins/helpers.js", () => ({

src/commands/channel-setup/channel-plugin-resolution.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ vi.mock("../../agents/agent-scope.js", () => ({
2020

2121
vi.mock("../../channels/plugins/catalog.js", () => ({
2222
listChannelPluginCatalogEntries: mocks.listChannelPluginCatalogEntries,
23-
listChannelPluginCatalogEntriesUnfiltered: mocks.listChannelPluginCatalogEntries,
23+
listRawChannelPluginCatalogEntries: mocks.listChannelPluginCatalogEntries,
2424
getChannelPluginCatalogEntry: mocks.getChannelPluginCatalogEntry,
2525
}));
2626

src/commands/channel-setup/channel-plugin-resolution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../../agents/agent-scope.js";
22
import {
3-
listChannelPluginCatalogEntries,
3+
listRawChannelPluginCatalogEntries,
44
type ChannelPluginCatalogEntry,
55
} from "../../channels/plugins/catalog.js";
66
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
@@ -63,7 +63,7 @@ function resolveCatalogChannelEntry(raw: string, cfg: OpenClawConfig | null) {
6363
cfg,
6464
workspaceDir: resolveWorkspaceDir(cfg),
6565
})
66-
: listChannelPluginCatalogEntries({ excludeWorkspace: true });
66+
: listRawChannelPluginCatalogEntries({ excludeWorkspace: true });
6767
return entries.find((entry) => {
6868
if (normalizeOptionalLowercaseString(entry.id) === trimmed) {
6969
return true;

src/commands/channel-setup/discovery.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ vi.mock("../../config/plugin-auto-enable.js", () => ({
3030

3131
vi.mock("../../channels/plugins/catalog.js", () => ({
3232
listChannelPluginCatalogEntries: (_args?: unknown) => listChannelPluginCatalogEntries(),
33-
listChannelPluginCatalogEntriesUnfiltered: (_args?: unknown) => listChannelPluginCatalogEntries(),
33+
listRawChannelPluginCatalogEntries: (_args?: unknown) => listChannelPluginCatalogEntries(),
3434
}));
3535

3636
vi.mock("../../channels/chat-meta.js", () => ({

src/commands/channel-setup/plugin-install.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ vi.mock("../../channels/plugins/catalog.js", () => {
4848
getChannelPluginCatalogEntry: (...args: unknown[]) => getChannelPluginCatalogEntry(...args),
4949
listChannelPluginCatalogEntries: (...args: unknown[]) =>
5050
listChannelPluginCatalogEntries(...args),
51-
listChannelPluginCatalogEntriesUnfiltered: (...args: unknown[]) =>
51+
listRawChannelPluginCatalogEntries: (...args: unknown[]) =>
5252
listChannelPluginCatalogEntries(...args),
5353
};
5454
});

src/commands/channel-setup/trusted-catalog.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it, vi } from "vitest";
22
import type { ChannelPluginCatalogEntry } from "../../channels/plugins/catalog.js";
33

4-
const listChannelPluginCatalogEntriesUnfiltered = vi.hoisted(() =>
4+
const listRawChannelPluginCatalogEntries = vi.hoisted(() =>
55
vi.fn((_opts?: unknown): ChannelPluginCatalogEntry[] => []),
66
);
77
const getChannelPluginCatalogEntry = vi.hoisted(() =>
@@ -16,8 +16,7 @@ const applyPluginAutoEnable = vi.hoisted(() =>
1616
);
1717

1818
vi.mock("../../channels/plugins/catalog.js", () => ({
19-
listChannelPluginCatalogEntriesUnfiltered: (opts?: unknown) =>
20-
listChannelPluginCatalogEntriesUnfiltered(opts),
19+
listRawChannelPluginCatalogEntries: (opts?: unknown) => listRawChannelPluginCatalogEntries(opts),
2120
getChannelPluginCatalogEntry: (id?: unknown, opts?: unknown) =>
2221
getChannelPluginCatalogEntry(id, opts),
2322
}));
@@ -125,7 +124,7 @@ describe("trusted catalog helpers", () => {
125124
pluginId: "my-cool-plugin",
126125
origin: "workspace",
127126
});
128-
listChannelPluginCatalogEntriesUnfiltered.mockImplementation((opts?: unknown) =>
127+
listRawChannelPluginCatalogEntries.mockImplementation((opts?: unknown) =>
129128
(opts as { excludeWorkspace?: boolean } | undefined)?.excludeWorkspace
130129
? []
131130
: [workspaceOnlyEntry],
@@ -146,7 +145,7 @@ describe("trusted catalog helpers", () => {
146145
pluginId: "my-cool-plugin",
147146
origin: "workspace",
148147
});
149-
listChannelPluginCatalogEntriesUnfiltered.mockImplementation((opts?: unknown) =>
148+
listRawChannelPluginCatalogEntries.mockImplementation((opts?: unknown) =>
150149
(opts as { excludeWorkspace?: boolean } | undefined)?.excludeWorkspace
151150
? []
152151
: [workspaceOnlyEntry],

src/commands/channel-setup/trusted-catalog.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
getChannelPluginCatalogEntry,
3-
listChannelPluginCatalogEntriesUnfiltered,
3+
listRawChannelPluginCatalogEntries,
44
type ChannelPluginCatalogEntry,
55
} from "../../channels/plugins/catalog.js";
66
import { applyPluginAutoEnable } from "../../config/plugin-auto-enable.js";
@@ -61,11 +61,11 @@ function listChannelPluginCatalogEntriesWithTrustedFallback(
6161
},
6262
onMissingFallback: (entry: ChannelPluginCatalogEntry) => ChannelPluginCatalogEntry[],
6363
): ChannelPluginCatalogEntry[] {
64-
const unfiltered = listChannelPluginCatalogEntriesUnfiltered({
64+
const unfiltered = listRawChannelPluginCatalogEntries({
6565
workspaceDir: params.workspaceDir,
6666
});
6767
const fallbackById = new Map(
68-
listChannelPluginCatalogEntriesUnfiltered({
68+
listRawChannelPluginCatalogEntries({
6969
workspaceDir: params.workspaceDir,
7070
excludeWorkspace: true,
7171
}).map((entry) => [entry.id, entry]),

src/commands/channel-setup/workspace-shadow-bypass.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ const getChannelPluginCatalogEntry = vi.hoisted(() => vi.fn());
3131

3232
vi.mock("../../channels/plugins/catalog.js", () => ({
3333
listChannelPluginCatalogEntries: (opts?: unknown) => listChannelPluginCatalogEntries(opts),
34-
listChannelPluginCatalogEntriesUnfiltered: (opts?: unknown) =>
35-
listChannelPluginCatalogEntries(opts),
34+
listRawChannelPluginCatalogEntries: (opts?: unknown) => listChannelPluginCatalogEntries(opts),
3635
getChannelPluginCatalogEntry: (...args: unknown[]) =>
3736
getChannelPluginCatalogEntry(...(args as [string, Record<string, unknown>])),
3837
}));

src/commands/channels.add.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const bundledMocks = vi.hoisted(() => ({
6565
vi.mock("../channels/plugins/catalog.js", () => ({
6666
getChannelPluginCatalogEntry: catalogMocks.getChannelPluginCatalogEntry,
6767
listChannelPluginCatalogEntries: catalogMocks.listChannelPluginCatalogEntries,
68-
listChannelPluginCatalogEntriesUnfiltered: catalogMocks.listChannelPluginCatalogEntries,
68+
listRawChannelPluginCatalogEntries: catalogMocks.listChannelPluginCatalogEntries,
6969
}));
7070

7171
vi.mock("./channel-setup/discovery.js", () => ({

0 commit comments

Comments
 (0)