@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,501 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DiapChannelBridge - 基于 Diap 去中心化协议的对外社交频道系统
|
|
3
|
-
*
|
|
4
|
-
* 核心功能:
|
|
5
|
-
* 1. 将本地频道注册到 Diap 网络,成为"可发现的服务"
|
|
6
|
-
* 2. 通过 Diap 发现具有特定能力的外部智能体
|
|
7
|
-
* 3. 跨频道智能体消息路由和通信
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { SocialSessionProvider } from '../heartbeat.js';
|
|
11
|
-
import type {
|
|
12
|
-
SocialChannel,
|
|
13
|
-
ChannelPresence,
|
|
14
|
-
ChannelAnnouncement,
|
|
15
|
-
DiscoveredAgent,
|
|
16
|
-
ServiceRegistration
|
|
17
|
-
} from './types.js';
|
|
18
|
-
import type { IdentityRegistration, KeyPair } from '@diap/sdk';
|
|
19
|
-
|
|
20
|
-
export interface DiapBridgeConfig {
|
|
21
|
-
discoveryInterval: number;
|
|
22
|
-
broadcastInterval: number;
|
|
23
|
-
maxDiscoveredAgents: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const DEFAULT_CONFIG: DiapBridgeConfig = {
|
|
27
|
-
discoveryInterval: 60 * 1000,
|
|
28
|
-
broadcastInterval: 30 * 1000,
|
|
29
|
-
maxDiscoveredAgents: 100
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export class DiapChannelBridge {
|
|
33
|
-
private agentAuthManager: any = null;
|
|
34
|
-
private keyPair: KeyPair | null = null;
|
|
35
|
-
private sessionProvider: SocialSessionProvider;
|
|
36
|
-
private registeredServices: Map<string, ServiceRegistration> = new Map();
|
|
37
|
-
private discoveredAgents: Map<string, DiscoveredAgent> = new Map();
|
|
38
|
-
private config: DiapBridgeConfig;
|
|
39
|
-
private initialized: boolean = false;
|
|
40
|
-
private discoveryTimer: ReturnType<typeof setInterval> | null = null;
|
|
41
|
-
private broadcastTimer: ReturnType<typeof setInterval> | null = null;
|
|
42
|
-
private ownChannel: SocialChannel | null = null;
|
|
43
|
-
|
|
44
|
-
constructor(
|
|
45
|
-
agentAuthManager: any,
|
|
46
|
-
keyPair: KeyPair,
|
|
47
|
-
sessionProvider: SocialSessionProvider,
|
|
48
|
-
config?: Partial<DiapBridgeConfig>
|
|
49
|
-
) {
|
|
50
|
-
this.agentAuthManager = agentAuthManager;
|
|
51
|
-
this.keyPair = keyPair;
|
|
52
|
-
this.sessionProvider = sessionProvider;
|
|
53
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async initialize(): Promise<void> {
|
|
57
|
-
if (this.initialized) return;
|
|
58
|
-
|
|
59
|
-
// 注册消息处理器
|
|
60
|
-
await this.registerMessageHandlers();
|
|
61
|
-
|
|
62
|
-
// 启动发现循环
|
|
63
|
-
this.startDiscoveryLoop();
|
|
64
|
-
|
|
65
|
-
// 启动广播循环
|
|
66
|
-
this.startBroadcastLoop();
|
|
67
|
-
|
|
68
|
-
this.initialized = true;
|
|
69
|
-
console.log('[DiapBridge] Initialized');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private async registerMessageHandlers(): Promise<void> {
|
|
73
|
-
try {
|
|
74
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
75
|
-
|
|
76
|
-
// 处理频道公告
|
|
77
|
-
p2pNetwork.onMessage('channel_announce', async (data: Uint8Array, from: string) => {
|
|
78
|
-
try {
|
|
79
|
-
const announcement: ChannelAnnouncement = JSON.parse(new TextDecoder().decode(data));
|
|
80
|
-
await this.handleChannelAnnouncement(announcement, from);
|
|
81
|
-
} catch (e) {
|
|
82
|
-
console.warn('[DiapBridge] Failed to parse channel announcement:', e);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// 处理频道消息
|
|
87
|
-
p2pNetwork.onMessage('channel_msg', async (data: Uint8Array, from: string) => {
|
|
88
|
-
try {
|
|
89
|
-
const msg = JSON.parse(new TextDecoder().decode(data));
|
|
90
|
-
await this.handleChannelMessage(msg, from);
|
|
91
|
-
} catch (e) {
|
|
92
|
-
console.warn('[DiapBridge] Failed to parse channel message:', e);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// 处理智能体发现请求
|
|
97
|
-
p2pNetwork.onMessage('agent_discovery', async (data: Uint8Array, from: string) => {
|
|
98
|
-
try {
|
|
99
|
-
const request = JSON.parse(new TextDecoder().decode(data));
|
|
100
|
-
await this.handleDiscoveryRequest(request, from);
|
|
101
|
-
} catch (e) {
|
|
102
|
-
console.warn('[DiapBridge] Failed to parse discovery request:', e);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// 处理发现响应
|
|
107
|
-
p2pNetwork.onMessage('agent_discovery_response', async (data: Uint8Array, from: string) => {
|
|
108
|
-
try {
|
|
109
|
-
const response = JSON.parse(new TextDecoder().decode(data));
|
|
110
|
-
await this.handleDiscoveryResponse(response, from);
|
|
111
|
-
} catch (e) {
|
|
112
|
-
console.warn('[DiapBridge] Failed to parse discovery response:', e);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
console.log('[DiapBridge] Message handlers registered');
|
|
117
|
-
} catch (e) {
|
|
118
|
-
console.warn('[DiapBridge] Failed to register message handlers:', e);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* 注册频道到 Diap 网络
|
|
124
|
-
*/
|
|
125
|
-
async registerChannelToDiap(channel: SocialChannel): Promise<void> {
|
|
126
|
-
this.ownChannel = channel;
|
|
127
|
-
|
|
128
|
-
if (!this.agentAuthManager) {
|
|
129
|
-
console.warn('[DiapBridge] No AgentAuthManager, skipping Diap registration');
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const service: ServiceRegistration = {
|
|
134
|
-
serviceType: 'social_channel',
|
|
135
|
-
endpoint: channel.id,
|
|
136
|
-
metadata: {
|
|
137
|
-
topic: channel.topic,
|
|
138
|
-
capabilities: channel.requiredCapabilities,
|
|
139
|
-
memberCount: channel.members.size,
|
|
140
|
-
channelType: channel.type,
|
|
141
|
-
name: channel.name
|
|
142
|
-
},
|
|
143
|
-
registeredAt: Date.now()
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
try {
|
|
147
|
-
// 通过 AgentAuthManager 注册服务
|
|
148
|
-
await this.agentAuthManager.registerService(
|
|
149
|
-
channel.id,
|
|
150
|
-
{
|
|
151
|
-
serviceType: 'channel',
|
|
152
|
-
endpoint: channel.id,
|
|
153
|
-
metadata: service.metadata
|
|
154
|
-
},
|
|
155
|
-
this.keyPair
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
this.registeredServices.set(channel.id, service);
|
|
159
|
-
console.log(`[DiapBridge] Registered channel to Diap: ${channel.name}`);
|
|
160
|
-
} catch (e) {
|
|
161
|
-
console.warn('[DiapBridge] Failed to register channel to Diap:', e);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* 通过 Diap 发现具有特定能力的外部智能体
|
|
167
|
-
*/
|
|
168
|
-
async discoverAgentsByCapability(capabilities: string[]): Promise<DiscoveredAgent[]> {
|
|
169
|
-
if (capabilities.length === 0) return [];
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
// 通过 P2P 网络发送发现请求
|
|
173
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
174
|
-
|
|
175
|
-
const request = {
|
|
176
|
-
type: 'discovery_request',
|
|
177
|
-
requesterDid: this.getOwnDid(),
|
|
178
|
-
capabilities,
|
|
179
|
-
timestamp: Date.now()
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
await p2pNetwork.broadcast('agent_discovery', JSON.stringify(request));
|
|
183
|
-
|
|
184
|
-
// 等待响应(实际由事件驱动)
|
|
185
|
-
return Array.from(this.discoveredAgents.values());
|
|
186
|
-
} catch (e) {
|
|
187
|
-
console.warn('[DiapBridge] Failed to discover agents:', e);
|
|
188
|
-
return [];
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* 处理频道公告
|
|
194
|
-
*/
|
|
195
|
-
private async handleChannelAnnouncement(
|
|
196
|
-
announcement: ChannelAnnouncement,
|
|
197
|
-
fromPeerId: string
|
|
198
|
-
): Promise<void> {
|
|
199
|
-
// 验证签名(如果实现)
|
|
200
|
-
if (announcement.signature) {
|
|
201
|
-
const isValid = await this.verifyAnnouncement(announcement);
|
|
202
|
-
if (!isValid) {
|
|
203
|
-
console.warn('[DiapBridge] Invalid channel announcement signature');
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// 检查是否是自己的公告
|
|
209
|
-
if (announcement.leaderDid === this.getOwnDid()) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// 记录发现的智能体
|
|
214
|
-
const agent: DiscoveredAgent = {
|
|
215
|
-
did: announcement.leaderDid,
|
|
216
|
-
name: announcement.channelName,
|
|
217
|
-
capabilities: announcement.capabilities,
|
|
218
|
-
lastSeen: Date.now(),
|
|
219
|
-
channelId: announcement.channelId
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
this.discoveredAgents.set(agent.did, agent);
|
|
223
|
-
console.log(`[DiapBridge] Discovered agent via channel: ${agent.name}`);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* 处理频道消息
|
|
228
|
-
*/
|
|
229
|
-
private async handleChannelMessage(msg: any, fromPeerId: string): Promise<void> {
|
|
230
|
-
const agent = this.discoveredAgents.get(msg.fromDid);
|
|
231
|
-
if (agent) {
|
|
232
|
-
agent.lastSeen = Date.now();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* 处理发现请求
|
|
238
|
-
*/
|
|
239
|
-
private async handleDiscoveryRequest(request: any, fromPeerId: string): Promise<void> {
|
|
240
|
-
// 忽略自己的请求
|
|
241
|
-
if (request.requesterDid === this.getOwnDid()) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const persona = this.sessionProvider.getPersona();
|
|
246
|
-
const capabilities = persona?.capabilities || [];
|
|
247
|
-
|
|
248
|
-
// 检查能力是否匹配
|
|
249
|
-
const hasMatch = request.capabilities.some((reqCap: string) =>
|
|
250
|
-
capabilities.some(myCap =>
|
|
251
|
-
reqCap.toLowerCase().includes(myCap.toLowerCase()) ||
|
|
252
|
-
myCap.toLowerCase().includes(reqCap.toLowerCase())
|
|
253
|
-
)
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
if (!hasMatch) return;
|
|
257
|
-
|
|
258
|
-
// 发送响应
|
|
259
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
260
|
-
|
|
261
|
-
const response = {
|
|
262
|
-
type: 'discovery_response',
|
|
263
|
-
responderDid: this.getOwnDid(),
|
|
264
|
-
responderName: persona?.name || 'Agent',
|
|
265
|
-
capabilities,
|
|
266
|
-
interests: persona?.interests || [],
|
|
267
|
-
channelId: this.ownChannel?.id,
|
|
268
|
-
timestamp: Date.now()
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
try {
|
|
272
|
-
await p2pNetwork.sendMessage(fromPeerId, 'agent_discovery_response', JSON.stringify(response));
|
|
273
|
-
} catch (e) {
|
|
274
|
-
console.warn('[DiapBridge] Failed to send discovery response:', e);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* 处理发现响应
|
|
280
|
-
*/
|
|
281
|
-
private async handleDiscoveryResponse(response: any, fromPeerId: string): Promise<void> {
|
|
282
|
-
const agent: DiscoveredAgent = {
|
|
283
|
-
did: response.responderDid,
|
|
284
|
-
name: response.responderName,
|
|
285
|
-
capabilities: response.capabilities,
|
|
286
|
-
interests: response.interests,
|
|
287
|
-
lastSeen: Date.now(),
|
|
288
|
-
peerId: fromPeerId,
|
|
289
|
-
channelId: response.channelId
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
this.discoveredAgents.set(agent.did, agent);
|
|
293
|
-
|
|
294
|
-
// 限制发现数量
|
|
295
|
-
if (this.discoveredAgents.size > this.config.maxDiscoveredAgents) {
|
|
296
|
-
const oldest = Array.from(this.discoveredAgents.values())
|
|
297
|
-
.sort((a, b) => a.lastSeen - b.lastSeen)[0];
|
|
298
|
-
if (oldest) {
|
|
299
|
-
this.discoveredAgents.delete(oldest.did);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
console.log(`[DiapBridge] Discovered agent: ${agent.name} (${(agent.capabilities || []).join(', ')})`);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
private verifyAnnouncement(announcement: ChannelAnnouncement): Promise<boolean> {
|
|
307
|
-
// TODO: 实现签名验证
|
|
308
|
-
return Promise.resolve(true);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
private getOwnDid(): string {
|
|
312
|
-
// 从 persona 或其他地方获取自己的 DID
|
|
313
|
-
const persona = this.sessionProvider.getPersona();
|
|
314
|
-
return persona?.name || `did:local:${Date.now()}`;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* 广播频道
|
|
319
|
-
*/
|
|
320
|
-
async broadcastChannel(channel: SocialChannel): Promise<void> {
|
|
321
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
322
|
-
|
|
323
|
-
const announcement: ChannelAnnouncement = {
|
|
324
|
-
type: 'channel_announce',
|
|
325
|
-
channelId: channel.id,
|
|
326
|
-
channelName: channel.name,
|
|
327
|
-
topic: channel.topic,
|
|
328
|
-
capabilities: channel.requiredCapabilities,
|
|
329
|
-
memberCount: channel.members.size,
|
|
330
|
-
leaderDid: this.getOwnDid(),
|
|
331
|
-
isPublic: channel.isPublic,
|
|
332
|
-
timestamp: Date.now()
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
// TODO: 添加签名
|
|
336
|
-
|
|
337
|
-
try {
|
|
338
|
-
await p2pNetwork.broadcast('channel_announce', JSON.stringify(announcement));
|
|
339
|
-
} catch (e) {
|
|
340
|
-
console.warn('[DiapBridge] Failed to broadcast channel:', e);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* 向智能体发送消息
|
|
346
|
-
*/
|
|
347
|
-
async sendToAgent(agentDid: string, type: string, payload: string): Promise<boolean> {
|
|
348
|
-
const agent = this.discoveredAgents.get(agentDid);
|
|
349
|
-
if (!agent?.peerId) {
|
|
350
|
-
console.warn(`[DiapBridge] Unknown agent or no peerId: ${agentDid}`);
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
try {
|
|
355
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
356
|
-
await p2pNetwork.sendMessage(agent.peerId, type, payload);
|
|
357
|
-
return true;
|
|
358
|
-
} catch (e) {
|
|
359
|
-
console.warn(`[DiapBridge] Failed to send to agent ${agentDid}:`, e);
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* 获取发现的智能体
|
|
366
|
-
*/
|
|
367
|
-
getDiscoveredAgents(): DiscoveredAgent[] {
|
|
368
|
-
return Array.from(this.discoveredAgents.values());
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* 获取注册的服务
|
|
373
|
-
*/
|
|
374
|
-
getRegisteredServices(): ServiceRegistration[] {
|
|
375
|
-
return Array.from(this.registeredServices.values());
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* 向指定 DID 的智能体发送消息(跨频道通信)
|
|
380
|
-
*/
|
|
381
|
-
async sendToAgentByDid(targetDid: string, type: string, payload: string): Promise<boolean> {
|
|
382
|
-
const agent = this.discoveredAgents.get(targetDid);
|
|
383
|
-
if (!agent?.peerId) {
|
|
384
|
-
console.warn(`[DiapBridge] Unknown agent or no peerId: ${targetDid}`);
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
try {
|
|
389
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
390
|
-
await p2pNetwork.sendMessage(agent.peerId, type, payload);
|
|
391
|
-
return true;
|
|
392
|
-
} catch (e) {
|
|
393
|
-
console.warn(`[DiapBridge] Failed to send to agent ${targetDid}:`, e);
|
|
394
|
-
return false;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* 广播消息到所有已发现的智能体
|
|
400
|
-
*/
|
|
401
|
-
async broadcastToAllAgents(type: string, payload: string): Promise<number> {
|
|
402
|
-
let successCount = 0;
|
|
403
|
-
|
|
404
|
-
for (const agent of this.discoveredAgents.values()) {
|
|
405
|
-
if (agent.peerId) {
|
|
406
|
-
try {
|
|
407
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
408
|
-
await p2pNetwork.sendMessage(agent.peerId, type, payload);
|
|
409
|
-
successCount++;
|
|
410
|
-
} catch (e) {
|
|
411
|
-
console.warn(`[DiapBridge] Failed to broadcast to ${agent.name}:`, e);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
return successCount;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* 根据能力筛选智能体并发送消息
|
|
421
|
-
*/
|
|
422
|
-
async sendToAgentsByCapability(
|
|
423
|
-
capabilities: string[],
|
|
424
|
-
type: string,
|
|
425
|
-
payload: string
|
|
426
|
-
): Promise<number> {
|
|
427
|
-
let successCount = 0;
|
|
428
|
-
|
|
429
|
-
for (const agent of this.discoveredAgents.values()) {
|
|
430
|
-
const agentCaps = agent.capabilities || [];
|
|
431
|
-
const hasMatch = capabilities.some(reqCap =>
|
|
432
|
-
agentCaps.some(myCap =>
|
|
433
|
-
reqCap.toLowerCase().includes(myCap.toLowerCase()) ||
|
|
434
|
-
myCap.toLowerCase().includes(reqCap.toLowerCase())
|
|
435
|
-
)
|
|
436
|
-
);
|
|
437
|
-
|
|
438
|
-
if (hasMatch && agent.peerId) {
|
|
439
|
-
try {
|
|
440
|
-
const { p2pNetwork } = await import('../../network/p2p.js');
|
|
441
|
-
await p2pNetwork.sendMessage(agent.peerId, type, payload);
|
|
442
|
-
successCount++;
|
|
443
|
-
} catch (e) {
|
|
444
|
-
console.warn(`[DiapBridge] Failed to send to ${agent.name}:`, e);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
return successCount;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* 设置自己的频道(用于跨频道消息发送)
|
|
454
|
-
*/
|
|
455
|
-
setOwnChannel(channel: SocialChannel): void {
|
|
456
|
-
this.ownChannel = channel;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
private startDiscoveryLoop(): void {
|
|
460
|
-
this.discoveryTimer = setInterval(async () => {
|
|
461
|
-
if (!this.initialized) return;
|
|
462
|
-
|
|
463
|
-
const persona = this.sessionProvider.getPersona();
|
|
464
|
-
const capabilities = persona?.capabilities || [];
|
|
465
|
-
|
|
466
|
-
if (capabilities.length > 0) {
|
|
467
|
-
await this.discoverAgentsByCapability(capabilities);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// 清理过期的发现
|
|
471
|
-
const now = Date.now();
|
|
472
|
-
for (const [did, agent] of this.discoveredAgents.entries()) {
|
|
473
|
-
if (now - agent.lastSeen > 5 * 60 * 1000) {
|
|
474
|
-
this.discoveredAgents.delete(did);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}, this.config.discoveryInterval);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
private startBroadcastLoop(): void {
|
|
481
|
-
this.broadcastTimer = setInterval(async () => {
|
|
482
|
-
if (!this.initialized || !this.ownChannel) return;
|
|
483
|
-
await this.broadcastChannel(this.ownChannel);
|
|
484
|
-
}, this.config.broadcastInterval);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* 关闭
|
|
489
|
-
*/
|
|
490
|
-
shutdown(): void {
|
|
491
|
-
if (this.discoveryTimer) {
|
|
492
|
-
clearInterval(this.discoveryTimer);
|
|
493
|
-
}
|
|
494
|
-
if (this.broadcastTimer) {
|
|
495
|
-
clearInterval(this.broadcastTimer);
|
|
496
|
-
}
|
|
497
|
-
this.discoveredAgents.clear();
|
|
498
|
-
this.registeredServices.clear();
|
|
499
|
-
console.log('[DiapBridge] Shutdown');
|
|
500
|
-
}
|
|
501
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* InterestMatcher - 兴趣/能力匹配算法
|
|
3
|
-
*
|
|
4
|
-
* 计算智能体与频道的匹配度,用于自动加入决策
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { PersonaDoc } from '../heartbeat.js';
|
|
8
|
-
import type { SocialChannel, ChannelPresence } from './types.js';
|
|
9
|
-
|
|
10
|
-
export class InterestMatcher {
|
|
11
|
-
/**
|
|
12
|
-
* 计算智能体与频道的匹配度 (0-1)
|
|
13
|
-
*/
|
|
14
|
-
calculateMatchScore(
|
|
15
|
-
personaCapabilities: string[],
|
|
16
|
-
personaInterests: string[],
|
|
17
|
-
channelTopic: string,
|
|
18
|
-
channelCapabilities: string[]
|
|
19
|
-
): number {
|
|
20
|
-
let score = 0;
|
|
21
|
-
let weight = 0;
|
|
22
|
-
|
|
23
|
-
// 能力匹配 (权重 0.5)
|
|
24
|
-
if (channelCapabilities.length > 0 && personaCapabilities.length > 0) {
|
|
25
|
-
const capabilityMatch = this.countMatches(personaCapabilities, channelCapabilities);
|
|
26
|
-
const capabilityScore = capabilityMatch / channelCapabilities.length;
|
|
27
|
-
score += capabilityScore * 0.5;
|
|
28
|
-
weight += 0.5;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// 兴趣匹配 (权重 0.3)
|
|
32
|
-
if (channelTopic && (personaInterests.length > 0 || personaCapabilities.length > 0)) {
|
|
33
|
-
const allPersonaTags = [...personaInterests, ...personaCapabilities];
|
|
34
|
-
const topicWords = channelTopic.toLowerCase().split(/[,\s]+/).filter(Boolean);
|
|
35
|
-
const interestMatch = this.countMatches(
|
|
36
|
-
allPersonaTags.map(t => t.toLowerCase()),
|
|
37
|
-
topicWords
|
|
38
|
-
);
|
|
39
|
-
const interestScore = topicWords.length > 0 ? interestMatch / topicWords.length : 0;
|
|
40
|
-
score += interestScore * 0.3;
|
|
41
|
-
weight += 0.3;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 额外能力加分 (权重 0.2)
|
|
45
|
-
if (personaCapabilities.length > 0 && channelCapabilities.length > 0) {
|
|
46
|
-
const extraCapabilities = personaCapabilities.filter(
|
|
47
|
-
cap => !channelCapabilities.some(ch => ch.toLowerCase() === cap.toLowerCase())
|
|
48
|
-
);
|
|
49
|
-
const extraScore = Math.min(extraCapabilities.length * 0.05, 0.2);
|
|
50
|
-
score += extraScore;
|
|
51
|
-
weight += 0.2;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return weight > 0 ? score / (weight / 1) : 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 计算两个数组的匹配数量
|
|
59
|
-
*/
|
|
60
|
-
private countMatches(arr1: string[], arr2: string[]): number {
|
|
61
|
-
let count = 0;
|
|
62
|
-
for (const item1 of arr1) {
|
|
63
|
-
for (const item2 of arr2) {
|
|
64
|
-
if (this.fuzzyMatch(item1, item2)) {
|
|
65
|
-
count++;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return count;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* 模糊匹配 (考虑包含关系)
|
|
75
|
-
*/
|
|
76
|
-
private fuzzyMatch(str1: string, str2: string): boolean {
|
|
77
|
-
const s1 = str1.toLowerCase();
|
|
78
|
-
const s2 = str2.toLowerCase();
|
|
79
|
-
return s1.includes(s2) || s2.includes(s1) || this.levenshteinSimilarity(s1, s2) > 0.7;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Levenshtein 相似度
|
|
84
|
-
*/
|
|
85
|
-
private levenshteinSimilarity(s1: string, s2: string): number {
|
|
86
|
-
if (s1 === s2) return 1;
|
|
87
|
-
if (s1.length === 0 || s2.length === 0) return 0;
|
|
88
|
-
|
|
89
|
-
const matrix: number[][] = [];
|
|
90
|
-
|
|
91
|
-
for (let i = 0; i <= s1.length; i++) {
|
|
92
|
-
matrix[i] = [i];
|
|
93
|
-
}
|
|
94
|
-
for (let j = 0; j <= s2.length; j++) {
|
|
95
|
-
matrix[0][j] = j;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
for (let i = 1; i <= s1.length; i++) {
|
|
99
|
-
for (let j = 1; j <= s2.length; j++) {
|
|
100
|
-
const cost = s1[i - 1] === s2[j - 1] ? 0 : 1;
|
|
101
|
-
matrix[i][j] = Math.min(
|
|
102
|
-
matrix[i - 1][j] + 1,
|
|
103
|
-
matrix[i][j - 1] + 1,
|
|
104
|
-
matrix[i - 1][j - 1] + cost
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const maxLen = Math.max(s1.length, s2.length);
|
|
110
|
-
return 1 - matrix[s1.length][s2.length] / maxLen;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 查找匹配的频道列表
|
|
115
|
-
*/
|
|
116
|
-
findMatchingChannels(
|
|
117
|
-
persona: PersonaDoc | null,
|
|
118
|
-
channels: (SocialChannel | ChannelPresence)[],
|
|
119
|
-
threshold: number = 0.5
|
|
120
|
-
): Array<{ channel: SocialChannel | ChannelPresence; score: number }> {
|
|
121
|
-
const capabilities = persona?.capabilities || [];
|
|
122
|
-
const interests = persona?.interests || [];
|
|
123
|
-
const topic = persona?.interests?.join(', ') || '';
|
|
124
|
-
|
|
125
|
-
const matches: Array<{ channel: SocialChannel | ChannelPresence; score: number }> = [];
|
|
126
|
-
|
|
127
|
-
for (const channel of channels) {
|
|
128
|
-
const channelTopic = 'topic' in channel ? channel.topic : '';
|
|
129
|
-
const channelCapabilities = 'requiredCapabilities' in channel
|
|
130
|
-
? channel.requiredCapabilities
|
|
131
|
-
: 'capabilities' in channel
|
|
132
|
-
? (channel as ChannelPresence).capabilities
|
|
133
|
-
: [];
|
|
134
|
-
|
|
135
|
-
const score = this.calculateMatchScore(
|
|
136
|
-
capabilities,
|
|
137
|
-
interests,
|
|
138
|
-
channelTopic,
|
|
139
|
-
channelCapabilities
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
if (score >= threshold) {
|
|
143
|
-
matches.push({ channel, score });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// 按匹配度排序
|
|
148
|
-
matches.sort((a, b) => b.score - a.score);
|
|
149
|
-
|
|
150
|
-
return matches;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 检查是否应该自动加入频道
|
|
155
|
-
*/
|
|
156
|
-
shouldAutoJoin(
|
|
157
|
-
persona: PersonaDoc | null,
|
|
158
|
-
channel: SocialChannel | ChannelPresence,
|
|
159
|
-
existingChannelIds: string[],
|
|
160
|
-
threshold: number = 0.5
|
|
161
|
-
): boolean {
|
|
162
|
-
const channelId = 'id' in channel ? channel.id : channel.channelId;
|
|
163
|
-
|
|
164
|
-
// 已经加入的频道不再加入
|
|
165
|
-
if (existingChannelIds.includes(channelId)) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const capabilities = persona?.capabilities || [];
|
|
170
|
-
const interests = persona?.interests || [];
|
|
171
|
-
const channelTopic = 'topic' in channel ? channel.topic : '';
|
|
172
|
-
const channelCapabilities = 'requiredCapabilities' in channel
|
|
173
|
-
? channel.requiredCapabilities
|
|
174
|
-
: 'capabilities' in channel
|
|
175
|
-
? (channel as ChannelPresence).capabilities
|
|
176
|
-
: [];
|
|
177
|
-
|
|
178
|
-
const score = this.calculateMatchScore(
|
|
179
|
-
capabilities,
|
|
180
|
-
interests,
|
|
181
|
-
channelTopic,
|
|
182
|
-
channelCapabilities
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
return score >= threshold;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export const interestMatcher = new InterestMatcher();
|