mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
refactor: consolidate coercion contracts (#122458)
* refactor: consolidate coercion contracts Centralize exact string, record, numeric, date, Boolean, argument, and structured-error coercions while preserving call-site semantics. Migrate canonical-name collisions and deprecated internal SDK bypasses, deleting 55 net production/tooling lines. Expand declaration ownership enforcement to 101 allowed helpers and add a narrow export-completeness audit. * fix: preserve standalone script coercions Keep copied Control UI tooling self-contained and retain the trusted release harness module-relative source seam when the harness runs against an old target cwd.
This commit is contained in:
committed by
GitHub
parent
66fe424590
commit
b080dd1e76
@@ -12,7 +12,11 @@ import {
|
||||
ModelSelectionLockedError,
|
||||
} from "openclaw/plugin-sdk/model-session-runtime";
|
||||
import type { OpenClawPluginToolContext } from "openclaw/plugin-sdk/plugin-entry";
|
||||
import { asBoolean, asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
import {
|
||||
asBoolean,
|
||||
asOptionalRecord,
|
||||
asSafeIntegerInRange,
|
||||
} from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
import { Type } from "typebox";
|
||||
import { resolveCodexBindingAppServerConnection } from "./app-server/binding-connection.js";
|
||||
import { CODEX_CONTROL_METHODS } from "./app-server/capabilities.js";
|
||||
@@ -112,12 +116,6 @@ type CodexThreadsToolOptions = {
|
||||
request?: typeof codexControlRequest;
|
||||
};
|
||||
|
||||
function readLimit(value: unknown): number | undefined {
|
||||
return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 100
|
||||
? value
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function resolveToolSession(
|
||||
context: OpenClawPluginToolContext,
|
||||
runtime: PluginRuntime,
|
||||
@@ -291,7 +289,7 @@ export function createCodexThreadsTool(options: CodexThreadsToolOptions): AnyAge
|
||||
CODEX_CONTROL_METHODS.listThreads,
|
||||
{
|
||||
archived: asBoolean(params.archived) ?? false,
|
||||
limit: readLimit(params.limit) ?? 20,
|
||||
limit: asSafeIntegerInRange(params.limit, { min: 1, max: 100 }) ?? 20,
|
||||
modelProviders: [],
|
||||
sortKey: "recency_at",
|
||||
sortDirection: "desc",
|
||||
|
||||
Reference in New Issue
Block a user