UNPKG

@copilotkit/runtime

Version:

<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />

24 lines (22 loc) 947 B
import "reflect-metadata"; import { PlatformRequestError } from "../../intelligence-platform/client.mjs"; //#region src/v2/runtime/handlers/shared/intelligence-utils.ts /** * Returns the HTTP status carried by platform request errors. */ function getPlatformErrorStatus(error) { if (error instanceof PlatformRequestError) return error.status; if (error !== null && typeof error === "object" && "status" in error && typeof error.status === "number") return error.status; } const MAX_ID_LENGTH = 128; const SAFE_ID_PATTERN = /^[\w.@:=-]+$/; /** * Validates that a string identifier (userId, agentId) is safe to pass through. * Returns `true` if valid, `false` otherwise. */ function isValidIdentifier(value) { return typeof value === "string" && value.length > 0 && value.length <= MAX_ID_LENGTH && SAFE_ID_PATTERN.test(value); } //#endregion export { getPlatformErrorStatus, isValidIdentifier }; //# sourceMappingURL=intelligence-utils.mjs.map