@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 • 2.12 kB
Source Map (JSON)
{"version":3,"file":"instance-created.cjs","names":[],"sources":["../../../../src/v2/runtime/telemetry/instance-created.ts"],"sourcesContent":["import { telemetry } from \".\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\n\n/**\n * Fire the `oss.runtime.instance_created` telemetry event for a v2 runtime\n * handler. Called once per handler factory invocation (not per request).\n *\n * v2 does not have a concept of remote endpoints or standalone actions, so\n * those counts are 0 / []. `cloud.api_key_provided` is false at this level\n * because in v2 the cloud public key arrives per-request via the\n * `x-copilotcloud-public-api-key` header — not at handler creation time.\n * See `handlers/handle-run.ts` for the per-request event that DOES carry\n * the key when present.\n *\n * Errors resolving agents are swallowed — telemetry must never break\n * runtime setup.\n */\nexport function fireInstanceCreatedTelemetry({\n runtime,\n}: {\n runtime: CopilotRuntimeLike;\n}): void {\n // agents can be a static Record, a Promise, or a per-request factory.\n // Factory configs cannot be resolved at handler-creation time (no Request\n // context), so report agentsAmount as null in that case.\n const agentsPromise =\n typeof runtime.agents === \"function\"\n ? Promise.resolve<Record<string, unknown> | null>(null)\n : Promise.resolve(runtime.agents);\n\n agentsPromise\n .then((agents) => {\n telemetry.capture(\"oss.runtime.instance_created\", {\n actionsAmount: 0,\n endpointTypes: [],\n endpointsAmount: 0,\n agentsAmount: agents ? Object.keys(agents).length : null,\n \"cloud.api_key_provided\": false,\n });\n })\n .catch(() => {\n // Swallow — telemetry must not break runtime creation.\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,6BAA6B,EAC3C,WAGO;AASP,EAJE,OAAO,QAAQ,WAAW,aACtB,QAAQ,QAAwC,KAAK,GACrD,QAAQ,QAAQ,QAAQ,OAAO,EAGlC,MAAM,WAAW;AAChB,mCAAU,QAAQ,gCAAgC;GAChD,eAAe;GACf,eAAe,EAAE;GACjB,iBAAiB;GACjB,cAAc,SAAS,OAAO,KAAK,OAAO,CAAC,SAAS;GACpD,0BAA0B;GAC3B,CAAC;GACF,CACD,YAAY,GAEX"}