@webskill/sdk 0.3.0 → 0.5.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/dist/agent.d.ts +2 -0
- package/dist/agent.js +867 -0
- package/dist/browser.d.ts +137 -4
- package/dist/browser.js +458 -22
- package/dist/{catalogComponents-C_V39rbF-BOHveMWa.js → catalogComponents-DV7cPpUm-C77AEEx9.js} +477 -157
- package/dist/{dist-rorEJsNi.js → dist-6C03DShK.js} +654 -298
- package/dist/{dist-ZKaM8j06.js → dist-bewtXYlO.js} +1061 -807
- package/dist/governance.d.ts +87 -10
- package/dist/governance.js +194 -24
- package/dist/{index-wiV5X8Rz.d.ts → index-Bsqg4ftU.d.ts} +151 -143
- package/dist/index-D_7ZZjkl.d.ts +411 -0
- package/dist/{index-8d-oEDww.d.ts → index-vBz_FC9w.d.ts} +289 -24
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/memoryArtifactStore-BtOeB_hm-tj3fC5ip.js +78 -0
- package/dist/node.d.ts +8 -4
- package/dist/node.js +1 -1
- package/dist/{openUiLibrary-B8-Cvou9-BbpNTXS3.js → openUiLibrary-W3Ce896k-ClFTRZFs.js} +6 -5
- package/dist/{skillVersionStore-DOEI9ptb-BxbYL70B.d.ts → skillVersionStore-BzLbzFOL-CxwIewHJ.d.ts} +43 -11
- package/dist/{testing-CsrG3XLz.js → testing-DDCJWvgA.js} +7 -5
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/{types-AmKCKJn_-VGabeXK4.d.ts → types-D_hoCri8-BnNPiZCi.d.ts} +111 -72
- package/dist/ui-react.d.ts +352 -20
- package/dist/ui-react.js +3804 -3478
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +25 -6
- package/dist/ui.d.ts +4 -3
- package/dist/ui.js +3 -3
- package/dist/{webskillLitCatalog-CNaUpasU-BslMcxRZ.js → webskillLitCatalog-_mugzRHx-DiuJpCuf.js} +398 -122
- package/package.json +6 -1
- package/dist/jsonRenderRegistry-9GrWP_hE-U6Do3Kid.js +0 -2468
- package/dist/memoryArtifactStore-C9lFVqPF-yFz6yJj0.js +0 -48
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { I as JsonSchema, T as UiSpecSnapshot, b as UiBridge, c as InteractionResponse, mt as UiSpecNode, r as ChartSpec, s as InteractionRequest, v as RenderBlock, x as UiSpecActionCapability, y as RenderResultRequest } from "./types-D_hoCri8-BnNPiZCi.js";
|
|
2
|
+
import { x as ExternalToolSource } from "./index-vBz_FC9w.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
//#region ../ui/dist/index.d.ts
|
|
@@ -23,6 +23,15 @@ interface ControlModel {
|
|
|
23
23
|
label: string;
|
|
24
24
|
value: unknown;
|
|
25
25
|
}>;
|
|
26
|
+
/**
|
|
27
|
+
* 上次填写值(FR-5.9)。与 `defaultValue` 严格分开:渲染器只能把它展示为建议,
|
|
28
|
+
* 用户主动采纳后才能进控件。
|
|
29
|
+
* @experimental
|
|
30
|
+
*/
|
|
31
|
+
suggestion?: {
|
|
32
|
+
value: unknown;
|
|
33
|
+
ts: number;
|
|
34
|
+
};
|
|
26
35
|
}
|
|
27
36
|
/** 提交值按请求类型归形(WebFormBridge 与框架组件库共享单一来源) */
|
|
28
37
|
declare function shapeInteractionValue(model: FormModel, values: Record<string, unknown>): unknown;
|
|
@@ -42,6 +51,13 @@ interface CollectedValues {
|
|
|
42
51
|
* - required 空值列入 missingRequired(由调用方阻止提交并标记)
|
|
43
52
|
*/
|
|
44
53
|
declare function collectValues(controls: ControlModel[], container: ParentNode): CollectedValues;
|
|
54
|
+
/**
|
|
55
|
+
* 采纳建议值(FR-5.9):把 `control.suggestion` 写进已渲染的控件。
|
|
56
|
+
* 与 `collectValues` 共用同一套选择器与编码约定——两边分开实现的话,
|
|
57
|
+
* select 的 JSON 编码值迟早会对不上。
|
|
58
|
+
* @experimental
|
|
59
|
+
*/
|
|
60
|
+
declare function applySuggestion(control: ControlModel, container: ParentNode): void;
|
|
45
61
|
//#endregion
|
|
46
62
|
//#region src/markdown/miniMarkdown.d.ts
|
|
47
63
|
/**
|
|
@@ -65,6 +81,24 @@ declare function chartToTable(chart: ChartSpec): {
|
|
|
65
81
|
rows: unknown[][];
|
|
66
82
|
};
|
|
67
83
|
//#endregion
|
|
84
|
+
//#region src/chart/echart.d.ts
|
|
85
|
+
/**
|
|
86
|
+
* catalog `Chart` 节点 props → `ChartSpec`。四档共用这一份转换:
|
|
87
|
+
* 此前 native / OpenUI / json-render / A2UI 各抄了一遍,改一处就会漂移。
|
|
88
|
+
* catalog 的 `area` 在 `ChartSpec` 里没有对应枚举,按折线渲染——
|
|
89
|
+
* 原先的裸 cast 会把非法枚举一路带进渲染器,画出空图。
|
|
90
|
+
*/
|
|
91
|
+
declare function chartSpecFromProps(props: Record<string, unknown>): ChartSpec;
|
|
92
|
+
interface EchartHandle {
|
|
93
|
+
setChart(chart: ChartSpec): void;
|
|
94
|
+
dispose(): void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 框架无关的 echarts 挂载点:三档的 React 组件与 A2UI 档的 Lit 元素共用同一实现,
|
|
98
|
+
* 图表不再因档位而异。echarts 走动态 import,不打进首屏。
|
|
99
|
+
*/
|
|
100
|
+
declare function mountEchart(container: HTMLElement): EchartHandle;
|
|
101
|
+
//#endregion
|
|
68
102
|
//#region src/web/webFormBridge.d.ts
|
|
69
103
|
/**
|
|
70
104
|
* 框架无关原生 DOM 的 UiBridge:request 渲染表单并返回 Promise
|
|
@@ -97,20 +131,11 @@ declare function renderRenderResult(request: RenderResultRequest, doc: Document)
|
|
|
97
131
|
//#endregion
|
|
98
132
|
//#region src/web/styles.d.ts
|
|
99
133
|
/** 最小样式(BEM class,应用可整体覆写) */
|
|
100
|
-
declare const WEBSKILL_STYLES_CSS = "\n.webskill-form { display: block; padding: 12px; border: 1px solid #d0d0d0; border-radius: 8px; font-family: system-ui, sans-serif; max-width: 420px; }\n.webskill-form__title { margin: 0 0 8px; font-size: 15px; font-weight: 600; }\n.webskill-form__message { margin: 0 0 10px; font-size: 14px; }\n.webskill-form__control { margin-bottom: 10px; display: flex; flex-direction: column; gap: 4px; }\n.webskill-form__control--invalid .webskill-form__input { border-color: #d33; }\n.webskill-form__label { font-size: 13px; font-weight: 500; }\n.webskill-form__label-required::after { content: ' *'; color: #d33; }\n.webskill-form__description { font-size: 12px; color: #666; }\n.webskill-form__error { font-size: 12px; color: #d33; display: none; }\n.webskill-form__control--invalid .webskill-form__error { display: block; }\n.webskill-form__input { padding: 6px 8px; border: 1px solid #bbb; border-radius: 4px; font-size: 14px; font-family: inherit; }\n.webskill-form__actions { display: flex; gap: 8px; margin-top: 12px; }\n.webskill-form__button { padding: 6px 14px; border-radius: 4px; border: 1px solid #bbb; background: #fff; cursor: pointer; font-size: 14px; }\n.webskill-form__button--primary { background: #2563eb; border-color: #2563eb; color: #fff; }\n.webskill-form__button--ghost { background: transparent; }\n.webskill-result { font-family: system-ui, sans-serif; font-size: 14px; }\n.webskill-result__summary { font-size: 12px; color: #666; margin-bottom: 6px; }\n.webskill-result__json { background: #f5f5f5; padding: 8px; border-radius: 4px; overflow-x: auto; }\n.webskill-result__file { padding: 4px 0; font-size: 13px; }\n.webskill-md pre { background: #f5f5f5; padding: 8px; border-radius: 4px; overflow-x: auto; }\n.webskill-md h1, .webskill-md h2, .webskill-md h3 { margin: 8px 0 4px; }\n.webskill-md p { margin: 4px 0; }\n.webskill-md ul { margin: 4px 0; padding-left: 20px; }\n";
|
|
134
|
+
declare const WEBSKILL_STYLES_CSS = "\n.webskill-form { display: block; padding: 12px; border: 1px solid #d0d0d0; border-radius: 8px; font-family: system-ui, sans-serif; max-width: 420px; }\n.webskill-form__title { margin: 0 0 8px; font-size: 15px; font-weight: 600; }\n.webskill-form__message { margin: 0 0 10px; font-size: 14px; }\n.webskill-form__control { margin-bottom: 10px; display: flex; flex-direction: column; gap: 4px; }\n.webskill-form__control--invalid .webskill-form__input { border-color: #d33; }\n.webskill-form__label { font-size: 13px; font-weight: 500; }\n.webskill-form__label-required::after { content: ' *'; color: #d33; }\n.webskill-form__description { font-size: 12px; color: #666; }\n.webskill-form__error { font-size: 12px; color: #d33; display: none; }\n.webskill-form__control--invalid .webskill-form__error { display: block; }\n.webskill-form__input { padding: 6px 8px; border: 1px solid #bbb; border-radius: 4px; font-size: 14px; font-family: inherit; }\n.webskill-form__suggestion { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #666; }\n.webskill-form__suggestion-use { padding: 1px 8px; border-radius: 4px; border: 1px solid #bbb; background: #fff; cursor: pointer; font-size: 12px; }\n.webskill-form__actions { display: flex; gap: 8px; margin-top: 12px; }\n.webskill-form__button { padding: 6px 14px; border-radius: 4px; border: 1px solid #bbb; background: #fff; cursor: pointer; font-size: 14px; }\n.webskill-form__button--primary { background: #2563eb; border-color: #2563eb; color: #fff; }\n.webskill-form__button--ghost { background: transparent; }\n.webskill-result { font-family: system-ui, sans-serif; font-size: 14px; }\n.webskill-result__summary { font-size: 12px; color: #666; margin-bottom: 6px; }\n.webskill-result__json { background: #f5f5f5; padding: 8px; border-radius: 4px; overflow-x: auto; }\n.webskill-result__file { padding: 4px 0; font-size: 13px; }\n.webskill-md pre { background: #f5f5f5; padding: 8px; border-radius: 4px; overflow-x: auto; }\n.webskill-md h1, .webskill-md h2, .webskill-md h3 { margin: 8px 0 4px; }\n.webskill-md p { margin: 4px 0; }\n.webskill-md ul { margin: 4px 0; padding-left: 20px; }\n";
|
|
101
135
|
/** 每个 document 只注入一次 */
|
|
102
136
|
declare function ensureStyles(doc: Document): void;
|
|
103
137
|
//#endregion
|
|
104
138
|
//#region src/catalog/types.d.ts
|
|
105
|
-
/** 声明式 UI 的节点:框架无关,技能脚本与 LLM 产出同一形状 */
|
|
106
|
-
interface UiSpecNode {
|
|
107
|
-
/** catalog 中声明过的组件名 */
|
|
108
|
-
component: string;
|
|
109
|
-
props?: Record<string, unknown>;
|
|
110
|
-
children?: UiSpecNode[];
|
|
111
|
-
/** 稳定 id(回放与 action 关联用) */
|
|
112
|
-
id?: string;
|
|
113
|
-
}
|
|
114
139
|
interface UiComponentDef {
|
|
115
140
|
/** 声明里使用的组件名(PascalCase,全局唯一) */
|
|
116
141
|
name: string;
|
|
@@ -121,6 +146,8 @@ interface UiComponentDef {
|
|
|
121
146
|
/** 允许的子节点组件名;省略表示叶子节点 */
|
|
122
147
|
children?: readonly string[] | 'any';
|
|
123
148
|
group: 'layout' | 'content' | 'data' | 'input' | 'feedback';
|
|
149
|
+
/** 同一容器(声明了 children 的父节点)下至多出现一个;超出时校验不通过 */
|
|
150
|
+
singletonPerContainer?: boolean;
|
|
124
151
|
/** 给模型的额外约束 */
|
|
125
152
|
constraints?: readonly string[];
|
|
126
153
|
/** 最小示例(进 prompt,显著提升生成质量) */
|
|
@@ -176,35 +203,83 @@ declare function defineUiCatalog(input: UiCatalogInput): UiCatalog;
|
|
|
176
203
|
//#endregion
|
|
177
204
|
//#region src/catalog/uiCatalog.d.ts
|
|
178
205
|
/**
|
|
179
|
-
* v3 首发 catalog
|
|
206
|
+
* v3 首发 catalog:覆盖旧六类 surface(metric / chart / table / form / file / custom)的全部表达力,先窄后宽。
|
|
180
207
|
* 只依赖 zod —— 不 import 任何 UI framework(21 号文档 §5.1)。
|
|
181
208
|
*/
|
|
182
209
|
declare const uiCatalog: UiCatalog;
|
|
183
210
|
/** prompt / 文档里引用的分组顺序(Console 展示同序) */
|
|
184
211
|
declare const UI_CATALOG_GROUPS: {
|
|
185
212
|
readonly content: readonly ["Stack", "Card", "Separator", "Heading", "Text", "Markdown", "Badge"];
|
|
186
|
-
readonly data: readonly ["Metric", "Table", "Chart", "FileLink"];
|
|
213
|
+
readonly data: readonly ["Metric", "Table", "Chart", "Timeline", "FileLink"];
|
|
187
214
|
readonly input: readonly ["Form", "Field", "Button"];
|
|
188
215
|
};
|
|
216
|
+
/**
|
|
217
|
+
* catalog 系统提示的体积上限(UTF-8 字节,FR-6.6)。
|
|
218
|
+
* 描述每次请求都要重发,所以上限必须是可判定的数字而不是「尽量精简」。
|
|
219
|
+
* 要改这个数字,先想清楚是否值得让每次请求都多付这些 token。
|
|
220
|
+
*/
|
|
221
|
+
declare const UI_CATALOG_PROMPT_BUDGET_BYTES = 20480;
|
|
189
222
|
//#endregion
|
|
190
|
-
//#region src/catalog/
|
|
223
|
+
//#region src/catalog/formScopes.d.ts
|
|
224
|
+
/** 声明树里一个 `Form` 的提交作用域。@experimental */
|
|
225
|
+
interface UiFormScope {
|
|
226
|
+
/** 提交动作所属的表单容器:节点 id 优先,否则按出现序生成 */
|
|
227
|
+
scopeId: string;
|
|
228
|
+
/** 该表单的提交 action id */
|
|
229
|
+
submitActionId: string;
|
|
230
|
+
/** 该表单的取消 action id(仅在声明了 cancelLabel 时会进能力表) */
|
|
231
|
+
cancelActionId: string;
|
|
232
|
+
/** 该表单子树内的字段名,按声明序 */
|
|
233
|
+
fieldNames: readonly string[];
|
|
234
|
+
form: UiSpecNode;
|
|
235
|
+
}
|
|
191
236
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
237
|
+
* 按出现序列出声明树里的每个 `Form`。
|
|
238
|
+
*
|
|
239
|
+
* 单表单时 action id 保持 `submit` / `cancel`,回传形状与容器级放宽前逐字节一致——
|
|
240
|
+
* 向后兼容是 FR-6.3 的硬约束,不能让既有单表单卡片跟着改。
|
|
241
|
+
* 多表单时每个表单拿到独立的 action id 与 `scopeId`,渲染层据此只收集本表单子树内的字段。
|
|
195
242
|
*/
|
|
196
|
-
declare
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
243
|
+
declare function collectFormScopes(spec: UiSpecNode): UiFormScope[];
|
|
244
|
+
/**
|
|
245
|
+
* 多表单时字段值在渲染层的存储键。
|
|
246
|
+
*
|
|
247
|
+
* 跨表单重名过去不可能发生,容器级放宽后它变成合法输入:两个表单各有一个 `email`,
|
|
248
|
+
* 共用一张扁平表就是后写的覆盖先写的,用户在 A 里输入会串到 B。
|
|
249
|
+
* 因此多表单时按作用域限定键;单表单不加前缀,存储与草稿形状保持不变。
|
|
250
|
+
*/
|
|
251
|
+
declare function qualifyFieldName(name: string, scopeId?: string): string;
|
|
252
|
+
/**
|
|
253
|
+
* 提交时回传的字段值。
|
|
254
|
+
*
|
|
255
|
+
* 不给 `scope` → 整张 surface 的扁平值,与容器级放宽前完全一致(FR-6.3 第 3 条)。
|
|
256
|
+
* 给了 `scope` → 只取该表单子树内的字段,键回落成裸字段名,
|
|
257
|
+
* 因此接收端看到的载荷形状与单表单时相同。
|
|
258
|
+
*/
|
|
259
|
+
declare function collectScopedValues(values: Readonly<Record<string, unknown>>, scope?: Pick<UiFormScope, 'scopeId' | 'fieldNames'>): Record<string, unknown>;
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/catalog/presets.d.ts
|
|
262
|
+
/** 场景预设名(FR-6.4) */
|
|
263
|
+
type UiPresetName = 'charts' | 'cards' | 'dashboards' | 'slides' | 'reports';
|
|
264
|
+
/**
|
|
265
|
+
* 一类场景的排版模板。产出的是 catalog 节点树,不是标记语言——
|
|
266
|
+
* 技能可以引用预设,但不能自带 HTML(需求 8 的方案 A)。
|
|
267
|
+
* @experimental
|
|
268
|
+
*/
|
|
269
|
+
interface UiPreset {
|
|
270
|
+
name: UiPresetName;
|
|
271
|
+
/** 一行说明,进工具入参枚举;这行是唯一无条件计入请求上下文的部分 */
|
|
272
|
+
summary: string;
|
|
273
|
+
/** 详细排版指引,只在模型显式索取该预设时才下发(FR-6.5) */
|
|
274
|
+
guidance: string;
|
|
275
|
+
/** 可运行示例:必须通过 `uiCatalog.validate`(AC-6.6) */
|
|
276
|
+
example: UiSpecNode;
|
|
277
|
+
}
|
|
278
|
+
/** 五类场景预设(FR-6.4)。@experimental */
|
|
279
|
+
declare const UI_PRESETS: readonly UiPreset[];
|
|
280
|
+
declare const UI_PRESET_NAMES: readonly UiPresetName[];
|
|
281
|
+
/** Returns undefined for names outside the catalog presets. @experimental */
|
|
282
|
+
declare function uiPreset(name: string): UiPreset | undefined;
|
|
208
283
|
//#endregion
|
|
209
284
|
//#region src/catalog/toJsonRenderSpec.d.ts
|
|
210
285
|
/** json-render 的扁平 spec:`elements` 以 key 索引,`children` 只存 key */
|
|
@@ -222,44 +297,43 @@ interface JsonRenderSpec {
|
|
|
222
297
|
*/
|
|
223
298
|
declare function toJsonRenderSpec(spec: UiSpecNode): JsonRenderSpec;
|
|
224
299
|
//#endregion
|
|
300
|
+
//#region src/catalog/interactionToUiSpec.d.ts
|
|
301
|
+
/**
|
|
302
|
+
* 宿主注入的界面文案(缺省用 `FormModel` 的英文默认值)。
|
|
303
|
+
* 生成器本身与语言无关,本地化由持有字典的宿主提供。
|
|
304
|
+
*/
|
|
305
|
+
interface InteractionSpecLabels {
|
|
306
|
+
title?: string;
|
|
307
|
+
submitLabel?: string;
|
|
308
|
+
cancelLabel?: string;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 五类 `InteractionRequest` → catalog 声明树。
|
|
312
|
+
*
|
|
313
|
+
* 路径 A(runtime 发起的交互请求)与路径 B(模型产出的 surface)的差别只在「谁产出这棵树」;
|
|
314
|
+
* 产出之后四档走的是同一条 spec 渲染路径,因此这份生成器全仓只写一份。
|
|
315
|
+
*/
|
|
316
|
+
declare function interactionToUiSpec(request: InteractionRequest, labels?: InteractionSpecLabels): UiSpecNode;
|
|
317
|
+
//#endregion
|
|
225
318
|
//#region src/catalog/uiCatalogToolSource.d.ts
|
|
226
319
|
declare const RENDER_UI_TOOL = "render_ui";
|
|
320
|
+
declare const DESCRIBE_UI_PRESET_TOOL = "describe_ui_preset";
|
|
227
321
|
interface UiCatalogToolSourceOptions {
|
|
228
322
|
/** 默认使用 v1 catalog */
|
|
229
323
|
catalog?: UiCatalog;
|
|
230
324
|
/** surface id 生成(默认时间戳 + 随机后缀) */
|
|
231
325
|
newSurfaceId?: () => string;
|
|
326
|
+
/** 向模型开放的场景预设;缺省全部开放,空数组等于关闭预设。不认识的名字直接忽略 */
|
|
327
|
+
presets?: readonly string[];
|
|
232
328
|
}
|
|
329
|
+
/** 节点树声明的 action 能力表(renderer 据此生成按钮,runtime 据此签发 nonce)。@experimental */
|
|
330
|
+
declare function collectSpecActions(spec: UiSpecNode): UiSpecActionCapability[];
|
|
233
331
|
/**
|
|
234
332
|
* 把 catalog 变成一个工具的入参 Schema,让模型直接生成声明式 UI(21 号文档 §3):
|
|
235
|
-
* agentLoop / UiBridge /
|
|
333
|
+
* agentLoop / UiBridge / extractUiSpecEvents 全部零改动,装配处只多一个 externalTools 条目。
|
|
236
334
|
*/
|
|
237
335
|
declare function createUiCatalogToolSource(options?: UiCatalogToolSourceOptions): ExternalToolSource;
|
|
238
336
|
//#endregion
|
|
239
|
-
//#region src/adapters/surface/surfaceDescriptor.d.ts
|
|
240
|
-
declare const WEBSKILL_SURFACE_ACTION = "webskill:surface-action";
|
|
241
|
-
type SurfaceRendererProvenance = 'a2ui-standard' | 'a2ui-extension' | 'openui-library' | 'openui-extension' | 'vercel-surface-host';
|
|
242
|
-
/** Serializable surface state consumed by a renderer-specific host. @experimental */
|
|
243
|
-
interface UiSurfaceDescriptor {
|
|
244
|
-
type: 'webskill-surface';
|
|
245
|
-
snapshot: UiSurfaceSnapshot;
|
|
246
|
-
provenance: SurfaceRendererProvenance;
|
|
247
|
-
}
|
|
248
|
-
/** Serializable renderer action. The Runtime validates nonce capability before resuming a run. @experimental */
|
|
249
|
-
interface UiSurfaceActionDispatch {
|
|
250
|
-
runId?: string;
|
|
251
|
-
surfaceId: string;
|
|
252
|
-
actionId: string;
|
|
253
|
-
intent: UiSurfaceAction['intent'];
|
|
254
|
-
nonce?: string;
|
|
255
|
-
value?: Record<string, unknown>;
|
|
256
|
-
cancelled?: boolean;
|
|
257
|
-
}
|
|
258
|
-
declare function toUiSurfaceDescriptor(snapshot: UiSurfaceSnapshot, provenance: SurfaceRendererProvenance): UiSurfaceDescriptor;
|
|
259
|
-
declare function toUiSurfaceActionDispatch(snapshot: UiSurfaceSnapshot, action: UiSurfaceAction, value?: Record<string, unknown>): UiSurfaceActionDispatch;
|
|
260
|
-
/** Returns undefined for malformed or non-WebSkill renderer events. @experimental */
|
|
261
|
-
declare function fromUiSurfaceActionDispatch(value: unknown): UiSurfaceActionDispatch | undefined;
|
|
262
|
-
//#endregion
|
|
263
337
|
//#region src/adapters/vercel/vercelPayload.d.ts
|
|
264
338
|
/** Vercel AI SDK v7 ToolCallPart 兼容结构 */
|
|
265
339
|
interface VercelToolInvocation {
|
|
@@ -269,22 +343,10 @@ interface VercelToolInvocation {
|
|
|
269
343
|
input: unknown;
|
|
270
344
|
}
|
|
271
345
|
declare const VERCEL_INTERACTION_TOOL_NAME = "webskill_interaction";
|
|
272
|
-
declare const VERCEL_SURFACE_DATA_PART_TYPE = "data-webskill-surface";
|
|
273
|
-
declare const VERCEL_SURFACE_ACTION_DATA_PART_TYPE = "webskill:surface-action";
|
|
274
|
-
/** Vercel AI SDK-compatible data part consumed by a WebSkill SurfaceHost. @experimental */
|
|
275
|
-
interface VercelSurfaceDataPart {
|
|
276
|
-
type: typeof VERCEL_SURFACE_DATA_PART_TYPE;
|
|
277
|
-
id: string;
|
|
278
|
-
data: ReturnType<typeof toUiSurfaceDescriptor>;
|
|
279
|
-
}
|
|
280
346
|
/** InteractionRequest → SDK tool UI 结构(应用聊天 UI 直接消费) */
|
|
281
347
|
declare function toVercelToolInvocation(request: InteractionRequest): VercelToolInvocation;
|
|
282
348
|
/** SDK 回传(tool result / output)→ InteractionResponse */
|
|
283
349
|
declare function fromVercelToolResult(part: unknown): InteractionResponse;
|
|
284
|
-
/** UiSurfaceSnapshot → AI SDK data part; the SurfaceHost owns renderer selection. @experimental */
|
|
285
|
-
declare function toVercelSurfaceDataPart(snapshot: UiSurfaceSnapshot): VercelSurfaceDataPart;
|
|
286
|
-
/** Decodes a nonce-bound action data part emitted by a Vercel SurfaceHost. @experimental */
|
|
287
|
-
declare function fromVercelSurfaceAction(part: unknown): UiSurfaceActionDispatch | undefined;
|
|
288
350
|
//#endregion
|
|
289
351
|
//#region src/adapters/vercel/vercelUiBridge.d.ts
|
|
290
352
|
/**
|
|
@@ -299,39 +361,6 @@ declare class VercelUiBridge implements UiBridge {
|
|
|
299
361
|
request(input: InteractionRequest): Promise<InteractionResponse>;
|
|
300
362
|
}
|
|
301
363
|
//#endregion
|
|
302
|
-
//#region src/adapters/openui/openuiLang.d.ts
|
|
303
|
-
/**
|
|
304
|
-
* InteractionRequest ↔ openui-lang 双向转换。
|
|
305
|
-
* openui-lang 语法(@openuidev/react-lang 实测):
|
|
306
|
-
* - 每行一条语句 `identifier = Expression`,`root = Component(...)` 为入口
|
|
307
|
-
* - 组件调用参数为位置参数;字符串双引号反斜杠转义
|
|
308
|
-
* - 组件词汇(与应用 Library 约定):Form(title, children)、
|
|
309
|
-
* Text(content)(纯展示文本,authorize 的能力描述用)、
|
|
310
|
-
* TextField(name, label, required?, defaultValue?)、NumberField、BooleanField(name, label, default?)、
|
|
311
|
-
* SelectField(name, label, options)、SubmitButton(label, actionType, requestId)、
|
|
312
|
-
* CancelButton(label, actionType, requestId)
|
|
313
|
-
*/
|
|
314
|
-
declare const OPENUI_SUBMIT_ACTION = "webskill:submit";
|
|
315
|
-
declare const OPENUI_CANCEL_ACTION = "webskill:cancel";
|
|
316
|
-
/** authorize 的 Allow 专用动作(提交即批准 → value:true;Deny 走 cancel → cancelled:true) */
|
|
317
|
-
declare const OPENUI_AUTHORIZE_ACTION = "webskill:authorize";
|
|
318
|
-
declare const OPENUI_SURFACE_ACTION = "webskill:surface-action";
|
|
319
|
-
/** @experimental */
|
|
320
|
-
declare function toOpenUiLang(request: InteractionRequest): string;
|
|
321
|
-
/**
|
|
322
|
-
* UiSurfaceSnapshot → OpenUI library program. OpenUI applications provide WebSkillSurfaceHost;
|
|
323
|
-
* its descriptor tells the host whether it is a native extension rather than an OpenUI-native component.
|
|
324
|
-
* @experimental
|
|
325
|
-
*/
|
|
326
|
-
declare function toOpenUiSurfaceLang(snapshot: UiSurfaceSnapshot): string;
|
|
327
|
-
/** Decodes a nonce-bound action emitted by an OpenUI WebSkillSurfaceHost. @experimental */
|
|
328
|
-
declare function fromOpenUiSurfaceAction(action: unknown): UiSurfaceActionDispatch | undefined;
|
|
329
|
-
/**
|
|
330
|
-
* OpenUI ActionEvent → InteractionResponse(formState 优先,取消单独分支)
|
|
331
|
-
* @experimental
|
|
332
|
-
*/
|
|
333
|
-
declare function fromOpenUiAction(action: unknown): InteractionResponse;
|
|
334
|
-
//#endregion
|
|
335
364
|
//#region src/adapters/openui/openUiSpecLang.d.ts
|
|
336
365
|
/**
|
|
337
366
|
* catalog 声明树 → openui-lang 文本。语法为每行一条 `id = Component(位置参数…)`,
|
|
@@ -339,56 +368,48 @@ declare function fromOpenUiAction(action: unknown): InteractionResponse;
|
|
|
339
368
|
*/
|
|
340
369
|
declare function toOpenUiSpecLang(spec: UiSpecNode, catalog?: UiCatalog): string;
|
|
341
370
|
//#endregion
|
|
371
|
+
//#region src/adapters/surface/surfaceDescriptor.d.ts
|
|
372
|
+
declare const WEBSKILL_SURFACE_ACTION = "webskill:surface-action";
|
|
373
|
+
/** Serializable renderer action. The Runtime validates nonce capability before resuming a run. @experimental */
|
|
374
|
+
interface UiSurfaceActionDispatch {
|
|
375
|
+
runId?: string;
|
|
376
|
+
surfaceId: string;
|
|
377
|
+
actionId: string;
|
|
378
|
+
intent: UiSpecActionCapability['intent'];
|
|
379
|
+
nonce?: string;
|
|
380
|
+
/** 提交动作所属的表单容器;单表单场景可省略 */
|
|
381
|
+
scopeId?: string;
|
|
382
|
+
value?: Record<string, unknown>;
|
|
383
|
+
cancelled?: boolean;
|
|
384
|
+
}
|
|
385
|
+
declare function toUiSurfaceActionDispatch(snapshot: UiSpecSnapshot, action: UiSpecActionCapability, value?: Record<string, unknown>, scopeId?: string): UiSurfaceActionDispatch;
|
|
386
|
+
/** Returns undefined for malformed or non-WebSkill renderer events. @experimental */
|
|
387
|
+
declare function fromUiSurfaceActionDispatch(value: unknown): UiSurfaceActionDispatch | undefined;
|
|
388
|
+
//#endregion
|
|
342
389
|
//#region src/adapters/a2ui/a2uiMessages.d.ts
|
|
343
390
|
/**
|
|
344
|
-
*
|
|
391
|
+
* A2UI 协议常量与 surface 动作编解码(v0.9.1)。
|
|
345
392
|
* 依据 https://a2ui.org/specification/v0.9-a2ui/:
|
|
346
393
|
* - 信封 {version, createSurface|updateComponents|updateDataModel|deleteSurface}
|
|
347
394
|
* - 组件为扁平邻接表(id 引用),root 必需
|
|
348
395
|
* - 输入组件与数据模型经 JSON Pointer 双向绑定;action.context 回传
|
|
349
|
-
* - createSurface.sendDataModel: true → 客户端动作时携带完整数据模型
|
|
350
396
|
*
|
|
351
|
-
*
|
|
352
|
-
* cancel → {name: 'webskill:cancel', context: {requestId}}。
|
|
397
|
+
* 声明树 → A2UI 消息的转换在 `specToA2ui.ts`(四档共用的单一渲染路径)。
|
|
353
398
|
*/
|
|
354
399
|
declare const A2UI_VERSION = "v0.9.1";
|
|
355
400
|
declare const A2UI_BASIC_CATALOG_ID = "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json";
|
|
356
|
-
declare const A2UI_SUBMIT_ACTION = "webskill:submit";
|
|
357
|
-
declare const A2UI_CANCEL_ACTION = "webskill:cancel";
|
|
358
401
|
declare const A2UI_SURFACE_ACTION = "webskill:surface-action";
|
|
359
402
|
interface A2uiMessage {
|
|
360
403
|
version: string;
|
|
361
404
|
[key: string]: unknown;
|
|
362
405
|
}
|
|
363
|
-
/** @experimental */
|
|
364
|
-
declare function toA2uiMessages(request: InteractionRequest): A2uiMessage[];
|
|
365
|
-
/**
|
|
366
|
-
* UiSurfaceSnapshot → A2UI extension-host messages.
|
|
367
|
-
* Basic Catalog has no chart/table vocabulary, so a labelled WebSkill host owns these controlled renderers.
|
|
368
|
-
* @experimental
|
|
369
|
-
*/
|
|
370
|
-
declare function toA2uiSurfaceMessages(snapshot: UiSurfaceSnapshot): A2uiMessage[];
|
|
371
406
|
/** Decodes a nonce-bound action emitted by a WebSkill A2UI extension host. @experimental */
|
|
372
407
|
declare function fromA2uiSurfaceAction(event: unknown): UiSurfaceActionDispatch | undefined;
|
|
373
408
|
/** Builds the A2UI event payload an extension host sends after a user action. @experimental */
|
|
374
|
-
declare function toA2uiSurfaceAction(snapshot:
|
|
409
|
+
declare function toA2uiSurfaceAction(snapshot: UiSpecSnapshot, action: UiSpecActionCapability, value?: Record<string, unknown>, scopeId?: string): {
|
|
375
410
|
name: string;
|
|
376
411
|
context: UiSurfaceActionDispatch;
|
|
377
412
|
};
|
|
378
|
-
/**
|
|
379
|
-
* 按 InteractionRequest.type 解码提交值(绑定模型原样回传的是表单对象):
|
|
380
|
-
* confirm 仅 confirmed===true 批准;select 还原原始 option 值(非字符串值经 JSON 编码比对);
|
|
381
|
-
* form 的 number 字段转 number(NaN 保留原值);ask 取 answer;authorize 提交即批准。
|
|
382
|
-
* 纯转换器:任何直接使用 fromA2uiAction 的消费者都应经此拿到正确类型。
|
|
383
|
-
* @experimental
|
|
384
|
-
*/
|
|
385
|
-
declare function decodeInteractionResponse(request: InteractionRequest, response: InteractionResponse): InteractionResponse;
|
|
386
|
-
/**
|
|
387
|
-
* A2UI client→server action 事件 → InteractionResponse。
|
|
388
|
-
* 传入 request 时按类型解码提交值(见 decodeInteractionResponse)。
|
|
389
|
-
* @experimental
|
|
390
|
-
*/
|
|
391
|
-
declare function fromA2uiAction(event: unknown, request?: InteractionRequest): InteractionResponse;
|
|
392
413
|
//#endregion
|
|
393
414
|
//#region src/adapters/a2ui/webskillCatalog.d.ts
|
|
394
415
|
/** 自定义 catalog 的协议 id(对齐 https://a2ui.org/specification/v1_0/catalog_definition.json) */
|
|
@@ -485,19 +506,6 @@ interface A2uiSpecActionEvent {
|
|
|
485
506
|
/** A2UI action 事件 → 声明树 action(非本 catalog 的事件返回 undefined) */
|
|
486
507
|
declare function fromA2uiSpecAction(event: unknown): A2uiSpecActionEvent | undefined;
|
|
487
508
|
//#endregion
|
|
488
|
-
//#region src/a2uiRuntime/litRendererBridge.d.ts
|
|
489
|
-
/** @experimental */
|
|
490
|
-
declare class LitRendererBridge implements UiBridge {
|
|
491
|
-
#private;
|
|
492
|
-
constructor(deps: {
|
|
493
|
-
mount: HTMLElement;
|
|
494
|
-
document?: Document;
|
|
495
|
-
});
|
|
496
|
-
request(input: InteractionRequest): Promise<InteractionResponse>;
|
|
497
|
-
/** runtime 交互超时/取消:移除 surface 并以 cancelled resolve pending Promise(防悬挂 + DOM 残留) */
|
|
498
|
-
cancel(id: string): void;
|
|
499
|
-
}
|
|
500
|
-
//#endregion
|
|
501
509
|
//#region src/a2uiRuntime/loadLitCatalog.d.ts
|
|
502
510
|
/** catalog 里单个组件的最小可见面(A2UI `LitComponentApi` 的结构子集) */
|
|
503
511
|
interface A2uiCatalogComponent {
|
|
@@ -594,4 +602,4 @@ interface LoadedOpenUiPeers {
|
|
|
594
602
|
*/
|
|
595
603
|
declare function loadOpenUiPeers(): Promise<LoadedOpenUiPeers>;
|
|
596
604
|
//#endregion
|
|
597
|
-
export {
|
|
605
|
+
export { buildA2uiCatalogDefinition as $, UiActionDef as A, uiCatalog as At, UiSpecValidation as B, OpenUiRendererProps as C, shapeInteractionValue as Ct, UI_CATALOG_PROMPT_BUDGET_BYTES as D, toOpenUiSpecLang as Dt, UI_CATALOG_GROUPS as E, toJsonRenderSpec as Et, UiComponentDef as F, WEBSKILL_A2UI_CATALOG_ID as G, VERCEL_INTERACTION_TOOL_NAME as H, UiFormScope as I, WebFormBridge as J, WEBSKILL_STYLES_CSS as K, UiPreset as L, UiCatalogInput as M, UiCatalogPromptOptions as N, UI_PRESETS as O, toUiSurfaceActionDispatch as Ot, UiCatalogToolSourceOptions as P, applySuggestion as Q, UiPresetName as R, LoadedOpenUiPeers as S, renderRenderResult as St, RENDER_UI_TOOL as T, toA2uiSurfaceAction as Tt, VercelToolInvocation as U, UiSurfaceActionDispatch as V, VercelUiBridge as W, a2uiComponentSchema as X, ZodRuntime as Y, a2uiComponentShapes as Z, DESCRIBE_UI_PRESET_TOOL as _, mountEchart as _t, A2UI_SURFACE_ACTION as a, collectValues as at, InteractionSpecLabels as b, renderMiniChart as bt, A2uiCatalogDefinition as c, ensureStyles as ct, A2uiMessage as d, fromUiSurfaceActionDispatch as dt, chartSpecFromProps as et, A2uiSpecActionEvent as f, fromVercelToolResult as ft, ControlModel as g, loadWebSkillLitCatalog as gt, CollectedValues as h, loadOpenUiPeers as ht, A2UI_SPEC_FORM_PATH as i, collectSpecActions as it, UiCatalog as j, uiPreset as jt, UI_PRESET_NAMES as k, toVercelToolInvocation as kt, A2uiCatalogHandle as l, fromA2uiSpecAction as lt, CHART_PALETTE as m, interactionToUiSpec as mt, A2UI_COMMON_TYPES as n, collectFormScopes as nt, A2UI_VERSION as o, createUiCatalogToolSource as ot, A2uiSpecMessageOptions as p, interactionToFormModel as pt, WEBSKILL_SURFACE_ACTION as q, A2UI_SPEC_ACTION as r, collectScopedValues as rt, A2uiCatalogComponent as s, defineUiCatalog as st, A2UI_BASIC_CATALOG_ID as t, chartToTable as tt, A2uiComponentShape as u, fromA2uiSurfaceAction as ut, EchartHandle as v, qualifyFieldName as vt, OpenUiRuntime as w, toA2uiSpecMessages as wt, JsonRenderSpec as x, renderMiniMarkdown as xt, FormModel as y, renderBlocks as yt, UiSpecIssue as z };
|