@bolloon/bolloon-agent 0.1.36 → 0.1.37
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/client.js +2861 -3746
- package/dist/web/components/p2p/index.js +226 -264
- package/dist/web/ui/message-renderer.js +323 -434
- package/dist/web/ui/step-timeline.js +255 -351
- package/package.json +2 -2
- package/.auto-evolve-calls +0 -1
- package/.last-auto-evolve-baseline +0 -1
- package/.playwright-mcp/page-2026-06-16T07-51-45-706Z.yml +0 -130
- package/.playwright-mcp/page-2026-06-16T07-56-44-116Z.yml +0 -131
- package/Bolloon.md +0 -144
- package/Dive-into/CITATION.cff +0 -17
- package/Dive-into/LICENSE +0 -25
- package/Dive-into/README.md +0 -598
- package/Dive-into/README_zh.md +0 -599
- package/Dive-into/assets/context.png +0 -0
- package/Dive-into/assets/extensibility.png +0 -0
- package/Dive-into/assets/iteration.png +0 -0
- package/Dive-into/assets/layered_architecture.png +0 -0
- package/Dive-into/assets/main_structure.png +0 -0
- package/Dive-into/assets/permission.png +0 -0
- package/Dive-into/assets/session_compact.png +0 -0
- package/Dive-into/assets/subagent.png +0 -0
- package/Dive-into/paper/Dive_into_Claude_Code.pdf +0 -0
- package/dist/agents/constraint-layer.js.map +0 -1
- package/dist/agents/pi-sdk.js.map +0 -1
- package/dist/agents/workflow-engine.js.map +0 -1
- package/dist/bollharness/src/index.js +0 -5
- package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_api_types.js +0 -45
- package/dist/bollharness/src/scripts/checks/check_artifact_link.js +0 -146
- package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +0 -135
- package/dist/bollharness/src/scripts/checks/check_doc_links.js +0 -31
- package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +0 -34
- package/dist/bollharness/src/scripts/checks/check_hook_installed.js +0 -63
- package/dist/bollharness/src/scripts/checks/check_issue_closure.js +0 -41
- package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_security.js +0 -48
- package/dist/bollharness/src/scripts/checks/check_skill_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_versions.js +0 -6
- package/dist/bollharness/src/scripts/checks/finding.js +0 -13
- package/dist/bollharness/src/scripts/checks/next_decision_number.js +0 -20
- package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +0 -6
- package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +0 -8
- package/dist/bollharness/src/scripts/context_router.js +0 -67
- package/dist/bollharness/src/scripts/deploy-guard.js +0 -157
- package/dist/bollharness/src/scripts/guard-feedback.js +0 -192
- package/dist/bollharness/src/scripts/guard_router.js +0 -158
- package/dist/bollharness/src/scripts/hooks/_hook_output.js +0 -6
- package/dist/bollharness/src/scripts/hooks/auto-python3.js +0 -6
- package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +0 -6
- package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +0 -6
- package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +0 -92
- package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +0 -63
- package/dist/bollharness/src/scripts/hooks/inbox-ack.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-validate.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +0 -6
- package/dist/bollharness/src/scripts/hooks/initializer-agent.js +0 -6
- package/dist/bollharness/src/scripts/hooks/loop-detection.js +0 -73
- package/dist/bollharness/src/scripts/hooks/owner-guard.js +0 -6
- package/dist/bollharness/src/scripts/hooks/precompact.js +0 -6
- package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +0 -6
- package/dist/bollharness/src/scripts/hooks/risk-tracker.js +0 -108
- package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +0 -6
- package/dist/bollharness/src/scripts/hooks/session-reflection.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +0 -7
- package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +0 -157
- package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +0 -6
- package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +0 -10
- package/dist/bollharness/src/scripts/install/install-trust-token.js +0 -7
- package/dist/bollharness/src/scripts/install/multi_project_registry.js +0 -9
- package/dist/bollharness/src/scripts/install/phase2_auto.js +0 -21
- package/dist/bollharness/src/scripts/install/pre_commit_installer.js +0 -6
- package/dist/bollharness/src/scripts/install/tier_selector.js +0 -7
- package/dist/bollharness/src/scripts/install/transcript_miner.js +0 -7
- package/dist/bollharness/src/scripts/lib/claim_patterns.js +0 -10
- package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +0 -12
- package/dist/bollharness/src/scripts/sanitize.js +0 -6
- package/dist/bollharness-integration/context-router-judgment.js.map +0 -1
- package/dist/bollharness-integration/context-router.js.map +0 -1
- package/dist/bollharness-integration/gate-state-machine.js.map +0 -1
- package/dist/bollharness-integration/gate-transition-hooks.js.map +0 -1
- package/dist/bollharness-integration/guard-checker.js.map +0 -1
- package/dist/bollharness-integration/index.js.map +0 -1
- package/dist/bollharness-integration/integration.js.map +0 -1
- package/dist/bollharness-integration/llm/pi-ai.d.ts +0 -60
- package/dist/bollharness-integration/pi-ecosystem-colony/index.d.ts +0 -153
- package/dist/bollharness-integration/pi-ecosystem-goals/index.d.ts +0 -136
- package/dist/bollharness-integration/pi-ecosystem-judgment/decision.d.ts +0 -117
- package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.d.ts +0 -78
- package/dist/bollharness-integration/pi-ecosystem-judgment/index.d.ts +0 -139
- package/dist/bollharness-integration/pi-ecosystem-mcp/index.d.ts +0 -127
- package/dist/bollharness-integration/pi-ecosystem-subagents/index.d.ts +0 -95
- package/dist/bollharness-integration/skill-adapter.js.map +0 -1
- 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/budget.js.map +0 -1
- 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/constraint/permission.js.map +0 -1
- 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/models.js.map +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/PolymarketSDK/cancelOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +0 -5
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +0 -4
- 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/deploySafe.js +0 -6
- 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/WalletTools/autoPay.js +0 -29
- package/dist/constraint-runtime/src/tools/WalletTools/createWallet.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/getBalance.js +0 -13
- package/dist/constraint-runtime/src/tools/WalletTools/importWallet.js +0 -22
- package/dist/constraint-runtime/src/tools/WalletTools/sendTransaction.js +0 -25
- package/dist/constraint-runtime/src/tools/WalletTools/signMessage.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/transferToken.js +0 -25
- 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/constraints/index.js.map +0 -1
- package/dist/documents/reader.js.map +0 -1
- package/dist/llm/config-store.js.map +0 -1
- package/dist/llm/pi-ai.js.map +0 -1
- package/dist/network/agent-network.js.map +0 -1
- package/dist/network/iroh-integration.js.map +0 -1
- package/dist/network/iroh-transport.js.map +0 -1
- package/dist/network/p2p.js.map +0 -1
- package/dist/network/storage/adapters/json-adapter.js.map +0 -1
- package/dist/pi-ecosystem-colony/index.js.map +0 -1
- package/dist/pi-ecosystem-goals/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/decision.js.map +0 -1
- package/dist/pi-ecosystem-judgment/distillation.js.map +0 -1
- package/dist/pi-ecosystem-judgment/human-value-store.js.map +0 -1
- package/dist/pi-ecosystem-judgment/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/value-injection.js.map +0 -1
- package/dist/pi-ecosystem-mcp/index.js.map +0 -1
- package/dist/pi-ecosystem-subagents/index.js.map +0 -1
- package/dist/social/ant-colony/AdaptiveHeartbeat.js.map +0 -1
- package/dist/social/ant-colony/PheromoneEngine.js.map +0 -1
- package/dist/social/ant-colony/types.js.map +0 -1
- package/dist/social/channels/ChannelManager.js.map +0 -1
- package/dist/social/channels/DiapChannelBridge.js.map +0 -1
- package/dist/social/channels/InterestMatcher.js.map +0 -1
- package/dist/social/channels/types.js.map +0 -1
- package/dist/social/global-shared-context.js.map +0 -1
- package/dist/social/heartbeat.js.map +0 -1
- package/dist/web/components/p2p/P2PModal.js +0 -188
- package/dist/web/components/p2p/p2p-modal.js +0 -657
- package/dist/web/components/p2p/p2p-tools.js +0 -248
- package/lefthook.yml +0 -33
- package/scripts/auto-evolve-loop.ts +0 -481
- package/scripts/auto-evolve-oneshot.sh +0 -155
- package/scripts/auto-evolve-snapshot.sh +0 -136
- package/scripts/build-cli.js +0 -216
- package/scripts/build-web.ts +0 -116
- package/scripts/detect-schema-changes.sh +0 -48
- package/scripts/diff-reviewer.ts +0 -159
- package/scripts/postinstall.js +0 -153
- package/scripts/validate-system-prompt.ts +0 -142
- package/scripts/weekly-report.ts +0 -364
- package/src/agents/agent-manifest-protocol.ts +0 -117
- package/src/agents/constraint-layer.ts +0 -309
- package/src/agents/iroh-secret.ts +0 -32
- package/src/agents/p2p-chat-tools.ts +0 -383
- package/src/agents/p2p-document-tools.ts +0 -347
- package/src/agents/permission-mode.ts +0 -127
- package/src/agents/pi-sdk.ts +0 -2895
- package/src/agents/pre-tool-validator.ts +0 -213
- package/src/agents/protocol.ts +0 -398
- package/src/agents/shell-guard.ts +0 -417
- package/src/agents/shell-tool.ts +0 -103
- package/src/agents/skill-loader.ts +0 -202
- package/src/agents/subagent-manager.ts +0 -553
- package/src/agents/workflow-engine.ts +0 -332
- package/src/agents/workflow-pivot-loop.ts +0 -766
- package/src/bollharness/.sanitize-report.json +0 -13
- package/src/bollharness/CLAUDE.md +0 -73
- package/src/bollharness/LICENSE +0 -21
- package/src/bollharness/README.md +0 -143
- package/src/bollharness/README.zh-CN.md +0 -131
- package/src/bollharness/package.json +0 -20
- package/src/bollharness/reference/SOURCE-COMMIT.txt +0 -3
- package/src/bollharness/reference/boll-reference/scripts/hooks/.sanitize-report.json +0 -12
- package/src/bollharness/reference/boll-reference/scripts/hooks/find-boll-root.sh +0 -27
- package/src/bollharness/reference/boll-reference/scripts/hooks/precompact.sh +0 -57
- package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +0 -57
- package/src/bollharness/schemas/metrics-jsonl-allowlist.json +0 -67
- package/src/bollharness/scripts/checks/next_decision_number.sh +0 -48
- package/src/bollharness/scripts/ci/count-components.sh +0 -65
- package/src/bollharness/scripts/context-fragments/artifact-linkage.md +0 -14
- package/src/bollharness/scripts/context-fragments/auth-consumers.md +0 -17
- package/src/bollharness/scripts/context-fragments/bridge-constitution.md +0 -13
- package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +0 -18
- package/src/bollharness/scripts/context-fragments/closure-checklist.md +0 -13
- package/src/bollharness/scripts/context-fragments/contract-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/db-shared-structures.md +0 -15
- package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +0 -19
- package/src/bollharness/scripts/context-fragments/general-dev-principles.md +0 -11
- package/src/bollharness/scripts/context-fragments/issue-first.md +0 -8
- package/src/bollharness/scripts/context-fragments/mcp-parity.md +0 -16
- package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +0 -108
- package/src/bollharness/scripts/context-fragments/protocol-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/run-events-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/scene-fidelity.md +0 -13
- package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +0 -15
- package/src/bollharness/scripts/context-fragments/two-language.md +0 -15
- package/src/bollharness/scripts/context-fragments/version-sources.md +0 -14
- package/src/bollharness/scripts/hooks/find-project-root.sh +0 -47
- package/src/bollharness/scripts/hooks/inbox-poll.sh +0 -78
- package/src/bollharness/scripts/hooks/precompact.sh +0 -56
- package/src/bollharness/scripts/hooks/stop-evaluator.md +0 -83
- package/src/bollharness/scripts/sync-from-upstream.sh +0 -281
- package/src/bollharness/src/index.ts +0 -5
- package/src/bollharness/src/scripts/checks/check_adr_plan_numbering.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_api_types.ts +0 -52
- package/src/bollharness/src/scripts/checks/check_artifact_link.ts +0 -156
- package/src/bollharness/src/scripts/checks/check_bridge_deps.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding_ci.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_file_references.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_freshness.ts +0 -141
- package/src/bollharness/src/scripts/checks/check_doc_links.ts +0 -36
- package/src/bollharness/src/scripts/checks/check_file_existence_claims.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_fragment_integrity.ts +0 -40
- package/src/bollharness/src/scripts/checks/check_hook_installed.ts +0 -70
- package/src/bollharness/src/scripts/checks/check_issue_closure.ts +0 -51
- package/src/bollharness/src/scripts/checks/check_mcp_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_security.ts +0 -54
- package/src/bollharness/src/scripts/checks/check_skill_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_versions.ts +0 -11
- package/src/bollharness/src/scripts/checks/finding.ts +0 -35
- package/src/bollharness/src/scripts/checks/next_decision_number.ts +0 -24
- package/src/bollharness/src/scripts/checks/regenerate_magic_docs.ts +0 -11
- package/src/bollharness/src/scripts/ci/detect_rebaseline_triggers.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_subprocess_cfg.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_verify_artifacts.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_yaml_schema.ts +0 -14
- package/src/bollharness/src/scripts/context_router.ts +0 -76
- package/src/bollharness/src/scripts/deploy-guard.ts +0 -182
- package/src/bollharness/src/scripts/guard-feedback.ts +0 -215
- package/src/bollharness/src/scripts/guard_router.ts +0 -194
- package/src/bollharness/src/scripts/hooks/_hook_output.js +0 -3
- package/src/bollharness/src/scripts/hooks/_hook_output.ts +0 -11
- package/src/bollharness/src/scripts/hooks/auto-python3.ts +0 -10
- package/src/bollharness/src/scripts/hooks/deploy-progress-on-session-end.ts +0 -10
- package/src/bollharness/src/scripts/hooks/failure-analyzer.ts +0 -10
- package/src/bollharness/src/scripts/hooks/gate-judgment-inject.ts +0 -111
- package/src/bollharness/src/scripts/hooks/gate-transition-judgment.ts +0 -74
- package/src/bollharness/src/scripts/hooks/inbox-ack.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-inject-on-start.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-validate.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-write-ledger.ts +0 -10
- package/src/bollharness/src/scripts/hooks/initializer-agent.ts +0 -10
- package/src/bollharness/src/scripts/hooks/loop-detection.ts +0 -83
- package/src/bollharness/src/scripts/hooks/owner-guard.ts +0 -10
- package/src/bollharness/src/scripts/hooks/precompact.ts +0 -10
- package/src/bollharness/src/scripts/hooks/review-agent-gatekeeper.ts +0 -10
- package/src/bollharness/src/scripts/hooks/risk-tracker.ts +0 -121
- package/src/bollharness/src/scripts/hooks/sanitize-on-read.ts +0 -10
- package/src/bollharness/src/scripts/hooks/session-reflection.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-magic-docs.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-reset-risk.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-toolkit-reminder.ts +0 -12
- package/src/bollharness/src/scripts/hooks/stop-evaluator.ts +0 -164
- package/src/bollharness/src/scripts/hooks/tool-call-counter.ts +0 -10
- package/src/bollharness/src/scripts/hooks/trace-analyzer.ts +0 -14
- package/src/bollharness/src/scripts/install/install-trust-token.ts +0 -13
- package/src/bollharness/src/scripts/install/multi_project_registry.ts +0 -13
- package/src/bollharness/src/scripts/install/phase2_auto.ts +0 -28
- package/src/bollharness/src/scripts/install/pre_commit_installer.ts +0 -10
- package/src/bollharness/src/scripts/install/tier_selector.ts +0 -10
- package/src/bollharness/src/scripts/install/transcript_miner.ts +0 -13
- package/src/bollharness/src/scripts/lib/claim_patterns.ts +0 -11
- package/src/bollharness/src/scripts/lib/sanitize_patterns.ts +0 -13
- package/src/bollharness/src/scripts/sanitize.ts +0 -9
- package/src/bollharness/templates/persona/default.json +0 -19
- package/src/bollharness/templates/scaffold/.gitignore.append +0 -16
- package/src/bollharness/templates/scaffold/CLAUDE.md +0 -89
- package/src/bollharness-integration/channel-judgment-engine.ts +0 -634
- package/src/bollharness-integration/context-chain-router.ts +0 -474
- package/src/bollharness-integration/context-router-judgment.ts +0 -339
- package/src/bollharness-integration/context-router.ts +0 -583
- package/src/bollharness-integration/gate-state-machine.ts +0 -444
- package/src/bollharness-integration/gate-transition-hooks.ts +0 -137
- package/src/bollharness-integration/guard-checker.ts +0 -451
- package/src/bollharness-integration/index.ts +0 -195
- package/src/bollharness-integration/integration.ts +0 -538
- package/src/bollharness-integration/judgment-prompts.yaml +0 -535
- package/src/bollharness-integration/llm-judgment-engine.ts +0 -712
- package/src/bollharness-integration/skill-adapter.ts +0 -646
- package/src/bootstrap/bootstrap.ts +0 -135
- package/src/bootstrap/context-collector.ts +0 -371
- package/src/bootstrap/context-hierarchy.ts +0 -283
- package/src/bootstrap/lifecycle-hooks.ts +0 -289
- package/src/bootstrap/project-context.ts +0 -171
- package/src/cli/interface.ts +0 -211
- package/src/cli-entry.ts +0 -304
- package/src/constraints/index.ts +0 -6
- package/src/context-compaction/auto-compact.ts +0 -153
- package/src/context-compaction/budget-gate.ts +0 -32
- package/src/context-compaction/budget-reduce.ts +0 -37
- package/src/context-compaction/context-collapse.ts +0 -72
- package/src/context-compaction/index.ts +0 -24
- package/src/context-compaction/microcompact.ts +0 -54
- package/src/context-compaction/pipeline.ts +0 -133
- package/src/context-compaction/snip.ts +0 -51
- package/src/context-compaction/token-estimator.ts +0 -36
- package/src/context-compaction/types.ts +0 -99
- package/src/documents/reader.ts +0 -85
- package/src/documents/store.ts +0 -252
- package/src/electron-preload.ts +0 -25
- package/src/electron.ts +0 -200
- package/src/heartbeat/DaemonManager.ts +0 -283
- package/src/heartbeat/HealthMonitor.ts +0 -317
- package/src/heartbeat/StartupVerifier.ts +0 -223
- package/src/heartbeat/Watchdog.ts +0 -208
- package/src/heartbeat/index.ts +0 -109
- package/src/heartbeat/self-improve-bus.ts +0 -110
- package/src/heartbeat/types.ts +0 -82
- package/src/index.ts +0 -1724
- package/src/llm/audio-config-store.ts +0 -246
- package/src/llm/config-store.ts +0 -400
- package/src/llm/llm-judgment-client.ts +0 -471
- package/src/llm/pi-ai.ts +0 -653
- package/src/llm/system-prompt/health.ts +0 -159
- package/src/llm/system-prompt/layers/channel/local.md +0 -14
- package/src/llm/system-prompt/layers/channel/p2p-agent.md +0 -18
- package/src/llm/system-prompt/layers/channel/p2p-visitor.md +0 -19
- package/src/llm/system-prompt/layers/core/artifacts_storage.md +0 -89
- package/src/llm/system-prompt/layers/core/evenhandedness.md +0 -21
- package/src/llm/system-prompt/layers/core/hibs_reminders.md +0 -15
- package/src/llm/system-prompt/layers/core/identity.md +0 -37
- package/src/llm/system-prompt/layers/core/knowledge.md +0 -17
- package/src/llm/system-prompt/layers/core/memory_system.md +0 -12
- package/src/llm/system-prompt/layers/core/network_filesystem.md +0 -28
- package/src/llm/system-prompt/layers/core/refusal.md +0 -37
- package/src/llm/system-prompt/layers/core/tone.md +0 -31
- package/src/llm/system-prompt/layers/core/tools.thin.md +0 -13
- package/src/llm/system-prompt/layers/core/wellbeing.md +0 -41
- package/src/llm/system-prompt/layers/role/architect.md +0 -20
- package/src/llm/system-prompt/layers/role/expert.md +0 -19
- package/src/llm/system-prompt/layers/role/implementer.md +0 -15
- package/src/llm/system-prompt/layers/role/security.md +0 -15
- package/src/llm/system-prompt/layers/tool/artifacts.md +0 -72
- package/src/llm/system-prompt/layers/tool/bash.md +0 -25
- package/src/llm/system-prompt/layers/tool/hibs_api.md +0 -171
- package/src/llm/system-prompt/layers/tool/image_search.md +0 -70
- package/src/llm/system-prompt/layers/tool/manifest.md +0 -89
- package/src/llm/system-prompt/layers/tool/mcp_apps.md +0 -53
- package/src/llm/system-prompt/layers/tool/web_search.md +0 -83
- package/src/llm/system-prompt/registry.ts +0 -325
- package/src/llm/system-prompt/strip-hibsml.ts +0 -52
- package/src/llm/tool-manifest/ask_user_input.ts +0 -37
- package/src/llm/tool-manifest/bash.ts +0 -25
- package/src/llm/tool-manifest/create_file.ts +0 -26
- package/src/llm/tool-manifest/fetch_sports_data.ts +0 -28
- package/src/llm/tool-manifest/image_search.ts +0 -26
- package/src/llm/tool-manifest/index.ts +0 -88
- package/src/llm/tool-manifest/mcp.ts +0 -46
- package/src/llm/tool-manifest/message_compose.ts +0 -33
- package/src/llm/tool-manifest/places.ts +0 -86
- package/src/llm/tool-manifest/present_files.ts +0 -23
- package/src/llm/tool-manifest/recipe.ts +0 -42
- package/src/llm/tool-manifest/recommend_apps.ts +0 -25
- package/src/llm/tool-manifest/str_replace.ts +0 -29
- package/src/llm/tool-manifest/types.ts +0 -52
- package/src/llm/tool-manifest/view.ts +0 -26
- package/src/llm/tool-manifest/weather.ts +0 -29
- package/src/llm/tool-manifest/web.ts +0 -54
- package/src/llm/video-config-store.ts +0 -257
- package/src/network/agent-network.ts +0 -800
- package/src/network/hybrid-messenger.ts +0 -199
- package/src/network/iroh-bootstrap.ts +0 -57
- package/src/network/iroh-discovery.ts +0 -208
- package/src/network/iroh-integration.ts +0 -158
- package/src/network/iroh-transport.ts +0 -637
- package/src/network/known-peers.ts +0 -102
- package/src/network/p2p-direct.ts +0 -262
- package/src/network/p2p-secret.ts +0 -153
- package/src/network/p2p.ts +0 -964
- package/src/network/source-intent-broadcaster.ts +0 -242
- package/src/network/source-intent.ts +0 -167
- package/src/network/storage/adapters/json-adapter.ts +0 -454
- package/src/network/storage/index.ts +0 -203
- package/src/network/storage/types.ts +0 -166
- package/src/security/builtin-guards.ts +0 -162
- package/src/security/context-router-tool.ts +0 -122
- package/src/security/input-scanner.ts +0 -287
- package/src/security/react-harness.ts +0 -177
- package/src/security/tool-gate.ts +0 -294
- package/src/social/ant-colony/index.js +0 -19
- package/src/social/channels/ChannelManager.ts +0 -485
- package/src/social/channels/DiapChannelBridge.ts +0 -501
- package/src/social/channels/InterestMatcher.ts +0 -189
- package/src/social/channels/agent-workflow-config.json +0 -214
- package/src/social/channels/agent-workflow-config.yaml +0 -334
- package/src/social/channels/channel-agent-session.ts +0 -407
- package/src/social/channels/channel-heartbeat-agent.ts +0 -622
- package/src/social/channels/diap-doc-parser.ts +0 -282
- package/src/social/channels/harness-workflow-integrator.ts +0 -594
- package/src/social/channels/index.ts +0 -22
- package/src/social/channels/types.ts +0 -115
- package/src/social/global-shared-context.ts +0 -506
- package/src/social/heartbeat.ts +0 -1057
- package/src/social/persona/enhanced-persona.ts +0 -359
- package/src/types.d.ts +0 -12
- package/src/utils/auto-evolve-policy.ts +0 -138
- package/src/utils/auto-update.ts +0 -482
- package/src/utils/clamp.ts +0 -5
- package/src/web/agent-delegate-server.ts +0 -148
- package/src/web/api-config.html +0 -520
- package/src/web/client.js +0 -2352
- package/src/web/client.ts +0 -4326
- package/src/web/components/p2p/P2PModal.tsx +0 -416
- package/src/web/components/p2p/index.ts +0 -566
- package/src/web/components/p2p/index.tsx +0 -297
- package/src/web/components/p2p/p2p-connection.ts +0 -338
- package/src/web/components/p2p/p2p-identity.ts +0 -92
- package/src/web/components/p2p/p2p-manager.ts +0 -147
- package/src/web/components/p2p/p2p-messages.ts +0 -219
- package/src/web/components/p2p/p2p-modal.ts +0 -685
- package/src/web/components/p2p/p2p-store-memory.ts +0 -162
- package/src/web/components/p2p/p2p-tools.ts +0 -315
- package/src/web/components/p2p/types.ts +0 -170
- package/src/web/components/wallet-viem.mjs +0 -118
- package/src/web/design.md +0 -99
- package/src/web/icons/apple-touch-icon.png +0 -0
- package/src/web/icons/favicon-16x16.png +0 -0
- package/src/web/icons/favicon-192x192.png +0 -0
- package/src/web/icons/favicon-32x32.png +0 -0
- package/src/web/icons/favicon-48x48.png +0 -0
- package/src/web/icons/favicon-512x512.png +0 -0
- package/src/web/icons/favicon.icns +0 -0
- package/src/web/icons/favicon.ico +0 -0
- package/src/web/icons/icon.png +0 -0
- package/src/web/icons/image.png +0 -0
- package/src/web/index.html +0 -373
- package/src/web/iroh-delegate-transport.ts +0 -139
- package/src/web/manifest.json +0 -21
- package/src/web/server.ts +0 -5731
- package/src/web/style.css +0 -4737
- package/src/web/ui/message-renderer.ts +0 -540
- package/src/web/ui/step-timeline.ts +0 -394
- package/staging/auto-evolve/clean-001/.review-verdict +0 -9
- package/staging/auto-evolve/clean-001/clean-001.patch +0 -14
- package/staging/auto-evolve/e2e-001/.patch-id +0 -1
- package/staging/auto-evolve/e2e-001/.review-verdict +0 -12
- package/staging/auto-evolve/e2e-001/e2e-001.patch +0 -11
- package/staging/auto-evolve/test-bad/.review-verdict +0 -12
- package/staging/auto-evolve/test-bad/test-bad.patch +0 -11
- package/test-results/.last-run.json +0 -6
- package/test-results/src-test-web-loop-status-b-5734c-atus-bar-/346/230/276/347/244/272-spinner-/344/270/215/346/230/276/347/244/272/345/276/252/347/216/257/350/256/241/346/225/260/error-context.md +0 -285
- package/tsconfig.cli.json +0 -16
- package/tsconfig.electron.json +0 -20
- package/tsconfig.json +0 -18
|
@@ -1,463 +1,352 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* - finalize 流式消息为正式 AI 气泡
|
|
8
|
-
* - 折叠 think / environment_details 块
|
|
9
|
-
* - 复制 / 重新回答 / 蒸馏为判断 按钮
|
|
10
|
-
* - 挂载 step-timeline (2026-06-15) 步骤状态条到每条 AI 消息内
|
|
11
|
-
*
|
|
12
|
-
* 状态 (本模块私有):
|
|
13
|
-
* - streamingMessageEl / streamingTextNode / streamingText
|
|
14
|
-
* - lastUserCommand / lastAiContent (去重)
|
|
15
|
-
*
|
|
16
|
-
* 依赖 (import):
|
|
17
|
-
* - 浏览器 API (document, marked, fetch, navigator)
|
|
18
|
-
* - ./step-timeline (4 状态步骤条模块)
|
|
19
|
-
*
|
|
20
|
-
* 不依赖 (零业务 import, 防循环):
|
|
21
|
-
* - 不 import client.js
|
|
22
|
-
* - 不 import 任何业务模块
|
|
23
|
-
*
|
|
24
|
-
* 输入 (从 client.js 调用):
|
|
25
|
-
* - addMessage(content, type, save, container, usedIds, ctx)
|
|
26
|
-
* - handleStreamTokenEvent({ streamType, content }, ctx)
|
|
27
|
-
* - finalizeTimelineAsMessage(ctx)
|
|
28
|
-
* - handleStepEvent({ type: 'step_start'|'step_done'|'step_error', ... }, ctx)
|
|
29
|
-
* - escapeHtml(s)
|
|
30
|
-
* - getMessagesContainerForCurrent(currentChannelId, messagesContainers, messagesEl)
|
|
31
|
-
*
|
|
32
|
-
* 输出 (DOM):
|
|
33
|
-
* - .message / .bubble / .think-container / .env-container
|
|
34
|
-
* - .message-streaming (流式期间, finalize 时移除)
|
|
35
|
-
* - .message-actions (复制/重新回答/蒸馏按钮)
|
|
36
|
-
* - .used-judgments-link (P0.5 反向引用)
|
|
37
|
-
* - .step-timeline (气泡内步骤状态条, 由 ./step-timeline 渲染)
|
|
38
|
-
*/
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
// 类型定义
|
|
41
|
-
// ---------------------------------------------------------------------------
|
|
42
|
-
import { mountStepTimeline, pushStepToTimeline, migrateStepTimeline, getStepTimeline, } from './step-timeline.js';
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
44
|
-
// 模块私有状态
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
1
|
+
import {
|
|
2
|
+
mountStepTimeline,
|
|
3
|
+
pushStepToTimeline,
|
|
4
|
+
migrateStepTimeline,
|
|
5
|
+
getStepTimeline
|
|
6
|
+
} from "./step-timeline.js";
|
|
46
7
|
let streamingMessageEl = null;
|
|
47
8
|
let streamingTextNode = null;
|
|
48
|
-
let streamingText =
|
|
49
|
-
let lastUserCommand =
|
|
50
|
-
let lastAiContent =
|
|
51
|
-
// 滚动限频 (60ms 16fps, 减 reflow)
|
|
9
|
+
let streamingText = "";
|
|
10
|
+
let lastUserCommand = "";
|
|
11
|
+
let lastAiContent = "";
|
|
52
12
|
let scrollToBottomTimer = null;
|
|
53
13
|
function scheduleScrollToBottom(container) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
scrollToBottomTimer =
|
|
59
|
-
|
|
60
|
-
scrollToBottomTimer = null;
|
|
61
|
-
}, 60);
|
|
14
|
+
if (!container) return;
|
|
15
|
+
if (scrollToBottomTimer) return;
|
|
16
|
+
scrollToBottomTimer = setTimeout(() => {
|
|
17
|
+
container.scrollTop = container.scrollHeight;
|
|
18
|
+
scrollToBottomTimer = null;
|
|
19
|
+
}, 60);
|
|
62
20
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return messagesContainers.get(currentChannelId) || null;
|
|
69
|
-
}
|
|
70
|
-
return messagesEl;
|
|
21
|
+
function getMessagesContainerForCurrent(currentChannelId, messagesContainers, messagesEl) {
|
|
22
|
+
if (currentChannelId && messagesContainers.get(currentChannelId)) {
|
|
23
|
+
return messagesContainers.get(currentChannelId) || null;
|
|
24
|
+
}
|
|
25
|
+
return messagesEl;
|
|
71
26
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
27
|
+
function escapeHtml(s) {
|
|
28
|
+
return String(s ?? "").replace(/[&<>"']/g, (c) => ({
|
|
29
|
+
"&": "&",
|
|
30
|
+
"<": "<",
|
|
31
|
+
">": ">",
|
|
32
|
+
'"': """,
|
|
33
|
+
"'": "'"
|
|
34
|
+
})[c]);
|
|
79
35
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const toRemove = msgContainer.children.length - 200;
|
|
91
|
-
for (let i = 0; i < toRemove; i++) {
|
|
92
|
-
const first = msgContainer.firstElementChild;
|
|
93
|
-
if (first)
|
|
94
|
-
msgContainer.removeChild(first);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// 去重 (save=true 时)
|
|
98
|
-
if (save) {
|
|
99
|
-
const lastContent = type === 'user' ? lastUserCommand : lastAiContent;
|
|
100
|
-
if (lastContent && content === lastContent) {
|
|
101
|
-
console.log(`[addMessage] 跳过重复的 ${type} 消息`);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (type === 'user')
|
|
105
|
-
lastUserCommand = content;
|
|
106
|
-
else
|
|
107
|
-
lastAiContent = content;
|
|
108
|
-
}
|
|
109
|
-
const div = document.createElement('div');
|
|
110
|
-
div.className = `message message-${type}`;
|
|
111
|
-
// 清理: 移除 tool_call 标记
|
|
112
|
-
let cleanContent = content
|
|
113
|
-
.replace(/\[TOOL_CALL\][\s\S]*?\[\/TOOL_CALL\]/g, '')
|
|
114
|
-
.replace(/TOOL_CALL[\s\S]*?\/TOOL_CALL/g, '')
|
|
115
|
-
.replace(/<tool_call>[\s\S]*?<\/tool_call>/gi, '')
|
|
116
|
-
.replace(/\{\s*"tool":[\s\S]*?\}/g, '')
|
|
117
|
-
.replace(/\{\s*tool\s*=>\s*["'][^"']+["']\s*(?:,\s*args\s*=>\s*\{[\s\S]*?\})?\s*\}/g, '')
|
|
118
|
-
.replace(/\[Function[^\]]*\]\s*/g, '')
|
|
119
|
-
.trim();
|
|
120
|
-
// think 折叠
|
|
121
|
-
const thinkMatch = cleanContent.match(/<think>([\s\S]*?)<\/think>/);
|
|
122
|
-
let mainContent = cleanContent;
|
|
123
|
-
let thinkContainer = null;
|
|
124
|
-
if (thinkMatch) {
|
|
125
|
-
const thinkContent = thinkMatch[1].trim();
|
|
126
|
-
mainContent = cleanContent.replace(/<think>[\s\S]*?<\/think>/, '').trim();
|
|
127
|
-
thinkContainer = buildThinkContainer(thinkContent);
|
|
128
|
-
}
|
|
129
|
-
// environment_details 折叠 + 身份头
|
|
130
|
-
const envMatch = mainContent.match(/^(.+?)\n<environment_details>([\s\S]*?)<\/environment_details>\n([\s\S]*)$/);
|
|
131
|
-
if (envMatch) {
|
|
132
|
-
const identity = envMatch[1].trim();
|
|
133
|
-
const envDetails = envMatch[2].trim();
|
|
134
|
-
const messageBody = envMatch[3].trim();
|
|
135
|
-
const header = document.createElement('div');
|
|
136
|
-
header.className = 'message-header';
|
|
137
|
-
header.textContent = identity;
|
|
138
|
-
div.appendChild(header);
|
|
139
|
-
div.appendChild(buildEnvContainer(envDetails));
|
|
140
|
-
if (thinkContainer)
|
|
141
|
-
div.appendChild(thinkContainer);
|
|
142
|
-
if (messageBody)
|
|
143
|
-
div.appendChild(buildBubble(messageBody, type));
|
|
144
|
-
}
|
|
145
|
-
else if (cleanContent) {
|
|
146
|
-
if (thinkContainer)
|
|
147
|
-
div.appendChild(thinkContainer);
|
|
148
|
-
div.appendChild(buildBubble(cleanContent, type));
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
return; // 空内容, 不上屏
|
|
152
|
-
}
|
|
153
|
-
// 纯文本用于复制按钮
|
|
154
|
-
const rawContent = cleanContent
|
|
155
|
-
.replace(/<[^>]+>/g, '')
|
|
156
|
-
.replace(/</g, '<')
|
|
157
|
-
.replace(/>/g, '>')
|
|
158
|
-
.replace(/&/g, '&')
|
|
159
|
-
.replace(/ /g, ' ');
|
|
160
|
-
// 时间
|
|
161
|
-
const time = document.createElement('div');
|
|
162
|
-
time.className = 'time';
|
|
163
|
-
time.textContent = new Date().toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
|
|
164
|
-
// AI 消息操作按钮
|
|
165
|
-
if (type === 'ai') {
|
|
166
|
-
div.appendChild(buildMessageActions(div, rawContent, ctx));
|
|
36
|
+
function addMessage(content, type, save = true, container, usedJudgmentIds = [], ctx = { messagesEl: null, messagesContainers: /* @__PURE__ */ new Map(), currentChannelId: null }) {
|
|
37
|
+
const messagesEl = ctx.messagesEl || (typeof document !== "undefined" ? document.getElementById("messages") : null);
|
|
38
|
+
const messagesContainers = ctx.messagesContainers || /* @__PURE__ */ new Map();
|
|
39
|
+
const currentChannelId = ctx.currentChannelId;
|
|
40
|
+
const msgContainer = container || getMessagesContainerForCurrent(currentChannelId, messagesContainers, messagesEl);
|
|
41
|
+
if (!save && msgContainer && msgContainer.children.length > 200) {
|
|
42
|
+
const toRemove = msgContainer.children.length - 200;
|
|
43
|
+
for (let i = 0; i < toRemove; i++) {
|
|
44
|
+
const first = msgContainer.firstElementChild;
|
|
45
|
+
if (first) msgContainer.removeChild(first);
|
|
167
46
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
e.preventDefault();
|
|
175
|
-
if (typeof ctx.openJudgmentsModalWithFilter === 'function') {
|
|
176
|
-
ctx.openJudgmentsModalWithFilter(usedJudgmentIds);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
div.appendChild(link);
|
|
180
|
-
}
|
|
181
|
-
// 2026-06-15: 每条 AI 消息挂一个空 step-timeline 占位 (用户决策)
|
|
182
|
-
// 后续 step_start/step_done 事件会通过 handleStepEvent 推入
|
|
183
|
-
if (type === 'ai' && msgContainer) {
|
|
184
|
-
mountStepTimeline(div, currentChannelId);
|
|
185
|
-
}
|
|
186
|
-
div.appendChild(time);
|
|
187
|
-
if (msgContainer) {
|
|
188
|
-
msgContainer.appendChild(div);
|
|
189
|
-
scheduleScrollToBottom(msgContainer);
|
|
47
|
+
}
|
|
48
|
+
if (save) {
|
|
49
|
+
const lastContent = type === "user" ? lastUserCommand : lastAiContent;
|
|
50
|
+
if (lastContent && content === lastContent) {
|
|
51
|
+
console.log(`[addMessage] \u8DF3\u8FC7\u91CD\u590D\u7684 ${type} \u6D88\u606F`);
|
|
52
|
+
return;
|
|
190
53
|
}
|
|
54
|
+
if (type === "user") lastUserCommand = content;
|
|
55
|
+
else lastAiContent = content;
|
|
56
|
+
}
|
|
57
|
+
const div = document.createElement("div");
|
|
58
|
+
div.className = `message message-${type}`;
|
|
59
|
+
let cleanContent = content.replace(/\[TOOL_CALL\][\s\S]*?\[\/TOOL_CALL\]/g, "").replace(/TOOL_CALL[\s\S]*?\/TOOL_CALL/g, "").replace(/<tool_call>[\s\S]*?<\/tool_call>/gi, "").replace(/\{\s*"tool":[\s\S]*?\}/g, "").replace(/\{\s*tool\s*=>\s*["'][^"']+["']\s*(?:,\s*args\s*=>\s*\{[\s\S]*?\})?\s*\}/g, "").replace(/\[Function[^\]]*\]\s*/g, "").trim();
|
|
60
|
+
const thinkMatch = cleanContent.match(/<think>([\s\S]*?)<\/think>/);
|
|
61
|
+
let mainContent = cleanContent;
|
|
62
|
+
let thinkContainer = null;
|
|
63
|
+
if (thinkMatch) {
|
|
64
|
+
const thinkContent = thinkMatch[1].trim();
|
|
65
|
+
mainContent = cleanContent.replace(/<think>[\s\S]*?<\/think>/, "").trim();
|
|
66
|
+
thinkContainer = buildThinkContainer(thinkContent);
|
|
67
|
+
}
|
|
68
|
+
const envMatch = mainContent.match(/^(.+?)\n<environment_details>([\s\S]*?)<\/environment_details>\n([\s\S]*)$/);
|
|
69
|
+
if (envMatch) {
|
|
70
|
+
const identity = envMatch[1].trim();
|
|
71
|
+
const envDetails = envMatch[2].trim();
|
|
72
|
+
const messageBody = envMatch[3].trim();
|
|
73
|
+
const header = document.createElement("div");
|
|
74
|
+
header.className = "message-header";
|
|
75
|
+
header.textContent = identity;
|
|
76
|
+
div.appendChild(header);
|
|
77
|
+
div.appendChild(buildEnvContainer(envDetails));
|
|
78
|
+
if (thinkContainer) div.appendChild(thinkContainer);
|
|
79
|
+
if (messageBody) div.appendChild(buildBubble(messageBody, type));
|
|
80
|
+
} else if (cleanContent) {
|
|
81
|
+
if (thinkContainer) div.appendChild(thinkContainer);
|
|
82
|
+
div.appendChild(buildBubble(cleanContent, type));
|
|
83
|
+
} else {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const rawContent = cleanContent.replace(/<[^>]+>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/ /g, " ");
|
|
87
|
+
const time = document.createElement("div");
|
|
88
|
+
time.className = "time";
|
|
89
|
+
time.textContent = (/* @__PURE__ */ new Date()).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" });
|
|
90
|
+
if (type === "ai") {
|
|
91
|
+
div.appendChild(buildMessageActions(div, rawContent, ctx));
|
|
92
|
+
}
|
|
93
|
+
if (type === "ai" && Array.isArray(usedJudgmentIds) && usedJudgmentIds.length > 0) {
|
|
94
|
+
const link = document.createElement("a");
|
|
95
|
+
link.className = "used-judgments-link";
|
|
96
|
+
link.textContent = `\u{1F4CE} \u53C2\u8003 ${usedJudgmentIds.length} \u6761\u539F\u5219`;
|
|
97
|
+
link.onclick = (e) => {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
if (typeof ctx.openJudgmentsModalWithFilter === "function") {
|
|
100
|
+
ctx.openJudgmentsModalWithFilter(usedJudgmentIds);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
div.appendChild(link);
|
|
104
|
+
}
|
|
105
|
+
if (type === "ai" && msgContainer) {
|
|
106
|
+
mountStepTimeline(div, currentChannelId);
|
|
107
|
+
}
|
|
108
|
+
div.appendChild(time);
|
|
109
|
+
if (msgContainer) {
|
|
110
|
+
msgContainer.appendChild(div);
|
|
111
|
+
scheduleScrollToBottom(msgContainer);
|
|
112
|
+
}
|
|
191
113
|
}
|
|
192
|
-
// ---------------------------------------------------------------------------
|
|
193
|
-
// 私有: think 折叠块
|
|
194
|
-
// ---------------------------------------------------------------------------
|
|
195
114
|
function buildThinkContainer(thinkContent) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
container.appendChild(content);
|
|
221
|
-
return container;
|
|
115
|
+
const container = document.createElement("div");
|
|
116
|
+
container.className = "think-container";
|
|
117
|
+
const toggle = document.createElement("div");
|
|
118
|
+
toggle.className = "think-toggle";
|
|
119
|
+
toggle.innerHTML = '\u{1F4AD} \u601D\u8003\u8FC7\u7A0B <span class="think-arrow">\u25B8</span>';
|
|
120
|
+
toggle.onclick = function() {
|
|
121
|
+
const details = container.querySelector(".think-content");
|
|
122
|
+
const arrow = toggle.querySelector(".think-arrow");
|
|
123
|
+
if (!details || !arrow) return;
|
|
124
|
+
if (details.style.display === "none") {
|
|
125
|
+
details.style.display = "block";
|
|
126
|
+
arrow.textContent = "\u25BE";
|
|
127
|
+
} else {
|
|
128
|
+
details.style.display = "none";
|
|
129
|
+
arrow.textContent = "\u25B8";
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const content = document.createElement("div");
|
|
133
|
+
content.className = "think-content";
|
|
134
|
+
content.style.display = "none";
|
|
135
|
+
content.innerHTML = `<pre>${escapeHtml(thinkContent)}</pre>`;
|
|
136
|
+
container.appendChild(toggle);
|
|
137
|
+
container.appendChild(content);
|
|
138
|
+
return container;
|
|
222
139
|
}
|
|
223
|
-
// ---------------------------------------------------------------------------
|
|
224
|
-
// 私有: environment_details 折叠块
|
|
225
|
-
// ---------------------------------------------------------------------------
|
|
226
140
|
function buildEnvContainer(envDetails) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
container.appendChild(content);
|
|
252
|
-
return container;
|
|
141
|
+
const container = document.createElement("div");
|
|
142
|
+
container.className = "env-container";
|
|
143
|
+
const toggle = document.createElement("div");
|
|
144
|
+
toggle.className = "env-toggle";
|
|
145
|
+
toggle.innerHTML = '\u2699\uFE0F \u73AF\u5883\u4FE1\u606F <span class="env-arrow">\u25B8</span>';
|
|
146
|
+
toggle.onclick = function() {
|
|
147
|
+
const details = container.querySelector(".environment-details");
|
|
148
|
+
const arrow = toggle.querySelector(".env-arrow");
|
|
149
|
+
if (!details || !arrow) return;
|
|
150
|
+
if (details.style.display === "none") {
|
|
151
|
+
details.style.display = "block";
|
|
152
|
+
arrow.textContent = "\u25BE";
|
|
153
|
+
} else {
|
|
154
|
+
details.style.display = "none";
|
|
155
|
+
arrow.textContent = "\u25B8";
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const content = document.createElement("div");
|
|
159
|
+
content.className = "environment-details";
|
|
160
|
+
content.style.display = "none";
|
|
161
|
+
content.innerHTML = `<pre>${escapeHtml(envDetails)}</pre>`;
|
|
162
|
+
container.appendChild(toggle);
|
|
163
|
+
container.appendChild(content);
|
|
164
|
+
return container;
|
|
253
165
|
}
|
|
254
|
-
// ---------------------------------------------------------------------------
|
|
255
|
-
// 私有: 气泡 (marked.parse 渲染)
|
|
256
|
-
// ---------------------------------------------------------------------------
|
|
257
166
|
function buildBubble(text, type) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
bubble.innerHTML = marked ? marked.parse(text) : escapeHtml(text);
|
|
264
|
-
return bubble;
|
|
167
|
+
const bubble = document.createElement("div");
|
|
168
|
+
bubble.className = `bubble bubble-${type}`;
|
|
169
|
+
const marked = window.marked;
|
|
170
|
+
bubble.innerHTML = marked ? marked.parse(text) : escapeHtml(text);
|
|
171
|
+
return bubble;
|
|
265
172
|
}
|
|
266
|
-
// ---------------------------------------------------------------------------
|
|
267
|
-
// 私有: 消息操作按钮 (复制 / 重新回答 / 蒸馏为判断)
|
|
268
|
-
// ---------------------------------------------------------------------------
|
|
269
173
|
function buildMessageActions(div, rawContent, ctx) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
regenBtn.
|
|
298
|
-
regenBtn.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
lastUserMsg = bubble.textContent || bubble.innerText || '';
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
174
|
+
const actions = document.createElement("div");
|
|
175
|
+
actions.className = "message-actions";
|
|
176
|
+
const copyBtn = document.createElement("button");
|
|
177
|
+
copyBtn.className = "action-btn copy-btn";
|
|
178
|
+
copyBtn.innerHTML = copyIcon() + " \u590D\u5236";
|
|
179
|
+
copyBtn.title = "\u590D\u5236\u6D88\u606F";
|
|
180
|
+
copyBtn.onclick = () => {
|
|
181
|
+
navigator.clipboard.writeText(rawContent).then(() => {
|
|
182
|
+
copyBtn.innerHTML = checkIcon() + " \u5DF2\u590D\u5236";
|
|
183
|
+
setTimeout(() => {
|
|
184
|
+
copyBtn.innerHTML = copyIcon() + " \u590D\u5236";
|
|
185
|
+
}, 2e3);
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
actions.appendChild(copyBtn);
|
|
189
|
+
const saveJudgmentBtn = document.createElement("button");
|
|
190
|
+
saveJudgmentBtn.className = "action-btn save-as-judgment";
|
|
191
|
+
saveJudgmentBtn.title = "AI \u84B8\u998F\u4E3A 30-80 \u5B57\u5224\u65AD\u529B + \u81EA\u52A8\u6F14\u5316\u5BF9\u9F50";
|
|
192
|
+
saveJudgmentBtn.setAttribute("data-decision", rawContent.substring(0, 800));
|
|
193
|
+
if (ctx.currentChannelId) saveJudgmentBtn.setAttribute("data-channel-id", ctx.currentChannelId);
|
|
194
|
+
saveJudgmentBtn.innerHTML = shieldIcon() + " \u84B8\u998F\u4E3A\u5224\u65AD";
|
|
195
|
+
actions.appendChild(saveJudgmentBtn);
|
|
196
|
+
const regenBtn = document.createElement("button");
|
|
197
|
+
regenBtn.className = "action-btn regenerate-btn";
|
|
198
|
+
regenBtn.innerHTML = refreshIcon(false) + " \u91CD\u65B0\u56DE\u7B54";
|
|
199
|
+
regenBtn.title = "\u91CD\u65B0\u751F\u6210\u56DE\u590D";
|
|
200
|
+
regenBtn.onclick = () => {
|
|
201
|
+
regenBtn.innerHTML = refreshIcon(true) + " \u751F\u6210\u4E2D...";
|
|
202
|
+
regenBtn.disabled = true;
|
|
203
|
+
const messages = div.parentElement?.querySelectorAll(".message") || [];
|
|
204
|
+
let lastUserMsg = "";
|
|
205
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
206
|
+
const msg = messages[i];
|
|
207
|
+
if (msg.classList.contains("message-user")) {
|
|
208
|
+
const bubble = msg.querySelector(".bubble");
|
|
209
|
+
if (bubble) {
|
|
210
|
+
lastUserMsg = bubble.textContent || bubble.innerText || "";
|
|
211
|
+
break;
|
|
312
212
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
fetch("/regenerate", {
|
|
216
|
+
method: "POST",
|
|
217
|
+
headers: { "Content-Type": "application/json" },
|
|
218
|
+
body: JSON.stringify({ channelId: ctx.currentChannelId, userMessage: lastUserMsg })
|
|
219
|
+
}).then((res) => {
|
|
220
|
+
if (!res.ok) throw new Error("regenerate failed");
|
|
221
|
+
}).catch((err) => {
|
|
222
|
+
console.error("\u91CD\u65B0\u751F\u6210\u5931\u8D25:", err);
|
|
223
|
+
regenBtn.innerHTML = refreshIcon(false) + " \u5931\u8D25";
|
|
224
|
+
setTimeout(() => {
|
|
225
|
+
regenBtn.innerHTML = refreshIcon(false) + " \u91CD\u65B0\u56DE\u7B54";
|
|
226
|
+
regenBtn.disabled = false;
|
|
227
|
+
}, 2e3);
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
actions.appendChild(regenBtn);
|
|
231
|
+
return actions;
|
|
331
232
|
}
|
|
332
|
-
function copyIcon() {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
function
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
scheduleScrollToBottom(container);
|
|
233
|
+
function copyIcon() {
|
|
234
|
+
return '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>';
|
|
235
|
+
}
|
|
236
|
+
function checkIcon() {
|
|
237
|
+
return '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"></polyline></svg>';
|
|
238
|
+
}
|
|
239
|
+
function shieldIcon() {
|
|
240
|
+
return '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2L4 6v6c0 5 3.5 9.5 8 10 4.5-.5 8-5 8-10V6l-8-4z"></path><path d="M9 12l2 2 4-4"></path></svg>';
|
|
241
|
+
}
|
|
242
|
+
function refreshIcon(spin = false) {
|
|
243
|
+
const cls = spin ? ' class="spin"' : "";
|
|
244
|
+
return `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"${cls}><path d="M21 2v6h-6M3 12a9 9 0 0 1 15-6.7L21 8M3 22v-6h6M21 12a9 9 0 0 1-15 6.7L3 16"></path></svg>`;
|
|
245
|
+
}
|
|
246
|
+
function handleStreamTokenEvent(data, ctx = { messagesEl: null, messagesContainers: /* @__PURE__ */ new Map(), currentChannelId: null }) {
|
|
247
|
+
const messagesEl = ctx.messagesEl || (typeof document !== "undefined" ? document.getElementById("messages") : null);
|
|
248
|
+
const messagesContainers = ctx.messagesContainers || /* @__PURE__ */ new Map();
|
|
249
|
+
const currentChannelId = ctx.currentChannelId;
|
|
250
|
+
const container = getMessagesContainerForCurrent(currentChannelId, messagesContainers, messagesEl);
|
|
251
|
+
if (!container) return;
|
|
252
|
+
const delta = data.content || "";
|
|
253
|
+
if (!delta) return;
|
|
254
|
+
if (!streamingMessageEl || !streamingMessageEl.isConnected) {
|
|
255
|
+
streamingMessageEl = document.createElement("div");
|
|
256
|
+
streamingMessageEl.className = "message message-ai message-streaming";
|
|
257
|
+
streamingTextNode = document.createTextNode("");
|
|
258
|
+
streamingMessageEl.appendChild(streamingTextNode);
|
|
259
|
+
streamingText = "";
|
|
260
|
+
mountStepTimeline(streamingMessageEl, currentChannelId);
|
|
261
|
+
container.appendChild(streamingMessageEl);
|
|
262
|
+
if (typeof ctx.setTimelineState === "function") {
|
|
263
|
+
ctx.setTimelineState("streaming");
|
|
365
264
|
}
|
|
366
|
-
if (streamingTextNode)
|
|
367
|
-
streamingTextNode.appendData(delta);
|
|
368
|
-
streamingText += delta;
|
|
369
265
|
scheduleScrollToBottom(container);
|
|
266
|
+
}
|
|
267
|
+
if (streamingTextNode) streamingTextNode.appendData(delta);
|
|
268
|
+
streamingText += delta;
|
|
269
|
+
scheduleScrollToBottom(container);
|
|
370
270
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
// 2026-06-15: finalize 时把 streaming 内的 step-timeline 整体搬到新建的正式 AI message 内
|
|
381
|
-
// addMessage 会建一个新 timeline 占位, 先记下 streaming 的引用, addMessage 后再迁移
|
|
382
|
-
// 避免节点从 0 重渲 (10+ 步的任务, 重渲闪烁会很厉害)
|
|
383
|
-
const oldStreamingEl = streamingMessageEl;
|
|
384
|
-
if (oldStreamingEl && oldStreamingEl.parentNode) {
|
|
385
|
-
oldStreamingEl.parentNode.removeChild(oldStreamingEl);
|
|
386
|
-
}
|
|
387
|
-
addMessage(streamingText, 'ai', true, container, ctx.lastUsedJudgmentIds || [], ctx);
|
|
388
|
-
if (oldStreamingEl && container) {
|
|
389
|
-
// 找刚 addMessage 创建的最后一条 ai message
|
|
390
|
-
const newAiMsg = container.querySelector('.message-ai:last-of-type');
|
|
391
|
-
if (newAiMsg && newAiMsg !== oldStreamingEl) {
|
|
392
|
-
migrateStepTimeline(oldStreamingEl, newAiMsg);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
271
|
+
function finalizeTimelineAsMessage(ctx = { messagesEl: null, messagesContainers: /* @__PURE__ */ new Map(), currentChannelId: null }) {
|
|
272
|
+
const messagesEl = ctx.messagesEl || (typeof document !== "undefined" ? document.getElementById("messages") : null);
|
|
273
|
+
const messagesContainers = ctx.messagesContainers || /* @__PURE__ */ new Map();
|
|
274
|
+
const currentChannelId = ctx.currentChannelId;
|
|
275
|
+
const container = getMessagesContainerForCurrent(currentChannelId, messagesContainers, messagesEl);
|
|
276
|
+
if (streamingText.trim().length > 0) {
|
|
277
|
+
const oldStreamingEl = streamingMessageEl;
|
|
278
|
+
if (oldStreamingEl && oldStreamingEl.parentNode) {
|
|
279
|
+
oldStreamingEl.parentNode.removeChild(oldStreamingEl);
|
|
395
280
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
ctx.setTimelineState('done');
|
|
281
|
+
addMessage(streamingText, "ai", true, container, ctx.lastUsedJudgmentIds || [], ctx);
|
|
282
|
+
if (oldStreamingEl && container) {
|
|
283
|
+
const newAiMsg = container.querySelector(".message-ai:last-of-type");
|
|
284
|
+
if (newAiMsg && newAiMsg !== oldStreamingEl) {
|
|
285
|
+
migrateStepTimeline(oldStreamingEl, newAiMsg);
|
|
286
|
+
}
|
|
403
287
|
}
|
|
288
|
+
}
|
|
289
|
+
streamingMessageEl = null;
|
|
290
|
+
streamingTextNode = null;
|
|
291
|
+
streamingText = "";
|
|
292
|
+
if (typeof ctx.setTimelineState === "function") {
|
|
293
|
+
ctx.setTimelineState("done");
|
|
294
|
+
}
|
|
404
295
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if (!timeline)
|
|
429
|
-
return;
|
|
430
|
-
pushStepToTimeline(timeline, data.type, {
|
|
431
|
-
tool: data.tool || 'unknown',
|
|
432
|
-
args: data.args,
|
|
433
|
-
success: data.success,
|
|
434
|
-
output: data.output,
|
|
435
|
-
error: data.error,
|
|
436
|
-
});
|
|
296
|
+
function handleStepEvent(data, ctx = { messagesEl: null, messagesContainers: /* @__PURE__ */ new Map(), currentChannelId: null }) {
|
|
297
|
+
const messagesEl = ctx.messagesEl || (typeof document !== "undefined" ? document.getElementById("messages") : null);
|
|
298
|
+
const messagesContainers = ctx.messagesContainers || /* @__PURE__ */ new Map();
|
|
299
|
+
const currentChannelId = ctx.currentChannelId;
|
|
300
|
+
const container = getMessagesContainerForCurrent(currentChannelId, messagesContainers, messagesEl);
|
|
301
|
+
if (!container) return;
|
|
302
|
+
if (!data || !data.type) return;
|
|
303
|
+
let target = streamingMessageEl && streamingMessageEl.isConnected ? streamingMessageEl : null;
|
|
304
|
+
if (!target) {
|
|
305
|
+
const aiMsgs = container.querySelectorAll(".message-ai");
|
|
306
|
+
if (aiMsgs.length === 0) return;
|
|
307
|
+
target = aiMsgs[aiMsgs.length - 1];
|
|
308
|
+
}
|
|
309
|
+
if (!target) return;
|
|
310
|
+
const timeline = getStepTimeline(target);
|
|
311
|
+
if (!timeline) return;
|
|
312
|
+
pushStepToTimeline(timeline, data.type, {
|
|
313
|
+
tool: data.tool || "unknown",
|
|
314
|
+
args: data.args,
|
|
315
|
+
success: data.success,
|
|
316
|
+
output: data.output,
|
|
317
|
+
error: data.error
|
|
318
|
+
});
|
|
437
319
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
clearTimeout(scrollToBottomTimer);
|
|
449
|
-
scrollToBottomTimer = null;
|
|
450
|
-
}
|
|
320
|
+
function resetRendererState() {
|
|
321
|
+
streamingMessageEl = null;
|
|
322
|
+
streamingTextNode = null;
|
|
323
|
+
streamingText = "";
|
|
324
|
+
lastUserCommand = "";
|
|
325
|
+
lastAiContent = "";
|
|
326
|
+
if (scrollToBottomTimer) {
|
|
327
|
+
clearTimeout(scrollToBottomTimer);
|
|
328
|
+
scrollToBottomTimer = null;
|
|
329
|
+
}
|
|
451
330
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
331
|
+
const MessageRenderer = {
|
|
332
|
+
addMessage,
|
|
333
|
+
handleStreamTokenEvent,
|
|
334
|
+
finalizeTimelineAsMessage,
|
|
335
|
+
handleStepEvent,
|
|
336
|
+
escapeHtml,
|
|
337
|
+
getMessagesContainerForCurrent,
|
|
338
|
+
resetRendererState
|
|
460
339
|
};
|
|
461
|
-
if (typeof window !==
|
|
462
|
-
|
|
340
|
+
if (typeof window !== "undefined") {
|
|
341
|
+
window.MR = MessageRenderer;
|
|
463
342
|
}
|
|
343
|
+
export {
|
|
344
|
+
MessageRenderer,
|
|
345
|
+
addMessage,
|
|
346
|
+
escapeHtml,
|
|
347
|
+
finalizeTimelineAsMessage,
|
|
348
|
+
getMessagesContainerForCurrent,
|
|
349
|
+
handleStepEvent,
|
|
350
|
+
handleStreamTokenEvent,
|
|
351
|
+
resetRendererState
|
|
352
|
+
};
|