@ateam-ai-mobile/core 0.1.35 → 0.1.37

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.
package/dist/index.js CHANGED
@@ -20,6 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ CHART_BLOCK_CLOSE: () => CHART_BLOCK_CLOSE,
24
+ CHART_BLOCK_OPEN: () => CHART_BLOCK_OPEN,
25
+ COMPARISON_BLOCK_CLOSE: () => COMPARISON_BLOCK_CLOSE,
26
+ COMPARISON_BLOCK_OPEN: () => COMPARISON_BLOCK_OPEN,
23
27
  DETAILS_BLOCK_CLOSE: () => DETAILS_BLOCK_CLOSE,
24
28
  DETAILS_BLOCK_OPEN: () => DETAILS_BLOCK_OPEN,
25
29
  DIAGRAM_BLOCK_CLOSE: () => DIAGRAM_BLOCK_CLOSE,
@@ -30,14 +34,22 @@ __export(index_exports, {
30
34
  PluginCommandEmitter: () => PluginCommandEmitter,
31
35
  TABLE_BLOCK_CLOSE: () => TABLE_BLOCK_CLOSE,
32
36
  TABLE_BLOCK_OPEN: () => TABLE_BLOCK_OPEN,
37
+ TIMELINE_BLOCK_CLOSE: () => TIMELINE_BLOCK_CLOSE,
38
+ TIMELINE_BLOCK_OPEN: () => TIMELINE_BLOCK_OPEN,
39
+ VISUALS: () => VISUALS,
33
40
  ada: () => ada,
34
41
  apiFetch: () => apiFetch,
35
42
  apiFetchRaw: () => apiFetchRaw,
36
43
  blocksToText: () => blocksToText,
37
44
  borderRadius: () => borderRadius,
38
45
  capabilityEnabled: () => capabilityEnabled,
46
+ chartAsText: () => chartAsText,
47
+ chartScale: () => chartScale,
48
+ chartView: () => chartView,
39
49
  closeChatStream: () => closeChatStream,
40
50
  colors: () => colors,
51
+ comparisonAsText: () => comparisonAsText,
52
+ comparisonView: () => comparisonView,
41
53
  connectAcsWs: () => connectAcsWs,
42
54
  connectorCall: () => connectorCall,
43
55
  createAuthSession: () => createAuthSession,
@@ -45,6 +57,7 @@ __export(index_exports, {
45
57
  deleteArtifact: () => deleteArtifact,
46
58
  devModeFromCatalog: () => devModeFromCatalog,
47
59
  diagramAsText: () => diagramAsText,
60
+ diagramFlow: () => diagramFlow,
48
61
  diagramView: () => diagramView,
49
62
  disconnectAcsWs: () => disconnectAcsWs,
50
63
  exchangeHandoff: () => exchangeHandoff,
@@ -65,6 +78,7 @@ __export(index_exports, {
65
78
  initAdas: () => initAdas,
66
79
  isAdasInitialized: () => isAdasInitialized,
67
80
  isDevHost: () => isDevHost,
81
+ isVisualKind: () => isVisualKind,
68
82
  joinWithApple: () => joinWithApple,
69
83
  joinWithGoogle: () => joinWithGoogle,
70
84
  linkChannelStart: () => linkChannelStart,
@@ -79,6 +93,7 @@ __export(index_exports, {
79
93
  nestByMaster: () => nestByMaster,
80
94
  notifyAcsWsForeground: () => notifyAcsWsForeground,
81
95
  notifyAppForeground: () => notifyAppForeground,
96
+ numText: () => numText,
82
97
  onAppForeground: () => onAppForeground,
83
98
  openJoinWithApple: () => openJoinWithApple,
84
99
  openJoinWithGoogle: () => openJoinWithGoogle,
@@ -112,6 +127,8 @@ __export(index_exports, {
112
127
  splitBlockSegments: () => splitBlockSegments,
113
128
  switchTenant: () => switchTenant,
114
129
  tenantFromToken: () => tenantFromToken,
130
+ timelineAsText: () => timelineAsText,
131
+ timelineView: () => timelineView,
115
132
  unlinkNotifChannel: () => unlinkChannel,
116
133
  unregisterPushDevice: () => unregisterDevice,
117
134
  unwrapMcpResult: () => unwrapMcpResult,
@@ -120,7 +137,8 @@ __export(index_exports, {
120
137
  useHomeActionsStore: () => useHomeActionsStore,
121
138
  useWidgetsStore: () => useWidgetsStore,
122
139
  useWorkspaceStore: () => useWorkspaceStore,
123
- userFromJwt: () => userFromJwt
140
+ userFromJwt: () => userFromJwt,
141
+ visualViewOf: () => visualViewOf
124
142
  });
125
143
  module.exports = __toCommonJS(index_exports);
126
144
 
@@ -1046,10 +1064,10 @@ function backoffMs(attempt) {
1046
1064
  const jitter = Math.random() * 250;
1047
1065
  return base + jitter;
1048
1066
  }
1049
- function send(obj) {
1067
+ function send(obj2) {
1050
1068
  if (_ws && _ws.readyState === 1) {
1051
1069
  try {
1052
- _ws.send(JSON.stringify(obj));
1070
+ _ws.send(JSON.stringify(obj2));
1053
1071
  } catch (e) {
1054
1072
  console.warn("[acsWs] send failed", e);
1055
1073
  }
@@ -1580,7 +1598,13 @@ var DETAILS_BLOCK_OPEN = "\uE102";
1580
1598
  var DETAILS_BLOCK_CLOSE = "\uE103";
1581
1599
  var DIAGRAM_BLOCK_OPEN = "\uE104";
1582
1600
  var DIAGRAM_BLOCK_CLOSE = "\uE105";
1583
- var SENTINEL_CHARS = /[\uE100-\uE105]/g;
1601
+ var CHART_BLOCK_OPEN = "\uE106";
1602
+ var CHART_BLOCK_CLOSE = "\uE107";
1603
+ var COMPARISON_BLOCK_OPEN = "\uE108";
1604
+ var COMPARISON_BLOCK_CLOSE = "\uE109";
1605
+ var TIMELINE_BLOCK_OPEN = "\uE10A";
1606
+ var TIMELINE_BLOCK_CLOSE = "\uE10B";
1607
+ var SENTINEL_CHARS = /[\uE100-\uE10B]/g;
1584
1608
  var clean = (text) => text.replace(SENTINEL_CHARS, "");
1585
1609
  function renderTableShape(content) {
1586
1610
  if (!content || typeof content !== "object") return null;
@@ -1596,28 +1620,152 @@ var statusOf = (v) => DIAGRAM_STATUSES.includes(v) ? v : "";
1596
1620
  function diagramView(content) {
1597
1621
  if (!content || typeof content !== "object" || !Array.isArray(content.steps)) return null;
1598
1622
  const steps = [];
1599
- for (const s of content.steps) {
1600
- if (!s || typeof s !== "object") continue;
1623
+ const kept = [];
1624
+ const rawNext = [];
1625
+ content.steps.forEach((s, i) => {
1626
+ kept[i + 1] = 0;
1627
+ if (!s || typeof s !== "object") return;
1601
1628
  const title = str(s.title);
1602
1629
  const text = str(s.text);
1603
- if (!title && !text) continue;
1630
+ if (!title && !text) return;
1604
1631
  const badges = [];
1605
1632
  for (const b of Array.isArray(s.badges) ? s.badges : []) {
1606
1633
  const bt = str(b && typeof b === "object" ? b.text : b);
1607
1634
  if (bt) badges.push({ text: bt, status: statusOf(b && b.status) });
1608
1635
  }
1609
- steps.push({ title: title || text, text: title ? text : "", status: statusOf(s.status), badges });
1610
- }
1611
- return steps.length < 2 ? null : { title: str(content.title), steps };
1636
+ steps.push({ title: title || text, text: title ? text : "", status: statusOf(s.status), badges, decision: s.kind === "decision" || s.decision === true, next: null });
1637
+ rawNext.push(Array.isArray(s.next) ? s.next : null);
1638
+ kept[i + 1] = steps.length;
1639
+ });
1640
+ if (steps.length < 2) return null;
1641
+ steps.forEach((st, i) => {
1642
+ const raw = rawNext[i];
1643
+ if (!raw) return;
1644
+ const out = [];
1645
+ for (const e of raw) {
1646
+ const to = e && typeof e === "object" && Number.isInteger(e.to) ? kept[e.to] || 0 : 0;
1647
+ if (!to || to === i + 1 || out.some((x) => x.to === to) || out.length >= 3) continue;
1648
+ out.push({ to, label: str(e.label).slice(0, 40) });
1649
+ }
1650
+ st.next = out;
1651
+ });
1652
+ return { title: str(content.title), steps };
1653
+ }
1654
+ function diagramFlow(view) {
1655
+ const last = view.steps.length - 1;
1656
+ return view.steps.map((st, i) => {
1657
+ const flow = { arrow: null, jumps: [], loops: [] };
1658
+ if (!st.next) {
1659
+ if (i < last) flow.arrow = { label: "" };
1660
+ return flow;
1661
+ }
1662
+ for (const e of st.next) {
1663
+ if (e.to === i + 2) flow.arrow = { label: e.label };
1664
+ else if (e.to > i + 2) flow.jumps.push(e);
1665
+ else flow.loops.push(e);
1666
+ }
1667
+ return flow;
1668
+ });
1612
1669
  }
1613
1670
  function diagramAsText(d) {
1614
1671
  const lines = d.title ? [d.title] : [];
1615
1672
  d.steps.forEach((s, i) => {
1616
1673
  const badges = s.badges.length ? ` [${s.badges.map((b) => b.text).join(", ")}]` : "";
1617
- lines.push(`${i + 1}. ${s.title}${s.text ? ` \u2014 ${s.text}` : ""}${badges}`);
1674
+ lines.push(`${i + 1}. ${s.title}${s.decision ? " (decision)" : ""}${s.text ? ` \u2014 ${s.text}` : ""}${badges}`);
1675
+ if (s.next) lines.push(s.next.length ? ` ${s.next.map((e) => `${e.label ? `${e.label} ` : ""}\u2192 ${e.to}`).join("; ")}` : " (end)");
1676
+ });
1677
+ return lines.join("\n");
1678
+ }
1679
+ var num = (v) => typeof v === "number" && Number.isFinite(v) && Math.abs(v) <= 1e15 ? v : null;
1680
+ var list = (v) => Array.isArray(v) ? v : [];
1681
+ var obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
1682
+ var numText = (n) => String(Math.round(n * 100) / 100);
1683
+ function chartView(content) {
1684
+ const c = obj(content);
1685
+ const labels = list(c.labels).map(str);
1686
+ if (labels.length < 2) return null;
1687
+ const series = [];
1688
+ for (const s of list(c.series)) {
1689
+ const values = list(obj(s).values).slice(0, labels.length).map(num);
1690
+ if (values.length === labels.length && values.every((v) => v !== null)) series.push({ name: str(obj(s).name), values });
1691
+ }
1692
+ if (!series.length) return null;
1693
+ const highlight = str(c.highlight);
1694
+ return { title: str(c.title), type: c.type === "line" ? "line" : "bar", labels, series, unit: str(c.unit), highlight: labels.includes(highlight) ? highlight : "" };
1695
+ }
1696
+ function chartScale(view) {
1697
+ const all = view.series.flatMap((s) => s.values);
1698
+ const lo = Math.min(0, ...all);
1699
+ const hi = Math.max(0, ...all);
1700
+ return { lo, hi: hi === lo ? lo + 1 : hi };
1701
+ }
1702
+ function chartAsText(view) {
1703
+ const u = view.unit ? ` ${view.unit}` : "";
1704
+ const lines = view.title ? [view.title] : [];
1705
+ view.labels.forEach((l, i) => {
1706
+ const cells = view.series.map((s) => `${s.name ? `${s.name} ` : ""}${numText(s.values[i])}${u}`);
1707
+ lines.push(`${l}: ${cells.join(", ")}${view.highlight === l ? " (highlighted)" : ""}`);
1708
+ });
1709
+ return lines.join("\n");
1710
+ }
1711
+ function comparisonView(content) {
1712
+ const c = obj(content);
1713
+ const options = [];
1714
+ for (const o of list(c.options)) {
1715
+ const ob = obj(o);
1716
+ const name = str(ob.name);
1717
+ if (!name) continue;
1718
+ const rows = list(ob.rows).map((r) => ({ text: str(obj(r).text), ok: typeof obj(r).ok === "boolean" ? obj(r).ok : null })).filter((r) => r.text);
1719
+ options.push({ name, price: str(ob.price), badge: str(ob.badge), best: ob.best === true, rows });
1720
+ }
1721
+ if (options.length < 2) return null;
1722
+ const first = options.findIndex((o) => o.best);
1723
+ options.forEach((o, i) => {
1724
+ if (i !== first) o.best = false;
1618
1725
  });
1726
+ return { title: str(c.title), options: options.slice(0, 3) };
1727
+ }
1728
+ function comparisonAsText(view) {
1729
+ const lines = view.title ? [view.title] : [];
1730
+ for (const o of view.options) {
1731
+ lines.push(`${o.name}${o.price ? ` (${o.price})` : ""}${o.badge ? ` [${o.badge}]` : ""}${o.best ? " (best)" : ""}`);
1732
+ for (const r of o.rows) lines.push(` ${r.ok === true ? "+" : r.ok === false ? "-" : "\xB7"} ${r.text}`);
1733
+ }
1619
1734
  return lines.join("\n");
1620
1735
  }
1736
+ function timelineView(content) {
1737
+ const c = obj(content);
1738
+ const days = list(c.days).map((d) => ({
1739
+ title: str(obj(d).title),
1740
+ events: list(obj(d).events).map((e) => ({ time: str(obj(e).time), text: str(obj(e).text) })).filter((e) => e.text)
1741
+ })).filter((d) => d.title || d.events.length);
1742
+ if (days.reduce((n, d) => n + d.events.length, 0) < 2) return null;
1743
+ return { title: str(c.title), subtitle: str(c.subtitle), days };
1744
+ }
1745
+ function timelineAsText(view) {
1746
+ const lines = [];
1747
+ if (view.title) lines.push(view.title);
1748
+ if (view.subtitle) lines.push(view.subtitle);
1749
+ for (const d of view.days) {
1750
+ if (d.title) lines.push(d.title);
1751
+ for (const e of d.events) lines.push(` ${e.time ? `${e.time} ` : ""}${e.text}`);
1752
+ }
1753
+ return lines.join("\n");
1754
+ }
1755
+ var VISUALS = {
1756
+ diagram: { open: DIAGRAM_BLOCK_OPEN, close: DIAGRAM_BLOCK_CLOSE, view: diagramView, asText: diagramAsText },
1757
+ chart: { open: CHART_BLOCK_OPEN, close: CHART_BLOCK_CLOSE, view: chartView, asText: chartAsText },
1758
+ comparison: { open: COMPARISON_BLOCK_OPEN, close: COMPARISON_BLOCK_CLOSE, view: comparisonView, asText: comparisonAsText },
1759
+ timeline: { open: TIMELINE_BLOCK_OPEN, close: TIMELINE_BLOCK_CLOSE, view: timelineView, asText: timelineAsText }
1760
+ };
1761
+ var isVisualKind = (kind) => typeof kind === "string" && Object.prototype.hasOwnProperty.call(VISUALS, kind);
1762
+ function visualViewOf(kind, payload) {
1763
+ try {
1764
+ return VISUALS[kind].view(JSON.parse(decodeURIComponent(payload)));
1765
+ } catch {
1766
+ return null;
1767
+ }
1768
+ }
1621
1769
  function fence(code, language) {
1622
1770
  const longest = (code.match(/`+/g) || []).reduce((n, run) => Math.max(n, run.length), 0);
1623
1771
  const ticks = "`".repeat(Math.max(3, longest + 1));
@@ -1640,9 +1788,10 @@ function blockText(b) {
1640
1788
  const md = renderTableShape(b.content);
1641
1789
  if (md) return md;
1642
1790
  }
1643
- if (b.kind === "diagram") {
1644
- const view = diagramView(b.content);
1645
- if (view) return `${DIAGRAM_BLOCK_OPEN}${encodeURIComponent(JSON.stringify(view))}${DIAGRAM_BLOCK_CLOSE}`;
1791
+ if (isVisualKind(b.kind)) {
1792
+ const v = VISUALS[b.kind];
1793
+ const view = v.view(b.content);
1794
+ if (view) return `${v.open}${encodeURIComponent(JSON.stringify(view))}${v.close}`;
1646
1795
  }
1647
1796
  if (b.kind === "json") {
1648
1797
  const md = renderTableShape(b.content);
@@ -1662,14 +1811,14 @@ function blocksToText(blocks) {
1662
1811
  if (!b || typeof b !== "object") return "";
1663
1812
  const text = blockText(b);
1664
1813
  if (!text) return "";
1665
- if (text.startsWith(TABLE_BLOCK_OPEN) || text.startsWith(DIAGRAM_BLOCK_OPEN)) return text;
1814
+ if (text.startsWith(TABLE_BLOCK_OPEN) || Object.values(VISUALS).some((v) => text.startsWith(v.open))) return text;
1666
1815
  return b.meta?.display === "folded" ? `${DETAILS_BLOCK_OPEN}${encodeURIComponent(text)}${DETAILS_BLOCK_CLOSE}` : text;
1667
1816
  }).filter(Boolean).join("\n\n");
1668
1817
  }
1669
1818
  var PAIRS = [
1670
1819
  { kind: "table", open: TABLE_BLOCK_OPEN, close: TABLE_BLOCK_CLOSE },
1671
1820
  { kind: "details", open: DETAILS_BLOCK_OPEN, close: DETAILS_BLOCK_CLOSE },
1672
- { kind: "diagram", open: DIAGRAM_BLOCK_OPEN, close: DIAGRAM_BLOCK_CLOSE }
1821
+ ...Object.keys(VISUALS).map((kind) => ({ kind, open: VISUALS[kind].open, close: VISUALS[kind].close }))
1673
1822
  ];
1674
1823
  function splitBlockSegments(content) {
1675
1824
  const segments = [];
@@ -1715,13 +1864,9 @@ function plainTextOf(content) {
1715
1864
  return splitBlockSegments(content).map((seg) => {
1716
1865
  if (seg.kind === "md") return seg.content;
1717
1866
  if (seg.kind === "table") return tableAsText(seg.content);
1718
- if (seg.kind === "diagram") {
1719
- try {
1720
- const view = diagramView(JSON.parse(decodeURIComponent(seg.content)));
1721
- return view ? diagramAsText(view) : "";
1722
- } catch {
1723
- return "";
1724
- }
1867
+ if (isVisualKind(seg.kind)) {
1868
+ const view = visualViewOf(seg.kind, seg.content);
1869
+ return view ? VISUALS[seg.kind].asText(view) : "";
1725
1870
  }
1726
1871
  try {
1727
1872
  return decodeURIComponent(seg.content);
@@ -2577,6 +2722,10 @@ var borderRadius = {
2577
2722
  };
2578
2723
  // Annotate the CommonJS export names for ESM import in node:
2579
2724
  0 && (module.exports = {
2725
+ CHART_BLOCK_CLOSE,
2726
+ CHART_BLOCK_OPEN,
2727
+ COMPARISON_BLOCK_CLOSE,
2728
+ COMPARISON_BLOCK_OPEN,
2580
2729
  DETAILS_BLOCK_CLOSE,
2581
2730
  DETAILS_BLOCK_OPEN,
2582
2731
  DIAGRAM_BLOCK_CLOSE,
@@ -2587,14 +2736,22 @@ var borderRadius = {
2587
2736
  PluginCommandEmitter,
2588
2737
  TABLE_BLOCK_CLOSE,
2589
2738
  TABLE_BLOCK_OPEN,
2739
+ TIMELINE_BLOCK_CLOSE,
2740
+ TIMELINE_BLOCK_OPEN,
2741
+ VISUALS,
2590
2742
  ada,
2591
2743
  apiFetch,
2592
2744
  apiFetchRaw,
2593
2745
  blocksToText,
2594
2746
  borderRadius,
2595
2747
  capabilityEnabled,
2748
+ chartAsText,
2749
+ chartScale,
2750
+ chartView,
2596
2751
  closeChatStream,
2597
2752
  colors,
2753
+ comparisonAsText,
2754
+ comparisonView,
2598
2755
  connectAcsWs,
2599
2756
  connectorCall,
2600
2757
  createAuthSession,
@@ -2602,6 +2759,7 @@ var borderRadius = {
2602
2759
  deleteArtifact,
2603
2760
  devModeFromCatalog,
2604
2761
  diagramAsText,
2762
+ diagramFlow,
2605
2763
  diagramView,
2606
2764
  disconnectAcsWs,
2607
2765
  exchangeHandoff,
@@ -2622,6 +2780,7 @@ var borderRadius = {
2622
2780
  initAdas,
2623
2781
  isAdasInitialized,
2624
2782
  isDevHost,
2783
+ isVisualKind,
2625
2784
  joinWithApple,
2626
2785
  joinWithGoogle,
2627
2786
  linkChannelStart,
@@ -2636,6 +2795,7 @@ var borderRadius = {
2636
2795
  nestByMaster,
2637
2796
  notifyAcsWsForeground,
2638
2797
  notifyAppForeground,
2798
+ numText,
2639
2799
  onAppForeground,
2640
2800
  openJoinWithApple,
2641
2801
  openJoinWithGoogle,
@@ -2669,6 +2829,8 @@ var borderRadius = {
2669
2829
  splitBlockSegments,
2670
2830
  switchTenant,
2671
2831
  tenantFromToken,
2832
+ timelineAsText,
2833
+ timelineView,
2672
2834
  unlinkNotifChannel,
2673
2835
  unregisterPushDevice,
2674
2836
  unwrapMcpResult,
@@ -2677,6 +2839,7 @@ var borderRadius = {
2677
2839
  useHomeActionsStore,
2678
2840
  useWidgetsStore,
2679
2841
  useWorkspaceStore,
2680
- userFromJwt
2842
+ userFromJwt,
2843
+ visualViewOf
2681
2844
  });
2682
2845
  //# sourceMappingURL=index.js.map