MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / clampedStringify

Function clampedStringify

packages/plugins/openapi/src/sdk/backing.ts:83–92  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

81const decodeUpstreamDescriptionBody = Schema.decodeUnknownOption(UpstreamDescriptionBody);
82
83const clampedStringify = (value: unknown): string => {
84 let s: string;
85 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: JSON.stringify may throw on cycles; fall back to String() so the upstream body can still be surfaced as ToolError.details fallback text
86 try {
87 s = JSON.stringify(value);
88 } catch {
89 s = String(value);
90 }
91 return s.length > STRINGIFIED_BODY_CAP ? `${s.slice(0, STRINGIFIED_BODY_CAP)}…` : s;
92};
93
94const firstNonEmpty = (...values: readonly (string | undefined)[]): string | undefined =>
95 values.find((value) => value !== undefined && value.length > 0);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected