mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -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
@@ -1,5 +1,6 @@
|
||||
// Bridges TUI chat requests to gateway session APIs.
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
|
||||
import { gatewayOriginScope } from "../../packages/gateway-client/src/gateway-origin-scope.js";
|
||||
import {
|
||||
GATEWAY_CLIENT_CAPS,
|
||||
@@ -114,10 +115,6 @@ function resolveStartupRetryDelayMs(err: GatewayClientRequestError): number {
|
||||
return Math.min(Math.max(retryAfterMs, 100), STARTUP_CHAT_HISTORY_MAX_RETRY_MS);
|
||||
}
|
||||
|
||||
function nonEmptyString(value: unknown): string | undefined {
|
||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
||||
}
|
||||
|
||||
function hasStoredOriginDeviceAuth(deviceAuthScope: string): boolean {
|
||||
try {
|
||||
const identity = loadDeviceIdentityIfPresent();
|
||||
@@ -306,8 +303,8 @@ export class GatewayChatClient implements TuiBackend {
|
||||
timeoutMs: opts.timeoutMs,
|
||||
idempotencyKey: runId,
|
||||
});
|
||||
const acceptedRunId = nonEmptyString(response?.runId) ?? runId;
|
||||
const status = nonEmptyString(response?.status);
|
||||
const acceptedRunId = normalizeOptionalString(response?.runId) ?? runId;
|
||||
const status = normalizeOptionalString(response?.status);
|
||||
return status ? { runId: acceptedRunId, status } : { runId: acceptedRunId };
|
||||
}
|
||||
|
||||
@@ -576,7 +573,7 @@ async function resolveGatewayConnection(
|
||||
resolveTlsFingerprint: async ({ urlSource, explicitTlsFingerprint }) =>
|
||||
explicitTlsFingerprint ??
|
||||
(urlSource === "config gateway.remote.url"
|
||||
? nonEmptyString(config.gateway?.remote?.tlsFingerprint)
|
||||
? normalizeOptionalString(config.gateway?.remote?.tlsFingerprint)
|
||||
: undefined),
|
||||
});
|
||||
const hasStoredOriginAuth = Boolean(
|
||||
|
||||
Reference in New Issue
Block a user