@aintela/bi 0.2.0 → 0.2.2

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 (46) hide show
  1. package/dist/GridCardPlaceHolder-DVVT3pqn.js +25 -0
  2. package/dist/GridCardPlaceHolder-DVVT3pqn.js.map +1 -0
  3. package/dist/GridLayout-1gWuIKeZ.js +348 -0
  4. package/dist/GridLayout-1gWuIKeZ.js.map +1 -0
  5. package/dist/ScriptDashboardViewerVertical-CuwnxisJ.js +713 -0
  6. package/dist/ScriptDashboardViewerVertical-CuwnxisJ.js.map +1 -0
  7. package/dist/biModuleSurface--gLAiZ9Z.js +34 -0
  8. package/dist/biModuleSurface--gLAiZ9Z.js.map +1 -0
  9. package/dist/cards.js +13 -12
  10. package/dist/cards.js.map +1 -1
  11. package/dist/composer.js +37 -37
  12. package/dist/filterFactory-Ysv0FOQ2.js +285 -0
  13. package/dist/filterFactory-Ysv0FOQ2.js.map +1 -0
  14. package/dist/filters.js +11 -10
  15. package/dist/filters.js.map +1 -1
  16. package/dist/grid.js +12 -10
  17. package/dist/grid.js.map +1 -1
  18. package/dist/index-BRx4bRbe.js +73 -0
  19. package/dist/index-BRx4bRbe.js.map +1 -0
  20. package/dist/index-BzUugG0A.js +136 -0
  21. package/dist/index-BzUugG0A.js.map +1 -0
  22. package/dist/index-DULVx84u.js +3630 -0
  23. package/dist/index-DULVx84u.js.map +1 -0
  24. package/dist/{index-wtSLspPh.js → index-DeiweWw8.js} +348 -368
  25. package/dist/index-DeiweWw8.js.map +1 -0
  26. package/dist/index-K50t61iI.js +13 -0
  27. package/dist/index-K50t61iI.js.map +1 -0
  28. package/dist/index.js +186 -180
  29. package/dist/index.js.map +1 -1
  30. package/dist/runtime/version.d.ts +1 -1
  31. package/dist/runtime.js +14 -13
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/style.css +1 -1
  34. package/dist/useContainerRectangle-D464wPFX.js +27 -0
  35. package/dist/useContainerRectangle-D464wPFX.js.map +1 -0
  36. package/dist/{version-DnqajORq.js → version-BpSiNdYv.js} +20 -19
  37. package/dist/{version-DnqajORq.js.map → version-BpSiNdYv.js.map} +1 -1
  38. package/dist/viewer.js +1 -1
  39. package/package.json +1 -1
  40. package/dist/index-C6JQ6770.js +0 -4545
  41. package/dist/index-C6JQ6770.js.map +0 -1
  42. package/dist/index-D7tVPX8d.js +0 -347
  43. package/dist/index-D7tVPX8d.js.map +0 -1
  44. package/dist/index-DGyvUtY3.js +0 -494
  45. package/dist/index-DGyvUtY3.js.map +0 -1
  46. package/dist/index-wtSLspPh.js.map +0 -1
@@ -1,23 +1,24 @@
1
- var g = Object.defineProperty;
2
- var o = (t, n) => g(t, "name", { value: n, configurable: !0 });
1
+ var x = Object.defineProperty;
2
+ var o = (t, n) => x(t, "name", { value: n, configurable: !0 });
3
3
  import { extendModuleRegistry as M, extendDefaultScope as _, createUiToolRegistry as y } from "@aintela/chat/components";
4
- import { ad as S, ax as B } from "./index-C6JQ6770.js";
4
+ import { getBiModuleSurface as S } from "./biModuleSurface--gLAiZ9Z.js";
5
+ import { s as B } from "./ScriptDashboardViewerVertical-CuwnxisJ.js";
5
6
  import { jsx as l } from "react/jsx-runtime";
6
7
  import { Box as b } from "@mui/material";
7
8
  import { M as m, a as I, C as E, I as R } from "./index-BYc79sSy.js";
8
9
  import { B as V } from "./BiClientProvider-CWJochvi.js";
9
10
  const f = /* @__PURE__ */ new Set();
10
- function z(t) {
11
+ function G(t) {
11
12
  const n = { ...S(), ...t.extraScope ?? {} }, r = t.specifiers.filter((a) => !f.has(a));
12
13
  for (const a of r)
13
14
  M(a, n), f.add(a);
14
15
  (r.length > 0 || t.extraScope) && _(n), B(t.specifiers, t.extraHostModules);
15
16
  }
16
- o(z, "registerBiModules");
17
- function G() {
17
+ o(G, "registerBiModules");
18
+ function P() {
18
19
  f.clear();
19
20
  }
20
- o(G, "resetBiModuleRegistration");
21
+ o(P, "resetBiModuleRegistration");
21
22
  function h(t) {
22
23
  const n = t ?? {}, r = /* @__PURE__ */ o((a) => {
23
24
  const c = n[a] ?? n[a.charAt(0).toUpperCase() + a.slice(1)];
@@ -34,7 +35,7 @@ function h(t) {
34
35
  };
35
36
  }
36
37
  o(h, "normalizeMetricArgs");
37
- function x(t, n) {
38
+ function g(t, n) {
38
39
  let r = t;
39
40
  for (let a = 0; a < 2 && typeof r == "string"; a++)
40
41
  try {
@@ -44,8 +45,8 @@ function x(t, n) {
44
45
  }
45
46
  return r ?? n;
46
47
  }
47
- o(x, "parseJsonArg");
48
- function P(t = {}) {
48
+ o(g, "parseJsonArg");
49
+ function T(t = {}) {
49
50
  const { client: n, onExpandChart: r, onExpandIframe: a } = t, c = /* @__PURE__ */ o((e) => {
50
51
  const s = /* @__PURE__ */ l(b, { sx: { my: 1 }, children: e });
51
52
  return n ? /* @__PURE__ */ l(V, { client: n, children: s }) : s;
@@ -63,21 +64,21 @@ function P(t = {}) {
63
64
  (e = i.refreshDashboard) == null || e.call(i);
64
65
  }, { status: "Dashboard atualizado" }).action("present_dashboard_pad", (e) => {
65
66
  var u, d;
66
- const s = x(e.definitionJson, {});
67
+ const s = g(e.definitionJson, {});
67
68
  e.mode === "create" ? (u = i.createDashboardPad) == null || u.call(i, s) : (d = i.updateDashboardPad) == null || d.call(i, s);
68
69
  }, { status: "Rascunho atualizado" }).action("present_guide", (e) => {
69
70
  var u;
70
- const s = x(e.stepsJson, []);
71
+ const s = g(e.stepsJson, []);
71
72
  Array.isArray(s) && s.length > 0 && ((u = i.showGuide) == null || u.call(i, s));
72
73
  }, { status: "Guia iniciado" }) : p;
73
74
  }
74
- o(P, "createBiUiTools");
75
- const T = "0.2.0";
75
+ o(T, "createBiUiTools");
76
+ const H = "0.2.2";
76
77
  export {
77
- T as B,
78
- G as a,
79
- P as c,
78
+ H as B,
79
+ P as a,
80
+ T as c,
80
81
  h as n,
81
- z as r
82
+ G as r
82
83
  };
83
- //# sourceMappingURL=version-DnqajORq.js.map
84
+ //# sourceMappingURL=version-BpSiNdYv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version-DnqajORq.js","sources":["../src/runtime/registerBiModules.ts","../src/runtime/createBiUiTools.tsx","../src/runtime/version.ts"],"sourcesContent":["import { extendModuleRegistry, extendDefaultScope } from '@aintela/chat/components';\nimport { getBiModuleSurface } from './biModuleSurface';\nimport { seedHostModules } from './loadDashboardBundle';\n\nexport interface RegisterBiModulesOptions {\n /**\n * The module specifiers LLM-emitted code imports from. The compiled\n * snippet does `__scope[\"<specifier>\"].X` and a bundle does\n * `require(\"<specifier>\")`, so every string here must match what the\n * template / instruction files told the model to write.\n *\n * AIA starts clean: `['@aintela/bi']`. Envision must keep resolving the\n * legacy keys forever (persisted sessions + content-hashed bundles):\n * `['@aintela/bi', '@envision/ui-library', '@envision/ui-library/components', …]`.\n */\n specifiers: string[];\n /**\n * Extra values merged into the surface under every specifier AND into the\n * bare-identifier scope — e.g. Envision's `VizLibrary` compat shim, or a\n * host's own components the instructions mention.\n */\n extraScope?: Record<string, unknown>;\n /**\n * Extra `require()` targets for dashboard bundles keyed by specifier\n * (`{ 'date-fns': dateFns, lodash }`). Not in the live-TSX scope.\n */\n extraHostModules?: Record<string, unknown>;\n}\n\nconst registeredKeys = new Set<string>();\n\n/**\n * Makes this library resolvable from LLM-generated code:\n * 1. `extendModuleRegistry(specifier, surface)` once per specifier (live TSX imports);\n * 2. `extendDefaultScope(surface)` once (bare identifiers, no import line);\n * 3. seeds the dashboard-bundle loader's host-module map under the same specifiers.\n *\n * Idempotent per specifier — call it at app start, before the first chat turn\n * or bundle renders.\n */\nexport function registerBiModules(options: RegisterBiModulesOptions): void {\n const surface = { ...getBiModuleSurface(), ...(options.extraScope ?? {}) };\n\n const fresh = options.specifiers.filter((s) => !registeredKeys.has(s));\n for (const specifier of fresh) {\n extendModuleRegistry(specifier, surface);\n registeredKeys.add(specifier);\n }\n if (fresh.length > 0 || options.extraScope) {\n extendDefaultScope(surface);\n }\n seedHostModules(options.specifiers, options.extraHostModules);\n}\n\n/** Test seam. */\nexport function resetBiModuleRegistration(): void {\n registeredKeys.clear();\n}\n","import React from 'react';\nimport { Box } from '@mui/material';\nimport { createUiToolRegistry } from '@aintela/chat/components';\nimport type { UiToolRegistryBuilder } from '@aintela/chat/components';\nimport { Chart, Metric, MetricGroup, IFrame } from '../inline';\nimport type { ChartExpandInfo, IFrameExpandInfo } from '../inline';\nimport { BiClientProvider, type BiClient } from '../client';\nimport type { DashboardEnvironment, GuideStep } from '../composer/environment/types';\n\n/**\n * The explorer's visual vocabulary as `uiTools` registry entries. The chat\n * library owns the plumbing (routing `[KernelUiFunction]` calls, unwrapping\n * args, replay); here we only declare WHAT to draw per tool name.\n *\n * `present_dashboard` and `present_tsx` are deliberately NOT registered — the\n * dashboard hand-off belongs to the dashboard slice and `present_tsx`'s\n * compiled-JS sibling-event plumbing is host policy. Both are added by the\n * host on the returned builder:\n *\n * const uiTools = createBiUiTools({ client })\n * .render('present_dashboard', (a) => <ScriptDashboardViewer dashboardId={a.id} />)\n * .build();\n */\nexport interface CreateBiUiToolsOptions {\n /**\n * Client whose `artifactUrl` / `iframeUrl` resolve the images. When\n * omitted the renderers rely on an ambient `<BiClientProvider>` above the\n * chat pane (which is how a host also passes the session id).\n */\n client?: BiClient;\n /** Expand handlers (a lightbox, an artifact panel). Default: open in a new tab. */\n onExpandChart?: (info: ChartExpandInfo) => void;\n onExpandIframe?: (info: IFrameExpandInfo) => void;\n /** Start from an existing builder to chain more tools before these. */\n builder?: UiToolRegistryBuilder;\n /**\n * The composer's environment (`useComposerEnvironment()` /\n * `environmentFromStore(store)`). When supplied, the three ACTION tools\n * the dashboard agent calls are registered too: `refresh_dashboard`,\n * `present_dashboard_pad` (`definitionJson` + `mode`) and `present_guide`\n * (`stepsJson`). Without it they are left to the host, like `present_dashboard`.\n */\n environment?: Partial<DashboardEnvironment>;\n}\n\n// present_metric uses camelCase params, but present_metric_group's items come\n// from a C# class serialised PascalCase. Read either casing.\nexport interface PresentMetricArgs {\n currentValue: string;\n previousValue?: string;\n prefix?: string;\n suffix?: string;\n differenceStyle?: 'Percentage' | 'Value';\n description?: string;\n icon?: string;\n}\n\nexport function normalizeMetricArgs(raw: unknown): PresentMetricArgs {\n const o = (raw ?? {}) as Record<string, unknown>;\n const g = (k: string): string | undefined => {\n const v = o[k] ?? o[k.charAt(0).toUpperCase() + k.slice(1)];\n return v == null ? undefined : String(v);\n };\n return {\n currentValue: g('currentValue') ?? '',\n previousValue: g('previousValue'),\n prefix: g('prefix'),\n suffix: g('suffix'),\n differenceStyle: g('differenceStyle') as 'Percentage' | 'Value' | undefined,\n description: g('description'),\n icon: g('icon'),\n };\n}\n\nexport interface PresentChartArgs { src?: string; name?: string; alt?: string; reasoning?: string; naked?: boolean }\nexport interface PresentMetricGroupArgs { title?: string; materialIcon?: string; footNote?: string; metrics?: unknown[] }\nexport interface PresentIframeArgs { src?: string; name?: string }\nexport interface PresentDashboardPadArgs { definitionJson?: string; mode?: 'create' | 'update' | string }\nexport interface PresentGuideArgs { stepsJson?: string }\n\n/** JSON text that may have been encoded once or twice on the way through the tool call. */\nfunction parseJsonArg<T>(raw: string | undefined, fallback: T): T {\n let value: unknown = raw;\n for (let i = 0; i < 2 && typeof value === 'string'; i++) {\n try {\n value = JSON.parse(value);\n } catch {\n return fallback;\n }\n }\n return (value ?? fallback) as T;\n}\n\nexport function createBiUiTools(options: CreateBiUiToolsOptions = {}): UiToolRegistryBuilder {\n const { client, onExpandChart, onExpandIframe } = options;\n const wrap = (node: React.ReactNode): React.ReactNode => {\n const boxed = <Box sx={{ my: 1 }}>{node}</Box>;\n return client ? <BiClientProvider client={client}>{boxed}</BiClientProvider> : boxed;\n };\n\n const builder = (options.builder ?? createUiToolRegistry())\n .render<PresentMetricArgs>('present_metric', (args) => {\n const m = normalizeMetricArgs(args);\n if (!m.currentValue) return null;\n return wrap(<Metric partial={false} {...m} />);\n })\n .render<PresentMetricGroupArgs>('present_metric_group', (a) => {\n if (!a.metrics?.length) return null;\n return wrap(\n <MetricGroup partial={false} title={a.title} materialIcon={a.materialIcon} footNote={a.footNote}>\n {a.metrics.map((raw, i) => (\n <Metric key={i} partial={false} {...normalizeMetricArgs(raw)} />\n ))}\n </MetricGroup>,\n );\n })\n .render<PresentChartArgs>('present_chart', (a) => {\n if (!a.src) return null;\n return wrap(<Chart src={a.src} name={a.name} alt={a.alt} reasoning={a.reasoning} naked={a.naked} onExpand={onExpandChart} />);\n })\n .render<PresentIframeArgs>('present_iframe', (a) => {\n if (!a.src || !a.name) return null;\n return wrap(<IFrame partial={false} src={a.src} name={a.name} onExpand={onExpandIframe} />);\n });\n\n const env = options.environment;\n if (!env) return builder;\n\n // Action tools: side effects on the composer, fired once per tool-call id\n // by the chat library; the status chip shows after a successful run.\n return builder\n .action('refresh_dashboard', () => {\n env.refreshDashboard?.();\n }, { status: 'Dashboard atualizado' })\n .action<PresentDashboardPadArgs>('present_dashboard_pad', (a) => {\n const def = parseJsonArg<Record<string, unknown>>(a.definitionJson, {});\n if (a.mode === 'create') env.createDashboardPad?.(def as never);\n else env.updateDashboardPad?.(def as never);\n }, { status: 'Rascunho atualizado' })\n .action<PresentGuideArgs>('present_guide', (a) => {\n const steps = parseJsonArg<GuideStep[]>(a.stepsJson, []);\n if (Array.isArray(steps) && steps.length > 0) env.showGuide?.(steps);\n }, { status: 'Guia iniciado' });\n}\n","/**\n * The package version, so a host can log a mismatch against the server-side\n * `AIntelA.Bi.Agents` version at handshake (the instruction files describe\n * THIS React API). Kept in sync with package.json by `tests/runtime/version.test.ts`.\n */\nexport const BI_RUNTIME_VERSION = '0.2.0';\n"],"names":["registeredKeys","registerBiModules","options","surface","getBiModuleSurface","fresh","s","specifier","extendModuleRegistry","extendDefaultScope","seedHostModules","__name","resetBiModuleRegistration","normalizeMetricArgs","raw","o","g","k","v","parseJsonArg","fallback","value","i","createBiUiTools","client","onExpandChart","onExpandIframe","wrap","node","boxed","Box","jsx","BiClientProvider","builder","createUiToolRegistry","args","m","Metric","a","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E,WAAW,OAAOA,EAAE,OAAO,UAAUb,GAAe,CAAE,IADzG,IAEtB,EACA,OAA0B,kBAAkB,CAACa,MACtC,CAACA,EAAE,OAAO,CAACA,EAAE,OAAa,OACvBX,EAAK,gBAAAI,EAACW,GAAA,EAAO,SAAS,IAAO,KAAKJ,EAAE,KAAK,MAAMA,EAAE,MAAM,UAAUZ,GAAgB,CAAE,CAC7F,GAECiB,IAAMzC,EAAQ;AACpB,SAAKyC,IAIEV,EACF,OAAO,qBAAqB,MAAM;;AAC/B,KAAAM,IAAAI,EAAI,qBAAJ,QAAAJ,EAAA,KAAAI;AAAA,EACJ,GAAG,EAAE,QAAQ,uBAAA,CAAwB,EACpC,OAAgC,yBAAyB,CAACL,MAAM;;AAC7D,UAAMM,IAAMzB,EAAsCmB,EAAE,gBAAgB,CAAA,CAAE;AACtE,IAAIA,EAAE,SAAS,YAAUC,IAAAI,EAAI,uBAAJ,QAAAJ,EAAA,KAAAI,GAAyBC,MAC7CC,IAAAF,EAAI,uBAAJ,QAAAE,EAAA,KAAAF,GAAyBC;AAAA,EAClC,GAAG,EAAE,QAAQ,sBAAA,CAAuB,EACnC,OAAyB,iBAAiB,CAACN,MAAM;;AAC9C,UAAMQ,IAAQ3B,EAA0BmB,EAAE,WAAW,CAAA,CAAE;AACvD,IAAI,MAAM,QAAQQ,CAAK,KAAKA,EAAM,SAAS,OAAGP,IAAAI,EAAI,cAAJ,QAAAJ,EAAA,KAAAI,GAAgBG;AAAA,EAClE,GAAG,EAAE,QAAQ,iBAAiB,IAhBjBb;AAiBrB;AAlDgBtB,EAAAY,GAAA;ACxFT,MAAMwB,IAAqB;"}
1
+ {"version":3,"file":"version-BpSiNdYv.js","sources":["../src/runtime/registerBiModules.ts","../src/runtime/createBiUiTools.tsx","../src/runtime/version.ts"],"sourcesContent":["import { extendModuleRegistry, extendDefaultScope } from '@aintela/chat/components';\nimport { getBiModuleSurface } from './biModuleSurface';\nimport { seedHostModules } from './loadDashboardBundle';\n\nexport interface RegisterBiModulesOptions {\n /**\n * The module specifiers LLM-emitted code imports from. The compiled\n * snippet does `__scope[\"<specifier>\"].X` and a bundle does\n * `require(\"<specifier>\")`, so every string here must match what the\n * template / instruction files told the model to write.\n *\n * AIA starts clean: `['@aintela/bi']`. Envision must keep resolving the\n * legacy keys forever (persisted sessions + content-hashed bundles):\n * `['@aintela/bi', '@envision/ui-library', '@envision/ui-library/components', …]`.\n */\n specifiers: string[];\n /**\n * Extra values merged into the surface under every specifier AND into the\n * bare-identifier scope — e.g. Envision's `VizLibrary` compat shim, or a\n * host's own components the instructions mention.\n */\n extraScope?: Record<string, unknown>;\n /**\n * Extra `require()` targets for dashboard bundles keyed by specifier\n * (`{ 'date-fns': dateFns, lodash }`). Not in the live-TSX scope.\n */\n extraHostModules?: Record<string, unknown>;\n}\n\nconst registeredKeys = new Set<string>();\n\n/**\n * Makes this library resolvable from LLM-generated code:\n * 1. `extendModuleRegistry(specifier, surface)` once per specifier (live TSX imports);\n * 2. `extendDefaultScope(surface)` once (bare identifiers, no import line);\n * 3. seeds the dashboard-bundle loader's host-module map under the same specifiers.\n *\n * Idempotent per specifier — call it at app start, before the first chat turn\n * or bundle renders.\n */\nexport function registerBiModules(options: RegisterBiModulesOptions): void {\n const surface = { ...getBiModuleSurface(), ...(options.extraScope ?? {}) };\n\n const fresh = options.specifiers.filter((s) => !registeredKeys.has(s));\n for (const specifier of fresh) {\n extendModuleRegistry(specifier, surface);\n registeredKeys.add(specifier);\n }\n if (fresh.length > 0 || options.extraScope) {\n extendDefaultScope(surface);\n }\n seedHostModules(options.specifiers, options.extraHostModules);\n}\n\n/** Test seam. */\nexport function resetBiModuleRegistration(): void {\n registeredKeys.clear();\n}\n","import React from 'react';\nimport { Box } from '@mui/material';\nimport { createUiToolRegistry } from '@aintela/chat/components';\nimport type { UiToolRegistryBuilder } from '@aintela/chat/components';\nimport { Chart, Metric, MetricGroup, IFrame } from '../inline';\nimport type { ChartExpandInfo, IFrameExpandInfo } from '../inline';\nimport { BiClientProvider, type BiClient } from '../client';\nimport type { DashboardEnvironment, GuideStep } from '../composer/environment/types';\n\n/**\n * The explorer's visual vocabulary as `uiTools` registry entries. The chat\n * library owns the plumbing (routing `[KernelUiFunction]` calls, unwrapping\n * args, replay); here we only declare WHAT to draw per tool name.\n *\n * `present_dashboard` and `present_tsx` are deliberately NOT registered — the\n * dashboard hand-off belongs to the dashboard slice and `present_tsx`'s\n * compiled-JS sibling-event plumbing is host policy. Both are added by the\n * host on the returned builder:\n *\n * const uiTools = createBiUiTools({ client })\n * .render('present_dashboard', (a) => <ScriptDashboardViewer dashboardId={a.id} />)\n * .build();\n */\nexport interface CreateBiUiToolsOptions {\n /**\n * Client whose `artifactUrl` / `iframeUrl` resolve the images. When\n * omitted the renderers rely on an ambient `<BiClientProvider>` above the\n * chat pane (which is how a host also passes the session id).\n */\n client?: BiClient;\n /** Expand handlers (a lightbox, an artifact panel). Default: open in a new tab. */\n onExpandChart?: (info: ChartExpandInfo) => void;\n onExpandIframe?: (info: IFrameExpandInfo) => void;\n /** Start from an existing builder to chain more tools before these. */\n builder?: UiToolRegistryBuilder;\n /**\n * The composer's environment (`useComposerEnvironment()` /\n * `environmentFromStore(store)`). When supplied, the three ACTION tools\n * the dashboard agent calls are registered too: `refresh_dashboard`,\n * `present_dashboard_pad` (`definitionJson` + `mode`) and `present_guide`\n * (`stepsJson`). Without it they are left to the host, like `present_dashboard`.\n */\n environment?: Partial<DashboardEnvironment>;\n}\n\n// present_metric uses camelCase params, but present_metric_group's items come\n// from a C# class serialised PascalCase. Read either casing.\nexport interface PresentMetricArgs {\n currentValue: string;\n previousValue?: string;\n prefix?: string;\n suffix?: string;\n differenceStyle?: 'Percentage' | 'Value';\n description?: string;\n icon?: string;\n}\n\nexport function normalizeMetricArgs(raw: unknown): PresentMetricArgs {\n const o = (raw ?? {}) as Record<string, unknown>;\n const g = (k: string): string | undefined => {\n const v = o[k] ?? o[k.charAt(0).toUpperCase() + k.slice(1)];\n return v == null ? undefined : String(v);\n };\n return {\n currentValue: g('currentValue') ?? '',\n previousValue: g('previousValue'),\n prefix: g('prefix'),\n suffix: g('suffix'),\n differenceStyle: g('differenceStyle') as 'Percentage' | 'Value' | undefined,\n description: g('description'),\n icon: g('icon'),\n };\n}\n\nexport interface PresentChartArgs { src?: string; name?: string; alt?: string; reasoning?: string; naked?: boolean }\nexport interface PresentMetricGroupArgs { title?: string; materialIcon?: string; footNote?: string; metrics?: unknown[] }\nexport interface PresentIframeArgs { src?: string; name?: string }\nexport interface PresentDashboardPadArgs { definitionJson?: string; mode?: 'create' | 'update' | string }\nexport interface PresentGuideArgs { stepsJson?: string }\n\n/** JSON text that may have been encoded once or twice on the way through the tool call. */\nfunction parseJsonArg<T>(raw: string | undefined, fallback: T): T {\n let value: unknown = raw;\n for (let i = 0; i < 2 && typeof value === 'string'; i++) {\n try {\n value = JSON.parse(value);\n } catch {\n return fallback;\n }\n }\n return (value ?? fallback) as T;\n}\n\nexport function createBiUiTools(options: CreateBiUiToolsOptions = {}): UiToolRegistryBuilder {\n const { client, onExpandChart, onExpandIframe } = options;\n const wrap = (node: React.ReactNode): React.ReactNode => {\n const boxed = <Box sx={{ my: 1 }}>{node}</Box>;\n return client ? <BiClientProvider client={client}>{boxed}</BiClientProvider> : boxed;\n };\n\n const builder = (options.builder ?? createUiToolRegistry())\n .render<PresentMetricArgs>('present_metric', (args) => {\n const m = normalizeMetricArgs(args);\n if (!m.currentValue) return null;\n return wrap(<Metric partial={false} {...m} />);\n })\n .render<PresentMetricGroupArgs>('present_metric_group', (a) => {\n if (!a.metrics?.length) return null;\n return wrap(\n <MetricGroup partial={false} title={a.title} materialIcon={a.materialIcon} footNote={a.footNote}>\n {a.metrics.map((raw, i) => (\n <Metric key={i} partial={false} {...normalizeMetricArgs(raw)} />\n ))}\n </MetricGroup>,\n );\n })\n .render<PresentChartArgs>('present_chart', (a) => {\n if (!a.src) return null;\n return wrap(<Chart src={a.src} name={a.name} alt={a.alt} reasoning={a.reasoning} naked={a.naked} onExpand={onExpandChart} />);\n })\n .render<PresentIframeArgs>('present_iframe', (a) => {\n if (!a.src || !a.name) return null;\n return wrap(<IFrame partial={false} src={a.src} name={a.name} onExpand={onExpandIframe} />);\n });\n\n const env = options.environment;\n if (!env) return builder;\n\n // Action tools: side effects on the composer, fired once per tool-call id\n // by the chat library; the status chip shows after a successful run.\n return builder\n .action('refresh_dashboard', () => {\n env.refreshDashboard?.();\n }, { status: 'Dashboard atualizado' })\n .action<PresentDashboardPadArgs>('present_dashboard_pad', (a) => {\n const def = parseJsonArg<Record<string, unknown>>(a.definitionJson, {});\n if (a.mode === 'create') env.createDashboardPad?.(def as never);\n else env.updateDashboardPad?.(def as never);\n }, { status: 'Rascunho atualizado' })\n .action<PresentGuideArgs>('present_guide', (a) => {\n const steps = parseJsonArg<GuideStep[]>(a.stepsJson, []);\n if (Array.isArray(steps) && steps.length > 0) env.showGuide?.(steps);\n }, { status: 'Guia iniciado' });\n}\n","/**\n * The package version, so a host can log a mismatch against the server-side\n * `AIntelA.Bi.Agents` version at handshake (the instruction files describe\n * THIS React API). Kept in sync with package.json by `tests/runtime/version.test.ts`.\n */\nexport const BI_RUNTIME_VERSION = '0.2.2';\n"],"names":["registeredKeys","registerBiModules","options","surface","getBiModuleSurface","fresh","s","specifier","extendModuleRegistry","extendDefaultScope","seedHostModules","__name","resetBiModuleRegistration","normalizeMetricArgs","raw","o","g","k","v","parseJsonArg","fallback","value","i","createBiUiTools","client","onExpandChart","onExpandIframe","wrap","node","boxed","Box","jsx","BiClientProvider","builder","createUiToolRegistry","args","m","Metric","a","_a","MetricGroup","Chart","IFrame","env","def","_b","steps","BI_RUNTIME_VERSION"],"mappings":";;;;;;;;;AA6BA,MAAMA,wBAAqB,IAAA;AAWpB,SAASC,EAAkBC,GAAyC;AACvE,QAAMC,IAAU,EAAE,GAAGC,EAAA,GAAsB,GAAIF,EAAQ,cAAc,GAAC,GAEhEG,IAAQH,EAAQ,WAAW,OAAO,CAACI,MAAM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7F,GAECiB,IAAMzC,EAAQ;AACpB,SAAKyC,IAIEV,EACF,OAAO,qBAAqB,MAAM;;AAC/B,KAAAM,IAAAI,EAAI,qBAAJ,QAAAJ,EAAA,KAAAI;AAAA,EACJ,GAAG,EAAE,QAAQ,uBAAA,CAAwB,EACpC,OAAgC,yBAAyB,CAACL,MAAM;;AAC7D,UAAMM,IAAMzB,EAAsCmB,EAAE,gBAAgB,CAAA,CAAE;AACtE,IAAIA,EAAE,SAAS,YAAUC,IAAAI,EAAI,uBAAJ,QAAAJ,EAAA,KAAAI,GAAyBC,MAC7CC,IAAAF,EAAI,uBAAJ,QAAAE,EAAA,KAAAF,GAAyBC;AAAA,EAClC,GAAG,EAAE,QAAQ,sBAAA,CAAuB,EACnC,OAAyB,iBAAiB,CAACN,MAAM;;AAC9C,UAAMQ,IAAQ3B,EAA0BmB,EAAE,WAAW,CAAA,CAAE;AACvD,IAAI,MAAM,QAAQQ,CAAK,KAAKA,EAAM,SAAS,OAAGP,IAAAI,EAAI,cAAJ,QAAAJ,EAAA,KAAAI,GAAgBG;AAAA,EAClE,GAAG,EAAE,QAAQ,iBAAiB,IAhBjBb;AAiBrB;AAlDgBtB,EAAAY,GAAA;ACxFT,MAAMwB,IAAqB;"}
package/dist/viewer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as e, K as s, L as d, ar as o, aL as t } from "./index-C6JQ6770.js";
1
+ import { C as e, S as s, a as d, r as o, u as t } from "./ScriptDashboardViewerVertical-CuwnxisJ.js";
2
2
  export {
3
3
  e as CATEGORY_PREFIXES,
4
4
  s as ScriptDashboardViewer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aintela/bi",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "BI visualisation components, dashboard grid, hooks, the dashboard composer (sketch pad + authoring view) and the LLM runtime registry for the AIA platform (extracted from Envision's dashboard app).",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",