@bolloon/bolloon-agent 0.2.12 → 0.2.14
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/README.md +495 -467
- package/bin/bolloon-cli.cjs +183 -183
- package/bin/bolloon-daemon.sh +207 -0
- package/bin/bolloon.cjs +0 -0
- package/bin/ipfs +0 -0
- package/dist/agents/agent-manifest-protocol.js +52 -0
- package/dist/agents/chat-segmenter.js +298 -0
- package/dist/agents/constraint-layer.js +19 -19
- package/dist/agents/judgment-protocol.js +479 -0
- package/dist/agents/parse-tool-call.js +304 -0
- package/dist/agents/peer-manifest-loader.js +210 -0
- package/dist/agents/pi-sdk-session-factory.js +110 -0
- package/dist/agents/pi-sdk-session-manager.js +297 -0
- package/dist/agents/pi-sdk-tools.js +1288 -0
- package/dist/agents/pi-sdk-types.js +13 -0
- package/dist/agents/pi-sdk.js +553 -1306
- package/dist/agents/react-loop.js +120 -0
- package/dist/agents/session-store.js +171 -0
- package/dist/agents/shell-guard.js +2 -2
- package/dist/agents/tool-registry.js +136 -0
- package/dist/agents/workflow-pivot-loop.js +200 -22
- package/dist/bollharness/src/scripts/context_router.js +7 -0
- package/dist/bollharness/src/scripts/deploy-guard.js +8 -8
- package/dist/bollharness-integration/context-router-judgment.js +4 -4
- package/dist/bollharness-integration/context-router.js +292 -292
- package/dist/bollharness-integration/gate-state-machine.js +26 -13
- package/dist/bollharness-integration/integration.js +71 -0
- package/dist/bollharness-integration/llm-judgment-engine.js +134 -134
- package/dist/bollharness-integration/skill-adapter.js +57 -127
- package/dist/bootstrap/chat-archiver.js +276 -0
- package/dist/bootstrap/context-collector.js +6 -3
- package/dist/bootstrap/event-log.js +160 -0
- package/dist/bootstrap/lifecycle-hooks.js +15 -1
- package/dist/bootstrap/memory-compressor.js +170 -0
- package/dist/bootstrap/persona-loader.js +94 -0
- package/dist/bootstrap/project-state.js +159 -0
- package/dist/bootstrap/remote-mirror.js +97 -0
- package/dist/bootstrap/session-window.js +121 -0
- package/dist/bootstrap/vector-index.js +248 -0
- package/dist/cli/loading-tui.js +40 -0
- package/dist/cli-entry.js +41 -37
- package/dist/context-compaction/auto-compact.js +7 -7
- package/dist/electron/config.js +21 -0
- package/dist/electron/config.js.map +1 -0
- package/dist/electron/dialogs.js +108 -0
- package/dist/electron/dialogs.js.map +1 -0
- package/dist/electron/first-run.js +170 -0
- package/dist/electron/first-run.js.map +1 -0
- package/dist/electron/ipc.js +20 -0
- package/dist/electron/ipc.js.map +1 -0
- package/dist/electron/logger.js +114 -0
- package/dist/electron/logger.js.map +1 -0
- package/dist/electron/main.js +63 -0
- package/dist/electron/main.js.map +1 -0
- package/dist/electron/menu.js +145 -0
- package/dist/electron/menu.js.map +1 -0
- package/dist/electron/paths.js +75 -0
- package/dist/electron/paths.js.map +1 -0
- package/dist/electron/server.js +119 -0
- package/dist/electron/server.js.map +1 -0
- package/dist/electron/tray.js +111 -0
- package/dist/electron/tray.js.map +1 -0
- package/dist/electron/window.js +111 -0
- package/dist/electron/window.js.map +1 -0
- package/dist/electron-preload.js +26 -6
- package/dist/electron-preload.js.map +1 -1
- package/dist/electron.js +6 -168
- package/dist/electron.js.map +1 -1
- package/dist/index.js +323 -266
- package/dist/llm/config-store.js +29 -8
- package/dist/llm/llm-judgment-client.js +102 -102
- package/dist/llm/pi-ai.js +139 -85
- package/dist/llm/system-prompt/layers/channel/local.md +14 -14
- package/dist/llm/system-prompt/layers/channel/p2p-agent.md +18 -18
- package/dist/llm/system-prompt/layers/channel/p2p-visitor.md +19 -19
- package/dist/llm/system-prompt/layers/core/artifacts_storage.md +89 -89
- package/dist/llm/system-prompt/layers/core/evenhandedness.md +21 -21
- package/dist/llm/system-prompt/layers/core/hibs_reminders.md +15 -15
- package/dist/llm/system-prompt/layers/core/identity.md +37 -37
- package/dist/llm/system-prompt/layers/core/knowledge.md +17 -17
- package/dist/llm/system-prompt/layers/core/memory_system.md +12 -12
- package/dist/llm/system-prompt/layers/core/network_filesystem.md +28 -28
- package/dist/llm/system-prompt/layers/core/refusal.md +37 -37
- package/dist/llm/system-prompt/layers/core/tone.md +31 -31
- package/dist/llm/system-prompt/layers/core/tools.thin.md +13 -13
- package/dist/llm/system-prompt/layers/core/wellbeing.md +41 -41
- package/dist/llm/system-prompt/layers/role/architect.md +20 -20
- package/dist/llm/system-prompt/layers/role/expert.md +19 -19
- package/dist/llm/system-prompt/layers/role/implementer.md +15 -15
- package/dist/llm/system-prompt/layers/role/security.md +15 -15
- package/dist/llm/system-prompt/layers/tool/artifacts.md +72 -72
- package/dist/llm/system-prompt/layers/tool/bash.md +25 -25
- package/dist/llm/system-prompt/layers/tool/hibs_api.md +171 -171
- package/dist/llm/system-prompt/layers/tool/image_search.md +70 -70
- package/dist/llm/system-prompt/layers/tool/manifest.md +89 -89
- package/dist/llm/system-prompt/layers/tool/mcp_apps.md +53 -53
- package/dist/llm/system-prompt/layers/tool/web_search.md +83 -83
- package/dist/llm/tool-manifest/ask_user_input.js +1 -1
- package/dist/llm/tool-manifest/bash.js +3 -3
- package/dist/llm/tool-manifest/create_file.js +4 -4
- package/dist/llm/tool-manifest/fetch_sports_data.js +3 -3
- package/dist/llm/tool-manifest/image_search.js +2 -2
- package/dist/llm/tool-manifest/mcp.js +2 -2
- package/dist/llm/tool-manifest/message_compose.js +3 -3
- package/dist/llm/tool-manifest/places.js +2 -2
- package/dist/llm/tool-manifest/present_files.js +1 -1
- package/dist/llm/tool-manifest/recipe.js +2 -2
- package/dist/llm/tool-manifest/str_replace.js +5 -5
- package/dist/llm/tool-manifest/view.js +3 -3
- package/dist/llm/tool-manifest/weather.js +4 -4
- package/dist/llm/tool-manifest/web.js +4 -4
- package/dist/network/local-inbox-bus.js +73 -0
- package/dist/network/p2p-outbox.js +161 -0
- package/dist/network/peer-fs.js +420 -0
- package/dist/network/peer-resource-bridge.js +216 -0
- package/dist/pi-ecosystem-judgment/causal-judge.js +51 -51
- package/dist/pi-ecosystem-judgment/cleanup.js +126 -0
- package/dist/pi-ecosystem-judgment/distill-prompt.js +42 -42
- package/dist/pi-ecosystem-judgment/distillation.js +14 -14
- package/dist/pi-ecosystem-judgment/human-value-store.js +45 -11
- package/dist/pi-ecosystem-judgment/monitor-gate.js +28 -28
- package/dist/pi-ecosystem-judgment/value-injection.js +102 -102
- package/dist/security/context-router-tool.js +15 -15
- package/dist/security/tool-gate.js +11 -0
- package/dist/web/api-config.html +520 -520
- package/dist/web/client-loop-status.js +220 -0
- package/dist/web/client.js +22 -5
- package/dist/web/client.js.map +7 -0
- package/dist/web/components/wallet-viem.mjs +118 -118
- package/dist/web/index.html +375 -375
- package/dist/web/input-validator.js +103 -0
- package/dist/web/manifest.json +20 -20
- package/dist/web/routes-judgments.js +738 -0
- package/dist/web/routes-llm-config.js +279 -0
- package/dist/web/routes-tasks.js +222 -0
- package/dist/web/server-sse.js +121 -0
- package/dist/web/server-storage.js +154 -0
- package/dist/web/server-types.js +15 -0
- package/dist/web/server-v3-p2p.js +224 -0
- package/dist/web/server.js +1070 -1307
- package/dist/web/style.css +4742 -4742
- package/dist/web/util/safe-name.js +32 -0
- package/package.json +162 -160
- package/scripts/build-cli.js +215 -215
- package/scripts/build-web.ts +130 -130
- package/scripts/postinstall.js +152 -152
- package/bin/bolloon.js +0 -157
- package/dist/constraint-runtime/src/_archive_helper.js +0 -9
- package/dist/constraint-runtime/src/agent/coordinator.js +0 -48
- package/dist/constraint-runtime/src/agent/index.js +0 -1
- package/dist/constraint-runtime/src/assistant/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap_graph.js +0 -13
- package/dist/constraint-runtime/src/bridge/index.js +0 -12
- package/dist/constraint-runtime/src/buddy/index.js +0 -12
- package/dist/constraint-runtime/src/cli/index.js +0 -12
- package/dist/constraint-runtime/src/command_graph.js +0 -10
- package/dist/constraint-runtime/src/commands.js +0 -60
- package/dist/constraint-runtime/src/components/index.js +0 -12
- package/dist/constraint-runtime/src/constants/index.js +0 -12
- package/dist/constraint-runtime/src/constraint/budget.js +0 -22
- package/dist/constraint-runtime/src/constraint/index.js +0 -2
- package/dist/constraint-runtime/src/constraint/permission.js +0 -20
- package/dist/constraint-runtime/src/context.js +0 -30
- package/dist/constraint-runtime/src/coordinator/index.js +0 -12
- package/dist/constraint-runtime/src/cost_hook.js +0 -4
- package/dist/constraint-runtime/src/cost_tracker.js +0 -8
- package/dist/constraint-runtime/src/deferred_init.js +0 -10
- package/dist/constraint-runtime/src/direct_modes.js +0 -6
- package/dist/constraint-runtime/src/dynamic-tool-loader.js +0 -85
- package/dist/constraint-runtime/src/entrypoints/index.js +0 -12
- package/dist/constraint-runtime/src/execution_registry.js +0 -44
- package/dist/constraint-runtime/src/history.js +0 -9
- package/dist/constraint-runtime/src/hooks/index.js +0 -12
- package/dist/constraint-runtime/src/index.js +0 -26
- package/dist/constraint-runtime/src/ink.js +0 -4
- package/dist/constraint-runtime/src/keybindings/index.js +0 -12
- package/dist/constraint-runtime/src/memdir/index.js +0 -12
- package/dist/constraint-runtime/src/migrations/index.js +0 -12
- package/dist/constraint-runtime/src/models.js +0 -1
- package/dist/constraint-runtime/src/moreright/index.js +0 -12
- package/dist/constraint-runtime/src/native_ts/index.js +0 -12
- package/dist/constraint-runtime/src/output_styles/index.js +0 -12
- package/dist/constraint-runtime/src/parity_audit.js +0 -12
- package/dist/constraint-runtime/src/plugins/index.js +0 -12
- package/dist/constraint-runtime/src/port_manifest.js +0 -11
- package/dist/constraint-runtime/src/prefetch.js +0 -9
- package/dist/constraint-runtime/src/query.js +0 -1
- package/dist/constraint-runtime/src/remote/index.js +0 -12
- package/dist/constraint-runtime/src/remote_runtime.js +0 -9
- package/dist/constraint-runtime/src/runtime/index.js +0 -1
- package/dist/constraint-runtime/src/runtime/session.js +0 -35
- package/dist/constraint-runtime/src/schemas/index.js +0 -12
- package/dist/constraint-runtime/src/screens/index.js +0 -12
- package/dist/constraint-runtime/src/server/index.js +0 -12
- package/dist/constraint-runtime/src/services/index.js +0 -12
- package/dist/constraint-runtime/src/session_store.js +0 -22
- package/dist/constraint-runtime/src/setup.js +0 -30
- package/dist/constraint-runtime/src/skills/index.js +0 -1
- package/dist/constraint-runtime/src/skills/skill-registry.js +0 -28
- package/dist/constraint-runtime/src/state/index.js +0 -12
- package/dist/constraint-runtime/src/system_init.js +0 -20
- package/dist/constraint-runtime/src/thinking/engine.js +0 -42
- package/dist/constraint-runtime/src/thinking/index.js +0 -1
- package/dist/constraint-runtime/src/tool_pool.js +0 -8
- package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +0 -7
- package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +0 -8
- package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools.js +0 -80
- package/dist/constraint-runtime/src/transcript.js +0 -19
- package/dist/constraint-runtime/src/types/index.js +0 -12
- package/dist/constraint-runtime/src/upstream_proxy/index.js +0 -12
- package/dist/constraint-runtime/src/utils/index.js +0 -12
- package/dist/constraint-runtime/src/vim/index.js +0 -12
- package/dist/constraint-runtime/src/voice/index.js +0 -12
- package/dist/constraint-runtime/tests/agent.test.js +0 -16
- package/dist/constraint-runtime/tests/constraint.test.js +0 -41
- package/dist/constraint-runtime/tests/skill.test.js +0 -19
- package/dist/constraint-runtime/tests/thinking.test.js +0 -22
- package/dist/pi-ecosystem-colony/index.js +0 -365
- package/dist/social/ant-colony/AdaptiveHeartbeat.js +0 -101
- package/dist/social/ant-colony/PheromoneEngine.js +0 -227
- package/dist/social/ant-colony/index.js +0 -6
- package/dist/social/ant-colony/types.js +0 -24
- package/dist/test/ai-judgment-test.js +0 -80
- package/dist/test/bollharness-integration.test.js +0 -318
- package/dist/test/channel-agent-multi-dialogue.js +0 -205
- package/dist/test/channel-heartbeat-agent-test.js +0 -201
- package/dist/test/constraint-layer.test.js +0 -164
- package/dist/test/diap-identity-test.js +0 -172
- package/dist/test/diap-quick-test.js +0 -62
- package/dist/test/global-shared-context.test.js +0 -315
- package/dist/test/harness-judgment-injection.test.js +0 -246
- package/dist/test/harness-workflow-integrator-test.js +0 -228
- package/dist/test/human-value-store.test.js +0 -243
- package/dist/test/hybrid-integration-test.js +0 -118
- package/dist/test/hybrid-messenger-verify.js +0 -55
- package/dist/test/iroh-bistream-debug.js +0 -38
- package/dist/test/iroh-communication.test.js +0 -66
- package/dist/test/iroh-debug-test.js +0 -57
- package/dist/test/iroh-diap-test.js +0 -71
- package/dist/test/iroh-direct-connect.js +0 -55
- package/dist/test/iroh-e2e-fixed.js +0 -89
- package/dist/test/iroh-e2e-same-process.js +0 -63
- package/dist/test/iroh-e2e.js +0 -66
- package/dist/test/iroh-final-e2e.js +0 -72
- package/dist/test/iroh-relay-test.js +0 -37
- package/dist/test/iroh-simple-test.js +0 -41
- package/dist/test/iroh-transport-verify.js +0 -54
- package/dist/test/iroh-transport.test.js +0 -37
- package/dist/test/iroh-two-nodes.js +0 -70
- package/dist/test/iroh-verify.js +0 -44
- package/dist/test/judgment-decision.test.js +0 -219
- package/dist/test/llm-judgment-integration.test.js +0 -220
- package/dist/test/p2p-agent-complex-dialogue.js +0 -385
- package/dist/test/p2p-agent-dialogue.js +0 -341
- package/dist/test/p2p-agent-full-bidirectional.js +0 -510
- package/dist/test/p2p-agent-harness-flow.js +0 -437
- package/dist/test/p2p-agent-harness-single.js +0 -143
- package/dist/test/p2p-ai-dialogue-test.js +0 -318
- package/dist/test/p2p-cid-connect-test.js +0 -195
- package/dist/test/p2p-connect-receiver.js +0 -69
- package/dist/test/p2p-doc-transfer.js +0 -110
- package/dist/test/p2p-identity-page-test.js +0 -77
- package/dist/test/p2p-iroh-test.js +0 -171
- package/dist/test/p2p-minimal-test.js +0 -241
- package/dist/test/p2p-node-1.js +0 -148
- package/dist/test/p2p-node-2.js +0 -148
- package/dist/test/p2p-server.js +0 -281
- package/dist/test/p2p-two-nodes-test.js +0 -438
- package/dist/test/pi-sdk.test.js +0 -44
- package/dist/test/set-persona.js +0 -40
- package/dist/test/simple.test.js +0 -9
- package/dist/test/storage-integration.test.js +0 -150
- package/dist/test/subagent-manager.test.js +0 -276
- package/dist/test/test-gate-flow.test.js +0 -81
- package/dist/test/workflow-engine.test.js +0 -87
- package/dist/test/workflow-pivot-loop.test.js +0 -246
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* client-loop-status.ts — client.ts 拆出的循环状态条 UI 模块
|
|
3
|
+
*
|
|
4
|
+
* 包含:
|
|
5
|
+
* - LOOP_STATUS_TOOLS: 关心的 system tool 集合
|
|
6
|
+
* - loopBarState: 'loading' / 'retrying' / 'done'
|
|
7
|
+
* - renderLoopStatusBar(): 渲染状态条 (含 retry badge)
|
|
8
|
+
* - markLoopBarDone() / hideLoopStatusBar() / applyLoopBarState()
|
|
9
|
+
* - inspectLoopResult(): 点击"检查"按钮拉循环产物
|
|
10
|
+
* - openLoopInspectModal(): 弹窗展示
|
|
11
|
+
*
|
|
12
|
+
* 从 src/web/client.ts 抽出 (2026-07-06).
|
|
13
|
+
*
|
|
14
|
+
* 浏览器侧: 通过 <script type="module"> 加载, 模块主动挂到 window.LoopStatus
|
|
15
|
+
* tsx 跑测试: 走 require() 同名拿
|
|
16
|
+
*/
|
|
17
|
+
const LOOP_STATUS_TOOLS = new Set(['loop', 'compactor', 'recovery', 'system']);
|
|
18
|
+
let loopBarState = 'loading';
|
|
19
|
+
let loopBarLastSummary = '';
|
|
20
|
+
const loopStatusBar = document.getElementById('loop-status-bar');
|
|
21
|
+
const loopStatusText = document.getElementById('loop-status-text');
|
|
22
|
+
const loopStatusMeta = document.getElementById('loop-status-meta');
|
|
23
|
+
function renderLoopStatusBar(tool, content) {
|
|
24
|
+
if (!loopStatusBar || !loopStatusText)
|
|
25
|
+
return;
|
|
26
|
+
const t = String(tool || '').toLowerCase();
|
|
27
|
+
if (!LOOP_STATUS_TOOLS.has(t)) {
|
|
28
|
+
console.log('[SSE] status (tool=' + t + ', ignored by UI):', content?.slice(0, 80));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const retryMatch = String(content || '').match(/自动重试(?: loop)?\s+(\d+)\/(\d+)/);
|
|
32
|
+
const retryFinal = /自动重试\s+\d+\s*次后仍失败/.test(String(content || ''));
|
|
33
|
+
loopStatusBar.hidden = false;
|
|
34
|
+
// 2026-07-06: 静默 pivot "循环 N/M" 文字 — 只显示 spinner 动画, 不暴露计数进度
|
|
35
|
+
// LLM 自己约束结束时机, 没有 hard cap. retrying 仍保留文字 (有意义提示).
|
|
36
|
+
const isPivotLoopMsg = /🔄\s*循环\s*\d+\s*\/\s*\d+/.test(String(content || ''));
|
|
37
|
+
let mainText;
|
|
38
|
+
if (isPivotLoopMsg && !retryMatch) {
|
|
39
|
+
mainText = ''; // 静默 — UI 用 spinner 表达"工作中"
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
mainText = String(content || '')
|
|
43
|
+
.replace(/^[\u{1F000}-\u{1FFFF}\u{2600}-\u{27BF}]\s*/u, '')
|
|
44
|
+
.replace(/^↻\s*/, '')
|
|
45
|
+
.replace(/^⛔\s*/, '')
|
|
46
|
+
.replace(/^⚠️\s*/, '')
|
|
47
|
+
.slice(0, 200);
|
|
48
|
+
}
|
|
49
|
+
loopStatusText.textContent = mainText;
|
|
50
|
+
if (retryMatch) {
|
|
51
|
+
loopBarState = 'retrying';
|
|
52
|
+
const retryEl = document.getElementById('loop-status-retry');
|
|
53
|
+
if (retryEl) {
|
|
54
|
+
retryEl.hidden = false;
|
|
55
|
+
retryEl.textContent = `自动重试 ${retryMatch[1]}/${retryMatch[2]}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (retryFinal) {
|
|
59
|
+
loopBarState = 'done';
|
|
60
|
+
const retryEl = document.getElementById('loop-status-retry');
|
|
61
|
+
if (retryEl)
|
|
62
|
+
retryEl.hidden = true;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (loopBarState !== 'loading')
|
|
66
|
+
loopBarState = 'loading';
|
|
67
|
+
const retryEl = document.getElementById('loop-status-retry');
|
|
68
|
+
if (retryEl)
|
|
69
|
+
retryEl.hidden = true;
|
|
70
|
+
}
|
|
71
|
+
applyLoopBarState();
|
|
72
|
+
}
|
|
73
|
+
function markLoopBarDone(summary) {
|
|
74
|
+
loopBarState = 'done';
|
|
75
|
+
if (summary)
|
|
76
|
+
loopBarLastSummary = summary;
|
|
77
|
+
applyLoopBarState();
|
|
78
|
+
}
|
|
79
|
+
function applyLoopBarState() {
|
|
80
|
+
if (!loopStatusBar)
|
|
81
|
+
return;
|
|
82
|
+
loopStatusBar.dataset.state = loopBarState;
|
|
83
|
+
const checkBtn = document.getElementById('loop-status-check');
|
|
84
|
+
if (checkBtn)
|
|
85
|
+
checkBtn.hidden = loopBarState !== 'done';
|
|
86
|
+
}
|
|
87
|
+
function hideLoopStatusBar() {
|
|
88
|
+
if (!loopStatusBar)
|
|
89
|
+
return;
|
|
90
|
+
loopStatusBar.hidden = true;
|
|
91
|
+
loopBarState = 'loading';
|
|
92
|
+
loopBarLastSummary = '';
|
|
93
|
+
const retryEl = document.getElementById('loop-status-retry');
|
|
94
|
+
if (retryEl)
|
|
95
|
+
retryEl.hidden = true;
|
|
96
|
+
applyLoopBarState();
|
|
97
|
+
}
|
|
98
|
+
async function inspectLoopResult() {
|
|
99
|
+
const checkBtn = document.getElementById('loop-status-check');
|
|
100
|
+
if (checkBtn) {
|
|
101
|
+
checkBtn.disabled = true;
|
|
102
|
+
checkBtn.textContent = '⏳ 加载...';
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const channelId = window.currentChannelId || '';
|
|
106
|
+
const r = await fetch(`/api/loop/inspect?channelId=${encodeURIComponent(channelId)}`);
|
|
107
|
+
const j = await r.json().catch(() => ({}));
|
|
108
|
+
openLoopInspectModal(j);
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
console.error('[inspect] error:', err);
|
|
112
|
+
if (typeof window.showSimpleToast === 'function')
|
|
113
|
+
window.showSimpleToast('✗ 检查失败');
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
if (checkBtn) {
|
|
117
|
+
checkBtn.disabled = false;
|
|
118
|
+
checkBtn.textContent = '✓ 检查';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function openLoopInspectModal(data) {
|
|
123
|
+
const existing = document.getElementById('loop-inspect-modal');
|
|
124
|
+
if (existing)
|
|
125
|
+
existing.remove();
|
|
126
|
+
const modal = document.createElement('div');
|
|
127
|
+
modal.id = 'loop-inspect-modal';
|
|
128
|
+
modal.className = 'modal active';
|
|
129
|
+
modal.style.cssText = 'position:fixed;inset:0;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center;z-index:1000;';
|
|
130
|
+
const panel = document.createElement('div');
|
|
131
|
+
panel.className = 'modal-panel';
|
|
132
|
+
panel.style.cssText = 'background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:20px;max-width:720px;width:90%;max-height:80vh;overflow:auto;position:relative;';
|
|
133
|
+
const title = document.createElement('h3');
|
|
134
|
+
title.textContent = '🔍 循环检查';
|
|
135
|
+
title.style.cssText = 'margin:0 0 12px;font-size:16px;';
|
|
136
|
+
panel.appendChild(title);
|
|
137
|
+
const close = document.createElement('button');
|
|
138
|
+
close.textContent = '×';
|
|
139
|
+
close.style.cssText = 'position:absolute;top:8px;right:12px;background:transparent;border:0;font-size:24px;cursor:pointer;color:var(--text-secondary);';
|
|
140
|
+
close.onclick = () => modal.remove();
|
|
141
|
+
panel.appendChild(close);
|
|
142
|
+
if (data.error) {
|
|
143
|
+
const e = document.createElement('div');
|
|
144
|
+
e.style.cssText = 'padding:8px 12px;background:rgba(239,68,68,0.12);color:var(--error,#ef4444);border-radius:4px;margin-bottom:12px;font-size:13px;';
|
|
145
|
+
e.textContent = '⚠️ ' + data.error;
|
|
146
|
+
panel.appendChild(e);
|
|
147
|
+
}
|
|
148
|
+
if (data.summary) {
|
|
149
|
+
const s = document.createElement('div');
|
|
150
|
+
s.style.cssText = 'padding:8px 12px;background:var(--bg-tertiary);border-radius:4px;margin-bottom:12px;font-size:13px;';
|
|
151
|
+
s.textContent = data.summary;
|
|
152
|
+
panel.appendChild(s);
|
|
153
|
+
}
|
|
154
|
+
if (data.tokens && (data.tokens.input || data.tokens.output)) {
|
|
155
|
+
const t = document.createElement('div');
|
|
156
|
+
t.style.cssText = 'font-size:12px;color:var(--text-muted);margin-bottom:12px;';
|
|
157
|
+
t.textContent = `token: input ${data.tokens.input || 0} · output ${data.tokens.output || 0}`;
|
|
158
|
+
panel.appendChild(t);
|
|
159
|
+
}
|
|
160
|
+
if (Array.isArray(data.steps) && data.steps.length > 0) {
|
|
161
|
+
const h = document.createElement('div');
|
|
162
|
+
h.textContent = `步骤 (${data.steps.length})`;
|
|
163
|
+
h.style.cssText = 'font-weight:600;margin-bottom:8px;';
|
|
164
|
+
panel.appendChild(h);
|
|
165
|
+
for (const step of data.steps) {
|
|
166
|
+
const row = document.createElement('div');
|
|
167
|
+
row.style.cssText = 'padding:6px 10px;margin-bottom:4px;background:var(--bg-secondary);border-left:3px solid var(--accent);border-radius:3px;font-size:12px;';
|
|
168
|
+
const icon = step.status === 'ok' || step.status === 'completed' ? '✓' : step.status === 'error' || step.status === 'failed' ? '✗' : '○';
|
|
169
|
+
const dur = step.durationMs ? ` (${(step.durationMs / 1000).toFixed(1)}s)` : '';
|
|
170
|
+
row.innerHTML = `<b>${icon} ${window.escapeHtml ? window.escapeHtml(step.name) : step.name}</b>${dur}`;
|
|
171
|
+
if (step.output) {
|
|
172
|
+
const pre = document.createElement('pre');
|
|
173
|
+
pre.style.cssText = 'margin:4px 0 0;padding:6px;background:var(--bg);border-radius:3px;font-size:11px;white-space:pre-wrap;word-break:break-word;max-height:120px;overflow:auto;';
|
|
174
|
+
pre.textContent = String(step.output).slice(0, 800);
|
|
175
|
+
row.appendChild(pre);
|
|
176
|
+
}
|
|
177
|
+
panel.appendChild(row);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (data.finalReply) {
|
|
181
|
+
const h = document.createElement('div');
|
|
182
|
+
h.textContent = '最终回复';
|
|
183
|
+
h.style.cssText = 'font-weight:600;margin:12px 0 8px;';
|
|
184
|
+
panel.appendChild(h);
|
|
185
|
+
const r = document.createElement('div');
|
|
186
|
+
r.style.cssText = 'padding:8px 12px;background:var(--bg-secondary);border-radius:4px;font-size:13px;white-space:pre-wrap;word-break:break-word;';
|
|
187
|
+
r.textContent = data.finalReply;
|
|
188
|
+
panel.appendChild(r);
|
|
189
|
+
}
|
|
190
|
+
if (!data.error && !data.summary && (!data.steps || data.steps.length === 0) && !data.finalReply) {
|
|
191
|
+
const empty = document.createElement('div');
|
|
192
|
+
empty.style.cssText = 'text-align:center;padding:24px;color:var(--text-muted);font-size:13px;';
|
|
193
|
+
empty.textContent = '无循环产出 (可能已 abort, 或没产生 step)';
|
|
194
|
+
panel.appendChild(empty);
|
|
195
|
+
}
|
|
196
|
+
modal.appendChild(panel);
|
|
197
|
+
modal.onclick = (e) => { if (e.target === modal)
|
|
198
|
+
modal.remove(); };
|
|
199
|
+
document.body.appendChild(modal);
|
|
200
|
+
}
|
|
201
|
+
// ESM / CommonJS 双向导出
|
|
202
|
+
// 浏览器侧: <script type="module"> 加载, 模块主动挂到 window.LoopStatus
|
|
203
|
+
// tsx 跑测试: 走 require() 同名拿
|
|
204
|
+
const LoopStatusExports = {
|
|
205
|
+
renderLoopStatusBar,
|
|
206
|
+
markLoopBarDone,
|
|
207
|
+
applyLoopBarState,
|
|
208
|
+
hideLoopStatusBar,
|
|
209
|
+
inspectLoopResult,
|
|
210
|
+
openLoopInspectModal,
|
|
211
|
+
get loopBarState() { return loopBarState; },
|
|
212
|
+
get loopBarLastSummary() { return loopBarLastSummary; },
|
|
213
|
+
};
|
|
214
|
+
if (typeof window !== 'undefined') {
|
|
215
|
+
window.LoopStatus = LoopStatusExports;
|
|
216
|
+
}
|
|
217
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
218
|
+
module.exports = LoopStatusExports;
|
|
219
|
+
}
|
|
220
|
+
export { renderLoopStatusBar, markLoopBarDone, applyLoopBarState, hideLoopStatusBar, inspectLoopResult, openLoopInspectModal, };
|
package/dist/web/client.js
CHANGED
|
@@ -2142,6 +2142,16 @@
|
|
|
2142
2142
|
}
|
|
2143
2143
|
expandedAgents.add(channelId);
|
|
2144
2144
|
console.log("[selectChannel] \u9891\u9053:", channel.name, "session:", currentSessionId);
|
|
2145
|
+
} else {
|
|
2146
|
+
console.warn("[selectChannel] channel \u4E0D\u5B58\u5728:", channelId);
|
|
2147
|
+
if (channelNameEl) channelNameEl.textContent = safeChannelName("(channel \u5DF2\u5220\u9664)");
|
|
2148
|
+
currentSessionId = targetSessionId || "default";
|
|
2149
|
+
const orphanContainer = ensureMessageContainer(channelId);
|
|
2150
|
+
showChannelView(channelId);
|
|
2151
|
+
orphanContainer.innerHTML = "";
|
|
2152
|
+
appendSystem(`\u26A0\uFE0F Channel ${channelId} \u5DF2\u4E0D\u5B58\u5728, \u65E0\u6CD5\u7EE7\u7EED\u5BF9\u8BDD\u3002
|
|
2153
|
+
\u8BF7\u5237\u65B0\u9875\u9762 (F5) \u6216\u5728\u5DE6\u4FA7\u9009\u62E9\u5176\u4ED6 channel\u3002`, "error");
|
|
2154
|
+
return;
|
|
2145
2155
|
}
|
|
2146
2156
|
const t0 = performance.now();
|
|
2147
2157
|
renderChannelsLite(channelId, currentSessionId);
|
|
@@ -2182,6 +2192,13 @@
|
|
|
2182
2192
|
const targetSessionId = sessionId || currentSessionId || "default";
|
|
2183
2193
|
try {
|
|
2184
2194
|
const res = await fetch(`/sessions/${channelId}?sessionId=${encodeURIComponent(targetSessionId)}`);
|
|
2195
|
+
if (res.status === 404) {
|
|
2196
|
+
const data = await res.json().catch(() => ({}));
|
|
2197
|
+
container.innerHTML = "";
|
|
2198
|
+
appendSystem(`\u26A0\uFE0F Channel ${channelId} \u5DF2\u4E0D\u5B58\u5728, \u65E0\u6CD5\u52A0\u8F7D\u5386\u53F2\u6D88\u606F\u3002
|
|
2199
|
+
${data.error || "channel not found"}`, "error");
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2185
2202
|
const session = await res.json();
|
|
2186
2203
|
container.innerHTML = "";
|
|
2187
2204
|
if (session.messages && session.messages.length > 0) {
|
|
@@ -4206,7 +4223,7 @@
|
|
|
4206
4223
|
addMessage2(text, role === "user" ? "user" : "ai", false, log);
|
|
4207
4224
|
log.scrollTop = log.scrollHeight;
|
|
4208
4225
|
};
|
|
4209
|
-
const
|
|
4226
|
+
const appendSystem2 = (text, kind = "info") => {
|
|
4210
4227
|
const el = document.createElement("div");
|
|
4211
4228
|
el.className = `remote-chat-sysmsg remote-chat-sysmsg-${kind}`;
|
|
4212
4229
|
el.textContent = text;
|
|
@@ -4240,13 +4257,13 @@
|
|
|
4240
4257
|
const res = await fetch(`/api/remote-channels/chat-history?targetPublicKey=${encodeURIComponent(peerPublicKey)}&channelId=${encodeURIComponent(channelId)}`);
|
|
4241
4258
|
const data = await res.json();
|
|
4242
4259
|
if (!res.ok) {
|
|
4243
|
-
|
|
4260
|
+
appendSystem2(`\u62C9\u53D6\u5931\u8D25: ${data.error || "unknown"}`, "error");
|
|
4244
4261
|
thinkingEl.style.display = "none";
|
|
4245
4262
|
return;
|
|
4246
4263
|
}
|
|
4247
4264
|
renderHistory(data);
|
|
4248
4265
|
} catch (err) {
|
|
4249
|
-
|
|
4266
|
+
appendSystem2(`\u62C9\u53D6\u5F02\u5E38: ${err.message}`, "error");
|
|
4250
4267
|
} finally {
|
|
4251
4268
|
thinkingEl.style.display = "none";
|
|
4252
4269
|
}
|
|
@@ -4269,7 +4286,7 @@
|
|
|
4269
4286
|
}
|
|
4270
4287
|
const msgs = data.messages || [];
|
|
4271
4288
|
if (msgs.length === 0) {
|
|
4272
|
-
|
|
4289
|
+
appendSystem2("\u8FD8\u6CA1\u6709\u5386\u53F2\u6D88\u606F, \u5728\u4E0B\u9762\u53D1\u7B2C\u4E00\u6761\u5427", "info");
|
|
4273
4290
|
} else {
|
|
4274
4291
|
for (const m of msgs) {
|
|
4275
4292
|
const type = m.type === "user" ? "user" : "ai";
|
|
@@ -4312,7 +4329,7 @@
|
|
|
4312
4329
|
const data = await res.json();
|
|
4313
4330
|
if (!res.ok) throw new Error(data.error || "send failed");
|
|
4314
4331
|
} catch (err) {
|
|
4315
|
-
|
|
4332
|
+
appendSystem2("\u53D1\u9001\u5931\u8D25: " + (err.message || err), "error");
|
|
4316
4333
|
} finally {
|
|
4317
4334
|
sendBtn2.disabled = false;
|
|
4318
4335
|
sendBtn2.textContent = "\u53D1\u9001";
|