@aalis/api-webui 0.9.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ace Nyan <ace@acenyan.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # @aalis/api-webui
2
+
3
+ 类型/接口/能力声明包(只导出 `type` 与 `*Capabilities`,不含运行时逻辑)
4
+
5
+ ## 角色
6
+
7
+ 类型/接口/能力声明包(只导出 `type` 与 `*Capabilities`,不含运行时逻辑)
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ pnpm add @aalis/api-webui
13
+ ```
14
+
15
+ ## 使用
16
+
17
+ ```ts
18
+ import type { /* ... */ } from '@aalis/api-webui';
19
+ ```
20
+
21
+ 本包为 *-api 类型包;实现见对应的运行时插件。
22
+
23
+ ## 许可
24
+
25
+ 见仓库根目录 LICENSE。
@@ -0,0 +1,309 @@
1
+ import type { UserIdentity } from '@aalis/api-authority';
2
+ import type { Context } from '@aalis/core';
3
+ import type { ConfigSchema } from '@aalis/schema-config';
4
+ /**
5
+ * WebUI 服务 —— Web 管理后台
6
+ *
7
+ * 负责启动 HTTP 服务器,提供 REST API(插件管理、配置、权限等)
8
+ * 和 WebSocket(消息/日志推送),同时托管前端静态文件。
9
+ *
10
+ * 核心要求此服务必须运行。
11
+ * 默认由 plugin-webui-server 提供,第三方可替换整个实现或仅替换前端部分。
12
+ */
13
+ export interface WebUIService {
14
+ /** 获取 HTTP 服务监听端口 */
15
+ getPort(): number;
16
+ /** 获取 HTTP 服务监听地址 */
17
+ getHost(): string;
18
+ /**
19
+ * 设置前端静态文件目录
20
+ * 允许外部插件在运行时替换前端
21
+ */
22
+ setClientDir?(dir: string): void;
23
+ /** 注册一个 WebUI 页面;返回 dispose */
24
+ registerPage(page: WebuiPage, pluginName: string): () => void;
25
+ /** 列出当前所有已注册的页面(含插件归属) */
26
+ getPages(): Array<WebuiPage & {
27
+ pluginName: string;
28
+ }>;
29
+ /** 按插件名批量清除(供插件卸载时调用) */
30
+ unregisterByPlugin(pluginName: string): void;
31
+ }
32
+ /** 统计卡片 */
33
+ export interface WebuiStatComponent {
34
+ type: 'stat';
35
+ label: string;
36
+ source: string;
37
+ icon?: string;
38
+ }
39
+ /** 数据表格 */
40
+ export interface WebuiTableComponent {
41
+ type: 'table';
42
+ label?: string;
43
+ source: string;
44
+ columns: Array<{
45
+ key: string;
46
+ label: string;
47
+ render?: string;
48
+ nowrap?: boolean;
49
+ minWidth?: number;
50
+ maxWidth?: number;
51
+ }>;
52
+ actions?: Array<{
53
+ label: string;
54
+ method: string;
55
+ confirm?: string;
56
+ danger?: boolean;
57
+ }>;
58
+ refresh?: number;
59
+ /** 启用前端本地文本搜索(空格分隔多关键词,AND 语义,对所有列值做不区分大小写子串匹配) */
60
+ searchable?: boolean;
61
+ /** 搜索框 placeholder(searchable=true 时生效) */
62
+ searchPlaceholder?: string;
63
+ }
64
+ /** 配置表单(复用 ConfigSchema) */
65
+ export interface WebuiFormComponent {
66
+ type: 'form';
67
+ label?: string;
68
+ source: string;
69
+ save: string;
70
+ schema: ConfigSchema;
71
+ }
72
+ /** 操作按钮组 */
73
+ export interface WebuiActionsComponent {
74
+ type: 'actions';
75
+ label?: string;
76
+ items: Array<{
77
+ label: string;
78
+ method: string;
79
+ confirm?: string;
80
+ danger?: boolean;
81
+ variant?: string;
82
+ }>;
83
+ }
84
+ /** 键值信息面板 */
85
+ export interface WebuiInfoComponent {
86
+ type: 'info';
87
+ label?: string;
88
+ source: string;
89
+ }
90
+ /** Markdown 内容 */
91
+ export interface WebuiMarkdownComponent {
92
+ type: 'markdown';
93
+ label?: string;
94
+ source: string;
95
+ }
96
+ /** 子标签页容器 */
97
+ export interface WebuiTabsComponent {
98
+ type: 'tabs';
99
+ label?: string;
100
+ items: Array<{
101
+ key: string;
102
+ label: string;
103
+ content: WebuiComponent[];
104
+ }>;
105
+ }
106
+ /**
107
+ * 交互式关系图组件(基于 Cytoscape)。
108
+ *
109
+ * `source` 后端方法签名: `(args: { focusId?: string; maxDepth?: number; maxBreadth?: number; filters?: Record<string, unknown> })`
110
+ * 返回 cytoscape 风格的 elements:
111
+ * ```ts
112
+ * {
113
+ * nodes: Array<{ data: { id: string; label: string; kind: 'person' | 'event' | string; [k: string]: unknown } }>;
114
+ * edges: Array<{ data: { id: string; source: string; target: string; label?: string; relationType?: string; [k: string]: unknown } }>;
115
+ * focusId?: string;
116
+ * stats?: Record<string, number | string>;
117
+ * }
118
+ * ```
119
+ *
120
+ * `detailSource` 可选:节点被点击时调用,签名 `(args: { nodeId: string; kind: string })`,返回任意键值对 → 右侧 Drawer 渲染。
121
+ */
122
+ export interface WebuiGraphComponent {
123
+ type: 'graph';
124
+ label?: string;
125
+ source: string;
126
+ detailSource?: string;
127
+ /** 节点最大深度/宽度默认值(前端展示初值) */
128
+ defaultMaxDepth?: number;
129
+ defaultMaxBreadth?: number;
130
+ /** 自动刷新(毫秒),0 / undefined = 关闭 */
131
+ refresh?: number;
132
+ /** 顶部右上角额外按钮 */
133
+ actions?: Array<{
134
+ label: string;
135
+ method: string;
136
+ confirm?: string;
137
+ danger?: boolean;
138
+ variant?: string;
139
+ }>;
140
+ /**
141
+ * 自定义节点类别:节点 data.kind → 形状/颜色/图例文本。
142
+ * 声明后组件据此生成样式与底部图例,**不再使用人物关系图的内置三类**
143
+ * (person/event/entity)语义——非关系图场景(如权限图)必须声明,
144
+ * 避免冒用他人图例。
145
+ */
146
+ nodeKinds?: Array<{
147
+ kind: string;
148
+ label: string;
149
+ shape?: 'circle' | 'round-rect' | 'diamond';
150
+ color?: string;
151
+ }>;
152
+ /** 自定义边类别:边 data.kind → 颜色/虚线/图例文本。 */
153
+ edgeKinds?: Array<{
154
+ kind: string;
155
+ label: string;
156
+ color?: string;
157
+ dashed?: boolean;
158
+ }>;
159
+ }
160
+ /** 所有声明式页面组件的联合类型 */
161
+ export type WebuiComponent = WebuiStatComponent | WebuiTableComponent | WebuiFormComponent | WebuiActionsComponent | WebuiInfoComponent | WebuiMarkdownComponent | WebuiTabsComponent | WebuiGraphComponent;
162
+ /**
163
+ * 插件可声明的 WebUI 页面 —— 完整定义。
164
+ *
165
+ * 由本包直接导出(core 不再持有 WebuiPage 骨架)。
166
+ */
167
+ export interface WebuiPage {
168
+ /** 页面唯一标识(对应前端路由/标签 key) */
169
+ key: string;
170
+ /** 页面显示名称 */
171
+ label: string;
172
+ /** 图标标识(命名标识或内联 SVG) */
173
+ icon?: string;
174
+ /** 排序权重(越小越靠前,默认 99) */
175
+ order?: number;
176
+ /** 自定义渲染器标识(非声明式 content 场景) */
177
+ renderer?: string;
178
+ /** 声明式页面内容(不提供则使用客户端内置页面) */
179
+ content?: WebuiComponent[];
180
+ }
181
+ /**
182
+ * 通过 declaration merging 向 core 的 PluginModule 注入
183
+ * 纯展示元数据字段(subsystem / extends)与 host-RPC 槽位(actions)。
184
+ *
185
+ * WebuiPage 注册路径为运行时 `useWebuiService(ctx).registerPage(...)`,
186
+ * 不作为静态 module 字段存在。
187
+ */
188
+ declare module '@aalis/core' {
189
+ interface PluginModule {
190
+ /**
191
+ * 子系统归属,仅用于 WebUI 分组展示。
192
+ *
193
+ * 可用 id 与中文 label 由本包的 `DEFAULT_SUBSYSTEM_METADATA` 提供,
194
+ * 但允许使用任意自定义字符串(未匹配 metadata 时直接以 id 作为 label 显示)。
195
+ */
196
+ subsystem?: string;
197
+ /** 声明该插件对 core 的扩展(新增事件、钩子),仅用于前端展示。 */
198
+ extends?: ExtendDeclaration;
199
+ /**
200
+ * 插件 RPC 动作表 —— 供 host(webui-server 等)远程调用。
201
+ *
202
+ * core 不感知此字段;host 路由层(POST /api/page-action/:plugin/:method)
203
+ * 在权限闸门放行后以插件自身的 `entry.context` 调用 handler。
204
+ * 第三参 caller 为路由层解析出的调用者身份,handler 可用它做业务级
205
+ * 检查(如"不能委托超出自身持有的能力");忽略该参数即向后兼容。
206
+ */
207
+ actions?: Record<string, (ctx: Context, args: Record<string, unknown>, caller?: UserIdentity) => Promise<unknown>>;
208
+ }
209
+ }
210
+ declare module '@aalis/schema-config' {
211
+ /**
212
+ * WebUI 表单交互属性 —— 由本包注入(config-api 的 SchemaField 只声明各宿主共需字段)。
213
+ * 这些属性只被 WebUI 配置表单消费;其他宿主可以忽略。
214
+ */
215
+ interface SchemaField {
216
+ /** 标记为敏感字段,前端显示时自动遮蔽 */
217
+ secret?: boolean;
218
+ /** select / multiselect 动态选项来源:服务名(前端经 webui-server 调该服务的 listModels() 或等价方法获取选项) */
219
+ dynamicOptions?: string;
220
+ /** multiselect 是否允许用户手动输入自定义值(不限于选项列表) */
221
+ allowCustom?: boolean;
222
+ }
223
+ }
224
+ /**
225
+ * Scoped WebUI 服务:在插件 apply() 中注册页面,自动绑定到当前 ctx 生命周期。
226
+ */
227
+ export interface ScopedWebuiService {
228
+ /** 注册页面;返回 dispose(与 ctx 生命周期绑定)。 */
229
+ registerPage(page: WebuiPage): () => void;
230
+ /** 获取底层 service(未就绪时为 undefined)。 */
231
+ readonly raw: WebUIService | undefined;
232
+ }
233
+ /**
234
+ * 获取 ScopedWebuiService。
235
+ *
236
+ * 实现委托给 `ctx.whenService('webui-server', ...)`:每次 webui-server
237
+ * 重新 provide(bounce/replace)都会重新调用 `registerPage`,让插件页面
238
+ * 自动重挂;上次注册的 cleanup 在 provider 下线时自动释放。
239
+ */
240
+ export declare function useWebuiService(ctx: Context): ScopedWebuiService;
241
+ /**
242
+ * 插件可以声明它对 core 做了哪些扩展,用于前端展示和文档生成。
243
+ *
244
+ * 仅是元数据描述,core 不会读取也不会校验,仅透传给 WebUI 展示。
245
+ *
246
+ * @example
247
+ * export const extends_: ExtendDeclaration = {
248
+ * events: ['scheduler:tick', 'scheduler:error'],
249
+ * hooks: ['schedule:before'],
250
+ * };
251
+ */
252
+ export interface ExtendDeclaration {
253
+ /** 该插件新增的自定义事件名 */
254
+ events?: string[];
255
+ /** 该插件新增的自定义钩子名 */
256
+ hooks?: string[];
257
+ /** 该插件向哪些服务混入了方法(服务名 → 方法名列表),仅用于前端展示。 */
258
+ mixins?: Record<string, string[]>;
259
+ }
260
+ /**
261
+ * 子系统展示目录条目。
262
+ *
263
+ * **职责边界**:
264
+ * - 这是 **WebUI 展示层契约**,唯一消费者是 webui-server 的 `/api/service-groups` 路由。
265
+ * - `core` 完全不知道 subsystem 概念,仅在 PluginModule 上保留一个透传字段
266
+ * `subsystem?: string`(不读不解释,纯粹搬运给 WebUI)。
267
+ * - 本表只描述 **展示元数据**(中文 label / 排序 / icon),**不再写死插件归属**。
268
+ * 归属由每个插件自己在 index.ts 中声明:`export const subsystem = 'llm';`
269
+ *
270
+ * 解耦收益:
271
+ * - 新增插件不需要改 webui-api(只改插件自身)
272
+ * - 新增子系统:只在本表加一行元数据即可(id 未匹配时回退为 id 直接展示)
273
+ * - webui-api 不再反向耦合具体插件 npm 名
274
+ */
275
+ export interface SubsystemMetadata {
276
+ /** subsystem id(与 PluginModule.subsystem 对应) */
277
+ id: string;
278
+ /** 显示名(中文 label) */
279
+ label: string;
280
+ /** 排序权重,越小越靠前 */
281
+ order: number;
282
+ }
283
+ /**
284
+ * 默认子系统元数据。
285
+ *
286
+ * 仅提供常用 id 的中文 label 与排序;插件可任意自定义 subsystem id,
287
+ * 未命中本表时 WebUI 会回退到「id 原样展示,order=9999」。
288
+ */
289
+ export declare const DEFAULT_SUBSYSTEM_METADATA: readonly SubsystemMetadata[];
290
+ /**
291
+ * 前端提供者(忒修斯之船「换前端」契约):把一份已构建的前端静态目录交给
292
+ * webui-server 托管。第三方前端两条接入:
293
+ * - **纯静态包**:package.json 标 `aalis.client: true` + 含 `dist/index.html`,被
294
+ * webui-server 自动发现挂载(无需 `apply`,runtime 不会把它当插件加载)。
295
+ * - **主动覆盖**:插件 `apply` 里 `ctx.provide('webui-client', impl)`,优先于自动发现。
296
+ */
297
+ export interface WebuiClientProvider {
298
+ /** 返回含 index.html 的前端静态目录绝对路径 */
299
+ getClientDir(): string;
300
+ /** 可选展示名(多前端切换/选择时用) */
301
+ label?: string;
302
+ }
303
+ declare module '@aalis/core' {
304
+ interface ServiceTypeMap {
305
+ 'webui-server': WebUIService;
306
+ 'webui-client': WebuiClientProvider;
307
+ }
308
+ }
309
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,qBAAqB;IACrB,OAAO,IAAI,MAAM,CAAC;IAClB,qBAAqB;I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AE,MAAM,EAAE,CAAC,CAAC;CACnC;AAID;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,iBAAiB,EAkBjE,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,YAAY,IAAI,MAAM,CAAC;IACvB,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,OAAO,QAAQ,aAAa,CAAC;IAC3B,UAAU,cAAc;QACtB,cAAc,EAAE,YAAY,CAAC;QAC7B,cAAc,EAAE,mBAAmB,CAAC;KACrC;CACF"}
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ // ----- WebUI 服务接口与声明式页面组件 -----
2
+ //
3
+ // 此包提供 @aalis/core 中 WebuiPage skeleton 的完整扩展,
4
+ // 以及所有声明式页面组件类型。
5
+ // 任何需要声明 webuiPages 的插件应从本包导入相关类型。
6
+ /**
7
+ * 获取 ScopedWebuiService。
8
+ *
9
+ * 实现委托给 `ctx.whenService('webui-server', ...)`:每次 webui-server
10
+ * 重新 provide(bounce/replace)都会重新调用 `registerPage`,让插件页面
11
+ * 自动重挂;上次注册的 cleanup 在 provider 下线时自动释放。
12
+ */
13
+ export function useWebuiService(ctx) {
14
+ const pluginName = ctx.id || 'unknown';
15
+ return {
16
+ registerPage(page) {
17
+ return ctx.whenService('webui-server', svc => svc.registerPage(page, pluginName));
18
+ },
19
+ get raw() {
20
+ return ctx.getService('webui-server');
21
+ },
22
+ };
23
+ }
24
+ /**
25
+ * 默认子系统元数据。
26
+ *
27
+ * 仅提供常用 id 的中文 label 与排序;插件可任意自定义 subsystem id,
28
+ * 未命中本表时 WebUI 会回退到「id 原样展示,order=9999」。
29
+ */
30
+ export const DEFAULT_SUBSYSTEM_METADATA = Object.freeze([
31
+ { id: 'system', label: '系统', order: 0 },
32
+ { id: 'core', label: '核心', order: 10 },
33
+ { id: 'platform', label: '平台', order: 20 },
34
+ { id: 'agent', label: 'Agent', order: 30 },
35
+ { id: 'llm', label: 'LLM', order: 40 },
36
+ { id: 'embedding', label: 'Embedding', order: 50 },
37
+ { id: 'memory', label: '记忆', order: 60 },
38
+ { id: 'persona', label: '人格', order: 70 },
39
+ { id: 'tools', label: '工具', order: 80 },
40
+ { id: 'storage', label: '存储', order: 85 },
41
+ { id: 'message', label: '消息', order: 90 },
42
+ { id: 'session', label: '会话', order: 100 },
43
+ { id: 'skills', label: '技能', order: 110 },
44
+ { id: 'scheduler', label: '调度', order: 120 },
45
+ { id: 'authority', label: '权限', order: 130 },
46
+ { id: 'user', label: '用户', order: 140 },
47
+ { id: 'external', label: '外部', order: 160 },
48
+ ]);
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,+CAA+C;AAC/C,iBAAiB;AACjB,mCAAmC;AAoOnC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,MAAM,UAAU,GAAG,GAAG,CAAC,EAAE,IAAI,SAAS,CAAC;IACvC,OAAO;QACL,YAAY,CAAC,IAAe;YAC1B,OAAO,GAAG,CAAC,WAAW,CAAe,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;QAClG,CAAC;QACD,IAAI,GAAG;YACL,OAAO,GAAG,CAAC,UAAU,CAAe,cAAc,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC;AAgDD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAiC,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AE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;IAC5C,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;IACvC,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;CAC5C,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@aalis/api-webui",
3
+ "version": "0.9.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/AalisLabs/Aalis.git",
8
+ "directory": "packages/api-webui"
9
+ },
10
+ "author": "Ace Nyan <ace@acenyan.com>",
11
+ "bugs": {
12
+ "url": "https://github.com/AalisLabs/Aalis/issues"
13
+ },
14
+ "homepage": "https://github.com/AalisLabs/Aalis#readme",
15
+ "type": "module",
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "dependencies": {
22
+ "@aalis/api-authority": ">=0.5.0 <1.0.0",
23
+ "@aalis/schema-config": ">=0.9.0 <1.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.0.0",
27
+ "typescript": "^5.7.0",
28
+ "@aalis/core": "0.10.0"
29
+ },
30
+ "aalis": {
31
+ "types": true
32
+ },
33
+ "peerDependencies": {
34
+ "@aalis/core": ">=0.2.0 <1.0.0"
35
+ },
36
+ "keywords": [
37
+ "aalis",
38
+ "aalis-api"
39
+ ],
40
+ "scripts": {
41
+ "build": "tsc",
42
+ "dev": "tsc --watch"
43
+ }
44
+ }