@copilotkit/web-inspector 1.69.0 → 1.69.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -120,6 +120,24 @@ function runtimeEventSignal(event) {
120
120
  ...eventDetails
121
121
  };
122
122
  }
123
+ /**
124
+ * Whether the runtime *connection* needs attention — the single condition
125
+ * shared by System Health and the launcher's error signal, so the two can
126
+ * never disagree about whether the wiring is broken.
127
+ *
128
+ * Exactly one state counts. `disconnected` is also the initial value, so
129
+ * counting it would raise the signal on every page load; `connecting` is a
130
+ * normal startup step; `unavailable` means no Core is attached, which is not
131
+ * a defect of the developer's wiring.
132
+ *
133
+ * Note the deliberate asymmetry with `health.state`: a failed *run* also
134
+ * drives System Health to "Needs attention" while the connection is fine.
135
+ * That is an event rather than a state, and it is excluded from the launcher
136
+ * on purpose — see the launcher-signal comments in index.ts.
137
+ */
138
+ function runtimeConnectionNeedsAttention(state) {
139
+ return state === "error";
140
+ }
123
141
  function runtimeHealthFromInput(input) {
124
142
  const lastEvent = runtimeEventSignal(input.lastRuntimeEvent);
125
143
  if (input.runtimeConnectionState === "connected") return {
@@ -161,15 +179,16 @@ function runtimeHealthFromInput(input) {
161
179
  },
162
180
  lastEvent
163
181
  };
182
+ const needsAttention = runtimeConnectionNeedsAttention(input.runtimeConnectionState);
164
183
  return {
165
- state: input.runtimeConnectionState === "error" ? "error" : "offline",
166
- label: input.runtimeConnectionState === "error" ? "Runtime error" : "Offline",
184
+ state: needsAttention ? "error" : "offline",
185
+ label: needsAttention ? "Runtime error" : "Offline",
167
186
  runtime: {
168
187
  label: "Offline",
169
188
  tone: "error"
170
189
  },
171
190
  liveUpdates: {
172
- label: input.runtimeConnectionState === "error" ? "Error" : "Disconnected",
191
+ label: needsAttention ? "Error" : "Disconnected",
173
192
  tone: "error"
174
193
  },
175
194
  lastEvent
@@ -267,4 +286,5 @@ function buildHomeModel(input) {
267
286
 
268
287
  //#endregion
269
288
  exports.buildHomeModel = buildHomeModel;
289
+ exports.runtimeConnectionNeedsAttention = runtimeConnectionNeedsAttention;
270
290
  //# sourceMappingURL=home-briefing.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"home-briefing.cjs","names":[],"sources":["../../src/lib/home-briefing.ts"],"sourcesContent":["import type { InspectorMetadataProjection } from \"./inspector-metadata.js\";\n\nexport type HomeHeroActionKind =\n | \"enable_intelligence\"\n | \"manage_plan\"\n | \"renew\";\n\nexport type HomeHeroAction = {\n kind: HomeHeroActionKind;\n url: string;\n label: string;\n};\n\nexport type HomeConnection = \"connected\" | \"disconnected\";\n\nexport type HomeRuntimeConnectionState =\n | \"connected\"\n | \"connecting\"\n | \"disconnected\"\n | \"error\"\n | \"unavailable\";\n\nexport type HomeRuntimeHealthTone = \"success\" | \"active\" | \"error\" | \"muted\";\n\nexport type HomeServiceId =\n | \"threads\"\n | \"memory\"\n | \"a2ui\"\n | \"open-gen-ui\"\n | \"suggestions\"\n | \"audio\"\n | \"websocket\";\n\nexport type HomeServiceTile = {\n id: HomeServiceId;\n label: string;\n enabled: boolean;\n url?: string;\n docsUrl: string;\n};\n\nexport type HomeModel = {\n hero: {\n connection: HomeConnection;\n title: string;\n body: string;\n action?: HomeHeroAction;\n };\n project?: {\n organizationName: string;\n projectName: string;\n planLabel?: string;\n license: string;\n usage?: {\n used: number;\n limitLabel: string;\n ratio?: number;\n };\n };\n projectLinked: boolean;\n runtime: {\n url?: string;\n health: {\n state: \"healthy\" | \"checking\" | \"offline\" | \"error\" | \"unavailable\";\n label: string;\n runtime: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n liveUpdates: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n lastEvent: {\n label: string;\n tone: HomeRuntimeHealthTone;\n id?: string;\n agentId?: string;\n type?: string;\n timestamp?: number;\n };\n };\n };\n services: HomeServiceTile[];\n news: {\n title: string;\n previewText: string;\n documentHtml?: string;\n empty: boolean;\n };\n};\n\nexport type HomeBriefingInput = {\n intelligenceConnected: boolean;\n threadsAvailable: boolean;\n metadata: InspectorMetadataProjection;\n runtimeUrl?: string;\n runtimeConnectionState: HomeRuntimeConnectionState;\n lastRuntimeEvent?: {\n id: string;\n agentId: string;\n type: string;\n timestamp: number;\n };\n memoriesOn: boolean;\n a2uiOn: boolean;\n openGenUiOn: boolean;\n suggestionsOn: boolean;\n audioOn: boolean;\n websocketUrl?: string;\n announcementPreviewText?: string;\n announcementMarkdown?: string;\n announcementHtml?: string;\n intelligenceSignupUrl?: string;\n};\n\nconst SERVICE_DOCS_URL: Record<HomeServiceId, string> = {\n threads: \"https://docs.copilotkit.ai/threads\",\n memory: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n a2ui: \"https://docs.copilotkit.ai/generative-ui/a2ui\",\n \"open-gen-ui\": \"https://docs.copilotkit.ai/generative-ui/open-generative-ui\",\n suggestions: \"https://docs.copilotkit.ai/agentic-chat-ui\",\n audio: \"https://docs.copilotkit.ai/voice\",\n websocket: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n};\n\n/** Return the Home hero button for a trusted metadata action. */\nexport function homeHeroActionFromMetadata(action: {\n kind: HomeHeroActionKind;\n url: string;\n}): HomeHeroAction {\n if (action.kind === \"manage_plan\") {\n return { kind: action.kind, url: action.url, label: \"Manage plan\" };\n }\n\n if (action.kind === \"renew\") {\n return { kind: action.kind, url: action.url, label: \"Renew plan\" };\n }\n\n return {\n kind: action.kind,\n url: action.url,\n label: \"Setup Intelligence\",\n };\n}\n\n/** Return a short preview from markdown, without links or headings. */\nexport function announcementPreview(markdown: string, maxLength = 140): string {\n const plain = markdown\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\")\n .replace(/[#*_`]/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim();\n if (plain.length <= maxLength) {\n return plain;\n }\n\n return `${plain.slice(0, maxLength).trimEnd()}…`;\n}\n\nfunction connectIntelligenceAction(\n action: HomeHeroAction | undefined,\n connectUrl?: string,\n licenseState?: InspectorMetadataProjection[\"licenseState\"],\n): HomeHeroAction | undefined {\n if (action) {\n return action;\n }\n\n if (connectUrl && (licenseState === \"none\" || licenseState === \"unknown\")) {\n return homeHeroActionFromMetadata({\n kind: \"enable_intelligence\",\n url: connectUrl,\n });\n }\n\n return undefined;\n}\n\nfunction heroForState(args: {\n connected: boolean;\n action?: HomeHeroAction;\n connectUrl?: string;\n licenseState: InspectorMetadataProjection[\"licenseState\"];\n}): HomeModel[\"hero\"] {\n if (!args.connected) {\n const renewing = args.action?.kind === \"renew\";\n return {\n connection: \"disconnected\",\n title: renewing ? \"Renew Intelligence\" : \"Intelligence is not setup\",\n body: renewing\n ? \"Renew Intelligence to restore persistent Threads and Memory.\"\n : \"Connect CopilotKit Intelligence to add persistent Threads, Learning and Analytics to your application. Inspect conversations and allow your agents to learn from real use.\",\n action: connectIntelligenceAction(\n args.action,\n args.connectUrl,\n args.licenseState,\n ),\n };\n }\n\n return {\n connection: \"connected\",\n title: \"Connected to Intelligence\",\n body: \"Use Workbench to inspect threads and memory.\",\n action:\n args.action?.kind === \"enable_intelligence\" ? undefined : args.action,\n };\n}\n\nfunction usageFromMetadata(metadata: InspectorMetadataProjection):\n | {\n used: number;\n limitLabel: string;\n ratio?: number;\n }\n | undefined {\n const usage = metadata.usage;\n if (!usage) {\n return undefined;\n }\n\n if (usage.limit.kind === \"finite\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / ${usage.limit.value}`,\n ratio: usage.limit.value === 0 ? 1 : usage.used / usage.limit.value,\n };\n }\n\n if (usage.limit.kind === \"unlimited\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / unlimited`,\n };\n }\n\n return {\n used: usage.used,\n limitLabel: `${usage.used} used`,\n };\n}\n\nfunction newsFromAnnouncement(args: {\n previewText?: string;\n markdown?: string;\n html?: string;\n}): HomeModel[\"news\"] {\n const markdown = args.markdown?.trim();\n if (markdown && args.html) {\n const heading = markdown.match(/^#{1,3}\\s+(.+)$/m)?.[1]?.trim();\n return {\n title: heading || \"The latest from CopilotKit\",\n previewText:\n args.previewText?.trim() || announcementPreview(markdown, 160),\n documentHtml: args.html,\n empty: false,\n };\n }\n\n return {\n title: \"You're all caught up\",\n previewText: \"Latest CopilotKit updates will appear here.\",\n empty: true,\n };\n}\n\nfunction runtimeEventSignal(\n event: HomeBriefingInput[\"lastRuntimeEvent\"],\n): HomeModel[\"runtime\"][\"health\"][\"lastEvent\"] {\n if (!event) {\n return { label: \"No events yet\", tone: \"muted\" };\n }\n\n const eventDetails = {\n id: event.id,\n agentId: event.agentId,\n type: event.type,\n timestamp: event.timestamp,\n };\n\n if (event.type === \"RUN_ERROR\" || event.type === \"ERROR\") {\n return {\n label: event.type === \"RUN_ERROR\" ? \"Run error\" : \"Error\",\n tone: \"error\",\n ...eventDetails,\n };\n }\n\n if (event.type === \"RUN_FINISHED\") {\n return {\n label: \"Run completed\",\n tone: \"success\",\n ...eventDetails,\n };\n }\n\n if (\n event.type.endsWith(\"_START\") ||\n event.type.endsWith(\"_STARTED\") ||\n event.type.endsWith(\"_CONTENT\") ||\n event.type.endsWith(\"_ARGS\") ||\n event.type.endsWith(\"_DELTA\")\n ) {\n return {\n label: \"Last event is in progress\",\n tone: \"active\",\n ...eventDetails,\n };\n }\n\n return {\n label: \"Last event received\",\n tone: \"success\",\n ...eventDetails,\n };\n}\n\nfunction runtimeHealthFromInput(\n input: HomeBriefingInput,\n): HomeModel[\"runtime\"][\"health\"] {\n const lastEvent = runtimeEventSignal(input.lastRuntimeEvent);\n\n if (input.runtimeConnectionState === \"connected\") {\n return {\n state: lastEvent.tone === \"error\" ? \"error\" : \"healthy\",\n label: lastEvent.tone === \"error\" ? \"Needs attention\" : \"Healthy\",\n runtime: { label: \"Available\", tone: \"success\" },\n liveUpdates: { label: \"Ready\", tone: \"success\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"connecting\") {\n return {\n state: \"checking\",\n label: \"Checking\",\n runtime: { label: \"Checking\", tone: \"active\" },\n liveUpdates: { label: \"Connecting\", tone: \"active\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"unavailable\") {\n return {\n state: \"unavailable\",\n label: \"Unavailable\",\n runtime: { label: \"Unavailable\", tone: \"muted\" },\n liveUpdates: { label: \"Not attached\", tone: \"muted\" },\n lastEvent,\n };\n }\n\n return {\n state: input.runtimeConnectionState === \"error\" ? \"error\" : \"offline\",\n label:\n input.runtimeConnectionState === \"error\" ? \"Runtime error\" : \"Offline\",\n runtime: { label: \"Offline\", tone: \"error\" },\n liveUpdates: {\n label:\n input.runtimeConnectionState === \"error\" ? \"Error\" : \"Disconnected\",\n tone: \"error\",\n },\n lastEvent,\n };\n}\n\n/** Build the Home briefing from data the Inspector already has. */\nexport function buildHomeModel(input: HomeBriefingInput): HomeModel {\n const metadataAction =\n input.metadata.threadsFooterAction ?? input.metadata.lockedAction;\n const action = metadataAction\n ? homeHeroActionFromMetadata({\n kind: metadataAction.kind,\n url: metadataAction.url,\n })\n : undefined;\n\n const identity = input.metadata.identity;\n const projectLinked = Boolean(identity);\n const intelligenceConnected =\n input.metadata.licenseState === \"valid\" ||\n (input.metadata.licenseState === \"unknown\" && input.intelligenceConnected);\n const usage = usageFromMetadata(input.metadata);\n\n return {\n hero: heroForState({\n connected: intelligenceConnected,\n action,\n connectUrl: input.intelligenceSignupUrl,\n licenseState: input.metadata.licenseState,\n }),\n projectLinked,\n project: identity\n ? {\n organizationName: identity.organizationName,\n projectName: identity.projectName,\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : input.metadata.plan || usage\n ? {\n organizationName: \"Not linked\",\n projectName: \"This runtime is not linked to a project\",\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : undefined,\n runtime: {\n url: input.runtimeUrl,\n health: runtimeHealthFromInput(input),\n },\n services: [\n {\n id: \"threads\",\n label: \"Threads\",\n enabled: intelligenceConnected && input.threadsAvailable,\n url: input.runtimeUrl,\n docsUrl: SERVICE_DOCS_URL.threads,\n },\n {\n id: \"memory\",\n label: \"Memory\",\n enabled: intelligenceConnected && input.memoriesOn,\n docsUrl: SERVICE_DOCS_URL.memory,\n },\n {\n id: \"a2ui\",\n label: \"A2UI\",\n enabled: input.a2uiOn,\n docsUrl: SERVICE_DOCS_URL.a2ui,\n },\n {\n id: \"open-gen-ui\",\n label: \"Open Gen UI\",\n enabled: input.openGenUiOn,\n docsUrl: SERVICE_DOCS_URL[\"open-gen-ui\"],\n },\n {\n id: \"suggestions\",\n label: \"Suggestions\",\n enabled: input.suggestionsOn,\n docsUrl: SERVICE_DOCS_URL.suggestions,\n },\n {\n id: \"audio\",\n label: \"Audio\",\n enabled: input.audioOn,\n docsUrl: SERVICE_DOCS_URL.audio,\n },\n {\n id: \"websocket\",\n label: \"Websocket\",\n enabled: intelligenceConnected && Boolean(input.websocketUrl),\n url: input.websocketUrl,\n docsUrl: SERVICE_DOCS_URL.websocket,\n },\n ],\n news: newsFromAnnouncement({\n previewText: input.announcementPreviewText,\n markdown: input.announcementMarkdown,\n html: input.announcementHtml ?? undefined,\n }),\n };\n}\n"],"mappings":";;AAoHA,MAAM,mBAAkD;CACtD,SAAS;CACT,QAAQ;CACR,MAAM;CACN,eAAe;CACf,aAAa;CACb,OAAO;CACP,WAAW;CACZ;;AAGD,SAAgB,2BAA2B,QAGxB;AACjB,KAAI,OAAO,SAAS,cAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAe;AAGrE,KAAI,OAAO,SAAS,QAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAc;AAGpE,QAAO;EACL,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,OAAO;EACR;;;AAIH,SAAgB,oBAAoB,UAAkB,YAAY,KAAa;CAC7E,MAAM,QAAQ,SACX,QAAQ,0BAA0B,KAAK,CACvC,QAAQ,WAAW,GAAG,CACtB,QAAQ,QAAQ,IAAI,CACpB,MAAM;A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OAAO;IACP,SAAS,MAAM;IACf,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,MAAM;IACf,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,MAAM;IACf,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,MAAM;IACf,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,QAAQ,MAAM,aAAa;IAC7D,KAAK,MAAM;IACX,SAAS,iBAAiB;IAC3B;GACF;EACD,MAAM,qBAAqB;GACzB,aAAa,MAAM;GACnB,UAAU,MAAM;GAChB,MAAM,MAAM,oBAAoB;GACjC,CAAC;EACH"}
1
+ {"version":3,"file":"home-briefing.cjs","names":[],"sources":["../../src/lib/home-briefing.ts"],"sourcesContent":["import type { InspectorMetadataProjection } from \"./inspector-metadata.js\";\n\nexport type HomeHeroActionKind =\n | \"enable_intelligence\"\n | \"manage_plan\"\n | \"renew\";\n\nexport type HomeHeroAction = {\n kind: HomeHeroActionKind;\n url: string;\n label: string;\n};\n\nexport type HomeConnection = \"connected\" | \"disconnected\";\n\nexport type HomeRuntimeConnectionState =\n | \"connected\"\n | \"connecting\"\n | \"disconnected\"\n | \"error\"\n | \"unavailable\";\n\nexport type HomeRuntimeHealthTone = \"success\" | \"active\" | \"error\" | \"muted\";\n\nexport type HomeServiceId =\n | \"threads\"\n | \"memory\"\n | \"a2ui\"\n | \"open-gen-ui\"\n | \"suggestions\"\n | \"audio\"\n | \"websocket\";\n\nexport type HomeServiceTile = {\n id: HomeServiceId;\n label: string;\n enabled: boolean;\n url?: string;\n docsUrl: string;\n};\n\nexport type HomeModel = {\n hero: {\n connection: HomeConnection;\n title: string;\n body: string;\n action?: HomeHeroAction;\n };\n project?: {\n organizationName: string;\n projectName: string;\n planLabel?: string;\n license: string;\n usage?: {\n used: number;\n limitLabel: string;\n ratio?: number;\n };\n };\n projectLinked: boolean;\n runtime: {\n url?: string;\n health: {\n state: \"healthy\" | \"checking\" | \"offline\" | \"error\" | \"unavailable\";\n label: string;\n runtime: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n liveUpdates: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n lastEvent: {\n label: string;\n tone: HomeRuntimeHealthTone;\n id?: string;\n agentId?: string;\n type?: string;\n timestamp?: number;\n };\n };\n };\n services: HomeServiceTile[];\n news: {\n title: string;\n previewText: string;\n documentHtml?: string;\n empty: boolean;\n };\n};\n\nexport type HomeBriefingInput = {\n intelligenceConnected: boolean;\n threadsAvailable: boolean;\n metadata: InspectorMetadataProjection;\n runtimeUrl?: string;\n runtimeConnectionState: HomeRuntimeConnectionState;\n lastRuntimeEvent?: {\n id: string;\n agentId: string;\n type: string;\n timestamp: number;\n };\n memoriesOn: boolean;\n a2uiOn: boolean;\n openGenUiOn: boolean;\n suggestionsOn: boolean;\n audioOn: boolean;\n websocketUrl?: string;\n announcementPreviewText?: string;\n announcementMarkdown?: string;\n announcementHtml?: string;\n intelligenceSignupUrl?: string;\n};\n\nconst SERVICE_DOCS_URL: Record<HomeServiceId, string> = {\n threads: \"https://docs.copilotkit.ai/threads\",\n memory: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n a2ui: \"https://docs.copilotkit.ai/generative-ui/a2ui\",\n \"open-gen-ui\": \"https://docs.copilotkit.ai/generative-ui/open-generative-ui\",\n suggestions: \"https://docs.copilotkit.ai/agentic-chat-ui\",\n audio: \"https://docs.copilotkit.ai/voice\",\n websocket: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n};\n\n/** Return the Home hero button for a trusted metadata action. */\nexport function homeHeroActionFromMetadata(action: {\n kind: HomeHeroActionKind;\n url: string;\n}): HomeHeroAction {\n if (action.kind === \"manage_plan\") {\n return { kind: action.kind, url: action.url, label: \"Manage plan\" };\n }\n\n if (action.kind === \"renew\") {\n return { kind: action.kind, url: action.url, label: \"Renew plan\" };\n }\n\n return {\n kind: action.kind,\n url: action.url,\n label: \"Setup Intelligence\",\n };\n}\n\n/** Return a short preview from markdown, without links or headings. */\nexport function announcementPreview(markdown: string, maxLength = 140): string {\n const plain = markdown\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\")\n .replace(/[#*_`]/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim();\n if (plain.length <= maxLength) {\n return plain;\n }\n\n return `${plain.slice(0, maxLength).trimEnd()}…`;\n}\n\nfunction connectIntelligenceAction(\n action: HomeHeroAction | undefined,\n connectUrl?: string,\n licenseState?: InspectorMetadataProjection[\"licenseState\"],\n): HomeHeroAction | undefined {\n if (action) {\n return action;\n }\n\n if (connectUrl && (licenseState === \"none\" || licenseState === \"unknown\")) {\n return homeHeroActionFromMetadata({\n kind: \"enable_intelligence\",\n url: connectUrl,\n });\n }\n\n return undefined;\n}\n\nfunction heroForState(args: {\n connected: boolean;\n action?: HomeHeroAction;\n connectUrl?: string;\n licenseState: InspectorMetadataProjection[\"licenseState\"];\n}): HomeModel[\"hero\"] {\n if (!args.connected) {\n const renewing = args.action?.kind === \"renew\";\n return {\n connection: \"disconnected\",\n title: renewing ? \"Renew Intelligence\" : \"Intelligence is not setup\",\n body: renewing\n ? \"Renew Intelligence to restore persistent Threads and Memory.\"\n : \"Connect CopilotKit Intelligence to add persistent Threads, Learning and Analytics to your application. Inspect conversations and allow your agents to learn from real use.\",\n action: connectIntelligenceAction(\n args.action,\n args.connectUrl,\n args.licenseState,\n ),\n };\n }\n\n return {\n connection: \"connected\",\n title: \"Connected to Intelligence\",\n body: \"Use Workbench to inspect threads and memory.\",\n action:\n args.action?.kind === \"enable_intelligence\" ? undefined : args.action,\n };\n}\n\nfunction usageFromMetadata(metadata: InspectorMetadataProjection):\n | {\n used: number;\n limitLabel: string;\n ratio?: number;\n }\n | undefined {\n const usage = metadata.usage;\n if (!usage) {\n return undefined;\n }\n\n if (usage.limit.kind === \"finite\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / ${usage.limit.value}`,\n ratio: usage.limit.value === 0 ? 1 : usage.used / usage.limit.value,\n };\n }\n\n if (usage.limit.kind === \"unlimited\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / unlimited`,\n };\n }\n\n return {\n used: usage.used,\n limitLabel: `${usage.used} used`,\n };\n}\n\nfunction newsFromAnnouncement(args: {\n previewText?: string;\n markdown?: string;\n html?: string;\n}): HomeModel[\"news\"] {\n const markdown = args.markdown?.trim();\n if (markdown && args.html) {\n const heading = markdown.match(/^#{1,3}\\s+(.+)$/m)?.[1]?.trim();\n return {\n title: heading || \"The latest from CopilotKit\",\n previewText:\n args.previewText?.trim() || announcementPreview(markdown, 160),\n documentHtml: args.html,\n empty: false,\n };\n }\n\n return {\n title: \"You're all caught up\",\n previewText: \"Latest CopilotKit updates will appear here.\",\n empty: true,\n };\n}\n\nfunction runtimeEventSignal(\n event: HomeBriefingInput[\"lastRuntimeEvent\"],\n): HomeModel[\"runtime\"][\"health\"][\"lastEvent\"] {\n if (!event) {\n return { label: \"No events yet\", tone: \"muted\" };\n }\n\n const eventDetails = {\n id: event.id,\n agentId: event.agentId,\n type: event.type,\n timestamp: event.timestamp,\n };\n\n if (event.type === \"RUN_ERROR\" || event.type === \"ERROR\") {\n return {\n label: event.type === \"RUN_ERROR\" ? \"Run error\" : \"Error\",\n tone: \"error\",\n ...eventDetails,\n };\n }\n\n if (event.type === \"RUN_FINISHED\") {\n return {\n label: \"Run completed\",\n tone: \"success\",\n ...eventDetails,\n };\n }\n\n if (\n event.type.endsWith(\"_START\") ||\n event.type.endsWith(\"_STARTED\") ||\n event.type.endsWith(\"_CONTENT\") ||\n event.type.endsWith(\"_ARGS\") ||\n event.type.endsWith(\"_DELTA\")\n ) {\n return {\n label: \"Last event is in progress\",\n tone: \"active\",\n ...eventDetails,\n };\n }\n\n return {\n label: \"Last event received\",\n tone: \"success\",\n ...eventDetails,\n };\n}\n\n/**\n * Whether the runtime *connection* needs attention — the single condition\n * shared by System Health and the launcher's error signal, so the two can\n * never disagree about whether the wiring is broken.\n *\n * Exactly one state counts. `disconnected` is also the initial value, so\n * counting it would raise the signal on every page load; `connecting` is a\n * normal startup step; `unavailable` means no Core is attached, which is not\n * a defect of the developer's wiring.\n *\n * Note the deliberate asymmetry with `health.state`: a failed *run* also\n * drives System Health to \"Needs attention\" while the connection is fine.\n * That is an event rather than a state, and it is excluded from the launcher\n * on purpose — see the launcher-signal comments in index.ts.\n */\nexport function runtimeConnectionNeedsAttention(\n state: HomeRuntimeConnectionState,\n): boolean {\n return state === \"error\";\n}\n\nfunction runtimeHealthFromInput(\n input: HomeBriefingInput,\n): HomeModel[\"runtime\"][\"health\"] {\n const lastEvent = runtimeEventSignal(input.lastRuntimeEvent);\n\n if (input.runtimeConnectionState === \"connected\") {\n return {\n state: lastEvent.tone === \"error\" ? \"error\" : \"healthy\",\n label: lastEvent.tone === \"error\" ? \"Needs attention\" : \"Healthy\",\n runtime: { label: \"Available\", tone: \"success\" },\n liveUpdates: { label: \"Ready\", tone: \"success\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"connecting\") {\n return {\n state: \"checking\",\n label: \"Checking\",\n runtime: { label: \"Checking\", tone: \"active\" },\n liveUpdates: { label: \"Connecting\", tone: \"active\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"unavailable\") {\n return {\n state: \"unavailable\",\n label: \"Unavailable\",\n runtime: { label: \"Unavailable\", tone: \"muted\" },\n liveUpdates: { label: \"Not attached\", tone: \"muted\" },\n lastEvent,\n };\n }\n\n const needsAttention = runtimeConnectionNeedsAttention(\n input.runtimeConnectionState,\n );\n return {\n state: needsAttention ? \"error\" : \"offline\",\n label: needsAttention ? \"Runtime error\" : \"Offline\",\n runtime: { label: \"Offline\", tone: \"error\" },\n liveUpdates: {\n label: needsAttention ? \"Error\" : \"Disconnected\",\n tone: \"error\",\n },\n lastEvent,\n };\n}\n\n/** Build the Home briefing from data the Inspector already has. */\nexport function buildHomeModel(input: HomeBriefingInput): HomeModel {\n const metadataAction =\n input.metadata.threadsFooterAction ?? input.metadata.lockedAction;\n const action = metadataAction\n ? homeHeroActionFromMetadata({\n kind: metadataAction.kind,\n url: metadataAction.url,\n })\n : undefined;\n\n const identity = input.metadata.identity;\n const projectLinked = Boolean(identity);\n const intelligenceConnected =\n input.metadata.licenseState === \"valid\" ||\n (input.metadata.licenseState === \"unknown\" && input.intelligenceConnected);\n const usage = usageFromMetadata(input.metadata);\n\n return {\n hero: heroForState({\n connected: intelligenceConnected,\n action,\n connectUrl: input.intelligenceSignupUrl,\n licenseState: input.metadata.licenseState,\n }),\n projectLinked,\n project: identity\n ? {\n organizationName: identity.organizationName,\n projectName: identity.projectName,\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : input.metadata.plan || usage\n ? {\n organizationName: \"Not linked\",\n projectName: \"This runtime is not linked to a project\",\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : undefined,\n runtime: {\n url: input.runtimeUrl,\n health: runtimeHealthFromInput(input),\n },\n services: [\n {\n id: \"threads\",\n label: \"Threads\",\n enabled: intelligenceConnected && input.threadsAvailable,\n url: input.runtimeUrl,\n docsUrl: SERVICE_DOCS_URL.threads,\n },\n {\n id: \"memory\",\n label: \"Memory\",\n enabled: intelligenceConnected && input.memoriesOn,\n docsUrl: SERVICE_DOCS_URL.memory,\n },\n {\n id: \"a2ui\",\n label: \"A2UI\",\n enabled: input.a2uiOn,\n docsUrl: SERVICE_DOCS_URL.a2ui,\n },\n {\n id: \"open-gen-ui\",\n label: \"Open Gen UI\",\n enabled: input.openGenUiOn,\n docsUrl: SERVICE_DOCS_URL[\"open-gen-ui\"],\n },\n {\n id: \"suggestions\",\n label: \"Suggestions\",\n enabled: input.suggestionsOn,\n docsUrl: SERVICE_DOCS_URL.suggestions,\n },\n {\n id: \"audio\",\n label: \"Audio\",\n enabled: input.audioOn,\n docsUrl: SERVICE_DOCS_URL.audio,\n },\n {\n id: \"websocket\",\n label: \"Websocket\",\n enabled: intelligenceConnected && Boolean(input.websocketUrl),\n url: input.websocketUrl,\n docsUrl: SERVICE_DOCS_URL.websocket,\n },\n ],\n news: newsFromAnnouncement({\n previewText: input.announcementPreviewText,\n markdown: input.announcementMarkdown,\n html: input.announcementHtml ?? undefined,\n }),\n };\n}\n"],"mappings":";;AAoHA,MAAM,mBAAkD;CACtD,SAAS;CACT,QAAQ;CACR,MAAM;CACN,eAAe;CACf,aAAa;CACb,OAAO;CACP,WAAW;CACZ;;AAGD,SAAgB,2BAA2B,QAGxB;AACjB,KAAI,OAAO,SAAS,cAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAe;AAGrE,KAAI,OAAO,SAAS,QAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAc;AAGpE,QAAO;EACL,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,OAAO;EACR;;;AAIH,SAAgB,oBAAoB,UAAkB,YAAY,KAAa;CAC7E,MAAM,QAAQ,SACX,QAAQ,0BAA0B,KAAK,CACvC,QAAQ,WAAW,GAAG,CACtB,QAAQ,QAAQ,IAAI,CACpB,MAAM;AACT,KAAI,MAAM,UAAU,UAClB,QAAO;AAGT,QAAO,GAAG,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC;;AAGhD,SAAS,0BACP,QACA,YACA,cAC4B;AAC5B,KAAI,OACF,QAAO;AAGT,KAAI,eAAe,iBAAiB,UAAU,iBAAiB,WAC7D,QAAO,2BAA2B;EAChC,MAAM;EACN,KAAK;EACN,CAAC;;AAMN,SAAS,aAAa,MAKA;AACpB,KAAI,CAAC,KAAK,WAAW;EACnB,MAAM,WAAW,KAAK,QAAQ,SAAS;AACvC,SAAO;GACL,YAAY;GACZ,OAAO,WAAW,uBAAuB;GACzC,MAAM,WACF,iEACA;GACJ,QAAQ,0BACN,KAAK,QACL,KAAK,YACL,K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AAqB;GACzB,aAAa,MAAM;GACnB,UAAU,MAAM;GAChB,MAAM,MAAM,oBAAoB;GACjC,CAAC;EACH"}
@@ -119,6 +119,24 @@ function runtimeEventSignal(event) {
119
119
  ...eventDetails
120
120
  };
121
121
  }
122
+ /**
123
+ * Whether the runtime *connection* needs attention — the single condition
124
+ * shared by System Health and the launcher's error signal, so the two can
125
+ * never disagree about whether the wiring is broken.
126
+ *
127
+ * Exactly one state counts. `disconnected` is also the initial value, so
128
+ * counting it would raise the signal on every page load; `connecting` is a
129
+ * normal startup step; `unavailable` means no Core is attached, which is not
130
+ * a defect of the developer's wiring.
131
+ *
132
+ * Note the deliberate asymmetry with `health.state`: a failed *run* also
133
+ * drives System Health to "Needs attention" while the connection is fine.
134
+ * That is an event rather than a state, and it is excluded from the launcher
135
+ * on purpose — see the launcher-signal comments in index.ts.
136
+ */
137
+ function runtimeConnectionNeedsAttention(state) {
138
+ return state === "error";
139
+ }
122
140
  function runtimeHealthFromInput(input) {
123
141
  const lastEvent = runtimeEventSignal(input.lastRuntimeEvent);
124
142
  if (input.runtimeConnectionState === "connected") return {
@@ -160,15 +178,16 @@ function runtimeHealthFromInput(input) {
160
178
  },
161
179
  lastEvent
162
180
  };
181
+ const needsAttention = runtimeConnectionNeedsAttention(input.runtimeConnectionState);
163
182
  return {
164
- state: input.runtimeConnectionState === "error" ? "error" : "offline",
165
- label: input.runtimeConnectionState === "error" ? "Runtime error" : "Offline",
183
+ state: needsAttention ? "error" : "offline",
184
+ label: needsAttention ? "Runtime error" : "Offline",
166
185
  runtime: {
167
186
  label: "Offline",
168
187
  tone: "error"
169
188
  },
170
189
  liveUpdates: {
171
- label: input.runtimeConnectionState === "error" ? "Error" : "Disconnected",
190
+ label: needsAttention ? "Error" : "Disconnected",
172
191
  tone: "error"
173
192
  },
174
193
  lastEvent
@@ -265,5 +284,5 @@ function buildHomeModel(input) {
265
284
  }
266
285
 
267
286
  //#endregion
268
- export { buildHomeModel };
287
+ export { buildHomeModel, runtimeConnectionNeedsAttention };
269
288
  //# sourceMappingURL=home-briefing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"home-briefing.mjs","names":[],"sources":["../../src/lib/home-briefing.ts"],"sourcesContent":["import type { InspectorMetadataProjection } from \"./inspector-metadata.js\";\n\nexport type HomeHeroActionKind =\n | \"enable_intelligence\"\n | \"manage_plan\"\n | \"renew\";\n\nexport type HomeHeroAction = {\n kind: HomeHeroActionKind;\n url: string;\n label: string;\n};\n\nexport type HomeConnection = \"connected\" | \"disconnected\";\n\nexport type HomeRuntimeConnectionState =\n | \"connected\"\n | \"connecting\"\n | \"disconnected\"\n | \"error\"\n | \"unavailable\";\n\nexport type HomeRuntimeHealthTone = \"success\" | \"active\" | \"error\" | \"muted\";\n\nexport type HomeServiceId =\n | \"threads\"\n | \"memory\"\n | \"a2ui\"\n | \"open-gen-ui\"\n | \"suggestions\"\n | \"audio\"\n | \"websocket\";\n\nexport type HomeServiceTile = {\n id: HomeServiceId;\n label: string;\n enabled: boolean;\n url?: string;\n docsUrl: string;\n};\n\nexport type HomeModel = {\n hero: {\n connection: HomeConnection;\n title: string;\n body: string;\n action?: HomeHeroAction;\n };\n project?: {\n organizationName: string;\n projectName: string;\n planLabel?: string;\n license: string;\n usage?: {\n used: number;\n limitLabel: string;\n ratio?: number;\n };\n };\n projectLinked: boolean;\n runtime: {\n url?: string;\n health: {\n state: \"healthy\" | \"checking\" | \"offline\" | \"error\" | \"unavailable\";\n label: string;\n runtime: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n liveUpdates: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n lastEvent: {\n label: string;\n tone: HomeRuntimeHealthTone;\n id?: string;\n agentId?: string;\n type?: string;\n timestamp?: number;\n };\n };\n };\n services: HomeServiceTile[];\n news: {\n title: string;\n previewText: string;\n documentHtml?: string;\n empty: boolean;\n };\n};\n\nexport type HomeBriefingInput = {\n intelligenceConnected: boolean;\n threadsAvailable: boolean;\n metadata: InspectorMetadataProjection;\n runtimeUrl?: string;\n runtimeConnectionState: HomeRuntimeConnectionState;\n lastRuntimeEvent?: {\n id: string;\n agentId: string;\n type: string;\n timestamp: number;\n };\n memoriesOn: boolean;\n a2uiOn: boolean;\n openGenUiOn: boolean;\n suggestionsOn: boolean;\n audioOn: boolean;\n websocketUrl?: string;\n announcementPreviewText?: string;\n announcementMarkdown?: string;\n announcementHtml?: string;\n intelligenceSignupUrl?: string;\n};\n\nconst SERVICE_DOCS_URL: Record<HomeServiceId, string> = {\n threads: \"https://docs.copilotkit.ai/threads\",\n memory: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n a2ui: \"https://docs.copilotkit.ai/generative-ui/a2ui\",\n \"open-gen-ui\": \"https://docs.copilotkit.ai/generative-ui/open-generative-ui\",\n suggestions: \"https://docs.copilotkit.ai/agentic-chat-ui\",\n audio: \"https://docs.copilotkit.ai/voice\",\n websocket: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n};\n\n/** Return the Home hero button for a trusted metadata action. */\nexport function homeHeroActionFromMetadata(action: {\n kind: HomeHeroActionKind;\n url: string;\n}): HomeHeroAction {\n if (action.kind === \"manage_plan\") {\n return { kind: action.kind, url: action.url, label: \"Manage plan\" };\n }\n\n if (action.kind === \"renew\") {\n return { kind: action.kind, url: action.url, label: \"Renew plan\" };\n }\n\n return {\n kind: action.kind,\n url: action.url,\n label: \"Setup Intelligence\",\n };\n}\n\n/** Return a short preview from markdown, without links or headings. */\nexport function announcementPreview(markdown: string, maxLength = 140): string {\n const plain = markdown\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\")\n .replace(/[#*_`]/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim();\n if (plain.length <= maxLength) {\n return plain;\n }\n\n return `${plain.slice(0, maxLength).trimEnd()}…`;\n}\n\nfunction connectIntelligenceAction(\n action: HomeHeroAction | undefined,\n connectUrl?: string,\n licenseState?: InspectorMetadataProjection[\"licenseState\"],\n): HomeHeroAction | undefined {\n if (action) {\n return action;\n }\n\n if (connectUrl && (licenseState === \"none\" || licenseState === \"unknown\")) {\n return homeHeroActionFromMetadata({\n kind: \"enable_intelligence\",\n url: connectUrl,\n });\n }\n\n return undefined;\n}\n\nfunction heroForState(args: {\n connected: boolean;\n action?: HomeHeroAction;\n connectUrl?: string;\n licenseState: InspectorMetadataProjection[\"licenseState\"];\n}): HomeModel[\"hero\"] {\n if (!args.connected) {\n const renewing = args.action?.kind === \"renew\";\n return {\n connection: \"disconnected\",\n title: renewing ? \"Renew Intelligence\" : \"Intelligence is not setup\",\n body: renewing\n ? \"Renew Intelligence to restore persistent Threads and Memory.\"\n : \"Connect CopilotKit Intelligence to add persistent Threads, Learning and Analytics to your application. Inspect conversations and allow your agents to learn from real use.\",\n action: connectIntelligenceAction(\n args.action,\n args.connectUrl,\n args.licenseState,\n ),\n };\n }\n\n return {\n connection: \"connected\",\n title: \"Connected to Intelligence\",\n body: \"Use Workbench to inspect threads and memory.\",\n action:\n args.action?.kind === \"enable_intelligence\" ? undefined : args.action,\n };\n}\n\nfunction usageFromMetadata(metadata: InspectorMetadataProjection):\n | {\n used: number;\n limitLabel: string;\n ratio?: number;\n }\n | undefined {\n const usage = metadata.usage;\n if (!usage) {\n return undefined;\n }\n\n if (usage.limit.kind === \"finite\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / ${usage.limit.value}`,\n ratio: usage.limit.value === 0 ? 1 : usage.used / usage.limit.value,\n };\n }\n\n if (usage.limit.kind === \"unlimited\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / unlimited`,\n };\n }\n\n return {\n used: usage.used,\n limitLabel: `${usage.used} used`,\n };\n}\n\nfunction newsFromAnnouncement(args: {\n previewText?: string;\n markdown?: string;\n html?: string;\n}): HomeModel[\"news\"] {\n const markdown = args.markdown?.trim();\n if (markdown && args.html) {\n const heading = markdown.match(/^#{1,3}\\s+(.+)$/m)?.[1]?.trim();\n return {\n title: heading || \"The latest from CopilotKit\",\n previewText:\n args.previewText?.trim() || announcementPreview(markdown, 160),\n documentHtml: args.html,\n empty: false,\n };\n }\n\n return {\n title: \"You're all caught up\",\n previewText: \"Latest CopilotKit updates will appear here.\",\n empty: true,\n };\n}\n\nfunction runtimeEventSignal(\n event: HomeBriefingInput[\"lastRuntimeEvent\"],\n): HomeModel[\"runtime\"][\"health\"][\"lastEvent\"] {\n if (!event) {\n return { label: \"No events yet\", tone: \"muted\" };\n }\n\n const eventDetails = {\n id: event.id,\n agentId: event.agentId,\n type: event.type,\n timestamp: event.timestamp,\n };\n\n if (event.type === \"RUN_ERROR\" || event.type === \"ERROR\") {\n return {\n label: event.type === \"RUN_ERROR\" ? \"Run error\" : \"Error\",\n tone: \"error\",\n ...eventDetails,\n };\n }\n\n if (event.type === \"RUN_FINISHED\") {\n return {\n label: \"Run completed\",\n tone: \"success\",\n ...eventDetails,\n };\n }\n\n if (\n event.type.endsWith(\"_START\") ||\n event.type.endsWith(\"_STARTED\") ||\n event.type.endsWith(\"_CONTENT\") ||\n event.type.endsWith(\"_ARGS\") ||\n event.type.endsWith(\"_DELTA\")\n ) {\n return {\n label: \"Last event is in progress\",\n tone: \"active\",\n ...eventDetails,\n };\n }\n\n return {\n label: \"Last event received\",\n tone: \"success\",\n ...eventDetails,\n };\n}\n\nfunction runtimeHealthFromInput(\n input: HomeBriefingInput,\n): HomeModel[\"runtime\"][\"health\"] {\n const lastEvent = runtimeEventSignal(input.lastRuntimeEvent);\n\n if (input.runtimeConnectionState === \"connected\") {\n return {\n state: lastEvent.tone === \"error\" ? \"error\" : \"healthy\",\n label: lastEvent.tone === \"error\" ? \"Needs attention\" : \"Healthy\",\n runtime: { label: \"Available\", tone: \"success\" },\n liveUpdates: { label: \"Ready\", tone: \"success\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"connecting\") {\n return {\n state: \"checking\",\n label: \"Checking\",\n runtime: { label: \"Checking\", tone: \"active\" },\n liveUpdates: { label: \"Connecting\", tone: \"active\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"unavailable\") {\n return {\n state: \"unavailable\",\n label: \"Unavailable\",\n runtime: { label: \"Unavailable\", tone: \"muted\" },\n liveUpdates: { label: \"Not attached\", tone: \"muted\" },\n lastEvent,\n };\n }\n\n return {\n state: input.runtimeConnectionState === \"error\" ? \"error\" : \"offline\",\n label:\n input.runtimeConnectionState === \"error\" ? \"Runtime error\" : \"Offline\",\n runtime: { label: \"Offline\", tone: \"error\" },\n liveUpdates: {\n label:\n input.runtimeConnectionState === \"error\" ? \"Error\" : \"Disconnected\",\n tone: \"error\",\n },\n lastEvent,\n };\n}\n\n/** Build the Home briefing from data the Inspector already has. */\nexport function buildHomeModel(input: HomeBriefingInput): HomeModel {\n const metadataAction =\n input.metadata.threadsFooterAction ?? input.metadata.lockedAction;\n const action = metadataAction\n ? homeHeroActionFromMetadata({\n kind: metadataAction.kind,\n url: metadataAction.url,\n })\n : undefined;\n\n const identity = input.metadata.identity;\n const projectLinked = Boolean(identity);\n const intelligenceConnected =\n input.metadata.licenseState === \"valid\" ||\n (input.metadata.licenseState === \"unknown\" && input.intelligenceConnected);\n const usage = usageFromMetadata(input.metadata);\n\n return {\n hero: heroForState({\n connected: intelligenceConnected,\n action,\n connectUrl: input.intelligenceSignupUrl,\n licenseState: input.metadata.licenseState,\n }),\n projectLinked,\n project: identity\n ? {\n organizationName: identity.organizationName,\n projectName: identity.projectName,\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : input.metadata.plan || usage\n ? {\n organizationName: \"Not linked\",\n projectName: \"This runtime is not linked to a project\",\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : undefined,\n runtime: {\n url: input.runtimeUrl,\n health: runtimeHealthFromInput(input),\n },\n services: [\n {\n id: \"threads\",\n label: \"Threads\",\n enabled: intelligenceConnected && input.threadsAvailable,\n url: input.runtimeUrl,\n docsUrl: SERVICE_DOCS_URL.threads,\n },\n {\n id: \"memory\",\n label: \"Memory\",\n enabled: intelligenceConnected && input.memoriesOn,\n docsUrl: SERVICE_DOCS_URL.memory,\n },\n {\n id: \"a2ui\",\n label: \"A2UI\",\n enabled: input.a2uiOn,\n docsUrl: SERVICE_DOCS_URL.a2ui,\n },\n {\n id: \"open-gen-ui\",\n label: \"Open Gen UI\",\n enabled: input.openGenUiOn,\n docsUrl: SERVICE_DOCS_URL[\"open-gen-ui\"],\n },\n {\n id: \"suggestions\",\n label: \"Suggestions\",\n enabled: input.suggestionsOn,\n docsUrl: SERVICE_DOCS_URL.suggestions,\n },\n {\n id: \"audio\",\n label: \"Audio\",\n enabled: input.audioOn,\n docsUrl: SERVICE_DOCS_URL.audio,\n },\n {\n id: \"websocket\",\n label: \"Websocket\",\n enabled: intelligenceConnected && Boolean(input.websocketUrl),\n url: input.websocketUrl,\n docsUrl: SERVICE_DOCS_URL.websocket,\n },\n ],\n news: newsFromAnnouncement({\n previewText: input.announcementPreviewText,\n markdown: input.announcementMarkdown,\n html: input.announcementHtml ?? undefined,\n }),\n };\n}\n"],"mappings":";AAoHA,MAAM,mBAAkD;CACtD,SAAS;CACT,QAAQ;CACR,MAAM;CACN,eAAe;CACf,aAAa;CACb,OAAO;CACP,WAAW;CACZ;;AAGD,SAAgB,2BAA2B,QAGxB;AACjB,KAAI,OAAO,SAAS,cAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAe;AAGrE,KAAI,OAAO,SAAS,QAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAc;AAGpE,QAAO;EACL,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,OAAO;EACR;;;AAIH,SAAgB,oBAAoB,UAAkB,YAAY,KAAa;CAC7E,MAAM,QAAQ,SACX,QAAQ,0BAA0B,KAAK,CACvC,QAAQ,WAAW,GAAG,CACtB,QAAQ,QAAQ,IAAI,CACpB,MAAM;AACT,KAAI,MAAM,UAAU,UAClB,QAAO;AAGT,QAAO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C3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,MAAM;IACf,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,MAAM;IACf,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,MAAM;IACf,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,QAAQ,MAAM,aAAa;IAC7D,KAAK,MAAM;IACX,SAAS,iBAAiB;IAC3B;GACF;EACD,MAAM,qBAAqB;GACzB,aAAa,MAAM;GACnB,UAAU,MAAM;GAChB,MAAM,MAAM,oBAAoB;GACjC,CAAC;EACH"}
1
+ {"version":3,"file":"home-briefing.mjs","names":[],"sources":["../../src/lib/home-briefing.ts"],"sourcesContent":["import type { InspectorMetadataProjection } from \"./inspector-metadata.js\";\n\nexport type HomeHeroActionKind =\n | \"enable_intelligence\"\n | \"manage_plan\"\n | \"renew\";\n\nexport type HomeHeroAction = {\n kind: HomeHeroActionKind;\n url: string;\n label: string;\n};\n\nexport type HomeConnection = \"connected\" | \"disconnected\";\n\nexport type HomeRuntimeConnectionState =\n | \"connected\"\n | \"connecting\"\n | \"disconnected\"\n | \"error\"\n | \"unavailable\";\n\nexport type HomeRuntimeHealthTone = \"success\" | \"active\" | \"error\" | \"muted\";\n\nexport type HomeServiceId =\n | \"threads\"\n | \"memory\"\n | \"a2ui\"\n | \"open-gen-ui\"\n | \"suggestions\"\n | \"audio\"\n | \"websocket\";\n\nexport type HomeServiceTile = {\n id: HomeServiceId;\n label: string;\n enabled: boolean;\n url?: string;\n docsUrl: string;\n};\n\nexport type HomeModel = {\n hero: {\n connection: HomeConnection;\n title: string;\n body: string;\n action?: HomeHeroAction;\n };\n project?: {\n organizationName: string;\n projectName: string;\n planLabel?: string;\n license: string;\n usage?: {\n used: number;\n limitLabel: string;\n ratio?: number;\n };\n };\n projectLinked: boolean;\n runtime: {\n url?: string;\n health: {\n state: \"healthy\" | \"checking\" | \"offline\" | \"error\" | \"unavailable\";\n label: string;\n runtime: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n liveUpdates: {\n label: string;\n tone: HomeRuntimeHealthTone;\n };\n lastEvent: {\n label: string;\n tone: HomeRuntimeHealthTone;\n id?: string;\n agentId?: string;\n type?: string;\n timestamp?: number;\n };\n };\n };\n services: HomeServiceTile[];\n news: {\n title: string;\n previewText: string;\n documentHtml?: string;\n empty: boolean;\n };\n};\n\nexport type HomeBriefingInput = {\n intelligenceConnected: boolean;\n threadsAvailable: boolean;\n metadata: InspectorMetadataProjection;\n runtimeUrl?: string;\n runtimeConnectionState: HomeRuntimeConnectionState;\n lastRuntimeEvent?: {\n id: string;\n agentId: string;\n type: string;\n timestamp: number;\n };\n memoriesOn: boolean;\n a2uiOn: boolean;\n openGenUiOn: boolean;\n suggestionsOn: boolean;\n audioOn: boolean;\n websocketUrl?: string;\n announcementPreviewText?: string;\n announcementMarkdown?: string;\n announcementHtml?: string;\n intelligenceSignupUrl?: string;\n};\n\nconst SERVICE_DOCS_URL: Record<HomeServiceId, string> = {\n threads: \"https://docs.copilotkit.ai/threads\",\n memory: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n a2ui: \"https://docs.copilotkit.ai/generative-ui/a2ui\",\n \"open-gen-ui\": \"https://docs.copilotkit.ai/generative-ui/open-generative-ui\",\n suggestions: \"https://docs.copilotkit.ai/agentic-chat-ui\",\n audio: \"https://docs.copilotkit.ai/voice\",\n websocket: \"https://docs.copilotkit.ai/premium/intelligence-platform\",\n};\n\n/** Return the Home hero button for a trusted metadata action. */\nexport function homeHeroActionFromMetadata(action: {\n kind: HomeHeroActionKind;\n url: string;\n}): HomeHeroAction {\n if (action.kind === \"manage_plan\") {\n return { kind: action.kind, url: action.url, label: \"Manage plan\" };\n }\n\n if (action.kind === \"renew\") {\n return { kind: action.kind, url: action.url, label: \"Renew plan\" };\n }\n\n return {\n kind: action.kind,\n url: action.url,\n label: \"Setup Intelligence\",\n };\n}\n\n/** Return a short preview from markdown, without links or headings. */\nexport function announcementPreview(markdown: string, maxLength = 140): string {\n const plain = markdown\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, \"$1\")\n .replace(/[#*_`]/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim();\n if (plain.length <= maxLength) {\n return plain;\n }\n\n return `${plain.slice(0, maxLength).trimEnd()}…`;\n}\n\nfunction connectIntelligenceAction(\n action: HomeHeroAction | undefined,\n connectUrl?: string,\n licenseState?: InspectorMetadataProjection[\"licenseState\"],\n): HomeHeroAction | undefined {\n if (action) {\n return action;\n }\n\n if (connectUrl && (licenseState === \"none\" || licenseState === \"unknown\")) {\n return homeHeroActionFromMetadata({\n kind: \"enable_intelligence\",\n url: connectUrl,\n });\n }\n\n return undefined;\n}\n\nfunction heroForState(args: {\n connected: boolean;\n action?: HomeHeroAction;\n connectUrl?: string;\n licenseState: InspectorMetadataProjection[\"licenseState\"];\n}): HomeModel[\"hero\"] {\n if (!args.connected) {\n const renewing = args.action?.kind === \"renew\";\n return {\n connection: \"disconnected\",\n title: renewing ? \"Renew Intelligence\" : \"Intelligence is not setup\",\n body: renewing\n ? \"Renew Intelligence to restore persistent Threads and Memory.\"\n : \"Connect CopilotKit Intelligence to add persistent Threads, Learning and Analytics to your application. Inspect conversations and allow your agents to learn from real use.\",\n action: connectIntelligenceAction(\n args.action,\n args.connectUrl,\n args.licenseState,\n ),\n };\n }\n\n return {\n connection: \"connected\",\n title: \"Connected to Intelligence\",\n body: \"Use Workbench to inspect threads and memory.\",\n action:\n args.action?.kind === \"enable_intelligence\" ? undefined : args.action,\n };\n}\n\nfunction usageFromMetadata(metadata: InspectorMetadataProjection):\n | {\n used: number;\n limitLabel: string;\n ratio?: number;\n }\n | undefined {\n const usage = metadata.usage;\n if (!usage) {\n return undefined;\n }\n\n if (usage.limit.kind === \"finite\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / ${usage.limit.value}`,\n ratio: usage.limit.value === 0 ? 1 : usage.used / usage.limit.value,\n };\n }\n\n if (usage.limit.kind === \"unlimited\") {\n return {\n used: usage.used,\n limitLabel: `${usage.used} / unlimited`,\n };\n }\n\n return {\n used: usage.used,\n limitLabel: `${usage.used} used`,\n };\n}\n\nfunction newsFromAnnouncement(args: {\n previewText?: string;\n markdown?: string;\n html?: string;\n}): HomeModel[\"news\"] {\n const markdown = args.markdown?.trim();\n if (markdown && args.html) {\n const heading = markdown.match(/^#{1,3}\\s+(.+)$/m)?.[1]?.trim();\n return {\n title: heading || \"The latest from CopilotKit\",\n previewText:\n args.previewText?.trim() || announcementPreview(markdown, 160),\n documentHtml: args.html,\n empty: false,\n };\n }\n\n return {\n title: \"You're all caught up\",\n previewText: \"Latest CopilotKit updates will appear here.\",\n empty: true,\n };\n}\n\nfunction runtimeEventSignal(\n event: HomeBriefingInput[\"lastRuntimeEvent\"],\n): HomeModel[\"runtime\"][\"health\"][\"lastEvent\"] {\n if (!event) {\n return { label: \"No events yet\", tone: \"muted\" };\n }\n\n const eventDetails = {\n id: event.id,\n agentId: event.agentId,\n type: event.type,\n timestamp: event.timestamp,\n };\n\n if (event.type === \"RUN_ERROR\" || event.type === \"ERROR\") {\n return {\n label: event.type === \"RUN_ERROR\" ? \"Run error\" : \"Error\",\n tone: \"error\",\n ...eventDetails,\n };\n }\n\n if (event.type === \"RUN_FINISHED\") {\n return {\n label: \"Run completed\",\n tone: \"success\",\n ...eventDetails,\n };\n }\n\n if (\n event.type.endsWith(\"_START\") ||\n event.type.endsWith(\"_STARTED\") ||\n event.type.endsWith(\"_CONTENT\") ||\n event.type.endsWith(\"_ARGS\") ||\n event.type.endsWith(\"_DELTA\")\n ) {\n return {\n label: \"Last event is in progress\",\n tone: \"active\",\n ...eventDetails,\n };\n }\n\n return {\n label: \"Last event received\",\n tone: \"success\",\n ...eventDetails,\n };\n}\n\n/**\n * Whether the runtime *connection* needs attention — the single condition\n * shared by System Health and the launcher's error signal, so the two can\n * never disagree about whether the wiring is broken.\n *\n * Exactly one state counts. `disconnected` is also the initial value, so\n * counting it would raise the signal on every page load; `connecting` is a\n * normal startup step; `unavailable` means no Core is attached, which is not\n * a defect of the developer's wiring.\n *\n * Note the deliberate asymmetry with `health.state`: a failed *run* also\n * drives System Health to \"Needs attention\" while the connection is fine.\n * That is an event rather than a state, and it is excluded from the launcher\n * on purpose — see the launcher-signal comments in index.ts.\n */\nexport function runtimeConnectionNeedsAttention(\n state: HomeRuntimeConnectionState,\n): boolean {\n return state === \"error\";\n}\n\nfunction runtimeHealthFromInput(\n input: HomeBriefingInput,\n): HomeModel[\"runtime\"][\"health\"] {\n const lastEvent = runtimeEventSignal(input.lastRuntimeEvent);\n\n if (input.runtimeConnectionState === \"connected\") {\n return {\n state: lastEvent.tone === \"error\" ? \"error\" : \"healthy\",\n label: lastEvent.tone === \"error\" ? \"Needs attention\" : \"Healthy\",\n runtime: { label: \"Available\", tone: \"success\" },\n liveUpdates: { label: \"Ready\", tone: \"success\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"connecting\") {\n return {\n state: \"checking\",\n label: \"Checking\",\n runtime: { label: \"Checking\", tone: \"active\" },\n liveUpdates: { label: \"Connecting\", tone: \"active\" },\n lastEvent,\n };\n }\n\n if (input.runtimeConnectionState === \"unavailable\") {\n return {\n state: \"unavailable\",\n label: \"Unavailable\",\n runtime: { label: \"Unavailable\", tone: \"muted\" },\n liveUpdates: { label: \"Not attached\", tone: \"muted\" },\n lastEvent,\n };\n }\n\n const needsAttention = runtimeConnectionNeedsAttention(\n input.runtimeConnectionState,\n );\n return {\n state: needsAttention ? \"error\" : \"offline\",\n label: needsAttention ? \"Runtime error\" : \"Offline\",\n runtime: { label: \"Offline\", tone: \"error\" },\n liveUpdates: {\n label: needsAttention ? \"Error\" : \"Disconnected\",\n tone: \"error\",\n },\n lastEvent,\n };\n}\n\n/** Build the Home briefing from data the Inspector already has. */\nexport function buildHomeModel(input: HomeBriefingInput): HomeModel {\n const metadataAction =\n input.metadata.threadsFooterAction ?? input.metadata.lockedAction;\n const action = metadataAction\n ? homeHeroActionFromMetadata({\n kind: metadataAction.kind,\n url: metadataAction.url,\n })\n : undefined;\n\n const identity = input.metadata.identity;\n const projectLinked = Boolean(identity);\n const intelligenceConnected =\n input.metadata.licenseState === \"valid\" ||\n (input.metadata.licenseState === \"unknown\" && input.intelligenceConnected);\n const usage = usageFromMetadata(input.metadata);\n\n return {\n hero: heroForState({\n connected: intelligenceConnected,\n action,\n connectUrl: input.intelligenceSignupUrl,\n licenseState: input.metadata.licenseState,\n }),\n projectLinked,\n project: identity\n ? {\n organizationName: identity.organizationName,\n projectName: identity.projectName,\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : input.metadata.plan || usage\n ? {\n organizationName: \"Not linked\",\n projectName: \"This runtime is not linked to a project\",\n planLabel: input.metadata.plan?.label,\n license: input.metadata.licenseState,\n usage,\n }\n : undefined,\n runtime: {\n url: input.runtimeUrl,\n health: runtimeHealthFromInput(input),\n },\n services: [\n {\n id: \"threads\",\n label: \"Threads\",\n enabled: intelligenceConnected && input.threadsAvailable,\n url: input.runtimeUrl,\n docsUrl: SERVICE_DOCS_URL.threads,\n },\n {\n id: \"memory\",\n label: \"Memory\",\n enabled: intelligenceConnected && input.memoriesOn,\n docsUrl: SERVICE_DOCS_URL.memory,\n },\n {\n id: \"a2ui\",\n label: \"A2UI\",\n enabled: input.a2uiOn,\n docsUrl: SERVICE_DOCS_URL.a2ui,\n },\n {\n id: \"open-gen-ui\",\n label: \"Open Gen UI\",\n enabled: input.openGenUiOn,\n docsUrl: SERVICE_DOCS_URL[\"open-gen-ui\"],\n },\n {\n id: \"suggestions\",\n label: \"Suggestions\",\n enabled: input.suggestionsOn,\n docsUrl: SERVICE_DOCS_URL.suggestions,\n },\n {\n id: \"audio\",\n label: \"Audio\",\n enabled: input.audioOn,\n docsUrl: SERVICE_DOCS_URL.audio,\n },\n {\n id: \"websocket\",\n label: \"Websocket\",\n enabled: intelligenceConnected && Boolean(input.websocketUrl),\n url: input.websocketUrl,\n docsUrl: SERVICE_DOCS_URL.websocket,\n },\n ],\n news: newsFromAnnouncement({\n previewText: input.announcementPreviewText,\n markdown: input.announcementMarkdown,\n html: input.announcementHtml ?? undefined,\n }),\n };\n}\n"],"mappings":";AAoHA,MAAM,mBAAkD;CACtD,SAAS;CACT,QAAQ;CACR,MAAM;CACN,eAAe;CACf,aAAa;CACb,OAAO;CACP,WAAW;CACZ;;AAGD,SAAgB,2BAA2B,QAGxB;AACjB,KAAI,OAAO,SAAS,cAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAe;AAGrE,KAAI,OAAO,SAAS,QAClB,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK,OAAO;EAAc;AAGpE,QAAO;EACL,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,OAAO;EACR;;;AAIH,SAAgB,oBAAoB,UAAkB,YAAY,KAAa;CAC7E,MAAM,QAAQ,SACX,QAAQ,0BAA0B,KAAK,CACvC,QAAQ,WAAW,GAAG,CACtB,QAAQ,QAAQ,IAAI,CACpB,MAAM;AACT,KAAI,MAAM,UAAU,UAClB,QAAO;AAGT,QAAO,GAAG,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC;;AAGhD,SAAS,0BACP,QACA,YACA,cAC4B;AAC5B,KAAI,OACF,QAAO;AAGT,KAAI,eAAe,iBAAiB,UAAU,iBAAiB,WAC7D,QAAO,2BAA2B;EAChC,MAAM;EACN,KAAK;EACN,CAAC;;AAMN,SAAS,aAAa,MAKA;AACpB,KAAI,CAAC,KAAK,WAAW;EACnB,MAAM,WAAW,KAAK,QAAQ,SAAS;AACvC,SAAO;GACL,YAAY;GACZ,OAAO,WAAW,uBAAuB;GACzC,MAAM,WACF,iEACA;GACJ,QAAQ,0BACN,KAAK,QACL,KAAK,YACL,KAAK,aACN;GACF;;AAGH,QAAO;EACL,YAAY;EACZ,O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B,MAAM,MAAM,oBAAoB;GACjC,CAAC;EACH"}
@@ -6,6 +6,7 @@ const TELEMETRY_EVENTS = {
6
6
  opened: "oss.inspector.opened",
7
7
  whatsNewViewed: "oss.inspector.whats_new_viewed",
8
8
  whatsNewSignalViewed: "oss.inspector.whats_new_signal_viewed",
9
+ errorSignalViewed: "oss.inspector.error_signal_viewed",
9
10
  whatsNewClicked: "oss.inspector.whats_new_clicked",
10
11
  threadsTabClicked: "oss.inspector.threads_tab_clicked",
11
12
  threadsLockedViewed: "oss.inspector.threads_locked_viewed",
@@ -88,6 +89,31 @@ function trackWhatsNewSignalViewed(props) {
88
89
  track(TELEMETRY_EVENTS.whatsNewSignalViewed, props);
89
90
  }
90
91
  /**
92
+ * Fires when the launcher's error signal becomes *visible* — not when it arms.
93
+ * Arming can happen with the panel open or the tab hidden, where there is no
94
+ * launcher to look at, so counting arms would inflate the denominator this
95
+ * event exists to provide.
96
+ *
97
+ * Deliberately carries three fixed enum values and nothing else. This is the
98
+ * one place a later change could casually attach a free-text field, and the
99
+ * failure message must never be transmitted.
100
+ *
101
+ * `label` is deliberately not a new event: the catalogue's size is asserted
102
+ * and spelled out in a test title, and a property answers the one open
103
+ * question — how often the no-room fallback fires — without touching either.
104
+ *
105
+ * The pill's own marginal effect cannot be measured here and must not be
106
+ * reverse-engineered from this data: it ships together with the dot and the
107
+ * beat, so there is no period with one and not the other.
108
+ */
109
+ function trackErrorSignalViewed(props) {
110
+ track(TELEMETRY_EVENTS.errorSignalViewed, {
111
+ source: props.source,
112
+ presentation: props.presentation,
113
+ label: props.label
114
+ });
115
+ }
116
+ /**
91
117
  * Fires for links followed inside the announcement body. `body` is the only
92
118
  * call-to-action left: dismissal no longer exists, so there is nothing else a
93
119
  * click on this surface can mean.
@@ -314,6 +340,7 @@ exports.ensureTelemetryDistinctId = ensureTelemetryDistinctId;
314
340
  exports.getRuntimeUrlType = getRuntimeUrlType;
315
341
  exports.getTelemetryDistinctIdForUrl = getTelemetryDistinctIdForUrl;
316
342
  exports.maybeShowDisclosure = maybeShowDisclosure;
343
+ exports.trackErrorSignalViewed = trackErrorSignalViewed;
317
344
  exports.trackHomeCtaClicked = trackHomeCtaClicked;
318
345
  exports.trackHomeViewed = trackHomeViewed;
319
346
  exports.trackInspectorOpened = trackInspectorOpened;
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.cjs","names":["isTelemetryOptedOut","getOrCreateTelemetryDistinctId","hasTelemetryDisclosureBeenShown"],"sources":["../../src/lib/telemetry.ts"],"sourcesContent":["// Inspector-side anonymous telemetry. V1 events fire from index.ts for\n// What's new and thread-inspection interactions. POSTs directly from the\n// browser to the CopilotKit telemetry sink at\n// `telemetry.copilotkit.ai/ingest`, where a Lambda fan-out forwards events to\n// PostHog / Reo / Scarf.\n//\n// The endpoint URL is intentionally clearly named so it's obvious in\n// DevTools / Network tab — transparency for opt-in users.\n//\n// Privacy invariants enforced here:\n// - We never send message content, agent state, prompts, completions,\n// or announcement markdown. Feature-specific properties are scoped to\n// event metadata only (banner_id/timestamp, cta location). Reviewers\n// should grep call sites for any unintended payload.\n// - The opt-out short-circuits before any network call. There is no\n// buffer, no retry queue.\n// - All errors are swallowed; telemetry must never break the host app.\n\nimport {\n getOrCreateTelemetryDistinctId,\n hasTelemetryDisclosureBeenShown,\n isTelemetryOptedOut,\n markTelemetryDisclosureShown,\n} from \"./persistence.js\";\nimport packageJson from \"../../package.json\" with { type: \"json\" };\n\n// V1 funnel events. Namespaced `oss.inspector.*` so the lambda's\n// owned-prefix gate (oss-path-to-production) can accept them server-side\n// without a per-event sink deploy.\nexport const TELEMETRY_EVENTS = {\n opened: \"oss.inspector.opened\",\n whatsNewViewed: \"oss.inspector.whats_new_viewed\",\n whatsNewSignalViewed: \"oss.inspector.whats_new_signal_viewed\",\n whatsNewClicked: \"oss.inspector.whats_new_clicked\",\n threadsTabClicked: \"oss.inspector.threads_tab_clicked\",\n threadsLockedViewed: \"oss.inspector.threads_locked_viewed\",\n threadsIntelligenceSignupClicked:\n \"oss.inspector.threads_intelligence_signup_clicked\",\n threadsTalkToEngineerClicked:\n \"oss.inspector.threads_talk_to_engineer_clicked\",\n talkToEngineerClicked: \"oss.inspector.talk_to_engineer_clicked\",\n threadsEmptyEnabledViewed: \"oss.inspector.threads_empty_enabled_viewed\",\n threadsEnabledViewed: \"oss.inspector.threads_enabled_viewed\",\n threadsExampleViewed: \"oss.inspector.threads_example_viewed\",\n threadsExampleSelected: \"oss.inspector.threads_example_selected\",\n threadsExampleTourStarted: \"oss.inspector.threads_example_tour_started\",\n threadsExampleTourStepViewed:\n \"oss.inspector.threads_example_tour_step_viewed\",\n threadsExampleTourDismissed: \"oss.inspector.threads_example_tour_dismissed\",\n threadsExampleTourCompleted: \"oss.inspector.threads_example_tour_completed\",\n threadsExampleTourReopened: \"oss.inspector.threads_example_tour_reopened\",\n memoriesTabClicked: \"oss.inspector.memories_tab_clicked\",\n homeViewed: \"oss.inspector.home_viewed\",\n homeCtaClicked: \"oss.inspector.home_cta_clicked\",\n metadataModuleViewed: \"oss.inspector.metadata_module_viewed\",\n metadataActionClicked: \"oss.inspector.metadata_action_clicked\",\n} as const;\n\nexport type TelemetryEvent =\n (typeof TELEMETRY_EVENTS)[keyof typeof TELEMETRY_EVENTS];\n\n// Per the OSS-96 ticket — the URL is intentionally clearly named for\n// transparency in the network tab.\nexport const TELEMETRY_INGEST_URL = \"https://telemetry.copilotkit.ai/ingest\";\n\n// Surfaced in console disclosure and the in-product opt-out panel.\n// Keep in sync with the live shell-docs telemetry page\n// (`showcase/shell-docs/src/content/docs/integrations/built-in-agent/telemetry.mdx`).\n// Mirror constant: packages/runtime/src/lib/telemetry-disclosure.ts\nexport const TELEMETRY_DOCS_URL = \"https://docs.copilotkit.ai/telemetry\";\n\nconst PACKAGE_NAME = \"@copilotkit/web-inspector\";\nconst PACKAGE_VERSION = packageJson.version;\n\n// 3-second cap so a slow gateway can't hang the host app. Matches the\n// runtime's existing scarf-client convention.\nconst FETCH_TIMEOUT_MS = 3000;\n\nexport type RuntimeUrlType =\n | \"missing\"\n | \"relative\"\n | \"localhost\"\n | \"same_origin\"\n | \"remote\"\n | \"invalid\";\n\nexport function getRuntimeUrlType(\n runtimeUrl: string | undefined,\n): RuntimeUrlType {\n if (!runtimeUrl) return \"missing\";\n if (runtimeUrl.startsWith(\"/\") && !runtimeUrl.startsWith(\"//\")) {\n return \"relative\";\n }\n\n try {\n const baseHref =\n typeof window !== \"undefined\"\n ? window.location.href\n : \"https://copilotkit.ai\";\n const url = new URL(runtimeUrl, baseHref);\n const baseUrl = new URL(baseHref);\n const hostname = url.hostname.toLowerCase();\n\n if (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n ) {\n return \"localhost\";\n }\n\n return url.origin === baseUrl.origin ? \"same_origin\" : \"remote\";\n } catch {\n return \"invalid\";\n }\n}\n\n/**\n * Fire-and-forget telemetry send. Returns synchronously; the network\n * call is dispatched in the background and any failure is swallowed.\n *\n * Short-circuits when the user has opted out. Does NOT itself trigger\n * the first-run disclosure — call `maybeShowDisclosure()` from the\n * inspector's mount lifecycle instead.\n */\nexport function track(\n event: TelemetryEvent,\n properties: Record<string, unknown> = {},\n): void {\n if (isTelemetryOptedOut()) return;\n\n try {\n const distinctId = getOrCreateTelemetryDistinctId();\n // Every event carries package identity and the inspector's anonymous\n // distinct-ID, so any of them can be segmented by inspector version.\n const body = JSON.stringify({\n event,\n properties: {\n ...properties,\n package_name: PACKAGE_NAME,\n package_version: PACKAGE_VERSION,\n inspector_distinct_id: distinctId,\n distinct_id: distinctId,\n },\n package: {\n name: PACKAGE_NAME,\n version: PACKAGE_VERSION,\n },\n ts: Math.floor(Date.now() / 1000),\n });\n void postBestEffort(TELEMETRY_INGEST_URL, body, distinctId);\n } catch {\n // Identity and serialization failures are best-effort too.\n }\n}\n\n// --- Typed per-event helpers ---\n// These enforce the known property shape for each V1 event at the call\n// site, so callers can't accidentally include PII under a wrong key.\n\n/**\n * Where an announcement was rendered when the event fired. What's new is the\n * only surface that carries one, so the value is currently a constant — it\n * stays a stamped property rather than an inferred one so a second surface\n * can be added without changing the event's shape.\n */\nexport type WhatsNewSurface = \"whats_new\";\n\nexport type WhatsNewSignalPresentation = \"animated\" | \"reduced_motion\";\n\n/**\n * Fires when What's new has rendered *with content*. A loading state is not\n * an impression, so the metric cannot inflate itself by counting readers who\n * arrived before the feed resolved.\n */\nexport function trackWhatsNewViewed(props: {\n banner_id: string;\n surface: WhatsNewSurface;\n cta_label?: string;\n}): void {\n track(TELEMETRY_EVENTS.whatsNewViewed, props);\n}\n\n/** Fires when the unread launcher signal is presented in a visible tab. */\nexport function trackWhatsNewSignalViewed(props: {\n banner_id: string;\n surface: \"launcher\";\n presentation: WhatsNewSignalPresentation;\n cta_label?: string;\n}): void {\n track(TELEMETRY_EVENTS.whatsNewSignalViewed, props);\n}\n\n/**\n * Fires for links followed inside the announcement body. `body` is the only\n * call-to-action left: dismissal no longer exists, so there is nothing else a\n * click on this surface can mean.\n */\nexport function trackWhatsNewClicked(props: {\n banner_id: string;\n cta: \"body\";\n cta_label?: string;\n}): void {\n track(TELEMETRY_EVENTS.whatsNewClicked, props);\n}\n\n/**\n * How the panel was opened. Restoring a persisted-open panel on mount is\n * deliberately NOT a source: it is not an open *intent*, and counting it\n * would turn every dev-server hot reload into an \"open\".\n */\nexport type InspectorOpenSource = \"floating_button\" | \"message_toolbar\";\n\nexport type InspectorOpenedTelemetryProps = {\n open_source: InspectorOpenSource;\n package_name?: typeof PACKAGE_NAME;\n package_version?: string;\n inspector_distinct_id?: string;\n license_status?:\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"expiring\"\n | \"invalid\"\n | \"unknown\";\n runtime_mode?: \"sse\" | \"intelligence\";\n runtime_url_type?: RuntimeUrlType;\n /** True when an unseen announcement was on screen at open time. */\n has_unseen_announcement?: boolean;\n /** True when this is the first Inspector open after install or upgrade. */\n first_open?: boolean;\n};\n\n/**\n * Panel-open signal (OSS-566). Before this event, opens could only be\n * inferred from in-panel activity (a floor) or from the announcement's own\n * click event (which misses the floating-button path entirely).\n */\nexport function trackInspectorOpened(\n props: InspectorOpenedTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.opened, props);\n}\n\nexport type ExampleKind = \"realtime_sync\" | \"manage_history\" | \"inspect_runs\";\nexport type ThreadsUsageBucket =\n | \"absent\"\n | \"empty\"\n | \"within_limit\"\n | \"at_or_over_limit\"\n | \"unlimited\"\n | \"unknown_limit\";\nexport type ThreadsExpiryBucket = \"unavailable\" | \"zero\" | \"positive\";\nexport type InspectorGroupKey = \"home\" | \"workbench\" | \"inspect\";\nexport type InspectorLeafKey =\n | \"home\"\n | \"whats-new\"\n | \"playground\"\n | \"threads\"\n | \"ag-ui-events\"\n | \"agents\"\n | \"frontend-tools\"\n | \"capabilities\"\n | \"agent-context\"\n | \"memories\";\nexport type MetadataActionPlacement = \"threads_footer\" | \"threads_locked\";\nexport type ExampleTourStep = 1 | 2 | 3;\nexport type ExampleTourTab = \"timeline\" | \"raw-events\" | \"state\";\n\nexport type InspectorThreadTelemetryProps = Readonly<{\n posthog_distinct_id?: string;\n intelligence_status?:\n | \"intelligence_not_enabled\"\n | \"intelligence_enabled\"\n | \"unknown\";\n thread_service_status?: \"unavailable\" | \"available\" | \"unknown\" | \"error\";\n license_status?:\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"expiring\"\n | \"invalid\"\n | \"unknown\";\n runtime_mode?: \"sse\" | \"intelligence\";\n runtime_url_type?: RuntimeUrlType;\n cta_surface?:\n | \"threads_locked\"\n | \"threads_header\"\n | \"threads_empty\"\n | \"threads_populated\"\n | \"sidebar_footer\";\n cta?: \"signup\" | \"talk_to_engineer\";\n telemetry_disabled?: boolean;\n has_threads?: boolean;\n usage_bucket?: ThreadsUsageBucket;\n expiry_bucket?: ThreadsExpiryBucket;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n example_kind?: ExampleKind;\n tour_step?: ExampleTourStep;\n tour_tab?: ExampleTourTab;\n dismiss_method?: \"skip\" | \"done\";\n}>;\n\n/** Rebuild the common Thread payload from its closed coarse allowlist. */\nfunction threadCommonProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...(props.intelligence_status === undefined\n ? {}\n : { intelligence_status: props.intelligence_status }),\n ...(props.thread_service_status === undefined\n ? {}\n : { thread_service_status: props.thread_service_status }),\n ...(props.license_status === undefined\n ? {}\n : { license_status: props.license_status }),\n ...(props.runtime_mode === undefined\n ? {}\n : { runtime_mode: props.runtime_mode }),\n ...(props.runtime_url_type === undefined\n ? {}\n : { runtime_url_type: props.runtime_url_type }),\n ...(props.telemetry_disabled === undefined\n ? {}\n : { telemetry_disabled: props.telemetry_disabled }),\n ...(props.has_threads === undefined\n ? {}\n : { has_threads: props.has_threads }),\n ...(props.usage_bucket === undefined\n ? {}\n : { usage_bucket: props.usage_bucket }),\n ...(props.expiry_bucket === undefined\n ? {}\n : { expiry_bucket: props.expiry_bucket }),\n ...(props.group_key === undefined ? {} : { group_key: props.group_key }),\n ...(props.leaf_key === undefined ? {} : { leaf_key: props.leaf_key }),\n };\n}\n\n/** Add only the fields used by the three Thread CTA funnels. */\nfunction threadCtaProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadCommonProperties(props),\n ...(props.cta === undefined ? {} : { cta: props.cta }),\n ...(props.cta_surface === undefined\n ? {}\n : { cta_surface: props.cta_surface }),\n ...(props.posthog_distinct_id === undefined\n ? {}\n : { posthog_distinct_id: props.posthog_distinct_id }),\n };\n}\n\n/** Add only the closed example kind used by example impressions/selections. */\nfunction threadExampleProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadCommonProperties(props),\n ...(props.example_kind === undefined\n ? {}\n : { example_kind: props.example_kind }),\n };\n}\n\n/** Add only a bounded example kind and tour step/tab pair. */\nfunction threadTourProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadExampleProperties(props),\n ...(props.tour_step === undefined ? {} : { tour_step: props.tour_step }),\n ...(props.tour_tab === undefined ? {} : { tour_tab: props.tour_tab }),\n };\n}\n\n/** Add the bounded dismissal leaf used only by terminal tour events. */\nfunction threadTourTerminalProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadTourProperties(props),\n ...(props.dismiss_method === undefined\n ? {}\n : { dismiss_method: props.dismiss_method }),\n };\n}\n\nexport function trackThreadsTabClicked(\n props: InspectorThreadTelemetryProps = {},\n): void {\n track(TELEMETRY_EVENTS.threadsTabClicked, threadCommonProperties(props));\n}\n\nexport function trackThreadsLockedViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.threadsLockedViewed, threadCommonProperties(props));\n}\n\nexport function trackThreadsIntelligenceSignupClicked(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsIntelligenceSignupClicked,\n threadCtaProperties(props),\n );\n}\n\nexport function trackThreadsTalkToEngineerClicked(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsTalkToEngineerClicked,\n threadCtaProperties(props),\n );\n}\n\nexport function trackTalkToEngineerClicked(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.talkToEngineerClicked, threadCtaProperties(props));\n}\n\nexport function trackThreadsEmptyEnabledViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsEmptyEnabledViewed,\n threadCommonProperties(props),\n );\n}\n\nexport function trackThreadsEnabledViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.threadsEnabledViewed, threadCommonProperties(props));\n}\n\nexport function trackThreadsExampleViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.threadsExampleViewed, threadExampleProperties(props));\n}\n\nexport function trackThreadsExampleSelected(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleSelected,\n threadExampleProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourStarted(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourStarted,\n threadTourProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourStepViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourStepViewed,\n threadTourProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourDismissed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourDismissed,\n threadTourTerminalProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourCompleted(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourCompleted,\n threadTourTerminalProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourReopened(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourReopened,\n threadTourProperties(props),\n );\n}\n\nexport type InspectorMemoryTelemetryProps = {\n package_name?: typeof PACKAGE_NAME;\n package_version?: string;\n inspector_distinct_id?: string;\n posthog_distinct_id?: string;\n memory_count?: number;\n available?: boolean;\n};\n\nexport function trackMemoriesTabClicked(\n props: InspectorMemoryTelemetryProps = {},\n): void {\n track(TELEMETRY_EVENTS.memoriesTabClicked, props);\n}\n\nexport type InspectorMetadataTelemetryModule = \"identity\" | \"plan\" | \"action\";\nexport type InspectorMetadataLicenseBucket =\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"unknown\";\nexport type InspectorMetadataActionKind =\n | \"manage_plan\"\n | \"renew\"\n | \"enable_intelligence\";\n\nexport type InspectorHomeTelemetryProps = Readonly<{\n action_kind?: InspectorMetadataActionKind;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n}>;\n\nexport function trackHomeViewed(props: InspectorHomeTelemetryProps = {}): void {\n track(TELEMETRY_EVENTS.homeViewed, {\n group_key: props.group_key ?? \"home\",\n leaf_key: props.leaf_key ?? \"home\",\n });\n}\n\nexport function trackHomeCtaClicked(props: InspectorHomeTelemetryProps): void {\n track(TELEMETRY_EVENTS.homeCtaClicked, {\n action_kind: props.action_kind,\n group_key: props.group_key ?? \"home\",\n leaf_key: props.leaf_key ?? \"home\",\n });\n}\n\nexport type InspectorMetadataModuleViewedTelemetryProps = Readonly<{\n module: InspectorMetadataTelemetryModule;\n license_bucket: InspectorMetadataLicenseBucket;\n action_kind?: InspectorMetadataActionKind;\n usage_bucket: ThreadsUsageBucket;\n expiry_bucket: ThreadsExpiryBucket;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n action_placement?: MetadataActionPlacement;\n}>;\n\nexport type InspectorMetadataActionClickedTelemetryProps = Readonly<{\n action_kind: Exclude<InspectorMetadataActionKind, \"enable_intelligence\">;\n license_bucket: InspectorMetadataLicenseBucket;\n usage_bucket: ThreadsUsageBucket;\n expiry_bucket: ThreadsExpiryBucket;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n action_placement?: MetadataActionPlacement;\n}>;\n\nfunction metadataCoarseProperties(\n props:\n | InspectorMetadataModuleViewedTelemetryProps\n | InspectorMetadataActionClickedTelemetryProps,\n) {\n const navigation =\n props.group_key === undefined || props.leaf_key === undefined\n ? {}\n : { group_key: props.group_key, leaf_key: props.leaf_key };\n return {\n license_bucket: props.license_bucket,\n usage_bucket: props.usage_bucket,\n expiry_bucket: props.expiry_bucket,\n ...navigation,\n ...(props.action_placement === undefined\n ? {}\n : { action_placement: props.action_placement }),\n };\n}\n\n/**\n * Tracks one visible Inspector metadata module using coarse fields only.\n * Rebuilding the payload here prevents local labels, IDs, URLs, and usage\n * values from crossing the telemetry boundary through extra object fields.\n */\nexport function trackMetadataModuleViewed(\n props: InspectorMetadataModuleViewedTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.metadataModuleViewed, {\n module: props.module,\n ...(props.action_kind === undefined\n ? {}\n : { action_kind: props.action_kind }),\n ...metadataCoarseProperties(props),\n });\n}\n\n/**\n * Tracks clicks for managed plan and renewal actions. The existing\n * Intelligence-enable funnel keeps its original event and never calls this\n * helper, which prevents a single click from producing two wire events.\n */\nexport function trackMetadataActionClicked(\n props: InspectorMetadataActionClickedTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.metadataActionClicked, {\n module: \"action\",\n action_kind: props.action_kind,\n ...metadataCoarseProperties(props),\n });\n}\n\n/**\n * Returns the inspector's anonymous distinct-ID for cross-domain\n * propagation onto outbound announcement-CTA links, or `null` when the user\n * is opted out.\n *\n * The website / Ops API reads this query param on signup-flow landing\n * pages and calls `posthog.alias(...)` to merge the inspector's anon\n * ID with the website's anon ID, enabling the\n * `whats_new_viewed → whats_new_clicked → signup_attributed` funnel.\n * `identify()` itself is out of scope here (it happens on signup, in\n * the website / Ops API).\n *\n * Opt-out short-circuits this too: if the user has opted out, we do\n * NOT leak an anon ID across domains.\n */\nexport function getTelemetryDistinctIdForUrl(): string | null {\n if (isTelemetryOptedOut()) return null;\n return getOrCreateTelemetryDistinctId();\n}\n\n/**\n * Seeds the anonymous distinct-ID into localStorage on inspector mount\n * so it is ready for cross-domain propagation onto announcement-CTA links\n * even before the first event fires. No-op when the user has opted out.\n */\nexport function ensureTelemetryDistinctId(): void {\n if (isTelemetryOptedOut()) return;\n getOrCreateTelemetryDistinctId();\n}\n\n/**\n * Fires the one-time console disclosure on inspector mount, when the\n * user is not opted out and hasn't seen it before. Idempotent across\n * calls within a single session because `markTelemetryDisclosureShown`\n * persists to localStorage.\n *\n * If the user is opted out, we deliberately do nothing and do NOT mark\n * the flag — so a future opt-in flips back to \"first run\" behavior.\n */\nexport function maybeShowDisclosure(): void {\n if (isTelemetryOptedOut()) return;\n if (hasTelemetryDisclosureBeenShown()) return;\n // eslint-disable-next-line no-console\n console.info(\n `[CopilotKit Inspector] anonymous interaction telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out.`,\n );\n markTelemetryDisclosureShown();\n}\n\nexport { isTelemetryOptedOut };\n\nasync function postBestEffort(\n url: string,\n body: string,\n distinctId: string,\n): Promise<void> {\n if (typeof fetch === \"undefined\") return;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n try {\n const controller = new AbortController();\n timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-CopilotKit-Telemetry-Id\": distinctId,\n },\n body,\n signal: controller.signal,\n // No credentials / no Authorization header — anonymous endpoint.\n });\n } catch {\n // Silent failure — telemetry must not break the application.\n } finally {\n if (timeoutId !== undefined) clearTimeout(timeoutId);\n }\n}\n"],"mappings":";;;;AA6BA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,gBAAgB;CAChB,sBAAsB;CACtB,iBAAiB;CACjB,mBAAmB;CACnB,qBAAqB;CACrB,kCACE;CACF,8BACE;CACF,uBAAuB;CACvB,2BAA2B;CAC3B,sBAAsB;CACtB,sBAAsB;CACtB,wBAAwB;CACxB,2BAA2B;CAC3B,8BACE;CACF,6BAA6B;CAC7B,6BAA6B;CAC7B,4BAA4B;CAC5B,oBAAoB;CACpB,YAAY;CACZ,gBAAgB;CAChB,sBAAsB;CACtB,uBAAuB;CACxB;AAOD,MAAa,uBAAuB;AAMpC,MAAa,qBAAqB;AAElC,MAAM,eAAe;AACrB,MAAM;AAIN,MAAM,mBAAmB;AAUzB,SAAgB,kBACd,YACgB;AAChB,KAAI,CAAC,WAAY,QAAO;AACxB,KAAI,WAAW,WAAW,IAAI,IAAI,CAAC,WAAW,WAAW,KAAK,CAC5D,QAAO;AAGT,KAAI;EACF,MAAM,WACJ,OAAO,WAAW,cACd,OAAO,SAAS,OAChB;EACN,MAAM,MAAM,IAAI,IAAI,YAAY,SAAS;EACzC,MAAM,UAAU,IAAI,IAAI,SAAS;EACjC,MAAM,WAAW,IAAI,SAAS,aAAa;AAE3C,MACE,aAAa,eACb,aAAa,eACb,aAAa,QAEb,QAAO;AAGT,SAAO,IAAI,WAAW,QAAQ,SAAS,gBAAgB;SACjD;A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getOrCreateTelemetryDistinctId","hasTelemetryDisclosureBeenShown"],"sources":["../../src/lib/telemetry.ts"],"sourcesContent":["// Inspector-side anonymous telemetry. V1 events fire from index.ts for\n// What's new and thread-inspection interactions. POSTs directly from the\n// browser to the CopilotKit telemetry sink at\n// `telemetry.copilotkit.ai/ingest`, where a Lambda fan-out forwards events to\n// PostHog / Reo / Scarf.\n//\n// The endpoint URL is intentionally clearly named so it's obvious in\n// DevTools / Network tab — transparency for opt-in users.\n//\n// Privacy invariants enforced here:\n// - We never send message content, agent state, prompts, completions,\n// or announcement markdown. Feature-specific properties are scoped to\n// event metadata only (banner_id/timestamp, cta location). Reviewers\n// should grep call sites for any unintended payload.\n// - The opt-out short-circuits before any network call. There is no\n// buffer, no retry queue.\n// - All errors are swallowed; telemetry must never break the host app.\n\nimport {\n getOrCreateTelemetryDistinctId,\n hasTelemetryDisclosureBeenShown,\n isTelemetryOptedOut,\n markTelemetryDisclosureShown,\n} from \"./persistence.js\";\nimport packageJson from \"../../package.json\" with { type: \"json\" };\n\n// V1 funnel events. Namespaced `oss.inspector.*` so the lambda's\n// owned-prefix gate (oss-path-to-production) can accept them server-side\n// without a per-event sink deploy.\nexport const TELEMETRY_EVENTS = {\n opened: \"oss.inspector.opened\",\n whatsNewViewed: \"oss.inspector.whats_new_viewed\",\n whatsNewSignalViewed: \"oss.inspector.whats_new_signal_viewed\",\n errorSignalViewed: \"oss.inspector.error_signal_viewed\",\n whatsNewClicked: \"oss.inspector.whats_new_clicked\",\n threadsTabClicked: \"oss.inspector.threads_tab_clicked\",\n threadsLockedViewed: \"oss.inspector.threads_locked_viewed\",\n threadsIntelligenceSignupClicked:\n \"oss.inspector.threads_intelligence_signup_clicked\",\n threadsTalkToEngineerClicked:\n \"oss.inspector.threads_talk_to_engineer_clicked\",\n talkToEngineerClicked: \"oss.inspector.talk_to_engineer_clicked\",\n threadsEmptyEnabledViewed: \"oss.inspector.threads_empty_enabled_viewed\",\n threadsEnabledViewed: \"oss.inspector.threads_enabled_viewed\",\n threadsExampleViewed: \"oss.inspector.threads_example_viewed\",\n threadsExampleSelected: \"oss.inspector.threads_example_selected\",\n threadsExampleTourStarted: \"oss.inspector.threads_example_tour_started\",\n threadsExampleTourStepViewed:\n \"oss.inspector.threads_example_tour_step_viewed\",\n threadsExampleTourDismissed: \"oss.inspector.threads_example_tour_dismissed\",\n threadsExampleTourCompleted: \"oss.inspector.threads_example_tour_completed\",\n threadsExampleTourReopened: \"oss.inspector.threads_example_tour_reopened\",\n memoriesTabClicked: \"oss.inspector.memories_tab_clicked\",\n homeViewed: \"oss.inspector.home_viewed\",\n homeCtaClicked: \"oss.inspector.home_cta_clicked\",\n metadataModuleViewed: \"oss.inspector.metadata_module_viewed\",\n metadataActionClicked: \"oss.inspector.metadata_action_clicked\",\n} as const;\n\nexport type TelemetryEvent =\n (typeof TELEMETRY_EVENTS)[keyof typeof TELEMETRY_EVENTS];\n\n// Per the OSS-96 ticket — the URL is intentionally clearly named for\n// transparency in the network tab.\nexport const TELEMETRY_INGEST_URL = \"https://telemetry.copilotkit.ai/ingest\";\n\n// Surfaced in console disclosure and the in-product opt-out panel.\n// Keep in sync with the live shell-docs telemetry page\n// (`showcase/shell-docs/src/content/docs/integrations/built-in-agent/telemetry.mdx`).\n// Mirror constant: packages/runtime/src/v1-deprecated/lib/telemetry-disclosure.ts\nexport const TELEMETRY_DOCS_URL = \"https://docs.copilotkit.ai/telemetry\";\n\nconst PACKAGE_NAME = \"@copilotkit/web-inspector\";\nconst PACKAGE_VERSION = packageJson.version;\n\n// 3-second cap so a slow gateway can't hang the host app. Matches the\n// runtime's existing scarf-client convention.\nconst FETCH_TIMEOUT_MS = 3000;\n\nexport type RuntimeUrlType =\n | \"missing\"\n | \"relative\"\n | \"localhost\"\n | \"same_origin\"\n | \"remote\"\n | \"invalid\";\n\nexport function getRuntimeUrlType(\n runtimeUrl: string | undefined,\n): RuntimeUrlType {\n if (!runtimeUrl) return \"missing\";\n if (runtimeUrl.startsWith(\"/\") && !runtimeUrl.startsWith(\"//\")) {\n return \"relative\";\n }\n\n try {\n const baseHref =\n typeof window !== \"undefined\"\n ? window.location.href\n : \"https://copilotkit.ai\";\n const url = new URL(runtimeUrl, baseHref);\n const baseUrl = new URL(baseHref);\n const hostname = url.hostname.toLowerCase();\n\n if (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n ) {\n return \"localhost\";\n }\n\n return url.origin === baseUrl.origin ? \"same_origin\" : \"remote\";\n } catch {\n return \"invalid\";\n }\n}\n\n/**\n * Fire-and-forget telemetry send. Returns synchronously; the network\n * call is dispatched in the background and any failure is swallowed.\n *\n * Short-circuits when the user has opted out. Does NOT itself trigger\n * the first-run disclosure — call `maybeShowDisclosure()` from the\n * inspector's mount lifecycle instead.\n */\nexport function track(\n event: TelemetryEvent,\n properties: Record<string, unknown> = {},\n): void {\n if (isTelemetryOptedOut()) return;\n\n try {\n const distinctId = getOrCreateTelemetryDistinctId();\n // Every event carries package identity and the inspector's anonymous\n // distinct-ID, so any of them can be segmented by inspector version.\n const body = JSON.stringify({\n event,\n properties: {\n ...properties,\n package_name: PACKAGE_NAME,\n package_version: PACKAGE_VERSION,\n inspector_distinct_id: distinctId,\n distinct_id: distinctId,\n },\n package: {\n name: PACKAGE_NAME,\n version: PACKAGE_VERSION,\n },\n ts: Math.floor(Date.now() / 1000),\n });\n void postBestEffort(TELEMETRY_INGEST_URL, body, distinctId);\n } catch {\n // Identity and serialization failures are best-effort too.\n }\n}\n\n// --- Typed per-event helpers ---\n// These enforce the known property shape for each V1 event at the call\n// site, so callers can't accidentally include PII under a wrong key.\n\n/**\n * Where an announcement was rendered when the event fired. What's new is the\n * only surface that carries one, so the value is currently a constant — it\n * stays a stamped property rather than an inferred one so a second surface\n * can be added without changing the event's shape.\n */\nexport type WhatsNewSurface = \"whats_new\";\n\n/**\n * Whether a launcher signal was animated, or held static because the reader\n * asked for reduced motion. Shared by every launcher signal so an\n * accessibility setting is never mistaken for disinterest.\n */\nexport type LauncherSignalPresentation = \"animated\" | \"reduced_motion\";\n\nexport type WhatsNewSignalPresentation = LauncherSignalPresentation;\n\n/**\n * Which failure class raised the launcher's error signal. A closed enum: the\n * failure *message* is never transmitted, so prompts, URLs and identifiers\n * embedded in an error cannot leave the browser.\n *\n * `connection` and `threads` are wiring *state*. `run`, `tool` and `memory`\n * are unread *events* that clear when their landing view is read.\n */\nexport type InspectorWiringErrorSource = \"connection\" | \"threads\";\nexport type InspectorEventErrorSource = \"run\" | \"tool\" | \"memory\";\nexport type InspectorErrorSignalSource =\n | InspectorWiringErrorSource\n | InspectorEventErrorSource;\n\n/**\n * Fires when What's new has rendered *with content*. A loading state is not\n * an impression, so the metric cannot inflate itself by counting readers who\n * arrived before the feed resolved.\n */\nexport function trackWhatsNewViewed(props: {\n banner_id: string;\n surface: WhatsNewSurface;\n cta_label?: string;\n}): void {\n track(TELEMETRY_EVENTS.whatsNewViewed, props);\n}\n\n/** Fires when the unread launcher signal is presented in a visible tab. */\nexport function trackWhatsNewSignalViewed(props: {\n banner_id: string;\n surface: \"launcher\";\n presentation: WhatsNewSignalPresentation;\n cta_label?: string;\n}): void {\n track(TELEMETRY_EVENTS.whatsNewSignalViewed, props);\n}\n\n/**\n * Whether the launcher opened its pill for this outage, or suppressed it.\n *\n * `suppressed` means no pill was shown. In practice that is the no-room\n * fallback — neither side of the launcher had space for the label — because\n * every other path to a visible error signal opens one.\n */\nexport type InspectorErrorSignalLabel = \"shown\" | \"suppressed\";\n\n/**\n * Fires when the launcher's error signal becomes *visible* — not when it arms.\n * Arming can happen with the panel open or the tab hidden, where there is no\n * launcher to look at, so counting arms would inflate the denominator this\n * event exists to provide.\n *\n * Deliberately carries three fixed enum values and nothing else. This is the\n * one place a later change could casually attach a free-text field, and the\n * failure message must never be transmitted.\n *\n * `label` is deliberately not a new event: the catalogue's size is asserted\n * and spelled out in a test title, and a property answers the one open\n * question — how often the no-room fallback fires — without touching either.\n *\n * The pill's own marginal effect cannot be measured here and must not be\n * reverse-engineered from this data: it ships together with the dot and the\n * beat, so there is no period with one and not the other.\n */\nexport function trackErrorSignalViewed(props: {\n source: InspectorErrorSignalSource;\n presentation: LauncherSignalPresentation;\n label: InspectorErrorSignalLabel;\n}): void {\n track(TELEMETRY_EVENTS.errorSignalViewed, {\n source: props.source,\n presentation: props.presentation,\n label: props.label,\n });\n}\n\n/**\n * Fires for links followed inside the announcement body. `body` is the only\n * call-to-action left: dismissal no longer exists, so there is nothing else a\n * click on this surface can mean.\n */\nexport function trackWhatsNewClicked(props: {\n banner_id: string;\n cta: \"body\";\n cta_label?: string;\n}): void {\n track(TELEMETRY_EVENTS.whatsNewClicked, props);\n}\n\n/**\n * How the panel was opened. Restoring a persisted-open panel on mount is\n * deliberately NOT a source: it is not an open *intent*, and counting it\n * would turn every dev-server hot reload into an \"open\".\n */\nexport type InspectorOpenSource = \"floating_button\" | \"message_toolbar\";\n\nexport type InspectorOpenedTelemetryProps = {\n open_source: InspectorOpenSource;\n package_name?: typeof PACKAGE_NAME;\n package_version?: string;\n inspector_distinct_id?: string;\n license_status?:\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"expiring\"\n | \"invalid\"\n | \"unknown\";\n runtime_mode?: \"sse\" | \"intelligence\";\n runtime_url_type?: RuntimeUrlType;\n /** True when an unseen announcement was on screen at open time. */\n has_unseen_announcement?: boolean;\n /** True when an error signal was on the launcher at open time. */\n has_error_signal?: boolean;\n /** Which failure class was signalling at open time, when one was. */\n error_signal_source?: InspectorErrorSignalSource;\n /** True when this is the first Inspector open after install or upgrade. */\n first_open?: boolean;\n};\n\n/**\n * Panel-open signal (OSS-566). Before this event, opens could only be\n * inferred from in-panel activity (a floor) or from the announcement's own\n * click event (which misses the floating-button path entirely).\n */\nexport function trackInspectorOpened(\n props: InspectorOpenedTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.opened, props);\n}\n\nexport type ExampleKind = \"realtime_sync\" | \"manage_history\" | \"inspect_runs\";\nexport type ThreadsUsageBucket =\n | \"absent\"\n | \"empty\"\n | \"within_limit\"\n | \"at_or_over_limit\"\n | \"unlimited\"\n | \"unknown_limit\";\nexport type ThreadsExpiryBucket = \"unavailable\" | \"zero\" | \"positive\";\nexport type InspectorGroupKey = \"home\" | \"workbench\" | \"inspect\";\nexport type InspectorLeafKey =\n | \"home\"\n | \"whats-new\"\n | \"playground\"\n | \"threads\"\n | \"ag-ui-events\"\n | \"agents\"\n | \"frontend-tools\"\n | \"capabilities\"\n | \"agent-context\"\n | \"memories\";\nexport type MetadataActionPlacement = \"threads_footer\" | \"threads_locked\";\nexport type ExampleTourStep = 1 | 2 | 3;\nexport type ExampleTourTab = \"timeline\" | \"raw-events\" | \"state\";\n\nexport type InspectorThreadTelemetryProps = Readonly<{\n posthog_distinct_id?: string;\n intelligence_status?:\n | \"intelligence_not_enabled\"\n | \"intelligence_enabled\"\n | \"unknown\";\n thread_service_status?: \"unavailable\" | \"available\" | \"unknown\" | \"error\";\n license_status?:\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"expiring\"\n | \"invalid\"\n | \"unknown\";\n runtime_mode?: \"sse\" | \"intelligence\";\n runtime_url_type?: RuntimeUrlType;\n cta_surface?:\n | \"threads_locked\"\n | \"threads_header\"\n | \"threads_empty\"\n | \"threads_populated\"\n | \"sidebar_footer\";\n cta?: \"signup\" | \"talk_to_engineer\";\n telemetry_disabled?: boolean;\n has_threads?: boolean;\n usage_bucket?: ThreadsUsageBucket;\n expiry_bucket?: ThreadsExpiryBucket;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n example_kind?: ExampleKind;\n tour_step?: ExampleTourStep;\n tour_tab?: ExampleTourTab;\n dismiss_method?: \"skip\" | \"done\";\n}>;\n\n/** Rebuild the common Thread payload from its closed coarse allowlist. */\nfunction threadCommonProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...(props.intelligence_status === undefined\n ? {}\n : { intelligence_status: props.intelligence_status }),\n ...(props.thread_service_status === undefined\n ? {}\n : { thread_service_status: props.thread_service_status }),\n ...(props.license_status === undefined\n ? {}\n : { license_status: props.license_status }),\n ...(props.runtime_mode === undefined\n ? {}\n : { runtime_mode: props.runtime_mode }),\n ...(props.runtime_url_type === undefined\n ? {}\n : { runtime_url_type: props.runtime_url_type }),\n ...(props.telemetry_disabled === undefined\n ? {}\n : { telemetry_disabled: props.telemetry_disabled }),\n ...(props.has_threads === undefined\n ? {}\n : { has_threads: props.has_threads }),\n ...(props.usage_bucket === undefined\n ? {}\n : { usage_bucket: props.usage_bucket }),\n ...(props.expiry_bucket === undefined\n ? {}\n : { expiry_bucket: props.expiry_bucket }),\n ...(props.group_key === undefined ? {} : { group_key: props.group_key }),\n ...(props.leaf_key === undefined ? {} : { leaf_key: props.leaf_key }),\n };\n}\n\n/** Add only the fields used by the three Thread CTA funnels. */\nfunction threadCtaProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadCommonProperties(props),\n ...(props.cta === undefined ? {} : { cta: props.cta }),\n ...(props.cta_surface === undefined\n ? {}\n : { cta_surface: props.cta_surface }),\n ...(props.posthog_distinct_id === undefined\n ? {}\n : { posthog_distinct_id: props.posthog_distinct_id }),\n };\n}\n\n/** Add only the closed example kind used by example impressions/selections. */\nfunction threadExampleProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadCommonProperties(props),\n ...(props.example_kind === undefined\n ? {}\n : { example_kind: props.example_kind }),\n };\n}\n\n/** Add only a bounded example kind and tour step/tab pair. */\nfunction threadTourProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadExampleProperties(props),\n ...(props.tour_step === undefined ? {} : { tour_step: props.tour_step }),\n ...(props.tour_tab === undefined ? {} : { tour_tab: props.tour_tab }),\n };\n}\n\n/** Add the bounded dismissal leaf used only by terminal tour events. */\nfunction threadTourTerminalProperties(props: InspectorThreadTelemetryProps) {\n return {\n ...threadTourProperties(props),\n ...(props.dismiss_method === undefined\n ? {}\n : { dismiss_method: props.dismiss_method }),\n };\n}\n\nexport function trackThreadsTabClicked(\n props: InspectorThreadTelemetryProps = {},\n): void {\n track(TELEMETRY_EVENTS.threadsTabClicked, threadCommonProperties(props));\n}\n\nexport function trackThreadsLockedViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.threadsLockedViewed, threadCommonProperties(props));\n}\n\nexport function trackThreadsIntelligenceSignupClicked(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsIntelligenceSignupClicked,\n threadCtaProperties(props),\n );\n}\n\nexport function trackThreadsTalkToEngineerClicked(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsTalkToEngineerClicked,\n threadCtaProperties(props),\n );\n}\n\nexport function trackTalkToEngineerClicked(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.talkToEngineerClicked, threadCtaProperties(props));\n}\n\nexport function trackThreadsEmptyEnabledViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsEmptyEnabledViewed,\n threadCommonProperties(props),\n );\n}\n\nexport function trackThreadsEnabledViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.threadsEnabledViewed, threadCommonProperties(props));\n}\n\nexport function trackThreadsExampleViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.threadsExampleViewed, threadExampleProperties(props));\n}\n\nexport function trackThreadsExampleSelected(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleSelected,\n threadExampleProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourStarted(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourStarted,\n threadTourProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourStepViewed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourStepViewed,\n threadTourProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourDismissed(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourDismissed,\n threadTourTerminalProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourCompleted(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourCompleted,\n threadTourTerminalProperties(props),\n );\n}\n\nexport function trackThreadsExampleTourReopened(\n props: InspectorThreadTelemetryProps,\n): void {\n track(\n TELEMETRY_EVENTS.threadsExampleTourReopened,\n threadTourProperties(props),\n );\n}\n\nexport type InspectorMemoryTelemetryProps = {\n package_name?: typeof PACKAGE_NAME;\n package_version?: string;\n inspector_distinct_id?: string;\n posthog_distinct_id?: string;\n memory_count?: number;\n available?: boolean;\n};\n\nexport function trackMemoriesTabClicked(\n props: InspectorMemoryTelemetryProps = {},\n): void {\n track(TELEMETRY_EVENTS.memoriesTabClicked, props);\n}\n\nexport type InspectorMetadataTelemetryModule = \"identity\" | \"plan\" | \"action\";\nexport type InspectorMetadataLicenseBucket =\n | \"valid\"\n | \"none\"\n | \"expired\"\n | \"unknown\";\nexport type InspectorMetadataActionKind =\n | \"manage_plan\"\n | \"renew\"\n | \"enable_intelligence\";\n\nexport type InspectorHomeTelemetryProps = Readonly<{\n action_kind?: InspectorMetadataActionKind;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n}>;\n\nexport function trackHomeViewed(props: InspectorHomeTelemetryProps = {}): void {\n track(TELEMETRY_EVENTS.homeViewed, {\n group_key: props.group_key ?? \"home\",\n leaf_key: props.leaf_key ?? \"home\",\n });\n}\n\nexport function trackHomeCtaClicked(props: InspectorHomeTelemetryProps): void {\n track(TELEMETRY_EVENTS.homeCtaClicked, {\n action_kind: props.action_kind,\n group_key: props.group_key ?? \"home\",\n leaf_key: props.leaf_key ?? \"home\",\n });\n}\n\nexport type InspectorMetadataModuleViewedTelemetryProps = Readonly<{\n module: InspectorMetadataTelemetryModule;\n license_bucket: InspectorMetadataLicenseBucket;\n action_kind?: InspectorMetadataActionKind;\n usage_bucket: ThreadsUsageBucket;\n expiry_bucket: ThreadsExpiryBucket;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n action_placement?: MetadataActionPlacement;\n}>;\n\nexport type InspectorMetadataActionClickedTelemetryProps = Readonly<{\n action_kind: Exclude<InspectorMetadataActionKind, \"enable_intelligence\">;\n license_bucket: InspectorMetadataLicenseBucket;\n usage_bucket: ThreadsUsageBucket;\n expiry_bucket: ThreadsExpiryBucket;\n group_key?: InspectorGroupKey;\n leaf_key?: InspectorLeafKey;\n action_placement?: MetadataActionPlacement;\n}>;\n\nfunction metadataCoarseProperties(\n props:\n | InspectorMetadataModuleViewedTelemetryProps\n | InspectorMetadataActionClickedTelemetryProps,\n) {\n const navigation =\n props.group_key === undefined || props.leaf_key === undefined\n ? {}\n : { group_key: props.group_key, leaf_key: props.leaf_key };\n return {\n license_bucket: props.license_bucket,\n usage_bucket: props.usage_bucket,\n expiry_bucket: props.expiry_bucket,\n ...navigation,\n ...(props.action_placement === undefined\n ? {}\n : { action_placement: props.action_placement }),\n };\n}\n\n/**\n * Tracks one visible Inspector metadata module using coarse fields only.\n * Rebuilding the payload here prevents local labels, IDs, URLs, and usage\n * values from crossing the telemetry boundary through extra object fields.\n */\nexport function trackMetadataModuleViewed(\n props: InspectorMetadataModuleViewedTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.metadataModuleViewed, {\n module: props.module,\n ...(props.action_kind === undefined\n ? {}\n : { action_kind: props.action_kind }),\n ...metadataCoarseProperties(props),\n });\n}\n\n/**\n * Tracks clicks for managed plan and renewal actions. The existing\n * Intelligence-enable funnel keeps its original event and never calls this\n * helper, which prevents a single click from producing two wire events.\n */\nexport function trackMetadataActionClicked(\n props: InspectorMetadataActionClickedTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.metadataActionClicked, {\n module: \"action\",\n action_kind: props.action_kind,\n ...metadataCoarseProperties(props),\n });\n}\n\n/**\n * Returns the inspector's anonymous distinct-ID for cross-domain\n * propagation onto outbound announcement-CTA links, or `null` when the user\n * is opted out.\n *\n * The website / Ops API reads this query param on signup-flow landing\n * pages and calls `posthog.alias(...)` to merge the inspector's anon\n * ID with the website's anon ID, enabling the\n * `whats_new_viewed → whats_new_clicked → signup_attributed` funnel.\n * `identify()` itself is out of scope here (it happens on signup, in\n * the website / Ops API).\n *\n * Opt-out short-circuits this too: if the user has opted out, we do\n * NOT leak an anon ID across domains.\n */\nexport function getTelemetryDistinctIdForUrl(): string | null {\n if (isTelemetryOptedOut()) return null;\n return getOrCreateTelemetryDistinctId();\n}\n\n/**\n * Seeds the anonymous distinct-ID into localStorage on inspector mount\n * so it is ready for cross-domain propagation onto announcement-CTA links\n * even before the first event fires. No-op when the user has opted out.\n */\nexport function ensureTelemetryDistinctId(): void {\n if (isTelemetryOptedOut()) return;\n getOrCreateTelemetryDistinctId();\n}\n\n/**\n * Fires the one-time console disclosure on inspector mount, when the\n * user is not opted out and hasn't seen it before. Idempotent across\n * calls within a single session because `markTelemetryDisclosureShown`\n * persists to localStorage.\n *\n * If the user is opted out, we deliberately do nothing and do NOT mark\n * the flag — so a future opt-in flips back to \"first run\" behavior.\n */\nexport function maybeShowDisclosure(): void {\n if (isTelemetryOptedOut()) return;\n if (hasTelemetryDisclosureBeenShown()) return;\n // eslint-disable-next-line no-console\n console.info(\n `[CopilotKit Inspector] anonymous interaction telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out.`,\n );\n markTelemetryDisclosureShown();\n}\n\nexport { isTelemetryOptedOut };\n\nasync function postBestEffort(\n url: string,\n body: string,\n distinctId: string,\n): Promise<void> {\n if (typeof fetch === \"undefined\") return;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n try {\n const controller = new AbortController();\n timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-CopilotKit-Telemetry-Id\": distinctId,\n },\n body,\n signal: controller.signal,\n // No credentials / no Authorization header — anonymous endpoint.\n });\n } catch {\n // Silent failure — telemetry must not break the application.\n } finally {\n if (timeoutId !== undefined) clearTimeout(timeoutId);\n }\n}\n"],"mappings":";;;;AA6BA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,gBAAgB;CAChB,sBAAsB;CACtB,mBAAmB;CACnB,iBAAiB;CACjB,mBAAmB;CACnB,qBAAqB;CACrB,kCACE;CACF,8BACE;CACF,uBAAuB;CACvB,2BAA2B;CAC3B,sBAAsB;CACtB,sBAAsB;CACtB,wBAAwB;CACxB,2BAA2B;CAC3B,8BACE;CACF,6BAA6B;CAC7B,6BAA6B;CAC7B,4BAA4B;CAC5B,oBAAoB;CACpB,YAAY;CACZ,gBAAgB;CAChB,sBAAsB;CACtB,uBAAuB;CACxB;AAOD,MAAa,uBAAuB;AAMpC,MAAa,qBAAqB;AAElC,MAAM,eAAe;AACrB,MAAM;AAIN,MAAM,mBAAmB;AAUzB,SAAgB,kBACd,YACgB;AAChB,KAAI,CAAC,WAAY,QAAO;AACxB,KAAI,WAAW,WAAW,IAAI,IAAI,CAAC,WAAW,WAAW,KAAK,CAC5D,QAAO;AAGT,KAAI;EACF,MAAM,WACJ,OAAO,WAAW,cACd,OAAO,SAAS,OAChB;EACN,MAAM,MAAM,IAAI,IAAI,YAAY,SAAS;EACzC,MAAM,UAAU,IAAI,IAAI,SAAS;EACjC,MAAM,WAAW,IAAI,SAAS,aAAa;AAE3C,MACE,aAAa,eACb,aAAa,eACb,aAAa,QAEb,QAAO;AAGT,SAAO,IAAI,WAAW,QAAQ,SAAS,gBAAgB;SACjD;AACN,SAAO;;;;;;;;;;;AAYX,SAAgB,MACd,OACA,aAAsC,EAAE,EAClC;AACN,KAAIA,yCAAqB,CAAE;AAE3B,KAAI;EACF,MAAM,aAAaC,oDAAgC;AAkBnD,EAAK,eAAe,sBAfP,KAAK,UAAU;GAC1B;GACA,YAAY;IACV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Y,mBAAA"}
1
+ {"version":3,"file":"telemetry.d.cts","names":[],"sources":["../../src/lib/telemetry.ts"],"mappings":";;;;;;KAgRY,mBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.mts","names":[],"sources":["../../src/lib/telemetry.ts"],"mappings":";;;;;;KAmNY,mBAAA"}
1
+ {"version":3,"file":"telemetry.d.mts","names":[],"sources":["../../src/lib/telemetry.ts"],"mappings":";;;;;;KAgRY,mBAAA"}
@@ -6,6 +6,7 @@ const TELEMETRY_EVENTS = {
6
6
  opened: "oss.inspector.opened",
7
7
  whatsNewViewed: "oss.inspector.whats_new_viewed",
8
8
  whatsNewSignalViewed: "oss.inspector.whats_new_signal_viewed",
9
+ errorSignalViewed: "oss.inspector.error_signal_viewed",
9
10
  whatsNewClicked: "oss.inspector.whats_new_clicked",
10
11
  threadsTabClicked: "oss.inspector.threads_tab_clicked",
11
12
  threadsLockedViewed: "oss.inspector.threads_locked_viewed",
@@ -88,6 +89,31 @@ function trackWhatsNewSignalViewed(props) {
88
89
  track(TELEMETRY_EVENTS.whatsNewSignalViewed, props);
89
90
  }
90
91
  /**
92
+ * Fires when the launcher's error signal becomes *visible* — not when it arms.
93
+ * Arming can happen with the panel open or the tab hidden, where there is no
94
+ * launcher to look at, so counting arms would inflate the denominator this
95
+ * event exists to provide.
96
+ *
97
+ * Deliberately carries three fixed enum values and nothing else. This is the
98
+ * one place a later change could casually attach a free-text field, and the
99
+ * failure message must never be transmitted.
100
+ *
101
+ * `label` is deliberately not a new event: the catalogue's size is asserted
102
+ * and spelled out in a test title, and a property answers the one open
103
+ * question — how often the no-room fallback fires — without touching either.
104
+ *
105
+ * The pill's own marginal effect cannot be measured here and must not be
106
+ * reverse-engineered from this data: it ships together with the dot and the
107
+ * beat, so there is no period with one and not the other.
108
+ */
109
+ function trackErrorSignalViewed(props) {
110
+ track(TELEMETRY_EVENTS.errorSignalViewed, {
111
+ source: props.source,
112
+ presentation: props.presentation,
113
+ label: props.label
114
+ });
115
+ }
116
+ /**
91
117
  * Fires for links followed inside the announcement body. `body` is the only
92
118
  * call-to-action left: dismissal no longer exists, so there is nothing else a
93
119
  * click on this surface can mean.
@@ -309,5 +335,5 @@ async function postBestEffort(url, body, distinctId) {
309
335
  }
310
336
 
311
337
  //#endregion
312
- export { TELEMETRY_DOCS_URL, ensureTelemetryDistinctId, getRuntimeUrlType, getTelemetryDistinctIdForUrl, maybeShowDisclosure, trackHomeCtaClicked, trackHomeViewed, trackInspectorOpened, trackMemoriesTabClicked, trackMetadataActionClicked, trackMetadataModuleViewed, trackTalkToEngineerClicked, trackThreadsEmptyEnabledViewed, trackThreadsEnabledViewed, trackThreadsExampleSelected, trackThreadsExampleTourCompleted, trackThreadsExampleTourDismissed, trackThreadsExampleTourReopened, trackThreadsExampleTourStarted, trackThreadsExampleTourStepViewed, trackThreadsExampleViewed, trackThreadsIntelligenceSignupClicked, trackThreadsLockedViewed, trackThreadsTabClicked, trackThreadsTalkToEngineerClicked, trackWhatsNewClicked, trackWhatsNewSignalViewed, trackWhatsNewViewed };
338
+ export { TELEMETRY_DOCS_URL, ensureTelemetryDistinctId, getRuntimeUrlType, getTelemetryDistinctIdForUrl, maybeShowDisclosure, trackErrorSignalViewed, trackHomeCtaClicked, trackHomeViewed, trackInspectorOpened, trackMemoriesTabClicked, trackMetadataActionClicked, trackMetadataModuleViewed, trackTalkToEngineerClicked, trackThreadsEmptyEnabledViewed, trackThreadsEnabledViewed, trackThreadsExampleSelected, trackThreadsExampleTourCompleted, trackThreadsExampleTourDismissed, trackThreadsExampleTourReopened, trackThreadsExampleTourStarted, trackThreadsExampleTourStepViewed, trackThreadsExampleViewed, trackThreadsIntelligenceSignupClicked, trackThreadsLockedViewed, trackThreadsTabClicked, trackThreadsTalkToEngineerClicked, trackWhatsNewClicked, trackWhatsNewSignalViewed, trackWhatsNewViewed };
313
339
  //# sourceMappingURL=telemetry.mjs.map