@webskill/sdk 0.4.0 → 0.6.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 +909 -0
- package/dist/browser.d.ts +233 -4
- package/dist/browser.js +869 -19
- package/dist/{catalogComponents-KsujmL4b-Clx1kCnU.js → catalogComponents-Dr5dFMAb-Dacibl1e.js} +372 -126
- package/dist/{dist-D9Lcn5Pp.js → dist-DnYG2-eY.js} +642 -39
- package/dist/{dist-C-Sh0MDU.js → dist-DusANsrn.js} +1035 -99
- package/dist/{env--jJB-TSX-04klhTYi.js → env-8cY40DXB-CGnEVZby.js} +7 -6
- package/dist/{env-BPUBZCwJ-4jat_SVG.d.ts → env-AK3cSMEA-Dli6QU5E.d.ts} +4 -3
- package/dist/governance.d.ts +46 -4
- package/dist/governance.js +45 -2
- package/dist/{index-CHXxDccV.d.ts → index-BMocOEi0.d.ts} +106 -10
- package/dist/index-BuTpBMzr.d.ts +474 -0
- package/dist/{index-DLfR2Y6I.d.ts → index-C-KFAZoF.d.ts} +337 -18
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/mcp.d.ts +39 -8
- package/dist/mcp.js +53 -19
- package/dist/{memoryArtifactStore-BtOeB_hm-tj3fC5ip.js → memoryArtifactStore-52Zn9npI-BMPYwvoy.js} +10 -2
- package/dist/node.d.ts +4 -4
- package/dist/node.js +9 -2
- package/dist/{openUiLibrary-YLS-cxyT-C96jWDQq.js → openUiLibrary-Bdrji9qK-DzAxRlTY.js} +3 -3
- package/dist/{skillVersionStore-uyefLPR1-DXOzbksv.d.ts → skillVersionStore-BzLbzFOL-CxdAFWO2.d.ts} +4 -3
- package/dist/{testing-DDCJWvgA.js → testing-CYTFqkDm.js} +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +3 -3
- package/dist/{types-7Wcg--Vh-1YlQ4jF9.d.ts → types-4pg-qp_I-Gq63X8Oa.d.ts} +55 -5
- package/dist/ui-react.d.ts +26 -5
- package/dist/ui-react.js +147 -29
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +30 -6
- package/dist/ui.d.ts +4 -4
- package/dist/ui.js +3 -3
- package/dist/{webskillLitCatalog-CSTbhBe_-CYIs5BX8.js → webskillLitCatalog-_mugzRHx-B_54vxum.js} +88 -2
- package/package.json +6 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
|
|
3
|
-
//#region ../node/dist/env
|
|
3
|
+
//#region ../node/dist/env-8cY40DXB.js
|
|
4
4
|
/** 解析 .env(简单 KEY=VALUE 行解析,不引依赖);文件缺失返回 undefined */
|
|
5
5
|
function readEnvVars(dotenvPath) {
|
|
6
6
|
let raw;
|
|
@@ -23,15 +23,16 @@ function readEnvVars(dotenvPath) {
|
|
|
23
23
|
return vars;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* 读取 LLM_BASE_URL / LLM_API_KEY / LLM_MODEL
|
|
27
|
-
*
|
|
26
|
+
* 读取 LLM_BASE_URL / LLM_API_KEY / LLM_MODEL;缺项返回 undefined 供测试 skip 判断。
|
|
27
|
+
* 0.6.0 FR-13.2 移除了旧的 `VITE_` 前缀回退:该前缀是 Vite 向**客户端 bundle** 注入变量的开关,
|
|
28
|
+
* 把 API key 放在它名下等于告诉使用者“这个 key 会被打进前端产物”。
|
|
28
29
|
*/
|
|
29
30
|
function loadLlmConfigFromEnv(dotenvPath = ".env") {
|
|
30
31
|
const vars = readEnvVars(dotenvPath);
|
|
31
32
|
if (!vars) return void 0;
|
|
32
|
-
const baseUrl = vars.get("LLM_BASE_URL")
|
|
33
|
-
const apiKey = vars.get("LLM_API_KEY")
|
|
34
|
-
const model = vars.get("LLM_MODEL")
|
|
33
|
+
const baseUrl = vars.get("LLM_BASE_URL");
|
|
34
|
+
const apiKey = vars.get("LLM_API_KEY");
|
|
35
|
+
const model = vars.get("LLM_MODEL");
|
|
35
36
|
if (!baseUrl || !apiKey || !model) return void 0;
|
|
36
37
|
return {
|
|
37
38
|
baseUrl,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../node/dist/env-
|
|
1
|
+
//#region ../node/dist/env-AK3cSMEA.d.ts
|
|
2
2
|
//#region src/env.d.ts
|
|
3
3
|
interface LlmEnvConfig {
|
|
4
4
|
baseUrl: string;
|
|
@@ -12,8 +12,9 @@ interface ProviderEnvConfig {
|
|
|
12
12
|
baseUrl?: string;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* 读取 LLM_BASE_URL / LLM_API_KEY / LLM_MODEL
|
|
16
|
-
*
|
|
15
|
+
* 读取 LLM_BASE_URL / LLM_API_KEY / LLM_MODEL;缺项返回 undefined 供测试 skip 判断。
|
|
16
|
+
* 0.6.0 FR-13.2 移除了旧的 `VITE_` 前缀回退:该前缀是 Vite 向**客户端 bundle** 注入变量的开关,
|
|
17
|
+
* 把 API key 放在它名下等于告诉使用者“这个 key 会被打进前端产物”。
|
|
17
18
|
*/
|
|
18
19
|
declare function loadLlmConfigFromEnv(dotenvPath?: string): LlmEnvConfig | undefined;
|
|
19
20
|
/** ANTHROPIC_API_KEY / ANTHROPIC_MODEL(可选 ANTHROPIC_BASE_URL);缺项返回 undefined */
|
package/dist/governance.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { _ as SkillVersion, a as AuditLog, c as CandidateFile, d as CandidateSource, f as CandidateStatus, g as SkillState, h as SKILL_VERSION_PAGE_SIZE, i as AuditEvent, l as CandidateRisk, m as CompositeApprovalPolicy, n as ApprovalDecision, o as AuditQueryFilter, p as CandidateStore, r as ApprovalPolicy, s as CANDIDATE_PAGE_SIZE, t as AlwaysHumanApprovalPolicy, u as CandidateSkill, v as SkillVersionStore, y as candidateToCatalogEntry } from "./skillVersionStore-
|
|
1
|
+
import { B as PageQuery, P as FileSystemProvider, Q as SkillCatalogEntry, b as UiBridge, et as SkillDocument, f as LlmMessage, it as SkillManagerPort, l as LlmClient, z as Page } from "./types-4pg-qp_I-Gq63X8Oa.js";
|
|
2
|
+
import { It as SkillStateGuard, Mt as SkillOutcomeReporter, V as IntegrityVerdict, jt as SkillIntegrityGuard, on as WebSkillRuntime, vt as RuntimeRun } from "./index-C-KFAZoF.js";
|
|
3
|
+
import { _ as SkillVersion, a as AuditLog, c as CandidateFile, d as CandidateSource, f as CandidateStatus, g as SkillState, h as SKILL_VERSION_PAGE_SIZE, i as AuditEvent, l as CandidateRisk, m as CompositeApprovalPolicy, n as ApprovalDecision, o as AuditQueryFilter, p as CandidateStore, r as ApprovalPolicy, s as CANDIDATE_PAGE_SIZE, t as AlwaysHumanApprovalPolicy, u as CandidateSkill, v as SkillVersionStore, y as candidateToCatalogEntry } from "./skillVersionStore-BzLbzFOL-CxdAFWO2.js";
|
|
4
4
|
//#region ../governance/dist/index.d.ts
|
|
5
5
|
//#region src/candidate/candidateNormalizer.d.ts
|
|
6
6
|
/** 剥 markdown fence 与 <think> 块、截取首尾 {};非对象 → CANDIDATE_INVALID */
|
|
@@ -32,6 +32,48 @@ declare function normalizeCandidate(input: {
|
|
|
32
32
|
/** 候选校验:缺 SKILL.md / 非法扩展名 → CANDIDATE_INVALID */
|
|
33
33
|
declare function validateCandidate(candidate: CandidateSkill): void;
|
|
34
34
|
//#endregion
|
|
35
|
+
//#region src/candidate/candidateSink.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* agent 侧 `SkillCandidateSink.submit()` 的入参形状。
|
|
38
|
+
* 这里按结构声明而不是 import `@webskill/agent`:治理层是可选层,
|
|
39
|
+
* 不该因为 agent 策略而多一条运行时依赖(两侧的兼容性由测试钉住)。
|
|
40
|
+
*/
|
|
41
|
+
interface GeneratedSkillSubmission {
|
|
42
|
+
draft: {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
/** SKILL.md 全文,含 frontmatter */
|
|
46
|
+
content: string;
|
|
47
|
+
files?: readonly {
|
|
48
|
+
path: string;
|
|
49
|
+
content: string;
|
|
50
|
+
}[];
|
|
51
|
+
};
|
|
52
|
+
/** 触发生成的会话,写进候选 metadata 供 console 溯源 */
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
/** 用户确认的时刻(FR-9.7 的「用户确认事实」) */
|
|
55
|
+
confirmedAt: string;
|
|
56
|
+
}
|
|
57
|
+
interface CandidateSinkOptions {
|
|
58
|
+
store: CandidateStore;
|
|
59
|
+
/** 缺省不写审计——但 FR-9.7 要求宿主接上它 */
|
|
60
|
+
audit?: AuditLog;
|
|
61
|
+
now?: () => string;
|
|
62
|
+
createId?: () => string;
|
|
63
|
+
}
|
|
64
|
+
interface CandidateSink {
|
|
65
|
+
submit(input: GeneratedSkillSubmission): Promise<{
|
|
66
|
+
id: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 把 agent 生成的技能草稿接进既有的候选管线(设计 02 §5)。
|
|
71
|
+
*
|
|
72
|
+
* 走的是与文档抽取、runtime-miss 完全相同的 `normalizeCandidate` → `CandidateStore.save`,
|
|
73
|
+
* 因此候选恒为 `draft`,审批/发布链路一行都不用改;差别只有 `source: 'generated'`。
|
|
74
|
+
*/
|
|
75
|
+
declare function createCandidateSink(options: CandidateSinkOptions): CandidateSink;
|
|
76
|
+
//#endregion
|
|
35
77
|
//#region src/candidate/llmCandidateGenerator.d.ts
|
|
36
78
|
/** LLM 候选生成器:prompt 强制约束 + 不信任归一化管线 + candidate.created 审计 */
|
|
37
79
|
declare class LlmCandidateGenerator {
|
|
@@ -363,4 +405,4 @@ declare function createMissHook(deps: {
|
|
|
363
405
|
*/
|
|
364
406
|
declare function completeText(llm: LlmClient, messages: LlmMessage[]): Promise<string>;
|
|
365
407
|
//#endregion
|
|
366
|
-
export { AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, type ApprovalDecision, type ApprovalPolicy, type AuditEvent, type AuditLog, type AuditQueryFilter, CANDIDATE_PAGE_SIZE, type CandidateFile, type CandidateRisk, type CandidateSkill, type CandidateSource, type CandidateStatus, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, type EvaluationReport, type EvaluationResult, EvaluationRunner, type EvaluationTask, FailureAnalyzer, type FailureDiagnosis, FsAuditLog, LlmCandidateGenerator, type RepairOption, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, type ScoreInput, SimilarityDetector, SkillScorer, type SkillState, SkillStatePolicy, type SkillVersion, SkillVersionStore, type SourceDocument, candidateToCatalogEntry, completeText, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
|
408
|
+
export { AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, type ApprovalDecision, type ApprovalPolicy, type AuditEvent, type AuditLog, type AuditQueryFilter, CANDIDATE_PAGE_SIZE, type CandidateFile, type CandidateRisk, type CandidateSink, type CandidateSinkOptions, type CandidateSkill, type CandidateSource, type CandidateStatus, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, type EvaluationReport, type EvaluationResult, EvaluationRunner, type EvaluationTask, FailureAnalyzer, type FailureDiagnosis, FsAuditLog, type GeneratedSkillSubmission, LlmCandidateGenerator, type RepairOption, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, type ScoreInput, SimilarityDetector, SkillScorer, type SkillState, SkillStatePolicy, type SkillVersion, SkillVersionStore, type SourceDocument, candidateToCatalogEntry, completeText, createCandidateSink, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
package/dist/governance.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { O as messageOf, T as isValidSkillName, g as assertSafePathSegment, m as WebSkillError } from "./dist-8oQRa8Xz.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as textParts, n as partsToText } from "./memoryArtifactStore-52Zn9npI-BMPYwvoy.js";
|
|
3
3
|
|
|
4
4
|
//#region ../governance/dist/index.js
|
|
5
5
|
const invalid = (message, details) => {
|
|
@@ -182,6 +182,49 @@ function candidateToCatalogEntry(candidate) {
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
|
+
* 把 agent 生成的技能草稿接进既有的候选管线(设计 02 §5)。
|
|
186
|
+
*
|
|
187
|
+
* 走的是与文档抽取、runtime-miss 完全相同的 `normalizeCandidate` → `CandidateStore.save`,
|
|
188
|
+
* 因此候选恒为 `draft`,审批/发布链路一行都不用改;差别只有 `source: 'generated'`。
|
|
189
|
+
*/
|
|
190
|
+
function createCandidateSink(options) {
|
|
191
|
+
return { async submit(input) {
|
|
192
|
+
const { draft } = input;
|
|
193
|
+
const candidate = normalizeCandidate({
|
|
194
|
+
raw: {
|
|
195
|
+
name: draft.name,
|
|
196
|
+
description: draft.description,
|
|
197
|
+
files: [{
|
|
198
|
+
path: "SKILL.md",
|
|
199
|
+
content: draft.content
|
|
200
|
+
}, ...draft.files ?? []]
|
|
201
|
+
},
|
|
202
|
+
source: "generated",
|
|
203
|
+
...options.now ? { now: options.now } : {},
|
|
204
|
+
...options.createId ? { createId: options.createId } : {}
|
|
205
|
+
});
|
|
206
|
+
candidate.metadata = {
|
|
207
|
+
...candidate.metadata,
|
|
208
|
+
confirmedAt: input.confirmedAt,
|
|
209
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {}
|
|
210
|
+
};
|
|
211
|
+
await options.store.save(candidate);
|
|
212
|
+
await options.audit?.append({
|
|
213
|
+
type: "candidate.created",
|
|
214
|
+
target: candidate.id,
|
|
215
|
+
data: {
|
|
216
|
+
name: candidate.name,
|
|
217
|
+
source: candidate.source,
|
|
218
|
+
risk: candidate.risk,
|
|
219
|
+
userConfirmed: true,
|
|
220
|
+
confirmedAt: input.confirmedAt,
|
|
221
|
+
...input.sessionId !== void 0 ? { sessionId: input.sessionId } : {}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
return { id: candidate.id };
|
|
225
|
+
} };
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
185
228
|
* 文本补全:优先走流式(慢速本地模型下非流式整响应缓冲会触发 fetch 头超时,
|
|
186
229
|
* SSE 首包秒到不受此限);无 stream 的客户端回退 complete。
|
|
187
230
|
*/
|
|
@@ -1046,4 +1089,4 @@ function createMissHook(deps) {
|
|
|
1046
1089
|
}
|
|
1047
1090
|
|
|
1048
1091
|
//#endregion
|
|
1049
|
-
export { AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, CANDIDATE_PAGE_SIZE, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, EvaluationRunner, FailureAnalyzer, FsAuditLog, LlmCandidateGenerator, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, SimilarityDetector, SkillScorer, SkillStatePolicy, SkillVersionStore, candidateToCatalogEntry, completeText, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
|
1092
|
+
export { AUDIT_PAGE_SIZE, AlwaysHumanApprovalPolicy, CANDIDATE_PAGE_SIZE, CandidateStore, CompositeApprovalPolicy, DependencyGraph, DocumentSkillExtractor, EvaluationRunner, FailureAnalyzer, FsAuditLog, LlmCandidateGenerator, RepairPlanner, SCORING_WEIGHTS, SKILL_VERSION_PAGE_SIZE, SimilarityDetector, SkillScorer, SkillStatePolicy, SkillVersionStore, candidateToCatalogEntry, completeText, createCandidateSink, createMissHook, jaccardSimilarity, normalizeCandidate, normalizeCandidateFiles, normalizeRisk, parseJsonObject, readDocument, sanitizeCandidateName, suggestFromFailedRun, validateCandidate };
|
|
@@ -1,11 +1,11 @@
|
|
|
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-4pg-qp_I-Gq63X8Oa.js";
|
|
2
|
+
import { O as ExternalToolSource } from "./index-C-KFAZoF.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
//#region ../ui/dist/index.d.ts
|
|
6
6
|
//#region src/model/formModel.d.ts
|
|
7
7
|
interface FormModel {
|
|
8
|
-
kind: 'ask' | 'confirm' | 'form' | 'select' | 'authorize';
|
|
8
|
+
kind: 'ask' | 'confirm' | 'form' | 'select' | 'authorize' | 'file-pick';
|
|
9
9
|
title?: string;
|
|
10
10
|
message?: string;
|
|
11
11
|
controls: ControlModel[];
|
|
@@ -15,7 +15,7 @@ interface FormModel {
|
|
|
15
15
|
interface ControlModel {
|
|
16
16
|
name: string;
|
|
17
17
|
label: string;
|
|
18
|
-
control: 'text' | 'number' | 'boolean' | 'select' | 'textarea';
|
|
18
|
+
control: 'text' | 'number' | 'boolean' | 'select' | 'textarea' | 'file';
|
|
19
19
|
required?: boolean;
|
|
20
20
|
description?: string;
|
|
21
21
|
defaultValue?: unknown;
|
|
@@ -23,6 +23,18 @@ interface ControlModel {
|
|
|
23
23
|
label: string;
|
|
24
24
|
value: unknown;
|
|
25
25
|
}>;
|
|
26
|
+
/** 传给 `input.accept` 的类型列表(仅 file 控件) */
|
|
27
|
+
accept?: readonly string[];
|
|
28
|
+
multiple?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 建议值(FR-19.4)。与 `defaultValue` 严格分开:渲染器只能把它展示为建议,
|
|
31
|
+
* 用户主动采纳后才能进控件。
|
|
32
|
+
* @experimental
|
|
33
|
+
*/
|
|
34
|
+
suggestion?: {
|
|
35
|
+
value: unknown;
|
|
36
|
+
reason?: string;
|
|
37
|
+
};
|
|
26
38
|
}
|
|
27
39
|
/** 提交值按请求类型归形(WebFormBridge 与框架组件库共享单一来源) */
|
|
28
40
|
declare function shapeInteractionValue(model: FormModel, values: Record<string, unknown>): unknown;
|
|
@@ -42,6 +54,13 @@ interface CollectedValues {
|
|
|
42
54
|
* - required 空值列入 missingRequired(由调用方阻止提交并标记)
|
|
43
55
|
*/
|
|
44
56
|
declare function collectValues(controls: ControlModel[], container: ParentNode): CollectedValues;
|
|
57
|
+
/**
|
|
58
|
+
* 采纳建议值(FR-5.9):把 `control.suggestion` 写进已渲染的控件。
|
|
59
|
+
* 与 `collectValues` 共用同一套选择器与编码约定——两边分开实现的话,
|
|
60
|
+
* select 的 JSON 编码值迟早会对不上。
|
|
61
|
+
* @experimental
|
|
62
|
+
*/
|
|
63
|
+
declare function applySuggestion(control: ControlModel, container: ParentNode): void;
|
|
45
64
|
//#endregion
|
|
46
65
|
//#region src/markdown/miniMarkdown.d.ts
|
|
47
66
|
/**
|
|
@@ -51,7 +70,10 @@ declare function collectValues(controls: ControlModel[], container: ParentNode):
|
|
|
51
70
|
declare function renderMiniMarkdown(text: string, doc: Document): HTMLElement;
|
|
52
71
|
//#endregion
|
|
53
72
|
//#region src/chart/miniChart.d.ts
|
|
54
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* 固定 8 色循环调色板。这是**数据编码**(区分序列),不是主题色;
|
|
75
|
+
* 图表的轴线与文字等“外壳”颜色走 currentColor,跟随宿主容器的主题。
|
|
76
|
+
*/
|
|
55
77
|
declare const CHART_PALETTE: readonly ["#4e79a7", "#f28e2b", "#e15759", "#76b7b2", "#59a14f", "#edc948", "#b07aa1", "#ff9da7"];
|
|
56
78
|
/**
|
|
57
79
|
* ChartSpec → SVG(bar 等宽柱 + 值标签;line 折线 + 点;pie 扇形 + 图例;空数据容错)
|
|
@@ -115,7 +137,7 @@ declare function renderRenderResult(request: RenderResultRequest, doc: Document)
|
|
|
115
137
|
//#endregion
|
|
116
138
|
//#region src/web/styles.d.ts
|
|
117
139
|
/** 最小样式(BEM class,应用可整体覆写) */
|
|
118
|
-
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";
|
|
140
|
+
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";
|
|
119
141
|
/** 每个 document 只注入一次 */
|
|
120
142
|
declare function ensureStyles(doc: Document): void;
|
|
121
143
|
//#endregion
|
|
@@ -130,6 +152,8 @@ interface UiComponentDef {
|
|
|
130
152
|
/** 允许的子节点组件名;省略表示叶子节点 */
|
|
131
153
|
children?: readonly string[] | 'any';
|
|
132
154
|
group: 'layout' | 'content' | 'data' | 'input' | 'feedback';
|
|
155
|
+
/** 同一容器(声明了 children 的父节点)下至多出现一个;超出时校验不通过 */
|
|
156
|
+
singletonPerContainer?: boolean;
|
|
133
157
|
/** 给模型的额外约束 */
|
|
134
158
|
constraints?: readonly string[];
|
|
135
159
|
/** 最小示例(进 prompt,显著提升生成质量) */
|
|
@@ -192,9 +216,76 @@ declare const uiCatalog: UiCatalog;
|
|
|
192
216
|
/** prompt / 文档里引用的分组顺序(Console 展示同序) */
|
|
193
217
|
declare const UI_CATALOG_GROUPS: {
|
|
194
218
|
readonly content: readonly ["Stack", "Card", "Separator", "Heading", "Text", "Markdown", "Badge"];
|
|
195
|
-
readonly data: readonly ["Metric", "Table", "Chart", "FileLink"];
|
|
219
|
+
readonly data: readonly ["Metric", "Table", "Chart", "Timeline", "FileLink"];
|
|
196
220
|
readonly input: readonly ["Form", "Field", "Button"];
|
|
197
221
|
};
|
|
222
|
+
/**
|
|
223
|
+
* catalog 系统提示的体积上限(UTF-8 字节,FR-6.6)。
|
|
224
|
+
* 描述每次请求都要重发,所以上限必须是可判定的数字而不是「尽量精简」。
|
|
225
|
+
* 要改这个数字,先想清楚是否值得让每次请求都多付这些 token。
|
|
226
|
+
*/
|
|
227
|
+
declare const UI_CATALOG_PROMPT_BUDGET_BYTES = 20480;
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/catalog/formScopes.d.ts
|
|
230
|
+
/** 声明树里一个 `Form` 的提交作用域。@experimental */
|
|
231
|
+
interface UiFormScope {
|
|
232
|
+
/** 提交动作所属的表单容器:节点 id 优先,否则按出现序生成 */
|
|
233
|
+
scopeId: string;
|
|
234
|
+
/** 该表单的提交 action id */
|
|
235
|
+
submitActionId: string;
|
|
236
|
+
/** 该表单的取消 action id(仅在声明了 cancelLabel 时会进能力表) */
|
|
237
|
+
cancelActionId: string;
|
|
238
|
+
/** 该表单子树内的字段名,按声明序 */
|
|
239
|
+
fieldNames: readonly string[];
|
|
240
|
+
form: UiSpecNode;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 按出现序列出声明树里的每个 `Form`。
|
|
244
|
+
*
|
|
245
|
+
* 单表单时 action id 保持 `submit` / `cancel`,回传形状与容器级放宽前逐字节一致——
|
|
246
|
+
* 向后兼容是 FR-6.3 的硬约束,不能让既有单表单卡片跟着改。
|
|
247
|
+
* 多表单时每个表单拿到独立的 action id 与 `scopeId`,渲染层据此只收集本表单子树内的字段。
|
|
248
|
+
*/
|
|
249
|
+
declare function collectFormScopes(spec: UiSpecNode): UiFormScope[];
|
|
250
|
+
/**
|
|
251
|
+
* 多表单时字段值在渲染层的存储键。
|
|
252
|
+
*
|
|
253
|
+
* 跨表单重名过去不可能发生,容器级放宽后它变成合法输入:两个表单各有一个 `email`,
|
|
254
|
+
* 共用一张扁平表就是后写的覆盖先写的,用户在 A 里输入会串到 B。
|
|
255
|
+
* 因此多表单时按作用域限定键;单表单不加前缀,存储与草稿形状保持不变。
|
|
256
|
+
*/
|
|
257
|
+
declare function qualifyFieldName(name: string, scopeId?: string): string;
|
|
258
|
+
/**
|
|
259
|
+
* 提交时回传的字段值。
|
|
260
|
+
*
|
|
261
|
+
* 不给 `scope` → 整张 surface 的扁平值,与容器级放宽前完全一致(FR-6.3 第 3 条)。
|
|
262
|
+
* 给了 `scope` → 只取该表单子树内的字段,键回落成裸字段名,
|
|
263
|
+
* 因此接收端看到的载荷形状与单表单时相同。
|
|
264
|
+
*/
|
|
265
|
+
declare function collectScopedValues(values: Readonly<Record<string, unknown>>, scope?: Pick<UiFormScope, 'scopeId' | 'fieldNames'>): Record<string, unknown>;
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/catalog/presets.d.ts
|
|
268
|
+
/** 场景预设名(FR-6.4) */
|
|
269
|
+
type UiPresetName = 'charts' | 'cards' | 'dashboards' | 'slides' | 'reports';
|
|
270
|
+
/**
|
|
271
|
+
* 一类场景的排版模板。产出的是 catalog 节点树,不是标记语言——
|
|
272
|
+
* 技能可以引用预设,但不能自带 HTML(需求 8 的方案 A)。
|
|
273
|
+
* @experimental
|
|
274
|
+
*/
|
|
275
|
+
interface UiPreset {
|
|
276
|
+
name: UiPresetName;
|
|
277
|
+
/** 一行说明,进工具入参枚举;这行是唯一无条件计入请求上下文的部分 */
|
|
278
|
+
summary: string;
|
|
279
|
+
/** 详细排版指引,只在模型显式索取该预设时才下发(FR-6.5) */
|
|
280
|
+
guidance: string;
|
|
281
|
+
/** 可运行示例:必须通过 `uiCatalog.validate`(AC-6.6) */
|
|
282
|
+
example: UiSpecNode;
|
|
283
|
+
}
|
|
284
|
+
/** 五类场景预设(FR-6.4)。@experimental */
|
|
285
|
+
declare const UI_PRESETS: readonly UiPreset[];
|
|
286
|
+
declare const UI_PRESET_NAMES: readonly UiPresetName[];
|
|
287
|
+
/** Returns undefined for names outside the catalog presets. @experimental */
|
|
288
|
+
declare function uiPreset(name: string): UiPreset | undefined;
|
|
198
289
|
//#endregion
|
|
199
290
|
//#region src/catalog/toJsonRenderSpec.d.ts
|
|
200
291
|
/** json-render 的扁平 spec:`elements` 以 key 索引,`children` 只存 key */
|
|
@@ -232,11 +323,14 @@ declare function interactionToUiSpec(request: InteractionRequest, labels?: Inter
|
|
|
232
323
|
//#endregion
|
|
233
324
|
//#region src/catalog/uiCatalogToolSource.d.ts
|
|
234
325
|
declare const RENDER_UI_TOOL = "render_ui";
|
|
326
|
+
declare const DESCRIBE_UI_PRESET_TOOL = "describe_ui_preset";
|
|
235
327
|
interface UiCatalogToolSourceOptions {
|
|
236
328
|
/** 默认使用 v1 catalog */
|
|
237
329
|
catalog?: UiCatalog;
|
|
238
330
|
/** surface id 生成(默认时间戳 + 随机后缀) */
|
|
239
331
|
newSurfaceId?: () => string;
|
|
332
|
+
/** 向模型开放的场景预设;缺省全部开放,空数组等于关闭预设。不认识的名字直接忽略 */
|
|
333
|
+
presets?: readonly string[];
|
|
240
334
|
}
|
|
241
335
|
/** 节点树声明的 action 能力表(renderer 据此生成按钮,runtime 据此签发 nonce)。@experimental */
|
|
242
336
|
declare function collectSpecActions(spec: UiSpecNode): UiSpecActionCapability[];
|
|
@@ -289,10 +383,12 @@ interface UiSurfaceActionDispatch {
|
|
|
289
383
|
actionId: string;
|
|
290
384
|
intent: UiSpecActionCapability['intent'];
|
|
291
385
|
nonce?: string;
|
|
386
|
+
/** 提交动作所属的表单容器;单表单场景可省略 */
|
|
387
|
+
scopeId?: string;
|
|
292
388
|
value?: Record<string, unknown>;
|
|
293
389
|
cancelled?: boolean;
|
|
294
390
|
}
|
|
295
|
-
declare function toUiSurfaceActionDispatch(snapshot: UiSpecSnapshot, action: UiSpecActionCapability, value?: Record<string, unknown
|
|
391
|
+
declare function toUiSurfaceActionDispatch(snapshot: UiSpecSnapshot, action: UiSpecActionCapability, value?: Record<string, unknown>, scopeId?: string): UiSurfaceActionDispatch;
|
|
296
392
|
/** Returns undefined for malformed or non-WebSkill renderer events. @experimental */
|
|
297
393
|
declare function fromUiSurfaceActionDispatch(value: unknown): UiSurfaceActionDispatch | undefined;
|
|
298
394
|
//#endregion
|
|
@@ -316,7 +412,7 @@ interface A2uiMessage {
|
|
|
316
412
|
/** Decodes a nonce-bound action emitted by a WebSkill A2UI extension host. @experimental */
|
|
317
413
|
declare function fromA2uiSurfaceAction(event: unknown): UiSurfaceActionDispatch | undefined;
|
|
318
414
|
/** Builds the A2UI event payload an extension host sends after a user action. @experimental */
|
|
319
|
-
declare function toA2uiSurfaceAction(snapshot: UiSpecSnapshot, action: UiSpecActionCapability, value?: Record<string, unknown
|
|
415
|
+
declare function toA2uiSurfaceAction(snapshot: UiSpecSnapshot, action: UiSpecActionCapability, value?: Record<string, unknown>, scopeId?: string): {
|
|
320
416
|
name: string;
|
|
321
417
|
context: UiSurfaceActionDispatch;
|
|
322
418
|
};
|
|
@@ -512,4 +608,4 @@ interface LoadedOpenUiPeers {
|
|
|
512
608
|
*/
|
|
513
609
|
declare function loadOpenUiPeers(): Promise<LoadedOpenUiPeers>;
|
|
514
610
|
//#endregion
|
|
515
|
-
export {
|
|
611
|
+
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 };
|