{"version":3,"file":"constants.mjs","sources":["../../src/constants.ts"],"sourcesContent":["import { LiveChannelAddress, LiveChannelScope } from \"@grafana/data\";\nimport { logWarning } from \"@grafana/runtime\";\n\nimport { SemVer } from \"semver\";\n\nexport const LLM_PLUGIN_ID = \"grafana-llm-app\";\nexport const LLM_PLUGIN_ROUTE = `/api/plugins/${LLM_PLUGIN_ID}`;\n\n// Grafana 12.4 renamed `LiveChannelAddress.namespace` to `stream` and now\n// builds the channel id from `stream`, ignoring `namespace`. Older versions do\n// the reverse. We must set both so a single plugin build subscribes to the\n// correct channel regardless of which Grafana version is running; omitting\n// `stream` on 12.4+ yields a `plugin/undefined/...` channel that never routes.\n// The intersection adds `stream` to the type without losing type checking on\n// the other fields, even when building against a pre-12.4 `@grafana/data`.\ntype PluginLiveChannelAddress = LiveChannelAddress & { stream: string };\n\nexport function pluginLiveChannel(\n  path: string,\n  data?: unknown,\n): PluginLiveChannelAddress {\n  return {\n    scope: LiveChannelScope.Plugin,\n    namespace: LLM_PLUGIN_ID,\n    stream: LLM_PLUGIN_ID,\n    path,\n    data,\n  };\n}\n\n// The LLM app was at version 0.2.0 before we added the health check.\n// If the health check fails, or the details don't exist on the response,\n// we should assume it's this older version.\nexport let LLM_PLUGIN_VERSION = new SemVer(\"0.2.0\");\n\nexport function setLLMPluginVersion(version: string) {\n  try {\n    LLM_PLUGIN_VERSION = new SemVer(version);\n  } catch (e) {\n    logWarning(\n      \"Failed to parse version of grafana-llm-app; assuming old version is present.\",\n    );\n  }\n}\n"],"names":[],"mappings":";;;;AAKO,MAAM,aAAA,GAAgB;AACtB,MAAM,gBAAA,GAAmB,gBAAgB,aAAa,CAAA;AAWtD,SAAS,iBAAA,CACd,MACA,IAAA,EAC0B;AAC1B,EAAA,OAAO;AAAA,IACL,OAAO,gBAAA,CAAiB,MAAA;AAAA,IACxB,SAAA,EAAW,aAAA;AAAA,IACX,MAAA,EAAQ,aAAA;AAAA,IACR,IAAA;AAAA,IACA;AAAA,GACF;AACF;AAKO,IAAI,kBAAA,GAAqB,IAAI,MAAA,CAAO,OAAO;AAE3C,SAAS,oBAAoB,OAAA,EAAiB;AACnD,EAAA,IAAI;AACF,IAAA,kBAAA,GAAqB,IAAI,OAAO,OAAO,CAAA;AAAA,EACzC,SAAS,CAAA,EAAG;AACV,IAAA,UAAA;AAAA,MACE;AAAA,KACF;AAAA,EACF;AACF;;;;"}