@webskill/sdk 0.13.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-ExSQky4C.js → approval-BnLLCOG0.js} +277 -2934
- package/dist/browser.d.ts +327 -8
- package/dist/browser.js +1017 -51
- package/dist/{openUiLibrary-BKXW7Iwx-CWWBVOkE.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-iBm9tJL_.d.ts → index-CQYo4tcT.d.ts} +469 -10
- package/dist/{index-C3XdItd_.d.ts → index-CU2md8R1.d.ts} +26 -18
- package/dist/{index-DkvBhJQy.d.ts → index-Oc3H89TJ.d.ts} +204 -4
- 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 +56 -3
- package/dist/mcp.js +75 -5
- 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 +110 -13
- 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-Bev6i6Ip.js → skill-CAJMsLod.js} +44 -314
- package/dist/{skillVersionStore-D-qHk9ZE-DheTIwAB.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-DLctJep_-B5G4uk2u.d.ts → types-C3V6lAeO-BIf7UB2e.d.ts} +79 -4
- 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-C9lrvvMr.js → webskillLitCatalog-DSqVFQjK.js} +11 -3
- package/package.json +1 -1
- package/dist/catalogComponents-BgAJN0p8-CYEXSk45.js +0 -124384
- package/dist/client-BCM6Z3yq-qUQNkKrK.js +0 -7787
- package/dist/dist-DqcL6jKO.js +0 -3509
- package/dist/dist-DxyxmXPU-DGC-dpXf.js +0 -5621
- package/dist/dist-GK6dtjRv.js +0 -1493
- package/dist/memoryArtifactStore-52Zn9npI-LbCQaqyx.js +0 -86
- package/dist/stdio-CFMoANJJ-BxrTeXh7.js +0 -31
- package/dist/testing-WPTyXQYt.js +0 -142
- package/dist/types-WovEf4ED-CZSDiiBU.js +0 -6215
package/dist/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { K as JsonSchema, _ as LlmToolSpec, ft as SkillDocument, ut as SkillCatalogEntry } from "./types-C3V6lAeO-BIf7UB2e.js";
|
|
2
|
+
import { R as ExternalSkillProvider, _n as ToolDisclosure, fr as mergeCatalogEntries, yn as ToolResult, z as ExternalToolSource } from "./index-Oc3H89TJ.js";
|
|
3
3
|
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
4
4
|
import { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -75,6 +75,59 @@ declare class EndpointRegistry<TClient> {
|
|
|
75
75
|
waitFor(endpoint: string, timeoutMs: number): Promise<TClient>;
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
|
+
//#region src/pageHost/pageHostAnchor.d.ts
|
|
79
|
+
/**
|
|
80
|
+
* 页面宿主握手(分册 18 FR-18.1)。
|
|
81
|
+
*
|
|
82
|
+
* 页面与宿主(浏览器扩展)是两个进程,各自持有一份 `EndpointRegistry`。
|
|
83
|
+
* 页面注册的端点如果不主动交出去,宿主那边永远是空的。本模块就是那个交接口。
|
|
84
|
+
*
|
|
85
|
+
* ## 只在宿主先落位时才交
|
|
86
|
+
*
|
|
87
|
+
* 锚点由宿主在**页面脚本运行之前**植入(扩展的 `document_start` 内容脚本)。
|
|
88
|
+
* 页面没被宿主接管时锚点不存在,本模块除了一次全局属性读取之外什么都不做——
|
|
89
|
+
* 默认态是「不暴露」,不是「对全网开放」(D-18-3)。
|
|
90
|
+
*
|
|
91
|
+
* ## 挡不住同世界的脚本,这一点不粉饰
|
|
92
|
+
*
|
|
93
|
+
* 锚点在页面自己的 JS 世界里,页面上任何脚本都读得到它、也能调它的 `register()`
|
|
94
|
+
* 塞进一个假端点。nonce、私有字段、闭包**都挡不住**同世界的脚本,这在 MAIN world
|
|
95
|
+
* 里无解。因此宿主必须把握手拿到的一切当作不可信内容(FR-18.7 第 1 条)。
|
|
96
|
+
* 反过来,握手也没给页面新权限:页面脚本本来就能调用页面自己的端点。
|
|
97
|
+
*/
|
|
98
|
+
/** 宿主植入的锚点契约。SDK 只消费,不生产,也不假设宿主是浏览器扩展 */
|
|
99
|
+
interface PageHostAnchor {
|
|
100
|
+
version: 1;
|
|
101
|
+
register(endpoint: string, client: unknown): void;
|
|
102
|
+
unregister(endpoint: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* 0.14.0 分册 21:页面自荐可用的数据源。宿主可不实现,页面据此判断本宿主支不支持。
|
|
105
|
+
*
|
|
106
|
+
* 入参是 `unknown[]` 而不是结构化类型:这段内容来自页面,
|
|
107
|
+
* 标成结构化类型会让宿主侧读代码的人以为它已经被验证过了。
|
|
108
|
+
* @experimental
|
|
109
|
+
*/
|
|
110
|
+
declareDataSources?(sources: readonly unknown[]): void;
|
|
111
|
+
}
|
|
112
|
+
/** 全局属性名。宿主侧写死同一个串,改这里必须同时改宿主 */
|
|
113
|
+
declare const PAGE_HOST_ANCHOR_KEY = "__webskillPageHost";
|
|
114
|
+
/**
|
|
115
|
+
* 向宿主登记 / 注销一个端点。
|
|
116
|
+
*
|
|
117
|
+
* 全程吞异常是**刻意的**:握手是附加行为,宿主那边出任何问题都不能让页面自己的
|
|
118
|
+
* 端点注册失败。把这个 catch 去掉,一个坏掉的扩展就能让页面的 chatbot 一起坏掉。
|
|
119
|
+
*/
|
|
120
|
+
declare function notifyPageHost(kind: 'register', endpoint: string, client: unknown): void;
|
|
121
|
+
declare function notifyPageHost(kind: 'unregister', endpoint: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* 向宿主自荐本页可用的数据源(0.14.0 分册 21)。
|
|
124
|
+
*
|
|
125
|
+
* 宿主不实现该方法即静默返回:页面无从得知宿主支不支持,这正是「不知道 ≠ 没有」。
|
|
126
|
+
* 提议**不等于**可用——宿主那边它只是候选,用户点头前谁都取不到数。
|
|
127
|
+
* @experimental
|
|
128
|
+
*/
|
|
129
|
+
declare function declareDataSourcesToPageHost(sources: readonly unknown[]): void;
|
|
130
|
+
//#endregion
|
|
78
131
|
//#region src/resolver/mcpToolResolver.d.ts
|
|
79
132
|
/** MCP Client 最小接口(SDK Client 结构兼容,测试可纯对象替身) */
|
|
80
133
|
interface McpClientLike {
|
|
@@ -515,4 +568,4 @@ interface RemoteEndpointHandle {
|
|
|
515
568
|
*/
|
|
516
569
|
declare function connectRemoteEndpoint(registry: EndpointRegistry<McpClientLike>, config: RemoteEndpointConfig): Promise<RemoteEndpointHandle>;
|
|
517
570
|
//#endregion
|
|
518
|
-
export { type BrowserModelContextLike, EndpointRegistry, ExperimentalWebMcpAdapter, type McpClientLike, type McpOAuthClient, type McpOAuthConfig, type McpOAuthHandshake, type McpOAuthHandshakeStore, type McpOAuthProvider, type McpOAuthStage, type McpOAuthTokenStore, type McpOAuthTokens, McpRuntimePlugin, type McpSourceTrust, type McpToolDisclosure, McpToolResolver, type McpToolVisibility, MessageChannelTransport, type MessageChannelTransportOptions, type MessagePortLike, type RemoteEndpointConfig, type RemoteEndpointHandle, type ServedSkill, TemporarySkillProvider, type TransportState, WEB_MCP_SOURCE_ID_MAX, type WebMcpToolDescriptor, type WebMcpToolLike, catalogMerge, connectRemoteEndpoint, createMemoryOAuthStores, createOAuthProvider, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
|
|
571
|
+
export { type BrowserModelContextLike, EndpointRegistry, ExperimentalWebMcpAdapter, type McpClientLike, type McpOAuthClient, type McpOAuthConfig, type McpOAuthHandshake, type McpOAuthHandshakeStore, type McpOAuthProvider, type McpOAuthStage, type McpOAuthTokenStore, type McpOAuthTokens, McpRuntimePlugin, type McpSourceTrust, type McpToolDisclosure, McpToolResolver, type McpToolVisibility, MessageChannelTransport, type MessageChannelTransportOptions, type MessagePortLike, PAGE_HOST_ANCHOR_KEY, type PageHostAnchor, type RemoteEndpointConfig, type RemoteEndpointHandle, type ServedSkill, TemporarySkillProvider, type TransportState, WEB_MCP_SOURCE_ID_MAX, type WebMcpToolDescriptor, type WebMcpToolLike, catalogMerge, connectRemoteEndpoint, createMemoryOAuthStores, createOAuthProvider, declareDataSourcesToPageHost, endpointToolLlmName, notifyPageHost, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
|
package/dist/mcp.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as messageOf, t as WebSkillError } from "./errors-BDZNpC13.js";
|
|
2
|
+
import { t as assertRemoteUrlAllowed } from "./urlSafety-CiSuCJvX.js";
|
|
3
|
+
import { n as normalizeToolContent, t as mergeCatalogEntries } from "./external-_ZRQe-V9.js";
|
|
3
4
|
|
|
4
|
-
//#region ../mcp/
|
|
5
|
+
//#region ../mcp/src/transport/jsonRpc.ts
|
|
5
6
|
/**
|
|
6
7
|
* JSON-RPC 2.0 消息校验(守卫)。
|
|
7
8
|
* 规则:jsonrpc === '2.0';请求/通知有 method;响应有 id 且 result/error 恰好其一;
|
|
@@ -29,6 +30,9 @@ function validateJsonRpcMessage(value) {
|
|
|
29
30
|
}
|
|
30
31
|
return true;
|
|
31
32
|
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region ../mcp/src/transport/messageChannelTransport.ts
|
|
32
36
|
const currentOrigin = () => globalThis.location?.origin;
|
|
33
37
|
/**
|
|
34
38
|
* 跑在 MessageChannel/MessagePort 端点间的 MCP Transport。
|
|
@@ -112,6 +116,42 @@ var MessageChannelTransport = class {
|
|
|
112
116
|
this.onmessage?.(event.data);
|
|
113
117
|
}
|
|
114
118
|
};
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region ../mcp/src/pageHost/pageHostAnchor.ts
|
|
122
|
+
/** 全局属性名。宿主侧写死同一个串,改这里必须同时改宿主 */
|
|
123
|
+
const PAGE_HOST_ANCHOR_KEY = "__webskillPageHost";
|
|
124
|
+
function readAnchor() {
|
|
125
|
+
const raw = globalThis[PAGE_HOST_ANCHOR_KEY];
|
|
126
|
+
if (typeof raw !== "object" || raw === null) return void 0;
|
|
127
|
+
const candidate = raw;
|
|
128
|
+
if (candidate.version !== 1) return void 0;
|
|
129
|
+
if (typeof candidate.register !== "function" || typeof candidate.unregister !== "function") return void 0;
|
|
130
|
+
return candidate;
|
|
131
|
+
}
|
|
132
|
+
function notifyPageHost(kind, endpoint, client) {
|
|
133
|
+
try {
|
|
134
|
+
const anchor = readAnchor();
|
|
135
|
+
if (anchor === void 0) return;
|
|
136
|
+
if (kind === "register") anchor.register(endpoint, client);
|
|
137
|
+
else anchor.unregister(endpoint);
|
|
138
|
+
} catch {}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 向宿主自荐本页可用的数据源(0.14.0 分册 21)。
|
|
142
|
+
*
|
|
143
|
+
* 宿主不实现该方法即静默返回:页面无从得知宿主支不支持,这正是「不知道 ≠ 没有」。
|
|
144
|
+
* 提议**不等于**可用——宿主那边它只是候选,用户点头前谁都取不到数。
|
|
145
|
+
* @experimental
|
|
146
|
+
*/
|
|
147
|
+
function declareDataSourcesToPageHost(sources) {
|
|
148
|
+
try {
|
|
149
|
+
readAnchor()?.declareDataSources?.(sources);
|
|
150
|
+
} catch {}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region ../mcp/src/registry/endpointRegistry.ts
|
|
115
155
|
/** endpoint 名 → client 注册表;单调版本号,事件驱动等待(禁止轮询) */
|
|
116
156
|
var EndpointRegistry = class {
|
|
117
157
|
#clients = /* @__PURE__ */ new Map();
|
|
@@ -124,12 +164,14 @@ var EndpointRegistry = class {
|
|
|
124
164
|
this.#clients.set(endpoint, client);
|
|
125
165
|
this.#versions.set(endpoint, (this.#versions.get(endpoint) ?? 0) + 1);
|
|
126
166
|
this.#flushWaiters(endpoint);
|
|
167
|
+
notifyPageHost("register", endpoint, client);
|
|
127
168
|
}
|
|
128
169
|
/** 热替换 client,版本号 +1 */
|
|
129
170
|
set(endpoint, client) {
|
|
130
171
|
this.#clients.set(endpoint, client);
|
|
131
172
|
this.#versions.set(endpoint, (this.#versions.get(endpoint) ?? 0) + 1);
|
|
132
173
|
this.#flushWaiters(endpoint);
|
|
174
|
+
notifyPageHost("register", endpoint, client);
|
|
133
175
|
}
|
|
134
176
|
get(endpoint) {
|
|
135
177
|
const client = this.#clients.get(endpoint);
|
|
@@ -138,6 +180,7 @@ var EndpointRegistry = class {
|
|
|
138
180
|
}
|
|
139
181
|
unregister(endpoint) {
|
|
140
182
|
this.#clients.delete(endpoint);
|
|
183
|
+
notifyPageHost("unregister", endpoint);
|
|
141
184
|
}
|
|
142
185
|
version(endpoint) {
|
|
143
186
|
return this.#versions.get(endpoint) ?? 0;
|
|
@@ -172,6 +215,9 @@ var EndpointRegistry = class {
|
|
|
172
215
|
for (const resolve of queue) resolve(client);
|
|
173
216
|
}
|
|
174
217
|
};
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region ../mcp/src/resolver/mcpToolResolver.ts
|
|
175
221
|
/** MCP 结果单项 text 上限(64KB) */
|
|
176
222
|
const MAX_MCP_RESULT_TEXT_BYTES = 64 * 1024;
|
|
177
223
|
const failure$1 = (code, message) => ({
|
|
@@ -260,6 +306,9 @@ var McpToolResolver = class {
|
|
|
260
306
|
};
|
|
261
307
|
}
|
|
262
308
|
};
|
|
309
|
+
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region ../mcp/src/resolver/nameSanitize.ts
|
|
263
312
|
/**
|
|
264
313
|
* LLM 可见名消毒(OpenAI 工具名只允许 [a-zA-Z0-9_-])。
|
|
265
314
|
* 约定:`endpoint:tool` ↔ `endpoint__tool`,`mcp#tool` ↔ `mcp__tool`;
|
|
@@ -302,6 +351,9 @@ function parseWebMcpToolLlmName(llmName, sourceIds = []) {
|
|
|
302
351
|
}
|
|
303
352
|
return { toolName: rest };
|
|
304
353
|
}
|
|
354
|
+
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region ../mcp/src/skills/temporarySkillProvider.ts
|
|
305
357
|
const textOfContent = (content) => {
|
|
306
358
|
if (typeof content === "string") return content;
|
|
307
359
|
if (typeof content === "object" && content !== null) {
|
|
@@ -388,6 +440,9 @@ var TemporarySkillProvider = class {
|
|
|
388
440
|
}
|
|
389
441
|
}
|
|
390
442
|
};
|
|
443
|
+
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region ../mcp/src/skills/serveSkillAsMcp.ts
|
|
391
446
|
async function loadFromJSONSchema() {
|
|
392
447
|
try {
|
|
393
448
|
return (await import("zod")).fromJSONSchema;
|
|
@@ -431,11 +486,17 @@ async function serveSkillAsMcp(server, skill) {
|
|
|
431
486
|
} : { content };
|
|
432
487
|
});
|
|
433
488
|
}
|
|
489
|
+
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region ../mcp/src/skills/catalogMerge.ts
|
|
434
492
|
/**
|
|
435
493
|
* 本地/临时 Catalog 合并:同名本地优先;mcp:// URI 保留用于强制指定临时技能。
|
|
436
494
|
* 实现单一来源在 runtime(runtime 自身合并也用同一函数)。
|
|
437
495
|
*/
|
|
438
496
|
const catalogMerge = mergeCatalogEntries;
|
|
497
|
+
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region ../mcp/src/webmcp/experimentalWebMcpAdapter.ts
|
|
439
500
|
const failure = (code, message) => ({
|
|
440
501
|
ok: false,
|
|
441
502
|
content: [],
|
|
@@ -505,7 +566,7 @@ var ExperimentalWebMcpAdapter = class {
|
|
|
505
566
|
this.#enabled = options?.enabled ?? false;
|
|
506
567
|
if (options?.sourceId !== void 0) {
|
|
507
568
|
if (!/^[a-zA-Z0-9-]+$/.test(options.sourceId)) throw new WebSkillError("VALIDATION_FAILED", `WebMCP sourceId "${options.sourceId}" may only contain letters, digits and hyphens.`);
|
|
508
|
-
if (options.sourceId.length > 24) throw new WebSkillError("VALIDATION_FAILED", `WebMCP sourceId "${options.sourceId}" is longer than 24 characters; it is prefixed onto every tool name and therefore costs tokens on every request.`);
|
|
569
|
+
if (options.sourceId.length > 24) throw new WebSkillError("VALIDATION_FAILED", `WebMCP sourceId "${options.sourceId}" is longer than ${24} characters; it is prefixed onto every tool name and therefore costs tokens on every request.`);
|
|
509
570
|
this.sourceId = options.sourceId;
|
|
510
571
|
}
|
|
511
572
|
}
|
|
@@ -569,6 +630,9 @@ var ExperimentalWebMcpAdapter = class {
|
|
|
569
630
|
}
|
|
570
631
|
}
|
|
571
632
|
};
|
|
633
|
+
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region ../mcp/src/plugin/mcpRuntimePlugin.ts
|
|
572
636
|
const disabledResult = (llmToolName) => ({
|
|
573
637
|
ok: false,
|
|
574
638
|
content: [],
|
|
@@ -766,6 +830,9 @@ var McpRuntimePlugin = class {
|
|
|
766
830
|
};
|
|
767
831
|
}
|
|
768
832
|
};
|
|
833
|
+
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region ../mcp/src/remote/oauth.ts
|
|
769
836
|
/**
|
|
770
837
|
* 构造授权相关错误。`message` 只含端点名与阶段,`details` 只有 `{ endpoint, stage }`——
|
|
771
838
|
* 不带 `cause`:SDK 的错误 message 可能回显授权 URL 或 token 端点的响应体(AC-22.6)。
|
|
@@ -892,6 +959,9 @@ function createOAuthProvider(endpoint, config) {
|
|
|
892
959
|
}
|
|
893
960
|
};
|
|
894
961
|
}
|
|
962
|
+
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region ../mcp/src/remote/connectRemoteEndpoint.ts
|
|
895
965
|
async function loadMcpSdk() {
|
|
896
966
|
try {
|
|
897
967
|
const [client, sse, streamable, auth, errors] = await Promise.all([
|
|
@@ -1037,4 +1107,4 @@ async function connectRemoteEndpoint(registry, config) {
|
|
|
1037
1107
|
}
|
|
1038
1108
|
|
|
1039
1109
|
//#endregion
|
|
1040
|
-
export { EndpointRegistry, ExperimentalWebMcpAdapter, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, TemporarySkillProvider, WEB_MCP_SOURCE_ID_MAX, catalogMerge, connectRemoteEndpoint, createMemoryOAuthStores, createOAuthProvider, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
|
|
1110
|
+
export { EndpointRegistry, ExperimentalWebMcpAdapter, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, PAGE_HOST_ANCHOR_KEY, TemporarySkillProvider, WEB_MCP_SOURCE_ID_MAX, catalogMerge, connectRemoteEndpoint, createMemoryOAuthStores, createOAuthProvider, declareDataSourcesToPageHost, endpointToolLlmName, notifyPageHost, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region ../runtime/src/artifacts/memoryArtifactStore.ts
|
|
2
|
+
/** 内存 ArtifactStore:测试与浏览器降级用;索引随进程生命周期存在 */
|
|
3
|
+
var MemoryArtifactStore = class {
|
|
4
|
+
#byRun = /* @__PURE__ */ new Map();
|
|
5
|
+
#seq = 0;
|
|
6
|
+
async createTextArtifact(input) {
|
|
7
|
+
return this.#record({
|
|
8
|
+
runId: input.runId,
|
|
9
|
+
path: input.path,
|
|
10
|
+
type: "text",
|
|
11
|
+
size: new TextEncoder().encode(input.content).length,
|
|
12
|
+
mimeType: input.mimeType,
|
|
13
|
+
metadata: input.metadata
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async createBinaryArtifact(input) {
|
|
17
|
+
return this.#record({
|
|
18
|
+
runId: input.runId,
|
|
19
|
+
path: input.path,
|
|
20
|
+
type: "binary",
|
|
21
|
+
size: input.content.length,
|
|
22
|
+
mimeType: input.mimeType,
|
|
23
|
+
metadata: input.metadata
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async listArtifacts(runId) {
|
|
27
|
+
return [...this.#byRun.get(runId) ?? []];
|
|
28
|
+
}
|
|
29
|
+
#record(input) {
|
|
30
|
+
const artifact = {
|
|
31
|
+
id: `art-${++this.#seq}`,
|
|
32
|
+
runId: input.runId,
|
|
33
|
+
path: input.path,
|
|
34
|
+
type: input.type,
|
|
35
|
+
mimeType: input.mimeType,
|
|
36
|
+
size: input.size,
|
|
37
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
38
|
+
metadata: input.metadata
|
|
39
|
+
};
|
|
40
|
+
const list = this.#byRun.get(input.runId) ?? [];
|
|
41
|
+
list.push(artifact);
|
|
42
|
+
this.#byRun.set(input.runId, list);
|
|
43
|
+
return artifact;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { MemoryArtifactStore as t };
|