@axiom-lattice/protocols 2.1.25 → 2.1.27

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @axiom-lattice/protocols@2.1.25 build /home/runner/work/agentic/agentic/packages/protocols
2
+ > @axiom-lattice/protocols@2.1.27 build /home/runner/work/agentic/agentic/packages/protocols
3
3
  > tsup src/index.ts --format cjs,esm --dts --sourcemap
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,13 +8,13 @@
8
8
  CLI Target: es2020
9
9
  CJS Build start
10
10
  ESM Build start
11
- ESM dist/index.mjs 3.92 KB
12
- ESM dist/index.mjs.map 34.72 KB
13
- ESM ⚡️ Build success in 72ms
14
11
  CJS dist/index.js 5.49 KB
15
- CJS dist/index.js.map 35.99 KB
16
- CJS ⚡️ Build success in 72ms
12
+ CJS dist/index.js.map 36.17 KB
13
+ CJS ⚡️ Build success in 143ms
14
+ ESM dist/index.mjs 3.92 KB
15
+ ESM dist/index.mjs.map 34.84 KB
16
+ ESM ⚡️ Build success in 149ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 2729ms
19
- DTS dist/index.d.ts 76.45 KB
20
- DTS dist/index.d.mts 76.45 KB
18
+ DTS ⚡️ Build success in 7653ms
19
+ DTS dist/index.d.ts 79.59 KB
20
+ DTS dist/index.d.mts 79.59 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @axiom-lattice/protocols
2
2
 
3
+ ## 2.1.27
4
+
5
+ ### Patch Changes
6
+
7
+ - 15808cd: update sandbox console
8
+
9
+ ## 2.1.26
10
+
11
+ ### Patch Changes
12
+
13
+ - 5444ad4: update
14
+
3
15
  ## 2.1.25
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -164,16 +164,16 @@ interface BaseAgentConfig {
164
164
  }
165
165
  type AvailableModule = "filesystem" | "code_eval" | "browser";
166
166
  interface SandboxMiddlewareConfig {
167
- isolatedLevel: "agent" | "thread" | "global";
167
+ vmIsolation: "agent" | "project" | "global";
168
168
  modules: AvailableModule[];
169
169
  }
170
170
  interface CodeEvalMiddlewareConfig {
171
- isolatedLevel: "agent" | "thread" | "global";
171
+ vmIsolation: "agent" | "project" | "global";
172
172
  timeout: number;
173
173
  memoryLimit: number;
174
174
  }
175
175
  interface BrowserMiddlewareConfig {
176
- isolatedLevel: "agent" | "thread" | "global";
176
+ vmIsolation: "agent" | "project" | "global";
177
177
  headless: boolean;
178
178
  }
179
179
  interface SqlMiddlewareConfig {
@@ -185,14 +185,17 @@ interface MetricsMiddlewareConfig {
185
185
  /** Optional descriptions for each server */
186
186
  serverDescriptions?: Record<string, string>;
187
187
  }
188
- type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date";
188
+ interface SchedulerMiddlewareConfig {
189
+ defaultMaxRetries?: number;
190
+ }
191
+ type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date" | "scheduler";
189
192
  interface AgentMiddlewareConfig {
190
193
  id: string;
191
194
  type: MiddlewareType;
192
195
  name: string;
193
196
  description: string;
194
197
  enabled: boolean;
195
- config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | MetricsMiddlewareConfig | ClawMiddlewareConfig | Record<string, any>;
198
+ config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | MetricsMiddlewareConfig | ClawMiddlewareConfig | SchedulerMiddlewareConfig | Record<string, any>;
196
199
  }
197
200
  /**
198
201
  * Bootstrap file configuration
@@ -1306,6 +1309,17 @@ interface CreateSkillRequest {
1306
1309
  */
1307
1310
  subSkills?: string[];
1308
1311
  }
1312
+ /**
1313
+ * SkillStore context for runtime sandbox resolution
1314
+ */
1315
+ interface SkillStoreContext {
1316
+ /** Assistant/agent identifier */
1317
+ assistantId?: string;
1318
+ /** Workspace identifier */
1319
+ workspaceId?: string;
1320
+ /** Project identifier */
1321
+ projectId?: string;
1322
+ }
1309
1323
  /**
1310
1324
  * SkillStore interface
1311
1325
  * Provides CRUD operations for skill data
@@ -1314,90 +1328,102 @@ interface SkillStore {
1314
1328
  /**
1315
1329
  * Get all skills for a tenant
1316
1330
  * @param tenantId Tenant identifier
1331
+ * @param context Optional runtime context for sandbox resolution
1317
1332
  * @returns Array of all skills for the tenant
1318
1333
  */
1319
- getAllSkills(tenantId: string): Promise<Skill[]>;
1334
+ getAllSkills(tenantId: string, context?: SkillStoreContext): Promise<Skill[]>;
1320
1335
  /**
1321
1336
  * Get skill by ID
1322
1337
  * @param tenantId Tenant identifier
1323
1338
  * @param id Skill identifier
1339
+ * @param context Optional runtime context for sandbox resolution
1324
1340
  * @returns Skill if found, null otherwise
1325
1341
  */
1326
- getSkillById(tenantId: string, id: string): Promise<Skill | null>;
1342
+ getSkillById(tenantId: string, id: string, context?: SkillStoreContext): Promise<Skill | null>;
1327
1343
  /**
1328
1344
  * Create a new skill
1329
1345
  * @param tenantId Tenant identifier
1330
1346
  * @param id Skill identifier
1331
1347
  * @param data Skill creation data
1348
+ * @param context Optional runtime context for sandbox resolution
1332
1349
  * @returns Created skill
1333
1350
  */
1334
- createSkill(tenantId: string, id: string, data: CreateSkillRequest): Promise<Skill>;
1351
+ createSkill(tenantId: string, id: string, data: CreateSkillRequest, context?: SkillStoreContext): Promise<Skill>;
1335
1352
  /**
1336
1353
  * Update an existing skill
1337
1354
  * @param tenantId Tenant identifier
1338
1355
  * @param id Skill identifier
1339
1356
  * @param updates Partial skill data to update
1357
+ * @param context Optional runtime context for sandbox resolution
1340
1358
  * @returns Updated skill if found, null otherwise
1341
1359
  */
1342
- updateSkill(tenantId: string, id: string, updates: Partial<CreateSkillRequest>): Promise<Skill | null>;
1360
+ updateSkill(tenantId: string, id: string, updates: Partial<CreateSkillRequest>, context?: SkillStoreContext): Promise<Skill | null>;
1343
1361
  /**
1344
1362
  * Delete a skill by ID
1345
1363
  * @param tenantId Tenant identifier
1346
1364
  * @param id Skill identifier
1365
+ * @param context Optional runtime context for sandbox resolution
1347
1366
  * @returns true if deleted, false otherwise
1348
1367
  */
1349
- deleteSkill(tenantId: string, id: string): Promise<boolean>;
1368
+ deleteSkill(tenantId: string, id: string, context?: SkillStoreContext): Promise<boolean>;
1350
1369
  /**
1351
1370
  * Check if skill exists
1352
1371
  * @param tenantId Tenant identifier
1353
1372
  * @param id Skill identifier
1373
+ * @param context Optional runtime context for sandbox resolution
1354
1374
  * @returns true if skill exists, false otherwise
1355
1375
  */
1356
- hasSkill(tenantId: string, id: string): Promise<boolean>;
1376
+ hasSkill(tenantId: string, id: string, context?: SkillStoreContext): Promise<boolean>;
1357
1377
  /**
1358
1378
  * Search skills by metadata within a tenant
1359
1379
  * @param tenantId Tenant identifier
1360
1380
  * @param metadataKey Metadata key to search for
1361
1381
  * @param metadataValue Metadata value to match
1382
+ * @param context Optional runtime context for sandbox resolution
1362
1383
  * @returns Array of matching skills
1363
1384
  */
1364
- searchByMetadata(tenantId: string, metadataKey: string, metadataValue: string): Promise<Skill[]>;
1385
+ searchByMetadata(tenantId: string, metadataKey: string, metadataValue: string, context?: SkillStoreContext): Promise<Skill[]>;
1365
1386
  /**
1366
1387
  * Filter skills by compatibility within a tenant
1367
1388
  * @param tenantId Tenant identifier
1368
1389
  * @param compatibility Compatibility string to filter by
1390
+ * @param context Optional runtime context for sandbox resolution
1369
1391
  * @returns Array of matching skills
1370
1392
  */
1371
- filterByCompatibility(tenantId: string, compatibility: string): Promise<Skill[]>;
1393
+ filterByCompatibility(tenantId: string, compatibility: string, context?: SkillStoreContext): Promise<Skill[]>;
1372
1394
  /**
1373
1395
  * Filter skills by license within a tenant
1374
1396
  * @param tenantId Tenant identifier
1375
1397
  * @param license License string to filter by
1398
+ * @param context Optional runtime context for sandbox resolution
1376
1399
  * @returns Array of matching skills
1377
1400
  */
1378
- filterByLicense(tenantId: string, license: string): Promise<Skill[]>;
1401
+ filterByLicense(tenantId: string, license: string, context?: SkillStoreContext): Promise<Skill[]>;
1379
1402
  /**
1380
1403
  * Get sub-skills of a parent skill within a tenant
1381
1404
  * @param tenantId Tenant identifier
1382
1405
  * @param parentSkillName Parent skill name
1406
+ * @param context Optional runtime context for sandbox resolution
1383
1407
  * @returns Array of sub-skills if found, empty array otherwise
1384
1408
  */
1385
- getSubSkills(tenantId: string, parentSkillName: string): Promise<Skill[]>;
1409
+ getSubSkills(tenantId: string, parentSkillName: string, context?: SkillStoreContext): Promise<Skill[]>;
1386
1410
  /**
1387
1411
  * List all resources in a skill's resources directory
1388
1412
  * @param tenantId Tenant identifier
1389
1413
  * @param id Skill identifier
1414
+ * @param context Optional runtime context for sandbox resolution
1390
1415
  * @returns Array of resource paths relative to resources/ directory
1391
1416
  */
1392
- listSkillResources?(tenantId: string, id: string): Promise<string[]>;
1417
+ listSkillResources?(tenantId: string, id: string, context?: SkillStoreContext): Promise<string[]>;
1393
1418
  /**
1394
1419
  * Load a specific resource from a skill's resources directory
1395
1420
  * @param tenantId Tenant identifier
1396
1421
  * @param id Skill identifier
1397
1422
  * @param resourcePath Path to the resource relative to resources/ directory
1423
+ * @param context Optional runtime context for sandbox resolution
1398
1424
  * @returns The resource content as string, or null if not found
1399
1425
  */
1400
- loadSkillResource?(tenantId: string, id: string, resourcePath: string): Promise<string | null>;
1426
+ loadSkillResource?(tenantId: string, id: string, resourcePath: string, context?: SkillStoreContext): Promise<string | null>;
1401
1427
  }
1402
1428
 
1403
1429
  /**
@@ -1974,6 +2000,43 @@ interface DatabaseConfigStore {
1974
2000
  hasConfig(tenantId: string, id: string): Promise<boolean>;
1975
2001
  }
1976
2002
 
2003
+ type ChannelInstallationType = "lark";
2004
+ interface LarkChannelInstallationConfig {
2005
+ appId: string;
2006
+ appSecret: string;
2007
+ verificationToken?: string;
2008
+ encryptKey?: string;
2009
+ mappingMode: "user" | "group" | "hybrid";
2010
+ assistantId: string;
2011
+ workspaceId?: string;
2012
+ projectId?: string;
2013
+ }
2014
+ interface ChannelInstallation {
2015
+ id: string;
2016
+ tenantId: string;
2017
+ channel: ChannelInstallationType;
2018
+ name?: string;
2019
+ config: LarkChannelInstallationConfig;
2020
+ createdAt: Date;
2021
+ updatedAt: Date;
2022
+ }
2023
+ interface CreateChannelInstallationRequest {
2024
+ channel: ChannelInstallationType;
2025
+ name?: string;
2026
+ config: LarkChannelInstallationConfig;
2027
+ }
2028
+ interface UpdateChannelInstallationRequest {
2029
+ name?: string;
2030
+ config?: Partial<LarkChannelInstallationConfig>;
2031
+ }
2032
+ interface ChannelInstallationStore {
2033
+ getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
2034
+ getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
2035
+ createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
2036
+ updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
2037
+ deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
2038
+ }
2039
+
1977
2040
  /**
1978
2041
  * MetricsServerConfigStoreProtocol
1979
2042
  *
@@ -2748,4 +2811,4 @@ type Timestamp = number;
2748
2811
  */
2749
2812
  type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
2750
2813
 
2751
- 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 BootstrapFilesConfig, type BrowserMiddlewareConfig, type Callback, type ClawMiddlewareConfig, type CodeEvalMiddlewareConfig, type CreateAssistantRequest, type CreateDatabaseConfigRequest, type CreateMcpServerConfigRequest, type CreateMetricsServerConfigRequest, type CreateProjectRequest, type CreateSkillRequest, type CreateTenantRequest, type CreateThreadRequest, type CreateUserRequest, type CreateUserTenantLinkRequest, type CreateWorkspaceRequest, type DataSource, type DatabaseConfig, type DatabaseConfigEntry, type DatabaseConfigStore, type DatabaseType, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type ExecuteSqlQueryRequest, type ExecuteSqlQueryResponse, 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 McpServerConfigEntry, type McpServerConfigStore, type McpStats, type McpTool, type McpToolResult, type McpTransportType, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type MessageChunkType, MessageChunkTypes, type MetricColumn, type MetricDataPoint, type MetricMeta, type MetricQueryResult, type MetricsMiddlewareConfig, type MetricsServerConfig, type MetricsServerConfigEntry, type MetricsServerConfigStore, type MetricsServerType, type MiddlewareType, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PinoFileOptions, type Project, type ProjectStore, type QueryParams, type QueryResultFormat, 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 SemanticMetricsFilter, type SemanticMetricsQueryRequest, type SemanticMetricsQueryResponse, type SemanticMetricsServerConfig, type Skill, type SkillClient, type SkillClientType, type SkillConfig, type SkillLatticeProtocol, type SkillStore, type SqlMiddlewareConfig, type StorageType, type SystemMessage, type TableQueryRequest, type TableQueryResponse, type TaskHandler, type TeamAgentConfig, type TeamTeammateConfig, type Tenant, type TenantStatus, type TenantStore, type TestMcpServerToolsResponse, 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 UpdateMcpServerConfigRequest, type UpdateMetricsServerConfigRequest, type UpdateProjectRequest, type UpdateTenantRequest, type UpdateUserRequest, type UpdateUserTenantLinkRequest, type UpdateWorkspaceRequest, type User, type UserMessage, type UserStatus, type UserStore, type UserTenantLink, type UserTenantLinkStore, type UserTenantRole, type VectorStoreConfig, type VectorStoreLatticeProtocol, type Workspace, type WorkspaceStore, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig, isTeamAgentConfig };
2814
+ 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 BootstrapFilesConfig, type BrowserMiddlewareConfig, type Callback, type ChannelInstallation, type ChannelInstallationStore, type ChannelInstallationType, type ClawMiddlewareConfig, type CodeEvalMiddlewareConfig, type CreateAssistantRequest, type CreateChannelInstallationRequest, type CreateDatabaseConfigRequest, type CreateMcpServerConfigRequest, type CreateMetricsServerConfigRequest, type CreateProjectRequest, type CreateSkillRequest, type CreateTenantRequest, type CreateThreadRequest, type CreateUserRequest, type CreateUserTenantLinkRequest, type CreateWorkspaceRequest, type DataSource, type DatabaseConfig, type DatabaseConfigEntry, type DatabaseConfigStore, type DatabaseType, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type ExecuteSqlQueryRequest, type ExecuteSqlQueryResponse, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, type LLMConfig, type LarkChannelInstallationConfig, 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 McpServerConfigEntry, type McpServerConfigStore, type McpStats, type McpTool, type McpToolResult, type McpTransportType, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type MessageChunkType, MessageChunkTypes, type MetricColumn, type MetricDataPoint, type MetricMeta, type MetricQueryResult, type MetricsMiddlewareConfig, type MetricsServerConfig, type MetricsServerConfigEntry, type MetricsServerConfigStore, type MetricsServerType, type MiddlewareType, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PinoFileOptions, type Project, type ProjectStore, type QueryParams, type QueryResultFormat, 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 SchedulerMiddlewareConfig, type SemanticMetricsFilter, type SemanticMetricsQueryRequest, type SemanticMetricsQueryResponse, type SemanticMetricsServerConfig, type Skill, type SkillClient, type SkillClientType, type SkillConfig, type SkillLatticeProtocol, type SkillStore, type SkillStoreContext, type SqlMiddlewareConfig, type StorageType, type SystemMessage, type TableQueryRequest, type TableQueryResponse, type TaskHandler, type TeamAgentConfig, type TeamTeammateConfig, type Tenant, type TenantStatus, type TenantStore, type TestMcpServerToolsResponse, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UpdateChannelInstallationRequest, type UpdateDatabaseConfigRequest, type UpdateMcpServerConfigRequest, type UpdateMetricsServerConfigRequest, type UpdateProjectRequest, type UpdateTenantRequest, type UpdateUserRequest, type UpdateUserTenantLinkRequest, type UpdateWorkspaceRequest, type User, type UserMessage, type UserStatus, type UserStore, type UserTenantLink, type UserTenantLinkStore, type UserTenantRole, type VectorStoreConfig, type VectorStoreLatticeProtocol, type Workspace, type WorkspaceStore, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig, isTeamAgentConfig };
package/dist/index.d.ts CHANGED
@@ -164,16 +164,16 @@ interface BaseAgentConfig {
164
164
  }
165
165
  type AvailableModule = "filesystem" | "code_eval" | "browser";
166
166
  interface SandboxMiddlewareConfig {
167
- isolatedLevel: "agent" | "thread" | "global";
167
+ vmIsolation: "agent" | "project" | "global";
168
168
  modules: AvailableModule[];
169
169
  }
170
170
  interface CodeEvalMiddlewareConfig {
171
- isolatedLevel: "agent" | "thread" | "global";
171
+ vmIsolation: "agent" | "project" | "global";
172
172
  timeout: number;
173
173
  memoryLimit: number;
174
174
  }
175
175
  interface BrowserMiddlewareConfig {
176
- isolatedLevel: "agent" | "thread" | "global";
176
+ vmIsolation: "agent" | "project" | "global";
177
177
  headless: boolean;
178
178
  }
179
179
  interface SqlMiddlewareConfig {
@@ -185,14 +185,17 @@ interface MetricsMiddlewareConfig {
185
185
  /** Optional descriptions for each server */
186
186
  serverDescriptions?: Record<string, string>;
187
187
  }
188
- type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date";
188
+ interface SchedulerMiddlewareConfig {
189
+ defaultMaxRetries?: number;
190
+ }
191
+ type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date" | "scheduler";
189
192
  interface AgentMiddlewareConfig {
190
193
  id: string;
191
194
  type: MiddlewareType;
192
195
  name: string;
193
196
  description: string;
194
197
  enabled: boolean;
195
- config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | MetricsMiddlewareConfig | ClawMiddlewareConfig | Record<string, any>;
198
+ config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | MetricsMiddlewareConfig | ClawMiddlewareConfig | SchedulerMiddlewareConfig | Record<string, any>;
196
199
  }
197
200
  /**
198
201
  * Bootstrap file configuration
@@ -1306,6 +1309,17 @@ interface CreateSkillRequest {
1306
1309
  */
1307
1310
  subSkills?: string[];
1308
1311
  }
1312
+ /**
1313
+ * SkillStore context for runtime sandbox resolution
1314
+ */
1315
+ interface SkillStoreContext {
1316
+ /** Assistant/agent identifier */
1317
+ assistantId?: string;
1318
+ /** Workspace identifier */
1319
+ workspaceId?: string;
1320
+ /** Project identifier */
1321
+ projectId?: string;
1322
+ }
1309
1323
  /**
1310
1324
  * SkillStore interface
1311
1325
  * Provides CRUD operations for skill data
@@ -1314,90 +1328,102 @@ interface SkillStore {
1314
1328
  /**
1315
1329
  * Get all skills for a tenant
1316
1330
  * @param tenantId Tenant identifier
1331
+ * @param context Optional runtime context for sandbox resolution
1317
1332
  * @returns Array of all skills for the tenant
1318
1333
  */
1319
- getAllSkills(tenantId: string): Promise<Skill[]>;
1334
+ getAllSkills(tenantId: string, context?: SkillStoreContext): Promise<Skill[]>;
1320
1335
  /**
1321
1336
  * Get skill by ID
1322
1337
  * @param tenantId Tenant identifier
1323
1338
  * @param id Skill identifier
1339
+ * @param context Optional runtime context for sandbox resolution
1324
1340
  * @returns Skill if found, null otherwise
1325
1341
  */
1326
- getSkillById(tenantId: string, id: string): Promise<Skill | null>;
1342
+ getSkillById(tenantId: string, id: string, context?: SkillStoreContext): Promise<Skill | null>;
1327
1343
  /**
1328
1344
  * Create a new skill
1329
1345
  * @param tenantId Tenant identifier
1330
1346
  * @param id Skill identifier
1331
1347
  * @param data Skill creation data
1348
+ * @param context Optional runtime context for sandbox resolution
1332
1349
  * @returns Created skill
1333
1350
  */
1334
- createSkill(tenantId: string, id: string, data: CreateSkillRequest): Promise<Skill>;
1351
+ createSkill(tenantId: string, id: string, data: CreateSkillRequest, context?: SkillStoreContext): Promise<Skill>;
1335
1352
  /**
1336
1353
  * Update an existing skill
1337
1354
  * @param tenantId Tenant identifier
1338
1355
  * @param id Skill identifier
1339
1356
  * @param updates Partial skill data to update
1357
+ * @param context Optional runtime context for sandbox resolution
1340
1358
  * @returns Updated skill if found, null otherwise
1341
1359
  */
1342
- updateSkill(tenantId: string, id: string, updates: Partial<CreateSkillRequest>): Promise<Skill | null>;
1360
+ updateSkill(tenantId: string, id: string, updates: Partial<CreateSkillRequest>, context?: SkillStoreContext): Promise<Skill | null>;
1343
1361
  /**
1344
1362
  * Delete a skill by ID
1345
1363
  * @param tenantId Tenant identifier
1346
1364
  * @param id Skill identifier
1365
+ * @param context Optional runtime context for sandbox resolution
1347
1366
  * @returns true if deleted, false otherwise
1348
1367
  */
1349
- deleteSkill(tenantId: string, id: string): Promise<boolean>;
1368
+ deleteSkill(tenantId: string, id: string, context?: SkillStoreContext): Promise<boolean>;
1350
1369
  /**
1351
1370
  * Check if skill exists
1352
1371
  * @param tenantId Tenant identifier
1353
1372
  * @param id Skill identifier
1373
+ * @param context Optional runtime context for sandbox resolution
1354
1374
  * @returns true if skill exists, false otherwise
1355
1375
  */
1356
- hasSkill(tenantId: string, id: string): Promise<boolean>;
1376
+ hasSkill(tenantId: string, id: string, context?: SkillStoreContext): Promise<boolean>;
1357
1377
  /**
1358
1378
  * Search skills by metadata within a tenant
1359
1379
  * @param tenantId Tenant identifier
1360
1380
  * @param metadataKey Metadata key to search for
1361
1381
  * @param metadataValue Metadata value to match
1382
+ * @param context Optional runtime context for sandbox resolution
1362
1383
  * @returns Array of matching skills
1363
1384
  */
1364
- searchByMetadata(tenantId: string, metadataKey: string, metadataValue: string): Promise<Skill[]>;
1385
+ searchByMetadata(tenantId: string, metadataKey: string, metadataValue: string, context?: SkillStoreContext): Promise<Skill[]>;
1365
1386
  /**
1366
1387
  * Filter skills by compatibility within a tenant
1367
1388
  * @param tenantId Tenant identifier
1368
1389
  * @param compatibility Compatibility string to filter by
1390
+ * @param context Optional runtime context for sandbox resolution
1369
1391
  * @returns Array of matching skills
1370
1392
  */
1371
- filterByCompatibility(tenantId: string, compatibility: string): Promise<Skill[]>;
1393
+ filterByCompatibility(tenantId: string, compatibility: string, context?: SkillStoreContext): Promise<Skill[]>;
1372
1394
  /**
1373
1395
  * Filter skills by license within a tenant
1374
1396
  * @param tenantId Tenant identifier
1375
1397
  * @param license License string to filter by
1398
+ * @param context Optional runtime context for sandbox resolution
1376
1399
  * @returns Array of matching skills
1377
1400
  */
1378
- filterByLicense(tenantId: string, license: string): Promise<Skill[]>;
1401
+ filterByLicense(tenantId: string, license: string, context?: SkillStoreContext): Promise<Skill[]>;
1379
1402
  /**
1380
1403
  * Get sub-skills of a parent skill within a tenant
1381
1404
  * @param tenantId Tenant identifier
1382
1405
  * @param parentSkillName Parent skill name
1406
+ * @param context Optional runtime context for sandbox resolution
1383
1407
  * @returns Array of sub-skills if found, empty array otherwise
1384
1408
  */
1385
- getSubSkills(tenantId: string, parentSkillName: string): Promise<Skill[]>;
1409
+ getSubSkills(tenantId: string, parentSkillName: string, context?: SkillStoreContext): Promise<Skill[]>;
1386
1410
  /**
1387
1411
  * List all resources in a skill's resources directory
1388
1412
  * @param tenantId Tenant identifier
1389
1413
  * @param id Skill identifier
1414
+ * @param context Optional runtime context for sandbox resolution
1390
1415
  * @returns Array of resource paths relative to resources/ directory
1391
1416
  */
1392
- listSkillResources?(tenantId: string, id: string): Promise<string[]>;
1417
+ listSkillResources?(tenantId: string, id: string, context?: SkillStoreContext): Promise<string[]>;
1393
1418
  /**
1394
1419
  * Load a specific resource from a skill's resources directory
1395
1420
  * @param tenantId Tenant identifier
1396
1421
  * @param id Skill identifier
1397
1422
  * @param resourcePath Path to the resource relative to resources/ directory
1423
+ * @param context Optional runtime context for sandbox resolution
1398
1424
  * @returns The resource content as string, or null if not found
1399
1425
  */
1400
- loadSkillResource?(tenantId: string, id: string, resourcePath: string): Promise<string | null>;
1426
+ loadSkillResource?(tenantId: string, id: string, resourcePath: string, context?: SkillStoreContext): Promise<string | null>;
1401
1427
  }
1402
1428
 
1403
1429
  /**
@@ -1974,6 +2000,43 @@ interface DatabaseConfigStore {
1974
2000
  hasConfig(tenantId: string, id: string): Promise<boolean>;
1975
2001
  }
1976
2002
 
2003
+ type ChannelInstallationType = "lark";
2004
+ interface LarkChannelInstallationConfig {
2005
+ appId: string;
2006
+ appSecret: string;
2007
+ verificationToken?: string;
2008
+ encryptKey?: string;
2009
+ mappingMode: "user" | "group" | "hybrid";
2010
+ assistantId: string;
2011
+ workspaceId?: string;
2012
+ projectId?: string;
2013
+ }
2014
+ interface ChannelInstallation {
2015
+ id: string;
2016
+ tenantId: string;
2017
+ channel: ChannelInstallationType;
2018
+ name?: string;
2019
+ config: LarkChannelInstallationConfig;
2020
+ createdAt: Date;
2021
+ updatedAt: Date;
2022
+ }
2023
+ interface CreateChannelInstallationRequest {
2024
+ channel: ChannelInstallationType;
2025
+ name?: string;
2026
+ config: LarkChannelInstallationConfig;
2027
+ }
2028
+ interface UpdateChannelInstallationRequest {
2029
+ name?: string;
2030
+ config?: Partial<LarkChannelInstallationConfig>;
2031
+ }
2032
+ interface ChannelInstallationStore {
2033
+ getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
2034
+ getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
2035
+ createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
2036
+ updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
2037
+ deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
2038
+ }
2039
+
1977
2040
  /**
1978
2041
  * MetricsServerConfigStoreProtocol
1979
2042
  *
@@ -2748,4 +2811,4 @@ type Timestamp = number;
2748
2811
  */
2749
2812
  type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
2750
2813
 
2751
- 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 BootstrapFilesConfig, type BrowserMiddlewareConfig, type Callback, type ClawMiddlewareConfig, type CodeEvalMiddlewareConfig, type CreateAssistantRequest, type CreateDatabaseConfigRequest, type CreateMcpServerConfigRequest, type CreateMetricsServerConfigRequest, type CreateProjectRequest, type CreateSkillRequest, type CreateTenantRequest, type CreateThreadRequest, type CreateUserRequest, type CreateUserTenantLinkRequest, type CreateWorkspaceRequest, type DataSource, type DatabaseConfig, type DatabaseConfigEntry, type DatabaseConfigStore, type DatabaseType, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type ExecuteSqlQueryRequest, type ExecuteSqlQueryResponse, 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 McpServerConfigEntry, type McpServerConfigStore, type McpStats, type McpTool, type McpToolResult, type McpTransportType, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type MessageChunkType, MessageChunkTypes, type MetricColumn, type MetricDataPoint, type MetricMeta, type MetricQueryResult, type MetricsMiddlewareConfig, type MetricsServerConfig, type MetricsServerConfigEntry, type MetricsServerConfigStore, type MetricsServerType, type MiddlewareType, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PinoFileOptions, type Project, type ProjectStore, type QueryParams, type QueryResultFormat, 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 SemanticMetricsFilter, type SemanticMetricsQueryRequest, type SemanticMetricsQueryResponse, type SemanticMetricsServerConfig, type Skill, type SkillClient, type SkillClientType, type SkillConfig, type SkillLatticeProtocol, type SkillStore, type SqlMiddlewareConfig, type StorageType, type SystemMessage, type TableQueryRequest, type TableQueryResponse, type TaskHandler, type TeamAgentConfig, type TeamTeammateConfig, type Tenant, type TenantStatus, type TenantStore, type TestMcpServerToolsResponse, 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 UpdateMcpServerConfigRequest, type UpdateMetricsServerConfigRequest, type UpdateProjectRequest, type UpdateTenantRequest, type UpdateUserRequest, type UpdateUserTenantLinkRequest, type UpdateWorkspaceRequest, type User, type UserMessage, type UserStatus, type UserStore, type UserTenantLink, type UserTenantLinkStore, type UserTenantRole, type VectorStoreConfig, type VectorStoreLatticeProtocol, type Workspace, type WorkspaceStore, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig, isTeamAgentConfig };
2814
+ 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 BootstrapFilesConfig, type BrowserMiddlewareConfig, type Callback, type ChannelInstallation, type ChannelInstallationStore, type ChannelInstallationType, type ClawMiddlewareConfig, type CodeEvalMiddlewareConfig, type CreateAssistantRequest, type CreateChannelInstallationRequest, type CreateDatabaseConfigRequest, type CreateMcpServerConfigRequest, type CreateMetricsServerConfigRequest, type CreateProjectRequest, type CreateSkillRequest, type CreateTenantRequest, type CreateThreadRequest, type CreateUserRequest, type CreateUserTenantLinkRequest, type CreateWorkspaceRequest, type DataSource, type DatabaseConfig, type DatabaseConfigEntry, type DatabaseConfigStore, type DatabaseType, type DeepAgentConfig, type DeveloperMessage, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type ExecuteSqlQueryRequest, type ExecuteSqlQueryResponse, type FilterCondition, type GraphBuildOptions, type ID, type InterruptMessage, type LLMConfig, type LarkChannelInstallationConfig, 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 McpServerConfigEntry, type McpServerConfigStore, type McpStats, type McpTool, type McpToolResult, type McpTransportType, type MemoryClient, type MemoryConfig, type MemoryLatticeProtocol, MemoryType, type Message, type MessageChunk, type MessageChunkType, MessageChunkTypes, type MetricColumn, type MetricDataPoint, type MetricMeta, type MetricQueryResult, type MetricsMiddlewareConfig, type MetricsServerConfig, type MetricsServerConfigEntry, type MetricsServerConfigStore, type MetricsServerType, type MiddlewareType, type ModelLatticeProtocol, type PaginatedResult, type PaginationParams, type PinoFileOptions, type Project, type ProjectStore, type QueryParams, type QueryResultFormat, 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 SchedulerMiddlewareConfig, type SemanticMetricsFilter, type SemanticMetricsQueryRequest, type SemanticMetricsQueryResponse, type SemanticMetricsServerConfig, type Skill, type SkillClient, type SkillClientType, type SkillConfig, type SkillLatticeProtocol, type SkillStore, type SkillStoreContext, type SqlMiddlewareConfig, type StorageType, type SystemMessage, type TableQueryRequest, type TableQueryResponse, type TaskHandler, type TeamAgentConfig, type TeamTeammateConfig, type Tenant, type TenantStatus, type TenantStore, type TestMcpServerToolsResponse, type Thread, type ThreadStore, type Timestamp, type ToolCall, type ToolConfig, type ToolExecutor, type ToolLatticeProtocol, type ToolMessage, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UpdateChannelInstallationRequest, type UpdateDatabaseConfigRequest, type UpdateMcpServerConfigRequest, type UpdateMetricsServerConfigRequest, type UpdateProjectRequest, type UpdateTenantRequest, type UpdateUserRequest, type UpdateUserTenantLinkRequest, type UpdateWorkspaceRequest, type User, type UserMessage, type UserStatus, type UserStore, type UserTenantLink, type UserTenantLinkStore, type UserTenantRole, type VectorStoreConfig, type VectorStoreLatticeProtocol, type Workspace, type WorkspaceStore, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isDeepAgentConfig, isTeamAgentConfig };
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/MessageProtocol.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 \"./TenantStoreProtocol\";\nexport * from \"./DatabaseConfigStoreProtocol\";\nexport * from \"./MetricsServerConfigStoreProtocol\";\nexport * from \"./McpServerConfigStoreProtocol\";\nexport * from \"./UserStoreProtocol\";\nexport * from \"./UserTenantLinkProtocol\";\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 interface MetricsMiddlewareConfig {\n /** List of configured metrics server keys */\n serverKeys: string[];\n /** Optional descriptions for each server */\n serverDescriptions?: Record<string, string>;\n}\n\nexport type MiddlewareType = \"filesystem\" | \"code_eval\" | \"browser\" | \"sql\" | \"skill\" | \"http\" | \"custom\" | \"metrics\" | \"ask_user_to_clarify\" | \"widget\" | \"claw\" | \"date\";\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 | MetricsMiddlewareConfig | ClawMiddlewareConfig | Record<string, any>;\n}\n\n/**\n * Bootstrap file configuration\n * Defines default content for project bootstrap files\n */\nexport interface BootstrapFilesConfig {\n /** Default content for AGENTS.md - operating instructions */\n agents?: string;\n /** Default content for SOUL.md - personality and tone */\n soul?: string;\n /** Default content for IDENTITY.md - agent identity */\n identity?: string;\n /** Default content for USER.md - user preferences */\n user?: string;\n /** Default content for TOOLS.md - tool documentation */\n tools?: string;\n /** Default content for BOOTSTRAP.md - first-run tasks */\n bootstrap?: string;\n}\n\n/**\n * Claw Middleware 配置\n * 用于配置 bootstrap 文件管理行为\n */\nexport interface ClawMiddlewareConfig {\n /** 是否启用 bootstrap 文件注入(默认:true) */\n injectBootstrapFiles?: boolean;\n /** 自定义 bootstrap 文件内容 */\n bootstrapFiles?: BootstrapFilesConfig;\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 tenantId: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string;\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 tenantId?: string;\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 * MessageProtocol\n *\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Base message interface\n */\nexport interface BaseMessage {\n id: string; // Unique identifier for the message\n role: string; // Role of the sender (user, assistant, system, tool, developer)\n content?: string; // Optional text content of the message\n name?: string; // Optional name of the sender\n}\n\n/**\n * User message interface\n */\nexport interface UserMessage extends BaseMessage {\n role: \"human\";\n content: string; // Text input from the user\n files?: Array<{ name: string; id: string }>; // Optional files attached to the message\n}\n\n/**\n * Tool call interface\n */\nexport interface ToolCall {\n id: string; // Unique identifier for this tool call\n name: string; // Name of the tool/function to call\n args: Record<string, any>; // Arguments as an object\n type: \"tool_call\"; // Type of tool call\n response?: string; // Optional response from the tool execution\n}\n\n/**\n * Assistant message interface\n */\nexport interface AssistantMessage extends BaseMessage {\n role: \"ai\";\n content?: string; // Text response from the assistant (optional if using tool calls)\n tool_calls?: ToolCall[]; // Optional tool calls made by the assistant\n}\n\nexport interface InterruptMessage extends BaseMessage {\n type: \"interrupt\";\n value: any;\n}\n\n/**\n * System message interface\n */\nexport interface SystemMessage extends BaseMessage {\n role: \"system\";\n content: string; // Instructions or context for the assistant\n}\n\n/**\n * Tool message interface\n */\nexport interface ToolMessage extends BaseMessage {\n role: \"tool\";\n content: string; // Result from the tool execution\n tool_call_id: string; // ID of the tool call this message responds to\n}\n\n/**\n * Developer message interface\n */\nexport interface DeveloperMessage extends BaseMessage {\n role: \"developer\";\n content: string; // Content for development or debugging\n}\n\n/**\n * Message chunk type constants\n */\nexport const MessageChunkTypes = {\n HUMAN: 'human',\n AI: 'ai',\n TOOL: 'tool',\n INTERRUPT: 'interrupt',\n MESSAGE_COMPLETED: 'message_completed',\n MESSAGE_FAILED: 'message_failed',\n THREAD_IDLE: 'thread_idle',\n} as const;\n\nexport type MessageChunkType = typeof MessageChunkTypes[keyof typeof MessageChunkTypes];\n\nexport interface MessageChunk {\n type: MessageChunkType;\n data: {\n id: string;\n content?: string;\n tool_call_chunks?: Array<{\n name?: string;\n args?: string;\n id?: string;\n index: number;\n }>;\n tool_calls?: Array<{\n name: string;\n args: Record<string, any>;\n id: string;\n type: string;\n response?: string;\n }>;\n additional_kwargs?: {\n tool_calls?: Array<{\n function?: { name?: string; arguments?: any };\n id?: string;\n }>;\n };\n tool_call_id?: string;\n };\n}\n\n/**\n * Message type union\n */\nexport type Message =\n | UserMessage\n | AssistantMessage\n | SystemMessage\n | ToolMessage\n | DeveloperMessage;\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;AAAA;;;ACaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AA6KL,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;;;ACxOO,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;;;ACoEL,IAAM,oBAAoB;AAAA,EAC/B,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;;;ACgIO,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/MessageProtocol.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 \"./TenantStoreProtocol\";\nexport * from \"./DatabaseConfigStoreProtocol\";\nexport * from \"./ChannelInstallationStoreProtocol\";\nexport * from \"./MetricsServerConfigStoreProtocol\";\nexport * from \"./McpServerConfigStoreProtocol\";\nexport * from \"./UserStoreProtocol\";\nexport * from \"./UserTenantLinkProtocol\";\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 vmIsolation: \"agent\" | \"project\" | \"global\";\n modules: AvailableModule[];\n}\n\nexport interface CodeEvalMiddlewareConfig {\n vmIsolation: \"agent\" | \"project\" | \"global\";\n timeout: number;\n memoryLimit: number;\n}\n\nexport interface BrowserMiddlewareConfig {\n vmIsolation: \"agent\" | \"project\" | \"global\";\n headless: boolean;\n}\n\nexport interface SqlMiddlewareConfig {\n databaseKeys?: string[];\n}\n\nexport interface MetricsMiddlewareConfig {\n /** List of configured metrics server keys */\n serverKeys: string[];\n /** Optional descriptions for each server */\n serverDescriptions?: Record<string, string>;\n}\n\nexport interface SchedulerMiddlewareConfig {\n defaultMaxRetries?: number;\n}\n\nexport type MiddlewareType = \"filesystem\" | \"code_eval\" | \"browser\" | \"sql\" | \"skill\" | \"http\" | \"custom\" | \"metrics\" | \"ask_user_to_clarify\" | \"widget\" | \"claw\" | \"date\" | \"scheduler\";\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 | MetricsMiddlewareConfig | ClawMiddlewareConfig | SchedulerMiddlewareConfig | Record<string, any>;\n}\n\n/**\n * Bootstrap file configuration\n * Defines default content for project bootstrap files\n */\nexport interface BootstrapFilesConfig {\n /** Default content for AGENTS.md - operating instructions */\n agents?: string;\n /** Default content for SOUL.md - personality and tone */\n soul?: string;\n /** Default content for IDENTITY.md - agent identity */\n identity?: string;\n /** Default content for USER.md - user preferences */\n user?: string;\n /** Default content for TOOLS.md - tool documentation */\n tools?: string;\n /** Default content for BOOTSTRAP.md - first-run tasks */\n bootstrap?: string;\n}\n\n/**\n * Claw Middleware 配置\n * 用于配置 bootstrap 文件管理行为\n */\nexport interface ClawMiddlewareConfig {\n /** 是否启用 bootstrap 文件注入(默认:true) */\n injectBootstrapFiles?: boolean;\n /** 自定义 bootstrap 文件内容 */\n bootstrapFiles?: BootstrapFilesConfig;\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 tenantId: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string;\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 tenantId?: string;\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 * MessageProtocol\n *\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Base message interface\n */\nexport interface BaseMessage {\n id: string; // Unique identifier for the message\n role: string; // Role of the sender (user, assistant, system, tool, developer)\n content?: string; // Optional text content of the message\n name?: string; // Optional name of the sender\n}\n\n/**\n * User message interface\n */\nexport interface UserMessage extends BaseMessage {\n role: \"human\";\n content: string; // Text input from the user\n files?: Array<{ name: string; id: string }>; // Optional files attached to the message\n}\n\n/**\n * Tool call interface\n */\nexport interface ToolCall {\n id: string; // Unique identifier for this tool call\n name: string; // Name of the tool/function to call\n args: Record<string, any>; // Arguments as an object\n type: \"tool_call\"; // Type of tool call\n response?: string; // Optional response from the tool execution\n}\n\n/**\n * Assistant message interface\n */\nexport interface AssistantMessage extends BaseMessage {\n role: \"ai\";\n content?: string; // Text response from the assistant (optional if using tool calls)\n tool_calls?: ToolCall[]; // Optional tool calls made by the assistant\n}\n\nexport interface InterruptMessage extends BaseMessage {\n type: \"interrupt\";\n value: any;\n}\n\n/**\n * System message interface\n */\nexport interface SystemMessage extends BaseMessage {\n role: \"system\";\n content: string; // Instructions or context for the assistant\n}\n\n/**\n * Tool message interface\n */\nexport interface ToolMessage extends BaseMessage {\n role: \"tool\";\n content: string; // Result from the tool execution\n tool_call_id: string; // ID of the tool call this message responds to\n}\n\n/**\n * Developer message interface\n */\nexport interface DeveloperMessage extends BaseMessage {\n role: \"developer\";\n content: string; // Content for development or debugging\n}\n\n/**\n * Message chunk type constants\n */\nexport const MessageChunkTypes = {\n HUMAN: 'human',\n AI: 'ai',\n TOOL: 'tool',\n INTERRUPT: 'interrupt',\n MESSAGE_COMPLETED: 'message_completed',\n MESSAGE_FAILED: 'message_failed',\n THREAD_IDLE: 'thread_idle',\n} as const;\n\nexport type MessageChunkType = typeof MessageChunkTypes[keyof typeof MessageChunkTypes];\n\nexport interface MessageChunk {\n type: MessageChunkType;\n data: {\n id: string;\n content?: string;\n tool_call_chunks?: Array<{\n name?: string;\n args?: string;\n id?: string;\n index: number;\n }>;\n tool_calls?: Array<{\n name: string;\n args: Record<string, any>;\n id: string;\n type: string;\n response?: string;\n }>;\n additional_kwargs?: {\n tool_calls?: Array<{\n function?: { name?: string; arguments?: any };\n id?: string;\n }>;\n };\n tool_call_id?: string;\n };\n}\n\n/**\n * Message type union\n */\nexport type Message =\n | UserMessage\n | AssistantMessage\n | SystemMessage\n | ToolMessage\n | DeveloperMessage;\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;AAAA;;;ACaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAiLL,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;;;AC5OO,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;;;ACoEL,IAAM,oBAAoB;AAAA,EAC/B,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;;;ACgIO,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 +1 @@
1
- {"version":3,"sources":["../src/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.ts","../src/ScheduleLatticeProtocol.ts","../src/LoggerLatticeProtocol.ts","../src/MessageProtocol.ts","../src/McpLatticeProtocol.ts"],"sourcesContent":["/**\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 interface MetricsMiddlewareConfig {\n /** List of configured metrics server keys */\n serverKeys: string[];\n /** Optional descriptions for each server */\n serverDescriptions?: Record<string, string>;\n}\n\nexport type MiddlewareType = \"filesystem\" | \"code_eval\" | \"browser\" | \"sql\" | \"skill\" | \"http\" | \"custom\" | \"metrics\" | \"ask_user_to_clarify\" | \"widget\" | \"claw\" | \"date\";\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 | MetricsMiddlewareConfig | ClawMiddlewareConfig | Record<string, any>;\n}\n\n/**\n * Bootstrap file configuration\n * Defines default content for project bootstrap files\n */\nexport interface BootstrapFilesConfig {\n /** Default content for AGENTS.md - operating instructions */\n agents?: string;\n /** Default content for SOUL.md - personality and tone */\n soul?: string;\n /** Default content for IDENTITY.md - agent identity */\n identity?: string;\n /** Default content for USER.md - user preferences */\n user?: string;\n /** Default content for TOOLS.md - tool documentation */\n tools?: string;\n /** Default content for BOOTSTRAP.md - first-run tasks */\n bootstrap?: string;\n}\n\n/**\n * Claw Middleware 配置\n * 用于配置 bootstrap 文件管理行为\n */\nexport interface ClawMiddlewareConfig {\n /** 是否启用 bootstrap 文件注入(默认:true) */\n injectBootstrapFiles?: boolean;\n /** 自定义 bootstrap 文件内容 */\n bootstrapFiles?: BootstrapFilesConfig;\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 tenantId: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string;\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 tenantId?: string;\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 * MessageProtocol\n *\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Base message interface\n */\nexport interface BaseMessage {\n id: string; // Unique identifier for the message\n role: string; // Role of the sender (user, assistant, system, tool, developer)\n content?: string; // Optional text content of the message\n name?: string; // Optional name of the sender\n}\n\n/**\n * User message interface\n */\nexport interface UserMessage extends BaseMessage {\n role: \"human\";\n content: string; // Text input from the user\n files?: Array<{ name: string; id: string }>; // Optional files attached to the message\n}\n\n/**\n * Tool call interface\n */\nexport interface ToolCall {\n id: string; // Unique identifier for this tool call\n name: string; // Name of the tool/function to call\n args: Record<string, any>; // Arguments as an object\n type: \"tool_call\"; // Type of tool call\n response?: string; // Optional response from the tool execution\n}\n\n/**\n * Assistant message interface\n */\nexport interface AssistantMessage extends BaseMessage {\n role: \"ai\";\n content?: string; // Text response from the assistant (optional if using tool calls)\n tool_calls?: ToolCall[]; // Optional tool calls made by the assistant\n}\n\nexport interface InterruptMessage extends BaseMessage {\n type: \"interrupt\";\n value: any;\n}\n\n/**\n * System message interface\n */\nexport interface SystemMessage extends BaseMessage {\n role: \"system\";\n content: string; // Instructions or context for the assistant\n}\n\n/**\n * Tool message interface\n */\nexport interface ToolMessage extends BaseMessage {\n role: \"tool\";\n content: string; // Result from the tool execution\n tool_call_id: string; // ID of the tool call this message responds to\n}\n\n/**\n * Developer message interface\n */\nexport interface DeveloperMessage extends BaseMessage {\n role: \"developer\";\n content: string; // Content for development or debugging\n}\n\n/**\n * Message chunk type constants\n */\nexport const MessageChunkTypes = {\n HUMAN: 'human',\n AI: 'ai',\n TOOL: 'tool',\n INTERRUPT: 'interrupt',\n MESSAGE_COMPLETED: 'message_completed',\n MESSAGE_FAILED: 'message_failed',\n THREAD_IDLE: 'thread_idle',\n} as const;\n\nexport type MessageChunkType = typeof MessageChunkTypes[keyof typeof MessageChunkTypes];\n\nexport interface MessageChunk {\n type: MessageChunkType;\n data: {\n id: string;\n content?: string;\n tool_call_chunks?: Array<{\n name?: string;\n args?: string;\n id?: string;\n index: number;\n }>;\n tool_calls?: Array<{\n name: string;\n args: Record<string, any>;\n id: string;\n type: string;\n response?: string;\n }>;\n additional_kwargs?: {\n tool_calls?: Array<{\n function?: { name?: string; arguments?: any };\n id?: string;\n }>;\n };\n tool_call_id?: string;\n };\n}\n\n/**\n * Message type union\n */\nexport type Message =\n | UserMessage\n | AssistantMessage\n | SystemMessage\n | ToolMessage\n | DeveloperMessage;\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":";AAaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AA6KL,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;;;ACxOO,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;;;ACoEL,IAAM,oBAAoB;AAAA,EAC/B,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;;;ACgIO,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/AgentLatticeProtocol.ts","../src/MemoryLatticeProtocol.ts","../src/UILatticeProtocol.ts","../src/QueueLatticeProtocol.ts","../src/ScheduleLatticeProtocol.ts","../src/LoggerLatticeProtocol.ts","../src/MessageProtocol.ts","../src/McpLatticeProtocol.ts"],"sourcesContent":["/**\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 vmIsolation: \"agent\" | \"project\" | \"global\";\n modules: AvailableModule[];\n}\n\nexport interface CodeEvalMiddlewareConfig {\n vmIsolation: \"agent\" | \"project\" | \"global\";\n timeout: number;\n memoryLimit: number;\n}\n\nexport interface BrowserMiddlewareConfig {\n vmIsolation: \"agent\" | \"project\" | \"global\";\n headless: boolean;\n}\n\nexport interface SqlMiddlewareConfig {\n databaseKeys?: string[];\n}\n\nexport interface MetricsMiddlewareConfig {\n /** List of configured metrics server keys */\n serverKeys: string[];\n /** Optional descriptions for each server */\n serverDescriptions?: Record<string, string>;\n}\n\nexport interface SchedulerMiddlewareConfig {\n defaultMaxRetries?: number;\n}\n\nexport type MiddlewareType = \"filesystem\" | \"code_eval\" | \"browser\" | \"sql\" | \"skill\" | \"http\" | \"custom\" | \"metrics\" | \"ask_user_to_clarify\" | \"widget\" | \"claw\" | \"date\" | \"scheduler\";\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 | MetricsMiddlewareConfig | ClawMiddlewareConfig | SchedulerMiddlewareConfig | Record<string, any>;\n}\n\n/**\n * Bootstrap file configuration\n * Defines default content for project bootstrap files\n */\nexport interface BootstrapFilesConfig {\n /** Default content for AGENTS.md - operating instructions */\n agents?: string;\n /** Default content for SOUL.md - personality and tone */\n soul?: string;\n /** Default content for IDENTITY.md - agent identity */\n identity?: string;\n /** Default content for USER.md - user preferences */\n user?: string;\n /** Default content for TOOLS.md - tool documentation */\n tools?: string;\n /** Default content for BOOTSTRAP.md - first-run tasks */\n bootstrap?: string;\n}\n\n/**\n * Claw Middleware 配置\n * 用于配置 bootstrap 文件管理行为\n */\nexport interface ClawMiddlewareConfig {\n /** 是否启用 bootstrap 文件注入(默认:true) */\n injectBootstrapFiles?: boolean;\n /** 自定义 bootstrap 文件内容 */\n bootstrapFiles?: BootstrapFilesConfig;\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 tenantId: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string; // Tenant isolation\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 tenantId?: string;\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 tenantId?: string;\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 * MessageProtocol\n *\n */\n\nimport { BaseLatticeProtocol } from \"./BaseLatticeProtocol\";\n\n/**\n * Base message interface\n */\nexport interface BaseMessage {\n id: string; // Unique identifier for the message\n role: string; // Role of the sender (user, assistant, system, tool, developer)\n content?: string; // Optional text content of the message\n name?: string; // Optional name of the sender\n}\n\n/**\n * User message interface\n */\nexport interface UserMessage extends BaseMessage {\n role: \"human\";\n content: string; // Text input from the user\n files?: Array<{ name: string; id: string }>; // Optional files attached to the message\n}\n\n/**\n * Tool call interface\n */\nexport interface ToolCall {\n id: string; // Unique identifier for this tool call\n name: string; // Name of the tool/function to call\n args: Record<string, any>; // Arguments as an object\n type: \"tool_call\"; // Type of tool call\n response?: string; // Optional response from the tool execution\n}\n\n/**\n * Assistant message interface\n */\nexport interface AssistantMessage extends BaseMessage {\n role: \"ai\";\n content?: string; // Text response from the assistant (optional if using tool calls)\n tool_calls?: ToolCall[]; // Optional tool calls made by the assistant\n}\n\nexport interface InterruptMessage extends BaseMessage {\n type: \"interrupt\";\n value: any;\n}\n\n/**\n * System message interface\n */\nexport interface SystemMessage extends BaseMessage {\n role: \"system\";\n content: string; // Instructions or context for the assistant\n}\n\n/**\n * Tool message interface\n */\nexport interface ToolMessage extends BaseMessage {\n role: \"tool\";\n content: string; // Result from the tool execution\n tool_call_id: string; // ID of the tool call this message responds to\n}\n\n/**\n * Developer message interface\n */\nexport interface DeveloperMessage extends BaseMessage {\n role: \"developer\";\n content: string; // Content for development or debugging\n}\n\n/**\n * Message chunk type constants\n */\nexport const MessageChunkTypes = {\n HUMAN: 'human',\n AI: 'ai',\n TOOL: 'tool',\n INTERRUPT: 'interrupt',\n MESSAGE_COMPLETED: 'message_completed',\n MESSAGE_FAILED: 'message_failed',\n THREAD_IDLE: 'thread_idle',\n} as const;\n\nexport type MessageChunkType = typeof MessageChunkTypes[keyof typeof MessageChunkTypes];\n\nexport interface MessageChunk {\n type: MessageChunkType;\n data: {\n id: string;\n content?: string;\n tool_call_chunks?: Array<{\n name?: string;\n args?: string;\n id?: string;\n index: number;\n }>;\n tool_calls?: Array<{\n name: string;\n args: Record<string, any>;\n id: string;\n type: string;\n response?: string;\n }>;\n additional_kwargs?: {\n tool_calls?: Array<{\n function?: { name?: string; arguments?: any };\n id?: string;\n }>;\n };\n tool_call_id?: string;\n };\n}\n\n/**\n * Message type union\n */\nexport type Message =\n | UserMessage\n | AssistantMessage\n | SystemMessage\n | ToolMessage\n | DeveloperMessage;\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":";AAaO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,WAAQ;AACR,EAAAA,WAAA,gBAAa;AACb,EAAAA,WAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAiLL,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;;;AC5OO,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;;;ACoEL,IAAM,oBAAoB;AAAA,EAC/B,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,WAAW;AAAA,EACX,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,aAAa;AACf;;;ACgIO,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiom-lattice/protocols",
3
- "version": "2.1.25",
3
+ "version": "2.1.27",
4
4
  "description": "Unified protocol type definitions for Axiom Lattice framework",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -56,18 +56,18 @@ interface BaseAgentConfig {
56
56
  export type AvailableModule = "filesystem" | "code_eval" | "browser";
57
57
 
58
58
  export interface SandboxMiddlewareConfig {
59
- isolatedLevel: "agent" | "thread" | "global";
59
+ vmIsolation: "agent" | "project" | "global";
60
60
  modules: AvailableModule[];
61
61
  }
62
62
 
63
63
  export interface CodeEvalMiddlewareConfig {
64
- isolatedLevel: "agent" | "thread" | "global";
64
+ vmIsolation: "agent" | "project" | "global";
65
65
  timeout: number;
66
66
  memoryLimit: number;
67
67
  }
68
68
 
69
69
  export interface BrowserMiddlewareConfig {
70
- isolatedLevel: "agent" | "thread" | "global";
70
+ vmIsolation: "agent" | "project" | "global";
71
71
  headless: boolean;
72
72
  }
73
73
 
@@ -82,7 +82,11 @@ export interface MetricsMiddlewareConfig {
82
82
  serverDescriptions?: Record<string, string>;
83
83
  }
84
84
 
85
- export type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date";
85
+ export interface SchedulerMiddlewareConfig {
86
+ defaultMaxRetries?: number;
87
+ }
88
+
89
+ export type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date" | "scheduler";
86
90
 
87
91
  export interface AgentMiddlewareConfig {
88
92
  id: string;
@@ -90,7 +94,7 @@ export interface AgentMiddlewareConfig {
90
94
  name: string;
91
95
  description: string;
92
96
  enabled: boolean;
93
- config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | MetricsMiddlewareConfig | ClawMiddlewareConfig | Record<string, any>;
97
+ config: SandboxMiddlewareConfig | CodeEvalMiddlewareConfig | BrowserMiddlewareConfig | SqlMiddlewareConfig | MetricsMiddlewareConfig | ClawMiddlewareConfig | SchedulerMiddlewareConfig | Record<string, any>;
94
98
  }
95
99
 
96
100
  /**
@@ -0,0 +1,61 @@
1
+ export type ChannelInstallationType = "lark";
2
+
3
+ export interface LarkChannelInstallationConfig {
4
+ appId: string;
5
+ appSecret: string;
6
+ verificationToken?: string;
7
+ encryptKey?: string;
8
+ mappingMode: "user" | "group" | "hybrid";
9
+ assistantId: string;
10
+ workspaceId?: string;
11
+ projectId?: string;
12
+ }
13
+
14
+ export interface ChannelInstallation {
15
+ id: string;
16
+ tenantId: string;
17
+ channel: ChannelInstallationType;
18
+ name?: string;
19
+ config: LarkChannelInstallationConfig;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ }
23
+
24
+ export interface CreateChannelInstallationRequest {
25
+ channel: ChannelInstallationType;
26
+ name?: string;
27
+ config: LarkChannelInstallationConfig;
28
+ }
29
+
30
+ export interface UpdateChannelInstallationRequest {
31
+ name?: string;
32
+ config?: Partial<LarkChannelInstallationConfig>;
33
+ }
34
+
35
+ export interface ChannelInstallationStore {
36
+ getInstallationById(
37
+ installationId: string,
38
+ ): Promise<ChannelInstallation | null>;
39
+
40
+ getInstallationsByTenant(
41
+ tenantId: string,
42
+ channel?: ChannelInstallationType,
43
+ ): Promise<ChannelInstallation[]>;
44
+
45
+ createInstallation(
46
+ tenantId: string,
47
+ installationId: string,
48
+ data: CreateChannelInstallationRequest,
49
+ ): Promise<ChannelInstallation>;
50
+
51
+ updateInstallation(
52
+ tenantId: string,
53
+ installationId: string,
54
+ updates: UpdateChannelInstallationRequest,
55
+ ): Promise<ChannelInstallation | null>;
56
+
57
+ deleteInstallation(
58
+ tenantId: string,
59
+ installationId: string,
60
+ ): Promise<boolean>;
61
+ }
@@ -113,6 +113,18 @@ export interface CreateSkillRequest {
113
113
  subSkills?: string[];
114
114
  }
115
115
 
116
+ /**
117
+ * SkillStore context for runtime sandbox resolution
118
+ */
119
+ export interface SkillStoreContext {
120
+ /** Assistant/agent identifier */
121
+ assistantId?: string;
122
+ /** Workspace identifier */
123
+ workspaceId?: string;
124
+ /** Project identifier */
125
+ projectId?: string;
126
+ }
127
+
116
128
  /**
117
129
  * SkillStore interface
118
130
  * Provides CRUD operations for skill data
@@ -121,107 +133,121 @@ export interface SkillStore {
121
133
  /**
122
134
  * Get all skills for a tenant
123
135
  * @param tenantId Tenant identifier
136
+ * @param context Optional runtime context for sandbox resolution
124
137
  * @returns Array of all skills for the tenant
125
138
  */
126
- getAllSkills(tenantId: string): Promise<Skill[]>;
139
+ getAllSkills(tenantId: string, context?: SkillStoreContext): Promise<Skill[]>;
127
140
 
128
141
  /**
129
142
  * Get skill by ID
130
143
  * @param tenantId Tenant identifier
131
144
  * @param id Skill identifier
145
+ * @param context Optional runtime context for sandbox resolution
132
146
  * @returns Skill if found, null otherwise
133
147
  */
134
- getSkillById(tenantId: string, id: string): Promise<Skill | null>;
148
+ getSkillById(tenantId: string, id: string, context?: SkillStoreContext): Promise<Skill | null>;
135
149
 
136
150
  /**
137
151
  * Create a new skill
138
152
  * @param tenantId Tenant identifier
139
153
  * @param id Skill identifier
140
154
  * @param data Skill creation data
155
+ * @param context Optional runtime context for sandbox resolution
141
156
  * @returns Created skill
142
157
  */
143
- createSkill(tenantId: string, id: string, data: CreateSkillRequest): Promise<Skill>;
158
+ createSkill(tenantId: string, id: string, data: CreateSkillRequest, context?: SkillStoreContext): Promise<Skill>;
144
159
 
145
160
  /**
146
161
  * Update an existing skill
147
162
  * @param tenantId Tenant identifier
148
163
  * @param id Skill identifier
149
164
  * @param updates Partial skill data to update
165
+ * @param context Optional runtime context for sandbox resolution
150
166
  * @returns Updated skill if found, null otherwise
151
167
  */
152
168
  updateSkill(
153
169
  tenantId: string,
154
170
  id: string,
155
- updates: Partial<CreateSkillRequest>
171
+ updates: Partial<CreateSkillRequest>,
172
+ context?: SkillStoreContext
156
173
  ): Promise<Skill | null>;
157
174
 
158
175
  /**
159
176
  * Delete a skill by ID
160
177
  * @param tenantId Tenant identifier
161
178
  * @param id Skill identifier
179
+ * @param context Optional runtime context for sandbox resolution
162
180
  * @returns true if deleted, false otherwise
163
181
  */
164
- deleteSkill(tenantId: string, id: string): Promise<boolean>;
182
+ deleteSkill(tenantId: string, id: string, context?: SkillStoreContext): Promise<boolean>;
165
183
 
166
184
  /**
167
185
  * Check if skill exists
168
186
  * @param tenantId Tenant identifier
169
187
  * @param id Skill identifier
188
+ * @param context Optional runtime context for sandbox resolution
170
189
  * @returns true if skill exists, false otherwise
171
190
  */
172
- hasSkill(tenantId: string, id: string): Promise<boolean>;
191
+ hasSkill(tenantId: string, id: string, context?: SkillStoreContext): Promise<boolean>;
173
192
 
174
193
  /**
175
194
  * Search skills by metadata within a tenant
176
195
  * @param tenantId Tenant identifier
177
196
  * @param metadataKey Metadata key to search for
178
197
  * @param metadataValue Metadata value to match
198
+ * @param context Optional runtime context for sandbox resolution
179
199
  * @returns Array of matching skills
180
200
  */
181
201
  searchByMetadata(
182
202
  tenantId: string,
183
203
  metadataKey: string,
184
- metadataValue: string
204
+ metadataValue: string,
205
+ context?: SkillStoreContext
185
206
  ): Promise<Skill[]>;
186
207
 
187
208
  /**
188
209
  * Filter skills by compatibility within a tenant
189
210
  * @param tenantId Tenant identifier
190
211
  * @param compatibility Compatibility string to filter by
212
+ * @param context Optional runtime context for sandbox resolution
191
213
  * @returns Array of matching skills
192
214
  */
193
- filterByCompatibility(tenantId: string, compatibility: string): Promise<Skill[]>;
215
+ filterByCompatibility(tenantId: string, compatibility: string, context?: SkillStoreContext): Promise<Skill[]>;
194
216
 
195
217
  /**
196
218
  * Filter skills by license within a tenant
197
219
  * @param tenantId Tenant identifier
198
220
  * @param license License string to filter by
221
+ * @param context Optional runtime context for sandbox resolution
199
222
  * @returns Array of matching skills
200
223
  */
201
- filterByLicense(tenantId: string, license: string): Promise<Skill[]>;
224
+ filterByLicense(tenantId: string, license: string, context?: SkillStoreContext): Promise<Skill[]>;
202
225
 
203
226
  /**
204
227
  * Get sub-skills of a parent skill within a tenant
205
228
  * @param tenantId Tenant identifier
206
229
  * @param parentSkillName Parent skill name
230
+ * @param context Optional runtime context for sandbox resolution
207
231
  * @returns Array of sub-skills if found, empty array otherwise
208
232
  */
209
- getSubSkills(tenantId: string, parentSkillName: string): Promise<Skill[]>;
233
+ getSubSkills(tenantId: string, parentSkillName: string, context?: SkillStoreContext): Promise<Skill[]>;
210
234
 
211
235
  /**
212
236
  * List all resources in a skill's resources directory
213
237
  * @param tenantId Tenant identifier
214
238
  * @param id Skill identifier
239
+ * @param context Optional runtime context for sandbox resolution
215
240
  * @returns Array of resource paths relative to resources/ directory
216
241
  */
217
- listSkillResources?(tenantId: string, id: string): Promise<string[]>;
242
+ listSkillResources?(tenantId: string, id: string, context?: SkillStoreContext): Promise<string[]>;
218
243
 
219
244
  /**
220
245
  * Load a specific resource from a skill's resources directory
221
246
  * @param tenantId Tenant identifier
222
247
  * @param id Skill identifier
223
248
  * @param resourcePath Path to the resource relative to resources/ directory
249
+ * @param context Optional runtime context for sandbox resolution
224
250
  * @returns The resource content as string, or null if not found
225
251
  */
226
- loadSkillResource?(tenantId: string, id: string, resourcePath: string): Promise<string | null>;
252
+ loadSkillResource?(tenantId: string, id: string, resourcePath: string, context?: SkillStoreContext): Promise<string | null>;
227
253
  }
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@ export * from "./McpLatticeProtocol";
24
24
  export * from "./WorkspaceStoreProtocol";
25
25
  export * from "./TenantStoreProtocol";
26
26
  export * from "./DatabaseConfigStoreProtocol";
27
+ export * from "./ChannelInstallationStoreProtocol";
27
28
  export * from "./MetricsServerConfigStoreProtocol";
28
29
  export * from "./McpServerConfigStoreProtocol";
29
30
  export * from "./UserStoreProtocol";