@axiom-lattice/protocols 2.1.12 → 2.1.14
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +299 -6
- package/dist/index.d.ts +299 -6
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/AgentLatticeProtocol.ts +56 -4
- package/src/DatabaseConfigStoreProtocol.ts +189 -0
- package/src/WorkspaceStoreProtocol.ts +92 -0
- package/src/index.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -122,7 +122,8 @@ interface ModelLatticeProtocol extends BaseLatticeProtocol<LLMConfig, BaseChatMo
|
|
|
122
122
|
*/
|
|
123
123
|
declare enum AgentType {
|
|
124
124
|
REACT = "react",
|
|
125
|
-
DEEP_AGENT = "deep_agent"
|
|
125
|
+
DEEP_AGENT = "deep_agent",
|
|
126
|
+
TEAM = "team"
|
|
126
127
|
}
|
|
127
128
|
/**
|
|
128
129
|
* Runtime configuration that will be injected into LangGraphRunnableConfig.configurable
|
|
@@ -142,6 +143,12 @@ interface BaseAgentConfig {
|
|
|
142
143
|
name: string;
|
|
143
144
|
description: string;
|
|
144
145
|
prompt: string;
|
|
146
|
+
/**
|
|
147
|
+
* Key of the parent agent to inherit configuration from.
|
|
148
|
+
* When set, unspecified fields are inherited from the parent agent's config.
|
|
149
|
+
* Child's explicitly set fields override the parent's.
|
|
150
|
+
*/
|
|
151
|
+
extendsAgent?: string;
|
|
145
152
|
schema?: ZodObject<any, any, any, any, any>;
|
|
146
153
|
modelKey?: string;
|
|
147
154
|
/**
|
|
@@ -167,8 +174,7 @@ interface BrowserMiddlewareConfig {
|
|
|
167
174
|
headless: boolean;
|
|
168
175
|
}
|
|
169
176
|
interface SqlMiddlewareConfig {
|
|
170
|
-
|
|
171
|
-
connectionString?: string;
|
|
177
|
+
databaseKeys?: string[];
|
|
172
178
|
}
|
|
173
179
|
type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom";
|
|
174
180
|
interface AgentMiddlewareConfig {
|
|
@@ -195,15 +201,54 @@ interface DeepAgentConfig extends BaseAgentConfig {
|
|
|
195
201
|
subAgents?: string[];
|
|
196
202
|
internalSubAgents?: AgentConfig[];
|
|
197
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Team teammate configuration -- describes an available teammate.
|
|
206
|
+
*/
|
|
207
|
+
interface TeamTeammateConfig {
|
|
208
|
+
/** Unique name for this teammate (used as agent ID) */
|
|
209
|
+
name: string;
|
|
210
|
+
/** Role category (e.g. "research", "writing", "review") */
|
|
211
|
+
role: string;
|
|
212
|
+
/** Human-readable description of what this teammate does */
|
|
213
|
+
description: string;
|
|
214
|
+
/** Tool keys this teammate has access to */
|
|
215
|
+
tools?: string[];
|
|
216
|
+
/** Custom system prompt for this teammate */
|
|
217
|
+
prompt?: string;
|
|
218
|
+
/** Model key override for this teammate */
|
|
219
|
+
modelKey?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* TEAM agent configuration -- a team lead that dynamically creates teammates.
|
|
223
|
+
* Teammates are created on-the-fly from create_team tool input (name, role, description).
|
|
224
|
+
*/
|
|
225
|
+
interface TeamAgentConfig extends BaseAgentConfig {
|
|
226
|
+
type: AgentType.TEAM;
|
|
227
|
+
/** Tool keys available to the team lead */
|
|
228
|
+
tools?: string[];
|
|
229
|
+
/** Maximum number of teammates running concurrently */
|
|
230
|
+
maxConcurrency?: number;
|
|
231
|
+
/**
|
|
232
|
+
* Schedule lattice key for polling task list / mailbox.
|
|
233
|
+
* When set, teammates use ScheduleLattice for periodic polling instead of event-driven wait.
|
|
234
|
+
*/
|
|
235
|
+
scheduleLatticeKey?: string;
|
|
236
|
+
/** Poll interval in ms when using schedule lattice (default: 5000) */
|
|
237
|
+
pollIntervalMs?: number;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Type guard to check if config is TeamAgentConfig
|
|
241
|
+
*/
|
|
242
|
+
declare function isTeamAgentConfig(config: AgentConfig): config is TeamAgentConfig;
|
|
198
243
|
/**
|
|
199
244
|
* Agent configuration union type
|
|
200
245
|
* Different agent types have different configuration options
|
|
201
246
|
*/
|
|
202
|
-
type AgentConfig = ReactAgentConfig | DeepAgentConfig;
|
|
247
|
+
type AgentConfig = ReactAgentConfig | DeepAgentConfig | TeamAgentConfig;
|
|
203
248
|
/**
|
|
204
249
|
* Agent configuration with tools property
|
|
205
250
|
*/
|
|
206
|
-
type AgentConfigWithTools = ReactAgentConfig | DeepAgentConfig;
|
|
251
|
+
type AgentConfigWithTools = ReactAgentConfig | DeepAgentConfig | TeamAgentConfig;
|
|
207
252
|
/**
|
|
208
253
|
* Type guard to check if config has tools property
|
|
209
254
|
*/
|
|
@@ -1530,6 +1575,254 @@ interface McpStats {
|
|
|
1530
1575
|
lastCallTimestamp: number;
|
|
1531
1576
|
}
|
|
1532
1577
|
|
|
1578
|
+
/**
|
|
1579
|
+
* WorkspaceStoreProtocol
|
|
1580
|
+
*
|
|
1581
|
+
* Workspace and Project store protocol definitions
|
|
1582
|
+
* for the Axiom Lattice framework
|
|
1583
|
+
*/
|
|
1584
|
+
type StorageType = "sandbox" | "filesystem";
|
|
1585
|
+
/**
|
|
1586
|
+
* Workspace type definition
|
|
1587
|
+
*/
|
|
1588
|
+
interface Workspace {
|
|
1589
|
+
id: string;
|
|
1590
|
+
tenantId: string;
|
|
1591
|
+
name: string;
|
|
1592
|
+
description?: string;
|
|
1593
|
+
storageType: StorageType;
|
|
1594
|
+
createdAt: Date;
|
|
1595
|
+
updatedAt: Date;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Create workspace request type
|
|
1599
|
+
*/
|
|
1600
|
+
interface CreateWorkspaceRequest {
|
|
1601
|
+
name: string;
|
|
1602
|
+
description?: string;
|
|
1603
|
+
storageType: StorageType;
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Update workspace request type
|
|
1607
|
+
*/
|
|
1608
|
+
interface UpdateWorkspaceRequest {
|
|
1609
|
+
name?: string;
|
|
1610
|
+
description?: string;
|
|
1611
|
+
storageType?: StorageType;
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* WorkspaceStore interface
|
|
1615
|
+
* Provides CRUD operations for workspace data
|
|
1616
|
+
*/
|
|
1617
|
+
interface WorkspaceStore {
|
|
1618
|
+
getAllWorkspaces(tenantId: string): Promise<Workspace[]>;
|
|
1619
|
+
getWorkspaceById(tenantId: string, id: string): Promise<Workspace | null>;
|
|
1620
|
+
createWorkspace(tenantId: string, id: string, data: CreateWorkspaceRequest): Promise<Workspace>;
|
|
1621
|
+
updateWorkspace(tenantId: string, id: string, updates: UpdateWorkspaceRequest): Promise<Workspace | null>;
|
|
1622
|
+
deleteWorkspace(tenantId: string, id: string): Promise<boolean>;
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Project type definition
|
|
1626
|
+
*/
|
|
1627
|
+
interface Project {
|
|
1628
|
+
id: string;
|
|
1629
|
+
tenantId: string;
|
|
1630
|
+
workspaceId: string;
|
|
1631
|
+
name: string;
|
|
1632
|
+
description?: string;
|
|
1633
|
+
createdAt: Date;
|
|
1634
|
+
updatedAt: Date;
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Create project request type
|
|
1638
|
+
*/
|
|
1639
|
+
interface CreateProjectRequest {
|
|
1640
|
+
name: string;
|
|
1641
|
+
description?: string;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Update project request type
|
|
1645
|
+
*/
|
|
1646
|
+
interface UpdateProjectRequest {
|
|
1647
|
+
name?: string;
|
|
1648
|
+
description?: string;
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* ProjectStore interface
|
|
1652
|
+
* Provides CRUD operations for project data
|
|
1653
|
+
*/
|
|
1654
|
+
interface ProjectStore {
|
|
1655
|
+
getProjectsByWorkspace(tenantId: string, workspaceId: string): Promise<Project[]>;
|
|
1656
|
+
getProjectById(tenantId: string, id: string): Promise<Project | null>;
|
|
1657
|
+
createProject(tenantId: string, workspaceId: string, id: string, data: CreateProjectRequest): Promise<Project>;
|
|
1658
|
+
updateProject(tenantId: string, id: string, updates: UpdateProjectRequest): Promise<Project | null>;
|
|
1659
|
+
deleteProject(tenantId: string, id: string): Promise<boolean>;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* DatabaseConfigStoreProtocol
|
|
1664
|
+
*
|
|
1665
|
+
* Database configuration store protocol for the Axiom Lattice framework
|
|
1666
|
+
* Provides standardized interfaces for database connection config management
|
|
1667
|
+
*/
|
|
1668
|
+
/**
|
|
1669
|
+
* Supported database types
|
|
1670
|
+
*/
|
|
1671
|
+
type DatabaseType = 'postgres' | 'mysql' | 'sqlite';
|
|
1672
|
+
/**
|
|
1673
|
+
* Database connection configuration
|
|
1674
|
+
*/
|
|
1675
|
+
interface DatabaseConfig {
|
|
1676
|
+
type: DatabaseType;
|
|
1677
|
+
host?: string;
|
|
1678
|
+
port?: number;
|
|
1679
|
+
database: string;
|
|
1680
|
+
user?: string;
|
|
1681
|
+
password?: string;
|
|
1682
|
+
connectionString?: string;
|
|
1683
|
+
ssl?: boolean;
|
|
1684
|
+
}
|
|
1685
|
+
/**
|
|
1686
|
+
* Database configuration entry stored in the store
|
|
1687
|
+
*/
|
|
1688
|
+
interface DatabaseConfigEntry {
|
|
1689
|
+
/**
|
|
1690
|
+
* Unique identifier for the configuration
|
|
1691
|
+
*/
|
|
1692
|
+
id: string;
|
|
1693
|
+
/**
|
|
1694
|
+
* Tenant identifier for multi-tenant isolation
|
|
1695
|
+
*/
|
|
1696
|
+
tenantId: string;
|
|
1697
|
+
/**
|
|
1698
|
+
* Business key for the configuration (unique within tenant)
|
|
1699
|
+
*/
|
|
1700
|
+
key: string;
|
|
1701
|
+
/**
|
|
1702
|
+
* Database connection configuration (password already decrypted)
|
|
1703
|
+
*/
|
|
1704
|
+
config: DatabaseConfig;
|
|
1705
|
+
/**
|
|
1706
|
+
* Optional friendly name
|
|
1707
|
+
*/
|
|
1708
|
+
name?: string;
|
|
1709
|
+
/**
|
|
1710
|
+
* Optional description
|
|
1711
|
+
*/
|
|
1712
|
+
description?: string;
|
|
1713
|
+
/**
|
|
1714
|
+
* Creation timestamp
|
|
1715
|
+
*/
|
|
1716
|
+
createdAt: Date;
|
|
1717
|
+
/**
|
|
1718
|
+
* Last update timestamp
|
|
1719
|
+
*/
|
|
1720
|
+
updatedAt: Date;
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Request to create a new database configuration
|
|
1724
|
+
*/
|
|
1725
|
+
interface CreateDatabaseConfigRequest {
|
|
1726
|
+
/**
|
|
1727
|
+
* Business key for the configuration (unique within tenant)
|
|
1728
|
+
*/
|
|
1729
|
+
key: string;
|
|
1730
|
+
/**
|
|
1731
|
+
* Database connection configuration
|
|
1732
|
+
*/
|
|
1733
|
+
config: DatabaseConfig;
|
|
1734
|
+
/**
|
|
1735
|
+
* Optional friendly name
|
|
1736
|
+
*/
|
|
1737
|
+
name?: string;
|
|
1738
|
+
/**
|
|
1739
|
+
* Optional description
|
|
1740
|
+
*/
|
|
1741
|
+
description?: string;
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Request to update an existing database configuration
|
|
1745
|
+
*/
|
|
1746
|
+
interface UpdateDatabaseConfigRequest {
|
|
1747
|
+
/**
|
|
1748
|
+
* Business key for the configuration
|
|
1749
|
+
*/
|
|
1750
|
+
key?: string;
|
|
1751
|
+
/**
|
|
1752
|
+
* Database connection configuration
|
|
1753
|
+
*/
|
|
1754
|
+
config?: DatabaseConfig;
|
|
1755
|
+
/**
|
|
1756
|
+
* Optional friendly name
|
|
1757
|
+
*/
|
|
1758
|
+
name?: string;
|
|
1759
|
+
/**
|
|
1760
|
+
* Optional description
|
|
1761
|
+
*/
|
|
1762
|
+
description?: string;
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* DatabaseConfigStore interface
|
|
1766
|
+
* Provides CRUD operations for database configuration data
|
|
1767
|
+
*/
|
|
1768
|
+
interface DatabaseConfigStore {
|
|
1769
|
+
/**
|
|
1770
|
+
* Get all database configurations for a tenant
|
|
1771
|
+
* @param tenantId - Tenant identifier
|
|
1772
|
+
* @returns Array of all database configurations
|
|
1773
|
+
*/
|
|
1774
|
+
getAllConfigs(tenantId: string): Promise<DatabaseConfigEntry[]>;
|
|
1775
|
+
/**
|
|
1776
|
+
* Get all database configurations across all tenants
|
|
1777
|
+
* @returns Array of all database configurations
|
|
1778
|
+
*/
|
|
1779
|
+
getAllConfigsWithoutTenant(): Promise<DatabaseConfigEntry[]>;
|
|
1780
|
+
/**
|
|
1781
|
+
* Get database configuration by ID
|
|
1782
|
+
* @param tenantId - Tenant identifier
|
|
1783
|
+
* @param id - Configuration identifier
|
|
1784
|
+
* @returns Configuration if found, null otherwise
|
|
1785
|
+
*/
|
|
1786
|
+
getConfigById(tenantId: string, id: string): Promise<DatabaseConfigEntry | null>;
|
|
1787
|
+
/**
|
|
1788
|
+
* Get database configuration by business key
|
|
1789
|
+
* @param tenantId - Tenant identifier
|
|
1790
|
+
* @param key - Business key
|
|
1791
|
+
* @returns Configuration if found, null otherwise
|
|
1792
|
+
*/
|
|
1793
|
+
getConfigByKey(tenantId: string, key: string): Promise<DatabaseConfigEntry | null>;
|
|
1794
|
+
/**
|
|
1795
|
+
* Create a new database configuration
|
|
1796
|
+
* @param tenantId - Tenant identifier
|
|
1797
|
+
* @param id - Configuration identifier
|
|
1798
|
+
* @param data - Configuration creation data
|
|
1799
|
+
* @returns Created configuration
|
|
1800
|
+
*/
|
|
1801
|
+
createConfig(tenantId: string, id: string, data: CreateDatabaseConfigRequest): Promise<DatabaseConfigEntry>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Update an existing database configuration
|
|
1804
|
+
* @param tenantId - Tenant identifier
|
|
1805
|
+
* @param id - Configuration identifier
|
|
1806
|
+
* @param updates - Partial configuration data to update
|
|
1807
|
+
* @returns Updated configuration if found, null otherwise
|
|
1808
|
+
*/
|
|
1809
|
+
updateConfig(tenantId: string, id: string, updates: Partial<UpdateDatabaseConfigRequest>): Promise<DatabaseConfigEntry | null>;
|
|
1810
|
+
/**
|
|
1811
|
+
* Delete a database configuration by ID
|
|
1812
|
+
* @param tenantId - Tenant identifier
|
|
1813
|
+
* @param id - Configuration identifier
|
|
1814
|
+
* @returns true if deleted, false otherwise
|
|
1815
|
+
*/
|
|
1816
|
+
deleteConfig(tenantId: string, id: string): Promise<boolean>;
|
|
1817
|
+
/**
|
|
1818
|
+
* Check if configuration exists
|
|
1819
|
+
* @param tenantId - Tenant identifier
|
|
1820
|
+
* @param id - Configuration identifier
|
|
1821
|
+
* @returns true if configuration exists, false otherwise
|
|
1822
|
+
*/
|
|
1823
|
+
hasConfig(tenantId: string, id: string): Promise<boolean>;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1533
1826
|
/**
|
|
1534
1827
|
* 通用类型定义
|
|
1535
1828
|
*
|
|
@@ -1593,4 +1886,4 @@ type Timestamp = number;
|
|
|
1593
1886
|
*/
|
|
1594
1887
|
type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
|
|
1595
1888
|
|
|
1596
|
-
export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, type AgentMiddlewareConfig, type AgentRunConfig, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type AvailableModule, type BaseLatticeProtocol, type BaseMessage, type BrowserMiddlewareConfig, type Callback, type CodeEvalMiddlewareConfig, type CreateAssistantRequest, type CreateSkillRequest, type CreateThreadRequest, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, type LLMConfig, type LatticeError, type LatticeEventBus, type LatticeMessage, type LoggerClient, type LoggerConfig, type LoggerContext, type LoggerLatticeProtocol, LoggerType, type McpClient, type McpClientOptions, type McpConnectionStatus, type McpLatticeMessage, type McpLatticeProtocol, McpMessageType, type McpServerConfig, type McpStats, type McpTool, type McpToolResult, type McpTransportType, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type MiddlewareType, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PinoFileOptions, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type SandboxMiddlewareConfig, type ScheduleClient, type ScheduleConfig, type ScheduleCronOptions, ScheduleExecutionType, type ScheduleLatticeProtocol, type ScheduleOnceOptions, type ScheduleStorage, ScheduleType, type ScheduledTaskDefinition, ScheduledTaskStatus, type Skill, type SkillClient, type SkillClientType, type SkillConfig, type SkillLatticeProtocol, type SkillStore, type SqlMiddlewareConfig, type SystemMessage, type TaskHandler, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UserMessage, type VectorStoreConfig, type VectorStoreLatticeProtocol, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig };
|
|
1889
|
+
export { type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, type AgentMiddlewareConfig, type AgentRunConfig, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type AvailableModule, type BaseLatticeProtocol, type BaseMessage, type BrowserMiddlewareConfig, type Callback, type CodeEvalMiddlewareConfig, type CreateAssistantRequest, type CreateDatabaseConfigRequest, type CreateProjectRequest, type CreateSkillRequest, type CreateThreadRequest, type CreateWorkspaceRequest, type DatabaseConfig, type DatabaseConfigEntry, type DatabaseConfigStore, type DatabaseType, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, type LLMConfig, type LatticeError, type LatticeEventBus, type LatticeMessage, type LoggerClient, type LoggerConfig, type LoggerContext, type LoggerLatticeProtocol, LoggerType, type McpClient, type McpClientOptions, type McpConnectionStatus, type McpLatticeMessage, type McpLatticeProtocol, McpMessageType, type McpServerConfig, type McpStats, type McpTool, type McpToolResult, type McpTransportType, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type MiddlewareType, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PinoFileOptions, type Project, type ProjectStore, type QueryParams, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type Result, type SandboxMiddlewareConfig, type ScheduleClient, type ScheduleConfig, type ScheduleCronOptions, ScheduleExecutionType, type ScheduleLatticeProtocol, type ScheduleOnceOptions, type ScheduleStorage, ScheduleType, type ScheduledTaskDefinition, ScheduledTaskStatus, type Skill, type SkillClient, type SkillClientType, type SkillConfig, type SkillLatticeProtocol, type SkillStore, type SqlMiddlewareConfig, type StorageType, type SystemMessage, type TaskHandler, type TeamAgentConfig, type TeamTeammateConfig, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UpdateDatabaseConfigRequest, type UpdateProjectRequest, type UpdateWorkspaceRequest, type UserMessage, type VectorStoreConfig, type VectorStoreLatticeProtocol, type Workspace, type WorkspaceStore, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig, isTeamAgentConfig };
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,8 @@ __export(index_exports, {
|
|
|
32
32
|
getSubAgentsFromConfig: () => getSubAgentsFromConfig,
|
|
33
33
|
getToolsFromConfig: () => getToolsFromConfig,
|
|
34
34
|
hasTools: () => hasTools,
|
|
35
|
-
isDeepAgentConfig: () => isDeepAgentConfig
|
|
35
|
+
isDeepAgentConfig: () => isDeepAgentConfig,
|
|
36
|
+
isTeamAgentConfig: () => isTeamAgentConfig
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
|
|
@@ -40,8 +41,12 @@ module.exports = __toCommonJS(index_exports);
|
|
|
40
41
|
var AgentType = /* @__PURE__ */ ((AgentType2) => {
|
|
41
42
|
AgentType2["REACT"] = "react";
|
|
42
43
|
AgentType2["DEEP_AGENT"] = "deep_agent";
|
|
44
|
+
AgentType2["TEAM"] = "team";
|
|
43
45
|
return AgentType2;
|
|
44
46
|
})(AgentType || {});
|
|
47
|
+
function isTeamAgentConfig(config) {
|
|
48
|
+
return config.type === "team" /* TEAM */;
|
|
49
|
+
}
|
|
45
50
|
function hasTools(config) {
|
|
46
51
|
return true;
|
|
47
52
|
}
|
|
@@ -149,6 +154,7 @@ var McpMessageType = /* @__PURE__ */ ((McpMessageType2) => {
|
|
|
149
154
|
getSubAgentsFromConfig,
|
|
150
155
|
getToolsFromConfig,
|
|
151
156
|
hasTools,
|
|
152
|
-
isDeepAgentConfig
|
|
157
|
+
isDeepAgentConfig,
|
|
158
|
+
isTeamAgentConfig
|
|
153
159
|
});
|
|
154
160
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.ts","../src/ScheduleLatticeProtocol.ts","../src/LoggerLatticeProtocol.ts","../src/McpLatticeProtocol.ts"],"sourcesContent":["/**\n * Protocols\n *\n * 导出所有Lattice协议接口,为整个系统提供统一的接口规范\n */\n\nexport * from \"./BaseLatticeProtocol\";\nexport * from \"./ToolLatticeProtocol\";\nexport * from \"./ModelLatticeProtocol\";\nexport * from \"./AgentLatticeProtocol\";\nexport * from \"./MemoryLatticeProtocol\";\nexport * from \"./UILatticeProtocol\";\nexport * from \"./QueueLatticeProtocol\";\nexport * from \"./ScheduleLatticeProtocol\";\nexport * from \"./EmbeddingsLatticeProtocol\";\nexport * from \"./VectorStoreLatticeProtocol\";\nexport * from \"./LoggerLatticeProtocol\";\nexport * from \"./MessageProtocol\";\nexport * from \"./ThreadStoreProtocol\";\nexport * from \"./AssistantStoreProtocol\";\nexport * from \"./SkillLatticeProtocol\";\nexport * from \"./SkillStoreProtocol\";\nexport * from \"./McpLatticeProtocol\";\n\n// 导出通用类型\nexport * from \"./types\";\n","/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport z, { ZodObject, ZodSchema } from \"zod\";\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 智能体类型枚举\n */\nexport enum AgentType {\n REACT = \"react\",\n DEEP_AGENT = \"deep_agent\",\n\n}\n\n/**\n * Runtime configuration that will be injected into LangGraphRunnableConfig.configurable\n * Tools can access these values via config.configurable.runConfig\n */\nexport interface AgentRunConfig {\n /** Database key for SQL tools (registered via sqlDatabaseManager) */\n databaseKey?: string;\n /** Any additional runtime configuration */\n [key: string]: any;\n}\n\n/**\n * Base agent configuration shared by all agent types\n */\ninterface BaseAgentConfig {\n key: string; // Unique key\n name: string; // Name\n description: string; // Description\n prompt: string; // Prompt\n schema?: ZodObject<any, any, any, any, any>; // Input validation schema\n modelKey?: string; // Model key to use\n /**\n * Runtime configuration to inject into tool execution context\n * Will be available in tools via config.configurable.runConfig\n */\n runConfig?: AgentRunConfig;\n skillCategories?: string[];\n middleware?: AgentMiddlewareConfig[];\n}\n\nexport type AvailableModule = \"filesystem\" | \"code_eval\" | \"browser\";\n\nexport interface SandboxMiddlewareConfig {\n isolatedLevel: \"agent\" | \"thread\" | \"global\";\n modules: AvailableModule[];\n}\n\nexport interface CodeEvalMiddlewareConfig {\n isolatedLevel: \"agent\" | \"thread\" | \"global\";\n timeout: number;\n memoryLimit: number;\n}\n\nexport interface BrowserMiddlewareConfig {\n isolatedLevel: \"agent\" | \"thread\" | \"global\";\n headless: boolean;\n}\n\nexport interface SqlMiddlewareConfig {\n databaseKey?: string;\n connectionString?: string;\n}\n\nexport type MiddlewareType = \"filesystem\" | \"code_eval\" | \"browser\" | \"sql\" | \"skill\" | \"http\" | \"custom\";\n\nexport interface AgentMiddlewareConfig {\n id: string;\n type: MiddlewareType;\n name: string;\n description: string;\n enabled: boolean;\n config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | Record<string, any>;\n}\n\n\n/**\n * REACT agent configuration\n */\nexport interface ReactAgentConfig extends BaseAgentConfig {\n type: AgentType.REACT;\n tools?: string[]; // Tool list\n}\n\n/**\n * DEEP_AGENT configuration - only this type supports subAgents\n */\nexport interface DeepAgentConfig extends BaseAgentConfig {\n type: AgentType.DEEP_AGENT;\n tools?: string[]; // Tool list\n subAgents?: string[]; // Sub-agent list (unique to DEEP_AGENT)\n internalSubAgents?: AgentConfig[]; // Internal sub-agent list (unique to DEEP_AGENT)\n}\n\n\n\n/**\n * Agent configuration union type\n * Different agent types have different configuration options\n */\nexport type AgentConfig =\n | ReactAgentConfig\n | DeepAgentConfig\n\n\n/**\n * Agent configuration with tools property\n */\nexport type AgentConfigWithTools =\n | ReactAgentConfig\n | DeepAgentConfig\n\n/**\n * Type guard to check if config has tools property\n */\nexport function hasTools(config: AgentConfig): config is AgentConfigWithTools {\n return true\n}\n\n/**\n * Type guard to check if config is DeepAgentConfig (has subAgents)\n */\nexport function isDeepAgentConfig(\n config: AgentConfig\n): config is DeepAgentConfig {\n return config.type === AgentType.DEEP_AGENT;\n}\n\n/**\n * Get tools from config safely\n */\nexport function getToolsFromConfig(config: AgentConfig): string[] {\n if (hasTools(config)) {\n return config.tools || [];\n }\n return [];\n}\n\n/**\n * Get subAgents from config safely (only DeepAgentConfig has subAgents)\n */\nexport function getSubAgentsFromConfig(config: AgentConfig): string[] {\n if (isDeepAgentConfig(config)) {\n return config.subAgents || [];\n }\n return [];\n}\n\n/**\n * 智能体客户端类型\n */\nexport type AgentClient = CompiledStateGraph<any, any, any, any, any>;\n\n/**\n * Graph构建选项\n */\nexport interface GraphBuildOptions {\n overrideTools?: string[];\n overrideModel?: string;\n metadata?: Record<string, any>;\n}\n\n/**\n * 智能体Lattice协议接口\n */\nexport interface AgentLatticeProtocol\n extends BaseLatticeProtocol<AgentConfig, AgentClient> {\n // 智能体执行函数\n invoke: (input: any, options?: any) => Promise<any>;\n\n // 构建智能体图\n buildGraph: (options?: GraphBuildOptions) => Promise<AgentClient>;\n}\n","/**\n * MemoryLatticeProtocol\n *\n * 记忆Lattice的协议,用于管理智能体的上下文和记忆\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 记忆类型枚举\n */\nexport enum MemoryType {\n SHORT_TERM = \"short_term\",\n LONG_TERM = \"long_term\",\n EPISODIC = \"episodic\",\n SEMANTIC = \"semantic\",\n WORKING = \"working\",\n}\n\n/**\n * 记忆配置接口\n */\nexport interface MemoryConfig {\n name: string; // 名称\n description: string; // 描述\n type: MemoryType; // 记忆类型\n ttl?: number; // 生存时间\n capacity?: number; // 容量限制\n}\n\n/**\n * 记忆客户端接口\n */\nexport interface MemoryClient {\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n\n/**\n * 记忆Lattice协议接口\n */\nexport interface MemoryLatticeProtocol\n extends BaseLatticeProtocol<MemoryConfig, MemoryClient> {\n // 记忆操作方法\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n","/**\n * UILatticeProtocol\n *\n * UI Lattice的协议,用于定义用户界面组件\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * UI组件类型枚举\n */\nexport enum UIComponentType {\n CONTAINER = \"container\",\n INPUT = \"input\",\n BUTTON = \"button\",\n LIST = \"list\",\n TABLE = \"table\",\n CHART = \"chart\",\n FORM = \"form\",\n CARD = \"card\",\n MODAL = \"modal\",\n CUSTOM = \"custom\",\n}\n\n/**\n * UI配置接口\n */\nexport interface UIConfig {\n name: string; // 组件名称\n description: string; // 组件描述\n type: UIComponentType; // 组件类型\n props?: Record<string, any>; // 组件属性\n children?: string[]; // 子组件列表\n}\n\n/**\n * UI组件接口\n * 使用泛型以适应不同的UI框架(React, Vue等)\n */\nexport interface UIComponent<T = any> {\n render: (props?: any) => T;\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n\n/**\n * UI Lattice协议接口\n */\nexport interface UILatticeProtocol<T = any>\n extends BaseLatticeProtocol<UIConfig, UIComponent<T>> {\n // UI渲染方法\n render: (props?: any) => T;\n\n // 事件处理\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n","/**\n * QueueLatticeProtocol\n *\n * Queue Lattice protocol for task queue management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Queue service type enumeration\n */\nexport enum QueueType {\n MEMORY = \"memory\",\n REDIS = \"redis\",\n}\n\n/**\n * Queue configuration interface\n */\nexport interface QueueConfig {\n name: string; // Queue name\n description: string; // Queue description\n type: QueueType; // Queue service type\n queueName?: string; // Specific queue name (e.g., \"tasks\")\n options?: Record<string, any>; // Additional options (e.g., Redis connection options)\n}\n\n/**\n * Queue operation result interface\n */\nexport interface QueueResult<T = any> {\n data: T | null;\n error: any | null;\n}\n\n/**\n * Queue client interface\n */\nexport interface QueueClient {\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n/**\n * Queue Lattice protocol interface\n */\nexport interface QueueLatticeProtocol\n extends BaseLatticeProtocol<QueueConfig, QueueClient> {\n // Queue operations\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n\n\n","/**\n * ScheduleLatticeProtocol\n *\n * Schedule Lattice protocol for delayed and recurring task execution management\n * Supports persistence and recovery after service restart\n * Supports both one-time delayed tasks and cron-style recurring tasks\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Schedule service type enumeration\n */\nexport enum ScheduleType {\n MEMORY = \"memory\",\n POSTGRES = \"postgres\",\n REDIS = \"redis\",\n}\n\n/**\n * Schedule execution type - one-time or recurring\n */\nexport enum ScheduleExecutionType {\n ONCE = \"once\", // Execute once at specified time\n CRON = \"cron\", // Recurring based on cron expression\n}\n\n/**\n * Task status enumeration\n */\nexport enum ScheduledTaskStatus {\n PENDING = \"pending\", // Waiting to be executed\n RUNNING = \"running\", // Currently executing\n COMPLETED = \"completed\", // Successfully completed (for ONCE type)\n FAILED = \"failed\", // Execution failed\n CANCELLED = \"cancelled\", // Manually cancelled\n PAUSED = \"paused\", // Paused (for CRON type)\n}\n\n/**\n * Schedule configuration interface\n */\nexport interface ScheduleConfig {\n name: string;\n description: string;\n type: ScheduleType;\n storage?: ScheduleStorage; // Optional storage for persistence\n options?: Record<string, any>;\n}\n\n/**\n * Scheduled task definition - fully serializable\n * Supports both one-time and cron-style recurring tasks\n */\nexport interface ScheduledTaskDefinition {\n taskId: string;\n taskType: string; // Maps to a registered handler\n payload: Record<string, any>; // JSON-serializable data passed to handler\n\n // Context fields for querying\n assistantId?: string; // Which assistant created/owns this task\n threadId?: string; // Which thread this task belongs to\n\n // Execution configuration\n executionType: ScheduleExecutionType;\n\n // For ONCE type - execute at specific time or after delay\n executeAt?: number; // Timestamp when to execute\n delayMs?: number; // Original delay in milliseconds (for reference)\n\n // For CRON type - recurring schedule\n cronExpression?: string; // Cron format: \"0 9 * * *\" (min hour day month weekday)\n timezone?: string; // Timezone: \"Asia/Shanghai\", defaults to system timezone\n nextRunAt?: number; // Next calculated execution time\n lastRunAt?: number; // Last execution time\n\n // Execution tracking\n status: ScheduledTaskStatus;\n runCount: number; // How many times executed\n maxRuns?: number; // Max executions (null/undefined = infinite for cron, 1 for once)\n\n // Error handling\n retryCount: number; // Current retry count\n maxRetries: number; // Maximum retry attempts\n lastError?: string; // Last error message if failed\n\n // Timestamps\n createdAt: number;\n updatedAt: number;\n expiresAt?: number; // When to stop (for cron, optional)\n\n metadata?: Record<string, any>; // Additional metadata\n}\n\n/**\n * Task handler function type\n */\nexport type TaskHandler = (\n payload: Record<string, any>,\n taskInfo: ScheduledTaskDefinition\n) => void | Promise<void>;\n\n/**\n * Options for scheduling a one-time task\n */\nexport interface ScheduleOnceOptions {\n executeAt?: number; // Absolute timestamp to execute\n delayMs?: number; // OR relative delay from now\n maxRetries?: number; // Max retry attempts (default: 0)\n assistantId?: string; // Which assistant created/owns this task\n threadId?: string; // Which thread this task belongs to\n metadata?: Record<string, any>;\n}\n\n/**\n * Options for scheduling a cron task\n */\nexport interface ScheduleCronOptions {\n cronExpression: string; // Cron expression: \"0 9 * * *\"\n timezone?: string; // Timezone: \"Asia/Shanghai\"\n maxRuns?: number; // Max executions (undefined = infinite)\n expiresAt?: number; // Stop after this timestamp\n maxRetries?: number; // Max retry attempts per run (default: 0)\n assistantId?: string; // Which assistant created/owns this task\n threadId?: string; // Which thread this task belongs to\n metadata?: Record<string, any>;\n}\n\n/**\n * Schedule storage interface for persistence\n */\nexport interface ScheduleStorage {\n /**\n * Save a new task\n */\n save(task: ScheduledTaskDefinition): Promise<void>;\n\n /**\n * Get task by ID\n */\n get(taskId: string): Promise<ScheduledTaskDefinition | null>;\n\n /**\n * Update task\n */\n update(\n taskId: string,\n updates: Partial<ScheduledTaskDefinition>\n ): Promise<void>;\n\n /**\n * Delete task\n */\n delete(taskId: string): Promise<void>;\n\n /**\n * Get all pending/active tasks (for recovery)\n * Returns tasks with status: PENDING or PAUSED\n */\n getActiveTasks(): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by type\n */\n getTasksByType(taskType: string): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by status\n */\n getTasksByStatus(\n status: ScheduledTaskStatus\n ): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by execution type\n */\n getTasksByExecutionType(\n executionType: ScheduleExecutionType\n ): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by assistant ID\n */\n getTasksByAssistantId(\n assistantId: string\n ): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by thread ID\n */\n getTasksByThreadId(threadId: string): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get all tasks (with optional filters)\n */\n getAllTasks(filters?: {\n status?: ScheduledTaskStatus;\n executionType?: ScheduleExecutionType;\n taskType?: string;\n assistantId?: string;\n threadId?: string;\n limit?: number;\n offset?: number;\n }): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Count tasks (with optional filters)\n */\n countTasks(filters?: {\n status?: ScheduledTaskStatus;\n executionType?: ScheduleExecutionType;\n taskType?: string;\n assistantId?: string;\n threadId?: string;\n }): Promise<number>;\n\n /**\n * Delete completed/cancelled tasks older than specified time\n * Useful for cleanup\n */\n deleteOldTasks(olderThanMs: number): Promise<number>;\n}\n\n/**\n * Schedule client interface\n */\nexport interface ScheduleClient {\n // ===== Handler Registration =====\n\n /**\n * Register a handler for a task type\n * Must be called before scheduling tasks of this type\n */\n registerHandler(taskType: string, handler: TaskHandler): void;\n\n /**\n * Unregister a handler\n */\n unregisterHandler(taskType: string): boolean;\n\n /**\n * Check if a handler is registered\n */\n hasHandler(taskType: string): boolean;\n\n /**\n * Get all registered handler types\n */\n getHandlerTypes(): string[];\n\n // ===== One-time Task Scheduling =====\n\n /**\n * Schedule a one-time task\n * @param taskId - Unique identifier for the task\n * @param taskType - Type of task (must have a registered handler)\n * @param payload - Data to pass to the handler (must be JSON-serializable)\n * @param options - Execution options (executeAt or delayMs required)\n */\n scheduleOnce(\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleOnceOptions\n ): Promise<boolean>;\n\n // ===== Cron Task Scheduling =====\n\n /**\n * Schedule a recurring cron task\n * @param taskId - Unique identifier for the task\n * @param taskType - Type of task (must have a registered handler)\n * @param payload - Data to pass to the handler (must be JSON-serializable)\n * @param options - Cron options (cronExpression required)\n */\n scheduleCron(\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleCronOptions\n ): Promise<boolean>;\n\n // ===== Task Management =====\n\n /**\n * Cancel a scheduled task\n */\n cancel(taskId: string): Promise<boolean>;\n\n /**\n * Pause a cron task (only for CRON type)\n */\n pause(taskId: string): Promise<boolean>;\n\n /**\n * Resume a paused cron task (only for CRON type)\n */\n resume(taskId: string): Promise<boolean>;\n\n /**\n * Check if a task exists\n */\n has(taskId: string): Promise<boolean>;\n\n /**\n * Get task information\n */\n getTask(taskId: string): Promise<ScheduledTaskDefinition | null>;\n\n /**\n * Get remaining time until next execution\n * Returns -1 if task not found or already executed\n */\n getRemainingTime(taskId: string): Promise<number>;\n\n /**\n * Get count of active tasks (pending + paused)\n */\n getActiveTaskCount(): Promise<number>;\n\n /**\n * Get all active task IDs\n */\n getActiveTaskIds(): Promise<string[]>;\n\n /**\n * Cancel all active tasks\n */\n cancelAll(): Promise<void>;\n\n // ===== Recovery =====\n\n /**\n * Restore active tasks from storage (call on service startup)\n * Re-schedules all pending tasks with their remaining time\n * Re-schedules all cron tasks for their next run\n * @returns Number of tasks restored\n */\n restore(): Promise<number>;\n\n // ===== Storage =====\n\n /**\n * Set the storage backend\n */\n setStorage(storage: ScheduleStorage): void;\n\n /**\n * Get current storage backend\n */\n getStorage(): ScheduleStorage | null;\n}\n\n/**\n * Schedule Lattice protocol interface\n */\nexport interface ScheduleLatticeProtocol\n extends BaseLatticeProtocol<ScheduleConfig, ScheduleClient> {\n // Handler registration\n registerHandler: (taskType: string, handler: TaskHandler) => void;\n unregisterHandler: (taskType: string) => boolean;\n hasHandler: (taskType: string) => boolean;\n getHandlerTypes: () => string[];\n\n // One-time task scheduling\n scheduleOnce: (\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleOnceOptions\n ) => Promise<boolean>;\n\n // Cron task scheduling\n scheduleCron: (\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleCronOptions\n ) => Promise<boolean>;\n\n // Task management\n cancel: (taskId: string) => Promise<boolean>;\n pause: (taskId: string) => Promise<boolean>;\n resume: (taskId: string) => Promise<boolean>;\n has: (taskId: string) => Promise<boolean>;\n getTask: (taskId: string) => Promise<ScheduledTaskDefinition | null>;\n getRemainingTime: (taskId: string) => Promise<number>;\n getActiveTaskCount: () => Promise<number>;\n getActiveTaskIds: () => Promise<string[]>;\n cancelAll: () => Promise<void>;\n\n // Recovery\n restore: () => Promise<number>;\n}\n","/**\n * LoggerLatticeProtocol\n *\n * Logger Lattice protocol for logging management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Logger service type enumeration\n */\nexport enum LoggerType {\n PINO = \"pino\",\n CONSOLE = \"console\",\n CUSTOM = \"custom\",\n}\n\n/**\n * Logger context interface\n */\nexport interface LoggerContext {\n \"x-user-id\"?: string;\n \"x-tenant-id\"?: string;\n \"x-request-id\"?: string;\n \"x-task-id\"?: string;\n \"x-thread-id\"?: string;\n [key: string]: any;\n}\n\n/**\n * Pino logger file transport options\n */\nexport interface PinoFileOptions {\n file?: string; // Log file path (e.g., \"./logs/app.log\" or \"./logs/app\")\n frequency?: \"daily\" | \"hourly\" | \"minutely\" | string; // Log rotation frequency\n mkdir?: boolean; // Create directory if not exists\n size?: string; // Max file size (e.g., \"10M\", \"100K\")\n maxFiles?: number; // Maximum number of log files to keep\n}\n\n/**\n * Logger configuration interface\n */\nexport interface LoggerConfig {\n name: string; // Logger name\n description?: string; // Logger description\n type: LoggerType; // Logger service type\n serviceName?: string; // Service name (e.g., \"lattice-gateway\")\n loggerName?: string; // Logger instance name (e.g., \"fastify-server\")\n context?: LoggerContext; // Initial context\n // File logging options (for PINO type)\n file?: string | PinoFileOptions; // Log file path or detailed file options\n // Additional options (e.g., pino config, custom logger settings)\n options?: Record<string, any>;\n}\n\n/**\n * Logger client interface\n */\nexport interface LoggerClient {\n info: (msg: string, obj?: object) => void;\n error: (msg: string, obj?: object | Error) => void;\n warn: (msg: string, obj?: object) => void;\n debug: (msg: string, obj?: object) => void;\n updateContext?: (context: Partial<LoggerContext>) => void;\n child?: (options: Partial<LoggerConfig>) => LoggerClient;\n}\n\n/**\n * Logger Lattice protocol interface\n */\nexport interface LoggerLatticeProtocol\n extends BaseLatticeProtocol<LoggerConfig, LoggerClient> {\n // Logger operations\n info: (msg: string, obj?: object) => void;\n error: (msg: string, obj?: object | Error) => void;\n warn: (msg: string, obj?: object) => void;\n debug: (msg: string, obj?: object) => void;\n updateContext?: (context: Partial<LoggerContext>) => void;\n child?: (options: Partial<LoggerConfig>) => LoggerClient;\n}\n","/**\n * McpLatticeProtocol\n *\n * Model Context Protocol (MCP) lattice protocol for integrating MCP servers\n * with the Lattice framework. Provides standardized interfaces for MCP\n * client connections, tool discovery, and remote execution.\n */\n\nimport { BaseLatticeProtocol, LatticeMessage } from \"./BaseLatticeProtocol\";\n\n/**\n * MCP transport type\n */\nexport type McpTransportType = \"stdio\" | \"streamable_http\" | \"sse\";\n\n/**\n * MCP server configuration\n */\nexport interface McpServerConfig {\n /** Server name */\n name: string;\n /** Server version */\n version: string;\n /** Transport type */\n transport: McpTransportType;\n /** Command for stdio transport (e.g., \"npx\", \"python\") */\n command?: string;\n /** Arguments for stdio transport */\n args?: string[];\n /** URL for HTTP/SSE transport */\n url?: string;\n /** Environment variables */\n env?: Record<string, string>;\n /** Connection timeout in milliseconds */\n timeout?: number;\n /** Retry attempts on connection failure */\n retryAttempts?: number;\n}\n\n/**\n * MCP tool definition\n */\nexport interface McpTool {\n /** Tool name */\n name: string;\n /** Tool description */\n description: string;\n /** Input schema */\n inputSchema: {\n type: \"object\";\n properties: Record<string, any>;\n required?: string[];\n };\n /** Tool metadata */\n metadata?: Record<string, any>;\n}\n\n/**\n * MCP tool call result\n */\nexport interface McpToolResult {\n /** Whether the call was successful */\n success: boolean;\n /** Result content */\n content: Array<{\n type: \"text\" | \"image\" | \"audio\" | \"resource\";\n data: any;\n mimeType?: string;\n }>;\n /** Error message if failed */\n error?: string;\n /** Execution metadata */\n metadata?: {\n duration: number;\n tokens?: number;\n model?: string;\n };\n}\n\n/**\n * MCP client interface\n */\nexport interface McpClient {\n /** Client name */\n name: string;\n /** Client version */\n version: string;\n /** Server configuration */\n serverConfig: McpServerConfig;\n \n /**\n * Connect to MCP server\n */\n connect(): Promise<void>;\n \n /**\n * Disconnect from MCP server\n */\n disconnect(): Promise<void>;\n \n /**\n * Check if connected\n */\n isConnected(): boolean;\n \n /**\n * List available tools\n */\n listTools(): Promise<McpTool[]>;\n \n /**\n * Call a tool\n */\n callTool(name: string, arguments_: Record<string, any>): Promise<McpToolResult>;\n \n /**\n * Subscribe to server notifications\n */\n subscribe(topic: string, handler: (data: any) => void): void;\n \n /**\n * Unsubscribe from server notifications\n */\n unsubscribe(topic: string): void;\n \n /**\n * Get client statistics\n */\n getStats(): McpStats;\n \n /**\n * Get connection status\n */\n getStatus(): McpConnectionStatus;\n}\n\n/**\n * MCP client options\n */\nexport interface McpClientOptions {\n /** Client name */\n name: string;\n /** Client version */\n version: string;\n /** Server configuration */\n serverConfig: McpServerConfig;\n /** Auto-connect on initialization */\n autoConnect?: boolean;\n /** Error handler */\n onError?: (error: Error) => void;\n /** Connection status handler */\n onStatusChange?: (status: McpConnectionStatus) => void;\n}\n\n/**\n * MCP Lattice protocol interface\n */\nexport interface McpLatticeProtocol\n extends BaseLatticeProtocol<McpServerConfig, McpClient> {\n /**\n * Server configuration\n */\n config: McpServerConfig;\n \n /**\n * MCP client instance\n */\n client: McpClient;\n \n /**\n * Connect to MCP server\n */\n connect(): Promise<void>;\n \n /**\n * Disconnect from MCP server\n */\n disconnect(): Promise<void>;\n \n /**\n * Get available tools\n */\n getTools(): Promise<McpTool[]>;\n \n /**\n * Execute a tool\n */\n executeTool(\n name: string,\n arguments_: Record<string, any>\n ): Promise<McpToolResult>;\n \n /**\n * Execute with automatic retries\n */\n executeToolWithRetry(\n name: string,\n arguments_: Record<string, any>,\n maxRetries?: number\n ): Promise<McpToolResult>;\n \n /**\n * Get protocol version\n */\n getProtocolVersion(): string;\n \n /**\n * Health check\n */\n healthCheck(): Promise<boolean>;\n}\n\n/**\n * MCP message types\n */\nexport enum McpMessageType {\n CONNECT = \"mcp:connect\",\n DISCONNECT = \"mcp:disconnect\",\n LIST_TOOLS = \"mcp:list_tools\",\n CALL_TOOL = \"mcp:call_tool\",\n TOOL_RESULT = \"mcp:tool_result\",\n NOTIFICATION = \"mcp:notification\",\n ERROR = \"mcp:error\",\n HEALTH_CHECK = \"mcp:health_check\",\n}\n\n/**\n * MCP Lattice message\n */\nexport interface McpLatticeMessage extends LatticeMessage {\n type: McpMessageType;\n payload: {\n toolName?: string;\n arguments?: Record<string, any>;\n result?: McpToolResult;\n tools?: McpTool[];\n error?: string;\n };\n}\n\n/**\n * MCP connection status\n */\nexport type McpConnectionStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"reconnecting\"\n | \"error\";\n\n/**\n * MCP statistics\n */\nexport interface McpStats {\n totalCalls: number;\n successfulCalls: number;\n failedCalls: number;\n averageLatency: number;\n lastCallTimestamp: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AAFH,SAAAA;AAAA,GAAA;AA8GL,SAAS,SAAS,QAAqD;AAC5E,SAAO;AACT;AAKO,SAAS,kBACd,QAC2B;AAC3B,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,mBAAmB,QAA+B;AAChE,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO,OAAO,SAAS,CAAC;AAAA,EAC1B;AACA,SAAO,CAAC;AACV;AAKO,SAAS,uBAAuB,QAA+B;AACpE,MAAI,kBAAkB,MAAM,GAAG;AAC7B,WAAO,OAAO,aAAa,CAAC;AAAA,EAC9B;AACA,SAAO,CAAC;AACV;;;AC/IO,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,aAAU;AALA,SAAAA;AAAA,GAAA;;;ACAL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,eAAY;AACZ,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AACT,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AAVC,SAAAA;AAAA,GAAA;;;ACAL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;;;ACEL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,WAAQ;AAHE,SAAAA;AAAA,GAAA;AASL,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,UAAO;AAFG,SAAAA;AAAA,GAAA;AAQL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,qBAAA,aAAU;AACV,EAAAA,qBAAA,aAAU;AACV,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,YAAS;AACT,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,YAAS;AANC,SAAAA;AAAA,GAAA;;;ACnBL,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;;;AC4ML,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,gBAAa;AACb,EAAAA,gBAAA,gBAAa;AACb,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,iBAAc;AACd,EAAAA,gBAAA,kBAAe;AACf,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,kBAAe;AARL,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","UIComponentType","QueueType","ScheduleType","ScheduleExecutionType","ScheduledTaskStatus","LoggerType","McpMessageType"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.ts","../src/ScheduleLatticeProtocol.ts","../src/LoggerLatticeProtocol.ts","../src/McpLatticeProtocol.ts"],"sourcesContent":["/**\n * Protocols\n *\n * 导出所有Lattice协议接口,为整个系统提供统一的接口规范\n */\n\nexport * from \"./BaseLatticeProtocol\";\nexport * from \"./ToolLatticeProtocol\";\nexport * from \"./ModelLatticeProtocol\";\nexport * from \"./AgentLatticeProtocol\";\nexport * from \"./MemoryLatticeProtocol\";\nexport * from \"./UILatticeProtocol\";\nexport * from \"./QueueLatticeProtocol\";\nexport * from \"./ScheduleLatticeProtocol\";\nexport * from \"./EmbeddingsLatticeProtocol\";\nexport * from \"./VectorStoreLatticeProtocol\";\nexport * from \"./LoggerLatticeProtocol\";\nexport * from \"./MessageProtocol\";\nexport * from \"./ThreadStoreProtocol\";\nexport * from \"./AssistantStoreProtocol\";\nexport * from \"./SkillLatticeProtocol\";\nexport * from \"./SkillStoreProtocol\";\nexport * from \"./McpLatticeProtocol\";\nexport * from \"./WorkspaceStoreProtocol\";\nexport * from \"./DatabaseConfigStoreProtocol\";\n\n// 导出通用类型\nexport * from \"./types\";\n","/**\n * AgentLatticeProtocol\n *\n * 智能体Lattice的协议,定义了智能体的行为和组合方式\n */\n\nimport { CompiledStateGraph } from \"@langchain/langgraph\";\nimport z, { ZodObject, ZodSchema } from \"zod\";\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 智能体类型枚举\n */\nexport enum AgentType {\n REACT = \"react\",\n DEEP_AGENT = \"deep_agent\",\n TEAM = \"team\",\n}\n\n/**\n * Runtime configuration that will be injected into LangGraphRunnableConfig.configurable\n * Tools can access these values via config.configurable.runConfig\n */\nexport interface AgentRunConfig {\n /** Database key for SQL tools (registered via sqlDatabaseManager) */\n databaseKey?: string;\n /** Any additional runtime configuration */\n [key: string]: any;\n}\n\n/**\n * Base agent configuration shared by all agent types\n */\ninterface BaseAgentConfig {\n key: string; // Unique key\n name: string; // Name\n description: string; // Description\n prompt: string; // Prompt\n /**\n * Key of the parent agent to inherit configuration from.\n * When set, unspecified fields are inherited from the parent agent's config.\n * Child's explicitly set fields override the parent's.\n */\n extendsAgent?: string;\n schema?: ZodObject<any, any, any, any, any>; // Input validation schema\n modelKey?: string; // Model key to use\n /**\n * Runtime configuration to inject into tool execution context\n * Will be available in tools via config.configurable.runConfig\n */\n runConfig?: AgentRunConfig;\n skillCategories?: string[];\n middleware?: AgentMiddlewareConfig[];\n}\n\nexport type AvailableModule = \"filesystem\" | \"code_eval\" | \"browser\";\n\nexport interface SandboxMiddlewareConfig {\n isolatedLevel: \"agent\" | \"thread\" | \"global\";\n modules: AvailableModule[];\n}\n\nexport interface CodeEvalMiddlewareConfig {\n isolatedLevel: \"agent\" | \"thread\" | \"global\";\n timeout: number;\n memoryLimit: number;\n}\n\nexport interface BrowserMiddlewareConfig {\n isolatedLevel: \"agent\" | \"thread\" | \"global\";\n headless: boolean;\n}\n\nexport interface SqlMiddlewareConfig {\n databaseKeys?: string[];\n}\n\nexport type MiddlewareType = \"filesystem\" | \"code_eval\" | \"browser\" | \"sql\" | \"skill\" | \"http\" | \"custom\";\n\nexport interface AgentMiddlewareConfig {\n id: string;\n type: MiddlewareType;\n name: string;\n description: string;\n enabled: boolean;\n config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | Record<string, any>;\n}\n\n\n/**\n * REACT agent configuration\n */\nexport interface ReactAgentConfig extends BaseAgentConfig {\n type: AgentType.REACT;\n tools?: string[]; // Tool list\n}\n\n/**\n * DEEP_AGENT configuration - only this type supports subAgents\n */\nexport interface DeepAgentConfig extends BaseAgentConfig {\n type: AgentType.DEEP_AGENT;\n tools?: string[]; // Tool list\n subAgents?: string[]; // Sub-agent list (unique to DEEP_AGENT)\n internalSubAgents?: AgentConfig[]; // Internal sub-agent list (unique to DEEP_AGENT)\n}\n\n\n\n/**\n * Team teammate configuration -- describes an available teammate.\n */\nexport interface TeamTeammateConfig {\n /** Unique name for this teammate (used as agent ID) */\n name: string;\n /** Role category (e.g. \"research\", \"writing\", \"review\") */\n role: string;\n /** Human-readable description of what this teammate does */\n description: string;\n /** Tool keys this teammate has access to */\n tools?: string[];\n /** Custom system prompt for this teammate */\n prompt?: string;\n /** Model key override for this teammate */\n modelKey?: string;\n}\n\n/**\n * TEAM agent configuration -- a team lead that dynamically creates teammates.\n * Teammates are created on-the-fly from create_team tool input (name, role, description).\n */\nexport interface TeamAgentConfig extends BaseAgentConfig {\n type: AgentType.TEAM;\n /** Tool keys available to the team lead */\n tools?: string[];\n /** Maximum number of teammates running concurrently */\n maxConcurrency?: number;\n /**\n * Schedule lattice key for polling task list / mailbox.\n * When set, teammates use ScheduleLattice for periodic polling instead of event-driven wait.\n */\n scheduleLatticeKey?: string;\n /** Poll interval in ms when using schedule lattice (default: 5000) */\n pollIntervalMs?: number;\n}\n\n/**\n * Type guard to check if config is TeamAgentConfig\n */\nexport function isTeamAgentConfig(\n config: AgentConfig\n): config is TeamAgentConfig {\n return config.type === AgentType.TEAM;\n}\n\n/**\n * Agent configuration union type\n * Different agent types have different configuration options\n */\nexport type AgentConfig =\n | ReactAgentConfig\n | DeepAgentConfig\n | TeamAgentConfig\n\n/**\n * Agent configuration with tools property\n */\nexport type AgentConfigWithTools =\n | ReactAgentConfig\n | DeepAgentConfig\n | TeamAgentConfig\n\n/**\n * Type guard to check if config has tools property\n */\nexport function hasTools(config: AgentConfig): config is AgentConfigWithTools {\n return true\n}\n\n/**\n * Type guard to check if config is DeepAgentConfig (has subAgents)\n */\nexport function isDeepAgentConfig(\n config: AgentConfig\n): config is DeepAgentConfig {\n return config.type === AgentType.DEEP_AGENT;\n}\n\n/**\n * Get tools from config safely\n */\nexport function getToolsFromConfig(config: AgentConfig): string[] {\n if (hasTools(config)) {\n return config.tools || [];\n }\n return [];\n}\n\n/**\n * Get subAgents from config safely (only DeepAgentConfig has subAgents)\n */\nexport function getSubAgentsFromConfig(config: AgentConfig): string[] {\n if (isDeepAgentConfig(config)) {\n return config.subAgents || [];\n }\n return [];\n}\n\n/**\n * 智能体客户端类型\n */\nexport type AgentClient = CompiledStateGraph<any, any, any, any, any>;\n\n/**\n * Graph构建选项\n */\nexport interface GraphBuildOptions {\n overrideTools?: string[];\n overrideModel?: string;\n metadata?: Record<string, any>;\n}\n\n/**\n * 智能体Lattice协议接口\n */\nexport interface AgentLatticeProtocol\n extends BaseLatticeProtocol<AgentConfig, AgentClient> {\n // 智能体执行函数\n invoke: (input: any, options?: any) => Promise<any>;\n\n // 构建智能体图\n buildGraph: (options?: GraphBuildOptions) => Promise<AgentClient>;\n}\n","/**\n * MemoryLatticeProtocol\n *\n * 记忆Lattice的协议,用于管理智能体的上下文和记忆\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * 记忆类型枚举\n */\nexport enum MemoryType {\n SHORT_TERM = \"short_term\",\n LONG_TERM = \"long_term\",\n EPISODIC = \"episodic\",\n SEMANTIC = \"semantic\",\n WORKING = \"working\",\n}\n\n/**\n * 记忆配置接口\n */\nexport interface MemoryConfig {\n name: string; // 名称\n description: string; // 描述\n type: MemoryType; // 记忆类型\n ttl?: number; // 生存时间\n capacity?: number; // 容量限制\n}\n\n/**\n * 记忆客户端接口\n */\nexport interface MemoryClient {\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n\n/**\n * 记忆Lattice协议接口\n */\nexport interface MemoryLatticeProtocol\n extends BaseLatticeProtocol<MemoryConfig, MemoryClient> {\n // 记忆操作方法\n add: (key: string, value: any) => Promise<void>;\n get: (key: string) => Promise<any>;\n update: (key: string, value: any) => Promise<void>;\n delete: (key: string) => Promise<void>;\n search: (query: string, options?: any) => Promise<any[]>;\n clear: () => Promise<void>;\n}\n","/**\n * UILatticeProtocol\n *\n * UI Lattice的协议,用于定义用户界面组件\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * UI组件类型枚举\n */\nexport enum UIComponentType {\n CONTAINER = \"container\",\n INPUT = \"input\",\n BUTTON = \"button\",\n LIST = \"list\",\n TABLE = \"table\",\n CHART = \"chart\",\n FORM = \"form\",\n CARD = \"card\",\n MODAL = \"modal\",\n CUSTOM = \"custom\",\n}\n\n/**\n * UI配置接口\n */\nexport interface UIConfig {\n name: string; // 组件名称\n description: string; // 组件描述\n type: UIComponentType; // 组件类型\n props?: Record<string, any>; // 组件属性\n children?: string[]; // 子组件列表\n}\n\n/**\n * UI组件接口\n * 使用泛型以适应不同的UI框架(React, Vue等)\n */\nexport interface UIComponent<T = any> {\n render: (props?: any) => T;\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n\n/**\n * UI Lattice协议接口\n */\nexport interface UILatticeProtocol<T = any>\n extends BaseLatticeProtocol<UIConfig, UIComponent<T>> {\n // UI渲染方法\n render: (props?: any) => T;\n\n // 事件处理\n addEventListener: (event: string, handler: Function) => void;\n removeEventListener: (event: string, handler: Function) => void;\n}\n","/**\n * QueueLatticeProtocol\n *\n * Queue Lattice protocol for task queue management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Queue service type enumeration\n */\nexport enum QueueType {\n MEMORY = \"memory\",\n REDIS = \"redis\",\n}\n\n/**\n * Queue configuration interface\n */\nexport interface QueueConfig {\n name: string; // Queue name\n description: string; // Queue description\n type: QueueType; // Queue service type\n queueName?: string; // Specific queue name (e.g., \"tasks\")\n options?: Record<string, any>; // Additional options (e.g., Redis connection options)\n}\n\n/**\n * Queue operation result interface\n */\nexport interface QueueResult<T = any> {\n data: T | null;\n error: any | null;\n}\n\n/**\n * Queue client interface\n */\nexport interface QueueClient {\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n/**\n * Queue Lattice protocol interface\n */\nexport interface QueueLatticeProtocol\n extends BaseLatticeProtocol<QueueConfig, QueueClient> {\n // Queue operations\n push: (item: any) => Promise<QueueResult<number>>;\n pop: () => Promise<QueueResult<any>>;\n createQueue?: () => Promise<{ success: boolean; queue_name?: string; error?: any }>;\n}\n\n\n\n","/**\n * ScheduleLatticeProtocol\n *\n * Schedule Lattice protocol for delayed and recurring task execution management\n * Supports persistence and recovery after service restart\n * Supports both one-time delayed tasks and cron-style recurring tasks\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Schedule service type enumeration\n */\nexport enum ScheduleType {\n MEMORY = \"memory\",\n POSTGRES = \"postgres\",\n REDIS = \"redis\",\n}\n\n/**\n * Schedule execution type - one-time or recurring\n */\nexport enum ScheduleExecutionType {\n ONCE = \"once\", // Execute once at specified time\n CRON = \"cron\", // Recurring based on cron expression\n}\n\n/**\n * Task status enumeration\n */\nexport enum ScheduledTaskStatus {\n PENDING = \"pending\", // Waiting to be executed\n RUNNING = \"running\", // Currently executing\n COMPLETED = \"completed\", // Successfully completed (for ONCE type)\n FAILED = \"failed\", // Execution failed\n CANCELLED = \"cancelled\", // Manually cancelled\n PAUSED = \"paused\", // Paused (for CRON type)\n}\n\n/**\n * Schedule configuration interface\n */\nexport interface ScheduleConfig {\n name: string;\n description: string;\n type: ScheduleType;\n storage?: ScheduleStorage; // Optional storage for persistence\n options?: Record<string, any>;\n}\n\n/**\n * Scheduled task definition - fully serializable\n * Supports both one-time and cron-style recurring tasks\n */\nexport interface ScheduledTaskDefinition {\n taskId: string;\n taskType: string; // Maps to a registered handler\n payload: Record<string, any>; // JSON-serializable data passed to handler\n\n // Context fields for querying\n assistantId?: string; // Which assistant created/owns this task\n threadId?: string; // Which thread this task belongs to\n\n // Execution configuration\n executionType: ScheduleExecutionType;\n\n // For ONCE type - execute at specific time or after delay\n executeAt?: number; // Timestamp when to execute\n delayMs?: number; // Original delay in milliseconds (for reference)\n\n // For CRON type - recurring schedule\n cronExpression?: string; // Cron format: \"0 9 * * *\" (min hour day month weekday)\n timezone?: string; // Timezone: \"Asia/Shanghai\", defaults to system timezone\n nextRunAt?: number; // Next calculated execution time\n lastRunAt?: number; // Last execution time\n\n // Execution tracking\n status: ScheduledTaskStatus;\n runCount: number; // How many times executed\n maxRuns?: number; // Max executions (null/undefined = infinite for cron, 1 for once)\n\n // Error handling\n retryCount: number; // Current retry count\n maxRetries: number; // Maximum retry attempts\n lastError?: string; // Last error message if failed\n\n // Timestamps\n createdAt: number;\n updatedAt: number;\n expiresAt?: number; // When to stop (for cron, optional)\n\n metadata?: Record<string, any>; // Additional metadata\n}\n\n/**\n * Task handler function type\n */\nexport type TaskHandler = (\n payload: Record<string, any>,\n taskInfo: ScheduledTaskDefinition\n) => void | Promise<void>;\n\n/**\n * Options for scheduling a one-time task\n */\nexport interface ScheduleOnceOptions {\n executeAt?: number; // Absolute timestamp to execute\n delayMs?: number; // OR relative delay from now\n maxRetries?: number; // Max retry attempts (default: 0)\n assistantId?: string; // Which assistant created/owns this task\n threadId?: string; // Which thread this task belongs to\n metadata?: Record<string, any>;\n}\n\n/**\n * Options for scheduling a cron task\n */\nexport interface ScheduleCronOptions {\n cronExpression: string; // Cron expression: \"0 9 * * *\"\n timezone?: string; // Timezone: \"Asia/Shanghai\"\n maxRuns?: number; // Max executions (undefined = infinite)\n expiresAt?: number; // Stop after this timestamp\n maxRetries?: number; // Max retry attempts per run (default: 0)\n assistantId?: string; // Which assistant created/owns this task\n threadId?: string; // Which thread this task belongs to\n metadata?: Record<string, any>;\n}\n\n/**\n * Schedule storage interface for persistence\n */\nexport interface ScheduleStorage {\n /**\n * Save a new task\n */\n save(task: ScheduledTaskDefinition): Promise<void>;\n\n /**\n * Get task by ID\n */\n get(taskId: string): Promise<ScheduledTaskDefinition | null>;\n\n /**\n * Update task\n */\n update(\n taskId: string,\n updates: Partial<ScheduledTaskDefinition>\n ): Promise<void>;\n\n /**\n * Delete task\n */\n delete(taskId: string): Promise<void>;\n\n /**\n * Get all pending/active tasks (for recovery)\n * Returns tasks with status: PENDING or PAUSED\n */\n getActiveTasks(): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by type\n */\n getTasksByType(taskType: string): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by status\n */\n getTasksByStatus(\n status: ScheduledTaskStatus\n ): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by execution type\n */\n getTasksByExecutionType(\n executionType: ScheduleExecutionType\n ): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by assistant ID\n */\n getTasksByAssistantId(\n assistantId: string\n ): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get tasks by thread ID\n */\n getTasksByThreadId(threadId: string): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Get all tasks (with optional filters)\n */\n getAllTasks(filters?: {\n status?: ScheduledTaskStatus;\n executionType?: ScheduleExecutionType;\n taskType?: string;\n assistantId?: string;\n threadId?: string;\n limit?: number;\n offset?: number;\n }): Promise<ScheduledTaskDefinition[]>;\n\n /**\n * Count tasks (with optional filters)\n */\n countTasks(filters?: {\n status?: ScheduledTaskStatus;\n executionType?: ScheduleExecutionType;\n taskType?: string;\n assistantId?: string;\n threadId?: string;\n }): Promise<number>;\n\n /**\n * Delete completed/cancelled tasks older than specified time\n * Useful for cleanup\n */\n deleteOldTasks(olderThanMs: number): Promise<number>;\n}\n\n/**\n * Schedule client interface\n */\nexport interface ScheduleClient {\n // ===== Handler Registration =====\n\n /**\n * Register a handler for a task type\n * Must be called before scheduling tasks of this type\n */\n registerHandler(taskType: string, handler: TaskHandler): void;\n\n /**\n * Unregister a handler\n */\n unregisterHandler(taskType: string): boolean;\n\n /**\n * Check if a handler is registered\n */\n hasHandler(taskType: string): boolean;\n\n /**\n * Get all registered handler types\n */\n getHandlerTypes(): string[];\n\n // ===== One-time Task Scheduling =====\n\n /**\n * Schedule a one-time task\n * @param taskId - Unique identifier for the task\n * @param taskType - Type of task (must have a registered handler)\n * @param payload - Data to pass to the handler (must be JSON-serializable)\n * @param options - Execution options (executeAt or delayMs required)\n */\n scheduleOnce(\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleOnceOptions\n ): Promise<boolean>;\n\n // ===== Cron Task Scheduling =====\n\n /**\n * Schedule a recurring cron task\n * @param taskId - Unique identifier for the task\n * @param taskType - Type of task (must have a registered handler)\n * @param payload - Data to pass to the handler (must be JSON-serializable)\n * @param options - Cron options (cronExpression required)\n */\n scheduleCron(\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleCronOptions\n ): Promise<boolean>;\n\n // ===== Task Management =====\n\n /**\n * Cancel a scheduled task\n */\n cancel(taskId: string): Promise<boolean>;\n\n /**\n * Pause a cron task (only for CRON type)\n */\n pause(taskId: string): Promise<boolean>;\n\n /**\n * Resume a paused cron task (only for CRON type)\n */\n resume(taskId: string): Promise<boolean>;\n\n /**\n * Check if a task exists\n */\n has(taskId: string): Promise<boolean>;\n\n /**\n * Get task information\n */\n getTask(taskId: string): Promise<ScheduledTaskDefinition | null>;\n\n /**\n * Get remaining time until next execution\n * Returns -1 if task not found or already executed\n */\n getRemainingTime(taskId: string): Promise<number>;\n\n /**\n * Get count of active tasks (pending + paused)\n */\n getActiveTaskCount(): Promise<number>;\n\n /**\n * Get all active task IDs\n */\n getActiveTaskIds(): Promise<string[]>;\n\n /**\n * Cancel all active tasks\n */\n cancelAll(): Promise<void>;\n\n // ===== Recovery =====\n\n /**\n * Restore active tasks from storage (call on service startup)\n * Re-schedules all pending tasks with their remaining time\n * Re-schedules all cron tasks for their next run\n * @returns Number of tasks restored\n */\n restore(): Promise<number>;\n\n // ===== Storage =====\n\n /**\n * Set the storage backend\n */\n setStorage(storage: ScheduleStorage): void;\n\n /**\n * Get current storage backend\n */\n getStorage(): ScheduleStorage | null;\n}\n\n/**\n * Schedule Lattice protocol interface\n */\nexport interface ScheduleLatticeProtocol\n extends BaseLatticeProtocol<ScheduleConfig, ScheduleClient> {\n // Handler registration\n registerHandler: (taskType: string, handler: TaskHandler) => void;\n unregisterHandler: (taskType: string) => boolean;\n hasHandler: (taskType: string) => boolean;\n getHandlerTypes: () => string[];\n\n // One-time task scheduling\n scheduleOnce: (\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleOnceOptions\n ) => Promise<boolean>;\n\n // Cron task scheduling\n scheduleCron: (\n taskId: string,\n taskType: string,\n payload: Record<string, any>,\n options: ScheduleCronOptions\n ) => Promise<boolean>;\n\n // Task management\n cancel: (taskId: string) => Promise<boolean>;\n pause: (taskId: string) => Promise<boolean>;\n resume: (taskId: string) => Promise<boolean>;\n has: (taskId: string) => Promise<boolean>;\n getTask: (taskId: string) => Promise<ScheduledTaskDefinition | null>;\n getRemainingTime: (taskId: string) => Promise<number>;\n getActiveTaskCount: () => Promise<number>;\n getActiveTaskIds: () => Promise<string[]>;\n cancelAll: () => Promise<void>;\n\n // Recovery\n restore: () => Promise<number>;\n}\n","/**\n * LoggerLatticeProtocol\n *\n * Logger Lattice protocol for logging management\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Logger service type enumeration\n */\nexport enum LoggerType {\n PINO = \"pino\",\n CONSOLE = \"console\",\n CUSTOM = \"custom\",\n}\n\n/**\n * Logger context interface\n */\nexport interface LoggerContext {\n \"x-user-id\"?: string;\n \"x-tenant-id\"?: string;\n \"x-request-id\"?: string;\n \"x-task-id\"?: string;\n \"x-thread-id\"?: string;\n [key: string]: any;\n}\n\n/**\n * Pino logger file transport options\n */\nexport interface PinoFileOptions {\n file?: string; // Log file path (e.g., \"./logs/app.log\" or \"./logs/app\")\n frequency?: \"daily\" | \"hourly\" | \"minutely\" | string; // Log rotation frequency\n mkdir?: boolean; // Create directory if not exists\n size?: string; // Max file size (e.g., \"10M\", \"100K\")\n maxFiles?: number; // Maximum number of log files to keep\n}\n\n/**\n * Logger configuration interface\n */\nexport interface LoggerConfig {\n name: string; // Logger name\n description?: string; // Logger description\n type: LoggerType; // Logger service type\n serviceName?: string; // Service name (e.g., \"lattice-gateway\")\n loggerName?: string; // Logger instance name (e.g., \"fastify-server\")\n context?: LoggerContext; // Initial context\n // File logging options (for PINO type)\n file?: string | PinoFileOptions; // Log file path or detailed file options\n // Additional options (e.g., pino config, custom logger settings)\n options?: Record<string, any>;\n}\n\n/**\n * Logger client interface\n */\nexport interface LoggerClient {\n info: (msg: string, obj?: object) => void;\n error: (msg: string, obj?: object | Error) => void;\n warn: (msg: string, obj?: object) => void;\n debug: (msg: string, obj?: object) => void;\n updateContext?: (context: Partial<LoggerContext>) => void;\n child?: (options: Partial<LoggerConfig>) => LoggerClient;\n}\n\n/**\n * Logger Lattice protocol interface\n */\nexport interface LoggerLatticeProtocol\n extends BaseLatticeProtocol<LoggerConfig, LoggerClient> {\n // Logger operations\n info: (msg: string, obj?: object) => void;\n error: (msg: string, obj?: object | Error) => void;\n warn: (msg: string, obj?: object) => void;\n debug: (msg: string, obj?: object) => void;\n updateContext?: (context: Partial<LoggerContext>) => void;\n child?: (options: Partial<LoggerConfig>) => LoggerClient;\n}\n","/**\n * McpLatticeProtocol\n *\n * Model Context Protocol (MCP) lattice protocol for integrating MCP servers\n * with the Lattice framework. Provides standardized interfaces for MCP\n * client connections, tool discovery, and remote execution.\n */\n\nimport { BaseLatticeProtocol, LatticeMessage } from \"./BaseLatticeProtocol\";\n\n/**\n * MCP transport type\n */\nexport type McpTransportType = \"stdio\" | \"streamable_http\" | \"sse\";\n\n/**\n * MCP server configuration\n */\nexport interface McpServerConfig {\n /** Server name */\n name: string;\n /** Server version */\n version: string;\n /** Transport type */\n transport: McpTransportType;\n /** Command for stdio transport (e.g., \"npx\", \"python\") */\n command?: string;\n /** Arguments for stdio transport */\n args?: string[];\n /** URL for HTTP/SSE transport */\n url?: string;\n /** Environment variables */\n env?: Record<string, string>;\n /** Connection timeout in milliseconds */\n timeout?: number;\n /** Retry attempts on connection failure */\n retryAttempts?: number;\n}\n\n/**\n * MCP tool definition\n */\nexport interface McpTool {\n /** Tool name */\n name: string;\n /** Tool description */\n description: string;\n /** Input schema */\n inputSchema: {\n type: \"object\";\n properties: Record<string, any>;\n required?: string[];\n };\n /** Tool metadata */\n metadata?: Record<string, any>;\n}\n\n/**\n * MCP tool call result\n */\nexport interface McpToolResult {\n /** Whether the call was successful */\n success: boolean;\n /** Result content */\n content: Array<{\n type: \"text\" | \"image\" | \"audio\" | \"resource\";\n data: any;\n mimeType?: string;\n }>;\n /** Error message if failed */\n error?: string;\n /** Execution metadata */\n metadata?: {\n duration: number;\n tokens?: number;\n model?: string;\n };\n}\n\n/**\n * MCP client interface\n */\nexport interface McpClient {\n /** Client name */\n name: string;\n /** Client version */\n version: string;\n /** Server configuration */\n serverConfig: McpServerConfig;\n \n /**\n * Connect to MCP server\n */\n connect(): Promise<void>;\n \n /**\n * Disconnect from MCP server\n */\n disconnect(): Promise<void>;\n \n /**\n * Check if connected\n */\n isConnected(): boolean;\n \n /**\n * List available tools\n */\n listTools(): Promise<McpTool[]>;\n \n /**\n * Call a tool\n */\n callTool(name: string, arguments_: Record<string, any>): Promise<McpToolResult>;\n \n /**\n * Subscribe to server notifications\n */\n subscribe(topic: string, handler: (data: any) => void): void;\n \n /**\n * Unsubscribe from server notifications\n */\n unsubscribe(topic: string): void;\n \n /**\n * Get client statistics\n */\n getStats(): McpStats;\n \n /**\n * Get connection status\n */\n getStatus(): McpConnectionStatus;\n}\n\n/**\n * MCP client options\n */\nexport interface McpClientOptions {\n /** Client name */\n name: string;\n /** Client version */\n version: string;\n /** Server configuration */\n serverConfig: McpServerConfig;\n /** Auto-connect on initialization */\n autoConnect?: boolean;\n /** Error handler */\n onError?: (error: Error) => void;\n /** Connection status handler */\n onStatusChange?: (status: McpConnectionStatus) => void;\n}\n\n/**\n * MCP Lattice protocol interface\n */\nexport interface McpLatticeProtocol\n extends BaseLatticeProtocol<McpServerConfig, McpClient> {\n /**\n * Server configuration\n */\n config: McpServerConfig;\n \n /**\n * MCP client instance\n */\n client: McpClient;\n \n /**\n * Connect to MCP server\n */\n connect(): Promise<void>;\n \n /**\n * Disconnect from MCP server\n */\n disconnect(): Promise<void>;\n \n /**\n * Get available tools\n */\n getTools(): Promise<McpTool[]>;\n \n /**\n * Execute a tool\n */\n executeTool(\n name: string,\n arguments_: Record<string, any>\n ): Promise<McpToolResult>;\n \n /**\n * Execute with automatic retries\n */\n executeToolWithRetry(\n name: string,\n arguments_: Record<string, any>,\n maxRetries?: number\n ): Promise<McpToolResult>;\n \n /**\n * Get protocol version\n */\n getProtocolVersion(): string;\n \n /**\n * Health check\n */\n healthCheck(): Promise<boolean>;\n}\n\n/**\n * MCP message types\n */\nexport enum McpMessageType {\n CONNECT = \"mcp:connect\",\n DISCONNECT = \"mcp:disconnect\",\n LIST_TOOLS = \"mcp:list_tools\",\n CALL_TOOL = \"mcp:call_tool\",\n TOOL_RESULT = \"mcp:tool_result\",\n NOTIFICATION = \"mcp:notification\",\n ERROR = \"mcp:error\",\n HEALTH_CHECK = \"mcp:health_check\",\n}\n\n/**\n * MCP Lattice message\n */\nexport interface McpLatticeMessage extends LatticeMessage {\n type: McpMessageType;\n payload: {\n toolName?: string;\n arguments?: Record<string, any>;\n result?: McpToolResult;\n tools?: McpTool[];\n error?: string;\n };\n}\n\n/**\n * MCP connection status\n */\nexport type McpConnectionStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"reconnecting\"\n | \"error\";\n\n/**\n * MCP statistics\n */\nexport interface McpStats {\n totalCalls: number;\n successfulCalls: number;\n failedCalls: number;\n averageLatency: number;\n lastCallTimestamp: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAwIL,SAAS,kBACd,QAC2B;AAC3B,SAAO,OAAO,SAAS;AACzB;AAsBO,SAAS,SAAS,QAAqD;AAC5E,SAAO;AACT;AAKO,SAAS,kBACd,QAC2B;AAC3B,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,mBAAmB,QAA+B;AAChE,MAAI,SAAS,MAAM,GAAG;AACpB,WAAO,OAAO,SAAS,CAAC;AAAA,EAC1B;AACA,SAAO,CAAC;AACV;AAKO,SAAS,uBAAuB,QAA+B;AACpE,MAAI,kBAAkB,MAAM,GAAG;AAC7B,WAAO,OAAO,aAAa,CAAC;AAAA,EAC9B;AACA,SAAO,CAAC;AACV;;;ACnMO,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,gBAAa;AACb,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,cAAW;AACX,EAAAA,YAAA,aAAU;AALA,SAAAA;AAAA,GAAA;;;ACAL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,eAAY;AACZ,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AACT,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AAVC,SAAAA;AAAA,GAAA;;;ACAL,IAAK,YAAL,kBAAKC,eAAL;AACL,EAAAA,WAAA,YAAS;AACT,EAAAA,WAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;;;ACEL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,YAAS;AACT,EAAAA,cAAA,cAAW;AACX,EAAAA,cAAA,WAAQ;AAHE,SAAAA;AAAA,GAAA;AASL,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,UAAO;AAFG,SAAAA;AAAA,GAAA;AAQL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,EAAAA,qBAAA,aAAU;AACV,EAAAA,qBAAA,aAAU;AACV,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,YAAS;AACT,EAAAA,qBAAA,eAAY;AACZ,EAAAA,qBAAA,YAAS;AANC,SAAAA;AAAA,GAAA;;;ACnBL,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;;;AC4ML,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,gBAAa;AACb,EAAAA,gBAAA,gBAAa;AACb,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,iBAAc;AACd,EAAAA,gBAAA,kBAAe;AACf,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,kBAAe;AARL,SAAAA;AAAA,GAAA;","names":["AgentType","MemoryType","UIComponentType","QueueType","ScheduleType","ScheduleExecutionType","ScheduledTaskStatus","LoggerType","McpMessageType"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
var AgentType = /* @__PURE__ */ ((AgentType2) => {
|
|
3
3
|
AgentType2["REACT"] = "react";
|
|
4
4
|
AgentType2["DEEP_AGENT"] = "deep_agent";
|
|
5
|
+
AgentType2["TEAM"] = "team";
|
|
5
6
|
return AgentType2;
|
|
6
7
|
})(AgentType || {});
|
|
8
|
+
function isTeamAgentConfig(config) {
|
|
9
|
+
return config.type === "team" /* TEAM */;
|
|
10
|
+
}
|
|
7
11
|
function hasTools(config) {
|
|
8
12
|
return true;
|
|
9
13
|
}
|
|
@@ -110,6 +114,7 @@ export {
|
|
|
110
114
|
getSubAgentsFromConfig,
|
|
111
115
|
getToolsFromConfig,
|
|
112
116
|
hasTools,
|
|
113
|
-
isDeepAgentConfig
|
|
117
|
+
isDeepAgentConfig,
|
|
118
|
+
isTeamAgentConfig
|
|
114
119
|
};
|
|
115
120
|
//# sourceMappingURL=index.mjs.map
|