{"version":3,"file":"get-runtime-info.mjs","names":[],"sources":["../../../../src/v2/runtime/handlers/get-runtime-info.ts"],"sourcesContent":["import { CopilotRuntimeLike, isIntelligenceRuntime } from \"../core/runtime\";\nimport {\n  AgentDescription,\n  RuntimeInfo,\n  type RuntimeLicenseStatus,\n} from \"@copilotkit/shared\";\nimport { VERSION } from \"../core/runtime\";\n\nfunction resolveLicenseStatus(\n  runtime: CopilotRuntimeLike,\n): RuntimeLicenseStatus {\n  if (!runtime.licenseChecker) return \"none\";\n  const status = runtime.licenseChecker.getStatus();\n  if (status.warningSeverity === \"none\") return \"valid\";\n  if (status.error === \"expired\") return \"expired\";\n  if (status.warningSeverity === \"warning\") return \"expiring\";\n  if (status.error) return \"invalid\";\n  if (status.warningSeverity === \"info\") return \"none\";\n  return \"unknown\";\n}\n\ninterface HandleGetRuntimeInfoParameters {\n  runtime: CopilotRuntimeLike;\n  request: Request;\n}\n\nexport async function handleGetRuntimeInfo({\n  runtime,\n}: HandleGetRuntimeInfoParameters) {\n  try {\n    const agents = await runtime.agents;\n\n    const agentsDict = Object.entries(agents).reduce(\n      (acc, [name, agent]) => {\n        acc[name] = {\n          name,\n          description: agent.description,\n          className: agent.constructor.name,\n        };\n        return acc;\n      },\n      {} as Record<string, AgentDescription>,\n    );\n\n    const runtimeInfo: RuntimeInfo = {\n      version: VERSION,\n      agents: agentsDict,\n      audioFileTranscriptionEnabled: !!runtime.transcriptionService,\n      mode: runtime.mode,\n      ...(isIntelligenceRuntime(runtime)\n        ? {\n            intelligence: {\n              wsUrl: runtime.intelligence.ɵgetClientWsUrl(),\n            },\n          }\n        : {}),\n      a2uiEnabled: !!runtime.a2ui,\n      openGenerativeUIEnabled: !!runtime.openGenerativeUI,\n      ...(isIntelligenceRuntime(runtime)\n        ? { licenseStatus: resolveLicenseStatus(runtime) }\n        : {}),\n    };\n\n    return new Response(JSON.stringify(runtimeInfo), {\n      status: 200,\n      headers: { \"Content-Type\": \"application/json\" },\n    });\n  } catch (error) {\n    return new Response(\n      JSON.stringify({\n        error: \"Failed to retrieve runtime information\",\n        message: error instanceof Error ? error.message : \"Unknown error\",\n      }),\n      {\n        status: 500,\n        headers: { \"Content-Type\": \"application/json\" },\n      },\n    );\n  }\n}\n"],"mappings":";;;;AAQA,SAAS,qBACP,SACsB;AACtB,KAAI,CAAC,QAAQ,eAAgB,QAAO;CACpC,MAAM,SAAS,QAAQ,eAAe,WAAW;AACjD,KAAI,OAAO,oBAAoB,OAAQ,QAAO;AAC9C,KAAI,OAAO,UAAU,UAAW,QAAO;AACvC,KAAI,OAAO,oBAAoB,UAAW,QAAO;AACjD,KAAI,OAAO,MAAO,QAAO;AACzB,KAAI,OAAO,oBAAoB,OAAQ,QAAO;AAC9C,QAAO;;AAQT,eAAsB,qBAAqB,EACzC,WACiC;AACjC,KAAI;EACF,MAAM,SAAS,MAAM,QAAQ;EAc7B,MAAM,cAA2B;GAC/B,SAAS;GACT,QAdiB,OAAO,QAAQ,OAAO,CAAC,QACvC,KAAK,CAAC,MAAM,WAAW;AACtB,QAAI,QAAQ;KACV;KACA,aAAa,MAAM;KACnB,WAAW,MAAM,YAAY;KAC9B;AACD,WAAO;MAET,EAAE,CACH;GAKC,+BAA+B,CAAC,CAAC,QAAQ;GACzC,MAAM,QAAQ;GACd,GAAI,sBAAsB,QAAQ,GAC9B,EACE,cAAc,EACZ,OAAO,QAAQ,aAAa,iBAAiB,EAC9C,EACF,GACD,EAAE;GACN,aAAa,CAAC,CAAC,QAAQ;GACvB,yBAAyB,CAAC,CAAC,QAAQ;GACnC,GAAI,sBAAsB,QAAQ,GAC9B,EAAE,eAAe,qBAAqB,QAAQ,EAAE,GAChD,EAAE;GACP;AAED,SAAO,IAAI,SAAS,KAAK,UAAU,YAAY,EAAE;GAC/C,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CAAC;UACK,OAAO;AACd,SAAO,IAAI,SACT,KAAK,UAAU;GACb,OAAO;GACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU;GACnD,CAAC,EACF;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CACF"}