@copilotz/admin 0.9.38 → 0.9.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -181,13 +181,16 @@ function createAdminClient(options = {}) {
181
181
  ),
182
182
  listAgents: async (listOptions = {}) => {
183
183
  const windowRange = getRangeWindow(listOptions.range ?? "7d");
184
- return await requestJson(`${paths.adminBase}/agents`, {
185
- search: listOptions.search,
186
- namespace: listOptions.namespace,
187
- from: windowRange.from,
188
- to: windowRange.to,
189
- limit: String(listOptions.limit ?? 25)
190
- });
184
+ return await requestJson(
185
+ `${paths.adminBase}/agents`,
186
+ {
187
+ search: listOptions.search,
188
+ namespace: listOptions.namespace,
189
+ from: windowRange.from,
190
+ to: windowRange.to,
191
+ limit: String(listOptions.limit ?? 25)
192
+ }
193
+ );
191
194
  },
192
195
  getThread: async (threadId) => await requestJson(
193
196
  `${paths.threadsBase}/${encodeURIComponent(threadId)}`
@@ -221,6 +224,27 @@ function createAdminClient(options = {}) {
221
224
  );
222
225
  return normalizeQueueEvent(payload);
223
226
  },
227
+ getBrain: async (filters = {}) => await requestJson(`${paths.adminBase}/brain`, {
228
+ namespace: filters.namespace,
229
+ memorySpaceId: filters.memorySpaceId,
230
+ checkpointId: filters.checkpointId,
231
+ agentId: filters.agentId,
232
+ threadId: filters.threadId,
233
+ layer: filters.layer === "all" ? void 0 : filters.layer,
234
+ kind: filters.kind === "all" ? void 0 : filters.kind,
235
+ status: filters.status === "all" ? void 0 : filters.status,
236
+ search: filters.search,
237
+ searchMode: filters.searchMode,
238
+ focusNodeId: filters.focusNodeId,
239
+ includeRelated: filters.includeRelated ? "true" : void 0,
240
+ includeSimilar: filters.includeSimilar ? "true" : void 0,
241
+ similarLimit: filters.similarLimit ? String(filters.similarLimit) : void 0,
242
+ minSimilarity: typeof filters.minSimilarity === "number" ? String(filters.minSimilarity) : void 0,
243
+ relationDepth: filters.relationDepth ? String(filters.relationDepth) : void 0,
244
+ relationTypes: filters.relationTypes?.join(","),
245
+ limit: String(filters.limit ?? 160),
246
+ offset: filters.offset ? String(filters.offset) : void 0
247
+ }),
224
248
  listCollections: async () => await requestJson(paths.collectionsBase),
225
249
  listCollectionItems: async (collection, listOptions = {}) => await requestJson(
226
250
  `${paths.collectionsBase}/${encodeURIComponent(collection)}`,
@@ -267,13 +291,13 @@ function createAdminClient(options = {}) {
267
291
  }
268
292
 
269
293
  // src/core/CopilotzAdmin.tsx
270
- import React15, { useMemo as useMemo3, useState as useState4 } from "react";
294
+ import React16, { useMemo as useMemo3, useState as useState4 } from "react";
271
295
  import {
272
296
  Bot as Bot4,
273
297
  ChevronsUpDown,
274
298
  Database as Database2,
275
299
  LayoutDashboard,
276
- RefreshCw
300
+ RefreshCw as RefreshCw2
277
301
  } from "lucide-react";
278
302
 
279
303
  // src/lib/utils.ts
@@ -1929,10 +1953,685 @@ function AgentDetailPage({ context }) {
1929
1953
  ] });
1930
1954
  }
1931
1955
 
1932
- // src/modules/collections/index.tsx
1956
+ // src/modules/brain/index.tsx
1933
1957
  import React7 from "react";
1934
- import { Database, Plus, Trash2 } from "lucide-react";
1958
+ import {
1959
+ Brain as Brain2,
1960
+ CircleDot,
1961
+ GitBranch,
1962
+ Network,
1963
+ RefreshCw,
1964
+ Search as Search2,
1965
+ Sparkles
1966
+ } from "lucide-react";
1935
1967
  import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
1968
+ var BRAIN_LAYERS = ["all", "knowledge", "working"];
1969
+ var BRAIN_SEARCH_MODES = ["hybrid", "semantic", "keyword"];
1970
+ var BRAIN_STATUSES = ["active", "all", "superseded", "archived"];
1971
+ var BRAIN_KINDS = [
1972
+ "all",
1973
+ "decision",
1974
+ "fact",
1975
+ "preference",
1976
+ "task",
1977
+ "constraint",
1978
+ "current_state",
1979
+ "challenge",
1980
+ "risk",
1981
+ "open_question",
1982
+ "next_action"
1983
+ ];
1984
+ function brainModule() {
1985
+ return {
1986
+ group: "data",
1987
+ icon: Brain2,
1988
+ id: "brain",
1989
+ label: "Brain",
1990
+ navItems: [{
1991
+ group: "data",
1992
+ icon: Brain2,
1993
+ id: "brain",
1994
+ label: "Brain",
1995
+ order: 10,
1996
+ routeId: "brain"
1997
+ }],
1998
+ routes: [{
1999
+ id: "brain",
2000
+ title: "Brain",
2001
+ render: (context) => /* @__PURE__ */ jsx21(BrainPage, { context })
2002
+ }]
2003
+ };
2004
+ }
2005
+ function BrainPage({ context }) {
2006
+ const [search, setSearch] = React7.useState("");
2007
+ const [searchMode, setSearchMode] = React7.useState(
2008
+ "hybrid"
2009
+ );
2010
+ const [layer, setLayer] = React7.useState("all");
2011
+ const [status, setStatus] = React7.useState(
2012
+ "active"
2013
+ );
2014
+ const [kind, setKind] = React7.useState("all");
2015
+ const [agentId, setAgentId] = React7.useState("");
2016
+ const [response, setResponse] = React7.useState(
2017
+ null
2018
+ );
2019
+ const [selectedNode, setSelectedNode] = React7.useState(
2020
+ null
2021
+ );
2022
+ const [focusNodeId, setFocusNodeId] = React7.useState(null);
2023
+ const [loading, setLoading] = React7.useState(false);
2024
+ const [error, setError] = React7.useState(null);
2025
+ const loadBrain = React7.useCallback(async (focusOverride) => {
2026
+ setLoading(true);
2027
+ setError(null);
2028
+ const effectiveFocusNodeId = focusOverride === void 0 ? focusNodeId : focusOverride;
2029
+ try {
2030
+ const next = await context.client.getBrain({
2031
+ namespace: context.scope.namespace || void 0,
2032
+ search: search.trim() || void 0,
2033
+ searchMode,
2034
+ layer,
2035
+ status,
2036
+ kind,
2037
+ agentId: agentId.trim() || void 0,
2038
+ focusNodeId: effectiveFocusNodeId || void 0,
2039
+ includeRelated: Boolean(effectiveFocusNodeId),
2040
+ includeSimilar: Boolean(effectiveFocusNodeId),
2041
+ similarLimit: 24,
2042
+ minSimilarity: 0.2,
2043
+ limit: 180
2044
+ });
2045
+ setResponse(next);
2046
+ setSelectedNode(
2047
+ (current) => effectiveFocusNodeId ? next.nodes.find((node) => node.id === effectiveFocusNodeId) ?? current : current && next.nodes.some((node) => node.id === current.id) ? next.nodes.find((node) => node.id === current.id) ?? current : next.nodes[0] ?? null
2048
+ );
2049
+ } catch (cause) {
2050
+ setError(cause instanceof Error ? cause.message : "Failed to load brain");
2051
+ setResponse(null);
2052
+ setSelectedNode(null);
2053
+ } finally {
2054
+ setLoading(false);
2055
+ }
2056
+ }, [
2057
+ agentId,
2058
+ context.client,
2059
+ context.scope.namespace,
2060
+ focusNodeId,
2061
+ kind,
2062
+ layer,
2063
+ search,
2064
+ searchMode,
2065
+ status
2066
+ ]);
2067
+ React7.useEffect(() => {
2068
+ void loadBrain();
2069
+ }, [context.refreshKey, context.scope.namespace, focusNodeId, loadBrain]);
2070
+ const data = response ?? emptyBrainResponse();
2071
+ const matches = data.matches ?? {};
2072
+ const related = data.related ?? [];
2073
+ const similar = data.similar ?? [];
2074
+ const knowledgeCount = data.stats.byLayer.knowledge ?? 0;
2075
+ const workingCount = data.stats.byLayer.working ?? 0;
2076
+ const selectNode = React7.useCallback((node) => {
2077
+ setSelectedNode(node);
2078
+ setFocusNodeId(node.id);
2079
+ }, []);
2080
+ const runSearch = React7.useCallback(() => {
2081
+ setFocusNodeId(null);
2082
+ void loadBrain(null);
2083
+ }, [loadBrain]);
2084
+ return /* @__PURE__ */ jsxs13("div", { className: "space-y-4", children: [
2085
+ /* @__PURE__ */ jsx21(
2086
+ PageHeader,
2087
+ {
2088
+ title: "Brain",
2089
+ description: "Unified knowledge and working state for the active namespace.",
2090
+ badges: [
2091
+ {
2092
+ label: context.scope.namespace ?? "all namespaces",
2093
+ variant: "secondary"
2094
+ }
2095
+ ],
2096
+ actions: /* @__PURE__ */ jsxs13(
2097
+ Button,
2098
+ {
2099
+ disabled: loading,
2100
+ onClick: () => void loadBrain(),
2101
+ size: "sm",
2102
+ type: "button",
2103
+ variant: "outline",
2104
+ children: [
2105
+ /* @__PURE__ */ jsx21(RefreshCw, { className: cn("size-3", loading && "animate-spin") }),
2106
+ "Refresh"
2107
+ ]
2108
+ }
2109
+ )
2110
+ }
2111
+ ),
2112
+ /* @__PURE__ */ jsx21(
2113
+ MetricStrip,
2114
+ {
2115
+ items: [
2116
+ {
2117
+ label: "Brain nodes",
2118
+ value: data.stats.total,
2119
+ detail: `${data.pageInfo.returned} shown`,
2120
+ icon: Brain2
2121
+ },
2122
+ {
2123
+ label: "Knowledge",
2124
+ value: knowledgeCount,
2125
+ detail: "Durable nodes",
2126
+ icon: CircleDot
2127
+ },
2128
+ {
2129
+ label: "Working",
2130
+ value: workingCount,
2131
+ detail: "Current state",
2132
+ icon: Sparkles
2133
+ },
2134
+ {
2135
+ label: "Clusters",
2136
+ value: data.clusters.length,
2137
+ detail: "Layer and kind",
2138
+ icon: Network
2139
+ }
2140
+ ]
2141
+ }
2142
+ ),
2143
+ /* @__PURE__ */ jsxs13(
2144
+ FilterBar,
2145
+ {
2146
+ actions: /* @__PURE__ */ jsxs13(
2147
+ Button,
2148
+ {
2149
+ disabled: loading,
2150
+ onClick: runSearch,
2151
+ size: "sm",
2152
+ type: "button",
2153
+ children: [
2154
+ /* @__PURE__ */ jsx21(Search2, { className: "size-3" }),
2155
+ "Search"
2156
+ ]
2157
+ }
2158
+ ),
2159
+ onSearchChange: setSearch,
2160
+ searchPlaceholder: "Search brain",
2161
+ searchValue: search,
2162
+ children: [
2163
+ /* @__PURE__ */ jsx21("div", { className: "inline-flex h-8 overflow-hidden rounded-md border bg-background", children: BRAIN_SEARCH_MODES.map((mode) => /* @__PURE__ */ jsx21(
2164
+ "button",
2165
+ {
2166
+ className: cn(
2167
+ "px-3 text-xs transition-colors",
2168
+ searchMode === mode ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-muted"
2169
+ ),
2170
+ onClick: () => setSearchMode(mode),
2171
+ type: "button",
2172
+ children: formatLabel(mode)
2173
+ },
2174
+ mode
2175
+ )) }),
2176
+ /* @__PURE__ */ jsxs13(
2177
+ Select,
2178
+ {
2179
+ value: layer,
2180
+ onValueChange: (value) => setLayer(value),
2181
+ children: [
2182
+ /* @__PURE__ */ jsx21(SelectTrigger, { className: "h-8 w-[140px] text-xs", "aria-label": "Layer", children: /* @__PURE__ */ jsx21(SelectValue, {}) }),
2183
+ /* @__PURE__ */ jsx21(SelectContent, { children: BRAIN_LAYERS.map((option) => /* @__PURE__ */ jsx21(SelectItem, { value: option, children: option === "all" ? "All layers" : formatLabel(option) }, option)) })
2184
+ ]
2185
+ }
2186
+ ),
2187
+ /* @__PURE__ */ jsxs13(
2188
+ Select,
2189
+ {
2190
+ value: status,
2191
+ onValueChange: (value) => setStatus(value),
2192
+ children: [
2193
+ /* @__PURE__ */ jsx21(SelectTrigger, { className: "h-8 w-[140px] text-xs", "aria-label": "Status", children: /* @__PURE__ */ jsx21(SelectValue, {}) }),
2194
+ /* @__PURE__ */ jsx21(SelectContent, { children: BRAIN_STATUSES.map((option) => /* @__PURE__ */ jsx21(SelectItem, { value: option, children: option === "all" ? "All statuses" : formatLabel(option) }, option)) })
2195
+ ]
2196
+ }
2197
+ ),
2198
+ /* @__PURE__ */ jsxs13(
2199
+ Select,
2200
+ {
2201
+ value: kind,
2202
+ onValueChange: (value) => setKind(value),
2203
+ children: [
2204
+ /* @__PURE__ */ jsx21(SelectTrigger, { className: "h-8 w-[170px] text-xs", "aria-label": "Kind", children: /* @__PURE__ */ jsx21(SelectValue, {}) }),
2205
+ /* @__PURE__ */ jsx21(SelectContent, { children: BRAIN_KINDS.map((option) => /* @__PURE__ */ jsx21(SelectItem, { value: option, children: option === "all" ? "All kinds" : formatLabel(option) }, option)) })
2206
+ ]
2207
+ }
2208
+ ),
2209
+ /* @__PURE__ */ jsx21(
2210
+ Input,
2211
+ {
2212
+ className: "h-8 w-[190px]",
2213
+ onChange: (event) => setAgentId(event.target.value),
2214
+ onKeyDown: (event) => {
2215
+ if (event.key === "Enter") runSearch();
2216
+ },
2217
+ placeholder: "Agent ID",
2218
+ value: agentId
2219
+ }
2220
+ )
2221
+ ]
2222
+ }
2223
+ ),
2224
+ data.semantic?.requested && data.semantic.error ? /* @__PURE__ */ jsxs13("div", { className: "rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-xs text-destructive", children: [
2225
+ "Semantic search unavailable: ",
2226
+ data.semantic.error
2227
+ ] }) : null,
2228
+ error ? /* @__PURE__ */ jsx21(EmptyState, { title: "Unable to load brain", description: error }) : /* @__PURE__ */ jsx21(
2229
+ InspectorPanel,
2230
+ {
2231
+ side: selectedNode ? /* @__PURE__ */ jsx21(
2232
+ BrainNodeInspector,
2233
+ {
2234
+ match: matches[selectedNode.id],
2235
+ node: selectedNode,
2236
+ onSelectNode: selectNode,
2237
+ related,
2238
+ similar
2239
+ }
2240
+ ) : /* @__PURE__ */ jsx21(
2241
+ EmptyState,
2242
+ {
2243
+ icon: Brain2,
2244
+ title: "No node selected",
2245
+ description: "Select a node from the map or table."
2246
+ }
2247
+ ),
2248
+ children: /* @__PURE__ */ jsxs13("div", { className: "space-y-4", children: [
2249
+ /* @__PURE__ */ jsx21(
2250
+ BrainMap,
2251
+ {
2252
+ clusters: data.clusters,
2253
+ edges: data.edges,
2254
+ loading,
2255
+ nodes: data.nodes,
2256
+ onSelectNode: selectNode,
2257
+ similar,
2258
+ selectedNodeId: selectedNode?.id ?? null
2259
+ }
2260
+ ),
2261
+ /* @__PURE__ */ jsx21(
2262
+ ResourceTable,
2263
+ {
2264
+ rows: data.nodes,
2265
+ getRowKey: (row) => row.id,
2266
+ onRowClick: selectNode,
2267
+ empty: /* @__PURE__ */ jsx21(
2268
+ EmptyState,
2269
+ {
2270
+ icon: Brain2,
2271
+ title: loading ? "Loading brain" : "No brain nodes",
2272
+ description: loading ? "Fetching brain nodes for the active namespace." : "Knowledge and working-state nodes will appear here."
2273
+ }
2274
+ ),
2275
+ columns: [
2276
+ {
2277
+ id: "node",
2278
+ header: "Node",
2279
+ className: "max-w-[360px]",
2280
+ render: (row) => /* @__PURE__ */ jsxs13("div", { className: "min-w-0", children: [
2281
+ /* @__PURE__ */ jsx21("div", { className: "truncate font-medium", children: row.name }),
2282
+ /* @__PURE__ */ jsx21("div", { className: "truncate text-xs text-muted-foreground", children: row.content || "-" }),
2283
+ /* @__PURE__ */ jsx21(MatchBadges, { match: matches[row.id] })
2284
+ ] })
2285
+ },
2286
+ {
2287
+ id: "layer",
2288
+ header: "Layer",
2289
+ render: (row) => /* @__PURE__ */ jsx21(LayerBadge, { layer: row.layer })
2290
+ },
2291
+ {
2292
+ id: "kind",
2293
+ header: "Kind",
2294
+ render: (row) => formatLabel(row.kind)
2295
+ },
2296
+ {
2297
+ id: "status",
2298
+ header: "Status",
2299
+ render: (row) => /* @__PURE__ */ jsx21(StatusBadge, { status: row.status })
2300
+ },
2301
+ {
2302
+ id: "agent",
2303
+ header: "Agent",
2304
+ className: "max-w-[160px] truncate font-mono text-xs",
2305
+ render: (row) => row.agentId ?? "-"
2306
+ }
2307
+ ]
2308
+ }
2309
+ )
2310
+ ] })
2311
+ }
2312
+ )
2313
+ ] });
2314
+ }
2315
+ function BrainMap({
2316
+ clusters,
2317
+ edges,
2318
+ loading,
2319
+ nodes,
2320
+ onSelectNode,
2321
+ similar,
2322
+ selectedNodeId
2323
+ }) {
2324
+ const nodeById = React7.useMemo(
2325
+ () => new Map(nodes.map((node) => [node.id, node])),
2326
+ [nodes]
2327
+ );
2328
+ if (nodes.length === 0) {
2329
+ return /* @__PURE__ */ jsx21("div", { className: "flex min-h-[360px] items-center justify-center rounded-lg border bg-background", children: /* @__PURE__ */ jsx21(
2330
+ EmptyState,
2331
+ {
2332
+ icon: Brain2,
2333
+ title: loading ? "Loading map" : "No map data",
2334
+ description: loading ? "Building the namespace brain map." : "The map will appear once brain nodes exist."
2335
+ }
2336
+ ) });
2337
+ }
2338
+ return /* @__PURE__ */ jsx21("div", { className: "overflow-hidden rounded-lg border bg-background", children: /* @__PURE__ */ jsxs13(
2339
+ "svg",
2340
+ {
2341
+ className: "block h-[420px] w-full bg-muted/20",
2342
+ role: "img",
2343
+ viewBox: "0 0 1000 600",
2344
+ children: [
2345
+ /* @__PURE__ */ jsx21("rect", { fill: "transparent", height: "600", width: "1000" }),
2346
+ clusters.map((cluster) => /* @__PURE__ */ jsxs13("g", { children: [
2347
+ /* @__PURE__ */ jsx21(
2348
+ "circle",
2349
+ {
2350
+ cx: cluster.x * 1e3,
2351
+ cy: cluster.y * 600,
2352
+ fill: cluster.layer === "working" ? "#ecfeff" : "#eef2ff",
2353
+ opacity: "0.7",
2354
+ r: Math.max(46, Math.min(96, 34 + cluster.count * 8)),
2355
+ stroke: cluster.layer === "working" ? "#0891b2" : "#4f46e5",
2356
+ strokeOpacity: "0.18"
2357
+ }
2358
+ ),
2359
+ /* @__PURE__ */ jsx21(
2360
+ "text",
2361
+ {
2362
+ className: "fill-muted-foreground text-[11px]",
2363
+ textAnchor: "middle",
2364
+ x: cluster.x * 1e3,
2365
+ y: cluster.y * 600 - 40,
2366
+ children: cluster.label
2367
+ }
2368
+ )
2369
+ ] }, cluster.id)),
2370
+ edges.map((edge) => {
2371
+ const source = nodeById.get(edge.sourceNodeId);
2372
+ const target = nodeById.get(edge.targetNodeId);
2373
+ if (!source || !target) return null;
2374
+ const isSelectedEdge = Boolean(
2375
+ selectedNodeId && (edge.sourceNodeId === selectedNodeId || edge.targetNodeId === selectedNodeId)
2376
+ );
2377
+ return /* @__PURE__ */ jsx21(
2378
+ "line",
2379
+ {
2380
+ stroke: edge.type === "contradicts" ? "#dc2626" : "#64748b",
2381
+ strokeOpacity: isSelectedEdge ? "0.75" : "0.32",
2382
+ strokeWidth: isSelectedEdge ? 2.6 : edge.type === "supports" ? 2 : 1.3,
2383
+ x1: source.x * 1e3,
2384
+ x2: target.x * 1e3,
2385
+ y1: source.y * 600,
2386
+ y2: target.y * 600
2387
+ },
2388
+ edge.id
2389
+ );
2390
+ }),
2391
+ selectedNodeId ? similar.map((item) => {
2392
+ const source = nodeById.get(selectedNodeId);
2393
+ const target = nodeById.get(item.node.id);
2394
+ if (!source || !target) return null;
2395
+ return /* @__PURE__ */ jsx21(
2396
+ "line",
2397
+ {
2398
+ stroke: "#0ea5e9",
2399
+ strokeDasharray: "5 6",
2400
+ strokeOpacity: "0.42",
2401
+ strokeWidth: "1.8",
2402
+ x1: source.x * 1e3,
2403
+ x2: target.x * 1e3,
2404
+ y1: source.y * 600,
2405
+ y2: target.y * 600
2406
+ },
2407
+ `similar-${item.node.id}`
2408
+ );
2409
+ }) : null,
2410
+ nodes.map((node) => {
2411
+ const isSelected = node.id === selectedNodeId;
2412
+ return /* @__PURE__ */ jsx21(
2413
+ "g",
2414
+ {
2415
+ className: "cursor-pointer",
2416
+ onClick: () => onSelectNode(node),
2417
+ children: /* @__PURE__ */ jsx21(
2418
+ "circle",
2419
+ {
2420
+ cx: node.x * 1e3,
2421
+ cy: node.y * 600,
2422
+ fill: nodeColor(node),
2423
+ r: isSelected ? 9 : 6,
2424
+ stroke: isSelected ? "#0f172a" : "#ffffff",
2425
+ strokeWidth: isSelected ? 3 : 2,
2426
+ children: /* @__PURE__ */ jsx21("title", { children: `${node.name} \xB7 ${formatLabel(node.kind)}` })
2427
+ }
2428
+ )
2429
+ },
2430
+ node.id
2431
+ );
2432
+ })
2433
+ ]
2434
+ }
2435
+ ) });
2436
+ }
2437
+ function BrainNodeInspector({
2438
+ match,
2439
+ node,
2440
+ onSelectNode,
2441
+ related,
2442
+ similar
2443
+ }) {
2444
+ const [tab, setTab] = React7.useState("overview");
2445
+ return /* @__PURE__ */ jsxs13("div", { className: "space-y-3", children: [
2446
+ /* @__PURE__ */ jsxs13("div", { className: "rounded-lg border bg-background p-4", children: [
2447
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", children: [
2448
+ /* @__PURE__ */ jsx21(LayerBadge, { layer: node.layer }),
2449
+ /* @__PURE__ */ jsx21(StatusBadge, { status: node.status }),
2450
+ /* @__PURE__ */ jsx21(Badge, { variant: "outline", children: formatLabel(node.kind) })
2451
+ ] }),
2452
+ /* @__PURE__ */ jsx21("h3", { className: "mt-3 text-base font-semibold", children: node.name }),
2453
+ /* @__PURE__ */ jsx21("p", { className: "mt-2 text-sm leading-6 text-muted-foreground", children: node.content || "-" }),
2454
+ /* @__PURE__ */ jsx21(MatchBadges, { match })
2455
+ ] }),
2456
+ /* @__PURE__ */ jsx21("div", { className: "inline-flex w-full overflow-hidden rounded-md border bg-background", children: ["overview", "related", "similar", "evidence", "json"].map((item) => /* @__PURE__ */ jsx21(
2457
+ "button",
2458
+ {
2459
+ className: cn(
2460
+ "min-w-0 flex-1 px-2 py-2 text-xs transition-colors",
2461
+ tab === item ? "bg-muted font-medium text-foreground" : "text-muted-foreground hover:bg-muted/60"
2462
+ ),
2463
+ onClick: () => setTab(item),
2464
+ type: "button",
2465
+ children: formatLabel(item)
2466
+ },
2467
+ item
2468
+ )) }),
2469
+ tab === "overview" ? /* @__PURE__ */ jsx21(BrainOverview, { node }) : null,
2470
+ tab === "related" ? /* @__PURE__ */ jsx21(RelatedPanel, { onSelectNode, related }) : null,
2471
+ tab === "similar" ? /* @__PURE__ */ jsx21(SimilarPanel, { onSelectNode, similar }) : null,
2472
+ tab === "evidence" ? /* @__PURE__ */ jsx21(EvidencePanel, { node }) : null,
2473
+ tab === "json" ? /* @__PURE__ */ jsx21(JsonPanel, { title: "Node JSON", value: node, minHeight: 300 }) : null
2474
+ ] });
2475
+ }
2476
+ function BrainOverview({ node }) {
2477
+ return /* @__PURE__ */ jsx21("div", { className: "rounded-lg border bg-background p-4", children: /* @__PURE__ */ jsxs13("dl", { className: "grid gap-2 text-xs", children: [
2478
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Agent", value: node.agentId }),
2479
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Thread", value: node.threadId }),
2480
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Memory space", value: node.memorySpaceId }),
2481
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Checkpoint", value: node.checkpointId }),
2482
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Source field", value: node.sourceField }),
2483
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Confidence", value: formatNullableNumber(node.confidence) }),
2484
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Updated", value: formatDateTime(node.updatedAt) })
2485
+ ] }) });
2486
+ }
2487
+ function RelatedPanel({
2488
+ onSelectNode,
2489
+ related
2490
+ }) {
2491
+ if (related.length === 0) {
2492
+ return /* @__PURE__ */ jsx21(
2493
+ EmptyState,
2494
+ {
2495
+ icon: GitBranch,
2496
+ title: "No explicit relations",
2497
+ description: "Relation edges will appear here when this node is connected to other concepts."
2498
+ }
2499
+ );
2500
+ }
2501
+ return /* @__PURE__ */ jsx21("div", { className: "space-y-2", children: related.map((item) => /* @__PURE__ */ jsxs13(
2502
+ "button",
2503
+ {
2504
+ className: "w-full rounded-lg border bg-background p-3 text-left transition-colors hover:bg-muted/40",
2505
+ onClick: () => onSelectNode(item.node),
2506
+ type: "button",
2507
+ children: [
2508
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", children: [
2509
+ /* @__PURE__ */ jsx21(Badge, { variant: "outline", children: formatLabel(item.edge.type) }),
2510
+ /* @__PURE__ */ jsx21(Badge, { variant: "secondary", children: item.direction === "out" ? "Outgoing" : "Incoming" })
2511
+ ] }),
2512
+ /* @__PURE__ */ jsx21("div", { className: "mt-2 text-sm font-medium", children: item.node.name }),
2513
+ /* @__PURE__ */ jsx21("p", { className: "mt-1 line-clamp-3 text-xs leading-5 text-muted-foreground", children: item.node.content || "-" })
2514
+ ]
2515
+ },
2516
+ item.edge.id
2517
+ )) });
2518
+ }
2519
+ function SimilarPanel({
2520
+ onSelectNode,
2521
+ similar
2522
+ }) {
2523
+ if (similar.length === 0) {
2524
+ return /* @__PURE__ */ jsx21(
2525
+ EmptyState,
2526
+ {
2527
+ icon: Sparkles,
2528
+ title: "No semantic neighbors",
2529
+ description: "Similar nodes appear here when the selected node has an embedding."
2530
+ }
2531
+ );
2532
+ }
2533
+ return /* @__PURE__ */ jsx21("div", { className: "space-y-2", children: similar.map((item) => /* @__PURE__ */ jsxs13(
2534
+ "button",
2535
+ {
2536
+ className: "w-full rounded-lg border bg-background p-3 text-left transition-colors hover:bg-muted/40",
2537
+ onClick: () => onSelectNode(item.node),
2538
+ type: "button",
2539
+ children: [
2540
+ /* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap items-center gap-2", children: [
2541
+ /* @__PURE__ */ jsx21(Badge, { variant: "secondary", children: formatSimilarityScore(item.similarity) }),
2542
+ /* @__PURE__ */ jsx21(LayerBadge, { layer: item.node.layer }),
2543
+ /* @__PURE__ */ jsx21(Badge, { variant: "outline", children: formatLabel(item.node.kind) })
2544
+ ] }),
2545
+ /* @__PURE__ */ jsx21("div", { className: "mt-2 text-sm font-medium", children: item.node.name }),
2546
+ /* @__PURE__ */ jsx21("p", { className: "mt-1 line-clamp-3 text-xs leading-5 text-muted-foreground", children: item.node.content || "-" })
2547
+ ]
2548
+ },
2549
+ item.node.id
2550
+ )) });
2551
+ }
2552
+ function EvidencePanel({ node }) {
2553
+ return /* @__PURE__ */ jsxs13("div", { className: "rounded-lg border bg-background p-4", children: [
2554
+ /* @__PURE__ */ jsxs13("dl", { className: "grid gap-2 text-xs", children: [
2555
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Source", value: node.sourceType }),
2556
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Source ID", value: node.sourceId }),
2557
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Thread", value: node.threadId }),
2558
+ /* @__PURE__ */ jsx21(InspectorRow, { label: "Checkpoint", value: node.checkpointId })
2559
+ ] }),
2560
+ /* @__PURE__ */ jsxs13("div", { className: "mt-4", children: [
2561
+ /* @__PURE__ */ jsx21("div", { className: "text-xs font-medium text-muted-foreground", children: "Source messages" }),
2562
+ /* @__PURE__ */ jsx21("div", { className: "mt-2 flex flex-wrap gap-1", children: node.sourceMessageIds.length ? node.sourceMessageIds.map((id) => /* @__PURE__ */ jsx21(Badge, { className: "max-w-full truncate", variant: "outline", children: id }, id)) : /* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground", children: "-" }) })
2563
+ ] })
2564
+ ] });
2565
+ }
2566
+ function MatchBadges({ match }) {
2567
+ if (!match?.reasons.length) return null;
2568
+ return /* @__PURE__ */ jsx21("div", { className: "mt-2 flex flex-wrap gap-1", children: match.reasons.slice(0, 4).map((reason) => /* @__PURE__ */ jsx21(Badge, { className: "text-[10px]", variant: "outline", children: reason }, reason)) });
2569
+ }
2570
+ function InspectorRow({
2571
+ label,
2572
+ value
2573
+ }) {
2574
+ return /* @__PURE__ */ jsxs13("div", { className: "grid grid-cols-[110px_minmax(0,1fr)] gap-2", children: [
2575
+ /* @__PURE__ */ jsx21("dt", { className: "text-muted-foreground", children: label }),
2576
+ /* @__PURE__ */ jsx21("dd", { className: "truncate font-mono", children: value || "-" })
2577
+ ] });
2578
+ }
2579
+ function LayerBadge({ layer }) {
2580
+ return /* @__PURE__ */ jsx21(Badge, { variant: layer === "working" ? "secondary" : "default", children: formatLabel(layer) });
2581
+ }
2582
+ function nodeColor(node) {
2583
+ if (node.layer === "working") return "#0891b2";
2584
+ if (node.kind === "decision") return "#4f46e5";
2585
+ if (node.kind === "risk") return "#dc2626";
2586
+ if (node.kind === "preference") return "#16a34a";
2587
+ return "#475569";
2588
+ }
2589
+ function formatLabel(value) {
2590
+ return value.replaceAll("_", " ").replace(/\b\w/g, (letter) => letter.toUpperCase());
2591
+ }
2592
+ function formatDateTime(value) {
2593
+ if (!value) return "-";
2594
+ const date = new Date(value);
2595
+ if (Number.isNaN(date.getTime())) return value;
2596
+ return date.toLocaleString();
2597
+ }
2598
+ function formatNullableNumber(value) {
2599
+ return typeof value === "number" && Number.isFinite(value) ? value.toFixed(2) : "-";
2600
+ }
2601
+ function formatSimilarityScore(value) {
2602
+ return Number.isFinite(value) ? `Similarity ${value.toFixed(2)}` : "-";
2603
+ }
2604
+ function emptyBrainResponse() {
2605
+ return {
2606
+ nodes: [],
2607
+ edges: [],
2608
+ clusters: [],
2609
+ stats: {
2610
+ total: 0,
2611
+ byLayer: {},
2612
+ byKind: {},
2613
+ byStatus: {}
2614
+ },
2615
+ matches: {},
2616
+ related: [],
2617
+ similar: [],
2618
+ semantic: {
2619
+ requested: false,
2620
+ available: false,
2621
+ error: null
2622
+ },
2623
+ pageInfo: {
2624
+ limit: 0,
2625
+ offset: 0,
2626
+ returned: 0
2627
+ }
2628
+ };
2629
+ }
2630
+
2631
+ // src/modules/collections/index.tsx
2632
+ import React8 from "react";
2633
+ import { Database, Plus, Trash2 } from "lucide-react";
2634
+ import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
1936
2635
  function collectionsModule() {
1937
2636
  return {
1938
2637
  group: "data",
@@ -1951,23 +2650,23 @@ function collectionsModule() {
1951
2650
  {
1952
2651
  id: "collections",
1953
2652
  title: "Collections",
1954
- render: (context) => /* @__PURE__ */ jsx21(CollectionsPage, { context })
2653
+ render: (context) => /* @__PURE__ */ jsx22(CollectionsPage, { context })
1955
2654
  },
1956
2655
  {
1957
2656
  id: "collections.detail",
1958
2657
  title: "Collection Item",
1959
- render: (context) => /* @__PURE__ */ jsx21(CollectionDetailPage, { context })
2658
+ render: (context) => /* @__PURE__ */ jsx22(CollectionDetailPage, { context })
1960
2659
  }
1961
2660
  ]
1962
2661
  };
1963
2662
  }
1964
2663
  function CollectionsPage({ context }) {
1965
- const [collections, setCollections] = React7.useState([]);
1966
- const [selected, setSelected] = React7.useState(null);
1967
- const [search, setSearch] = React7.useState("");
1968
- const [items, setItems] = React7.useState([]);
1969
- const [error, setError] = React7.useState(null);
1970
- React7.useEffect(() => {
2664
+ const [collections, setCollections] = React8.useState([]);
2665
+ const [selected, setSelected] = React8.useState(null);
2666
+ const [search, setSearch] = React8.useState("");
2667
+ const [items, setItems] = React8.useState([]);
2668
+ const [error, setError] = React8.useState(null);
2669
+ React8.useEffect(() => {
1971
2670
  let active = true;
1972
2671
  void context.client.listCollections().then((names) => {
1973
2672
  if (!active) return;
@@ -1980,7 +2679,7 @@ function CollectionsPage({ context }) {
1980
2679
  active = false;
1981
2680
  };
1982
2681
  }, [context.client, context.refreshKey]);
1983
- React7.useEffect(() => {
2682
+ React8.useEffect(() => {
1984
2683
  if (!selected) return;
1985
2684
  let active = true;
1986
2685
  setError(null);
@@ -1997,30 +2696,30 @@ function CollectionsPage({ context }) {
1997
2696
  active = false;
1998
2697
  };
1999
2698
  }, [context.client, context.refreshKey, context.scope.namespace, search, selected]);
2000
- return /* @__PURE__ */ jsxs13("div", { className: "space-y-4", children: [
2001
- /* @__PURE__ */ jsx21(
2699
+ return /* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
2700
+ /* @__PURE__ */ jsx22(
2002
2701
  PageHeader,
2003
2702
  {
2004
2703
  title: "Collections",
2005
2704
  description: "Schema-aware collection browsing with advanced JSON fallback for records that do not have custom editors.",
2006
- actions: selected && /* @__PURE__ */ jsxs13(
2705
+ actions: selected && /* @__PURE__ */ jsxs14(
2007
2706
  Button,
2008
2707
  {
2009
2708
  onClick: () => context.navigate("collections.detail", { collection: selected }),
2010
2709
  size: "sm",
2011
2710
  type: "button",
2012
2711
  children: [
2013
- /* @__PURE__ */ jsx21(Plus, { className: "size-3" }),
2712
+ /* @__PURE__ */ jsx22(Plus, { className: "size-3" }),
2014
2713
  "New"
2015
2714
  ]
2016
2715
  }
2017
2716
  )
2018
2717
  }
2019
2718
  ),
2020
- /* @__PURE__ */ jsxs13("div", { className: "grid gap-4 lg:grid-cols-[240px_minmax(0,1fr)]", children: [
2021
- /* @__PURE__ */ jsxs13("div", { className: "overflow-hidden rounded-lg border bg-background", children: [
2022
- /* @__PURE__ */ jsx21("div", { className: "border-b px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: "Collections" }),
2023
- /* @__PURE__ */ jsx21("div", { className: "max-h-[620px] overflow-auto p-1", children: collections.map((collection) => /* @__PURE__ */ jsx21(
2719
+ /* @__PURE__ */ jsxs14("div", { className: "grid gap-4 lg:grid-cols-[240px_minmax(0,1fr)]", children: [
2720
+ /* @__PURE__ */ jsxs14("div", { className: "overflow-hidden rounded-lg border bg-background", children: [
2721
+ /* @__PURE__ */ jsx22("div", { className: "border-b px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: "Collections" }),
2722
+ /* @__PURE__ */ jsx22("div", { className: "max-h-[620px] overflow-auto p-1", children: collections.map((collection) => /* @__PURE__ */ jsx22(
2024
2723
  "button",
2025
2724
  {
2026
2725
  className: `flex w-full items-center rounded-md px-2 py-1.5 text-left text-sm ${selected === collection ? "bg-accent text-accent-foreground" : "hover:bg-muted"}`,
@@ -2031,8 +2730,8 @@ function CollectionsPage({ context }) {
2031
2730
  collection
2032
2731
  )) })
2033
2732
  ] }),
2034
- /* @__PURE__ */ jsxs13("div", { className: "space-y-3", children: [
2035
- /* @__PURE__ */ jsx21(
2733
+ /* @__PURE__ */ jsxs14("div", { className: "space-y-3", children: [
2734
+ /* @__PURE__ */ jsx22(
2036
2735
  FilterBar,
2037
2736
  {
2038
2737
  onSearchChange: setSearch,
@@ -2040,7 +2739,7 @@ function CollectionsPage({ context }) {
2040
2739
  searchValue: search
2041
2740
  }
2042
2741
  ),
2043
- error ? /* @__PURE__ */ jsx21(EmptyState, { title: "Unable to load collection", description: error }) : selected ? /* @__PURE__ */ jsx21(
2742
+ error ? /* @__PURE__ */ jsx22(EmptyState, { title: "Unable to load collection", description: error }) : selected ? /* @__PURE__ */ jsx22(
2044
2743
  ResourceTable,
2045
2744
  {
2046
2745
  rows: items,
@@ -2049,7 +2748,7 @@ function CollectionsPage({ context }) {
2049
2748
  collection: selected,
2050
2749
  itemId: getItemId(item)
2051
2750
  }),
2052
- empty: /* @__PURE__ */ jsx21(
2751
+ empty: /* @__PURE__ */ jsx22(
2053
2752
  EmptyState,
2054
2753
  {
2055
2754
  icon: Database,
@@ -2061,16 +2760,16 @@ function CollectionsPage({ context }) {
2061
2760
  {
2062
2761
  id: "id",
2063
2762
  header: "ID",
2064
- render: (item) => /* @__PURE__ */ jsx21("div", { className: "max-w-sm truncate font-mono text-xs", children: getItemId(item) })
2763
+ render: (item) => /* @__PURE__ */ jsx22("div", { className: "max-w-sm truncate font-mono text-xs", children: getItemId(item) })
2065
2764
  },
2066
2765
  {
2067
2766
  id: "preview",
2068
2767
  header: "Preview",
2069
- render: (item) => /* @__PURE__ */ jsx21("div", { className: "max-w-xl truncate text-sm", children: getItemPreview(item) })
2768
+ render: (item) => /* @__PURE__ */ jsx22("div", { className: "max-w-xl truncate text-sm", children: getItemPreview(item) })
2070
2769
  }
2071
2770
  ]
2072
2771
  }
2073
- ) : /* @__PURE__ */ jsx21(EmptyState, { title: "No collections" })
2772
+ ) : /* @__PURE__ */ jsx22(EmptyState, { title: "No collections" })
2074
2773
  ] })
2075
2774
  ] })
2076
2775
  ] });
@@ -2078,10 +2777,10 @@ function CollectionsPage({ context }) {
2078
2777
  function CollectionDetailPage({ context }) {
2079
2778
  const collection = context.route.params?.collection;
2080
2779
  const itemId = context.route.params?.itemId ?? null;
2081
- const [item, setItem] = React7.useState(null);
2082
- const [error, setError] = React7.useState(null);
2780
+ const [item, setItem] = React8.useState(null);
2781
+ const [error, setError] = React8.useState(null);
2083
2782
  const isNew = !itemId;
2084
- React7.useEffect(() => {
2783
+ React8.useEffect(() => {
2085
2784
  if (!collection || !itemId) {
2086
2785
  setItem(null);
2087
2786
  return;
@@ -2099,8 +2798,8 @@ function CollectionDetailPage({ context }) {
2099
2798
  active = false;
2100
2799
  };
2101
2800
  }, [collection, context.client, context.refreshKey, context.scope.namespace, itemId]);
2102
- if (!collection) return /* @__PURE__ */ jsx21(EmptyState, { title: "Collection not selected" });
2103
- if (error) return /* @__PURE__ */ jsx21(EmptyState, { title: "Unable to load item", description: error });
2801
+ if (!collection) return /* @__PURE__ */ jsx22(EmptyState, { title: "Collection not selected" });
2802
+ if (error) return /* @__PURE__ */ jsx22(EmptyState, { title: "Unable to load item", description: error });
2104
2803
  const Editor = context.collectionEditors[collection];
2105
2804
  const save = async (value) => {
2106
2805
  if (isNew) {
@@ -2120,14 +2819,14 @@ function CollectionDetailPage({ context }) {
2120
2819
  });
2121
2820
  setItem(updated);
2122
2821
  };
2123
- return /* @__PURE__ */ jsxs13("div", { className: "space-y-4", children: [
2124
- /* @__PURE__ */ jsx21(
2822
+ return /* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
2823
+ /* @__PURE__ */ jsx22(
2125
2824
  PageHeader,
2126
2825
  {
2127
2826
  title: isNew ? `New ${collection}` : `${collection} / ${itemId}`,
2128
2827
  description: "Schema-aware editors can override this view. Advanced JSON remains available as a fallback.",
2129
- actions: /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
2130
- !isNew && itemId && /* @__PURE__ */ jsxs13(
2828
+ actions: /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
2829
+ !isNew && itemId && /* @__PURE__ */ jsxs14(
2131
2830
  Button,
2132
2831
  {
2133
2832
  onClick: () => {
@@ -2139,12 +2838,12 @@ function CollectionDetailPage({ context }) {
2139
2838
  type: "button",
2140
2839
  variant: "destructive",
2141
2840
  children: [
2142
- /* @__PURE__ */ jsx21(Trash2, { className: "size-3" }),
2841
+ /* @__PURE__ */ jsx22(Trash2, { className: "size-3" }),
2143
2842
  "Delete"
2144
2843
  ]
2145
2844
  }
2146
2845
  ),
2147
- /* @__PURE__ */ jsx21(
2846
+ /* @__PURE__ */ jsx22(
2148
2847
  Button,
2149
2848
  {
2150
2849
  onClick: () => context.navigate("collections"),
@@ -2157,7 +2856,7 @@ function CollectionDetailPage({ context }) {
2157
2856
  ] })
2158
2857
  }
2159
2858
  ),
2160
- Editor ? /* @__PURE__ */ jsx21(
2859
+ Editor ? /* @__PURE__ */ jsx22(
2161
2860
  Editor,
2162
2861
  {
2163
2862
  collection,
@@ -2168,7 +2867,7 @@ function CollectionDetailPage({ context }) {
2168
2867
  onSaved: setItem,
2169
2868
  onDeleted: () => context.navigate("collections")
2170
2869
  }
2171
- ) : /* @__PURE__ */ jsx21(
2870
+ ) : /* @__PURE__ */ jsx22(
2172
2871
  JsonPanel,
2173
2872
  {
2174
2873
  title: "Advanced JSON",
@@ -2193,9 +2892,9 @@ function getItemPreview(item) {
2193
2892
  }
2194
2893
 
2195
2894
  // src/modules/events/index.tsx
2196
- import React8 from "react";
2197
- import { Activity, Search as Search2 } from "lucide-react";
2198
- import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
2895
+ import React9 from "react";
2896
+ import { Activity, Search as Search3 } from "lucide-react";
2897
+ import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
2199
2898
  function eventsModule() {
2200
2899
  return {
2201
2900
  group: "operate",
@@ -2213,7 +2912,7 @@ function eventsModule() {
2213
2912
  routes: [{
2214
2913
  id: "events",
2215
2914
  title: "Events",
2216
- render: (context) => /* @__PURE__ */ jsx22(EventsPage, { context })
2915
+ render: (context) => /* @__PURE__ */ jsx23(EventsPage, { context })
2217
2916
  }]
2218
2917
  };
2219
2918
  }
@@ -2227,17 +2926,17 @@ var EVENT_STATUSES = [
2227
2926
  "overwritten"
2228
2927
  ];
2229
2928
  function EventsPage({ context }) {
2230
- const [threadId, setThreadId] = React8.useState("");
2231
- const [status, setStatus] = React8.useState(
2929
+ const [threadId, setThreadId] = React9.useState("");
2930
+ const [status, setStatus] = React9.useState(
2232
2931
  "all"
2233
2932
  );
2234
- const [eventType, setEventType] = React8.useState("");
2235
- const [traceId, setTraceId] = React8.useState("");
2236
- const [events, setEvents] = React8.useState([]);
2237
- const [selectedEvent, setSelectedEvent] = React8.useState(null);
2238
- const [error, setError] = React8.useState(null);
2239
- const [loading, setLoading] = React8.useState(false);
2240
- const [hasLoaded, setHasLoaded] = React8.useState(false);
2933
+ const [eventType, setEventType] = React9.useState("");
2934
+ const [traceId, setTraceId] = React9.useState("");
2935
+ const [events, setEvents] = React9.useState([]);
2936
+ const [selectedEvent, setSelectedEvent] = React9.useState(null);
2937
+ const [error, setError] = React9.useState(null);
2938
+ const [loading, setLoading] = React9.useState(false);
2939
+ const [hasLoaded, setHasLoaded] = React9.useState(false);
2241
2940
  const inspect = async () => {
2242
2941
  setHasLoaded(true);
2243
2942
  setLoading(true);
@@ -2263,21 +2962,21 @@ function EventsPage({ context }) {
2263
2962
  setLoading(false);
2264
2963
  }
2265
2964
  };
2266
- React8.useEffect(() => {
2965
+ React9.useEffect(() => {
2267
2966
  void inspect();
2268
2967
  }, [context.client, context.refreshKey, context.scope.namespace]);
2269
- return /* @__PURE__ */ jsxs14("div", { className: "space-y-4", children: [
2270
- /* @__PURE__ */ jsx22(
2968
+ return /* @__PURE__ */ jsxs15("div", { className: "space-y-4", children: [
2969
+ /* @__PURE__ */ jsx23(
2271
2970
  PageHeader,
2272
2971
  {
2273
2972
  title: "Events",
2274
2973
  description: "Queue and event inspection across the active namespace."
2275
2974
  }
2276
2975
  ),
2277
- /* @__PURE__ */ jsxs14(
2976
+ /* @__PURE__ */ jsxs15(
2278
2977
  FilterBar,
2279
2978
  {
2280
- actions: /* @__PURE__ */ jsxs14(
2979
+ actions: /* @__PURE__ */ jsxs15(
2281
2980
  Button,
2282
2981
  {
2283
2982
  disabled: loading,
@@ -2285,13 +2984,13 @@ function EventsPage({ context }) {
2285
2984
  size: "sm",
2286
2985
  type: "button",
2287
2986
  children: [
2288
- /* @__PURE__ */ jsx22(Search2, { className: "size-3" }),
2987
+ /* @__PURE__ */ jsx23(Search3, { className: "size-3" }),
2289
2988
  loading ? "Loading" : "Inspect"
2290
2989
  ]
2291
2990
  }
2292
2991
  ),
2293
2992
  children: [
2294
- /* @__PURE__ */ jsx22(
2993
+ /* @__PURE__ */ jsx23(
2295
2994
  Input,
2296
2995
  {
2297
2996
  className: "h-8 w-[220px]",
@@ -2303,18 +3002,18 @@ function EventsPage({ context }) {
2303
3002
  value: threadId
2304
3003
  }
2305
3004
  ),
2306
- /* @__PURE__ */ jsxs14(
3005
+ /* @__PURE__ */ jsxs15(
2307
3006
  Select,
2308
3007
  {
2309
3008
  value: status,
2310
3009
  onValueChange: (value) => setStatus(value),
2311
3010
  children: [
2312
- /* @__PURE__ */ jsx22(SelectTrigger, { className: "h-8 w-[150px] text-xs", "aria-label": "Status", children: /* @__PURE__ */ jsx22(SelectValue, {}) }),
2313
- /* @__PURE__ */ jsx22(SelectContent, { children: EVENT_STATUSES.map((option) => /* @__PURE__ */ jsx22(SelectItem, { value: option, children: option === "all" ? "All statuses" : option }, option)) })
3011
+ /* @__PURE__ */ jsx23(SelectTrigger, { className: "h-8 w-[150px] text-xs", "aria-label": "Status", children: /* @__PURE__ */ jsx23(SelectValue, {}) }),
3012
+ /* @__PURE__ */ jsx23(SelectContent, { children: EVENT_STATUSES.map((option) => /* @__PURE__ */ jsx23(SelectItem, { value: option, children: option === "all" ? "All statuses" : option }, option)) })
2314
3013
  ]
2315
3014
  }
2316
3015
  ),
2317
- /* @__PURE__ */ jsx22(
3016
+ /* @__PURE__ */ jsx23(
2318
3017
  Input,
2319
3018
  {
2320
3019
  className: "h-8 w-[180px]",
@@ -2326,7 +3025,7 @@ function EventsPage({ context }) {
2326
3025
  value: eventType
2327
3026
  }
2328
3027
  ),
2329
- /* @__PURE__ */ jsx22(
3028
+ /* @__PURE__ */ jsx23(
2330
3029
  Input,
2331
3030
  {
2332
3031
  className: "h-8 w-[180px]",
@@ -2341,21 +3040,21 @@ function EventsPage({ context }) {
2341
3040
  ]
2342
3041
  }
2343
3042
  ),
2344
- error ? /* @__PURE__ */ jsx22(EmptyState, { title: "Unable to inspect event", description: error }) : !hasLoaded && loading ? /* @__PURE__ */ jsx22(
3043
+ error ? /* @__PURE__ */ jsx23(EmptyState, { title: "Unable to inspect event", description: error }) : !hasLoaded && loading ? /* @__PURE__ */ jsx23(
2345
3044
  EmptyState,
2346
3045
  {
2347
3046
  icon: Activity,
2348
3047
  title: "Loading events",
2349
3048
  description: "Fetching recent queue events for the active namespace."
2350
3049
  }
2351
- ) : /* @__PURE__ */ jsxs14("div", { className: "grid gap-4 xl:grid-cols-[1fr_420px]", children: [
2352
- /* @__PURE__ */ jsx22(
3050
+ ) : /* @__PURE__ */ jsxs15("div", { className: "grid gap-4 xl:grid-cols-[1fr_420px]", children: [
3051
+ /* @__PURE__ */ jsx23(
2353
3052
  ResourceTable,
2354
3053
  {
2355
3054
  rows: events,
2356
3055
  getRowKey: (row) => row.id,
2357
3056
  onRowClick: setSelectedEvent,
2358
- empty: /* @__PURE__ */ jsx22(
3057
+ empty: /* @__PURE__ */ jsx23(
2359
3058
  EmptyState,
2360
3059
  {
2361
3060
  title: "No matching events",
@@ -2377,7 +3076,7 @@ function EventsPage({ context }) {
2377
3076
  {
2378
3077
  id: "status",
2379
3078
  header: "Status",
2380
- render: (row) => /* @__PURE__ */ jsx22(StatusBadge, { status: row.status })
3079
+ render: (row) => /* @__PURE__ */ jsx23(StatusBadge, { status: row.status })
2381
3080
  },
2382
3081
  {
2383
3082
  id: "trace",
@@ -2387,19 +3086,19 @@ function EventsPage({ context }) {
2387
3086
  {
2388
3087
  id: "created",
2389
3088
  header: "Created",
2390
- render: (row) => formatDateTime(row.createdAt)
3089
+ render: (row) => formatDateTime2(row.createdAt)
2391
3090
  }
2392
3091
  ]
2393
3092
  }
2394
3093
  ),
2395
- selectedEvent ? /* @__PURE__ */ jsx22(
3094
+ selectedEvent ? /* @__PURE__ */ jsx23(
2396
3095
  JsonPanel,
2397
3096
  {
2398
3097
  title: "Event JSON",
2399
3098
  value: selectedEvent,
2400
3099
  minHeight: 420
2401
3100
  }
2402
- ) : /* @__PURE__ */ jsx22(
3101
+ ) : /* @__PURE__ */ jsx23(
2403
3102
  EmptyState,
2404
3103
  {
2405
3104
  title: "No event selected",
@@ -2409,7 +3108,7 @@ function EventsPage({ context }) {
2409
3108
  ] })
2410
3109
  ] });
2411
3110
  }
2412
- function formatDateTime(value) {
3111
+ function formatDateTime2(value) {
2413
3112
  if (!value) return "-";
2414
3113
  const date = new Date(value);
2415
3114
  if (Number.isNaN(date.getTime())) return value;
@@ -2422,17 +3121,17 @@ function formatDateTime(value) {
2422
3121
  }
2423
3122
 
2424
3123
  // src/modules/overview/index.tsx
2425
- import React9 from "react";
3124
+ import React10 from "react";
2426
3125
  import {
2427
3126
  Activity as Activity2,
2428
3127
  AlertTriangle,
2429
3128
  Bot as Bot2,
2430
3129
  MessageSquare,
2431
- Sparkles,
3130
+ Sparkles as Sparkles2,
2432
3131
  Users,
2433
3132
  Wallet
2434
3133
  } from "lucide-react";
2435
- import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
3134
+ import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
2436
3135
  function overviewModule() {
2437
3136
  return {
2438
3137
  group: "operate",
@@ -2450,17 +3149,17 @@ function overviewModule() {
2450
3149
  routes: [{
2451
3150
  id: "overview",
2452
3151
  title: "Overview",
2453
- render: (context) => /* @__PURE__ */ jsx23(OverviewPage, { context })
3152
+ render: (context) => /* @__PURE__ */ jsx24(OverviewPage, { context })
2454
3153
  }]
2455
3154
  };
2456
3155
  }
2457
3156
  function OverviewPage({ context }) {
2458
- const [overview, setOverview] = React9.useState(null);
2459
- const [threads, setThreads] = React9.useState([]);
2460
- const [agents, setAgents] = React9.useState([]);
2461
- const [error, setError] = React9.useState(null);
2462
- const [isLoading, setIsLoading] = React9.useState(false);
2463
- React9.useEffect(() => {
3157
+ const [overview, setOverview] = React10.useState(null);
3158
+ const [threads, setThreads] = React10.useState([]);
3159
+ const [agents, setAgents] = React10.useState([]);
3160
+ const [error, setError] = React10.useState(null);
3161
+ const [isLoading, setIsLoading] = React10.useState(false);
3162
+ React10.useEffect(() => {
2464
3163
  let active = true;
2465
3164
  setIsLoading(true);
2466
3165
  setError(null);
@@ -2493,11 +3192,11 @@ function OverviewPage({ context }) {
2493
3192
  };
2494
3193
  }, [context.client, context.refreshKey, context.scope.namespace]);
2495
3194
  if (error) {
2496
- return /* @__PURE__ */ jsx23(EmptyState, { title: "Unable to load overview", description: error });
3195
+ return /* @__PURE__ */ jsx24(EmptyState, { title: "Unable to load overview", description: error });
2497
3196
  }
2498
3197
  const queueFailures = (overview?.queueTotals.failed ?? 0) + (overview?.queueTotals.expired ?? 0);
2499
- return /* @__PURE__ */ jsxs15("div", { className: "space-y-4", children: [
2500
- /* @__PURE__ */ jsx23(
3198
+ return /* @__PURE__ */ jsxs16("div", { className: "space-y-4", children: [
3199
+ /* @__PURE__ */ jsx24(
2501
3200
  PageHeader,
2502
3201
  {
2503
3202
  title: "Overview",
@@ -2508,7 +3207,7 @@ function OverviewPage({ context }) {
2508
3207
  ]
2509
3208
  }
2510
3209
  ),
2511
- /* @__PURE__ */ jsx23(
3210
+ /* @__PURE__ */ jsx24(
2512
3211
  MetricStrip,
2513
3212
  {
2514
3213
  items: [
@@ -2532,17 +3231,17 @@ function OverviewPage({ context }) {
2532
3231
  },
2533
3232
  {
2534
3233
  detail: `${formatNumber(queueFailures)} failures/expired`,
2535
- icon: queueFailures > 0 ? AlertTriangle : Sparkles,
3234
+ icon: queueFailures > 0 ? AlertTriangle : Sparkles2,
2536
3235
  label: "Queue",
2537
3236
  value: formatNumber(overview?.queueTotals.total ?? 0)
2538
3237
  }
2539
3238
  ]
2540
3239
  }
2541
3240
  ),
2542
- /* @__PURE__ */ jsxs15("div", { className: "grid gap-4 xl:grid-cols-2", children: [
2543
- /* @__PURE__ */ jsxs15("section", { className: "space-y-3", children: [
2544
- /* @__PURE__ */ jsx23(PageHeader, { title: "Recent Threads" }),
2545
- /* @__PURE__ */ jsx23(
3241
+ /* @__PURE__ */ jsxs16("div", { className: "grid gap-4 xl:grid-cols-2", children: [
3242
+ /* @__PURE__ */ jsxs16("section", { className: "space-y-3", children: [
3243
+ /* @__PURE__ */ jsx24(PageHeader, { title: "Recent Threads" }),
3244
+ /* @__PURE__ */ jsx24(
2546
3245
  ResourceTable,
2547
3246
  {
2548
3247
  rows: threads,
@@ -2552,15 +3251,15 @@ function OverviewPage({ context }) {
2552
3251
  {
2553
3252
  id: "name",
2554
3253
  header: "Thread",
2555
- render: (thread) => /* @__PURE__ */ jsxs15("div", { children: [
2556
- /* @__PURE__ */ jsx23("div", { className: "max-w-md truncate font-medium", children: thread.name || thread.threadId }),
2557
- /* @__PURE__ */ jsx23("div", { className: "max-w-md truncate text-xs text-muted-foreground", children: thread.summary ?? thread.lastMessagePreview ?? "No summary" })
3254
+ render: (thread) => /* @__PURE__ */ jsxs16("div", { children: [
3255
+ /* @__PURE__ */ jsx24("div", { className: "max-w-md truncate font-medium", children: thread.name || thread.threadId }),
3256
+ /* @__PURE__ */ jsx24("div", { className: "max-w-md truncate text-xs text-muted-foreground", children: thread.summary ?? thread.lastMessagePreview ?? "No summary" })
2558
3257
  ] })
2559
3258
  },
2560
3259
  {
2561
3260
  id: "status",
2562
3261
  header: "Status",
2563
- render: (thread) => /* @__PURE__ */ jsx23(StatusBadge, { status: thread.status })
3262
+ render: (thread) => /* @__PURE__ */ jsx24(StatusBadge, { status: thread.status })
2564
3263
  },
2565
3264
  {
2566
3265
  align: "right",
@@ -2572,9 +3271,9 @@ function OverviewPage({ context }) {
2572
3271
  }
2573
3272
  )
2574
3273
  ] }),
2575
- /* @__PURE__ */ jsxs15("section", { className: "space-y-3", children: [
2576
- /* @__PURE__ */ jsx23(PageHeader, { title: "Top Agents" }),
2577
- /* @__PURE__ */ jsx23(
3274
+ /* @__PURE__ */ jsxs16("section", { className: "space-y-3", children: [
3275
+ /* @__PURE__ */ jsx24(PageHeader, { title: "Top Agents" }),
3276
+ /* @__PURE__ */ jsx24(
2578
3277
  ResourceTable,
2579
3278
  {
2580
3279
  rows: agents,
@@ -2584,11 +3283,11 @@ function OverviewPage({ context }) {
2584
3283
  {
2585
3284
  id: "agent",
2586
3285
  header: "Agent",
2587
- render: (agent) => /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2", children: [
2588
- /* @__PURE__ */ jsx23(Bot2, { className: "size-4 text-muted-foreground" }),
2589
- /* @__PURE__ */ jsxs15("div", { children: [
2590
- /* @__PURE__ */ jsx23("div", { className: "font-medium", children: agent.displayName }),
2591
- /* @__PURE__ */ jsx23("div", { className: "text-xs text-muted-foreground", children: agent.agentId })
3286
+ render: (agent) => /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-2", children: [
3287
+ /* @__PURE__ */ jsx24(Bot2, { className: "size-4 text-muted-foreground" }),
3288
+ /* @__PURE__ */ jsxs16("div", { children: [
3289
+ /* @__PURE__ */ jsx24("div", { className: "font-medium", children: agent.displayName }),
3290
+ /* @__PURE__ */ jsx24("div", { className: "text-xs text-muted-foreground", children: agent.agentId })
2592
3291
  ] })
2593
3292
  ] })
2594
3293
  },
@@ -2613,9 +3312,9 @@ function OverviewPage({ context }) {
2613
3312
  }
2614
3313
 
2615
3314
  // src/modules/participants/index.tsx
2616
- import React10 from "react";
3315
+ import React11 from "react";
2617
3316
  import { Users as Users2 } from "lucide-react";
2618
- import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
3317
+ import { jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
2619
3318
  function participantsModule() {
2620
3319
  return {
2621
3320
  group: "data",
@@ -2634,21 +3333,21 @@ function participantsModule() {
2634
3333
  {
2635
3334
  id: "participants",
2636
3335
  title: "Participants",
2637
- render: (context) => /* @__PURE__ */ jsx24(ParticipantsPage, { context })
3336
+ render: (context) => /* @__PURE__ */ jsx25(ParticipantsPage, { context })
2638
3337
  },
2639
3338
  {
2640
3339
  id: "participants.detail",
2641
3340
  title: "Participant Detail",
2642
- render: (context) => /* @__PURE__ */ jsx24(ParticipantDetailPage, { context })
3341
+ render: (context) => /* @__PURE__ */ jsx25(ParticipantDetailPage, { context })
2643
3342
  }
2644
3343
  ]
2645
3344
  };
2646
3345
  }
2647
3346
  function ParticipantsPage({ context }) {
2648
- const [search, setSearch] = React10.useState("");
2649
- const [participants, setParticipants] = React10.useState([]);
2650
- const [error, setError] = React10.useState(null);
2651
- React10.useEffect(() => {
3347
+ const [search, setSearch] = React11.useState("");
3348
+ const [participants, setParticipants] = React11.useState([]);
3349
+ const [error, setError] = React11.useState(null);
3350
+ React11.useEffect(() => {
2652
3351
  let active = true;
2653
3352
  setError(null);
2654
3353
  void context.client.listParticipants({
@@ -2664,15 +3363,15 @@ function ParticipantsPage({ context }) {
2664
3363
  active = false;
2665
3364
  };
2666
3365
  }, [context.client, context.refreshKey, context.scope.namespace, search]);
2667
- return /* @__PURE__ */ jsxs16("div", { className: "space-y-4", children: [
2668
- /* @__PURE__ */ jsx24(
3366
+ return /* @__PURE__ */ jsxs17("div", { className: "space-y-4", children: [
3367
+ /* @__PURE__ */ jsx25(
2669
3368
  PageHeader,
2670
3369
  {
2671
3370
  title: "Participants",
2672
3371
  description: "Humans, agents, and jobs observed by Copilotz across conversations."
2673
3372
  }
2674
3373
  ),
2675
- /* @__PURE__ */ jsx24(
3374
+ /* @__PURE__ */ jsx25(
2676
3375
  FilterBar,
2677
3376
  {
2678
3377
  onSearchChange: setSearch,
@@ -2680,7 +3379,7 @@ function ParticipantsPage({ context }) {
2680
3379
  searchValue: search
2681
3380
  }
2682
3381
  ),
2683
- error ? /* @__PURE__ */ jsx24(EmptyState, { title: "Unable to load participants", description: error }) : /* @__PURE__ */ jsx24(
3382
+ error ? /* @__PURE__ */ jsx25(EmptyState, { title: "Unable to load participants", description: error }) : /* @__PURE__ */ jsx25(
2684
3383
  ResourceTable,
2685
3384
  {
2686
3385
  rows: participants,
@@ -2688,7 +3387,7 @@ function ParticipantsPage({ context }) {
2688
3387
  onRowClick: (participant) => context.navigate("participants.detail", {
2689
3388
  participantId: participant.externalId
2690
3389
  }),
2691
- empty: /* @__PURE__ */ jsx24(
3390
+ empty: /* @__PURE__ */ jsx25(
2692
3391
  EmptyState,
2693
3392
  {
2694
3393
  icon: Users2,
@@ -2700,15 +3399,15 @@ function ParticipantsPage({ context }) {
2700
3399
  {
2701
3400
  id: "participant",
2702
3401
  header: "Participant",
2703
- render: (participant) => /* @__PURE__ */ jsxs16("div", { children: [
2704
- /* @__PURE__ */ jsx24("div", { className: "max-w-md truncate font-medium", children: participant.displayName }),
2705
- /* @__PURE__ */ jsx24("div", { className: "max-w-md truncate text-xs text-muted-foreground", children: participant.externalId })
3402
+ render: (participant) => /* @__PURE__ */ jsxs17("div", { children: [
3403
+ /* @__PURE__ */ jsx25("div", { className: "max-w-md truncate font-medium", children: participant.displayName }),
3404
+ /* @__PURE__ */ jsx25("div", { className: "max-w-md truncate text-xs text-muted-foreground", children: participant.externalId })
2706
3405
  ] })
2707
3406
  },
2708
3407
  {
2709
3408
  id: "type",
2710
3409
  header: "Type",
2711
- render: (participant) => /* @__PURE__ */ jsx24(StatusBadge, { status: participant.participantType })
3410
+ render: (participant) => /* @__PURE__ */ jsx25(StatusBadge, { status: participant.participantType })
2712
3411
  },
2713
3412
  {
2714
3413
  id: "scope",
@@ -2734,9 +3433,9 @@ function ParticipantsPage({ context }) {
2734
3433
  }
2735
3434
  function ParticipantDetailPage({ context }) {
2736
3435
  const participantId = context.route.params?.participantId;
2737
- const [participant, setParticipant] = React10.useState(null);
2738
- const [error, setError] = React10.useState(null);
2739
- React10.useEffect(() => {
3436
+ const [participant, setParticipant] = React11.useState(null);
3437
+ const [error, setError] = React11.useState(null);
3438
+ React11.useEffect(() => {
2740
3439
  if (!participantId) return;
2741
3440
  let active = true;
2742
3441
  setError(null);
@@ -2752,19 +3451,19 @@ function ParticipantDetailPage({ context }) {
2752
3451
  };
2753
3452
  }, [context.client, context.refreshKey, context.scope.namespace, participantId]);
2754
3453
  if (!participantId) {
2755
- return /* @__PURE__ */ jsx24(EmptyState, { title: "Participant not selected" });
3454
+ return /* @__PURE__ */ jsx25(EmptyState, { title: "Participant not selected" });
2756
3455
  }
2757
3456
  if (error) {
2758
- return /* @__PURE__ */ jsx24(EmptyState, { title: "Unable to load participant", description: error });
3457
+ return /* @__PURE__ */ jsx25(EmptyState, { title: "Unable to load participant", description: error });
2759
3458
  }
2760
3459
  const memories = Array.isArray(participant?.memories) ? participant.memories.length : 0;
2761
- return /* @__PURE__ */ jsxs16("div", { className: "space-y-4", children: [
2762
- /* @__PURE__ */ jsx24(
3460
+ return /* @__PURE__ */ jsxs17("div", { className: "space-y-4", children: [
3461
+ /* @__PURE__ */ jsx25(
2763
3462
  PageHeader,
2764
3463
  {
2765
3464
  title: String(participant?.displayName ?? participantId),
2766
3465
  description: "Participant profile, activity-ready metrics, and advanced record data.",
2767
- actions: /* @__PURE__ */ jsx24(
3466
+ actions: /* @__PURE__ */ jsx25(
2768
3467
  "button",
2769
3468
  {
2770
3469
  className: "text-sm text-muted-foreground hover:text-foreground",
@@ -2775,7 +3474,7 @@ function ParticipantDetailPage({ context }) {
2775
3474
  )
2776
3475
  }
2777
3476
  ),
2778
- /* @__PURE__ */ jsx24(
3477
+ /* @__PURE__ */ jsx25(
2779
3478
  MetricStrip,
2780
3479
  {
2781
3480
  items: [
@@ -2785,12 +3484,12 @@ function ParticipantDetailPage({ context }) {
2785
3484
  ]
2786
3485
  }
2787
3486
  ),
2788
- /* @__PURE__ */ jsx24(JsonPanel, { title: "Advanced JSON", value: participant, minHeight: 460 })
3487
+ /* @__PURE__ */ jsx25(JsonPanel, { title: "Advanced JSON", value: participant, minHeight: 460 })
2789
3488
  ] });
2790
3489
  }
2791
3490
 
2792
3491
  // src/modules/threads/index.tsx
2793
- import React11 from "react";
3492
+ import React12 from "react";
2794
3493
  import {
2795
3494
  Bot as Bot3,
2796
3495
  ChevronUp as ChevronUp2,
@@ -2800,7 +3499,7 @@ import {
2800
3499
  User,
2801
3500
  Wrench as Wrench2
2802
3501
  } from "lucide-react";
2803
- import { jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
3502
+ import { jsx as jsx26, jsxs as jsxs18 } from "react/jsx-runtime";
2804
3503
  var MESSAGE_PAGE_SIZE = 50;
2805
3504
  function threadsModule() {
2806
3505
  return {
@@ -2820,22 +3519,22 @@ function threadsModule() {
2820
3519
  {
2821
3520
  id: "threads",
2822
3521
  title: "Threads",
2823
- render: (context) => /* @__PURE__ */ jsx25(ThreadsPage, { context })
3522
+ render: (context) => /* @__PURE__ */ jsx26(ThreadsPage, { context })
2824
3523
  },
2825
3524
  {
2826
3525
  id: "threads.detail",
2827
3526
  title: "Thread Detail",
2828
- render: (context) => /* @__PURE__ */ jsx25(ThreadDetailPage, { context })
3527
+ render: (context) => /* @__PURE__ */ jsx26(ThreadDetailPage, { context })
2829
3528
  }
2830
3529
  ]
2831
3530
  };
2832
3531
  }
2833
3532
  function ThreadsPage({ context }) {
2834
- const [search, setSearch] = React11.useState("");
2835
- const [threads, setThreads] = React11.useState([]);
2836
- const [error, setError] = React11.useState(null);
2837
- const [isLoading, setIsLoading] = React11.useState(false);
2838
- React11.useEffect(() => {
3533
+ const [search, setSearch] = React12.useState("");
3534
+ const [threads, setThreads] = React12.useState([]);
3535
+ const [error, setError] = React12.useState(null);
3536
+ const [isLoading, setIsLoading] = React12.useState(false);
3537
+ React12.useEffect(() => {
2839
3538
  let active = true;
2840
3539
  setIsLoading(true);
2841
3540
  setError(null);
@@ -2854,8 +3553,8 @@ function ThreadsPage({ context }) {
2854
3553
  active = false;
2855
3554
  };
2856
3555
  }, [context.client, context.refreshKey, context.scope.namespace, search]);
2857
- return /* @__PURE__ */ jsxs17("div", { className: "space-y-4", children: [
2858
- /* @__PURE__ */ jsx25(
3556
+ return /* @__PURE__ */ jsxs18("div", { className: "space-y-4", children: [
3557
+ /* @__PURE__ */ jsx26(
2859
3558
  PageHeader,
2860
3559
  {
2861
3560
  title: "Threads",
@@ -2863,7 +3562,7 @@ function ThreadsPage({ context }) {
2863
3562
  badges: isLoading ? [{ label: "Loading" }] : []
2864
3563
  }
2865
3564
  ),
2866
- /* @__PURE__ */ jsx25(
3565
+ /* @__PURE__ */ jsx26(
2867
3566
  FilterBar,
2868
3567
  {
2869
3568
  onSearchChange: setSearch,
@@ -2871,13 +3570,13 @@ function ThreadsPage({ context }) {
2871
3570
  searchValue: search
2872
3571
  }
2873
3572
  ),
2874
- error ? /* @__PURE__ */ jsx25(EmptyState, { title: "Unable to load threads", description: error }) : /* @__PURE__ */ jsx25(
3573
+ error ? /* @__PURE__ */ jsx26(EmptyState, { title: "Unable to load threads", description: error }) : /* @__PURE__ */ jsx26(
2875
3574
  ResourceTable,
2876
3575
  {
2877
3576
  rows: threads,
2878
3577
  getRowKey: (thread) => thread.threadId,
2879
3578
  onRowClick: (thread) => context.navigate("threads.detail", { threadId: thread.threadId }),
2880
- empty: /* @__PURE__ */ jsx25(
3579
+ empty: /* @__PURE__ */ jsx26(
2881
3580
  EmptyState,
2882
3581
  {
2883
3582
  icon: MessageSquare2,
@@ -2889,15 +3588,15 @@ function ThreadsPage({ context }) {
2889
3588
  {
2890
3589
  id: "thread",
2891
3590
  header: "Thread",
2892
- render: (thread) => /* @__PURE__ */ jsxs17("div", { className: "min-w-0", children: [
2893
- /* @__PURE__ */ jsx25("div", { className: "max-w-xl truncate font-medium", children: thread.name || thread.threadId }),
2894
- /* @__PURE__ */ jsx25("div", { className: "max-w-xl truncate text-xs text-muted-foreground", children: thread.summary ?? thread.lastMessagePreview ?? "No summary yet" })
3591
+ render: (thread) => /* @__PURE__ */ jsxs18("div", { className: "min-w-0", children: [
3592
+ /* @__PURE__ */ jsx26("div", { className: "max-w-xl truncate font-medium", children: thread.name || thread.threadId }),
3593
+ /* @__PURE__ */ jsx26("div", { className: "max-w-xl truncate text-xs text-muted-foreground", children: thread.summary ?? thread.lastMessagePreview ?? "No summary yet" })
2895
3594
  ] })
2896
3595
  },
2897
3596
  {
2898
3597
  id: "status",
2899
3598
  header: "Status",
2900
- render: (thread) => /* @__PURE__ */ jsx25(StatusBadge, { status: thread.status })
3599
+ render: (thread) => /* @__PURE__ */ jsx26(StatusBadge, { status: thread.status })
2901
3600
  },
2902
3601
  {
2903
3602
  align: "right",
@@ -2916,7 +3615,7 @@ function ThreadsPage({ context }) {
2916
3615
  {
2917
3616
  id: "activity",
2918
3617
  header: "Last activity",
2919
- render: (thread) => formatDateTime2(thread.lastActivityAt)
3618
+ render: (thread) => formatDateTime3(thread.lastActivityAt)
2920
3619
  }
2921
3620
  ]
2922
3621
  }
@@ -2926,7 +3625,7 @@ function ThreadsPage({ context }) {
2926
3625
  function ThreadDetailPage({ context }) {
2927
3626
  const threadId = context.route.params?.threadId;
2928
3627
  if (!threadId) {
2929
- return /* @__PURE__ */ jsx25(
3628
+ return /* @__PURE__ */ jsx26(
2930
3629
  EmptyState,
2931
3630
  {
2932
3631
  title: "Thread not selected",
@@ -2934,19 +3633,19 @@ function ThreadDetailPage({ context }) {
2934
3633
  }
2935
3634
  );
2936
3635
  }
2937
- return /* @__PURE__ */ jsx25(ThreadInspector, { context, threadId });
3636
+ return /* @__PURE__ */ jsx26(ThreadInspector, { context, threadId });
2938
3637
  }
2939
3638
  function ThreadInspector({
2940
3639
  context,
2941
3640
  threadId
2942
3641
  }) {
2943
- const [thread, setThread] = React11.useState(null);
2944
- const [messages, setMessages] = React11.useState([]);
2945
- const [pageInfo, setPageInfo] = React11.useState(null);
2946
- const [isLoading, setIsLoading] = React11.useState(true);
2947
- const [isLoadingMore, setIsLoadingMore] = React11.useState(false);
2948
- const [error, setError] = React11.useState(null);
2949
- React11.useEffect(() => {
3642
+ const [thread, setThread] = React12.useState(null);
3643
+ const [messages, setMessages] = React12.useState([]);
3644
+ const [pageInfo, setPageInfo] = React12.useState(null);
3645
+ const [isLoading, setIsLoading] = React12.useState(true);
3646
+ const [isLoadingMore, setIsLoadingMore] = React12.useState(false);
3647
+ const [error, setError] = React12.useState(null);
3648
+ React12.useEffect(() => {
2950
3649
  let active = true;
2951
3650
  setIsLoading(true);
2952
3651
  setError(null);
@@ -2987,13 +3686,13 @@ function ThreadInspector({
2987
3686
  }
2988
3687
  };
2989
3688
  if (isLoading) {
2990
- return /* @__PURE__ */ jsx25(EmptyState, { icon: Loader2, title: "Loading thread" });
3689
+ return /* @__PURE__ */ jsx26(EmptyState, { icon: Loader2, title: "Loading thread" });
2991
3690
  }
2992
3691
  if (error) {
2993
- return /* @__PURE__ */ jsx25(EmptyState, { title: "Unable to load thread", description: error });
3692
+ return /* @__PURE__ */ jsx26(EmptyState, { title: "Unable to load thread", description: error });
2994
3693
  }
2995
- return /* @__PURE__ */ jsxs17("div", { className: "space-y-4", children: [
2996
- /* @__PURE__ */ jsx25(
3694
+ return /* @__PURE__ */ jsxs18("div", { className: "space-y-4", children: [
3695
+ /* @__PURE__ */ jsx26(
2997
3696
  PageHeader,
2998
3697
  {
2999
3698
  title: thread?.name ?? threadId,
@@ -3002,7 +3701,7 @@ function ThreadInspector({
3002
3701
  { label: thread?.status ?? "unknown" },
3003
3702
  { label: `${messages.length}${pageInfo?.hasMoreBefore ? "+" : ""} messages`, variant: "secondary" }
3004
3703
  ],
3005
- actions: /* @__PURE__ */ jsx25(
3704
+ actions: /* @__PURE__ */ jsx26(
3006
3705
  Button,
3007
3706
  {
3008
3707
  onClick: () => context.navigate("threads"),
@@ -3014,14 +3713,14 @@ function ThreadInspector({
3014
3713
  )
3015
3714
  }
3016
3715
  ),
3017
- /* @__PURE__ */ jsx25(
3716
+ /* @__PURE__ */ jsx26(
3018
3717
  InspectorPanel,
3019
3718
  {
3020
- side: /* @__PURE__ */ jsx25(JsonPanel, { title: "Thread JSON", value: thread, minHeight: 420 }),
3021
- children: /* @__PURE__ */ jsxs17("div", { className: "overflow-hidden rounded-lg border bg-background", children: [
3022
- /* @__PURE__ */ jsxs17("div", { className: "flex items-center justify-between border-b px-4 py-2", children: [
3023
- /* @__PURE__ */ jsx25("div", { className: "text-sm font-medium", children: "Timeline" }),
3024
- pageInfo?.hasMoreBefore && /* @__PURE__ */ jsxs17(
3719
+ side: /* @__PURE__ */ jsx26(JsonPanel, { title: "Thread JSON", value: thread, minHeight: 420 }),
3720
+ children: /* @__PURE__ */ jsxs18("div", { className: "overflow-hidden rounded-lg border bg-background", children: [
3721
+ /* @__PURE__ */ jsxs18("div", { className: "flex items-center justify-between border-b px-4 py-2", children: [
3722
+ /* @__PURE__ */ jsx26("div", { className: "text-sm font-medium", children: "Timeline" }),
3723
+ pageInfo?.hasMoreBefore && /* @__PURE__ */ jsxs18(
3025
3724
  Button,
3026
3725
  {
3027
3726
  disabled: isLoadingMore,
@@ -3030,51 +3729,51 @@ function ThreadInspector({
3030
3729
  type: "button",
3031
3730
  variant: "ghost",
3032
3731
  children: [
3033
- isLoadingMore ? /* @__PURE__ */ jsx25(Loader2, { className: "size-3 animate-spin" }) : /* @__PURE__ */ jsx25(ChevronUp2, { className: "size-3" }),
3732
+ isLoadingMore ? /* @__PURE__ */ jsx26(Loader2, { className: "size-3 animate-spin" }) : /* @__PURE__ */ jsx26(ChevronUp2, { className: "size-3" }),
3034
3733
  "Load older"
3035
3734
  ]
3036
3735
  }
3037
3736
  )
3038
3737
  ] }),
3039
- messages.length === 0 ? /* @__PURE__ */ jsx25(EmptyState, { title: "No messages", description: "This thread has no messages yet." }) : /* @__PURE__ */ jsx25("div", { className: "divide-y", children: messages.map((message) => /* @__PURE__ */ jsx25(MessageRow, { message }, message.id)) })
3738
+ messages.length === 0 ? /* @__PURE__ */ jsx26(EmptyState, { title: "No messages", description: "This thread has no messages yet." }) : /* @__PURE__ */ jsx26("div", { className: "divide-y", children: messages.map((message) => /* @__PURE__ */ jsx26(MessageRow, { message }, message.id)) })
3040
3739
  ] })
3041
3740
  }
3042
3741
  )
3043
3742
  ] });
3044
3743
  }
3045
3744
  function MessageRow({ message }) {
3046
- const [expanded, setExpanded] = React11.useState(false);
3745
+ const [expanded, setExpanded] = React12.useState(false);
3047
3746
  const hasToolCalls = Array.isArray(message.toolCalls) && message.toolCalls.length > 0;
3048
3747
  const hasReasoning = Boolean(message.reasoning);
3049
3748
  const hasMetadata = Boolean(message.metadata && Object.keys(message.metadata).length);
3050
- return /* @__PURE__ */ jsx25("div", { className: "px-4 py-3", children: /* @__PURE__ */ jsxs17("div", { className: "flex items-start gap-3", children: [
3051
- /* @__PURE__ */ jsx25(SenderIcon, { senderType: message.senderType }),
3052
- /* @__PURE__ */ jsxs17("div", { className: "min-w-0 flex-1", children: [
3053
- /* @__PURE__ */ jsxs17("div", { className: "flex flex-wrap items-center gap-2 text-xs", children: [
3054
- /* @__PURE__ */ jsx25("span", { className: "font-medium", children: message.senderId ?? message.senderUserId ?? message.senderType }),
3055
- /* @__PURE__ */ jsx25(Badge, { variant: "outline", className: "text-[10px]", children: message.senderType }),
3056
- message.targetId && /* @__PURE__ */ jsxs17(Badge, { variant: "secondary", className: "text-[10px]", children: [
3749
+ return /* @__PURE__ */ jsx26("div", { className: "px-4 py-3", children: /* @__PURE__ */ jsxs18("div", { className: "flex items-start gap-3", children: [
3750
+ /* @__PURE__ */ jsx26(SenderIcon, { senderType: message.senderType }),
3751
+ /* @__PURE__ */ jsxs18("div", { className: "min-w-0 flex-1", children: [
3752
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-wrap items-center gap-2 text-xs", children: [
3753
+ /* @__PURE__ */ jsx26("span", { className: "font-medium", children: message.senderId ?? message.senderUserId ?? message.senderType }),
3754
+ /* @__PURE__ */ jsx26(Badge, { variant: "outline", className: "text-[10px]", children: message.senderType }),
3755
+ message.targetId && /* @__PURE__ */ jsxs18(Badge, { variant: "secondary", className: "text-[10px]", children: [
3057
3756
  "to ",
3058
3757
  message.targetId
3059
3758
  ] }),
3060
- message.createdAt && /* @__PURE__ */ jsx25("span", { className: "text-muted-foreground", children: formatDateTime2(message.createdAt) })
3759
+ message.createdAt && /* @__PURE__ */ jsx26("span", { className: "text-muted-foreground", children: formatDateTime3(message.createdAt) })
3061
3760
  ] }),
3062
- message.content && /* @__PURE__ */ jsx25("p", { className: "mt-1 whitespace-pre-wrap break-words text-sm", children: message.content }),
3063
- (hasToolCalls || hasReasoning || hasMetadata) && /* @__PURE__ */ jsxs17("div", { className: "mt-2", children: [
3064
- /* @__PURE__ */ jsxs17(
3761
+ message.content && /* @__PURE__ */ jsx26("p", { className: "mt-1 whitespace-pre-wrap break-words text-sm", children: message.content }),
3762
+ (hasToolCalls || hasReasoning || hasMetadata) && /* @__PURE__ */ jsxs18("div", { className: "mt-2", children: [
3763
+ /* @__PURE__ */ jsxs18(
3065
3764
  "button",
3066
3765
  {
3067
3766
  className: "inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",
3068
3767
  onClick: () => setExpanded((value) => !value),
3069
3768
  type: "button",
3070
3769
  children: [
3071
- hasToolCalls && /* @__PURE__ */ jsx25(Wrench2, { className: "size-3" }),
3072
- hasReasoning && !hasToolCalls && /* @__PURE__ */ jsx25(Cpu, { className: "size-3" }),
3770
+ hasToolCalls && /* @__PURE__ */ jsx26(Wrench2, { className: "size-3" }),
3771
+ hasReasoning && !hasToolCalls && /* @__PURE__ */ jsx26(Cpu, { className: "size-3" }),
3073
3772
  "Details"
3074
3773
  ]
3075
3774
  }
3076
3775
  ),
3077
- expanded && /* @__PURE__ */ jsx25("pre", { className: "mt-2 max-h-72 overflow-auto rounded-md bg-muted p-3 text-xs", children: JSON.stringify({
3776
+ expanded && /* @__PURE__ */ jsx26("pre", { className: "mt-2 max-h-72 overflow-auto rounded-md bg-muted p-3 text-xs", children: JSON.stringify({
3078
3777
  ...hasToolCalls ? { toolCalls: message.toolCalls } : {},
3079
3778
  ...hasReasoning ? { reasoning: message.reasoning } : {},
3080
3779
  ...hasMetadata ? { metadata: message.metadata } : {}
@@ -3087,16 +3786,16 @@ function SenderIcon({ senderType }) {
3087
3786
  const base = "flex size-7 shrink-0 items-center justify-center rounded-full";
3088
3787
  switch (senderType) {
3089
3788
  case "agent":
3090
- return /* @__PURE__ */ jsx25("div", { className: cn(base, "bg-primary/10 text-primary"), children: /* @__PURE__ */ jsx25(Bot3, { className: "size-3.5" }) });
3789
+ return /* @__PURE__ */ jsx26("div", { className: cn(base, "bg-primary/10 text-primary"), children: /* @__PURE__ */ jsx26(Bot3, { className: "size-3.5" }) });
3091
3790
  case "user":
3092
- return /* @__PURE__ */ jsx25("div", { className: cn(base, "bg-secondary text-secondary-foreground"), children: /* @__PURE__ */ jsx25(User, { className: "size-3.5" }) });
3791
+ return /* @__PURE__ */ jsx26("div", { className: cn(base, "bg-secondary text-secondary-foreground"), children: /* @__PURE__ */ jsx26(User, { className: "size-3.5" }) });
3093
3792
  case "tool":
3094
- return /* @__PURE__ */ jsx25("div", { className: cn(base, "bg-muted text-muted-foreground"), children: /* @__PURE__ */ jsx25(Wrench2, { className: "size-3.5" }) });
3793
+ return /* @__PURE__ */ jsx26("div", { className: cn(base, "bg-muted text-muted-foreground"), children: /* @__PURE__ */ jsx26(Wrench2, { className: "size-3.5" }) });
3095
3794
  default:
3096
- return /* @__PURE__ */ jsx25("div", { className: cn(base, "bg-muted text-muted-foreground"), children: /* @__PURE__ */ jsx25(Cpu, { className: "size-3.5" }) });
3795
+ return /* @__PURE__ */ jsx26("div", { className: cn(base, "bg-muted text-muted-foreground"), children: /* @__PURE__ */ jsx26(Cpu, { className: "size-3.5" }) });
3097
3796
  }
3098
3797
  }
3099
- function formatDateTime2(value) {
3798
+ function formatDateTime3(value) {
3100
3799
  if (!value) return "No activity";
3101
3800
  const date = new Date(value);
3102
3801
  if (Number.isNaN(date.getTime())) return value;
@@ -3109,7 +3808,7 @@ function formatDateTime2(value) {
3109
3808
  }
3110
3809
 
3111
3810
  // src/modules/usage/index.tsx
3112
- import React13 from "react";
3811
+ import React14 from "react";
3113
3812
  import {
3114
3813
  Bar,
3115
3814
  BarChart,
@@ -3126,16 +3825,16 @@ import {
3126
3825
  Clock,
3127
3826
  Coins,
3128
3827
  DollarSign,
3129
- Sparkles as Sparkles2
3828
+ Sparkles as Sparkles3
3130
3829
  } from "lucide-react";
3131
3830
 
3132
3831
  // src/components/ui/chart.tsx
3133
- import * as React12 from "react";
3832
+ import * as React13 from "react";
3134
3833
  import * as RechartsPrimitive from "recharts";
3135
- import { jsx as jsx26, jsxs as jsxs18 } from "react/jsx-runtime";
3136
- var ChartContext = React12.createContext(null);
3834
+ import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
3835
+ var ChartContext = React13.createContext(null);
3137
3836
  function useChart() {
3138
- const context = React12.useContext(ChartContext);
3837
+ const context = React13.useContext(ChartContext);
3139
3838
  if (!context) {
3140
3839
  throw new Error("useChart must be used within a ChartContainer");
3141
3840
  }
@@ -3148,9 +3847,9 @@ function ChartContainer({
3148
3847
  children,
3149
3848
  ...props
3150
3849
  }) {
3151
- const uniqueId = React12.useId();
3850
+ const uniqueId = React13.useId();
3152
3851
  const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
3153
- return /* @__PURE__ */ jsx26(ChartContext.Provider, { value: config, children: /* @__PURE__ */ jsxs18(
3852
+ return /* @__PURE__ */ jsx27(ChartContext.Provider, { value: config, children: /* @__PURE__ */ jsxs19(
3154
3853
  "div",
3155
3854
  {
3156
3855
  "data-chart": chartId,
@@ -3160,10 +3859,10 @@ function ChartContainer({
3160
3859
  ),
3161
3860
  ...props,
3162
3861
  children: [
3163
- /* @__PURE__ */ jsx26("style", { children: Object.entries(config).map(([key, item]) => {
3862
+ /* @__PURE__ */ jsx27("style", { children: Object.entries(config).map(([key, item]) => {
3164
3863
  return `[data-chart=${chartId}] { --color-${key}: ${item.color}; }`;
3165
3864
  }).join("\n") }),
3166
- /* @__PURE__ */ jsx26(RechartsPrimitive.ResponsiveContainer, { children })
3865
+ /* @__PURE__ */ jsx27(RechartsPrimitive.ResponsiveContainer, { children })
3167
3866
  ]
3168
3867
  }
3169
3868
  ) });
@@ -3182,7 +3881,7 @@ function ChartTooltipContent({
3182
3881
  const value = typeof item.value === "number" ? item.value : Number(item.value ?? 0);
3183
3882
  return sum + (Number.isFinite(value) ? value : 0);
3184
3883
  }, 0);
3185
- return /* @__PURE__ */ jsxs18(
3884
+ return /* @__PURE__ */ jsxs19(
3186
3885
  "div",
3187
3886
  {
3188
3887
  className: cn(
@@ -3190,28 +3889,28 @@ function ChartTooltipContent({
3190
3889
  className
3191
3890
  ),
3192
3891
  children: [
3193
- /* @__PURE__ */ jsxs18("div", { className: "mb-2 flex items-center justify-between gap-4 border-b pb-2", children: [
3194
- /* @__PURE__ */ jsx26("p", { className: "text-xs font-medium text-muted-foreground", children: labelFormatter ? labelFormatter(label) : label }),
3195
- /* @__PURE__ */ jsx26("p", { className: "text-xs font-semibold text-foreground", children: formatter ? formatter(total) : total })
3892
+ /* @__PURE__ */ jsxs19("div", { className: "mb-2 flex items-center justify-between gap-4 border-b pb-2", children: [
3893
+ /* @__PURE__ */ jsx27("p", { className: "text-xs font-medium text-muted-foreground", children: labelFormatter ? labelFormatter(label) : label }),
3894
+ /* @__PURE__ */ jsx27("p", { className: "text-xs font-semibold text-foreground", children: formatter ? formatter(total) : total })
3196
3895
  ] }),
3197
- /* @__PURE__ */ jsx26("div", { className: "space-y-1.5", children: payload.filter((item) => Number(item.value ?? 0) > 0).map((item) => {
3896
+ /* @__PURE__ */ jsx27("div", { className: "space-y-1.5", children: payload.filter((item) => Number(item.value ?? 0) > 0).map((item) => {
3198
3897
  const key = String(item.dataKey ?? item.name ?? "");
3199
3898
  const itemConfig = config[key];
3200
3899
  const color = item.color ?? itemConfig?.color ?? "currentColor";
3201
- return /* @__PURE__ */ jsxs18(
3900
+ return /* @__PURE__ */ jsxs19(
3202
3901
  "div",
3203
3902
  {
3204
3903
  className: "grid grid-cols-[0.6rem_1fr_auto] items-center gap-2",
3205
3904
  children: [
3206
- /* @__PURE__ */ jsx26(
3905
+ /* @__PURE__ */ jsx27(
3207
3906
  "span",
3208
3907
  {
3209
3908
  className: "size-2 rounded-[2px]",
3210
3909
  style: { backgroundColor: color }
3211
3910
  }
3212
3911
  ),
3213
- /* @__PURE__ */ jsx26("span", { className: "max-w-48 truncate text-muted-foreground", children: itemConfig?.label ?? item.name ?? key }),
3214
- /* @__PURE__ */ jsx26("span", { className: "font-medium text-foreground", children: formatter ? formatter(item.value ?? 0) : item.value })
3912
+ /* @__PURE__ */ jsx27("span", { className: "max-w-48 truncate text-muted-foreground", children: itemConfig?.label ?? item.name ?? key }),
3913
+ /* @__PURE__ */ jsx27("span", { className: "font-medium text-foreground", children: formatter ? formatter(item.value ?? 0) : item.value })
3215
3914
  ]
3216
3915
  },
3217
3916
  key
@@ -3227,11 +3926,11 @@ function ChartLegendContent({
3227
3926
  }) {
3228
3927
  const config = useChart();
3229
3928
  if (!payload?.length) return null;
3230
- return /* @__PURE__ */ jsx26("div", { className: cn("flex flex-wrap items-center gap-x-4 gap-y-2", className), children: payload.map((item) => {
3929
+ return /* @__PURE__ */ jsx27("div", { className: cn("flex flex-wrap items-center gap-x-4 gap-y-2", className), children: payload.map((item) => {
3231
3930
  const key = String(item.dataKey ?? item.value ?? "");
3232
3931
  const itemConfig = config[key];
3233
- return /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2", children: [
3234
- /* @__PURE__ */ jsx26(
3932
+ return /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2", children: [
3933
+ /* @__PURE__ */ jsx27(
3235
3934
  "span",
3236
3935
  {
3237
3936
  className: "size-2 rounded-[2px]",
@@ -3240,13 +3939,13 @@ function ChartLegendContent({
3240
3939
  }
3241
3940
  }
3242
3941
  ),
3243
- /* @__PURE__ */ jsx26("span", { className: "max-w-52 truncate text-xs text-muted-foreground", children: itemConfig?.label ?? item.value ?? key })
3942
+ /* @__PURE__ */ jsx27("span", { className: "max-w-52 truncate text-xs text-muted-foreground", children: itemConfig?.label ?? item.value ?? key })
3244
3943
  ] }, key);
3245
3944
  }) });
3246
3945
  }
3247
3946
 
3248
3947
  // src/modules/usage/index.tsx
3249
- import { Fragment as Fragment2, jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
3948
+ import { Fragment as Fragment2, jsx as jsx28, jsxs as jsxs20 } from "react/jsx-runtime";
3250
3949
  var USAGE_DIMENSIONS = [
3251
3950
  "total",
3252
3951
  "input",
@@ -3288,70 +3987,70 @@ function usageModule() {
3288
3987
  routes: [{
3289
3988
  id: "usage",
3290
3989
  title: "Usage",
3291
- render: (context) => /* @__PURE__ */ jsx27(UsagePage, { context })
3990
+ render: (context) => /* @__PURE__ */ jsx28(UsagePage, { context })
3292
3991
  }]
3293
3992
  };
3294
3993
  }
3295
3994
  function UsagePage({ context }) {
3296
- const [period, setPeriod] = React13.useState(
3995
+ const [period, setPeriod] = React14.useState(
3297
3996
  "7d"
3298
3997
  );
3299
- const [interval, setInterval] = React13.useState("day");
3300
- const [workload, setWorkload] = React13.useState("all");
3301
- const [metricKind, setMetricKind] = React13.useState(
3998
+ const [interval, setInterval] = React14.useState("day");
3999
+ const [workload, setWorkload] = React14.useState("all");
4000
+ const [metricKind, setMetricKind] = React14.useState(
3302
4001
  "calls"
3303
4002
  );
3304
- const [dimension, setDimension] = React13.useState("total");
3305
- const [groupBy, setGroupBy] = React13.useState("kind");
3306
- const [attribution, setAttribution] = React13.useState(
4003
+ const [dimension, setDimension] = React14.useState("total");
4004
+ const [groupBy, setGroupBy] = React14.useState("kind");
4005
+ const [attribution, setAttribution] = React14.useState(
3307
4006
  "initiatedBy"
3308
4007
  );
3309
- const [participantType, setParticipantType] = React13.useState("all");
3310
- const [threadId, setThreadId] = React13.useState("");
3311
- const [participantId, setParticipantId] = React13.useState("");
3312
- const [provider, setProvider] = React13.useState("");
3313
- const [model, setModel] = React13.useState("");
3314
- const [resource, setResource] = React13.useState("");
3315
- const [operation, setOperation] = React13.useState("");
3316
- const [status, setStatus] = React13.useState(
4008
+ const [participantType, setParticipantType] = React14.useState("all");
4009
+ const [threadId, setThreadId] = React14.useState("");
4010
+ const [participantId, setParticipantId] = React14.useState("");
4011
+ const [provider, setProvider] = React14.useState("");
4012
+ const [model, setModel] = React14.useState("");
4013
+ const [resource, setResource] = React14.useState("");
4014
+ const [operation, setOperation] = React14.useState("");
4015
+ const [status, setStatus] = React14.useState(
3317
4016
  "all"
3318
4017
  );
3319
- const [customFrom, setCustomFrom] = React13.useState("");
3320
- const [customTo, setCustomTo] = React13.useState("");
3321
- const [usage, setUsage] = React13.useState(null);
3322
- const [error, setError] = React13.useState(null);
3323
- const [isLoading, setIsLoading] = React13.useState(false);
3324
- const range = React13.useMemo(
4018
+ const [customFrom, setCustomFrom] = React14.useState("");
4019
+ const [customTo, setCustomTo] = React14.useState("");
4020
+ const [usage, setUsage] = React14.useState(null);
4021
+ const [error, setError] = React14.useState(null);
4022
+ const [isLoading, setIsLoading] = React14.useState(false);
4023
+ const range = React14.useMemo(
3325
4024
  () => getUsageRange(period, customFrom, customTo),
3326
4025
  [customFrom, customTo, period]
3327
4026
  );
3328
- const metricOptions = React13.useMemo(
4027
+ const metricOptions = React14.useMemo(
3329
4028
  () => getUsageMetricOptions(workload),
3330
4029
  [workload]
3331
4030
  );
3332
- const groupOptions = React13.useMemo(
4031
+ const groupOptions = React14.useMemo(
3333
4032
  () => getUsageGroupOptions(workload),
3334
4033
  [workload]
3335
4034
  );
3336
4035
  const showLlmFields = workload === "llm";
3337
4036
  const showResourceFields = workload !== "llm";
3338
4037
  const showDimension = metricKind === "tokens" || metricKind === "cost" && workload === "llm";
3339
- React13.useEffect(() => {
4038
+ React14.useEffect(() => {
3340
4039
  if (!metricOptions.includes(metricKind)) {
3341
4040
  setMetricKind(metricOptions[0]);
3342
4041
  }
3343
4042
  }, [metricKind, metricOptions]);
3344
- React13.useEffect(() => {
4043
+ React14.useEffect(() => {
3345
4044
  if (!groupOptions.includes(groupBy)) {
3346
4045
  setGroupBy(groupOptions[0]);
3347
4046
  }
3348
4047
  }, [groupBy, groupOptions]);
3349
- React13.useEffect(() => {
4048
+ React14.useEffect(() => {
3350
4049
  if (!showDimension && dimension !== "total") {
3351
4050
  setDimension("total");
3352
4051
  }
3353
4052
  }, [dimension, showDimension]);
3354
- React13.useEffect(() => {
4053
+ React14.useEffect(() => {
3355
4054
  let active = true;
3356
4055
  setIsLoading(true);
3357
4056
  setError(null);
@@ -3409,16 +4108,16 @@ function UsagePage({ context }) {
3409
4108
  ]);
3410
4109
  const points = usage?.points ?? [];
3411
4110
  const totals = usage?.totals ?? EMPTY_USAGE_TOTALS;
3412
- const chartState = React13.useMemo(
4111
+ const chartState = React14.useMemo(
3413
4112
  () => buildUsageChartState(points, metricKind, dimension, interval),
3414
4113
  [dimension, interval, metricKind, points]
3415
4114
  );
3416
- const rows = React13.useMemo(
4115
+ const rows = React14.useMemo(
3417
4116
  () => aggregateUsageRows(points, metricKind, dimension),
3418
4117
  [dimension, metricKind, points]
3419
4118
  );
3420
- return /* @__PURE__ */ jsxs19("div", { className: "space-y-4", children: [
3421
- /* @__PURE__ */ jsx27(
4119
+ return /* @__PURE__ */ jsxs20("div", { className: "space-y-4", children: [
4120
+ /* @__PURE__ */ jsx28(
3422
4121
  PageHeader,
3423
4122
  {
3424
4123
  title: "Usage",
@@ -3431,8 +4130,8 @@ function UsagePage({ context }) {
3431
4130
  ]
3432
4131
  }
3433
4132
  ),
3434
- /* @__PURE__ */ jsxs19(FilterBar, { children: [
3435
- /* @__PURE__ */ jsx27(
4133
+ /* @__PURE__ */ jsxs20(FilterBar, { children: [
4134
+ /* @__PURE__ */ jsx28(
3436
4135
  UsageSelect,
3437
4136
  {
3438
4137
  label: "Period",
@@ -3441,7 +4140,7 @@ function UsagePage({ context }) {
3441
4140
  value: period
3442
4141
  }
3443
4142
  ),
3444
- /* @__PURE__ */ jsx27(
4143
+ /* @__PURE__ */ jsx28(
3445
4144
  UsageSelect,
3446
4145
  {
3447
4146
  label: "Bucket",
@@ -3450,7 +4149,7 @@ function UsagePage({ context }) {
3450
4149
  value: interval
3451
4150
  }
3452
4151
  ),
3453
- /* @__PURE__ */ jsx27(
4152
+ /* @__PURE__ */ jsx28(
3454
4153
  UsageSelect,
3455
4154
  {
3456
4155
  label: "Workload",
@@ -3460,7 +4159,7 @@ function UsagePage({ context }) {
3460
4159
  formatOption: getUsageKindLabel
3461
4160
  }
3462
4161
  ),
3463
- /* @__PURE__ */ jsx27(
4162
+ /* @__PURE__ */ jsx28(
3464
4163
  UsageSelect,
3465
4164
  {
3466
4165
  label: "Measure",
@@ -3470,7 +4169,7 @@ function UsagePage({ context }) {
3470
4169
  formatOption: getUsageMetricLabel
3471
4170
  }
3472
4171
  ),
3473
- /* @__PURE__ */ jsx27(
4172
+ /* @__PURE__ */ jsx28(
3474
4173
  UsageSelect,
3475
4174
  {
3476
4175
  label: "Group",
@@ -3480,7 +4179,7 @@ function UsagePage({ context }) {
3480
4179
  formatOption: getUsageGroupLabel
3481
4180
  }
3482
4181
  ),
3483
- /* @__PURE__ */ jsx27(
4182
+ /* @__PURE__ */ jsx28(
3484
4183
  UsageSelect,
3485
4184
  {
3486
4185
  label: "Actor",
@@ -3490,7 +4189,7 @@ function UsagePage({ context }) {
3490
4189
  formatOption: getUsageAttributionLabel
3491
4190
  }
3492
4191
  ),
3493
- showDimension && /* @__PURE__ */ jsx27(
4192
+ showDimension && /* @__PURE__ */ jsx28(
3494
4193
  UsageSelect,
3495
4194
  {
3496
4195
  label: "Dimension",
@@ -3501,9 +4200,9 @@ function UsagePage({ context }) {
3501
4200
  }
3502
4201
  )
3503
4202
  ] }),
3504
- /* @__PURE__ */ jsxs19(FilterBar, { children: [
3505
- period === "custom" && /* @__PURE__ */ jsxs19(Fragment2, { children: [
3506
- /* @__PURE__ */ jsx27(
4203
+ /* @__PURE__ */ jsxs20(FilterBar, { children: [
4204
+ period === "custom" && /* @__PURE__ */ jsxs20(Fragment2, { children: [
4205
+ /* @__PURE__ */ jsx28(
3507
4206
  Input,
3508
4207
  {
3509
4208
  className: "h-8 w-[190px]",
@@ -3512,7 +4211,7 @@ function UsagePage({ context }) {
3512
4211
  value: customFrom
3513
4212
  }
3514
4213
  ),
3515
- /* @__PURE__ */ jsx27(
4214
+ /* @__PURE__ */ jsx28(
3516
4215
  Input,
3517
4216
  {
3518
4217
  className: "h-8 w-[190px]",
@@ -3522,7 +4221,7 @@ function UsagePage({ context }) {
3522
4221
  }
3523
4222
  )
3524
4223
  ] }),
3525
- /* @__PURE__ */ jsx27(
4224
+ /* @__PURE__ */ jsx28(
3526
4225
  UsageSelect,
3527
4226
  {
3528
4227
  label: "Actor type",
@@ -3531,7 +4230,7 @@ function UsagePage({ context }) {
3531
4230
  value: participantType
3532
4231
  }
3533
4232
  ),
3534
- /* @__PURE__ */ jsx27(
4233
+ /* @__PURE__ */ jsx28(
3535
4234
  UsageSelect,
3536
4235
  {
3537
4236
  label: "Status",
@@ -3540,7 +4239,7 @@ function UsagePage({ context }) {
3540
4239
  value: status
3541
4240
  }
3542
4241
  ),
3543
- /* @__PURE__ */ jsx27(
4242
+ /* @__PURE__ */ jsx28(
3544
4243
  Input,
3545
4244
  {
3546
4245
  className: "h-8 w-[170px]",
@@ -3549,7 +4248,7 @@ function UsagePage({ context }) {
3549
4248
  value: threadId
3550
4249
  }
3551
4250
  ),
3552
- /* @__PURE__ */ jsx27(
4251
+ /* @__PURE__ */ jsx28(
3553
4252
  Input,
3554
4253
  {
3555
4254
  className: "h-8 w-[170px]",
@@ -3558,8 +4257,8 @@ function UsagePage({ context }) {
3558
4257
  value: participantId
3559
4258
  }
3560
4259
  ),
3561
- showResourceFields && /* @__PURE__ */ jsxs19(Fragment2, { children: [
3562
- /* @__PURE__ */ jsx27(
4260
+ showResourceFields && /* @__PURE__ */ jsxs20(Fragment2, { children: [
4261
+ /* @__PURE__ */ jsx28(
3563
4262
  Input,
3564
4263
  {
3565
4264
  className: "h-8 w-[170px]",
@@ -3568,7 +4267,7 @@ function UsagePage({ context }) {
3568
4267
  value: resource
3569
4268
  }
3570
4269
  ),
3571
- /* @__PURE__ */ jsx27(
4270
+ /* @__PURE__ */ jsx28(
3572
4271
  Input,
3573
4272
  {
3574
4273
  className: "h-8 w-[150px]",
@@ -3578,8 +4277,8 @@ function UsagePage({ context }) {
3578
4277
  }
3579
4278
  )
3580
4279
  ] }),
3581
- showLlmFields && /* @__PURE__ */ jsxs19(Fragment2, { children: [
3582
- /* @__PURE__ */ jsx27(
4280
+ showLlmFields && /* @__PURE__ */ jsxs20(Fragment2, { children: [
4281
+ /* @__PURE__ */ jsx28(
3583
4282
  Input,
3584
4283
  {
3585
4284
  className: "h-8 w-[140px]",
@@ -3588,7 +4287,7 @@ function UsagePage({ context }) {
3588
4287
  value: provider
3589
4288
  }
3590
4289
  ),
3591
- /* @__PURE__ */ jsx27(
4290
+ /* @__PURE__ */ jsx28(
3592
4291
  Input,
3593
4292
  {
3594
4293
  className: "h-8 w-[140px]",
@@ -3599,7 +4298,7 @@ function UsagePage({ context }) {
3599
4298
  )
3600
4299
  ] })
3601
4300
  ] }),
3602
- /* @__PURE__ */ jsx27(
4301
+ /* @__PURE__ */ jsx28(
3603
4302
  MetricStrip,
3604
4303
  {
3605
4304
  items: [
@@ -3623,7 +4322,7 @@ function UsagePage({ context }) {
3623
4322
  },
3624
4323
  {
3625
4324
  detail: `${formatMetricValue(totals.inputTokens, "tokens")} input`,
3626
- icon: Sparkles2,
4325
+ icon: Sparkles3,
3627
4326
  label: "Tokens",
3628
4327
  value: formatMetricValue(totals.totalTokens, "tokens")
3629
4328
  },
@@ -3642,15 +4341,15 @@ function UsagePage({ context }) {
3642
4341
  ]
3643
4342
  }
3644
4343
  ),
3645
- error ? /* @__PURE__ */ jsx27(EmptyState, { title: "Unable to load usage", description: error }) : chartState.data.length === 0 ? /* @__PURE__ */ jsx27(
4344
+ error ? /* @__PURE__ */ jsx28(EmptyState, { title: "Unable to load usage", description: error }) : chartState.data.length === 0 ? /* @__PURE__ */ jsx28(
3646
4345
  EmptyState,
3647
4346
  {
3648
4347
  title: "No usage",
3649
4348
  description: "Metered LLM, tool, and resource records will appear here after work is captured in the usage ledger."
3650
4349
  }
3651
- ) : /* @__PURE__ */ jsxs19(Fragment2, { children: [
3652
- /* @__PURE__ */ jsx27(Card, { className: "h-[320px] py-3", children: /* @__PURE__ */ jsx27(CardContent, { className: "h-full px-3", children: /* @__PURE__ */ jsx27(UsageChart, { chartState, metricKind }) }) }),
3653
- /* @__PURE__ */ jsx27(
4350
+ ) : /* @__PURE__ */ jsxs20(Fragment2, { children: [
4351
+ /* @__PURE__ */ jsx28(Card, { className: "h-[320px] py-3", children: /* @__PURE__ */ jsx28(CardContent, { className: "h-full px-3", children: /* @__PURE__ */ jsx28(UsageChart, { chartState, metricKind }) }) }),
4352
+ /* @__PURE__ */ jsx28(
3654
4353
  UsageRowsTable,
3655
4354
  {
3656
4355
  dimension,
@@ -3670,19 +4369,19 @@ function UsageSelect({
3670
4369
  options,
3671
4370
  value
3672
4371
  }) {
3673
- return /* @__PURE__ */ jsxs19(Select, { value, onValueChange, children: [
3674
- /* @__PURE__ */ jsx27(SelectTrigger, { className: "h-8 w-[132px] text-xs", "aria-label": label, children: /* @__PURE__ */ jsx27(SelectValue, {}) }),
3675
- /* @__PURE__ */ jsx27(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx27(SelectItem, { value: option, children: formatOption ? formatOption(option) : option }, option)) })
4372
+ return /* @__PURE__ */ jsxs20(Select, { value, onValueChange, children: [
4373
+ /* @__PURE__ */ jsx28(SelectTrigger, { className: "h-8 w-[132px] text-xs", "aria-label": label, children: /* @__PURE__ */ jsx28(SelectValue, {}) }),
4374
+ /* @__PURE__ */ jsx28(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx28(SelectItem, { value: option, children: formatOption ? formatOption(option) : option }, option)) })
3676
4375
  ] });
3677
4376
  }
3678
4377
  function UsageChart({
3679
4378
  chartState,
3680
4379
  metricKind
3681
4380
  }) {
3682
- return /* @__PURE__ */ jsx27(ChartContainer, { className: "h-full w-full", config: chartState.config, children: /* @__PURE__ */ jsxs19(BarChart, { accessibilityLayer: true, data: chartState.data, margin: { left: 8, right: 8, top: 12 }, children: [
3683
- /* @__PURE__ */ jsx27(CartesianGrid, { vertical: false }),
3684
- /* @__PURE__ */ jsx27(XAxis, { dataKey: "label", tickLine: false, axisLine: false, tickMargin: 10 }),
3685
- /* @__PURE__ */ jsx27(
4381
+ return /* @__PURE__ */ jsx28(ChartContainer, { className: "h-full w-full", config: chartState.config, children: /* @__PURE__ */ jsxs20(BarChart, { accessibilityLayer: true, data: chartState.data, margin: { left: 8, right: 8, top: 12 }, children: [
4382
+ /* @__PURE__ */ jsx28(CartesianGrid, { vertical: false }),
4383
+ /* @__PURE__ */ jsx28(XAxis, { dataKey: "label", tickLine: false, axisLine: false, tickMargin: 10 }),
4384
+ /* @__PURE__ */ jsx28(
3686
4385
  YAxis,
3687
4386
  {
3688
4387
  axisLine: false,
@@ -3691,10 +4390,10 @@ function UsageChart({
3691
4390
  width: 64
3692
4391
  }
3693
4392
  ),
3694
- /* @__PURE__ */ jsx27(
4393
+ /* @__PURE__ */ jsx28(
3695
4394
  RechartsTooltip,
3696
4395
  {
3697
- content: /* @__PURE__ */ jsx27(
4396
+ content: /* @__PURE__ */ jsx28(
3698
4397
  ChartTooltipContent,
3699
4398
  {
3700
4399
  formatter: (value) => formatMetricValue(Number(value), metricKind),
@@ -3704,8 +4403,8 @@ function UsageChart({
3704
4403
  cursor: false
3705
4404
  }
3706
4405
  ),
3707
- /* @__PURE__ */ jsx27(Legend, { content: /* @__PURE__ */ jsx27(ChartLegendContent, { className: "justify-center pt-3" }) }),
3708
- chartState.series.map((series) => /* @__PURE__ */ jsx27(
4406
+ /* @__PURE__ */ jsx28(Legend, { content: /* @__PURE__ */ jsx28(ChartLegendContent, { className: "justify-center pt-3" }) }),
4407
+ chartState.series.map((series) => /* @__PURE__ */ jsx28(
3709
4408
  Bar,
3710
4409
  {
3711
4410
  dataKey: series.id,
@@ -3726,7 +4425,7 @@ function UsageRowsTable({
3726
4425
  }) {
3727
4426
  const totalValue = getUsageTotalValue(totals, metricKind, dimension);
3728
4427
  const valueHeader = (metricKind === "tokens" || metricKind === "cost") && dimension !== "total" ? `${getUsageDimensionLabel(dimension)} ${getUsageMetricLabel(metricKind)}` : getUsageMetricLabel(metricKind);
3729
- return /* @__PURE__ */ jsx27(
4428
+ return /* @__PURE__ */ jsx28(
3730
4429
  ResourceTable,
3731
4430
  {
3732
4431
  rows: rows.slice(0, 80),
@@ -3735,9 +4434,9 @@ function UsageRowsTable({
3735
4434
  {
3736
4435
  id: "group",
3737
4436
  header: getUsageGroupLabel(groupBy),
3738
- render: (row) => /* @__PURE__ */ jsxs19("div", { className: "min-w-0", children: [
3739
- /* @__PURE__ */ jsx27("div", { className: "max-w-80 truncate font-medium", children: row.groupLabel }),
3740
- row.groupKey !== row.groupLabel && /* @__PURE__ */ jsx27("div", { className: "max-w-80 truncate text-xs text-muted-foreground", children: row.groupKey })
4437
+ render: (row) => /* @__PURE__ */ jsxs20("div", { className: "min-w-0", children: [
4438
+ /* @__PURE__ */ jsx28("div", { className: "max-w-80 truncate font-medium", children: row.groupLabel }),
4439
+ row.groupKey !== row.groupLabel && /* @__PURE__ */ jsx28("div", { className: "max-w-80 truncate text-xs text-muted-foreground", children: row.groupKey })
3741
4440
  ] })
3742
4441
  },
3743
4442
  {
@@ -3866,6 +4565,7 @@ function defaultCopilotzModules() {
3866
4565
  usageModule(),
3867
4566
  eventsModule(),
3868
4567
  threadsModule(),
4568
+ brainModule(),
3869
4569
  agentsModule(),
3870
4570
  participantsModule(),
3871
4571
  collectionsModule()
@@ -3946,13 +4646,13 @@ function firstAccessibleRoute(modules, permissions) {
3946
4646
 
3947
4647
  // src/core/scope.tsx
3948
4648
  import { createContext as createContext3, useContext as useContext3 } from "react";
3949
- import { jsx as jsx28 } from "react/jsx-runtime";
4649
+ import { jsx as jsx29 } from "react/jsx-runtime";
3950
4650
  var AdminContext = createContext3(null);
3951
4651
  function AdminProvider({
3952
4652
  children,
3953
4653
  value
3954
4654
  }) {
3955
- return /* @__PURE__ */ jsx28(AdminContext.Provider, { value, children });
4655
+ return /* @__PURE__ */ jsx29(AdminContext.Provider, { value, children });
3956
4656
  }
3957
4657
  function useAdmin() {
3958
4658
  const context = useContext3(AdminContext);
@@ -3963,7 +4663,7 @@ function useAdmin() {
3963
4663
  }
3964
4664
 
3965
4665
  // src/core/CopilotzAdmin.tsx
3966
- import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
4666
+ import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
3967
4667
  var DEFAULT_BRANDING = {
3968
4668
  title: "Copilotz Admin",
3969
4669
  subtitle: "Operate and configure Copilotz projects",
@@ -4063,7 +4763,7 @@ function CopilotzAdmin({
4063
4763
  scope,
4064
4764
  setNamespace: setNamespaceState
4065
4765
  };
4066
- return /* @__PURE__ */ jsx29(AdminProvider, { value: runtime, children: /* @__PURE__ */ jsx29(TooltipProvider, { children: /* @__PURE__ */ jsx29(SidebarProvider, { defaultOpen: true, children: /* @__PURE__ */ jsxs20(
4766
+ return /* @__PURE__ */ jsx30(AdminProvider, { value: runtime, children: /* @__PURE__ */ jsx30(TooltipProvider, { children: /* @__PURE__ */ jsx30(SidebarProvider, { defaultOpen: true, children: /* @__PURE__ */ jsxs21(
4067
4767
  "div",
4068
4768
  {
4069
4769
  className: cn(
@@ -4071,7 +4771,7 @@ function CopilotzAdmin({
4071
4771
  className
4072
4772
  ),
4073
4773
  children: [
4074
- /* @__PURE__ */ jsx29(
4774
+ /* @__PURE__ */ jsx30(
4075
4775
  AdminShellSidebar,
4076
4776
  {
4077
4777
  branding,
@@ -4083,8 +4783,8 @@ function CopilotzAdmin({
4083
4783
  scopeOptions: scope.availableNamespaces
4084
4784
  }
4085
4785
  ),
4086
- /* @__PURE__ */ jsx29(SidebarInset, { children: /* @__PURE__ */ jsxs20("div", { className: "flex h-full min-h-0 flex-col", children: [
4087
- /* @__PURE__ */ jsx29(
4786
+ /* @__PURE__ */ jsx30(SidebarInset, { children: /* @__PURE__ */ jsxs21("div", { className: "flex h-full min-h-0 flex-col", children: [
4787
+ /* @__PURE__ */ jsx30(
4088
4788
  AdminShellHeader,
4089
4789
  {
4090
4790
  brandingActions: branding.actions,
@@ -4093,7 +4793,7 @@ function CopilotzAdmin({
4093
4793
  title: activeRoute?.title ?? "Admin"
4094
4794
  }
4095
4795
  ),
4096
- /* @__PURE__ */ jsx29("main", { className: "min-h-0 flex-1 overflow-auto bg-muted/20", children: /* @__PURE__ */ jsx29("div", { className: "mx-auto flex w-full max-w-[1600px] flex-col gap-4 p-4 lg:p-5", children: activeRoute ? activeRoute.render(runtime) : /* @__PURE__ */ jsx29("div", { className: "rounded-lg border bg-background p-8 text-sm text-muted-foreground", children: "No accessible admin route is configured." }) }) })
4796
+ /* @__PURE__ */ jsx30("main", { className: "min-h-0 flex-1 overflow-auto bg-muted/20", children: /* @__PURE__ */ jsx30("div", { className: "mx-auto flex w-full max-w-[1600px] flex-col gap-4 p-4 lg:p-5", children: activeRoute ? activeRoute.render(runtime) : /* @__PURE__ */ jsx30("div", { className: "rounded-lg border bg-background p-8 text-sm text-muted-foreground", children: "No accessible admin route is configured." }) }) })
4097
4797
  ] }) })
4098
4798
  ]
4099
4799
  }
@@ -4112,57 +4812,57 @@ function AdminShellSidebar({
4112
4812
  group,
4113
4813
  items: navItems.filter((item) => (item.group ?? "extensions") === group)
4114
4814
  })).filter((entry) => entry.items.length > 0);
4115
- return /* @__PURE__ */ jsxs20(Sidebar, { collapsible: "icon", children: [
4116
- /* @__PURE__ */ jsx29(SidebarHeader, { children: /* @__PURE__ */ jsxs20("div", { className: "flex items-center gap-3 px-2 py-3", children: [
4117
- /* @__PURE__ */ jsx29("div", { className: "flex size-8 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground", children: branding.logo ?? /* @__PURE__ */ jsx29(Bot4, { className: "size-4" }) }),
4118
- /* @__PURE__ */ jsxs20("div", { className: "min-w-0 group-data-[collapsible=icon]:hidden", children: [
4119
- /* @__PURE__ */ jsx29("div", { className: "truncate text-sm font-semibold", children: branding.title }),
4120
- /* @__PURE__ */ jsx29("div", { className: "truncate text-xs text-muted-foreground", children: branding.subtitle })
4815
+ return /* @__PURE__ */ jsxs21(Sidebar, { collapsible: "icon", children: [
4816
+ /* @__PURE__ */ jsx30(SidebarHeader, { children: /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-3 px-2 py-3", children: [
4817
+ /* @__PURE__ */ jsx30("div", { className: "flex size-8 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground", children: branding.logo ?? /* @__PURE__ */ jsx30(Bot4, { className: "size-4" }) }),
4818
+ /* @__PURE__ */ jsxs21("div", { className: "min-w-0 group-data-[collapsible=icon]:hidden", children: [
4819
+ /* @__PURE__ */ jsx30("div", { className: "truncate text-sm font-semibold", children: branding.title }),
4820
+ /* @__PURE__ */ jsx30("div", { className: "truncate text-xs text-muted-foreground", children: branding.subtitle })
4121
4821
  ] })
4122
4822
  ] }) }),
4123
- /* @__PURE__ */ jsx29(SidebarContent, { children: grouped.map(({ group, items }, index) => /* @__PURE__ */ jsxs20(React15.Fragment, { children: [
4124
- index > 0 && /* @__PURE__ */ jsx29(SidebarSeparator, {}),
4125
- /* @__PURE__ */ jsxs20(SidebarGroup, { children: [
4126
- /* @__PURE__ */ jsx29(SidebarGroupLabel, { className: "group-data-[collapsible=icon]:hidden", children: ADMIN_GROUP_LABELS[group] }),
4127
- /* @__PURE__ */ jsx29(SidebarGroupContent, { children: /* @__PURE__ */ jsx29(SidebarMenu, { children: items.map((item) => {
4823
+ /* @__PURE__ */ jsx30(SidebarContent, { children: grouped.map(({ group, items }, index) => /* @__PURE__ */ jsxs21(React16.Fragment, { children: [
4824
+ index > 0 && /* @__PURE__ */ jsx30(SidebarSeparator, {}),
4825
+ /* @__PURE__ */ jsxs21(SidebarGroup, { children: [
4826
+ /* @__PURE__ */ jsx30(SidebarGroupLabel, { className: "group-data-[collapsible=icon]:hidden", children: ADMIN_GROUP_LABELS[group] }),
4827
+ /* @__PURE__ */ jsx30(SidebarGroupContent, { children: /* @__PURE__ */ jsx30(SidebarMenu, { children: items.map((item) => {
4128
4828
  const Icon2 = item.icon ?? LayoutDashboard;
4129
- return /* @__PURE__ */ jsx29(SidebarMenuItem, { children: /* @__PURE__ */ jsxs20(
4829
+ return /* @__PURE__ */ jsx30(SidebarMenuItem, { children: /* @__PURE__ */ jsxs21(
4130
4830
  SidebarMenuButton,
4131
4831
  {
4132
4832
  isActive: route.routeId === item.routeId,
4133
4833
  onClick: () => onNavigate(item.routeId),
4134
4834
  tooltip: item.label,
4135
4835
  children: [
4136
- /* @__PURE__ */ jsx29(Icon2, {}),
4137
- /* @__PURE__ */ jsx29("span", { children: item.label })
4836
+ /* @__PURE__ */ jsx30(Icon2, {}),
4837
+ /* @__PURE__ */ jsx30("span", { children: item.label })
4138
4838
  ]
4139
4839
  }
4140
4840
  ) }, item.id);
4141
4841
  }) }) })
4142
4842
  ] })
4143
4843
  ] }, group)) }),
4144
- /* @__PURE__ */ jsxs20(SidebarFooter, { children: [
4145
- /* @__PURE__ */ jsxs20("div", { className: "group-data-[collapsible=icon]:hidden", children: [
4146
- /* @__PURE__ */ jsx29("label", { className: "mb-1 block px-2 text-xs font-medium text-muted-foreground", children: "Namespace" }),
4147
- /* @__PURE__ */ jsxs20(
4844
+ /* @__PURE__ */ jsxs21(SidebarFooter, { children: [
4845
+ /* @__PURE__ */ jsxs21("div", { className: "group-data-[collapsible=icon]:hidden", children: [
4846
+ /* @__PURE__ */ jsx30("label", { className: "mb-1 block px-2 text-xs font-medium text-muted-foreground", children: "Namespace" }),
4847
+ /* @__PURE__ */ jsxs21(
4148
4848
  Select,
4149
4849
  {
4150
4850
  value: namespace || "__all__",
4151
4851
  onValueChange: (value) => onNamespaceChange(value === "__all__" ? "" : value),
4152
4852
  children: [
4153
- /* @__PURE__ */ jsx29(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsx29(SelectValue, { placeholder: "All namespaces" }) }),
4154
- /* @__PURE__ */ jsxs20(SelectContent, { children: [
4155
- /* @__PURE__ */ jsx29(SelectItem, { value: "__all__", children: "All namespaces" }),
4156
- scopeOptions?.map((option) => /* @__PURE__ */ jsx29(SelectItem, { value: option.id, children: option.label ?? option.id }, option.id)),
4157
- namespace && !scopeOptions?.some((option) => option.id === namespace) && /* @__PURE__ */ jsx29(SelectItem, { value: namespace, children: namespace })
4853
+ /* @__PURE__ */ jsx30(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsx30(SelectValue, { placeholder: "All namespaces" }) }),
4854
+ /* @__PURE__ */ jsxs21(SelectContent, { children: [
4855
+ /* @__PURE__ */ jsx30(SelectItem, { value: "__all__", children: "All namespaces" }),
4856
+ scopeOptions?.map((option) => /* @__PURE__ */ jsx30(SelectItem, { value: option.id, children: option.label ?? option.id }, option.id)),
4857
+ namespace && !scopeOptions?.some((option) => option.id === namespace) && /* @__PURE__ */ jsx30(SelectItem, { value: namespace, children: namespace })
4158
4858
  ] })
4159
4859
  ]
4160
4860
  }
4161
4861
  )
4162
4862
  ] }),
4163
- /* @__PURE__ */ jsx29("div", { className: "hidden justify-center group-data-[collapsible=icon]:flex", children: /* @__PURE__ */ jsx29(ChevronsUpDown, { className: "size-4 text-muted-foreground" }) })
4863
+ /* @__PURE__ */ jsx30("div", { className: "hidden justify-center group-data-[collapsible=icon]:flex", children: /* @__PURE__ */ jsx30(ChevronsUpDown, { className: "size-4 text-muted-foreground" }) })
4164
4864
  ] }),
4165
- /* @__PURE__ */ jsx29(SidebarRail, {})
4865
+ /* @__PURE__ */ jsx30(SidebarRail, {})
4166
4866
  ] });
4167
4867
  }
4168
4868
  function AdminShellHeader({
@@ -4171,17 +4871,17 @@ function AdminShellHeader({
4171
4871
  onRefresh,
4172
4872
  title
4173
4873
  }) {
4174
- return /* @__PURE__ */ jsxs20("header", { className: "flex min-h-12 shrink-0 items-center gap-2 border-b bg-background/95 px-3 backdrop-blur supports-[backdrop-filter]:bg-background/80", children: [
4175
- /* @__PURE__ */ jsxs20(Tooltip, { children: [
4176
- /* @__PURE__ */ jsx29(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx29(SidebarTrigger, { className: "-ml-1" }) }),
4177
- /* @__PURE__ */ jsx29(TooltipContent, { children: "Toggle sidebar" })
4874
+ return /* @__PURE__ */ jsxs21("header", { className: "flex min-h-12 shrink-0 items-center gap-2 border-b bg-background/95 px-3 backdrop-blur supports-[backdrop-filter]:bg-background/80", children: [
4875
+ /* @__PURE__ */ jsxs21(Tooltip, { children: [
4876
+ /* @__PURE__ */ jsx30(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx30(SidebarTrigger, { className: "-ml-1" }) }),
4877
+ /* @__PURE__ */ jsx30(TooltipContent, { children: "Toggle sidebar" })
4178
4878
  ] }),
4179
- /* @__PURE__ */ jsxs20("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
4180
- /* @__PURE__ */ jsx29(Database2, { className: "size-4 text-muted-foreground" }),
4181
- /* @__PURE__ */ jsx29("h1", { className: "truncate text-sm font-medium", children: title })
4879
+ /* @__PURE__ */ jsxs21("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
4880
+ /* @__PURE__ */ jsx30(Database2, { className: "size-4 text-muted-foreground" }),
4881
+ /* @__PURE__ */ jsx30("h1", { className: "truncate text-sm font-medium", children: title })
4182
4882
  ] }),
4183
- /* @__PURE__ */ jsxs20(Tooltip, { children: [
4184
- /* @__PURE__ */ jsx29(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx29(
4883
+ /* @__PURE__ */ jsxs21(Tooltip, { children: [
4884
+ /* @__PURE__ */ jsx30(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx30(
4185
4885
  Button,
4186
4886
  {
4187
4887
  className: "size-8",
@@ -4190,10 +4890,10 @@ function AdminShellHeader({
4190
4890
  size: "icon",
4191
4891
  type: "button",
4192
4892
  variant: "ghost",
4193
- children: /* @__PURE__ */ jsx29(RefreshCw, { className: "size-4" })
4893
+ children: /* @__PURE__ */ jsx30(RefreshCw2, { className: "size-4" })
4194
4894
  }
4195
4895
  ) }),
4196
- /* @__PURE__ */ jsx29(TooltipContent, { children: "Refresh" })
4896
+ /* @__PURE__ */ jsx30(TooltipContent, { children: "Refresh" })
4197
4897
  ] }),
4198
4898
  brandingActions
4199
4899
  ] });
@@ -4323,6 +5023,7 @@ export {
4323
5023
  addUsageTotals,
4324
5024
  agentsModule,
4325
5025
  aggregateUsageRows,
5026
+ brainModule,
4326
5027
  buildUsageChartState,
4327
5028
  canAccessAdminPermission,
4328
5029
  collectAdminNavItems,