@webskill/sdk 0.0.1

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.
@@ -0,0 +1,219 @@
1
+ import { C as InteractionRequest, Mt as FileSystemProvider, X as RenderResultRequest, _ as FsMemoryStore, ct as ToolResult, g as FsArtifactStore, it as ScriptExecutor, jt as FileStat, l as BridgeCapabilities, ot as ToolDefinition, pt as UiBridge, rt as ScriptExecutionContext, w as InteractionResponse } from "./index-88KNOnbr.js";
2
+ import { Readable, Writable } from "node:stream";
3
+ //#region ../node/dist/index.d.ts
4
+ //#region src/fs/nodeFs.d.ts
5
+ /** 基于 node:fs/promises 的 FileSystemProvider;接受 `/` 风格路径,写入自动创建父目录 */
6
+ declare class NodeFS implements FileSystemProvider {
7
+ #private;
8
+ readonly kind = "node";
9
+ readText(p: string): Promise<string>;
10
+ writeText(p: string, content: string): Promise<void>;
11
+ readBinary(p: string): Promise<Uint8Array>;
12
+ writeBinary(p: string, content: Uint8Array): Promise<void>;
13
+ exists(p: string): Promise<boolean>;
14
+ stat(p: string): Promise<FileStat>;
15
+ list(p: string): Promise<FileStat[]>;
16
+ mkdir(p: string): Promise<void>;
17
+ remove(p: string, options?: {
18
+ recursive?: boolean;
19
+ }): Promise<void>;
20
+ }
21
+ //#endregion
22
+ //#region src/executor/nodeScriptExecutor.d.ts
23
+ /**
24
+ * 进程内脚本执行器。接口按沙箱语义设计(context 无隐式宿主访问),
25
+ * worker_threads 沙箱见 deferred-items D1。
26
+ */
27
+ declare class NodeScriptExecutor implements ScriptExecutor {
28
+ #private;
29
+ constructor(fs: FileSystemProvider);
30
+ loadDefinition(skillRoot: string, scriptName: string): Promise<ToolDefinition>;
31
+ execute(input: {
32
+ skillRoot: string;
33
+ scriptName: string;
34
+ args: Record<string, unknown>;
35
+ context: Parameters<ScriptExecutor['execute']>[0]['context'];
36
+ timeoutMs: number;
37
+ }): Promise<ToolResult>;
38
+ }
39
+ //#endregion
40
+ //#region src/executor/sandboxedScriptExecutor.d.ts
41
+ interface SandboxOptions {
42
+ /** 默认 { maxOldGenerationSizeMb: 64, maxYoungGenerationSizeMb: 16 } */
43
+ resourceLimits?: {
44
+ maxOldGenerationSizeMb?: number;
45
+ maxYoungGenerationSizeMb?: number;
46
+ };
47
+ /** env 白名单(仅这些变量传入 Worker;默认空) */
48
+ envWhitelist?: string[];
49
+ capabilities?: BridgeCapabilities;
50
+ }
51
+ /**
52
+ * D1:worker_threads 沙箱脚本执行器。
53
+ * 每次执行独立 Worker(resourceLimits + env 白名单),loadDefinition 同样在
54
+ * Worker 内完成(禁止主进程 import 不可信脚本);超时 terminate(可杀同步死循环)。
55
+ * 能力桥协议与浏览器同一来源(runtime/sandbox/bridgeProtocol)。
56
+ */
57
+ declare class SandboxedScriptExecutor implements ScriptExecutor {
58
+ #private;
59
+ constructor(fs: FileSystemProvider, options?: SandboxOptions);
60
+ loadDefinition(skillRoot: string, scriptName: string): Promise<ToolDefinition>;
61
+ execute(input: {
62
+ skillRoot: string;
63
+ scriptName: string;
64
+ args: Record<string, unknown>;
65
+ context: ScriptExecutionContext;
66
+ timeoutMs: number;
67
+ }): Promise<ToolResult>;
68
+ }
69
+ //#endregion
70
+ //#region src/artifacts/fileArtifactStore.d.ts
71
+ /**
72
+ * FileArtifactStore:兼容别名,语义同阶段 2-4。
73
+ * 实现已上移到 runtime 的 FsArtifactStore;node 侧保留 NodeFS 默认值。
74
+ */
75
+ declare class FileArtifactStore extends FsArtifactStore {
76
+ constructor(deps: {
77
+ root: string;
78
+ fs?: FileSystemProvider;
79
+ });
80
+ }
81
+ //#endregion
82
+ //#region src/memory/fileMemoryStore.d.ts
83
+ /**
84
+ * FileMemoryStore:兼容别名,语义同阶段 3。
85
+ * 实现已上移到 runtime 的 FsMemoryStore;node 侧保留 NodeFS 默认值。
86
+ */
87
+ declare class FileMemoryStore extends FsMemoryStore {
88
+ constructor(deps: {
89
+ root: string;
90
+ fs?: FileSystemProvider;
91
+ });
92
+ }
93
+ //#endregion
94
+ //#region src/ui/cliUiBridge.d.ts
95
+ /**
96
+ * 命令行 UiBridge:ask→问答,confirm→y/n(带默认值),
97
+ * form→逐字段提示(显示默认值与必填标记),select→编号列表。
98
+ * 输入/输出流可注入(测试用 PassThrough)。
99
+ */
100
+ declare class CliUiBridge implements UiBridge {
101
+ #private;
102
+ constructor(deps?: {
103
+ input?: Readable;
104
+ output?: Writable;
105
+ });
106
+ request(input: InteractionRequest): Promise<InteractionResponse>;
107
+ progress(input: {
108
+ runId: string;
109
+ message: string;
110
+ value?: number;
111
+ }): Promise<void>;
112
+ renderResult(input: RenderResultRequest): Promise<void>;
113
+ }
114
+ //#endregion
115
+ //#region src/skillManagement/types.d.ts
116
+ type SkillSource = {
117
+ type: 'local';
118
+ path: string;
119
+ } | {
120
+ type: 'http';
121
+ url: string;
122
+ } | {
123
+ type: 'git';
124
+ url: string;
125
+ ref?: string;
126
+ commit?: string;
127
+ } | {
128
+ type: 'npm';
129
+ packageName: string;
130
+ version?: string;
131
+ };
132
+ interface SkillManifest {
133
+ schemaVersion: 1;
134
+ name: string;
135
+ version?: string;
136
+ source: SkillSource;
137
+ installedAt: string;
138
+ integrity: {
139
+ algorithm: 'sha256';
140
+ digest: string;
141
+ };
142
+ files: Array<{
143
+ path: string;
144
+ size: number;
145
+ sha256: string;
146
+ }>;
147
+ }
148
+ interface SkillsLockfile {
149
+ schemaVersion: 1;
150
+ skills: Record<string, {
151
+ digest: string;
152
+ installedAt: string;
153
+ source: SkillSource;
154
+ }>;
155
+ }
156
+ interface VerifyResult {
157
+ ok: boolean;
158
+ mismatches: string[];
159
+ }
160
+ /** 技能目录内的安装清单文件名(不参与 files 列表与 digest) */
161
+ declare const SKILL_MANIFEST_FILE = "webskill.skill-manifest.json";
162
+ /** managed root 下的锁定文件名(不参与 files 列表与 digest) */
163
+ declare const SKILLS_LOCKFILE = "skills.lock.json";
164
+ //#endregion
165
+ //#region src/skillManagement/skillManager.d.ts
166
+ /**
167
+ * 技能管理门面:统一安装管线(staging → 解析 name → 校验 → 拷贝 → manifest → lockfile),
168
+ * 任何失败清理现场抛 INSTALL_FAILED。
169
+ */
170
+ declare class SkillManager {
171
+ #private;
172
+ constructor(deps: {
173
+ managedRoot: string;
174
+ fs?: FileSystemProvider;
175
+ fetchImpl?: typeof fetch;
176
+ });
177
+ install(source: SkillSource, options?: {
178
+ expectedSha256?: string;
179
+ }): Promise<SkillManifest>;
180
+ uninstall(name: string): Promise<void>;
181
+ verifyIntegrity(name: string): Promise<VerifyResult>;
182
+ listInstalled(): Promise<SkillsLockfile>;
183
+ exportArchive(name: string, options: {
184
+ format: 'zip' | 'tar';
185
+ outPath: string;
186
+ }): Promise<string>;
187
+ }
188
+ //#endregion
189
+ //#region src/skillManagement/export/archiveExporter.d.ts
190
+ /** 只解出归档中的 webskill.skill-manifest.json 条目(安装前预览) */
191
+ declare function readArchiveManifest(fs: FileSystemProvider, archivePath: string): Promise<SkillManifest>;
192
+ //#endregion
193
+ //#region src/env.d.ts
194
+ interface LlmEnvConfig {
195
+ baseUrl: string;
196
+ apiKey: string;
197
+ model: string;
198
+ }
199
+ /**
200
+ * 解析 .env(简单 KEY=VALUE 行解析,不引依赖),
201
+ * 读取 VITE_BASE_URL / VITE_API_KEY / VITE_MODEL_NAME;缺项返回 undefined 供测试 skip 判断。
202
+ */
203
+ declare function loadLlmConfigFromEnv(dotenvPath?: string): LlmEnvConfig | undefined;
204
+ interface LlmCapabilities {
205
+ available: boolean;
206
+ nonStreaming: boolean;
207
+ reason?: string;
208
+ }
209
+ /**
210
+ * 探测 LLM 能力(结果模块级缓存):
211
+ * - available:GET /models 可达(与 checkAvailability 同语义)
212
+ * - nonStreaming:最小非流式 chat completion(max_tokens=1,短超时);
213
+ * HTTP 400/404 或明确不支持非流式的错误 → false
214
+ * - streaming 能力由 available 推断(SSE 解析在 SDK 侧实现)
215
+ * 环境变量 VITE_LLM_NON_STREAMING=0 可显式强制 nonStreaming=false(模拟流式-only 回归)。
216
+ */
217
+ declare function probeLlmCapabilities(config: LlmEnvConfig): Promise<LlmCapabilities>;
218
+ //#endregion
219
+ export { loadLlmConfigFromEnv as _, LlmEnvConfig as a, SKILLS_LOCKFILE as c, SandboxedScriptExecutor as d, SkillManager as f, VerifyResult as g, SkillsLockfile as h, LlmCapabilities as i, SKILL_MANIFEST_FILE as l, SkillSource as m, FileArtifactStore as n, NodeFS as o, SkillManifest as p, FileMemoryStore as r, NodeScriptExecutor as s, CliUiBridge as t, SandboxOptions as u, probeLlmCapabilities as v, readArchiveManifest as y };
@@ -0,0 +1,2 @@
1
+ import { $ as RunTerminationReason, $t as jsonRenderer, A as LlmCompleteInput, At as DiscoveryResult, B as MockLlmQueueItem, Bt as SkillDocument, C as InteractionRequest, Ct as normalizeToolContent, D as LifecycleHookContext, Dt as toLlmToolSpec, E as LifecycleHook, Et as schemaToForm, F as LlmToolSpec, Ft as SKILL_NAME_MAX_LENGTH, G as ProgressiveRouter, Gt as SkillSource, H as MockUiBridge, Ht as SkillLocation, I as MemoryArtifactStore, It as SKILL_NAME_PATTERN, J as READ_SKILL_FILE_TOOL_NAME, Jt as WebSkillErrorCode, K as READ_SKILL_FILE_INPUT_SCHEMA, Kt as ValidationReport, L as MemoryStore, Lt as SkillCatalog, M as LlmResponse, Mt as FileSystemProvider, N as LlmStreamEvent, Nt as JsonSchema, O as LifecycleListener, Ot as toVercelToolSpecs, P as LlmToolCall, Pt as MemoryFS, Q as RunResult, Qt as isValidSkillName, R as MockLlmClient, Rt as SkillCatalogEntry, S as InteractionPolicy, St as mergeCatalogEntries, T as LifecycleEvent, Tt as resolveToolName, U as OpenAiCompatibleClient, Ut as SkillMetadata, V as MockUiAnswer, Vt as SkillIssue, W as OpenAiCompatibleClientConfig, Wt as SkillReader, X as RenderResultRequest, Xt as checkSkillRules, Y as RenderBlock, Yt as buildCatalog, Z as RouteResult, Zt as escapeXml, _ as FsMemoryStore, _t as bridgeError, a as AgentLoopConfig, an as validateSkills, at as SkillRouter, b as HookRunnerOptions, bt as fromVercelResult, c as ArtifactStore, ct as ToolResult, d as BridgeResponse, dt as TraceEventType, en as normalizePath, et as RuntimePhase, f as EventBus, ft as TraceRecorder, g as FsArtifactStore, gt as WebSkillRuntimeDeps, h as FormField, ht as WebSkillRuntime, i as AgentLoop, in as resolveInsideRoot, it as ScriptExecutor, j as LlmMessage, jt as FileStat, k as LlmClient, kt as CatalogRenderer, l as BridgeCapabilities, lt as TraceClock, m as ExternalToolSource, mt as VercelToolSpec, n as ASK_USER_TOOL, nn as renderAvailableSkillsXml, nt as RuntimeSession, o as AgentLoopDeps, on as xmlRenderer, ot as ToolDefinition, p as ExternalSkillProvider, pt as UiBridge, q as READ_SKILL_FILE_TOOL, qt as WebSkillError, r as ASK_USER_TOOL_NAME, rn as renderCatalogJson, rt as ScriptExecutionContext, s as Artifact, st as ToolResolution, t as ASK_USER_INPUT_SCHEMA, tn as parseSkillMarkdown, tt as RuntimeRun, u as BridgeRequest, ut as TraceEvent, v as FullDisclosureRouter, vt as buildRenderResult, w as InteractionResponse, wt as parseBridgeRequest, x as InMemoryStore, xt as fromVercelStreamPart, y as HookRunner, yt as createScriptContext, z as MockLlmHandler, zt as SkillDiscovery } from "./index-88KNOnbr.js";
2
+ export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, type AgentLoopConfig, type AgentLoopDeps, type Artifact, type ArtifactStore, type BridgeCapabilities, type BridgeRequest, type BridgeResponse, type CatalogRenderer, type DiscoveryResult, EventBus, type ExternalSkillProvider, type ExternalToolSource, type FileStat, type FileSystemProvider, type FormField, FsArtifactStore, FsMemoryStore, FullDisclosureRouter, HookRunner, type HookRunnerOptions, InMemoryStore, type InteractionPolicy, type InteractionRequest, type InteractionResponse, type JsonSchema, type LifecycleEvent, type LifecycleHook, type LifecycleHookContext, type LifecycleListener, type LlmClient, type LlmCompleteInput, type LlmMessage, type LlmResponse, type LlmStreamEvent, type LlmToolCall, type LlmToolSpec, MemoryArtifactStore, MemoryFS, type MemoryStore, MockLlmClient, type MockLlmHandler, type MockLlmQueueItem, type MockUiAnswer, MockUiBridge, OpenAiCompatibleClient, type OpenAiCompatibleClientConfig, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, type RenderBlock, type RenderResultRequest, type RouteResult, type RunResult, type RunTerminationReason, type RuntimePhase, type RuntimeRun, type RuntimeSession, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, type ScriptExecutionContext, type ScriptExecutor, type SkillCatalog, type SkillCatalogEntry, SkillDiscovery, type SkillDocument, type SkillIssue, type SkillLocation, type SkillMetadata, SkillReader, type SkillRouter, type SkillSource, type ToolDefinition, type ToolResolution, type ToolResult, type TraceClock, type TraceEvent, type TraceEventType, TraceRecorder, type UiBridge, type ValidationReport, type VercelToolSpec, WebSkillError, type WebSkillErrorCode, WebSkillRuntime, type WebSkillRuntimeDeps, bridgeError, buildCatalog, buildRenderResult, checkSkillRules, createScriptContext, escapeXml, fromVercelResult, fromVercelStreamPart, isValidSkillName, jsonRenderer, mergeCatalogEntries, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, xmlRenderer };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { A as schemaToForm, B as checkSkillRules, C as createScriptContext, D as normalizeToolContent, E as mergeCatalogEntries, F as SKILL_NAME_PATTERN, G as parseSkillMarkdown, H as isValidSkillName, I as SkillDiscovery, J as resolveInsideRoot, K as renderAvailableSkillsXml, L as SkillReader, M as toVercelToolSpecs, N as MemoryFS, O as parseBridgeRequest, P as SKILL_NAME_MAX_LENGTH, R as WebSkillError, S as buildRenderResult, T as fromVercelStreamPart, U as jsonRenderer, V as escapeXml, W as normalizePath, X as xmlRenderer, Y as validateSkills, _ as READ_SKILL_FILE_TOOL, a as EventBus, b as WebSkillRuntime, c as FullDisclosureRouter, d as MemoryArtifactStore, f as MockLlmClient, g as READ_SKILL_FILE_INPUT_SCHEMA, h as ProgressiveRouter, i as AgentLoop, j as toLlmToolSpec, k as resolveToolName, l as HookRunner, m as OpenAiCompatibleClient, n as ASK_USER_TOOL, o as FsArtifactStore, p as MockUiBridge, q as renderCatalogJson, r as ASK_USER_TOOL_NAME, s as FsMemoryStore, t as ASK_USER_INPUT_SCHEMA, u as InMemoryStore, v as READ_SKILL_FILE_TOOL_NAME, w as fromVercelResult, x as bridgeError, y as TraceRecorder, z as buildCatalog } from "./dist-B_ldNWwT.js";
2
+
3
+ export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, EventBus, FsArtifactStore, FsMemoryStore, FullDisclosureRouter, HookRunner, InMemoryStore, MemoryArtifactStore, MemoryFS, MockLlmClient, MockUiBridge, OpenAiCompatibleClient, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SkillDiscovery, SkillReader, TraceRecorder, WebSkillError, WebSkillRuntime, bridgeError, buildCatalog, buildRenderResult, checkSkillRules, createScriptContext, escapeXml, fromVercelResult, fromVercelStreamPart, isValidSkillName, jsonRenderer, mergeCatalogEntries, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, xmlRenderer };
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,237 @@
1
+ import { Bt as SkillDocument, F as LlmToolSpec, Nt as JsonSchema, Rt as SkillCatalogEntry, St as mergeCatalogEntries, ct as ToolResult, m as ExternalToolSource, p as ExternalSkillProvider } from "./index-88KNOnbr.js";
2
+ import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
3
+ import { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
4
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ //#region ../mcp/dist/index.d.ts
6
+ //#region src/transport/messagePort.d.ts
7
+ /**
8
+ * 显式 MessagePort 接口(禁止 arity 嗅探)。
9
+ * window/iframe 的 targetOrigin 差异由调用方在适配层处理,不进 transport 主体。
10
+ */
11
+ interface MessagePortLike {
12
+ postMessage(message: unknown): void;
13
+ addEventListener(type: 'message', listener: (event: {
14
+ data: unknown;
15
+ origin?: string;
16
+ }) => void): void;
17
+ removeEventListener(type: 'message', listener: (event: {
18
+ data: unknown;
19
+ }) => void): void;
20
+ start?(): void;
21
+ close?(): void;
22
+ }
23
+ //#endregion
24
+ //#region src/transport/jsonRpc.d.ts
25
+ /**
26
+ * JSON-RPC 2.0 消息校验(守卫)。
27
+ * 规则:jsonrpc === '2.0';请求/通知有 method;响应有 id 且 result/error 恰好其一;
28
+ * error 必须含数值 code 与字符串 message。
29
+ */
30
+ declare function validateJsonRpcMessage(value: unknown): boolean;
31
+ //#endregion
32
+ //#region src/transport/messageChannelTransport.d.ts
33
+ type TransportState = 'idle' | 'listening' | 'connected' | 'closed' | 'failed';
34
+ interface MessageChannelTransportOptions {
35
+ /** 缺省 = 当前 origin(无 window 环境时不校验);显式 ['*'] 才全放行 */
36
+ allowedOrigins?: string[];
37
+ /** start 后等待首个合法消息的超时;0/缺省 = 不超时 */
38
+ connectionTimeoutMs?: number;
39
+ }
40
+ /**
41
+ * 跑在 MessageChannel/MessagePort 端点间的 MCP Transport。
42
+ * 入站双重校验(origin 白名单 + JSON-RPC),失败走 onerror 不静默。
43
+ */
44
+ declare class MessageChannelTransport implements Transport {
45
+ #private;
46
+ onclose?: () => void;
47
+ onerror?: (error: Error) => void;
48
+ onmessage?: (message: JSONRPCMessage) => void;
49
+ constructor(port: MessagePortLike, options?: MessageChannelTransportOptions);
50
+ get state(): TransportState;
51
+ start(): Promise<void>;
52
+ send(message: JSONRPCMessage): Promise<void>;
53
+ close(): Promise<void>;
54
+ }
55
+ //#endregion
56
+ //#region src/registry/endpointRegistry.d.ts
57
+ /** endpoint 名 → client 注册表;单调版本号,事件驱动等待(禁止轮询) */
58
+ declare class EndpointRegistry<TClient> {
59
+ #private;
60
+ /** 注册新 endpoint;重名抛错 */
61
+ register(endpoint: string, client: TClient): void;
62
+ /** 热替换 client,版本号 +1 */
63
+ set(endpoint: string, client: TClient): void;
64
+ get(endpoint: string): TClient;
65
+ unregister(endpoint: string): void;
66
+ version(endpoint: string): number;
67
+ endpoints(): string[];
68
+ /** 事件驱动等待 endpoint 出现;超时 reject */
69
+ waitFor(endpoint: string, timeoutMs: number): Promise<TClient>;
70
+ }
71
+ //#endregion
72
+ //#region src/resolver/mcpToolResolver.d.ts
73
+ /** MCP Client 最小接口(SDK Client 结构兼容,测试可纯对象替身) */
74
+ interface McpClientLike {
75
+ listTools(): Promise<{
76
+ tools: Array<{
77
+ name: string;
78
+ description?: string;
79
+ inputSchema?: unknown;
80
+ }>;
81
+ }>;
82
+ callTool(input: {
83
+ name: string;
84
+ arguments?: Record<string, unknown>;
85
+ }): Promise<unknown>;
86
+ listPrompts(): Promise<{
87
+ prompts: Array<{
88
+ name: string;
89
+ description?: string;
90
+ }>;
91
+ }>;
92
+ getPrompt(input: {
93
+ name: string;
94
+ }): Promise<{
95
+ description?: string;
96
+ messages?: Array<{
97
+ role?: string;
98
+ content?: unknown;
99
+ }>;
100
+ }>;
101
+ listResources(): Promise<{
102
+ resources: Array<{
103
+ uri: string;
104
+ name?: string;
105
+ mimeType?: string;
106
+ }>;
107
+ }>;
108
+ readResource(input: {
109
+ uri: string;
110
+ }): Promise<{
111
+ contents?: Array<{
112
+ uri: string;
113
+ text?: string;
114
+ blob?: string;
115
+ mimeType?: string;
116
+ }>;
117
+ }>;
118
+ }
119
+ /**
120
+ * endpoint:toolName 调用 + 工具清单缓存(TTL 默认 1s + registry 版本号双失效)。
121
+ */
122
+ declare class McpToolResolver {
123
+ #private;
124
+ constructor(registry: EndpointRegistry<McpClientLike>, options?: {
125
+ cacheTtlMs?: number;
126
+ });
127
+ call(endpoint: string, toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
128
+ }
129
+ //#endregion
130
+ //#region src/resolver/nameSanitize.d.ts
131
+ /**
132
+ * LLM 可见名消毒(OpenAI 工具名只允许 [a-zA-Z0-9_-])。
133
+ * 约定:`endpoint:tool` ↔ `endpoint__tool`,`mcp#tool` ↔ `mcp__tool`;
134
+ * 反向映射基于已知前缀,无歧义。
135
+ */
136
+ declare function endpointToolLlmName(endpoint: string, toolName: string): string;
137
+ declare function parseEndpointToolLlmName(endpoint: string, llmName: string): string | undefined;
138
+ declare function webMcpToolLlmName(toolName: string): string;
139
+ declare function parseWebMcpToolLlmName(llmName: string): string | undefined;
140
+ //#endregion
141
+ //#region src/skills/temporarySkillProvider.d.ts
142
+ /**
143
+ * 消费端:endpoint 的 prompts → 临时技能(source:'mcp',随 endpoint 生灭);
144
+ * resources → 可读 references(readFile 的 path 即 resource URI)。
145
+ */
146
+ declare class TemporarySkillProvider implements ExternalSkillProvider {
147
+ #private;
148
+ constructor(deps: {
149
+ registry: EndpointRegistry<McpClientLike>;
150
+ endpoint: string;
151
+ });
152
+ /** endpoint 未注册时返回空(断开即技能消失) */
153
+ listSkills(): Promise<SkillCatalogEntry[]>;
154
+ loadSkill(name: string): Promise<SkillDocument>;
155
+ /** path 即 resource URI;blob 内容转 base64 标注 */
156
+ readFile(name: string, relativePath: string): Promise<string>;
157
+ }
158
+ //#endregion
159
+ //#region src/skills/serveSkillAsMcp.d.ts
160
+ interface ServedSkill {
161
+ name: string;
162
+ description: string;
163
+ /** SKILL.md 正文 */
164
+ body: string;
165
+ resources?: Array<{
166
+ uri: string;
167
+ name?: string;
168
+ text: string;
169
+ mimeType?: string;
170
+ }>;
171
+ tools?: Array<{
172
+ name: string;
173
+ description?: string;
174
+ inputSchema?: JsonSchema;
175
+ handler: (args: Record<string, unknown>) => Promise<unknown>;
176
+ }>;
177
+ }
178
+ /** 注册端:在页面 MCP server 上一行声明动态技能(prompt + resources + tools) */
179
+ declare function serveSkillAsMcp(server: McpServer, skill: ServedSkill): void;
180
+ //#endregion
181
+ //#region src/skills/catalogMerge.d.ts
182
+ /**
183
+ * 本地/临时 Catalog 合并:同名本地优先;mcp:// URI 保留用于强制指定临时技能。
184
+ * 实现单一来源在 runtime(runtime 自身合并也用同一函数)。
185
+ */
186
+ declare const catalogMerge: typeof mergeCatalogEntries;
187
+ //#endregion
188
+ //#region src/webmcp/experimentalWebMcpAdapter.d.ts
189
+ /** navigator.modelContext 鸭子类型(对齐浏览器 WebMCP API 草案) */
190
+ interface BrowserModelContextLike {
191
+ listTools?: () => Promise<unknown>;
192
+ executeTool?: (name: string, argsJson: string) => Promise<unknown>;
193
+ }
194
+ interface WebMcpToolDescriptor {
195
+ name: string;
196
+ description?: string;
197
+ inputSchema?: unknown;
198
+ }
199
+ /**
200
+ * Experimental WebMCP Adapter(mcp# 分支):默认关闭显式启用;
201
+ * 不可用 TOOL_UNSUPPORTED;工具不存在 MCP_TOOL_NOT_FOUND。
202
+ * api 可传对象或惰性解析函数(页面异步注入 modelContext 的场景)。
203
+ */
204
+ declare class ExperimentalWebMcpAdapter {
205
+ #private;
206
+ constructor(api?: BrowserModelContextLike | (() => BrowserModelContextLike | undefined), options?: {
207
+ enabled?: boolean;
208
+ });
209
+ isAvailable(): boolean;
210
+ /** 工具清单(listTools 缺失/失败时返回 undefined);描述含 inputSchema 时透传 */
211
+ listTools(): Promise<WebMcpToolDescriptor[] | undefined>;
212
+ /** 工具名清单(listTools 缺失/失败时返回 undefined) */
213
+ listToolNames(): Promise<string[] | undefined>;
214
+ call(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
215
+ }
216
+ //#endregion
217
+ //#region src/plugin/mcpRuntimePlugin.d.ts
218
+ /**
219
+ * runtime 扩展点实现:endpoint 注册表 + WebMCP adapter 一处装配。
220
+ * LLM 可见名:endpoint__tool / mcp__tool;call 时反向映射。
221
+ */
222
+ declare class McpRuntimePlugin implements ExternalToolSource {
223
+ #private;
224
+ readonly kind = "mcp";
225
+ constructor(deps: {
226
+ registry: EndpointRegistry<McpClientLike>;
227
+ webMcp?: ExperimentalWebMcpAdapter;
228
+ resolver?: McpToolResolver;
229
+ /** 已知的 endpoint 名(注销后仍按 MCP_ENDPOINT_UNAVAILABLE 响应,而非 TOOL_NOT_FOUND) */
230
+ endpoints?: string[];
231
+ });
232
+ listToolSpecs(): Promise<LlmToolSpec[]>;
233
+ canHandle(llmToolName: string): boolean;
234
+ call(llmToolName: string, args: Record<string, unknown>): Promise<ToolResult>;
235
+ }
236
+ //#endregion
237
+ export { type BrowserModelContextLike, EndpointRegistry, ExperimentalWebMcpAdapter, type McpClientLike, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, type MessageChannelTransportOptions, type MessagePortLike, type ServedSkill, TemporarySkillProvider, type TransportState, type WebMcpToolDescriptor, catalogMerge, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };