@agent-native/dispatch 0.2.20 → 0.4.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/actions/archive-workspace-app.d.ts +3 -0
- package/dist/actions/archive-workspace-app.d.ts.map +1 -0
- package/dist/actions/archive-workspace-app.js +15 -0
- package/dist/actions/archive-workspace-app.js.map +1 -0
- package/dist/actions/get-agent-thread-debug.d.ts +3 -0
- package/dist/actions/get-agent-thread-debug.d.ts.map +1 -0
- package/dist/actions/get-agent-thread-debug.js +24 -0
- package/dist/actions/get-agent-thread-debug.js.map +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +8 -0
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/list-agent-thread-sources.d.ts +3 -0
- package/dist/actions/list-agent-thread-sources.d.ts.map +1 -0
- package/dist/actions/list-agent-thread-sources.js +11 -0
- package/dist/actions/list-agent-thread-sources.js.map +1 -0
- package/dist/actions/list-available-workspace-templates.d.ts +3 -0
- package/dist/actions/list-available-workspace-templates.d.ts.map +1 -0
- package/dist/actions/list-available-workspace-templates.js +10 -0
- package/dist/actions/list-available-workspace-templates.js.map +1 -0
- package/dist/actions/navigate.js +1 -1
- package/dist/actions/navigate.js.map +1 -1
- package/dist/actions/remove-pending-workspace-app.d.ts +3 -0
- package/dist/actions/remove-pending-workspace-app.d.ts.map +1 -0
- package/dist/actions/remove-pending-workspace-app.js +15 -0
- package/dist/actions/remove-pending-workspace-app.js.map +1 -0
- package/dist/actions/scaffold-workspace-app.d.ts +3 -0
- package/dist/actions/scaffold-workspace-app.d.ts.map +1 -0
- package/dist/actions/scaffold-workspace-app.js +27 -0
- package/dist/actions/scaffold-workspace-app.js.map +1 -0
- package/dist/actions/search-agent-threads.d.ts +3 -0
- package/dist/actions/search-agent-threads.d.ts.map +1 -0
- package/dist/actions/search-agent-threads.js +25 -0
- package/dist/actions/search-agent-threads.js.map +1 -0
- package/dist/actions/unarchive-workspace-app.d.ts +3 -0
- package/dist/actions/unarchive-workspace-app.d.ts.map +1 -0
- package/dist/actions/unarchive-workspace-app.js +15 -0
- package/dist/actions/unarchive-workspace-app.js.map +1 -0
- package/dist/actions/view-screen.d.ts.map +1 -1
- package/dist/actions/view-screen.js +38 -0
- package/dist/actions/view-screen.js.map +1 -1
- package/dist/components/layout/Layout.d.ts.map +1 -1
- package/dist/components/layout/Layout.js +8 -1
- package/dist/components/layout/Layout.js.map +1 -1
- package/dist/components/ui/command.d.ts +7 -7
- package/dist/hooks/use-navigation-state.js +5 -0
- package/dist/hooks/use-navigation-state.js.map +1 -1
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/pages/thread-debug.d.ts +5 -0
- package/dist/routes/pages/thread-debug.d.ts.map +1 -0
- package/dist/routes/pages/thread-debug.js +160 -0
- package/dist/routes/pages/thread-debug.js.map +1 -0
- package/dist/server/lib/app-creation-store.d.ts +40 -0
- package/dist/server/lib/app-creation-store.d.ts.map +1 -1
- package/dist/server/lib/app-creation-store.js +245 -6
- package/dist/server/lib/app-creation-store.js.map +1 -1
- package/dist/server/lib/thread-debug-store.d.ts +101 -0
- package/dist/server/lib/thread-debug-store.d.ts.map +1 -0
- package/dist/server/lib/thread-debug-store.js +587 -0
- package/dist/server/lib/thread-debug-store.js.map +1 -0
- package/package.json +2 -2
- package/src/actions/archive-workspace-app.ts +16 -0
- package/src/actions/get-agent-thread-debug.ts +25 -0
- package/src/actions/index.ts +12 -0
- package/src/actions/list-agent-thread-sources.ts +12 -0
- package/src/actions/list-available-workspace-templates.ts +11 -0
- package/src/actions/navigate.ts +1 -1
- package/src/actions/remove-pending-workspace-app.ts +16 -0
- package/src/actions/scaffold-workspace-app.ts +34 -0
- package/src/actions/search-agent-threads.ts +30 -0
- package/src/actions/unarchive-workspace-app.ts +16 -0
- package/src/actions/view-screen.ts +41 -0
- package/src/components/layout/Layout.tsx +8 -0
- package/src/hooks/use-navigation-state.ts +4 -0
- package/src/routes/index.ts +1 -0
- package/src/routes/pages/thread-debug.tsx +683 -0
- package/src/server/lib/app-creation-store.ts +312 -15
- package/src/server/lib/thread-debug-store.ts +779 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,WAAW,EACX,UAAU,EACV,eAAe,EACf,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,KAAK,EACL,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AA6BxD,MAAM,iBAAiB,GAAG;IACxB;QACE,EAAE,EAAE,UAAU;QACd,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,SAAS;KACnB;IACD;QACE,EAAE,EAAE,MAAM;QACV,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,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UAAU,EAAE,UAAU,GAAI,GAChC,EAER,KAAC,KAAK,IAAC,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,YAClD,MAAC,YAAY,IACX,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,+DAA+D,aAEzE,KAAC,UAAU,IAAC,SAAS,EAAC,SAAS,2BAAwB,EACvD,KAAC,gBAAgB,IAAC,SAAS,EAAC,SAAS,2CAElB,EACnB,cAAK,SAAS,EAAC,6BAA6B,YAC1C,KAAC,UAAU,IACT,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GACtC,GACE,IACO,GACT,EAMR,KAAC,YAAY,IACX,QAAQ,EAAC,OAAO,EAChB,WAAW,EAAE,KAAK,EAClB,cAAc,EAAC,+DAA+D,EAC9E,WAAW,EAAE,mBAAmB,YAE/B,UAAU,GACE,IACX,GACgB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { useState, type ComponentType, type ReactNode } from \"react\";\nimport { NavLink, useLocation } from \"react-router\";\nimport {\n AgentSidebar,\n FeedbackButton,\n appBasePath,\n appPath,\n useActionQuery,\n} from \"@agent-native/core/client\";\nimport { ExtensionsSidebarSection } from \"@agent-native/core/client/extensions\";\nimport { InvitationBanner, OrgSwitcher } from \"@agent-native/core/client/org\";\nimport {\n IconArrowUpRight,\n IconApps,\n IconChartBar,\n IconBrandTelegram,\n IconKey,\n IconChevronDown,\n IconLayersSubtract,\n IconPlugConnected,\n IconBroadcast,\n IconFingerprint,\n IconHistory,\n IconPuzzle,\n IconShieldCheck,\n IconUsersGroup,\n} from \"@tabler/icons-react\";\nimport { cn } from \"@/lib/utils\";\nimport {\n Sheet,\n SheetContent,\n SheetDescription,\n SheetTitle,\n} from \"@/components/ui/sheet\";\nimport { Header } from \"./Header\";\nimport { HeaderActionsProvider } from \"./HeaderActions\";\n\nexport type DispatchNavSection = \"primary\" | \"operations\";\n\nexport type DispatchNavIcon = ComponentType<{\n size?: number | string;\n className?: string;\n}>;\n\nexport interface DispatchNavItem {\n /** Stable id used for keys and navigation.view. Avoid built-in ids. */\n id: string;\n /** React Router path for the tab, usually backed by an app/routes/*.tsx file. */\n to: string;\n label: string;\n icon?: DispatchNavIcon;\n /** Defaults to \"operations\", which is where local management tools usually fit. */\n section?: DispatchNavSection;\n /** Override active matching for nested or multi-route tools. */\n match?: (pathname: string) => boolean;\n}\n\nexport interface DispatchExtensionConfig {\n /** Extra sidebar tabs supplied by the generated workspace. */\n navItems?: readonly DispatchNavItem[];\n /** Extra React Query keys to invalidate when Dispatch receives DB sync events. */\n queryKeys?: readonly string[];\n}\n\nconst PRIMARY_NAV_ITEMS = [\n {\n id: \"overview\",\n to: \"/overview\",\n label: \"Overview\",\n icon: IconBroadcast,\n section: \"primary\",\n },\n {\n id: \"apps\",\n to: \"/apps\",\n label: \"Apps\",\n icon: IconApps,\n section: \"primary\",\n },\n {\n id: \"metrics\",\n to: \"/metrics\",\n label: \"Metrics\",\n icon: IconChartBar,\n section: \"primary\",\n },\n {\n id: \"vault\",\n to: \"/vault\",\n label: \"Vault\",\n icon: IconKey,\n section: \"primary\",\n },\n {\n id: \"integrations\",\n to: \"/integrations\",\n label: \"Integrations\",\n icon: IconPuzzle,\n section: \"primary\",\n },\n {\n id: \"agents\",\n to: \"/agents\",\n label: \"Agents\",\n icon: IconPlugConnected,\n section: \"primary\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst OPERATIONS_NAV_ITEMS = [\n {\n id: \"workspace\",\n to: \"/workspace\",\n label: \"Resources\",\n icon: IconLayersSubtract,\n section: \"operations\",\n },\n {\n id: \"messaging\",\n to: \"/messaging\",\n label: \"Messaging\",\n icon: IconBrandTelegram,\n section: \"operations\",\n },\n {\n id: \"destinations\",\n to: \"/destinations\",\n label: \"Destinations\",\n icon: IconArrowUpRight,\n section: \"operations\",\n },\n {\n id: \"identities\",\n to: \"/identities\",\n label: \"Identities\",\n icon: IconFingerprint,\n section: \"operations\",\n },\n {\n id: \"approvals\",\n to: \"/approvals\",\n label: \"Approvals\",\n icon: IconShieldCheck,\n section: \"operations\",\n },\n {\n id: \"audit\",\n to: \"/audit\",\n label: \"Audit\",\n icon: IconHistory,\n section: \"operations\",\n },\n {\n id: \"team\",\n to: \"/team\",\n label: \"Team\",\n icon: IconUsersGroup,\n section: \"operations\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst EMPTY_NAV_ITEMS: readonly DispatchNavItem[] = [];\n\nconst SIDEBAR_SUGGESTIONS = [\n \"Create a new app\",\n \"Grant a key to an app\",\n \"Check integration health\",\n];\n\nconst CHROMELESS_PATHS = [\"/approval\"];\n\n// Routes whose page renders its own toolbar (with NotificationsBell + AgentToggleButton).\n// Layout still mounts the sidebar + AgentSidebar, but skips its own Header so\n// there's no double-header.\nfunction pageOwnsToolbar(pathname: string): boolean {\n if (pathname === \"/tools\" || pathname.startsWith(\"/tools/\")) return true;\n if (pathname === \"/extensions\" || pathname.startsWith(\"/extensions/\"))\n return true;\n return false;\n}\n\ninterface WorkspaceInfo {\n name: string | null;\n displayName: string | null;\n appCount: number;\n}\n\nfunction sectionFor(item: DispatchNavItem): DispatchNavSection {\n return item.section ?? \"operations\";\n}\n\nfunction navItemMatchesPath(item: DispatchNavItem, pathname: string): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction navItemsForSection(\n items: readonly DispatchNavItem[],\n section: DispatchNavSection,\n): DispatchNavItem[] {\n return items.filter((item) => sectionFor(item) === section);\n}\n\nfunction localDispatchPath(pathname: string): string {\n const basePath = appBasePath();\n if (!basePath) return pathname;\n if (pathname === basePath) return \"/\";\n if (pathname.startsWith(`${basePath}/`)) {\n return pathname.slice(basePath.length) || \"/\";\n }\n return pathname;\n}\n\nfunction dispatchNavLinkTarget(path: string): string {\n if (typeof window === \"undefined\") return path;\n const basePath = appBasePath();\n if (!basePath) return path;\n const context = (\n window as Window & { __reactRouterContext?: { basename?: string } }\n ).__reactRouterContext;\n return context?.basename === basePath ? path : appPath(path);\n}\n\nexport function NavContent({\n onNavigate,\n extensions,\n}: {\n onNavigate?: () => void;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const { data: workspace } = useActionQuery(\n \"get-workspace-info\",\n {},\n { staleTime: 60_000 },\n );\n const ws = workspace as WorkspaceInfo | undefined;\n const workspaceLabel = ws?.displayName ?? ws?.name ?? null;\n const extensionNavItems = extensions?.navItems ?? EMPTY_NAV_ITEMS;\n const primaryNavItems = [\n ...PRIMARY_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"primary\"),\n ];\n const operationsNavItems = [\n ...OPERATIONS_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"operations\"),\n ];\n const localPathname = localDispatchPath(location.pathname);\n const operationsOpen = operationsNavItems.some((item) =>\n navItemMatchesPath(item, localPathname),\n );\n\n const renderNavItem = (item: DispatchNavItem) => {\n const Icon = item.icon;\n return (\n <li key={item.id}>\n <NavLink\n to={dispatchNavLinkTarget(item.to)}\n onClick={onNavigate}\n className={({ isActive }) => {\n const active = isActive || navItemMatchesPath(item, localPathname);\n return cn(\n \"flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm\",\n active\n ? \"bg-sidebar-accent font-medium text-sidebar-accent-foreground\"\n : \"text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\",\n );\n }}\n >\n {Icon ? (\n <Icon size={16} className=\"shrink-0\" />\n ) : (\n <span className=\"h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n )}\n <span className=\"truncate\">{item.label}</span>\n </NavLink>\n </li>\n );\n };\n\n return (\n <>\n <div className=\"border-b px-4 py-3\">\n <div className=\"flex items-center gap-3\">\n <div className=\"flex h-9 w-9 items-center justify-center rounded-xl border bg-card text-foreground\">\n <img\n src={appPath(\"/agent-native-icon-light.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"block h-4 w-auto shrink-0 dark:hidden\"\n />\n <img\n src={appPath(\"/agent-native-icon-dark.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"hidden h-4 w-auto shrink-0 dark:block\"\n />\n </div>\n <div className=\"min-w-0\">\n <div className=\"truncate text-sm font-semibold text-foreground\">\n {workspaceLabel ?? \"Dispatch\"}\n </div>\n <div className=\"truncate text-xs text-muted-foreground\">\n {workspaceLabel\n ? `Workspace · ${ws?.appCount ?? 0} app${ws?.appCount === 1 ? \"\" : \"s\"}`\n : \"Workspace control plane\"}\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto\">\n <nav className=\"px-2 py-3\">\n <ul className=\"space-y-0.5\">{primaryNavItems.map(renderNavItem)}</ul>\n </nav>\n\n <div className=\"mt-auto shrink-0\">\n <div className=\"border-t px-2 py-2\">\n <details className=\"group\" open={operationsOpen}>\n <summary className=\"flex h-8 cursor-pointer list-none items-center justify-between rounded-md px-2 text-xs font-medium uppercase text-sidebar-foreground/50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&::-webkit-details-marker]:hidden\">\n <span>Operations</span>\n <IconChevronDown\n size={14}\n className=\"transition-transform group-open:rotate-180\"\n />\n </summary>\n <ul className=\"mt-1 space-y-0.5\">\n {operationsNavItems.map(renderNavItem)}\n </ul>\n </details>\n </div>\n\n <div className=\"border-t px-2 py-1\">\n <ExtensionsSidebarSection />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <OrgSwitcher />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <FeedbackButton />\n </div>\n </div>\n </div>\n </>\n );\n}\n\nexport function Layout({\n children,\n extensions,\n}: {\n children: ReactNode;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const [mobileOpen, setMobileOpen] = useState(false);\n\n if (CHROMELESS_PATHS.some((path) => location.pathname === path)) {\n return <>{children}</>;\n }\n\n const showHeader = !pageOwnsToolbar(location.pathname);\n const appContent = (\n <div className=\"flex h-full flex-1 flex-col overflow-hidden\">\n {showHeader ? <Header onOpenMobile={() => setMobileOpen(true)} /> : null}\n <InvitationBanner />\n <main className=\"flex-1 overflow-y-auto\">\n {showHeader ? (\n <div className=\"mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6\">\n {children}\n </div>\n ) : (\n children\n )}\n </main>\n </div>\n );\n\n return (\n <HeaderActionsProvider>\n <div className=\"flex h-screen w-full overflow-hidden bg-background\">\n <aside className=\"hidden lg:flex w-64 shrink-0 flex-col border-r bg-sidebar text-sidebar-foreground\">\n <NavContent extensions={extensions} />\n </aside>\n\n <Sheet open={mobileOpen} onOpenChange={setMobileOpen}>\n <SheetContent\n side=\"left\"\n className=\"w-72 p-0 bg-sidebar text-sidebar-foreground [&>button]:hidden\"\n >\n <SheetTitle className=\"sr-only\">Navigation</SheetTitle>\n <SheetDescription className=\"sr-only\">\n Workspace navigation links\n </SheetDescription>\n <div className=\"flex h-full w-full flex-col\">\n <NavContent\n extensions={extensions}\n onNavigate={() => setMobileOpen(false)}\n />\n </div>\n </SheetContent>\n </Sheet>\n\n {/*\n * Always mount AgentSidebar so home composer's sendToAgentChat\n * fallback can pop it via agent-panel:open.\n */}\n <AgentSidebar\n position=\"right\"\n defaultOpen={false}\n emptyStateText=\"Create apps, grant keys, and route work across the workspace.\"\n suggestions={SIDEBAR_SUGGESTIONS}\n >\n {appContent}\n </AgentSidebar>\n </div>\n </HeaderActionsProvider>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../src/components/layout/Layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,OAAO,EACP,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,w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AAU,EAAE,UAAU,EACtB,UAAU,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,GACtC,GACE,IACO,GACT,EAMR,KAAC,YAAY,IACX,QAAQ,EAAC,OAAO,EAChB,WAAW,EAAE,KAAK,EAClB,cAAc,EAAC,+DAA+D,EAC9E,WAAW,EAAE,mBAAmB,YAE/B,UAAU,GACE,IACX,GACgB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { useState, type ComponentType, type ReactNode } from \"react\";\nimport { NavLink, useLocation } from \"react-router\";\nimport {\n AgentSidebar,\n FeedbackButton,\n appBasePath,\n appPath,\n useActionQuery,\n} from \"@agent-native/core/client\";\nimport { ExtensionsSidebarSection } from \"@agent-native/core/client/extensions\";\nimport { InvitationBanner, OrgSwitcher } from \"@agent-native/core/client/org\";\nimport {\n IconArrowUpRight,\n IconApps,\n IconChartBar,\n IconBrandTelegram,\n IconKey,\n IconChevronDown,\n IconLayersSubtract,\n IconMessages,\n IconPlugConnected,\n IconBroadcast,\n IconFingerprint,\n IconHistory,\n IconPuzzle,\n IconShieldCheck,\n IconUsersGroup,\n} from \"@tabler/icons-react\";\nimport { cn } from \"@/lib/utils\";\nimport {\n Sheet,\n SheetContent,\n SheetDescription,\n SheetTitle,\n} from \"@/components/ui/sheet\";\nimport { Header } from \"./Header\";\nimport { HeaderActionsProvider } from \"./HeaderActions\";\n\nexport type DispatchNavSection = \"primary\" | \"operations\";\n\nexport type DispatchNavIcon = ComponentType<{\n size?: number | string;\n className?: string;\n}>;\n\nexport interface DispatchNavItem {\n /** Stable id used for keys and navigation.view. Avoid built-in ids. */\n id: string;\n /** React Router path for the tab, usually backed by an app/routes/*.tsx file. */\n to: string;\n label: string;\n icon?: DispatchNavIcon;\n /** Defaults to \"operations\", which is where local management tools usually fit. */\n section?: DispatchNavSection;\n /** Override active matching for nested or multi-route tools. */\n match?: (pathname: string) => boolean;\n}\n\nexport interface DispatchExtensionConfig {\n /** Extra sidebar tabs supplied by the generated workspace. */\n navItems?: readonly DispatchNavItem[];\n /** Extra React Query keys to invalidate when Dispatch receives DB sync events. */\n queryKeys?: readonly string[];\n}\n\nconst PRIMARY_NAV_ITEMS = [\n {\n id: \"overview\",\n to: \"/overview\",\n label: \"Overview\",\n icon: IconBroadcast,\n section: \"primary\",\n },\n {\n id: \"apps\",\n to: \"/apps\",\n label: \"Apps\",\n icon: IconApps,\n section: \"primary\",\n },\n {\n id: \"metrics\",\n to: \"/metrics\",\n label: \"Metrics\",\n icon: IconChartBar,\n section: \"primary\",\n },\n {\n id: \"vault\",\n to: \"/vault\",\n label: \"Vault\",\n icon: IconKey,\n section: \"primary\",\n },\n {\n id: \"integrations\",\n to: \"/integrations\",\n label: \"Integrations\",\n icon: IconPuzzle,\n section: \"primary\",\n },\n {\n id: \"agents\",\n to: \"/agents\",\n label: \"Agents\",\n icon: IconPlugConnected,\n section: \"primary\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst OPERATIONS_NAV_ITEMS = [\n {\n id: \"workspace\",\n to: \"/workspace\",\n label: \"Resources\",\n icon: IconLayersSubtract,\n section: \"operations\",\n },\n {\n id: \"messaging\",\n to: \"/messaging\",\n label: \"Messaging\",\n icon: IconBrandTelegram,\n section: \"operations\",\n },\n {\n id: \"destinations\",\n to: \"/destinations\",\n label: \"Destinations\",\n icon: IconArrowUpRight,\n section: \"operations\",\n },\n {\n id: \"identities\",\n to: \"/identities\",\n label: \"Identities\",\n icon: IconFingerprint,\n section: \"operations\",\n },\n {\n id: \"approvals\",\n to: \"/approvals\",\n label: \"Approvals\",\n icon: IconShieldCheck,\n section: \"operations\",\n },\n {\n id: \"audit\",\n to: \"/audit\",\n label: \"Audit\",\n icon: IconHistory,\n section: \"operations\",\n },\n {\n id: \"thread-debug\",\n to: \"/thread-debug\",\n label: \"Thread Debug\",\n icon: IconMessages,\n section: \"operations\",\n },\n {\n id: \"team\",\n to: \"/team\",\n label: \"Team\",\n icon: IconUsersGroup,\n section: \"operations\",\n },\n] as const satisfies readonly DispatchNavItem[];\n\nconst EMPTY_NAV_ITEMS: readonly DispatchNavItem[] = [];\n\nconst SIDEBAR_SUGGESTIONS = [\n \"Create a new app\",\n \"Grant a key to an app\",\n \"Check integration health\",\n];\n\nconst CHROMELESS_PATHS = [\"/approval\"];\n\n// Routes whose page renders its own toolbar (with NotificationsBell + AgentToggleButton).\n// Layout still mounts the sidebar + AgentSidebar, but skips its own Header so\n// there's no double-header.\nfunction pageOwnsToolbar(pathname: string): boolean {\n if (pathname === \"/tools\" || pathname.startsWith(\"/tools/\")) return true;\n if (pathname === \"/extensions\" || pathname.startsWith(\"/extensions/\"))\n return true;\n return false;\n}\n\ninterface WorkspaceInfo {\n name: string | null;\n displayName: string | null;\n appCount: number;\n}\n\nfunction sectionFor(item: DispatchNavItem): DispatchNavSection {\n return item.section ?? \"operations\";\n}\n\nfunction navItemMatchesPath(item: DispatchNavItem, pathname: string): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction navItemsForSection(\n items: readonly DispatchNavItem[],\n section: DispatchNavSection,\n): DispatchNavItem[] {\n return items.filter((item) => sectionFor(item) === section);\n}\n\nfunction localDispatchPath(pathname: string): string {\n const basePath = appBasePath();\n if (!basePath) return pathname;\n if (pathname === basePath) return \"/\";\n if (pathname.startsWith(`${basePath}/`)) {\n return pathname.slice(basePath.length) || \"/\";\n }\n return pathname;\n}\n\nfunction dispatchNavLinkTarget(path: string): string {\n if (typeof window === \"undefined\") return path;\n const basePath = appBasePath();\n if (!basePath) return path;\n const context = (\n window as Window & { __reactRouterContext?: { basename?: string } }\n ).__reactRouterContext;\n return context?.basename === basePath ? path : appPath(path);\n}\n\nexport function NavContent({\n onNavigate,\n extensions,\n}: {\n onNavigate?: () => void;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const { data: workspace } = useActionQuery(\n \"get-workspace-info\",\n {},\n { staleTime: 60_000 },\n );\n const ws = workspace as WorkspaceInfo | undefined;\n const workspaceLabel = ws?.displayName ?? ws?.name ?? null;\n const extensionNavItems = extensions?.navItems ?? EMPTY_NAV_ITEMS;\n const primaryNavItems = [\n ...PRIMARY_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"primary\"),\n ];\n const operationsNavItems = [\n ...OPERATIONS_NAV_ITEMS,\n ...navItemsForSection(extensionNavItems, \"operations\"),\n ];\n const localPathname = localDispatchPath(location.pathname);\n const operationsOpen = operationsNavItems.some((item) =>\n navItemMatchesPath(item, localPathname),\n );\n\n const renderNavItem = (item: DispatchNavItem) => {\n const Icon = item.icon;\n return (\n <li key={item.id}>\n <NavLink\n to={dispatchNavLinkTarget(item.to)}\n onClick={onNavigate}\n className={({ isActive }) => {\n const active = isActive || navItemMatchesPath(item, localPathname);\n return cn(\n \"flex h-8 w-full items-center gap-2 rounded-md px-2 text-sm\",\n active\n ? \"bg-sidebar-accent font-medium text-sidebar-accent-foreground\"\n : \"text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\",\n );\n }}\n >\n {Icon ? (\n <Icon size={16} className=\"shrink-0\" />\n ) : (\n <span className=\"h-4 w-4 shrink-0\" aria-hidden=\"true\" />\n )}\n <span className=\"truncate\">{item.label}</span>\n </NavLink>\n </li>\n );\n };\n\n return (\n <>\n <div className=\"border-b px-4 py-3\">\n <div className=\"flex items-center gap-3\">\n <div className=\"flex h-9 w-9 items-center justify-center rounded-xl border bg-card text-foreground\">\n <img\n src={appPath(\"/agent-native-icon-light.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"block h-4 w-auto shrink-0 dark:hidden\"\n />\n <img\n src={appPath(\"/agent-native-icon-dark.svg\")}\n alt=\"\"\n aria-hidden=\"true\"\n className=\"hidden h-4 w-auto shrink-0 dark:block\"\n />\n </div>\n <div className=\"min-w-0\">\n <div className=\"truncate text-sm font-semibold text-foreground\">\n {workspaceLabel ?? \"Dispatch\"}\n </div>\n <div className=\"truncate text-xs text-muted-foreground\">\n {workspaceLabel\n ? `Workspace · ${ws?.appCount ?? 0} app${ws?.appCount === 1 ? \"\" : \"s\"}`\n : \"Workspace control plane\"}\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"flex min-h-0 flex-1 flex-col overflow-y-auto\">\n <nav className=\"px-2 py-3\">\n <ul className=\"space-y-0.5\">{primaryNavItems.map(renderNavItem)}</ul>\n </nav>\n\n <div className=\"mt-auto shrink-0\">\n <div className=\"border-t px-2 py-2\">\n <details className=\"group\" open={operationsOpen}>\n <summary className=\"flex h-8 cursor-pointer list-none items-center justify-between rounded-md px-2 text-xs font-medium uppercase text-sidebar-foreground/50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground [&::-webkit-details-marker]:hidden\">\n <span>Operations</span>\n <IconChevronDown\n size={14}\n className=\"transition-transform group-open:rotate-180\"\n />\n </summary>\n <ul className=\"mt-1 space-y-0.5\">\n {operationsNavItems.map(renderNavItem)}\n </ul>\n </details>\n </div>\n\n <div className=\"border-t px-2 py-1\">\n <ExtensionsSidebarSection />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <OrgSwitcher />\n </div>\n\n <div className=\"border-t px-3 py-2\">\n <FeedbackButton />\n </div>\n </div>\n </div>\n </>\n );\n}\n\nexport function Layout({\n children,\n extensions,\n}: {\n children: ReactNode;\n extensions?: DispatchExtensionConfig;\n}) {\n const location = useLocation();\n const [mobileOpen, setMobileOpen] = useState(false);\n\n if (CHROMELESS_PATHS.some((path) => location.pathname === path)) {\n return <>{children}</>;\n }\n\n const showHeader = !pageOwnsToolbar(location.pathname);\n const appContent = (\n <div className=\"flex h-full flex-1 flex-col overflow-hidden\">\n {showHeader ? <Header onOpenMobile={() => setMobileOpen(true)} /> : null}\n <InvitationBanner />\n <main className=\"flex-1 overflow-y-auto\">\n {showHeader ? (\n <div className=\"mx-auto max-w-7xl space-y-5 px-4 py-6 sm:px-6\">\n {children}\n </div>\n ) : (\n children\n )}\n </main>\n </div>\n );\n\n return (\n <HeaderActionsProvider>\n <div className=\"flex h-screen w-full overflow-hidden bg-background\">\n <aside className=\"hidden lg:flex w-64 shrink-0 flex-col border-r bg-sidebar text-sidebar-foreground\">\n <NavContent extensions={extensions} />\n </aside>\n\n <Sheet open={mobileOpen} onOpenChange={setMobileOpen}>\n <SheetContent\n side=\"left\"\n className=\"w-72 p-0 bg-sidebar text-sidebar-foreground [&>button]:hidden\"\n >\n <SheetTitle className=\"sr-only\">Navigation</SheetTitle>\n <SheetDescription className=\"sr-only\">\n Workspace navigation links\n </SheetDescription>\n <div className=\"flex h-full w-full flex-col\">\n <NavContent\n extensions={extensions}\n onNavigate={() => setMobileOpen(false)}\n />\n </div>\n </SheetContent>\n </Sheet>\n\n {/*\n * Always mount AgentSidebar so home composer's sendToAgentChat\n * fallback can pop it via agent-panel:open.\n */}\n <AgentSidebar\n position=\"right\"\n defaultOpen={false}\n emptyStateText=\"Create apps, grant keys, and route work across the workspace.\"\n suggestions={SIDEBAR_SUGGESTIONS}\n >\n {appContent}\n </AgentSidebar>\n </div>\n </HeaderActionsProvider>\n );\n}\n"]}
|
|
@@ -6,7 +6,7 @@ declare const Command: React.ForwardRefExoticComponent<Omit<{
|
|
|
6
6
|
ref?: React.Ref<HTMLDivElement>;
|
|
7
7
|
} & {
|
|
8
8
|
asChild?: boolean;
|
|
9
|
-
}, "
|
|
9
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
10
10
|
label?: string;
|
|
11
11
|
shouldFilter?: boolean;
|
|
12
12
|
filter?: (value: string, search: string, keywords?: string[]) => number;
|
|
@@ -24,7 +24,7 @@ declare const CommandInput: React.ForwardRefExoticComponent<Omit<Omit<Pick<Pick<
|
|
|
24
24
|
ref?: React.Ref<HTMLInputElement>;
|
|
25
25
|
} & {
|
|
26
26
|
asChild?: boolean;
|
|
27
|
-
}, "
|
|
27
|
+
}, "key" | "asChild" | keyof React.InputHTMLAttributes<HTMLInputElement>>, "value" | "type" | "onChange"> & {
|
|
28
28
|
value?: string;
|
|
29
29
|
onValueChange?: (search: string) => void;
|
|
30
30
|
} & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -34,7 +34,7 @@ declare const CommandList: React.ForwardRefExoticComponent<Omit<{
|
|
|
34
34
|
ref?: React.Ref<HTMLDivElement>;
|
|
35
35
|
} & {
|
|
36
36
|
asChild?: boolean;
|
|
37
|
-
}, "
|
|
37
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
38
38
|
label?: string;
|
|
39
39
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
40
40
|
declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -43,14 +43,14 @@ declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<{
|
|
|
43
43
|
ref?: React.Ref<HTMLDivElement>;
|
|
44
44
|
} & {
|
|
45
45
|
asChild?: boolean;
|
|
46
|
-
}, "
|
|
46
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
47
47
|
declare const CommandGroup: React.ForwardRefExoticComponent<Omit<{
|
|
48
48
|
children?: React.ReactNode;
|
|
49
49
|
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
50
50
|
ref?: React.Ref<HTMLDivElement>;
|
|
51
51
|
} & {
|
|
52
52
|
asChild?: boolean;
|
|
53
|
-
}, "
|
|
53
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>>, "value" | "heading"> & {
|
|
54
54
|
heading?: React.ReactNode;
|
|
55
55
|
value?: string;
|
|
56
56
|
forceMount?: boolean;
|
|
@@ -59,7 +59,7 @@ declare const CommandSeparator: React.ForwardRefExoticComponent<Omit<Pick<Pick<R
|
|
|
59
59
|
ref?: React.Ref<HTMLDivElement>;
|
|
60
60
|
} & {
|
|
61
61
|
asChild?: boolean;
|
|
62
|
-
}, "
|
|
62
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
63
63
|
alwaysRender?: boolean;
|
|
64
64
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
65
65
|
declare const CommandItem: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -68,7 +68,7 @@ declare const CommandItem: React.ForwardRefExoticComponent<Omit<{
|
|
|
68
68
|
ref?: React.Ref<HTMLDivElement>;
|
|
69
69
|
} & {
|
|
70
70
|
asChild?: boolean;
|
|
71
|
-
}, "
|
|
71
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>>, "value" | "disabled" | "onSelect"> & {
|
|
72
72
|
disabled?: boolean;
|
|
73
73
|
onSelect?: (value: string) => void;
|
|
74
74
|
value?: string;
|
|
@@ -111,6 +111,8 @@ function resolveView(pathname, extensions) {
|
|
|
111
111
|
return "approvals";
|
|
112
112
|
if (pathname.startsWith("/audit"))
|
|
113
113
|
return "audit";
|
|
114
|
+
if (pathname.startsWith("/thread-debug"))
|
|
115
|
+
return "thread-debug";
|
|
114
116
|
if (pathname.startsWith("/team"))
|
|
115
117
|
return "team";
|
|
116
118
|
return "overview";
|
|
@@ -148,6 +150,9 @@ function resolvePath(view, extensions) {
|
|
|
148
150
|
return "/approvals";
|
|
149
151
|
case "audit":
|
|
150
152
|
return "/audit";
|
|
153
|
+
case "thread-debug":
|
|
154
|
+
case "threads":
|
|
155
|
+
return "/thread-debug";
|
|
151
156
|
case "team":
|
|
152
157
|
return "/team";
|
|
153
158
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-navigation-state.js","sourceRoot":"","sources":["../../src/hooks/use-navigation-state.ts"],"names":[],"mappings":"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ACpB,KAAK,OAAO,CAAC;QACb,KAAK,SAAS;YACZ,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc;YACjB,OAAO,eAAe,CAAC;QACzB,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,YAAY,CAAC;QACtB,KAAK,QAAQ;YACX,OAAO,SAAS,CAAC;QACnB,KAAK,WAAW;YACd,OAAO,YAAY,CAAC;QACtB,KAAK,cAAc,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,eAAe,CAAC;QACzB,KAAK,YAAY;YACf,OAAO,aAAa,CAAC;QACvB,KAAK,WAAW;YACd,OAAO,YAAY,CAAC;QACtB,KAAK,OAAO;YACV,OAAO,QAAQ,CAAC;QAClB,KAAK,MAAM;YACT,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC;AACH,CAAC","sourcesContent":["import { useEffect } from \"react\";\nimport { useLocation, useNavigate } from \"react-router\";\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n agentNativePath,\n appBasePath,\n appPath,\n} from \"@agent-native/core/client\";\nimport type {\n DispatchExtensionConfig,\n DispatchNavItem,\n} from \"../components/index.js\";\n\nexport interface NavigationState {\n view: string;\n path?: string;\n}\n\nexport function useNavigationState(extensions?: DispatchExtensionConfig) {\n const location = useLocation();\n const navigate = useNavigate();\n const qc = useQueryClient();\n\n // Sync current route to application state\n useEffect(() => {\n const localPathname = routerPath(location.pathname);\n const state: NavigationState = {\n view: resolveView(localPathname, extensions),\n path: appPath(localPathname),\n };\n\n fetch(agentNativePath(\"/_agent-native/application-state/navigation\"), {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n }).catch(() => {});\n }, [extensions, location.pathname]);\n\n // Listen for navigate commands from agent\n const { data: navCommand } = useQuery({\n queryKey: [\"navigate-command\"],\n queryFn: async () => {\n const res = await fetch(\n agentNativePath(\"/_agent-native/application-state/navigate\"),\n );\n if (!res.ok) return null;\n const data = await res.json();\n if (data) {\n // Return with a timestamp to ensure uniqueness\n return { ...data, _ts: Date.now() };\n }\n return null;\n },\n refetchInterval: 2_000,\n structuralSharing: false,\n });\n\n useEffect(() => {\n if (!navCommand) return;\n // Delete the one-shot command AFTER reading it\n fetch(agentNativePath(\"/_agent-native/application-state/navigate\"), {\n method: \"DELETE\",\n headers: { \"X-Agent-Native-CSRF\": \"1\" },\n }).catch(() => {});\n const cmd = navCommand as NavigationState;\n\n // Navigate to a specific path or resolve view name to path\n const path = routerPath(\n cmd.path || resolvePath(cmd.view, extensions) || \"/overview\",\n );\n navigate(path);\n qc.setQueryData([\"navigate-command\"], null);\n }, [extensions, navCommand, navigate, qc]);\n}\n\nfunction routerPath(path: string): string {\n const basePath = appBasePath();\n if (!basePath) return path;\n if (path === basePath) return \"/\";\n if (path.startsWith(`${basePath}/`)) {\n return path.slice(basePath.length) || \"/\";\n }\n return path;\n}\n\nfunction extensionItemMatchesPath(\n item: DispatchNavItem,\n pathname: string,\n): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction resolveExtensionView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n return extensions?.navItems?.find((item) =>\n extensionItemMatchesPath(item, pathname),\n )?.id;\n}\n\nfunction resolveExtensionPath(\n view: string | undefined,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n if (!view) return undefined;\n return extensions?.navItems?.find((item) => item.id === view)?.to;\n}\n\nfunction resolveView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string {\n const extensionView = resolveExtensionView(pathname, extensions);\n if (extensionView) return extensionView;\n if (pathname.startsWith(\"/apps\")) return \"apps\";\n if (pathname.startsWith(\"/metrics\")) return \"metrics\";\n if (pathname.startsWith(\"/new-app\")) return \"new-app\";\n if (pathname.startsWith(\"/vault\")) return \"vault\";\n if (pathname.startsWith(\"/integrations\")) return \"integrations\";\n if (pathname.startsWith(\"/workspace\")) return \"workspace\";\n if (pathname.startsWith(\"/agents\")) return \"agents\";\n if (pathname.startsWith(\"/messaging\")) return \"messaging\";\n if (pathname.startsWith(\"/destinations\")) return \"destinations\";\n if (pathname.startsWith(\"/identities\")) return \"identities\";\n if (pathname.startsWith(\"/approvals\")) return \"approvals\";\n if (pathname.startsWith(\"/audit\")) return \"audit\";\n if (pathname.startsWith(\"/team\")) return \"team\";\n return \"overview\";\n}\n\nfunction resolvePath(\n view?: string,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n switch (view) {\n case \"overview\":\n return \"/overview\";\n case \"apps\":\n return \"/apps\";\n case \"metrics\":\n case \"usage\":\n return \"/metrics\";\n case \"new-app\":\n case \"create-app\":\n return \"/new-app\";\n case \"vault\":\n case \"secrets\":\n return \"/vault\";\n case \"integrations\":\n return \"/integrations\";\n case \"workspace\":\n case \"resources\":\n return \"/workspace\";\n case \"agents\":\n return \"/agents\";\n case \"messaging\":\n return \"/messaging\";\n case \"destinations\":\n case \"routes\":\n return \"/destinations\";\n case \"identities\":\n return \"/identities\";\n case \"approvals\":\n return \"/approvals\";\n case \"audit\":\n return \"/audit\";\n case \"team\":\n return \"/team\";\n default:\n return resolveExtensionPath(view, extensions);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-navigation-state.js","sourceRoot":"","sources":["../../src/hooks/use-navigation-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EACL,eAAe,EACf,WAAW,EACX,OAAO,GACR,MAAM,2BAA2B,CAAC;AAWnC,MAAM,UAAU,kBAAkB,CAAC,UAAoC;IACrE,MAAM,QAAQ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WAAW;YACd,OAAO,YAAY,CAAC;QACtB,KAAK,cAAc,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,eAAe,CAAC;QACzB,KAAK,YAAY;YACf,OAAO,aAAa,CAAC;QACvB,KAAK,WAAW;YACd,OAAO,YAAY,CAAC;QACtB,KAAK,OAAO;YACV,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,eAAe,CAAC;QACzB,KAAK,MAAM;YACT,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC;AACH,CAAC","sourcesContent":["import { useEffect } from \"react\";\nimport { useLocation, useNavigate } from \"react-router\";\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport {\n agentNativePath,\n appBasePath,\n appPath,\n} from \"@agent-native/core/client\";\nimport type {\n DispatchExtensionConfig,\n DispatchNavItem,\n} from \"../components/index.js\";\n\nexport interface NavigationState {\n view: string;\n path?: string;\n}\n\nexport function useNavigationState(extensions?: DispatchExtensionConfig) {\n const location = useLocation();\n const navigate = useNavigate();\n const qc = useQueryClient();\n\n // Sync current route to application state\n useEffect(() => {\n const localPathname = routerPath(location.pathname);\n const state: NavigationState = {\n view: resolveView(localPathname, extensions),\n path: appPath(localPathname),\n };\n\n fetch(agentNativePath(\"/_agent-native/application-state/navigation\"), {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(state),\n }).catch(() => {});\n }, [extensions, location.pathname]);\n\n // Listen for navigate commands from agent\n const { data: navCommand } = useQuery({\n queryKey: [\"navigate-command\"],\n queryFn: async () => {\n const res = await fetch(\n agentNativePath(\"/_agent-native/application-state/navigate\"),\n );\n if (!res.ok) return null;\n const data = await res.json();\n if (data) {\n // Return with a timestamp to ensure uniqueness\n return { ...data, _ts: Date.now() };\n }\n return null;\n },\n refetchInterval: 2_000,\n structuralSharing: false,\n });\n\n useEffect(() => {\n if (!navCommand) return;\n // Delete the one-shot command AFTER reading it\n fetch(agentNativePath(\"/_agent-native/application-state/navigate\"), {\n method: \"DELETE\",\n headers: { \"X-Agent-Native-CSRF\": \"1\" },\n }).catch(() => {});\n const cmd = navCommand as NavigationState;\n\n // Navigate to a specific path or resolve view name to path\n const path = routerPath(\n cmd.path || resolvePath(cmd.view, extensions) || \"/overview\",\n );\n navigate(path);\n qc.setQueryData([\"navigate-command\"], null);\n }, [extensions, navCommand, navigate, qc]);\n}\n\nfunction routerPath(path: string): string {\n const basePath = appBasePath();\n if (!basePath) return path;\n if (path === basePath) return \"/\";\n if (path.startsWith(`${basePath}/`)) {\n return path.slice(basePath.length) || \"/\";\n }\n return path;\n}\n\nfunction extensionItemMatchesPath(\n item: DispatchNavItem,\n pathname: string,\n): boolean {\n if (item.match) {\n try {\n if (item.match(pathname)) return true;\n } catch {\n return false;\n }\n }\n return pathname === item.to || pathname.startsWith(`${item.to}/`);\n}\n\nfunction resolveExtensionView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n return extensions?.navItems?.find((item) =>\n extensionItemMatchesPath(item, pathname),\n )?.id;\n}\n\nfunction resolveExtensionPath(\n view: string | undefined,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n if (!view) return undefined;\n return extensions?.navItems?.find((item) => item.id === view)?.to;\n}\n\nfunction resolveView(\n pathname: string,\n extensions?: DispatchExtensionConfig,\n): string {\n const extensionView = resolveExtensionView(pathname, extensions);\n if (extensionView) return extensionView;\n if (pathname.startsWith(\"/apps\")) return \"apps\";\n if (pathname.startsWith(\"/metrics\")) return \"metrics\";\n if (pathname.startsWith(\"/new-app\")) return \"new-app\";\n if (pathname.startsWith(\"/vault\")) return \"vault\";\n if (pathname.startsWith(\"/integrations\")) return \"integrations\";\n if (pathname.startsWith(\"/workspace\")) return \"workspace\";\n if (pathname.startsWith(\"/agents\")) return \"agents\";\n if (pathname.startsWith(\"/messaging\")) return \"messaging\";\n if (pathname.startsWith(\"/destinations\")) return \"destinations\";\n if (pathname.startsWith(\"/identities\")) return \"identities\";\n if (pathname.startsWith(\"/approvals\")) return \"approvals\";\n if (pathname.startsWith(\"/audit\")) return \"audit\";\n if (pathname.startsWith(\"/thread-debug\")) return \"thread-debug\";\n if (pathname.startsWith(\"/team\")) return \"team\";\n return \"overview\";\n}\n\nfunction resolvePath(\n view?: string,\n extensions?: DispatchExtensionConfig,\n): string | undefined {\n switch (view) {\n case \"overview\":\n return \"/overview\";\n case \"apps\":\n return \"/apps\";\n case \"metrics\":\n case \"usage\":\n return \"/metrics\";\n case \"new-app\":\n case \"create-app\":\n return \"/new-app\";\n case \"vault\":\n case \"secrets\":\n return \"/vault\";\n case \"integrations\":\n return \"/integrations\";\n case \"workspace\":\n case \"resources\":\n return \"/workspace\";\n case \"agents\":\n return \"/agents\";\n case \"messaging\":\n return \"/messaging\";\n case \"destinations\":\n case \"routes\":\n return \"/destinations\";\n case \"identities\":\n return \"/identities\";\n case \"approvals\":\n return \"/approvals\";\n case \"audit\":\n return \"/audit\";\n case \"thread-debug\":\n case \"threads\":\n return \"/thread-debug\";\n case \"team\":\n return \"/team\";\n default:\n return resolveExtensionPath(view, extensions);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc,EAAE,WAqB5B,CAAC"}
|
package/dist/routes/index.js
CHANGED
|
@@ -45,6 +45,7 @@ export const dispatchRoutes = [
|
|
|
45
45
|
route("approval", "./pages/approval.js"),
|
|
46
46
|
route("approvals", "./pages/approvals.js"),
|
|
47
47
|
route("audit", "./pages/audit.js"),
|
|
48
|
+
route("thread-debug", "./pages/thread-debug.js"),
|
|
48
49
|
route("team", "./pages/team.js"),
|
|
49
50
|
route("extensions", "./pages/extensions._index.js"),
|
|
50
51
|
route("extensions/:id", "./pages/extensions.$id.js"),
|
package/dist/routes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAgB;IACzC,KAAK,CAAC,mBAAmB,CAAC;IAC1B,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,aAAa,EAAE,wBAAwB,CAAC;IAC9C,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAC5C,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,YAAY,EAAE,8BAA8B,CAAC;IACnD,KAAK,CAAC,gBAAgB,EAAE,2BAA2B,CAAC;CACrD,CAAC","sourcesContent":["import { type RouteConfig, route, index } from \"@react-router/dev/routes\";\n\n/**\n * Dispatch's routes as a programmatic `RouteConfig[]`. Splat into the\n * consumer's `app/routes.ts`:\n *\n * ```ts\n * import { type RouteConfig } from \"@react-router/dev/routes\";\n * import { dispatchRoutes } from \"@agent-native/dispatch/routes\";\n *\n * export default [\n * ...localRoutes, // consumer's own routes win on collision\n * ...dispatchRoutes, // dispatch fills in everything else\n * ] satisfies RouteConfig;\n * ```\n *\n * Route precedence: React Router 7 matches in declaration order, so\n * placing `dispatchRoutes` LAST means consumer-defined routes with the\n * same path take precedence. To override a single dispatch route, define\n * it in your local routes; to keep it, omit it.\n *\n * The `file` paths below resolve relative to this file at runtime — they\n * point into `packages/dispatch/dist/routes/pages/*.js` after build.\n *\n * Naming maps the original flatRoutes file conventions:\n * `_index.tsx` → `index(...)`\n * `<name>.tsx` → `route(\"<name>\", ...)`\n * `<a>.$<param>.tsx` → `route(\"<a>/:<param>\", ...)`\n * `<a>._index.tsx` → flattened as `route(\"<a>\", ...)` (workspace\n * versions are bare and don't wrap a parent layout)\n */\nexport const dispatchRoutes: RouteConfig = [\n index(\"./pages/_index.js\"),\n route(\"overview\", \"./pages/overview.js\"),\n route(\"metrics\", \"./pages/metrics.js\"),\n route(\"apps\", \"./pages/apps.js\"),\n route(\"apps/:appId\", \"./pages/apps.$appId.js\"),\n route(\"new-app\", \"./pages/new-app.js\"),\n route(\"vault\", \"./pages/vault.js\"),\n route(\"integrations\", \"./pages/integrations.js\"),\n route(\"agents\", \"./pages/agents.js\"),\n route(\"workspace\", \"./pages/workspace.js\"),\n route(\"messaging\", \"./pages/messaging.js\"),\n route(\"destinations\", \"./pages/destinations.js\"),\n route(\"identities\", \"./pages/identities.js\"),\n route(\"approval\", \"./pages/approval.js\"),\n route(\"approvals\", \"./pages/approvals.js\"),\n route(\"audit\", \"./pages/audit.js\"),\n route(\"team\", \"./pages/team.js\"),\n route(\"extensions\", \"./pages/extensions._index.js\"),\n route(\"extensions/:id\", \"./pages/extensions.$id.js\"),\n];\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAgB;IACzC,KAAK,CAAC,mBAAmB,CAAC;IAC1B,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,aAAa,EAAE,wBAAwB,CAAC;IAC9C,KAAK,CAAC,SAAS,EAAE,oBAAoB,CAAC;IACtC,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAC5C,KAAK,CAAC,UAAU,EAAE,qBAAqB,CAAC;IACxC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC;IAChD,KAAK,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAChC,KAAK,CAAC,YAAY,EAAE,8BAA8B,CAAC;IACnD,KAAK,CAAC,gBAAgB,EAAE,2BAA2B,CAAC;CACrD,CAAC","sourcesContent":["import { type RouteConfig, route, index } from \"@react-router/dev/routes\";\n\n/**\n * Dispatch's routes as a programmatic `RouteConfig[]`. Splat into the\n * consumer's `app/routes.ts`:\n *\n * ```ts\n * import { type RouteConfig } from \"@react-router/dev/routes\";\n * import { dispatchRoutes } from \"@agent-native/dispatch/routes\";\n *\n * export default [\n * ...localRoutes, // consumer's own routes win on collision\n * ...dispatchRoutes, // dispatch fills in everything else\n * ] satisfies RouteConfig;\n * ```\n *\n * Route precedence: React Router 7 matches in declaration order, so\n * placing `dispatchRoutes` LAST means consumer-defined routes with the\n * same path take precedence. To override a single dispatch route, define\n * it in your local routes; to keep it, omit it.\n *\n * The `file` paths below resolve relative to this file at runtime — they\n * point into `packages/dispatch/dist/routes/pages/*.js` after build.\n *\n * Naming maps the original flatRoutes file conventions:\n * `_index.tsx` → `index(...)`\n * `<name>.tsx` → `route(\"<name>\", ...)`\n * `<a>.$<param>.tsx` → `route(\"<a>/:<param>\", ...)`\n * `<a>._index.tsx` → flattened as `route(\"<a>\", ...)` (workspace\n * versions are bare and don't wrap a parent layout)\n */\nexport const dispatchRoutes: RouteConfig = [\n index(\"./pages/_index.js\"),\n route(\"overview\", \"./pages/overview.js\"),\n route(\"metrics\", \"./pages/metrics.js\"),\n route(\"apps\", \"./pages/apps.js\"),\n route(\"apps/:appId\", \"./pages/apps.$appId.js\"),\n route(\"new-app\", \"./pages/new-app.js\"),\n route(\"vault\", \"./pages/vault.js\"),\n route(\"integrations\", \"./pages/integrations.js\"),\n route(\"agents\", \"./pages/agents.js\"),\n route(\"workspace\", \"./pages/workspace.js\"),\n route(\"messaging\", \"./pages/messaging.js\"),\n route(\"destinations\", \"./pages/destinations.js\"),\n route(\"identities\", \"./pages/identities.js\"),\n route(\"approval\", \"./pages/approval.js\"),\n route(\"approvals\", \"./pages/approvals.js\"),\n route(\"audit\", \"./pages/audit.js\"),\n route(\"thread-debug\", \"./pages/thread-debug.js\"),\n route(\"team\", \"./pages/team.js\"),\n route(\"extensions\", \"./pages/extensions._index.js\"),\n route(\"extensions/:id\", \"./pages/extensions.$id.js\"),\n];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-debug.d.ts","sourceRoot":"","sources":["../../../src/routes/pages/thread-debug.tsx"],"names":[],"mappings":"AAwBA,wBAAgB,IAAI;;IAEnB;AAgYD,MAAM,CAAC,OAAO,UAAU,gBAAgB,4CAgRvC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { agentNativePath, useActionQuery } from "@agent-native/core/client";
|
|
4
|
+
import { IconDatabase, IconFileSearch, IconRefresh, IconSearch, } from "@tabler/icons-react";
|
|
5
|
+
import { DispatchShell } from "../../components/dispatch-shell.js";
|
|
6
|
+
import { Alert, AlertDescription, AlertTitle } from "../../components/ui/alert.js";
|
|
7
|
+
import { Badge } from "../../components/ui/badge.js";
|
|
8
|
+
import { Button } from "../../components/ui/button.js";
|
|
9
|
+
import { Input } from "../../components/ui/input.js";
|
|
10
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../../components/ui/select.js";
|
|
11
|
+
import { Skeleton } from "../../components/ui/skeleton.js";
|
|
12
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../../components/ui/tabs.js";
|
|
13
|
+
import { cn } from "../../lib/utils.js";
|
|
14
|
+
export function meta() {
|
|
15
|
+
return [{ title: "Thread Debug — Dispatch" }];
|
|
16
|
+
}
|
|
17
|
+
function formatDate(value) {
|
|
18
|
+
if (value == null || value === "")
|
|
19
|
+
return "n/a";
|
|
20
|
+
const numeric = Number(value);
|
|
21
|
+
const date = Number.isFinite(numeric) ? new Date(numeric) : new Date(value);
|
|
22
|
+
if (Number.isNaN(date.getTime()))
|
|
23
|
+
return "n/a";
|
|
24
|
+
return date.toLocaleString();
|
|
25
|
+
}
|
|
26
|
+
function json(value) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.stringify(value, null, 2);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return String(value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function eventLabel(event) {
|
|
35
|
+
if (!event || typeof event !== "object")
|
|
36
|
+
return "event";
|
|
37
|
+
if (event.type === "tool_start")
|
|
38
|
+
return `tool_start · ${event.tool}`;
|
|
39
|
+
if (event.type === "tool_done")
|
|
40
|
+
return `tool_done · ${event.tool}`;
|
|
41
|
+
if (event.type === "text")
|
|
42
|
+
return "text";
|
|
43
|
+
if (event.type === "error")
|
|
44
|
+
return `error · ${event.errorCode ?? "agent"}`;
|
|
45
|
+
return String(event.type ?? "event");
|
|
46
|
+
}
|
|
47
|
+
function messageTitle(message) {
|
|
48
|
+
const role = message.role || "unknown";
|
|
49
|
+
return `${role.charAt(0).toUpperCase()}${role.slice(1)} ${message.index + 1}`;
|
|
50
|
+
}
|
|
51
|
+
function toolParts(message) {
|
|
52
|
+
return message.contentParts.filter((part) => part?.type === "tool-call");
|
|
53
|
+
}
|
|
54
|
+
function RawBlock({ value, className, }) {
|
|
55
|
+
return (_jsx("pre", { className: cn("max-h-[520px] overflow-auto rounded-lg border bg-muted/30 p-3 text-xs leading-relaxed text-foreground", "whitespace-pre-wrap break-words", className), children: typeof value === "string" ? value : json(value) }));
|
|
56
|
+
}
|
|
57
|
+
function SourceBadge({ source }) {
|
|
58
|
+
return (_jsx(Badge, { variant: source.current ? "default" : "secondary", children: source.current ? "current" : source.kind }));
|
|
59
|
+
}
|
|
60
|
+
function ResultCard({ result, selected, onSelect, }) {
|
|
61
|
+
return (_jsxs("button", { type: "button", onClick: onSelect, className: cn("w-full rounded-lg border px-3 py-3 text-left transition-colors", selected
|
|
62
|
+
? "border-foreground bg-muted"
|
|
63
|
+
: "bg-card hover:border-foreground/30 hover:bg-muted/40"), children: [_jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-sm font-medium text-foreground", children: result.title || result.preview || result.id }), _jsx("div", { className: "mt-1 truncate font-mono text-[11px] text-muted-foreground", children: result.id })] }), _jsx(Badge, { variant: "outline", className: "shrink-0", children: result.messageCount })] }), _jsx("div", { className: "mt-2 line-clamp-3 text-xs leading-relaxed text-muted-foreground", children: result.snippet || result.preview || "No preview" }), _jsxs("div", { className: "mt-2 flex items-center justify-between gap-3 text-[11px] text-muted-foreground", children: [_jsx("span", { className: "truncate", children: result.ownerEmail }), _jsx("span", { className: "shrink-0", children: formatDate(result.updatedAt) })] })] }));
|
|
64
|
+
}
|
|
65
|
+
function MessageBlock({ message }) {
|
|
66
|
+
const tools = toolParts(message);
|
|
67
|
+
return (_jsxs("div", { className: "rounded-lg border bg-card", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Badge, { variant: message.role === "assistant" ? "default" : "secondary", children: message.role }), _jsx("span", { className: "truncate text-sm font-medium text-foreground", children: messageTitle(message) })] }), _jsxs("div", { className: "flex items-center gap-2 text-[11px] text-muted-foreground", children: [message.attachments.length > 0 ? (_jsxs(Badge, { variant: "outline", children: [message.attachments.length, " files"] })) : null, _jsx("span", { children: formatDate(message.createdAt) })] })] }), _jsxs("div", { className: "space-y-3 px-3 py-3", children: [message.text ? (_jsx("div", { className: "whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground", children: message.text })) : (_jsx("div", { className: "text-sm text-muted-foreground", children: "No text content" })), tools.length > 0 ? (_jsx("div", { className: "space-y-2", children: tools.map((tool, index) => (_jsxs("details", { className: "rounded-md border bg-muted/30 px-3 py-2", children: [_jsx("summary", { className: "cursor-pointer text-xs font-medium text-foreground", children: tool.toolName ?? tool.name ?? "tool-call" }), _jsx(RawBlock, { value: tool, className: "mt-2 max-h-72" })] }, `${message.id ?? message.index}-tool-${index}`))) })) : null] })] }));
|
|
68
|
+
}
|
|
69
|
+
function ThreadDetail({ detail }) {
|
|
70
|
+
const rawBundle = useMemo(() => ({
|
|
71
|
+
thread: detail.thread,
|
|
72
|
+
debug: detail.debug,
|
|
73
|
+
debugRuns: detail.debugRuns,
|
|
74
|
+
queuedMessages: detail.queuedMessages,
|
|
75
|
+
threadData: detail.threadData,
|
|
76
|
+
runs: detail.runs,
|
|
77
|
+
traces: detail.traces,
|
|
78
|
+
feedback: detail.feedback,
|
|
79
|
+
satisfaction: detail.satisfaction,
|
|
80
|
+
evals: detail.evals,
|
|
81
|
+
checkpoints: detail.checkpoints,
|
|
82
|
+
}), [detail]);
|
|
83
|
+
return (_jsxs("div", { className: "rounded-lg border bg-card", children: [_jsxs("div", { className: "border-b px-4 py-3", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-base font-semibold text-foreground", children: detail.thread.title || detail.thread.preview || detail.thread.id }), _jsx("div", { className: "mt-1 truncate font-mono text-xs text-muted-foreground", children: detail.thread.id })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Badge, { variant: "secondary", children: [detail.messages.length, " messages"] }), _jsxs(Badge, { variant: "secondary", children: [detail.runs.length, " runs"] }), _jsx(Badge, { variant: "outline", children: detail.source.label })] })] }), _jsxs("div", { className: "mt-3 grid gap-2 text-xs text-muted-foreground sm:grid-cols-3", children: [_jsxs("div", { className: "truncate", children: ["Owner: ", detail.thread.ownerEmail] }), _jsxs("div", { children: ["Created: ", formatDate(detail.thread.createdAt)] }), _jsxs("div", { children: ["Updated: ", formatDate(detail.thread.updatedAt)] })] })] }), _jsxs(Tabs, { defaultValue: "transcript", className: "p-4", children: [_jsxs(TabsList, { children: [_jsx(TabsTrigger, { value: "transcript", children: "Transcript" }), _jsx(TabsTrigger, { value: "runs", children: "Runs" }), _jsx(TabsTrigger, { value: "internals", children: "Internals" }), _jsx(TabsTrigger, { value: "raw", children: "Raw" })] }), _jsx(TabsContent, { value: "transcript", className: "mt-4 space-y-3", children: detail.messages.length > 0 ? (detail.messages.map((message) => (_jsx(MessageBlock, { message: message }, message.id ?? `message-${message.index}`)))) : (_jsx("div", { className: "rounded-lg border border-dashed px-4 py-8 text-center text-sm text-muted-foreground", children: "No persisted messages." })) }), _jsx(TabsContent, { value: "runs", className: "mt-4 space-y-3", children: detail.runs.length > 0 ? (detail.runs.map((run) => (_jsxs("details", { className: "rounded-lg border bg-card", children: [_jsx("summary", { className: "cursor-pointer px-4 py-3", children: _jsxs("div", { className: "inline-flex flex-wrap items-center gap-2", children: [_jsx(Badge, { variant: "outline", children: run.status }), _jsx("span", { className: "font-mono text-xs text-foreground", children: run.id }), _jsx("span", { className: "text-xs text-muted-foreground", children: formatDate(run.startedAt) })] }) }), _jsxs("div", { className: "space-y-2 border-t px-4 py-3", children: [run.events.map((event) => (_jsxs("details", { className: "rounded-md border bg-muted/30 px-3 py-2", children: [_jsxs("summary", { className: "cursor-pointer text-xs font-medium text-foreground", children: ["#", event.seq, " ", eventLabel(event.event)] }), _jsx(RawBlock, { value: event.event, className: "mt-2 max-h-72" })] }, `${run.id}-${event.seq}`))), run.events.length === 0 ? (_jsx("div", { className: "text-sm text-muted-foreground", children: "No retained run events." })) : null] })] }, run.id)))) : (_jsx("div", { className: "rounded-lg border border-dashed px-4 py-8 text-center text-sm text-muted-foreground", children: "No retained runs." })) }), _jsx(TabsContent, { value: "internals", className: "mt-4 space-y-4", children: _jsxs("div", { className: "grid gap-4 lg:grid-cols-2", children: [_jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Debug Runs" }), _jsx(RawBlock, { value: detail.debugRuns.length > 0
|
|
84
|
+
? detail.debugRuns
|
|
85
|
+
: (detail.debug ?? {}) })] }), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Trace Summaries" }), _jsx(RawBlock, { value: detail.traces.summaries })] }), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Trace Spans" }), _jsx(RawBlock, { value: detail.traces.spans })] }), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Feedback And Evals" }), _jsx(RawBlock, { value: {
|
|
86
|
+
feedback: detail.feedback,
|
|
87
|
+
satisfaction: detail.satisfaction,
|
|
88
|
+
evals: detail.evals,
|
|
89
|
+
checkpoints: detail.checkpoints,
|
|
90
|
+
} })] })] }) }), _jsxs(TabsContent, { value: "raw", className: "mt-4 space-y-4", children: [_jsx(RawBlock, { value: rawBundle }), _jsx(RawBlock, { value: detail.rawThreadData })] })] })] }));
|
|
91
|
+
}
|
|
92
|
+
export default function ThreadDebugRoute() {
|
|
93
|
+
const [sourceId, setSourceId] = useState("current");
|
|
94
|
+
const [query, setQuery] = useState("");
|
|
95
|
+
const [ownerEmail, setOwnerEmail] = useState("");
|
|
96
|
+
const [threadId, setThreadId] = useState("");
|
|
97
|
+
const [submittedSearch, setSubmittedSearch] = useState({
|
|
98
|
+
sourceId: "current",
|
|
99
|
+
query: "",
|
|
100
|
+
ownerEmail: "",
|
|
101
|
+
});
|
|
102
|
+
const [selected, setSelected] = useState(null);
|
|
103
|
+
const { data: sourcesData, isLoading: sourcesLoading } = useActionQuery("list-agent-thread-sources", {});
|
|
104
|
+
const sources = sourcesData?.sources ?? [];
|
|
105
|
+
const searchParams = useMemo(() => ({
|
|
106
|
+
sourceId: submittedSearch.sourceId,
|
|
107
|
+
query: submittedSearch.query || undefined,
|
|
108
|
+
ownerEmail: submittedSearch.ownerEmail || undefined,
|
|
109
|
+
limit: 25,
|
|
110
|
+
}), [submittedSearch]);
|
|
111
|
+
const { data: searchData, isLoading: searchLoading, error: searchError, refetch: refetchSearch, } = useActionQuery("search-agent-threads", searchParams);
|
|
112
|
+
const detailParams = useMemo(() => ({
|
|
113
|
+
sourceId: selected?.sourceId ?? "current",
|
|
114
|
+
threadId: selected?.threadId ?? "",
|
|
115
|
+
ownerEmail: selected?.ownerEmail,
|
|
116
|
+
maxRuns: 20,
|
|
117
|
+
maxEvents: 800,
|
|
118
|
+
maxTraceSpans: 600,
|
|
119
|
+
}), [selected]);
|
|
120
|
+
const { data: detail, isLoading: detailLoading, error: detailError, } = useActionQuery("get-agent-thread-debug", detailParams, {
|
|
121
|
+
enabled: Boolean(selected?.threadId),
|
|
122
|
+
});
|
|
123
|
+
const selectedSource = sources.find((source) => source.id === sourceId);
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
fetch(agentNativePath("/_agent-native/application-state/navigation"), {
|
|
126
|
+
method: "PUT",
|
|
127
|
+
keepalive: true,
|
|
128
|
+
headers: { "Content-Type": "application/json" },
|
|
129
|
+
body: JSON.stringify({
|
|
130
|
+
view: "thread-debug",
|
|
131
|
+
path: typeof window === "undefined"
|
|
132
|
+
? "/thread-debug"
|
|
133
|
+
: window.location.pathname,
|
|
134
|
+
sourceId,
|
|
135
|
+
query,
|
|
136
|
+
ownerEmail: ownerEmail.trim() || undefined,
|
|
137
|
+
threadId: selected?.threadId ?? (threadId.trim() || undefined),
|
|
138
|
+
}),
|
|
139
|
+
}).catch(() => { });
|
|
140
|
+
}, [ownerEmail, query, selected?.threadId, sourceId, threadId]);
|
|
141
|
+
return (_jsx(DispatchShell, { title: "Thread Debug", description: "Inspect persisted agent chat threads, run events, and AI internals.", children: _jsxs("div", { className: "space-y-4", children: [_jsxs("section", { className: "rounded-lg border bg-card p-4", children: [_jsxs("div", { className: "grid gap-3 lg:grid-cols-[220px_1fr_260px_auto]", children: [_jsxs(Select, { value: sourceId, onValueChange: setSourceId, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Source" }) }), _jsxs(SelectContent, { children: [sources.map((source) => (_jsx(SelectItem, { value: source.id, children: source.label }, source.id))), sources.length === 0 ? (_jsx(SelectItem, { value: "current", children: "Current Dispatch DB" })) : null] })] }), _jsx(Input, { value: query, onChange: (event) => setQuery(event.target.value), placeholder: "Search title, preview, messages, tools" }), _jsx(Input, { value: ownerEmail, onChange: (event) => setOwnerEmail(event.target.value), placeholder: "Owner email" }), _jsxs(Button, { type: "button", onClick: () => setSubmittedSearch({
|
|
142
|
+
sourceId,
|
|
143
|
+
query: query.trim(),
|
|
144
|
+
ownerEmail: ownerEmail.trim(),
|
|
145
|
+
}), children: [_jsx(IconSearch, { size: 16 }), "Search"] })] }), _jsxs("div", { className: "mt-3 grid gap-3 lg:grid-cols-[1fr_auto]", children: [_jsx(Input, { value: threadId, onChange: (event) => setThreadId(event.target.value), placeholder: "Paste thread ID", className: "font-mono" }), _jsxs(Button, { type: "button", variant: "outline", onClick: () => {
|
|
146
|
+
const trimmed = threadId.trim();
|
|
147
|
+
if (!trimmed)
|
|
148
|
+
return;
|
|
149
|
+
setSelected({
|
|
150
|
+
sourceId,
|
|
151
|
+
threadId: trimmed,
|
|
152
|
+
ownerEmail: ownerEmail.trim() || undefined,
|
|
153
|
+
});
|
|
154
|
+
}, children: [_jsx(IconFileSearch, { size: 16 }), "Inspect"] })] }), _jsxs("div", { className: "mt-3 flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [sourcesLoading ? _jsx(Skeleton, { className: "h-5 w-32" }) : null, selectedSource ? _jsx(SourceBadge, { source: selectedSource }) : null, selectedSource?.databaseUrlEnv ? (_jsx(Badge, { variant: "outline", className: "font-mono", children: selectedSource.databaseUrlEnv })) : null, sourcesData?.access ? (_jsxs("span", { children: [sourcesData.access.viewerEmail, " \u00B7", " ", sourcesData.access.canInspectAll ? "admin scope" : "own scope"] })) : null] })] }), searchError ? (_jsxs(Alert, { variant: "destructive", children: [_jsx(AlertTitle, { children: "Search failed" }), _jsx(AlertDescription, { children: String(searchError.message) })] })) : null, _jsxs("div", { className: "grid gap-4 xl:grid-cols-[380px_1fr]", children: [_jsxs("section", { className: "min-h-[520px] rounded-lg border bg-card", children: [_jsxs("div", { className: "flex items-center justify-between border-b px-4 py-3", children: [_jsxs("div", { children: [_jsx("div", { className: "text-sm font-semibold text-foreground", children: "Threads" }), _jsxs("div", { className: "text-xs text-muted-foreground", children: [searchData?.count ?? 0, " results \u00B7", " ", searchData?.access?.scope ?? "current scope"] })] }), _jsx(Button, { type: "button", variant: "ghost", size: "icon", onClick: () => refetchSearch(), "aria-label": "Refresh threads", children: _jsx(IconRefresh, { size: 16 }) })] }), _jsxs("div", { className: "max-h-[760px] space-y-2 overflow-auto p-3", children: [searchLoading ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "h-28 w-full rounded-lg" }), _jsx(Skeleton, { className: "h-28 w-full rounded-lg" }), _jsx(Skeleton, { className: "h-28 w-full rounded-lg" })] })) : null, !searchLoading && (searchData?.threads?.length ?? 0) === 0 ? (_jsxs("div", { className: "flex min-h-64 flex-col items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground", children: [_jsx(IconDatabase, { className: "mb-2 h-5 w-5" }), "No threads found."] })) : null, searchData?.threads?.map((result) => (_jsx(ResultCard, { result: result, selected: selected?.threadId === result.id, onSelect: () => setSelected({
|
|
155
|
+
sourceId: submittedSearch.sourceId,
|
|
156
|
+
threadId: result.id,
|
|
157
|
+
ownerEmail: submittedSearch.ownerEmail || undefined,
|
|
158
|
+
}) }, result.id)))] })] }), _jsxs("section", { className: "min-w-0", children: [detailError ? (_jsxs(Alert, { variant: "destructive", children: [_jsx(AlertTitle, { children: "Thread lookup failed" }), _jsx(AlertDescription, { children: String(detailError.message) })] })) : null, detailLoading ? (_jsxs("div", { className: "rounded-lg border bg-card p-4", children: [_jsx(Skeleton, { className: "h-6 w-72" }), _jsx(Skeleton, { className: "mt-3 h-4 w-96" }), _jsx(Skeleton, { className: "mt-6 h-[520px] w-full" })] })) : detail ? (_jsx(ThreadDetail, { detail: detail })) : (_jsxs("div", { className: "flex min-h-[520px] flex-col items-center justify-center rounded-lg border border-dashed bg-card px-4 text-center text-sm text-muted-foreground", children: [_jsx(IconFileSearch, { className: "mb-2 h-5 w-5" }), "Select or inspect a thread."] }))] })] })] }) }));
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=thread-debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-debug.js","sourceRoot":"","sources":["../../../src/routes/pages/thread-debug.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC,CAAC;AAChD,CAAC;AAqED,SAAS,UAAU,CAAC,KAAyC;IAC3D,IAAI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C,uBAAuB,GAAG,IAC1C,CACP,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CACX,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,CACjC,CAAC,CAAC,CAAC,CACF,eAAK,SAAS,EAAC,gJAAgJ,aAC7J,KAAC,cAAc,IAAC,SAAS,EAAC,cAAc,GAAG,mCAEvC,CACP,IACO,IACN,IACF,GACQ,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import { useEffect, useMemo, useState } from \"react\";\nimport { agentNativePath, useActionQuery } from \"@agent-native/core/client\";\nimport {\n IconDatabase,\n IconFileSearch,\n IconRefresh,\n IconSearch,\n} from \"@tabler/icons-react\";\nimport { DispatchShell } from \"@/components/dispatch-shell\";\nimport { Alert, AlertDescription, AlertTitle } from \"@/components/ui/alert\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/ui/select\";\nimport { Skeleton } from \"@/components/ui/skeleton\";\nimport { Tabs, TabsContent, TabsList, TabsTrigger } from \"@/components/ui/tabs\";\nimport { cn } from \"@/lib/utils\";\n\nexport function meta() {\n return [{ title: \"Thread Debug — Dispatch\" }];\n}\n\ninterface ThreadDebugSource {\n id: string;\n label: string;\n kind: \"current\" | \"env\" | \"configured\";\n current: boolean;\n connected: boolean;\n databaseUrlEnv: string | null;\n databaseAuthTokenEnv: string | null;\n canInspectAll: boolean;\n}\n\ninterface ThreadSearchResult {\n id: string;\n ownerEmail: string;\n title: string;\n preview: string;\n messageCount: number;\n createdAt: number;\n updatedAt: number;\n snippet: string;\n}\n\ninterface ThreadMessage {\n index: number;\n id: string | null;\n role: string;\n createdAt: string | number | null;\n status: unknown;\n text: string;\n contentParts: any[];\n attachments: any[];\n metadata: unknown;\n}\n\ninterface ThreadRun {\n id: string;\n status: string;\n abortReason: string | null;\n startedAt: number;\n completedAt: number | null;\n heartbeatAt: number | null;\n events: Array<{ seq: number; event: any; rawEventData: string }>;\n}\n\ninterface ThreadDebugResponse {\n source: {\n id: string;\n label: string;\n kind: string;\n databaseUrlEnv: string | null;\n };\n access: { viewerEmail: string; scope: string; canInspectAll: boolean };\n thread: ThreadSearchResult;\n messages: ThreadMessage[];\n debug: any;\n debugRuns: any[];\n queuedMessages: any[];\n threadData: any;\n rawThreadData: string;\n runs: ThreadRun[];\n traces: { summaries: any[]; spans: any[] };\n feedback: any[];\n satisfaction: any[];\n evals: any[];\n checkpoints: any[];\n}\n\nfunction formatDate(value: number | string | null | undefined): string {\n if (value == null || value === \"\") return \"n/a\";\n const numeric = Number(value);\n const date = Number.isFinite(numeric) ? new Date(numeric) : new Date(value);\n if (Number.isNaN(date.getTime())) return \"n/a\";\n return date.toLocaleString();\n}\n\nfunction json(value: unknown): string {\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n\nfunction eventLabel(event: any): string {\n if (!event || typeof event !== \"object\") return \"event\";\n if (event.type === \"tool_start\") return `tool_start · ${event.tool}`;\n if (event.type === \"tool_done\") return `tool_done · ${event.tool}`;\n if (event.type === \"text\") return \"text\";\n if (event.type === \"error\") return `error · ${event.errorCode ?? \"agent\"}`;\n return String(event.type ?? \"event\");\n}\n\nfunction messageTitle(message: ThreadMessage): string {\n const role = message.role || \"unknown\";\n return `${role.charAt(0).toUpperCase()}${role.slice(1)} ${message.index + 1}`;\n}\n\nfunction toolParts(message: ThreadMessage): any[] {\n return message.contentParts.filter((part) => part?.type === \"tool-call\");\n}\n\nfunction RawBlock({\n value,\n className,\n}: {\n value: unknown;\n className?: string;\n}) {\n return (\n <pre\n className={cn(\n \"max-h-[520px] overflow-auto rounded-lg border bg-muted/30 p-3 text-xs leading-relaxed text-foreground\",\n \"whitespace-pre-wrap break-words\",\n className,\n )}\n >\n {typeof value === \"string\" ? value : json(value)}\n </pre>\n );\n}\n\nfunction SourceBadge({ source }: { source: ThreadDebugSource }) {\n return (\n <Badge variant={source.current ? \"default\" : \"secondary\"}>\n {source.current ? \"current\" : source.kind}\n </Badge>\n );\n}\n\nfunction ResultCard({\n result,\n selected,\n onSelect,\n}: {\n result: ThreadSearchResult;\n selected: boolean;\n onSelect: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n className={cn(\n \"w-full rounded-lg border px-3 py-3 text-left transition-colors\",\n selected\n ? \"border-foreground bg-muted\"\n : \"bg-card hover:border-foreground/30 hover:bg-muted/40\",\n )}\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <div className=\"truncate text-sm font-medium text-foreground\">\n {result.title || result.preview || result.id}\n </div>\n <div className=\"mt-1 truncate font-mono text-[11px] text-muted-foreground\">\n {result.id}\n </div>\n </div>\n <Badge variant=\"outline\" className=\"shrink-0\">\n {result.messageCount}\n </Badge>\n </div>\n <div className=\"mt-2 line-clamp-3 text-xs leading-relaxed text-muted-foreground\">\n {result.snippet || result.preview || \"No preview\"}\n </div>\n <div className=\"mt-2 flex items-center justify-between gap-3 text-[11px] text-muted-foreground\">\n <span className=\"truncate\">{result.ownerEmail}</span>\n <span className=\"shrink-0\">{formatDate(result.updatedAt)}</span>\n </div>\n </button>\n );\n}\n\nfunction MessageBlock({ message }: { message: ThreadMessage }) {\n const tools = toolParts(message);\n return (\n <div className=\"rounded-lg border bg-card\">\n <div className=\"flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <Badge\n variant={message.role === \"assistant\" ? \"default\" : \"secondary\"}\n >\n {message.role}\n </Badge>\n <span className=\"truncate text-sm font-medium text-foreground\">\n {messageTitle(message)}\n </span>\n </div>\n <div className=\"flex items-center gap-2 text-[11px] text-muted-foreground\">\n {message.attachments.length > 0 ? (\n <Badge variant=\"outline\">{message.attachments.length} files</Badge>\n ) : null}\n <span>{formatDate(message.createdAt)}</span>\n </div>\n </div>\n <div className=\"space-y-3 px-3 py-3\">\n {message.text ? (\n <div className=\"whitespace-pre-wrap break-words text-sm leading-relaxed text-foreground\">\n {message.text}\n </div>\n ) : (\n <div className=\"text-sm text-muted-foreground\">No text content</div>\n )}\n {tools.length > 0 ? (\n <div className=\"space-y-2\">\n {tools.map((tool, index) => (\n <details\n key={`${message.id ?? message.index}-tool-${index}`}\n className=\"rounded-md border bg-muted/30 px-3 py-2\"\n >\n <summary className=\"cursor-pointer text-xs font-medium text-foreground\">\n {tool.toolName ?? tool.name ?? \"tool-call\"}\n </summary>\n <RawBlock value={tool} className=\"mt-2 max-h-72\" />\n </details>\n ))}\n </div>\n ) : null}\n </div>\n </div>\n );\n}\n\nfunction ThreadDetail({ detail }: { detail: ThreadDebugResponse }) {\n const rawBundle = useMemo(\n () => ({\n thread: detail.thread,\n debug: detail.debug,\n debugRuns: detail.debugRuns,\n queuedMessages: detail.queuedMessages,\n threadData: detail.threadData,\n runs: detail.runs,\n traces: detail.traces,\n feedback: detail.feedback,\n satisfaction: detail.satisfaction,\n evals: detail.evals,\n checkpoints: detail.checkpoints,\n }),\n [detail],\n );\n\n return (\n <div className=\"rounded-lg border bg-card\">\n <div className=\"border-b px-4 py-3\">\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <div className=\"truncate text-base font-semibold text-foreground\">\n {detail.thread.title || detail.thread.preview || detail.thread.id}\n </div>\n <div className=\"mt-1 truncate font-mono text-xs text-muted-foreground\">\n {detail.thread.id}\n </div>\n </div>\n <div className=\"flex flex-wrap items-center gap-2\">\n <Badge variant=\"secondary\">{detail.messages.length} messages</Badge>\n <Badge variant=\"secondary\">{detail.runs.length} runs</Badge>\n <Badge variant=\"outline\">{detail.source.label}</Badge>\n </div>\n </div>\n <div className=\"mt-3 grid gap-2 text-xs text-muted-foreground sm:grid-cols-3\">\n <div className=\"truncate\">Owner: {detail.thread.ownerEmail}</div>\n <div>Created: {formatDate(detail.thread.createdAt)}</div>\n <div>Updated: {formatDate(detail.thread.updatedAt)}</div>\n </div>\n </div>\n\n <Tabs defaultValue=\"transcript\" className=\"p-4\">\n <TabsList>\n <TabsTrigger value=\"transcript\">Transcript</TabsTrigger>\n <TabsTrigger value=\"runs\">Runs</TabsTrigger>\n <TabsTrigger value=\"internals\">Internals</TabsTrigger>\n <TabsTrigger value=\"raw\">Raw</TabsTrigger>\n </TabsList>\n\n <TabsContent value=\"transcript\" className=\"mt-4 space-y-3\">\n {detail.messages.length > 0 ? (\n detail.messages.map((message) => (\n <MessageBlock\n key={message.id ?? `message-${message.index}`}\n message={message}\n />\n ))\n ) : (\n <div className=\"rounded-lg border border-dashed px-4 py-8 text-center text-sm text-muted-foreground\">\n No persisted messages.\n </div>\n )}\n </TabsContent>\n\n <TabsContent value=\"runs\" className=\"mt-4 space-y-3\">\n {detail.runs.length > 0 ? (\n detail.runs.map((run) => (\n <details key={run.id} className=\"rounded-lg border bg-card\">\n <summary className=\"cursor-pointer px-4 py-3\">\n <div className=\"inline-flex flex-wrap items-center gap-2\">\n <Badge variant=\"outline\">{run.status}</Badge>\n <span className=\"font-mono text-xs text-foreground\">\n {run.id}\n </span>\n <span className=\"text-xs text-muted-foreground\">\n {formatDate(run.startedAt)}\n </span>\n </div>\n </summary>\n <div className=\"space-y-2 border-t px-4 py-3\">\n {run.events.map((event) => (\n <details\n key={`${run.id}-${event.seq}`}\n className=\"rounded-md border bg-muted/30 px-3 py-2\"\n >\n <summary className=\"cursor-pointer text-xs font-medium text-foreground\">\n #{event.seq} {eventLabel(event.event)}\n </summary>\n <RawBlock value={event.event} className=\"mt-2 max-h-72\" />\n </details>\n ))}\n {run.events.length === 0 ? (\n <div className=\"text-sm text-muted-foreground\">\n No retained run events.\n </div>\n ) : null}\n </div>\n </details>\n ))\n ) : (\n <div className=\"rounded-lg border border-dashed px-4 py-8 text-center text-sm text-muted-foreground\">\n No retained runs.\n </div>\n )}\n </TabsContent>\n\n <TabsContent value=\"internals\" className=\"mt-4 space-y-4\">\n <div className=\"grid gap-4 lg:grid-cols-2\">\n <div>\n <div className=\"mb-2 text-sm font-medium text-foreground\">\n Debug Runs\n </div>\n <RawBlock\n value={\n detail.debugRuns.length > 0\n ? detail.debugRuns\n : (detail.debug ?? {})\n }\n />\n </div>\n <div>\n <div className=\"mb-2 text-sm font-medium text-foreground\">\n Trace Summaries\n </div>\n <RawBlock value={detail.traces.summaries} />\n </div>\n <div>\n <div className=\"mb-2 text-sm font-medium text-foreground\">\n Trace Spans\n </div>\n <RawBlock value={detail.traces.spans} />\n </div>\n <div>\n <div className=\"mb-2 text-sm font-medium text-foreground\">\n Feedback And Evals\n </div>\n <RawBlock\n value={{\n feedback: detail.feedback,\n satisfaction: detail.satisfaction,\n evals: detail.evals,\n checkpoints: detail.checkpoints,\n }}\n />\n </div>\n </div>\n </TabsContent>\n\n <TabsContent value=\"raw\" className=\"mt-4 space-y-4\">\n <RawBlock value={rawBundle} />\n <RawBlock value={detail.rawThreadData} />\n </TabsContent>\n </Tabs>\n </div>\n );\n}\n\nexport default function ThreadDebugRoute() {\n const [sourceId, setSourceId] = useState(\"current\");\n const [query, setQuery] = useState(\"\");\n const [ownerEmail, setOwnerEmail] = useState(\"\");\n const [threadId, setThreadId] = useState(\"\");\n const [submittedSearch, setSubmittedSearch] = useState({\n sourceId: \"current\",\n query: \"\",\n ownerEmail: \"\",\n });\n const [selected, setSelected] = useState<{\n sourceId: string;\n threadId: string;\n ownerEmail?: string;\n } | null>(null);\n\n const { data: sourcesData, isLoading: sourcesLoading } = useActionQuery<{\n access: {\n viewerEmail: string;\n orgId: string | null;\n role: string | null;\n envAdmin: boolean;\n canInspectAll: boolean;\n memberCount: number;\n };\n sources: ThreadDebugSource[];\n }>(\"list-agent-thread-sources\", {});\n\n const sources = sourcesData?.sources ?? [];\n const searchParams = useMemo(\n () => ({\n sourceId: submittedSearch.sourceId,\n query: submittedSearch.query || undefined,\n ownerEmail: submittedSearch.ownerEmail || undefined,\n limit: 25,\n }),\n [submittedSearch],\n );\n const {\n data: searchData,\n isLoading: searchLoading,\n error: searchError,\n refetch: refetchSearch,\n } = useActionQuery<{\n count: number;\n threads: ThreadSearchResult[];\n access: { scope: string; canInspectAll: boolean };\n source: { id: string; label: string };\n }>(\"search-agent-threads\", searchParams);\n\n const detailParams = useMemo(\n () => ({\n sourceId: selected?.sourceId ?? \"current\",\n threadId: selected?.threadId ?? \"\",\n ownerEmail: selected?.ownerEmail,\n maxRuns: 20,\n maxEvents: 800,\n maxTraceSpans: 600,\n }),\n [selected],\n );\n const {\n data: detail,\n isLoading: detailLoading,\n error: detailError,\n } = useActionQuery<ThreadDebugResponse>(\n \"get-agent-thread-debug\",\n detailParams,\n {\n enabled: Boolean(selected?.threadId),\n },\n );\n\n const selectedSource = sources.find((source) => source.id === sourceId);\n\n useEffect(() => {\n fetch(agentNativePath(\"/_agent-native/application-state/navigation\"), {\n method: \"PUT\",\n keepalive: true,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n view: \"thread-debug\",\n path:\n typeof window === \"undefined\"\n ? \"/thread-debug\"\n : window.location.pathname,\n sourceId,\n query,\n ownerEmail: ownerEmail.trim() || undefined,\n threadId: selected?.threadId ?? (threadId.trim() || undefined),\n }),\n }).catch(() => {});\n }, [ownerEmail, query, selected?.threadId, sourceId, threadId]);\n\n return (\n <DispatchShell\n title=\"Thread Debug\"\n description=\"Inspect persisted agent chat threads, run events, and AI internals.\"\n >\n <div className=\"space-y-4\">\n <section className=\"rounded-lg border bg-card p-4\">\n <div className=\"grid gap-3 lg:grid-cols-[220px_1fr_260px_auto]\">\n <Select value={sourceId} onValueChange={setSourceId}>\n <SelectTrigger>\n <SelectValue placeholder=\"Source\" />\n </SelectTrigger>\n <SelectContent>\n {sources.map((source) => (\n <SelectItem key={source.id} value={source.id}>\n {source.label}\n </SelectItem>\n ))}\n {sources.length === 0 ? (\n <SelectItem value=\"current\">Current Dispatch DB</SelectItem>\n ) : null}\n </SelectContent>\n </Select>\n <Input\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n placeholder=\"Search title, preview, messages, tools\"\n />\n <Input\n value={ownerEmail}\n onChange={(event) => setOwnerEmail(event.target.value)}\n placeholder=\"Owner email\"\n />\n <Button\n type=\"button\"\n onClick={() =>\n setSubmittedSearch({\n sourceId,\n query: query.trim(),\n ownerEmail: ownerEmail.trim(),\n })\n }\n >\n <IconSearch size={16} />\n Search\n </Button>\n </div>\n\n <div className=\"mt-3 grid gap-3 lg:grid-cols-[1fr_auto]\">\n <Input\n value={threadId}\n onChange={(event) => setThreadId(event.target.value)}\n placeholder=\"Paste thread ID\"\n className=\"font-mono\"\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n const trimmed = threadId.trim();\n if (!trimmed) return;\n setSelected({\n sourceId,\n threadId: trimmed,\n ownerEmail: ownerEmail.trim() || undefined,\n });\n }}\n >\n <IconFileSearch size={16} />\n Inspect\n </Button>\n </div>\n\n <div className=\"mt-3 flex flex-wrap items-center gap-2 text-xs text-muted-foreground\">\n {sourcesLoading ? <Skeleton className=\"h-5 w-32\" /> : null}\n {selectedSource ? <SourceBadge source={selectedSource} /> : null}\n {selectedSource?.databaseUrlEnv ? (\n <Badge variant=\"outline\" className=\"font-mono\">\n {selectedSource.databaseUrlEnv}\n </Badge>\n ) : null}\n {sourcesData?.access ? (\n <span>\n {sourcesData.access.viewerEmail} ·{\" \"}\n {sourcesData.access.canInspectAll ? \"admin scope\" : \"own scope\"}\n </span>\n ) : null}\n </div>\n </section>\n\n {searchError ? (\n <Alert variant=\"destructive\">\n <AlertTitle>Search failed</AlertTitle>\n <AlertDescription>{String(searchError.message)}</AlertDescription>\n </Alert>\n ) : null}\n\n <div className=\"grid gap-4 xl:grid-cols-[380px_1fr]\">\n <section className=\"min-h-[520px] rounded-lg border bg-card\">\n <div className=\"flex items-center justify-between border-b px-4 py-3\">\n <div>\n <div className=\"text-sm font-semibold text-foreground\">\n Threads\n </div>\n <div className=\"text-xs text-muted-foreground\">\n {searchData?.count ?? 0} results ·{\" \"}\n {searchData?.access?.scope ?? \"current scope\"}\n </div>\n </div>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => refetchSearch()}\n aria-label=\"Refresh threads\"\n >\n <IconRefresh size={16} />\n </Button>\n </div>\n <div className=\"max-h-[760px] space-y-2 overflow-auto p-3\">\n {searchLoading ? (\n <>\n <Skeleton className=\"h-28 w-full rounded-lg\" />\n <Skeleton className=\"h-28 w-full rounded-lg\" />\n <Skeleton className=\"h-28 w-full rounded-lg\" />\n </>\n ) : null}\n {!searchLoading && (searchData?.threads?.length ?? 0) === 0 ? (\n <div className=\"flex min-h-64 flex-col items-center justify-center rounded-lg border border-dashed px-4 text-center text-sm text-muted-foreground\">\n <IconDatabase className=\"mb-2 h-5 w-5\" />\n No threads found.\n </div>\n ) : null}\n {searchData?.threads?.map((result) => (\n <ResultCard\n key={result.id}\n result={result}\n selected={selected?.threadId === result.id}\n onSelect={() =>\n setSelected({\n sourceId: submittedSearch.sourceId,\n threadId: result.id,\n ownerEmail: submittedSearch.ownerEmail || undefined,\n })\n }\n />\n ))}\n </div>\n </section>\n\n <section className=\"min-w-0\">\n {detailError ? (\n <Alert variant=\"destructive\">\n <AlertTitle>Thread lookup failed</AlertTitle>\n <AlertDescription>\n {String(detailError.message)}\n </AlertDescription>\n </Alert>\n ) : null}\n {detailLoading ? (\n <div className=\"rounded-lg border bg-card p-4\">\n <Skeleton className=\"h-6 w-72\" />\n <Skeleton className=\"mt-3 h-4 w-96\" />\n <Skeleton className=\"mt-6 h-[520px] w-full\" />\n </div>\n ) : detail ? (\n <ThreadDetail detail={detail} />\n ) : (\n <div className=\"flex min-h-[520px] flex-col items-center justify-center rounded-lg border border-dashed bg-card px-4 text-center text-sm text-muted-foreground\">\n <IconFileSearch className=\"mb-2 h-5 w-5\" />\n Select or inspect a thread.\n </div>\n )}\n </section>\n </div>\n </div>\n </DispatchShell>\n );\n}\n"]}
|