import * as tasksApi from '../api/tasks'; import * as escalationsApi from '../api/escalations'; import * as workflowsApi from '../api/workflows'; import * as yamlWorkflowsApi from '../api/yaml-workflows'; import * as usersApi from '../api/users'; import * as rolesApi from '../api/roles'; import * as authApi from '../api/auth'; import * as mcpApi from '../api/mcp'; import * as pipelinesApi from '../api/pipelines'; import * as insightApi from '../api/insight'; import * as settingsApi from '../api/settings'; import * as exportsApi from '../api/exports'; import * as controlplaneApi from '../api/controlplane'; import * as botAccountsApi from '../api/bot-accounts'; import * as workflowSetsApi from '../api/workflow-sets'; import * as dbaApi from '../api/dba'; import * as namespacesApi from '../api/namespaces'; import * as maintenanceApi from '../api/maintenance'; import * as filesApi from '../api/files'; import * as knowledgeApi from '../api/knowledge'; import * as agentsApi from '../api/agents'; import * as agentSubsApi from '../api/agent-subscriptions'; import type { LTApiAuth, LTApiResult } from '../types/sdk'; import type { LTEvent, LTEventType } from '../types/events'; /** * Options for createClient. */ export interface LTClientOptions { /** Default auth context bound to every API call. Override per-call if needed. */ auth?: LTApiAuth; } /** * Create a Long Tail SDK client for direct in-process API calls. * * All operations go through the same API layer as HTTP routes — * same validation, same RBAC, same event publishing — without * HTTP transport overhead. * * ```typescript * import { createClient } from '@hotmeshio/long-tail/sdk'; * * const lt = createClient({ auth: { userId: 'system' } }); * * const result = await lt.escalations.claim({ id: 'esc_123', durationMinutes: 30 }); * // { status: 200, data: { escalation: {...}, isExtension: false } } * * lt.events.on('escalation.claimed', (event) => { * console.log('claimed:', event.escalationId); * }); * ``` */ export declare function createClient(options?: LTClientOptions): { tasks: { create: (input: { workflow_id: string; workflow_type: string; lt_type: string; task_queue?: string; signal_id: string; parent_workflow_id: string; origin_id?: string; parent_id?: string; envelope?: string; metadata?: Record; priority?: number; trace_id?: string; span_id?: string; }, auth?: LTApiAuth) => Promise>; list: typeof tasksApi.listTasks; get: typeof tasksApi.getTask; listProcesses: typeof tasksApi.listProcesses; getProcess: typeof tasksApi.getProcess; getProcessStats: typeof tasksApi.getProcessStats; }; escalations: { create: (input: { type: string; subtype?: string; role: string; description?: string; priority?: number; envelope?: string; metadata?: Record; escalation_payload?: string; }, auth?: LTApiAuth) => Promise>; list: (input: { status?: string; role?: string; type?: string; subtype?: string; assigned_to?: string; claimed?: boolean; priority?: number; limit?: number; offset?: number; sort_by?: string; order?: string; search?: string; }, auth?: LTApiAuth) => Promise>; listAvailable: (input: { role?: string; type?: string; subtype?: string; priority?: number; limit?: number; offset?: number; sort_by?: string; order?: string; search?: string; }, auth?: LTApiAuth) => Promise>; listTypes: typeof escalationsApi.listDistinctTypes; getStats: (input: { period?: string; }, auth?: LTApiAuth) => Promise>; get: (input: { id: string; }, auth?: LTApiAuth) => Promise>; getByWorkflowId: typeof escalationsApi.getEscalationsByWorkflowId; escalate: (input: { id: string; targetRole: string; }, auth?: LTApiAuth) => Promise>; claim: (input: { id: string; durationMinutes?: number; provisionIfAbsent?: import("../api/escalations/helpers").ProvisionIfAbsent; }, auth?: LTApiAuth) => Promise>; release: (input: { id: string; }, auth?: LTApiAuth) => Promise>; resolve: (input: { id: string; resolverPayload: Record; }, auth?: LTApiAuth) => Promise>; releaseExpired: typeof escalationsApi.releaseExpiredClaims; updatePriority: (input: { ids: string[]; priority: number; }, auth?: LTApiAuth) => Promise>; bulkClaim: (input: { ids: string[]; durationMinutes?: number; }, auth?: LTApiAuth) => Promise>; bulkAssign: (input: { ids: string[]; targetUserId: string; durationMinutes?: number; }, auth?: LTApiAuth) => Promise>; bulkEscalate: (input: { ids: string[]; targetRole: string; }, auth?: LTApiAuth) => Promise>; bulkTriage: (input: { ids: string[]; hint?: string; }, auth?: LTApiAuth) => Promise>; findByMetadata: (input: { key: string; value: string; status?: string; limit?: number; offset?: number; }, auth?: LTApiAuth) => Promise>; claimByMetadata: (input: { key: string; value: string; durationMinutes?: number; assignee?: string; metadata?: Record; provisionIfAbsent?: import("../api/escalations/helpers").ProvisionIfAbsent; }, auth?: LTApiAuth) => Promise>; resolveByMetadata: (input: { key: string; value: string; resolverPayload: Record; assignee?: string; metadata?: Record; }, auth?: LTApiAuth) => Promise>; }; workflows: { invoke: (input: { type: string; data?: Record; metadata?: Record; execute_as?: string; options?: Record; }, auth?: LTApiAuth) => Promise>; getStatus: typeof workflowsApi.getWorkflowStatus; getResult: typeof workflowsApi.getWorkflowResult; terminate: typeof workflowsApi.terminateWorkflow; export: typeof workflowsApi.exportWorkflow; listWorkers: typeof workflowsApi.listWorkers; listDiscovered: typeof workflowsApi.listDiscoveredWorkflows; getCronStatus: typeof workflowsApi.getCronStatus; listConfigs: typeof workflowsApi.listWorkflowConfigs; getConfig: typeof workflowsApi.getWorkflowConfig; upsertConfig: typeof workflowsApi.upsertWorkflowConfig; deleteConfig: typeof workflowsApi.deleteWorkflowConfig; }; yamlWorkflows: { list: typeof yamlWorkflowsApi.listYamlWorkflows; create: typeof yamlWorkflowsApi.createYamlWorkflow; createDirect: typeof yamlWorkflowsApi.createYamlWorkflowDirect; getAppIds: typeof yamlWorkflowsApi.getAppIds; get: typeof yamlWorkflowsApi.getYamlWorkflow; update: typeof yamlWorkflowsApi.updateYamlWorkflow; regenerate: typeof yamlWorkflowsApi.regenerateYamlWorkflow; delete: typeof yamlWorkflowsApi.deleteYamlWorkflow; deploy: typeof yamlWorkflowsApi.deployYamlWorkflow; activate: typeof yamlWorkflowsApi.activateYamlWorkflow; invoke: (input: { id: string; data?: any; sync?: boolean; timeout?: number; execute_as?: string; }, auth?: LTApiAuth) => Promise>; archive: typeof yamlWorkflowsApi.archiveYamlWorkflow; getVersionHistory: typeof yamlWorkflowsApi.getVersionHistory; getVersionSnapshot: typeof yamlWorkflowsApi.getVersionSnapshot; getYamlContent: typeof yamlWorkflowsApi.getYamlContent; setCronSchedule: typeof yamlWorkflowsApi.setCronSchedule; clearCronSchedule: typeof yamlWorkflowsApi.clearCronSchedule; getCronStatus: typeof yamlWorkflowsApi.getCronStatus; }; users: { list: typeof usersApi.listUsers; get: typeof usersApi.getUser; create: typeof usersApi.createUser; update: typeof usersApi.updateUser; delete: typeof usersApi.deleteUser; getRoles: typeof usersApi.getUserRoles; addRole: typeof usersApi.addUserRole; removeRole: typeof usersApi.removeUserRole; }; roles: { list: typeof rolesApi.listRoles; listWithDetails: typeof rolesApi.listRolesWithDetails; create: typeof rolesApi.createRole; delete: typeof rolesApi.deleteRole; getEscalationChains: typeof rolesApi.getEscalationChains; addEscalationChain: typeof rolesApi.addEscalationChain; removeEscalationChain: typeof rolesApi.removeEscalationChain; getEscalationTargets: typeof rolesApi.getEscalationTargets; replaceEscalationTargets: typeof rolesApi.replaceEscalationTargets; }; auth: { login: typeof authApi.login; }; mcp: { listServers: typeof mcpApi.listMcpServers; createServer: typeof mcpApi.createMcpServer; testConnection: typeof mcpApi.testConnection; getServer: typeof mcpApi.getMcpServer; updateServer: typeof mcpApi.updateMcpServer; deleteServer: typeof mcpApi.deleteMcpServer; connectServer: typeof mcpApi.connectMcpServer; disconnectServer: typeof mcpApi.disconnectMcpServer; getCredentialStatus: (input: { id: string; }, auth?: LTApiAuth) => Promise>; listTools: typeof mcpApi.listMcpServerTools; callTool: (input: { id: string; toolName: string; arguments?: Record; execute_as?: string; }, auth?: LTApiAuth) => Promise>; }; pipelines: { listEntities: typeof pipelinesApi.listEntities; listJobs: typeof pipelinesApi.listJobs; getExecution: typeof pipelinesApi.getJobExecution; interrupt: typeof pipelinesApi.interruptJob; }; /** @deprecated Use `pipelines` */ mcpRuns: { listEntities: typeof pipelinesApi.listEntities; listJobs: typeof pipelinesApi.listJobs; getExecution: typeof pipelinesApi.getJobExecution; }; insight: { mcpQuery: (input: { prompt: string; tags?: string[]; wait?: boolean; direct?: boolean; context?: any; }, auth?: LTApiAuth) => Promise>; buildWorkflow: (input: { prompt: string; tags?: string[]; wait?: boolean; feedback?: string; prior_yaml?: string; answers?: any; prior_questions?: any; }, auth?: LTApiAuth) => Promise>; refineWorkflow: (input: { prompt: string; prior_yaml: string; feedback: string; tags?: string[]; wait?: boolean; }, auth?: LTApiAuth) => Promise>; describeWorkflow: typeof insightApi.describeWorkflow; }; settings: { get: typeof settingsApi.getSettings; }; exports: { listJobs: typeof exportsApi.listJobs; exportState: typeof exportsApi.exportWorkflowState; exportExecution: typeof exportsApi.exportWorkflowExecution; getStatus: typeof exportsApi.getWorkflowStatus; getState: typeof exportsApi.getWorkflowState; }; controlplane: { listApps: typeof controlplaneApi.listApps; rollCall: typeof controlplaneApi.rollCall; throttle: typeof controlplaneApi.applyThrottle; getStreamStats: typeof controlplaneApi.getStreamStats; listStreamMessages: typeof controlplaneApi.listStreamMessages; subscribe: typeof controlplaneApi.subscribeMesh; }; botAccounts: { list: typeof botAccountsApi.listBots; get: typeof botAccountsApi.getBot; create: (input: { name: string; description?: string; display_name?: string; roles?: { role: string; type: string; }[]; }, auth?: LTApiAuth) => Promise>; update: typeof botAccountsApi.updateBot; delete: typeof botAccountsApi.deleteBot; getRoles: typeof botAccountsApi.getBotRoles; addRole: typeof botAccountsApi.addBotRole; removeRole: typeof botAccountsApi.removeBotRole; listKeys: typeof botAccountsApi.listBotKeys; createKey: typeof botAccountsApi.createBotKey; revokeKey: typeof botAccountsApi.revokeBotKey; }; workflowSets: { create: (input: { name: string; description?: string; specification: string; }, auth?: LTApiAuth) => Promise>; list: typeof workflowSetsApi.listWorkflowSets; get: typeof workflowSetsApi.getWorkflowSet; updatePlan: typeof workflowSetsApi.updateWorkflowSetPlanApi; build: typeof workflowSetsApi.buildWorkflowSet; deploy: typeof workflowSetsApi.deployWorkflowSet; }; dba: { prune: typeof dbaApi.prune; deploy: typeof dbaApi.deploy; }; namespaces: { list: typeof namespacesApi.listNamespaces; register: typeof namespacesApi.registerNamespace; }; maintenance: { getConfig: typeof maintenanceApi.getMaintenanceConfig; updateConfig: typeof maintenanceApi.updateMaintenanceConfig; }; files: { browse: typeof filesApi.browseFiles; getMetadata: typeof filesApi.getFileMetadata; delete: typeof filesApi.deleteFile; generateSignedUrl: typeof filesApi.generateSignedUrl; }; knowledge: { listDomains: typeof knowledgeApi.listDomains; listEntries: typeof knowledgeApi.listEntries; getEntry: typeof knowledgeApi.getEntry; storeEntry: typeof knowledgeApi.storeEntry; setField: typeof knowledgeApi.setField; removeField: typeof knowledgeApi.removeField; deleteEntry: typeof knowledgeApi.deleteEntry; }; agents: { list: (input?: Parameters[0]) => Promise>; get: typeof agentsApi.getAgent; create: (input: Parameters[0]) => Promise>; update: typeof agentsApi.updateAgent; delete: typeof agentsApi.deleteAgent; listSubscriptions: typeof agentSubsApi.listSubscriptions; createSubscription: typeof agentSubsApi.createSubscription; updateSubscription: typeof agentSubsApi.updateSubscription; deleteSubscription: typeof agentSubsApi.deleteSubscription; }; events: { /** * Subscribe to Long Tail events. * * Supports exact types (`'task.created'`), category wildcards (`'task.*'`), * and global wildcard (`'*'`). * * Returns an unsubscribe function. * * ```typescript * const unsub = lt.events.on('escalation.claimed', (event) => { * console.log('claimed:', event.escalationId); * }); * // Later: unsub(); * ``` */ on: (pattern: LTEventType | "*" | (string & {}), callback: (event: LTEvent) => void) => (() => void); }; }; /** The return type of createClient(). */ export type LTClient = ReturnType;