Eloquent

Documentation

@elqnt/agents

Complete AI agent management for the Eloquent platform. Provides types, browser & server APIs, React hooks, and utilities for building agent-powered applications.

Installation

npm install @elqnt/agents

Entry Points

ImportDescription
@elqnt/agentsAll exports
@elqnt/agents/hooksReact hooks (primary interface)
@elqnt/agents/modelsTypeScript types
@elqnt/agents/apiInternal browser API functions (use hooks instead)
@elqnt/agents/api/serverServer-side API (SSR, Server Actions)
@elqnt/agents/utilsUtility functions

React Hooks

useAgents

Hook for agent CRUD operations with loading/error states.

import { useAgents } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listAgents,
  listAgentSummaries,
  getAgent,
  createAgent,
  updateAgent,
  deleteAgent,
  getDefaultAgent,
} = useAgents({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all agents
const agents = await listAgents();

// List agent summaries (lightweight)
const summaries = await listAgentSummaries();

// Get agent by ID
const agent = await getAgent("agent-uuid");

// Get default agent
const defaultAgent = await getDefaultAgent();

// Create agent
const newAgent = await createAgent({
  name: "Support Agent",
  goal: "Help customers with questions",
  model: "claude-sonnet-4-20250514",
});

// Update agent
const updated = await updateAgent("agent-uuid", { name: "Updated Name" });

// Delete agent
const success = await deleteAgent("agent-uuid");

Methods:

MethodParametersReturnsDescription
listAgents-Agent[]List all agents
listAgentSummaries-AgentSummary[]List lightweight agent summaries
getAgentagentId: stringAgent | nullGet agent by ID
getDefaultAgent-Agent | nullGet organization's default agent
createAgentagent: Partial<Agent>Agent | nullCreate a new agent
updateAgentagentId: string, updates: Partial<Agent>Agent | nullUpdate an agent
deleteAgentagentId: stringbooleanDelete an agent

useSkills

Hook for skill CRUD operations with loading/error states.

import { useSkills } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listSkills,
  getSkill,
  createSkill,
  updateSkill,
  deleteSkill,
  getCategories,
} = useSkills({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all skills
const skills = await listSkills();

// Get skill categories
const categories = await getCategories();

// Get skill by ID
const skill = await getSkill("skill-uuid");

// Create skill
const newSkill = await createSkill({
  name: "Web Search",
  description: "Search the web for information",
  category: "research",
});

// Update skill
const updated = await updateSkill("skill-uuid", { enabled: true });

// Delete skill
const success = await deleteSkill("skill-uuid");

Methods:

MethodParametersReturnsDescription
listSkills-Skill[]List all skills
getSkillskillId: stringSkill | nullGet skill by ID
createSkillskill: Partial<Skill>Skill | nullCreate a new skill
updateSkillskillId: string, updates: Partial<Skill>Skill | nullUpdate a skill
deleteSkillskillId: stringbooleanDelete a skill
getCategories-string[]Get available skill categories

useSubAgents

Hook for sub-agent CRUD operations with loading/error states.

import { useSubAgents } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listSubAgents,
  getSubAgent,
  createSubAgent,
  updateSubAgent,
  deleteSubAgent,
} = useSubAgents({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all sub-agents
const subAgents = await listSubAgents();

// Get sub-agent by ID
const subAgent = await getSubAgent("subagent-uuid");

// Create sub-agent
const newSubAgent = await createSubAgent({
  name: "Document Analyzer",
  description: "Specialized in document analysis",
  model: "claude-sonnet-4-20250514",
});

// Update sub-agent
const updated = await updateSubAgent("subagent-uuid", { enabled: true });

// Delete sub-agent
const success = await deleteSubAgent("subagent-uuid");

Methods:

MethodParametersReturnsDescription
listSubAgents-SubAgent[]List all sub-agents
getSubAgentsubAgentId: stringSubAgent | nullGet sub-agent by ID
createSubAgentsubAgent: Partial<SubAgent>SubAgent | nullCreate a new sub-agent
updateSubAgentsubAgentId: string, updates: Partial<SubAgent>SubAgent | nullUpdate a sub-agent
deleteSubAgentsubAgentId: stringbooleanDelete a sub-agent

useToolDefinitions

Hook for tool definition CRUD operations with loading/error states.

import { useToolDefinitions } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listToolDefinitions,
  getToolDefinition,
  getToolDefinitionsByIds,
  createToolDefinition,
  updateToolDefinition,
  deleteToolDefinition,
} = useToolDefinitions({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all tool definitions
const toolDefs = await listToolDefinitions();

// Get tool definition by ID
const toolDef = await getToolDefinition("tooldef-uuid");

// Get multiple tool definitions by IDs
const toolDefs = await getToolDefinitionsByIds(["id1", "id2", "id3"]);

// Create tool definition
const newToolDef = await createToolDefinition({
  name: "get_weather",
  description: "Get current weather for a location",
  inputSchema: { type: "object", properties: { location: { type: "string" } } },
});

// Update tool definition
const updated = await updateToolDefinition("tooldef-uuid", { enabled: true });

// Delete tool definition
const success = await deleteToolDefinition("tooldef-uuid");

Methods:

MethodParametersReturnsDescription
listToolDefinitions-ToolDefinition[]List all tool definitions
getToolDefinitiontoolDefId: stringToolDefinition | nullGet tool definition by ID
getToolDefinitionsByIdsids: string[]ToolDefinition[]Get multiple tool definitions
createToolDefinitiontoolDef: Partial<ToolDefinition>ToolDefinition | nullCreate a tool definition
updateToolDefinitiontoolDefId: string, updates: Partial<ToolDefinition>ToolDefinition | nullUpdate a tool definition
deleteToolDefinitiontoolDefId: stringbooleanDelete a tool definition

useAgentJobs

Hook for scheduled agent job CRUD operations with loading/error states.

import { useAgentJobs } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listAgentJobs,
  getAgentJob,
  createAgentJob,
  updateAgentJob,
  deleteAgentJob,
  pauseAgentJob,
  resumeAgentJob,
} = useAgentJobs({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all agent jobs
const jobs = await listAgentJobs();

// Get job by ID
const job = await getAgentJob("job-uuid");

// Create job
const newJob = await createAgentJob({
  agentId: "agent-uuid",
  name: "Daily Report",
  schedule: "0 9 * * *", // 9am daily
  prompt: "Generate daily sales report",
});

// Pause job
const paused = await pauseAgentJob("job-uuid");

// Resume job
const resumed = await resumeAgentJob("job-uuid");

// Delete job
const success = await deleteAgentJob("job-uuid");

Methods:

MethodParametersReturnsDescription
listAgentJobs-AgentJob[]List all agent jobs
getAgentJobjobId: stringAgentJob | nullGet job by ID
createAgentJobjob: Partial<AgentJob>AgentJob | nullCreate a new job
updateAgentJobjobId: string, updates: Partial<AgentJob>AgentJob | nullUpdate a job
deleteAgentJobjobId: stringbooleanDelete a job
pauseAgentJobjobId: stringAgentJob | nullPause a running job
resumeAgentJobjobId: stringAgentJob | nullResume a paused job

useWidgets

Hook for chat widget CRUD operations with loading/error states.

import { useWidgets } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listWidgets,
  getWidget,
  getDefaultWidget,
  createWidget,
  updateWidget,
  deleteWidget,
  setDefaultWidget,
} = useWidgets({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
  agentId: selectedAgentId,
});

// List all widgets for agent
const widgets = await listWidgets();

// Get default widget
const defaultWidget = await getDefaultWidget();

// Get widget by ID
const widget = await getWidget("widget-uuid");

// Create widget
const newWidget = await createWidget({
  name: "Support Widget",
  theme: { primaryColor: "#007bff" },
  placement: "bottom-right",
});

// Update widget
const updated = await updateWidget("widget-uuid", { name: "Updated Widget" });

// Set as default widget
await setDefaultWidget("widget-uuid");

// Delete widget
const success = await deleteWidget("widget-uuid");

Methods:

MethodParametersReturnsDescription
listWidgets-AgentWidget[]List all widgets for agent
getWidgetwidgetId: stringAgentWidget | nullGet widget by ID
getDefaultWidget-AgentWidget | nullGet agent's default widget
createWidgetwidget: Partial<AgentWidget>AgentWidget | nullCreate a new widget
updateWidgetwidgetId: string, updates: Partial<AgentWidget>AgentWidget | nullUpdate a widget
deleteWidgetwidgetId: stringbooleanDelete a widget
setDefaultWidgetwidgetId: stringbooleanSet widget as default

useSkillUserConfig

Hook for per-user skill configuration operations.

import { useSkillUserConfig } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  getSkillUserConfig,
  updateSkillUserConfig,
  deleteSkillUserConfig,
  listSkillUserConfigs,
  resolveSkillConfig,
} = useSkillUserConfig({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// Get skill config for user
const config = await getSkillUserConfig("skill-uuid", "agent-uuid");

// Update skill config
const updated = await updateSkillUserConfig("skill-uuid", {
  enabled: true,
  displayOrder: 1,
  config: { apiKey: "xxx" },
  agentId: "agent-uuid",
});

// List all user configs
const configs = await listSkillUserConfigs({ agentId: "agent-uuid" });

// Resolve effective config (merges org + user configs)
const resolved = await resolveSkillConfig("skill-uuid", "agent-uuid");

// Delete user config
const success = await deleteSkillUserConfig("skill-uuid", "agent-uuid");

Methods:

MethodParametersReturnsDescription
getSkillUserConfigskillId: string, agentId?: stringSkillUserConfig | nullGet user's skill config
updateSkillUserConfigskillId: string, data: {...}SkillUserConfig | nullUpdate user's skill config
deleteSkillUserConfigskillId: string, agentId?: stringbooleanDelete user's skill config
listSkillUserConfigsparams?: {...}SkillUserConfig[]List all user configs
resolveSkillConfigskillId: string, agentId: stringResolveSkillConfigResponse | nullGet resolved config

useAnalytics

Hook for agent analytics operations.

import { useAnalytics } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  getAgentChatsAnalytics,
  getAgentCSATAnalytics,
  getAgentListAnalytics,
  getTaskOutcomes,
} = useAnalytics({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// Get chat analytics
const chatsData = await getAgentChatsAnalytics({
  date_filter: { from: "2024-01-01", to: "2024-12-31" },
  agent_id: "agent-uuid", // optional
});

// Get CSAT analytics
const csatData = await getAgentCSATAnalytics({
  date_filter: { from: "2024-01-01", to: "2024-12-31" },
});

// Get agent list analytics
const agentListData = await getAgentListAnalytics();

// Get task outcomes
const taskData = await getTaskOutcomes({
  date_filter: { from: "2024-01-01", to: "2024-12-31" },
});

Methods:

MethodParametersReturnsDescription
getAgentChatsAnalytics{ date_filter, agent_id? }unknown[]Get chat volume analytics
getAgentCSATAnalytics{ date_filter, agent_id? }unknown[]Get customer satisfaction analytics
getAgentListAnalytics-unknown[]Get agent performance list
getTaskOutcomes{ date_filter }unknown[]Get task outcome analytics

useIntegrations

Hook for OAuth integration management (Google, Microsoft) for email, calendar, and drive.

import { useIntegrations } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listIntegrations,
  getIntegration,
  connectIntegration,
  disconnectIntegration,
  refreshIntegration,
  updateTriage,
  runEmailTriage,
} = useIntegrations({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all user integrations
const integrations = await listIntegrations();

// Get specific integration
const emailIntegration = await getIntegration("google", "email");

// Connect new integration (returns OAuth URL)
const { authUrl, state } = await connectIntegration({
  provider: "google",
  integrationType: "email",
  redirectUri: "/settings/integrations/callback",
});
window.location.href = authUrl; // Redirect to OAuth

// Disconnect integration
await disconnectIntegration({
  provider: "google",
  integrationType: "email",
});

// Refresh token
const refreshed = await refreshIntegration({
  provider: "google",
  integrationType: "email",
});

// Enable/disable email triage
const updated = await updateTriage({
  provider: "google",
  integrationType: "email",
  triageEnabled: true,
});

// Manually run email triage
const result = await runEmailTriage();
console.log(`Found ${result.emailsFound} emails, created ${result.instancesCreated} instances`);

Methods:

MethodParametersReturnsDescription
listIntegrations-UserIntegration[]List all user integrations
getIntegrationprovider, integrationTypeUserIntegration | nullGet specific integration
connectIntegration{ provider, integrationType, redirectUri }{ authUrl, state }Initiate OAuth connection
disconnectIntegration{ provider, integrationType }booleanDisconnect integration
refreshIntegration{ provider, integrationType }UserIntegration | nullRefresh OAuth token
updateTriage{ provider, integrationType, triageEnabled }UserIntegration | nullUpdate triage setting
runEmailTriage-{ success, emailsFound, instancesCreated }Manually run email triage

useSandbox

Hook for AI-generated HTML sandbox operations. Sandboxes are interactive HTML visualizations created from natural language prompts.

import { useSandbox } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  createSandbox,
  getSandbox,
  updateSandbox,
  listSandboxes,
  deleteSandbox,
} = useSandbox({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// Create a new sandbox from prompt
const result = await createSandbox({
  prompt: "Create an interactive bar chart showing monthly sales data",
  title: "Sales Dashboard",
  libraries: ["chart.js"], // Optional library hints
  style: "dark mode", // Optional style preference
});
console.log(result.url); // Sandbox URL for viewing

// Get sandbox by ID
const sandbox = await getSandbox("sandbox-uuid");

// Update sandbox with new prompt
const updated = await updateSandbox("sandbox-uuid", {
  prompt: "Add a trend line to the chart",
  title: "Sales Dashboard v2",
});

// List all sandboxes
const { sandboxes, total } = await listSandboxes(50); // limit

// Delete sandbox
const success = await deleteSandbox("sandbox-uuid");

Methods:

MethodParametersReturnsDescription
createSandbox{ prompt, title?, libraries?, style? }{ id, url, sandbox? }Create sandbox from prompt
getSandboxsandboxId: stringSandbox | nullGet sandbox by ID
updateSandboxsandboxId: string, { prompt, title? }{ id, url, sandbox? }Update sandbox with prompt
listSandboxeslimit?: number{ sandboxes, total }List all sandboxes
deleteSandboxsandboxId: stringbooleanDelete a sandbox

useSchedulerTasks

Hook for scheduler task operations. Tasks are one-time scheduled jobs that can be snoozed, completed, or started manually.

import { useSchedulerTasks } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listTasks,
  createTask,
  getTask,
  updateTask,
  deleteTask,
  snoozeTask,
  completeTask,
  startTask,
} = useSchedulerTasks({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all tasks
const tasks = await listTasks({ status: "scheduled", limit: 50 });

// Create a new task
const newTask = await createTask({
  name: "Send weekly report",
  description: "Generate and send the weekly analytics report",
  subject: "workflow.execute",
  runAt: Date.now() + 3600000, // 1 hour from now
  fields: { reportType: "weekly", recipients: ["team@example.com"] },
});

// Get task by ID
const task = await getTask("task-uuid");

// Snooze task
const snoozed = await snoozeTask("task-uuid", { amount: 30, unit: "minutes" });

// Complete task manually
const completed = await completeTask("task-uuid");

// Start task immediately
const started = await startTask("task-uuid");

// Delete task
const success = await deleteTask("task-uuid");

Methods:

MethodParametersReturnsDescription
listTasks{ status?, limit?, offset? }SchedulerTask[]List tasks with optional filters
createTasktask: Partial<SchedulerTask>SchedulerTask | nullCreate a new task
getTasktaskId: stringSchedulerTask | nullGet task by ID
updateTasktaskId: string, updates: Partial<SchedulerTask>SchedulerTask | nullUpdate a task
deleteTasktaskId: stringbooleanDelete a task
snoozeTasktaskId: string, { amount, unit }SchedulerTask | nullSnooze task by duration
completeTasktaskId: stringSchedulerTask | nullMark task as completed
startTasktaskId: stringSchedulerTask | nullStart task immediately

useSchedulerSchedules

Hook for scheduler schedule operations. Schedules are recurring jobs defined with cron expressions.

import { useSchedulerSchedules } from "@elqnt/agents/hooks";

const {
  loading,
  error,
  listSchedules,
  createSchedule,
  getSchedule,
  updateSchedule,
  deleteSchedule,
  pauseSchedule,
  resumeSchedule,
  runSchedule,
} = useSchedulerSchedules({
  baseUrl: apiGatewayUrl,
  orgId: selectedOrgId,
});

// List all schedules
const schedules = await listSchedules({ status: "active", limit: 50 });

// Create a recurring schedule
const newSchedule = await createSchedule({
  name: "Daily email triage",
  cronExpression: "0 9 * * *", // 9am daily
  action: {
    type: "email_triage",
    emailQuery: "is:unread",
  },
});

// Get schedule by ID
const schedule = await getSchedule("schedule-uuid");

// Pause schedule
const paused = await pauseSchedule("schedule-uuid");

// Resume schedule
const resumed = await resumeSchedule("schedule-uuid");

// Run schedule immediately (trigger next execution)
const ran = await runSchedule("schedule-uuid");

// Delete schedule
const success = await deleteSchedule("schedule-uuid");

Methods:

MethodParametersReturnsDescription
listSchedules{ status?, limit?, offset? }SchedulerSchedule[]List schedules with optional filters
createScheduleschedule: Partial<SchedulerSchedule>SchedulerSchedule | nullCreate a recurring schedule
getSchedulescheduleId: stringSchedulerSchedule | nullGet schedule by ID
updateSchedulescheduleId: string, updates: Partial<SchedulerSchedule>SchedulerSchedule | nullUpdate a schedule
deleteSchedulescheduleId: stringbooleanDelete a schedule
pauseSchedulescheduleId: stringSchedulerSchedule | nullPause a schedule
resumeSchedulescheduleId: stringSchedulerSchedule | nullResume a paused schedule
runSchedulescheduleId: stringSchedulerSchedule | nullTrigger immediate execution

Server API (SSR)

Server-side functions for Next.js Server Actions, API routes, and SSR. These generate JWT tokens internally.

import {
  listAgentsServer,
  getAgentServer,
  listSkillsServer,
  listSubAgentsServer,
  listToolDefinitionsServer,
  listAgentJobsServer,
  listWidgetsServer,
} from "@elqnt/agents/api/server";

// In a Next.js Server Action
"use server";

export async function getAgentsList(orgId: string) {
  const response = await listAgentsServer({
    gatewayUrl: process.env.API_GATEWAY_URL!,
    jwtSecret: process.env.JWT_SECRET!,
    orgId,
    userId: "system",
  });
  return response.data?.agents || [];
}

// Get single agent
const agent = await getAgentServer("agent-uuid", {
  gatewayUrl: process.env.API_GATEWAY_URL!,
  jwtSecret: process.env.JWT_SECRET!,
  orgId,
});

ServerApiOptions:

interface ServerApiOptions {
  gatewayUrl: string;  // API Gateway URL
  jwtSecret: string;   // JWT secret for token generation
  orgId: string;       // Organization ID
  userId?: string;     // User ID (defaults to "system")
  userEmail?: string;  // User email
  timeout?: number;    // Request timeout in ms
  cache?: RequestCache; // Cache strategy
}

Available Server Functions:

CategoryFunctions
AgentslistAgentsServer, getAgentServer, createAgentServer, updateAgentServer, deleteAgentServer, getDefaultAgentServer
SkillslistSkillsServer, getSkillServer, createSkillServer, updateSkillServer, deleteSkillServer, getSkillCategoriesServer
Sub-AgentslistSubAgentsServer, getSubAgentServer, createSubAgentServer, updateSubAgentServer, deleteSubAgentServer
Tool DefinitionslistToolDefinitionsServer, getToolDefinitionServer, createToolDefinitionServer, updateToolDefinitionServer, deleteToolDefinitionServer
Agent JobslistAgentJobsServer, getAgentJobServer, createAgentJobServer, updateAgentJobServer, deleteAgentJobServer, pauseAgentJobServer, resumeAgentJobServer
WidgetslistWidgetsServer, getWidgetServer, createWidgetServer, updateWidgetServer, deleteWidgetServer, getDefaultWidgetServer
Skill ConfiggetSkillUserConfigServer, updateSkillUserConfigServer, deleteSkillUserConfigServer, listSkillUserConfigsServer, resolveSkillConfigServer

Provisioning API

Function for bulk provisioning agents, skills, and tools.

import { provisionAgentsApi } from "@elqnt/agents/api";

// Provision default agents for a new organization
const result = await provisionAgentsApi(
  agentDefinitions,
  { baseUrl: config.apiGatewayUrl, orgId: config.orgId }
);

// Result:
// {
//   agents: Agent[],
//   agentsCreated: number,
//   subAgentsCreated: number,
//   toolsCreated: number,
//   skillsCreated: number,
//   success: boolean
// }

Models

Agent

import type { Agent, AgentSummary } from "@elqnt/agents/models";

interface Agent {
  id?: string;
  orgId: string;
  name: string;
  description?: string;
  goal?: string;
  systemPrompt?: string;
  model: string;
  temperature?: number;
  maxTokens?: number;
  tools?: AgentTool[];
  skills?: AgentSkill[];
  subAgentIds?: string[];
  status: AgentStatusTS;
  isDefault?: boolean;
  contextConfig?: AgentContextConfig;
  createdAt?: number;
  updatedAt?: number;
}

interface AgentSummary {
  id: string;
  name: string;
  description?: string;
  status: AgentStatusTS;
  isDefault?: boolean;
}

Skill

import type { Skill, SkillUserConfig } from "@elqnt/agents/models";

interface Skill {
  id?: string;
  name: string;
  description: string;
  category: string;
  icon?: string;
  toolDefinitionIds?: string[];
  enabled: boolean;
  isSystem: boolean;
  configSchema?: JSONSchema;
  defaultConfig?: Record<string, unknown>;
  createdAt?: number;
  updatedAt?: number;
}

interface SkillUserConfig {
  id?: string;
  skillId: string;
  userId: string;
  orgId: string;
  agentId?: string;
  enabled: boolean;
  displayOrder: number;
  config?: Record<string, unknown>;
  createdAt?: number;
  updatedAt?: number;
}

SubAgent

import type { SubAgent } from "@elqnt/agents/models";

interface SubAgent {
  id?: string;
  name: string;
  description: string;
  model: string;
  systemPrompt?: string;
  toolDefinitionIds?: string[];
  enabled: boolean;
  isSystem: boolean;
  createdAt?: number;
  updatedAt?: number;
}

ToolDefinition

import type { ToolDefinition } from "@elqnt/agents/models";

interface ToolDefinition {
  id?: string;
  name: string;
  description: string;
  inputSchema?: JSONSchema;
  outputSchema?: JSONSchema;
  toolType: ToolTypeTS;
  config?: Record<string, unknown>;
  enabled: boolean;
  isSystem: boolean;
  createdAt?: number;
  updatedAt?: number;
}

AgentJob

import type { AgentJob } from "@elqnt/agents/models";

interface AgentJob {
  id?: string;
  agentId: string;
  name: string;
  description?: string;
  schedule: string; // Cron expression
  prompt: string;
  frequency: JobFrequencyTS;
  status: JobStatusTS;
  scope: JobScopeTS;
  ownerId: string;
  lastRunAt?: number;
  nextRunAt?: number;
  createdAt?: number;
  updatedAt?: number;
}

AgentWidget

import type { AgentWidget } from "@elqnt/agents/models";

interface AgentWidget {
  id?: string;
  widgetId: string; // Public widget ID for embedding
  agentId: string;
  name: string;
  isDefault: boolean;
  theme?: WidgetTheme;
  placement?: string;
  welcomeMessage?: string;
  suggestedPrompts?: string[];
  allowedDomains?: string[];
  createdAt?: number;
  updatedAt?: number;
}

AgentContext

import type { AgentContext, AgentExecution } from "@elqnt/agents/models";

interface AgentContext {
  orgId: string;
  agentId: string;
  chatKey: string;
  schema: JSONSchema;
  variables: Record<string, unknown>;
  executions: AgentExecution[];
  pendingPlan?: ExecutionPlan;
  completedPlans?: ExecutionPlan[];
  createdAt: number;
  lastUpdated: number;
}

interface AgentExecution {
  id: string;
  toolName: string;
  title: string;
  type: string;
  status: ExecutionStatusTS;
  input: Record<string, unknown>;
  output?: Record<string, unknown>;
  startedAt: number;
  completedAt?: number;
}

Organization Settings

import type { OrgSettings } from "@elqnt/agents/models";

interface OrgSettings {
  id: string;
  orgId: string;
  title: string;
  description: string;
  logoUrl: string;
  defaultLang: string;
  timezone: string;
  additionalSettings: Record<string, unknown>;
}

Integration Types

OAuth integrations for email, calendar, and drive services.

import type {
  UserIntegration,
  OrgIntegration,
  IntegrationProviderTS,
  IntegrationTypeTS,
  IntegrationStatusTS,
} from "@elqnt/agents/models";

// Providers
type IntegrationProviderTS = "google" | "microsoft";

// Integration Types
type IntegrationTypeTS = "email" | "calendar" | "drive";

// Status
type IntegrationStatusTS = "active" | "expired" | "revoked" | "error";

// Enterprise Mode
type IntegrationMode = "service_principal" | "domain_delegation";

interface UserIntegration {
  id: string;
  org_id: string;
  user_id: string;
  provider: IntegrationProviderTS;
  integration_type: IntegrationTypeTS;
  account_email: string;
  account_name?: string;
  status: IntegrationStatusTS;
  scopes: string[];
  triage_enabled: boolean;
  last_used_at?: string;
  last_error?: string;
  created_at: string;
  updated_at: string;
  expires_at?: string;
}

interface OrgIntegration {
  id: string;
  org_id: string;
  provider: IntegrationProviderTS;
  integration_type: IntegrationTypeTS;
  mode: IntegrationMode;
  domain?: string;
  enabled: boolean;
  config?: Record<string, any>;
  scopes: string[];
  created_by: string;
  created_at: string;
  updated_at: string;
}

Email Types

import type { EmailSummary, EmailDetails, EmailAttachment } from "@elqnt/agents/models";

interface EmailSummary {
  id: string;
  thread_id?: string;
  from: string;
  from_name?: string;
  to: string[];
  cc?: string[];
  subject: string;
  snippet: string;
  date: string;
  has_attachments: boolean;
  is_read: boolean;
  labels?: string[];
  web_link?: string;
  provider?: IntegrationProviderTS;
}

interface EmailDetails {
  id: string;
  thread_id?: string;
  from: string;
  from_name?: string;
  to: string[];
  cc?: string[];
  bcc?: string[];
  subject: string;
  body: string;
  body_html?: string;
  date: string;
  attachments?: EmailAttachment[];
  labels?: string[];
  is_read: boolean;
  web_link?: string;
  provider?: IntegrationProviderTS;
}

interface EmailAttachment {
  id: string;
  filename: string;
  mime_type: string;
  size: number;
}

interface SendEmailResult {
  message_id: string;
  thread_id?: string;
  success: boolean;
  error?: string;
}

Calendar Types

import type { CalendarEvent, EventAttendee, EventReminder } from "@elqnt/agents/models";

interface CalendarEvent {
  id: string;
  title: string;
  description?: string;
  location?: string;
  start: string;
  end: string;
  is_all_day: boolean;
  organizer?: string;
  organizer_name?: string;
  attendees?: EventAttendee[];
  status?: "confirmed" | "tentative" | "cancelled";
  response_status?: "accepted" | "declined" | "tentative" | "needsAction";
  recurrence_rule?: string;
  conference_url?: string;
  calendar_id?: string;
  provider?: IntegrationProviderTS;
}

interface EventAttendee {
  email: string;
  name?: string;
  response_status?: string;
  is_organizer?: boolean;
}

interface EventReminder {
  method: "email" | "popup";
  minutes: number;
}

Drive Types

import type { FileSummary, FileDetails, FilePermission } from "@elqnt/agents/models";

interface FileSummary {
  id: string;
  name: string;
  mime_type: string;
  size: number;
  modified_time: string;
  created_time?: string;
  owner?: string;
  owner_email?: string;
  web_link?: string;
  icon_link?: string;
  thumbnail_link?: string;
  is_folder: boolean;
  parent_id?: string;
  provider?: IntegrationProviderTS;
}

interface FileDetails {
  id: string;
  name: string;
  mime_type: string;
  size: number;
  modified_time: string;
  created_time?: string;
  owner?: string;
  owner_email?: string;
  description?: string;
  web_link?: string;
  download_link?: string;
  icon_link?: string;
  thumbnail_link?: string;
  is_folder: boolean;
  parent_id?: string;
  parent_name?: string;
  shared_with?: FilePermission[];
  provider?: IntegrationProviderTS;
}

interface FilePermission {
  email: string;
  name?: string;
  role: "owner" | "writer" | "reader";
}

Sandbox Types

AI-generated HTML sandboxes for interactive visualizations and tools.

import type {
  Sandbox,
  CreateSandboxRequest,
  CreateSandboxResponse,
  UpdateSandboxRequest,
  ListSandboxesResponse,
} from "@elqnt/agents/models";

import {
  CreateSandboxSubject,   // "agents.tool.execute.sandbox.create"
  GetSandboxSubject,      // "agents.tool.execute.sandbox.get"
  UpdateSandboxSubject,   // "agents.tool.execute.sandbox.update"
  ListSandboxSubject,     // "agents.tool.execute.sandbox.list"
  DeleteSandboxSubject,   // "agents.tool.execute.sandbox.delete"
} from "@elqnt/agents/models";

interface Sandbox {
  id: string;
  orgId?: string;
  userId?: string;
  html: string;
  title?: string;
  description?: string;
  url?: string;               // Sandbox URL for viewing
  metadata?: Record<string, string>;
  createdAt: string;
  expiresAt: string;
}

interface CreateSandboxRequest {
  orgId: string;
  userId?: string;
  prompt: string;             // Description of what to create
  title?: string;
  description?: string;
  libraries?: string[];       // Library hints: "d3", "chart.js", "three.js"
  style?: string;             // Style preference: "dark mode", "minimal"
}

interface CreateSandboxResponse {
  sandbox?: Sandbox;
  id: string;
  url: string;
  metadata: ResponseMetadata;
}

interface UpdateSandboxRequest {
  id: string;
  orgId: string;
  userId?: string;
  prompt: string;             // Description of changes to make
  title?: string;
}

interface ListSandboxesResponse {
  sandboxes: Sandbox[];
  total: number;
  metadata: ResponseMetadata;
}

Scheduler Types

Scheduled tasks and recurring schedules for automated job execution.

import type {
  SchedulerTask,
  SchedulerSchedule,
} from "@elqnt/agents/api";

interface SchedulerTask {
  id: string;
  orgId: string;
  userId?: string;
  name?: string;
  description?: string;
  subject: string;              // NATS subject to publish to
  fields?: Record<string, unknown>; // Payload data
  status: "scheduled" | "running" | "in-progress" | "completed" | "failed" | "cancelled";
  progress: number;             // 0-100
  runAt: number;                // Unix timestamp
  delay?: {
    amount?: number;
    unit?: string;              // "minutes", "hours", "days"
  };
  recurring?: boolean;
  cronExpr?: string;
  output?: Record<string, unknown>;
  error?: string;
  startedAt?: number;
  completedAt?: number;
  createdAt?: number;
  updatedAt?: number;
}

interface SchedulerSchedule {
  id: string;
  orgId: string;
  userId: string;
  name: string;
  description?: string;
  cronExpression: string;       // e.g., "0 9 * * *" (9am daily)
  timezone?: string;            // e.g., "America/New_York"
  status: "active" | "paused" | "failed" | "deleted";
  action: {
    type: string;               // e.g., "email_triage", "workflow_execute"
    emailQuery?: string;        // For email triage actions
    taskTemplate?: {
      subject: string;
      fields?: Record<string, unknown>;
    };
  };
  lastRunAt?: number;
  nextRunAt?: number;
  runCount?: number;
  failCount?: number;
  lastError?: string;
  createdAt?: number;
  updatedAt?: number;
}

NATS Subjects

For backend service communication:

import {
  AgentsSubjects,
  SettingsSubjects,
  // Integration subjects
  HubIntegrationUserList,
  HubIntegrationUserGet,
  HubIntegrationUserConnect,
  HubIntegrationUserCallback,
  HubIntegrationUserDisconnect,
  HubIntegrationUserRefresh,
  HubIntegrationUserUpdateTriage,
  HubIntegrationEmailSearch,
  HubIntegrationEmailGet,
  HubIntegrationEmailSend,
  HubIntegrationCalendarList,
  HubIntegrationCalendarCreate,
  HubIntegrationDriveSearch,
} from "@elqnt/agents/models";

// Agent subjects
AgentsSubjects.agentGet;      // "agents.get"
AgentsSubjects.agentCreate;   // "agents.create"
AgentsSubjects.agentUpdate;   // "agents.update"
AgentsSubjects.agentDelete;   // "agents.delete"
AgentsSubjects.agentsList;    // "agents.list"

// Settings subjects
SettingsSubjects.orgSettingsGet;     // "hub.org-settings.get"
SettingsSubjects.orgSettingsUpdate;  // "hub.org-settings.update"

// Integration - User Management
HubIntegrationUserList;       // "hub.integrations.user.list"
HubIntegrationUserGet;        // "hub.integrations.user.get"
HubIntegrationUserConnect;    // "hub.integrations.user.connect"
HubIntegrationUserCallback;   // "hub.integrations.user.callback"
HubIntegrationUserDisconnect; // "hub.integrations.user.disconnect"
HubIntegrationUserRefresh;    // "hub.integrations.user.refresh"
HubIntegrationUserUpdateTriage; // "hub.integrations.user.triage.update"

// Integration - Org Management (Enterprise)
HubIntegrationOrgList;        // "hub.integrations.org.list"
HubIntegrationOrgConfigure;   // "hub.integrations.org.configure"
HubIntegrationOrgDisable;     // "hub.integrations.org.disable"

// Integration - Email Operations
HubIntegrationEmailSearch;    // "hub.integrations.email.search"
HubIntegrationEmailGet;       // "hub.integrations.email.get"
HubIntegrationEmailThread;    // "hub.integrations.email.thread"
HubIntegrationEmailSend;      // "hub.integrations.email.send"
HubIntegrationEmailArchive;   // "hub.integrations.email.archive"
HubIntegrationEmailMarkRead;  // "hub.integrations.email.markread"
HubIntegrationEmailForward;   // "hub.integrations.email.forward"
HubEmailTriageRunNow;         // "hub.email.triage.run"

// Integration - Calendar Operations
HubIntegrationCalendarList;   // "hub.integrations.calendar.list"
HubIntegrationCalendarGet;    // "hub.integrations.calendar.get"
HubIntegrationCalendarCreate; // "hub.integrations.calendar.create"
HubIntegrationCalendarUpdate; // "hub.integrations.calendar.update"
HubIntegrationCalendarDelete; // "hub.integrations.calendar.delete"
HubIntegrationCalendarRSVP;   // "hub.integrations.calendar.rsvp"

// Integration - Drive Operations
HubIntegrationDriveSearch;    // "hub.integrations.drive.search"
HubIntegrationDriveGet;       // "hub.integrations.drive.get"

// Integration - Setup
HubIntegrationSetupOrg;       // "hub.integrations.setup.org"

API Gateway Routes

FunctionMethodGateway Route
Agents
ListGET/api/v1/agents
List SummaryGET/api/v1/agents/summary
GetGET/api/v1/agents/{agentId}
Get DefaultGET/api/v1/agents/default
Get by NameGET/api/v1/agents/by-name
CreatePOST/api/v1/agents
UpdatePUT/api/v1/agents/{agentId}
DeleteDELETE/api/v1/agents/{agentId}
Skills
ListGET/api/v1/skills
GetGET/api/v1/skills/{skillId}
Get by IDsPOST/api/v1/skills/by-ids
SearchGET/api/v1/skills/search
CategoriesGET/api/v1/skills/categories
CreatePOST/api/v1/skills
UpdatePUT/api/v1/skills/{skillId}
DeleteDELETE/api/v1/skills/{skillId}
Skill User Config
GetGET/api/v1/skills/{skillId}/user-config
UpdatePUT/api/v1/skills/{skillId}/user-config
DeleteDELETE/api/v1/skills/{skillId}/user-config
ListGET/api/v1/skills/user-configs
ResolveGET/api/v1/skills/{skillId}/resolve-config
Sub-Agents
ListGET/api/v1/subagents
GetGET/api/v1/subagents/{subAgentId}
CreatePOST/api/v1/subagents
UpdatePUT/api/v1/subagents/{subAgentId}
DeleteDELETE/api/v1/subagents/{subAgentId}
Tool Definitions
ListGET/api/v1/tool-definitions
GetGET/api/v1/tool-definitions/{toolDefId}
Get by IDsPOST/api/v1/tool-definitions/by-ids
CreatePOST/api/v1/tool-definitions
UpdatePUT/api/v1/tool-definitions/{toolDefId}
DeleteDELETE/api/v1/tool-definitions/{toolDefId}
Agent Jobs
ListGET/api/v1/agent-jobs
GetGET/api/v1/agent-jobs/{jobId}
CreatePOST/api/v1/agent-jobs
UpdatePUT/api/v1/agent-jobs/{jobId}
DeleteDELETE/api/v1/agent-jobs/{jobId}
PausePOST/api/v1/agent-jobs/{jobId}/pause
ResumePOST/api/v1/agent-jobs/{jobId}/resume
Widgets
ListGET/api/v1/agents/{agentId}/widgets
Get DefaultGET/api/v1/agents/{agentId}/widgets/default
CreatePOST/api/v1/agents/{agentId}/widgets
GetGET/api/v1/widgets/{widgetId}
Get by Widget IDGET/api/v1/widgets/by-widget-id/{widgetId}
UpdatePUT/api/v1/widgets/{widgetId}
DeleteDELETE/api/v1/widgets/{widgetId}
Set DefaultPOST/api/v1/widgets/{widgetId}/default
Analytics
ChatsPOST/api/v1/analytics/agents/chats
CSATPOST/api/v1/analytics/agents/csat
Agent ListGET/api/v1/analytics/agents
Task OutcomesPOST/api/v1/analytics/tasks
Provisioning
ProvisionPOST/api/v1/admin/provision/agents
Integrations
ListGET/api/v1/integrations
GetGET/api/v1/integrations/{provider}/{type}
ConnectPOST/api/v1/integrations/connect
CallbackPOST/api/v1/integrations/callback
DisconnectPOST/api/v1/integrations/disconnect
RefreshPOST/api/v1/integrations/refresh
Update TriagePUT/api/v1/integrations/triage
Run TriagePOST/api/v1/integrations/triage/run
Sandbox
CreatePOST/api/v1/sandbox
GetGET/api/v1/sandbox/{sandboxId}
UpdatePUT/api/v1/sandbox/{sandboxId}
ListGET/api/v1/sandbox
DeleteDELETE/api/v1/sandbox/{sandboxId}
Scheduler Tasks
ListGET/api/v1/scheduler/tasks
CreatePOST/api/v1/scheduler/tasks
GetGET/api/v1/scheduler/tasks/{taskId}
UpdatePUT/api/v1/scheduler/tasks/{taskId}
DeleteDELETE/api/v1/scheduler/tasks/{taskId}
SnoozePOST/api/v1/scheduler/tasks/{taskId}/snooze
CompletePOST/api/v1/scheduler/tasks/{taskId}/complete
StartPOST/api/v1/scheduler/tasks/{taskId}/start
Scheduler Schedules
ListGET/api/v1/scheduler/schedules
CreatePOST/api/v1/scheduler/schedules
GetGET/api/v1/scheduler/schedules/{scheduleId}
UpdatePUT/api/v1/scheduler/schedules/{scheduleId}
DeleteDELETE/api/v1/scheduler/schedules/{scheduleId}
PausePOST/api/v1/scheduler/schedules/{scheduleId}/pause
ResumePOST/api/v1/scheduler/schedules/{scheduleId}/resume
RunPOST/api/v1/scheduler/schedules/{scheduleId}/run

Type Generation

Agent types are generated from Go using tygo:

cd backend && tygo generate
Go PackageTypeScript Output
blazi/common/agents@elqnt/agents/models/agent-models.ts
blazi/common/hub@elqnt/agents/models/hub.ts
blazi/common/integration@elqnt/agents/models/integration.ts

See Also