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;" />

1 lines 1.55 kB
{"version":3,"file":"intelligence-utils.cjs","names":["PlatformRequestError"],"sources":["../../../../../src/v2/runtime/handlers/shared/intelligence-utils.ts"],"sourcesContent":["import { PlatformRequestError } from \"../../intelligence-platform/client\";\n\n/**\n * Returns the HTTP status carried by platform request errors.\n */\nexport function getPlatformErrorStatus(error: unknown): number | undefined {\n if (error instanceof PlatformRequestError) {\n return error.status;\n }\n\n if (\n error !== null &&\n typeof error === \"object\" &&\n \"status\" in error &&\n typeof error.status === \"number\"\n ) {\n return error.status;\n }\n\n return undefined;\n}\n\nexport function isPlatformNotFoundError(error: unknown): boolean {\n return getPlatformErrorStatus(error) === 404;\n}\n\nconst MAX_ID_LENGTH = 128;\nconst SAFE_ID_PATTERN = /^[\\w.@:=-]+$/;\n\n/**\n * Validates that a string identifier (userId, agentId) is safe to pass through.\n * Returns `true` if valid, `false` otherwise.\n */\nexport function isValidIdentifier(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.length > 0 &&\n value.length <= MAX_ID_LENGTH &&\n SAFE_ID_PATTERN.test(value)\n );\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,uBAAuB,OAAoC;AACzE,KAAI,iBAAiBA,oCACnB,QAAO,MAAM;AAGf,KACE,UAAU,QACV,OAAO,UAAU,YACjB,YAAY,SACZ,OAAO,MAAM,WAAW,SAExB,QAAO,MAAM;;AAUjB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;;;;;AAMxB,SAAgB,kBAAkB,OAAiC;AACjE,QACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,UAAU,iBAChB,gBAAgB,KAAK,MAAM"}