MCPcopy Index your code
hub / github.com/coder/mux / normalizeFinishReason

Function normalizeFinishReason

src/node/utils/gatewayStreamNormalization.ts:73–81  ·  view source on GitHub ↗
(fr: unknown)

Source from the content-addressed store, hash-verified

71 * The gateway server may send a plain string instead of the nested object.
72 */
73export function normalizeFinishReason(fr: unknown): { unified: string; raw: unknown } | undefined {
74 if (fr == null) return undefined;
75 if (typeof fr === "object" && "unified" in (fr as Record<string, unknown>)) {
76 return fr as { unified: string; raw: unknown };
77 }
78 // Plain string → convert to v3 object
79 const str = typeof fr === "string" ? fr : "other";
80 return { unified: str === "unknown" ? "other" : str, raw: str };
81}
82
83/**
84 * Normalize a doGenerate result from the gateway.

Callers 3

transformFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected