@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
package/src/llm/pi-ai.ts
DELETED
|
@@ -1,653 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
|
|
4
|
-
export type ModelProvider = 'openai' | 'anthropic' | 'ollama' | 'openrouter' | 'gemini' | 'minimax' | 'deepseek' | 'kimi' | 'glm' | 'qwen' | 'local';
|
|
5
|
-
|
|
6
|
-
export interface ModelConfig {
|
|
7
|
-
provider: ModelProvider;
|
|
8
|
-
apiKey?: string;
|
|
9
|
-
baseUrl?: string;
|
|
10
|
-
model: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ChatMessage {
|
|
14
|
-
role: 'system' | 'user' | 'assistant';
|
|
15
|
-
content: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface ChatResult {
|
|
19
|
-
reply: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface SummarizeResult {
|
|
23
|
-
summary: string;
|
|
24
|
-
qualityScore: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface GenerateOptions {
|
|
28
|
-
messages: ChatMessage[];
|
|
29
|
-
temperature?: number;
|
|
30
|
-
maxTokens?: number;
|
|
31
|
-
signal?: AbortSignal;
|
|
32
|
-
/** 工具 id 列表 — 代码侧 (src/llm/tool-manifest/) 查 schema, prompt 里只嵌 oneLine + callExample */
|
|
33
|
-
tools?: string[];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 外部 system 注入钩子.
|
|
38
|
-
* 调用方 (e.g. auto-evolve-loop) 用 setSystemPrependProvider() 注册一个返回字符串的函数,
|
|
39
|
-
* generateText 在拼 finalMessages 时, 把返回的字符串作为最前一个 system message.
|
|
40
|
-
*
|
|
41
|
-
* 用途: P2P 协作时把"行级 reserve 状态"实时塞给 LLM,
|
|
42
|
-
* 让 LLM 主动避开对方正在改的代码行.
|
|
43
|
-
*
|
|
44
|
-
* 返回 '' / null / undefined → 不注入.
|
|
45
|
-
*/
|
|
46
|
-
let _prependProvider: (() => string | null | undefined | Promise<string | null | undefined>) | null = null;
|
|
47
|
-
export function setSystemPrependProvider(
|
|
48
|
-
p: (() => string | null | undefined | Promise<string | null | undefined>) | null
|
|
49
|
-
): void {
|
|
50
|
-
_prependProvider = p;
|
|
51
|
-
}
|
|
52
|
-
export function getSystemPrependProvider(): typeof _prependProvider {
|
|
53
|
-
return _prependProvider;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class PiAIModel {
|
|
57
|
-
private config: ModelConfig;
|
|
58
|
-
private provider: ModelProvider;
|
|
59
|
-
|
|
60
|
-
constructor(config: ModelConfig) {
|
|
61
|
-
this.config = config;
|
|
62
|
-
this.provider = config.provider;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async chat(message: string, context?: string, signal?: AbortSignal): Promise<ChatResult> {
|
|
66
|
-
const systemPrompt = await this.buildSystemPromptAsync(context);
|
|
67
|
-
const messages: ChatMessage[] = [
|
|
68
|
-
{ role: 'system', content: systemPrompt },
|
|
69
|
-
{ role: 'user', content: message }
|
|
70
|
-
];
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const response = await this.generateText({
|
|
74
|
-
messages,
|
|
75
|
-
temperature: 0.8,
|
|
76
|
-
maxTokens: 8192, // 2026-06-15: 提到 8192, 避免长回答 (含表格/代码块) 被截断
|
|
77
|
-
signal,
|
|
78
|
-
});
|
|
79
|
-
return { reply: response };
|
|
80
|
-
} catch (error: any) {
|
|
81
|
-
// abort 不当作错误, 透传一个 sentinel 让上层能识别
|
|
82
|
-
if (signal?.aborted || error?.name === 'AbortError') {
|
|
83
|
-
throw error; // 上层 try/catch 处理
|
|
84
|
-
}
|
|
85
|
-
console.error('PiAI chat error:', error);
|
|
86
|
-
// 2026-06-15: 真实 error 信息 + 明确告诉 LLM "这是 API 错, 不要 retry"
|
|
87
|
-
// 旧版: "抱歉,AI服务暂时不可用。" → LLM 看到 isTooShort=false(< 50 但 > 0),
|
|
88
|
-
// needsMoreWork 不会触发, 但 hasError 模式 (含 "error" / "失败") 会判定要继续修
|
|
89
|
-
// 新版: 让 LLM 立即停止循环, 直接展示给用户
|
|
90
|
-
const errMsg = (error?.message || '').slice(0, 300);
|
|
91
|
-
return {
|
|
92
|
-
reply: `[AI 服务调用失败] ${errMsg}\n\n这是一个**底层 API 错误**(401 / 鉴权失败 / 网络中断 / 配额耗尽等),不是你的任务有问题。**请直接把这个错误消息回复给用户,不要再循环尝试。**`,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async summarize(text: string, context?: string): Promise<SummarizeResult> {
|
|
98
|
-
const prompt = this.buildSummarizePrompt(text, context);
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
const response = await this.generateText({
|
|
102
|
-
messages: [
|
|
103
|
-
{ role: 'system', content: 'You are a professional document summarizer.' },
|
|
104
|
-
{ role: 'user', content: prompt }
|
|
105
|
-
],
|
|
106
|
-
temperature: 0.7
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const qualityScore = this.estimateQuality(text, response);
|
|
110
|
-
return { summary: response, qualityScore };
|
|
111
|
-
} catch (error) {
|
|
112
|
-
console.error('PiAI summarize error:', error);
|
|
113
|
-
return {
|
|
114
|
-
summary: text.substring(0, 500) + '...',
|
|
115
|
-
qualityScore: 0.5
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async improveContent(content: string, requirements: string, context?: string): Promise<string> {
|
|
121
|
-
const prompt = this.buildImprovePrompt(content, requirements, context);
|
|
122
|
-
|
|
123
|
-
try {
|
|
124
|
-
const response = await this.generateText({
|
|
125
|
-
messages: [
|
|
126
|
-
{ role: 'system', content: 'You are a professional document editor and improver.' },
|
|
127
|
-
{ role: 'user', content: prompt }
|
|
128
|
-
],
|
|
129
|
-
temperature: 0.8
|
|
130
|
-
});
|
|
131
|
-
return response;
|
|
132
|
-
} catch (error) {
|
|
133
|
-
console.error('PiAI improve error:', error);
|
|
134
|
-
return content;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
private async generateText(options: GenerateOptions): Promise<string> {
|
|
139
|
-
const { messages, temperature = 0.7, maxTokens = 4096, signal, tools } = options;
|
|
140
|
-
|
|
141
|
-
// 工具清单: 代码侧 schema → 进 system prompt (作为额外 system message)
|
|
142
|
-
let finalMessages = messages;
|
|
143
|
-
|
|
144
|
-
// 1) 外部 prepend (e.g. P2P 行级 reserve 状态), 拼到最前
|
|
145
|
-
if (_prependProvider) {
|
|
146
|
-
try {
|
|
147
|
-
const pre = await _prependProvider();
|
|
148
|
-
if (pre && typeof pre === 'string' && pre.trim()) {
|
|
149
|
-
finalMessages = [{ role: 'system', content: pre }, ...finalMessages];
|
|
150
|
-
}
|
|
151
|
-
} catch (err: any) {
|
|
152
|
-
console.warn('[pi-ai] systemPrepend 失败:', err?.message?.slice(0, 100));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (tools && tools.length > 0) {
|
|
157
|
-
try {
|
|
158
|
-
const { getToolManifest, formatForPrompt } = await import('./tool-manifest/index.js');
|
|
159
|
-
const manifests = tools
|
|
160
|
-
.map((id) => getToolManifest(id))
|
|
161
|
-
.filter((m): m is NonNullable<typeof m> => m !== undefined);
|
|
162
|
-
if (manifests.length > 0) {
|
|
163
|
-
const toolPrompt = formatForPrompt(manifests);
|
|
164
|
-
finalMessages = [
|
|
165
|
-
{ role: 'system', content: toolPrompt },
|
|
166
|
-
...messages,
|
|
167
|
-
];
|
|
168
|
-
}
|
|
169
|
-
} catch (err: any) {
|
|
170
|
-
console.warn('[pi-ai] tool-manifest 加载失败:', err.message?.slice(0, 100));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
switch (this.provider) {
|
|
175
|
-
case 'openai':
|
|
176
|
-
case 'minimax':
|
|
177
|
-
case 'deepseek':
|
|
178
|
-
case 'kimi':
|
|
179
|
-
case 'glm':
|
|
180
|
-
case 'qwen':
|
|
181
|
-
return this.callOpenAI(finalMessages, temperature, maxTokens, signal);
|
|
182
|
-
case 'anthropic':
|
|
183
|
-
return this.callAnthropic(finalMessages, temperature, maxTokens, signal);
|
|
184
|
-
case 'ollama':
|
|
185
|
-
return this.callOllama(finalMessages, temperature, signal);
|
|
186
|
-
case 'openrouter':
|
|
187
|
-
return this.callOpenRouter(finalMessages, temperature, maxTokens, signal);
|
|
188
|
-
case 'gemini':
|
|
189
|
-
return this.callGemini(finalMessages, temperature, maxTokens, signal);
|
|
190
|
-
case 'local':
|
|
191
|
-
return this.callLocal(finalMessages, temperature, signal);
|
|
192
|
-
default:
|
|
193
|
-
throw new Error(`Unsupported provider: ${this.provider}`);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
private getApiKey(): string {
|
|
198
|
-
return this.config.apiKey || this.getEnvApiKey();
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
private getEnvApiKey(): string {
|
|
202
|
-
const envVars: Record<ModelProvider, string> = {
|
|
203
|
-
openai: process.env.OPENAI_API_KEY || '',
|
|
204
|
-
anthropic: process.env.ANTHROPIC_API_KEY || '',
|
|
205
|
-
ollama: '',
|
|
206
|
-
openrouter: process.env.OPENROUTER_API_KEY || '',
|
|
207
|
-
gemini: process.env.GEMINI_API_KEY || '',
|
|
208
|
-
minimax: process.env.MINIMAX_API_KEY || '',
|
|
209
|
-
deepseek: process.env.DEEPSEEK_API_KEY || '',
|
|
210
|
-
kimi: process.env.KIMI_API_KEY || process.env.MOONSHOT_API_KEY || '',
|
|
211
|
-
glm: process.env.GLM_API_KEY || process.env.ZHIPU_API_KEY || '',
|
|
212
|
-
qwen: process.env.QWEN_API_KEY || process.env.DASHSCOPE_API_KEY || '',
|
|
213
|
-
local: ''
|
|
214
|
-
};
|
|
215
|
-
return envVars[this.provider] || '';
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
private getBaseUrl(): string {
|
|
219
|
-
if (this.config.baseUrl) {
|
|
220
|
-
return this.config.baseUrl;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// 允许通过 OPENAI_BASE_URL 等环境变量覆盖默认 base URL
|
|
224
|
-
const baseUrls: Record<ModelProvider, string> = {
|
|
225
|
-
openai: process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1',
|
|
226
|
-
anthropic: 'https://api.anthropic.com/v1',
|
|
227
|
-
ollama: process.env.OLLAMA_BASE_URL || 'http://localhost:11434',
|
|
228
|
-
openrouter: process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1',
|
|
229
|
-
gemini: 'https://generativelanguage.googleapis.com/v1beta',
|
|
230
|
-
minimax: process.env.MINIMAX_BASE_URL || 'https://api.minimaxi.com/v1',
|
|
231
|
-
deepseek: process.env.DEEPSEEK_BASE_URL || 'https://api.deepseek.com/v1',
|
|
232
|
-
kimi: process.env.KIMI_BASE_URL || process.env.MOONSHOT_BASE_URL || 'https://api.moonshot.cn/v1',
|
|
233
|
-
glm: process.env.GLM_BASE_URL || process.env.ZHIPU_BASE_URL || 'https://open.bigmodel.cn/api/paas/v4',
|
|
234
|
-
qwen: process.env.QWEN_BASE_URL || process.env.DASHSCOPE_BASE_URL || 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
235
|
-
local: 'http://localhost:11434'
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
return baseUrls[this.provider];
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
private mapModel(): string {
|
|
242
|
-
const modelMap: Record<ModelProvider, string> = {
|
|
243
|
-
openai: this.config.model || process.env.OPENAI_MODEL || 'gpt-4',
|
|
244
|
-
anthropic: this.config.model || 'claude-3-5-sonnet-20241022',
|
|
245
|
-
ollama: this.config.model || 'llama3.2',
|
|
246
|
-
openrouter: this.config.model || 'anthropic/claude-3.5-sonnet',
|
|
247
|
-
gemini: this.config.model || 'gemini-2.0-flash',
|
|
248
|
-
minimax: this.config.model || process.env.MINIMAX_MODEL || 'MiniMax-M3',
|
|
249
|
-
deepseek: this.config.model || process.env.DEEPSEEK_MODEL || 'deepseek-chat',
|
|
250
|
-
kimi: this.config.model || process.env.KIMI_MODEL || process.env.MOONSHOT_MODEL || 'moonshot-v1-8k',
|
|
251
|
-
glm: this.config.model || process.env.GLM_MODEL || process.env.ZHIPU_MODEL || 'glm-4-flash',
|
|
252
|
-
qwen: this.config.model || process.env.QWEN_MODEL || process.env.DASHSCOPE_MODEL || 'qwen-plus',
|
|
253
|
-
local: this.config.model || 'llama3.2'
|
|
254
|
-
};
|
|
255
|
-
return modelMap[this.provider];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
private async callOpenAI(messages: ChatMessage[], temperature: number, maxTokens: number, signal?: AbortSignal): Promise<string> {
|
|
259
|
-
const apiKey = this.getApiKey();
|
|
260
|
-
if (!apiKey) {
|
|
261
|
-
throw new Error('OPENAI_API_KEY not set');
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const requestBody = {
|
|
265
|
-
model: this.mapModel(),
|
|
266
|
-
messages,
|
|
267
|
-
temperature,
|
|
268
|
-
max_tokens: maxTokens
|
|
269
|
-
};
|
|
270
|
-
const response = await fetch(`${this.getBaseUrl()}/chat/completions`, {
|
|
271
|
-
method: 'POST',
|
|
272
|
-
headers: {
|
|
273
|
-
'Content-Type': 'application/json',
|
|
274
|
-
'Authorization': `Bearer ${apiKey}`
|
|
275
|
-
},
|
|
276
|
-
body: JSON.stringify(requestBody),
|
|
277
|
-
// 2026-06-15: signal 字段防御 — Node 22+ undici 强类型 AbortSignal, 非 AbortSignal 实例
|
|
278
|
-
// (e.g. 误传的 { maxTokens: 1 } 对象) 会 throw "Expected signal to be AbortSignal".
|
|
279
|
-
// 若不是 AbortSignal, 退到无 signal 调用, fetch 自然支持 timeout 由外层控制.
|
|
280
|
-
signal: signal instanceof AbortSignal ? signal : undefined,
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
if (!response.ok) {
|
|
284
|
-
throw new Error(`OpenAI API error: ${response.status}`);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const data = await response.json() as { choices?: { message?: { content?: string } }[] };
|
|
288
|
-
return data.choices?.[0]?.message?.content || '';
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
private async callAnthropic(messages: ChatMessage[], temperature: number, maxTokens: number, signal?: AbortSignal): Promise<string> {
|
|
292
|
-
const apiKey = this.getApiKey();
|
|
293
|
-
if (!apiKey) {
|
|
294
|
-
throw new Error('ANTHROPIC_API_KEY not set');
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const systemMessage = messages.find(m => m.role === 'system')?.content || '';
|
|
298
|
-
const userMessages = messages.filter(m => m.role !== 'system');
|
|
299
|
-
|
|
300
|
-
const response = await fetch(`${this.getBaseUrl()}/messages`, {
|
|
301
|
-
method: 'POST',
|
|
302
|
-
headers: {
|
|
303
|
-
'Content-Type': 'application/json',
|
|
304
|
-
'x-api-key': apiKey,
|
|
305
|
-
'anthropic-version': '2023-06-01',
|
|
306
|
-
'anthropic-dangerous-direct-browser-access': 'true'
|
|
307
|
-
},
|
|
308
|
-
body: JSON.stringify({
|
|
309
|
-
model: this.mapModel(),
|
|
310
|
-
messages: userMessages,
|
|
311
|
-
system: systemMessage,
|
|
312
|
-
temperature,
|
|
313
|
-
max_tokens: maxTokens
|
|
314
|
-
}),
|
|
315
|
-
signal,
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
if (!response.ok) {
|
|
319
|
-
throw new Error(`Anthropic API error: ${response.status}`);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const data = await response.json() as { content?: { text?: string }[] };
|
|
323
|
-
return data.content?.[0]?.text || '';
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
private async callOllama(messages: ChatMessage[], temperature: number, signal?: AbortSignal): Promise<string> {
|
|
327
|
-
const response = await fetch(`${this.getBaseUrl()}/api/chat`, {
|
|
328
|
-
method: 'POST',
|
|
329
|
-
headers: {
|
|
330
|
-
'Content-Type': 'application/json'
|
|
331
|
-
},
|
|
332
|
-
body: JSON.stringify({
|
|
333
|
-
model: this.mapModel(),
|
|
334
|
-
messages,
|
|
335
|
-
temperature,
|
|
336
|
-
stream: false
|
|
337
|
-
}),
|
|
338
|
-
signal,
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
if (!response.ok) {
|
|
342
|
-
throw new Error(`Ollama API error: ${response.status}`);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const data = await response.json() as { message?: { content?: string } };
|
|
346
|
-
return data.message?.content || '';
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
private async callOpenRouter(messages: ChatMessage[], temperature: number, maxTokens: number, signal?: AbortSignal): Promise<string> {
|
|
350
|
-
const apiKey = this.getApiKey();
|
|
351
|
-
if (!apiKey) {
|
|
352
|
-
throw new Error('OPENROUTER_API_KEY not set');
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const response = await fetch(`${this.getBaseUrl()}/chat/completions`, {
|
|
356
|
-
method: 'POST',
|
|
357
|
-
headers: {
|
|
358
|
-
'Content-Type': 'application/json',
|
|
359
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
360
|
-
'HTTP-Referer': 'https://openclaw.ai',
|
|
361
|
-
'X-Title': 'OpenClaw'
|
|
362
|
-
},
|
|
363
|
-
body: JSON.stringify({
|
|
364
|
-
model: this.mapModel(),
|
|
365
|
-
messages,
|
|
366
|
-
temperature,
|
|
367
|
-
max_tokens: maxTokens
|
|
368
|
-
}),
|
|
369
|
-
signal,
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
if (!response.ok) {
|
|
373
|
-
throw new Error(`OpenRouter API error: ${response.status}`);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
const data = await response.json() as { choices?: { message?: { content?: string } }[] };
|
|
377
|
-
return data.choices?.[0]?.message?.content || '';
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
private async callGemini(messages: ChatMessage[], temperature: number, maxTokens: number, signal?: AbortSignal): Promise<string> {
|
|
381
|
-
const apiKey = this.getApiKey();
|
|
382
|
-
if (!apiKey) {
|
|
383
|
-
throw new Error('GEMINI_API_KEY not set');
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const contents = messages
|
|
387
|
-
.filter(m => m.role !== 'system')
|
|
388
|
-
.map(m => ({
|
|
389
|
-
role: m.role === 'assistant' ? 'model' : 'user',
|
|
390
|
-
parts: [{ text: m.content }]
|
|
391
|
-
}));
|
|
392
|
-
|
|
393
|
-
const systemInstruction = messages.find(m => m.role === 'system')?.content;
|
|
394
|
-
|
|
395
|
-
const response = await fetch(
|
|
396
|
-
`${this.getBaseUrl()}/models/${this.mapModel()}:generateContent?key=${apiKey}`,
|
|
397
|
-
{
|
|
398
|
-
method: 'POST',
|
|
399
|
-
headers: {
|
|
400
|
-
'Content-Type': 'application/json'
|
|
401
|
-
},
|
|
402
|
-
body: JSON.stringify({
|
|
403
|
-
contents,
|
|
404
|
-
systemInstruction: systemInstruction ? { parts: [{ text: systemInstruction }] } : undefined,
|
|
405
|
-
generationConfig: {
|
|
406
|
-
temperature,
|
|
407
|
-
maxOutputTokens: maxTokens
|
|
408
|
-
}
|
|
409
|
-
}),
|
|
410
|
-
signal,
|
|
411
|
-
}
|
|
412
|
-
);
|
|
413
|
-
|
|
414
|
-
if (!response.ok) {
|
|
415
|
-
throw new Error(`Gemini API error: ${response.status}`);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
const data = await response.json() as { candidates?: { content?: { parts?: { text?: string }[] } }[] };
|
|
419
|
-
return data.candidates?.[0]?.content?.parts?.[0]?.text || '';
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
private async callLocal(messages: ChatMessage[], temperature: number, signal?: AbortSignal): Promise<string> {
|
|
423
|
-
return this.callOllama(messages, temperature, signal);
|
|
424
|
-
}
|
|
425
|
-
// 注: callLocal 直接代理 ollama. 工具清单由 generateText 在外层拼到 messages, 这里 messages 已是 finalMessages.
|
|
426
|
-
|
|
427
|
-
private async buildSystemPromptAsync(context?: string): Promise<string> {
|
|
428
|
-
// 走 layer registry: 装配所有相关 layer (身份/行为/工具/角色/渠道)
|
|
429
|
-
try {
|
|
430
|
-
const { assembleSystemPrompt, SYSTEM_PROMPT_VERSION } = await import(
|
|
431
|
-
'./system-prompt/registry.js' as any
|
|
432
|
-
).catch(() => import('./system-prompt/registry.js'));
|
|
433
|
-
// channel = 本机 (PI SDK 直接调就是 local)
|
|
434
|
-
// role = 由 prompt context 决定 (默认 expert)
|
|
435
|
-
const ctx = context ? { channel: 'local' as const, role: 'expert' as const } : { channel: 'local' as const, role: 'expert' as const };
|
|
436
|
-
const result = await assembleSystemPrompt(ctx);
|
|
437
|
-
return `${result.text}\n\n## User Working Directory\n${context || process.cwd()}\n\n## bolloon-runtime\n${SYSTEM_PROMPT_VERSION} · layers: ${result.layerIds.join(',')}`;
|
|
438
|
-
} catch (err: any) {
|
|
439
|
-
// 降级: 旧硬编码 (layer registry 不可用时不挂)
|
|
440
|
-
console.warn('[pi-ai] layer registry 不可用, 降级:', err.message?.slice(0, 100));
|
|
441
|
-
const envDetails = this.getEnvironmentDetails();
|
|
442
|
-
return `You are a friendly AI assistant in a P2P document collaboration network.
|
|
443
|
-
|
|
444
|
-
## User Working Directory
|
|
445
|
-
${context || process.cwd()}
|
|
446
|
-
|
|
447
|
-
## Environment
|
|
448
|
-
${envDetails}`;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// 同步版: 旧调用点 (buildSystemPrompt 是同步)
|
|
453
|
-
// 保留但内部用 sync fallback; 后续可改成 async
|
|
454
|
-
private buildSystemPrompt(context?: string): string {
|
|
455
|
-
const envDetails = this.getEnvironmentDetails();
|
|
456
|
-
return `You are a friendly AI assistant in a P2P document collaboration network.
|
|
457
|
-
|
|
458
|
-
## User Working Directory
|
|
459
|
-
${context || process.cwd()}
|
|
460
|
-
|
|
461
|
-
## Environment
|
|
462
|
-
${envDetails}`;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
private getEnvironmentDetails(): string {
|
|
466
|
-
return `
|
|
467
|
-
## Available Workflows
|
|
468
|
-
- read - Read documents
|
|
469
|
-
- summarize - Summarize documents
|
|
470
|
-
- improve - Improve documents
|
|
471
|
-
- collaborate - Multi-agent collaboration
|
|
472
|
-
- query - Query status
|
|
473
|
-
- report - Generate reports
|
|
474
|
-
|
|
475
|
-
## System Capabilities
|
|
476
|
-
- Document processing (Markdown, Text, PDF, DOCX)
|
|
477
|
-
- Multi-agent collaboration (P2P network)
|
|
478
|
-
- Workflow engine (constraint layer)
|
|
479
|
-
- Quality assessment and auto-send
|
|
480
|
-
|
|
481
|
-
## Current Time
|
|
482
|
-
${new Date().toISOString()}`;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
private buildSummarizePrompt(text: string, context?: string): string {
|
|
486
|
-
const maxLength = 8000;
|
|
487
|
-
const truncatedText = text.length > maxLength ? text.substring(0, maxLength) + '...' : text;
|
|
488
|
-
|
|
489
|
-
let prompt = `Please generate a concise and accurate summary for the following document:
|
|
490
|
-
|
|
491
|
-
${truncatedText}
|
|
492
|
-
|
|
493
|
-
Please output in the following format:
|
|
494
|
-
## Summary
|
|
495
|
-
[Write summary here]
|
|
496
|
-
|
|
497
|
-
## Quality Self-Assessment
|
|
498
|
-
[Score 1-10, with reasoning]`;
|
|
499
|
-
|
|
500
|
-
if (context) {
|
|
501
|
-
prompt = `Context: ${context}
|
|
502
|
-
|
|
503
|
-
${prompt}`;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return prompt;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
private buildImprovePrompt(content: string, requirements: string, context?: string): string {
|
|
510
|
-
const maxLength = 8000;
|
|
511
|
-
const truncatedContent = content.length > maxLength ? content.substring(0, maxLength) + '...' : content;
|
|
512
|
-
|
|
513
|
-
let prompt = `Please improve the document according to the following requirements:
|
|
514
|
-
|
|
515
|
-
Requirements: ${requirements}
|
|
516
|
-
|
|
517
|
-
Original Document:
|
|
518
|
-
${truncatedContent}
|
|
519
|
-
|
|
520
|
-
Please output only the improved document without additional explanation.`;
|
|
521
|
-
|
|
522
|
-
if (context) {
|
|
523
|
-
prompt = `Context: ${context}
|
|
524
|
-
|
|
525
|
-
${prompt}`;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
return prompt;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
estimateQuality(original: string, summary: string): number {
|
|
532
|
-
const coverageRatio = summary.length / Math.max(original.length, 1);
|
|
533
|
-
const hasKeyPoints = /\d+\s*[.。]/.test(summary);
|
|
534
|
-
const decentLength = summary.length > 100 && summary.length < original.length * 0.5;
|
|
535
|
-
|
|
536
|
-
let score = 0.5;
|
|
537
|
-
if (coverageRatio > 0.1 && coverageRatio < 0.5) score += 0.2;
|
|
538
|
-
if (hasKeyPoints) score += 0.15;
|
|
539
|
-
if (decentLength) score += 0.15;
|
|
540
|
-
|
|
541
|
-
return Math.min(1, score);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
async shouldAutoSend(qualityScore: number, threshold: number = 0.7): Promise<boolean> {
|
|
545
|
-
return qualityScore >= threshold;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
let modelInstance: PiAIModel | null = null;
|
|
550
|
-
|
|
551
|
-
export interface PiAIConfig {
|
|
552
|
-
provider?: ModelProvider;
|
|
553
|
-
apiKey?: string;
|
|
554
|
-
baseUrl?: string;
|
|
555
|
-
model?: string;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function detectProvider(): ModelProvider {
|
|
559
|
-
// 首先检查配置文件(优先级最高)
|
|
560
|
-
try {
|
|
561
|
-
const configPath = path.join(process.env.HOME || '/tmp', '.bolloon', 'llm-config.json');
|
|
562
|
-
const configData = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
563
|
-
if (configData.activeProvider && configData.providers[configData.activeProvider]) {
|
|
564
|
-
console.log('[PiAIModel] Detected provider from config:', configData.activeProvider);
|
|
565
|
-
return configData.activeProvider;
|
|
566
|
-
}
|
|
567
|
-
} catch {}
|
|
568
|
-
|
|
569
|
-
// 然后检查环境变量
|
|
570
|
-
if (process.env.OPENAI_API_KEY) return 'openai';
|
|
571
|
-
if (process.env.ANTHROPIC_API_KEY) return 'anthropic';
|
|
572
|
-
if (process.env.OPENROUTER_API_KEY) return 'openrouter';
|
|
573
|
-
if (process.env.GEMINI_API_KEY) return 'gemini';
|
|
574
|
-
if (process.env.OLLAMA_BASE_URL) return 'ollama';
|
|
575
|
-
if (process.env.MINIMAX_API_KEY) return 'minimax';
|
|
576
|
-
if (process.env.DEEPSEEK_API_KEY) return 'deepseek';
|
|
577
|
-
if (process.env.KIMI_API_KEY || process.env.MOONSHOT_API_KEY) return 'kimi';
|
|
578
|
-
if (process.env.GLM_API_KEY || process.env.ZHIPU_API_KEY) return 'glm';
|
|
579
|
-
if (process.env.QWEN_API_KEY || process.env.DASHSCOPE_API_KEY) return 'qwen';
|
|
580
|
-
|
|
581
|
-
return 'openai';
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
function detectModel(provider: ModelProvider): string {
|
|
585
|
-
const defaults: Record<ModelProvider, string> = {
|
|
586
|
-
openai: 'gpt-4',
|
|
587
|
-
anthropic: 'claude-3-5-sonnet-20241022',
|
|
588
|
-
ollama: 'llama3.2',
|
|
589
|
-
openrouter: 'anthropic/claude-3.5-sonnet',
|
|
590
|
-
gemini: 'gemini-2.0-flash',
|
|
591
|
-
minimax: 'MiniMax-M3',
|
|
592
|
-
deepseek: 'deepseek-chat',
|
|
593
|
-
kimi: 'moonshot-v1-8k',
|
|
594
|
-
glm: 'glm-4-flash',
|
|
595
|
-
qwen: 'qwen-plus',
|
|
596
|
-
local: 'llama3.2'
|
|
597
|
-
};
|
|
598
|
-
return defaults[provider];
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
export function initPiAI(config: PiAIConfig = {}): PiAIModel {
|
|
602
|
-
const provider = config.provider || detectProvider();
|
|
603
|
-
const model = config.model || detectModel(provider);
|
|
604
|
-
|
|
605
|
-
console.log('[PiAIModel] Initializing with provider:', provider, 'model:', model);
|
|
606
|
-
|
|
607
|
-
// 如果没有提供 apiKey,从配置文件读取
|
|
608
|
-
let apiKey = config.apiKey;
|
|
609
|
-
if (!apiKey) {
|
|
610
|
-
try {
|
|
611
|
-
const configPath = path.join(process.env.HOME || '/tmp', '.bolloon', 'llm-config.json');
|
|
612
|
-
const configData = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
613
|
-
const providerConfig = configData.providers[provider];
|
|
614
|
-
if (providerConfig?.apiKey) {
|
|
615
|
-
apiKey = providerConfig.apiKey;
|
|
616
|
-
console.log('[PiAIModel] Loaded apiKey from config for', provider);
|
|
617
|
-
}
|
|
618
|
-
} catch (e) {
|
|
619
|
-
console.log('[PiAIModel] Error reading apiKey from config:', e);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
modelInstance = new PiAIModel({
|
|
624
|
-
provider,
|
|
625
|
-
apiKey,
|
|
626
|
-
baseUrl: config.baseUrl,
|
|
627
|
-
model
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
console.log('[PiAIModel] Model instance created, provider:', provider);
|
|
631
|
-
return modelInstance;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
export function getModel(): PiAIModel {
|
|
635
|
-
if (!modelInstance) {
|
|
636
|
-
throw new Error('PiAI not initialized. Call initPiAI first.');
|
|
637
|
-
}
|
|
638
|
-
return modelInstance;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
export function isModelAvailable(): boolean {
|
|
642
|
-
return modelInstance !== null;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
export function getMinimax(): PiAIModel {
|
|
646
|
-
return getModel();
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
export function initMinimax(config: PiAIConfig = {}): PiAIModel {
|
|
650
|
-
return initPiAI(config);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
export { PiAIModel as MinimaxLLM };
|