mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 17:24:05 +00:00
fix(codex): centralize session limit parsing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import crypto from "node:crypto";
|
||||
import { resolveAgentDir, resolveSessionAgentIds } from "openclaw/plugin-sdk/agent-runtime";
|
||||
import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
|
||||
import type { PluginCommandContext, PluginCommandResult } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
import { CODEX_CONTROL_METHODS, type CodexControlMethod } from "./app-server/capabilities.js";
|
||||
@@ -1932,9 +1933,8 @@ function parseCodexCliSessionsArgs(args: string[]): ParsedCodexCliSessionsArgs {
|
||||
}
|
||||
if (arg === "--limit") {
|
||||
const value = readRequiredOptionValue(args, index);
|
||||
const parsedLimit =
|
||||
value && /^\+?\d+$/.test(value.trim()) ? Number(value.trim()) : Number.NaN;
|
||||
if (!Number.isSafeInteger(parsedLimit) || parsedLimit <= 0) {
|
||||
const parsedLimit = parseStrictPositiveInteger(value);
|
||||
if (parsedLimit === undefined) {
|
||||
parsed.help = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -595,6 +595,26 @@ describe("codex command", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes signed decimal Codex CLI session limits before node dispatch", async () => {
|
||||
const listCodexCliSessionsOnNode = vi.fn(async () => ({
|
||||
node: { nodeId: "mb-m5", displayName: "mb-m5" },
|
||||
result: {
|
||||
codexHome: "/Users/mariano/.codex",
|
||||
sessions: [],
|
||||
},
|
||||
}));
|
||||
|
||||
await handleCodexCommand(createContext("sessions --host mb-m5 --limit +05 bridge"), {
|
||||
deps: createDeps({ listCodexCliSessionsOnNode }),
|
||||
});
|
||||
|
||||
expect(listCodexCliSessionsOnNode).toHaveBeenCalledWith({
|
||||
requestedNode: "mb-m5",
|
||||
filter: "bridge",
|
||||
limit: 5,
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects partial Codex CLI session limits before node dispatch", async () => {
|
||||
const listCodexCliSessionsOnNode = vi.fn();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user