@opentiny/next-sdk 0.4.0 → 0.4.2

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 (149) 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 +0 -3
  6. package/dist/SimulatorMask-BHVXyogh-CARX3Rff.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 +0 -1
  10. package/dist/core.js +16 -17
  11. package/dist/index-R_HIbfUX.js +6604 -0
  12. package/dist/index.d.ts +11 -3
  13. package/dist/index.js +76 -4969
  14. package/dist/{initialize-builtin-WebMCP-HgObT902.js → initialize-builtin-WebMCP-JaoKwVlm.js} +1156 -1037
  15. package/dist/page-tools/a11y/build.d.ts +10 -0
  16. package/dist/page-tools/a11y/config.d.ts +96 -0
  17. package/dist/page-tools/a11y/constants.d.ts +11 -0
  18. package/dist/page-tools/a11y/search.d.ts +17 -0
  19. package/dist/page-tools/a11y/types.d.ts +95 -0
  20. package/dist/page-tools/a11y/utils.d.ts +55 -0
  21. package/dist/page-tools/a11y/vnode.d.ts +40 -0
  22. package/dist/page-tools/a11y-tree.d.ts +9 -99
  23. package/dist/page-tools/configs/console-cloud.d.ts +6 -0
  24. package/dist/page-tools/constants.d.ts +10 -0
  25. package/dist/page-tools/context.d.ts +40 -0
  26. package/dist/page-tools/handlers/browserState.d.ts +8 -0
  27. package/dist/page-tools/handlers/click.d.ts +8 -0
  28. package/dist/page-tools/handlers/executeJavascript.d.ts +8 -0
  29. package/dist/page-tools/handlers/fill.d.ts +8 -0
  30. package/dist/page-tools/handlers/scroll.d.ts +8 -0
  31. package/dist/page-tools/handlers/searchTree.d.ts +9 -0
  32. package/dist/page-tools/handlers/select.d.ts +8 -0
  33. package/dist/page-tools/page-agent-highlight/index.d.ts +21 -0
  34. package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +16 -0
  35. package/dist/page-tools/page-agent-mask/checkDarkMode.d.ts +5 -0
  36. package/dist/page-tools/page-agent-tool-event.d.ts +26 -0
  37. package/dist/page-tools/page-agent-tool.d.ts +3 -8
  38. package/dist/page-tools/schema.d.ts +44 -0
  39. package/dist/page-tools/tool-config.d.ts +50 -0
  40. package/dist/page-tools/utils/dom.d.ts +6 -0
  41. package/dist/page-tools/utils/scroll.d.ts +15 -0
  42. package/dist/runtime.d.ts +7 -0
  43. package/dist/runtime.js +732 -0
  44. package/dist/utils/builtinProxy.d.ts +1 -1
  45. package/dist/vitest.config.d.ts +2 -0
  46. package/index.ts +35 -5
  47. package/package.json +23 -29
  48. package/page-tools/a11y/build.ts +74 -0
  49. package/page-tools/a11y/config.ts +465 -0
  50. package/page-tools/a11y/constants.ts +131 -0
  51. package/page-tools/a11y/search.ts +127 -0
  52. package/page-tools/a11y/types.ts +105 -0
  53. package/page-tools/a11y/utils.ts +239 -0
  54. package/page-tools/a11y/vnode.ts +439 -0
  55. package/page-tools/a11y-tree.ts +9 -527
  56. package/page-tools/bridge.ts +23 -3
  57. package/page-tools/configs/console-cloud.ts +172 -0
  58. package/page-tools/constants.ts +12 -0
  59. package/page-tools/context.ts +50 -0
  60. package/page-tools/handlers/browserState.ts +12 -0
  61. package/page-tools/handlers/click.ts +30 -0
  62. package/page-tools/handlers/executeJavascript.ts +22 -0
  63. package/page-tools/handlers/fill.ts +65 -0
  64. package/page-tools/handlers/scroll.ts +66 -0
  65. package/page-tools/handlers/searchTree.ts +27 -0
  66. package/page-tools/handlers/select.ts +39 -0
  67. package/page-tools/page-agent-highlight/index.ts +245 -0
  68. package/page-tools/page-agent-mask/SimulatorMask.module.css +14 -0
  69. package/page-tools/page-agent-mask/SimulatorMask.ts +299 -0
  70. package/page-tools/page-agent-mask/checkDarkMode.ts +181 -0
  71. package/page-tools/page-agent-mask/cursor-border.svg +3 -0
  72. package/page-tools/page-agent-mask/cursor-fill.svg +5 -0
  73. package/page-tools/page-agent-mask/cursor.module.css +70 -0
  74. package/page-tools/page-agent-mask/hauwei.svg +25 -0
  75. package/page-tools/page-agent-prompt.md +34 -18
  76. package/page-tools/page-agent-tool-event.ts +113 -0
  77. package/page-tools/page-agent-tool.ts +146 -162
  78. package/page-tools/schema.ts +52 -0
  79. package/page-tools/tool-config.ts +100 -0
  80. package/page-tools/utils/dom.ts +158 -0
  81. package/page-tools/utils/scroll.ts +58 -0
  82. package/runtime.ts +44 -0
  83. package/test/page-tools/a11y/build.test.ts +638 -0
  84. package/test/page-tools/a11y/config.test.ts +370 -0
  85. package/test/page-tools/configs/console-cloud.test.ts +168 -0
  86. package/test/page-tools/page-agent-highlight.test.ts +110 -0
  87. package/test/page-tools/page-agent-tool-dispatch.test.ts +208 -0
  88. package/test/page-tools/page-agent-tool.test.ts +102 -0
  89. package/test/page-tools/tool-config.test.ts +112 -0
  90. package/test/page-tools/utils/dom.test.ts +122 -0
  91. package/utils/builtinProxy.ts +45 -13
  92. package/vite.config.runtime.ts +22 -0
  93. package/vite.config.ts +52 -8
  94. package/vitest.config.ts +10 -0
  95. package/McpSdk.ts +0 -14
  96. package/WebAgent.ts +0 -5
  97. package/WebMcp.ts +0 -26
  98. package/Zod.ts +0 -1
  99. package/dist/McpSdk.d.ts +0 -14
  100. package/dist/SimulatorMask-BHVXyogh-BFEGpD5S.js +0 -1048
  101. package/dist/SimulatorMask-BHVXyogh-CCYbrb84.js +0 -801
  102. package/dist/WebAgent.d.ts +0 -5
  103. package/dist/WebMcp.d.ts +0 -23
  104. package/dist/Zod.d.ts +0 -1
  105. package/dist/index.es.dev.js +0 -59017
  106. package/dist/index.es.js +0 -46795
  107. package/dist/index.umd.dev.js +0 -60355
  108. package/dist/index.umd.js +0 -1248
  109. package/dist/mcpsdk@1.25.3.dev.js +0 -22780
  110. package/dist/mcpsdk@1.25.3.es.dev.js +0 -22778
  111. package/dist/mcpsdk@1.25.3.es.js +0 -16960
  112. package/dist/mcpsdk@1.25.3.js +0 -48
  113. package/dist/transport/ExtensionClientTransport.d.ts +0 -24
  114. package/dist/transport/ExtensionContentServerTransport.d.ts +0 -39
  115. package/dist/transport/ExtensionPageServerTransport.d.ts +0 -36
  116. package/dist/transport/messages.d.ts +0 -9
  117. package/dist/vite.config.mcpSdk.d.ts +0 -2
  118. package/dist/vite.config.webAgent.d.ts +0 -2
  119. package/dist/vite.config.webMcp.d.ts +0 -2
  120. package/dist/vite.config.webMcpFull.d.ts +0 -2
  121. package/dist/vite.config.zod.d.ts +0 -2
  122. package/dist/webagent.dev.js +0 -49360
  123. package/dist/webagent.es.dev.js +0 -49071
  124. package/dist/webagent.es.js +0 -39219
  125. package/dist/webagent.js +0 -642
  126. package/dist/webmcp-full.dev.js +0 -31336
  127. package/dist/webmcp-full.es.dev.js +0 -30283
  128. package/dist/webmcp-full.es.js +0 -22889
  129. package/dist/webmcp-full.js +0 -645
  130. package/dist/webmcp.dev.js +0 -9572
  131. package/dist/webmcp.es.dev.js +0 -8518
  132. package/dist/webmcp.es.js +0 -6727
  133. package/dist/webmcp.js +0 -602
  134. package/dist/zod@3.25.76.dev.js +0 -4037
  135. package/dist/zod@3.25.76.es.dev.js +0 -4033
  136. package/dist/zod@3.25.76.es.js +0 -2945
  137. package/dist/zod@3.25.76.js +0 -1
  138. package/transport/ExtensionClientTransport.ts +0 -100
  139. package/transport/ExtensionContentServerTransport.ts +0 -162
  140. package/transport/ExtensionPageServerTransport.ts +0 -149
  141. package/transport/messages.ts +0 -63
  142. package/vite-build-tsc.ts +0 -63
  143. package/vite-env.d.ts +0 -10
  144. package/vite.config.mcpSdk.ts +0 -28
  145. package/vite.config.webAgent.ts +0 -19
  146. package/vite.config.webMcp.ts +0 -40
  147. package/vite.config.webMcpFull.ts +0 -19
  148. package/vite.config.zod.ts +0 -23
  149. /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,6 @@ 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';
package/dist/core.js CHANGED
@@ -1,36 +1,35 @@
1
1
  import { default as a } from "ajv";
2
2
  import { z as t } from "zod";
3
- import { AuthClientProvider as o } from "@opentiny/next";
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
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 b, e as h, W as v, j as P, a as d, c as A, f as u, h as E, g as W, i as j, n as y, d as z, m as D, b as H, k as I, l as k } from "./initialize-builtin-WebMCP-HgObT902.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-JaoKwVlm.js";
10
10
  export {
11
- g as AgentModelProvider,
11
+ x as AgentModelProvider,
12
12
  a as Ajv,
13
- o as AuthClientProvider,
14
- b as ExtensionClientTransport,
13
+ n as AuthClientProvider,
15
14
  S as InMemoryTransport,
16
15
  l as ResourceTemplate,
17
- T as UriTemplate,
18
- h as WebMcpClient,
19
- v as WebMcpServer,
16
+ m as UriTemplate,
17
+ b as WebMcpClient,
18
+ h as WebMcpServer,
20
19
  C as completable,
21
- P as createMessageChannelClientTransport,
22
- d as createMessageChannelPairTransport,
23
- A as createMessageChannelServerTransport,
24
- u as createSSEClientTransport,
25
- E as createStreamableHTTPClientTransport,
20
+ v as createMessageChannelClientTransport,
21
+ P as createMessageChannelPairTransport,
22
+ d as createMessageChannelServerTransport,
23
+ A as createSSEClientTransport,
24
+ u as createStreamableHTTPClientTransport,
26
25
  W as getAISDKTools,
27
26
  M as getDisplayName,
28
27
  j as initializeBuiltinWebMCP,
29
28
  y as isMcpClient,
30
29
  z as isMcpServer,
31
30
  D as isMessageChannelClientTransport,
32
- H as isMessageChannelServerTransport,
33
- I as isSSEClientTransport,
34
- k as isStreamableHTTPClientTransport,
31
+ E as isMessageChannelServerTransport,
32
+ H as isSSEClientTransport,
33
+ I as isStreamableHTTPClientTransport,
35
34
  t as z
36
35
  };