The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
// Parent-first order is persisted in the 2.42 migration cursor; keep it frozen.
export const AGENT_HISTORY_TABLES = [
{
name: 'agentChatThread',
columns: [
'id',
'userWorkspaceId',
'title',
'totalInputTokens',
'totalOutputTokens',
'contextWindowTokens',
'conversationSize',
'totalInputCredits',
'totalOutputCredits',
'totalCacheReadTokens',
'totalCacheCreationTokens',
'activeStreamId',
'pendingQuestionMessageId',
'lastStreamError',
'deletedAt',
'createdAt',
'updatedAt',
],
},
{
name: 'agentTurn',
columns: ['id', 'threadId', 'agentId', 'createdAt'],
},
{
name: 'agentMessage',
columns: [
'id',
'threadId',
'turnId',
'agentId',
'senderUserWorkspaceId',
'senderApplicationId',
'role',
'status',
'isHidden',
'processedAt',
'createdAt',
],
},
{
name: 'agentMessagePart',
columns: [
'id',
'messageId',
'orderIndex',
'type',
'textContent',
'reasoningContent',
'toolName',
'toolCallId',
'toolInput',
'toolOutput',
'state',
'providerExecuted',
'errorMessage',
'errorDetails',
'sourceUrlSourceId',
'sourceUrlUrl',
'sourceUrlTitle',
'sourceDocumentSourceId',
'sourceDocumentMediaType',
'sourceDocumentTitle',
'sourceDocumentFilename',
'fileFilename',
'fileId',
'providerMetadata',
'createdAt',
],
},
{
name: 'agentTurnEvaluation',
columns: ['id', 'turnId', 'score', 'comment', 'createdAt'],
},
] as const;
type AgentHistoryTable = (typeof AGENT_HISTORY_TABLES)[number];
// Turn evaluations were removed after 2.42 shipped. Their entry keeps the cursor
// order, but nothing is copied to workspace storage and their core rows go with
// the core tables.
export type ActiveAgentHistoryTable = Exclude<
AgentHistoryTable,
{ name: 'agentTurnEvaluation' }
>;
export const isActiveAgentHistoryTable = (
table: AgentHistoryTable,
): table is ActiveAgentHistoryTable => table.name !== 'agentTurnEvaluation';
export const ACTIVE_AGENT_HISTORY_TABLES = AGENT_HISTORY_TABLES.filter(
isActiveAgentHistoryTable,
);