@copilotkit/web-inspector 1.69.2 → 1.70.0
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.
- package/dist/index.cjs +2259 -659
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +161 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +161 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2260 -661
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2512 -814
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/home-briefing.cjs +2 -2
- package/dist/lib/home-briefing.cjs.map +1 -1
- package/dist/lib/home-briefing.mjs +2 -2
- package/dist/lib/home-briefing.mjs.map +1 -1
- package/dist/lib/onboarding-prompt.cjs +48 -0
- package/dist/lib/onboarding-prompt.cjs.map +1 -0
- package/dist/lib/onboarding-prompt.mjs +46 -0
- package/dist/lib/onboarding-prompt.mjs.map +1 -0
- package/dist/lib/telemetry.cjs +42 -0
- package/dist/lib/telemetry.cjs.map +1 -1
- package/dist/lib/telemetry.d.cts.map +1 -1
- package/dist/lib/telemetry.d.mts.map +1 -1
- package/dist/lib/telemetry.mjs +40 -1
- package/dist/lib/telemetry.mjs.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/styles/generated.cjs +1 -1
- package/dist/styles/generated.cjs.map +1 -1
- package/dist/styles/generated.mjs +1 -1
- package/dist/styles/generated.mjs.map +1 -1
- package/package.json +5 -4
|
@@ -45,8 +45,8 @@ function heroForState(args) {
|
|
|
45
45
|
const renewing = args.action?.kind === "renew";
|
|
46
46
|
return {
|
|
47
47
|
connection: "disconnected",
|
|
48
|
-
title: renewing ? "Renew Intelligence" : "Intelligence
|
|
49
|
-
body: renewing ? "Renew Intelligence to restore persistent Threads and Memory." : "
|
|
48
|
+
title: renewing ? "Renew Intelligence" : "CopilotKit Intelligence",
|
|
49
|
+
body: renewing ? "Renew Intelligence to restore persistent Threads and Memory." : "Intelligence keeps every thread your users have, finds evidence-backed patterns in them, and proposes skills you approve before your agent uses them.",
|
|
50
50
|
action: connectIntelligenceAction(args.action, args.connectUrl, args.licenseState)
|
|
51
51
|
};
|
|
52
52
|
}
|
|
@@ -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\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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AAS;GAC9B,CAAC;EACF;EACA,SAAS,WACL;GACE,kBAAkB,SAAS;GAC3B,aAAa,SAAS;GACtB,WAAW,MAAM,SAAS,MAAM;GAChC,SAAS,MAAM,SAAS;GACxB;GACD,GACD,MAAM,SAAS,QAAQ,QACrB;GACE,kBAAkB;GAClB,aAAa;GACb,WAAW,MAAM,SAAS,MAAM;GAChC,SAAS,MAAM,SAAS;GACxB;GACD,GACD;EACN,SAAS;GACP,KAAK,MAAM;GACX,QAAQ,uBAAuB,MAAM;GACtC;EACD,UAAU;GACR;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,KAAK,MAAM;IACX,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,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,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 // Not \"Intelligence is not setup\" — that reads as a defect in the tool,\n // and a defect gets dismissed. The heading names the product; the\n // argument for it is made by the rotating copy on Home, which changes\n // with the picture beside it.\n title: renewing ? \"Renew Intelligence\" : \"CopilotKit Intelligence\",\n // In install mode this is NOT the visible paragraph. The visible copy\n // rotates every few seconds, which would make a screen reader announce a\n // new sentence four times a loop, so the rotating text is hidden from\n // assistive tech and this one stable sentence is exposed instead. It has\n // to carry the whole chain on its own.\n body: renewing\n ? \"Renew Intelligence to restore persistent Threads and Memory.\"\n : \"Intelligence keeps every thread your users have, finds evidence-backed patterns in them, and proposes skills you approve before your agent uses them.\",\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;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,SAAS,QAAQ,QACrB;GACE,kBAAkB;GAClB,aAAa;GACb,WAAW,MAAM,SAAS,MAAM;GAChC,SAAS,MAAM,SAAS;GACxB;GACD,GACD;EACN,SAAS;GACP,KAAK,MAAM;GACX,QAAQ,uBAAuB,MAAM;GACtC;EACD,UAAU;GACR;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,KAAK,MAAM;IACX,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,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,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"}
|
|
@@ -44,8 +44,8 @@ function heroForState(args) {
|
|
|
44
44
|
const renewing = args.action?.kind === "renew";
|
|
45
45
|
return {
|
|
46
46
|
connection: "disconnected",
|
|
47
|
-
title: renewing ? "Renew Intelligence" : "Intelligence
|
|
48
|
-
body: renewing ? "Renew Intelligence to restore persistent Threads and Memory." : "
|
|
47
|
+
title: renewing ? "Renew Intelligence" : "CopilotKit Intelligence",
|
|
48
|
+
body: renewing ? "Renew Intelligence to restore persistent Threads and Memory." : "Intelligence keeps every thread your users have, finds evidence-backed patterns in them, and proposes skills you approve before your agent uses them.",
|
|
49
49
|
action: connectIntelligenceAction(args.action, args.connectUrl, args.licenseState)
|
|
50
50
|
};
|
|
51
51
|
}
|
|
@@ -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\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;A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SAAS;GACtB,WAAW,MAAM,SAAS,MAAM;GAChC,SAAS,MAAM,SAAS;GACxB;GACD,GACD,MAAM,SAAS,QAAQ,QACrB;GACE,kBAAkB;GAClB,aAAa;GACb,WAAW,MAAM,SAAS,MAAM;GAChC,SAAS,MAAM,SAAS;GACxB;GACD,GACD;EACN,SAAS;GACP,KAAK,MAAM;GACX,QAAQ,uBAAuB,MAAM;GACtC;EACD,UAAU;GACR;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,KAAK,MAAM;IACX,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,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,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 // Not \"Intelligence is not setup\" — that reads as a defect in the tool,\n // and a defect gets dismissed. The heading names the product; the\n // argument for it is made by the rotating copy on Home, which changes\n // with the picture beside it.\n title: renewing ? \"Renew Intelligence\" : \"CopilotKit Intelligence\",\n // In install mode this is NOT the visible paragraph. The visible copy\n // rotates every few seconds, which would make a screen reader announce a\n // new sentence four times a loop, so the rotating text is hidden from\n // assistive tech and this one stable sentence is exposed instead. It has\n // to carry the whole chain on its own.\n body: renewing\n ? \"Renew Intelligence to restore persistent Threads and Memory.\"\n : \"Intelligence keeps every thread your users have, finds evidence-backed patterns in them, and proposes skills you approve before your agent uses them.\",\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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M;GAChC,SAAS,MAAM,SAAS;GACxB;GACD,GACD;EACN,SAAS;GACP,KAAK,MAAM;GACX,QAAQ,uBAAuB,MAAM;GACtC;EACD,UAAU;GACR;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,KAAK,MAAM;IACX,SAAS,iBAAiB;IAC3B;GACD;IACE,IAAI;IACJ,OAAO;IACP,SAAS,yBAAyB,MAAM;IACxC,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,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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/lib/onboarding-prompt.ts
|
|
3
|
+
/**
|
|
4
|
+
* The Intelligence install prompt the Inspector hands to a coding agent.
|
|
5
|
+
*
|
|
6
|
+
* Every other Intelligence call to action in the Inspector opens a page in a
|
|
7
|
+
* new tab, which is where developers drop out: they leave the editor, meet a
|
|
8
|
+
* signup form, and never come back. This prompt lets the install happen where
|
|
9
|
+
* they already are.
|
|
10
|
+
*
|
|
11
|
+
* The wording is kept byte-identical to `INTELLIGENCE_ONBOARDING_PROMPT` in the
|
|
12
|
+
* Intelligence app (`apps/app-frontend/react-shell/src/home/intelligence-home.tsx`).
|
|
13
|
+
* The CLI resolves `onboard start` against a prompt graph, so the two surfaces
|
|
14
|
+
* must not drift — if the CLI's entry point changes, both change together.
|
|
15
|
+
*/
|
|
16
|
+
const RUN_ID_PLACEHOLDER = "<run-id>";
|
|
17
|
+
const ONBOARDING_PROMPT_TEMPLATE = `Identify which coding-agent product you are, using a short slug such as \`codex\` or \`claude-code\`. From the root of the project where you want CopilotKit, run \`npx --yes copilotkit@latest onboard start --run ${RUN_ID_PLACEHOLDER} --coding-agent <coding-agent-slug>\`. Follow the Markdown instructions it prints until onboarding is complete.`;
|
|
18
|
+
/** Length and alphabet are the CLI's, so a run id copied here resolves there. */
|
|
19
|
+
const RUN_ID_LENGTH = 12;
|
|
20
|
+
/**
|
|
21
|
+
* Mint the identifier that joins this copy to the CLI run it starts.
|
|
22
|
+
*
|
|
23
|
+
* The Intelligence app derives it from `crypto.randomUUID()`. The Inspector
|
|
24
|
+
* runs inside whatever page embeds it, so neither `randomUUID` nor a secure
|
|
25
|
+
* context is guaranteed; the two fallbacks keep the id present rather than
|
|
26
|
+
* letting the button fail. Collision risk is irrelevant — this correlates
|
|
27
|
+
* telemetry, it does not authorise anything.
|
|
28
|
+
*/
|
|
29
|
+
function createOnboardingRunId() {
|
|
30
|
+
const webCrypto = globalThis.crypto;
|
|
31
|
+
if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID().replaceAll("-", "").slice(0, RUN_ID_LENGTH);
|
|
32
|
+
if (typeof webCrypto?.getRandomValues === "function") {
|
|
33
|
+
const bytes = webCrypto.getRandomValues(new Uint8Array(RUN_ID_LENGTH / 2));
|
|
34
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
35
|
+
}
|
|
36
|
+
let id = "";
|
|
37
|
+
while (id.length < RUN_ID_LENGTH) id += Math.floor(Math.random() * 16).toString(16);
|
|
38
|
+
return id.slice(0, RUN_ID_LENGTH);
|
|
39
|
+
}
|
|
40
|
+
/** Bind one run id into the prompt text that gets copied. */
|
|
41
|
+
function createOnboardingPrompt(runId) {
|
|
42
|
+
return ONBOARDING_PROMPT_TEMPLATE.replace(RUN_ID_PLACEHOLDER, runId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.createOnboardingPrompt = createOnboardingPrompt;
|
|
47
|
+
exports.createOnboardingRunId = createOnboardingRunId;
|
|
48
|
+
//# sourceMappingURL=onboarding-prompt.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding-prompt.cjs","names":[],"sources":["../../src/lib/onboarding-prompt.ts"],"sourcesContent":["/**\n * The Intelligence install prompt the Inspector hands to a coding agent.\n *\n * Every other Intelligence call to action in the Inspector opens a page in a\n * new tab, which is where developers drop out: they leave the editor, meet a\n * signup form, and never come back. This prompt lets the install happen where\n * they already are.\n *\n * The wording is kept byte-identical to `INTELLIGENCE_ONBOARDING_PROMPT` in the\n * Intelligence app (`apps/app-frontend/react-shell/src/home/intelligence-home.tsx`).\n * The CLI resolves `onboard start` against a prompt graph, so the two surfaces\n * must not drift — if the CLI's entry point changes, both change together.\n */\nconst RUN_ID_PLACEHOLDER = \"<run-id>\";\n\nexport const ONBOARDING_PROMPT_TEMPLATE =\n \"Identify which coding-agent product you are, using a short slug such as \" +\n \"`codex` or `claude-code`. From the root of the project where you want \" +\n \"CopilotKit, run `npx --yes copilotkit@latest onboard start --run \" +\n `${RUN_ID_PLACEHOLDER}` +\n \" --coding-agent <coding-agent-slug>`. Follow the Markdown instructions it \" +\n \"prints until onboarding is complete.\";\n\n/** Length and alphabet are the CLI's, so a run id copied here resolves there. */\nconst RUN_ID_LENGTH = 12;\n\n/**\n * Mint the identifier that joins this copy to the CLI run it starts.\n *\n * The Intelligence app derives it from `crypto.randomUUID()`. The Inspector\n * runs inside whatever page embeds it, so neither `randomUUID` nor a secure\n * context is guaranteed; the two fallbacks keep the id present rather than\n * letting the button fail. Collision risk is irrelevant — this correlates\n * telemetry, it does not authorise anything.\n */\nexport function createOnboardingRunId(): string {\n const webCrypto = globalThis.crypto;\n\n if (typeof webCrypto?.randomUUID === \"function\") {\n return webCrypto.randomUUID().replaceAll(\"-\", \"\").slice(0, RUN_ID_LENGTH);\n }\n\n if (typeof webCrypto?.getRandomValues === \"function\") {\n const bytes = webCrypto.getRandomValues(new Uint8Array(RUN_ID_LENGTH / 2));\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\n \"\",\n );\n }\n\n let id = \"\";\n while (id.length < RUN_ID_LENGTH) {\n id += Math.floor(Math.random() * 16).toString(16);\n }\n return id.slice(0, RUN_ID_LENGTH);\n}\n\n/** Bind one run id into the prompt text that gets copied. */\nexport function createOnboardingPrompt(runId: string): string {\n return ONBOARDING_PROMPT_TEMPLATE.replace(RUN_ID_PLACEHOLDER, runId);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAM,qBAAqB;AAE3B,MAAa,6BACX,uNAGG;;AAKL,MAAM,gBAAgB;;;;;;;;;;AAWtB,SAAgB,wBAAgC;CAC9C,MAAM,YAAY,WAAW;AAE7B,KAAI,OAAO,WAAW,eAAe,WACnC,QAAO,UAAU,YAAY,CAAC,WAAW,KAAK,GAAG,CAAC,MAAM,GAAG,cAAc;AAG3E,KAAI,OAAO,WAAW,oBAAoB,YAAY;EACpD,MAAM,QAAQ,UAAU,gBAAgB,IAAI,WAAW,gBAAgB,EAAE,CAAC;AAC1E,SAAO,MAAM,KAAK,QAAQ,SAAS,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KACrE,GACD;;CAGH,IAAI,KAAK;AACT,QAAO,GAAG,SAAS,cACjB,OAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,GAAG,CAAC,SAAS,GAAG;AAEnD,QAAO,GAAG,MAAM,GAAG,cAAc;;;AAInC,SAAgB,uBAAuB,OAAuB;AAC5D,QAAO,2BAA2B,QAAQ,oBAAoB,MAAM"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/lib/onboarding-prompt.ts
|
|
2
|
+
/**
|
|
3
|
+
* The Intelligence install prompt the Inspector hands to a coding agent.
|
|
4
|
+
*
|
|
5
|
+
* Every other Intelligence call to action in the Inspector opens a page in a
|
|
6
|
+
* new tab, which is where developers drop out: they leave the editor, meet a
|
|
7
|
+
* signup form, and never come back. This prompt lets the install happen where
|
|
8
|
+
* they already are.
|
|
9
|
+
*
|
|
10
|
+
* The wording is kept byte-identical to `INTELLIGENCE_ONBOARDING_PROMPT` in the
|
|
11
|
+
* Intelligence app (`apps/app-frontend/react-shell/src/home/intelligence-home.tsx`).
|
|
12
|
+
* The CLI resolves `onboard start` against a prompt graph, so the two surfaces
|
|
13
|
+
* must not drift — if the CLI's entry point changes, both change together.
|
|
14
|
+
*/
|
|
15
|
+
const RUN_ID_PLACEHOLDER = "<run-id>";
|
|
16
|
+
const ONBOARDING_PROMPT_TEMPLATE = `Identify which coding-agent product you are, using a short slug such as \`codex\` or \`claude-code\`. From the root of the project where you want CopilotKit, run \`npx --yes copilotkit@latest onboard start --run ${RUN_ID_PLACEHOLDER} --coding-agent <coding-agent-slug>\`. Follow the Markdown instructions it prints until onboarding is complete.`;
|
|
17
|
+
/** Length and alphabet are the CLI's, so a run id copied here resolves there. */
|
|
18
|
+
const RUN_ID_LENGTH = 12;
|
|
19
|
+
/**
|
|
20
|
+
* Mint the identifier that joins this copy to the CLI run it starts.
|
|
21
|
+
*
|
|
22
|
+
* The Intelligence app derives it from `crypto.randomUUID()`. The Inspector
|
|
23
|
+
* runs inside whatever page embeds it, so neither `randomUUID` nor a secure
|
|
24
|
+
* context is guaranteed; the two fallbacks keep the id present rather than
|
|
25
|
+
* letting the button fail. Collision risk is irrelevant — this correlates
|
|
26
|
+
* telemetry, it does not authorise anything.
|
|
27
|
+
*/
|
|
28
|
+
function createOnboardingRunId() {
|
|
29
|
+
const webCrypto = globalThis.crypto;
|
|
30
|
+
if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID().replaceAll("-", "").slice(0, RUN_ID_LENGTH);
|
|
31
|
+
if (typeof webCrypto?.getRandomValues === "function") {
|
|
32
|
+
const bytes = webCrypto.getRandomValues(new Uint8Array(RUN_ID_LENGTH / 2));
|
|
33
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
34
|
+
}
|
|
35
|
+
let id = "";
|
|
36
|
+
while (id.length < RUN_ID_LENGTH) id += Math.floor(Math.random() * 16).toString(16);
|
|
37
|
+
return id.slice(0, RUN_ID_LENGTH);
|
|
38
|
+
}
|
|
39
|
+
/** Bind one run id into the prompt text that gets copied. */
|
|
40
|
+
function createOnboardingPrompt(runId) {
|
|
41
|
+
return ONBOARDING_PROMPT_TEMPLATE.replace(RUN_ID_PLACEHOLDER, runId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
export { createOnboardingPrompt, createOnboardingRunId };
|
|
46
|
+
//# sourceMappingURL=onboarding-prompt.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding-prompt.mjs","names":[],"sources":["../../src/lib/onboarding-prompt.ts"],"sourcesContent":["/**\n * The Intelligence install prompt the Inspector hands to a coding agent.\n *\n * Every other Intelligence call to action in the Inspector opens a page in a\n * new tab, which is where developers drop out: they leave the editor, meet a\n * signup form, and never come back. This prompt lets the install happen where\n * they already are.\n *\n * The wording is kept byte-identical to `INTELLIGENCE_ONBOARDING_PROMPT` in the\n * Intelligence app (`apps/app-frontend/react-shell/src/home/intelligence-home.tsx`).\n * The CLI resolves `onboard start` against a prompt graph, so the two surfaces\n * must not drift — if the CLI's entry point changes, both change together.\n */\nconst RUN_ID_PLACEHOLDER = \"<run-id>\";\n\nexport const ONBOARDING_PROMPT_TEMPLATE =\n \"Identify which coding-agent product you are, using a short slug such as \" +\n \"`codex` or `claude-code`. From the root of the project where you want \" +\n \"CopilotKit, run `npx --yes copilotkit@latest onboard start --run \" +\n `${RUN_ID_PLACEHOLDER}` +\n \" --coding-agent <coding-agent-slug>`. Follow the Markdown instructions it \" +\n \"prints until onboarding is complete.\";\n\n/** Length and alphabet are the CLI's, so a run id copied here resolves there. */\nconst RUN_ID_LENGTH = 12;\n\n/**\n * Mint the identifier that joins this copy to the CLI run it starts.\n *\n * The Intelligence app derives it from `crypto.randomUUID()`. The Inspector\n * runs inside whatever page embeds it, so neither `randomUUID` nor a secure\n * context is guaranteed; the two fallbacks keep the id present rather than\n * letting the button fail. Collision risk is irrelevant — this correlates\n * telemetry, it does not authorise anything.\n */\nexport function createOnboardingRunId(): string {\n const webCrypto = globalThis.crypto;\n\n if (typeof webCrypto?.randomUUID === \"function\") {\n return webCrypto.randomUUID().replaceAll(\"-\", \"\").slice(0, RUN_ID_LENGTH);\n }\n\n if (typeof webCrypto?.getRandomValues === \"function\") {\n const bytes = webCrypto.getRandomValues(new Uint8Array(RUN_ID_LENGTH / 2));\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, \"0\")).join(\n \"\",\n );\n }\n\n let id = \"\";\n while (id.length < RUN_ID_LENGTH) {\n id += Math.floor(Math.random() * 16).toString(16);\n }\n return id.slice(0, RUN_ID_LENGTH);\n}\n\n/** Bind one run id into the prompt text that gets copied. */\nexport function createOnboardingPrompt(runId: string): string {\n return ONBOARDING_PROMPT_TEMPLATE.replace(RUN_ID_PLACEHOLDER, runId);\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,qBAAqB;AAE3B,MAAa,6BACX,uNAGG;;AAKL,MAAM,gBAAgB;;;;;;;;;;AAWtB,SAAgB,wBAAgC;CAC9C,MAAM,YAAY,WAAW;AAE7B,KAAI,OAAO,WAAW,eAAe,WACnC,QAAO,UAAU,YAAY,CAAC,WAAW,KAAK,GAAG,CAAC,MAAM,GAAG,cAAc;AAG3E,KAAI,OAAO,WAAW,oBAAoB,YAAY;EACpD,MAAM,QAAQ,UAAU,gBAAgB,IAAI,WAAW,gBAAgB,EAAE,CAAC;AAC1E,SAAO,MAAM,KAAK,QAAQ,SAAS,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,KACrE,GACD;;CAGH,IAAI,KAAK;AACT,QAAO,GAAG,SAAS,cACjB,OAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,GAAG,CAAC,SAAS,GAAG;AAEnD,QAAO,GAAG,MAAM,GAAG,cAAc;;;AAInC,SAAgB,uBAAuB,OAAuB;AAC5D,QAAO,2BAA2B,QAAQ,oBAAoB,MAAM"}
|
package/dist/lib/telemetry.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const TELEMETRY_EVENTS = {
|
|
|
9
9
|
errorSignalViewed: "oss.inspector.error_signal_viewed",
|
|
10
10
|
whatsNewClicked: "oss.inspector.whats_new_clicked",
|
|
11
11
|
threadsTabClicked: "oss.inspector.threads_tab_clicked",
|
|
12
|
+
threadsTryFromHereClicked: "oss.inspector.threads_try_from_here_clicked",
|
|
12
13
|
threadsLockedViewed: "oss.inspector.threads_locked_viewed",
|
|
13
14
|
threadsIntelligenceSignupClicked: "oss.inspector.threads_intelligence_signup_clicked",
|
|
14
15
|
threadsTalkToEngineerClicked: "oss.inspector.threads_talk_to_engineer_clicked",
|
|
@@ -25,6 +26,8 @@ const TELEMETRY_EVENTS = {
|
|
|
25
26
|
memoriesTabClicked: "oss.inspector.memories_tab_clicked",
|
|
26
27
|
homeViewed: "oss.inspector.home_viewed",
|
|
27
28
|
homeCtaClicked: "oss.inspector.home_cta_clicked",
|
|
29
|
+
homePromptCopied: "oss.inspector.home_prompt_copied",
|
|
30
|
+
homeStoryBeatSelected: "oss.inspector.home_story_beat_selected",
|
|
28
31
|
metadataModuleViewed: "oss.inspector.metadata_module_viewed",
|
|
29
32
|
metadataActionClicked: "oss.inspector.metadata_action_clicked"
|
|
30
33
|
};
|
|
@@ -179,6 +182,12 @@ function threadTourTerminalProperties(props) {
|
|
|
179
182
|
function trackThreadsTabClicked(props = {}) {
|
|
180
183
|
track(TELEMETRY_EVENTS.threadsTabClicked, threadCommonProperties(props));
|
|
181
184
|
}
|
|
185
|
+
function trackThreadsTryFromHereClicked(props) {
|
|
186
|
+
track(TELEMETRY_EVENTS.threadsTryFromHereClicked, {
|
|
187
|
+
...threadCommonProperties(props),
|
|
188
|
+
...props.outcome === void 0 ? {} : { outcome: props.outcome }
|
|
189
|
+
});
|
|
190
|
+
}
|
|
182
191
|
function trackThreadsLockedViewed(props) {
|
|
183
192
|
track(TELEMETRY_EVENTS.threadsLockedViewed, threadCommonProperties(props));
|
|
184
193
|
}
|
|
@@ -234,6 +243,36 @@ function trackHomeCtaClicked(props) {
|
|
|
234
243
|
leaf_key: props.leaf_key ?? "home"
|
|
235
244
|
});
|
|
236
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Report a copy of the Intelligence install prompt.
|
|
248
|
+
*
|
|
249
|
+
* `outcome` is reported rather than only emitting on success, because a
|
|
250
|
+
* clipboard that refuses is indistinguishable from a developer who never
|
|
251
|
+
* pressed the button — and the two call for opposite fixes.
|
|
252
|
+
*/
|
|
253
|
+
function trackHomePromptCopied(props) {
|
|
254
|
+
track(TELEMETRY_EVENTS.homePromptCopied, {
|
|
255
|
+
onboarding_run_id: props.onboarding_run_id,
|
|
256
|
+
outcome: props.outcome,
|
|
257
|
+
group_key: "home",
|
|
258
|
+
leaf_key: "home"
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Report a step of the Intelligence story that a developer opened themselves.
|
|
263
|
+
*
|
|
264
|
+
* Only a press reports. The story also advances on its own every few seconds,
|
|
265
|
+
* and reporting that would bury the handful of real interactions under a
|
|
266
|
+
* metronome — one event per idle developer per six seconds, none of it intent.
|
|
267
|
+
*/
|
|
268
|
+
function trackHomeStoryBeatSelected(props) {
|
|
269
|
+
track(TELEMETRY_EVENTS.homeStoryBeatSelected, {
|
|
270
|
+
beat: props.beat,
|
|
271
|
+
beat_index: props.beat_index,
|
|
272
|
+
group_key: "home",
|
|
273
|
+
leaf_key: "home"
|
|
274
|
+
});
|
|
275
|
+
}
|
|
237
276
|
function metadataCoarseProperties(props) {
|
|
238
277
|
const navigation = props.group_key === void 0 || props.leaf_key === void 0 ? {} : {
|
|
239
278
|
group_key: props.group_key,
|
|
@@ -342,6 +381,8 @@ exports.getTelemetryDistinctIdForUrl = getTelemetryDistinctIdForUrl;
|
|
|
342
381
|
exports.maybeShowDisclosure = maybeShowDisclosure;
|
|
343
382
|
exports.trackErrorSignalViewed = trackErrorSignalViewed;
|
|
344
383
|
exports.trackHomeCtaClicked = trackHomeCtaClicked;
|
|
384
|
+
exports.trackHomePromptCopied = trackHomePromptCopied;
|
|
385
|
+
exports.trackHomeStoryBeatSelected = trackHomeStoryBeatSelected;
|
|
345
386
|
exports.trackHomeViewed = trackHomeViewed;
|
|
346
387
|
exports.trackInspectorOpened = trackInspectorOpened;
|
|
347
388
|
exports.trackMemoriesTabClicked = trackMemoriesTabClicked;
|
|
@@ -361,6 +402,7 @@ exports.trackThreadsIntelligenceSignupClicked = trackThreadsIntelligenceSignupCl
|
|
|
361
402
|
exports.trackThreadsLockedViewed = trackThreadsLockedViewed;
|
|
362
403
|
exports.trackThreadsTabClicked = trackThreadsTabClicked;
|
|
363
404
|
exports.trackThreadsTalkToEngineerClicked = trackThreadsTalkToEngineerClicked;
|
|
405
|
+
exports.trackThreadsTryFromHereClicked = trackThreadsTryFromHereClicked;
|
|
364
406
|
exports.trackWhatsNewClicked = trackWhatsNewClicked;
|
|
365
407
|
exports.trackWhatsNewSignalViewed = trackWhatsNewSignalViewed;
|
|
366
408
|
exports.trackWhatsNewViewed = trackWhatsNewViewed;
|
|
@@ -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 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"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AM,kBAAkB;EACjD;;;;;;;AAQH,SAAgB,0BACd,OACM;AACN,OAAM,iBAAiB,sBAAsB;EAC3C,QAAQ,MAAM;EACd,GAAI,MAAM,gBAAgB,SACtB,EAAE,GACF,EAAE,aAAa,MAAM,aAAa;EACtC,GAAG,yBAAyB,MAAM;EACnC,CAAC;;;;;;;AAQJ,SAAgB,2BACd,OACM;AACN,OAAM,iBAAiB,uBAAuB;EAC5C,QAAQ;EACR,aAAa,MAAM;EACnB,GAAG,yBAAyB,MAAM;EACnC,CAAC;;;;;;;;;;;;;;;;;AAkBJ,SAAgB,+BAA8C;AAC5D,KAAID,yCAAqB,CAAE,QAAO;AAClC,QAAOC,oDAAgC;;;;;;;AAQzC,SAAgB,4BAAkC;AAChD,KAAID,yCAAqB,CAAE;AAC3B,qDAAgC;;;;;;;;;;;AAYlC,SAAgB,sBAA4B;AAC1C,KAAIA,yCAAqB,CAAE;AAC3B,KAAIE,qDAAiC,CAAE;AAEvC,SAAQ,KACN,wEAAwE,mBAAmB,cAC5F;AACD,mDAA8B;;AAKhC,eAAe,eACb,KACA,MACA,YACe;AACf,KAAI,OAAO,UAAU,YAAa;CAClC,IAAI;AACJ,KAAI;EACF,MAAM,aAAa,IAAI,iBAAiB;AACxC,cAAY,iBAAiB,WAAW,OAAO,EAAE,iBAAiB;AAClE,QAAM,MAAM,KAAK;GACf,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,6BAA6B;IAC9B;GACD;GACA,QAAQ,WAAW;GAEpB,CAAC;SACI,WAEE;AACR,MAAI,cAAc,OAAW,cAAa,UAAU"}
|
|
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 errorSignalViewed: \"oss.inspector.error_signal_viewed\",\n whatsNewClicked: \"oss.inspector.whats_new_clicked\",\n threadsTabClicked: \"oss.inspector.threads_tab_clicked\",\n threadsTryFromHereClicked: \"oss.inspector.threads_try_from_here_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 // Carries the CLI's own `onboarding_run_id`, which is the whole point: it is\n // the first event that can be joined to `cli.onboarding.completed` on the\n // Intelligence side. `home_cta_clicked` only ever proved someone clicked a\n // link, never that an install followed.\n homePromptCopied: \"oss.inspector.home_prompt_copied\",\n // Which step of the Intelligence story a developer opened by hand. Carries\n // the beat as a property rather than splitting into one event per label,\n // because the labels are expected to change as the story is iterated and a\n // per-label event would retire with them.\n homeStoryBeatSelected: \"oss.inspector.home_story_beat_selected\",\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 outcome?: \"success\" | \"failure\";\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 trackThreadsTryFromHereClicked(\n props: InspectorThreadTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.threadsTryFromHereClicked, {\n ...threadCommonProperties(props),\n ...(props.outcome === undefined ? {} : { outcome: props.outcome }),\n });\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 InspectorHomePromptCopiedTelemetryProps = Readonly<{\n /** The id minted for this session and substituted into the copied prompt. */\n onboarding_run_id: string;\n /** Whether the clipboard write actually landed. */\n outcome: \"copied\" | \"failed\";\n}>;\n\n/**\n * Report a copy of the Intelligence install prompt.\n *\n * `outcome` is reported rather than only emitting on success, because a\n * clipboard that refuses is indistinguishable from a developer who never\n * pressed the button — and the two call for opposite fixes.\n */\nexport function trackHomePromptCopied(\n props: InspectorHomePromptCopiedTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.homePromptCopied, {\n onboarding_run_id: props.onboarding_run_id,\n outcome: props.outcome,\n group_key: \"home\",\n leaf_key: \"home\",\n });\n}\n\nexport type InspectorHomeStoryBeatTelemetryProps = Readonly<{\n /** Stable id of the step, e.g. \"threads\". Survives a label rename. */\n beat: string;\n /** Its position in the rail, so a reorder can be evaluated against clicks. */\n beat_index: number;\n}>;\n\n/**\n * Report a step of the Intelligence story that a developer opened themselves.\n *\n * Only a press reports. The story also advances on its own every few seconds,\n * and reporting that would bury the handful of real interactions under a\n * metronome — one event per idle developer per six seconds, none of it intent.\n */\nexport function trackHomeStoryBeatSelected(\n props: InspectorHomeStoryBeatTelemetryProps,\n): void {\n track(TELEMETRY_EVENTS.homeStoryBeatSelected, {\n beat: props.beat,\n beat_index: props.beat_index,\n group_key: \"home\",\n 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,2BAA2B;CAC3B,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;CAKhB,kBAAkB;CAKlB,uBAAuB;CACvB,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,GAAG;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;AAKhC,eAAe,eACb,KACA,MACA,YACe;AACf,KAAI,OAAO,UAAU,YAAa;CAClC,IAAI;AACJ,KAAI;EACF,MAAM,aAAa,IAAI,iBAAiB;AACxC,cAAY,iBAAiB,WAAW,OAAO,EAAE,iBAAiB;AAClE,QAAM,MAAM,KAAK;GACf,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,6BAA6B;IAC9B;GACD;GACA,QAAQ,WAAW;GAEpB,CAAC;SACI,WAEE;AACR,MAAI,cAAc,OAAW,cAAa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.cts","names":[],"sources":["../../src/lib/telemetry.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"telemetry.d.cts","names":[],"sources":["../../src/lib/telemetry.ts"],"mappings":";;;;;;KA2RY,mBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.mts","names":[],"sources":["../../src/lib/telemetry.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"telemetry.d.mts","names":[],"sources":["../../src/lib/telemetry.ts"],"mappings":";;;;;;KA2RY,mBAAA"}
|