@opentiny/next-sdk 0.3.3 → 0.4.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.
Files changed (134) hide show
  1. package/agent/AgentModelProvider.ts +78 -81
  2. package/agent/type.ts +6 -9
  3. package/agent/utils/getAISDKTools.ts +0 -1
  4. package/agent/utils/getBuiltinMcpTools.ts +7 -7
  5. package/core.ts +1 -3
  6. package/dist/SimulatorMask-BHVXyogh-iNUb4dyF.js +361 -0
  7. package/dist/agent/type.d.ts +4 -12
  8. package/dist/agent/utils/getBuiltinMcpTools.d.ts +3 -3
  9. package/dist/core.d.ts +1 -1
  10. package/dist/core.js +18 -18
  11. package/dist/index-CXK8CcKq.js +6076 -0
  12. package/dist/index.d.ts +2 -4
  13. package/dist/index.js +57 -2783
  14. package/dist/initialize-builtin-WebMCP-rALfqS-o.js +6389 -0
  15. package/dist/page-tools/a11y/build.d.ts +11 -0
  16. package/dist/page-tools/a11y/constants.d.ts +9 -0
  17. package/dist/page-tools/a11y/search.d.ts +17 -0
  18. package/dist/page-tools/a11y/types.d.ts +104 -0
  19. package/dist/page-tools/a11y/utils.d.ts +34 -0
  20. package/dist/page-tools/a11y/vnode.d.ts +37 -0
  21. package/dist/page-tools/a11y-tree.d.ts +12 -0
  22. package/dist/page-tools/bridge.d.ts +0 -6
  23. package/dist/page-tools/constants.d.ts +22 -0
  24. package/dist/page-tools/context.d.ts +28 -0
  25. package/dist/page-tools/handlers/browserState.d.ts +8 -0
  26. package/dist/page-tools/handlers/click.d.ts +8 -0
  27. package/dist/page-tools/handlers/executeJavascript.d.ts +8 -0
  28. package/dist/page-tools/handlers/fill.d.ts +8 -0
  29. package/dist/page-tools/handlers/scroll.d.ts +8 -0
  30. package/dist/page-tools/handlers/searchTree.d.ts +8 -0
  31. package/dist/page-tools/handlers/select.d.ts +8 -0
  32. package/dist/page-tools/initialize-builtin-WebMCP.d.ts +1 -0
  33. package/dist/page-tools/page-agent-highlight/index.d.ts +9 -0
  34. package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +14 -0
  35. package/dist/page-tools/page-agent-mask/checkDarkMode.d.ts +5 -0
  36. package/dist/page-tools/page-agent-tool.d.ts +4 -0
  37. package/dist/page-tools/page-state-cache.d.ts +36 -0
  38. package/dist/page-tools/schema.d.ts +43 -0
  39. package/dist/page-tools/utils/dom.d.ts +6 -0
  40. package/dist/page-tools/utils/scroll.d.ts +15 -0
  41. package/dist/runtime.d.ts +4 -0
  42. package/dist/runtime.js +744 -0
  43. package/dist/utils/builtinProxy.d.ts +1 -1
  44. package/index.ts +2 -19
  45. package/package.json +14 -18
  46. package/page-tools/a11y/build.ts +70 -0
  47. package/page-tools/a11y/constants.ts +110 -0
  48. package/page-tools/a11y/search.ts +129 -0
  49. package/page-tools/a11y/types.ts +108 -0
  50. package/page-tools/a11y/utils.ts +266 -0
  51. package/page-tools/a11y/vnode.ts +229 -0
  52. package/page-tools/a11y-tree.ts +13 -0
  53. package/page-tools/bridge.ts +49 -15
  54. package/page-tools/constants.ts +72 -0
  55. package/page-tools/context.ts +13 -0
  56. package/page-tools/handlers/browserState.ts +12 -0
  57. package/page-tools/handlers/click.ts +26 -0
  58. package/page-tools/handlers/executeJavascript.ts +22 -0
  59. package/page-tools/handlers/fill.ts +60 -0
  60. package/page-tools/handlers/scroll.ts +66 -0
  61. package/page-tools/handlers/searchTree.ts +30 -0
  62. package/page-tools/handlers/select.ts +34 -0
  63. package/page-tools/initialize-builtin-WebMCP.ts +20 -0
  64. package/page-tools/page-agent-highlight/index.ts +198 -0
  65. package/page-tools/page-agent-mask/SimulatorMask.module.css +14 -0
  66. package/page-tools/page-agent-mask/SimulatorMask.ts +279 -0
  67. package/page-tools/page-agent-mask/checkDarkMode.ts +181 -0
  68. package/page-tools/page-agent-mask/cursor-border.svg +3 -0
  69. package/page-tools/page-agent-mask/cursor-fill.svg +5 -0
  70. package/page-tools/page-agent-mask/cursor.module.css +70 -0
  71. package/page-tools/page-agent-prompt.md +139 -0
  72. package/page-tools/page-agent-tool.ts +175 -0
  73. package/page-tools/page-state-cache.ts +78 -0
  74. package/page-tools/schema.ts +51 -0
  75. package/page-tools/utils/dom.ts +155 -0
  76. package/page-tools/utils/scroll.ts +58 -0
  77. package/runtime.ts +13 -0
  78. package/utils/builtinProxy.ts +45 -13
  79. package/vite.config.runtime.ts +22 -0
  80. package/vite.config.ts +52 -8
  81. package/McpSdk.ts +0 -14
  82. package/WebAgent.ts +0 -5
  83. package/WebMcp.ts +0 -20
  84. package/Zod.ts +0 -1
  85. package/dist/AgentModelProvider-CwqOT28f.js +0 -4198
  86. package/dist/McpSdk.d.ts +0 -14
  87. package/dist/WebAgent.d.ts +0 -5
  88. package/dist/WebMcp.d.ts +0 -20
  89. package/dist/Zod.d.ts +0 -1
  90. package/dist/index.es.dev.js +0 -53427
  91. package/dist/index.es.js +0 -42147
  92. package/dist/index.umd.dev.js +0 -53820
  93. package/dist/index.umd.js +0 -814
  94. package/dist/mcpsdk@1.25.3.dev.js +0 -22621
  95. package/dist/mcpsdk@1.25.3.es.dev.js +0 -22619
  96. package/dist/mcpsdk@1.25.3.es.js +0 -16802
  97. package/dist/mcpsdk@1.25.3.js +0 -43
  98. package/dist/transport/ExtensionClientTransport.d.ts +0 -24
  99. package/dist/transport/ExtensionContentServerTransport.d.ts +0 -39
  100. package/dist/transport/ExtensionPageServerTransport.d.ts +0 -36
  101. package/dist/transport/messages.d.ts +0 -9
  102. package/dist/vite.config.mcpSdk.d.ts +0 -2
  103. package/dist/vite.config.webAgent.d.ts +0 -2
  104. package/dist/vite.config.webMcp.d.ts +0 -2
  105. package/dist/vite.config.webMcpFull.d.ts +0 -2
  106. package/dist/vite.config.zod.d.ts +0 -2
  107. package/dist/webagent.dev.js +0 -47597
  108. package/dist/webagent.es.dev.js +0 -47204
  109. package/dist/webagent.es.js +0 -37494
  110. package/dist/webagent.js +0 -634
  111. package/dist/webmcp-full.dev.js +0 -24430
  112. package/dist/webmcp-full.es.dev.js +0 -24426
  113. package/dist/webmcp-full.es.js +0 -18333
  114. package/dist/webmcp-full.js +0 -43
  115. package/dist/webmcp.dev.js +0 -1595
  116. package/dist/webmcp.es.dev.js +0 -1589
  117. package/dist/webmcp.es.js +0 -1406
  118. package/dist/webmcp.js +0 -1
  119. package/dist/zod@3.25.76.dev.js +0 -4037
  120. package/dist/zod@3.25.76.es.dev.js +0 -4033
  121. package/dist/zod@3.25.76.es.js +0 -2945
  122. package/dist/zod@3.25.76.js +0 -1
  123. package/transport/ExtensionClientTransport.ts +0 -100
  124. package/transport/ExtensionContentServerTransport.ts +0 -162
  125. package/transport/ExtensionPageServerTransport.ts +0 -149
  126. package/transport/messages.ts +0 -63
  127. package/vite-build-tsc.ts +0 -63
  128. package/vite-env.d.ts +0 -5
  129. package/vite.config.mcpSdk.ts +0 -28
  130. package/vite.config.webAgent.ts +0 -19
  131. package/vite.config.webMcp.ts +0 -40
  132. package/vite.config.webMcpFull.ts +0 -19
  133. package/vite.config.zod.ts +0 -23
  134. /package/dist/{vite-build-tsc.d.ts → vite.config.runtime.d.ts} +0 -0
@@ -3,12 +3,12 @@ import { MCPClientConfig } from '@ai-sdk/mcp';
3
3
 
4
4
  export type MCPTransport = MCPClientConfig['transport'];
5
5
  /**
6
- * 浏览器内置 WebMCP 测试 API 接口 (如 navigator.modelContextTesting)
6
+ * 浏览器内置 WebMCP 测试 API 接口 (如 document.modelContext)
7
7
  */
8
8
  export interface BuiltinMcpClient {
9
9
  listTools?: () => Promise<any[]>;
10
10
  getTools?: () => Promise<any[]>;
11
- executeTool: (name: string, input: string) => Promise<any>;
11
+ executeTool: (tool: any, input: string) => Promise<any>;
12
12
  registerTool?: (config: {
13
13
  name: string;
14
14
  execute: (input: any) => Promise<any> | any;
@@ -56,14 +56,6 @@ export type McpServerConfig = {
56
56
  headers?: Record<string, string>;
57
57
  name?: string;
58
58
  description?: string;
59
- } | {
60
- type: 'extension';
61
- url: string;
62
- sessionId: string;
63
- useAISdkClient?: boolean;
64
- headers?: Record<string, string>;
65
- name?: string;
66
- description?: string;
67
59
  } | {
68
60
  type: 'local';
69
61
  transport: MCPTransport;
@@ -73,11 +65,11 @@ export type McpServerConfig = {
73
65
  } | {
74
66
  /**
75
67
  * 浏览器内置 WebMCP 类型。
76
- * 将 `navigator.modelContextTesting` 作为 MCP 工具数据源,
68
+ * 将 `document.modelContext` 作为 MCP 工具数据源,
77
69
  * 通过 `getBuiltinMcpTools` 适配为 ai-sdk 可调用的 ToolSet。
78
70
  */
79
71
  type: 'builtin';
80
- /** 传入 `navigator.modelContextTesting` 对象 */
72
+ /** 传入 `document.modelContext` 对象 */
81
73
  client: BuiltinMcpClient;
82
74
  name?: string;
83
75
  description?: string;
@@ -1,12 +1,12 @@
1
1
  import { ToolSet } from 'ai';
2
2
 
3
3
  /**
4
- * 将浏览器内置 WebMCP 的 `navigator.modelContext` 适配为 ai-sdk 的 ToolSet。
4
+ * 将浏览器内置 WebMCP 的 `document.modelContext` 适配为 ai-sdk 的 ToolSet。
5
5
  *
6
6
  * 类似 getAISDKTools,但数据源是浏览器原生 API 而非 MCP client。
7
- * 工具执行时通过 `executeTool(name, JSON.stringify(args))` 代理给浏览器。
7
+ * 工具执行时通过 `executeTool(toolObj, JSON.stringify(args))` 代理给浏览器。
8
8
  *
9
- * @param client - `navigator.modelContext` 对象
9
+ * @param client - `document.modelContext` 对象
10
10
  * @returns ai-sdk 格式的 ToolSet,可直接传入 streamText/generateText 的 tools 参数
11
11
  */
12
12
  export declare const getBuiltinMcpTools: (client: object | undefined | null) => Promise<ToolSet>;
package/dist/core.d.ts CHANGED
@@ -18,7 +18,7 @@ export type * from '@modelcontextprotocol/sdk/client/streamableHttp.js';
18
18
  export type * from '@modelcontextprotocol/sdk/server/mcp.js';
19
19
  export * from './WebMcpServer';
20
20
  export * from './WebMcpClient';
21
- export * from './transport/ExtensionClientTransport';
22
21
  export { AgentModelProvider } from './agent/AgentModelProvider';
23
22
  export { getAISDKTools } from './agent/utils/getAISDKTools';
24
23
  export type * from './agent/type';
24
+ export { initializeBuiltinWebMCP } from './page-tools/initialize-builtin-WebMCP';
package/dist/core.js CHANGED
@@ -2,34 +2,34 @@ import { default as a } from "ajv";
2
2
  import { z as t } from "zod";
3
3
  import { AuthClientProvider as n } from "@opentiny/next";
4
4
  import { ResourceTemplate as l } from "@modelcontextprotocol/sdk/server/mcp.js";
5
- import { UriTemplate as T } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
5
+ import { UriTemplate as m } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
6
6
  import { completable as C } from "@modelcontextprotocol/sdk/server/completable.js";
7
- import { getDisplayName as f } from "@modelcontextprotocol/sdk/shared/metadataUtils.js";
7
+ import { getDisplayName as M } from "@modelcontextprotocol/sdk/shared/metadataUtils.js";
8
8
  import { InMemoryTransport as S } from "@modelcontextprotocol/sdk/inMemory.js";
9
- import { A as g, E as h, d as v, W as b, h as d, a as A, c as P, e as E, f as u, g as W, m as j, b as y, l as D, i as H, j as I, k } from "./AgentModelProvider-CwqOT28f.js";
9
+ import { A as x, e as b, W as h, j as v, a as P, c as d, f as A, h as u, g as W, i as j, n as y, d as z, m as D, b as E, k as H, l as I } from "./initialize-builtin-WebMCP-rALfqS-o.js";
10
10
  export {
11
- g as AgentModelProvider,
11
+ x as AgentModelProvider,
12
12
  a as Ajv,
13
13
  n as AuthClientProvider,
14
- h as ExtensionClientTransport,
15
14
  S as InMemoryTransport,
16
15
  l as ResourceTemplate,
17
- T as UriTemplate,
18
- v as WebMcpClient,
19
- b as WebMcpServer,
16
+ m as UriTemplate,
17
+ b as WebMcpClient,
18
+ h as WebMcpServer,
20
19
  C as completable,
21
- d as createMessageChannelClientTransport,
22
- A as createMessageChannelPairTransport,
23
- P as createMessageChannelServerTransport,
24
- E as createSSEClientTransport,
20
+ v as createMessageChannelClientTransport,
21
+ P as createMessageChannelPairTransport,
22
+ d as createMessageChannelServerTransport,
23
+ A as createSSEClientTransport,
25
24
  u as createStreamableHTTPClientTransport,
26
25
  W as getAISDKTools,
27
- f as getDisplayName,
28
- j as isMcpClient,
29
- y as isMcpServer,
26
+ M as getDisplayName,
27
+ j as initializeBuiltinWebMCP,
28
+ y as isMcpClient,
29
+ z as isMcpServer,
30
30
  D as isMessageChannelClientTransport,
31
- H as isMessageChannelServerTransport,
32
- I as isSSEClientTransport,
33
- k as isStreamableHTTPClientTransport,
31
+ E as isMessageChannelServerTransport,
32
+ H as isSSEClientTransport,
33
+ I as isStreamableHTTPClientTransport,
34
34
  t as z
35
35
  };