@longzai-intelligence-agent-ui-render/core 0.0.0-stage → 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 +11 -2
- package/dist/index.d.ts +220 -0
- package/dist/index.js +1 -0
- package/dist/rolldown-runtime-BqT_7tdF.js +1 -0
- package/package.json +47 -4
package/README.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @longzai-intelligence-agent-ui-render/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
渲染协议核心包。承载 json-render 策略的私有载荷协议即 Spec 扁平树、SpecStream 补丁与 Catalog 白名单的类型与 zod schema,自 agent-ui 仓 `packages/core` 渲染协议面迁入,运行时依赖仅 `zod`。
|
|
4
|
+
|
|
5
|
+
## 导出面
|
|
6
|
+
|
|
7
|
+
- 类型:`SpecElement`、`Spec`、`SpecStreamPatch`、`CatalogEntry`、`ActionDefinition`、`ValidatorDefinition`、`Catalog`
|
|
8
|
+
- schema:`SpecElementSchema`、`SpecSchema`、`SpecStreamPatchSchema`、`CatalogEntrySchema`、`ActionDefinitionSchema`、`ValidatorDefinitionSchema`、`CatalogSchema`
|
|
9
|
+
|
|
10
|
+
## 契约边界
|
|
11
|
+
|
|
12
|
+
Spec 为扁平元素表加根元素引用加可选初始状态,补丁经类 JSON 指针路径描述单次变更。协议为 `json-render-spec` 策略私有面,跨策略公共面归装载容器仓的中立载荷模型。
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import "./rolldown-runtime-BqT_7tdF.js";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* json-render 策略载荷协议类型
|
|
5
|
+
*
|
|
6
|
+
* Spec 扁平元素树、SpecStream 补丁与 Catalog 组件白名单,构成 `json-render-spec`
|
|
7
|
+
* 策略的私有载荷协议面,自 agent-ui 仓 `packages/core` 渲染协议面迁入
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Spec 扁平树中的单个元素
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* 元素以 id 互引,父子关系经 `children` 标识列表表达
|
|
14
|
+
*/
|
|
15
|
+
type SpecElement = {
|
|
16
|
+
/**
|
|
17
|
+
* 元素唯一标识
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
/**
|
|
21
|
+
* 组件类型名,按 Catalog 解析
|
|
22
|
+
*/
|
|
23
|
+
type: string;
|
|
24
|
+
/**
|
|
25
|
+
* 元素 props 即以 prop 名为键
|
|
26
|
+
*/
|
|
27
|
+
props?: Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* 子元素标识的有序列表
|
|
30
|
+
*/
|
|
31
|
+
children?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* 可见性表达式或字面量
|
|
34
|
+
*/
|
|
35
|
+
visible?: unknown;
|
|
36
|
+
/**
|
|
37
|
+
* 响应状态变迁的 watch 绑定
|
|
38
|
+
*/
|
|
39
|
+
watch?: Record<string, unknown>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 完整 Spec 树
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* 扁平元素表加根元素引用加可选初始状态快照
|
|
46
|
+
*/
|
|
47
|
+
type Spec = {
|
|
48
|
+
/**
|
|
49
|
+
* 根元素标识
|
|
50
|
+
*/
|
|
51
|
+
root: string;
|
|
52
|
+
/**
|
|
53
|
+
* 元素标识到元素定义的扁平映射
|
|
54
|
+
*/
|
|
55
|
+
elements: Record<string, SpecElement>;
|
|
56
|
+
/**
|
|
57
|
+
* 可选初始状态值
|
|
58
|
+
*/
|
|
59
|
+
state?: Record<string, unknown>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 流式 Spec 更新的单条补丁
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* 每条补丁经类 JSON 指针路径描述对 Spec 树的一次变更
|
|
66
|
+
*/
|
|
67
|
+
type SpecStreamPatch = {
|
|
68
|
+
/**
|
|
69
|
+
* 变更操作类型
|
|
70
|
+
*/
|
|
71
|
+
op: 'add' | 'update' | 'remove' | 'replace';
|
|
72
|
+
/**
|
|
73
|
+
* 类 JSON 指针路径
|
|
74
|
+
*/
|
|
75
|
+
path: string;
|
|
76
|
+
/**
|
|
77
|
+
* 补丁载荷值
|
|
78
|
+
*/
|
|
79
|
+
value: unknown;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Catalog 组件白名单条目
|
|
83
|
+
*/
|
|
84
|
+
type CatalogEntry = {
|
|
85
|
+
/**
|
|
86
|
+
* 组件名,与 Registry 键一致
|
|
87
|
+
*/
|
|
88
|
+
name: string;
|
|
89
|
+
/**
|
|
90
|
+
* 组件的 props 契约
|
|
91
|
+
*/
|
|
92
|
+
props?: Record<string, unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* 组件暴露的具名插槽列表
|
|
95
|
+
*/
|
|
96
|
+
slots?: string[];
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Catalog 暴露的动作定义
|
|
100
|
+
*/
|
|
101
|
+
type ActionDefinition = {
|
|
102
|
+
/**
|
|
103
|
+
* 动作名,用于触发动作
|
|
104
|
+
*/
|
|
105
|
+
name: string;
|
|
106
|
+
/**
|
|
107
|
+
* 动作参数契约
|
|
108
|
+
*/
|
|
109
|
+
params?: Record<string, unknown>;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Catalog 暴露的校验器定义
|
|
113
|
+
*/
|
|
114
|
+
type ValidatorDefinition = {
|
|
115
|
+
/**
|
|
116
|
+
* 校验器名,用于引用校验器
|
|
117
|
+
*/
|
|
118
|
+
name: string;
|
|
119
|
+
/**
|
|
120
|
+
* 校验器函数引用,运行时绑定
|
|
121
|
+
*/
|
|
122
|
+
fn?: unknown;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Catalog 即生成与渲染管线可用的组件、动作与校验器白名单
|
|
126
|
+
*/
|
|
127
|
+
type Catalog = {
|
|
128
|
+
/**
|
|
129
|
+
* 组件名到目录条目的映射
|
|
130
|
+
*/
|
|
131
|
+
components: Record<string, CatalogEntry>;
|
|
132
|
+
/**
|
|
133
|
+
* 动作名到动作定义的映射
|
|
134
|
+
*/
|
|
135
|
+
actions?: Record<string, ActionDefinition>;
|
|
136
|
+
/**
|
|
137
|
+
* 校验器名到校验器定义的映射
|
|
138
|
+
*/
|
|
139
|
+
validators?: Record<string, ValidatorDefinition>;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* 单个 Spec 元素 schema
|
|
143
|
+
*/
|
|
144
|
+
declare const SpecElementSchema: z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
type: z.ZodString;
|
|
147
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
148
|
+
children: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
149
|
+
visible: z.ZodOptional<z.ZodUnknown>;
|
|
150
|
+
watch: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
/**
|
|
153
|
+
* 完整 Spec 树 schema
|
|
154
|
+
*/
|
|
155
|
+
declare const SpecSchema: z.ZodObject<{
|
|
156
|
+
root: z.ZodString;
|
|
157
|
+
elements: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
158
|
+
id: z.ZodString;
|
|
159
|
+
type: z.ZodString;
|
|
160
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
161
|
+
children: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
162
|
+
visible: z.ZodOptional<z.ZodUnknown>;
|
|
163
|
+
watch: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
164
|
+
}, z.core.$strip>>;
|
|
165
|
+
state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
/**
|
|
168
|
+
* 流式 Spec 补丁 schema
|
|
169
|
+
*/
|
|
170
|
+
declare const SpecStreamPatchSchema: z.ZodObject<{
|
|
171
|
+
op: z.ZodEnum<{
|
|
172
|
+
add: "add";
|
|
173
|
+
remove: "remove";
|
|
174
|
+
replace: "replace";
|
|
175
|
+
update: "update";
|
|
176
|
+
}>;
|
|
177
|
+
path: z.ZodString;
|
|
178
|
+
value: z.ZodUnknown;
|
|
179
|
+
}, z.core.$strip>;
|
|
180
|
+
/**
|
|
181
|
+
* Catalog 组件条目 schema
|
|
182
|
+
*/
|
|
183
|
+
declare const CatalogEntrySchema: z.ZodObject<{
|
|
184
|
+
name: z.ZodString;
|
|
185
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
186
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
/**
|
|
189
|
+
* Catalog 动作定义 schema
|
|
190
|
+
*/
|
|
191
|
+
declare const ActionDefinitionSchema: z.ZodObject<{
|
|
192
|
+
name: z.ZodString;
|
|
193
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
194
|
+
}, z.core.$strip>;
|
|
195
|
+
/**
|
|
196
|
+
* Catalog 校验器定义 schema
|
|
197
|
+
*/
|
|
198
|
+
declare const ValidatorDefinitionSchema: z.ZodObject<{
|
|
199
|
+
name: z.ZodString;
|
|
200
|
+
fn: z.ZodOptional<z.ZodUnknown>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
/**
|
|
203
|
+
* Catalog 白名单 schema
|
|
204
|
+
*/
|
|
205
|
+
declare const CatalogSchema: z.ZodObject<{
|
|
206
|
+
components: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
207
|
+
name: z.ZodString;
|
|
208
|
+
props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
209
|
+
slots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
210
|
+
}, z.core.$strip>>;
|
|
211
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
212
|
+
name: z.ZodString;
|
|
213
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
214
|
+
}, z.core.$strip>>>;
|
|
215
|
+
validators: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
216
|
+
name: z.ZodString;
|
|
217
|
+
fn: z.ZodOptional<z.ZodUnknown>;
|
|
218
|
+
}, z.core.$strip>>>;
|
|
219
|
+
}, z.core.$strip>;
|
|
220
|
+
export { ActionDefinition, ActionDefinitionSchema, Catalog, CatalogEntry, CatalogEntrySchema, CatalogSchema, Spec, SpecElement, SpecElementSchema, SpecSchema, SpecStreamPatch, SpecStreamPatchSchema, ValidatorDefinition, ValidatorDefinitionSchema };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import*as e from"zod";const t=e.object({id:e.string(),type:e.string(),props:e.record(e.string(),e.unknown()).optional(),children:e.array(e.string()).optional(),visible:e.unknown().optional(),watch:e.record(e.string(),e.unknown()).optional()}),n=e.object({root:e.string(),elements:e.record(e.string(),t),state:e.record(e.string(),e.unknown()).optional()}),r=e.object({op:e.enum([`add`,`update`,`remove`,`replace`]),path:e.string(),value:e.unknown()}),i=e.object({name:e.string(),props:e.record(e.string(),e.unknown()).optional(),slots:e.array(e.string()).optional()}),a=e.object({name:e.string(),params:e.record(e.string(),e.unknown()).optional()}),o=e.object({name:e.string(),fn:e.unknown().optional()}),s=e.object({components:e.record(e.string(),i),actions:e.record(e.string(),a).optional(),validators:e.record(e.string(),o).optional()});export{a as ActionDefinitionSchema,i as CatalogEntrySchema,s as CatalogSchema,t as SpecElementSchema,n as SpecSchema,r as SpecStreamPatchSchema,o as ValidatorDefinitionSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:module";export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-agent-ui-render/core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Longzai Intelligence Agent UI 渲染协议核心包",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agent-ui",
|
|
7
|
+
"core",
|
|
8
|
+
"longzai-intelligence",
|
|
9
|
+
"protocol",
|
|
10
|
+
"spec",
|
|
11
|
+
"zod"
|
|
12
|
+
],
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "lzi-builder",
|
|
26
|
+
"build:prod": "NODE_ENV=production bun run build",
|
|
27
|
+
"prepublishOnly": "bun run build:prod",
|
|
28
|
+
"dev": "lzi-builder --watch",
|
|
29
|
+
"clean": "lzi-dev-tools clean",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest",
|
|
32
|
+
"test:coverage": "vitest run --coverage",
|
|
33
|
+
"lint": "lzi-lint lint",
|
|
34
|
+
"lint:fix": "lzi-lint fix",
|
|
35
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
36
|
+
"typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
|
|
37
|
+
"typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
|
|
38
|
+
"typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"zod": "^4.4.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@longzai-intelligence-testing/utils": "^0.0.3",
|
|
45
|
+
"@longzai-intelligence-vitest/config": "^0.0.12",
|
|
46
|
+
"vitest": "^4.1.4"
|
|
47
|
+
},
|
|
48
|
+
"packageManager": "bun@1.4.3"
|
|
49
|
+
}
|