@ateam-ai-mobile/core 0.1.35 → 0.1.38
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 +150 -14
- package/dist/index.d.ts +150 -14
- package/dist/index.js +211 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +190 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/acs/api.ts +46 -0
- package/src/chat/blockText.ts +238 -32
- package/src/index.ts +34 -1
package/dist/index.mjs
CHANGED
|
@@ -621,6 +621,26 @@ async function recordEvent(artifactId, event, surface) {
|
|
|
621
621
|
} catch {
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
+
async function fetchLauncherPlaces() {
|
|
625
|
+
try {
|
|
626
|
+
const res = await authedFetch("/api/acs/launcher", { method: "GET" });
|
|
627
|
+
if (!res.ok) return null;
|
|
628
|
+
const data = await res.json();
|
|
629
|
+
if (!data?.ok) return null;
|
|
630
|
+
return {
|
|
631
|
+
mine: Array.isArray(data.mine) ? data.mine : [],
|
|
632
|
+
resting: Array.isArray(data.resting) ? data.resting : [],
|
|
633
|
+
hidden: Array.isArray(data.hidden) ? data.hidden : []
|
|
634
|
+
};
|
|
635
|
+
} catch (e) {
|
|
636
|
+
console.warn("[acs] /launcher failed:", e?.message || e);
|
|
637
|
+
return null;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
function recordWidgetOpen(pluginId, surface) {
|
|
641
|
+
if (typeof pluginId !== "string" || !pluginId.startsWith("acs:")) return;
|
|
642
|
+
void recordEvent(pluginId.slice(4), "clicked", surface);
|
|
643
|
+
}
|
|
624
644
|
async function listHomeActions() {
|
|
625
645
|
try {
|
|
626
646
|
const res = await authedFetch("/api/acs/home-actions", { method: "GET" });
|
|
@@ -920,10 +940,10 @@ function backoffMs(attempt) {
|
|
|
920
940
|
const jitter = Math.random() * 250;
|
|
921
941
|
return base + jitter;
|
|
922
942
|
}
|
|
923
|
-
function send(
|
|
943
|
+
function send(obj2) {
|
|
924
944
|
if (_ws && _ws.readyState === 1) {
|
|
925
945
|
try {
|
|
926
|
-
_ws.send(JSON.stringify(
|
|
946
|
+
_ws.send(JSON.stringify(obj2));
|
|
927
947
|
} catch (e) {
|
|
928
948
|
console.warn("[acsWs] send failed", e);
|
|
929
949
|
}
|
|
@@ -1454,7 +1474,13 @@ var DETAILS_BLOCK_OPEN = "\uE102";
|
|
|
1454
1474
|
var DETAILS_BLOCK_CLOSE = "\uE103";
|
|
1455
1475
|
var DIAGRAM_BLOCK_OPEN = "\uE104";
|
|
1456
1476
|
var DIAGRAM_BLOCK_CLOSE = "\uE105";
|
|
1457
|
-
var
|
|
1477
|
+
var CHART_BLOCK_OPEN = "\uE106";
|
|
1478
|
+
var CHART_BLOCK_CLOSE = "\uE107";
|
|
1479
|
+
var COMPARISON_BLOCK_OPEN = "\uE108";
|
|
1480
|
+
var COMPARISON_BLOCK_CLOSE = "\uE109";
|
|
1481
|
+
var TIMELINE_BLOCK_OPEN = "\uE10A";
|
|
1482
|
+
var TIMELINE_BLOCK_CLOSE = "\uE10B";
|
|
1483
|
+
var SENTINEL_CHARS = /[\uE100-\uE10B]/g;
|
|
1458
1484
|
var clean = (text) => text.replace(SENTINEL_CHARS, "");
|
|
1459
1485
|
function renderTableShape(content) {
|
|
1460
1486
|
if (!content || typeof content !== "object") return null;
|
|
@@ -1470,28 +1496,152 @@ var statusOf = (v) => DIAGRAM_STATUSES.includes(v) ? v : "";
|
|
|
1470
1496
|
function diagramView(content) {
|
|
1471
1497
|
if (!content || typeof content !== "object" || !Array.isArray(content.steps)) return null;
|
|
1472
1498
|
const steps = [];
|
|
1473
|
-
|
|
1474
|
-
|
|
1499
|
+
const kept = [];
|
|
1500
|
+
const rawNext = [];
|
|
1501
|
+
content.steps.forEach((s, i) => {
|
|
1502
|
+
kept[i + 1] = 0;
|
|
1503
|
+
if (!s || typeof s !== "object") return;
|
|
1475
1504
|
const title = str(s.title);
|
|
1476
1505
|
const text = str(s.text);
|
|
1477
|
-
if (!title && !text)
|
|
1506
|
+
if (!title && !text) return;
|
|
1478
1507
|
const badges = [];
|
|
1479
1508
|
for (const b of Array.isArray(s.badges) ? s.badges : []) {
|
|
1480
1509
|
const bt = str(b && typeof b === "object" ? b.text : b);
|
|
1481
1510
|
if (bt) badges.push({ text: bt, status: statusOf(b && b.status) });
|
|
1482
1511
|
}
|
|
1483
|
-
steps.push({ title: title || text, text: title ? text : "", status: statusOf(s.status), badges });
|
|
1484
|
-
|
|
1485
|
-
|
|
1512
|
+
steps.push({ title: title || text, text: title ? text : "", status: statusOf(s.status), badges, decision: s.kind === "decision" || s.decision === true, next: null });
|
|
1513
|
+
rawNext.push(Array.isArray(s.next) ? s.next : null);
|
|
1514
|
+
kept[i + 1] = steps.length;
|
|
1515
|
+
});
|
|
1516
|
+
if (steps.length < 2) return null;
|
|
1517
|
+
steps.forEach((st, i) => {
|
|
1518
|
+
const raw = rawNext[i];
|
|
1519
|
+
if (!raw) return;
|
|
1520
|
+
const out = [];
|
|
1521
|
+
for (const e of raw) {
|
|
1522
|
+
const to = e && typeof e === "object" && Number.isInteger(e.to) ? kept[e.to] || 0 : 0;
|
|
1523
|
+
if (!to || to === i + 1 || out.some((x) => x.to === to) || out.length >= 3) continue;
|
|
1524
|
+
out.push({ to, label: str(e.label).slice(0, 40) });
|
|
1525
|
+
}
|
|
1526
|
+
st.next = out;
|
|
1527
|
+
});
|
|
1528
|
+
return { title: str(content.title), steps };
|
|
1529
|
+
}
|
|
1530
|
+
function diagramFlow(view) {
|
|
1531
|
+
const last = view.steps.length - 1;
|
|
1532
|
+
return view.steps.map((st, i) => {
|
|
1533
|
+
const flow = { arrow: null, jumps: [], loops: [] };
|
|
1534
|
+
if (!st.next) {
|
|
1535
|
+
if (i < last) flow.arrow = { label: "" };
|
|
1536
|
+
return flow;
|
|
1537
|
+
}
|
|
1538
|
+
for (const e of st.next) {
|
|
1539
|
+
if (e.to === i + 2) flow.arrow = { label: e.label };
|
|
1540
|
+
else if (e.to > i + 2) flow.jumps.push(e);
|
|
1541
|
+
else flow.loops.push(e);
|
|
1542
|
+
}
|
|
1543
|
+
return flow;
|
|
1544
|
+
});
|
|
1486
1545
|
}
|
|
1487
1546
|
function diagramAsText(d) {
|
|
1488
1547
|
const lines = d.title ? [d.title] : [];
|
|
1489
1548
|
d.steps.forEach((s, i) => {
|
|
1490
1549
|
const badges = s.badges.length ? ` [${s.badges.map((b) => b.text).join(", ")}]` : "";
|
|
1491
|
-
lines.push(`${i + 1}. ${s.title}${s.text ? ` \u2014 ${s.text}` : ""}${badges}`);
|
|
1550
|
+
lines.push(`${i + 1}. ${s.title}${s.decision ? " (decision)" : ""}${s.text ? ` \u2014 ${s.text}` : ""}${badges}`);
|
|
1551
|
+
if (s.next) lines.push(s.next.length ? ` ${s.next.map((e) => `${e.label ? `${e.label} ` : ""}\u2192 ${e.to}`).join("; ")}` : " (end)");
|
|
1492
1552
|
});
|
|
1493
1553
|
return lines.join("\n");
|
|
1494
1554
|
}
|
|
1555
|
+
var num = (v) => typeof v === "number" && Number.isFinite(v) && Math.abs(v) <= 1e15 ? v : null;
|
|
1556
|
+
var list = (v) => Array.isArray(v) ? v : [];
|
|
1557
|
+
var obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
1558
|
+
var numText = (n) => String(Math.round(n * 100) / 100);
|
|
1559
|
+
function chartView(content) {
|
|
1560
|
+
const c = obj(content);
|
|
1561
|
+
const labels = list(c.labels).map(str);
|
|
1562
|
+
if (labels.length < 2) return null;
|
|
1563
|
+
const series = [];
|
|
1564
|
+
for (const s of list(c.series)) {
|
|
1565
|
+
const values = list(obj(s).values).slice(0, labels.length).map(num);
|
|
1566
|
+
if (values.length === labels.length && values.every((v) => v !== null)) series.push({ name: str(obj(s).name), values });
|
|
1567
|
+
}
|
|
1568
|
+
if (!series.length) return null;
|
|
1569
|
+
const highlight = str(c.highlight);
|
|
1570
|
+
return { title: str(c.title), type: c.type === "line" ? "line" : "bar", labels, series, unit: str(c.unit), highlight: labels.includes(highlight) ? highlight : "" };
|
|
1571
|
+
}
|
|
1572
|
+
function chartScale(view) {
|
|
1573
|
+
const all = view.series.flatMap((s) => s.values);
|
|
1574
|
+
const lo = Math.min(0, ...all);
|
|
1575
|
+
const hi = Math.max(0, ...all);
|
|
1576
|
+
return { lo, hi: hi === lo ? lo + 1 : hi };
|
|
1577
|
+
}
|
|
1578
|
+
function chartAsText(view) {
|
|
1579
|
+
const u = view.unit ? ` ${view.unit}` : "";
|
|
1580
|
+
const lines = view.title ? [view.title] : [];
|
|
1581
|
+
view.labels.forEach((l, i) => {
|
|
1582
|
+
const cells = view.series.map((s) => `${s.name ? `${s.name} ` : ""}${numText(s.values[i])}${u}`);
|
|
1583
|
+
lines.push(`${l}: ${cells.join(", ")}${view.highlight === l ? " (highlighted)" : ""}`);
|
|
1584
|
+
});
|
|
1585
|
+
return lines.join("\n");
|
|
1586
|
+
}
|
|
1587
|
+
function comparisonView(content) {
|
|
1588
|
+
const c = obj(content);
|
|
1589
|
+
const options = [];
|
|
1590
|
+
for (const o of list(c.options)) {
|
|
1591
|
+
const ob = obj(o);
|
|
1592
|
+
const name = str(ob.name);
|
|
1593
|
+
if (!name) continue;
|
|
1594
|
+
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);
|
|
1595
|
+
options.push({ name, price: str(ob.price), badge: str(ob.badge), best: ob.best === true, rows });
|
|
1596
|
+
}
|
|
1597
|
+
if (options.length < 2) return null;
|
|
1598
|
+
const first = options.findIndex((o) => o.best);
|
|
1599
|
+
options.forEach((o, i) => {
|
|
1600
|
+
if (i !== first) o.best = false;
|
|
1601
|
+
});
|
|
1602
|
+
return { title: str(c.title), options: options.slice(0, 3) };
|
|
1603
|
+
}
|
|
1604
|
+
function comparisonAsText(view) {
|
|
1605
|
+
const lines = view.title ? [view.title] : [];
|
|
1606
|
+
for (const o of view.options) {
|
|
1607
|
+
lines.push(`${o.name}${o.price ? ` (${o.price})` : ""}${o.badge ? ` [${o.badge}]` : ""}${o.best ? " (best)" : ""}`);
|
|
1608
|
+
for (const r of o.rows) lines.push(` ${r.ok === true ? "+" : r.ok === false ? "-" : "\xB7"} ${r.text}`);
|
|
1609
|
+
}
|
|
1610
|
+
return lines.join("\n");
|
|
1611
|
+
}
|
|
1612
|
+
function timelineView(content) {
|
|
1613
|
+
const c = obj(content);
|
|
1614
|
+
const days = list(c.days).map((d) => ({
|
|
1615
|
+
title: str(obj(d).title),
|
|
1616
|
+
events: list(obj(d).events).map((e) => ({ time: str(obj(e).time), text: str(obj(e).text) })).filter((e) => e.text)
|
|
1617
|
+
})).filter((d) => d.title || d.events.length);
|
|
1618
|
+
if (days.reduce((n, d) => n + d.events.length, 0) < 2) return null;
|
|
1619
|
+
return { title: str(c.title), subtitle: str(c.subtitle), days };
|
|
1620
|
+
}
|
|
1621
|
+
function timelineAsText(view) {
|
|
1622
|
+
const lines = [];
|
|
1623
|
+
if (view.title) lines.push(view.title);
|
|
1624
|
+
if (view.subtitle) lines.push(view.subtitle);
|
|
1625
|
+
for (const d of view.days) {
|
|
1626
|
+
if (d.title) lines.push(d.title);
|
|
1627
|
+
for (const e of d.events) lines.push(` ${e.time ? `${e.time} ` : ""}${e.text}`);
|
|
1628
|
+
}
|
|
1629
|
+
return lines.join("\n");
|
|
1630
|
+
}
|
|
1631
|
+
var VISUALS = {
|
|
1632
|
+
diagram: { open: DIAGRAM_BLOCK_OPEN, close: DIAGRAM_BLOCK_CLOSE, view: diagramView, asText: diagramAsText },
|
|
1633
|
+
chart: { open: CHART_BLOCK_OPEN, close: CHART_BLOCK_CLOSE, view: chartView, asText: chartAsText },
|
|
1634
|
+
comparison: { open: COMPARISON_BLOCK_OPEN, close: COMPARISON_BLOCK_CLOSE, view: comparisonView, asText: comparisonAsText },
|
|
1635
|
+
timeline: { open: TIMELINE_BLOCK_OPEN, close: TIMELINE_BLOCK_CLOSE, view: timelineView, asText: timelineAsText }
|
|
1636
|
+
};
|
|
1637
|
+
var isVisualKind = (kind) => typeof kind === "string" && Object.prototype.hasOwnProperty.call(VISUALS, kind);
|
|
1638
|
+
function visualViewOf(kind, payload) {
|
|
1639
|
+
try {
|
|
1640
|
+
return VISUALS[kind].view(JSON.parse(decodeURIComponent(payload)));
|
|
1641
|
+
} catch {
|
|
1642
|
+
return null;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1495
1645
|
function fence(code, language) {
|
|
1496
1646
|
const longest = (code.match(/`+/g) || []).reduce((n, run) => Math.max(n, run.length), 0);
|
|
1497
1647
|
const ticks = "`".repeat(Math.max(3, longest + 1));
|
|
@@ -1514,9 +1664,10 @@ function blockText(b) {
|
|
|
1514
1664
|
const md = renderTableShape(b.content);
|
|
1515
1665
|
if (md) return md;
|
|
1516
1666
|
}
|
|
1517
|
-
if (b.kind
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1667
|
+
if (isVisualKind(b.kind)) {
|
|
1668
|
+
const v = VISUALS[b.kind];
|
|
1669
|
+
const view = v.view(b.content);
|
|
1670
|
+
if (view) return `${v.open}${encodeURIComponent(JSON.stringify(view))}${v.close}`;
|
|
1520
1671
|
}
|
|
1521
1672
|
if (b.kind === "json") {
|
|
1522
1673
|
const md = renderTableShape(b.content);
|
|
@@ -1536,14 +1687,14 @@ function blocksToText(blocks) {
|
|
|
1536
1687
|
if (!b || typeof b !== "object") return "";
|
|
1537
1688
|
const text = blockText(b);
|
|
1538
1689
|
if (!text) return "";
|
|
1539
|
-
if (text.startsWith(TABLE_BLOCK_OPEN) || text.startsWith(
|
|
1690
|
+
if (text.startsWith(TABLE_BLOCK_OPEN) || Object.values(VISUALS).some((v) => text.startsWith(v.open))) return text;
|
|
1540
1691
|
return b.meta?.display === "folded" ? `${DETAILS_BLOCK_OPEN}${encodeURIComponent(text)}${DETAILS_BLOCK_CLOSE}` : text;
|
|
1541
1692
|
}).filter(Boolean).join("\n\n");
|
|
1542
1693
|
}
|
|
1543
1694
|
var PAIRS = [
|
|
1544
1695
|
{ kind: "table", open: TABLE_BLOCK_OPEN, close: TABLE_BLOCK_CLOSE },
|
|
1545
1696
|
{ kind: "details", open: DETAILS_BLOCK_OPEN, close: DETAILS_BLOCK_CLOSE },
|
|
1546
|
-
{ kind
|
|
1697
|
+
...Object.keys(VISUALS).map((kind) => ({ kind, open: VISUALS[kind].open, close: VISUALS[kind].close }))
|
|
1547
1698
|
];
|
|
1548
1699
|
function splitBlockSegments(content) {
|
|
1549
1700
|
const segments = [];
|
|
@@ -1589,13 +1740,9 @@ function plainTextOf(content) {
|
|
|
1589
1740
|
return splitBlockSegments(content).map((seg) => {
|
|
1590
1741
|
if (seg.kind === "md") return seg.content;
|
|
1591
1742
|
if (seg.kind === "table") return tableAsText(seg.content);
|
|
1592
|
-
if (seg.kind
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
return view ? diagramAsText(view) : "";
|
|
1596
|
-
} catch {
|
|
1597
|
-
return "";
|
|
1598
|
-
}
|
|
1743
|
+
if (isVisualKind(seg.kind)) {
|
|
1744
|
+
const view = visualViewOf(seg.kind, seg.content);
|
|
1745
|
+
return view ? VISUALS[seg.kind].asText(view) : "";
|
|
1599
1746
|
}
|
|
1600
1747
|
try {
|
|
1601
1748
|
return decodeURIComponent(seg.content);
|
|
@@ -2450,6 +2597,10 @@ var borderRadius = {
|
|
|
2450
2597
|
full: 9999
|
|
2451
2598
|
};
|
|
2452
2599
|
export {
|
|
2600
|
+
CHART_BLOCK_CLOSE,
|
|
2601
|
+
CHART_BLOCK_OPEN,
|
|
2602
|
+
COMPARISON_BLOCK_CLOSE,
|
|
2603
|
+
COMPARISON_BLOCK_OPEN,
|
|
2453
2604
|
DETAILS_BLOCK_CLOSE,
|
|
2454
2605
|
DETAILS_BLOCK_OPEN,
|
|
2455
2606
|
DIAGRAM_BLOCK_CLOSE,
|
|
@@ -2460,14 +2611,22 @@ export {
|
|
|
2460
2611
|
PluginCommandEmitter,
|
|
2461
2612
|
TABLE_BLOCK_CLOSE,
|
|
2462
2613
|
TABLE_BLOCK_OPEN,
|
|
2614
|
+
TIMELINE_BLOCK_CLOSE,
|
|
2615
|
+
TIMELINE_BLOCK_OPEN,
|
|
2616
|
+
VISUALS,
|
|
2463
2617
|
ada,
|
|
2464
2618
|
apiFetch,
|
|
2465
2619
|
apiFetchRaw,
|
|
2466
2620
|
blocksToText,
|
|
2467
2621
|
borderRadius,
|
|
2468
2622
|
capabilityEnabled,
|
|
2623
|
+
chartAsText,
|
|
2624
|
+
chartScale,
|
|
2625
|
+
chartView,
|
|
2469
2626
|
closeChatStream,
|
|
2470
2627
|
colors,
|
|
2628
|
+
comparisonAsText,
|
|
2629
|
+
comparisonView,
|
|
2471
2630
|
connectAcsWs,
|
|
2472
2631
|
connectorCall,
|
|
2473
2632
|
createAuthSession,
|
|
@@ -2475,10 +2634,12 @@ export {
|
|
|
2475
2634
|
deleteArtifact,
|
|
2476
2635
|
devModeFromCatalog,
|
|
2477
2636
|
diagramAsText,
|
|
2637
|
+
diagramFlow,
|
|
2478
2638
|
diagramView,
|
|
2479
2639
|
disconnectAcsWs,
|
|
2480
2640
|
exchangeHandoff,
|
|
2481
2641
|
fetchConsumerConfig,
|
|
2642
|
+
fetchLauncherPlaces,
|
|
2482
2643
|
focusPlugin,
|
|
2483
2644
|
fontSize,
|
|
2484
2645
|
getConfig,
|
|
@@ -2495,6 +2656,7 @@ export {
|
|
|
2495
2656
|
initAdas,
|
|
2496
2657
|
isAdasInitialized,
|
|
2497
2658
|
isDevHost,
|
|
2659
|
+
isVisualKind,
|
|
2498
2660
|
joinWithApple,
|
|
2499
2661
|
joinWithGoogle,
|
|
2500
2662
|
linkChannelStart,
|
|
@@ -2509,6 +2671,7 @@ export {
|
|
|
2509
2671
|
nestByMaster,
|
|
2510
2672
|
notifyAcsWsForeground,
|
|
2511
2673
|
notifyAppForeground,
|
|
2674
|
+
numText,
|
|
2512
2675
|
onAppForeground,
|
|
2513
2676
|
openJoinWithApple,
|
|
2514
2677
|
openJoinWithGoogle,
|
|
@@ -2525,6 +2688,7 @@ export {
|
|
|
2525
2688
|
readDevMode,
|
|
2526
2689
|
recentDispatches as recentNotifDispatches,
|
|
2527
2690
|
recordEvent,
|
|
2691
|
+
recordWidgetOpen,
|
|
2528
2692
|
refreshToken,
|
|
2529
2693
|
registerHostIntent,
|
|
2530
2694
|
registerDevice as registerPushDevice,
|
|
@@ -2542,6 +2706,8 @@ export {
|
|
|
2542
2706
|
splitBlockSegments,
|
|
2543
2707
|
switchTenant,
|
|
2544
2708
|
tenantFromToken,
|
|
2709
|
+
timelineAsText,
|
|
2710
|
+
timelineView,
|
|
2545
2711
|
unlinkChannel as unlinkNotifChannel,
|
|
2546
2712
|
unregisterDevice as unregisterPushDevice,
|
|
2547
2713
|
unwrapMcpResult,
|
|
@@ -2550,6 +2716,7 @@ export {
|
|
|
2550
2716
|
useHomeActionsStore,
|
|
2551
2717
|
useWidgetsStore,
|
|
2552
2718
|
useWorkspaceStore,
|
|
2553
|
-
userFromJwt
|
|
2719
|
+
userFromJwt,
|
|
2720
|
+
visualViewOf
|
|
2554
2721
|
};
|
|
2555
2722
|
//# sourceMappingURL=index.mjs.map
|