@dudko.dev/agent-web-ui 0.0.3 → 0.0.5

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 (88) hide show
  1. package/README.md +78 -6
  2. package/dist/{chunk-UNIXGP4N.js → chunk-627OXMFG.js} +2 -0
  3. package/dist/{chunk-G7LQTOA2.js → chunk-NHU6WQM5.js} +61 -6
  4. package/dist/controller.cjs +621 -20
  5. package/dist/controller.d.cts +110 -3
  6. package/dist/controller.d.ts +110 -3
  7. package/dist/controller.js +575 -17
  8. package/dist/index.cjs +81 -14
  9. package/dist/index.d.cts +28 -10
  10. package/dist/index.d.ts +28 -10
  11. package/dist/index.js +27 -8
  12. package/dist/{labels-DH1ESUtm.d.ts → labels-CCPL7t17.d.ts} +8 -1
  13. package/dist/{labels-CmiTBLWD.d.cts → labels-ipy-ydkp.d.cts} +8 -1
  14. package/dist/locales/be.cjs +2 -0
  15. package/dist/locales/be.js +1 -1
  16. package/dist/locales/bg.cjs +2 -0
  17. package/dist/locales/bg.js +1 -1
  18. package/dist/locales/ca.cjs +2 -0
  19. package/dist/locales/ca.js +1 -1
  20. package/dist/locales/cs.cjs +2 -0
  21. package/dist/locales/cs.js +1 -1
  22. package/dist/locales/da.cjs +2 -0
  23. package/dist/locales/da.js +1 -1
  24. package/dist/locales/de.cjs +2 -0
  25. package/dist/locales/de.js +1 -1
  26. package/dist/locales/el.cjs +2 -0
  27. package/dist/locales/el.js +1 -1
  28. package/dist/locales/en.cjs +2 -0
  29. package/dist/locales/en.js +1 -1
  30. package/dist/locales/es-419.cjs +2 -0
  31. package/dist/locales/es-419.js +1 -1
  32. package/dist/locales/es.cjs +2 -0
  33. package/dist/locales/es.js +1 -1
  34. package/dist/locales/fi.cjs +2 -0
  35. package/dist/locales/fi.js +1 -1
  36. package/dist/locales/fr-CA.cjs +2 -0
  37. package/dist/locales/fr-CA.js +1 -1
  38. package/dist/locales/fr.cjs +2 -0
  39. package/dist/locales/fr.js +1 -1
  40. package/dist/locales/gn.cjs +2 -0
  41. package/dist/locales/gn.js +1 -1
  42. package/dist/locales/hr.cjs +2 -0
  43. package/dist/locales/hr.js +1 -1
  44. package/dist/locales/ht.cjs +2 -0
  45. package/dist/locales/ht.js +1 -1
  46. package/dist/locales/hu.cjs +2 -0
  47. package/dist/locales/hu.js +1 -1
  48. package/dist/locales/index.cjs +2 -0
  49. package/dist/locales/index.js +1 -1
  50. package/dist/locales/it.cjs +2 -0
  51. package/dist/locales/it.js +1 -1
  52. package/dist/locales/nb.cjs +2 -0
  53. package/dist/locales/nb.js +1 -1
  54. package/dist/locales/nl.cjs +2 -0
  55. package/dist/locales/nl.js +1 -1
  56. package/dist/locales/pl.cjs +2 -0
  57. package/dist/locales/pl.js +1 -1
  58. package/dist/locales/pt-BR.cjs +2 -0
  59. package/dist/locales/pt-BR.js +1 -1
  60. package/dist/locales/pt.cjs +2 -0
  61. package/dist/locales/pt.js +1 -1
  62. package/dist/locales/qu.cjs +2 -0
  63. package/dist/locales/qu.js +1 -1
  64. package/dist/locales/ro.cjs +2 -0
  65. package/dist/locales/ro.js +1 -1
  66. package/dist/locales/ru.cjs +2 -0
  67. package/dist/locales/ru.js +1 -1
  68. package/dist/locales/sk.cjs +2 -0
  69. package/dist/locales/sk.js +1 -1
  70. package/dist/locales/sq.cjs +2 -0
  71. package/dist/locales/sq.js +1 -1
  72. package/dist/locales/sr-Latn.cjs +2 -0
  73. package/dist/locales/sr-Latn.js +1 -1
  74. package/dist/locales/sr.cjs +2 -0
  75. package/dist/locales/sr.js +1 -1
  76. package/dist/locales/sv.cjs +2 -0
  77. package/dist/locales/sv.js +1 -1
  78. package/dist/locales/tr.cjs +2 -0
  79. package/dist/locales/tr.js +1 -1
  80. package/dist/locales/uk.cjs +2 -0
  81. package/dist/locales/uk.js +1 -1
  82. package/dist/markdown.cjs +36 -0
  83. package/dist/markdown.d.cts +27 -1
  84. package/dist/markdown.d.ts +27 -1
  85. package/dist/markdown.js +33 -0
  86. package/dist/mcp-app.cjs +1 -4
  87. package/dist/mcp-app.js +1 -2
  88. package/package.json +1 -1
package/dist/markdown.cjs CHANGED
@@ -23,9 +23,12 @@ __export(markdown_exports, {
23
23
  MARKDOWN_CACHE_MAX: () => MARKDOWN_CACHE_MAX,
24
24
  MARKDOWN_LONG_CELL: () => MARKDOWN_LONG_CELL,
25
25
  emptyMarkdownStream: () => emptyMarkdownStream,
26
+ linkHostAllowed: () => linkHostAllowed,
27
+ linkPolicyOf: () => linkPolicyOf,
26
28
  markdownCellIsLong: () => markdownCellIsLong,
27
29
  markdownPlainText: () => markdownPlainText,
28
30
  markdownSettled: () => markdownSettled,
31
+ parseLinkHosts: () => parseLinkHosts,
29
32
  parseMarkdown: () => parseMarkdown,
30
33
  parseMarkdownCached: () => parseMarkdownCached,
31
34
  parseMarkdownInline: () => parseMarkdownInline,
@@ -602,14 +605,47 @@ var lengthOf = (runs) => runs.reduce(
602
605
  0
603
606
  );
604
607
  var markdownCellIsLong = (runs) => lengthOf(runs) > MARKDOWN_LONG_CELL;
608
+
609
+ // src/markdown/links.ts
610
+ var linkHostAllowed = (href, hosts) => {
611
+ let u;
612
+ try {
613
+ u = new URL(href.trim());
614
+ } catch {
615
+ return false;
616
+ }
617
+ if (u.protocol !== "https:" && u.protocol !== "http:") return false;
618
+ if (u.username !== "" || u.password !== "" || u.port !== "") return false;
619
+ const host = u.hostname.toLowerCase();
620
+ for (const entry of hosts) {
621
+ const e = entry.trim();
622
+ const slash = e.indexOf("/");
623
+ const eHost = (slash < 0 ? e : e.slice(0, slash)).toLowerCase();
624
+ const ePath = slash < 0 ? "" : e.slice(slash).replace(/\/+$/, "");
625
+ if (!eHost || eHost !== host) continue;
626
+ if (!ePath) return true;
627
+ if (u.pathname === ePath || u.pathname.startsWith(`${ePath}/`)) return true;
628
+ }
629
+ return false;
630
+ };
631
+ var linkPolicyOf = (hosts) => (href) => linkHostAllowed(href, hosts);
632
+ var parseLinkHosts = (value) => {
633
+ if (value === null || value === void 0) return void 0;
634
+ const entries = value.split(/[\s,]+/).map((s) => s.trim()).filter(Boolean);
635
+ const ok = entries.every((e) => /^[A-Za-z0-9.-]+(\/[A-Za-z0-9._~@%+-]+)*\/?$/.test(e));
636
+ return ok ? entries : [];
637
+ };
605
638
  // Annotate the CommonJS export names for ESM import in node:
606
639
  0 && (module.exports = {
607
640
  MARKDOWN_CACHE_MAX,
608
641
  MARKDOWN_LONG_CELL,
609
642
  emptyMarkdownStream,
643
+ linkHostAllowed,
644
+ linkPolicyOf,
610
645
  markdownCellIsLong,
611
646
  markdownPlainText,
612
647
  markdownSettled,
648
+ parseLinkHosts,
613
649
  parseMarkdown,
614
650
  parseMarkdownCached,
615
651
  parseMarkdownInline,
@@ -149,5 +149,31 @@ declare const MARKDOWN_LONG_CELL = 48;
149
149
  /** Whether a table cell wraps (see {@link MARKDOWN_LONG_CELL}). */
150
150
  declare const markdownCellIsLong: (runs: MarkdownInline[]) => boolean;
151
151
 
152
- export { MARKDOWN_CACHE_MAX, MARKDOWN_LONG_CELL, emptyMarkdownStream, markdownCellIsLong, markdownPlainText, markdownSettled, parseMarkdown, parseMarkdownCached, parseMarkdownInline, parseMarkdownStreaming, safeHref, workspaceLinkPath };
152
+ /**
153
+ * Which links an answer may keep (a renderer's `linkAllowed`): a host's list of hosts, each
154
+ * `host` or `host/path` - `dudko.dev`, `github.com/dudko-dev`, `npmjs.com/package/@dudko.dev`. A
155
+ * link the list does not name is drawn as its words (and its address, as text): a public chat
156
+ * that should only send people to its own sites (examples/support-cloudflare). Without a list,
157
+ * nothing changes: every link `safeHref` takes stays a link.
158
+ *
159
+ * The rules (each a guard, `tests/markdown.test.ts`): `http(s)` only (no `mailto:`, no other
160
+ * scheme); the host EXACTLY one of the list's, case-insensitive - no subdomain (`evil.dudko.dev`),
161
+ * no look-alike (`dudko.dev.evil.com`); no user or password in the address (`dudko.dev@evil.com`
162
+ * is evil.com's, `user@dudko.dev` refused anyway); the default port only; a path in the entry is a
163
+ * prefix by whole segments (`github.com/dudko-dev` takes `/dudko-dev` and `/dudko-dev/agents`,
164
+ * never `/dudko-devil`), compared after the URL parser's normalisation (`/x/../dudko-dev` is
165
+ * `/dudko-dev`, `%2e%2e` too) and before any percent-decoding.
166
+ */
167
+ declare const linkHostAllowed: (href: string, hosts: readonly string[]) => boolean;
168
+ /** `linkHostAllowed` bound to a list, for a renderer's `linkAllowed`. */
169
+ declare const linkPolicyOf: (hosts: readonly string[]) => ((href: string) => boolean);
170
+ /**
171
+ * A list of hosts as an attribute writes it (`<dd-agent-chat link-hosts="dudko.dev
172
+ * github.com/dudko-dev">`): separated by commas or blanks, empty entries dropped; an entry with a
173
+ * scheme, a query, a fragment, a user or a port makes the whole list empty (the attribute is
174
+ * wrong: no link is kept - never "every link"). No attribute: `undefined` (no allowlist).
175
+ */
176
+ declare const parseLinkHosts: (value: string | null | undefined) => string[] | undefined;
177
+
178
+ export { MARKDOWN_CACHE_MAX, MARKDOWN_LONG_CELL, emptyMarkdownStream, linkHostAllowed, linkPolicyOf, markdownCellIsLong, markdownPlainText, markdownSettled, parseLinkHosts, parseMarkdown, parseMarkdownCached, parseMarkdownInline, parseMarkdownStreaming, safeHref, workspaceLinkPath };
153
179
  export type { MarkdownAlign, MarkdownBlock, MarkdownInline, MarkdownListBlock, MarkdownListItem, MarkdownStream };
@@ -149,5 +149,31 @@ declare const MARKDOWN_LONG_CELL = 48;
149
149
  /** Whether a table cell wraps (see {@link MARKDOWN_LONG_CELL}). */
150
150
  declare const markdownCellIsLong: (runs: MarkdownInline[]) => boolean;
151
151
 
152
- export { MARKDOWN_CACHE_MAX, MARKDOWN_LONG_CELL, emptyMarkdownStream, markdownCellIsLong, markdownPlainText, markdownSettled, parseMarkdown, parseMarkdownCached, parseMarkdownInline, parseMarkdownStreaming, safeHref, workspaceLinkPath };
152
+ /**
153
+ * Which links an answer may keep (a renderer's `linkAllowed`): a host's list of hosts, each
154
+ * `host` or `host/path` - `dudko.dev`, `github.com/dudko-dev`, `npmjs.com/package/@dudko.dev`. A
155
+ * link the list does not name is drawn as its words (and its address, as text): a public chat
156
+ * that should only send people to its own sites (examples/support-cloudflare). Without a list,
157
+ * nothing changes: every link `safeHref` takes stays a link.
158
+ *
159
+ * The rules (each a guard, `tests/markdown.test.ts`): `http(s)` only (no `mailto:`, no other
160
+ * scheme); the host EXACTLY one of the list's, case-insensitive - no subdomain (`evil.dudko.dev`),
161
+ * no look-alike (`dudko.dev.evil.com`); no user or password in the address (`dudko.dev@evil.com`
162
+ * is evil.com's, `user@dudko.dev` refused anyway); the default port only; a path in the entry is a
163
+ * prefix by whole segments (`github.com/dudko-dev` takes `/dudko-dev` and `/dudko-dev/agents`,
164
+ * never `/dudko-devil`), compared after the URL parser's normalisation (`/x/../dudko-dev` is
165
+ * `/dudko-dev`, `%2e%2e` too) and before any percent-decoding.
166
+ */
167
+ declare const linkHostAllowed: (href: string, hosts: readonly string[]) => boolean;
168
+ /** `linkHostAllowed` bound to a list, for a renderer's `linkAllowed`. */
169
+ declare const linkPolicyOf: (hosts: readonly string[]) => ((href: string) => boolean);
170
+ /**
171
+ * A list of hosts as an attribute writes it (`<dd-agent-chat link-hosts="dudko.dev
172
+ * github.com/dudko-dev">`): separated by commas or blanks, empty entries dropped; an entry with a
173
+ * scheme, a query, a fragment, a user or a port makes the whole list empty (the attribute is
174
+ * wrong: no link is kept - never "every link"). No attribute: `undefined` (no allowlist).
175
+ */
176
+ declare const parseLinkHosts: (value: string | null | undefined) => string[] | undefined;
177
+
178
+ export { MARKDOWN_CACHE_MAX, MARKDOWN_LONG_CELL, emptyMarkdownStream, linkHostAllowed, linkPolicyOf, markdownCellIsLong, markdownPlainText, markdownSettled, parseLinkHosts, parseMarkdown, parseMarkdownCached, parseMarkdownInline, parseMarkdownStreaming, safeHref, workspaceLinkPath };
153
179
  export type { MarkdownAlign, MarkdownBlock, MarkdownInline, MarkdownListBlock, MarkdownListItem, MarkdownStream };
package/dist/markdown.js CHANGED
@@ -556,13 +556,46 @@ var lengthOf = (runs) => runs.reduce(
556
556
  0
557
557
  );
558
558
  var markdownCellIsLong = (runs) => lengthOf(runs) > MARKDOWN_LONG_CELL;
559
+
560
+ // src/markdown/links.ts
561
+ var linkHostAllowed = (href, hosts) => {
562
+ let u;
563
+ try {
564
+ u = new URL(href.trim());
565
+ } catch {
566
+ return false;
567
+ }
568
+ if (u.protocol !== "https:" && u.protocol !== "http:") return false;
569
+ if (u.username !== "" || u.password !== "" || u.port !== "") return false;
570
+ const host = u.hostname.toLowerCase();
571
+ for (const entry of hosts) {
572
+ const e = entry.trim();
573
+ const slash = e.indexOf("/");
574
+ const eHost = (slash < 0 ? e : e.slice(0, slash)).toLowerCase();
575
+ const ePath = slash < 0 ? "" : e.slice(slash).replace(/\/+$/, "");
576
+ if (!eHost || eHost !== host) continue;
577
+ if (!ePath) return true;
578
+ if (u.pathname === ePath || u.pathname.startsWith(`${ePath}/`)) return true;
579
+ }
580
+ return false;
581
+ };
582
+ var linkPolicyOf = (hosts) => (href) => linkHostAllowed(href, hosts);
583
+ var parseLinkHosts = (value) => {
584
+ if (value === null || value === void 0) return void 0;
585
+ const entries = value.split(/[\s,]+/).map((s) => s.trim()).filter(Boolean);
586
+ const ok = entries.every((e) => /^[A-Za-z0-9.-]+(\/[A-Za-z0-9._~@%+-]+)*\/?$/.test(e));
587
+ return ok ? entries : [];
588
+ };
559
589
  export {
560
590
  MARKDOWN_CACHE_MAX,
561
591
  MARKDOWN_LONG_CELL,
562
592
  emptyMarkdownStream,
593
+ linkHostAllowed,
594
+ linkPolicyOf,
563
595
  markdownCellIsLong,
564
596
  markdownPlainText,
565
597
  markdownSettled,
598
+ parseLinkHosts,
566
599
  parseMarkdown,
567
600
  parseMarkdownCached,
568
601
  parseMarkdownInline,
package/dist/mcp-app.cjs CHANGED
@@ -85,9 +85,6 @@ __export(mcp_app_entry_exports, {
85
85
  });
86
86
  module.exports = __toCommonJS(mcp_app_entry_exports);
87
87
 
88
- // src/mcp-app.ts
89
- var import_agent_web = require("@dudko.dev/agent-web");
90
-
91
88
  // src/html-preview.ts
92
89
  var escapeAttribute = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
93
90
  var cspMetaTag = (policy) => `<meta http-equiv="Content-Security-Policy" content="${escapeAttribute(policy)}">`;
@@ -213,7 +210,7 @@ var clampAppHeight = (height, max = APP_MAX_HEIGHT) => Math.min(
213
210
  var origins = (list) => {
214
211
  const out = [];
215
212
  for (const entry of list ?? []) {
216
- const origin = (0, import_agent_web.mcpAppOrigin)(entry);
213
+ const origin = mcpAppPolicyOrigin(entry);
217
214
  if (origin && !out.includes(origin)) out.push(origin);
218
215
  }
219
216
  return out;
package/dist/mcp-app.js CHANGED
@@ -18,7 +18,6 @@ import {
18
18
  } from "./chunk-WEYQMUKY.js";
19
19
 
20
20
  // src/mcp-app.ts
21
- import { mcpAppOrigin } from "@dudko.dev/agent-web";
22
21
  var MCP_APP_PROTOCOL_VERSION = "2026-01-26";
23
22
  var APP_DEFAULT_HEIGHT = 360;
24
23
  var APP_MIN_HEIGHT = 120;
@@ -50,7 +49,7 @@ var clampAppHeight = (height, max = APP_MAX_HEIGHT) => Math.min(
50
49
  var origins = (list) => {
51
50
  const out = [];
52
51
  for (const entry of list ?? []) {
53
- const origin = mcpAppOrigin(entry);
52
+ const origin = mcpAppPolicyOrigin(entry);
54
53
  if (origin && !out.includes(origin)) out.push(origin);
55
54
  }
56
55
  return out;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudko.dev/agent-web-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "private": false,
5
5
  "description": "The framework-free UI logic of @dudko.dev/agent-web, the in-browser LLM agent: the headless reducer that turns the agent's events into UI state, every UI string, the composer's and transcript's pure helpers, voice, saved chats, the sandboxed-frame and MCP Apps security cores, the MCP Apps sandbox page for a server, and the pipeline editor's logic - plus the stylesheets. No React: build a front end for any framework on it.",
6
6
  "type": "module",