import { AgentActionJSONSchema, AgentActionResult, AgentContentPart } from '../utils/register-agent-server/types'; /** Layout modes for the PAIA agent panel. Mirrors `PaiaLayoutMode` from `@fusion/paia-sdk`. */ export declare const AgentLayoutMode: { readonly Closed: "closed"; readonly Sidebar: "sidebar"; readonly Fullscreen: "fullscreen"; }; export type AgentLayoutMode = (typeof AgentLayoutMode)[keyof typeof AgentLayoutMode]; /** * Identifies the product surface that triggered a PAIA layout change. * Mirrors `PaiaSource` from `@fusion/paia-sdk`. */ export type AgentSource = 'navrail' | 'canvas' | 'charts' | 'eos' | 'agent-library'; /** * Payload for requesting an agent panel layout mode change. * Mirrors `LayoutPayload` from `@fusion/paia-sdk`. */ export type AgentLayoutPayload = { mode: AgentLayoutMode; conversationId?: string; agentExternalId?: string; source?: AgentSource; }; /** * Payload for sending a message to the agent panel. * Mirrors `MessagePayload` from `@fusion/paia-sdk`. */ export type AgentMessagePayload = { message: string; newSession?: boolean; }; /** * Payload for setting the agent panel theme. * Mirrors `ThemePayload` from `@fusion/paia-sdk`. */ export type AgentThemePayload = { theme: 'light' | 'dark'; }; /** * Serializable metadata for an agent action (no functions). * Used when transferring action metadata across boundaries (e.g. Comlink). * * This is an internal type that is not meant to be used externally. */ export type CustomAppAgentActionMetadata = { identifier: string; name: string; description: string; schema: AgentActionJSONSchema; }; /** * Serializable metadata for an agent resource (no functions). * Used when transferring resource metadata across boundaries (e.g. Comlink). * * This is an internal type that is not meant to be used externally. */ export type CustomAppAgentResourceMetadata = { uri: string; name: string; description: string; }; /** * Runtime context passed to every action handler invocation. */ export type CustomAppAgentRuntimeContext = { abortSignal: AbortSignal | Promise; onStatusUpdate?: (params: { actionName: string; message: string; }) => Promise; }; /** * Handle exposed by the Dune app for Comlink transfer. All methods return * serializable data or perform RPCs; we never return objects containing * nested proxies (which Comlink cannot serialize). * * This is an internal handle that is not meant to be used externally. */ export type CustomAppAgentServerHandle = { getUri: () => Promise; getActionsMetadata: () => Promise; getResourcesMetadata: () => Promise; invokeAction: (identifier: string, args: unknown, context: CustomAppAgentRuntimeContext) => Promise; readResource: (identifier: string) => Promise; }; export interface HostAppAPI { /** * Returns the CDF project name that the app is rendered for. * * @returns the project name */ getProject: () => Promise; /** * Returns the CDF base URL (cluster) for API requests, * e.g. "https://greenfield.cognitedata.com". * * @returns the base URL */ getBaseUrl: () => Promise; /** * Returns the access token from host side. * * @returns the access token */ getAccessToken: () => Promise; /** * Returns the application ID (external ID) of the running app. * * @returns the app ID */ getAppId: () => Promise; /** * Synchronizes the internal state of the app with the host. * This is to ensure the app's current state can be bookmarked and shared. * * @param state - the internal state to synchronize * @returns boolean indicating if the host handled the sync */ syncInternalState: (state: string) => Promise; /** * Navigates within Fusion. The host constructs the full URL including * the current project, cluster, and workspace context. * * @param options - navigation options * @returns boolean indicating if the navigation was performed */ navigateInternal: (options: NavigateInternalOptions) => Promise; /** * Navigates to an external URL outside of Fusion. * * @remarks * - Only https: URLs are allowed. * - By default, navigates to the current tab. Set `openInNewTab` to open in a new tab instead. * * @param options - navigation options * @returns boolean indicating if the navigation was performed */ navigateExternal: (options: NavigateExternalOptions) => Promise; /** * Registers an {@link AgentServer} with the host's global agent registry. * The host namespaces the server URI with the app instance ID to prevent * clashes when multiple instances of the same app are running. * * @param handle - Comlink proxy of {@link DuneAgentServerHandle}; methods * return only serializable data so we avoid "Unserializable return value". */ registerAgentServer: (handle: CustomAppAgentServerHandle) => Promise; /** * Unregisters a previously registered {@link AgentServer} by its original URI. * The host resolves the namespaced URI internally. * * @param uri - the original server URI used during registration */ unregisterAgentServer: (uri: string) => Promise; /** * Requests a layout mode change for the PAIA agent panel. * Accepts the full {@link AgentLayoutPayload} so optional fields such as * `conversationId`, `agentExternalId`, and `source` are preserved. * * @param payload - the layout payload to send */ sendAgentLayoutMode: (payload: AgentLayoutPayload) => Promise; /** * Sends a message to the PAIA agent panel's chat. * Pass `newSession: true` to start a fresh conversation before injecting the message. * * @param payload - the message payload to send */ sendAgentMessage: (payload: AgentMessagePayload) => Promise; /** * Sets the PAIA agent panel theme. * * @param payload - the theme payload to send */ sendAgentTheme: (payload: AgentThemePayload) => Promise; } export type NavigateInternalOptions = { /** * Path within Fusion, e.g. "/search" or "/charts" * * @example "/search" */ path: string; /** * Optional query parameters to include in the URL * * @example { tab: "assets" } */ queryParams?: Record; /** * Optional hash fragment to append to the URL (without the leading #) * * @example 'searchCategory="file"' or "section1" */ hash?: string; /** * If true, opens in a new tab instead of navigating the current tab. * * @default false */ openInNewTab?: boolean; }; export type NavigateExternalOptions = { /** * Full URL to navigate to. Must use https: scheme. * * @example "https://cognite.com" */ url: string; /** * If true, opens in a new tab instead of navigating the current tab. * * @default false */ openInNewTab?: boolean; };