{"version":3,"file":"intelligence-utils.mjs","names":[],"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,iBAAiB,qBACnB,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"}