@webskill/sdk 0.9.0 → 0.11.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 -2
- package/dist/agent.js +3 -1098
- package/dist/browser.d.ts +260 -11
- package/dist/browser.js +772 -52
- package/dist/{catalogComponents-DfxxfUvn-T7Ic8QFV.js → catalogComponents-BFoqpT1v-CjUBZ3bc.js} +1604 -426
- package/dist/{dist-CFmkV45C.js → dist-B-cOu08W.js} +874 -107
- package/dist/{dist-BQe1uglQ.js → dist-DTHZS2k1.js} +524 -30
- package/dist/dist-qnlI2Iup.js +1280 -0
- package/dist/{eventTypes-DbOpAECr-BjcjZVms.js → eventTypes-FllCrX-Z-DNDeHWoG.js} +9 -2
- package/dist/governance.d.ts +33 -6
- package/dist/governance.js +45 -7
- package/dist/{index-znZjobkr.d.ts → index-D3mONFHD.d.ts} +281 -11
- package/dist/{index-DXNTIa-6.d.ts → index-DACk2_XZ.d.ts} +114 -7
- package/dist/{index-lLcCpHE-.d.ts → index-DWbs58LF.d.ts} +234 -14
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/mcp.d.ts +49 -6
- package/dist/mcp.js +146 -38
- package/dist/node.d.ts +3 -3
- package/dist/node.js +52 -2
- package/dist/{openUiLibrary-DURlAxjk-Do_yqg3u.js → openUiLibrary-D5u8oIvx-BLOAQCho.js} +3 -3
- package/dist/processSandboxEntry.js +6 -0
- package/dist/sandboxWorkerEntry.js +6 -0
- package/dist/{skillVersionStore-Bl-ElD45-dMJ8Ybhb.d.ts → skillVersionStore-D-qHk9ZE-BcmFLykd.d.ts} +13 -5
- package/dist/{testing-Csg5ljNm.js → testing-WPTyXQYt.js} +26 -3
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/{types-B3n0cMZu-BDhheIhX.d.ts → types-C26b05fW-CdrRCRDb.d.ts} +55 -6
- package/dist/ui-react.d.ts +11 -2
- package/dist/ui-react.js +141 -42
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +2 -2
- package/dist/ui.d.ts +4 -4
- package/dist/ui.js +3 -3
- package/dist/{webskillLitCatalog-DwTwSBFt-BG7kL-Es.js → webskillLitCatalog-DME6PBkV-CmYNLlIT.js} +135 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as jsonRenderer, B as resolveArchiveLimits, C as computeDigest, D as exportSkills, E as escapeXml, F as parseSkillPackManifest, G as unzipWithLimits, H as signSkill, I as readResponseWithLimit, J as verifySkillSignature, K as validateSkills, L as readSkillSignature, M as messageOf, N as normalizePath, O as isAtomicTempPath, P as parseSkillMarkdown, R as renderAvailableSkillsXml, S as checkSkillRules, T as detectSkillArchiveShapeFromFs, U as signaturePayloadBytes, V as resolveInsideRoot, W as stripArchiveRoot, Y as xmlRenderer, _ as assertSafePathSegment, a as MemoryFS, b as buildManifest, c as SKILL_MANIFEST_FILE, d as SKILL_PACK_FILE, f as SKILL_SIGNATURE_FILE, g as assertRemoteUrlAllowed, h as WebSkillError, i as MANIFEST_EXCLUDED_FILES, j as keyIdOf, k as isValidSkillName, l as SKILL_NAME_MAX_LENGTH, m as SkillReader, n as DEFAULT_ARCHIVE_LIMITS, o as SIGNATURE_SCHEMA_VERSION, p as SkillDiscovery, q as verifyManifest, r as FsTrustedKeyStore, s as SKILLS_LOCKFILE, t as ATOMIC_TMP_SUFFIX_PATTERN, u as SKILL_NAME_PATTERN, v as atomicWriteText, w as detectSkillArchiveShape, x as checkDependencyCycles, y as buildCatalog, z as renderCatalogJson } from "./dist-Bev6i6Ip.js";
|
|
2
2
|
import { a as textParts, n as partsToText } from "./memoryArtifactStore-52Zn9npI-LbCQaqyx.js";
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as createWebSkillApi, A as READ_LINKED_DOCUMENT_TOOL_NAME, At as schemaSourceLabel, B as TraceRecorder, Bt as validateUiSpecNode, C as FsSessionStore, Ct as readBehaviorRecords, D as OpenAiCompatibleClient, Dt as renderUserProfileContext, E as HookRunner, Et as refineUserProfile, F as RUN_TRACE_SCHEMA_VERSION, Ft as summarizeToolCalls, G as USER_PROFILE_PROMPT_HEADER, H as USER_PROFILE_EXPORT_VERSION, I as SESSION_SCHEMA_VERSION, It as toLlmToolSpec, J as appendBehaviorRecords, K as USER_PROFILE_REFINE_PROMPT, L as SUPPORTED_DOCUMENT_MIME, Lt as toRecordDigests, M as READ_SKILL_FILE_TOOL, Mt as scriptToolName, N as READ_SKILL_FILE_TOOL_NAME, Nt as sealToolCallPairs, O as ProgressiveRouter, Ot as resolveToolName, P as RUN_SNAPSHOT_SCHEMA_VERSION, Pt as summarizeRunUsage, Q as createScriptContext, R as SerializingMemoryStore, Rt as toVercelToolSpecs, S as FsRunTraceStore, St as parseUserProfileExport, T as GoogleGenAiClient, Tt as readUserProfile, U as USER_PROFILE_KEY, V as UNSUPPORTED_DOCUMENT_MESSAGE, W as USER_PROFILE_NO_INVENTION_RULE, X as bridgeError, Y as applyUserProfileImport, Z as buildRenderResult, _ as EventBus, _t as networkUrlHost, a as ASK_USER_TOOL, at as extractUiSpecEvents, b as FsMemoryStore, bt as normalizeToolError, c as AnthropicClient, ct as fromVercelResult, d as DEFAULT_LOOP_LIMITS, dt as isNetworkAllowed, et as diffUserProfile, f as DEFAULT_MAX_DATA_SOURCE_BYTES, ft as isUnsupportedRunSnapshot, g as EMPTY_USER_PROFILE, gt as networkPolicyLibSource, h as DEFAULT_USER_PROFILE_LIMITS, ht as mergeProfileEntries, i as ASK_USER_MAX_FIELDS, it as extractTodoTraceEvents, j as READ_SKILL_FILE_INPUT_SCHEMA, jt as schemaToForm, k as READ_LINKED_DOCUMENT_TOOL, kt as sampleBehaviorRecords, l as BEHAVIOR_RECORDS_KEY, lt as fromVercelStreamPart, m as DEFAULT_MAX_DOCUMENT_TEXT_BYTES, mt as mergeCatalogEntries, n as ASK_USER_FIELD_TYPES, nt as extractChartSpec, o as ASK_USER_TOOL_NAME, ot as findUnpairedToolCalls, p as DEFAULT_MAX_DOCUMENT_BYTES, pt as listSkillScripts, q as WebSkillRuntime, r as ASK_USER_INPUT_SCHEMA, rt as extractSkillCandidate, s as AgentLoop, st as formatSkillScriptManifest, t as ALLOWED_TOOLS_EXCLUSION_REASON, tt as exportUserProfile, u as CapabilityApproval, ut as interruptedToolResult, v as FS_SESSION_PAGE_SIZE, vt as normalizeErrorCode, w as FullDisclosureRouter, wt as readProfileEntries, x as FsRunSnapshotStore, xt as parseBridgeRequest, y as FsArtifactStore, yt as normalizeToolContent, z as TEXT_BUDGETED_CONTENT_TYPES, zt as validateUiSpecEvent } from "./dist-B-cOu08W.js";
|
|
4
4
|
|
|
5
5
|
//#region src/version.ts
|
|
6
6
|
/** Generated by scripts/syncVersionConstant.mjs from packages/sdk/package.json. Do not edit by hand. */
|
|
@@ -8,7 +8,7 @@ import { $ as fromVercelStreamPart, A as SerializingMemoryStore, B as bridgeErro
|
|
|
8
8
|
* Version of the published `@webskill/sdk` package, injected at build time.
|
|
9
9
|
* @stable
|
|
10
10
|
*/
|
|
11
|
-
const SDK_VERSION = "0.
|
|
11
|
+
const SDK_VERSION = "0.11.0";
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
|
-
export { ALLOWED_TOOLS_EXCLUSION_REASON, ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, ATOMIC_TMP_SUFFIX_PATTERN, AgentLoop, AnthropicClient, BEHAVIOR_RECORDS_KEY, CapabilityApproval, DEFAULT_ARCHIVE_LIMITS, DEFAULT_LOOP_LIMITS, DEFAULT_USER_PROFILE_LIMITS, EMPTY_USER_PROFILE, EventBus, FS_SESSION_PAGE_SIZE, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FsRunTraceStore, FsSessionStore, FsTrustedKeyStore, FullDisclosureRouter, GoogleGenAiClient, HookRunner, MANIFEST_EXCLUDED_FILES, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, RUN_TRACE_SCHEMA_VERSION, SDK_VERSION, SESSION_SCHEMA_VERSION, SIGNATURE_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SKILL_SIGNATURE_FILE, SerializingMemoryStore, SkillDiscovery, SkillReader, TraceRecorder, USER_PROFILE_EXPORT_VERSION, USER_PROFILE_KEY, USER_PROFILE_NO_INVENTION_RULE, USER_PROFILE_PROMPT_HEADER, USER_PROFILE_REFINE_PROMPT, WebSkillError, WebSkillRuntime, appendBehaviorRecords, applyUserProfileImport, assertRemoteUrlAllowed, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, detectSkillArchiveShape, detectSkillArchiveShapeFromFs, diffUserProfile, escapeXml, exportSkills, exportUserProfile, extractChartSpec, extractSkillCandidate, extractTodoTraceEvents, extractUiSpecEvents, findUnpairedToolCalls, formatSkillScriptManifest, fromVercelResult, fromVercelStreamPart, interruptedToolResult, isAtomicTempPath, isNetworkAllowed, isUnsupportedRunSnapshot, isValidSkillName, jsonRenderer, keyIdOf, listSkillScripts, mergeCatalogEntries, mergeProfileEntries, messageOf, networkPolicyLibSource, networkUrlHost, normalizeErrorCode, normalizePath, normalizeToolContent, normalizeToolError, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, parseUserProfileExport, partsToText, readBehaviorRecords, readProfileEntries, readResponseWithLimit, readSkillSignature, readUserProfile, refineUserProfile, renderAvailableSkillsXml, renderCatalogJson, renderUserProfileContext, resolveArchiveLimits, resolveInsideRoot, resolveToolName, sampleBehaviorRecords, schemaSourceLabel, schemaToForm, scriptToolName, sealToolCallPairs, signSkill, signaturePayloadBytes, stripArchiveRoot, summarizeToolCalls, textParts, toLlmToolSpec, toRecordDigests, toVercelToolSpecs, unzipWithLimits, validateSkills, validateUiSpecEvent, validateUiSpecNode, verifyManifest, verifySkillSignature, xmlRenderer };
|
|
14
|
+
export { ALLOWED_TOOLS_EXCLUSION_REASON, ASK_USER_FIELD_TYPES, ASK_USER_INPUT_SCHEMA, ASK_USER_MAX_FIELDS, ASK_USER_TOOL, ASK_USER_TOOL_NAME, ATOMIC_TMP_SUFFIX_PATTERN, AgentLoop, AnthropicClient, BEHAVIOR_RECORDS_KEY, CapabilityApproval, DEFAULT_ARCHIVE_LIMITS, DEFAULT_LOOP_LIMITS, DEFAULT_MAX_DATA_SOURCE_BYTES, DEFAULT_MAX_DOCUMENT_BYTES, DEFAULT_MAX_DOCUMENT_TEXT_BYTES, DEFAULT_USER_PROFILE_LIMITS, EMPTY_USER_PROFILE, EventBus, FS_SESSION_PAGE_SIZE, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FsRunTraceStore, FsSessionStore, FsTrustedKeyStore, FullDisclosureRouter, GoogleGenAiClient, HookRunner, MANIFEST_EXCLUDED_FILES, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_LINKED_DOCUMENT_TOOL, READ_LINKED_DOCUMENT_TOOL_NAME, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, RUN_TRACE_SCHEMA_VERSION, SDK_VERSION, SESSION_SCHEMA_VERSION, SIGNATURE_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SKILL_SIGNATURE_FILE, SUPPORTED_DOCUMENT_MIME, SerializingMemoryStore, SkillDiscovery, SkillReader, TEXT_BUDGETED_CONTENT_TYPES, TraceRecorder, UNSUPPORTED_DOCUMENT_MESSAGE, USER_PROFILE_EXPORT_VERSION, USER_PROFILE_KEY, USER_PROFILE_NO_INVENTION_RULE, USER_PROFILE_PROMPT_HEADER, USER_PROFILE_REFINE_PROMPT, WebSkillError, WebSkillRuntime, appendBehaviorRecords, applyUserProfileImport, assertRemoteUrlAllowed, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, detectSkillArchiveShape, detectSkillArchiveShapeFromFs, diffUserProfile, escapeXml, exportSkills, exportUserProfile, extractChartSpec, extractSkillCandidate, extractTodoTraceEvents, extractUiSpecEvents, findUnpairedToolCalls, formatSkillScriptManifest, fromVercelResult, fromVercelStreamPart, interruptedToolResult, isAtomicTempPath, isNetworkAllowed, isUnsupportedRunSnapshot, isValidSkillName, jsonRenderer, keyIdOf, listSkillScripts, mergeCatalogEntries, mergeProfileEntries, messageOf, networkPolicyLibSource, networkUrlHost, normalizeErrorCode, normalizePath, normalizeToolContent, normalizeToolError, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, parseUserProfileExport, partsToText, readBehaviorRecords, readProfileEntries, readResponseWithLimit, readSkillSignature, readUserProfile, refineUserProfile, renderAvailableSkillsXml, renderCatalogJson, renderUserProfileContext, resolveArchiveLimits, resolveInsideRoot, resolveToolName, sampleBehaviorRecords, schemaSourceLabel, schemaToForm, scriptToolName, sealToolCallPairs, signSkill, signaturePayloadBytes, stripArchiveRoot, summarizeRunUsage, summarizeToolCalls, textParts, toLlmToolSpec, toRecordDigests, toVercelToolSpecs, unzipWithLimits, validateSkills, validateUiSpecEvent, validateUiSpecNode, verifyManifest, verifySkillSignature, xmlRenderer };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { B as JsonSchema, _ as LlmToolSpec, it as SkillCatalogEntry, ot as SkillDocument } from "./types-C26b05fW-CdrRCRDb.js";
|
|
2
|
+
import { F as ExternalToolSource, P as ExternalSkillProvider, qn as mergeCatalogEntries, sn as ToolResult } from "./index-D3mONFHD.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";
|
|
@@ -141,8 +141,26 @@ declare class McpToolResolver {
|
|
|
141
141
|
*/
|
|
142
142
|
declare function endpointToolLlmName(endpoint: string, toolName: string): string;
|
|
143
143
|
declare function parseEndpointToolLlmName(endpoint: string, llmName: string): string | undefined;
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
/**
|
|
145
|
+
* 来源标识的长度上限(分册 26 §2.2)。
|
|
146
|
+
*
|
|
147
|
+
* 前缀计入工具名,而工具名进**每一次**请求 —— 长 sourceId 是持续成本。
|
|
148
|
+
* 装配期校验并给出可读错误,比运行时被 provider 拒掉好查。
|
|
149
|
+
*/
|
|
150
|
+
declare const WEB_MCP_SOURCE_ID_MAX = 24;
|
|
151
|
+
/**
|
|
152
|
+
* WebMCP 工具的 LLM 可见名。
|
|
153
|
+
*
|
|
154
|
+
* 多来源时带来源前缀(FR-26.2):三个文档都注册 `get_current_date` 是常态,
|
|
155
|
+
* 「首个来源优先」是**静默歧义** —— 模型选中的到底是哪个,谁也说不清。
|
|
156
|
+
* 不传 sourceId 时保持 0.10.0 的旧名,单来源宿主无感。
|
|
157
|
+
*/
|
|
158
|
+
declare function webMcpToolLlmName(toolName: string, sourceId?: string): string;
|
|
159
|
+
/** 解析回 `{ sourceId?, toolName }`;旧名(无来源段)解析出 `sourceId: undefined` */
|
|
160
|
+
declare function parseWebMcpToolLlmName(llmName: string, sourceIds?: readonly string[]): {
|
|
161
|
+
sourceId?: string;
|
|
162
|
+
toolName: string;
|
|
163
|
+
} | undefined;
|
|
146
164
|
//#endregion
|
|
147
165
|
//#region src/skills/temporarySkillProvider.d.ts
|
|
148
166
|
/**
|
|
@@ -241,8 +259,14 @@ interface WebMcpToolDescriptor {
|
|
|
241
259
|
*/
|
|
242
260
|
declare class ExperimentalWebMcpAdapter {
|
|
243
261
|
#private;
|
|
262
|
+
/**
|
|
263
|
+
* 多来源时的消歧标识(分册 26 FR-26.2)。不设即沿用 0.10.0 的旧工具名,
|
|
264
|
+
* 单来源宿主无感;**两个以上来源必须各自设**,否则同名工具会撞车。
|
|
265
|
+
*/
|
|
266
|
+
readonly sourceId?: string;
|
|
244
267
|
constructor(api?: BrowserModelContextLike | (() => BrowserModelContextLike | undefined), options?: {
|
|
245
268
|
enabled?: boolean;
|
|
269
|
+
sourceId?: string;
|
|
246
270
|
});
|
|
247
271
|
/**
|
|
248
272
|
* 宿主能力检测(FR-19.2/19.4):**只**看 `document.modelContext.executeTool` 是否存在,
|
|
@@ -264,6 +288,23 @@ declare class ExperimentalWebMcpAdapter {
|
|
|
264
288
|
}
|
|
265
289
|
//#endregion
|
|
266
290
|
//#region src/plugin/mcpRuntimePlugin.d.ts
|
|
291
|
+
/**
|
|
292
|
+
* 工具可见性策略(0.10.0 UI-UX5 #50.3):端点禁用 ∨ 工具禁用 ⇒ 不进 LLM tool spec,
|
|
293
|
+
* 调用侧同样拦截(模型找不到这些工具)。各判定缺省视为启用。
|
|
294
|
+
* 回调每次 listToolSpecs/call 实时求值,宿主改状态不需要重建插件。
|
|
295
|
+
*/
|
|
296
|
+
interface McpToolVisibility {
|
|
297
|
+
/** 端点级开关;返回 false 时该端点所有工具对大模型不可见 */
|
|
298
|
+
isEndpointEnabled?(endpoint: string): boolean;
|
|
299
|
+
/** 端点工具级开关;返回 false 时该工具对大模型不可见 */
|
|
300
|
+
isEndpointToolEnabled?(endpoint: string, tool: string): boolean;
|
|
301
|
+
/** WebMCP 工具级开关;返回 false 时该工具对大模型不可见 */
|
|
302
|
+
/**
|
|
303
|
+
* 两级启停(FR-26.3,与端点/工具同款):`sourceId` 为空即整个来源那一组。
|
|
304
|
+
* 宿主按来源关 → 该组全灭;按工具关 → 只灭一个。
|
|
305
|
+
*/
|
|
306
|
+
isWebMcpToolEnabled?(tool: string, sourceId?: string): boolean;
|
|
307
|
+
}
|
|
267
308
|
/**
|
|
268
309
|
* runtime 扩展点实现:endpoint 注册表 + WebMCP adapter 一处装配。
|
|
269
310
|
* LLM 可见名:endpoint__tool / mcp__tool;call 时反向映射。
|
|
@@ -273,8 +314,10 @@ declare class McpRuntimePlugin implements ExternalToolSource {
|
|
|
273
314
|
readonly kind = "mcp";
|
|
274
315
|
constructor(deps: {
|
|
275
316
|
registry: EndpointRegistry<McpClientLike>;
|
|
276
|
-
webMcp?: ExperimentalWebMcpAdapter;
|
|
317
|
+
webMcp?: readonly ExperimentalWebMcpAdapter[];
|
|
277
318
|
resolver?: McpToolResolver;
|
|
319
|
+
/** 工具可见性策略(端点/工具级启停);缺省全部可见 */
|
|
320
|
+
visibility?: McpToolVisibility;
|
|
278
321
|
/** 已知的 endpoint 名(注销后仍按 MCP_ENDPOINT_UNAVAILABLE 响应,而非 TOOL_NOT_FOUND) */
|
|
279
322
|
endpoints?: string[];
|
|
280
323
|
/** endpoint 不可用时的告警出口(默认 console.warn) */
|
|
@@ -428,4 +471,4 @@ interface RemoteEndpointHandle {
|
|
|
428
471
|
*/
|
|
429
472
|
declare function connectRemoteEndpoint(registry: EndpointRegistry<McpClientLike>, config: RemoteEndpointConfig): Promise<RemoteEndpointHandle>;
|
|
430
473
|
//#endregion
|
|
431
|
-
export { type BrowserModelContextLike, EndpointRegistry, ExperimentalWebMcpAdapter, type McpClientLike, type McpOAuthClient, type McpOAuthConfig, type McpOAuthHandshake, type McpOAuthHandshakeStore, type McpOAuthProvider, type McpOAuthStage, type McpOAuthTokenStore, type McpOAuthTokens, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, type MessageChannelTransportOptions, type MessagePortLike, type RemoteEndpointConfig, type RemoteEndpointHandle, type ServedSkill, TemporarySkillProvider, type TransportState, type WebMcpToolDescriptor, type WebMcpToolLike, catalogMerge, connectRemoteEndpoint, createMemoryOAuthStores, createOAuthProvider, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
|
|
474
|
+
export { type BrowserModelContextLike, EndpointRegistry, ExperimentalWebMcpAdapter, type McpClientLike, type McpOAuthClient, type McpOAuthConfig, type McpOAuthHandshake, type McpOAuthHandshakeStore, type McpOAuthProvider, type McpOAuthStage, type McpOAuthTokenStore, type McpOAuthTokens, McpRuntimePlugin, 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 };
|
package/dist/mcp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as messageOf, g as assertRemoteUrlAllowed, h as WebSkillError } from "./dist-Bev6i6Ip.js";
|
|
2
|
-
import {
|
|
2
|
+
import { mt as mergeCatalogEntries, yt as normalizeToolContent } from "./dist-B-cOu08W.js";
|
|
3
3
|
|
|
4
4
|
//#region ../mcp/dist/index.js
|
|
5
5
|
/**
|
|
@@ -249,6 +249,11 @@ var McpToolResolver = class {
|
|
|
249
249
|
return failure$1("TOOL_EXECUTION_FAILED", text || "MCP tool returned an error");
|
|
250
250
|
}
|
|
251
251
|
for (const item of content) if (item.text !== void 0 && item.text.length > MAX_MCP_RESULT_TEXT_BYTES) item.text = `${item.text.slice(0, MAX_MCP_RESULT_TEXT_BYTES)}…[truncated ${item.text.length - MAX_MCP_RESULT_TEXT_BYTES} chars]`;
|
|
252
|
+
const structured = result?.structuredContent;
|
|
253
|
+
if (typeof structured === "object" && structured !== null) content.push({
|
|
254
|
+
type: "json",
|
|
255
|
+
data: structured
|
|
256
|
+
});
|
|
252
257
|
return {
|
|
253
258
|
ok: true,
|
|
254
259
|
content
|
|
@@ -267,11 +272,35 @@ function parseEndpointToolLlmName(endpoint, llmName) {
|
|
|
267
272
|
const prefix = `${endpoint}__`;
|
|
268
273
|
return llmName.startsWith(prefix) && llmName.length > prefix.length ? llmName.slice(prefix.length) : void 0;
|
|
269
274
|
}
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
/**
|
|
276
|
+
* 来源标识的长度上限(分册 26 §2.2)。
|
|
277
|
+
*
|
|
278
|
+
* 前缀计入工具名,而工具名进**每一次**请求 —— 长 sourceId 是持续成本。
|
|
279
|
+
* 装配期校验并给出可读错误,比运行时被 provider 拒掉好查。
|
|
280
|
+
*/
|
|
281
|
+
const WEB_MCP_SOURCE_ID_MAX = 24;
|
|
282
|
+
/**
|
|
283
|
+
* WebMCP 工具的 LLM 可见名。
|
|
284
|
+
*
|
|
285
|
+
* 多来源时带来源前缀(FR-26.2):三个文档都注册 `get_current_date` 是常态,
|
|
286
|
+
* 「首个来源优先」是**静默歧义** —— 模型选中的到底是哪个,谁也说不清。
|
|
287
|
+
* 不传 sourceId 时保持 0.10.0 的旧名,单来源宿主无感。
|
|
288
|
+
*/
|
|
289
|
+
function webMcpToolLlmName(toolName, sourceId) {
|
|
290
|
+
return sourceId === void 0 ? `mcp__${toolName}` : `mcp__${sourceId}__${toolName}`;
|
|
272
291
|
}
|
|
273
|
-
|
|
274
|
-
|
|
292
|
+
/** 解析回 `{ sourceId?, toolName }`;旧名(无来源段)解析出 `sourceId: undefined` */
|
|
293
|
+
function parseWebMcpToolLlmName(llmName, sourceIds = []) {
|
|
294
|
+
if (!llmName.startsWith("mcp__") || llmName.length <= 5) return void 0;
|
|
295
|
+
const rest = llmName.slice(5);
|
|
296
|
+
for (const sourceId of sourceIds) {
|
|
297
|
+
const sourcePrefix = `${sourceId}__`;
|
|
298
|
+
if (rest.startsWith(sourcePrefix) && rest.length > sourcePrefix.length) return {
|
|
299
|
+
sourceId,
|
|
300
|
+
toolName: rest.slice(sourcePrefix.length)
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
return { toolName: rest };
|
|
275
304
|
}
|
|
276
305
|
const textOfContent = (content) => {
|
|
277
306
|
if (typeof content === "string") return content;
|
|
@@ -354,6 +383,10 @@ async function loadFromJSONSchema() {
|
|
|
354
383
|
throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", "The \"zod\" package is required to serve skills as MCP tools; install it first (npm i zod)", e);
|
|
355
384
|
}
|
|
356
385
|
}
|
|
386
|
+
/** MCP 的 structuredContent 必须是对象(规范用 `z.record`):数组与标量不适用 */
|
|
387
|
+
function isPlainObject(value) {
|
|
388
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
389
|
+
}
|
|
357
390
|
/** 注册端:在页面 MCP server 上一行声明动态技能(prompt + resources + tools) */
|
|
358
391
|
async function serveSkillAsMcp(server, skill) {
|
|
359
392
|
server.registerPrompt(skill.name, { description: skill.description }, async () => ({ messages: [{
|
|
@@ -372,13 +405,18 @@ async function serveSkillAsMcp(server, skill) {
|
|
|
372
405
|
description: tool.description ?? "",
|
|
373
406
|
...tool.inputSchema ? { inputSchema: (await loadFromJSONSchema())(tool.inputSchema) } : {}
|
|
374
407
|
}, async (args) => {
|
|
375
|
-
|
|
408
|
+
const value = await tool.handler(args ?? {});
|
|
409
|
+
const content = normalizeToolContent(value).map((item) => item.type === "text" ? {
|
|
376
410
|
type: "text",
|
|
377
411
|
text: item.text ?? ""
|
|
378
412
|
} : {
|
|
379
413
|
type: "text",
|
|
380
414
|
text: JSON.stringify(item.data ?? null)
|
|
381
|
-
})
|
|
415
|
+
});
|
|
416
|
+
return isPlainObject(value) ? {
|
|
417
|
+
content,
|
|
418
|
+
structuredContent: value
|
|
419
|
+
} : { content };
|
|
382
420
|
});
|
|
383
421
|
}
|
|
384
422
|
/**
|
|
@@ -394,6 +432,14 @@ const failure = (code, message) => ({
|
|
|
394
432
|
message
|
|
395
433
|
}
|
|
396
434
|
});
|
|
435
|
+
/**
|
|
436
|
+
* `executeTool` 按 MCP 规范返回 `{ content: [...] }`,但也有页面直接返回分片数组或裸值。
|
|
437
|
+
* 先解包 `content` 再归一——不解包的话规范形状会被整体序列化成一段 JSON 文本,
|
|
438
|
+
* 模型读到的不是工具答案而是一层信封。与 McpToolResolver 同一口径。
|
|
439
|
+
*/
|
|
440
|
+
function unwrapToolContent(raw) {
|
|
441
|
+
return normalizeToolContent((typeof raw === "object" && raw !== null ? raw.content : void 0) ?? raw);
|
|
442
|
+
}
|
|
397
443
|
/** getTools() 返回的工具 → 描述符:inputSchema 为 JSON 字符串时解析为对象,并保留原始对象 */
|
|
398
444
|
function toDescriptor(raw) {
|
|
399
445
|
if (typeof raw !== "object" || raw === null) return void 0;
|
|
@@ -437,9 +483,19 @@ function extractToolDescriptors(raw) {
|
|
|
437
483
|
var ExperimentalWebMcpAdapter = class {
|
|
438
484
|
#resolveApi;
|
|
439
485
|
#enabled;
|
|
486
|
+
/**
|
|
487
|
+
* 多来源时的消歧标识(分册 26 FR-26.2)。不设即沿用 0.10.0 的旧工具名,
|
|
488
|
+
* 单来源宿主无感;**两个以上来源必须各自设**,否则同名工具会撞车。
|
|
489
|
+
*/
|
|
490
|
+
sourceId;
|
|
440
491
|
constructor(api, options) {
|
|
441
492
|
this.#resolveApi = typeof api === "function" ? api : () => api;
|
|
442
493
|
this.#enabled = options?.enabled ?? false;
|
|
494
|
+
if (options?.sourceId !== void 0) {
|
|
495
|
+
if (!/^[a-zA-Z0-9-]+$/.test(options.sourceId)) throw new WebSkillError("VALIDATION_FAILED", `WebMCP sourceId "${options.sourceId}" may only contain letters, digits and hyphens.`);
|
|
496
|
+
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.`);
|
|
497
|
+
this.sourceId = options.sourceId;
|
|
498
|
+
}
|
|
443
499
|
}
|
|
444
500
|
/**
|
|
445
501
|
* 宿主能力检测(FR-19.2/19.4):**只**看 `document.modelContext.executeTool` 是否存在,
|
|
@@ -486,7 +542,7 @@ var ExperimentalWebMcpAdapter = class {
|
|
|
486
542
|
const tool = match?.raw ?? { name: toolName };
|
|
487
543
|
return {
|
|
488
544
|
ok: true,
|
|
489
|
-
content:
|
|
545
|
+
content: unwrapToolContent(await api.executeTool(tool, argsJson))
|
|
490
546
|
};
|
|
491
547
|
} catch (e) {
|
|
492
548
|
return failure("TOOL_EXECUTION_FAILED", `WebMCP tool "${toolName}" failed: ${messageOf(e)}`);
|
|
@@ -494,13 +550,21 @@ var ExperimentalWebMcpAdapter = class {
|
|
|
494
550
|
try {
|
|
495
551
|
return {
|
|
496
552
|
ok: true,
|
|
497
|
-
content:
|
|
553
|
+
content: unwrapToolContent(await api.executeTool(toolName, argsJson))
|
|
498
554
|
};
|
|
499
555
|
} catch (e) {
|
|
500
556
|
return failure("TOOL_EXECUTION_FAILED", `WebMCP tool "${toolName}" failed: ${messageOf(e)}`);
|
|
501
557
|
}
|
|
502
558
|
}
|
|
503
559
|
};
|
|
560
|
+
const disabledResult = (llmToolName) => ({
|
|
561
|
+
ok: false,
|
|
562
|
+
content: [],
|
|
563
|
+
error: {
|
|
564
|
+
code: "MCP_TOOL_DISABLED",
|
|
565
|
+
message: `Tool "${llmToolName}" is disabled`
|
|
566
|
+
}
|
|
567
|
+
});
|
|
504
568
|
/**
|
|
505
569
|
* runtime 扩展点实现:endpoint 注册表 + WebMCP adapter 一处装配。
|
|
506
570
|
* LLM 可见名:endpoint__tool / mcp__tool;call 时反向映射。
|
|
@@ -509,55 +573,94 @@ var McpRuntimePlugin = class {
|
|
|
509
573
|
kind = "mcp";
|
|
510
574
|
#registry;
|
|
511
575
|
#resolver;
|
|
576
|
+
/**
|
|
577
|
+
* 多来源(分册 26 FR-26.1):**不做聚合适配器**。
|
|
578
|
+
* 聚合会让「部分来源可用」无法回答,把 0.9.0 刚理清的
|
|
579
|
+
* 「不支持 / 未启用」二分重新搅浑。这里逐个问,不合并成一个布尔。
|
|
580
|
+
*/
|
|
512
581
|
#webMcp;
|
|
582
|
+
#visibility;
|
|
513
583
|
#configuredEndpoints;
|
|
514
584
|
#onWarning;
|
|
515
585
|
constructor(deps) {
|
|
516
586
|
this.#registry = deps.registry;
|
|
517
587
|
this.#resolver = deps.resolver ?? new McpToolResolver(deps.registry);
|
|
518
|
-
this.#webMcp = deps.webMcp;
|
|
588
|
+
this.#webMcp = deps.webMcp ?? [];
|
|
589
|
+
this.#visibility = deps.visibility;
|
|
519
590
|
this.#configuredEndpoints = deps.endpoints ?? [];
|
|
520
591
|
this.#onWarning = deps.onWarning ?? ((message) => console.warn(message));
|
|
521
592
|
}
|
|
522
593
|
#endpoints() {
|
|
523
594
|
return [.../* @__PURE__ */ new Set([...this.#configuredEndpoints, ...this.#registry.endpoints()])];
|
|
524
595
|
}
|
|
596
|
+
/** 端点级可见性:未接策略或判定非 false 即启用 */
|
|
597
|
+
#endpointEnabled(endpoint) {
|
|
598
|
+
return this.#visible(() => this.#visibility?.isEndpointEnabled?.(endpoint));
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* 可见性回调统一求值:宿主注入的回调抛异常时按「放行 + 告警」处理。
|
|
602
|
+
* 可见性不是安全闸门(安全由审批链兜底),异常关闭会让整轮工具集消失、
|
|
603
|
+
* 模型转而幻觉;放行代价更小,但必须走 onWarning,否则宿主回调 bug 被静默吞掉。
|
|
604
|
+
*/
|
|
605
|
+
#visible(probe) {
|
|
606
|
+
try {
|
|
607
|
+
return probe() !== false;
|
|
608
|
+
} catch (e) {
|
|
609
|
+
this.#onWarning(`[webskill] MCP visibility callback failed; treating as enabled: ${e instanceof Error ? e.message : String(e)}`);
|
|
610
|
+
return true;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
525
613
|
async listToolSpecs() {
|
|
526
614
|
const specs = [];
|
|
527
|
-
for (const endpoint of this.#endpoints())
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
615
|
+
for (const endpoint of this.#endpoints()) {
|
|
616
|
+
if (!this.#endpointEnabled(endpoint)) continue;
|
|
617
|
+
try {
|
|
618
|
+
const { tools } = await this.#registry.get(endpoint).listTools();
|
|
619
|
+
for (const tool of tools) {
|
|
620
|
+
if (!this.#visible(() => this.#visibility?.isEndpointToolEnabled?.(endpoint, tool.name))) continue;
|
|
621
|
+
specs.push({
|
|
622
|
+
name: endpointToolLlmName(endpoint, tool.name),
|
|
623
|
+
...tool.description ? { description: `[${endpoint}] ${tool.description}` } : {},
|
|
624
|
+
inputSchema: typeof tool.inputSchema === "object" && tool.inputSchema !== null ? tool.inputSchema : {
|
|
625
|
+
type: "object",
|
|
626
|
+
properties: {}
|
|
627
|
+
}
|
|
628
|
+
});
|
|
535
629
|
}
|
|
536
|
-
})
|
|
537
|
-
|
|
538
|
-
|
|
630
|
+
} catch (e) {
|
|
631
|
+
this.#onWarning(`[webskill] MCP endpoint "${endpoint}" is unavailable; its tools are omitted from this turn: ${e instanceof Error ? e.message : String(e)}`);
|
|
632
|
+
}
|
|
539
633
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
634
|
+
for (const source of this.#webMcp) {
|
|
635
|
+
if (!source.isEnabled()) continue;
|
|
636
|
+
const tools = await source.listTools();
|
|
637
|
+
for (const tool of tools ?? []) {
|
|
638
|
+
if (!this.#visible(() => this.#visibility?.isWebMcpToolEnabled?.(tool.name, source.sourceId))) continue;
|
|
639
|
+
specs.push({
|
|
640
|
+
name: webMcpToolLlmName(tool.name, source.sourceId),
|
|
641
|
+
description: tool.description ?? `[webmcp] ${tool.name}`,
|
|
642
|
+
inputSchema: typeof tool.inputSchema === "object" && tool.inputSchema !== null ? tool.inputSchema : {
|
|
643
|
+
type: "object",
|
|
644
|
+
properties: {}
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
}
|
|
550
648
|
}
|
|
551
649
|
return specs;
|
|
552
650
|
}
|
|
651
|
+
/** 已知来源标识;解析工具名时用它切分,避免把工具名里的 `__` 当成来源分隔 */
|
|
652
|
+
#sourceIds() {
|
|
653
|
+
return this.#webMcp.map((source) => source.sourceId).filter((id) => id !== void 0);
|
|
654
|
+
}
|
|
553
655
|
canHandle(llmToolName) {
|
|
554
|
-
if (parseWebMcpToolLlmName(llmToolName) !== void 0) return true;
|
|
656
|
+
if (parseWebMcpToolLlmName(llmToolName, this.#sourceIds()) !== void 0) return true;
|
|
555
657
|
return this.#endpoints().some((endpoint) => parseEndpointToolLlmName(endpoint, llmToolName) !== void 0);
|
|
556
658
|
}
|
|
557
659
|
async call(llmToolName, args) {
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
560
|
-
|
|
660
|
+
const parsed = parseWebMcpToolLlmName(llmToolName, this.#sourceIds());
|
|
661
|
+
if (parsed !== void 0) {
|
|
662
|
+
const source = parsed.sourceId === void 0 ? this.#webMcp.find((candidate) => candidate.sourceId === void 0) : this.#webMcp.find((candidate) => candidate.sourceId === parsed.sourceId);
|
|
663
|
+
if (source === void 0) return {
|
|
561
664
|
ok: false,
|
|
562
665
|
content: [],
|
|
563
666
|
error: {
|
|
@@ -565,11 +668,16 @@ var McpRuntimePlugin = class {
|
|
|
565
668
|
message: "WebMCP adapter is not configured"
|
|
566
669
|
}
|
|
567
670
|
};
|
|
568
|
-
|
|
671
|
+
if (!this.#visible(() => this.#visibility?.isWebMcpToolEnabled?.(parsed.toolName, source.sourceId))) return disabledResult(llmToolName);
|
|
672
|
+
return source.call(parsed.toolName, args);
|
|
569
673
|
}
|
|
570
674
|
for (const endpoint of this.#endpoints()) {
|
|
571
675
|
const toolName = parseEndpointToolLlmName(endpoint, llmToolName);
|
|
572
|
-
if (toolName !== void 0)
|
|
676
|
+
if (toolName !== void 0) {
|
|
677
|
+
if (!this.#endpointEnabled(endpoint)) return disabledResult(llmToolName);
|
|
678
|
+
if (!this.#visible(() => this.#visibility?.isEndpointToolEnabled?.(endpoint, toolName))) return disabledResult(llmToolName);
|
|
679
|
+
return this.#resolver.call(endpoint, toolName, args);
|
|
680
|
+
}
|
|
573
681
|
}
|
|
574
682
|
return {
|
|
575
683
|
ok: false,
|
|
@@ -852,4 +960,4 @@ async function connectRemoteEndpoint(registry, config) {
|
|
|
852
960
|
}
|
|
853
961
|
|
|
854
962
|
//#endregion
|
|
855
|
-
export { EndpointRegistry, ExperimentalWebMcpAdapter, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, TemporarySkillProvider, catalogMerge, connectRemoteEndpoint, createMemoryOAuthStores, createOAuthProvider, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
|
|
963
|
+
export { EndpointRegistry, ExperimentalWebMcpAdapter, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, TemporarySkillProvider, WEB_MCP_SOURCE_ID_MAX, catalogMerge, connectRemoteEndpoint, createMemoryOAuthStores, createOAuthProvider, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as AuditLog,
|
|
1
|
+
import { $ as SignatureAuditSink, B as JsonSchema, Ct as VerifyResult, J as SKILL_MANIFEST_FILE, L as FileStat, M as ArchiveLimits, R as FileSystemProvider, S as UiBridge, _t as SkillsLockfile, b as RenderResultRequest, c as InteractionResponse, dt as SkillManifest, q as SKILLS_LOCKFILE, s as InteractionRequest, st as SkillInstallSource, ut as SkillManagerPort, xt as UnsignedPolicy, yt as TrustedKeyStore } from "./types-C26b05fW-CdrRCRDb.js";
|
|
2
|
+
import { Dn as WebSkillRuntimeDeps, En as WebSkillRuntime, Ft as SchemaInferer, It as ScriptExecutionContext, L as FsArtifactStore, Lt as ScriptExecutor, Mn as createScriptContext, R as FsMemoryStore, an as ToolDefinition, m as ApprovalScope, nt as NetworkPolicy, sn as ToolResult, y as BridgeCapabilities } from "./index-D3mONFHD.js";
|
|
3
|
+
import { a as AuditLog, b as SkillVersionStore, d as CandidateSkill, m as CandidateStore, r as ApprovalPolicy } from "./skillVersionStore-D-qHk9ZE-BcmFLykd.js";
|
|
4
4
|
import { n as LlmEnvConfig, s as probeLlmCapabilities, t as LlmCapabilities } from "./env-AK3cSMEA-Dli6QU5E.js";
|
|
5
5
|
import { Readable, Writable } from "node:stream";
|
|
6
6
|
//#region ../node/dist/index.d.ts
|
package/dist/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { B as resolveArchiveLimits, D as exportSkills, F as parseSkillPackManifest, G as unzipWithLimits, I as readResponseWithLimit, J as verifySkillSignature, K as validateSkills, L as readSkillSignature, M as messageOf, O as isAtomicTempPath, P as parseSkillMarkdown, V as resolveInsideRoot, _ as assertSafePathSegment, b as buildManifest, c as SKILL_MANIFEST_FILE, d as SKILL_PACK_FILE, g as assertRemoteUrlAllowed, h as WebSkillError, i as MANIFEST_EXCLUDED_FILES, k as isValidSkillName, q as verifyManifest, s as SKILLS_LOCKFILE, v as atomicWriteText } from "./dist-Bev6i6Ip.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Q as createScriptContext, X as bridgeError, b as FsMemoryStore, bt as normalizeToolError, gt as networkPolicyLibSource, q as WebSkillRuntime, u as CapabilityApproval, xt as parseBridgeRequest, y as FsArtifactStore, yt as normalizeToolContent } from "./dist-B-cOu08W.js";
|
|
3
3
|
import { i as probeLlmCapabilities } from "./env-8cY40DXB-CGnEVZby.js";
|
|
4
|
-
import { t as AUDIT_EVENT_TYPES } from "./eventTypes-
|
|
4
|
+
import { t as AUDIT_EVENT_TYPES } from "./eventTypes-FllCrX-Z-DNDeHWoG.js";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { unzipSync, zipSync } from "fflate";
|
|
7
7
|
import { existsSync, promises, realpathSync } from "node:fs";
|
|
@@ -336,6 +336,8 @@ var SandboxedScriptExecutor = class {
|
|
|
336
336
|
this.#options = options;
|
|
337
337
|
this.#capabilities = {
|
|
338
338
|
readReference: options.capabilities?.readReference ?? true,
|
|
339
|
+
readAsset: options.capabilities?.readAsset ?? true,
|
|
340
|
+
fetchData: options.capabilities?.fetchData ?? false,
|
|
339
341
|
writeArtifact: options.capabilities?.writeArtifact ?? true,
|
|
340
342
|
confirm: options.capabilities?.confirm ?? true
|
|
341
343
|
};
|
|
@@ -509,6 +511,29 @@ var SandboxedScriptExecutor = class {
|
|
|
509
511
|
value: await context.readReference(request.path)
|
|
510
512
|
};
|
|
511
513
|
}
|
|
514
|
+
case "readAsset":
|
|
515
|
+
case "readAssetBinary": {
|
|
516
|
+
const read = request.kind === "readAsset" ? context.readAsset : context.readAssetBinary;
|
|
517
|
+
if (!read) return bridgeError(request.id, "TOOL_UNSUPPORTED", "Capability \"readAsset\" is disabled");
|
|
518
|
+
const denied = await gate("readAsset", `Script "${context.skillName}" wants to read asset "${request.path}"`, { path: request.path });
|
|
519
|
+
if (denied) return denied;
|
|
520
|
+
const value = await read(request.path);
|
|
521
|
+
return {
|
|
522
|
+
id: request.id,
|
|
523
|
+
ok: true,
|
|
524
|
+
value: typeof value === "string" ? value : Array.from(value)
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
case "fetchData": {
|
|
528
|
+
if (!context.fetchData) return bridgeError(request.id, "TOOL_UNSUPPORTED", "Capability \"fetchData\" is disabled");
|
|
529
|
+
const denied = await gate("fetchData", `Script "${context.skillName}" wants to fetch data source "${request.sourceId}"`, { sourceId: request.sourceId });
|
|
530
|
+
if (denied) return denied;
|
|
531
|
+
return {
|
|
532
|
+
id: request.id,
|
|
533
|
+
ok: true,
|
|
534
|
+
value: await context.fetchData(request.sourceId, request.params)
|
|
535
|
+
};
|
|
536
|
+
}
|
|
512
537
|
case "writeArtifact": {
|
|
513
538
|
const denied = await gate("writeArtifact", `Script "${context.skillName}" wants to write artifact "${request.path}"`, {
|
|
514
539
|
path: request.path,
|
|
@@ -578,6 +603,8 @@ var ProcessSandboxExecutor = class {
|
|
|
578
603
|
this.#options = options;
|
|
579
604
|
this.#capabilities = {
|
|
580
605
|
readReference: options.capabilities?.readReference ?? true,
|
|
606
|
+
readAsset: options.capabilities?.readAsset ?? true,
|
|
607
|
+
fetchData: options.capabilities?.fetchData ?? false,
|
|
581
608
|
writeArtifact: options.capabilities?.writeArtifact ?? true,
|
|
582
609
|
confirm: options.capabilities?.confirm ?? true
|
|
583
610
|
};
|
|
@@ -858,6 +885,29 @@ var ProcessSandboxExecutor = class {
|
|
|
858
885
|
value: await context.readReference(request.path)
|
|
859
886
|
};
|
|
860
887
|
}
|
|
888
|
+
case "readAsset":
|
|
889
|
+
case "readAssetBinary": {
|
|
890
|
+
const read = request.kind === "readAsset" ? context.readAsset : context.readAssetBinary;
|
|
891
|
+
if (!read) return bridgeError(request.id, "TOOL_UNSUPPORTED", "Capability \"readAsset\" is disabled");
|
|
892
|
+
const denied = await gate("readAsset", `Script "${context.skillName}" wants to read asset "${request.path}"`, { path: request.path });
|
|
893
|
+
if (denied) return denied;
|
|
894
|
+
const value = await read(request.path);
|
|
895
|
+
return {
|
|
896
|
+
id: request.id,
|
|
897
|
+
ok: true,
|
|
898
|
+
value: typeof value === "string" ? value : Array.from(value)
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
case "fetchData": {
|
|
902
|
+
if (!context.fetchData) return bridgeError(request.id, "TOOL_UNSUPPORTED", "Capability \"fetchData\" is disabled");
|
|
903
|
+
const denied = await gate("fetchData", `Script "${context.skillName}" wants to fetch data source "${request.sourceId}"`, { sourceId: request.sourceId });
|
|
904
|
+
if (denied) return denied;
|
|
905
|
+
return {
|
|
906
|
+
id: request.id,
|
|
907
|
+
ok: true,
|
|
908
|
+
value: await context.fetchData(request.sourceId, request.params)
|
|
909
|
+
};
|
|
910
|
+
}
|
|
861
911
|
case "writeArtifact": {
|
|
862
912
|
const denied = await gate("writeArtifact", `Script "${context.skillName}" wants to write artifact "${request.path}"`, {
|
|
863
913
|
path: request.path,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CatalogNode } from "./catalogComponents-
|
|
1
|
+
import { St as uiCatalog } from "./dist-DTHZS2k1.js";
|
|
2
|
+
import { t as CatalogNode } from "./catalogComponents-BFoqpT1v-CjUBZ3bc.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Component, Fragment, createContext, useCallback, useContext, useEffect, useInsertionEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -3761,7 +3761,7 @@ function Renderer({ response, library, isStreaming = false, onAction, onStateUpd
|
|
|
3761
3761
|
const FormValidationContext = createContext(null);
|
|
3762
3762
|
|
|
3763
3763
|
//#endregion
|
|
3764
|
-
//#region ../ui-react/dist/openUiLibrary-
|
|
3764
|
+
//#region ../ui-react/dist/openUiLibrary-D5u8oIvx.js
|
|
3765
3765
|
const propsFor = (props, container) => container ? props.extend({ children: z.array(z.any()).optional() }) : props;
|
|
3766
3766
|
/**
|
|
3767
3767
|
* catalog 的 OpenUI 投影:`defineComponent` 复用同一份 zod schema 与描述,
|
|
@@ -165,6 +165,12 @@ async function main(task) {
|
|
|
165
165
|
skillName: task.skillName ?? "",
|
|
166
166
|
runId: task.runId ?? "",
|
|
167
167
|
readReference: (path) => callCapability("readReference", { path }),
|
|
168
|
+
readAsset: (path) => callCapability("readAsset", { path }),
|
|
169
|
+
fetchData: (sourceId, params) => callCapability("fetchData", {
|
|
170
|
+
sourceId,
|
|
171
|
+
params
|
|
172
|
+
}),
|
|
173
|
+
readAssetBinary: async (path) => new Uint8Array(await callCapability("readAssetBinary", { path })),
|
|
168
174
|
writeArtifact: (path, content, options) => callCapability("writeArtifact", {
|
|
169
175
|
path,
|
|
170
176
|
content: typeof content === "string" ? content : Array.from(content ?? []),
|
|
@@ -226,6 +226,12 @@ async function main() {
|
|
|
226
226
|
skillName: task.skillName ?? "",
|
|
227
227
|
runId: task.runId ?? "",
|
|
228
228
|
readReference: (path) => callCapability("readReference", { path }),
|
|
229
|
+
readAsset: (path) => callCapability("readAsset", { path }),
|
|
230
|
+
fetchData: (sourceId, params) => callCapability("fetchData", {
|
|
231
|
+
sourceId,
|
|
232
|
+
params
|
|
233
|
+
}),
|
|
234
|
+
readAssetBinary: async (path) => new Uint8Array(await callCapability("readAssetBinary", { path })),
|
|
229
235
|
writeArtifact: (path, content, options) => callCapability("writeArtifact", {
|
|
230
236
|
path,
|
|
231
237
|
content: typeof content === "string" ? content : Array.from(content ?? []),
|