@bolloon/bolloon-agent 0.4.8 → 0.4.9
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 +35 -0
- package/dist/web/server.js +5 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -831,6 +831,41 @@ async function processInput(input, comm) {
|
|
|
831
831
|
}
|
|
832
832
|
catch { /* DID 生成失败不阻塞创建 */ }
|
|
833
833
|
const channels = await updateChannels((chs) => [...chs, ch]);
|
|
834
|
+
// 2026-08-12 (TaskFix): CLI 创建的 agent 同步写 agents.json + 关联 channelId —
|
|
835
|
+
// 与 server 创建 channel 逻辑对齐. 否则 CLI 创建的 agent 不在 agents.json,
|
|
836
|
+
// 重启后 server 的 healMissingChannels 只能从 agents.json 恢复 → 该 agent 永远消失.
|
|
837
|
+
try {
|
|
838
|
+
const agentsPath = path.join(process.env.HOME || '/tmp', '.bolloon', 'agents', 'agents.json');
|
|
839
|
+
await fs.mkdir(path.dirname(agentsPath), { recursive: true });
|
|
840
|
+
let arr = [];
|
|
841
|
+
try {
|
|
842
|
+
arr = JSON.parse(await fs.readFile(agentsPath, 'utf-8'));
|
|
843
|
+
}
|
|
844
|
+
catch { }
|
|
845
|
+
if (!Array.isArray(arr))
|
|
846
|
+
arr = [];
|
|
847
|
+
const exists = arr.find((a) => a && a.id === agentId);
|
|
848
|
+
if (exists) {
|
|
849
|
+
exists.channelId = id;
|
|
850
|
+
exists.name = name.trim();
|
|
851
|
+
exists.lastActive = new Date().toISOString();
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
arr.push({
|
|
855
|
+
id: agentId,
|
|
856
|
+
name: name.trim(),
|
|
857
|
+
did: `did:local:${id}`,
|
|
858
|
+
description: `Agent ${name} (auto-registered from channel ${id})`,
|
|
859
|
+
status: 'active',
|
|
860
|
+
createdAt: new Date().toISOString(),
|
|
861
|
+
lastActive: new Date().toISOString(),
|
|
862
|
+
channelId: id,
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
await fs.writeFile(agentsPath, JSON.stringify(arr, null, 2), 'utf-8');
|
|
866
|
+
console.log(`[创建频道] agent 同步进 agents.json: ${agentId} → channel ${id}`);
|
|
867
|
+
}
|
|
868
|
+
catch { /* agents.json 写失败不阻塞创建 */ }
|
|
834
869
|
// 刷新 store 缓存 (updateChannels 走了 server-storage, store 内存还是旧的)
|
|
835
870
|
await store.load();
|
|
836
871
|
await store.setActive(id);
|
package/dist/web/server.js
CHANGED
|
@@ -1731,7 +1731,6 @@ export async function createWebServer(port = 3000, options = {}) {
|
|
|
1731
1731
|
const { existsSync } = await import('fs');
|
|
1732
1732
|
const { readFile } = await import('fs/promises');
|
|
1733
1733
|
const agentsFile = `${process.env.HOME || '/tmp'}/.bolloon/agents/agents.json`;
|
|
1734
|
-
const sessionsDir = `${process.env.HOME || '/tmp'}/.bolloon/sessions/cache`;
|
|
1735
1734
|
if (!existsSync(agentsFile))
|
|
1736
1735
|
return 0;
|
|
1737
1736
|
const agentsRaw = await readFile(agentsFile, 'utf-8');
|
|
@@ -1744,14 +1743,11 @@ export async function createWebServer(port = 3000, options = {}) {
|
|
|
1744
1743
|
const cid = a && a.channelId;
|
|
1745
1744
|
if (!cid || knownIds.has(cid))
|
|
1746
1745
|
continue;
|
|
1747
|
-
//
|
|
1748
|
-
//
|
|
1749
|
-
//
|
|
1750
|
-
//
|
|
1751
|
-
|
|
1752
|
-
const hasSession = existsSync(getSessionCacheFile(cid, 'default')) || existsSync(`${sessionsDir}/${cid}.json`);
|
|
1753
|
-
if (!hasSession)
|
|
1754
|
-
continue;
|
|
1746
|
+
// 2026-08-12 (TaskFix): 放宽恢复条件 — 只要 agents.json 里 agent 关联了 channelId (非空),
|
|
1747
|
+
// 且 channels.json 缺失该 channel, 就恢复 channel stub.
|
|
1748
|
+
// 之前强制要求 session cache 文件存在, 导致"刚创建还没对话"的 agent (CLI /new agent 同步 agents.json 后)
|
|
1749
|
+
// 重启时 session 文件不存在 → 永不恢复 → "以前创建的智能体消失" bug.
|
|
1750
|
+
// 空 channelId (旧数据无关联 channel) 仍跳过, 避免给无关 agent 乱建 channel.
|
|
1755
1751
|
const restored = {
|
|
1756
1752
|
id: cid,
|
|
1757
1753
|
name: a.name || `Agent-${String(cid).slice(-6)}`,
|