@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,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Compaction — 类型定义
|
|
3
|
-
*
|
|
4
|
-
* 严格对齐 Claude Code 论文 5 层压缩流水线:
|
|
5
|
-
* 1. Budget Reduction (单条消息大小限制)
|
|
6
|
-
* 2. Snip (裁掉老历史, feature flag 关闭)
|
|
7
|
-
* 3. Microcompact (cache-aware 细粒度压缩, 老 tool_result 折叠)
|
|
8
|
-
* 4. Context Collapse (读时虚拟投影, 非破坏)
|
|
9
|
-
* 5. Auto-Compact (LLM 摘要, 兜底)
|
|
10
|
-
*
|
|
11
|
-
* 关键不变量:
|
|
12
|
-
* - 第 1-3 层不破坏 messageHistory 内存结构, 只改 buildContext 输出
|
|
13
|
-
* - 第 4 层读时投影, 绝不改 messageHistory
|
|
14
|
-
* - 第 5 层破坏 messageHistory, 把 N 对折叠成 1 条 summary
|
|
15
|
-
*
|
|
16
|
-
* 类型设计: Message 在本模块内独立定义, 靠 structural typing 与 pi-sdk.ts 的 Message 兼容.
|
|
17
|
-
* 不 import pi-sdk 避免循环依赖.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export type Role = 'user' | 'assistant' | 'tool' | 'system';
|
|
21
|
-
|
|
22
|
-
export interface Message {
|
|
23
|
-
role: Role;
|
|
24
|
-
content: string;
|
|
25
|
-
toolCall?: { name: string; args: Record<string, unknown> };
|
|
26
|
-
toolResult?: unknown;
|
|
27
|
-
toolName?: string;
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// ============================================================
|
|
32
|
-
// 5 层 stage 共享的输入输出
|
|
33
|
-
// ============================================================
|
|
34
|
-
|
|
35
|
-
export interface StageOptions {
|
|
36
|
-
/** Token 预算 (默认 8000) */
|
|
37
|
-
maxTokens?: number;
|
|
38
|
-
/** 跳过本层 (per-stage 开关) */
|
|
39
|
-
skip?: boolean;
|
|
40
|
-
/** Snip 专用: 保留最近多少对 (默认 20) */
|
|
41
|
-
snipKeepPairs?: number;
|
|
42
|
-
/** Budget Reduction 专用: 单条消息上限 (默认 4000 字符) */
|
|
43
|
-
budgetReduceMaxChars?: number;
|
|
44
|
-
/** Microcompact 专用: 保留最近多少条完整 tool_result (默认 3) */
|
|
45
|
-
microcompactKeepRecent?: number;
|
|
46
|
-
/** Context Collapse 专用: 折叠前多少对 (默认 5) */
|
|
47
|
-
contextCollapseCollapsePairs?: number;
|
|
48
|
-
/** Auto-Compact 专用: 摘要前多少对 (默认 5) */
|
|
49
|
-
autoCompactCollapsePairs?: number;
|
|
50
|
-
/** Auto-Compact 专用: 注入 LLM 调用 (用于生成摘要) */
|
|
51
|
-
llmChat?: (systemPrompt: string, userPrompt: string, signal?: AbortSignal) => Promise<string>;
|
|
52
|
-
/** Auto-Compact 专用: 缓存 key 后缀 (通常 = channelId) */
|
|
53
|
-
cacheScope?: string;
|
|
54
|
-
/** Context Collapse 专用: 注入 LLM (虚拟投影需要 summary 文本) */
|
|
55
|
-
collapseLlmChat?: (systemPrompt: string, userPrompt: string) => Promise<string>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface CompactionContext {
|
|
59
|
-
/** 输入: 原始 history */
|
|
60
|
-
inputHistory: Message[];
|
|
61
|
-
/** 当前已压缩的 history (经过前面 stage) */
|
|
62
|
-
history: Message[];
|
|
63
|
-
/** 估算的 token 数 */
|
|
64
|
-
estimatedTokens: number;
|
|
65
|
-
/** 选项 */
|
|
66
|
-
opts: StageOptions;
|
|
67
|
-
/** Pipeline 元数据, 记录每层做了什么 */
|
|
68
|
-
stages: Array<{ stage: string; applied: boolean; before: number; after: number; detail?: string }>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface StageResult {
|
|
72
|
-
/** 压缩后的 history */
|
|
73
|
-
history: Message[];
|
|
74
|
-
/** 该 stage 是否做了改动 */
|
|
75
|
-
applied: boolean;
|
|
76
|
-
/** 详情 (供 audit / debug) */
|
|
77
|
-
detail?: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// ============================================================
|
|
81
|
-
// Budget Gate
|
|
82
|
-
// ============================================================
|
|
83
|
-
|
|
84
|
-
export interface BudgetReport {
|
|
85
|
-
fit: boolean;
|
|
86
|
-
estimatedTokens: number;
|
|
87
|
-
/** 占用比例 0-1 */
|
|
88
|
-
ratio: number;
|
|
89
|
-
/** 触发了哪一层 (>=0.8 = next layer, >1 = all layers) */
|
|
90
|
-
triggerNextLayer: boolean;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface PipelineResult {
|
|
94
|
-
history: Message[];
|
|
95
|
-
estimatedTokens: number;
|
|
96
|
-
stages: CompactionContext['stages'];
|
|
97
|
-
/** 是否至少跑了一层 */
|
|
98
|
-
compacted: boolean;
|
|
99
|
-
}
|
package/src/documents/reader.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs/promises';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import pdfParse from 'pdf-parse';
|
|
4
|
-
import mammoth from 'mammoth';
|
|
5
|
-
|
|
6
|
-
export interface DocumentContent {
|
|
7
|
-
text: string;
|
|
8
|
-
metadata: {
|
|
9
|
-
filename: string;
|
|
10
|
-
size: number;
|
|
11
|
-
type: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class DocumentReader {
|
|
16
|
-
async read(filePath: string): Promise<DocumentContent> {
|
|
17
|
-
const stats = await fs.stat(filePath);
|
|
18
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
19
|
-
const filename = path.basename(filePath);
|
|
20
|
-
|
|
21
|
-
let text: string;
|
|
22
|
-
|
|
23
|
-
switch (ext) {
|
|
24
|
-
case '.txt':
|
|
25
|
-
case '.md':
|
|
26
|
-
case '.html':
|
|
27
|
-
case '.htm':
|
|
28
|
-
case '.yaml':
|
|
29
|
-
case '.yml':
|
|
30
|
-
case '.json':
|
|
31
|
-
text = await fs.readFile(filePath, 'utf-8');
|
|
32
|
-
break;
|
|
33
|
-
case '.pdf':
|
|
34
|
-
text = await this.readPdf(filePath);
|
|
35
|
-
break;
|
|
36
|
-
case '.docx':
|
|
37
|
-
text = await this.readDocx(filePath);
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
throw new Error(`Unsupported file type: ${ext}`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
text,
|
|
45
|
-
metadata: {
|
|
46
|
-
filename,
|
|
47
|
-
size: stats.size,
|
|
48
|
-
type: ext
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private async readPdf(filePath: string): Promise<string> {
|
|
54
|
-
const dataBuffer = await fs.readFile(filePath);
|
|
55
|
-
// @ts-ignore - pdf-parse v2 API differs
|
|
56
|
-
const data = await pdfParse(dataBuffer);
|
|
57
|
-
return data.text;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private async readDocx(filePath: string): Promise<string> {
|
|
61
|
-
const result = await mammoth.extractRawText({ path: filePath });
|
|
62
|
-
return result.value;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
chunk(text: string, maxChunkSize: number = 4000): string[] {
|
|
66
|
-
const chunks: string[] = [];
|
|
67
|
-
let current = '';
|
|
68
|
-
|
|
69
|
-
const sentences = text.split(/(?<=[.!?。!?])\s+/);
|
|
70
|
-
|
|
71
|
-
for (const sentence of sentences) {
|
|
72
|
-
if ((current + sentence).length <= maxChunkSize) {
|
|
73
|
-
current += (current ? ' ' : '') + sentence;
|
|
74
|
-
} else {
|
|
75
|
-
if (current) chunks.push(current);
|
|
76
|
-
current = sentence;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (current) chunks.push(current);
|
|
81
|
-
return chunks;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const documentReader = new DocumentReader();
|
package/src/documents/store.ts
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Document Store - P2P Document Receiving and Storage
|
|
3
|
-
* 接收并存储来自其他 iroh 节点的文档
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from 'fs/promises';
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
import * as crypto from 'crypto';
|
|
9
|
-
|
|
10
|
-
export interface DocumentChunk {
|
|
11
|
-
docId: string;
|
|
12
|
-
fileName: string;
|
|
13
|
-
fileSize: number;
|
|
14
|
-
mimeType: string;
|
|
15
|
-
chunkIndex: number;
|
|
16
|
-
totalChunks: number;
|
|
17
|
-
content: string; // Base64 encoded
|
|
18
|
-
fromNodeId: string;
|
|
19
|
-
message?: string;
|
|
20
|
-
timestamp: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface ReceivedDocument {
|
|
24
|
-
id: string;
|
|
25
|
-
fileName: string;
|
|
26
|
-
fileSize: number;
|
|
27
|
-
mimeType: string;
|
|
28
|
-
fromNodeId: string;
|
|
29
|
-
fromNodeIdShort: string;
|
|
30
|
-
receivedAt: number;
|
|
31
|
-
message?: string;
|
|
32
|
-
path: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type DocumentReceivedCallback = (doc: ReceivedDocument) => void;
|
|
36
|
-
|
|
37
|
-
interface PendingDocument {
|
|
38
|
-
docId: string;
|
|
39
|
-
fileName: string;
|
|
40
|
-
fileSize: number;
|
|
41
|
-
mimeType: string;
|
|
42
|
-
totalChunks: number;
|
|
43
|
-
receivedChunks: Map<number, string>; // chunkIndex -> Base64 content
|
|
44
|
-
fromNodeId: string;
|
|
45
|
-
message?: string;
|
|
46
|
-
timestamp: number;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class DocumentStore {
|
|
50
|
-
private baseDir: string;
|
|
51
|
-
private pendingDocs: Map<string, PendingDocument> = new Map();
|
|
52
|
-
private receivedCallback: DocumentReceivedCallback | null = null;
|
|
53
|
-
|
|
54
|
-
constructor(baseDir?: string) {
|
|
55
|
-
this.baseDir = baseDir || path.join(process.env.HOME || '/tmp', '.bolloon', 'documents', 'received');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async initialize(): Promise<void> {
|
|
59
|
-
await fs.mkdir(this.baseDir, { recursive: true });
|
|
60
|
-
await fs.mkdir(path.join(this.baseDir, 'chunks'), { recursive: true });
|
|
61
|
-
console.log('[DocumentStore] Initialized at', this.baseDir);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
onDocumentReceived(callback: DocumentReceivedCallback): void {
|
|
65
|
-
this.receivedCallback = callback;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async receiveChunk(chunk: DocumentChunk): Promise<ReceivedDocument | null> {
|
|
69
|
-
const { docId, chunkIndex, totalChunks, fileName, fileSize, mimeType, content, fromNodeId, message, timestamp } = chunk;
|
|
70
|
-
|
|
71
|
-
// 获取或创建 pending document
|
|
72
|
-
let pending = this.pendingDocs.get(docId);
|
|
73
|
-
if (!pending) {
|
|
74
|
-
pending = {
|
|
75
|
-
docId,
|
|
76
|
-
fileName,
|
|
77
|
-
fileSize,
|
|
78
|
-
mimeType,
|
|
79
|
-
totalChunks,
|
|
80
|
-
receivedChunks: new Map(),
|
|
81
|
-
fromNodeId,
|
|
82
|
-
message,
|
|
83
|
-
timestamp,
|
|
84
|
-
};
|
|
85
|
-
this.pendingDocs.set(docId, pending);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// 存储分块
|
|
89
|
-
pending.receivedChunks.set(chunkIndex, content);
|
|
90
|
-
|
|
91
|
-
// 检查是否收齐
|
|
92
|
-
if (pending.receivedChunks.size >= totalChunks) {
|
|
93
|
-
return this.assembleDocument(docId);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private async assembleDocument(docId: string): Promise<ReceivedDocument | null> {
|
|
100
|
-
const pending = this.pendingDocs.get(docId);
|
|
101
|
-
if (!pending) return null;
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
// 按顺序合并所有分块
|
|
105
|
-
const allContent: number[] = [];
|
|
106
|
-
for (let i = 0; i < pending.totalChunks; i++) {
|
|
107
|
-
const chunkContent = pending.receivedChunks.get(i);
|
|
108
|
-
if (!chunkContent) {
|
|
109
|
-
console.warn(`[DocumentStore] Missing chunk ${i} for doc ${docId}`);
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
const bytes = Uint8Array.from(atob(chunkContent), c => c.charCodeAt(0));
|
|
113
|
-
allContent.push(...Array.from(bytes));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// 创建文档目录
|
|
117
|
-
const docDir = path.join(this.baseDir, docId);
|
|
118
|
-
await fs.mkdir(docDir, { recursive: true });
|
|
119
|
-
|
|
120
|
-
// 保存文件
|
|
121
|
-
const filePath = path.join(docDir, pending.fileName);
|
|
122
|
-
await fs.writeFile(filePath, Buffer.from(allContent));
|
|
123
|
-
|
|
124
|
-
// 保存 manifest
|
|
125
|
-
const manifest = {
|
|
126
|
-
id: docId,
|
|
127
|
-
fileName: pending.fileName,
|
|
128
|
-
fileSize: pending.fileSize,
|
|
129
|
-
mimeType: pending.mimeType,
|
|
130
|
-
fromNodeId: pending.fromNodeId,
|
|
131
|
-
receivedAt: Date.now(),
|
|
132
|
-
message: pending.message,
|
|
133
|
-
};
|
|
134
|
-
await fs.writeFile(path.join(docDir, 'manifest.json'), JSON.stringify(manifest, null, 2));
|
|
135
|
-
|
|
136
|
-
// 更新索引
|
|
137
|
-
await this.updateIndex(manifest);
|
|
138
|
-
|
|
139
|
-
// 清理 pending
|
|
140
|
-
this.pendingDocs.delete(docId);
|
|
141
|
-
|
|
142
|
-
const receivedDoc: ReceivedDocument = {
|
|
143
|
-
...manifest,
|
|
144
|
-
fromNodeIdShort: pending.fromNodeId.substring(0, 16) + '...',
|
|
145
|
-
path: filePath,
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
// 触发回调
|
|
149
|
-
if (this.receivedCallback) {
|
|
150
|
-
this.receivedCallback(receivedDoc);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
console.log(`[DocumentStore] Document assembled: ${pending.fileName} (${pending.fileSize} bytes)`);
|
|
154
|
-
return receivedDoc;
|
|
155
|
-
} catch (e) {
|
|
156
|
-
console.error('[DocumentStore] Failed to assemble document:', e);
|
|
157
|
-
this.pendingDocs.delete(docId);
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private async updateIndex(manifest: any): Promise<void> {
|
|
163
|
-
const indexPath = path.join(this.baseDir, 'index.json');
|
|
164
|
-
let index: any[] = [];
|
|
165
|
-
|
|
166
|
-
try {
|
|
167
|
-
const existing = await fs.readFile(indexPath, 'utf-8');
|
|
168
|
-
index = JSON.parse(existing);
|
|
169
|
-
} catch {
|
|
170
|
-
// Index doesn't exist yet
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// 添加新文档
|
|
174
|
-
index.unshift(manifest); // newest first
|
|
175
|
-
|
|
176
|
-
// 只保留最近 100 条
|
|
177
|
-
if (index.length > 100) {
|
|
178
|
-
index = index.slice(0, 100);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
await fs.writeFile(indexPath, JSON.stringify(index, null, 2));
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
async getReceivedDocuments(limit: number = 50, senderPeerId?: string): Promise<ReceivedDocument[]> {
|
|
185
|
-
const indexPath = path.join(this.baseDir, 'index.json');
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
const data = await fs.readFile(indexPath, 'utf-8');
|
|
189
|
-
let docs: any[] = JSON.parse(data);
|
|
190
|
-
|
|
191
|
-
if (senderPeerId) {
|
|
192
|
-
docs = docs.filter(d => d.fromNodeId === senderPeerId);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return docs.slice(0, limit).map(doc => ({
|
|
196
|
-
...doc,
|
|
197
|
-
fromNodeIdShort: doc.fromNodeId.substring(0, 16) + '...',
|
|
198
|
-
path: path.join(this.baseDir, doc.id, doc.fileName),
|
|
199
|
-
}));
|
|
200
|
-
} catch {
|
|
201
|
-
return [];
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
async readDocument(docId: string): Promise<{ content: string; metadata: ReceivedDocument } | null> {
|
|
206
|
-
const docDir = path.join(this.baseDir, docId);
|
|
207
|
-
const manifestPath = path.join(docDir, 'manifest.json');
|
|
208
|
-
|
|
209
|
-
try {
|
|
210
|
-
const manifestData = await fs.readFile(manifestPath, 'utf-8');
|
|
211
|
-
const manifest = JSON.parse(manifestData);
|
|
212
|
-
const filePath = path.join(docDir, manifest.fileName);
|
|
213
|
-
const fileContent = await fs.readFile(filePath, 'utf-8');
|
|
214
|
-
|
|
215
|
-
return {
|
|
216
|
-
content: fileContent,
|
|
217
|
-
metadata: {
|
|
218
|
-
...manifest,
|
|
219
|
-
fromNodeIdShort: manifest.fromNodeId.substring(0, 16) + '...',
|
|
220
|
-
path: filePath,
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
} catch {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
async deleteDocument(docId: string): Promise<boolean> {
|
|
229
|
-
const docDir = path.join(this.baseDir, docId);
|
|
230
|
-
|
|
231
|
-
try {
|
|
232
|
-
await fs.rm(docDir, { recursive: true });
|
|
233
|
-
|
|
234
|
-
// 更新索引
|
|
235
|
-
const indexPath = path.join(this.baseDir, 'index.json');
|
|
236
|
-
try {
|
|
237
|
-
const data = await fs.readFile(indexPath, 'utf-8');
|
|
238
|
-
let index: any[] = JSON.parse(data);
|
|
239
|
-
index = index.filter(d => d.id !== docId);
|
|
240
|
-
await fs.writeFile(indexPath, JSON.stringify(index, null, 2));
|
|
241
|
-
} catch {
|
|
242
|
-
// Index doesn't exist
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return true;
|
|
246
|
-
} catch {
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export const documentStore = new DocumentStore();
|
package/src/electron-preload.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Electron Preload 脚本
|
|
3
|
-
* 在渲染进程和主进程之间建立安全的通信桥梁
|
|
4
|
-
*/
|
|
5
|
-
import { contextBridge, ipcRenderer } from 'electron';
|
|
6
|
-
|
|
7
|
-
// 暴露给渲染进程的 API
|
|
8
|
-
contextBridge.exposeInMainWorld('electronAPI', {
|
|
9
|
-
getVersion: () => ipcRenderer.invoke('get-version'),
|
|
10
|
-
getUserDataPath: () => ipcRenderer.invoke('get-user-data-path'),
|
|
11
|
-
openExternal: (url: string) => ipcRenderer.invoke('open-external', url),
|
|
12
|
-
platform: process.platform,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
// 类型声明
|
|
16
|
-
declare global {
|
|
17
|
-
interface Window {
|
|
18
|
-
electronAPI: {
|
|
19
|
-
getVersion: () => Promise<string>;
|
|
20
|
-
getUserDataPath: () => Promise<string>;
|
|
21
|
-
openExternal: (url: string) => Promise<void>;
|
|
22
|
-
platform: string;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
package/src/electron.ts
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Electron 主进程入口
|
|
3
|
-
*/
|
|
4
|
-
import { app, BrowserWindow, ipcMain, shell } from 'electron';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import * as fs from 'fs';
|
|
7
|
-
import { spawn, ChildProcess } from 'child_process';
|
|
8
|
-
|
|
9
|
-
const isDev = process.env.NODE_ENV === 'development' || !app.isPackaged;
|
|
10
|
-
|
|
11
|
-
// 日志文件路径
|
|
12
|
-
const userDataPath = app.getPath('userData');
|
|
13
|
-
const logPath = path.join(userDataPath, 'bolloon.log');
|
|
14
|
-
|
|
15
|
-
function log(msg: string) {
|
|
16
|
-
const ts = new Date().toISOString();
|
|
17
|
-
const line = `[${ts}] ${msg}\n`;
|
|
18
|
-
fs.appendFileSync(logPath, line);
|
|
19
|
-
console.log(msg);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
log('Bolloon Electron 启动');
|
|
23
|
-
|
|
24
|
-
// 全局窗口引用
|
|
25
|
-
let mainWindow: BrowserWindow | null = null;
|
|
26
|
-
let webServerProcess: ChildProcess | null = null;
|
|
27
|
-
|
|
28
|
-
// 防止多个实例
|
|
29
|
-
const gotTheLock = app.requestSingleInstanceLock();
|
|
30
|
-
if (!gotTheLock) {
|
|
31
|
-
log('已有实例在运行,退出');
|
|
32
|
-
app.quit();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
app.on('second-instance', () => {
|
|
36
|
-
if (mainWindow) {
|
|
37
|
-
if (mainWindow.isMinimized()) mainWindow.restore();
|
|
38
|
-
mainWindow.focus();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
function startWebServer(port: number): Promise<void> {
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
const serverScript = path.join(__dirname, 'web', 'server.js');
|
|
45
|
-
log(`启动 Web 服务器进程: ${serverScript}`);
|
|
46
|
-
|
|
47
|
-
webServerProcess = spawn(process.execPath, [serverScript], {
|
|
48
|
-
env: {
|
|
49
|
-
...process.env,
|
|
50
|
-
NODE_ENV: 'production',
|
|
51
|
-
PORT: String(port),
|
|
52
|
-
ELECTRON_PORT: String(port),
|
|
53
|
-
},
|
|
54
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
let stdoutData = '';
|
|
58
|
-
let stderrData = '';
|
|
59
|
-
|
|
60
|
-
webServerProcess.stdout?.on('data', (data: Buffer) => {
|
|
61
|
-
stdoutData += data.toString();
|
|
62
|
-
process.stdout.write(`[WebServer] ${data}`);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
webServerProcess.stderr?.on('data', (data: Buffer) => {
|
|
66
|
-
stderrData += data.toString();
|
|
67
|
-
process.stderr.write(`[WebServer ERR] ${data}`);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
webServerProcess.on('error', (err) => {
|
|
71
|
-
log(`Web 服务器进程启动失败: ${err}`);
|
|
72
|
-
reject(err);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
webServerProcess.on('exit', (code, signal) => {
|
|
76
|
-
log(`Web 服务器进程退出: code=${code} signal=${signal}`);
|
|
77
|
-
if (code !== 0 && code !== null) {
|
|
78
|
-
log(`Web 服务器 stderr: ${stderrData}`);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// 等待服务器就绪 - 检查 stdout 中的标记
|
|
83
|
-
const checkReady = setInterval(() => {
|
|
84
|
-
if (stdoutData.includes('服务器已监听') || stdoutData.includes('Web 服务器启动完成')) {
|
|
85
|
-
clearInterval(checkReady);
|
|
86
|
-
log('Web 服务器进程已就绪');
|
|
87
|
-
resolve();
|
|
88
|
-
}
|
|
89
|
-
}, 200);
|
|
90
|
-
|
|
91
|
-
// 超时
|
|
92
|
-
setTimeout(() => {
|
|
93
|
-
clearInterval(checkReady);
|
|
94
|
-
if (webServerProcess?.killed === false) {
|
|
95
|
-
log('Web 服务器启动超时');
|
|
96
|
-
reject(new Error('Web server startup timeout'));
|
|
97
|
-
}
|
|
98
|
-
}, 15000);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async function createWindow() {
|
|
103
|
-
log('创建主窗口...');
|
|
104
|
-
|
|
105
|
-
const width = 1200;
|
|
106
|
-
const height = 800;
|
|
107
|
-
const minWidth = 800;
|
|
108
|
-
const minHeight = 600;
|
|
109
|
-
|
|
110
|
-
mainWindow = new BrowserWindow({
|
|
111
|
-
width,
|
|
112
|
-
height,
|
|
113
|
-
minWidth,
|
|
114
|
-
minHeight,
|
|
115
|
-
title: 'Bolloon Agent',
|
|
116
|
-
webPreferences: {
|
|
117
|
-
nodeIntegration: false,
|
|
118
|
-
contextIsolation: true,
|
|
119
|
-
sandbox: false,
|
|
120
|
-
},
|
|
121
|
-
show: false,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const port = parseInt(process.env.ELECTRON_PORT || '54188');
|
|
125
|
-
|
|
126
|
-
if (isDev) {
|
|
127
|
-
mainWindow.loadURL(`http://localhost:${port}`);
|
|
128
|
-
mainWindow.webContents.openDevTools();
|
|
129
|
-
} else {
|
|
130
|
-
try {
|
|
131
|
-
log(`启动内置 Web 服务器...`);
|
|
132
|
-
await startWebServer(port);
|
|
133
|
-
mainWindow.loadURL(`http://localhost:${port}`);
|
|
134
|
-
} catch (err) {
|
|
135
|
-
log(`启动服务器失败: ${err}`);
|
|
136
|
-
console.error('启动服务器失败:', err);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
mainWindow.once('ready-to-show', () => {
|
|
141
|
-
mainWindow?.show();
|
|
142
|
-
log('窗口已显示');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
|
146
|
-
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
147
|
-
shell.openExternal(url);
|
|
148
|
-
}
|
|
149
|
-
return { action: 'deny' };
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
mainWindow.on('closed', () => {
|
|
153
|
-
mainWindow = null;
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
log('窗口创建完成');
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
app.whenReady().then(async () => {
|
|
160
|
-
log('Electron 准备好');
|
|
161
|
-
await createWindow();
|
|
162
|
-
|
|
163
|
-
app.on('activate', async () => {
|
|
164
|
-
if (BrowserWindow.getAllWindows().length === 0) {
|
|
165
|
-
await createWindow();
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
app.on('window-all-closed', () => {
|
|
171
|
-
log('所有窗口已关闭');
|
|
172
|
-
if (webServerProcess) {
|
|
173
|
-
webServerProcess.kill();
|
|
174
|
-
log('Web 服务器进程已终止');
|
|
175
|
-
}
|
|
176
|
-
if (process.platform !== 'darwin') {
|
|
177
|
-
app.quit();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
app.on('before-quit', () => {
|
|
182
|
-
log('应用即将退出');
|
|
183
|
-
if (webServerProcess) {
|
|
184
|
-
webServerProcess.kill();
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
ipcMain.handle('get-version', () => {
|
|
189
|
-
return app.getVersion();
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
ipcMain.handle('get-user-data-path', () => {
|
|
193
|
-
return userDataPath;
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
ipcMain.handle('open-external', async (_, url: string) => {
|
|
197
|
-
await shell.openExternal(url);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
log('主进程初始化完成');
|