import { ForwardedParametersInput } from '@vn-sdk/runtime-client-gql'; import { FrontendAction } from '../types/frontend-action.js'; import { a as AiContextParams } from '../ai-context-2768aadc.js'; import '@vn-sdk/shared'; import 'react'; import '../hooks/use-tree.js'; import '../types/document-pointer.js'; import '../types/chat-suggestion-configuration.js'; import '../types/ai-agent-action.js'; import '../types/ai-agent-state.js'; /** * This class is used to execute one-off tasks, for example on button press. It can use the context available via [useAiReadable](/reference/hooks/useAiReadable) and the actions provided by [useAiAction](/reference/hooks/useAiAction), or you can provide your own context and actions. * * ## Example * In the simplest case, use AiTask in the context of your app by giving it instructions on what to do. * * ```tsx * import { AiTask, useAiContext } from "@vn-sdk/react-core"; * * export function MyComponent() { * const context = useAiContext(); * * const task = new AiTask({ * instructions: "Set a random message", * actions: [ * { * name: "setMessage", * description: "Set the message.", * argumentAnnotations: [ * { * name: "message", * type: "string", * description: * "A message to display.", * required: true, * }, * ], * } * ] * }); * * const executeTask = async () => { * await task.run(context, action); * } * * return ( * <> * * * ) * } * ``` * * Have a look at the [Presentation Example App](https://github.com/VN SDK/VN SDK/blob/main/VN SDK/examples/next-openai/src/app/presentation/page.tsx) for a more complete example. */ interface AiTaskConfig { /** * The instructions to be given to the assistant. */ instructions: string; /** * An array of action definitions that can be called. */ actions?: FrontendAction[]; /** * Whether to include the copilot readable context in the task. */ includeCopilotReadable?: boolean; /** * Whether to include actions defined via useAiAction in the task. */ includeAiActions?: boolean; /** * The forwarded parameters to use for the task. */ forwardedParameters?: ForwardedParametersInput; } declare class AiTask { private instructions; private actions; private includeCopilotReadable; private includeAiActions; private forwardedParameters?; constructor(config: AiTaskConfig); /** * Run the task. * @param context The AiContext to use for the task. Use `useAiContext` to obtain the current context. * @param data The data to use for the task. */ run(context: AiContextParams, data?: T): Promise; } export { AiTask, AiTaskConfig };