@webskill/sdk 0.14.0 → 0.15.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 +3 -3
- package/dist/agent.js +2442 -3
- package/dist/{dist-Bfga1TmS.js → approval-BnLLCOG0.js} +235 -2932
- package/dist/browser.d.ts +106 -5
- package/dist/browser.js +364 -10
- package/dist/{openUiLibrary-BKXW7Iwx-DjvEnMlJ.js → dist-CTsxblSD.js} +496 -28
- package/dist/{echarts-De78wXqV.js → echarts-BE7oV_Dl.js} +1 -1
- package/dist/{env-8cY40DXB-CGnEVZby.js → env-Bj1MI2Ww.js} +1 -1
- package/dist/errors-BDZNpC13.js +22 -0
- package/dist/{eventTypes-FllCrX-Z-DNDeHWoG.js → eventTypes-Y07N8IAC.js} +14 -2
- package/dist/external-_ZRQe-V9.js +53 -0
- package/dist/governance.d.ts +15 -3
- package/dist/governance.js +86 -4
- package/dist/{index-DQwGvHAI.d.ts → index-CQYo4tcT.d.ts} +85 -6
- package/dist/{index-sd-gVKey.d.ts → index-CU2md8R1.d.ts} +26 -18
- package/dist/{index-CWoKOFBP.d.ts → index-Oc3H89TJ.d.ts} +159 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1001 -5
- package/dist/kind-DxgS8LM-.js +77 -0
- package/dist/linkedDocument-xNXF-z8n.js +94 -0
- package/dist/llm-B7lLH0ZI.js +1767 -0
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +41 -4
- package/dist/memoryArtifactStore-D6dLeY55.js +48 -0
- package/dist/miniChart-owdCdaw-.js +533 -0
- package/dist/node.d.ts +3 -3
- package/dist/node.js +106 -9
- package/dist/openUiLibrary-CY_ADoe0.js +30 -0
- package/dist/openUiSpecLang-DuOCdw9G.js +1849 -0
- package/dist/pathSecurity-B1owvJAF.js +65 -0
- package/dist/processSandboxEntry.js +5 -1
- package/dist/renderResult-D9Q-Vu2x.js +143 -0
- package/dist/{rolldown-runtime-BOF7iYI8.js → rolldown-runtime-BHkdefai.js} +1 -2
- package/dist/sandboxWorkerEntry.js +5 -1
- package/dist/{dist-D5YhlCdY.js → skill-CAJMsLod.js} +44 -372
- package/dist/{skillVersionStore-D-qHk9ZE-C0OFDTQY.d.ts → skillVersionStore-B24Jjjry-C4zomhMZ.d.ts} +14 -2
- package/dist/surface-DVGiCmwq.js +145 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +64 -3
- package/dist/{types-C3V6lAeO-BgeOvc1Y.d.ts → types-C3V6lAeO-BIf7UB2e.d.ts} +17 -1
- package/dist/types-TUydnxaj.js +78 -0
- package/dist/ui-react.d.ts +12 -5
- package/dist/ui-react.js +128548 -4729
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +11 -2
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +1254 -3
- package/dist/urlSafety-CiSuCJvX.js +65 -0
- package/dist/webSkillApi-DOOyz2G5.js +106 -0
- package/dist/{webskillLitCatalog-D_zCqeQF-swXsWoAe.js → webskillLitCatalog-DSqVFQjK.js} +11 -3
- package/package.json +1 -1
- package/dist/catalogComponents-BgAJN0p8-Cr55ouOg.js +0 -124384
- package/dist/client-BCM6Z3yq-qUQNkKrK.js +0 -7787
- package/dist/dist-BnqAkSS6.js +0 -2384
- package/dist/dist-CiaDIqkV.js +0 -3509
- package/dist/dist-DxyxmXPU-DGC-dpXf.js +0 -5621
- package/dist/memoryArtifactStore-52Zn9npI-BxtUkrgV.js +0 -86
- package/dist/stdio-CFMoANJJ-BxrTeXh7.js +0 -31
- package/dist/testing-Cm8MseLF.js +0 -142
- package/dist/types-WovEf4ED-CZSDiiBU.js +0 -6215
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { b as WebSkillError } from "./dist-D5YhlCdY.js";
|
|
2
|
-
|
|
3
|
-
//#region ../runtime/dist/memoryArtifactStore-52Zn9npI.js
|
|
4
|
-
/** 纯文本消息内容的构造快捷方式(引擎内部绝大多数消息仍是纯文本) */
|
|
5
|
-
const textParts = (text) => [{
|
|
6
|
-
type: "text",
|
|
7
|
-
text
|
|
8
|
-
}];
|
|
9
|
-
/** 取出 parts 中的文本(非文本分片在纯文本语境下无法表达,此处按丢弃处理——调用方须先校验) */
|
|
10
|
-
const partsToText = (parts) => (parts ?? []).reduce((acc, part) => part.type === "text" ? acc + part.text : acc, "");
|
|
11
|
-
/**
|
|
12
|
-
* run 的提示词文本投影:`RuntimeRun.userPrompt` 与快照都是字符串字段,
|
|
13
|
-
* 而多模态提示词里的图片/文件分片没有文本形态,用占位符标注,避免记录成空串。
|
|
14
|
-
*/
|
|
15
|
-
const promptText = (prompt) => {
|
|
16
|
-
if (typeof prompt === "string") return prompt;
|
|
17
|
-
return prompt.map((part) => part.type === "text" ? part.text : `[${part.type}: ${part.mimeType}]`).join("\n");
|
|
18
|
-
};
|
|
19
|
-
const isContentPart = (value) => {
|
|
20
|
-
if (typeof value !== "object" || value === null) return false;
|
|
21
|
-
const part = value;
|
|
22
|
-
if (part["type"] === "text") return typeof part["text"] === "string";
|
|
23
|
-
if (part["type"] === "image" || part["type"] === "file") return typeof part["mimeType"] === "string" && typeof part["data"] === "string";
|
|
24
|
-
return false;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* 0.4.0 起 `content` 是 parts 数组。旧的 `string` content 一律拒绝,不做静默转换:
|
|
28
|
-
* 转换会让「模型看到的输入」与「历史记录的输入」悄悄分叉。
|
|
29
|
-
*/
|
|
30
|
-
function validateLlmMessages(messages) {
|
|
31
|
-
messages.forEach((message, index) => {
|
|
32
|
-
if (typeof message.content === "string") throw new WebSkillError("VALIDATION_FAILED", `messages[${index}].content is a string; since schema version 2 it must be an array of content parts. Legacy data is not converted automatically.`);
|
|
33
|
-
if (!Array.isArray(message.content) || !message.content.every(isContentPart)) throw new WebSkillError("VALIDATION_FAILED", `messages[${index}].content is not a valid array of content parts`);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/** provider 不支持某类分片时的统一拒绝:静默丢弃会让模型回答一个它没看见的附件 */
|
|
37
|
-
function rejectUnsupportedPart(part, provider, where) {
|
|
38
|
-
throw new WebSkillError("VALIDATION_FAILED", `${provider} does not support ${part.type} content in ${where} messages`);
|
|
39
|
-
}
|
|
40
|
-
/** 内存 ArtifactStore:测试与浏览器降级用;索引随进程生命周期存在 */
|
|
41
|
-
var MemoryArtifactStore = class {
|
|
42
|
-
#byRun = /* @__PURE__ */ new Map();
|
|
43
|
-
#seq = 0;
|
|
44
|
-
async createTextArtifact(input) {
|
|
45
|
-
return this.#record({
|
|
46
|
-
runId: input.runId,
|
|
47
|
-
path: input.path,
|
|
48
|
-
type: "text",
|
|
49
|
-
size: new TextEncoder().encode(input.content).length,
|
|
50
|
-
mimeType: input.mimeType,
|
|
51
|
-
metadata: input.metadata
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
async createBinaryArtifact(input) {
|
|
55
|
-
return this.#record({
|
|
56
|
-
runId: input.runId,
|
|
57
|
-
path: input.path,
|
|
58
|
-
type: "binary",
|
|
59
|
-
size: input.content.length,
|
|
60
|
-
mimeType: input.mimeType,
|
|
61
|
-
metadata: input.metadata
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async listArtifacts(runId) {
|
|
65
|
-
return [...this.#byRun.get(runId) ?? []];
|
|
66
|
-
}
|
|
67
|
-
#record(input) {
|
|
68
|
-
const artifact = {
|
|
69
|
-
id: `art-${++this.#seq}`,
|
|
70
|
-
runId: input.runId,
|
|
71
|
-
path: input.path,
|
|
72
|
-
type: input.type,
|
|
73
|
-
mimeType: input.mimeType,
|
|
74
|
-
size: input.size,
|
|
75
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
76
|
-
metadata: input.metadata
|
|
77
|
-
};
|
|
78
|
-
const list = this.#byRun.get(input.runId) ?? [];
|
|
79
|
-
list.push(artifact);
|
|
80
|
-
this.#byRun.set(input.runId, list);
|
|
81
|
-
return artifact;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
export { textParts as a, rejectUnsupportedPart as i, partsToText as n, validateLlmMessages as o, promptText as r, MemoryArtifactStore as t };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { y as JSONRPCMessageSchema } from "./types-WovEf4ED-CZSDiiBU.js";
|
|
2
|
-
|
|
3
|
-
//#region ../node/dist/stdio-CFMoANJJ.js
|
|
4
|
-
/**
|
|
5
|
-
* Buffers a continuous stdio stream into discrete JSON-RPC messages.
|
|
6
|
-
*/
|
|
7
|
-
var ReadBuffer = class {
|
|
8
|
-
append(chunk) {
|
|
9
|
-
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
10
|
-
}
|
|
11
|
-
readMessage() {
|
|
12
|
-
if (!this._buffer) return null;
|
|
13
|
-
const index = this._buffer.indexOf("\n");
|
|
14
|
-
if (index === -1) return null;
|
|
15
|
-
const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
|
|
16
|
-
this._buffer = this._buffer.subarray(index + 1);
|
|
17
|
-
return deserializeMessage(line);
|
|
18
|
-
}
|
|
19
|
-
clear() {
|
|
20
|
-
this._buffer = void 0;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
function deserializeMessage(line) {
|
|
24
|
-
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
|
25
|
-
}
|
|
26
|
-
function serializeMessage(message) {
|
|
27
|
-
return JSON.stringify(message) + "\n";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { ReadBuffer, deserializeMessage, serializeMessage };
|
package/dist/testing-Cm8MseLF.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { b as WebSkillError } from "./dist-D5YhlCdY.js";
|
|
2
|
-
import { a as textParts, n as partsToText } from "./memoryArtifactStore-52Zn9npI-BxtUkrgV.js";
|
|
3
|
-
|
|
4
|
-
//#region ../runtime/dist/testing.js
|
|
5
|
-
/**
|
|
6
|
-
* 预设响应序列的确定性 LlmClient;handler 形式可按会话状态动态应答。
|
|
7
|
-
* 默认不含 stream(存量行为);构造传 { streaming: true } 启用流式:
|
|
8
|
-
* 队列项 { stream: [...] } 按预设 delta 序列产出,LlmResponse 项自动合成增量。
|
|
9
|
-
*/
|
|
10
|
-
var MockLlmClient = class {
|
|
11
|
-
calls = [];
|
|
12
|
-
stream;
|
|
13
|
-
#queue;
|
|
14
|
-
constructor(responses, options) {
|
|
15
|
-
this.#queue = [...responses];
|
|
16
|
-
if (options?.streaming) this.stream = (input) => this.#streamImpl(input);
|
|
17
|
-
}
|
|
18
|
-
async complete(input) {
|
|
19
|
-
this.calls.push(input);
|
|
20
|
-
const next = this.#queue.shift();
|
|
21
|
-
if (!next) throw new WebSkillError("LLM_REQUEST_FAILED", "MockLlmClient: response queue exhausted");
|
|
22
|
-
if (typeof next === "function") return next(input);
|
|
23
|
-
if ("stream" in next) {
|
|
24
|
-
const events = typeof next.stream === "function" ? next.stream(input) : next.stream;
|
|
25
|
-
let content = "";
|
|
26
|
-
let thinking = "";
|
|
27
|
-
let toolCalls;
|
|
28
|
-
let usage;
|
|
29
|
-
for (const event of events) if (event.type === "text-delta") content += event.delta;
|
|
30
|
-
else if (event.type === "thinking-delta") thinking += event.delta;
|
|
31
|
-
else if (event.type === "tool-calls") toolCalls = event.toolCalls;
|
|
32
|
-
else if (event.type === "done") {
|
|
33
|
-
if (event.content !== void 0) content = event.content;
|
|
34
|
-
if (event.usage !== void 0) usage = event.usage;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
content: content === "" ? void 0 : textParts(content),
|
|
38
|
-
toolCalls,
|
|
39
|
-
...thinking === "" ? {} : { thinking },
|
|
40
|
-
...usage ? { usage } : {}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return next;
|
|
44
|
-
}
|
|
45
|
-
async *#streamImpl(input) {
|
|
46
|
-
this.calls.push(input);
|
|
47
|
-
const next = this.#queue.shift();
|
|
48
|
-
if (!next) throw new WebSkillError("LLM_REQUEST_FAILED", "MockLlmClient: response queue exhausted");
|
|
49
|
-
if (typeof next !== "function" && "stream" in next) {
|
|
50
|
-
const events = typeof next.stream === "function" ? next.stream(input) : next.stream;
|
|
51
|
-
for (const event of events) yield event;
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const response = typeof next === "function" ? await next(input) : next;
|
|
55
|
-
if (response.thinking !== void 0 && response.thinking !== "") {
|
|
56
|
-
const half = Math.ceil(response.thinking.length / 2);
|
|
57
|
-
yield {
|
|
58
|
-
type: "thinking-delta",
|
|
59
|
-
delta: response.thinking.slice(0, half)
|
|
60
|
-
};
|
|
61
|
-
const rest = response.thinking.slice(half);
|
|
62
|
-
if (rest !== "") yield {
|
|
63
|
-
type: "thinking-delta",
|
|
64
|
-
delta: rest
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const text = partsToText(response.content);
|
|
68
|
-
if (text !== "") {
|
|
69
|
-
const chunkSize = Math.max(1, Math.ceil(text.length / 3));
|
|
70
|
-
for (let i = 0; i < text.length; i += chunkSize) yield {
|
|
71
|
-
type: "text-delta",
|
|
72
|
-
delta: text.slice(i, i + chunkSize)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
if (response.toolCalls?.length) yield {
|
|
76
|
-
type: "tool-calls",
|
|
77
|
-
toolCalls: response.toolCalls
|
|
78
|
-
};
|
|
79
|
-
yield {
|
|
80
|
-
type: "done",
|
|
81
|
-
...response.usage ? { usage: response.usage } : {}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* 测试用 UiBridge:按请求 id 或类型预设应答(永不 resolve 的 handler 可模拟超时);
|
|
87
|
-
* 记录全部请求供断言。
|
|
88
|
-
*/
|
|
89
|
-
var MockUiBridge = class {
|
|
90
|
-
requests = [];
|
|
91
|
-
#answers = /* @__PURE__ */ new Map();
|
|
92
|
-
#fallback;
|
|
93
|
-
/** key 为请求 id 或请求类型('ask' | 'confirm' | 'form' | 'select') */
|
|
94
|
-
respondTo(key, answer) {
|
|
95
|
-
this.#answers.set(key, answer);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
setFallback(answer) {
|
|
99
|
-
this.#fallback = answer;
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
async request(input) {
|
|
103
|
-
this.requests.push(input);
|
|
104
|
-
const answer = this.#answers.get(input.id) ?? this.#answers.get(input.type) ?? this.#fallback;
|
|
105
|
-
if (!answer) return {
|
|
106
|
-
id: input.id,
|
|
107
|
-
cancelled: true
|
|
108
|
-
};
|
|
109
|
-
return typeof answer === "function" ? answer(input) : answer;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
/** 内存 MemoryStore:测试与浏览器降级用 */
|
|
113
|
-
var InMemoryStore = class {
|
|
114
|
-
#data = /* @__PURE__ */ new Map();
|
|
115
|
-
async get(scope, key) {
|
|
116
|
-
return this.#data.get(scope)?.get(key);
|
|
117
|
-
}
|
|
118
|
-
async set(scope, key, value) {
|
|
119
|
-
let bucket = this.#data.get(scope);
|
|
120
|
-
if (!bucket) {
|
|
121
|
-
bucket = /* @__PURE__ */ new Map();
|
|
122
|
-
this.#data.set(scope, bucket);
|
|
123
|
-
}
|
|
124
|
-
bucket.set(key, value);
|
|
125
|
-
}
|
|
126
|
-
async delete(scope, key) {
|
|
127
|
-
this.#data.get(scope)?.delete(key);
|
|
128
|
-
}
|
|
129
|
-
async list(scope) {
|
|
130
|
-
return [...(this.#data.get(scope) ?? /* @__PURE__ */ new Map()).entries()].map(([key, value]) => ({
|
|
131
|
-
key,
|
|
132
|
-
value
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
async clear(scope) {
|
|
136
|
-
if (scope === void 0) this.#data.clear();
|
|
137
|
-
else this.#data.delete(scope);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
export { MockLlmClient as n, MockUiBridge as r, InMemoryStore as t };
|