Skip to content

The open alternative to Salesforce, designed for AI.

882 B
Raw Blame
import gql from 'graphql-tag';

type AgentConversationVariables = {
  threadId?: string;
  agentUniversalIdentifier?: string;
  threadKey?: string;
};

export const agentConversationHistoryQueryFactory = (
  variables: AgentConversationVariables,
) => ({
  query: gql`
    query ConversationHistory(
      $threadId: UUID
      $agentUniversalIdentifier: UUID
      $threadKey: String
    ) {
      chatMessages(
        threadId: $threadId
        agentUniversalIdentifier: $agentUniversalIdentifier
        threadKey: $threadKey
      ) {
        threadId
        turnId
        role
        parts {
          type
          textContent
        }
      }
      chatStreamCatchupChunks(
        threadId: $threadId
        agentUniversalIdentifier: $agentUniversalIdentifier
        threadKey: $threadKey
      ) {
        chunks
        maxSeq
      }
    }
  `,
  variables,
});