@bolloon/bolloon-agent 0.1.22 → 0.1.24

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.
@@ -0,0 +1,139 @@
1
+ /**
2
+ * iroh-delegate-transport — 把 irohTransport 适配成 DelegateTransport 抽象
3
+ *
4
+ * 目的: 让 agent-delegate-server 可以挂到 iroh transport 上, 而不是只在 Hyperswarm 测试里跑.
5
+ *
6
+ * 注意命名坑:
7
+ * - DelegateTransport.sendToNode 用的是 "publicKey" (Hyperswarm 测试用 Hyperswarm 公钥)
8
+ * - iroh 路径里我们没有 "publicKey", 只有 nodeId (string)
9
+ * - 这里我们把 iroh nodeId 直接当作 publicKey 字段传入. 调用方 (/api/agent/delegate) 的
10
+ * toPublicKey 参数实际上对应的就是 iroh 目标 nodeId.
11
+ * - DIAP 真实 did:key 与 iroh nodeId 的映射关系另由 agent-manifest 协议承担
12
+ * (manifest_payload.ownerPublicKey 字段), 后续在 manifest cache 里维护.
13
+ */
14
+
15
+ import { irohTransport } from '../network/iroh-transport.js';
16
+ import { parseFrame, type AgentManifest } from '../agents/agent-manifest-protocol.js';
17
+ import type { DelegateTransport } from './agent-delegate-server.js';
18
+
19
+ export interface IrohDelegateTransportOptions {
20
+ /** 超时 (毫秒), 默认 30000 */
21
+ timeoutMs?: number;
22
+ /** 调试日志开关 */
23
+ verbose?: boolean;
24
+ }
25
+
26
+ /**
27
+ * 构造一个基于 irohTransport 的 DelegateTransport 实现.
28
+ *
29
+ * sendToNode: 用 irohTransport.sendMessage 发送 frame, 然后用 requestResponse 等待
30
+ * 对端 via onIncomingFrame 注册的 handler 写回.
31
+ * 由于 iroh 1-shot 消息没有 req/resp 关联, 这里用 'agent_request' 类型
32
+ * 包一层, 在 onMessage('agent_request') 内部复用现有 handler, 拿到 reply
33
+ * 再用 'agent_response' 单播回原 node.
34
+ *
35
+ * onIncomingFrame: 把对方发的 manifest_request / manifest_payload / agent_delegate
36
+ * 类型消息路由到 agent-delegate-server 注册的 handler.
37
+ */
38
+ export function createIrohDelegateTransport(opts: IrohDelegateTransportOptions = {}): DelegateTransport {
39
+ const timeoutMs = opts.timeoutMs ?? 30000;
40
+ const verbose = opts.verbose ?? false;
41
+
42
+ let incomingHandler: ((fromPublicKey: string, frame: string) => Promise<string | null>) | null = null;
43
+
44
+ // 单播回包映射: requestId -> resolver
45
+ const pendingReplies: Map<string, { resolve: (v: string | null) => void; timer: any }> = new Map();
46
+
47
+ // 启动时挂一次 onMessage 监听 (重复挂也只会换 handler, 不重复触发)
48
+ irohTransport.onMessage('agent_request', async (msg) => {
49
+ if (!incomingHandler) return;
50
+ const f = parseFrame(new TextDecoder().decode(msg.payload));
51
+ if (!f) return;
52
+ const fromKey = msg.from;
53
+ const reply = await incomingHandler(fromKey, new TextDecoder().decode(msg.payload));
54
+ if (reply) {
55
+ try {
56
+ // 把 reply 也用 agent_response 类型发回去, requestId 透传
57
+ const replyFrame = JSON.parse(reply);
58
+ const reqId = (f as any)._reqId || replyFrame._reqId;
59
+ const tagged = reqId ? JSON.stringify({ ...replyFrame, _reqId: reqId }) : reply;
60
+ await irohTransport.sendMessage(fromKey, 'agent_response', new TextEncoder().encode(tagged));
61
+ if (verbose) console.log(`[iroh-delegate] 已回包给 ${fromKey.substring(0, 12)}... (${replyFrame.type})`);
62
+ } catch (e) {
63
+ if (verbose) console.warn('[iroh-delegate] 回包失败:', e);
64
+ }
65
+ }
66
+ });
67
+
68
+ irohTransport.onMessage('agent_response', (msg) => {
69
+ const f = parseFrame(new TextDecoder().decode(msg.payload));
70
+ if (!f) return;
71
+ const reqId = (f as any)._reqId;
72
+ if (!reqId) return;
73
+ const pending = pendingReplies.get(reqId);
74
+ if (pending) {
75
+ clearTimeout(pending.timer);
76
+ pendingReplies.delete(reqId);
77
+ pending.resolve(JSON.stringify(f));
78
+ }
79
+ });
80
+
81
+ return {
82
+ sendToNode: async (publicKey, frame, timeoutOverrideMs) => {
83
+ const t = timeoutOverrideMs ?? timeoutMs;
84
+ const reqId = `req-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
85
+ const tagged = JSON.stringify({ ...JSON.parse(frame), _reqId: reqId });
86
+ const payload = new TextEncoder().encode(tagged);
87
+ return new Promise(async (resolve) => {
88
+ const timer = setTimeout(() => {
89
+ pendingReplies.delete(reqId);
90
+ resolve(null);
91
+ }, t);
92
+ pendingReplies.set(reqId, { resolve, timer });
93
+ try {
94
+ const ok = await irohTransport.sendMessage(publicKey, 'agent_request', payload);
95
+ if (!ok) {
96
+ clearTimeout(timer);
97
+ pendingReplies.delete(reqId);
98
+ resolve(null);
99
+ }
100
+ } catch (e) {
101
+ if (verbose) console.warn('[iroh-delegate] 发送失败:', e);
102
+ clearTimeout(timer);
103
+ pendingReplies.delete(reqId);
104
+ resolve(null);
105
+ }
106
+ });
107
+ },
108
+
109
+ onIncomingFrame: (handler) => {
110
+ incomingHandler = handler;
111
+ },
112
+ };
113
+ }
114
+
115
+ /**
116
+ * 把本地节点 manifest 注册到 agent-manifest 协议, 并写入本地缓存.
117
+ * 在 iroh 初始化完成时调用一次.
118
+ */
119
+ export function registerLocalAgents(
120
+ ownerName: string,
121
+ ownerPublicKey: string,
122
+ agents: Array<{ id: string; name: string; capabilities: string[]; status?: 'active' | 'idle' | 'busy' }>
123
+ ): void {
124
+ // 动态导入避免循环引用
125
+ import('../agents/agent-manifest-protocol.js').then((mod) => {
126
+ mod.setLocalManifest({
127
+ ownerName,
128
+ ownerPublicKey,
129
+ agents: agents.map((a) => ({
130
+ id: a.id,
131
+ name: a.name,
132
+ capabilities: a.capabilities,
133
+ status: a.status || 'active',
134
+ })),
135
+ });
136
+ });
137
+ }
138
+
139
+ export type { AgentManifest };
package/src/web/server.ts CHANGED
@@ -19,6 +19,8 @@ import { initMinimax, getMinimax } from '../constraints/index.js';
19
19
  import { createAgentSession, type AgentSession, type StreamCallback, type StreamEvent } from '../agents/pi-sdk.js';
20
20
  import { llmConfigStore, type ModelProvider, PROVIDER_INFO } from '../llm/config-store.js';
21
21
  import { irohTransport } from '../network/iroh-transport.js';
22
+ import { createAgentDelegateApp } from './agent-delegate-server.js';
23
+ import { createIrohDelegateTransport } from './iroh-delegate-transport.js';
22
24
  import { verifyMessage, isAddress, getAddress } from 'viem';
23
25
 
24
26
  // 前端资源路径:在打包后会通过 CommonJS require 加载,使用 import.meta.url
@@ -452,7 +454,14 @@ async function getAgentForChannel(
452
454
  return session;
453
455
  }
454
456
 
455
- export async function createWebServer(port: number = 3000) {
457
+ export interface CreateWebServerOptions {
458
+ selfImprove?: boolean;
459
+ }
460
+
461
+ let selfImproveEnabled = false;
462
+
463
+ export async function createWebServer(port: number = 3000, options: CreateWebServerOptions = {}) {
464
+ selfImproveEnabled = options.selfImprove ?? false;
456
465
  // 防止 P2P DHT 超时等错误导致进程崩溃
457
466
  process.on('unhandledRejection', (reason, promise) => {
458
467
  console.error('[警告] 未处理的 Promise 拒绝:', reason);
@@ -1733,6 +1742,17 @@ app.get('/channels', async (_req, res) => {
1733
1742
  };
1734
1743
  irohInitialized = true;
1735
1744
 
1745
+ // 挂载 agent-delegate app (manifest 协议 + agent_delegate)
1746
+ // 必须在 irohInitialized 之后挂, 因为适配器要监听 irohTransport.onMessage
1747
+ try {
1748
+ const delegateTransport = createIrohDelegateTransport({ verbose: true });
1749
+ const delegateApp = createAgentDelegateApp(delegateTransport);
1750
+ app.use('/api/agent', delegateApp);
1751
+ console.log('[iroh API] agent-delegate app 已挂载到 /api/agent');
1752
+ } catch (e) {
1753
+ console.error('[iroh API] 挂载 agent-delegate app 失败:', e);
1754
+ }
1755
+
1736
1756
  // 设置消息处理
1737
1757
  irohTransport.onMessage('chat', (msg) => {
1738
1758
  const content = new TextDecoder().decode(msg.payload);
@@ -2489,6 +2509,297 @@ app.get('/channels', async (_req, res) => {
2489
2509
  }
2490
2510
  });
2491
2511
 
2512
+ // ==================== Judgments (v1 核心: 让我能记录判断) ====================
2513
+ // POST /api/judgments — 记录一个判断
2514
+ // GET /api/judgments — 列出所有判断 (新→旧)
2515
+ // 存储: ~/.bolloon/human-values/judgments.json (human-value-store)
2516
+ // 极简版: 只记录 decision + reason; 其它字段可选
2517
+ app.post('/api/judgments', async (req, res) => {
2518
+ try {
2519
+ const { decision, reason, context } = req.body as {
2520
+ decision?: string; reason?: string; context?: { domain?: string; stakes?: string };
2521
+ };
2522
+ if (!decision || typeof decision !== 'string' || !decision.trim()) {
2523
+ return res.status(400).json({ error: 'decision required' });
2524
+ }
2525
+ const { storeHumanJudgment, initializeValueStore } = await import(
2526
+ '../pi-ecosystem-judgment/human-value-store.js'
2527
+ );
2528
+ await initializeValueStore();
2529
+ const j = await storeHumanJudgment({
2530
+ decision: decision.trim(),
2531
+ decision_type: 'approve',
2532
+ reasons: reason ? [reason.trim()] : [],
2533
+ values_derived: [],
2534
+ context: {
2535
+ domain: context?.domain || 'general',
2536
+ complexity: 'moderate',
2537
+ stakes: (context?.stakes as 'low' | 'medium' | 'high' | 'critical') || 'medium',
2538
+ time_pressure: 'low',
2539
+ },
2540
+ metadata: {
2541
+ source: 'explicit',
2542
+ confidence: 0.8,
2543
+ revisable: true,
2544
+ },
2545
+ });
2546
+ res.json({ ok: true, judgment: j });
2547
+ } catch (err: any) {
2548
+ console.error('[judgments] POST failed:', err);
2549
+ res.status(500).json({ error: err.message });
2550
+ }
2551
+ });
2552
+
2553
+ app.get('/api/judgments', async (_req, res) => {
2554
+ try {
2555
+ const { loadAllJudgments, initializeValueStore } = await import(
2556
+ '../pi-ecosystem-judgment/human-value-store.js'
2557
+ );
2558
+ await initializeValueStore();
2559
+ const all = await loadAllJudgments();
2560
+ // 新的在前
2561
+ all.sort((a, b) => (b.timestamp || '').localeCompare(a.timestamp || ''));
2562
+ res.json({ count: all.length, judgments: all });
2563
+ } catch (err: any) {
2564
+ console.error('[judgments] GET failed:', err);
2565
+ res.status(500).json({ error: err.message });
2566
+ }
2567
+ });
2568
+
2569
+ // 导入判断: 接受 { filename, content (base64), context }.
2570
+ // 支持 .json / .yaml / .yml / .md / .txt / .html. 完全离线解析, 不调 LLM.
2571
+ // 解析规则:
2572
+ // - .json: 顶层数组 [{decision, reason?, context?}, ...] 或 {judgments: [...]} 或 {items: [...]}
2573
+ // - .yaml/.yml: 期望顶层数组 (用 js-yaml); 不支持复杂结构
2574
+ // - .md/.txt/.html: 每一段 (按空行分隔) 算一条判断, 首行非空 = decision, 整段 = content
2575
+ // 如果首行是 markdown 标题 (# ...) 则去掉 #, 整段去掉首行后作 reason
2576
+ app.post('/api/judgments/import', async (req, res) => {
2577
+ try {
2578
+ const { filename, content, context } = req.body as {
2579
+ filename?: string; content?: string; context?: { domain?: string; stakes?: string };
2580
+ };
2581
+ if (!filename || !content) {
2582
+ return res.status(400).json({ error: 'filename and content (base64) required' });
2583
+ }
2584
+ let raw: string;
2585
+ try { raw = Buffer.from(content, 'base64').toString('utf-8'); }
2586
+ catch { return res.status(400).json({ error: 'content is not valid base64' }); }
2587
+
2588
+ const lower = filename.toLowerCase();
2589
+ let items: Array<{ decision: string; reason?: string; context?: any }> = [];
2590
+ if (lower.endsWith('.json')) {
2591
+ try {
2592
+ const parsed = JSON.parse(raw);
2593
+ const arr = Array.isArray(parsed) ? parsed
2594
+ : Array.isArray(parsed?.judgments) ? parsed.judgments
2595
+ : Array.isArray(parsed?.items) ? parsed.items
2596
+ : null;
2597
+ if (!arr) return res.status(400).json({ error: 'JSON must be an array, or {judgments:[]}/{items:[]}' });
2598
+ for (const it of arr) {
2599
+ if (it && typeof it.decision === 'string' && it.decision.trim()) {
2600
+ items.push({ decision: it.decision.trim(), reason: it.reason, context: it.context });
2601
+ }
2602
+ }
2603
+ } catch (e: any) {
2604
+ return res.status(400).json({ error: 'JSON parse failed: ' + e.message });
2605
+ }
2606
+ } else if (lower.endsWith('.yaml') || lower.endsWith('.yml')) {
2607
+ try {
2608
+ const yaml = (await import('js-yaml')).default;
2609
+ const parsed = yaml.load(raw);
2610
+ if (!Array.isArray(parsed)) return res.status(400).json({ error: 'YAML must be a top-level array' });
2611
+ for (const it of parsed) {
2612
+ if (it && typeof it.decision === 'string' && it.decision.trim()) {
2613
+ items.push({ decision: it.decision.trim(), reason: it.reason, context: it.context });
2614
+ }
2615
+ }
2616
+ } catch (e: any) {
2617
+ return res.status(400).json({ error: 'YAML parse failed: ' + e.message });
2618
+ }
2619
+ } else if (lower.endsWith('.md') || lower.endsWith('.txt') || lower.endsWith('.html') || lower.endsWith('.htm')) {
2620
+ // 通用纯文本: 按空行分段, 每段是一条判断
2621
+ // 对 .html 先剥掉标签, 但保留段落分隔
2622
+ let text = raw;
2623
+ if (lower.endsWith('.html') || lower.endsWith('.htm')) {
2624
+ text = text.replace(/<script[\s\S]*?<\/script>/gi, '')
2625
+ .replace(/<style[\s\S]*?<\/style>/gi, '')
2626
+ // 块级标签 -> 双换行 (保留段落分隔)
2627
+ .replace(/<\/?(p|div|h[1-6]|li|tr|br)[^>]*>/gi, '\n\n')
2628
+ .replace(/<[^>]+>/g, ' ')
2629
+ .replace(/&nbsp;/g, ' ').replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>');
2630
+ }
2631
+ const blocks = text.split(/\n\s*\n/).map(b => b.trim()).filter(b => b.length > 0);
2632
+ for (const block of blocks) {
2633
+ const lines = block.split('\n').map(l => l.trim()).filter(l => l.length > 0);
2634
+ if (lines.length === 0) continue;
2635
+ let decision = lines[0];
2636
+ // 如果首行是 markdown 标题, 去掉 # 前缀
2637
+ decision = decision.replace(/^#+\s*/, '');
2638
+ // 如果整段就是一个短句 (没有换行), 直接当 decision
2639
+ const reason = lines.length > 1 ? lines.slice(1).join(' ').trim() || undefined : undefined;
2640
+ if (decision) items.push({ decision, reason });
2641
+ }
2642
+ } else {
2643
+ return res.status(400).json({ error: 'unsupported file type (use .json .yaml .yml .md .txt .html)' });
2644
+ }
2645
+
2646
+ if (items.length === 0) {
2647
+ return res.status(400).json({ error: 'no parseable judgments found in file' });
2648
+ }
2649
+
2650
+ const { storeHumanJudgment, initializeValueStore } = await import(
2651
+ '../pi-ecosystem-judgment/human-value-store.js'
2652
+ );
2653
+ await initializeValueStore();
2654
+
2655
+ const imported: any[] = [];
2656
+ const errors: string[] = [];
2657
+ for (let i = 0; i < items.length; i++) {
2658
+ try {
2659
+ const it = items[i];
2660
+ const j = await storeHumanJudgment({
2661
+ decision: it.decision,
2662
+ decision_type: 'approve',
2663
+ reasons: it.reason ? [String(it.reason)] : [],
2664
+ values_derived: [],
2665
+ context: {
2666
+ domain: it.context?.domain || context?.domain || 'general',
2667
+ complexity: 'moderate',
2668
+ stakes: (it.context?.stakes as any) || context?.stakes || 'medium',
2669
+ time_pressure: 'low',
2670
+ },
2671
+ metadata: {
2672
+ source: 'explicit',
2673
+ confidence: 0.8,
2674
+ revisable: true,
2675
+ },
2676
+ });
2677
+ imported.push(j);
2678
+ } catch (e: any) {
2679
+ errors.push(`#${i + 1} (${items[i].decision.substring(0, 30)}): ${e.message}`);
2680
+ }
2681
+ }
2682
+
2683
+ res.json({ ok: true, imported: imported.length, failed: errors.length, errors: errors.slice(0, 5), judgments: imported });
2684
+ } catch (err: any) {
2685
+ console.error('[judgments] import failed:', err);
2686
+ res.status(500).json({ error: err.message });
2687
+ }
2688
+ });
2689
+
2690
+ // 修改判断 (手动编辑 decision / reasons / context / values_derived)
2691
+ app.patch('/api/judgments/:id', async (req, res) => {
2692
+ try {
2693
+ const { id } = req.params;
2694
+ const { updateJudgment, initializeValueStore } = await import(
2695
+ '../pi-ecosystem-judgment/human-value-store.js'
2696
+ );
2697
+ await initializeValueStore();
2698
+ const updated = await updateJudgment(id, req.body || {});
2699
+ if (!updated) return res.status(404).json({ error: 'judgment not found' });
2700
+ res.json({ ok: true, judgment: updated });
2701
+ } catch (err: any) {
2702
+ console.error('[judgments] PATCH failed:', err);
2703
+ res.status(500).json({ error: err.message });
2704
+ }
2705
+ });
2706
+
2707
+ // 删除判断
2708
+ app.delete('/api/judgments/:id', async (req, res) => {
2709
+ try {
2710
+ const { id } = req.params;
2711
+ const { deleteJudgment, initializeValueStore } = await import(
2712
+ '../pi-ecosystem-judgment/human-value-store.js'
2713
+ );
2714
+ await initializeValueStore();
2715
+ const ok = await deleteJudgment(id);
2716
+ if (!ok) return res.status(404).json({ error: 'judgment not found' });
2717
+ res.json({ ok: true });
2718
+ } catch (err: any) {
2719
+ console.error('[judgments] DELETE failed:', err);
2720
+ res.status(500).json({ error: err.message });
2721
+ }
2722
+ });
2723
+
2724
+ // 批量删除: { ids: ['hv-xxx', ...] } → { ok, deleted, notFound }
2725
+ app.post('/api/judgments/batch-delete', async (req, res) => {
2726
+ try {
2727
+ const ids = (req.body && Array.isArray(req.body.ids)) ? (req.body.ids as unknown[]) : null;
2728
+ if (!ids) return res.status(400).json({ error: 'ids array required' });
2729
+ const { deleteJudgment, initializeValueStore } = await import(
2730
+ '../pi-ecosystem-judgment/human-value-store.js'
2731
+ );
2732
+ await initializeValueStore();
2733
+ const idStrs = ids.filter((x): x is string => typeof x === 'string' && x.length > 0);
2734
+ let deleted = 0;
2735
+ const notFound: string[] = [];
2736
+ for (const id of idStrs) {
2737
+ const ok = await deleteJudgment(id);
2738
+ if (ok) deleted++; else notFound.push(id);
2739
+ }
2740
+ res.json({ ok: true, deleted, notFound });
2741
+ } catch (err: any) {
2742
+ console.error('[judgments] batch-delete failed:', err);
2743
+ res.status(500).json({ error: err.message });
2744
+ }
2745
+ });
2746
+
2747
+ // AI 自动委派: 根据新判断的 capability / context 找最匹配的远端 agent, 委派任务
2748
+ // 由前端在 POST /api/judgments 成功后调用 (fire-and-forget)
2749
+ // 出参: { matched, targetAgent, response | skipped, reason }
2750
+ app.post('/api/judgments/auto-delegate', async (req, res) => {
2751
+ try {
2752
+ const { judgmentId, capability, instruction } = req.body as {
2753
+ judgmentId?: string; capability?: string; instruction?: string;
2754
+ };
2755
+ if (!judgmentId && !capability) {
2756
+ return res.status(400).json({ error: 'judgmentId or capability required' });
2757
+ }
2758
+ const cap = capability || 'general';
2759
+ // 用 agent-manifest-protocol 里的 pickAgent (内存) — 走本节点已经缓存的远端 manifest
2760
+ const manifestMod = await import('../agents/agent-manifest-protocol.js');
2761
+ const picked = manifestMod.pickAgent(cap);
2762
+ if (!picked) {
2763
+ return res.json({ ok: true, matched: false, reason: 'no remote agent matches capability' });
2764
+ }
2765
+ // 命中后, 用 iroh delegate transport 真正发过去
2766
+ // 注: irohDelegateTransport.sendToNode 走的是 sendToNode(publicKey, frame, timeoutMs)
2767
+ // irohTransport 的 sendMessage 不等回包, 所以委托是 fire-and-forget
2768
+ // 想等回包需要新接口. 这里先把 "找得到目标 + 发送成功" 作为成功.
2769
+ // TODO: 接入 requestResponse 等待远端 agent_response
2770
+ try {
2771
+ const idMod = await import('../network/iroh-integration.js');
2772
+ const integ = idMod.getIrohIntegration();
2773
+ if (!integ || !integ.getNodeId()) {
2774
+ return res.json({ ok: true, matched: true, targetAgent: picked.agent, sent: false, reason: 'iroh not initialized' });
2775
+ }
2776
+ // 用 pickAgent 选出来的 agent 关联的 irohNodeId (有的话), 没有就跳到本地自处理
2777
+ const targetIrohNodeId = picked.agent.irohNodeId;
2778
+ if (!targetIrohNodeId) {
2779
+ return res.json({ ok: true, matched: true, targetAgent: picked.agent, sent: false, reason: 'target agent has no irohNodeId (peer identity not bound)' });
2780
+ }
2781
+ const ok = await integ.sendTo(targetIrohNodeId, 'agent_delegate', new TextEncoder().encode(JSON.stringify({
2782
+ type: 'agent_delegate',
2783
+ payload: {
2784
+ capability: cap,
2785
+ instruction: instruction || `请执行我的判断: ${judgmentId}`,
2786
+ fromAgentId: 'local-judgment',
2787
+ },
2788
+ ts: Date.now(),
2789
+ fromDid: '',
2790
+ })));
2791
+ res.json({ ok: true, matched: true, targetAgent: picked.agent, sent: ok });
2792
+ } catch (e: any) {
2793
+ res.json({ ok: true, matched: true, targetAgent: picked.agent, sent: false, error: e.message });
2794
+ }
2795
+ } catch (err: any) {
2796
+ console.error('[judgments] auto-delegate failed:', err);
2797
+ res.status(500).json({ error: err.message });
2798
+ }
2799
+ });
2800
+
2801
+ // (判断的 UI 已合并到主页面 header 的盾牌按钮 + modal, 不再走独立路由)
2802
+
2492
2803
  // 启动看门狗监控
2493
2804
  if (watchdog) {
2494
2805
  // level 1 (内存爆) → 进程自杀, 依赖外层 supervisor / 用户重启 (Windows 任务计划/手动)
package/src/web/style.css CHANGED
@@ -575,6 +575,13 @@ body {
575
575
  transform: rotate(90deg);
576
576
  }
577
577
 
578
+ /* ⚡ 自动工具徽章 + 当前会话名: 折叠时不显示, 只在展开时可见.
579
+ 配置 (钱包/工具) 按钮保留在行上, 用户随时能进 modal. */
580
+ .agent-group:not(.expanded) .agent-tools-badge,
581
+ .agent-group:not(.expanded) .agent-current-session {
582
+ display: none !important;
583
+ }
584
+
578
585
  .agent-new-session {
579
586
  /* 已废弃: 新建会话按钮迁移到 session 列表顶部, 见 .session-new-item */
580
587
  display: none;