@axiom-lattice/protocols 2.1.42 → 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/.eslintrc.json +22 -0
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +447 -95
- package/dist/index.d.ts +447 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/AgentLatticeProtocol.ts +8 -9
- package/src/AssistantStoreProtocol.ts +19 -0
- package/src/ChannelAdapterProtocol.ts +20 -0
- package/src/ChannelInstallationStoreProtocol.ts +8 -0
- package/src/InternalDSL.ts +11 -21
- package/src/MenuProtocol.ts +70 -0
- package/src/MessageProtocol.ts +1 -1
- package/src/SkillStoreProtocol.ts +1 -1
- package/src/TaskStoreProtocol.ts +306 -0
- package/src/UILatticeProtocol.ts +4 -4
- package/src/WorkflowDSL.ts +53 -328
- package/src/WorkflowTrackingStoreProtocol.ts +4 -1
- package/src/index.ts +2 -0
|
@@ -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,
|
package/src/InternalDSL.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal DSL — expanded intermediate representation.
|
|
3
3
|
*
|
|
4
|
-
* Generated by the
|
|
5
|
-
* Not part of the public API
|
|
4
|
+
* Generated by parseYaml() from the YAML workflow DSL. Consumed by compileWorkflow.
|
|
5
|
+
* Not part of the public API.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
// ─── Top-level ─────────────────────────────────────────────────────────────
|
|
@@ -32,14 +32,13 @@ export interface InternalStateField {
|
|
|
32
32
|
|
|
33
33
|
export type InternalNode =
|
|
34
34
|
| InternalAgentNode
|
|
35
|
-
| InternalHumanFeedbackNode
|
|
36
35
|
| InternalMapNode
|
|
37
36
|
| InternalTerminalNode
|
|
38
37
|
| InternalInputNode;
|
|
39
38
|
|
|
40
39
|
export interface InternalBaseNode {
|
|
41
40
|
id: string;
|
|
42
|
-
type: "agent" | "
|
|
41
|
+
type: "agent" | "map" | "terminal" | "input";
|
|
43
42
|
name: string;
|
|
44
43
|
description?: string;
|
|
45
44
|
config?: InternalNodeConfig;
|
|
@@ -50,19 +49,20 @@ export interface InternalBaseNode {
|
|
|
50
49
|
export interface InternalAgentNode extends InternalBaseNode {
|
|
51
50
|
type: "agent";
|
|
52
51
|
ref?: string;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
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;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
export interface InternalMapNode extends InternalBaseNode {
|
|
63
61
|
type: "map";
|
|
64
62
|
source: string;
|
|
65
63
|
itemKey?: string;
|
|
64
|
+
/** Runtime condition expression evaluated as JS. Map skipped when false. */
|
|
65
|
+
condition?: string;
|
|
66
66
|
config?: InternalNodeConfig & {
|
|
67
67
|
batchSize?: number;
|
|
68
68
|
maxConcurrency?: number;
|
|
@@ -106,16 +106,6 @@ export interface InternalOutput {
|
|
|
106
106
|
export interface InternalEdge {
|
|
107
107
|
from: string;
|
|
108
108
|
to?: string | string[];
|
|
109
|
-
type?: "normal" | "conditional";
|
|
110
|
-
name?: string;
|
|
111
|
-
rule?: InternalEdgeRule;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface InternalEdgeRule {
|
|
115
|
-
type: "state_field" | "expression";
|
|
116
|
-
field?: string;
|
|
117
|
-
code?: string;
|
|
118
|
-
mapping: Record<string, string>;
|
|
119
109
|
}
|
|
120
110
|
|
|
121
111
|
// ─── Node Config ───────────────────────────────────────────────────────────
|
|
@@ -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
|
+
}
|
package/src/MessageProtocol.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/UILatticeProtocol.ts
CHANGED
|
@@ -39,8 +39,8 @@ export interface UIConfig {
|
|
|
39
39
|
*/
|
|
40
40
|
export interface UIComponent<T = any> {
|
|
41
41
|
render: (props?: any) => T;
|
|
42
|
-
addEventListener: (event: string, handler:
|
|
43
|
-
removeEventListener: (event: string, handler:
|
|
42
|
+
addEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
43
|
+
removeEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -52,6 +52,6 @@ export interface UILatticeProtocol<T = any>
|
|
|
52
52
|
render: (props?: any) => T;
|
|
53
53
|
|
|
54
54
|
// 事件处理
|
|
55
|
-
addEventListener: (event: string, handler:
|
|
56
|
-
removeEventListener: (event: string, handler:
|
|
55
|
+
addEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
56
|
+
removeEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
|
|
57
57
|
}
|