@longzai-intelligence-collaboration/core 0.0.1
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/README.md +53 -0
- package/dist/index.d.ts +276 -0
- package/dist/index.js +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @longzai-intelligence-collaboration/core
|
|
2
|
+
|
|
3
|
+
collaboration 项目跨域共享的基础层,集中提供六大业务域共用的类型定义与 Zod 校验 Schema。
|
|
4
|
+
|
|
5
|
+
## 定位
|
|
6
|
+
|
|
7
|
+
作为 collaboration 工作区的基础设施包,core 不承载业务逻辑,只向 domains、apps、sdk、elysia 等子包输出统一的类型与 Schema,是其他子包依赖的最底层共享件。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun add @longzai-intelligence-collaboration/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 核心能力
|
|
16
|
+
|
|
17
|
+
提供跨域共享的类型定义(含会话、房间、消息、协作、Agent、Agent 任务等领域的公共类型)与对应的 Zod 校验 Schema,确保各业务包在类型与校验层面保持一致。
|
|
18
|
+
|
|
19
|
+
### 领域枚举 Schema 与类型
|
|
20
|
+
|
|
21
|
+
基于 Zod v4 `z.enum()` 定义枚举 Schema,类型经 `z.infer` 推导,运行时校验与编译期类型一一对应,按业务域分组:
|
|
22
|
+
|
|
23
|
+
- Agent 域:`AgentType`、`AgentStatus`、`AgentPermission`、`AgentTaskStatus`、`AgentTaskPriority`、`AgentTaskType`
|
|
24
|
+
- 房间域:`RoomType`、`RoomVisibility`、`RoomStatus`
|
|
25
|
+
- 会话域:`SessionRole`、`SessionStatus`、`SessionParticipantType`
|
|
26
|
+
- 消息域:`MessageType`、`MessageSenderType`
|
|
27
|
+
- 协作域:`OperationType`、`ConflictResolutionStrategy`、`SyncStrategy`
|
|
28
|
+
|
|
29
|
+
每个类型均有同名 `*Schema` 对应(如 `AgentStatus` ↔ `AgentStatusSchema`)。
|
|
30
|
+
|
|
31
|
+
### 分页 Schema
|
|
32
|
+
|
|
33
|
+
- `PaginationParams`:通用分页查询参数(`page` 从 1 起、`pageSize` 上限 100,均可选)
|
|
34
|
+
- `PaginatedResult`:通用分页结果(`items`、`total`、`page`、`pageSize`、`totalPages`)
|
|
35
|
+
|
|
36
|
+
## 快速上手
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import {
|
|
40
|
+
AgentStatusSchema,
|
|
41
|
+
PaginationParamsSchema,
|
|
42
|
+
type AgentStatus,
|
|
43
|
+
} from '@longzai-intelligence-collaboration/core';
|
|
44
|
+
|
|
45
|
+
const status: AgentStatus = 'connected';
|
|
46
|
+
AgentStatusSchema.parse(status); // 校验通过
|
|
47
|
+
|
|
48
|
+
const params = PaginationParamsSchema.parse({ page: 1, pageSize: 20 });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 实现情况
|
|
52
|
+
|
|
53
|
+
已实现,作为纯类型与 Schema 包提供完整导出,按项目约定跳过单元测试,被 sdk、elysia、memory、apps 等多包依赖。
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/types/enums.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Agent 类型 Schema
|
|
5
|
+
* 定义 Agent 的分类类型
|
|
6
|
+
*/
|
|
7
|
+
declare const AgentTypeSchema: z.ZodEnum<{
|
|
8
|
+
analysis: "analysis";
|
|
9
|
+
assistant: "assistant";
|
|
10
|
+
automation: "automation";
|
|
11
|
+
custom: "custom";
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Agent 类型
|
|
15
|
+
*/
|
|
16
|
+
type AgentType = z.infer<typeof AgentTypeSchema>;
|
|
17
|
+
/**
|
|
18
|
+
* Agent 状态 Schema
|
|
19
|
+
* 定义 Agent 的连接与运行状态
|
|
20
|
+
*/
|
|
21
|
+
declare const AgentStatusSchema: z.ZodEnum<{
|
|
22
|
+
connected: "connected";
|
|
23
|
+
disconnected: "disconnected";
|
|
24
|
+
error: "error";
|
|
25
|
+
registered: "registered";
|
|
26
|
+
suspended: "suspended";
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Agent 状态
|
|
30
|
+
*/
|
|
31
|
+
type AgentStatus = z.infer<typeof AgentStatusSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* Agent 权限级别 Schema
|
|
34
|
+
* 定义 Agent 的操作权限等级
|
|
35
|
+
*/
|
|
36
|
+
declare const AgentPermissionSchema: z.ZodEnum<{
|
|
37
|
+
full: "full";
|
|
38
|
+
read_only: "read_only";
|
|
39
|
+
read_write: "read_write";
|
|
40
|
+
restricted: "restricted";
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Agent 权限级别
|
|
44
|
+
*/
|
|
45
|
+
type AgentPermission = z.infer<typeof AgentPermissionSchema>;
|
|
46
|
+
/**
|
|
47
|
+
* Agent 任务状态 Schema
|
|
48
|
+
* 定义 Agent 任务的生命周期状态
|
|
49
|
+
*/
|
|
50
|
+
declare const AgentTaskStatusSchema: z.ZodEnum<{
|
|
51
|
+
assigned: "assigned";
|
|
52
|
+
cancelled: "cancelled";
|
|
53
|
+
completed: "completed";
|
|
54
|
+
executing: "executing";
|
|
55
|
+
failed: "failed";
|
|
56
|
+
pending: "pending";
|
|
57
|
+
timeout: "timeout";
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Agent 任务状态
|
|
61
|
+
*/
|
|
62
|
+
type AgentTaskStatus = z.infer<typeof AgentTaskStatusSchema>;
|
|
63
|
+
/**
|
|
64
|
+
* Agent 任务优先级 Schema
|
|
65
|
+
* 定义 Agent 任务的优先级等级
|
|
66
|
+
*/
|
|
67
|
+
declare const AgentTaskPrioritySchema: z.ZodEnum<{
|
|
68
|
+
high: "high";
|
|
69
|
+
low: "low";
|
|
70
|
+
medium: "medium";
|
|
71
|
+
urgent: "urgent";
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Agent 任务优先级
|
|
75
|
+
*/
|
|
76
|
+
type AgentTaskPriority = z.infer<typeof AgentTaskPrioritySchema>;
|
|
77
|
+
/**
|
|
78
|
+
* Agent 任务类型 Schema
|
|
79
|
+
* 定义 Agent 可执行的任务类型
|
|
80
|
+
*/
|
|
81
|
+
declare const AgentTaskTypeSchema: z.ZodEnum<{
|
|
82
|
+
analysis: "analysis";
|
|
83
|
+
automation: "automation";
|
|
84
|
+
custom: "custom";
|
|
85
|
+
document_edit: "document_edit";
|
|
86
|
+
message_send: "message_send";
|
|
87
|
+
whiteboard_draw: "whiteboard_draw";
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Agent 任务类型
|
|
91
|
+
*/
|
|
92
|
+
type AgentTaskType = z.infer<typeof AgentTaskTypeSchema>;
|
|
93
|
+
/**
|
|
94
|
+
* 房间类型 Schema
|
|
95
|
+
* 定义协作房间的类型分类
|
|
96
|
+
*/
|
|
97
|
+
declare const RoomTypeSchema: z.ZodEnum<{
|
|
98
|
+
custom: "custom";
|
|
99
|
+
document: "document";
|
|
100
|
+
webpage: "webpage";
|
|
101
|
+
whiteboard: "whiteboard";
|
|
102
|
+
}>;
|
|
103
|
+
/**
|
|
104
|
+
* 房间类型
|
|
105
|
+
*/
|
|
106
|
+
type RoomType = z.infer<typeof RoomTypeSchema>;
|
|
107
|
+
/**
|
|
108
|
+
* 房间可见性 Schema
|
|
109
|
+
* 定义房间的访问可见性级别
|
|
110
|
+
*/
|
|
111
|
+
declare const RoomVisibilitySchema: z.ZodEnum<{
|
|
112
|
+
invite_only: "invite_only";
|
|
113
|
+
private: "private";
|
|
114
|
+
public: "public";
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* 房间可见性
|
|
118
|
+
*/
|
|
119
|
+
type RoomVisibility = z.infer<typeof RoomVisibilitySchema>;
|
|
120
|
+
/**
|
|
121
|
+
* 房间状态 Schema
|
|
122
|
+
* 定义房间的生命周期状态
|
|
123
|
+
*/
|
|
124
|
+
declare const RoomStatusSchema: z.ZodEnum<{
|
|
125
|
+
active: "active";
|
|
126
|
+
archived: "archived";
|
|
127
|
+
closed: "closed";
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* 房间状态
|
|
131
|
+
*/
|
|
132
|
+
type RoomStatus = z.infer<typeof RoomStatusSchema>;
|
|
133
|
+
/**
|
|
134
|
+
* 会话角色 Schema
|
|
135
|
+
* 定义会话参与者的角色等级
|
|
136
|
+
*/
|
|
137
|
+
declare const SessionRoleSchema: z.ZodEnum<{
|
|
138
|
+
admin: "admin";
|
|
139
|
+
editor: "editor";
|
|
140
|
+
owner: "owner";
|
|
141
|
+
viewer: "viewer";
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* 会话角色
|
|
145
|
+
*/
|
|
146
|
+
type SessionRole = z.infer<typeof SessionRoleSchema>;
|
|
147
|
+
/**
|
|
148
|
+
* 会话状态 Schema
|
|
149
|
+
* 定义会话的连接状态
|
|
150
|
+
*/
|
|
151
|
+
declare const SessionStatusSchema: z.ZodEnum<{
|
|
152
|
+
connected: "connected";
|
|
153
|
+
disconnected: "disconnected";
|
|
154
|
+
reconnecting: "reconnecting";
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* 会话状态
|
|
158
|
+
*/
|
|
159
|
+
type SessionStatus = z.infer<typeof SessionStatusSchema>;
|
|
160
|
+
/**
|
|
161
|
+
* 会话参与者类型 Schema
|
|
162
|
+
* 区分用户和 Agent 两种参与者
|
|
163
|
+
*/
|
|
164
|
+
declare const SessionParticipantTypeSchema: z.ZodEnum<{
|
|
165
|
+
agent: "agent";
|
|
166
|
+
user: "user";
|
|
167
|
+
}>;
|
|
168
|
+
/**
|
|
169
|
+
* 会话参与者类型
|
|
170
|
+
*/
|
|
171
|
+
type SessionParticipantType = z.infer<typeof SessionParticipantTypeSchema>;
|
|
172
|
+
/**
|
|
173
|
+
* 消息类型 Schema
|
|
174
|
+
* 定义消息的分类类型
|
|
175
|
+
*/
|
|
176
|
+
declare const MessageTypeSchema: z.ZodEnum<{
|
|
177
|
+
agent_notification: "agent_notification";
|
|
178
|
+
agent_request: "agent_request";
|
|
179
|
+
agent_response: "agent_response";
|
|
180
|
+
chat: "chat";
|
|
181
|
+
notification: "notification";
|
|
182
|
+
operation: "operation";
|
|
183
|
+
sync: "sync";
|
|
184
|
+
system: "system";
|
|
185
|
+
}>;
|
|
186
|
+
/**
|
|
187
|
+
* 消息类型
|
|
188
|
+
*/
|
|
189
|
+
type MessageType = z.infer<typeof MessageTypeSchema>;
|
|
190
|
+
/**
|
|
191
|
+
* 消息发送者类型 Schema
|
|
192
|
+
* 区分消息发送者的来源类型
|
|
193
|
+
*/
|
|
194
|
+
declare const MessageSenderTypeSchema: z.ZodEnum<{
|
|
195
|
+
agent: "agent";
|
|
196
|
+
system: "system";
|
|
197
|
+
user: "user";
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* 消息发送者类型
|
|
201
|
+
*/
|
|
202
|
+
type MessageSenderType = z.infer<typeof MessageSenderTypeSchema>;
|
|
203
|
+
/**
|
|
204
|
+
* 操作类型 Schema
|
|
205
|
+
* 定义协作操作的基本类型
|
|
206
|
+
*/
|
|
207
|
+
declare const OperationTypeSchema: z.ZodEnum<{
|
|
208
|
+
delete: "delete";
|
|
209
|
+
insert: "insert";
|
|
210
|
+
move: "move";
|
|
211
|
+
transform: "transform";
|
|
212
|
+
update: "update";
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* 操作类型
|
|
216
|
+
*/
|
|
217
|
+
type OperationType = z.infer<typeof OperationTypeSchema>;
|
|
218
|
+
/**
|
|
219
|
+
* 冲突解决策略 Schema
|
|
220
|
+
* 定义协作冲突的解决方式
|
|
221
|
+
*/
|
|
222
|
+
declare const ConflictResolutionStrategySchema: z.ZodEnum<{
|
|
223
|
+
lww: "lww";
|
|
224
|
+
merge: "merge";
|
|
225
|
+
ot: "ot";
|
|
226
|
+
}>;
|
|
227
|
+
/**
|
|
228
|
+
* 冲突解决策略
|
|
229
|
+
*/
|
|
230
|
+
type ConflictResolutionStrategy = z.infer<typeof ConflictResolutionStrategySchema>;
|
|
231
|
+
/**
|
|
232
|
+
* 同步策略 Schema
|
|
233
|
+
* 定义协作数据的同步方式
|
|
234
|
+
*/
|
|
235
|
+
declare const SyncStrategySchema: z.ZodEnum<{
|
|
236
|
+
manual: "manual";
|
|
237
|
+
periodic: "periodic";
|
|
238
|
+
realtime: "realtime";
|
|
239
|
+
}>;
|
|
240
|
+
/**
|
|
241
|
+
* 同步策略
|
|
242
|
+
*/
|
|
243
|
+
type SyncStrategy = z.infer<typeof SyncStrategySchema>;
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/schemas/pagination.schema.d.ts
|
|
246
|
+
/**
|
|
247
|
+
* 分页参数 Schema
|
|
248
|
+
* 定义通用的分页查询参数
|
|
249
|
+
*/
|
|
250
|
+
declare const PaginationParamsSchema: z.ZodObject<{
|
|
251
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
252
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
253
|
+
}, z.core.$strip>;
|
|
254
|
+
/**
|
|
255
|
+
* 分页参数类型
|
|
256
|
+
*/
|
|
257
|
+
type PaginationParams = z.infer<typeof PaginationParamsSchema>;
|
|
258
|
+
/**
|
|
259
|
+
* 分页结果 Schema
|
|
260
|
+
* 包装分页查询的返回数据
|
|
261
|
+
*
|
|
262
|
+
* @template T - 数据项的 Zod Schema 类型
|
|
263
|
+
*/
|
|
264
|
+
declare const PaginatedResultSchema: z.ZodObject<{
|
|
265
|
+
items: z.ZodArray<z.ZodUnknown>;
|
|
266
|
+
total: z.ZodNumber;
|
|
267
|
+
page: z.ZodNumber;
|
|
268
|
+
pageSize: z.ZodNumber;
|
|
269
|
+
totalPages: z.ZodNumber;
|
|
270
|
+
}, z.core.$strip>;
|
|
271
|
+
/**
|
|
272
|
+
* 分页结果类型
|
|
273
|
+
*/
|
|
274
|
+
type PaginatedResult = z.infer<typeof PaginatedResultSchema>;
|
|
275
|
+
//#endregion
|
|
276
|
+
export { type AgentPermission, AgentPermissionSchema, type AgentStatus, AgentStatusSchema, type AgentTaskPriority, AgentTaskPrioritySchema, type AgentTaskStatus, AgentTaskStatusSchema, type AgentTaskType, AgentTaskTypeSchema, type AgentType, AgentTypeSchema, type ConflictResolutionStrategy, ConflictResolutionStrategySchema, type MessageSenderType, MessageSenderTypeSchema, type MessageType, MessageTypeSchema, type OperationType, OperationTypeSchema, type PaginatedResult, PaginatedResultSchema, type PaginationParams, PaginationParamsSchema, type RoomStatus, RoomStatusSchema, type RoomType, RoomTypeSchema, type RoomVisibility, RoomVisibilitySchema, type SessionParticipantType, SessionParticipantTypeSchema, type SessionRole, SessionRoleSchema, type SessionStatus, SessionStatusSchema, type SyncStrategy, SyncStrategySchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod";const t=e.enum([`assistant`,`automation`,`analysis`,`custom`]),n=e.enum([`registered`,`connected`,`disconnected`,`suspended`,`error`]),r=e.enum([`full`,`read_write`,`read_only`,`restricted`]),i=e.enum([`pending`,`assigned`,`executing`,`completed`,`failed`,`cancelled`,`timeout`]),a=e.enum([`low`,`medium`,`high`,`urgent`]),o=e.enum([`document_edit`,`whiteboard_draw`,`message_send`,`analysis`,`automation`,`custom`]),s=e.enum([`whiteboard`,`document`,`webpage`,`custom`]),c=e.enum([`public`,`private`,`invite_only`]),l=e.enum([`active`,`archived`,`closed`]),u=e.enum([`owner`,`admin`,`editor`,`viewer`]),d=e.enum([`connected`,`disconnected`,`reconnecting`]),f=e.enum([`user`,`agent`]),p=e.enum([`operation`,`chat`,`notification`,`system`,`sync`,`agent_request`,`agent_response`,`agent_notification`]),m=e.enum([`user`,`agent`,`system`]),h=e.enum([`insert`,`delete`,`update`,`move`,`transform`]),g=e.enum([`lww`,`ot`,`merge`]),_=e.enum([`realtime`,`periodic`,`manual`]),v=e.object({page:e.number().int().min(1).optional(),pageSize:e.number().int().min(1).max(100).optional()}),y=e.object({items:e.array(e.unknown()),total:e.number().int().min(0),page:e.number().int().min(1),pageSize:e.number().int().min(1),totalPages:e.number().int().min(0)});export{r as AgentPermissionSchema,n as AgentStatusSchema,a as AgentTaskPrioritySchema,i as AgentTaskStatusSchema,o as AgentTaskTypeSchema,t as AgentTypeSchema,g as ConflictResolutionStrategySchema,m as MessageSenderTypeSchema,p as MessageTypeSchema,h as OperationTypeSchema,y as PaginatedResultSchema,v as PaginationParamsSchema,l as RoomStatusSchema,s as RoomTypeSchema,c as RoomVisibilitySchema,f as SessionParticipantTypeSchema,u as SessionRoleSchema,d as SessionStatusSchema,_ as SyncStrategySchema};
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-collaboration/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"bun": "./src/index.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "lzi-builder",
|
|
21
|
+
"build:prod": "NODE_ENV=production bun run build",
|
|
22
|
+
"prepublishOnly": "bun run build:prod",
|
|
23
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
24
|
+
"typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
|
|
25
|
+
"typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
|
|
26
|
+
"typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
|
|
27
|
+
"lint": "oxlint && oxfmt --check",
|
|
28
|
+
"lint:fix": "oxlint --fix && oxfmt",
|
|
29
|
+
"test": "lzi-bun-cli test",
|
|
30
|
+
"test:watch": "lzi-bun-cli test --watch",
|
|
31
|
+
"test:coverage": "lzi-bun-cli test --coverage",
|
|
32
|
+
"clean": "lzi-dev-cli clean"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@longzai-intelligence-shared-kernel/core": "^0.1.4",
|
|
36
|
+
"zod": "^4.4.3"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {}
|
|
39
|
+
}
|