@nextblock-cms/cortex 0.20.3 → 0.21.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 (100) hide show
  1. package/README.md +46 -0
  2. package/client.cjs +1 -0
  3. package/client.es.js +3 -7
  4. package/index.cjs +1 -0
  5. package/index.es.js +24 -277
  6. package/lib/ai-block-generation.cjs +4 -0
  7. package/lib/ai-block-generation.es.js +143 -182
  8. package/lib/ai-client.cjs +1 -0
  9. package/lib/ai-client.d.ts +1 -1
  10. package/lib/ai-client.es.js +101 -135
  11. package/lib/ai-config.cjs +1 -0
  12. package/lib/ai-config.es.js +89 -108
  13. package/lib/ai-cortex-widget-builder.cjs +1 -0
  14. package/lib/ai-cortex-widget-builder.es.js +56 -70
  15. package/lib/ai-global-agent-content-ops-tools.cjs +1 -0
  16. package/lib/ai-global-agent-content-ops-tools.d.ts +1943 -68
  17. package/lib/ai-global-agent-content-ops-tools.es.js +185 -199
  18. package/lib/ai-global-agent-custom-block-tools.cjs +1 -0
  19. package/lib/ai-global-agent-custom-block-tools.d.ts +2160 -95
  20. package/lib/ai-global-agent-custom-block-tools.es.js +226 -223
  21. package/lib/ai-global-agent-db-tools.cjs +1 -0
  22. package/lib/ai-global-agent-db-tools.d.ts +2708 -98
  23. package/lib/ai-global-agent-db-tools.es.js +1013 -986
  24. package/lib/ai-global-agent-ecommerce.cjs +1 -0
  25. package/lib/ai-global-agent-ecommerce.es.js +3 -7
  26. package/lib/ai-global-agent-site-tools.cjs +2 -0
  27. package/lib/ai-global-agent-site-tools.d.ts +10695 -500
  28. package/lib/ai-global-agent-site-tools.es.js +750 -757
  29. package/lib/ai-global-agent-theming-tools.cjs +1 -0
  30. package/lib/ai-global-agent-theming-tools.d.ts +2905 -105
  31. package/lib/ai-global-agent-theming-tools.es.js +326 -396
  32. package/lib/ai-global-agent-tools.cjs +15 -0
  33. package/lib/ai-global-agent-tools.d.ts +4 -2230
  34. package/lib/ai-global-agent-tools.es.js +3899 -4328
  35. package/lib/ai-key-crypto.cjs +1 -0
  36. package/lib/ai-key-crypto.es.js +63 -82
  37. package/lib/ai-key-verification.cjs +1 -0
  38. package/lib/ai-key-verification.es.js +74 -63
  39. package/lib/ai-model-catalog.cjs +1 -0
  40. package/lib/ai-model-catalog.es.js +18 -22
  41. package/lib/ai-model-registry.cjs +2 -0
  42. package/lib/ai-model-registry.es.js +246 -309
  43. package/lib/ai-seo-metadata.cjs +3 -0
  44. package/lib/ai-seo-metadata.es.js +143 -185
  45. package/lib/ai-vision.cjs +3 -0
  46. package/lib/ai-vision.d.ts +6 -6
  47. package/lib/ai-vision.es.js +161 -215
  48. package/lib/block-content-schemas.cjs +1 -0
  49. package/lib/block-content-schemas.es.js +324 -254
  50. package/lib/cortex-widget-registry.cjs +1 -0
  51. package/lib/cortex-widget-registry.es.js +35 -43
  52. package/lib/cortex-widget-schema.cjs +4 -0
  53. package/lib/cortex-widget-schema.es.js +280 -309
  54. package/lib/editor-document-from-html.cjs +1 -0
  55. package/lib/editor-document-from-html.es.js +334 -278
  56. package/lib/fetch-host-guard.cjs +1 -0
  57. package/lib/fetch-host-guard.d.ts +2 -0
  58. package/lib/fetch-host-guard.es.js +30 -0
  59. package/lib/mcp-server.cjs +1 -0
  60. package/lib/mcp-server.es.js +155 -173
  61. package/lib/mcp-tokens.cjs +1 -0
  62. package/lib/mcp-tokens.es.js +95 -107
  63. package/lib/mcp-tool-registry.cjs +5 -0
  64. package/lib/mcp-tool-registry.es.js +533 -411
  65. package/lib/site-brief.cjs +2 -0
  66. package/lib/site-brief.es.js +102 -108
  67. package/lib/vision-image-download.cjs +1 -0
  68. package/lib/vision-image-download.d.ts +43 -0
  69. package/lib/vision-image-download.es.js +120 -0
  70. package/lib/zod-config.cjs +1 -0
  71. package/lib/zod-config.es.js +5 -6
  72. package/package.json +13 -12
  73. package/client.cjs.js +0 -1
  74. package/index.cjs.js +0 -1
  75. package/lib/ai-block-generation.cjs.js +0 -5
  76. package/lib/ai-client.cjs.js +0 -1
  77. package/lib/ai-config.cjs.js +0 -1
  78. package/lib/ai-cortex-widget-builder.cjs.js +0 -1
  79. package/lib/ai-global-agent-content-ops-tools.cjs.js +0 -1
  80. package/lib/ai-global-agent-custom-block-tools.cjs.js +0 -1
  81. package/lib/ai-global-agent-db-tools.cjs.js +0 -1
  82. package/lib/ai-global-agent-ecommerce.cjs.js +0 -1
  83. package/lib/ai-global-agent-site-tools.cjs.js +0 -3
  84. package/lib/ai-global-agent-theming-tools.cjs.js +0 -3
  85. package/lib/ai-global-agent-tools.cjs.js +0 -15
  86. package/lib/ai-key-crypto.cjs.js +0 -1
  87. package/lib/ai-key-verification.cjs.js +0 -1
  88. package/lib/ai-model-catalog.cjs.js +0 -1
  89. package/lib/ai-model-registry.cjs.js +0 -2
  90. package/lib/ai-seo-metadata.cjs.js +0 -4
  91. package/lib/ai-vision.cjs.js +0 -3
  92. package/lib/block-content-schemas.cjs.js +0 -1
  93. package/lib/cortex-widget-registry.cjs.js +0 -1
  94. package/lib/cortex-widget-schema.cjs.js +0 -5
  95. package/lib/editor-document-from-html.cjs.js +0 -1
  96. package/lib/mcp-server.cjs.js +0 -1
  97. package/lib/mcp-tokens.cjs.js +0 -1
  98. package/lib/mcp-tool-registry.cjs.js +0 -6
  99. package/lib/site-brief.cjs.js +0 -2
  100. package/lib/zod-config.cjs.js +0 -1
@@ -1,290 +1,346 @@
1
- const w = /* @__PURE__ */ new Set([
2
- "area",
3
- "base",
4
- "br",
5
- "col",
6
- "embed",
7
- "hr",
8
- "img",
9
- "input",
10
- "link",
11
- "meta",
12
- "param",
13
- "source",
14
- "track",
15
- "wbr"
16
- ]), I = {
17
- b: "bold",
18
- code: "code",
19
- del: "strike",
20
- em: "italic",
21
- i: "italic",
22
- mark: "highlight",
23
- s: "strike",
24
- strike: "strike",
25
- strong: "bold",
26
- sub: "subscript",
27
- sup: "superscript"
28
- }, S = /* @__PURE__ */ new Set([
29
- "article",
30
- "aside",
31
- "body",
32
- "div",
33
- "footer",
34
- "header",
35
- "html",
36
- "main",
37
- "nav",
38
- "section"
39
- ]), h = /* @__PURE__ */ new Set(["script", "style", "noscript", "svg", "template", "iframe", "form"]), b = 12;
40
- function u(i) {
41
- return i.replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, '"').replace(/&#0?39;/g, "'").replace(/&apos;/gi, "'").replace(/&#(\d+);/g, (e, t) => String.fromCodePoint(Number(t))).replace(/&#x([0-9a-f]+);/gi, (e, t) => String.fromCodePoint(Number.parseInt(t, 16))).replace(/&amp;/gi, "&");
1
+ //#region src/lib/editor-document-from-html.ts
2
+ var e = /* @__PURE__ */ new Set([
3
+ "area",
4
+ "base",
5
+ "br",
6
+ "col",
7
+ "embed",
8
+ "hr",
9
+ "img",
10
+ "input",
11
+ "link",
12
+ "meta",
13
+ "param",
14
+ "source",
15
+ "track",
16
+ "wbr"
17
+ ]), t = {
18
+ b: "bold",
19
+ code: "code",
20
+ del: "strike",
21
+ em: "italic",
22
+ i: "italic",
23
+ mark: "highlight",
24
+ s: "strike",
25
+ strike: "strike",
26
+ strong: "bold",
27
+ sub: "subscript",
28
+ sup: "superscript"
29
+ }, n = /* @__PURE__ */ new Set([
30
+ "article",
31
+ "aside",
32
+ "body",
33
+ "div",
34
+ "footer",
35
+ "header",
36
+ "html",
37
+ "main",
38
+ "nav",
39
+ "section"
40
+ ]), r = /* @__PURE__ */ new Set([
41
+ "script",
42
+ "style",
43
+ "noscript",
44
+ "svg",
45
+ "template",
46
+ "iframe",
47
+ "form"
48
+ ]), i = 12;
49
+ function a(e) {
50
+ return e.replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, "\"").replace(/&#0?39;/g, "'").replace(/&apos;/gi, "'").replace(/&#(\d+);/g, (e, t) => String.fromCodePoint(Number(t))).replace(/&#x([0-9a-f]+);/gi, (e, t) => String.fromCodePoint(Number.parseInt(t, 16))).replace(/&amp;/gi, "&");
42
51
  }
43
- function A(i, e) {
44
- const t = i.match(
45
- new RegExp(`\\b${e}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i")
46
- );
47
- return t ? u(t[1] ?? t[2] ?? t[3] ?? "") : null;
52
+ function o(e, t) {
53
+ let n = e.match(RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
54
+ return n ? a(n[1] ?? n[2] ?? n[3] ?? "") : null;
48
55
  }
49
- function T(i, e, t) {
50
- const n = new RegExp(`<${t}\\b`, "gi"), o = new RegExp(`</${t}\\s*>`, "gi");
51
- let r = 1, a = e;
52
- for (; r > 0; ) {
53
- o.lastIndex = a;
54
- const c = o.exec(i);
55
- if (!c)
56
- return { end: i.length, inner: i.slice(e) };
57
- n.lastIndex = a;
58
- const s = n.exec(i);
59
- if (s && s.index < c.index) {
60
- r += 1, a = s.index + s[0].length;
61
- continue;
62
- }
63
- if (r -= 1, a = c.index + c[0].length, r === 0)
64
- return { end: a, inner: i.slice(e, c.index) };
65
- }
66
- return { end: a, inner: i.slice(e) };
56
+ function s(e, t, n) {
57
+ let r = RegExp(`<${n}\\b`, "gi"), i = RegExp(`</${n}\\s*>`, "gi"), a = 1, o = t;
58
+ for (; a > 0;) {
59
+ i.lastIndex = o;
60
+ let n = i.exec(e);
61
+ if (!n) return {
62
+ end: e.length,
63
+ inner: e.slice(t)
64
+ };
65
+ r.lastIndex = o;
66
+ let s = r.exec(e);
67
+ if (s && s.index < n.index) {
68
+ a += 1, o = s.index + s[0].length;
69
+ continue;
70
+ }
71
+ if (--a, o = n.index + n[0].length, a === 0) return {
72
+ end: o,
73
+ inner: e.slice(t, n.index)
74
+ };
75
+ }
76
+ return {
77
+ end: o,
78
+ inner: e.slice(t)
79
+ };
67
80
  }
68
- function d(i) {
69
- const e = [];
70
- let t = 0;
71
- for (; t < i.length; ) {
72
- const n = i.indexOf("<", t);
73
- if (n === -1) {
74
- e.push({ text: i.slice(t), type: "text" });
75
- break;
76
- }
77
- n > t && e.push({ text: i.slice(t, n), type: "text" });
78
- const o = i.indexOf(">", n);
79
- if (o === -1) {
80
- e.push({ text: i.slice(n), type: "text" });
81
- break;
82
- }
83
- const r = i.slice(n + 1, o);
84
- if (r.startsWith("!") || r.startsWith("/") || r.startsWith("?")) {
85
- t = o + 1;
86
- continue;
87
- }
88
- const a = r.match(/^([a-zA-Z][a-zA-Z0-9-]*)/);
89
- if (!a) {
90
- t = o + 1;
91
- continue;
92
- }
93
- const c = a[1].toLowerCase();
94
- if (w.has(c) || r.trimEnd().endsWith("/")) {
95
- e.push({ attrs: r, inner: "", tag: c, type: "element" }), t = o + 1;
96
- continue;
97
- }
98
- const s = T(i, o + 1, c);
99
- e.push({ attrs: r, inner: s.inner, tag: c, type: "element" }), t = s.end;
100
- }
101
- return e;
81
+ function c(t) {
82
+ let n = [], r = 0;
83
+ for (; r < t.length;) {
84
+ let i = t.indexOf("<", r);
85
+ if (i === -1) {
86
+ n.push({
87
+ text: t.slice(r),
88
+ type: "text"
89
+ });
90
+ break;
91
+ }
92
+ i > r && n.push({
93
+ text: t.slice(r, i),
94
+ type: "text"
95
+ });
96
+ let a = t.indexOf(">", i);
97
+ if (a === -1) {
98
+ n.push({
99
+ text: t.slice(i),
100
+ type: "text"
101
+ });
102
+ break;
103
+ }
104
+ let o = t.slice(i + 1, a);
105
+ if (o.startsWith("!") || o.startsWith("/") || o.startsWith("?")) {
106
+ r = a + 1;
107
+ continue;
108
+ }
109
+ let c = o.match(/^([a-zA-Z][a-zA-Z0-9-]*)/);
110
+ if (!c) {
111
+ r = a + 1;
112
+ continue;
113
+ }
114
+ let l = c[1].toLowerCase();
115
+ if (e.has(l) || o.trimEnd().endsWith("/")) {
116
+ n.push({
117
+ attrs: o,
118
+ inner: "",
119
+ tag: l,
120
+ type: "element"
121
+ }), r = a + 1;
122
+ continue;
123
+ }
124
+ let u = s(t, a + 1, l);
125
+ n.push({
126
+ attrs: o,
127
+ inner: u.inner,
128
+ tag: l,
129
+ type: "element"
130
+ }), r = u.end;
131
+ }
132
+ return n;
102
133
  }
103
- function g(i, e, t) {
104
- if (!e)
105
- return;
106
- const n = i[i.length - 1];
107
- if (n && n.type === "text" && JSON.stringify(n.marks ?? []) === JSON.stringify(t)) {
108
- n.text += e;
109
- return;
110
- }
111
- i.push(t.length > 0 ? { marks: t, text: e, type: "text" } : { text: e, type: "text" });
134
+ function l(e, t, n) {
135
+ if (!t) return;
136
+ let r = e[e.length - 1];
137
+ if (r && r.type === "text" && JSON.stringify(r.marks ?? []) === JSON.stringify(n)) {
138
+ r.text += t;
139
+ return;
140
+ }
141
+ e.push(n.length > 0 ? {
142
+ marks: n,
143
+ text: t,
144
+ type: "text"
145
+ } : {
146
+ text: t,
147
+ type: "text"
148
+ });
112
149
  }
113
- function l(i, e, t) {
114
- const n = [];
115
- if (t > b)
116
- return g(n, u(i.replace(/<[^>]*>/g, "")).replace(/\s+/g, " "), e), n;
117
- for (const o of d(i)) {
118
- if (o.type === "text") {
119
- g(n, u(o.text).replace(/\s+/g, " "), e);
120
- continue;
121
- }
122
- if (h.has(o.tag))
123
- continue;
124
- if (o.tag === "br") {
125
- n.push({ type: "hardBreak" });
126
- continue;
127
- }
128
- if (o.tag === "a") {
129
- const a = A(o.attrs, "href"), c = a ? [...e, { attrs: { href: a, target: "_blank" }, type: "link" }] : e;
130
- n.push(...l(o.inner, c, t + 1));
131
- continue;
132
- }
133
- const r = I[o.tag];
134
- if (r) {
135
- const a = e.some((c) => c.type === r) ? e : [...e, { type: r }];
136
- n.push(...l(o.inner, a, t + 1));
137
- continue;
138
- }
139
- n.push(...l(o.inner, e, t + 1));
140
- }
141
- return n;
150
+ function u(e, n, s) {
151
+ let d = [];
152
+ if (s > i) return l(d, a(e.replace(/<[^>]*>/g, "")).replace(/\s+/g, " "), n), d;
153
+ for (let i of c(e)) {
154
+ if (i.type === "text") {
155
+ l(d, a(i.text).replace(/\s+/g, " "), n);
156
+ continue;
157
+ }
158
+ if (r.has(i.tag)) continue;
159
+ if (i.tag === "br") {
160
+ d.push({ type: "hardBreak" });
161
+ continue;
162
+ }
163
+ if (i.tag === "a") {
164
+ let e = o(i.attrs, "href"), t = e ? [...n, {
165
+ attrs: {
166
+ href: e,
167
+ target: "_blank"
168
+ },
169
+ type: "link"
170
+ }] : n;
171
+ d.push(...u(i.inner, t, s + 1));
172
+ continue;
173
+ }
174
+ let e = t[i.tag];
175
+ if (e) {
176
+ let t = n.some((t) => t.type === e) ? n : [...n, { type: e }];
177
+ d.push(...u(i.inner, t, s + 1));
178
+ continue;
179
+ }
180
+ d.push(...u(i.inner, n, s + 1));
181
+ }
182
+ return d;
142
183
  }
143
- function k(i) {
144
- const e = [...i];
145
- for (; e.length > 0; ) {
146
- const t = e[0];
147
- if (t.type === "hardBreak") {
148
- e.shift();
149
- continue;
150
- }
151
- const n = t.text.replace(/^\s+/, "");
152
- if (!n) {
153
- e.shift();
154
- continue;
155
- }
156
- e[0] = { ...t, text: n };
157
- break;
158
- }
159
- for (; e.length > 0; ) {
160
- const t = e[e.length - 1];
161
- if (t.type === "hardBreak") {
162
- e.pop();
163
- continue;
164
- }
165
- const n = t.text.replace(/\s+$/, "");
166
- if (!n) {
167
- e.pop();
168
- continue;
169
- }
170
- e[e.length - 1] = { ...t, text: n };
171
- break;
172
- }
173
- return e;
184
+ function d(e) {
185
+ let t = [...e];
186
+ for (; t.length > 0;) {
187
+ let e = t[0];
188
+ if (e.type === "hardBreak") {
189
+ t.shift();
190
+ continue;
191
+ }
192
+ let n = e.text.replace(/^\s+/, "");
193
+ if (!n) {
194
+ t.shift();
195
+ continue;
196
+ }
197
+ t[0] = {
198
+ ...e,
199
+ text: n
200
+ };
201
+ break;
202
+ }
203
+ for (; t.length > 0;) {
204
+ let e = t[t.length - 1];
205
+ if (e.type === "hardBreak") {
206
+ t.pop();
207
+ continue;
208
+ }
209
+ let n = e.text.replace(/\s+$/, "");
210
+ if (!n) {
211
+ t.pop();
212
+ continue;
213
+ }
214
+ t[t.length - 1] = {
215
+ ...e,
216
+ text: n
217
+ };
218
+ break;
219
+ }
220
+ return t;
174
221
  }
175
- function y(i) {
176
- const e = k(i);
177
- return e.length > 0 ? { content: e, type: "paragraph" } : null;
222
+ function f(e) {
223
+ let t = d(e);
224
+ return t.length > 0 ? {
225
+ content: t,
226
+ type: "paragraph"
227
+ } : null;
178
228
  }
179
- function $(i, e) {
180
- const t = [];
181
- for (const n of d(i)) {
182
- if (n.type !== "element" || n.tag !== "li")
183
- continue;
184
- const o = f(n.inner, e + 1);
185
- t.push({
186
- content: o.length > 0 ? o : [{ type: "paragraph" }],
187
- type: "listItem"
188
- });
189
- }
190
- return t;
229
+ function p(e, t) {
230
+ let n = [];
231
+ for (let r of c(e)) {
232
+ if (r.type !== "element" || r.tag !== "li") continue;
233
+ let e = m(r.inner, t + 1);
234
+ n.push({
235
+ content: e.length > 0 ? e : [{ type: "paragraph" }],
236
+ type: "listItem"
237
+ });
238
+ }
239
+ return n;
191
240
  }
192
- function f(i, e) {
193
- const t = [];
194
- if (e > b)
195
- return t;
196
- let n = [];
197
- const o = () => {
198
- const r = y(n);
199
- r && t.push(r), n = [];
200
- };
201
- for (const r of d(i)) {
202
- if (r.type === "text") {
203
- g(n, u(r.text).replace(/\s+/g, " "), []);
204
- continue;
205
- }
206
- const { attrs: a, inner: c, tag: s } = r;
207
- if (h.has(s))
208
- continue;
209
- const x = s.match(/^h([1-6])$/);
210
- if (x) {
211
- o();
212
- const p = k(l(c, [], e + 1));
213
- p.length > 0 && t.push({
214
- attrs: { level: Number(x[1]) },
215
- content: p,
216
- type: "heading"
217
- });
218
- continue;
219
- }
220
- if (s === "p") {
221
- o();
222
- const p = y(l(c, [], e + 1));
223
- p && t.push(p);
224
- continue;
225
- }
226
- if (s === "ul" || s === "ol") {
227
- o();
228
- const p = $(c, e);
229
- p.length > 0 && t.push({
230
- content: p,
231
- type: s === "ul" ? "bulletList" : "orderedList"
232
- });
233
- continue;
234
- }
235
- if (s === "blockquote") {
236
- o();
237
- const p = f(c, e + 1);
238
- p.length > 0 && t.push({ content: p, type: "blockquote" });
239
- continue;
240
- }
241
- if (s === "pre") {
242
- o();
243
- const p = u(c.replace(/<[^>]*>/g, "")).replace(/^\n+|\n+$/g, "");
244
- p && t.push({ content: [{ text: p, type: "text" }], type: "codeBlock" });
245
- continue;
246
- }
247
- if (s === "hr") {
248
- o(), t.push({ type: "horizontalRule" });
249
- continue;
250
- }
251
- if (s === "br") {
252
- n.push({ type: "hardBreak" });
253
- continue;
254
- }
255
- if (S.has(s) || s === "li" || s === "table") {
256
- o(), t.push(...f(c, e + 1));
257
- continue;
258
- }
259
- n.push(...l(`<${a}>${c}</${s}>`, [], e + 1));
260
- }
261
- return o(), t;
241
+ function m(e, t) {
242
+ let o = [];
243
+ if (t > i) return o;
244
+ let s = [], h = () => {
245
+ let e = f(s);
246
+ e && o.push(e), s = [];
247
+ };
248
+ for (let i of c(e)) {
249
+ if (i.type === "text") {
250
+ l(s, a(i.text).replace(/\s+/g, " "), []);
251
+ continue;
252
+ }
253
+ let { attrs: e, inner: c, tag: g } = i;
254
+ if (r.has(g)) continue;
255
+ let _ = g.match(/^h([1-6])$/);
256
+ if (_) {
257
+ h();
258
+ let e = d(u(c, [], t + 1));
259
+ e.length > 0 && o.push({
260
+ attrs: { level: Number(_[1]) },
261
+ content: e,
262
+ type: "heading"
263
+ });
264
+ continue;
265
+ }
266
+ if (g === "p") {
267
+ h();
268
+ let e = f(u(c, [], t + 1));
269
+ e && o.push(e);
270
+ continue;
271
+ }
272
+ if (g === "ul" || g === "ol") {
273
+ h();
274
+ let e = p(c, t);
275
+ e.length > 0 && o.push({
276
+ content: e,
277
+ type: g === "ul" ? "bulletList" : "orderedList"
278
+ });
279
+ continue;
280
+ }
281
+ if (g === "blockquote") {
282
+ h();
283
+ let e = m(c, t + 1);
284
+ e.length > 0 && o.push({
285
+ content: e,
286
+ type: "blockquote"
287
+ });
288
+ continue;
289
+ }
290
+ if (g === "pre") {
291
+ h();
292
+ let e = a(c.replace(/<[^>]*>/g, "")).replace(/^\n+|\n+$/g, "");
293
+ e && o.push({
294
+ content: [{
295
+ text: e,
296
+ type: "text"
297
+ }],
298
+ type: "codeBlock"
299
+ });
300
+ continue;
301
+ }
302
+ if (g === "hr") {
303
+ h(), o.push({ type: "horizontalRule" });
304
+ continue;
305
+ }
306
+ if (g === "br") {
307
+ s.push({ type: "hardBreak" });
308
+ continue;
309
+ }
310
+ if (n.has(g) || g === "li" || g === "table") {
311
+ h(), o.push(...m(c, t + 1));
312
+ continue;
313
+ }
314
+ s.push(...u(`<${e}>${c}</${g}>`, [], t + 1));
315
+ }
316
+ return h(), o;
262
317
  }
263
- function m(i) {
264
- return i.split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean).map((e) => ({
265
- content: [{ text: e.replace(/\s*\n\s*/g, " "), type: "text" }],
266
- type: "paragraph"
267
- }));
318
+ function h(e) {
319
+ return e.split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean).map((e) => ({
320
+ content: [{
321
+ text: e.replace(/\s*\n\s*/g, " "),
322
+ type: "text"
323
+ }],
324
+ type: "paragraph"
325
+ }));
268
326
  }
269
- function E(i) {
270
- const e = (typeof i == "string" ? i : "").trim().replace(/^```(?:html|xml)?\s*\n?/i, "").replace(/\n?```$/, "").trim();
271
- if (!e)
272
- return null;
273
- const t = [...h].reduce(
274
- (r, a) => r.replace(new RegExp(`<${a}\\b[\\s\\S]*?</${a}\\s*>`, "gi"), " "),
275
- e
276
- ).trim();
277
- if (!t)
278
- return null;
279
- const o = /<[a-zA-Z!/]/.test(t) ? f(t, 0) : m(t);
280
- if (o.length === 0) {
281
- const r = m(
282
- u(t.replace(/<[^>]*>/g, " ")).replace(/[ \t]+/g, " ")
283
- );
284
- return r.length > 0 ? { content: r, type: "doc" } : null;
285
- }
286
- return { content: o, type: "doc" };
327
+ function g(e) {
328
+ let t = (typeof e == "string" ? e : "").trim().replace(/^```(?:html|xml)?\s*\n?/i, "").replace(/\n?```$/, "").trim();
329
+ if (!t) return null;
330
+ let n = [...r].reduce((e, t) => e.replace(RegExp(`<${t}\\b[\\s\\S]*?</${t}\\s*>`, "gi"), " "), t).trim();
331
+ if (!n) return null;
332
+ let i = /<[a-zA-Z!/]/.test(n) ? m(n, 0) : h(n);
333
+ if (i.length === 0) {
334
+ let e = h(a(n.replace(/<[^>]*>/g, " ")).replace(/[ \t]+/g, " "));
335
+ return e.length > 0 ? {
336
+ content: e,
337
+ type: "doc"
338
+ } : null;
339
+ }
340
+ return {
341
+ content: i,
342
+ type: "doc"
343
+ };
287
344
  }
288
- export {
289
- E as editorDocumentFromHtml
290
- };
345
+ //#endregion
346
+ export { g as editorDocumentFromHtml };
@@ -0,0 +1 @@
1
+ function e(e){let t=e.match(/^::ffff:(.+)$/i);if(!t)return null;let n=t[1];if(/^\d{1,3}(\.\d{1,3}){3}$/.test(n))return n;let r=n.match(/^([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);if(!r)return null;let i=Number.parseInt(r[1],16),a=Number.parseInt(r[2],16);return[i>>8&255,i&255,a>>8&255,a&255].join(`.`)}function t(n){let r=n.trim().toLowerCase().replace(/\.$/,``).replace(/^\[|\]$/g,``);if(!r||r===`localhost`||r.endsWith(`.localhost`)||r.endsWith(`.local`)||r.endsWith(`.internal`)||r===`metadata.google.internal`||r===`0.0.0.0`||r===`::`||r===`::1`||r.startsWith(`fe80:`)||r.startsWith(`fc`)||r.startsWith(`fd`))return!0;let i=e(r);if(i)return t(i);let a=r.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(a){let e=Number(a[1]),t=Number(a[2]);if(e===10||e===127||e===0||e===192&&t===168||e===169&&t===254||e===172&&t>=16&&t<=31)return!0}return!1}exports.isBlockedFetchHost=t;
@@ -0,0 +1,2 @@
1
+ /** Exported for the SSRF regression tests in ai-global-agent-ssrf.test.ts. */
2
+ export declare function isBlockedFetchHost(hostname: string): boolean;