{"version":3,"file":"telemetry-client.cjs","names":["TelemetryClient","resolveEndpointType","EndpointType"],"sources":["../../src/lib/telemetry-client.ts"],"sourcesContent":["import { TelemetryClient } from \"@copilotkit/shared\";\nimport { createHash } from \"node:crypto\";\nimport { CopilotRuntime, resolveEndpointType } from \"./runtime/copilot-runtime\";\nimport { RuntimeInstanceCreatedInfo } from \"@copilotkit/shared/src/telemetry/events\";\nimport { CreateCopilotRuntimeServerOptions } from \"./integrations/shared\";\nimport { EndpointType, LangGraphPlatformEndpoint } from \"./runtime/types\";\nconst packageJson = require(\"../../package.json\");\n\nconst telemetryClient = new TelemetryClient({\n  packageName: packageJson.name,\n  packageVersion: packageJson.version,\n});\n\nexport function getRuntimeInstanceTelemetryInfo(\n  options: CreateCopilotRuntimeServerOptions,\n): RuntimeInstanceCreatedInfo {\n  const runtime = options.runtime;\n  const remoteEndpoints = runtime.params?.remoteEndpoints ?? [];\n  const endpointsInfo = remoteEndpoints.reduce(\n    (acc, endpoint) => {\n      let info = { ...acc };\n\n      const endpointType = resolveEndpointType(endpoint);\n      if (!info.endpointTypes.includes(endpointType)) {\n        info = {\n          ...info,\n          endpointTypes: [...info.endpointTypes, endpointType],\n        };\n      }\n\n      if (endpointType === EndpointType.LangGraphPlatform) {\n        // When type is resolved, recreating a const with casting of type\n        const ep = endpoint as LangGraphPlatformEndpoint;\n        info = {\n          ...info,\n          agentsAmount: ep.agents.length,\n          hashedKey: ep.langsmithApiKey\n            ? createHash(\"sha256\").update(ep.langsmithApiKey).digest(\"hex\")\n            : null,\n        };\n      }\n\n      return info;\n    },\n    { endpointTypes: [], agentsAmount: null, hashedKey: null },\n  );\n\n  // Get public API key from options.cloud.publicApiKey\n  const publicApiKey = options.cloud?.publicApiKey;\n  const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;\n\n  return {\n    actionsAmount: runtime.params?.actions?.length ?? 0,\n    endpointsAmount: remoteEndpoints.length,\n    endpointTypes: endpointsInfo.endpointTypes,\n    agentsAmount: Object.keys(runtime.instance.agents).length,\n    hashedLgcKey: endpointsInfo.hashedKey,\n    \"cloud.api_key_provided\": apiKeyProvided,\n    ...(apiKeyProvided ? { \"cloud.public_api_key\": publicApiKey } : {}),\n    ...(options.cloud?.baseUrl\n      ? { \"cloud.base_url\": options.cloud.baseUrl }\n      : {}),\n  } as RuntimeInstanceCreatedInfo;\n}\n\nexport default telemetryClient;\n"],"mappings":";;;;;;;;;AAMA,MAAM;AAEN,MAAM,kBAAkB,IAAIA,mCAAgB;CAC1C,aAAa,YAAY;CACzB,gBAAgB,YAAY;CAC7B,CAAC;AAEF,SAAgB,gCACd,SAC4B;CAC5B,MAAM,UAAU,QAAQ;CACxB,MAAM,kBAAkB,QAAQ,QAAQ,mBAAmB,EAAE;CAC7D,MAAM,gBAAgB,gBAAgB,QACnC,KAAK,aAAa;EACjB,IAAI,OAAO,EAAE,GAAG,KAAK;EAErB,MAAM,eAAeC,4CAAoB,SAAS;AAClD,MAAI,CAAC,KAAK,cAAc,SAAS,aAAa,CAC5C,QAAO;GACL,GAAG;GACH,eAAe,CAAC,GAAG,KAAK,eAAe,aAAa;GACrD;AAGH,MAAI,iBAAiBC,2BAAa,mBAAmB;GAEnD,MAAM,KAAK;AACX,UAAO;IACL,GAAG;IACH,cAAc,GAAG,OAAO;IACxB,WAAW,GAAG,8CACC,SAAS,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO,MAAM,GAC7D;IACL;;AAGH,SAAO;IAET;EAAE,eAAe,EAAE;EAAE,cAAc;EAAM,WAAW;EAAM,CAC3D;CAGD,MAAM,eAAe,QAAQ,OAAO;CACpC,MAAM,iBAAiB,CAAC,CAAC,gBAAgB,aAAa,MAAM,CAAC,SAAS;AAEtE,QAAO;EACL,eAAe,QAAQ,QAAQ,SAAS,UAAU;EAClD,iBAAiB,gBAAgB;EACjC,eAAe,cAAc;EAC7B,cAAc,OAAO,KAAK,QAAQ,SAAS,OAAO,CAAC;EACnD,cAAc,cAAc;EAC5B,0BAA0B;EAC1B,GAAI,iBAAiB,EAAE,wBAAwB,cAAc,GAAG,EAAE;EAClE,GAAI,QAAQ,OAAO,UACf,EAAE,kBAAkB,QAAQ,MAAM,SAAS,GAC3C,EAAE;EACP"}