mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 06:01:11 +00:00
* refactor(browser): collapse Playwright export paths * refactor(browser): remove dead plugin exports * refactor(codex): remove dead app-server exports * refactor(codex): remove remaining dead exports * test(codex): use canonical private-type owners * test(browser): isolate proxy startup state * test(browser): remove stale chrome imports * refactor(codex): privatize remaining helpers * chore(deadcode): refresh export baseline after rebase * refactor(browser): finish canonical helper ownership * refactor: fix dead-export cleanup gates * refactor(codex): keep runtime facades LOC-neutral * chore(ci): refresh TypeScript LOC baseline * chore(deadcode): refresh ratchets after rebase * chore(ci): refresh LOC baseline after main advance * chore(deadcode): align ratchets with latest main
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import type { PluginCommandContext, PluginCommandResult } from "openclaw/plugin-sdk/plugin-entry";
|
|
import { describeControlFailure } from "./app-server/capabilities.js";
|
|
import { formatCodexDisplayText } from "./command-formatters.js";
|
|
import type { CodexCommandDepsOverride } from "./command-handlers.js";
|
|
|
|
type CodexCommandOptions = {
|
|
pluginConfig?: unknown;
|
|
resolvePluginConfig?: () => unknown;
|
|
deps: CodexCommandDepsOverride;
|
|
};
|
|
|
|
type CodexSubcommandHandler = (
|
|
ctx: PluginCommandContext,
|
|
options: CodexCommandOptions,
|
|
) => Promise<PluginCommandResult>;
|
|
|
|
type CodexCommandInternalOptions = CodexCommandOptions & {
|
|
loadSubcommandHandler?: () => Promise<CodexSubcommandHandler>;
|
|
};
|
|
|
|
/** Dispatches a `/codex` command to the lazily loaded handler. */
|
|
export async function handleCodexCommand(
|
|
ctx: PluginCommandContext,
|
|
options: CodexCommandInternalOptions,
|
|
): Promise<PluginCommandResult> {
|
|
const { loadSubcommandHandler, resolvePluginConfig, ...subcommandOptions } = options;
|
|
try {
|
|
const handleCodexSubcommand = loadSubcommandHandler
|
|
? await loadSubcommandHandler()
|
|
: await loadDefaultCodexSubcommandHandler();
|
|
return await handleCodexSubcommand(ctx, {
|
|
...subcommandOptions,
|
|
pluginConfig: resolvePluginConfig?.() ?? subcommandOptions.pluginConfig,
|
|
});
|
|
} catch (error) {
|
|
return {
|
|
text: `Codex command failed: ${formatCodexDisplayText(describeControlFailure(error))}`,
|
|
};
|
|
}
|
|
}
|
|
|
|
async function loadDefaultCodexSubcommandHandler(): Promise<CodexSubcommandHandler> {
|
|
const { handleCodexSubcommand } = await import("./command-handlers.js");
|
|
return handleCodexSubcommand;
|
|
}
|