@axiom-lattice/protocols 2.1.41 → 2.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -129,7 +129,9 @@ declare enum AgentType {
129
129
  TEAM = "team",
130
130
  PROCESSING = "processing",
131
131
  /** Remote A2A agent — delegates to an external A2A-compatible server */
132
- A2A_REMOTE = "a2a_remote"
132
+ A2A_REMOTE = "a2a_remote",
133
+ /** Workflow agent — compiled from YAML DSL into a LangGraph StateGraph */
134
+ WORKFLOW = "workflow"
133
135
  }
134
136
  /**
135
137
  * Runtime configuration that will be injected into LangGraphRunnableConfig.configurable
@@ -164,6 +166,21 @@ interface BaseAgentConfig {
164
166
  runConfig?: AgentRunConfig;
165
167
  skillCategories?: string[];
166
168
  middleware?: AgentMiddlewareConfig[];
169
+ /**
170
+ * Structured output response format for the agent.
171
+ * Supports Zod schema (z.object({...})), JSON Schema object ({ type: "object", properties: {...} }),
172
+ * providerStrategy(), toolStrategy(), and other formats accepted by the underlying model.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * // Zod schema
177
+ * responseFormat: z.object({ name: z.string(), age: z.number() })
178
+ *
179
+ * // JSON Schema
180
+ * responseFormat: { type: "object", properties: { name: { type: "string" } }, required: ["name"] }
181
+ * ```
182
+ */
183
+ responseFormat?: any;
167
184
  }
168
185
  type AvailableModule = "filesystem" | "code_eval" | "browser";
169
186
  interface SandboxMiddlewareConfig {
@@ -191,7 +208,7 @@ interface MetricsMiddlewareConfig {
191
208
  interface SchedulerMiddlewareConfig {
192
209
  defaultMaxRetries?: number;
193
210
  }
194
- type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date" | "scheduler" | "topology";
211
+ type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date" | "scheduler" | "topology" | "task";
195
212
  interface AgentMiddlewareConfig {
196
213
  id: string;
197
214
  type: MiddlewareType;
@@ -319,19 +336,37 @@ interface A2ARemoteAgentConfig extends BaseAgentConfig {
319
336
  */
320
337
  tools?: string[];
321
338
  }
339
+ /**
340
+ * WORKFLOW agent configuration — compiled from YAML workflow DSL into a LangGraph StateGraph.
341
+ *
342
+ * The workflow field contains the full DSL definition (nodes, edges, state).
343
+ * The WorkflowAgentGraphBuilder compiles this into a multi-node LangGraph
344
+ * where each node invokes a registered sub-agent by ref.
345
+ */
346
+ interface WorkflowAgentConfig extends BaseAgentConfig {
347
+ type: AgentType.WORKFLOW;
348
+ /** The YAML workflow DSL definition string (needs+if format) */
349
+ workflowYaml: string;
350
+ /** Optional tool keys */
351
+ tools?: string[];
352
+ }
322
353
  /**
323
354
  * Type guard to check if config is A2ARemoteAgentConfig
324
355
  */
325
356
  declare function isA2ARemoteAgentConfig(config: AgentConfig): config is A2ARemoteAgentConfig;
357
+ /**
358
+ * Type guard to check if config is WorkflowAgentConfig
359
+ */
360
+ declare function isWorkflowAgentConfig(config: AgentConfig): config is WorkflowAgentConfig;
326
361
  /**
327
362
  * Agent configuration union type
328
363
  * Different agent types have different configuration options
329
364
  */
330
- type AgentConfig = ReactAgentConfig | DeepAgentConfig | TeamAgentConfig | ProcessingAgentConfig | A2ARemoteAgentConfig;
365
+ type AgentConfig = ReactAgentConfig | DeepAgentConfig | TeamAgentConfig | ProcessingAgentConfig | A2ARemoteAgentConfig | WorkflowAgentConfig;
331
366
  /**
332
367
  * Agent configuration with tools property
333
368
  */
334
- type AgentConfigWithTools = ReactAgentConfig | DeepAgentConfig | TeamAgentConfig | ProcessingAgentConfig | A2ARemoteAgentConfig;
369
+ type AgentConfigWithTools = ReactAgentConfig | DeepAgentConfig | TeamAgentConfig | ProcessingAgentConfig | A2ARemoteAgentConfig | WorkflowAgentConfig;
335
370
  /**
336
371
  * Type guard to check if config has tools property
337
372
  */
@@ -458,16 +493,16 @@ interface UIConfig {
458
493
  */
459
494
  interface UIComponent<T = any> {
460
495
  render: (props?: any) => T;
461
- addEventListener: (event: string, handler: Function) => void;
462
- removeEventListener: (event: string, handler: Function) => void;
496
+ addEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
497
+ removeEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
463
498
  }
464
499
  /**
465
500
  * UI Lattice协议接口
466
501
  */
467
502
  interface UILatticeProtocol<T = any> extends BaseLatticeProtocol<UIConfig, UIComponent<T>> {
468
503
  render: (props?: any) => T;
469
- addEventListener: (event: string, handler: Function) => void;
470
- removeEventListener: (event: string, handler: Function) => void;
504
+ addEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
505
+ removeEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
471
506
  }
472
507
 
473
508
  /**
@@ -1182,6 +1217,11 @@ interface Assistant {
1182
1217
  * Assistant description
1183
1218
  */
1184
1219
  description?: string;
1220
+ /**
1221
+ * Owner user ID — when set, this assistant is a personal assistant
1222
+ * owned by the given user. NULL for shared/tenant agents.
1223
+ */
1224
+ ownerUserId?: string;
1185
1225
  /**
1186
1226
  * Graph definition for the assistant
1187
1227
  */
@@ -1207,6 +1247,10 @@ interface CreateAssistantRequest {
1207
1247
  * Assistant description
1208
1248
  */
1209
1249
  description?: string;
1250
+ /**
1251
+ * Owner user ID for personal assistants
1252
+ */
1253
+ ownerUserId?: string;
1210
1254
  /**
1211
1255
  * Graph definition for the assistant
1212
1256
  */
@@ -1260,6 +1304,13 @@ interface AssistantStore {
1260
1304
  * @returns true if assistant exists, false otherwise
1261
1305
  */
1262
1306
  hasAssistant(tenantId: string, id: string): Promise<boolean>;
1307
+ /**
1308
+ * Get personal assistant by owner user ID
1309
+ * @param tenantId Tenant identifier
1310
+ * @param userId Owner user identifier
1311
+ * @returns Assistant if found, null otherwise
1312
+ */
1313
+ getByOwner(tenantId: string, userId: string): Promise<Assistant | null>;
1263
1314
  }
1264
1315
 
1265
1316
  /**
@@ -2095,6 +2146,11 @@ interface UpdateChannelInstallationRequest {
2095
2146
  interface ChannelInstallationStore {
2096
2147
  getInstallationById(installationId: string): Promise<ChannelInstallation | null>;
2097
2148
  getInstallationsByTenant(tenantId: string, channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
2149
+ /**
2150
+ * 返回所有租户下指定 channel 类型的安装(跨租户查询)。
2151
+ * 用于 connectAllChannels 等不需要按租户过滤的场景。
2152
+ */
2153
+ getAllInstallations(channel?: ChannelInstallationType): Promise<ChannelInstallation[]>;
2098
2154
  createInstallation(tenantId: string, installationId: string, data: CreateChannelInstallationRequest): Promise<ChannelInstallation>;
2099
2155
  updateInstallation(tenantId: string, installationId: string, updates: UpdateChannelInstallationRequest): Promise<ChannelInstallation | null>;
2100
2156
  deleteInstallation(tenantId: string, installationId: string): Promise<boolean>;
@@ -2822,7 +2878,7 @@ interface TopologyEdge {
2822
2878
  to: string;
2823
2879
  purpose: string;
2824
2880
  }
2825
- type WorkflowRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
2881
+ type WorkflowRunStatus = 'running' | 'completed' | 'failed' | 'cancelled' | 'interrupted';
2826
2882
  interface WorkflowRun {
2827
2883
  id: string;
2828
2884
  tenantId: string;
@@ -2835,18 +2891,20 @@ interface WorkflowRun {
2835
2891
  errorMessage?: string;
2836
2892
  metadata?: Record<string, any>;
2837
2893
  startedAt: Date;
2838
- completedAt?: Date;
2894
+ completedAt?: Date | null;
2839
2895
  createdAt: Date;
2840
2896
  updatedAt: Date;
2841
2897
  }
2842
- type StepType = 'task_delegation' | 'tool_call' | 'human_in_loop' | 'topology_transition';
2843
- type StepStatus = 'running' | 'completed' | 'failed' | 'interrupted';
2898
+ type StepType = 'task_delegation' | 'tool_call' | 'human_in_loop' | 'topology_transition' | 'agent' | 'human_feedback' | 'map' | 'input' | 'terminal';
2899
+ type StepStatus = 'running' | 'completed' | 'failed' | 'interrupted' | 'skipped';
2844
2900
  interface RunStep {
2845
2901
  id: string;
2846
2902
  runId: string;
2847
2903
  tenantId: string;
2848
2904
  stepType: StepType;
2849
2905
  stepName: string;
2906
+ /** Sub-agent thread_id for agent/map steps. null for input/terminal. */
2907
+ threadId?: string | null;
2850
2908
  edgeFrom?: string;
2851
2909
  edgeTo?: string;
2852
2910
  edgePurpose?: string;
@@ -2855,7 +2913,7 @@ interface RunStep {
2855
2913
  status: StepStatus;
2856
2914
  errorMessage?: string;
2857
2915
  startedAt: Date;
2858
- completedAt?: Date;
2916
+ completedAt?: Date | null;
2859
2917
  durationMs?: number;
2860
2918
  createdAt: Date;
2861
2919
  updatedAt: Date;
@@ -2871,7 +2929,7 @@ interface UpdateWorkflowRunRequest {
2871
2929
  status?: WorkflowRunStatus;
2872
2930
  completedEdges?: number;
2873
2931
  errorMessage?: string;
2874
- completedAt?: Date;
2932
+ completedAt?: Date | null;
2875
2933
  metadata?: Record<string, any>;
2876
2934
  }
2877
2935
  interface CreateRunStepRequest {
@@ -2879,6 +2937,7 @@ interface CreateRunStepRequest {
2879
2937
  tenantId: string;
2880
2938
  stepType: StepType;
2881
2939
  stepName: string;
2940
+ threadId?: string | null;
2882
2941
  edgeFrom?: string;
2883
2942
  edgeTo?: string;
2884
2943
  edgePurpose?: string;
@@ -2888,7 +2947,7 @@ interface UpdateRunStepRequest {
2888
2947
  status?: StepStatus;
2889
2948
  output?: Record<string, any>;
2890
2949
  errorMessage?: string;
2891
- completedAt?: Date;
2950
+ completedAt?: Date | null;
2892
2951
  durationMs?: number;
2893
2952
  }
2894
2953
  interface WorkflowTrackingStore {
@@ -2900,6 +2959,8 @@ interface WorkflowTrackingStore {
2900
2959
  getWorkflowRunsByAssistantId(tenantId: string, assistantId: string): Promise<WorkflowRun[]>;
2901
2960
  getWorkflowRunsByTenantId(tenantId: string): Promise<WorkflowRun[]>;
2902
2961
  createRunStep(request: CreateRunStepRequest): Promise<RunStep>;
2962
+ /** Idempotent create — uses (runId, stepType, stepName) as unique key. Returns existing step if one already exists. */
2963
+ upsertRunStep(request: CreateRunStepRequest): Promise<RunStep>;
2903
2964
  updateRunStep(runId: string, stepId: string, updates: UpdateRunStepRequest): Promise<RunStep | null>;
2904
2965
  getRunSteps(runId: string): Promise<RunStep[]>;
2905
2966
  getRunStepsByType(runId: string, stepType: StepType): Promise<RunStep[]>;
@@ -2963,6 +3024,72 @@ interface BindingRegistry {
2963
3024
  }): Promise<Binding[]>;
2964
3025
  }
2965
3026
 
3027
+ /**
3028
+ * MenuProtocol
3029
+ *
3030
+ * Defines types and registry interface for per-tenant customizable menu items.
3031
+ * Menu items are merged with built-in defaults at the React SDK layer.
3032
+ */
3033
+ type MenuTarget = 'sidebar' | 'workspace';
3034
+ type MenuContentType = 'agent' | 'html' | 'custom';
3035
+ interface AgentMenuConfig {
3036
+ agentId: string;
3037
+ workspaceId?: string;
3038
+ projectId?: string;
3039
+ }
3040
+ interface HtmlMenuConfig {
3041
+ url: string;
3042
+ params?: Record<string, string>;
3043
+ title?: string;
3044
+ }
3045
+ interface CustomMenuConfig {
3046
+ componentKey: string;
3047
+ }
3048
+ type MenuContentConfig = AgentMenuConfig | HtmlMenuConfig | CustomMenuConfig;
3049
+ interface MenuItem {
3050
+ id: string;
3051
+ tenantId: string;
3052
+ menuTarget: MenuTarget;
3053
+ group?: string;
3054
+ name: string;
3055
+ icon?: string;
3056
+ sortOrder: number;
3057
+ contentType: MenuContentType;
3058
+ contentConfig: MenuContentConfig;
3059
+ enabled: boolean;
3060
+ createdAt: Date;
3061
+ updatedAt: Date;
3062
+ }
3063
+ interface CreateMenuItemInput {
3064
+ menuTarget: MenuTarget;
3065
+ group?: string;
3066
+ name: string;
3067
+ icon?: string;
3068
+ sortOrder?: number;
3069
+ contentType: MenuContentType;
3070
+ contentConfig: MenuContentConfig;
3071
+ }
3072
+ interface UpdateMenuItemInput {
3073
+ group?: string;
3074
+ name?: string;
3075
+ icon?: string;
3076
+ sortOrder?: number;
3077
+ contentConfig?: MenuContentConfig;
3078
+ enabled?: boolean;
3079
+ }
3080
+ interface MenuRegistry {
3081
+ list(params: {
3082
+ tenantId: string;
3083
+ menuTarget?: MenuTarget;
3084
+ }): Promise<MenuItem[]>;
3085
+ getById(id: string): Promise<MenuItem | null>;
3086
+ create(input: CreateMenuItemInput & {
3087
+ tenantId: string;
3088
+ }): Promise<MenuItem>;
3089
+ update(id: string, patch: UpdateMenuItemInput): Promise<MenuItem>;
3090
+ delete(id: string): Promise<void>;
3091
+ }
3092
+
2966
3093
  interface EvalProject {
2967
3094
  id: string;
2968
3095
  tenantId: string;
@@ -3124,6 +3251,265 @@ interface EvalStore {
3124
3251
  getProjectReport(tenantId: string, projectId: string): Promise<EvalProjectReport | null>;
3125
3252
  }
3126
3253
 
3254
+ /**
3255
+ * TaskStoreProtocol
3256
+ *
3257
+ * Task store protocol definitions for the Axiom Lattice framework.
3258
+ * Provides standardized interfaces for task management across all implementations.
3259
+ */
3260
+ /**
3261
+ * TaskItem — unified task model for users and agents.
3262
+ */
3263
+ interface TaskItem {
3264
+ /**
3265
+ * Task identifier
3266
+ */
3267
+ id: string;
3268
+ /**
3269
+ * Tenant identifier
3270
+ */
3271
+ tenantId: string;
3272
+ /**
3273
+ * Owner type — either a user or an agent
3274
+ */
3275
+ ownerType: 'user' | 'agent';
3276
+ /**
3277
+ * Owner identifier
3278
+ */
3279
+ ownerId: string;
3280
+ /**
3281
+ * Task title
3282
+ */
3283
+ title: string;
3284
+ /**
3285
+ * Task description
3286
+ */
3287
+ description?: string;
3288
+ /**
3289
+ * Task status
3290
+ */
3291
+ status: 'pending' | 'in_progress' | 'completed' | 'cancelled';
3292
+ /**
3293
+ * Task priority level
3294
+ */
3295
+ priority: 'low' | 'medium' | 'high';
3296
+ /**
3297
+ * Optional due date as ISO string
3298
+ */
3299
+ dueDate?: string;
3300
+ /**
3301
+ * Arbitrary metadata key-value pairs
3302
+ */
3303
+ metadata?: Record<string, unknown>;
3304
+ /**
3305
+ * Parent task ID for hierarchical tasks
3306
+ */
3307
+ parentId?: string;
3308
+ /**
3309
+ * Source system identifier for external task tracking
3310
+ */
3311
+ sourceId?: string;
3312
+ /**
3313
+ * Additional contextual data
3314
+ */
3315
+ context?: Record<string, unknown>;
3316
+ /**
3317
+ * Task creation timestamp
3318
+ */
3319
+ createdAt: Date;
3320
+ /**
3321
+ * Task last update timestamp
3322
+ */
3323
+ updatedAt: Date;
3324
+ }
3325
+ /**
3326
+ * Create task request type
3327
+ */
3328
+ interface CreateTaskRequest {
3329
+ /**
3330
+ * Task title
3331
+ */
3332
+ title: string;
3333
+ /**
3334
+ * Task description
3335
+ */
3336
+ description?: string;
3337
+ /**
3338
+ * Task status — defaults to 'pending' if not provided
3339
+ */
3340
+ status?: 'pending' | 'in_progress' | 'completed' | 'cancelled';
3341
+ /**
3342
+ * Task priority level — defaults to 'medium' if not provided
3343
+ */
3344
+ priority?: 'low' | 'medium' | 'high';
3345
+ /**
3346
+ * Optional due date as ISO string
3347
+ */
3348
+ dueDate?: string;
3349
+ /**
3350
+ * Arbitrary metadata key-value pairs
3351
+ */
3352
+ metadata?: Record<string, unknown>;
3353
+ /**
3354
+ * Parent task ID for hierarchical tasks
3355
+ */
3356
+ parentId?: string;
3357
+ /**
3358
+ * Source system identifier for external task tracking
3359
+ */
3360
+ sourceId?: string;
3361
+ /**
3362
+ * Additional contextual data
3363
+ */
3364
+ context?: Record<string, unknown>;
3365
+ /**
3366
+ * Owner type — defaults based on context if not provided
3367
+ */
3368
+ ownerType?: 'user' | 'agent';
3369
+ /**
3370
+ * Owner identifier — defaults based on context if not provided
3371
+ */
3372
+ ownerId?: string;
3373
+ }
3374
+ /**
3375
+ * Update task request type
3376
+ */
3377
+ interface UpdateTaskRequest {
3378
+ /**
3379
+ * Task title
3380
+ */
3381
+ title?: string;
3382
+ /**
3383
+ * Task description
3384
+ */
3385
+ description?: string;
3386
+ /**
3387
+ * Task status
3388
+ */
3389
+ status?: 'pending' | 'in_progress' | 'completed' | 'cancelled';
3390
+ /**
3391
+ * Task priority level
3392
+ */
3393
+ priority?: 'low' | 'medium' | 'high';
3394
+ /**
3395
+ * Optional due date as ISO string
3396
+ */
3397
+ dueDate?: string;
3398
+ /**
3399
+ * Arbitrary metadata key-value pairs
3400
+ */
3401
+ metadata?: Record<string, unknown>;
3402
+ /**
3403
+ * Parent task ID for hierarchical tasks
3404
+ */
3405
+ parentId?: string;
3406
+ /**
3407
+ * Source system identifier for external task tracking
3408
+ */
3409
+ sourceId?: string;
3410
+ /**
3411
+ * Additional contextual data
3412
+ */
3413
+ context?: Record<string, unknown>;
3414
+ /**
3415
+ * Owner type
3416
+ */
3417
+ ownerType?: 'user' | 'agent';
3418
+ /**
3419
+ * Owner identifier
3420
+ */
3421
+ ownerId?: string;
3422
+ }
3423
+ /**
3424
+ * Task list filter criteria
3425
+ */
3426
+ interface TaskListFilter {
3427
+ /**
3428
+ * Tenant identifier (required)
3429
+ */
3430
+ tenantId: string;
3431
+ /**
3432
+ * Filter by owner type
3433
+ */
3434
+ ownerType?: 'user' | 'agent';
3435
+ /**
3436
+ * Filter by owner ID
3437
+ */
3438
+ ownerId?: string;
3439
+ /**
3440
+ * Filter by task status
3441
+ */
3442
+ status?: string;
3443
+ /**
3444
+ * Filter by priority level
3445
+ */
3446
+ priority?: string;
3447
+ /**
3448
+ * Filter by parent task ID
3449
+ */
3450
+ parentId?: string;
3451
+ /**
3452
+ * Filter by source system ID
3453
+ */
3454
+ sourceId?: string;
3455
+ /**
3456
+ * Filter by metadata key-value pairs
3457
+ */
3458
+ metadata?: Record<string, unknown>;
3459
+ /**
3460
+ * Maximum number of results to return
3461
+ */
3462
+ limit?: number;
3463
+ /**
3464
+ * Number of results to skip for pagination
3465
+ */
3466
+ offset?: number;
3467
+ }
3468
+ /**
3469
+ * TaskStore interface
3470
+ * Provides CRUD operations for task data
3471
+ */
3472
+ interface TaskStore {
3473
+ /**
3474
+ * Create a new task
3475
+ * @param params Task creation data including tenant, ownerType ('user' | 'agent'), and owner info
3476
+ * @returns Created task
3477
+ */
3478
+ create(params: CreateTaskRequest & {
3479
+ tenantId: string;
3480
+ ownerType: string;
3481
+ ownerId: string;
3482
+ }): Promise<TaskItem>;
3483
+ /**
3484
+ * Get a task by ID
3485
+ * @param tenantId Tenant identifier
3486
+ * @param id Task identifier
3487
+ * @returns Task if found, null otherwise
3488
+ */
3489
+ getById(tenantId: string, id: string): Promise<TaskItem | null>;
3490
+ /**
3491
+ * List tasks matching the given filter
3492
+ * @param filter Filter criteria
3493
+ * @returns Array of matching tasks
3494
+ */
3495
+ list(filter: TaskListFilter): Promise<TaskItem[]>;
3496
+ /**
3497
+ * Update an existing task
3498
+ * @param tenantId Tenant identifier
3499
+ * @param id Task identifier
3500
+ * @param updates Partial task data to update
3501
+ * @returns Updated task if found, null otherwise
3502
+ */
3503
+ update(tenantId: string, id: string, updates: UpdateTaskRequest): Promise<TaskItem | null>;
3504
+ /**
3505
+ * Delete a task by ID
3506
+ * @param tenantId Tenant identifier
3507
+ * @param id Task identifier
3508
+ * @returns true if deleted, false otherwise
3509
+ */
3510
+ delete(tenantId: string, id: string): Promise<boolean>;
3511
+ }
3512
+
3127
3513
  /**
3128
3514
  * ChannelAdapterProtocol
3129
3515
  */
@@ -3182,6 +3568,20 @@ interface ChannelAdapter<TConfig = unknown> {
3182
3568
  readonly configSchema: z.ZodSchema<TConfig>;
3183
3569
  receive(rawPayload: unknown, installation: ChannelInstallation): Promise<InboundMessage | null>;
3184
3570
  sendReply(replyTarget: ReplyTarget, message: OutboundMessage, installation: ChannelInstallation): Promise<void>;
3571
+ /**
3572
+ * 可选:Channel 自定义 thread ID 生成策略。
3573
+ * 如果提供,MessageRouter 会优先使用此方法决定 thread ID,
3574
+ * 替代默认的 binding.threadMode(fixed / per_conversation)。
3575
+ *
3576
+ * 返回的 thread ID 会持久化到 binding 中,以便后续消息复用。
3577
+ */
3578
+ resolveThreadId?(message: InboundMessage, binding: unknown): Promise<string> | string;
3579
+ /**
3580
+ * 可选:建立持久连接并开始接收事件。
3581
+ * adapter 自己负责连接管理、事件处理、消息分发。
3582
+ * `deps` 由调用方传入,通常包含 MessageRouter。
3583
+ */
3584
+ connect?(installation: ChannelInstallation<TConfig>, deps?: unknown): Promise<void>;
3185
3585
  }
3186
3586
 
3187
3587
  /**
@@ -3379,6 +3779,157 @@ interface A2AApiKeyStore {
3379
3779
  loadIntoMap(): Promise<Map<string, A2AApiKeyEntry>>;
3380
3780
  }
3381
3781
 
3782
+ /**
3783
+ * YAML Workflow DSL — linear model with parallel blocks
3784
+ *
3785
+ * Steps execute top-to-bottom. `parallel:` blocks declare concurrency.
3786
+ * `if` on any step skips it. `map` iterates over arrays.
3787
+ * No `needs` — execution order = reading order.
3788
+ *
3789
+ * Template syntax:
3790
+ * {{input}} — initial user input
3791
+ * {{label}} — output of step with given label
3792
+ * {{label.field}} — nested field access on structured output
3793
+ * {{item}} — current element in map iterations
3794
+ */
3795
+ interface YamlWorkflow {
3796
+ /** Optional workflow name — defaults to "workflow" if omitted. */
3797
+ name?: string;
3798
+ steps: YamlTopLevelStep[];
3799
+ }
3800
+ type YamlTopLevelStep = YamlAgentStep | YamlParallelBlock | YamlMapStep;
3801
+ interface YamlAgentStep {
3802
+ /** Unique label serving as state key and template reference. */
3803
+ label: string;
3804
+ /** JS expression evaluated as boolean. Step skipped when falsy. */
3805
+ if?: string;
3806
+ /** Agent instruction with {{template}} references. */
3807
+ prompt: string;
3808
+ /** Shorthand output schema: { field: "string" | "number" | "boolean" } */
3809
+ output?: Record<string, unknown>;
3810
+ /** When true, inject ask_user_to_clarify middleware. */
3811
+ ask?: boolean;
3812
+ }
3813
+ interface YamlParallelBlock {
3814
+ parallel: YamlAgentStep[];
3815
+ /** JS expression evaluated as boolean. Entire block skipped when falsy. */
3816
+ if?: string;
3817
+ /** Shorthand output schema for aggregated results. */
3818
+ output?: Record<string, unknown>;
3819
+ }
3820
+ interface YamlMapStep {
3821
+ map: {
3822
+ /** Path to source array (e.g. "extract.items"). */
3823
+ source: string;
3824
+ /** Step label for referencing in templates (e.g. {{label}}). */
3825
+ label: string;
3826
+ /** JS expression evaluated as boolean. Entire map skipped when falsy. */
3827
+ if?: string;
3828
+ /** Agent applied to each element. Use {{item}} for current element. */
3829
+ each: {
3830
+ prompt: string;
3831
+ output?: Record<string, unknown>;
3832
+ };
3833
+ /** Shorthand output schema for the aggregated results. */
3834
+ output?: Record<string, unknown>;
3835
+ /** Items per batch (default 50). */
3836
+ batch?: number;
3837
+ /** Max parallel items (default 5). */
3838
+ concurrency?: number;
3839
+ };
3840
+ }
3841
+
3842
+ /**
3843
+ * Internal DSL — expanded intermediate representation.
3844
+ *
3845
+ * Generated by parseYaml() from the YAML workflow DSL. Consumed by compileWorkflow.
3846
+ * Not part of the public API.
3847
+ */
3848
+ interface InternalDSL {
3849
+ version: "1.0";
3850
+ name: string;
3851
+ description?: string;
3852
+ state?: InternalState;
3853
+ nodes: InternalNode[];
3854
+ edges: InternalEdge[];
3855
+ }
3856
+ interface InternalState {
3857
+ fields: Record<string, InternalStateField>;
3858
+ }
3859
+ interface InternalStateField {
3860
+ type: "string" | "number" | "boolean" | "object" | "array";
3861
+ default?: unknown;
3862
+ reducer?: "replace" | "append" | "merge";
3863
+ }
3864
+ type InternalNode = InternalAgentNode | InternalMapNode | InternalTerminalNode | InternalInputNode;
3865
+ interface InternalBaseNode {
3866
+ id: string;
3867
+ type: "agent" | "map" | "terminal" | "input";
3868
+ name: string;
3869
+ description?: string;
3870
+ config?: InternalNodeConfig;
3871
+ input?: InternalInput;
3872
+ output?: InternalOutput;
3873
+ }
3874
+ interface InternalAgentNode extends InternalBaseNode {
3875
+ type: "agent";
3876
+ ref?: string;
3877
+ /** When true, the agent loads ask_user_to_clarify middleware. */
3878
+ ask?: boolean;
3879
+ /** Runtime condition expression evaluated as JS. Step skipped when false. */
3880
+ condition?: string;
3881
+ /** Parallel group ID — children in the same group run concurrently. */
3882
+ parallelGroup?: string;
3883
+ }
3884
+ interface InternalMapNode extends InternalBaseNode {
3885
+ type: "map";
3886
+ source: string;
3887
+ itemKey?: string;
3888
+ /** Runtime condition expression evaluated as JS. Map skipped when false. */
3889
+ condition?: string;
3890
+ config?: InternalNodeConfig & {
3891
+ batchSize?: number;
3892
+ maxConcurrency?: number;
3893
+ innerConcurrency?: number;
3894
+ };
3895
+ node: {
3896
+ type: "agent";
3897
+ ref?: string;
3898
+ input?: InternalInput;
3899
+ schema?: Record<string, unknown>;
3900
+ };
3901
+ reduce?: {
3902
+ ref?: string;
3903
+ input?: InternalInput;
3904
+ schema?: Record<string, unknown>;
3905
+ };
3906
+ }
3907
+ interface InternalTerminalNode extends InternalBaseNode {
3908
+ type: "terminal";
3909
+ status: "success" | "failed" | "cancelled";
3910
+ }
3911
+ interface InternalInputNode extends InternalBaseNode {
3912
+ type: "input";
3913
+ /** output key for the user message (typically "input") */
3914
+ output: InternalOutput;
3915
+ }
3916
+ type InternalInput = {
3917
+ template: string;
3918
+ };
3919
+ interface InternalOutput {
3920
+ schema?: Record<string, unknown>;
3921
+ key?: string;
3922
+ }
3923
+ interface InternalEdge {
3924
+ from: string;
3925
+ to?: string | string[];
3926
+ }
3927
+ interface InternalNodeConfig {
3928
+ timeout?: number;
3929
+ maxRetries?: number;
3930
+ retryOn?: string[];
3931
+ }
3932
+
3382
3933
  /**
3383
3934
  * 通用类型定义
3384
3935
  *
@@ -3442,4 +3993,4 @@ type Timestamp = number;
3442
3993
  */
3443
3994
  type Callback<T = any, R = void> = (data: T) => R | Promise<R>;
3444
3995
 
3445
- export { type A2AApiKeyEntry, type A2AApiKeyRecord, type A2AApiKeyStore, type A2AArtifact, type A2AAuthContext, type A2ACapabilities, type A2AConfig, type A2ADataPart, type A2AFilePart, type A2AMessage, type A2APart, type A2AProvider, type A2APushNotification, type A2ARemoteAgentConfig, type A2ASSEEvent, type A2ASkill, type A2ATask, type A2ATaskArtifactUpdatePayload, type A2ATaskSendRequest, type A2ATaskState, type A2ATaskStatus, type A2ATaskUpdatePayload, type A2ATextPart, A2A_DEFAULT_CAPABILITIES, A2A_DEFAULT_INPUT_MODES, A2A_DEFAULT_OUTPUT_MODES, type AgentCard, type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, type AgentMiddlewareConfig, type AgentRunConfig, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type Attachment, type AvailableModule, type BaseLatticeProtocol, type BaseMessage, type Binding, type BindingRegistry, type BootstrapFilesConfig, type BrowserMiddlewareConfig, type Callback, type ChannelAdapter, type ChannelInstallation, type ChannelInstallationStore, type ChannelInstallationType, type ClawMiddlewareConfig, type CodeEvalMiddlewareConfig, type CreateA2AApiKeyInput, type CreateAssistantRequest, type CreateBindingInput, type CreateChannelInstallationRequest, type CreateDatabaseConfigRequest, type CreateEvalCaseRequest, type CreateEvalProjectRequest, type CreateEvalRunRequest, type CreateEvalSuiteRequest, type CreateMcpServerConfigRequest, type CreateMetricsServerConfigRequest, type CreateProjectRequest, type CreateRunStepRequest, type CreateSkillRequest, type CreateTenantRequest, type CreateThreadRequest, type CreateUserRequest, type CreateUserTenantLinkRequest, type CreateWorkflowRunRequest, type CreateWorkspaceRequest, type DataSource, type DatabaseConfig, type DatabaseConfigEntry, type DatabaseConfigStore, type DatabaseType, type DeepAgentConfig, type DeveloperMessage, type DispatchResult, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type EvalCase, type EvalProject, type EvalProjectReport, type EvalRun, type EvalRunResult, type EvalStore, type EvalSuite, type ExecuteSqlQueryRequest, type ExecuteSqlQueryResponse, type FilterCondition, type GraphBuildOptions, type ID, type InboundMessage, 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 MessageContext, type MessageMiddleware, type MetricColumn, type MetricDataPoint, type MetricMeta, type MetricQueryResult, type MetricsMiddlewareConfig, type MetricsServerConfig, type MetricsServerConfigEntry, type MetricsServerConfigStore, type MetricsServerType, type MiddlewareType, type ModelLatticeProtocol, type OutboundMessage, type PaginatedResult, type PaginationParams, type PinoFileOptions, type ProcessingAgentConfig, type Project, type ProjectStore, type QueryParams, type QueryResultFormat, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type ReplyTarget, type Result, type RunStep, 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 StepStatus, type StepType, 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 TopologyEdge, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UpdateChannelInstallationRequest, type UpdateDatabaseConfigRequest, type UpdateMcpServerConfigRequest, type UpdateMetricsServerConfigRequest, type UpdateProjectRequest, type UpdateRunStepRequest, type UpdateTenantRequest, type UpdateUserRequest, type UpdateUserTenantLinkRequest, type UpdateWorkflowRunRequest, type UpdateWorkspaceRequest, type User, type UserMessage, type UserStatus, type UserStore, type UserTenantLink, type UserTenantLinkStore, type UserTenantRole, type VectorStoreConfig, type VectorStoreLatticeProtocol, type WorkflowRun, type WorkflowRunStatus, type WorkflowTrackingStore, type Workspace, type WorkspaceStore, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isA2ARemoteAgentConfig, isDeepAgentConfig, isProcessingAgentConfig, isTeamAgentConfig };
3996
+ export { type A2AApiKeyEntry, type A2AApiKeyRecord, type A2AApiKeyStore, type A2AArtifact, type A2AAuthContext, type A2ACapabilities, type A2AConfig, type A2ADataPart, type A2AFilePart, type A2AMessage, type A2APart, type A2AProvider, type A2APushNotification, type A2ARemoteAgentConfig, type A2ASSEEvent, type A2ASkill, type A2ATask, type A2ATaskArtifactUpdatePayload, type A2ATaskSendRequest, type A2ATaskState, type A2ATaskStatus, type A2ATaskUpdatePayload, type A2ATextPart, A2A_DEFAULT_CAPABILITIES, A2A_DEFAULT_INPUT_MODES, A2A_DEFAULT_OUTPUT_MODES, type AgentCard, type AgentClient, type AgentConfig, type AgentConfigWithTools, type AgentLatticeProtocol, type AgentMenuConfig, type AgentMiddlewareConfig, type AgentRunConfig, AgentType, type Assistant, type AssistantMessage, type AssistantStore, type Attachment, type AvailableModule, type BaseLatticeProtocol, type BaseMessage, type Binding, type BindingRegistry, type BootstrapFilesConfig, type BrowserMiddlewareConfig, type Callback, type ChannelAdapter, type ChannelInstallation, type ChannelInstallationStore, type ChannelInstallationType, type ClawMiddlewareConfig, type CodeEvalMiddlewareConfig, type CreateA2AApiKeyInput, type CreateAssistantRequest, type CreateBindingInput, type CreateChannelInstallationRequest, type CreateDatabaseConfigRequest, type CreateEvalCaseRequest, type CreateEvalProjectRequest, type CreateEvalRunRequest, type CreateEvalSuiteRequest, type CreateMcpServerConfigRequest, type CreateMenuItemInput, type CreateMetricsServerConfigRequest, type CreateProjectRequest, type CreateRunStepRequest, type CreateSkillRequest, type CreateTaskRequest, type CreateTenantRequest, type CreateThreadRequest, type CreateUserRequest, type CreateUserTenantLinkRequest, type CreateWorkflowRunRequest, type CreateWorkspaceRequest, type CustomMenuConfig, type DataSource, type DatabaseConfig, type DatabaseConfigEntry, type DatabaseConfigStore, type DatabaseType, type DeepAgentConfig, type DeveloperMessage, type DispatchResult, type EmbeddingsConfig, type EmbeddingsLatticeProtocol, type EvalCase, type EvalProject, type EvalProjectReport, type EvalRun, type EvalRunResult, type EvalStore, type EvalSuite, type ExecuteSqlQueryRequest, type ExecuteSqlQueryResponse, type FilterCondition, type GraphBuildOptions, type HtmlMenuConfig, type ID, type InboundMessage, type InternalAgentNode, type InternalBaseNode, type InternalDSL, type InternalEdge, type InternalInput, type InternalInputNode, type InternalMapNode, type InternalNode, type InternalNodeConfig, type InternalOutput, type InternalState, type InternalStateField, type InternalTerminalNode, 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 MenuContentConfig, type MenuContentType, type MenuItem, type MenuRegistry, type MenuTarget, type Message, type MessageChunk, type MessageChunkType, MessageChunkTypes, type MessageContext, type MessageMiddleware, type MetricColumn, type MetricDataPoint, type MetricMeta, type MetricQueryResult, type MetricsMiddlewareConfig, type MetricsServerConfig, type MetricsServerConfigEntry, type MetricsServerConfigStore, type MetricsServerType, type MiddlewareType, type ModelLatticeProtocol, type OutboundMessage, type PaginatedResult, type PaginationParams, type PinoFileOptions, type ProcessingAgentConfig, type Project, type ProjectStore, type QueryParams, type QueryResultFormat, type QueueClient, type QueueConfig, type QueueLatticeProtocol, type QueueResult, QueueType, type ReactAgentConfig, type ReplyTarget, type Result, type RunStep, 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 StepStatus, type StepType, type StorageType, type SystemMessage, type TableQueryRequest, type TableQueryResponse, type TaskHandler, type TaskItem, type TaskListFilter, type TaskStore, 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 TopologyEdge, type UIComponent, UIComponentType, type UIConfig, type UILatticeProtocol, type UpdateChannelInstallationRequest, type UpdateDatabaseConfigRequest, type UpdateMcpServerConfigRequest, type UpdateMenuItemInput, type UpdateMetricsServerConfigRequest, type UpdateProjectRequest, type UpdateRunStepRequest, type UpdateTaskRequest, type UpdateTenantRequest, type UpdateUserRequest, type UpdateUserTenantLinkRequest, type UpdateWorkflowRunRequest, type UpdateWorkspaceRequest, type User, type UserMessage, type UserStatus, type UserStore, type UserTenantLink, type UserTenantLinkStore, type UserTenantRole, type VectorStoreConfig, type VectorStoreLatticeProtocol, type WorkflowAgentConfig, type WorkflowRun, type WorkflowRunStatus, type WorkflowTrackingStore, type Workspace, type WorkspaceStore, type YamlAgentStep, type YamlMapStep, type YamlParallelBlock, type YamlTopLevelStep, type YamlWorkflow, getSubAgentsFromConfig, getToolsFromConfig, hasTools, isA2ARemoteAgentConfig, isDeepAgentConfig, isProcessingAgentConfig, isTeamAgentConfig, isWorkflowAgentConfig };