mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
105 lines
4.6 KiB
TypeScript
105 lines
4.6 KiB
TypeScript
import { MakeLogicType, connect, kea, listeners, path, selectors } from 'kea'
|
|
import { combineUrl, router } from 'kea-router'
|
|
|
|
import { urls } from 'scenes/urls'
|
|
|
|
import { sceneLogic } from '~/scenes/sceneLogic'
|
|
|
|
import { mcpAnalyticsOnboardingLogic } from './mcpAnalyticsOnboardingLogic'
|
|
|
|
export type MCPAnalyticsTab =
|
|
| 'activity'
|
|
| 'dashboard'
|
|
| 'sessions'
|
|
| 'tool-quality'
|
|
| 'intent-clustering'
|
|
| 'notifications'
|
|
|
|
export const TAB_DESCRIPTIONS: Record<MCPAnalyticsTab, string> = {
|
|
activity: 'Live feed of tool calls and what agents are trying to do with your MCP server.',
|
|
dashboard: 'Tool call volume, error rates, and latency across your MCP server.',
|
|
sessions: 'Sessions where users interacted with your MCP tools.',
|
|
'tool-quality': 'Understand how reliably your MCP tools support user workflows.',
|
|
'intent-clustering':
|
|
'Cluster semantically similar user intents and see which tools each cluster routes to. Highlights inconsistent routing.',
|
|
notifications:
|
|
'Recurring summaries of what agents are doing, plus instant alerts for the things you need to know about right away.',
|
|
}
|
|
|
|
// Per-tab question seeded into Insights AI so the answer is grounded in what the user is looking at.
|
|
export const TAB_AI_PROMPTS: Record<MCPAnalyticsTab, string> = {
|
|
activity:
|
|
'What have agents done with my MCP server recently? Look at the latest $mcp_tool_call events — tools, intents, failures.',
|
|
dashboard:
|
|
"Summarize how agents are using my MCP server from $mcp_tool_call events — top tools, error rates, and what they're trying to do.",
|
|
sessions:
|
|
'What are agents actually trying to do across my MCP sessions? Group the $mcp_intent values on $mcp_tool_call events into themes.',
|
|
'tool-quality':
|
|
'Which of my MCP tools are least reliable? Break down $mcp_tool_call error rate and p95 $mcp_duration_ms by $mcp_tool_name.',
|
|
'intent-clustering':
|
|
"What's the biggest unmet need agents have that my MCP tools don't cover? Look at $mcp_intent on failing tool calls.",
|
|
notifications:
|
|
'What MCP events should I be notified about? Summarize what agents were trying to do on failing $mcp_tool_call events.',
|
|
}
|
|
|
|
const SCENE_KEY_TO_TAB: Record<string, MCPAnalyticsTab> = {
|
|
mcpAnalyticsActivity: 'activity',
|
|
mcpAnalyticsDashboard: 'dashboard',
|
|
mcpAnalyticsSessions: 'sessions',
|
|
mcpAnalyticsToolQuality: 'tool-quality',
|
|
mcpAnalyticsIntentClustering: 'intent-clustering',
|
|
mcpAnalyticsNotifications: 'notifications',
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface mcpAnalyticsSceneLogicValues {
|
|
sceneKey: string | null // sceneLogic
|
|
activeTab: MCPAnalyticsTab
|
|
}
|
|
|
|
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
|
|
export interface mcpAnalyticsSceneLogicMeta {
|
|
__keaTypeGenInternalSelectorTypes: {
|
|
activeTab: (sceneKey: string | null) => MCPAnalyticsTab
|
|
}
|
|
}
|
|
|
|
export type mcpAnalyticsSceneLogicType = MakeLogicType<
|
|
mcpAnalyticsSceneLogicValues,
|
|
{},
|
|
Record<string, any>,
|
|
mcpAnalyticsSceneLogicMeta
|
|
>
|
|
|
|
export const mcpAnalyticsSceneLogic = kea<mcpAnalyticsSceneLogicType>([
|
|
path(['products', 'mcp_analytics', 'frontend', 'mcpAnalyticsSceneLogic']),
|
|
connect(() => ({
|
|
values: [sceneLogic, ['sceneKey']],
|
|
})),
|
|
selectors({
|
|
activeTab: [
|
|
(s) => [s.sceneKey],
|
|
(sceneKey: string): MCPAnalyticsTab => SCENE_KEY_TO_TAB[sceneKey] ?? 'dashboard',
|
|
],
|
|
}),
|
|
listeners(({ values, cache }) => ({
|
|
// Never-set-up projects stay in-scene: the scene's `emptyState` (SceneExport)
|
|
// renders the setup screen right here until data arrives, so there's no
|
|
// redirect into the app-wide onboarding flow.
|
|
[mcpAnalyticsOnboardingLogic.actionTypes.loadSignalsSuccess]: () => {
|
|
// Volume decides the default landing tab. Only fires when the manifest's
|
|
// bare-URL redirect tagged the navigation with `landing=auto` — a deep link
|
|
// to /dashboard never re-routes, and an explicit tab click is never overridden.
|
|
const { landing, ...restParams } = router.values.searchParams
|
|
if (landing === 'auto' && values.activeTab === 'dashboard' && !cache.landingResolved) {
|
|
cache.landingResolved = true
|
|
const target =
|
|
mcpAnalyticsOnboardingLogic.values.dashboardStage === 'activity'
|
|
? urls.mcpAnalyticsActivity()
|
|
: urls.mcpAnalyticsDashboard()
|
|
router.actions.replace(combineUrl(target, restParams).url)
|
|
}
|
|
},
|
|
})),
|
|
])
|