@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.
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { CompiledStateGraph } from "@langchain/langgraph";
8
- import z, { ZodObject, ZodSchema } from "zod";
8
+ import { ZodObject } from "zod";
9
9
  import { BaseLatticeProtocol } from "./BaseLatticeProtocol";
10
10
 
11
11
  /**
@@ -18,6 +18,8 @@ export enum AgentType {
18
18
  PROCESSING = "processing",
19
19
  /** Remote A2A agent — delegates to an external A2A-compatible server */
20
20
  A2A_REMOTE = "a2a_remote",
21
+ /** Workflow agent — compiled from YAML DSL into a LangGraph StateGraph */
22
+ WORKFLOW = "workflow",
21
23
  }
22
24
 
23
25
  /**
@@ -54,6 +56,21 @@ interface BaseAgentConfig {
54
56
  runConfig?: AgentRunConfig;
55
57
  skillCategories?: string[];
56
58
  middleware?: AgentMiddlewareConfig[];
59
+ /**
60
+ * Structured output response format for the agent.
61
+ * Supports Zod schema (z.object({...})), JSON Schema object ({ type: "object", properties: {...} }),
62
+ * providerStrategy(), toolStrategy(), and other formats accepted by the underlying model.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * // Zod schema
67
+ * responseFormat: z.object({ name: z.string(), age: z.number() })
68
+ *
69
+ * // JSON Schema
70
+ * responseFormat: { type: "object", properties: { name: { type: "string" } }, required: ["name"] }
71
+ * ```
72
+ */
73
+ responseFormat?: any;
57
74
  }
58
75
 
59
76
  export type AvailableModule = "filesystem" | "code_eval" | "browser";
@@ -89,7 +106,7 @@ export interface SchedulerMiddlewareConfig {
89
106
  defaultMaxRetries?: number;
90
107
  }
91
108
 
92
- export type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date" | "scheduler" | "topology";
109
+ export type MiddlewareType = "filesystem" | "code_eval" | "browser" | "sql" | "skill" | "http" | "custom" | "metrics" | "ask_user_to_clarify" | "widget" | "claw" | "date" | "scheduler" | "topology" | "task";
93
110
 
94
111
  export interface AgentMiddlewareConfig {
95
112
  id: string;
@@ -235,6 +252,21 @@ export interface A2ARemoteAgentConfig extends BaseAgentConfig {
235
252
  tools?: string[];
236
253
  }
237
254
 
255
+ /**
256
+ * WORKFLOW agent configuration — compiled from YAML workflow DSL into a LangGraph StateGraph.
257
+ *
258
+ * The workflow field contains the full DSL definition (nodes, edges, state).
259
+ * The WorkflowAgentGraphBuilder compiles this into a multi-node LangGraph
260
+ * where each node invokes a registered sub-agent by ref.
261
+ */
262
+ export interface WorkflowAgentConfig extends BaseAgentConfig {
263
+ type: AgentType.WORKFLOW;
264
+ /** The YAML workflow DSL definition string (needs+if format) */
265
+ workflowYaml: string;
266
+ /** Optional tool keys */
267
+ tools?: string[];
268
+ }
269
+
238
270
  /**
239
271
  * Type guard to check if config is A2ARemoteAgentConfig
240
272
  */
@@ -244,6 +276,15 @@ export function isA2ARemoteAgentConfig(
244
276
  return config.type === AgentType.A2A_REMOTE;
245
277
  }
246
278
 
279
+ /**
280
+ * Type guard to check if config is WorkflowAgentConfig
281
+ */
282
+ export function isWorkflowAgentConfig(
283
+ config: AgentConfig
284
+ ): config is WorkflowAgentConfig {
285
+ return config.type === AgentType.WORKFLOW;
286
+ }
287
+
247
288
  /**
248
289
  * Agent configuration union type
249
290
  * Different agent types have different configuration options
@@ -254,6 +295,7 @@ export type AgentConfig =
254
295
  | TeamAgentConfig
255
296
  | ProcessingAgentConfig
256
297
  | A2ARemoteAgentConfig
298
+ | WorkflowAgentConfig
257
299
 
258
300
  /**
259
301
  * Agent configuration with tools property
@@ -264,12 +306,13 @@ export type AgentConfigWithTools =
264
306
  | TeamAgentConfig
265
307
  | ProcessingAgentConfig
266
308
  | A2ARemoteAgentConfig
309
+ | WorkflowAgentConfig
267
310
 
268
311
  /**
269
312
  * Type guard to check if config has tools property
270
313
  */
271
314
  export function hasTools(config: AgentConfig): config is AgentConfigWithTools {
272
- return true
315
+ return true;
273
316
  }
274
317
 
275
318
  /**
@@ -29,6 +29,12 @@ export interface Assistant {
29
29
  */
30
30
  description?: string;
31
31
 
32
+ /**
33
+ * Owner user ID — when set, this assistant is a personal assistant
34
+ * owned by the given user. NULL for shared/tenant agents.
35
+ */
36
+ ownerUserId?: string;
37
+
32
38
  /**
33
39
  * Graph definition for the assistant
34
40
  */
@@ -59,6 +65,11 @@ export interface CreateAssistantRequest {
59
65
  */
60
66
  description?: string;
61
67
 
68
+ /**
69
+ * Owner user ID for personal assistants
70
+ */
71
+ ownerUserId?: string;
72
+
62
73
  /**
63
74
  * Graph definition for the assistant
64
75
  */
@@ -122,4 +133,12 @@ export interface AssistantStore {
122
133
  * @returns true if assistant exists, false otherwise
123
134
  */
124
135
  hasAssistant(tenantId: string, id: string): Promise<boolean>;
136
+
137
+ /**
138
+ * Get personal assistant by owner user ID
139
+ * @param tenantId Tenant identifier
140
+ * @param userId Owner user identifier
141
+ * @returns Assistant if found, null otherwise
142
+ */
143
+ getByOwner(tenantId: string, userId: string): Promise<Assistant | null>;
125
144
  }
@@ -76,4 +76,24 @@ export interface ChannelAdapter<TConfig = unknown> {
76
76
  message: OutboundMessage,
77
77
  installation: ChannelInstallation,
78
78
  ): Promise<void>;
79
+ /**
80
+ * 可选:Channel 自定义 thread ID 生成策略。
81
+ * 如果提供,MessageRouter 会优先使用此方法决定 thread ID,
82
+ * 替代默认的 binding.threadMode(fixed / per_conversation)。
83
+ *
84
+ * 返回的 thread ID 会持久化到 binding 中,以便后续消息复用。
85
+ */
86
+ resolveThreadId?(
87
+ message: InboundMessage,
88
+ binding: unknown,
89
+ ): Promise<string> | string;
90
+ /**
91
+ * 可选:建立持久连接并开始接收事件。
92
+ * adapter 自己负责连接管理、事件处理、消息分发。
93
+ * `deps` 由调用方传入,通常包含 MessageRouter。
94
+ */
95
+ connect?(
96
+ installation: ChannelInstallation<TConfig>,
97
+ deps?: unknown,
98
+ ): Promise<void>;
79
99
  }
@@ -48,6 +48,14 @@ export interface ChannelInstallationStore {
48
48
  channel?: ChannelInstallationType,
49
49
  ): Promise<ChannelInstallation[]>;
50
50
 
51
+ /**
52
+ * 返回所有租户下指定 channel 类型的安装(跨租户查询)。
53
+ * 用于 connectAllChannels 等不需要按租户过滤的场景。
54
+ */
55
+ getAllInstallations(
56
+ channel?: ChannelInstallationType,
57
+ ): Promise<ChannelInstallation[]>;
58
+
51
59
  createInstallation(
52
60
  tenantId: string,
53
61
  installationId: string,
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Internal DSL — expanded intermediate representation.
3
+ *
4
+ * Generated by parseYaml() from the YAML workflow DSL. Consumed by compileWorkflow.
5
+ * Not part of the public API.
6
+ */
7
+
8
+ // ─── Top-level ─────────────────────────────────────────────────────────────
9
+
10
+ export interface InternalDSL {
11
+ version: "1.0";
12
+ name: string;
13
+ description?: string;
14
+ state?: InternalState;
15
+ nodes: InternalNode[];
16
+ edges: InternalEdge[];
17
+ }
18
+
19
+ // ─── State ─────────────────────────────────────────────────────────────────
20
+
21
+ export interface InternalState {
22
+ fields: Record<string, InternalStateField>;
23
+ }
24
+
25
+ export interface InternalStateField {
26
+ type: "string" | "number" | "boolean" | "object" | "array";
27
+ default?: unknown;
28
+ reducer?: "replace" | "append" | "merge";
29
+ }
30
+
31
+ // ─── Nodes ─────────────────────────────────────────────────────────────────
32
+
33
+ export type InternalNode =
34
+ | InternalAgentNode
35
+ | InternalMapNode
36
+ | InternalTerminalNode
37
+ | InternalInputNode;
38
+
39
+ export interface InternalBaseNode {
40
+ id: string;
41
+ type: "agent" | "map" | "terminal" | "input";
42
+ name: string;
43
+ description?: string;
44
+ config?: InternalNodeConfig;
45
+ input?: InternalInput;
46
+ output?: InternalOutput;
47
+ }
48
+
49
+ export interface InternalAgentNode extends InternalBaseNode {
50
+ type: "agent";
51
+ ref?: string;
52
+ /** When true, the agent loads ask_user_to_clarify middleware. */
53
+ ask?: boolean;
54
+ /** Runtime condition expression evaluated as JS. Step skipped when false. */
55
+ condition?: string;
56
+ /** Parallel group ID — children in the same group run concurrently. */
57
+ parallelGroup?: string;
58
+ }
59
+
60
+ export interface InternalMapNode extends InternalBaseNode {
61
+ type: "map";
62
+ source: string;
63
+ itemKey?: string;
64
+ /** Runtime condition expression evaluated as JS. Map skipped when false. */
65
+ condition?: string;
66
+ config?: InternalNodeConfig & {
67
+ batchSize?: number;
68
+ maxConcurrency?: number;
69
+ innerConcurrency?: number;
70
+ };
71
+ node: {
72
+ type: "agent";
73
+ ref?: string;
74
+ input?: InternalInput;
75
+ schema?: Record<string, unknown>;
76
+ };
77
+ reduce?: {
78
+ ref?: string;
79
+ input?: InternalInput;
80
+ schema?: Record<string, unknown>;
81
+ };
82
+ }
83
+
84
+ export interface InternalTerminalNode extends InternalBaseNode {
85
+ type: "terminal";
86
+ status: "success" | "failed" | "cancelled";
87
+ }
88
+
89
+ export interface InternalInputNode extends InternalBaseNode {
90
+ type: "input";
91
+ /** output key for the user message (typically "input") */
92
+ output: InternalOutput;
93
+ }
94
+
95
+ // ─── Input / Output ────────────────────────────────────────────────────────
96
+
97
+ export type InternalInput = { template: string };
98
+
99
+ export interface InternalOutput {
100
+ schema?: Record<string, unknown>;
101
+ key?: string;
102
+ }
103
+
104
+ // ─── Edges ─────────────────────────────────────────────────────────────────
105
+
106
+ export interface InternalEdge {
107
+ from: string;
108
+ to?: string | string[];
109
+ }
110
+
111
+ // ─── Node Config ───────────────────────────────────────────────────────────
112
+
113
+ export interface InternalNodeConfig {
114
+ timeout?: number;
115
+ maxRetries?: number;
116
+ retryOn?: string[];
117
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * MenuProtocol
3
+ *
4
+ * Defines types and registry interface for per-tenant customizable menu items.
5
+ * Menu items are merged with built-in defaults at the React SDK layer.
6
+ */
7
+
8
+ export type MenuTarget = 'sidebar' | 'workspace';
9
+
10
+ export type MenuContentType = 'agent' | 'html' | 'custom';
11
+
12
+ export interface AgentMenuConfig {
13
+ agentId: string;
14
+ workspaceId?: string;
15
+ projectId?: string;
16
+ }
17
+
18
+ export interface HtmlMenuConfig {
19
+ url: string;
20
+ params?: Record<string, string>;
21
+ title?: string;
22
+ }
23
+
24
+ export interface CustomMenuConfig {
25
+ componentKey: string;
26
+ }
27
+
28
+ export type MenuContentConfig = AgentMenuConfig | HtmlMenuConfig | CustomMenuConfig;
29
+
30
+ export interface MenuItem {
31
+ id: string;
32
+ tenantId: string;
33
+ menuTarget: MenuTarget;
34
+ group?: string;
35
+ name: string;
36
+ icon?: string;
37
+ sortOrder: number;
38
+ contentType: MenuContentType;
39
+ contentConfig: MenuContentConfig;
40
+ enabled: boolean;
41
+ createdAt: Date;
42
+ updatedAt: Date;
43
+ }
44
+
45
+ export interface CreateMenuItemInput {
46
+ menuTarget: MenuTarget;
47
+ group?: string;
48
+ name: string;
49
+ icon?: string;
50
+ sortOrder?: number;
51
+ contentType: MenuContentType;
52
+ contentConfig: MenuContentConfig;
53
+ }
54
+
55
+ export interface UpdateMenuItemInput {
56
+ group?: string;
57
+ name?: string;
58
+ icon?: string;
59
+ sortOrder?: number;
60
+ contentConfig?: MenuContentConfig;
61
+ enabled?: boolean;
62
+ }
63
+
64
+ export interface MenuRegistry {
65
+ list(params: { tenantId: string; menuTarget?: MenuTarget }): Promise<MenuItem[]>;
66
+ getById(id: string): Promise<MenuItem | null>;
67
+ create(input: CreateMenuItemInput & { tenantId: string }): Promise<MenuItem>;
68
+ update(id: string, patch: UpdateMenuItemInput): Promise<MenuItem>;
69
+ delete(id: string): Promise<void>;
70
+ }
@@ -3,7 +3,7 @@
3
3
  *
4
4
  */
5
5
 
6
- import { BaseLatticeProtocol } from "./BaseLatticeProtocol";
6
+
7
7
 
8
8
  /**
9
9
  * Base message interface
@@ -5,7 +5,7 @@
5
5
  * Provides standardized interfaces for skill management across all implementations
6
6
  */
7
7
 
8
- import { SkillConfig } from "./SkillLatticeProtocol";
8
+
9
9
 
10
10
  /**
11
11
  * Skill type definition
@@ -0,0 +1,306 @@
1
+ /**
2
+ * TaskStoreProtocol
3
+ *
4
+ * Task store protocol definitions for the Axiom Lattice framework.
5
+ * Provides standardized interfaces for task management across all implementations.
6
+ */
7
+
8
+ /**
9
+ * TaskItem — unified task model for users and agents.
10
+ */
11
+ export interface TaskItem {
12
+ /**
13
+ * Task identifier
14
+ */
15
+ id: string;
16
+
17
+ /**
18
+ * Tenant identifier
19
+ */
20
+ tenantId: string;
21
+
22
+ /**
23
+ * Owner type — either a user or an agent
24
+ */
25
+ ownerType: 'user' | 'agent';
26
+
27
+ /**
28
+ * Owner identifier
29
+ */
30
+ ownerId: string;
31
+
32
+ /**
33
+ * Task title
34
+ */
35
+ title: string;
36
+
37
+ /**
38
+ * Task description
39
+ */
40
+ description?: string;
41
+
42
+ /**
43
+ * Task status
44
+ */
45
+ status: 'pending' | 'in_progress' | 'completed' | 'cancelled';
46
+
47
+ /**
48
+ * Task priority level
49
+ */
50
+ priority: 'low' | 'medium' | 'high';
51
+
52
+ /**
53
+ * Optional due date as ISO string
54
+ */
55
+ dueDate?: string;
56
+
57
+ /**
58
+ * Arbitrary metadata key-value pairs
59
+ */
60
+ metadata?: Record<string, unknown>;
61
+
62
+ /**
63
+ * Parent task ID for hierarchical tasks
64
+ */
65
+ parentId?: string;
66
+
67
+ /**
68
+ * Source system identifier for external task tracking
69
+ */
70
+ sourceId?: string;
71
+
72
+ /**
73
+ * Additional contextual data
74
+ */
75
+ context?: Record<string, unknown>;
76
+
77
+ /**
78
+ * Task creation timestamp
79
+ */
80
+ createdAt: Date;
81
+
82
+ /**
83
+ * Task last update timestamp
84
+ */
85
+ updatedAt: Date;
86
+ }
87
+
88
+ /**
89
+ * Create task request type
90
+ */
91
+ export interface CreateTaskRequest {
92
+ /**
93
+ * Task title
94
+ */
95
+ title: string;
96
+
97
+ /**
98
+ * Task description
99
+ */
100
+ description?: string;
101
+
102
+ /**
103
+ * Task status — defaults to 'pending' if not provided
104
+ */
105
+ status?: 'pending' | 'in_progress' | 'completed' | 'cancelled';
106
+
107
+ /**
108
+ * Task priority level — defaults to 'medium' if not provided
109
+ */
110
+ priority?: 'low' | 'medium' | 'high';
111
+
112
+ /**
113
+ * Optional due date as ISO string
114
+ */
115
+ dueDate?: string;
116
+
117
+ /**
118
+ * Arbitrary metadata key-value pairs
119
+ */
120
+ metadata?: Record<string, unknown>;
121
+
122
+ /**
123
+ * Parent task ID for hierarchical tasks
124
+ */
125
+ parentId?: string;
126
+
127
+ /**
128
+ * Source system identifier for external task tracking
129
+ */
130
+ sourceId?: string;
131
+
132
+ /**
133
+ * Additional contextual data
134
+ */
135
+ context?: Record<string, unknown>;
136
+
137
+ /**
138
+ * Owner type — defaults based on context if not provided
139
+ */
140
+ ownerType?: 'user' | 'agent';
141
+
142
+ /**
143
+ * Owner identifier — defaults based on context if not provided
144
+ */
145
+ ownerId?: string;
146
+ }
147
+
148
+ /**
149
+ * Update task request type
150
+ */
151
+ export interface UpdateTaskRequest {
152
+ /**
153
+ * Task title
154
+ */
155
+ title?: string;
156
+
157
+ /**
158
+ * Task description
159
+ */
160
+ description?: string;
161
+
162
+ /**
163
+ * Task status
164
+ */
165
+ status?: 'pending' | 'in_progress' | 'completed' | 'cancelled';
166
+
167
+ /**
168
+ * Task priority level
169
+ */
170
+ priority?: 'low' | 'medium' | 'high';
171
+
172
+ /**
173
+ * Optional due date as ISO string
174
+ */
175
+ dueDate?: string;
176
+
177
+ /**
178
+ * Arbitrary metadata key-value pairs
179
+ */
180
+ metadata?: Record<string, unknown>;
181
+
182
+ /**
183
+ * Parent task ID for hierarchical tasks
184
+ */
185
+ parentId?: string;
186
+
187
+ /**
188
+ * Source system identifier for external task tracking
189
+ */
190
+ sourceId?: string;
191
+
192
+ /**
193
+ * Additional contextual data
194
+ */
195
+ context?: Record<string, unknown>;
196
+
197
+ /**
198
+ * Owner type
199
+ */
200
+ ownerType?: 'user' | 'agent';
201
+
202
+ /**
203
+ * Owner identifier
204
+ */
205
+ ownerId?: string;
206
+ }
207
+
208
+ /**
209
+ * Task list filter criteria
210
+ */
211
+ export interface TaskListFilter {
212
+ /**
213
+ * Tenant identifier (required)
214
+ */
215
+ tenantId: string;
216
+
217
+ /**
218
+ * Filter by owner type
219
+ */
220
+ ownerType?: 'user' | 'agent';
221
+
222
+ /**
223
+ * Filter by owner ID
224
+ */
225
+ ownerId?: string;
226
+
227
+ /**
228
+ * Filter by task status
229
+ */
230
+ status?: string;
231
+
232
+ /**
233
+ * Filter by priority level
234
+ */
235
+ priority?: string;
236
+
237
+ /**
238
+ * Filter by parent task ID
239
+ */
240
+ parentId?: string;
241
+
242
+ /**
243
+ * Filter by source system ID
244
+ */
245
+ sourceId?: string;
246
+
247
+ /**
248
+ * Filter by metadata key-value pairs
249
+ */
250
+ metadata?: Record<string, unknown>;
251
+
252
+ /**
253
+ * Maximum number of results to return
254
+ */
255
+ limit?: number;
256
+
257
+ /**
258
+ * Number of results to skip for pagination
259
+ */
260
+ offset?: number;
261
+ }
262
+
263
+ /**
264
+ * TaskStore interface
265
+ * Provides CRUD operations for task data
266
+ */
267
+ export interface TaskStore {
268
+ /**
269
+ * Create a new task
270
+ * @param params Task creation data including tenant, ownerType ('user' | 'agent'), and owner info
271
+ * @returns Created task
272
+ */
273
+ create(params: CreateTaskRequest & { tenantId: string; ownerType: string; ownerId: string }): Promise<TaskItem>;
274
+
275
+ /**
276
+ * Get a task by ID
277
+ * @param tenantId Tenant identifier
278
+ * @param id Task identifier
279
+ * @returns Task if found, null otherwise
280
+ */
281
+ getById(tenantId: string, id: string): Promise<TaskItem | null>;
282
+
283
+ /**
284
+ * List tasks matching the given filter
285
+ * @param filter Filter criteria
286
+ * @returns Array of matching tasks
287
+ */
288
+ list(filter: TaskListFilter): Promise<TaskItem[]>;
289
+
290
+ /**
291
+ * Update an existing task
292
+ * @param tenantId Tenant identifier
293
+ * @param id Task identifier
294
+ * @param updates Partial task data to update
295
+ * @returns Updated task if found, null otherwise
296
+ */
297
+ update(tenantId: string, id: string, updates: UpdateTaskRequest): Promise<TaskItem | null>;
298
+
299
+ /**
300
+ * Delete a task by ID
301
+ * @param tenantId Tenant identifier
302
+ * @param id Task identifier
303
+ * @returns true if deleted, false otherwise
304
+ */
305
+ delete(tenantId: string, id: string): Promise<boolean>;
306
+ }