Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
429 lines
13 KiB
TypeScript
429 lines
13 KiB
TypeScript
// Codex tests cover plugin inventory plugin behavior.
|
|
import { describe, expect, it } from "vitest";
|
|
import { CodexAppInventoryCache } from "./app-inventory-cache.js";
|
|
import { CODEX_PLUGINS_MARKETPLACE_NAME } from "./config.js";
|
|
import { findOpenAiCuratedPluginSummary, readCodexPluginInventory } from "./plugin-inventory.js";
|
|
import type { v2 } from "./protocol.js";
|
|
|
|
describe("Codex plugin inventory", () => {
|
|
it("returns enabled migrated curated plugins with stable owned app ids", async () => {
|
|
const appCache = new CodexAppInventoryCache();
|
|
await appCache.refreshNow({
|
|
key: "runtime",
|
|
nowMs: 0,
|
|
request: async () => ({
|
|
data: [appInfo("google-calendar-app", true)],
|
|
nextCursor: null,
|
|
}),
|
|
});
|
|
const calls: string[] = [];
|
|
const inventory = await readCodexPluginInventory({
|
|
pluginConfig: {
|
|
codexPlugins: {
|
|
enabled: true,
|
|
plugins: {
|
|
"google-calendar": {
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
pluginName: "google-calendar",
|
|
},
|
|
slack: {
|
|
enabled: false,
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
pluginName: "slack",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
appCache,
|
|
appCacheKey: "runtime",
|
|
nowMs: 1,
|
|
request: async (method, params) => {
|
|
calls.push(method);
|
|
if (method === "plugin/list") {
|
|
return pluginList([
|
|
pluginSummary("google-calendar", { installed: true, enabled: true }),
|
|
pluginSummary("slack", { installed: true, enabled: true }),
|
|
]);
|
|
}
|
|
if (method === "plugin/read") {
|
|
expect(params).toEqual({
|
|
marketplacePath: "/marketplaces/openai-curated",
|
|
pluginName: "google-calendar",
|
|
});
|
|
return pluginDetail("google-calendar", [appSummary("google-calendar-app")]);
|
|
}
|
|
throw new Error(`unexpected request ${method}`);
|
|
},
|
|
});
|
|
|
|
expect(inventory.records).toHaveLength(1);
|
|
const record = inventory.records[0];
|
|
expect(record?.policy.pluginName).toBe("google-calendar");
|
|
expect(record?.summary.installed).toBe(true);
|
|
expect(record?.summary.enabled).toBe(true);
|
|
expect(record?.appOwnership).toBe("proven");
|
|
expect(record?.ownedAppIds).toStrictEqual(["google-calendar-app"]);
|
|
expect(record?.apps).toStrictEqual([
|
|
{
|
|
id: "google-calendar-app",
|
|
name: "google-calendar-app",
|
|
accessible: true,
|
|
enabled: true,
|
|
needsAuth: false,
|
|
},
|
|
]);
|
|
expect(calls).toEqual(["plugin/list", "plugin/read"]);
|
|
});
|
|
|
|
it("matches namespaced curated plugin ids by normalized path segment", async () => {
|
|
const appCache = new CodexAppInventoryCache();
|
|
await appCache.refreshNow({
|
|
key: "runtime",
|
|
nowMs: 0,
|
|
request: async () => ({
|
|
data: [appInfo("github-app", true)],
|
|
nextCursor: null,
|
|
}),
|
|
});
|
|
|
|
const listed = pluginList([
|
|
pluginSummary("openai-curated/github", {
|
|
name: "GitHub",
|
|
installed: true,
|
|
enabled: true,
|
|
}),
|
|
]);
|
|
expect(findOpenAiCuratedPluginSummary(listed, "github")?.summary.id).toBe(
|
|
"openai-curated/github",
|
|
);
|
|
|
|
const inventory = await readCodexPluginInventory({
|
|
pluginConfig: {
|
|
codexPlugins: {
|
|
enabled: true,
|
|
plugins: {
|
|
github: {
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
pluginName: "github",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
appCache,
|
|
appCacheKey: "runtime",
|
|
nowMs: 1,
|
|
request: async (method, params) => {
|
|
if (method === "plugin/list") {
|
|
return listed;
|
|
}
|
|
if (method === "plugin/read") {
|
|
expect(params).toEqual({
|
|
marketplacePath: "/marketplaces/openai-curated",
|
|
pluginName: "github",
|
|
});
|
|
return pluginDetail("github", [appSummary("github-app")]);
|
|
}
|
|
throw new Error(`unexpected request ${method}`);
|
|
},
|
|
});
|
|
|
|
expect(inventory.records).toHaveLength(1);
|
|
const record = inventory.records[0];
|
|
expect(record?.policy.pluginName).toBe("github");
|
|
expect(record?.summary.id).toBe("openai-curated/github");
|
|
expect(record?.summary.installed).toBe(true);
|
|
expect(record?.summary.enabled).toBe(true);
|
|
expect(record?.appOwnership).toBe("proven");
|
|
expect(record?.ownedAppIds).toStrictEqual(["github-app"]);
|
|
expect(inventory.diagnostics.map((diagnostic) => diagnostic.code)).not.toContain(
|
|
"plugin_missing",
|
|
);
|
|
});
|
|
|
|
it("accepts the remote curated marketplace wire name", async () => {
|
|
const appCache = new CodexAppInventoryCache();
|
|
await appCache.refreshNow({
|
|
key: "runtime",
|
|
nowMs: 0,
|
|
request: async () => ({
|
|
data: [appInfo("google-calendar-app", true)],
|
|
nextCursor: null,
|
|
}),
|
|
});
|
|
const remoteSummary = pluginSummary("google-calendar@openai-curated-remote", {
|
|
name: "google-calendar",
|
|
remotePluginId: "plugin_connector_google_calendar",
|
|
installed: true,
|
|
enabled: true,
|
|
});
|
|
const localListed = pluginList([pluginSummary("github")]);
|
|
const listed = {
|
|
...localListed,
|
|
marketplaces: [
|
|
...localListed.marketplaces,
|
|
{
|
|
name: "openai-curated-remote",
|
|
path: null,
|
|
interface: null,
|
|
plugins: [remoteSummary],
|
|
},
|
|
],
|
|
} satisfies v2.PluginListResponse;
|
|
|
|
const inventory = await readCodexPluginInventory({
|
|
pluginConfig: {
|
|
codexPlugins: {
|
|
enabled: true,
|
|
plugins: {
|
|
"google-calendar": {
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
pluginName: "google-calendar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
appCache,
|
|
appCacheKey: "runtime",
|
|
nowMs: 1,
|
|
request: async (method, params) => {
|
|
if (method === "plugin/list") {
|
|
return listed;
|
|
}
|
|
if (method === "plugin/read") {
|
|
expect(params).toEqual({
|
|
remoteMarketplaceName: "openai-curated-remote",
|
|
pluginName: "plugin_connector_google_calendar",
|
|
});
|
|
return pluginDetail("google-calendar", [appSummary("google-calendar-app")]);
|
|
}
|
|
throw new Error(`unexpected request ${method}`);
|
|
},
|
|
});
|
|
|
|
expect(inventory.marketplace).toEqual({
|
|
name: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
remoteMarketplaceName: "openai-curated-remote",
|
|
});
|
|
expect(inventory.records[0]?.ownedAppIds).toStrictEqual(["google-calendar-app"]);
|
|
expect(inventory.records[0]?.apps[0]?.accessible).toBe(true);
|
|
expect(inventory.diagnostics).toStrictEqual([]);
|
|
});
|
|
|
|
it("fails closed when plugin detail apps are absent from app inventory", async () => {
|
|
const appCache = new CodexAppInventoryCache();
|
|
await appCache.refreshNow({
|
|
key: "runtime",
|
|
nowMs: 0,
|
|
request: async () => ({
|
|
data: [],
|
|
nextCursor: null,
|
|
}),
|
|
});
|
|
const inventory = await readCodexPluginInventory({
|
|
pluginConfig: {
|
|
codexPlugins: {
|
|
enabled: true,
|
|
plugins: {
|
|
"google-calendar": {
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
pluginName: "google-calendar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
appCache,
|
|
appCacheKey: "runtime",
|
|
nowMs: 1,
|
|
request: async (method) => {
|
|
if (method === "plugin/list") {
|
|
return pluginList([pluginSummary("google-calendar", { installed: true, enabled: true })]);
|
|
}
|
|
if (method === "plugin/read") {
|
|
return pluginDetail("google-calendar", [appSummary("google-calendar-app")]);
|
|
}
|
|
throw new Error(`unexpected request ${method}`);
|
|
},
|
|
});
|
|
|
|
const record = inventory.records[0];
|
|
expect(record?.appOwnership).toBe("proven");
|
|
expect(record?.authRequired).toBe(true);
|
|
expect(record?.ownedAppIds).toStrictEqual(["google-calendar-app"]);
|
|
expect(record?.apps).toStrictEqual([
|
|
{
|
|
id: "google-calendar-app",
|
|
name: "google-calendar-app",
|
|
accessible: false,
|
|
enabled: false,
|
|
needsAuth: true,
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("marks display-name-only app matches ambiguous instead of exposing app ids", async () => {
|
|
const appCache = new CodexAppInventoryCache();
|
|
await appCache.refreshNow({
|
|
key: "runtime",
|
|
nowMs: 0,
|
|
request: async () => ({
|
|
data: [
|
|
{
|
|
...appInfo("calendar-app", true),
|
|
pluginDisplayNames: ["Google Calendar"],
|
|
},
|
|
],
|
|
nextCursor: null,
|
|
}),
|
|
});
|
|
|
|
const inventory = await readCodexPluginInventory({
|
|
pluginConfig: {
|
|
codexPlugins: {
|
|
enabled: true,
|
|
plugins: {
|
|
"google-calendar": {
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
pluginName: "google-calendar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
appCache,
|
|
appCacheKey: "runtime",
|
|
nowMs: 1,
|
|
readPluginDetails: false,
|
|
request: async (method) => {
|
|
if (method === "plugin/list") {
|
|
return pluginList([
|
|
pluginSummary("google-calendar", {
|
|
name: "Google Calendar",
|
|
installed: true,
|
|
enabled: true,
|
|
}),
|
|
]);
|
|
}
|
|
throw new Error(`unexpected request ${method}`);
|
|
},
|
|
});
|
|
|
|
expect(inventory.records[0]?.appOwnership).toBe("ambiguous");
|
|
expect(inventory.records[0]?.ownedAppIds).toStrictEqual([]);
|
|
expect(inventory.diagnostics.map((diagnostic) => diagnostic.code)).toStrictEqual([
|
|
"app_ownership_ambiguous",
|
|
]);
|
|
});
|
|
|
|
it("fails closed when the app inventory cache is missing", async () => {
|
|
const appCache = new CodexAppInventoryCache();
|
|
const inventory = await readCodexPluginInventory({
|
|
pluginConfig: {
|
|
codexPlugins: {
|
|
enabled: true,
|
|
plugins: {
|
|
"google-calendar": {
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
pluginName: "google-calendar",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
appCache,
|
|
appCacheKey: "runtime",
|
|
request: async (method) => {
|
|
if (method === "app/list") {
|
|
return { data: [], nextCursor: null };
|
|
}
|
|
if (method === "plugin/list") {
|
|
return pluginList([pluginSummary("google-calendar", { installed: true, enabled: true })]);
|
|
}
|
|
if (method === "plugin/read") {
|
|
return pluginDetail("google-calendar", [appSummary("google-calendar-app")]);
|
|
}
|
|
throw new Error(`unexpected request ${method}`);
|
|
},
|
|
});
|
|
|
|
expect(inventory.appInventory?.state).toBe("missing");
|
|
expect(inventory.records[0]?.ownedAppIds).toEqual(["google-calendar-app"]);
|
|
expect(inventory.records[0]?.apps).toStrictEqual([]);
|
|
expect(inventory.diagnostics.map((diagnostic) => diagnostic.code)).toStrictEqual([
|
|
"app_inventory_missing",
|
|
]);
|
|
});
|
|
});
|
|
|
|
function pluginList(
|
|
plugins: v2.PluginSummary[],
|
|
marketplace: { name?: string; path?: string | null } = {},
|
|
): v2.PluginListResponse {
|
|
return {
|
|
marketplaces: [
|
|
{
|
|
name: marketplace.name ?? CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
path: marketplace.path === undefined ? "/marketplaces/openai-curated" : marketplace.path,
|
|
interface: null,
|
|
plugins,
|
|
},
|
|
],
|
|
marketplaceLoadErrors: [],
|
|
featuredPluginIds: [],
|
|
};
|
|
}
|
|
|
|
function pluginSummary(id: string, overrides: Partial<v2.PluginSummary> = {}): v2.PluginSummary {
|
|
return {
|
|
id,
|
|
name: id,
|
|
source: { type: "remote" },
|
|
installed: false,
|
|
enabled: false,
|
|
installPolicy: "AVAILABLE",
|
|
authPolicy: "ON_USE",
|
|
availability: "AVAILABLE",
|
|
interface: null,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
function pluginDetail(pluginName: string, apps: v2.AppSummary[]): v2.PluginReadResponse {
|
|
return {
|
|
plugin: {
|
|
marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
|
|
marketplacePath: "/marketplaces/openai-curated",
|
|
summary: pluginSummary(pluginName, { installed: true, enabled: true }),
|
|
description: null,
|
|
skills: [],
|
|
apps,
|
|
mcpServers: [],
|
|
},
|
|
};
|
|
}
|
|
|
|
function appSummary(id: string): v2.AppSummary {
|
|
return {
|
|
id,
|
|
name: id,
|
|
description: null,
|
|
installUrl: null,
|
|
needsAuth: false,
|
|
};
|
|
}
|
|
|
|
function appInfo(id: string, accessible: boolean): v2.AppInfo {
|
|
return {
|
|
id,
|
|
name: id,
|
|
description: null,
|
|
logoUrl: null,
|
|
logoUrlDark: null,
|
|
distributionChannel: null,
|
|
branding: null,
|
|
appMetadata: null,
|
|
labels: null,
|
|
installUrl: null,
|
|
isAccessible: accessible,
|
|
isEnabled: true,
|
|
pluginDisplayNames: [],
|
|
};
|
|
}
|