@bolloon/bolloon-agent 0.4.21 → 0.4.22
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/web/mobile.html +1 -0
- package/dist/web/mobile.js +41 -1
- package/package.json +1 -1
package/dist/web/mobile.html
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
<!-- 网络 tab -->
|
|
65
65
|
<section class="page" id="page-network" data-tab="network" hidden>
|
|
66
66
|
<div class="list">
|
|
67
|
+
<div class="list-item" id="item-join-global"><span class="list-icon"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5"/><path d="M3.5 12h17"/><path d="M12 3.5c2.7 2.6 2.7 14.4 0 17M12 3.5c-2.7 2.6-2.7 14.4 0 17"/><circle cx="12" cy="12" r="1.2" fill="currentColor" stroke="none"/></svg></span><span>一键入网 · 全球智能体网络</span><span class="list-arrow">›</span></div>
|
|
67
68
|
<div class="list-item" id="item-join-net"><span class="list-icon"><svg class="ico" viewBox="0 0 24 24"><path d="M3.5 9.5a13 13 0 0 1 17 0M6.5 13a8.5 8.5 0 0 1 11 0M9.6 16.3a4 4 0 0 1 4.8 0"/><circle cx="12" cy="19.5" r="1.1" fill="currentColor" stroke="none"/></svg></span><span>加入网络</span><span class="list-arrow">›</span></div>
|
|
68
69
|
<div class="list-item" id="item-add-friend"><span class="list-icon"><svg class="ico" viewBox="0 0 24 24"><circle cx="9" cy="8" r="3.2"/><path d="M3.5 19c.8-3 3-4.6 5.5-4.6S13.7 16 14.5 19"/><path d="M17 8v6M14 11h6"/></svg></span><span>连接好友</span><span class="list-arrow">›</span></div>
|
|
69
70
|
<div class="list-item" id="item-nearby"><span class="list-icon"><svg class="ico" viewBox="0 0 24 24"><path d="M4 12a8 8 0 0 1 16 0"/><path d="M7.5 12a4.5 4.5 0 0 1 9 0"/><circle cx="12" cy="12" r="1.4"/><path d="M12 13.6V19"/></svg></span><span>附近设备</span><span class="list-arrow">›</span></div>
|
package/dist/web/mobile.js
CHANGED
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
// 一键入网默认 prompt: 交给智能体去读网关入网说明并执行入网 (人类只点一下)
|
|
20
|
+
const DEFAULT_JOIN_PROMPT = 'read https://bolloon.cn/bolloon-gateway-join.md';
|
|
21
|
+
|
|
19
22
|
const THEMES = {
|
|
20
23
|
dark: { '--bg': '#1a1a18', '--bg-card': '#222220', '--bg-hover': '#2a2a26', '--text': '#d8d8c8', '--text-secondary': '#909088', '--accent': '#c4d640', '--border': '#3a3a36' },
|
|
21
24
|
light: { '--bg': '#f5f5f0', '--bg-card': '#ffffff', '--bg-hover': '#eeeeea', '--text': '#1a1a18', '--text-secondary': '#606058', '--accent': '#8a9430', '--border': '#d0d0c8' },
|
|
@@ -681,6 +684,7 @@
|
|
|
681
684
|
let chatEventSource = null;
|
|
682
685
|
let chatStepCancel = null;
|
|
683
686
|
let streamingBubble = null;
|
|
687
|
+
let chatLoadPromise = Promise.resolve(); // openChat 的首次历史加载 (供一键入网等自动发消息等它完成, 免被清屏抹掉)
|
|
684
688
|
|
|
685
689
|
function openChat(ch) {
|
|
686
690
|
activeChannel = ch;
|
|
@@ -710,7 +714,7 @@
|
|
|
710
714
|
$('#chat-send').addEventListener('click', sendChat);
|
|
711
715
|
$('#chat-input').addEventListener('keydown', (e) => { if (e.key === 'Enter') sendChat(); });
|
|
712
716
|
attachStepListener();
|
|
713
|
-
loadMessages();
|
|
717
|
+
chatLoadPromise = loadMessages().catch(() => {});
|
|
714
718
|
openChatSse();
|
|
715
719
|
window.__mobileTouch?.('chat', ch.id);
|
|
716
720
|
}
|
|
@@ -1734,6 +1738,38 @@
|
|
|
1734
1738
|
function showSheet(id) { const s = $(id); if (s) s.hidden = false; }
|
|
1735
1739
|
function hideSheet(id) { const s = $(id); if (s) s.hidden = true; }
|
|
1736
1740
|
|
|
1741
|
+
/**
|
|
1742
|
+
* 一键入网 (全球智能体网络): 把默认 prompt 发给智能体, 由它读网关入网说明并执行入网。
|
|
1743
|
+
* 人类只点一下 — 没有可用会话时先建一个 (与"新建会话"同一条路径)。
|
|
1744
|
+
*/
|
|
1745
|
+
async function joinGlobalNetwork() {
|
|
1746
|
+
showToast('正在加入全球智能体网络…');
|
|
1747
|
+
try {
|
|
1748
|
+
let ch = activeChannel;
|
|
1749
|
+
if (!ch) {
|
|
1750
|
+
let channels = [];
|
|
1751
|
+
try { channels = await api.get('/channels'); } catch { channels = []; }
|
|
1752
|
+
ch = (Array.isArray(channels) && channels[0]) || null;
|
|
1753
|
+
if (!ch) {
|
|
1754
|
+
await api.post('/api/channels/create', {});
|
|
1755
|
+
await new Promise((r) => setTimeout(r, 700));
|
|
1756
|
+
channels = await api.get('/channels').catch(() => []);
|
|
1757
|
+
ch = (Array.isArray(channels) && channels[0]) || null;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
if (!ch) { showToast('没有可用会话: 先在电脑端连上你的智能体'); return; }
|
|
1761
|
+
openChat(ch);
|
|
1762
|
+
await chatLoadPromise; // 等首次历史加载完成再发, 免得用户气泡被清屏抹掉
|
|
1763
|
+
const input = $('#chat-input');
|
|
1764
|
+
if (!input) return;
|
|
1765
|
+
input.value = DEFAULT_JOIN_PROMPT;
|
|
1766
|
+
await sendChat();
|
|
1767
|
+
showToast('入网指令已交给智能体');
|
|
1768
|
+
} catch (e) {
|
|
1769
|
+
showToast('入网失败: ' + ((e && e.message) || e));
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1737
1773
|
// 创建智能体: 无输入框, 底部滑入加载 sheet, 完成后滑出
|
|
1738
1774
|
async function createSession() {
|
|
1739
1775
|
showSheet('#create-sheet');
|
|
@@ -1855,6 +1891,10 @@
|
|
|
1855
1891
|
try { const net = await api.get('/api/network/status'); const p2p = net && net.nodeId; alert('P2P ID (通信ID, ≠ DID):\n' + (p2p || '未连接')); }
|
|
1856
1892
|
catch (e) { alert('P2P ID: 获取失败'); }
|
|
1857
1893
|
});
|
|
1894
|
+
// #1 一键入网 (全球智能体网络): 点一下 → 默认 prompt 交给智能体执行
|
|
1895
|
+
const joinGlobalBtn = $('#item-join-global');
|
|
1896
|
+
if (joinGlobalBtn) joinGlobalBtn.addEventListener('click', () => { void joinGlobalNetwork(); });
|
|
1897
|
+
|
|
1858
1898
|
// #2 加入网络 (点按式): sheet → [附近的电脑/设备] [扫电脑上的二维码] [粘贴链接兜底]
|
|
1859
1899
|
const joinNetBtn = $('#item-join-net');
|
|
1860
1900
|
if (joinNetBtn) joinNetBtn.addEventListener('click', () => showSheet('#network-sheet'));
|