
Integrate Fusion Agent
Wire a Cognite Fusion Flows or Dune app to the built-in PAIA agent panel so users can open chat, inject context, and expose app resources and actions via @cognite/app-sdk.
Overview
Integrate-fusion-agent is an agent skill for the Build phase that connects Fusion Flows/Dune apps to the PAIA agent panel using @cognite/app-sdk.
Install
npx skills add https://github.com/cognitedata/builder-skills --skill integrate-fusion-agentWhat is this skill?
- Three independent capabilities: open agent panel, send contextual chat messages, register agent server for resources and
- Mandates reading package.json and App.tsx first and implementing only the capabilities the user needs
- Enforces correct lifecycle, graceful fallback when the host agent is unavailable, and recommended file structure
- Triggers on PAIA, sendAgentLayoutMode, registerAgentServer, connectToHostApp, and agent sidebar integration phrases
- Replaces hand-rolled agent integration code that often misses SDK lifecycle hooks
- Documents three independent integration capabilities (panel, message injection, agent server)
Adoption & trust: 813 installs on skills.sh; 4 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You need your Fusion app to open the agent sidebar, pass live context, and expose actions—but manual SDK snippets miss lifecycle, fallback, and file layout.
Who is it for?
Developers building on Cognite Fusion who want PAIA chat tied to real app state and actions in Flows or Dune projects.
Skip if: Generic React apps outside Fusion, greenfield agents without @cognite/app-sdk, or teams that only need documentation with no host-app wiring.
When should I use this skill?
Developer asks for Fusion agent, PAIA, agent panel, sendAgentMessage, sendAgentLayoutMode, registerAgentServer, connectToHostApp, or app-sdk agent integration.
What do I get? / Deliverables
Your app gains the chosen PAIA integrations with SDK-recommended structure so the agent can read resources and call actions without breaking when the host panel is absent.
- SDK wiring for panel open, contextual messages, and/or agent server registration
- Recommended file structure with graceful fallback when agent host is unavailable
Recommended Skills
Journey fit
Fusion agent integration is implemented while building the product shell that must talk to Cognite’s host agent—not during initial market research. The work is SDK wiring—sendAgentMessage, registerAgentServer, connectToHostApp—against Fusion’s agent host APIs.
How it compares
Use this integration skill instead of copying disconnected sendAgentMessage examples that omit registerAgentServer and graceful fallback.
Common Questions / FAQ
Who is integrate-fusion-agent for?
Fusion app developers and integrators wiring PAIA into Flows or Dune with @cognite/app-sdk, typically on small teams shipping operator-facing tools.
When should I use integrate-fusion-agent?
Use it during Build integrations when adding agent panel UI, contextual messages on clicks, or agent-callable app actions; revisit in Ship review before releasing to production tenants.
Is integrate-fusion-agent safe to install?
The skill edits app source and may run Bash for installs; review the Security Audits panel on this Prism page and diff all SDK and agent-server changes before merge.
SKILL.md
READMESKILL.md - Integrate Fusion Agent
# Integrate Fusion Agent Panel Wire a Flows/Dune app into the Fusion built-in PAIA agent using `@cognite/app-sdk`. There are three independent capabilities — implement only the ones needed: 1. **Open the agent panel** — a button that shows the sidebar/fullscreen agent UI 2. **Send the agent a message** — inject context into the chat (e.g. on item click) 3. **Register an agent server** — expose app state (resources) and actions the agent can call --- ## Step 0 — Understand the app Before writing any code, read: - `package.json` — detect package manager and whether `@cognite/app-sdk` is already installed - `src/App.tsx` (or main entry) — understand current structure, existing SDK usage Ask the user which of the three capabilities they need if it's not clear from context. --- ## Step 1 — Install the SDK If `@cognite/app-sdk` is not already in `package.json`, install it: ```shell pnpm add @cognite/app-sdk # or npm/yarn depending on the app ``` Minimum required version: `0.3.1` --- ## Step 2 — Connect to the host app All capabilities require a `HostAppAPI` instance. Obtain it once on mount and store it in React state or context. Always catch the rejection — the SDK throws when running outside Fusion (e.g. standalone `vite dev`). **Pattern for React apps:** ```typescript // src/hooks/useHostApp.ts import { useState, useEffect } from 'react'; import { connectToHostApp, type HostAppAPI } from '@cognite/app-sdk'; export function useHostApp(): HostAppAPI | null { const [api, setApi] = useState<HostAppAPI | null>(null); useEffect(() => { connectToHostApp({ applicationName: 'my-app' }) .then(({ api: resolvedApi }) => { // IMPORTANT: use the updater form here. Comlink proxies are callable // objects, so setApi(proxy) causes React to invoke the proxy as a // state-updater function — storing a Promise instead of the proxy. // setApi(() => proxy) returns the proxy as the new state value. setApi(() => resolvedApi); }) .catch(() => { // Running outside Fusion — agent features disabled, no-op }); }, []); return api; } ``` Call `useHostApp()` at the root of your app and pass `api` down (or put it in context). When `api` is `null`, all agent UI triggers should be hidden or disabled — not shown as broken. --- ## Step 3 — Opening the agent panel Wire a persistent toolbar button (or equivalent trigger) to `api.sendAgentLayoutMode`. ```typescript import { type AgentLayoutPayload } from '@cognite/app-sdk'; // Open as sidebar (most common) await api.sendAgentLayoutMode({ mode: 'sidebar' }); // Other modes await api.sendAgentLayoutMode({ mode: 'fullscreen' }); await api.sendAgentLayoutMode({ mode: 'closed' }); ``` The button should only render when `api` is not null — agent features are unavailable outside Fusion. ```tsx {api && ( <button onClick={() => api.sendAgentLayoutMode({ mode: 'sidebar' })}> Open Assistant </button> )} ``` --- ## Step 4 — Sending the agent a message Use `sendAgentMessage` on contextual triggers (e.g. "Analyse this item" button). Always pair it with `sendAgentLayoutMode` so the panel is visible. ```typescript // Open sidebar then