mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -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
@@ -255,7 +255,10 @@ function numericTimerValueMs(valueMs: unknown) {
|
||||
return Number.isFinite(value) ? Math.floor(value) : undefined;
|
||||
}
|
||||
|
||||
function resolveTimerTimeoutMs(valueMs: unknown, fallbackMs: unknown = MAX_TIMER_TIMEOUT_MS) {
|
||||
function resolveDockerSchedulerTimeoutMs(
|
||||
valueMs: unknown,
|
||||
fallbackMs: unknown = MAX_TIMER_TIMEOUT_MS,
|
||||
) {
|
||||
const value = numericTimerValueMs(valueMs) ?? numericTimerValueMs(fallbackMs);
|
||||
return Math.min(Math.max(value ?? MAX_TIMER_TIMEOUT_MS, 1), MAX_TIMER_TIMEOUT_MS);
|
||||
}
|
||||
@@ -265,7 +268,7 @@ function resolveOptionalTimerTimeoutMs(valueMs: unknown) {
|
||||
if (value === undefined || value <= 0) {
|
||||
return undefined;
|
||||
}
|
||||
return resolveTimerTimeoutMs(value);
|
||||
return resolveDockerSchedulerTimeoutMs(value);
|
||||
}
|
||||
|
||||
function resourceLimitsSummary(resourceLimits: Record<string, number>) {
|
||||
@@ -819,7 +822,7 @@ export function runShellCommand({
|
||||
return new Promise<ShellCommandResult>((resolve) => {
|
||||
const resolvedTimeoutMs = resolveOptionalTimerTimeoutMs(timeoutMs);
|
||||
const resolvedNoOutputTimeoutMs = resolveOptionalTimerTimeoutMs(noOutputTimeoutMs);
|
||||
const resolvedTimeoutKillGraceMs = resolveTimerTimeoutMs(
|
||||
const resolvedTimeoutKillGraceMs = resolveDockerSchedulerTimeoutMs(
|
||||
timeoutKillGraceMs,
|
||||
SHELL_TIMEOUT_KILL_GRACE_MS,
|
||||
);
|
||||
@@ -951,7 +954,7 @@ export function runShellCaptureCommand({
|
||||
}
|
||||
return new Promise<ShellCaptureResult>((resolve) => {
|
||||
const resolvedTimeoutMs = resolveOptionalTimerTimeoutMs(timeoutMs);
|
||||
const resolvedTimeoutKillGraceMs = resolveTimerTimeoutMs(
|
||||
const resolvedTimeoutKillGraceMs = resolveDockerSchedulerTimeoutMs(
|
||||
timeoutKillGraceMs,
|
||||
SHELL_TIMEOUT_KILL_GRACE_MS,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user