@ateam-ai-mobile/core 0.1.33 → 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.d.mts +202 -20
- package/dist/index.d.ts +202 -20
- package/dist/index.js +343 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/chat/blockText.ts +459 -0
- package/src/chat/store.ts +1 -70
- package/src/index.ts +42 -1
package/dist/index.js
CHANGED
|
@@ -20,25 +20,45 @@ 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,
|
|
27
|
+
DETAILS_BLOCK_CLOSE: () => DETAILS_BLOCK_CLOSE,
|
|
28
|
+
DETAILS_BLOCK_OPEN: () => DETAILS_BLOCK_OPEN,
|
|
29
|
+
DIAGRAM_BLOCK_CLOSE: () => DIAGRAM_BLOCK_CLOSE,
|
|
30
|
+
DIAGRAM_BLOCK_OPEN: () => DIAGRAM_BLOCK_OPEN,
|
|
31
|
+
DIAGRAM_STATUSES: () => DIAGRAM_STATUSES,
|
|
23
32
|
MAX_ATTACHMENT_BYTES: () => MAX_ATTACHMENT_BYTES,
|
|
24
33
|
MAX_INLINE_ATTACHMENT_BYTES: () => MAX_INLINE_ATTACHMENT_BYTES,
|
|
25
34
|
PluginCommandEmitter: () => PluginCommandEmitter,
|
|
26
35
|
TABLE_BLOCK_CLOSE: () => TABLE_BLOCK_CLOSE,
|
|
27
36
|
TABLE_BLOCK_OPEN: () => TABLE_BLOCK_OPEN,
|
|
37
|
+
TIMELINE_BLOCK_CLOSE: () => TIMELINE_BLOCK_CLOSE,
|
|
38
|
+
TIMELINE_BLOCK_OPEN: () => TIMELINE_BLOCK_OPEN,
|
|
39
|
+
VISUALS: () => VISUALS,
|
|
28
40
|
ada: () => ada,
|
|
29
41
|
apiFetch: () => apiFetch,
|
|
30
42
|
apiFetchRaw: () => apiFetchRaw,
|
|
31
43
|
blocksToText: () => blocksToText,
|
|
32
44
|
borderRadius: () => borderRadius,
|
|
33
45
|
capabilityEnabled: () => capabilityEnabled,
|
|
46
|
+
chartAsText: () => chartAsText,
|
|
47
|
+
chartScale: () => chartScale,
|
|
48
|
+
chartView: () => chartView,
|
|
34
49
|
closeChatStream: () => closeChatStream,
|
|
35
50
|
colors: () => colors,
|
|
51
|
+
comparisonAsText: () => comparisonAsText,
|
|
52
|
+
comparisonView: () => comparisonView,
|
|
36
53
|
connectAcsWs: () => connectAcsWs,
|
|
37
54
|
connectorCall: () => connectorCall,
|
|
38
55
|
createAuthSession: () => createAuthSession,
|
|
39
56
|
createPushRegistration: () => createPushRegistration,
|
|
40
57
|
deleteArtifact: () => deleteArtifact,
|
|
41
58
|
devModeFromCatalog: () => devModeFromCatalog,
|
|
59
|
+
diagramAsText: () => diagramAsText,
|
|
60
|
+
diagramFlow: () => diagramFlow,
|
|
61
|
+
diagramView: () => diagramView,
|
|
42
62
|
disconnectAcsWs: () => disconnectAcsWs,
|
|
43
63
|
exchangeHandoff: () => exchangeHandoff,
|
|
44
64
|
fetchConsumerConfig: () => fetchConsumerConfig,
|
|
@@ -58,6 +78,7 @@ __export(index_exports, {
|
|
|
58
78
|
initAdas: () => initAdas,
|
|
59
79
|
isAdasInitialized: () => isAdasInitialized,
|
|
60
80
|
isDevHost: () => isDevHost,
|
|
81
|
+
isVisualKind: () => isVisualKind,
|
|
61
82
|
joinWithApple: () => joinWithApple,
|
|
62
83
|
joinWithGoogle: () => joinWithGoogle,
|
|
63
84
|
linkChannelStart: () => linkChannelStart,
|
|
@@ -72,6 +93,7 @@ __export(index_exports, {
|
|
|
72
93
|
nestByMaster: () => nestByMaster,
|
|
73
94
|
notifyAcsWsForeground: () => notifyAcsWsForeground,
|
|
74
95
|
notifyAppForeground: () => notifyAppForeground,
|
|
96
|
+
numText: () => numText,
|
|
75
97
|
onAppForeground: () => onAppForeground,
|
|
76
98
|
openJoinWithApple: () => openJoinWithApple,
|
|
77
99
|
openJoinWithGoogle: () => openJoinWithGoogle,
|
|
@@ -80,6 +102,7 @@ __export(index_exports, {
|
|
|
80
102
|
parseInviteCode: () => parseInviteCode,
|
|
81
103
|
patchArtifact: () => patchArtifact,
|
|
82
104
|
patchHomeAction: () => patchHomeAction,
|
|
105
|
+
plainTextOf: () => plainTextOf,
|
|
83
106
|
pluginCommandEmitter: () => pluginCommandEmitter,
|
|
84
107
|
postCommandResult: () => postCommandResult,
|
|
85
108
|
prepareAttachments: () => prepareAttachments,
|
|
@@ -101,8 +124,11 @@ __export(index_exports, {
|
|
|
101
124
|
signInWithApple: () => signInWithApple,
|
|
102
125
|
signInWithGoogle: () => signInWithGoogle,
|
|
103
126
|
spacing: () => spacing,
|
|
127
|
+
splitBlockSegments: () => splitBlockSegments,
|
|
104
128
|
switchTenant: () => switchTenant,
|
|
105
129
|
tenantFromToken: () => tenantFromToken,
|
|
130
|
+
timelineAsText: () => timelineAsText,
|
|
131
|
+
timelineView: () => timelineView,
|
|
106
132
|
unlinkNotifChannel: () => unlinkChannel,
|
|
107
133
|
unregisterPushDevice: () => unregisterDevice,
|
|
108
134
|
unwrapMcpResult: () => unwrapMcpResult,
|
|
@@ -111,7 +137,8 @@ __export(index_exports, {
|
|
|
111
137
|
useHomeActionsStore: () => useHomeActionsStore,
|
|
112
138
|
useWidgetsStore: () => useWidgetsStore,
|
|
113
139
|
useWorkspaceStore: () => useWorkspaceStore,
|
|
114
|
-
userFromJwt: () => userFromJwt
|
|
140
|
+
userFromJwt: () => userFromJwt,
|
|
141
|
+
visualViewOf: () => visualViewOf
|
|
115
142
|
});
|
|
116
143
|
module.exports = __toCommonJS(index_exports);
|
|
117
144
|
|
|
@@ -1037,10 +1064,10 @@ function backoffMs(attempt) {
|
|
|
1037
1064
|
const jitter = Math.random() * 250;
|
|
1038
1065
|
return base + jitter;
|
|
1039
1066
|
}
|
|
1040
|
-
function send(
|
|
1067
|
+
function send(obj2) {
|
|
1041
1068
|
if (_ws && _ws.readyState === 1) {
|
|
1042
1069
|
try {
|
|
1043
|
-
_ws.send(JSON.stringify(
|
|
1070
|
+
_ws.send(JSON.stringify(obj2));
|
|
1044
1071
|
} catch (e) {
|
|
1045
1072
|
console.warn("[acsWs] send failed", e);
|
|
1046
1073
|
}
|
|
@@ -1564,6 +1591,291 @@ async function prepareAttachments(attachments, onProgress) {
|
|
|
1564
1591
|
return out;
|
|
1565
1592
|
}
|
|
1566
1593
|
|
|
1594
|
+
// src/chat/blockText.ts
|
|
1595
|
+
var TABLE_BLOCK_OPEN = "\uE100";
|
|
1596
|
+
var TABLE_BLOCK_CLOSE = "\uE101";
|
|
1597
|
+
var DETAILS_BLOCK_OPEN = "\uE102";
|
|
1598
|
+
var DETAILS_BLOCK_CLOSE = "\uE103";
|
|
1599
|
+
var DIAGRAM_BLOCK_OPEN = "\uE104";
|
|
1600
|
+
var DIAGRAM_BLOCK_CLOSE = "\uE105";
|
|
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;
|
|
1608
|
+
var clean = (text) => text.replace(SENTINEL_CHARS, "");
|
|
1609
|
+
function renderTableShape(content) {
|
|
1610
|
+
if (!content || typeof content !== "object") return null;
|
|
1611
|
+
const cols = Array.isArray(content.columns) ? content.columns : null;
|
|
1612
|
+
const rows = Array.isArray(content.rows) ? content.rows : null;
|
|
1613
|
+
if (!cols || !rows) return null;
|
|
1614
|
+
const payload = encodeURIComponent(JSON.stringify({ columns: cols, rows }));
|
|
1615
|
+
return `${TABLE_BLOCK_OPEN}${payload}${TABLE_BLOCK_CLOSE}`;
|
|
1616
|
+
}
|
|
1617
|
+
var DIAGRAM_STATUSES = ["ok", "bad", "warn", "info"];
|
|
1618
|
+
var str = (v) => typeof v === "string" ? v : typeof v === "number" || typeof v === "boolean" ? String(v) : "";
|
|
1619
|
+
var statusOf = (v) => DIAGRAM_STATUSES.includes(v) ? v : "";
|
|
1620
|
+
function diagramView(content) {
|
|
1621
|
+
if (!content || typeof content !== "object" || !Array.isArray(content.steps)) return null;
|
|
1622
|
+
const steps = [];
|
|
1623
|
+
const kept = [];
|
|
1624
|
+
const rawNext = [];
|
|
1625
|
+
content.steps.forEach((s, i) => {
|
|
1626
|
+
kept[i + 1] = 0;
|
|
1627
|
+
if (!s || typeof s !== "object") return;
|
|
1628
|
+
const title = str(s.title);
|
|
1629
|
+
const text = str(s.text);
|
|
1630
|
+
if (!title && !text) return;
|
|
1631
|
+
const badges = [];
|
|
1632
|
+
for (const b of Array.isArray(s.badges) ? s.badges : []) {
|
|
1633
|
+
const bt = str(b && typeof b === "object" ? b.text : b);
|
|
1634
|
+
if (bt) badges.push({ text: bt, status: statusOf(b && b.status) });
|
|
1635
|
+
}
|
|
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
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
function diagramAsText(d) {
|
|
1671
|
+
const lines = d.title ? [d.title] : [];
|
|
1672
|
+
d.steps.forEach((s, i) => {
|
|
1673
|
+
const badges = s.badges.length ? ` [${s.badges.map((b) => b.text).join(", ")}]` : "";
|
|
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;
|
|
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
|
+
}
|
|
1734
|
+
return lines.join("\n");
|
|
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
|
+
}
|
|
1769
|
+
function fence(code, language) {
|
|
1770
|
+
const longest = (code.match(/`+/g) || []).reduce((n, run) => Math.max(n, run.length), 0);
|
|
1771
|
+
const ticks = "`".repeat(Math.max(3, longest + 1));
|
|
1772
|
+
return `${ticks}${language}
|
|
1773
|
+
${code}
|
|
1774
|
+
${ticks}`;
|
|
1775
|
+
}
|
|
1776
|
+
function blockText(b) {
|
|
1777
|
+
if (b.kind === "text" || b.kind === "markdown" || b.kind === "description") {
|
|
1778
|
+
return typeof b.content === "string" ? clean(b.content) : "";
|
|
1779
|
+
}
|
|
1780
|
+
if (b.kind === "code") {
|
|
1781
|
+
const nested = b.content && typeof b.content === "object";
|
|
1782
|
+
const code = nested ? b.content.content : b.content;
|
|
1783
|
+
if (typeof code !== "string" || !code.trim()) return "";
|
|
1784
|
+
const lang = clean(String((nested ? b.content.language : b.language) || "").trim());
|
|
1785
|
+
return fence(clean(code), lang && lang.toLowerCase() !== "auto" ? lang : "");
|
|
1786
|
+
}
|
|
1787
|
+
if (b.kind === "table" && b.content && typeof b.content === "object") {
|
|
1788
|
+
const md = renderTableShape(b.content);
|
|
1789
|
+
if (md) return md;
|
|
1790
|
+
}
|
|
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}`;
|
|
1795
|
+
}
|
|
1796
|
+
if (b.kind === "json") {
|
|
1797
|
+
const md = renderTableShape(b.content);
|
|
1798
|
+
if (md) return md;
|
|
1799
|
+
const pretty = JSON.stringify(b.content, null, 2);
|
|
1800
|
+
return typeof pretty === "string" ? fence(clean(pretty), "json") : "";
|
|
1801
|
+
}
|
|
1802
|
+
if (b.kind === "html") {
|
|
1803
|
+
return typeof b.content === "string" ? clean(b.content) : "";
|
|
1804
|
+
}
|
|
1805
|
+
if (typeof b.content === "string") return clean(b.content);
|
|
1806
|
+
return b.content === void 0 ? "" : clean(JSON.stringify(b.content) ?? "");
|
|
1807
|
+
}
|
|
1808
|
+
function blocksToText(blocks) {
|
|
1809
|
+
if (!blocks || blocks.length === 0) return "";
|
|
1810
|
+
return blocks.map((b) => {
|
|
1811
|
+
if (!b || typeof b !== "object") return "";
|
|
1812
|
+
const text = blockText(b);
|
|
1813
|
+
if (!text) return "";
|
|
1814
|
+
if (text.startsWith(TABLE_BLOCK_OPEN) || Object.values(VISUALS).some((v) => text.startsWith(v.open))) return text;
|
|
1815
|
+
return b.meta?.display === "folded" ? `${DETAILS_BLOCK_OPEN}${encodeURIComponent(text)}${DETAILS_BLOCK_CLOSE}` : text;
|
|
1816
|
+
}).filter(Boolean).join("\n\n");
|
|
1817
|
+
}
|
|
1818
|
+
var PAIRS = [
|
|
1819
|
+
{ kind: "table", open: TABLE_BLOCK_OPEN, close: TABLE_BLOCK_CLOSE },
|
|
1820
|
+
{ kind: "details", open: DETAILS_BLOCK_OPEN, close: DETAILS_BLOCK_CLOSE },
|
|
1821
|
+
...Object.keys(VISUALS).map((kind) => ({ kind, open: VISUALS[kind].open, close: VISUALS[kind].close }))
|
|
1822
|
+
];
|
|
1823
|
+
function splitBlockSegments(content) {
|
|
1824
|
+
const segments = [];
|
|
1825
|
+
if (!content) return segments;
|
|
1826
|
+
let cursor = 0;
|
|
1827
|
+
while (cursor < content.length) {
|
|
1828
|
+
let found = null;
|
|
1829
|
+
for (const pair of PAIRS) {
|
|
1830
|
+
const index = content.indexOf(pair.open, cursor);
|
|
1831
|
+
if (index !== -1 && (!found || index < found.index)) found = { index, pair };
|
|
1832
|
+
}
|
|
1833
|
+
if (!found) {
|
|
1834
|
+
segments.push({ kind: "md", content: content.slice(cursor) });
|
|
1835
|
+
break;
|
|
1836
|
+
}
|
|
1837
|
+
if (found.index > cursor) {
|
|
1838
|
+
segments.push({ kind: "md", content: content.slice(cursor, found.index) });
|
|
1839
|
+
}
|
|
1840
|
+
const close = content.indexOf(found.pair.close, found.index + found.pair.open.length);
|
|
1841
|
+
if (close === -1) {
|
|
1842
|
+
segments.push({ kind: "md", content: content.slice(found.index) });
|
|
1843
|
+
break;
|
|
1844
|
+
}
|
|
1845
|
+
segments.push({ kind: found.pair.kind, content: content.slice(found.index + found.pair.open.length, close) });
|
|
1846
|
+
cursor = close + found.pair.close.length;
|
|
1847
|
+
}
|
|
1848
|
+
return segments;
|
|
1849
|
+
}
|
|
1850
|
+
function tableAsText(payload) {
|
|
1851
|
+
try {
|
|
1852
|
+
const data = JSON.parse(decodeURIComponent(payload));
|
|
1853
|
+
const cols = Array.isArray(data?.columns) ? data.columns : [];
|
|
1854
|
+
const rows = Array.isArray(data?.rows) ? data.rows : [];
|
|
1855
|
+
const cell = (v) => v == null ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
1856
|
+
const line = (cells) => (Array.isArray(cells) ? cells : [cells]).map(cell).join(" | ");
|
|
1857
|
+
return [line(cols), ...rows.map(line)].join("\n");
|
|
1858
|
+
} catch {
|
|
1859
|
+
return "";
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
function plainTextOf(content) {
|
|
1863
|
+
if (!content) return "";
|
|
1864
|
+
return splitBlockSegments(content).map((seg) => {
|
|
1865
|
+
if (seg.kind === "md") return seg.content;
|
|
1866
|
+
if (seg.kind === "table") return tableAsText(seg.content);
|
|
1867
|
+
if (isVisualKind(seg.kind)) {
|
|
1868
|
+
const view = visualViewOf(seg.kind, seg.content);
|
|
1869
|
+
return view ? VISUALS[seg.kind].asText(view) : "";
|
|
1870
|
+
}
|
|
1871
|
+
try {
|
|
1872
|
+
return decodeURIComponent(seg.content);
|
|
1873
|
+
} catch {
|
|
1874
|
+
return seg.content;
|
|
1875
|
+
}
|
|
1876
|
+
}).join("");
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1567
1879
|
// src/chat/store.ts
|
|
1568
1880
|
function coreHeaders() {
|
|
1569
1881
|
const token = getToken();
|
|
@@ -1643,48 +1955,6 @@ function isTerminalSnapshot(snap) {
|
|
|
1643
1955
|
if (extractPendingQuestion(snap)) return false;
|
|
1644
1956
|
return snap?.done === true || isTerminalStatus(snap?.status);
|
|
1645
1957
|
}
|
|
1646
|
-
var TABLE_BLOCK_OPEN = "\uE100";
|
|
1647
|
-
var TABLE_BLOCK_CLOSE = "\uE101";
|
|
1648
|
-
function renderTableShape(content) {
|
|
1649
|
-
if (!content || typeof content !== "object") return null;
|
|
1650
|
-
const cols = Array.isArray(content.columns) ? content.columns : null;
|
|
1651
|
-
const rows = Array.isArray(content.rows) ? content.rows : null;
|
|
1652
|
-
if (!cols || !rows) return null;
|
|
1653
|
-
const payload = encodeURIComponent(JSON.stringify({ columns: cols, rows }));
|
|
1654
|
-
return `${TABLE_BLOCK_OPEN}${payload}${TABLE_BLOCK_CLOSE}`;
|
|
1655
|
-
}
|
|
1656
|
-
function blocksToText(blocks) {
|
|
1657
|
-
if (!blocks || blocks.length === 0) return "";
|
|
1658
|
-
const hasTextBlock = blocks.some(
|
|
1659
|
-
(b) => b.kind === "text" || b.kind === "markdown" || b.kind === "description"
|
|
1660
|
-
);
|
|
1661
|
-
return blocks.map((b) => {
|
|
1662
|
-
if ((b.kind === "json" || b.kind === "code") && hasTextBlock) return "";
|
|
1663
|
-
if (b.kind === "text" || b.kind === "markdown" || b.kind === "description") {
|
|
1664
|
-
return typeof b.content === "string" ? b.content : "";
|
|
1665
|
-
}
|
|
1666
|
-
if (b.kind === "code") {
|
|
1667
|
-
const code = typeof b.content === "object" ? b.content.content : b.content;
|
|
1668
|
-
return `\`\`\`
|
|
1669
|
-
${code}
|
|
1670
|
-
\`\`\``;
|
|
1671
|
-
}
|
|
1672
|
-
if (b.kind === "table" && b.content && typeof b.content === "object") {
|
|
1673
|
-
const md = renderTableShape(b.content);
|
|
1674
|
-
if (md) return md;
|
|
1675
|
-
}
|
|
1676
|
-
if (b.kind === "json") {
|
|
1677
|
-
if (b.content && typeof b.content === "object" && "pendingQuestion" in b.content) return "";
|
|
1678
|
-
const md = renderTableShape(b.content);
|
|
1679
|
-
if (md) return md;
|
|
1680
|
-
return "```json\n" + JSON.stringify(b.content, null, 2) + "\n```";
|
|
1681
|
-
}
|
|
1682
|
-
if (b.kind === "html") {
|
|
1683
|
-
return typeof b.content === "string" ? b.content : "";
|
|
1684
|
-
}
|
|
1685
|
-
return typeof b.content === "string" ? b.content : JSON.stringify(b.content);
|
|
1686
|
-
}).filter(Boolean).join("\n\n");
|
|
1687
|
-
}
|
|
1688
1958
|
function blocksToAttachments(blocks) {
|
|
1689
1959
|
if (!blocks || blocks.length === 0) return void 0;
|
|
1690
1960
|
const atts = [];
|
|
@@ -2452,25 +2722,45 @@ var borderRadius = {
|
|
|
2452
2722
|
};
|
|
2453
2723
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2454
2724
|
0 && (module.exports = {
|
|
2725
|
+
CHART_BLOCK_CLOSE,
|
|
2726
|
+
CHART_BLOCK_OPEN,
|
|
2727
|
+
COMPARISON_BLOCK_CLOSE,
|
|
2728
|
+
COMPARISON_BLOCK_OPEN,
|
|
2729
|
+
DETAILS_BLOCK_CLOSE,
|
|
2730
|
+
DETAILS_BLOCK_OPEN,
|
|
2731
|
+
DIAGRAM_BLOCK_CLOSE,
|
|
2732
|
+
DIAGRAM_BLOCK_OPEN,
|
|
2733
|
+
DIAGRAM_STATUSES,
|
|
2455
2734
|
MAX_ATTACHMENT_BYTES,
|
|
2456
2735
|
MAX_INLINE_ATTACHMENT_BYTES,
|
|
2457
2736
|
PluginCommandEmitter,
|
|
2458
2737
|
TABLE_BLOCK_CLOSE,
|
|
2459
2738
|
TABLE_BLOCK_OPEN,
|
|
2739
|
+
TIMELINE_BLOCK_CLOSE,
|
|
2740
|
+
TIMELINE_BLOCK_OPEN,
|
|
2741
|
+
VISUALS,
|
|
2460
2742
|
ada,
|
|
2461
2743
|
apiFetch,
|
|
2462
2744
|
apiFetchRaw,
|
|
2463
2745
|
blocksToText,
|
|
2464
2746
|
borderRadius,
|
|
2465
2747
|
capabilityEnabled,
|
|
2748
|
+
chartAsText,
|
|
2749
|
+
chartScale,
|
|
2750
|
+
chartView,
|
|
2466
2751
|
closeChatStream,
|
|
2467
2752
|
colors,
|
|
2753
|
+
comparisonAsText,
|
|
2754
|
+
comparisonView,
|
|
2468
2755
|
connectAcsWs,
|
|
2469
2756
|
connectorCall,
|
|
2470
2757
|
createAuthSession,
|
|
2471
2758
|
createPushRegistration,
|
|
2472
2759
|
deleteArtifact,
|
|
2473
2760
|
devModeFromCatalog,
|
|
2761
|
+
diagramAsText,
|
|
2762
|
+
diagramFlow,
|
|
2763
|
+
diagramView,
|
|
2474
2764
|
disconnectAcsWs,
|
|
2475
2765
|
exchangeHandoff,
|
|
2476
2766
|
fetchConsumerConfig,
|
|
@@ -2490,6 +2780,7 @@ var borderRadius = {
|
|
|
2490
2780
|
initAdas,
|
|
2491
2781
|
isAdasInitialized,
|
|
2492
2782
|
isDevHost,
|
|
2783
|
+
isVisualKind,
|
|
2493
2784
|
joinWithApple,
|
|
2494
2785
|
joinWithGoogle,
|
|
2495
2786
|
linkChannelStart,
|
|
@@ -2504,6 +2795,7 @@ var borderRadius = {
|
|
|
2504
2795
|
nestByMaster,
|
|
2505
2796
|
notifyAcsWsForeground,
|
|
2506
2797
|
notifyAppForeground,
|
|
2798
|
+
numText,
|
|
2507
2799
|
onAppForeground,
|
|
2508
2800
|
openJoinWithApple,
|
|
2509
2801
|
openJoinWithGoogle,
|
|
@@ -2512,6 +2804,7 @@ var borderRadius = {
|
|
|
2512
2804
|
parseInviteCode,
|
|
2513
2805
|
patchArtifact,
|
|
2514
2806
|
patchHomeAction,
|
|
2807
|
+
plainTextOf,
|
|
2515
2808
|
pluginCommandEmitter,
|
|
2516
2809
|
postCommandResult,
|
|
2517
2810
|
prepareAttachments,
|
|
@@ -2533,8 +2826,11 @@ var borderRadius = {
|
|
|
2533
2826
|
signInWithApple,
|
|
2534
2827
|
signInWithGoogle,
|
|
2535
2828
|
spacing,
|
|
2829
|
+
splitBlockSegments,
|
|
2536
2830
|
switchTenant,
|
|
2537
2831
|
tenantFromToken,
|
|
2832
|
+
timelineAsText,
|
|
2833
|
+
timelineView,
|
|
2538
2834
|
unlinkNotifChannel,
|
|
2539
2835
|
unregisterPushDevice,
|
|
2540
2836
|
unwrapMcpResult,
|
|
@@ -2543,6 +2839,7 @@ var borderRadius = {
|
|
|
2543
2839
|
useHomeActionsStore,
|
|
2544
2840
|
useWidgetsStore,
|
|
2545
2841
|
useWorkspaceStore,
|
|
2546
|
-
userFromJwt
|
|
2842
|
+
userFromJwt,
|
|
2843
|
+
visualViewOf
|
|
2547
2844
|
});
|
|
2548
2845
|
//# sourceMappingURL=index.js.map
|