@opentiny/next-sdk 0.4.1 → 0.4.3

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 (90) hide show
  1. package/dist/{SimulatorMask-BHVXyogh-iNUb4dyF.js → SimulatorMask-BHVXyogh-CKmEDsYG.js} +1 -1
  2. package/dist/core.js +1 -1
  3. package/dist/{index-CXK8CcKq.js → index-CHMa2zG4.js} +1985 -1434
  4. package/dist/index.d.ts +11 -0
  5. package/dist/index.js +69 -50
  6. package/dist/{initialize-builtin-WebMCP-rALfqS-o.js → initialize-builtin-WebMCP-JaoKwVlm.js} +355 -346
  7. package/dist/page-tools/a11y/build.d.ts +3 -4
  8. package/dist/page-tools/a11y/config.d.ts +99 -0
  9. package/dist/page-tools/a11y/constants.d.ts +22 -0
  10. package/dist/page-tools/a11y/search.d.ts +1 -1
  11. package/dist/page-tools/a11y/types.d.ts +13 -22
  12. package/dist/page-tools/a11y/utils.d.ts +46 -11
  13. package/dist/page-tools/a11y/vnode.d.ts +14 -11
  14. package/dist/page-tools/a11y-tree.d.ts +1 -0
  15. package/dist/page-tools/configs/console-cloud.d.ts +6 -0
  16. package/dist/page-tools/constants.d.ts +7 -17
  17. package/dist/page-tools/context.d.ts +14 -0
  18. package/dist/page-tools/handlers/hover.d.ts +9 -0
  19. package/dist/page-tools/handlers/searchTree.d.ts +2 -1
  20. package/dist/page-tools/page-agent-highlight/index.d.ts +12 -0
  21. package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +2 -0
  22. package/dist/page-tools/page-agent-tool-event.d.ts +26 -0
  23. package/dist/page-tools/schema.d.ts +4 -3
  24. package/dist/page-tools/tool-config.d.ts +50 -0
  25. package/dist/page-tools/utils/dom.d.ts +8 -2
  26. package/dist/runtime.d.ts +4 -1
  27. package/dist/runtime.js +22 -187
  28. package/dist/vitest.config.d.ts +2 -0
  29. package/package.json +26 -16
  30. package/WebMcpClient.ts +0 -505
  31. package/WebMcpServer.ts +0 -447
  32. package/agent/AgentModelProvider.ts +0 -932
  33. package/agent/type.ts +0 -91
  34. package/agent/utils/generateReActPrompt.ts +0 -71
  35. package/agent/utils/getAISDKTools.ts +0 -34
  36. package/agent/utils/getBuiltinMcpTools.ts +0 -86
  37. package/agent/utils/parseReActAction.ts +0 -34
  38. package/core.ts +0 -26
  39. package/index.ts +0 -56
  40. package/page-tools/a11y/build.ts +0 -70
  41. package/page-tools/a11y/constants.ts +0 -110
  42. package/page-tools/a11y/search.ts +0 -129
  43. package/page-tools/a11y/types.ts +0 -108
  44. package/page-tools/a11y/utils.ts +0 -266
  45. package/page-tools/a11y/vnode.ts +0 -229
  46. package/page-tools/a11y-tree.ts +0 -13
  47. package/page-tools/bridge.ts +0 -702
  48. package/page-tools/constants.ts +0 -72
  49. package/page-tools/context.ts +0 -13
  50. package/page-tools/effects.ts +0 -345
  51. package/page-tools/handlers/browserState.ts +0 -12
  52. package/page-tools/handlers/click.ts +0 -26
  53. package/page-tools/handlers/executeJavascript.ts +0 -22
  54. package/page-tools/handlers/fill.ts +0 -60
  55. package/page-tools/handlers/scroll.ts +0 -66
  56. package/page-tools/handlers/searchTree.ts +0 -30
  57. package/page-tools/handlers/select.ts +0 -34
  58. package/page-tools/initialize-builtin-WebMCP.ts +0 -20
  59. package/page-tools/page-agent-highlight/index.ts +0 -198
  60. package/page-tools/page-agent-mask/SimulatorMask.module.css +0 -14
  61. package/page-tools/page-agent-mask/SimulatorMask.ts +0 -279
  62. package/page-tools/page-agent-mask/checkDarkMode.ts +0 -181
  63. package/page-tools/page-agent-mask/cursor-border.svg +0 -3
  64. package/page-tools/page-agent-mask/cursor-fill.svg +0 -5
  65. package/page-tools/page-agent-mask/cursor.module.css +0 -70
  66. package/page-tools/page-agent-prompt.md +0 -139
  67. package/page-tools/page-agent-tool.ts +0 -175
  68. package/page-tools/page-state-cache.ts +0 -78
  69. package/page-tools/schema.ts +0 -51
  70. package/page-tools/utils/dom.ts +0 -155
  71. package/page-tools/utils/scroll.ts +0 -58
  72. package/remoter/QrCode.ts +0 -54
  73. package/remoter/createRemoter.ts +0 -957
  74. package/remoter/svgs/chat.svg +0 -43
  75. package/remoter/svgs/icon-copy.svg +0 -25
  76. package/remoter/svgs/link.svg +0 -28
  77. package/remoter/svgs/logo.svg +0 -45
  78. package/remoter/svgs/qrcode.svg +0 -35
  79. package/remoter/svgs/scan.svg +0 -21
  80. package/remoter/tooltips.ts +0 -260
  81. package/runtime.html +0 -39
  82. package/runtime.ts +0 -13
  83. package/script/utils.ts +0 -26
  84. package/skills/index.ts +0 -287
  85. package/tsconfig.json +0 -16
  86. package/utils/builtinProxy.ts +0 -144
  87. package/utils/env.ts +0 -13
  88. package/utils/uuid.ts +0 -10
  89. package/vite.config.runtime.ts +0 -22
  90. package/vite.config.ts +0 -63
@@ -13,7 +13,7 @@ import { createOpenAI as Pn } from "@ai-sdk/openai";
13
13
  import { createDeepSeek as Rn } from "@ai-sdk/deepseek";
14
14
  import { Client as yr } from "@modelcontextprotocol/sdk/client/index.js";
15
15
  import { WebSocketClientTransport as kn } from "@modelcontextprotocol/sdk/client/websocket.js";
16
- class Wa {
16
+ class Ba {
17
17
  constructor(t, r) {
18
18
  const n = {
19
19
  name: "web-mcp-server",
@@ -212,7 +212,7 @@ class Wa {
212
212
  t.persisted || this.transport && typeof this.transport.close == "function" && await this.transport.close();
213
213
  }
214
214
  }
215
- const Ba = (e, t) => new xt(e, t), Ga = () => on(), Ka = (e) => e instanceof xt, Ya = (e) => e instanceof hr, On = (e) => {
215
+ const Ga = (e, t) => new xt(e, t), Ka = () => on(), Ya = (e) => e instanceof xt, Xa = (e) => e instanceof hr, On = (e) => {
216
216
  const t = () => {
217
217
  let r = null;
218
218
  return typeof document < "u" && (r = r || document.modelContext), typeof navigator < "u" && (r = r || navigator.modelContext), r = r || globalThis.modelContext, r || null;
@@ -534,7 +534,7 @@ class An {
534
534
  t.persisted || (In(this.transport) ? await this.transport.terminateSession() : this.transport && typeof this.transport.close == "function" && await this.transport.close());
535
535
  }
536
536
  }
537
- const Xa = (e, t) => new Xe(e, t), Qa = (e, t) => new Ye(e, t), el = (e, t) => new St(e, t), tl = (e) => e instanceof Xe, In = (e) => e instanceof Ye, rl = (e) => e instanceof St, nl = (e) => e instanceof yr;
537
+ const Qa = (e, t) => new Xe(e, t), el = (e, t) => new Ye(e, t), tl = (e, t) => new St(e, t), rl = (e) => e instanceof Xe, In = (e) => e instanceof Ye, nl = (e) => e instanceof St, ol = (e) => e instanceof yr;
538
538
  class it extends Error {
539
539
  constructor(t, r) {
540
540
  super(t), this.name = "ParseError", this.type = r.type, this.field = r.field, this.value = r.value, this.line = r.line;
@@ -1789,15 +1789,21 @@ function Cr(e) {
1789
1789
  type: "object",
1790
1790
  properties: {},
1791
1791
  additionalProperties: !1
1792
- }) : Oo(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? No(e) : Ao(e) : e();
1792
+ }) : Oo(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? zo(e) : Ao(e) : e();
1793
1793
  }
1794
1794
  function Ao(e) {
1795
1795
  return Pe(
1796
- () => Tt(
1797
- e["~standard"].jsonSchema.input({
1798
- target: "draft-07"
1799
- })
1800
- ),
1796
+ () => {
1797
+ if (!Io(e))
1798
+ throw new Error(
1799
+ `Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`
1800
+ );
1801
+ return Tt(
1802
+ e["~standard"].jsonSchema.input({
1803
+ target: "draft-07"
1804
+ })
1805
+ );
1806
+ },
1801
1807
  {
1802
1808
  validate: async (t) => {
1803
1809
  const r = await e["~standard"].validate(t);
@@ -1812,7 +1818,10 @@ function Ao(e) {
1812
1818
  }
1813
1819
  );
1814
1820
  }
1815
- function Io(e, t) {
1821
+ function Io(e) {
1822
+ return e["~standard"].jsonSchema != null;
1823
+ }
1824
+ function Mo(e, t) {
1816
1825
  var r;
1817
1826
  const n = (r = void 0) != null ? r : !1;
1818
1827
  return Pe(
@@ -1828,7 +1837,7 @@ function Io(e, t) {
1828
1837
  }
1829
1838
  );
1830
1839
  }
1831
- function Mo(e, t) {
1840
+ function jo(e, t) {
1832
1841
  var r;
1833
1842
  const n = (r = void 0) != null ? r : !1;
1834
1843
  return Pe(
@@ -1848,13 +1857,13 @@ function Mo(e, t) {
1848
1857
  }
1849
1858
  );
1850
1859
  }
1851
- function jo(e) {
1860
+ function No(e) {
1852
1861
  return "_zod" in e;
1853
1862
  }
1854
- function No(e, t) {
1855
- return jo(e) ? Mo(e) : Io(e);
1863
+ function zo(e, t) {
1864
+ return No(e) ? jo(e) : Mo(e);
1856
1865
  }
1857
- async function zo({
1866
+ async function Uo({
1858
1867
  value: e,
1859
1868
  schema: t,
1860
1869
  context: r
@@ -1893,12 +1902,12 @@ async function $r({
1893
1902
  }) {
1894
1903
  try {
1895
1904
  const r = br(e);
1896
- return t == null ? r : zo({ value: r, schema: t });
1905
+ return t == null ? r : Uo({ value: r, schema: t });
1897
1906
  } catch (r) {
1898
1907
  throw Le.isInstance(r) || Ce.isInstance(r) ? r : new Le({ text: e, cause: r });
1899
1908
  }
1900
1909
  }
1901
- async function Uo({
1910
+ async function Do({
1902
1911
  text: e,
1903
1912
  schema: t
1904
1913
  }) {
@@ -1913,10 +1922,10 @@ async function Uo({
1913
1922
  };
1914
1923
  }
1915
1924
  }
1916
- function Do(e) {
1925
+ function Lo(e) {
1917
1926
  return { ...e, type: "dynamic" };
1918
1927
  }
1919
- var Lo = ({
1928
+ var qo = ({
1920
1929
  maxRetries: e = 2,
1921
1930
  initialDelayInMs: t = 2e3,
1922
1931
  backoffFactor: r = 2,
@@ -1984,41 +1993,41 @@ async function Er(e, {
1984
1993
  new TextDecoder();
1985
1994
  let $t;
1986
1995
  $t = globalThis.crypto;
1987
- async function qo(e) {
1996
+ async function Ho(e) {
1988
1997
  return (await $t).getRandomValues(new Uint8Array(e));
1989
1998
  }
1990
- async function Ho(e) {
1999
+ async function Fo(e) {
1991
2000
  const t = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", r = Math.pow(2, 8) - Math.pow(2, 8) % t.length;
1992
2001
  let n = "";
1993
2002
  for (; n.length < e; ) {
1994
- const o = await qo(e - n.length);
2003
+ const o = await Ho(e - n.length);
1995
2004
  for (const s of o)
1996
2005
  s < r && (n += t[s % t.length]);
1997
2006
  }
1998
2007
  return n;
1999
2008
  }
2000
- async function Fo(e) {
2001
- return await Ho(e);
2002
- }
2003
2009
  async function Zo(e) {
2010
+ return await Fo(e);
2011
+ }
2012
+ async function Vo(e) {
2004
2013
  const t = await (await $t).subtle.digest("SHA-256", new TextEncoder().encode(e));
2005
2014
  return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
2006
2015
  }
2007
- async function Vo(e) {
2016
+ async function Jo(e) {
2008
2017
  if (e || (e = 43), e < 43 || e > 128)
2009
2018
  throw `Expected a length between 43 and 128. Received ${e}.`;
2010
- const t = await Fo(e), r = await Zo(t);
2019
+ const t = await Zo(e), r = await Vo(t);
2011
2020
  return {
2012
2021
  code_verifier: t,
2013
2022
  code_challenge: r
2014
2023
  };
2015
2024
  }
2016
- var we = "2025-11-25", Jo = [
2025
+ var we = "2025-11-25", Wo = [
2017
2026
  we,
2018
2027
  "2025-06-18",
2019
2028
  "2025-03-26",
2020
2029
  "2024-11-05"
2021
- ], Wo = a.optional(a.record(a.string(), a.unknown())), Bo = a.looseObject({
2030
+ ], Bo = a.optional(a.record(a.string(), a.unknown())), Go = a.looseObject({
2022
2031
  name: a.string(),
2023
2032
  version: a.string(),
2024
2033
  title: a.optional(a.string())
@@ -2029,7 +2038,7 @@ var we = "2025-11-25", Jo = [
2029
2038
  params: a.optional(Re)
2030
2039
  }), Rr = a.object({
2031
2040
  applyDefaults: a.optional(a.boolean())
2032
- }).loose(), Go = a.looseObject({
2041
+ }).loose(), Ko = a.looseObject({
2033
2042
  experimental: a.optional(a.object({}).loose()),
2034
2043
  logging: a.optional(a.object({}).loose()),
2035
2044
  completions: a.optional(a.object({}).loose()),
@@ -2054,14 +2063,14 @@ var we = "2025-11-25", Jo = [
2054
2063
  a.object({
2055
2064
  elicitation: a.optional(Rr)
2056
2065
  }).loose();
2057
- var Ko = ne.extend({
2066
+ var Yo = ne.extend({
2058
2067
  protocolVersion: a.string(),
2059
- capabilities: Go,
2060
- serverInfo: Bo,
2068
+ capabilities: Ko,
2069
+ serverInfo: Go,
2061
2070
  instructions: a.optional(a.string())
2062
2071
  }), Et = ne.extend({
2063
2072
  nextCursor: a.optional(a.string())
2064
- }), Yo = a.object({
2073
+ }), Xo = a.object({
2065
2074
  name: a.string(),
2066
2075
  /**
2067
2076
  * @see https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool
@@ -2081,9 +2090,9 @@ var Ko = ne.extend({
2081
2090
  title: a.optional(a.string())
2082
2091
  }).loose()
2083
2092
  ),
2084
- _meta: Wo
2085
- }).loose(), Xo = Et.extend({
2086
- tools: a.array(Yo)
2093
+ _meta: Bo
2094
+ }).loose(), Qo = Et.extend({
2095
+ tools: a.array(Xo)
2087
2096
  }), kr = a.object({
2088
2097
  type: a.literal("text"),
2089
2098
  text: a.string()
@@ -2091,15 +2100,15 @@ var Ko = ne.extend({
2091
2100
  type: a.literal("image"),
2092
2101
  data: a.base64(),
2093
2102
  mimeType: a.string()
2094
- }).loose(), Qo = a.object({
2103
+ }).loose(), es = a.object({
2095
2104
  uri: a.string(),
2096
2105
  name: a.string(),
2097
2106
  title: a.optional(a.string()),
2098
2107
  description: a.optional(a.string()),
2099
2108
  mimeType: a.optional(a.string()),
2100
2109
  size: a.optional(a.number())
2101
- }).loose(), es = Et.extend({
2102
- resources: a.array(Qo)
2110
+ }).loose(), ts = Et.extend({
2111
+ resources: a.array(es)
2103
2112
  }), Ar = a.object({
2104
2113
  /**
2105
2114
  * The URI of this resource.
@@ -2130,7 +2139,7 @@ var Ko = ne.extend({
2130
2139
  name: a.string(),
2131
2140
  description: a.optional(a.string()),
2132
2141
  mimeType: a.optional(a.string())
2133
- }).loose(), ts = ne.extend({
2142
+ }).loose(), rs = ne.extend({
2134
2143
  content: a.array(
2135
2144
  a.union([
2136
2145
  kr,
@@ -2148,55 +2157,55 @@ var Ko = ne.extend({
2148
2157
  ne.extend({
2149
2158
  toolResult: a.unknown()
2150
2159
  })
2151
- ), rs = a.object({
2160
+ ), ns = a.object({
2152
2161
  uriTemplate: a.string(),
2153
2162
  name: a.string(),
2154
2163
  title: a.optional(a.string()),
2155
2164
  description: a.optional(a.string()),
2156
2165
  mimeType: a.optional(a.string())
2157
- }).loose(), ns = ne.extend({
2158
- resourceTemplates: a.array(rs)
2159
- }), os = ne.extend({
2166
+ }).loose(), os = ne.extend({
2167
+ resourceTemplates: a.array(ns)
2168
+ }), ss = ne.extend({
2160
2169
  contents: a.array(
2161
2170
  a.union([Ir, Mr])
2162
2171
  )
2163
- }), ss = a.object({
2172
+ }), is = a.object({
2164
2173
  type: a.literal("ref/prompt"),
2165
2174
  name: a.string()
2166
- }).loose(), is = a.object({
2175
+ }).loose(), as = a.object({
2167
2176
  type: a.literal("ref/resource"),
2168
2177
  uri: a.string()
2169
- }).loose(), as = a.object({
2178
+ }).loose(), ls = a.object({
2170
2179
  name: a.string(),
2171
2180
  value: a.string()
2172
2181
  }).loose();
2173
2182
  Re.extend({
2174
- ref: a.union([ss, is]),
2175
- argument: as,
2183
+ ref: a.union([is, as]),
2184
+ argument: ls,
2176
2185
  context: a.optional(
2177
2186
  a.object({
2178
2187
  arguments: a.record(a.string(), a.string())
2179
2188
  }).loose()
2180
2189
  )
2181
2190
  });
2182
- var ls = ne.extend({
2191
+ var cs = ne.extend({
2183
2192
  completion: a.object({
2184
2193
  values: a.array(a.string()).max(100),
2185
2194
  total: a.optional(a.number().int()),
2186
2195
  hasMore: a.optional(a.boolean())
2187
2196
  }).loose()
2188
- }), cs = a.object({
2197
+ }), us = a.object({
2189
2198
  name: a.string(),
2190
2199
  description: a.optional(a.string()),
2191
2200
  required: a.optional(a.boolean())
2192
- }).loose(), us = a.object({
2201
+ }).loose(), ds = a.object({
2193
2202
  name: a.string(),
2194
2203
  title: a.optional(a.string()),
2195
2204
  description: a.optional(a.string()),
2196
- arguments: a.optional(a.array(cs))
2197
- }).loose(), ds = Et.extend({
2198
- prompts: a.array(us)
2199
- }), fs = a.object({
2205
+ arguments: a.optional(a.array(us))
2206
+ }).loose(), fs = Et.extend({
2207
+ prompts: a.array(ds)
2208
+ }), ps = a.object({
2200
2209
  role: a.union([a.literal("user"), a.literal("assistant")]),
2201
2210
  content: a.union([
2202
2211
  kr,
@@ -2204,30 +2213,30 @@ var ls = ne.extend({
2204
2213
  jr,
2205
2214
  Nr
2206
2215
  ])
2207
- }).loose(), ps = ne.extend({
2216
+ }).loose(), hs = ne.extend({
2208
2217
  description: a.optional(a.string()),
2209
- messages: a.array(fs)
2210
- }), hs = Re.extend({
2218
+ messages: a.array(ps)
2219
+ }), ms = Re.extend({
2211
2220
  message: a.string(),
2212
2221
  requestedSchema: a.unknown()
2213
2222
  }), Bt = Pr.extend({
2214
2223
  method: a.literal("elicitation/create"),
2215
- params: hs
2216
- }), ms = ne.extend({
2224
+ params: ms
2225
+ }), gs = ne.extend({
2217
2226
  action: a.union([
2218
2227
  a.literal("accept"),
2219
2228
  a.literal("decline"),
2220
2229
  a.literal("cancel")
2221
2230
  ]),
2222
2231
  content: a.optional(a.record(a.string(), a.unknown()))
2223
- }), Qe = "2.0", gs = a.object({
2232
+ }), Qe = "2.0", ys = a.object({
2224
2233
  jsonrpc: a.literal(Qe),
2225
2234
  id: a.union([a.string(), a.number().int()])
2226
- }).merge(Pr).strict(), ys = a.object({
2235
+ }).merge(Pr).strict(), vs = a.object({
2227
2236
  jsonrpc: a.literal(Qe),
2228
2237
  id: a.union([a.string(), a.number().int()]),
2229
2238
  result: ne
2230
- }).strict(), vs = a.object({
2239
+ }).strict(), ws = a.object({
2231
2240
  jsonrpc: a.literal(Qe),
2232
2241
  id: a.union([a.string(), a.number().int()]),
2233
2242
  error: a.object({
@@ -2235,26 +2244,26 @@ var ls = ne.extend({
2235
2244
  message: a.string(),
2236
2245
  data: a.optional(a.unknown())
2237
2246
  })
2238
- }).strict(), ws = a.object({
2247
+ }).strict(), bs = a.object({
2239
2248
  jsonrpc: a.literal(Qe)
2240
2249
  }).merge(
2241
2250
  a.object({
2242
2251
  method: a.string(),
2243
2252
  params: a.optional(Re)
2244
2253
  })
2245
- ).strict(), bs = a.union([
2246
- gs,
2247
- ws,
2254
+ ).strict(), _s = a.union([
2248
2255
  ys,
2249
- vs
2256
+ bs,
2257
+ vs,
2258
+ ws
2250
2259
  ]);
2251
2260
  function mt(e) {
2252
- return bs.parse(e);
2261
+ return _s.parse(e);
2253
2262
  }
2254
2263
  async function gt(e) {
2255
2264
  return mt(await $r({ text: e }));
2256
2265
  }
2257
- var _s = "AI_MCPClientError", zr = `vercel.ai.error.${_s}`, xs = Symbol.for(zr), Gt, Kt, A = class extends (Kt = qe, Gt = xs, Kt) {
2266
+ var xs = "AI_MCPClientError", zr = `vercel.ai.error.${xs}`, Ss = Symbol.for(zr), Gt, Kt, A = class extends (Kt = qe, Gt = Ss, Kt) {
2258
2267
  constructor({
2259
2268
  name: e = "MCPClientError",
2260
2269
  message: t,
@@ -2293,7 +2302,7 @@ var _s = "AI_MCPClientError", zr = `vercel.ai.error.${_s}`, xs = Symbol.for(zr),
2293
2302
  refresh_token: a.string().optional(),
2294
2303
  authorization_server: F.optional(),
2295
2304
  token_endpoint: F.optional()
2296
- }).strip(), Ss = a.object({
2305
+ }).strip(), Ts = a.object({
2297
2306
  resource: a.string().url(),
2298
2307
  authorization_servers: a.array(F).optional(),
2299
2308
  jwks_uri: a.string().url().optional(),
@@ -2319,7 +2328,7 @@ var _s = "AI_MCPClientError", zr = `vercel.ai.error.${_s}`, xs = Symbol.for(zr),
2319
2328
  code_challenge_methods_supported: a.array(a.string()),
2320
2329
  token_endpoint_auth_methods_supported: a.array(a.string()).optional(),
2321
2330
  token_endpoint_auth_signing_alg_values_supported: a.array(a.string()).optional()
2322
- }).passthrough(), Ts = a.object({
2331
+ }).passthrough(), Cs = a.object({
2323
2332
  issuer: a.string(),
2324
2333
  authorization_endpoint: F,
2325
2334
  token_endpoint: F,
@@ -2333,18 +2342,18 @@ var _s = "AI_MCPClientError", zr = `vercel.ai.error.${_s}`, xs = Symbol.for(zr),
2333
2342
  id_token_signing_alg_values_supported: a.array(a.string()),
2334
2343
  claims_supported: a.array(a.string()).optional(),
2335
2344
  token_endpoint_auth_methods_supported: a.array(a.string()).optional()
2336
- }).passthrough(), Cs = Ts.merge(
2345
+ }).passthrough(), $s = Cs.merge(
2337
2346
  Lr.pick({
2338
2347
  code_challenge_methods_supported: !0
2339
2348
  })
2340
- ), $s = a.object({
2349
+ ), Es = a.object({
2341
2350
  client_id: a.string(),
2342
2351
  client_secret: a.string().optional(),
2343
2352
  client_id_issued_at: a.number().optional(),
2344
2353
  client_secret_expires_at: a.number().optional(),
2345
2354
  authorization_server: F.optional(),
2346
2355
  token_endpoint: F.optional()
2347
- }).strip(), Es = a.object({
2356
+ }).strip(), Ps = a.object({
2348
2357
  redirect_uris: a.array(F),
2349
2358
  token_endpoint_auth_method: a.string().optional(),
2350
2359
  grant_types: a.array(a.string()).optional(),
@@ -2361,13 +2370,13 @@ var _s = "AI_MCPClientError", zr = `vercel.ai.error.${_s}`, xs = Symbol.for(zr),
2361
2370
  software_id: a.string().optional(),
2362
2371
  software_version: a.string().optional(),
2363
2372
  software_statement: a.string().optional()
2364
- }).strip(), Ps = a.object({
2373
+ }).strip(), Rs = a.object({
2365
2374
  error: a.string(),
2366
2375
  error_description: a.string().optional(),
2367
2376
  error_uri: a.string().optional()
2368
- }), Rs = Es.merge(
2369
- $s
2370
- ), ks = "AI_MCPClientOAuthError", qr = `vercel.ai.error.${ks}`, Os = Symbol.for(qr), Yt, Xt, re = class extends (Xt = qe, Yt = Os, Xt) {
2377
+ }), ks = Ps.merge(
2378
+ Es
2379
+ ), Os = "AI_MCPClientOAuthError", qr = `vercel.ai.error.${Os}`, As = Symbol.for(qr), Yt, Xt, re = class extends (Xt = qe, Yt = As, Xt) {
2371
2380
  constructor({
2372
2381
  name: e = "MCPClientOAuthError",
2373
2382
  message: t,
@@ -2390,13 +2399,13 @@ Fe.errorCode = "invalid_grant";
2390
2399
  var Ze = class extends re {
2391
2400
  };
2392
2401
  Ze.errorCode = "unauthorized_client";
2393
- var As = {
2402
+ var Is = {
2394
2403
  [ge.errorCode]: ge,
2395
2404
  [He.errorCode]: He,
2396
2405
  [Fe.errorCode]: Fe,
2397
2406
  [Ze.errorCode]: Ze
2398
2407
  };
2399
- function Is(e) {
2408
+ function Ms(e) {
2400
2409
  const t = typeof e == "string" ? new URL(e) : new URL(e.href);
2401
2410
  return t.hash = "", t;
2402
2411
  }
@@ -2404,7 +2413,7 @@ function Pt(e) {
2404
2413
  const t = e.href;
2405
2414
  return e.pathname === "/" && t.endsWith("/") ? t.slice(0, -1) : t;
2406
2415
  }
2407
- function Ms({
2416
+ function js({
2408
2417
  requestedResource: e,
2409
2418
  configuredResource: t
2410
2419
  }) {
@@ -2422,7 +2431,7 @@ var Ve = class extends Error {
2422
2431
  function ye(e) {
2423
2432
  return new URL(e).href;
2424
2433
  }
2425
- function js(e, t) {
2434
+ function Ns(e, t) {
2426
2435
  return {
2427
2436
  authorizationServerUrl: ye(e),
2428
2437
  tokenEndpoint: ye(
@@ -2470,7 +2479,7 @@ async function tr({
2470
2479
  )
2471
2480
  } : er(t);
2472
2481
  }
2473
- async function Ns({
2482
+ async function zs({
2474
2483
  provider: e,
2475
2484
  clientInformation: t,
2476
2485
  authorizationServerInformation: r
@@ -2484,7 +2493,7 @@ async function Ns({
2484
2493
  )
2485
2494
  ), !0) : !1;
2486
2495
  }
2487
- function zs(e, t) {
2496
+ function Us(e, t) {
2488
2497
  if (!t)
2489
2498
  return;
2490
2499
  const r = new URL(e).origin;
@@ -2518,7 +2527,7 @@ function Je(e) {
2518
2527
  return;
2519
2528
  }
2520
2529
  }
2521
- function Us(e, t = "", r = {}) {
2530
+ function Ds(e, t = "", r = {}) {
2522
2531
  return t.endsWith("/") && (t = t.slice(0, -1)), r.prependPathname ? `${t}/.well-known/${e}` : `/.well-known/${e}${t}`;
2523
2532
  }
2524
2533
  async function Rt(e, t, r = fetch) {
@@ -2535,28 +2544,28 @@ async function nr(e, t, r = fetch) {
2535
2544
  "MCP-Protocol-Version": t
2536
2545
  }, r);
2537
2546
  }
2538
- function Ds(e, t) {
2547
+ function Ls(e, t) {
2539
2548
  return !e || e.status >= 400 && e.status < 500 && t !== "/";
2540
2549
  }
2541
- async function Ls(e, t, r, n) {
2550
+ async function qs(e, t, r, n) {
2542
2551
  var o, s;
2543
2552
  const i = new URL(e), l = (o = n?.protocolVersion) != null ? o : we;
2544
2553
  let u;
2545
2554
  if (n?.metadataUrl)
2546
2555
  u = new URL(n.metadataUrl);
2547
2556
  else {
2548
- const d = Us(t, i.pathname);
2557
+ const d = Ds(t, i.pathname);
2549
2558
  u = new URL(d, (s = n?.metadataServerUrl) != null ? s : i), u.search = i.search;
2550
2559
  }
2551
2560
  let c = await nr(u, l, r);
2552
- if (!n?.metadataUrl && Ds(c, i.pathname)) {
2561
+ if (!n?.metadataUrl && Ls(c, i.pathname)) {
2553
2562
  const d = new URL(`/.well-known/${t}`, i);
2554
2563
  c = await nr(d, l, r);
2555
2564
  }
2556
2565
  return c;
2557
2566
  }
2558
- async function qs(e, t, r = fetch) {
2559
- const n = await Ls(
2567
+ async function Hs(e, t, r = fetch) {
2568
+ const n = await qs(
2560
2569
  e,
2561
2570
  "oauth-protected-resource",
2562
2571
  r,
@@ -2573,9 +2582,9 @@ async function qs(e, t, r = fetch) {
2573
2582
  throw new Error(
2574
2583
  `HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`
2575
2584
  );
2576
- return Ss.parse(await n.json());
2585
+ return Ts.parse(await n.json());
2577
2586
  }
2578
- function Hs(e) {
2587
+ function Fs(e) {
2579
2588
  const t = typeof e == "string" ? new URL(e) : e, r = t.pathname !== "/", n = t.origin, o = [];
2580
2589
  if (!r)
2581
2590
  return o.push({
@@ -2617,12 +2626,12 @@ function or(e, t) {
2617
2626
  message: `OAuth authorization server metadata issuer ${e.issuer} does not match expected issuer ${t}`
2618
2627
  });
2619
2628
  }
2620
- async function Fs(e, {
2629
+ async function Zs(e, {
2621
2630
  fetchFn: t = fetch,
2622
2631
  protocolVersion: r = we
2623
2632
  } = {}) {
2624
2633
  var n;
2625
- const o = { "MCP-Protocol-Version": r }, s = Hs(e);
2634
+ const o = { "MCP-Protocol-Version": r }, s = Fs(e);
2626
2635
  for (const { url: i, type: l, expectedIssuer: u } of s) {
2627
2636
  const c = await Rt(i, o, t);
2628
2637
  if (c) {
@@ -2637,7 +2646,7 @@ async function Fs(e, {
2637
2646
  const d = Lr.parse(await c.json());
2638
2647
  return or(d, u), d;
2639
2648
  } else {
2640
- const d = Cs.parse(
2649
+ const d = $s.parse(
2641
2650
  await c.json()
2642
2651
  );
2643
2652
  if (or(d, u), !((n = d.code_challenge_methods_supported) != null && n.includes("S256")))
@@ -2649,7 +2658,7 @@ async function Fs(e, {
2649
2658
  }
2650
2659
  }
2651
2660
  }
2652
- async function Zs(e, {
2661
+ async function Vs(e, {
2653
2662
  metadata: t,
2654
2663
  clientInformation: r,
2655
2664
  redirectUrl: n,
@@ -2670,7 +2679,7 @@ async function Zs(e, {
2670
2679
  );
2671
2680
  } else
2672
2681
  c = new URL("/authorize", e);
2673
- const d = await Vo(), p = d.code_verifier, f = d.code_challenge;
2682
+ const d = await Jo(), p = d.code_verifier, f = d.code_challenge;
2674
2683
  return c.searchParams.set("response_type", l), c.searchParams.set("client_id", r.client_id), c.searchParams.set("code_challenge", f), c.searchParams.set(
2675
2684
  "code_challenge_method",
2676
2685
  u
@@ -2687,19 +2696,19 @@ function Zr(e, t, r, n) {
2687
2696
  const { client_id: o, client_secret: s } = t;
2688
2697
  switch (e) {
2689
2698
  case "client_secret_basic":
2690
- Vs(o, s, r);
2699
+ Js(o, s, r);
2691
2700
  return;
2692
2701
  case "client_secret_post":
2693
- Js(o, s, n);
2702
+ Ws(o, s, n);
2694
2703
  return;
2695
2704
  case "none":
2696
- Ws(o, n);
2705
+ Bs(o, n);
2697
2706
  return;
2698
2707
  default:
2699
2708
  throw new Error(`Unsupported client authentication method: ${e}`);
2700
2709
  }
2701
2710
  }
2702
- function Vs(e, t, r) {
2711
+ function Js(e, t, r) {
2703
2712
  if (!t)
2704
2713
  throw new Error(
2705
2714
  "client_secret_basic authentication requires a client_secret"
@@ -2707,18 +2716,18 @@ function Vs(e, t, r) {
2707
2716
  const n = btoa(`${e}:${t}`);
2708
2717
  r.set("Authorization", `Basic ${n}`);
2709
2718
  }
2710
- function Js(e, t, r) {
2719
+ function Ws(e, t, r) {
2711
2720
  r.set("client_id", e), t && r.set("client_secret", t);
2712
2721
  }
2713
- function Ws(e, t) {
2722
+ function Bs(e, t) {
2714
2723
  t.set("client_id", e);
2715
2724
  }
2716
2725
  async function kt(e) {
2717
2726
  const t = e instanceof Response ? e.status : void 0, r = e instanceof Response ? await e.text() : e;
2718
2727
  try {
2719
- const n = Ps.parse(
2728
+ const n = Rs.parse(
2720
2729
  await $r({ text: r })
2721
- ), { error: o, error_description: s, error_uri: i } = n, l = As[o] || ge;
2730
+ ), { error: o, error_description: s, error_uri: i } = n, l = Is[o] || ge;
2722
2731
  return new l({
2723
2732
  message: s || "",
2724
2733
  cause: i
@@ -2728,7 +2737,7 @@ async function kt(e) {
2728
2737
  return new ge({ message: o });
2729
2738
  }
2730
2739
  }
2731
- async function Bs(e, {
2740
+ async function Gs(e, {
2732
2741
  metadata: t,
2733
2742
  clientInformation: r,
2734
2743
  authorizationCode: n,
@@ -2777,7 +2786,7 @@ async function Bs(e, {
2777
2786
  throw await kt(m);
2778
2787
  return Dr.parse(await m.json());
2779
2788
  }
2780
- async function Gs(e, {
2789
+ async function Ks(e, {
2781
2790
  metadata: t,
2782
2791
  clientInformation: r,
2783
2792
  refreshToken: n,
@@ -2829,7 +2838,7 @@ async function Gs(e, {
2829
2838
  ...await f.json()
2830
2839
  });
2831
2840
  }
2832
- async function Ks(e, {
2841
+ async function Ys(e, {
2833
2842
  metadata: t,
2834
2843
  clientMetadata: r,
2835
2844
  fetchFn: n
@@ -2852,7 +2861,7 @@ async function Ks(e, {
2852
2861
  });
2853
2862
  if (!s.ok)
2854
2863
  throw await kt(s);
2855
- return Rs.parse(await s.json());
2864
+ return ks.parse(await s.json());
2856
2865
  }
2857
2866
  async function yt(e, t) {
2858
2867
  var r, n;
@@ -2866,15 +2875,15 @@ async function yt(e, t) {
2866
2875
  throw o;
2867
2876
  }
2868
2877
  }
2869
- async function Ys(e, t, r) {
2870
- const n = Is(e);
2878
+ async function Xs(e, t, r) {
2879
+ const n = Ms(e);
2871
2880
  if (t.validateResourceURL)
2872
2881
  return await t.validateResourceURL(
2873
2882
  n,
2874
2883
  r?.resource
2875
2884
  );
2876
2885
  if (r) {
2877
- if (!Ms({
2886
+ if (!js({
2878
2887
  requestedResource: n,
2879
2888
  configuredResource: r.resource
2880
2889
  }))
@@ -2894,9 +2903,9 @@ async function ut(e, {
2894
2903
  }) {
2895
2904
  var l, u;
2896
2905
  let c, d;
2897
- zs(t, s);
2906
+ Us(t, s);
2898
2907
  try {
2899
- c = await qs(
2908
+ c = await Hs(
2900
2909
  t,
2901
2910
  { resourceMetadataUrl: s },
2902
2911
  i
@@ -2904,7 +2913,7 @@ async function ut(e, {
2904
2913
  } catch {
2905
2914
  }
2906
2915
  d || (d = t);
2907
- const p = await Ys(
2916
+ const p = await Xs(
2908
2917
  t,
2909
2918
  e,
2910
2919
  c
@@ -2914,12 +2923,12 @@ async function ut(e, {
2914
2923
  t,
2915
2924
  d
2916
2925
  ));
2917
- const f = await Fs(
2926
+ const f = await Zs(
2918
2927
  d,
2919
2928
  {
2920
2929
  fetchFn: i
2921
2930
  }
2922
- ), v = js(d, f);
2931
+ ), v = Ns(d, f);
2923
2932
  let m = await Promise.resolve(e.clientInformation());
2924
2933
  if (!m) {
2925
2934
  if (r !== void 0)
@@ -2930,7 +2939,7 @@ async function ut(e, {
2930
2939
  throw new Error(
2931
2940
  "OAuth client information must be saveable for dynamic registration"
2932
2941
  );
2933
- const j = await Ks(d, {
2942
+ const j = await Ys(d, {
2934
2943
  metadata: f,
2935
2944
  clientMetadata: e.clientMetadata,
2936
2945
  fetchFn: i
@@ -2960,7 +2969,7 @@ async function ut(e, {
2960
2969
  storedAuthorizationServerInformation: j,
2961
2970
  currentAuthorizationServerInformation: v
2962
2971
  });
2963
- const h = await e.codeVerifier(), g = await Bs(d, {
2972
+ const h = await e.codeVerifier(), g = await Gs(d, {
2964
2973
  metadata: f,
2965
2974
  clientInformation: m,
2966
2975
  authorizationCode: r,
@@ -2990,7 +2999,7 @@ async function ut(e, {
2990
2999
  }) : await ((u = e.invalidateCredentials) == null ? void 0 : u.call(e, "tokens"));
2991
3000
  try {
2992
3001
  if (j) {
2993
- const h = await Gs(d, {
3002
+ const h = await Ks(d, {
2994
3003
  metadata: f,
2995
3004
  clientInformation: m,
2996
3005
  refreshToken: S.refresh_token,
@@ -3014,7 +3023,7 @@ async function ut(e, {
3014
3023
  }
3015
3024
  const x = e.state ? await e.state() : void 0;
3016
3025
  x && e.saveState && await e.saveState(x);
3017
- const { authorizationUrl: R, codeVerifier: M } = await Zs(
3026
+ const { authorizationUrl: R, codeVerifier: M } = await Vs(
3018
3027
  d,
3019
3028
  {
3020
3029
  metadata: f,
@@ -3025,7 +3034,7 @@ async function ut(e, {
3025
3034
  resource: p
3026
3035
  }
3027
3036
  );
3028
- if (!await Ns({
3037
+ if (!await zs({
3029
3038
  provider: e,
3030
3039
  clientInformation: m,
3031
3040
  authorizationServerInformation: v
@@ -3035,10 +3044,10 @@ async function ut(e, {
3035
3044
  });
3036
3045
  return await e.saveCodeVerifier(M), await e.redirectToAuthorization(R), "REDIRECT";
3037
3046
  }
3038
- function Xs(e) {
3047
+ function Qs(e) {
3039
3048
  return e === void 0 || e === "message";
3040
3049
  }
3041
- var Qs = class {
3050
+ var ei = class {
3042
3051
  constructor({
3043
3052
  url: e,
3044
3053
  headers: t,
@@ -3129,7 +3138,7 @@ var Qs = class {
3129
3138
  message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${_.origin}`
3130
3139
  });
3131
3140
  this.endpoint = _, this.connected = !0, e();
3132
- } else if (Xs(h))
3141
+ } else if (Qs(h))
3133
3142
  try {
3134
3143
  const _ = await gt(g);
3135
3144
  (x = this.onmessage) == null || x.call(this, _);
@@ -3216,7 +3225,7 @@ var Qs = class {
3216
3225
  function sr(e) {
3217
3226
  return e === void 0 || e === "message";
3218
3227
  }
3219
- var ei = class {
3228
+ var ti = class {
3220
3229
  constructor({
3221
3230
  url: e,
3222
3231
  headers: t,
@@ -3506,22 +3515,22 @@ var ei = class {
3506
3515
  }
3507
3516
  }
3508
3517
  };
3509
- function ti(e) {
3518
+ function ri(e) {
3510
3519
  switch (e.type) {
3511
3520
  case "sse":
3512
- return new Qs(e);
3513
- case "http":
3514
3521
  return new ei(e);
3522
+ case "http":
3523
+ return new ti(e);
3515
3524
  default:
3516
3525
  throw new A({
3517
3526
  message: "Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."
3518
3527
  });
3519
3528
  }
3520
3529
  }
3521
- function ri(e) {
3530
+ function ni(e) {
3522
3531
  return "start" in e && typeof e.start == "function" && "send" in e && typeof e.send == "function" && "close" in e && typeof e.close == "function";
3523
3532
  }
3524
- var ni = "1.0.0", oi = 0, si = [
3533
+ var oi = "1.0.0", si = 0, ii = [
3525
3534
  "ConnectionRefused",
3526
3535
  "ConnectionClosed",
3527
3536
  "FailedToOpenSocket",
@@ -3530,26 +3539,26 @@ var ni = "1.0.0", oi = 0, si = [
3530
3539
  "ETIMEDOUT",
3531
3540
  "EPIPE"
3532
3541
  ];
3533
- function ii(e) {
3542
+ function ai(e) {
3534
3543
  if (e != null && typeof e == "object" && "statusCode" in e && typeof e.statusCode == "number")
3535
3544
  return e.statusCode;
3536
3545
  }
3537
- function ai(e) {
3546
+ function li(e) {
3538
3547
  if (e != null && typeof e == "object" && "code" in e && typeof e.code == "string")
3539
3548
  return e.code;
3540
3549
  }
3541
- function li(e) {
3542
- const t = ii(e);
3550
+ function ci(e) {
3551
+ const t = ai(e);
3543
3552
  if (t != null)
3544
3553
  return t === 408 || t === 409 || t === 429 || t >= 500;
3545
3554
  if (A.isInstance(e) && e.code != null)
3546
3555
  return !1;
3547
- const r = ai(e);
3548
- return r != null && si.includes(r);
3556
+ const r = li(e);
3557
+ return r != null && ii.includes(r);
3549
3558
  }
3550
- function ci(e) {
3559
+ function ui(e) {
3551
3560
  if (e == null)
3552
- return oi;
3561
+ return si;
3553
3562
  if (!Number.isInteger(e))
3554
3563
  throw new A({
3555
3564
  message: "maxRetries must be an integer"
@@ -3572,21 +3581,21 @@ function ir({
3572
3581
  } : { type: "text", text: JSON.stringify(n) }
3573
3582
  ) };
3574
3583
  }
3575
- async function ui(e) {
3576
- const t = new di(e);
3584
+ async function di(e) {
3585
+ const t = new fi(e);
3577
3586
  return await t.init(), t;
3578
3587
  }
3579
- var di = class {
3588
+ var fi = class {
3580
3589
  constructor({
3581
3590
  transport: e,
3582
3591
  name: t,
3583
3592
  clientName: r = t ?? "ai-sdk-mcp-client",
3584
- version: n = ni,
3593
+ version: n = oi,
3585
3594
  onUncaughtError: o,
3586
3595
  maxRetries: s,
3587
3596
  capabilities: i
3588
3597
  }) {
3589
- this.requestMessageId = 0, this.responseHandlers = /* @__PURE__ */ new Map(), this.serverCapabilities = {}, this._serverInfo = { name: "", version: "" }, this.isClosed = !0, this.onUncaughtError = o, this.maxRetries = ci(s), this.clientCapabilities = i ?? {}, ri(e) ? this.transport = e : this.transport = ti(e), this.transport.onclose = () => this.onClose(), this.transport.onerror = (l) => this.onError(l), this.transport.onmessage = (l) => {
3598
+ this.requestMessageId = 0, this.responseHandlers = /* @__PURE__ */ new Map(), this.serverCapabilities = {}, this._serverInfo = { name: "", version: "" }, this.isClosed = !0, this.onUncaughtError = o, this.maxRetries = ui(s), this.clientCapabilities = i ?? {}, ni(e) ? this.transport = e : this.transport = ri(e), this.transport.onclose = () => this.onClose(), this.transport.onerror = (l) => this.onError(l), this.transport.onmessage = (l) => {
3590
3599
  if ("method" in l) {
3591
3600
  "id" in l ? this.onRequestMessage(l) : this.onError(
3592
3601
  new A({
@@ -3619,13 +3628,13 @@ var di = class {
3619
3628
  clientInfo: this.clientInfo
3620
3629
  }
3621
3630
  },
3622
- resultSchema: Ko
3631
+ resultSchema: Yo
3623
3632
  });
3624
3633
  if (e === void 0)
3625
3634
  throw new A({
3626
3635
  message: "Server sent invalid initialize result"
3627
3636
  });
3628
- if (!Jo.includes(e.protocolVersion))
3637
+ if (!Wo.includes(e.protocolVersion))
3629
3638
  throw new A({
3630
3639
  message: `Server's protocol version is not supported: ${e.protocolVersion}`
3631
3640
  });
@@ -3737,7 +3746,7 @@ var di = class {
3737
3746
  } = {}) {
3738
3747
  return this.request({
3739
3748
  request: { method: "tools/list", params: e },
3740
- resultSchema: Xo,
3749
+ resultSchema: Qo,
3741
3750
  options: t
3742
3751
  });
3743
3752
  }
@@ -3745,10 +3754,10 @@ var di = class {
3745
3754
  options: e,
3746
3755
  execute: t
3747
3756
  }) {
3748
- return this.maxRetries === 0 ? t() : Lo({
3757
+ return this.maxRetries === 0 ? t() : qo({
3749
3758
  maxRetries: this.maxRetries,
3750
3759
  abortSignal: e?.abortSignal,
3751
- shouldRetry: li,
3760
+ shouldRetry: ci,
3752
3761
  createRetryError: ({ message: r, errors: n }) => new A({
3753
3762
  message: r,
3754
3763
  cause: n[n.length - 1]
@@ -3768,7 +3777,7 @@ var di = class {
3768
3777
  method: "tools/call",
3769
3778
  params: { name: e, arguments: t }
3770
3779
  },
3771
- resultSchema: ts,
3780
+ resultSchema: rs,
3772
3781
  options: {
3773
3782
  signal: r?.abortSignal
3774
3783
  }
@@ -3785,7 +3794,7 @@ var di = class {
3785
3794
  try {
3786
3795
  return this.request({
3787
3796
  request: { method: "resources/list", params: e },
3788
- resultSchema: es,
3797
+ resultSchema: ts,
3789
3798
  options: t
3790
3799
  });
3791
3800
  } catch (r) {
@@ -3799,7 +3808,7 @@ var di = class {
3799
3808
  try {
3800
3809
  return this.request({
3801
3810
  request: { method: "resources/read", params: { uri: e } },
3802
- resultSchema: os,
3811
+ resultSchema: ss,
3803
3812
  options: t
3804
3813
  });
3805
3814
  } catch (r) {
@@ -3812,7 +3821,7 @@ var di = class {
3812
3821
  try {
3813
3822
  return this.request({
3814
3823
  request: { method: "resources/templates/list" },
3815
- resultSchema: ns,
3824
+ resultSchema: os,
3816
3825
  options: e
3817
3826
  });
3818
3827
  } catch (t) {
@@ -3826,7 +3835,7 @@ var di = class {
3826
3835
  try {
3827
3836
  return this.request({
3828
3837
  request: { method: "prompts/list", params: e },
3829
- resultSchema: ds,
3838
+ resultSchema: fs,
3830
3839
  options: t
3831
3840
  });
3832
3841
  } catch (r) {
@@ -3841,7 +3850,7 @@ var di = class {
3841
3850
  try {
3842
3851
  return this.request({
3843
3852
  request: { method: "prompts/get", params: { name: e, arguments: t } },
3844
- resultSchema: ps,
3853
+ resultSchema: hs,
3845
3854
  options: r
3846
3855
  });
3847
3856
  } catch (n) {
@@ -3854,7 +3863,7 @@ var di = class {
3854
3863
  }) {
3855
3864
  return this.request({
3856
3865
  request: { method: "completion/complete", params: t },
3857
- resultSchema: ls,
3866
+ resultSchema: cs,
3858
3867
  options: e
3859
3868
  });
3860
3869
  }
@@ -3900,7 +3909,7 @@ var di = class {
3900
3909
  (M = R?.abortSignal) == null || M.throwIfAborted();
3901
3910
  const O = await f.callTool({ name: s, args: x, options: R });
3902
3911
  return O.isError ? O : v != null ? f.extractStructuredContent(O, v, s) : O;
3903
- }, S = t === "automatic" ? Do({
3912
+ }, S = t === "automatic" ? Lo({
3904
3913
  description: l,
3905
3914
  title: p,
3906
3915
  metadata: {
@@ -3947,7 +3956,7 @@ var di = class {
3947
3956
  if ("content" in e && Array.isArray(e.content)) {
3948
3957
  const n = e.content.find((o) => o.type === "text");
3949
3958
  if (n && "text" in n) {
3950
- const o = await Uo({
3959
+ const o = await Do({
3951
3960
  text: n.text,
3952
3961
  schema: t
3953
3962
  });
@@ -4052,7 +4061,7 @@ var di = class {
4052
4061
  return;
4053
4062
  }
4054
4063
  try {
4055
- const r = await this.elicitationRequestHandler(t.data), n = ms.parse(r);
4064
+ const r = await this.elicitationRequestHandler(t.data), n = gs.parse(r);
4056
4065
  await this.transport.send({
4057
4066
  jsonrpc: "2.0",
4058
4067
  id: e.id,
@@ -4103,7 +4112,7 @@ var di = class {
4103
4112
  );
4104
4113
  }
4105
4114
  };
4106
- const fi = async (e) => {
4115
+ const pi = async (e) => {
4107
4116
  const t = {};
4108
4117
  try {
4109
4118
  const r = await e.listTools();
@@ -4123,7 +4132,7 @@ const fi = async (e) => {
4123
4132
  } catch (r) {
4124
4133
  throw r;
4125
4134
  }
4126
- }, pi = async (e) => {
4135
+ }, hi = async (e) => {
4127
4136
  const t = {};
4128
4137
  if (!e)
4129
4138
  return t;
@@ -4160,7 +4169,7 @@ const fi = async (e) => {
4160
4169
  }
4161
4170
  return t;
4162
4171
  };
4163
- function hi(e) {
4172
+ function mi(e) {
4164
4173
  const t = Object.entries(e);
4165
4174
  if (t.length === 0)
4166
4175
  return "";
@@ -4223,11 +4232,11 @@ function ar(e, t) {
4223
4232
  }
4224
4233
  return null;
4225
4234
  }
4226
- const mi = {
4235
+ const gi = {
4227
4236
  openai: Pn,
4228
4237
  deepseek: Rn
4229
4238
  };
4230
- class ol {
4239
+ class sl {
4231
4240
  constructor({ llmConfig: t, mcpServers: r }) {
4232
4241
  if (this.mcpServers = {}, this.mcpClients = {}, this.mcpTools = {}, this.ignoreToolnames = [], this.responseMessages = [], this.useReActMode = !1, !t)
4233
4242
  throw new Error("llmConfig is required to initialize AgentModelProvider");
@@ -4236,7 +4245,7 @@ class ol {
4236
4245
  else if (t.providerType) {
4237
4246
  const n = t.providerType;
4238
4247
  let o;
4239
- typeof n == "string" ? o = mi[n] : o = n, this.llm = o({
4248
+ typeof n == "string" ? o = gi[n] : o = n, this.llm = o({
4240
4249
  apiKey: t.apiKey,
4241
4250
  baseURL: t.baseURL
4242
4251
  });
@@ -4251,7 +4260,7 @@ class ol {
4251
4260
  if ("type" in t && t.type === "builtin") {
4252
4261
  const o = t.client;
4253
4262
  return {
4254
- tools: () => pi(o),
4263
+ tools: () => hi(o),
4255
4264
  close: async () => {
4256
4265
  }
4257
4266
  };
@@ -4264,7 +4273,7 @@ class ol {
4264
4273
  r = new Xe(new URL(o.url), { requestInit: s });
4265
4274
  } else "transport" in t ? r = t.transport : r = t;
4266
4275
  if (t.useAISdkClient ?? !1) {
4267
- const o = await ui({ transport: r });
4276
+ const o = await di({ transport: r });
4268
4277
  return o.__transport__ = r, o;
4269
4278
  } else {
4270
4279
  const o = new An(
@@ -4304,7 +4313,7 @@ class ol {
4304
4313
  if (!t)
4305
4314
  return null;
4306
4315
  try {
4307
- return typeof t.tools == "function" ? await t.tools() : await fi(t);
4316
+ return typeof t.tools == "function" ? await t.tools() : await pi(t);
4308
4317
  } catch (n) {
4309
4318
  return this.onError && this.onError(n?.message || `Failed to query tools for ${r}`, n), console.error(`Failed to query tools for ${r}`, n), null;
4310
4319
  }
@@ -4389,7 +4398,7 @@ class ol {
4389
4398
  }
4390
4399
  /** 生成 ReAct 模式的系统提示词(包含工具描述) */
4391
4400
  _generateReActSystemPrompt(t, r, n) {
4392
- const o = hi(t);
4401
+ const o = mi(t);
4393
4402
  return n ? `${n}${o}` : `你是一个智能助手,可以通过调用工具来完成任务。
4394
4403
  ${o}`;
4395
4404
  }
@@ -4663,20 +4672,20 @@ ${G}
4663
4672
  return this._chat(st, t);
4664
4673
  }
4665
4674
  }
4666
- const gi = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
4675
+ const yi = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
4667
4676
  const t = Math.random() * 16 | 0;
4668
4677
  return (e === "x" ? t : t & 3 | 8).toString(16);
4669
- }), ae = () => typeof window < "u" && typeof navigator < "u", yi = () => ae() && typeof document < "u";
4678
+ }), ae = () => typeof window < "u" && typeof navigator < "u", vi = () => ae() && typeof document < "u";
4670
4679
  let ie = null, We = null, lr = null, De = 0;
4671
- const vi = "next-sdk-tool-body-glow";
4680
+ const wi = "next-sdk-tool-body-glow";
4672
4681
  function ke() {
4673
- return yi();
4682
+ return vi();
4674
4683
  }
4675
- function wi() {
4684
+ function bi() {
4676
4685
  if (!ke() || lr) return;
4677
4686
  const e = document.createElement("style");
4678
4687
  e.textContent = `
4679
- .${vi} {
4688
+ .${wi} {
4680
4689
  position: relative;
4681
4690
  }
4682
4691
 
@@ -4845,9 +4854,9 @@ function wi() {
4845
4854
  }
4846
4855
  `, document.head.appendChild(e), lr = e;
4847
4856
  }
4848
- function bi() {
4857
+ function _i() {
4849
4858
  if (!ke() || ie) return;
4850
- wi();
4859
+ bi();
4851
4860
  const e = document.createElement("div");
4852
4861
  e.className = "next-sdk-tool-overlay";
4853
4862
  const t = document.createElement("div");
@@ -4869,10 +4878,10 @@ function bi() {
4869
4878
  const c = document.createElement("div");
4870
4879
  c.className = "next-sdk-tool-overlay__label", l.prepend(u), i.appendChild(l), i.appendChild(c), n.appendChild(o), n.appendChild(s), r.appendChild(n), r.appendChild(i), e.appendChild(t), e.appendChild(r), document.body.appendChild(e), ie = e, We = c;
4871
4880
  }
4872
- function _i(e) {
4873
- ke() && (bi(), !(!ie || !We) && (ie.classList.remove("next-sdk-tool-overlay--exit"), We.textContent = e.label));
4881
+ function xi(e) {
4882
+ ke() && (_i(), !(!ie || !We) && (ie.classList.remove("next-sdk-tool-overlay--exit"), We.textContent = e.label));
4874
4883
  }
4875
- function xi() {
4884
+ function Si() {
4876
4885
  if (!ie) return;
4877
4886
  ie.classList.add("next-sdk-tool-overlay--exit");
4878
4887
  const e = ie;
@@ -4882,11 +4891,11 @@ function xi() {
4882
4891
  };
4883
4892
  e.addEventListener("animationend", n), r = setTimeout(n, 500);
4884
4893
  }
4885
- function Si(e) {
4886
- ke() && (De += 1, _i(e));
4894
+ function Ti(e) {
4895
+ ke() && (De += 1, xi(e));
4887
4896
  }
4888
- function Ti() {
4889
- !ke() || De <= 0 || (De -= 1, De === 0 && xi());
4897
+ function Ci() {
4898
+ !ke() || De <= 0 || (De -= 1, De === 0 && Si());
4890
4899
  }
4891
4900
  function Vr(e, t, r) {
4892
4901
  if (!r) return;
@@ -4895,11 +4904,11 @@ function Vr(e, t, r) {
4895
4904
  label: r.label || n
4896
4905
  };
4897
4906
  }
4898
- const Jr = "next-sdk:tool-call", vt = "next-sdk:tool-response", ve = "next-sdk:tool-registered", Be = "next-sdk:tool-unregistered", Ci = "next-sdk:remoter-ready", wt = /* @__PURE__ */ new Map(), $e = (e) => e.replace(/\/+$/, "") || "/", Ot = /* @__PURE__ */ new Set();
4899
- function $i() {
4907
+ const Jr = "next-sdk:tool-call", vt = "next-sdk:tool-response", ve = "next-sdk:tool-registered", Be = "next-sdk:tool-unregistered", $i = "next-sdk:remoter-ready", wt = /* @__PURE__ */ new Map(), $e = (e) => e.replace(/\/+$/, "") || "/", Ot = /* @__PURE__ */ new Set();
4908
+ function Ei() {
4900
4909
  ae() && Ot.add({ win: window, origin: window.location.origin || "*" });
4901
4910
  }
4902
- $i();
4911
+ Ei();
4903
4912
  function ce(e) {
4904
4913
  if (!ae()) return;
4905
4914
  const t = { type: e };
@@ -4910,14 +4919,14 @@ function ce(e) {
4910
4919
  }
4911
4920
  });
4912
4921
  }
4913
- function Ei() {
4922
+ function Pi() {
4914
4923
  ae() && window.addEventListener("message", (e) => {
4915
- if (e.data?.type !== Ci || !e.source || e.origin !== window.location.origin) return;
4924
+ if (e.data?.type !== $i || !e.source || e.origin !== window.location.origin) return;
4916
4925
  const t = e.source;
4917
4926
  Ot.add({ win: t, origin: e.origin || "*" });
4918
4927
  });
4919
4928
  }
4920
- Ei();
4929
+ Pi();
4921
4930
  function dt(e) {
4922
4931
  if (!e) return;
4923
4932
  const t = e;
@@ -4931,15 +4940,15 @@ function cr(e, t) {
4931
4940
  return !!r && r.has(t);
4932
4941
  }
4933
4942
  let Ee = null;
4934
- function sl(e) {
4943
+ function il(e) {
4935
4944
  Ee = e;
4936
4945
  }
4937
- function Pi(e) {
4946
+ function Ri(e) {
4938
4947
  if (!ae()) return !1;
4939
4948
  const t = $e(e);
4940
4949
  return $e(window.location.pathname) === t;
4941
4950
  }
4942
- function Ri(e) {
4951
+ function ki(e) {
4943
4952
  return ae() ? new Promise((t) => {
4944
4953
  let r = !1;
4945
4954
  const n = () => {
@@ -4950,7 +4959,7 @@ function Ri(e) {
4950
4959
  window.addEventListener("message", o), setTimeout(n, e);
4951
4960
  }) : Promise.resolve();
4952
4961
  }
4953
- function il(e, t) {
4962
+ function al(e, t) {
4954
4963
  const r = t?.name ?? "navigate_to_page", n = t?.title ?? "页面跳转", o = t?.description ?? '当需要的工具在当前页面不可用时,使用此工具跳转到特定页面。例如:要查询订单时跳转到 "/orders",要创建价保时跳转到 "/price-protection"。', s = t?.timeoutMs ?? 5e3, i = {
4955
4964
  type: "object",
4956
4965
  properties: {
@@ -4977,11 +4986,11 @@ function il(e, t) {
4977
4986
  ]
4978
4987
  };
4979
4988
  try {
4980
- if (Pi(u))
4989
+ if (Ri(u))
4981
4990
  return {
4982
4991
  content: [{ type: "text", text: `当前已在页面:${u}。请继续你的下一步操作。` }]
4983
4992
  };
4984
- const c = Ri(s);
4993
+ const c = ki(s);
4985
4994
  return await Ee(u) !== !0 && (await c, await new Promise((p) => setTimeout(p, 500))), {
4986
4995
  content: [{ type: "text", text: `已成功跳转至页面:${u}。请继续你的下一步操作。` }]
4987
4996
  };
@@ -5016,11 +5025,11 @@ function il(e, t) {
5016
5025
  }
5017
5026
  function Wr(e, t, r = 3e4, n) {
5018
5027
  return (o) => {
5019
- const s = gi();
5028
+ const s = yi();
5020
5029
  return new Promise((i, l) => {
5021
5030
  let u, c;
5022
5031
  const d = () => {
5023
- clearTimeout(u), window.removeEventListener("message", p), c && window.removeEventListener("message", c), n && Ti();
5032
+ clearTimeout(u), window.removeEventListener("message", p), c && window.removeEventListener("message", c), n && Ci();
5024
5033
  };
5025
5034
  u = setTimeout(() => {
5026
5035
  d(), l(new Error(`工具 [${e}] 调用超时 (${r}ms),请检查目标页面是否正确调用了 registerPageTool`));
@@ -5038,7 +5047,7 @@ function Wr(e, t, r = 3e4, n) {
5038
5047
  };
5039
5048
  (async () => {
5040
5049
  try {
5041
- if (n && Si(n), cr(t, e)) {
5050
+ if (n && Ti(n), cr(t, e)) {
5042
5051
  m();
5043
5052
  return;
5044
5053
  }
@@ -5056,7 +5065,7 @@ function Wr(e, t, r = 3e4, n) {
5056
5065
  });
5057
5066
  };
5058
5067
  }
5059
- function al(e) {
5068
+ function ll(e) {
5060
5069
  const t = /* @__PURE__ */ new Map(), r = (n, o, s = !1) => {
5061
5070
  const i = t.get(o), l = !!i;
5062
5071
  if (t.delete(o), i)
@@ -5081,7 +5090,7 @@ function al(e) {
5081
5090
  }
5082
5091
  });
5083
5092
  }
5084
- function ll(e) {
5093
+ function cl(e) {
5085
5094
  const { route: t, handlers: r } = e, n = $e(t ?? window.location.pathname), o = Object.keys(r), s = async (i) => {
5086
5095
  if (i.source !== window || i.data?.type !== Jr || !(i.data.toolName in r))
5087
5096
  return;
@@ -5107,41 +5116,41 @@ function ll(e) {
5107
5116
  };
5108
5117
  }
5109
5118
  const Se = /* @__PURE__ */ new Map();
5110
- function ki() {
5119
+ function Oi() {
5111
5120
  if (typeof document > "u") return;
5112
- const t = document.modelContext;
5113
- if (!t || t.__isNextSdkBridgeSetup) return;
5114
- ae() && (window.__nextSdkRegisteredTools = () => Array.from(Se.values()));
5115
- const r = t.registerTool?.bind(t), n = t.unregisterTool?.bind(t);
5116
- typeof r == "function" && (t.registerTool = (o, s) => {
5117
- const i = o.name, l = { ...o };
5118
- s?.signal && s.signal.addEventListener("abort", () => {
5119
- Se.delete(i), ce(Be);
5121
+ const e = document, t = typeof navigator < "u" ? navigator : void 0, r = e.modelContext || t?.modelContext;
5122
+ if (!r || r.__isNextSdkBridgeSetup) return;
5123
+ !e.modelContext && t?.modelContext && (e.modelContext = t.modelContext), ae() && (window.__nextSdkRegisteredTools = () => Array.from(Se.values()));
5124
+ const n = r.registerTool?.bind(r), o = r.unregisterTool?.bind(r);
5125
+ typeof n == "function" && (r.registerTool = (s, i) => {
5126
+ const l = s.name, u = { ...s };
5127
+ i?.signal && i.signal.addEventListener("abort", () => {
5128
+ Se.delete(l), ce(Be);
5120
5129
  });
5121
- const u = l.routeConfig && typeof l.routeConfig == "object" && "route" in l.routeConfig ? l.routeConfig : null;
5122
- if (u) {
5123
- const c = $e(u.route), d = Vr(i, l.title, u.invokeEffect), p = Wr(i, c, u.timeout, d);
5124
- l.execute = p, delete l.routeConfig;
5130
+ const c = u.routeConfig && typeof u.routeConfig == "object" && "route" in u.routeConfig ? u.routeConfig : null;
5131
+ if (c) {
5132
+ const d = $e(c.route), p = Vr(l, u.title, c.invokeEffect), f = Wr(l, d, c.timeout, p);
5133
+ u.execute = f, delete u.routeConfig;
5125
5134
  }
5126
- Se.set(i, {
5127
- name: i,
5128
- title: o.title,
5129
- description: o.description,
5130
- inputSchema: o.inputSchema
5135
+ Se.set(l, {
5136
+ name: l,
5137
+ title: s.title,
5138
+ description: s.description,
5139
+ inputSchema: s.inputSchema
5131
5140
  });
5132
5141
  try {
5133
- r(l, s), ce(ve);
5142
+ n(u, i), ce(ve);
5134
5143
  } catch {
5135
- Se.delete(i);
5144
+ Se.delete(l);
5136
5145
  }
5137
- }), t.unregisterTool = (o) => {
5146
+ }), r.unregisterTool = (s) => {
5138
5147
  try {
5139
- typeof n == "function" && n(o);
5148
+ typeof o == "function" && o(s);
5140
5149
  } catch {
5141
5150
  } finally {
5142
- Se.delete(o), ce(Be);
5151
+ Se.delete(s), ce(Be);
5143
5152
  }
5144
- }, t.__isNextSdkBridgeSetup = !0;
5153
+ }, r.__isNextSdkBridgeSetup = !0;
5145
5154
  }
5146
5155
  function Te(e, t) {
5147
5156
  const r = typeof e;
@@ -5172,24 +5181,24 @@ function Te(e, t) {
5172
5181
  return e === t;
5173
5182
  }
5174
5183
  function Q(e) {
5175
- return encodeURI(Oi(e));
5184
+ return encodeURI(Ai(e));
5176
5185
  }
5177
- function Oi(e) {
5186
+ function Ai(e) {
5178
5187
  return e.replace(/~/g, "~0").replace(/\//g, "~1");
5179
5188
  }
5180
- const Ai = {
5189
+ const Ii = {
5181
5190
  prefixItems: !0,
5182
5191
  items: !0,
5183
5192
  allOf: !0,
5184
5193
  anyOf: !0,
5185
5194
  oneOf: !0
5186
- }, Ii = {
5195
+ }, Mi = {
5187
5196
  $defs: !0,
5188
5197
  definitions: !0,
5189
5198
  properties: !0,
5190
5199
  patternProperties: !0,
5191
5200
  dependentSchemas: !0
5192
- }, Mi = {
5201
+ }, ji = {
5193
5202
  id: !0,
5194
5203
  $id: !0,
5195
5204
  $ref: !0,
@@ -5217,8 +5226,8 @@ const Ai = {
5217
5226
  maxProperties: !0,
5218
5227
  minProperties: !0
5219
5228
  };
5220
- let ji = typeof self < "u" && self.location && self.location.origin !== "null" ? new URL(self.location.origin + self.location.pathname + location.search) : new URL("https://github.com/cfworker");
5221
- function he(e, t = /* @__PURE__ */ Object.create(null), r = ji, n = "") {
5229
+ let Ni = typeof self < "u" && self.location && self.location.origin !== "null" ? new URL(self.location.origin + self.location.pathname + location.search) : new URL("https://github.com/cfworker");
5230
+ function he(e, t = /* @__PURE__ */ Object.create(null), r = Ni, n = "") {
5222
5231
  if (e && typeof e == "object" && !Array.isArray(e)) {
5223
5232
  const s = e.$id || e.id;
5224
5233
  if (s) {
@@ -5254,16 +5263,16 @@ function he(e, t = /* @__PURE__ */ Object.create(null), r = ji, n = "") {
5254
5263
  t[s.href] = e;
5255
5264
  }
5256
5265
  for (let s in e) {
5257
- if (Mi[s])
5266
+ if (ji[s])
5258
5267
  continue;
5259
5268
  const i = `${n}/${Q(s)}`, l = e[s];
5260
5269
  if (Array.isArray(l)) {
5261
- if (Ai[s]) {
5270
+ if (Ii[s]) {
5262
5271
  const u = l.length;
5263
5272
  for (let c = 0; c < u; c++)
5264
5273
  he(l[c], t, r, `${i}/${c}`);
5265
5274
  }
5266
- } else if (Ii[s])
5275
+ } else if (Mi[s])
5267
5276
  for (let u in l)
5268
5277
  he(l[u], t, r, `${i}/${Q(u)}`);
5269
5278
  else
@@ -5271,63 +5280,63 @@ function he(e, t = /* @__PURE__ */ Object.create(null), r = ji, n = "") {
5271
5280
  }
5272
5281
  return t;
5273
5282
  }
5274
- const Ni = /^(\d\d\d\d)-(\d\d)-(\d\d)$/, zi = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Ui = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i, Di = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i, Li = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i, qi = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i, Hi = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu, Fi = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i, Zi = /^(?:\/(?:[^~/]|~0|~1)*)*$/, Vi = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i, Ji = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/, Wi = (e) => {
5283
+ const zi = /^(\d\d\d\d)-(\d\d)-(\d\d)$/, Ui = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Di = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i, Li = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i, qi = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i, Hi = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i, Fi = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu, Zi = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i, Vi = /^(?:\/(?:[^~/]|~0|~1)*)*$/, Ji = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i, Wi = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/, Bi = (e) => {
5275
5284
  if (e[0] === '"')
5276
5285
  return !1;
5277
5286
  const [t, r, ...n] = e.split("@");
5278
5287
  return !t || !r || n.length !== 0 || t.length > 64 || r.length > 253 || t[0] === "." || t.endsWith(".") || t.includes("..") || !/^[a-z0-9.-]+$/i.test(r) || !/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t) ? !1 : r.split(".").every((o) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(o));
5279
- }, Bi = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, Gi = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i, Ki = (e) => e.length > 1 && e.length < 80 && (/^P\d+([.,]\d+)?W$/.test(e) || /^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e) && /^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));
5288
+ }, Gi = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, Ki = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i, Yi = (e) => e.length > 1 && e.length < 80 && (/^P\d+([.,]\d+)?W$/.test(e) || /^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e) && /^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));
5280
5289
  function ee(e) {
5281
5290
  return e.test.bind(e);
5282
5291
  }
5283
5292
  const ur = {
5284
5293
  date: Br,
5285
5294
  time: Gr.bind(void 0, !1),
5286
- "date-time": Qi,
5287
- duration: Ki,
5288
- uri: ra,
5289
- "uri-reference": ee(Li),
5290
- "uri-template": ee(qi),
5291
- url: ee(Hi),
5292
- email: Wi,
5293
- hostname: ee(Di),
5294
- ipv4: ee(Bi),
5295
- ipv6: ee(Gi),
5296
- regex: oa,
5297
- uuid: ee(Fi),
5298
- "json-pointer": ee(Zi),
5299
- "json-pointer-uri-fragment": ee(Vi),
5300
- "relative-json-pointer": ee(Ji)
5295
+ "date-time": ea,
5296
+ duration: Yi,
5297
+ uri: na,
5298
+ "uri-reference": ee(qi),
5299
+ "uri-template": ee(Hi),
5300
+ url: ee(Fi),
5301
+ email: Bi,
5302
+ hostname: ee(Li),
5303
+ ipv4: ee(Gi),
5304
+ ipv6: ee(Ki),
5305
+ regex: sa,
5306
+ uuid: ee(Zi),
5307
+ "json-pointer": ee(Vi),
5308
+ "json-pointer-uri-fragment": ee(Ji),
5309
+ "relative-json-pointer": ee(Wi)
5301
5310
  };
5302
- function Yi(e) {
5311
+ function Xi(e) {
5303
5312
  return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
5304
5313
  }
5305
5314
  function Br(e) {
5306
- const t = e.match(Ni);
5315
+ const t = e.match(zi);
5307
5316
  if (!t)
5308
5317
  return !1;
5309
5318
  const r = +t[1], n = +t[2], o = +t[3];
5310
- return n >= 1 && n <= 12 && o >= 1 && o <= (n == 2 && Yi(r) ? 29 : zi[n]);
5319
+ return n >= 1 && n <= 12 && o >= 1 && o <= (n == 2 && Xi(r) ? 29 : Ui[n]);
5311
5320
  }
5312
5321
  function Gr(e, t) {
5313
- const r = t.match(Ui);
5322
+ const r = t.match(Di);
5314
5323
  if (!r)
5315
5324
  return !1;
5316
5325
  const n = +r[1], o = +r[2], s = +r[3], i = !!r[5];
5317
5326
  return (n <= 23 && o <= 59 && s <= 59 || n == 23 && o == 59 && s == 60) && (!e || i);
5318
5327
  }
5319
- const Xi = /t|\s/i;
5320
- function Qi(e) {
5321
- const t = e.split(Xi);
5328
+ const Qi = /t|\s/i;
5329
+ function ea(e) {
5330
+ const t = e.split(Qi);
5322
5331
  return t.length == 2 && Br(t[0]) && Gr(!0, t[1]);
5323
5332
  }
5324
- const ea = /\/|:/, ta = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
5325
- function ra(e) {
5326
- return ea.test(e) && ta.test(e);
5333
+ const ta = /\/|:/, ra = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
5334
+ function na(e) {
5335
+ return ta.test(e) && ra.test(e);
5327
5336
  }
5328
- const na = /[^\\]\\Z/;
5329
- function oa(e) {
5330
- if (na.test(e))
5337
+ const oa = /[^\\]\\Z/;
5338
+ function sa(e) {
5339
+ if (oa.test(e))
5331
5340
  return !1;
5332
5341
  try {
5333
5342
  return new RegExp(e, "u"), !0;
@@ -5335,7 +5344,7 @@ function oa(e) {
5335
5344
  return !1;
5336
5345
  }
5337
5346
  }
5338
- function sa(e) {
5347
+ function ia(e) {
5339
5348
  let t = 0, r = e.length, n = 0, o;
5340
5349
  for (; n < r; )
5341
5350
  t++, o = e.charCodeAt(n++), o >= 55296 && o <= 56319 && n < r && (o = e.charCodeAt(n), (o & 64512) == 56320 && n++);
@@ -5833,7 +5842,7 @@ Known schemas:
5833
5842
  });
5834
5843
  }
5835
5844
  } else if (d === "string") {
5836
- const C = Ie === void 0 && Me === void 0 ? 0 : sa(e);
5845
+ const C = Ie === void 0 && Me === void 0 ? 0 : ia(e);
5837
5846
  Ie !== void 0 && C < Ie && w.push({
5838
5847
  instanceLocation: i,
5839
5848
  keyword: "minLength",
@@ -5858,7 +5867,7 @@ Known schemas:
5858
5867
  }
5859
5868
  return { valid: w.length === 0, errors: w };
5860
5869
  }
5861
- class ia {
5870
+ class aa {
5862
5871
  schema;
5863
5872
  draft;
5864
5873
  shortCircuit;
@@ -5876,7 +5885,7 @@ class ia {
5876
5885
  const dr = "Failed to parse input arguments", Ge = "Tool was executed but the invocation failed. For example, the script function threw an error", bt = "Tool was cancelled", ze = {
5877
5886
  type: "object",
5878
5887
  properties: {}
5879
- }, aa = ["draft-2020-12", "draft-07"], la = "__isWebMCPPolyfill", Kr = Symbol("standardValidator"), U = {
5888
+ }, la = ["draft-2020-12", "draft-07"], ca = "__isWebMCPPolyfill", Kr = Symbol("standardValidator"), U = {
5880
5889
  installed: !1,
5881
5890
  previousNavigatorModelContextDescriptor: void 0,
5882
5891
  previousNavigatorModelContextTestingDescriptor: void 0,
@@ -5885,7 +5894,7 @@ const dr = "Failed to parse input arguments", Ge = "Tool was executed but the in
5885
5894
  installedNavigatorModelContextTesting: !1,
5886
5895
  installedDocumentModelContext: !1
5887
5896
  };
5888
- var ca = class extends EventTarget {
5897
+ var ua = class extends EventTarget {
5889
5898
  tools = /* @__PURE__ */ new Map();
5890
5899
  testingShim = null;
5891
5900
  _ontoolchange = null;
@@ -5902,14 +5911,14 @@ var ca = class extends EventTarget {
5902
5911
  console.warn(`[WebMCPPolyfill] registerTool("${e?.name ?? "<unknown>"}") skipped: options.signal was already aborted.`);
5903
5912
  return;
5904
5913
  }
5905
- const n = ya(e, this.tools);
5914
+ const n = va(e, this.tools);
5906
5915
  this.tools.set(n.name, n), this.notifyToolsChanged(), r && r.addEventListener("abort", () => {
5907
5916
  this.tools.delete(n.name) && this.notifyToolsChanged();
5908
5917
  }, { once: !0 });
5909
5918
  }
5910
5919
  unregisterTool(e) {
5911
5920
  this.warnUnregisterToolDeprecationOnce();
5912
- const t = fa(e);
5921
+ const t = pa(e);
5913
5922
  this.tools.delete(t) && this.notifyToolsChanged();
5914
5923
  }
5915
5924
  getTools() {
@@ -5919,7 +5928,7 @@ var ca = class extends EventTarget {
5919
5928
  return this.executeToolByName(e.name, t, r, !1);
5920
5929
  }
5921
5930
  getTestingShim() {
5922
- return this.testingShim || (this.testingShim = new ua(this)), this.testingShim;
5931
+ return this.testingShim || (this.testingShim = new da(this)), this.testingShim;
5923
5932
  }
5924
5933
  /** @internal Used by PolyfillTestingShim */
5925
5934
  getToolInfos() {
@@ -5957,7 +5966,7 @@ var ca = class extends EventTarget {
5957
5966
  if (r?.signal?.aborted) throw te(bt);
5958
5967
  const o = this.tools.get(e);
5959
5968
  if (!o) throw te(`Tool not found: ${e}`);
5960
- const s = da(t), i = await _a(s, o);
5969
+ const s = fa(t), i = await xa(s, o);
5961
5970
  if (i) throw te(i);
5962
5971
  let l = !0;
5963
5972
  const u = { requestUserInteraction: async (c) => {
@@ -5966,8 +5975,8 @@ var ca = class extends EventTarget {
5966
5975
  return c();
5967
5976
  } };
5968
5977
  try {
5969
- const c = o.execute(s, u), d = await Ra(Promise.resolve(c), r?.signal);
5970
- if (n) return Pa($a(d));
5978
+ const c = o.execute(s, u), d = await ka(Promise.resolve(c), r?.signal);
5979
+ if (n) return Ra(Ea(d));
5971
5980
  const p = JSON.stringify(d);
5972
5981
  return p === void 0 ? null : p;
5973
5982
  } catch (c) {
@@ -5990,7 +5999,7 @@ var ca = class extends EventTarget {
5990
5999
  warnUnregisterToolDeprecationOnce() {
5991
6000
  this.unregisterToolDeprecationWarned || (this.unregisterToolDeprecationWarned = !0, console.warn("[WebMCPPolyfill] navigator.modelContext.unregisterTool() is deprecated. The April 23, 2026 WebMCP draft removed it in favor of registerTool(tool, { signal }) — pass an AbortSignal and abort it to unregister."));
5992
6001
  }
5993
- }, ua = class extends EventTarget {
6002
+ }, da = class extends EventTarget {
5994
6003
  context;
5995
6004
  _ontoolchange = null;
5996
6005
  constructor(e) {
@@ -6038,7 +6047,7 @@ function te(e) {
6038
6047
  return t.name = "UnknownError", t;
6039
6048
  }
6040
6049
  }
6041
- function da(e) {
6050
+ function fa(e) {
6042
6051
  let t;
6043
6052
  try {
6044
6053
  t = JSON.parse(e);
@@ -6048,7 +6057,7 @@ function da(e) {
6048
6057
  if (!t || typeof t != "object" || Array.isArray(t)) throw te(dr);
6049
6058
  return t;
6050
6059
  }
6051
- function fa(e) {
6060
+ function pa(e) {
6052
6061
  if (typeof e == "string") return e;
6053
6062
  if (V(e) && typeof e.name == "string") return e.name;
6054
6063
  throw new TypeError("Failed to execute 'unregisterTool' on 'ModelContext': parameter 1 must be a string or an object with a string name.");
@@ -6061,11 +6070,11 @@ function Yr(e) {
6061
6070
  const t = e["~standard"];
6062
6071
  return V(t) ? t : null;
6063
6072
  }
6064
- function pa(e) {
6073
+ function ha(e) {
6065
6074
  const t = Yr(e);
6066
6075
  return !!(t && t.version === 1 && typeof t.validate == "function");
6067
6076
  }
6068
- function ha(e) {
6077
+ function ma(e) {
6069
6078
  const t = Yr(e);
6070
6079
  return !t || t.version !== 1 || !V(t.jsonSchema) ? !1 : typeof t.jsonSchema.input == "function";
6071
6080
  }
@@ -6075,13 +6084,13 @@ function Ue(e) {
6075
6084
  vendor: "@mcp-b/webmcp-polyfill-json-schema",
6076
6085
  validate(t) {
6077
6086
  if (!V(t)) return { issues: [{ message: "expected object arguments" }] };
6078
- const r = va(t, e);
6087
+ const r = wa(t, e);
6079
6088
  return r ? { issues: [r] } : { value: t };
6080
6089
  }
6081
6090
  } };
6082
6091
  }
6083
- function ma(e) {
6084
- for (const t of aa) try {
6092
+ function ga(e) {
6093
+ for (const t of la) try {
6085
6094
  const r = e["~standard"].jsonSchema.input({ target: t });
6086
6095
  return Xr(r), r;
6087
6096
  } catch (r) {
@@ -6089,7 +6098,7 @@ function ma(e) {
6089
6098
  }
6090
6099
  throw new Error("Failed to convert Standard JSON Schema inputSchema to a JSON Schema object");
6091
6100
  }
6092
- function ga(e) {
6101
+ function ya(e) {
6093
6102
  if (e === void 0) {
6094
6103
  const r = ze;
6095
6104
  return {
@@ -6097,14 +6106,14 @@ function ga(e) {
6097
6106
  standardValidator: Ue(r)
6098
6107
  };
6099
6108
  }
6100
- if (ha(e)) {
6101
- const r = ma(e);
6109
+ if (ma(e)) {
6110
+ const r = ga(e);
6102
6111
  return {
6103
6112
  inputSchema: r,
6104
6113
  standardValidator: Ue(r)
6105
6114
  };
6106
6115
  }
6107
- if (pa(e)) return {
6116
+ if (ha(e)) return {
6108
6117
  inputSchema: ze,
6109
6118
  standardValidator: e
6110
6119
  };
@@ -6170,13 +6179,13 @@ function me(e, t) {
6170
6179
  throw new Error(`Invalid JSON Schema at ${t}: schema must be JSON-serializable`);
6171
6180
  }
6172
6181
  }
6173
- function ya(e, t) {
6182
+ function va(e, t) {
6174
6183
  if (!e || typeof e != "object") throw new TypeError("registerTool(tool) requires a tool object");
6175
6184
  if (typeof e.name != "string" || e.name.length === 0) throw new TypeError('Tool "name" must be a non-empty string');
6176
6185
  if (typeof e.description != "string" || e.description.length === 0) throw new TypeError('Tool "description" must be a non-empty string');
6177
6186
  if (typeof e.execute != "function") throw new TypeError('Tool "execute" must be a function');
6178
6187
  if (t.has(e.name)) throw new Error(`Tool already registered: ${e.name}`);
6179
- const r = ga(e.inputSchema), n = e.annotations, o = n ? {
6188
+ const r = ya(e.inputSchema), n = e.annotations, o = n ? {
6180
6189
  ...n,
6181
6190
  ...n.readOnlyHint === "true" ? { readOnlyHint: !0 } : n.readOnlyHint === "false" ? { readOnlyHint: !1 } : {},
6182
6191
  ...n.destructiveHint === "true" ? { destructiveHint: !0 } : n.destructiveHint === "false" ? { destructiveHint: !1 } : {},
@@ -6190,18 +6199,18 @@ function ya(e, t) {
6190
6199
  [Kr]: r.standardValidator
6191
6200
  };
6192
6201
  }
6193
- function va(e, t) {
6194
- const r = new ia(t, "2020-12", !0).validate(e);
6202
+ function wa(e, t) {
6203
+ const r = new aa(t, "2020-12", !0).validate(e);
6195
6204
  if (r.valid) return null;
6196
6205
  const n = r.errors[r.errors.length - 1];
6197
6206
  return n ? { message: n.error } : { message: "Input validation failed" };
6198
6207
  }
6199
- function wa(e) {
6208
+ function ba(e) {
6200
6209
  if (!e || e.length === 0) return null;
6201
6210
  const t = e.map((r) => V(r) && "key" in r ? r.key : r).map((r) => String(r)).filter((r) => r.length > 0);
6202
6211
  return t.length === 0 ? null : t.join(".");
6203
6212
  }
6204
- async function ba(e, t) {
6213
+ async function _a(e, t) {
6205
6214
  let r;
6206
6215
  try {
6207
6216
  r = await Promise.resolve(t["~standard"].validate(e));
@@ -6212,26 +6221,26 @@ async function ba(e, t) {
6212
6221
  if (!r.issues || r.issues.length === 0) return null;
6213
6222
  const n = r.issues[0];
6214
6223
  if (!n) return "Input validation error";
6215
- const o = wa(n?.path);
6224
+ const o = ba(n?.path);
6216
6225
  return o ? `Input validation error: ${n.message} at ${o}` : `Input validation error: ${n.message}`;
6217
6226
  }
6218
- async function _a(e, t) {
6219
- return ba(e, t[Kr]);
6227
+ async function xa(e, t) {
6228
+ return _a(e, t[Kr]);
6220
6229
  }
6221
- function xa(e) {
6230
+ function Sa(e) {
6222
6231
  return V(e) && Array.isArray(e.content);
6223
6232
  }
6224
- function Sa(e) {
6233
+ function Ta(e) {
6225
6234
  return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean";
6226
6235
  }
6227
6236
  function _t(e) {
6228
- return Sa(e) ? Number.isFinite(e) || typeof e != "number" : Array.isArray(e) ? e.every((t) => _t(t)) : V(e) ? Object.values(e).every((t) => _t(t)) : !1;
6237
+ return Ta(e) ? Number.isFinite(e) || typeof e != "number" : Array.isArray(e) ? e.every((t) => _t(t)) : V(e) ? Object.values(e).every((t) => _t(t)) : !1;
6229
6238
  }
6230
- function Ta(e) {
6239
+ function Ca(e) {
6231
6240
  if (!(!V(e) || !_t(e)))
6232
6241
  return e;
6233
6242
  }
6234
- function Ca(e) {
6243
+ function $a(e) {
6235
6244
  if (typeof e == "string") return e;
6236
6245
  try {
6237
6246
  return JSON.stringify(e) ?? String(e);
@@ -6239,24 +6248,24 @@ function Ca(e) {
6239
6248
  return String(e);
6240
6249
  }
6241
6250
  }
6242
- function $a(e) {
6243
- if (xa(e)) return e;
6244
- const t = Ta(e);
6251
+ function Ea(e) {
6252
+ if (Sa(e)) return e;
6253
+ const t = Ca(e);
6245
6254
  return {
6246
6255
  content: [{
6247
6256
  type: "text",
6248
- text: Ca(e)
6257
+ text: $a(e)
6249
6258
  }],
6250
6259
  ...t ? { structuredContent: t } : {},
6251
6260
  isError: !1
6252
6261
  };
6253
6262
  }
6254
- function Ea(e) {
6263
+ function Pa(e) {
6255
6264
  for (const t of e.content ?? []) if (t.type === "text" && "text" in t && typeof t.text == "string") return t.text;
6256
6265
  return null;
6257
6266
  }
6258
- function Pa(e) {
6259
- if (e.isError) throw te(Ea(e)?.replace(/^Error:\s*/i, "").trim() || Ge);
6267
+ function Ra(e) {
6268
+ if (e.isError) throw te(Pa(e)?.replace(/^Error:\s*/i, "").trim() || Ge);
6260
6269
  const t = e.metadata;
6261
6270
  if (t && typeof t == "object" && t.willNavigate) return null;
6262
6271
  try {
@@ -6265,7 +6274,7 @@ function Pa(e) {
6265
6274
  throw te(Ge);
6266
6275
  }
6267
6276
  }
6268
- function Ra(e, t) {
6277
+ function ka(e, t) {
6269
6278
  return t ? t.aborted ? Promise.reject(te(bt)) : new Promise((r, n) => {
6270
6279
  const o = () => {
6271
6280
  s(), n(te(bt));
@@ -6285,7 +6294,7 @@ function Qr() {
6285
6294
  function en() {
6286
6295
  return typeof document < "u" ? document : null;
6287
6296
  }
6288
- function ka(e, t, r) {
6297
+ function Oa(e, t, r) {
6289
6298
  Object.defineProperty(e, t, {
6290
6299
  configurable: !0,
6291
6300
  enumerable: !0,
@@ -6302,7 +6311,7 @@ function fr(e, t) {
6302
6311
  });
6303
6312
  }
6304
6313
  let Ke = !1;
6305
- function Oa(e, t) {
6314
+ function Aa(e, t) {
6306
6315
  Object.defineProperty(e, "modelContext", {
6307
6316
  configurable: !0,
6308
6317
  enumerable: !0,
@@ -6315,20 +6324,20 @@ function tn(e) {
6315
6324
  const t = Qr(), r = en();
6316
6325
  if (!t && !r || r?.modelContext) return;
6317
6326
  const o = t?.modelContext, s = !!o;
6318
- if (U.installed && Aa(), r && o) {
6327
+ if (U.installed && Ia(), r && o) {
6319
6328
  U.previousDocumentModelContextDescriptor = Object.getOwnPropertyDescriptor(r, "modelContext"), fr(r, o), U.installedDocumentModelContext = !0, U.installed = !0;
6320
6329
  return;
6321
6330
  }
6322
6331
  if (s) return;
6323
- const i = new ca(), l = i;
6324
- if (l[la] = !0, r && (U.previousDocumentModelContextDescriptor = Object.getOwnPropertyDescriptor(r, "modelContext"), fr(r, l), U.installedDocumentModelContext = !0), t) {
6325
- U.previousNavigatorModelContextDescriptor = Object.getOwnPropertyDescriptor(t, "modelContext"), U.previousNavigatorModelContextTestingDescriptor = Object.getOwnPropertyDescriptor(t, "modelContextTesting"), Ke = !1, Oa(t, l), U.installedNavigatorModelContext = !0;
6332
+ const i = new ua(), l = i;
6333
+ if (l[ca] = !0, r && (U.previousDocumentModelContextDescriptor = Object.getOwnPropertyDescriptor(r, "modelContext"), fr(r, l), U.installedDocumentModelContext = !0), t) {
6334
+ U.previousNavigatorModelContextDescriptor = Object.getOwnPropertyDescriptor(t, "modelContext"), U.previousNavigatorModelContextTestingDescriptor = Object.getOwnPropertyDescriptor(t, "modelContextTesting"), Ke = !1, Aa(t, l), U.installedNavigatorModelContext = !0;
6326
6335
  const u = e?.installTestingShim ?? "if-missing", c = !!t.modelContextTesting;
6327
- (u === "always" || (u === !0 || u === "if-missing") && !c) && (ka(t, "modelContextTesting", i.getTestingShim()), U.installedNavigatorModelContextTesting = !0);
6336
+ (u === "always" || (u === !0 || u === "if-missing") && !c) && (Oa(t, "modelContextTesting", i.getTestingShim()), U.installedNavigatorModelContextTesting = !0);
6328
6337
  }
6329
6338
  U.installed = !0;
6330
6339
  }
6331
- function Aa() {
6340
+ function Ia() {
6332
6341
  if (!U.installed) return;
6333
6342
  const e = (n, o, s) => {
6334
6343
  if (s) {
@@ -6348,42 +6357,42 @@ if (typeof window < "u" && typeof document < "u") {
6348
6357
  }
6349
6358
  }
6350
6359
  let pr = !1;
6351
- const cl = () => {
6360
+ const ul = () => {
6352
6361
  if (ae())
6353
6362
  try {
6354
6363
  if (pr) return;
6355
- tn(), ki(), pr = !0;
6364
+ tn(), Oi(), pr = !0;
6356
6365
  } catch (e) {
6357
6366
  console.warn("[next-sdk] 自动注入 modelContext polyfill 和桥接同步失败:", e);
6358
6367
  }
6359
6368
  };
6360
6369
  export {
6361
- ol as A,
6370
+ sl as A,
6362
6371
  ve as M,
6363
- Wa as W,
6364
- Ga as a,
6365
- Ka as b,
6366
- Ba as c,
6367
- Ya as d,
6372
+ Ba as W,
6373
+ Ka as a,
6374
+ Ya as b,
6375
+ Ga as c,
6376
+ Xa as d,
6368
6377
  An as e,
6369
- Xa as f,
6370
- fi as g,
6371
- Qa as h,
6372
- cl as i,
6373
- el as j,
6374
- tl as k,
6378
+ Qa as f,
6379
+ pi as g,
6380
+ el as h,
6381
+ ul as i,
6382
+ tl as j,
6383
+ rl as k,
6375
6384
  In as l,
6376
- rl as m,
6377
- nl as n,
6385
+ nl as m,
6386
+ ol as n,
6378
6387
  Be as o,
6379
- Ci as p,
6380
- ll as q,
6381
- il as r,
6382
- sl as s,
6383
- ki as t,
6384
- Aa as u,
6388
+ $i as p,
6389
+ cl as q,
6390
+ al as r,
6391
+ il as s,
6392
+ Oi as t,
6393
+ Ia as u,
6385
6394
  tn as v,
6386
- al as w,
6395
+ ll as w,
6387
6396
  V as x,
6388
- va as y
6397
+ wa as y
6389
6398
  };