@adecore/agents-react 0.32.0 → 0.33.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.
@@ -1,80 +1,55 @@
1
- /* The token each color reads. Borders carry an alpha, so they are resolved over the ground. */
2
- export const MERMAID_TOKENS = {
3
- ground: '--chat-code-bg',
4
- node: '--surface-raised',
5
- nodeBorder: '--border-strong',
6
- text: '--text',
7
- line: '--text-muted',
8
- cluster: '--surface',
9
- clusterBorder: '--border',
10
- note: '--accent-soft'
1
+ /* The variable of Pele each token of the theme fills. Borders carry an alpha, so every color is resolved over the ground. */
2
+ export const DIAGRAM_TOKENS = {
3
+ '--pele-bg': '--chat-code-bg',
4
+ '--pele-fg': '--text',
5
+ '--pele-muted': '--text-muted',
6
+ '--pele-line': '--text-muted',
7
+ '--pele-surface': '--surface-raised',
8
+ '--pele-surface-alt': '--surface',
9
+ '--pele-border': '--border-strong',
10
+ '--pele-accent': '--accent',
11
+ '--pele-critical': '--status-error',
12
+ '--pele-series-1': '--accent',
13
+ '--pele-series-2': '--chart-2',
14
+ '--pele-series-3': '--chart-3',
15
+ '--pele-series-4': '--chart-4',
16
+ '--pele-series-5': '--chart-5',
17
+ '--pele-series-6': '--chart-6'
11
18
  };
12
- // Mermaid's own list plus what keeps a diagram in the theme and out of HTML: a directive in the text cannot change these.
13
- const SECURE_KEYS = ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize', 'maxEdges', 'suppressErrorRendering', 'htmlLabels', 'theme', 'themeVariables', 'themeCSS', 'darkMode', 'fontFamily'];
19
+ export const GROUND_TOKEN = DIAGRAM_TOKENS['--pele-bg'];
14
20
  /*
15
- * Strict: no HTML in labels, no click handlers, no links that run script. What comes out is drawn as an
16
- * image as well, which never runs script and loads nothing, whatever the text of the diagram says.
21
+ * At the size it was laid out at, since an image has no container to shrink to. No links and no images, and no
22
+ * math or icon resolver, which are the only markup Pele inserts unfiltered. What comes out is drawn as an image as
23
+ * well, which never runs script and loads nothing, whatever the text of the diagram says.
17
24
  */
18
- export function mermaidConfig(colors, dark, font) {
25
+ export function renderOptions(font, idPrefix) {
19
26
  return {
20
- startOnLoad: false,
21
- securityLevel: 'strict',
22
- htmlLabels: false,
23
- suppressErrorRendering: true,
24
- secure: SECURE_KEYS,
25
- theme: 'base',
26
- darkMode: dark,
27
+ responsive: false,
28
+ idPrefix,
27
29
  fontFamily: font.family,
28
- themeVariables: {
29
- darkMode: dark,
30
- fontFamily: font.family,
31
- fontSize: font.size,
32
- background: colors.ground,
33
- primaryColor: colors.node,
34
- primaryTextColor: colors.text,
35
- primaryBorderColor: colors.nodeBorder,
36
- secondaryColor: colors.note,
37
- tertiaryColor: colors.cluster,
38
- mainBkg: colors.node,
39
- nodeBorder: colors.nodeBorder,
40
- textColor: colors.text,
41
- titleColor: colors.text,
42
- lineColor: colors.line,
43
- clusterBkg: colors.cluster,
44
- clusterBorder: colors.clusterBorder,
45
- edgeLabelBackground: colors.ground,
46
- noteBkgColor: colors.note,
47
- noteTextColor: colors.text,
48
- noteBorderColor: colors.nodeBorder
49
- }
30
+ fontFamilyMono: font.mono,
31
+ fontSize: font.size,
32
+ links: false,
33
+ images: false
50
34
  };
51
35
  }
52
36
  const ROOT = /<svg\b[^>]*>/;
53
- const VIEW_BOX = /\sviewBox="([^"]*)"/;
54
- const SIZE_ATTRIBUTES = /\s(?:width|height|style)="[^"]*"/g;
37
+ const STYLE = /\sstyle="/;
38
+ function attributeText(value) {
39
+ return value.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;');
40
+ }
55
41
  /*
56
- * The diagram at the size it was laid out at. Mermaid fits it to the width of its container instead,
57
- * which an image does not have, so the root takes the size its view box names. Null for anything
58
- * without one.
42
+ * The drawing with the colors set on its root. An image does not see the variables of the page, so they are
43
+ * written in, and a change of the theme only writes them again.
59
44
  */
60
- export function sizedSvg(svg) {
45
+ export function themedSvg(svg, colors) {
61
46
  const root = ROOT.exec(svg);
62
- const viewBox = root === null ? null : VIEW_BOX.exec(root[0]);
63
- if (root === null || viewBox === null) {
64
- return null;
65
- }
66
- const [,, boxWidth, boxHeight] = viewBox[1].trim().split(/[\s,]+/).map(Number);
67
- if (!Number.isFinite(boxWidth) || !Number.isFinite(boxHeight) || boxWidth <= 0 || boxHeight <= 0) {
68
- return null;
47
+ if (root === null) {
48
+ return svg;
69
49
  }
70
- const width = Math.ceil(boxWidth);
71
- const height = Math.ceil(boxHeight);
72
- const tag = root[0].replace(SIZE_ATTRIBUTES, '').replace(/^<svg\b/, `<svg width="${width}" height="${height}"`);
73
- return {
74
- svg: svg.slice(0, root.index) + tag + svg.slice(root.index + root[0].length),
75
- width,
76
- height
77
- };
50
+ const variables = attributeText(Object.entries(colors).map(([name, value]) => `${name}:${value};`).join(''));
51
+ const tag = STYLE.test(root[0]) ? root[0].replace(STYLE, style => style + variables) : root[0].replace(/^<svg\b/, `<svg style="${variables}"`);
52
+ return svg.slice(0, root.index) + tag + svg.slice(root.index + root[0].length);
78
53
  }
79
54
  export function svgDataUrl(svg) {
80
55
  return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
@@ -22,6 +22,9 @@ export declare function ToggleLine({ icon, label, brand, detail, command, look,
22
22
  time?: number;
23
23
  className?: string;
24
24
  }): import("react").JSX.Element;
25
+ export declare function ToolBody({ tool }: {
26
+ tool: ChatToolItem;
27
+ }): import("react").JSX.Element;
25
28
  export declare function WorkRow({ tool, chatId, nested, detail, icon, label, failed }: {
26
29
  tool: ChatToolItem;
27
30
  chatId?: string;
@@ -678,7 +678,7 @@ function ToolOutput(t0) {
678
678
  return t3;
679
679
  }
680
680
  /* An opened call without a card: what it was asked in the foreground, what it answered muted below. */
681
- function ToolBody(t0) {
681
+ export function ToolBody(t0) {
682
682
  const $ = _c(16);
683
683
  const {
684
684
  tool