@opentiny/next-sdk 0.4.0 → 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 (130) 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-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 +0 -1
  10. package/dist/core.js +16 -17
  11. package/dist/index-CXK8CcKq.js +6076 -0
  12. package/dist/index.d.ts +0 -3
  13. package/dist/index.js +57 -4969
  14. package/dist/{initialize-builtin-WebMCP-HgObT902.js → initialize-builtin-WebMCP-rALfqS-o.js} +1166 -1056
  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 +8 -99
  22. package/dist/page-tools/constants.d.ts +22 -0
  23. package/dist/page-tools/context.d.ts +28 -0
  24. package/dist/page-tools/handlers/browserState.d.ts +8 -0
  25. package/dist/page-tools/handlers/click.d.ts +8 -0
  26. package/dist/page-tools/handlers/executeJavascript.d.ts +8 -0
  27. package/dist/page-tools/handlers/fill.d.ts +8 -0
  28. package/dist/page-tools/handlers/scroll.d.ts +8 -0
  29. package/dist/page-tools/handlers/searchTree.d.ts +8 -0
  30. package/dist/page-tools/handlers/select.d.ts +8 -0
  31. package/dist/page-tools/page-agent-highlight/index.d.ts +9 -0
  32. package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +14 -0
  33. package/dist/page-tools/page-agent-mask/checkDarkMode.d.ts +5 -0
  34. package/dist/page-tools/page-agent-tool.d.ts +3 -8
  35. package/dist/page-tools/schema.d.ts +43 -0
  36. package/dist/page-tools/utils/dom.d.ts +6 -0
  37. package/dist/page-tools/utils/scroll.d.ts +15 -0
  38. package/dist/runtime.d.ts +4 -0
  39. package/dist/runtime.js +744 -0
  40. package/dist/utils/builtinProxy.d.ts +1 -1
  41. package/index.ts +0 -5
  42. package/package.json +6 -17
  43. package/page-tools/a11y/build.ts +70 -0
  44. package/page-tools/a11y/constants.ts +110 -0
  45. package/page-tools/a11y/search.ts +129 -0
  46. package/page-tools/a11y/types.ts +108 -0
  47. package/page-tools/a11y/utils.ts +266 -0
  48. package/page-tools/a11y/vnode.ts +229 -0
  49. package/page-tools/a11y-tree.ts +8 -527
  50. package/page-tools/bridge.ts +1 -1
  51. package/page-tools/constants.ts +72 -0
  52. package/page-tools/context.ts +13 -0
  53. package/page-tools/handlers/browserState.ts +12 -0
  54. package/page-tools/handlers/click.ts +26 -0
  55. package/page-tools/handlers/executeJavascript.ts +22 -0
  56. package/page-tools/handlers/fill.ts +60 -0
  57. package/page-tools/handlers/scroll.ts +66 -0
  58. package/page-tools/handlers/searchTree.ts +30 -0
  59. package/page-tools/handlers/select.ts +34 -0
  60. package/page-tools/page-agent-highlight/index.ts +198 -0
  61. package/page-tools/page-agent-mask/SimulatorMask.module.css +14 -0
  62. package/page-tools/page-agent-mask/SimulatorMask.ts +279 -0
  63. package/page-tools/page-agent-mask/checkDarkMode.ts +181 -0
  64. package/page-tools/page-agent-mask/cursor-border.svg +3 -0
  65. package/page-tools/page-agent-mask/cursor-fill.svg +5 -0
  66. package/page-tools/page-agent-mask/cursor.module.css +70 -0
  67. package/page-tools/page-agent-prompt.md +34 -18
  68. package/page-tools/page-agent-tool.ts +104 -152
  69. package/page-tools/schema.ts +51 -0
  70. package/page-tools/utils/dom.ts +155 -0
  71. package/page-tools/utils/scroll.ts +58 -0
  72. package/runtime.ts +13 -0
  73. package/utils/builtinProxy.ts +45 -13
  74. package/vite.config.runtime.ts +22 -0
  75. package/vite.config.ts +52 -8
  76. package/McpSdk.ts +0 -14
  77. package/WebAgent.ts +0 -5
  78. package/WebMcp.ts +0 -26
  79. package/Zod.ts +0 -1
  80. package/dist/McpSdk.d.ts +0 -14
  81. package/dist/SimulatorMask-BHVXyogh-BFEGpD5S.js +0 -1048
  82. package/dist/SimulatorMask-BHVXyogh-CCYbrb84.js +0 -801
  83. package/dist/WebAgent.d.ts +0 -5
  84. package/dist/WebMcp.d.ts +0 -23
  85. package/dist/Zod.d.ts +0 -1
  86. package/dist/index.es.dev.js +0 -59017
  87. package/dist/index.es.js +0 -46795
  88. package/dist/index.umd.dev.js +0 -60355
  89. package/dist/index.umd.js +0 -1248
  90. package/dist/mcpsdk@1.25.3.dev.js +0 -22780
  91. package/dist/mcpsdk@1.25.3.es.dev.js +0 -22778
  92. package/dist/mcpsdk@1.25.3.es.js +0 -16960
  93. package/dist/mcpsdk@1.25.3.js +0 -48
  94. package/dist/transport/ExtensionClientTransport.d.ts +0 -24
  95. package/dist/transport/ExtensionContentServerTransport.d.ts +0 -39
  96. package/dist/transport/ExtensionPageServerTransport.d.ts +0 -36
  97. package/dist/transport/messages.d.ts +0 -9
  98. package/dist/vite.config.mcpSdk.d.ts +0 -2
  99. package/dist/vite.config.webAgent.d.ts +0 -2
  100. package/dist/vite.config.webMcp.d.ts +0 -2
  101. package/dist/vite.config.webMcpFull.d.ts +0 -2
  102. package/dist/vite.config.zod.d.ts +0 -2
  103. package/dist/webagent.dev.js +0 -49360
  104. package/dist/webagent.es.dev.js +0 -49071
  105. package/dist/webagent.es.js +0 -39219
  106. package/dist/webagent.js +0 -642
  107. package/dist/webmcp-full.dev.js +0 -31336
  108. package/dist/webmcp-full.es.dev.js +0 -30283
  109. package/dist/webmcp-full.es.js +0 -22889
  110. package/dist/webmcp-full.js +0 -645
  111. package/dist/webmcp.dev.js +0 -9572
  112. package/dist/webmcp.es.dev.js +0 -8518
  113. package/dist/webmcp.es.js +0 -6727
  114. package/dist/webmcp.js +0 -602
  115. package/dist/zod@3.25.76.dev.js +0 -4037
  116. package/dist/zod@3.25.76.es.dev.js +0 -4033
  117. package/dist/zod@3.25.76.es.js +0 -2945
  118. package/dist/zod@3.25.76.js +0 -1
  119. package/transport/ExtensionClientTransport.ts +0 -100
  120. package/transport/ExtensionContentServerTransport.ts +0 -162
  121. package/transport/ExtensionPageServerTransport.ts +0 -149
  122. package/transport/messages.ts +0 -63
  123. package/vite-build-tsc.ts +0 -63
  124. package/vite-env.d.ts +0 -10
  125. package/vite.config.mcpSdk.ts +0 -28
  126. package/vite.config.webAgent.ts +0 -19
  127. package/vite.config.webMcp.ts +0 -40
  128. package/vite.config.webMcpFull.ts +0 -19
  129. package/vite.config.zod.ts +0 -23
  130. /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-rALfqS-o.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
  };