Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | 3x 2x 3x 2x 2x 3x 3x 1x 3x 3x 3x 1x 3x 3x 3x 3x 3x 3x 3x 70x 70x 70x 70x 70x 70x 70x 70x 70x 70x 39x 70x 39x 70x 38x 70x 70x 39x 70x 70x 39x 70x 70x 1x 70x 70x 3x 70x 70x 70x 70x 70x 11x 59x | import AgentsGrid from "@/apps/user/pages/agents/AgentsGrid";
import SkillsGrid from "@/apps/user/pages/agents/skills/SkillsGrid";
import ModelsGrid from "@/apps/user/pages/models/ModelsGrid";
import {
SectionTabBar,
SectionTabConfig,
SubsectionBackLink,
SubsectionLinkConfig,
SubsectionLinks,
} from "@/components/nav/SectionNav/SectionNav";
import McpComingSoon from "@/components/mcp/McpComingSoon";
import MainPage from "@/components/page/MainPage/MainPage";
import { APP_ROUTES } from "@/routes/const";
import { Agent } from "@/objects/Agent";
import { isSystemManaged } from "@/objects/Doc";
import { Model } from "@/objects/Model";
import { Skill } from "@/objects/Skill";
import type { TopologyCatalogue } from "@/services/api/routers/SwarmRouter";
import { QUERY_KEYS } from "@/services/query_keys";
import { useApiHandler } from "@/services/useApiHandler";
import { MCP_AVAILABLE } from "@/util/mcp";
import { useQuery } from "@tanstack/react-query";
import {
Bot,
BrainCog,
Hammer,
Layers3,
Loader2,
Network,
Server,
Users,
} from "lucide-react";
import React from "react";
import { Navigate, useSearchParams } from "react-router-dom";
/**
* The sections loaded on demand, so opening /inference doesn't pull them into
* its chunk until they are visited. One list, so a test can load them all up
* front instead of charging the whole transform to whichever test renders
* first (see Inference.sections.test.tsx).
*/
export const INFERENCE_SECTION_LOADERS = {
mcpServers: () => import("@/apps/user/pages/MCPServers"),
skillsets: () => import("@/apps/user/pages/Skillsets"),
swarms: () => import("@/apps/user/pages/swarms/SwarmsContent"),
toolkits: () => import("@/apps/user/pages/Toolkits"),
};
const MCPServersContent = React.lazy(() =>
INFERENCE_SECTION_LOADERS.mcpServers().then((m) => ({
default: m.MCPServersContent,
})),
);
const SkillsetsContent = React.lazy(() =>
INFERENCE_SECTION_LOADERS.skillsets().then((m) => ({
default: m.SkillsetsContent,
})),
);
const SwarmsContent = React.lazy(() =>
INFERENCE_SECTION_LOADERS.swarms().then((m) => ({
default: m.SwarmsContent,
})),
);
const ToolkitsContent = React.lazy(() =>
INFERENCE_SECTION_LOADERS.toolkits().then((m) => ({
default: m.ToolkitsContent,
})),
);
const SectionLoading: React.FC = () => (
<div className="flex items-center justify-center py-16">
<Loader2 className="size-5 animate-spin text-gray-400 dark:text-gray-500" />
</div>
);
// ─── Section types ────────────────────────────────────────────────────────────
// Every root resource is a tab: Agents, Skills and MCP Servers. They used to be three tabs with a sidebar of
// root-level items under two of them, which meant the page's real structure
// was split across two controls and a skillset read as a child of "agents"
// rather than a resource in its own right.
//
// Three relations survive as subsections rather than tabs: skillsets are
// reached from Skills (a skill is what a user builds and runs; a skillset
// only bundles skills to grant them to an agent, so it is the step after, not
// the way in), toolkits from MCP Servers (same relation: a server is what a
// user connects; a toolkit bundles servers for an agent), and models from
// Agents — a model is the platform's
// own record rather than something you build, and what an agent runs on, so
// it is looked up from the agents rather than opened as a peer of them.
// `SubsectionLinks` offers them on the owning tab and `SubsectionBackLink`
// comes back. Their `?section=` values are unchanged, so every existing link
// still resolves — it just lands on the owning tab.
//
// Rules used to have a subpage here *and* another under Models, each showing
// a scope-filtered slice of the same list. They now live under Governance —
// a rule is a policy over the account, not a property of whichever resource
// page you found it on. The two `?section=` values still resolve so existing
// links keep working; both redirect.
// Evaluation was a tab here until it moved under Governance: it is how the
// platform shows its models and agents are fit for purpose, which is an
// assurance question, not a building one. Every `?section=` value it ever had
// here — including the six from before it was cut to three — redirects.
type InferenceSection =
| "models"
| "agents"
| "skills"
| "swarms"
| "toolkits"
| "mcp"
| "skillsets"
// Sections that moved to Governance and redirect there: the two rule
// subpages, and every value the evaluation section had here.
| "rules"
| "model_rules"
| "evaluation"
| "datasets"
| "reports"
| "labs"
| "compare"
| "experiments"
| "evaluations"
| "benchmarking"
| "test_suites";
type InferenceTab = "agents" | "skills" | "swarms" | "mcp";
//: Sections that render a tab here. The two rule sections are deliberately
//: absent: they redirect (see RELOCATED_SECTIONS) rather than resolving to a
//: tab, so an old link lands on the page that now owns them instead of
//: silently falling back to Agents.
const SECTIONS: InferenceSection[] = [
"models",
"agents",
"skills",
"swarms",
"toolkits",
"mcp",
"skillsets",
];
//: Where a section that no longer lives here has gone. Rules moved out of
//: Inference entirely, so these resolve to a URL rather than to a tab.
const RELOCATED_SECTIONS: Partial<Record<InferenceSection, string>> = {
rules: APP_ROUTES.USER.GOVERNANCE.rules,
model_rules: APP_ROUTES.USER.GOVERNANCE.rules,
// Evaluation moved to Governance. The tab itself opens on its entry page
// (Assurance) and Reports keeps its own section there; every other value —
// current or long retired — named a list of datasets or experiments, so it
// opens on the datasets.
evaluation: APP_ROUTES.USER.GOVERNANCE.evaluation,
datasets: APP_ROUTES.USER.GOVERNANCE.EVALUATION.datasets,
reports: APP_ROUTES.USER.GOVERNANCE.EVALUATION.reports,
labs: APP_ROUTES.USER.GOVERNANCE.EVALUATION.datasets,
compare: APP_ROUTES.USER.GOVERNANCE.EVALUATION.datasets,
experiments: APP_ROUTES.USER.GOVERNANCE.EVALUATION.datasets,
evaluations: APP_ROUTES.USER.GOVERNANCE.EVALUATION.datasets,
benchmarking: APP_ROUTES.USER.GOVERNANCE.EVALUATION.datasets,
test_suites: APP_ROUTES.USER.GOVERNANCE.EVALUATION.datasets,
};
//: Sections that folded into another one here. Unlike RELOCATED_SECTIONS these
//: stay on this page, so they resolve to their new section rather than to a
//: URL. "workers" was a list of the reasoning units a skill graph is built
//: from; a worker is now configured on the node that uses it, inside the graph
//: builder, so the skills list is where that work starts.
const SECTION_ALIASES: Partial<Record<string, InferenceSection>> = {
workers: "skills",
// MCP servers are not available in this release (util/mcp.ts), so the tab
// shows that they are coming soon and has no toolkits subsection: an old
// toolkits link lands on the tab instead.
...(MCP_AVAILABLE ? {} : { toolkits: "mcp" as const }),
// The `Tool` resource is gone — built-ins are bound to every agent and need
// no management surface, and reaching an external system is MCP's job. So
// the MCP servers list is where a link to "tools" now lands.
tools: "mcp",
// Simulations are out of the navigation for now — the runner simulates a
// stand-in, not the agent — so the tab is gone and its old link lands on
// the agents the feature was about. Its viewers stay reachable by URL.
simulations: "agents",
};
const TAB_FOR_SECTION: Record<InferenceSection, InferenceTab> = {
// Inside Agents: every agent runs on one of these models.
models: "agents",
agents: "agents",
skills: "skills",
// Inside Skills: a skillset bundles skills to grant them to an agent.
skillsets: "skills",
// Beside Skills: a team of agents in a shape, sent on a long task.
swarms: "swarms",
mcp: "mcp",
// Inside MCP Servers: a toolkit bundles servers to grant them to an agent.
toolkits: "mcp",
// Unreachable in practice — each redirects before a tab is chosen — but
// the record is exhaustive over the union, so they need an entry.
rules: "agents",
model_rules: "agents",
evaluation: "agents",
datasets: "agents",
reports: "agents",
labs: "agents",
compare: "agents",
experiments: "agents",
evaluations: "agents",
benchmarking: "agents",
test_suites: "agents",
};
//: The tab a subsection returns to, and what the way back is called.
const PARENT_TAB: Partial<Record<InferenceSection, InferenceTab>> = {
models: "agents",
skillsets: "skills",
toolkits: "mcp",
};
const TAB_LABEL: Record<InferenceTab, string> = {
agents: "Agents",
skills: "Skills",
swarms: "Swarms",
mcp: "MCP Servers",
};
// ─── Inference ────────────────────────────────────────────────────────────────
const Inference: React.FC = () => {
const [searchParams, setSearchParams] = useSearchParams();
const rawSection = searchParams.get("section") as InferenceSection | null;
const relocated = rawSection ? RELOCATED_SECTIONS[rawSection] : undefined;
const aliased = rawSection ? SECTION_ALIASES[rawSection] : undefined;
const resolved = aliased ?? rawSection;
const section: InferenceSection =
resolved && SECTIONS.includes(resolved) ? resolved : "agents";
const activeTab = TAB_FOR_SECTION[section];
const { getApiHandler } = useApiHandler();
const setSection = (s: InferenceSection) => setSearchParams({ section: s });
const { data: models = [], isLoading: modelsLoading } = useQuery<Model[]>({
queryKey: [QUERY_KEYS.GET.MODELS],
queryFn: () => getApiHandler().model_router.list() as Promise<Model[]>,
});
const { data: agents = [], isLoading: agentsLoading } = useQuery<Agent[]>({
queryKey: [QUERY_KEYS.GET.AGENTS],
queryFn: () =>
getApiHandler().agent_router.list(undefined) as Promise<Agent[]>,
});
// With the built-in skills: the grid lists them in a section of their own.
const { data: skills = [], isLoading: skillsLoading } = useQuery<Skill[]>({
queryKey: [QUERY_KEYS.GET.SKILLS, "include_system"],
queryFn: () => getApiHandler().skill_router.list({ include_system: true }),
});
// MCP servers are fetched by their content component too — this shares its
// cache key, so the tab badge stays in step with the list without a second
// request. It is a tab badge, so it cannot wait for the tab to be opened.
// Neither it nor the toolkits list is asked for while MCP servers are not
// available.
const { data: mcpServers = [] } = useQuery<{ id: string }[]>({
queryKey: [QUERY_KEYS.GET.USER_MCP_SERVERS],
queryFn: () =>
getApiHandler().mcp_server_router.list() as Promise<{ id: string }[]>,
enabled: MCP_AVAILABLE,
});
// The skillsets and toolkits counts are subsection-link badges.
const { data: skillsets = [] } = useQuery<{ id: string }[]>({
queryKey: [QUERY_KEYS.GET.SKILLSETS],
queryFn: () =>
getApiHandler().skillset_router.list() as Promise<{ id: string }[]>,
});
const { data: toolkits = [] } = useQuery<{ id: string }[]>({
queryKey: [QUERY_KEYS.GET.TOOLKITS],
queryFn: () =>
getApiHandler().toolkit_router.list() as Promise<{ id: string }[]>,
enabled: MCP_AVAILABLE,
});
// Swarms are switched off on most deployments for now (svc-core
// `SWARMS_ENABLED`): the tab is offered only where they are on. The
// section shares these keys, so neither request is made twice.
const { data: swarmCatalogue } = useQuery<TopologyCatalogue>({
queryKey: [QUERY_KEYS.GET.SWARM_TOPOLOGIES],
queryFn: () => getApiHandler().swarm_router.topologies(),
});
// On, and offering a shape: with none there is nothing to build.
const swarmsOn =
swarmCatalogue?.unavailable === null && swarmCatalogue.topologies.length > 0;
const { data: swarms = [] } = useQuery<{ id: string }[]>({
queryKey: [QUERY_KEYS.GET.SWARMS],
queryFn: () => getApiHandler().swarm_router.list(),
enabled: swarmsOn,
});
const tabs: SectionTabConfig<InferenceTab>[] = [
{
key: "agents",
label: "Agents",
Icon: Bot,
// The user's own, as the grid's stats count them: CHAINR Bot is
// listed beside the fleet, not in it.
count: agents.filter((a: Agent) => !isSystemManaged(a)).length,
},
{
key: "skills",
label: "Skills",
Icon: Network,
// The user's own, as the grid's stats count them: the built-in skills
// are listed beside them, not among them.
count: skills.filter((s: Skill) => !isSystemManaged(s)).length,
},
...(swarmsOn || section === "swarms"
? [
{
key: "swarms" as const,
label: "Swarms",
Icon: Users,
count: swarms.length,
},
]
: []),
{
key: "mcp",
label: "MCP Servers",
Icon: Server,
...(MCP_AVAILABLE ? { count: mcpServers.length } : { badge: "Soon" }),
},
];
const agentSubsections: SubsectionLinkConfig<InferenceSection>[] = [
{
key: "models",
label: "Models",
hint: "What agents run on",
Icon: BrainCog,
// What the Models page opens on (its "Available here" filter), not the
// whole catalogue, which keeps models this deployment cannot run.
count: models.filter((m: Model) => m.is_available).length,
},
];
const skillSubsections: SubsectionLinkConfig<InferenceSection>[] = [
{
key: "skillsets",
label: "Skillsets",
hint: "Bundle skills for agents",
Icon: Layers3,
count: skillsets.length,
},
];
const mcpSubsections: SubsectionLinkConfig<InferenceSection>[] = [
{
key: "toolkits",
label: "Toolkits",
hint: "Bundle servers for agents",
Icon: Hammer,
count: toolkits.length,
},
];
// The way back out of a subsection, to the tab that owns it.
const parentTab = PARENT_TAB[section];
const backLink = parentTab && (
<SubsectionBackLink
label={TAB_LABEL[parentTab]}
onClick={() => setSection(parentTab)}
/>
);
// Rules moved out of Inference entirely. An old `?section=rules` link is
// sent on rather than quietly falling back to the Agents tab, which would
// look like the rules had been deleted.
if (relocated) {
return <Navigate to={relocated} replace />;
}
return (
<MainPage
title="Inference"
description={`Build and run your fleet: agents and the models they run on, ${
MCP_AVAILABLE
? "the skills and MCP servers that extend them"
: "the skills that extend them"
}${
swarmsOn ? ", and the swarms that send them as a team" : ""
}. The rules that govern them, and the evaluations that show they are fit for purpose, live under Governance.`}
>
<SectionTabBar
tabs={tabs}
active={activeTab}
onChange={(t) => setSection(t)}
/>
{activeTab === "agents" && (
<>
{backLink}
{section === "models" && (
<ModelsGrid models={models} loading={modelsLoading} />
)}
{section === "agents" && (
<>
<SubsectionLinks
items={agentSubsections}
onSelect={setSection}
/>
<AgentsGrid agents={agents} loading={agentsLoading} />
</>
)}
</>
)}
{activeTab === "skills" && (
<>
{backLink}
{section === "skills" && (
<>
<SubsectionLinks
items={skillSubsections}
onSelect={setSection}
/>
<SkillsGrid skills={skills} loading={skillsLoading} />
</>
)}
{section === "skillsets" && (
<React.Suspense fallback={<SectionLoading />}>
<SkillsetsContent />
</React.Suspense>
)}
</>
)}
{activeTab === "swarms" && (
<React.Suspense fallback={<SectionLoading />}>
<SwarmsContent />
</React.Suspense>
)}
{activeTab === "mcp" && !MCP_AVAILABLE && <McpComingSoon />}
{activeTab === "mcp" && MCP_AVAILABLE && (
<>
{backLink}
<React.Suspense fallback={<SectionLoading />}>
{section === "mcp" && (
<>
<SubsectionLinks items={mcpSubsections} onSelect={setSection} />
<MCPServersContent />
</>
)}
{section === "toolkits" && <ToolkitsContent />}
</React.Suspense>
</>
)}
</MainPage>
);
};
export default Inference;
|