import { WorkflowRunResponse } from '@knocklabs/mgmt/resources.js'; import { Message } from '@knocklabs/node/resources.js'; type Metadata = Record | undefined; interface DeferredToolCallWorkflowData { type: "deferred_tool_call"; /** * The tool call to trigger. */ tool_call: DeferredToolCall; /** * Any extra data to pass to the workflow as context. */ metadata?: Metadata; /** * Any extra data to pass to the workflow as context. */ [key: string]: unknown; } interface DeferredToolCallConfig { /** * The workflow to trigger. */ workflow: string; /** * The recipients to trigger the workflow for. */ recipients: string[] | Record[]; /** * Any extra data to pass to the workflow as context. */ metadata?: Metadata; /** * The tenant to trigger the workflow for. */ tenant?: string; /** * The actor to trigger the workflow for. */ actor?: string | Record; /** * A function to call before calling the Knock API. */ onBeforeCallKnock?: (toolCall: DeferredToolCall) => Promise; /** * A function to call after calling the Knock API. */ onAfterCallKnock?: (toolCall: DeferredToolCall, result: WorkflowRunResponse) => Promise; } type DeferredToolCall = { /** * The ID of the tool call. Should be automatically generated by the SDK. */ id: string; /** * The method of the tool that was called. */ method: string; /** * The arguments to pass to the tool. */ args: Record | undefined; /** * Any extra options to pass to the tool call. This is required for some providers. */ extra: Record | undefined; }; interface KnockOutboundWebhookEvent { /** * The type of event. */ type: string; /** * The timestamp of the event. */ created_at: string; /** * The underlying message that was generated */ data: Message; /** * Extra data associated with the event. */ event_data: Record; } interface DeferredToolCallInteractionResult, Metadata = Record> { /** * The workflow that was triggered. */ workflow: string; /** * The interaction data. */ interaction: InteractionData; /** * The tool call. */ toolCall: DeferredToolCall; /** * The metadata passed with the tool call. */ metadata?: Metadata; /** * The context of the tool call. */ context: { /** * The message ID. */ messageId: string; /** * The channel ID. */ channelId: string; /** * The timestamp of the event. */ timestamp: string; }; } export type { DeferredToolCallInteractionResult as D, KnockOutboundWebhookEvent as K, DeferredToolCall as a, DeferredToolCallConfig as b, DeferredToolCallWorkflowData as c };