@bolloon/bolloon-agent 0.1.36 → 0.1.38
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/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/lefthook.yml +0 -33
- package/scripts/auto-evolve-loop.ts +0 -481
- package/scripts/build-web.ts +0 -116
- package/scripts/diff-reviewer.ts +0 -159
- 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,454 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON File Adapter for MessageStore
|
|
3
|
-
* 基于 JSON 文件的消息存储实现
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from 'fs/promises';
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
import * as fsSync from 'fs';
|
|
9
|
-
import * as crypto from 'crypto';
|
|
10
|
-
|
|
11
|
-
import type {
|
|
12
|
-
MessageStore,
|
|
13
|
-
StoredMessage,
|
|
14
|
-
OfflineMessage,
|
|
15
|
-
PendingResponse,
|
|
16
|
-
MessageQueryOptions,
|
|
17
|
-
StorageConfig,
|
|
18
|
-
MessageStatus,
|
|
19
|
-
} from '../types';
|
|
20
|
-
|
|
21
|
-
const DEFAULT_CONFIG: Required<StorageConfig> = {
|
|
22
|
-
baseDir: '',
|
|
23
|
-
maxFileSize: 10 * 1024 * 1024, // 10MB
|
|
24
|
-
maxMessagesPerFile: 1000,
|
|
25
|
-
fileNamingStrategy: 'daily',
|
|
26
|
-
maxAge: 30 * 24 * 60 * 60 * 1000, // 30 days
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
interface FileLock {
|
|
30
|
-
release: () => void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class JsonMessageStore implements MessageStore {
|
|
34
|
-
private config: Required<StorageConfig>;
|
|
35
|
-
private initialized: boolean = false;
|
|
36
|
-
private offlineMessages: Map<string, OfflineMessage[]> = new Map();
|
|
37
|
-
private pendingResponses: Map<string, PendingResponse> = new Map();
|
|
38
|
-
private locks: Map<string, Promise<FileLock>> = new Map();
|
|
39
|
-
|
|
40
|
-
constructor(config: StorageConfig) {
|
|
41
|
-
// 设置默认基础路径
|
|
42
|
-
const baseDir = config.baseDir || path.join(process.env.HOME || '/tmp', '.bolloon', 'messages');
|
|
43
|
-
this.config = { ...DEFAULT_CONFIG, ...config, baseDir };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async initialize(): Promise<void> {
|
|
47
|
-
// 创建必要的目录
|
|
48
|
-
await fs.mkdir(this.config.baseDir, { recursive: true });
|
|
49
|
-
await fs.mkdir(path.join(this.config.baseDir, 'offline'), { recursive: true });
|
|
50
|
-
await fs.mkdir(path.join(this.config.baseDir, 'pending'), { recursive: true });
|
|
51
|
-
|
|
52
|
-
// 加载离线消息
|
|
53
|
-
await this.loadOfflineMessages();
|
|
54
|
-
|
|
55
|
-
// 加载待响应请求
|
|
56
|
-
await this.loadPendingResponses();
|
|
57
|
-
|
|
58
|
-
this.initialized = true;
|
|
59
|
-
console.log(`[JsonMessageStore] Initialized at ${this.config.baseDir}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ============================================================================
|
|
63
|
-
// 消息持久化
|
|
64
|
-
// ============================================================================
|
|
65
|
-
|
|
66
|
-
async saveMessage(msg: Omit<StoredMessage, 'id'>): Promise<StoredMessage> {
|
|
67
|
-
const id = crypto.randomUUID();
|
|
68
|
-
const stored: StoredMessage = { ...msg, id };
|
|
69
|
-
const filePath = this.getMessageFilePath(new Date(msg.timestamp));
|
|
70
|
-
|
|
71
|
-
await this.withLock(filePath, async () => {
|
|
72
|
-
let messages = await this.readJsonFile<StoredMessage[]>(filePath) || [];
|
|
73
|
-
messages.push(stored);
|
|
74
|
-
|
|
75
|
-
// 如果文件过大,拆分
|
|
76
|
-
if (messages.length > this.config.maxMessagesPerFile) {
|
|
77
|
-
const newFile = this.getMessageFilePath(new Date(), true);
|
|
78
|
-
await this.writeJsonFile(newFile, messages.slice(this.config.maxMessagesPerFile / 2));
|
|
79
|
-
messages = messages.slice(0, this.config.maxMessagesPerFile / 2);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
await this.writeJsonFile(filePath, messages);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return stored;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async getMessage(id: string): Promise<StoredMessage | null> {
|
|
89
|
-
const allMessages = await this.getAllMessageFiles();
|
|
90
|
-
for (const file of allMessages) {
|
|
91
|
-
const messages = await this.readJsonFile<StoredMessage[]>(file) || [];
|
|
92
|
-
const found = messages.find(m => m.id === id);
|
|
93
|
-
if (found) return found;
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async updateMessageStatus(id: string, status: MessageStatus): Promise<void> {
|
|
99
|
-
const allFiles = await this.getAllMessageFiles();
|
|
100
|
-
for (const file of allFiles) {
|
|
101
|
-
const messages = await this.readJsonFile<StoredMessage[]>(file);
|
|
102
|
-
if (!messages) continue;
|
|
103
|
-
|
|
104
|
-
const idx = messages.findIndex(m => m.id === id);
|
|
105
|
-
if (idx >= 0) {
|
|
106
|
-
messages[idx].status = status;
|
|
107
|
-
await this.writeJsonFile(file, messages);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async getMessages(options?: MessageQueryOptions): Promise<StoredMessage[]> {
|
|
114
|
-
const allMessages: StoredMessage[] = [];
|
|
115
|
-
const files = await this.getAllMessageFiles();
|
|
116
|
-
|
|
117
|
-
for (const file of files) {
|
|
118
|
-
const messages = await this.readJsonFile<StoredMessage[]>(file) || [];
|
|
119
|
-
allMessages.push(...messages);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// 过滤
|
|
123
|
-
let filtered = allMessages;
|
|
124
|
-
|
|
125
|
-
if (options?.direction) {
|
|
126
|
-
filtered = filtered.filter(m => m.direction === options.direction);
|
|
127
|
-
}
|
|
128
|
-
if (options?.type) {
|
|
129
|
-
filtered = filtered.filter(m => m.type === options.type);
|
|
130
|
-
}
|
|
131
|
-
if (options?.from) {
|
|
132
|
-
filtered = filtered.filter(m => m.from === options.from);
|
|
133
|
-
}
|
|
134
|
-
if (options?.to) {
|
|
135
|
-
filtered = filtered.filter(m => m.to === options.to);
|
|
136
|
-
}
|
|
137
|
-
if (options?.startTime) {
|
|
138
|
-
filtered = filtered.filter(m => m.timestamp >= options.startTime!);
|
|
139
|
-
}
|
|
140
|
-
if (options?.endTime) {
|
|
141
|
-
filtered = filtered.filter(m => m.timestamp <= options.endTime!);
|
|
142
|
-
}
|
|
143
|
-
if (options?.status) {
|
|
144
|
-
filtered = filtered.filter(m => m.status === options.status);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// 排序和分页
|
|
148
|
-
filtered.sort((a, b) => b.timestamp - a.timestamp);
|
|
149
|
-
|
|
150
|
-
if (options?.offset) {
|
|
151
|
-
filtered = filtered.slice(options.offset);
|
|
152
|
-
}
|
|
153
|
-
if (options?.limit) {
|
|
154
|
-
filtered = filtered.slice(0, options.limit);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return filtered;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async deleteMessage(id: string): Promise<void> {
|
|
161
|
-
const allFiles = await this.getAllMessageFiles();
|
|
162
|
-
for (const file of allFiles) {
|
|
163
|
-
const messages = await this.readJsonFile<StoredMessage[]>(file);
|
|
164
|
-
if (!messages) continue;
|
|
165
|
-
|
|
166
|
-
const idx = messages.findIndex(m => m.id === id);
|
|
167
|
-
if (idx >= 0) {
|
|
168
|
-
messages.splice(idx, 1);
|
|
169
|
-
await this.writeJsonFile(file, messages);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// ============================================================================
|
|
176
|
-
// 离线消息队列
|
|
177
|
-
// ============================================================================
|
|
178
|
-
|
|
179
|
-
async enqueueOfflineMessage(msg: Omit<OfflineMessage, 'id'>): Promise<OfflineMessage> {
|
|
180
|
-
const id = crypto.randomUUID();
|
|
181
|
-
const offline: OfflineMessage = { ...msg, id };
|
|
182
|
-
|
|
183
|
-
// 更新内存缓存
|
|
184
|
-
const queue = this.offlineMessages.get(msg.targetNodeId) || [];
|
|
185
|
-
queue.push(offline);
|
|
186
|
-
this.offlineMessages.set(msg.targetNodeId, queue);
|
|
187
|
-
|
|
188
|
-
// 持久化到文件
|
|
189
|
-
const filePath = this.getOfflineFilePath(msg.targetNodeId);
|
|
190
|
-
await this.writeJsonFile(filePath, queue);
|
|
191
|
-
|
|
192
|
-
console.log(`[JsonMessageStore] Enqueued offline message for ${msg.targetNodeId}`);
|
|
193
|
-
return offline;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async getOfflineMessages(targetNodeId: string): Promise<OfflineMessage[]> {
|
|
197
|
-
// 优先从内存返回
|
|
198
|
-
if (this.offlineMessages.has(targetNodeId)) {
|
|
199
|
-
return this.offlineMessages.get(targetNodeId)!;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 从文件加载
|
|
203
|
-
const filePath = this.getOfflineFilePath(targetNodeId);
|
|
204
|
-
const messages = await this.readJsonFile<OfflineMessage[]>(filePath) || [];
|
|
205
|
-
this.offlineMessages.set(targetNodeId, messages);
|
|
206
|
-
return messages;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async dequeueOfflineMessage(id: string): Promise<void> {
|
|
210
|
-
for (const [targetId, queue] of this.offlineMessages.entries()) {
|
|
211
|
-
const idx = queue.findIndex(m => m.id === id);
|
|
212
|
-
if (idx >= 0) {
|
|
213
|
-
queue.splice(idx, 1);
|
|
214
|
-
this.offlineMessages.set(targetId, queue);
|
|
215
|
-
await this.writeJsonFile(this.getOfflineFilePath(targetId), queue);
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
async incrementOfflineRetry(id: string): Promise<void> {
|
|
222
|
-
for (const [targetId, queue] of this.offlineMessages.entries()) {
|
|
223
|
-
const idx = queue.findIndex(m => m.id === id);
|
|
224
|
-
if (idx >= 0) {
|
|
225
|
-
queue[idx].retryCount++;
|
|
226
|
-
this.offlineMessages.set(targetId, queue);
|
|
227
|
-
await this.writeJsonFile(this.getOfflineFilePath(targetId), queue);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
async getPendingOfflineCount(): Promise<number> {
|
|
234
|
-
let count = 0;
|
|
235
|
-
for (const queue of this.offlineMessages.values()) {
|
|
236
|
-
count += queue.length;
|
|
237
|
-
}
|
|
238
|
-
return count;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
async getAllOfflineTargets(): Promise<string[]> {
|
|
242
|
-
// 重新从磁盘加载最新状态(避免内存 vs 磁盘不一致)
|
|
243
|
-
const baseDir = path.join(this.config.baseDir, 'offline');
|
|
244
|
-
let files: string[] = [];
|
|
245
|
-
try {
|
|
246
|
-
files = await fs.readdir(baseDir);
|
|
247
|
-
} catch {
|
|
248
|
-
return Array.from(this.offlineMessages.keys());
|
|
249
|
-
}
|
|
250
|
-
return files
|
|
251
|
-
.filter((f) => f.endsWith('.json'))
|
|
252
|
-
.map((f) => f.replace(/\.json$/, ''))
|
|
253
|
-
.filter((id) => id.length > 0);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// ============================================================================
|
|
257
|
-
// 待响应请求
|
|
258
|
-
// ============================================================================
|
|
259
|
-
|
|
260
|
-
async savePendingResponse(req: Omit<PendingResponse, 'id'>): Promise<PendingResponse> {
|
|
261
|
-
const id = crypto.randomUUID();
|
|
262
|
-
const pending: PendingResponse = { ...req, id };
|
|
263
|
-
|
|
264
|
-
this.pendingResponses.set(req.requestId, pending);
|
|
265
|
-
await this.savePendingResponsesToFile();
|
|
266
|
-
|
|
267
|
-
console.log(`[JsonMessageStore] Saved pending response ${req.requestId}`);
|
|
268
|
-
return pending;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
async getPendingResponse(requestId: string): Promise<PendingResponse | null> {
|
|
272
|
-
// 优先从内存返回
|
|
273
|
-
if (this.pendingResponses.has(requestId)) {
|
|
274
|
-
return this.pendingResponses.get(requestId)!;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// 尝试从文件恢复
|
|
278
|
-
await this.loadPendingResponses();
|
|
279
|
-
return this.pendingResponses.get(requestId) || null;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
async removePendingResponse(requestId: string): Promise<void> {
|
|
283
|
-
this.pendingResponses.delete(requestId);
|
|
284
|
-
await this.savePendingResponsesToFile();
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// ============================================================================
|
|
288
|
-
// 统计与清理
|
|
289
|
-
// ============================================================================
|
|
290
|
-
|
|
291
|
-
async getMessageCount(): Promise<number> {
|
|
292
|
-
const files = await this.getAllMessageFiles();
|
|
293
|
-
let count = 0;
|
|
294
|
-
for (const file of files) {
|
|
295
|
-
const messages = await this.readJsonFile<StoredMessage[]>(file);
|
|
296
|
-
if (messages) count += messages.length;
|
|
297
|
-
}
|
|
298
|
-
return count;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
async getOfflineMessageCount(): Promise<number> {
|
|
302
|
-
return this.getPendingOfflineCount();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
async pruneOldMessages(maxAgeMs: number): Promise<number> {
|
|
306
|
-
const cutoff = Date.now() - maxAgeMs;
|
|
307
|
-
let pruned = 0;
|
|
308
|
-
const files = await this.getAllMessageFiles();
|
|
309
|
-
|
|
310
|
-
for (const file of files) {
|
|
311
|
-
const messages = await this.readJsonFile<StoredMessage[]>(file);
|
|
312
|
-
if (!messages) continue;
|
|
313
|
-
|
|
314
|
-
const originalLen = messages.length;
|
|
315
|
-
const filtered = messages.filter(m => m.timestamp >= cutoff || m.status === 'pending');
|
|
316
|
-
|
|
317
|
-
if (filtered.length < originalLen) {
|
|
318
|
-
pruned += originalLen - filtered.length;
|
|
319
|
-
await this.writeJsonFile(file, filtered);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
console.log(`[JsonMessageStore] Pruned ${pruned} old messages`);
|
|
324
|
-
return pruned;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// ============================================================================
|
|
328
|
-
// 生命周期
|
|
329
|
-
// ============================================================================
|
|
330
|
-
|
|
331
|
-
async shutdown(): Promise<void> {
|
|
332
|
-
// 保存所有待处理数据
|
|
333
|
-
await this.savePendingResponsesToFile();
|
|
334
|
-
|
|
335
|
-
for (const [targetId, queue] of this.offlineMessages.entries()) {
|
|
336
|
-
if (queue.length > 0) {
|
|
337
|
-
await this.writeJsonFile(this.getOfflineFilePath(targetId), queue);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
this.initialized = false;
|
|
342
|
-
console.log('[JsonMessageStore] Shutdown complete');
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// ============================================================================
|
|
346
|
-
// 私有辅助方法
|
|
347
|
-
// ============================================================================
|
|
348
|
-
|
|
349
|
-
private getMessageFilePath(date: Date, useNewFile = false): string {
|
|
350
|
-
const dateStr = this.config.fileNamingStrategy === 'daily'
|
|
351
|
-
? date.toISOString().split('T')[0]
|
|
352
|
-
: `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`;
|
|
353
|
-
|
|
354
|
-
const filename = useNewFile
|
|
355
|
-
? `messages-${dateStr}-${Date.now()}.json`
|
|
356
|
-
: `messages-${dateStr}.json`;
|
|
357
|
-
|
|
358
|
-
return path.join(this.config.baseDir, filename);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
private getOfflineFilePath(nodeId: string): string {
|
|
362
|
-
// 清理 nodeId 中的非法字符
|
|
363
|
-
const safeId = nodeId.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
364
|
-
return path.join(this.config.baseDir, 'offline', `${safeId}.json`);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
private getPendingFilePath(): string {
|
|
368
|
-
return path.join(this.config.baseDir, 'pending', 'responses.json');
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
private async getAllMessageFiles(): Promise<string[]> {
|
|
372
|
-
try {
|
|
373
|
-
const files = await fs.readdir(this.config.baseDir);
|
|
374
|
-
return files
|
|
375
|
-
.filter(f => f.startsWith('messages-') && f.endsWith('.json'))
|
|
376
|
-
.map(f => path.join(this.config.baseDir, f));
|
|
377
|
-
} catch {
|
|
378
|
-
return [];
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
private async readJsonFile<T>(filePath: string): Promise<T | null> {
|
|
383
|
-
try {
|
|
384
|
-
const content = await fs.readFile(filePath, 'utf-8');
|
|
385
|
-
return JSON.parse(content) as T;
|
|
386
|
-
} catch {
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
private async writeJsonFile(filePath: string, data: unknown): Promise<void> {
|
|
392
|
-
const dir = path.dirname(filePath);
|
|
393
|
-
await fs.mkdir(dir, { recursive: true });
|
|
394
|
-
await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
private async loadOfflineMessages(): Promise<void> {
|
|
398
|
-
const offlineDir = path.join(this.config.baseDir, 'offline');
|
|
399
|
-
try {
|
|
400
|
-
const files = await fs.readdir(offlineDir);
|
|
401
|
-
for (const file of files) {
|
|
402
|
-
if (!file.endsWith('.json')) continue;
|
|
403
|
-
const nodeId = file.replace('.json', '');
|
|
404
|
-
const messages = await this.readJsonFile<OfflineMessage[]>(path.join(offlineDir, file));
|
|
405
|
-
if (messages) {
|
|
406
|
-
this.offlineMessages.set(nodeId, messages);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
} catch {
|
|
410
|
-
// 目录不存在或为空
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
private async loadPendingResponses(): Promise<void> {
|
|
415
|
-
const filePath = this.getPendingFilePath();
|
|
416
|
-
const data = await this.readJsonFile<PendingResponse[]>(filePath);
|
|
417
|
-
if (data) {
|
|
418
|
-
for (const req of data) {
|
|
419
|
-
this.pendingResponses.set(req.requestId, req);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
private async savePendingResponsesToFile(): Promise<void> {
|
|
425
|
-
const data = Array.from(this.pendingResponses.values());
|
|
426
|
-
await this.writeJsonFile(this.getPendingFilePath(), data);
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
private async withLock<T>(filePath: string, fn: () => Promise<T>): Promise<T> {
|
|
430
|
-
// 简化的文件锁实现
|
|
431
|
-
const lockKey = filePath;
|
|
432
|
-
|
|
433
|
-
// 等待现有锁
|
|
434
|
-
while (this.locks.has(lockKey)) {
|
|
435
|
-
await this.locks.get(lockKey);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// 获取新锁
|
|
439
|
-
let releaseLock: () => void;
|
|
440
|
-
const lockPromise = new Promise<FileLock>((resolve) => {
|
|
441
|
-
releaseLock = () => {
|
|
442
|
-
this.locks.delete(lockKey);
|
|
443
|
-
resolve({ release: () => {} });
|
|
444
|
-
};
|
|
445
|
-
});
|
|
446
|
-
this.locks.set(lockKey, lockPromise);
|
|
447
|
-
|
|
448
|
-
try {
|
|
449
|
-
return await fn();
|
|
450
|
-
} finally {
|
|
451
|
-
releaseLock!();
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Storage Layer Entry Point
|
|
3
|
-
* 导出消息存储工厂函数和类型
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
MessageStore,
|
|
8
|
-
StoredMessage,
|
|
9
|
-
OfflineMessage,
|
|
10
|
-
PendingResponse,
|
|
11
|
-
LocalPendingRequest,
|
|
12
|
-
MessageQueryOptions,
|
|
13
|
-
StorageConfig,
|
|
14
|
-
MessageDirection,
|
|
15
|
-
MessageStatus,
|
|
16
|
-
TransportType,
|
|
17
|
-
IrohPeer,
|
|
18
|
-
IrohMessage,
|
|
19
|
-
IrohMessageHandler,
|
|
20
|
-
} from './types.js';
|
|
21
|
-
import { DEFAULT_STORAGE_CONFIG } from './types.js';
|
|
22
|
-
|
|
23
|
-
export type {
|
|
24
|
-
MessageStore,
|
|
25
|
-
StoredMessage,
|
|
26
|
-
OfflineMessage,
|
|
27
|
-
PendingResponse,
|
|
28
|
-
LocalPendingRequest,
|
|
29
|
-
MessageQueryOptions,
|
|
30
|
-
StorageConfig,
|
|
31
|
-
MessageDirection,
|
|
32
|
-
MessageStatus,
|
|
33
|
-
TransportType,
|
|
34
|
-
IrohPeer,
|
|
35
|
-
IrohMessage,
|
|
36
|
-
IrohMessageHandler,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { DEFAULT_STORAGE_CONFIG };
|
|
40
|
-
|
|
41
|
-
import { JsonMessageStore } from './adapters/json-adapter.js';
|
|
42
|
-
import * as path from 'path';
|
|
43
|
-
|
|
44
|
-
// 默认存储配置
|
|
45
|
-
const DEFAULT_BASE_DIR = path.join(
|
|
46
|
-
process.env.HOME || '/tmp',
|
|
47
|
-
'.bolloon',
|
|
48
|
-
'messages'
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 创建消息存储实例
|
|
53
|
-
* @param transport 传输类型 ('iroh' | 'libp2p')
|
|
54
|
-
* @param config 存储配置
|
|
55
|
-
* @returns MessageStore 实例
|
|
56
|
-
*/
|
|
57
|
-
export async function createMessageStore(
|
|
58
|
-
transport: 'iroh' | 'libp2p' = 'libp2p',
|
|
59
|
-
config?: Partial<StorageConfig>
|
|
60
|
-
): Promise<MessageStore> {
|
|
61
|
-
const fullConfig: StorageConfig = {
|
|
62
|
-
baseDir: config?.baseDir || DEFAULT_BASE_DIR,
|
|
63
|
-
maxFileSize: config?.maxFileSize || 10 * 1024 * 1024,
|
|
64
|
-
maxMessagesPerFile: config?.maxMessagesPerFile || 1000,
|
|
65
|
-
fileNamingStrategy: config?.fileNamingStrategy || 'daily',
|
|
66
|
-
maxAge: config?.maxAge || 30 * 24 * 60 * 60 * 1000,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const store = new JsonMessageStore(fullConfig);
|
|
70
|
-
await store.initialize();
|
|
71
|
-
|
|
72
|
-
console.log(`[Storage] Created ${transport} message store at ${fullConfig.baseDir}`);
|
|
73
|
-
return store;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 创建离线消息存储(无持久化,仅内存)
|
|
78
|
-
* 用于不需要消息历史的轻量级场景
|
|
79
|
-
*/
|
|
80
|
-
export function createInMemoryStore(): MessageStore {
|
|
81
|
-
const messages: Map<string, StoredMessage> = new Map();
|
|
82
|
-
const offlineQueues: Map<string, OfflineMessage[]> = new Map();
|
|
83
|
-
const pendingResponses: Map<string, PendingResponse> = new Map();
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
async saveMessage(msg) {
|
|
87
|
-
const id = crypto.randomUUID();
|
|
88
|
-
const stored = { ...msg, id };
|
|
89
|
-
messages.set(id, stored);
|
|
90
|
-
return stored;
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
async getMessage(id) {
|
|
94
|
-
return messages.get(id) || null;
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
async updateMessageStatus(id, status) {
|
|
98
|
-
const msg = messages.get(id);
|
|
99
|
-
if (msg) {
|
|
100
|
-
msg.status = status;
|
|
101
|
-
messages.set(id, msg);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
async getMessages(options) {
|
|
106
|
-
let result = Array.from(messages.values());
|
|
107
|
-
if (options?.direction) result = result.filter(m => m.direction === options.direction);
|
|
108
|
-
if (options?.type) result = result.filter(m => m.type === options.type);
|
|
109
|
-
if (options?.from) result = result.filter(m => m.from === options.from);
|
|
110
|
-
if (options?.to) result = result.filter(m => m.to === options.to);
|
|
111
|
-
if (options?.startTime) result = result.filter(m => m.timestamp >= options.startTime!);
|
|
112
|
-
if (options?.endTime) result = result.filter(m => m.timestamp <= options.endTime!);
|
|
113
|
-
if (options?.status) result = result.filter(m => m.status === options.status);
|
|
114
|
-
result.sort((a, b) => b.timestamp - a.timestamp);
|
|
115
|
-
if (options?.offset) result = result.slice(options.offset);
|
|
116
|
-
if (options?.limit) result = result.slice(0, options.limit);
|
|
117
|
-
return result;
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
async deleteMessage(id) {
|
|
121
|
-
messages.delete(id);
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
async enqueueOfflineMessage(msg) {
|
|
125
|
-
const id = crypto.randomUUID();
|
|
126
|
-
const offline = { ...msg, id };
|
|
127
|
-
const queue = offlineQueues.get(msg.targetNodeId) || [];
|
|
128
|
-
queue.push(offline);
|
|
129
|
-
offlineQueues.set(msg.targetNodeId, queue);
|
|
130
|
-
return offline;
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
async getOfflineMessages(targetNodeId) {
|
|
134
|
-
return offlineQueues.get(targetNodeId) || [];
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
async dequeueOfflineMessage(id) {
|
|
138
|
-
for (const [nodeId, queue] of offlineQueues.entries()) {
|
|
139
|
-
const idx = queue.findIndex(m => m.id === id);
|
|
140
|
-
if (idx >= 0) {
|
|
141
|
-
queue.splice(idx, 1);
|
|
142
|
-
offlineQueues.set(nodeId, queue);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
async incrementOfflineRetry(id) {
|
|
149
|
-
for (const queue of offlineQueues.values()) {
|
|
150
|
-
const msg = queue.find(m => m.id === id);
|
|
151
|
-
if (msg) {
|
|
152
|
-
msg.retryCount++;
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
async getPendingOfflineCount() {
|
|
159
|
-
let count = 0;
|
|
160
|
-
for (const queue of offlineQueues.values()) {
|
|
161
|
-
count += queue.length;
|
|
162
|
-
}
|
|
163
|
-
return count;
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
async savePendingResponse(req) {
|
|
167
|
-
const id = crypto.randomUUID();
|
|
168
|
-
const pending = { ...req, id };
|
|
169
|
-
pendingResponses.set(req.requestId, pending);
|
|
170
|
-
return pending;
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
async getPendingResponse(requestId) {
|
|
174
|
-
return pendingResponses.get(requestId) || null;
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
async removePendingResponse(requestId) {
|
|
178
|
-
pendingResponses.delete(requestId);
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
async getMessageCount() {
|
|
182
|
-
return messages.size;
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
async getOfflineMessageCount() {
|
|
186
|
-
return this.getPendingOfflineCount();
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
async pruneOldMessages() {
|
|
190
|
-
return 0;
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
async initialize() {},
|
|
194
|
-
async shutdown() {
|
|
195
|
-
messages.clear();
|
|
196
|
-
offlineQueues.clear();
|
|
197
|
-
pendingResponses.clear();
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// 导入 crypto 用于内存存储的 ID 生成
|
|
203
|
-
import * as crypto from 'crypto';
|