@axiom-lattice/core 2.1.44 → 2.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1744,6 +1744,10 @@ declare abstract class ChunkBuffer {
1744
1744
  * Chunks are appended in order
1745
1745
  */
1746
1746
  abstract addChunk(threadId: string, content: MessageChunk): Promise<void>;
1747
+ /**
1748
+ * Ensure a thread buffer exists before any chunks are emitted.
1749
+ */
1750
+ abstract ensureThread(threadId: string): Promise<void>;
1747
1751
  /**
1748
1752
  * Mark thread as completed (explicit call)
1749
1753
  */
@@ -1829,6 +1833,7 @@ declare class InMemoryChunkBuffer extends ChunkBuffer {
1829
1833
  private getOrCreateBuffer;
1830
1834
  addChunk(threadId: string, messageId: string, content: string): Promise<void>;
1831
1835
  addChunk(threadId: string, content: MessageChunk): Promise<void>;
1836
+ ensureThread(threadId: string): Promise<void>;
1832
1837
  completeThread(threadId: string): Promise<void>;
1833
1838
  abortThread(threadId: string): Promise<void>;
1834
1839
  isThreadActive(threadId: string): Promise<boolean>;
@@ -2259,6 +2264,7 @@ interface PendingMessage {
2259
2264
  createdAt: Date;
2260
2265
  priority?: number;
2261
2266
  command?: CommandParams<unknown>;
2267
+ custom_run_config?: unknown;
2262
2268
  }
2263
2269
  interface PendingQueueMessageInput {
2264
2270
  message: string;
@@ -2290,6 +2296,7 @@ interface AddMessageParams {
2290
2296
  type?: "human" | "system";
2291
2297
  priority?: number;
2292
2298
  command?: CommandParams<unknown>;
2299
+ custom_run_config?: unknown;
2293
2300
  id?: string;
2294
2301
  }
2295
2302
  interface ThreadInfo {
@@ -2303,7 +2310,7 @@ interface ThreadInfo {
2303
2310
  */
2304
2311
  interface IMessageQueueStore {
2305
2312
  addMessage(params: AddMessageParams): Promise<PendingMessage>;
2306
- addMessageAtHead(threadId: string, content: PendingMessageContent, type?: "human" | "system", id?: string, command?: CommandParams<unknown>): Promise<PendingMessage>;
2313
+ addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
2307
2314
  getPendingMessages(threadId: string): Promise<PendingMessage[]>;
2308
2315
  getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
2309
2316
  getQueueSize(threadId: string): Promise<number>;
@@ -2464,7 +2471,7 @@ declare class InMemoryThreadStore implements ThreadStore {
2464
2471
  /**
2465
2472
  * Get all threads for a specific tenant and assistant
2466
2473
  */
2467
- getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
2474
+ getThreadsByAssistantId(tenantId: string, assistantId: string, metadataFilter?: Record<string, string>): Promise<Thread[]>;
2468
2475
  /**
2469
2476
  * Get a thread by ID for a specific tenant
2470
2477
  */
@@ -2871,7 +2878,7 @@ declare class InMemoryThreadMessageQueueStore implements IMessageQueueStore {
2871
2878
  private generateId;
2872
2879
  private getMessagesForThread;
2873
2880
  addMessage(params: AddMessageParams): Promise<PendingMessage>;
2874
- addMessageAtHead(threadId: string, content: PendingMessageContent, type?: "human" | "system", id?: string, command?: CommandParams<unknown>): Promise<PendingMessage>;
2881
+ addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
2875
2882
  getPendingMessages(threadId: string): Promise<PendingMessage[]>;
2876
2883
  getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
2877
2884
  getQueueSize(threadId: string): Promise<number>;
@@ -5103,8 +5110,9 @@ declare class Agent {
5103
5110
  /**
5104
5111
  * Abort the current agent execution
5105
5112
  * This will cancel any ongoing invoke or stream operations
5113
+ * and clear all queued messages (pending + processing)
5106
5114
  */
5107
- abort(): void;
5115
+ abort(): Promise<void>;
5108
5116
  /**
5109
5117
  * Check if the agent is currently being aborted
5110
5118
  */
@@ -5261,4 +5269,53 @@ interface RuntimeModelConfig {
5261
5269
  */
5262
5270
  declare function createModelSelectorMiddleware(): AgentMiddleware;
5263
5271
 
5264
- export { AGENT_TASK_EVENT, type AddMessageParams, Agent, type AgentClient, type AgentExecutor, AgentInstanceManager, type AgentLattice, AgentLatticeManager, type AgentLifecycleEventName, AgentManager, type AgentStreamExecutor, type AgentThreadInterface, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DefaultScheduleClient, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMessageQueueStore, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadMessageQueueStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, type IsolatedLevel, LINE_NUMBER_WIDTH, type LangGraphStateChecker, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, type MessageCompletedEvent, type MessageFailedEvent, type MessageStartedEvent, MessageType, MetricsServerManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type PendingMessage, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, QueueMode, type QueuePendingEvent, type RunSandboxConfig, type RuntimeModelConfig, SandboxFilesystem, SandboxLatticeManager, type SandboxManagerProtocol, SandboxSkillStore, type SandboxSkillStoreOptions, type ScheduleLattice, ScheduleLatticeManager, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, type ThreadBusyEvent, type ThreadIdleEvent, type ThreadInfo, type ThreadQueueConfig, type ThreadState, ThreadStatus, type ThreadStatusChangedEvent, type ToolDefinition, type ToolLattice, ToolLatticeManager, type VectorStoreLatticeInterface, VectorStoreLatticeManager, type WriteResult, agentInstanceManager, agentLatticeManager, buildGrepResultsDict, checkEmptyContent, clearEncryptionKeyCache, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createModelSelectorMiddleware, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createTeamMiddleware, createTeammateTools, createWidgetMiddleware, decrypt, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLatticeWithTenant, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };
5272
+ /**
5273
+ * Unknown Tool Handler Middleware
5274
+ *
5275
+ * Intercepts unknown tools selected by the model and returns error feedback
5276
+ * instead of throwing exceptions.
5277
+ *
5278
+ * Implementation: Uses wrapModelCall to get available tools, then afterModel
5279
+ * to generate error ToolMessages and jump back to the model.
5280
+ *
5281
+ * Key Design Principles:
5282
+ * 1. Preserve all tool_calls in AIMessage (keep model's original intent)
5283
+ * 2. Generate error ToolMessages for unknown tools (preserve tool_call_id mapping)
5284
+ * 3. Use jumpTo to loop back to model node (required for agent loop)
5285
+ * 4. ToolNode will skip tool calls that already have ToolMessages
5286
+ *
5287
+ * Architecture:
5288
+ * - Positioned first in middleware chain (before HITL)
5289
+ * - Shared across all agent types (ReAct, DeepAgent, TeamAgent)
5290
+ * - Injected via createCommonMiddlewares
5291
+ *
5292
+ * @example
5293
+ * ```typescript
5294
+ * middlewares.push(createUnknownToolHandlerMiddleware());
5295
+ * ```
5296
+ */
5297
+
5298
+ interface UnknownToolHandlerConfig {
5299
+ /**
5300
+ * Strategy when encountering unknown tools
5301
+ * - 'error': Return error message to model (default)
5302
+ * - 'strict': Throw exception and terminate
5303
+ */
5304
+ strategy?: 'error' | 'strict';
5305
+ /**
5306
+ * Custom error message template
5307
+ * @param toolName - The unknown tool name requested
5308
+ * @param availableTools - List of currently available tool names
5309
+ * @returns Error message content
5310
+ */
5311
+ errorMessageTemplate?: (toolName: string, availableTools: string[]) => string;
5312
+ }
5313
+ /**
5314
+ * Create unknown tool handler middleware
5315
+ *
5316
+ * @param config - Configuration options
5317
+ * @returns AgentMiddleware instance
5318
+ */
5319
+ declare function createUnknownToolHandlerMiddleware(config?: UnknownToolHandlerConfig): AgentMiddleware;
5320
+
5321
+ export { AGENT_TASK_EVENT, type AddMessageParams, Agent, type AgentClient, type AgentExecutor, AgentInstanceManager, type AgentLattice, AgentLatticeManager, type AgentLifecycleEventName, AgentManager, type AgentStreamExecutor, type AgentThreadInterface, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DefaultScheduleClient, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMessageQueueStore, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadMessageQueueStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, type IsolatedLevel, LINE_NUMBER_WIDTH, type LangGraphStateChecker, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, type MessageCompletedEvent, type MessageFailedEvent, type MessageStartedEvent, MessageType, MetricsServerManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type PendingMessage, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, QueueMode, type QueuePendingEvent, type RunSandboxConfig, type RuntimeModelConfig, SandboxFilesystem, SandboxLatticeManager, type SandboxManagerProtocol, SandboxSkillStore, type SandboxSkillStoreOptions, type ScheduleLattice, ScheduleLatticeManager, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, type ThreadBusyEvent, type ThreadIdleEvent, type ThreadInfo, type ThreadQueueConfig, type ThreadState, ThreadStatus, type ThreadStatusChangedEvent, type ToolDefinition, type ToolLattice, ToolLatticeManager, type UnknownToolHandlerConfig, type VectorStoreLatticeInterface, VectorStoreLatticeManager, type WriteResult, agentInstanceManager, agentLatticeManager, buildGrepResultsDict, checkEmptyContent, clearEncryptionKeyCache, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createModelSelectorMiddleware, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createTeamMiddleware, createTeammateTools, createUnknownToolHandlerMiddleware, createWidgetMiddleware, decrypt, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLatticeWithTenant, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };
package/dist/index.d.ts CHANGED
@@ -1744,6 +1744,10 @@ declare abstract class ChunkBuffer {
1744
1744
  * Chunks are appended in order
1745
1745
  */
1746
1746
  abstract addChunk(threadId: string, content: MessageChunk): Promise<void>;
1747
+ /**
1748
+ * Ensure a thread buffer exists before any chunks are emitted.
1749
+ */
1750
+ abstract ensureThread(threadId: string): Promise<void>;
1747
1751
  /**
1748
1752
  * Mark thread as completed (explicit call)
1749
1753
  */
@@ -1829,6 +1833,7 @@ declare class InMemoryChunkBuffer extends ChunkBuffer {
1829
1833
  private getOrCreateBuffer;
1830
1834
  addChunk(threadId: string, messageId: string, content: string): Promise<void>;
1831
1835
  addChunk(threadId: string, content: MessageChunk): Promise<void>;
1836
+ ensureThread(threadId: string): Promise<void>;
1832
1837
  completeThread(threadId: string): Promise<void>;
1833
1838
  abortThread(threadId: string): Promise<void>;
1834
1839
  isThreadActive(threadId: string): Promise<boolean>;
@@ -2259,6 +2264,7 @@ interface PendingMessage {
2259
2264
  createdAt: Date;
2260
2265
  priority?: number;
2261
2266
  command?: CommandParams<unknown>;
2267
+ custom_run_config?: unknown;
2262
2268
  }
2263
2269
  interface PendingQueueMessageInput {
2264
2270
  message: string;
@@ -2290,6 +2296,7 @@ interface AddMessageParams {
2290
2296
  type?: "human" | "system";
2291
2297
  priority?: number;
2292
2298
  command?: CommandParams<unknown>;
2299
+ custom_run_config?: unknown;
2293
2300
  id?: string;
2294
2301
  }
2295
2302
  interface ThreadInfo {
@@ -2303,7 +2310,7 @@ interface ThreadInfo {
2303
2310
  */
2304
2311
  interface IMessageQueueStore {
2305
2312
  addMessage(params: AddMessageParams): Promise<PendingMessage>;
2306
- addMessageAtHead(threadId: string, content: PendingMessageContent, type?: "human" | "system", id?: string, command?: CommandParams<unknown>): Promise<PendingMessage>;
2313
+ addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
2307
2314
  getPendingMessages(threadId: string): Promise<PendingMessage[]>;
2308
2315
  getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
2309
2316
  getQueueSize(threadId: string): Promise<number>;
@@ -2464,7 +2471,7 @@ declare class InMemoryThreadStore implements ThreadStore {
2464
2471
  /**
2465
2472
  * Get all threads for a specific tenant and assistant
2466
2473
  */
2467
- getThreadsByAssistantId(tenantId: string, assistantId: string): Promise<Thread[]>;
2474
+ getThreadsByAssistantId(tenantId: string, assistantId: string, metadataFilter?: Record<string, string>): Promise<Thread[]>;
2468
2475
  /**
2469
2476
  * Get a thread by ID for a specific tenant
2470
2477
  */
@@ -2871,7 +2878,7 @@ declare class InMemoryThreadMessageQueueStore implements IMessageQueueStore {
2871
2878
  private generateId;
2872
2879
  private getMessagesForThread;
2873
2880
  addMessage(params: AddMessageParams): Promise<PendingMessage>;
2874
- addMessageAtHead(threadId: string, content: PendingMessageContent, type?: "human" | "system", id?: string, command?: CommandParams<unknown>): Promise<PendingMessage>;
2881
+ addMessageAtHead(params: AddMessageParams): Promise<PendingMessage>;
2875
2882
  getPendingMessages(threadId: string): Promise<PendingMessage[]>;
2876
2883
  getProcessingMessages(threadId: string): Promise<PendingMessage[]>;
2877
2884
  getQueueSize(threadId: string): Promise<number>;
@@ -5103,8 +5110,9 @@ declare class Agent {
5103
5110
  /**
5104
5111
  * Abort the current agent execution
5105
5112
  * This will cancel any ongoing invoke or stream operations
5113
+ * and clear all queued messages (pending + processing)
5106
5114
  */
5107
- abort(): void;
5115
+ abort(): Promise<void>;
5108
5116
  /**
5109
5117
  * Check if the agent is currently being aborted
5110
5118
  */
@@ -5261,4 +5269,53 @@ interface RuntimeModelConfig {
5261
5269
  */
5262
5270
  declare function createModelSelectorMiddleware(): AgentMiddleware;
5263
5271
 
5264
- export { AGENT_TASK_EVENT, type AddMessageParams, Agent, type AgentClient, type AgentExecutor, AgentInstanceManager, type AgentLattice, AgentLatticeManager, type AgentLifecycleEventName, AgentManager, type AgentStreamExecutor, type AgentThreadInterface, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DefaultScheduleClient, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMessageQueueStore, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadMessageQueueStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, type IsolatedLevel, LINE_NUMBER_WIDTH, type LangGraphStateChecker, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, type MessageCompletedEvent, type MessageFailedEvent, type MessageStartedEvent, MessageType, MetricsServerManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type PendingMessage, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, QueueMode, type QueuePendingEvent, type RunSandboxConfig, type RuntimeModelConfig, SandboxFilesystem, SandboxLatticeManager, type SandboxManagerProtocol, SandboxSkillStore, type SandboxSkillStoreOptions, type ScheduleLattice, ScheduleLatticeManager, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, type ThreadBusyEvent, type ThreadIdleEvent, type ThreadInfo, type ThreadQueueConfig, type ThreadState, ThreadStatus, type ThreadStatusChangedEvent, type ToolDefinition, type ToolLattice, ToolLatticeManager, type VectorStoreLatticeInterface, VectorStoreLatticeManager, type WriteResult, agentInstanceManager, agentLatticeManager, buildGrepResultsDict, checkEmptyContent, clearEncryptionKeyCache, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createModelSelectorMiddleware, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createTeamMiddleware, createTeammateTools, createWidgetMiddleware, decrypt, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLatticeWithTenant, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };
5272
+ /**
5273
+ * Unknown Tool Handler Middleware
5274
+ *
5275
+ * Intercepts unknown tools selected by the model and returns error feedback
5276
+ * instead of throwing exceptions.
5277
+ *
5278
+ * Implementation: Uses wrapModelCall to get available tools, then afterModel
5279
+ * to generate error ToolMessages and jump back to the model.
5280
+ *
5281
+ * Key Design Principles:
5282
+ * 1. Preserve all tool_calls in AIMessage (keep model's original intent)
5283
+ * 2. Generate error ToolMessages for unknown tools (preserve tool_call_id mapping)
5284
+ * 3. Use jumpTo to loop back to model node (required for agent loop)
5285
+ * 4. ToolNode will skip tool calls that already have ToolMessages
5286
+ *
5287
+ * Architecture:
5288
+ * - Positioned first in middleware chain (before HITL)
5289
+ * - Shared across all agent types (ReAct, DeepAgent, TeamAgent)
5290
+ * - Injected via createCommonMiddlewares
5291
+ *
5292
+ * @example
5293
+ * ```typescript
5294
+ * middlewares.push(createUnknownToolHandlerMiddleware());
5295
+ * ```
5296
+ */
5297
+
5298
+ interface UnknownToolHandlerConfig {
5299
+ /**
5300
+ * Strategy when encountering unknown tools
5301
+ * - 'error': Return error message to model (default)
5302
+ * - 'strict': Throw exception and terminate
5303
+ */
5304
+ strategy?: 'error' | 'strict';
5305
+ /**
5306
+ * Custom error message template
5307
+ * @param toolName - The unknown tool name requested
5308
+ * @param availableTools - List of currently available tool names
5309
+ * @returns Error message content
5310
+ */
5311
+ errorMessageTemplate?: (toolName: string, availableTools: string[]) => string;
5312
+ }
5313
+ /**
5314
+ * Create unknown tool handler middleware
5315
+ *
5316
+ * @param config - Configuration options
5317
+ * @returns AgentMiddleware instance
5318
+ */
5319
+ declare function createUnknownToolHandlerMiddleware(config?: UnknownToolHandlerConfig): AgentMiddleware;
5320
+
5321
+ export { AGENT_TASK_EVENT, type AddMessageParams, Agent, type AgentClient, type AgentExecutor, AgentInstanceManager, type AgentLattice, AgentLatticeManager, type AgentLifecycleEventName, AgentManager, type AgentStreamExecutor, type AgentThreadInterface, type BackendFactory, type BackendProtocol, type BufferStats, type Chunk, ChunkBuffer, ChunkBufferLatticeManager, type ColumnInfo, CompositeBackend, ConsoleLoggerClient, type CronFields, CustomMetricsClient, type DatabaseConfig, type DatabaseType, DefaultScheduleClient, EMPTY_CONTENT_WARNING, type EditResult, type EmbeddingsLatticeInterface, EmbeddingsLatticeManager, type FileData, type FileInfo, FileSystemSkillStore, type FileSystemSkillStoreOptions, FilesystemBackend, type GrepMatch, type IMessageQueueStore, type IMetricsServerClient, type ISqlDatabase, InMemoryAssistantStore, InMemoryChunkBuffer, InMemoryDatabaseConfigStore, InMemoryMailboxStore, InMemoryTaskListStore, InMemoryTenantStore, InMemoryThreadMessageQueueStore, InMemoryThreadStore, InMemoryUserStore, InMemoryUserTenantLinkStore, type IsolatedLevel, LINE_NUMBER_WIDTH, type LangGraphStateChecker, type LoggerLattice, LoggerLatticeManager, MAX_LINE_LENGTH, type MailboxMessage, type MailboxStore, type McpLatticeInterface, McpLatticeManager, type McpServerInfo, MemoryBackend, MemoryLatticeManager, MemoryQueueClient, MemoryScheduleStorage, type MessageCompletedEvent, type MessageFailedEvent, type MessageStartedEvent, MessageType, MetricsServerManager, type ModelConfig, type ModelLatticeInterface, ModelLatticeManager, type PendingMessage, PinoLoggerClient, PostgresDatabase, PrometheusClient, type QueryResult, type QueueLattice, QueueLatticeManager, QueueMode, type QueuePendingEvent, type RunSandboxConfig, type RuntimeModelConfig, SandboxFilesystem, SandboxLatticeManager, type SandboxManagerProtocol, SandboxSkillStore, type SandboxSkillStoreOptions, type ScheduleLattice, ScheduleLatticeManager, SemanticMetricsClient, type SkillLattice, SkillLatticeManager, type SkillResource, SqlDatabaseManager, type StateAndStore, StateBackend, StoreBackend, type StoreLattice, StoreLatticeManager, type StoreType, type StoreTypeMap, TOOL_RESULT_TOKEN_LIMIT, TRUNCATION_GUIDANCE, type TableInfo, type TableSchema, type TaskEvent, type TaskListStore, type TaskSpec, TaskStatus, type TaskUpdatable, TeamAgentGraphBuilder, type TeamConfig, type TeamMiddlewareOptions, type TeamTask, type TeammateSpec, type TeammateToolsOptions, type ThreadBuffer, type ThreadBufferConfig, type ThreadBusyEvent, type ThreadIdleEvent, type ThreadInfo, type ThreadQueueConfig, type ThreadState, ThreadStatus, type ThreadStatusChangedEvent, type ToolDefinition, type ToolLattice, ToolLatticeManager, type UnknownToolHandlerConfig, type VectorStoreLatticeInterface, VectorStoreLatticeManager, type WriteResult, agentInstanceManager, agentLatticeManager, buildGrepResultsDict, checkEmptyContent, clearEncryptionKeyCache, createAgentTeam, createExecuteSqlQueryTool, createFileData, createInfoSqlTool, createListMetricsDataSourcesTool, createListMetricsServersTool, createListTablesSqlTool, createModelSelectorMiddleware, createQueryCheckerSqlTool, createQueryMetricDefinitionTool, createQueryMetricsListTool, createQuerySemanticMetricDataTool, createQuerySqlTool, createQueryTableDefinitionTool, createQueryTablesListTool, createTeamMiddleware, createTeammateTools, createUnknownToolHandlerMiddleware, createWidgetMiddleware, decrypt, describeCronExpression, embeddingsLatticeManager, encrypt, eventBus, eventBus as eventBusDefault, fileDataToString, formatContentWithLineNumbers, formatGrepMatches, formatGrepResults, formatReadResponse, getAgentClient, getAgentConfig, getAllAgentConfigs, getAllToolDefinitions, getCheckpointSaver, getChunkBuffer, getEmbeddingsClient, getEmbeddingsLattice, getEncryptionKey, getLoggerLattice, getModelLattice, getNextCronTime, getQueueLattice, getSandBoxManager, getScheduleLattice, getStoreLattice, getToolClient, getToolDefinition, getToolLattice, getVectorStoreClient, getVectorStoreLattice, globSearchFiles, grepMatchesFromFiles, grepSearchFiles, hasChunkBuffer, isUsingDefaultKey, isValidCronExpression, isValidSandboxName, isValidSkillName, loggerLatticeManager, mcpManager, metricsServerManager, modelLatticeManager, normalizeSandboxName, parseCronExpression, performStringReplacement, queueLatticeManager, registerAgentLattice, registerAgentLatticeWithTenant, registerAgentLattices, registerCheckpointSaver, registerChunkBuffer, registerEmbeddingsLattice, registerExistingTool, registerLoggerLattice, registerModelLattice, registerQueueLattice, registerScheduleLattice, registerStoreLattice, registerTeammateAgent, registerToolLattice, registerVectorStoreLattice, sandboxLatticeManager, sanitizeToolCallId, scheduleLatticeManager, skillLatticeManager, sqlDatabaseManager, storeLatticeManager, toolLatticeManager, truncateIfTooLong, unregisterTeammateAgent, updateFileData, validateAgentInput, validateEncryptionKey, validatePath, validateSkillName, validateToolInput, vectorStoreLatticeManager };