Skip to content

Commit 745b8c3

Browse files
fix(codex-supervisor): ship CLI metadata entry (#102803)
* fix(codex-supervisor): ship CLI metadata entry * chore: keep release notes in PR body --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent b714fdb commit 745b8c3

6 files changed

Lines changed: 102 additions & 11 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Codex Supervisor tests cover lightweight CLI discovery and lazy registration.
2+
import { Command } from "commander";
3+
import { createTestPluginApi } from "openclaw/plugin-sdk/plugin-test-api";
4+
import { describe, expect, it, vi } from "vitest";
5+
6+
const mocks = vi.hoisted(() => ({
7+
registerCodexSupervisorCli: vi.fn(),
8+
}));
9+
10+
vi.mock("./src/cli.js", () => ({
11+
registerCodexSupervisorCli: mocks.registerCodexSupervisorCli,
12+
}));
13+
14+
import entry from "./cli-metadata.js";
15+
16+
describe("codex-supervisor CLI metadata entry", () => {
17+
it("advertises codex and loads its registrar only when invoked", async () => {
18+
const registerCli = vi.fn();
19+
const api = createTestPluginApi({
20+
id: "codex-supervisor",
21+
name: "Codex Supervisor",
22+
registerCli,
23+
});
24+
25+
entry.register(api);
26+
27+
expect(registerCli).toHaveBeenCalledWith(expect.any(Function), {
28+
descriptors: [
29+
{
30+
name: "codex",
31+
description: "Inspect Codex sessions across the Gateway and paired nodes",
32+
hasSubcommands: true,
33+
},
34+
],
35+
});
36+
expect(mocks.registerCodexSupervisorCli).not.toHaveBeenCalled();
37+
38+
const registrar = registerCli.mock.calls[0]?.[0];
39+
if (typeof registrar !== "function") {
40+
throw new Error("expected codex-supervisor CLI registrar");
41+
}
42+
const program = new Command();
43+
await registrar({
44+
program,
45+
parentPath: [],
46+
config: {},
47+
workspaceDir: undefined,
48+
logger: api.logger,
49+
});
50+
51+
expect(mocks.registerCodexSupervisorCli).toHaveBeenCalledWith(program);
52+
});
53+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Codex Supervisor CLI metadata stays lightweight until the command runs.
2+
import { definePluginEntry, type OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
3+
4+
export function registerCodexSupervisorCliMetadata(api: OpenClawPluginApi): void {
5+
api.registerCli(
6+
async ({ program }) => {
7+
const { registerCodexSupervisorCli } = await import("./src/cli.js");
8+
registerCodexSupervisorCli(program);
9+
},
10+
{
11+
descriptors: [
12+
{
13+
name: "codex",
14+
description: "Inspect Codex sessions across the Gateway and paired nodes",
15+
hasSubcommands: true,
16+
},
17+
],
18+
},
19+
);
20+
}
21+
22+
export default definePluginEntry({
23+
id: "codex-supervisor",
24+
name: "Codex Supervisor",
25+
description: "Supervise Codex app-server sessions from OpenClaw.",
26+
register: registerCodexSupervisorCliMetadata,
27+
});

extensions/codex-supervisor/index.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* OpenClaw agents.
44
*/
55
import { buildJsonPluginConfigSchema, definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
6-
import { registerCodexSupervisorCli } from "./src/cli.js";
6+
import { registerCodexSupervisorCliMetadata } from "./cli-metadata.js";
77
import {
88
CodexSupervisorPluginConfigSchema,
99
resolveCodexSupervisorPluginConfig,
@@ -46,15 +46,7 @@ export default definePluginEntry({
4646
api.registerNodeInvokePolicy(policy);
4747
}
4848
registerCodexSessionCatalogGateway({ api, supervisor: catalogSupervisor });
49-
api.registerCli(({ program }) => registerCodexSupervisorCli(program), {
50-
descriptors: [
51-
{
52-
name: "codex",
53-
description: "Inspect Codex sessions across the Gateway and paired nodes",
54-
hasSubcommands: true,
55-
},
56-
],
57-
});
49+
registerCodexSupervisorCliMetadata(api);
5850
for (const tool of createCodexSupervisorTools({
5951
supervisor,
6052
policy: {

extensions/codex-supervisor/openclaw.plugin.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"id": "codex-supervisor",
33
"enabledByDefault": false,
44
"activation": {
5-
"onStartup": true
5+
"onStartup": true,
6+
"onCommands": ["codex"]
67
},
78
"name": "Codex Supervisor",
89
"description": "Supervise Codex app-server sessions from OpenClaw.",

src/plugins/bundled-plugin-metadata.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ describe("bundled plugin metadata", () => {
579579
expect(entry?.manifest.activation?.onCommands).toStrictEqual(["voicecall"]);
580580
});
581581

582+
it("scopes Codex Supervisor CLI activation to the codex command", () => {
583+
const entry = listRepoBundledPluginManifests().find(
584+
({ manifest }) => manifest.id === "codex-supervisor",
585+
);
586+
587+
expect(entry?.manifest.activation?.onCommands).toStrictEqual(["codex"]);
588+
});
589+
582590
it("keeps empty-config Gateway startup narrower than declared startup sidecars", () => {
583591
const manifestRegistry = createRepoBundledManifestRegistry();
584592
const index = createInstalledPluginIndexForManifests(manifestRegistry);

test/scripts/bundled-plugin-build-entries.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ describe("bundled plugin build entries", () => {
6868
expect(pickEntries(entries, Object.keys(expectedEntries))).toStrictEqual(expectedEntries);
6969
});
7070

71+
it("keeps Codex Supervisor CLI metadata in bundled build and pack entries", () => {
72+
const entries = listBundledPluginBuildEntries();
73+
const artifacts = listBundledPluginPackArtifacts();
74+
75+
expect(entries["extensions/codex-supervisor/cli-metadata"]).toBe(
76+
"extensions/codex-supervisor/cli-metadata.ts",
77+
);
78+
expect(artifacts).toContain("dist/extensions/codex-supervisor/cli-metadata.js");
79+
});
80+
7181
it("filters bundled plugin build entries for bounded script lanes", () => {
7282
const entries = listBundledPluginBuildEntries({
7383
env: {

0 commit comments

Comments
 (0)