@seastudio/sdk 3.0.3 → 3.0.5

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/README.md CHANGED
@@ -68,6 +68,20 @@ await preview.get('/path/to/file');
68
68
 
69
69
  说明:`@seastudio/sdk/mcp` 现在的官方稳定支持面聚焦在 raw MCP catalog、包索引和通用转换能力,不包含额外的上层适配逻辑。
70
70
 
71
+ ### 指定插件实例调用 Tool
72
+
73
+ ```typescript
74
+ import { callHostTool } from '@seastudio/sdk';
75
+
76
+ await callHostTool(
77
+ 'plugin-editor_open_file',
78
+ { path: '/tmp/demo.ts' },
79
+ { pluginInstanceId: 'plugin-123' }
80
+ );
81
+ ```
82
+
83
+ `pluginInstanceId` 是 `tools/call` 的可选协议字段,用于在同一插件存在多个实例时精确路由到目标实例。宿主在已知上下文时也可以自动补齐这个字段,因此大多数常规调用不需要手动传入。
84
+
71
85
  ### 动态加载插件 MCP
72
86
 
73
87
  ```typescript
@@ -294,10 +294,12 @@ var MCPClient = class {
294
294
  return this.timeout;
295
295
  }
296
296
  async callTool(name, args = {}, options) {
297
- return this.request("tools/call", {
297
+ const request = {
298
298
  name,
299
- arguments: args
300
- }, {
299
+ arguments: args,
300
+ ...typeof options?.pluginInstanceId === "string" && options.pluginInstanceId.trim() ? { pluginInstanceId: options.pluginInstanceId.trim() } : {}
301
+ };
302
+ return this.request("tools/call", request, {
301
303
  timeout: this.resolveToolCallTimeout(name, args, options)
302
304
  });
303
305
  }
@@ -379,11 +381,11 @@ function getDefaultClient() {
379
381
  function setDefaultClient(client) {
380
382
  defaultClient = client;
381
383
  }
382
- async function callHostTool(toolName, args = {}) {
383
- return getDefaultClient().callTool(toolName, args);
384
+ async function callHostTool(toolName, args = {}, options) {
385
+ return getDefaultClient().callTool(toolName, args, options);
384
386
  }
385
- async function callHostToolText(toolName, args = {}) {
386
- return getDefaultClient().callToolText(toolName, args);
387
+ async function callHostToolText(toolName, args = {}, options) {
388
+ return getDefaultClient().callToolText(toolName, args, options);
387
389
  }
388
390
 
389
391
  // src/mcp/core/server.ts