@bolloon/bolloon-agent 0.4.28 → 0.4.29
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/bin/bolloon.cjs +18 -148
- package/bin/bolloon.cmd +6 -3
- package/dist/agents/pi-sdk-tools.js +3 -1
- package/dist/agents/pi-sdk.js +4 -1
- package/dist/cli/update-commands.js +349 -0
- package/dist/cli-entry.js +41 -55
- package/dist/electron-build/agents/agent-gateway.js +169 -0
- package/dist/electron-build/agents/agent-gateway.js.map +1 -0
- package/dist/electron-build/agents/agent-identity-store.js +212 -0
- package/dist/electron-build/agents/agent-identity-store.js.map +1 -0
- package/dist/electron-build/agents/agent-identity.js +196 -0
- package/dist/electron-build/agents/agent-identity.js.map +1 -0
- package/dist/electron-build/agents/agent-manifest-protocol.js +151 -0
- package/dist/electron-build/agents/agent-manifest-protocol.js.map +1 -0
- package/dist/electron-build/agents/agent-registry.js +217 -0
- package/dist/electron-build/agents/agent-registry.js.map +1 -0
- package/dist/electron-build/agents/agent-reputation.js +60 -0
- package/dist/electron-build/agents/agent-reputation.js.map +1 -0
- package/dist/electron-build/agents/agent-service-client.js +186 -0
- package/dist/electron-build/agents/agent-service-client.js.map +1 -0
- package/dist/electron-build/agents/browser-cdp.js +765 -0
- package/dist/electron-build/agents/browser-cdp.js.map +1 -0
- package/dist/electron-build/agents/computer-use.js +341 -0
- package/dist/electron-build/agents/computer-use.js.map +1 -0
- package/dist/electron-build/agents/constraint-layer.js +210 -0
- package/dist/electron-build/agents/constraint-layer.js.map +1 -0
- package/dist/electron-build/agents/decision-store.js +292 -0
- package/dist/electron-build/agents/decision-store.js.map +1 -0
- package/dist/electron-build/agents/deny-pipeline.js +125 -0
- package/dist/electron-build/agents/deny-pipeline.js.map +1 -0
- package/dist/electron-build/agents/economic-policy.js +172 -0
- package/dist/electron-build/agents/economic-policy.js.map +1 -0
- package/dist/electron-build/agents/error-classifier.js +125 -0
- package/dist/electron-build/agents/error-classifier.js.map +1 -0
- package/dist/electron-build/agents/execution-supervisor.js +539 -0
- package/dist/electron-build/agents/execution-supervisor.js.map +1 -0
- package/dist/electron-build/agents/external-events.js +171 -0
- package/dist/electron-build/agents/external-events.js.map +1 -0
- package/dist/electron-build/agents/gateway-join.js +315 -0
- package/dist/electron-build/agents/gateway-join.js.map +1 -0
- package/dist/electron-build/agents/gateway-network.js +505 -0
- package/dist/electron-build/agents/gateway-network.js.map +1 -0
- package/dist/electron-build/agents/goal-criteria.js +133 -0
- package/dist/electron-build/agents/goal-criteria.js.map +1 -0
- package/dist/electron-build/agents/goal-resume.js +364 -0
- package/dist/electron-build/agents/goal-resume.js.map +1 -0
- package/dist/electron-build/agents/goal-store.js +587 -0
- package/dist/electron-build/agents/goal-store.js.map +1 -0
- package/dist/electron-build/agents/intent-classifier.js +104 -0
- package/dist/electron-build/agents/intent-classifier.js.map +1 -0
- package/dist/electron-build/agents/iroh-secret.js +70 -0
- package/dist/electron-build/agents/iroh-secret.js.map +1 -0
- package/dist/electron-build/agents/loop-review.js +101 -0
- package/dist/electron-build/agents/loop-review.js.map +1 -0
- package/dist/electron-build/agents/memory-recall.js +154 -0
- package/dist/electron-build/agents/memory-recall.js.map +1 -0
- package/dist/electron-build/agents/p2p-document-tools.js +328 -0
- package/dist/electron-build/agents/p2p-document-tools.js.map +1 -0
- package/dist/electron-build/agents/parse-tool-call.js +564 -0
- package/dist/electron-build/agents/parse-tool-call.js.map +1 -0
- package/dist/electron-build/agents/patch-tool.js +205 -0
- package/dist/electron-build/agents/patch-tool.js.map +1 -0
- package/dist/electron-build/agents/payment-approval.js +183 -0
- package/dist/electron-build/agents/payment-approval.js.map +1 -0
- package/dist/electron-build/agents/payment-gate.js +139 -0
- package/dist/electron-build/agents/payment-gate.js.map +1 -0
- package/dist/electron-build/agents/permission-mode.js +124 -0
- package/dist/electron-build/agents/permission-mode.js.map +1 -0
- package/dist/electron-build/agents/pi-harness.js +268 -0
- package/dist/electron-build/agents/pi-harness.js.map +1 -0
- package/dist/electron-build/agents/pi-sdk-session-factory.js +117 -0
- package/dist/electron-build/agents/pi-sdk-session-factory.js.map +1 -0
- package/dist/electron-build/agents/pi-sdk-session-manager.js +335 -0
- package/dist/electron-build/agents/pi-sdk-session-manager.js.map +1 -0
- package/dist/electron-build/agents/pi-sdk-tools.js +4042 -0
- package/dist/electron-build/agents/pi-sdk-tools.js.map +1 -0
- package/dist/electron-build/agents/pi-sdk-types.js +17 -0
- package/dist/electron-build/agents/pi-sdk-types.js.map +1 -0
- package/dist/electron-build/agents/pi-sdk.js +3325 -0
- package/dist/electron-build/agents/pi-sdk.js.map +1 -0
- package/dist/electron-build/agents/plan-store.js +212 -0
- package/dist/electron-build/agents/plan-store.js.map +1 -0
- package/dist/electron-build/agents/pre-tool-validator.js +200 -0
- package/dist/electron-build/agents/pre-tool-validator.js.map +1 -0
- package/dist/electron-build/agents/process-runner.js +148 -0
- package/dist/electron-build/agents/process-runner.js.map +1 -0
- package/dist/electron-build/agents/react-loop.js +131 -0
- package/dist/electron-build/agents/react-loop.js.map +1 -0
- package/dist/electron-build/agents/resource-store.js +180 -0
- package/dist/electron-build/agents/resource-store.js.map +1 -0
- package/dist/electron-build/agents/resource-token.js +118 -0
- package/dist/electron-build/agents/resource-token.js.map +1 -0
- package/dist/electron-build/agents/resource-wallet.js +84 -0
- package/dist/electron-build/agents/resource-wallet.js.map +1 -0
- package/dist/electron-build/agents/run-store.js +854 -0
- package/dist/electron-build/agents/run-store.js.map +1 -0
- package/dist/electron-build/agents/runner-resolver.js +267 -0
- package/dist/electron-build/agents/runner-resolver.js.map +1 -0
- package/dist/electron-build/agents/session-store.js +294 -0
- package/dist/electron-build/agents/session-store.js.map +1 -0
- package/dist/electron-build/agents/shell-guard.js +465 -0
- package/dist/electron-build/agents/shell-guard.js.map +1 -0
- package/dist/electron-build/agents/shell-tool.js +102 -0
- package/dist/electron-build/agents/shell-tool.js.map +1 -0
- package/dist/electron-build/agents/skill-loader.js +216 -0
- package/dist/electron-build/agents/skill-loader.js.map +1 -0
- package/dist/electron-build/agents/skill-readiness.js +174 -0
- package/dist/electron-build/agents/skill-readiness.js.map +1 -0
- package/dist/electron-build/agents/skill-share.js +394 -0
- package/dist/electron-build/agents/skill-share.js.map +1 -0
- package/dist/electron-build/agents/skill-supervisor-link.js +75 -0
- package/dist/electron-build/agents/skill-supervisor-link.js.map +1 -0
- package/dist/electron-build/agents/skill-writer.js +347 -0
- package/dist/electron-build/agents/skill-writer.js.map +1 -0
- package/dist/electron-build/agents/skills-manager.js +763 -0
- package/dist/electron-build/agents/skills-manager.js.map +1 -0
- package/dist/electron-build/agents/supervisor-host.js +294 -0
- package/dist/electron-build/agents/supervisor-host.js.map +1 -0
- package/dist/electron-build/agents/task/local-seller.js +188 -0
- package/dist/electron-build/agents/task/local-seller.js.map +1 -0
- package/dist/electron-build/agents/task/report-card.js +152 -0
- package/dist/electron-build/agents/task/report-card.js.map +1 -0
- package/dist/electron-build/agents/task/resource-advisor.js +222 -0
- package/dist/electron-build/agents/task/resource-advisor.js.map +1 -0
- package/dist/electron-build/agents/task/task-budget.js +111 -0
- package/dist/electron-build/agents/task/task-budget.js.map +1 -0
- package/dist/electron-build/agents/task/task-runner.js +670 -0
- package/dist/electron-build/agents/task/task-runner.js.map +1 -0
- package/dist/electron-build/agents/task-state.js +266 -0
- package/dist/electron-build/agents/task-state.js.map +1 -0
- package/dist/electron-build/agents/tool-registry.js +141 -0
- package/dist/electron-build/agents/tool-registry.js.map +1 -0
- package/dist/electron-build/agents/treasury-bridge.js +165 -0
- package/dist/electron-build/agents/treasury-bridge.js.map +1 -0
- package/dist/electron-build/agents/user-questions.js +223 -0
- package/dist/electron-build/agents/user-questions.js.map +1 -0
- package/dist/electron-build/agents/verify-recipe.js +90 -0
- package/dist/electron-build/agents/verify-recipe.js.map +1 -0
- package/dist/electron-build/agents/workflow-engine.js +222 -0
- package/dist/electron-build/agents/workflow-engine.js.map +1 -0
- package/dist/electron-build/agents/workflow-pivot-loop.js +988 -0
- package/dist/electron-build/agents/workflow-pivot-loop.js.map +1 -0
- package/dist/electron-build/agents/write-staging.js +133 -0
- package/dist/electron-build/agents/write-staging.js.map +1 -0
- package/dist/electron-build/agents/x402/goal-run-bridge.js +115 -0
- package/dist/electron-build/agents/x402/goal-run-bridge.js.map +1 -0
- package/dist/electron-build/agents/x402/milestone-settlement.js +163 -0
- package/dist/electron-build/agents/x402/milestone-settlement.js.map +1 -0
- package/dist/electron-build/agents/x402/paid-info-protocol.js +274 -0
- package/dist/electron-build/agents/x402/paid-info-protocol.js.map +1 -0
- package/dist/electron-build/agents/x402/paid-info-store.js +409 -0
- package/dist/electron-build/agents/x402/paid-info-store.js.map +1 -0
- package/dist/electron-build/agents/x402/paid-info-tools.js +346 -0
- package/dist/electron-build/agents/x402/paid-info-tools.js.map +1 -0
- package/dist/electron-build/agents/x402/payment-recovery.js +330 -0
- package/dist/electron-build/agents/x402/payment-recovery.js.map +1 -0
- package/dist/electron-build/agents/x402/resource-contract.js +533 -0
- package/dist/electron-build/agents/x402/resource-contract.js.map +1 -0
- package/dist/electron-build/agents/x402/settlement-state.js +432 -0
- package/dist/electron-build/agents/x402/settlement-state.js.map +1 -0
- package/dist/electron-build/agents/x402/trade.js +294 -0
- package/dist/electron-build/agents/x402/trade.js.map +1 -0
- package/dist/electron-build/agents/x402/transaction-protocol.js +109 -0
- package/dist/electron-build/agents/x402/transaction-protocol.js.map +1 -0
- package/dist/electron-build/agents/x402/transaction-store.js +404 -0
- package/dist/electron-build/agents/x402/transaction-store.js.map +1 -0
- package/dist/electron-build/agents/x402/x402Pay.js +377 -0
- package/dist/electron-build/agents/x402/x402Pay.js.map +1 -0
- package/dist/electron-build/bollharness-integration/context-router-judgment.js +269 -0
- package/dist/electron-build/bollharness-integration/context-router-judgment.js.map +1 -0
- package/dist/electron-build/bollharness-integration/context-router.js +584 -0
- package/dist/electron-build/bollharness-integration/context-router.js.map +1 -0
- package/dist/electron-build/bollharness-integration/gate-state-machine.js +362 -0
- package/dist/electron-build/bollharness-integration/gate-state-machine.js.map +1 -0
- package/dist/electron-build/bollharness-integration/gate-transition-hooks.js +136 -0
- package/dist/electron-build/bollharness-integration/gate-transition-hooks.js.map +1 -0
- package/dist/electron-build/bollharness-integration/guard-checker.js +400 -0
- package/dist/electron-build/bollharness-integration/guard-checker.js.map +1 -0
- package/dist/electron-build/bollharness-integration/index.js +123 -0
- package/dist/electron-build/bollharness-integration/index.js.map +1 -0
- package/dist/electron-build/bollharness-integration/integration.js +531 -0
- package/dist/electron-build/bollharness-integration/integration.js.map +1 -0
- package/dist/electron-build/bollharness-integration/skill-adapter.js +608 -0
- package/dist/electron-build/bollharness-integration/skill-adapter.js.map +1 -0
- package/dist/electron-build/bootstrap/bootstrap.js +173 -0
- package/dist/electron-build/bootstrap/bootstrap.js.map +1 -0
- package/dist/electron-build/bootstrap/context-collector.js +358 -0
- package/dist/electron-build/bootstrap/context-collector.js.map +1 -0
- package/dist/electron-build/bootstrap/context-hierarchy.js +262 -0
- package/dist/electron-build/bootstrap/context-hierarchy.js.map +1 -0
- package/dist/electron-build/bootstrap/context-manager.js +211 -0
- package/dist/electron-build/bootstrap/context-manager.js.map +1 -0
- package/dist/electron-build/bootstrap/context-os.js +277 -0
- package/dist/electron-build/bootstrap/context-os.js.map +1 -0
- package/dist/electron-build/bootstrap/event-log.js +203 -0
- package/dist/electron-build/bootstrap/event-log.js.map +1 -0
- package/dist/electron-build/bootstrap/exhaust-scrubber.js +277 -0
- package/dist/electron-build/bootstrap/exhaust-scrubber.js.map +1 -0
- package/dist/electron-build/bootstrap/lifecycle-hooks.js +282 -0
- package/dist/electron-build/bootstrap/lifecycle-hooks.js.map +1 -0
- package/dist/electron-build/bootstrap/memory-compressor.js +377 -0
- package/dist/electron-build/bootstrap/memory-compressor.js.map +1 -0
- package/dist/electron-build/bootstrap/persona-loader.js +219 -0
- package/dist/electron-build/bootstrap/persona-loader.js.map +1 -0
- package/dist/electron-build/bootstrap/project-context.js +162 -0
- package/dist/electron-build/bootstrap/project-context.js.map +1 -0
- package/dist/electron-build/bootstrap/project-state.js +205 -0
- package/dist/electron-build/bootstrap/project-state.js.map +1 -0
- package/dist/electron-build/bootstrap/session-window.js +162 -0
- package/dist/electron-build/bootstrap/session-window.js.map +1 -0
- package/dist/electron-build/bootstrap/vector-index.js +291 -0
- package/dist/electron-build/bootstrap/vector-index.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js +22 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/clobShared.js +86 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/clobShared.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +37 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/createOrder.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +20 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/getMarket.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +29 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/getOrders.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +28 -0
- package/dist/electron-build/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/SafeSDK/deploySafe.js +10 -0
- package/dist/electron-build/constraint-runtime/src/tools/SafeSDK/deploySafe.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/autoPay.js +68 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/autoPay.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/createWallet.js +14 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/createWallet.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/getBalance.js +17 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/getBalance.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/importWallet.js +59 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/importWallet.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/sendTransaction.js +29 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/sendTransaction.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/signMessage.js +14 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/signMessage.js.map +1 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/transferToken.js +29 -0
- package/dist/electron-build/constraint-runtime/src/tools/WalletTools/transferToken.js.map +1 -0
- package/dist/electron-build/constraints/index.js +11 -0
- package/dist/electron-build/constraints/index.js.map +1 -0
- package/dist/electron-build/context-compaction/auto-compact.js +182 -0
- package/dist/electron-build/context-compaction/auto-compact.js.map +1 -0
- package/dist/electron-build/context-compaction/budget-gate.js +32 -0
- package/dist/electron-build/context-compaction/budget-gate.js.map +1 -0
- package/dist/electron-build/context-compaction/budget-reduce.js +39 -0
- package/dist/electron-build/context-compaction/budget-reduce.js.map +1 -0
- package/dist/electron-build/context-compaction/context-collapse.js +71 -0
- package/dist/electron-build/context-compaction/context-collapse.js.map +1 -0
- package/dist/electron-build/context-compaction/index.js +38 -0
- package/dist/electron-build/context-compaction/index.js.map +1 -0
- package/dist/electron-build/context-compaction/microcompact.js +55 -0
- package/dist/electron-build/context-compaction/microcompact.js.map +1 -0
- package/dist/electron-build/context-compaction/pipeline.js +128 -0
- package/dist/electron-build/context-compaction/pipeline.js.map +1 -0
- package/dist/electron-build/context-compaction/snip.js +50 -0
- package/dist/electron-build/context-compaction/snip.js.map +1 -0
- package/dist/electron-build/context-compaction/token-estimator.js +40 -0
- package/dist/electron-build/context-compaction/token-estimator.js.map +1 -0
- package/dist/electron-build/context-compaction/types.js +21 -0
- package/dist/electron-build/context-compaction/types.js.map +1 -0
- package/dist/electron-build/cron/tick-lock.js +247 -0
- package/dist/electron-build/cron/tick-lock.js.map +1 -0
- package/dist/electron-build/documents/reader.js +131 -0
- package/dist/electron-build/documents/reader.js.map +1 -0
- package/dist/electron-build/documents/store.js +220 -0
- package/dist/electron-build/documents/store.js.map +1 -0
- package/dist/electron-build/external-engines/delegate-handle.js +76 -0
- package/dist/electron-build/external-engines/delegate-handle.js.map +1 -0
- package/dist/electron-build/external-engines/delegate.js +225 -0
- package/dist/electron-build/external-engines/delegate.js.map +1 -0
- package/dist/electron-build/external-engines/discovery.js +448 -0
- package/dist/electron-build/external-engines/discovery.js.map +1 -0
- package/dist/electron-build/external-engines/types.js +13 -0
- package/dist/electron-build/external-engines/types.js.map +1 -0
- package/dist/electron-build/hooks/hooks-engine.js +367 -0
- package/dist/electron-build/hooks/hooks-engine.js.map +1 -0
- package/dist/electron-build/judgeness/reflect.js +100 -0
- package/dist/electron-build/judgeness/reflect.js.map +1 -0
- package/dist/electron-build/judgeness/store.js +536 -0
- package/dist/electron-build/judgeness/store.js.map +1 -0
- package/dist/electron-build/judgeness/types.js +21 -0
- package/dist/electron-build/judgeness/types.js.map +1 -0
- package/dist/electron-build/llm/config-store.js +551 -0
- package/dist/electron-build/llm/config-store.js.map +1 -0
- package/dist/electron-build/llm/error-lessons.js +76 -0
- package/dist/electron-build/llm/error-lessons.js.map +1 -0
- package/dist/electron-build/llm/pi-ai.js +830 -0
- package/dist/electron-build/llm/pi-ai.js.map +1 -0
- package/dist/electron-build/llm/system-prompt/registry.js +318 -0
- package/dist/electron-build/llm/system-prompt/registry.js.map +1 -0
- package/dist/electron-build/llm/system-prompt/strip-hibsml.js +55 -0
- package/dist/electron-build/llm/system-prompt/strip-hibsml.js.map +1 -0
- package/dist/electron-build/locales/en.js +32 -0
- package/dist/electron-build/locales/en.js.map +1 -0
- package/dist/electron-build/locales/zh.js +30 -0
- package/dist/electron-build/locales/zh.js.map +1 -0
- package/dist/electron-build/lsp/lsp-manager.js +327 -0
- package/dist/electron-build/lsp/lsp-manager.js.map +1 -0
- package/dist/electron-build/lsp/lsp-tools.js +226 -0
- package/dist/electron-build/lsp/lsp-tools.js.map +1 -0
- package/dist/electron-build/migration/external-agent-migrator.js +451 -0
- package/dist/electron-build/migration/external-agent-migrator.js.map +1 -0
- package/dist/electron-build/network/agent-network.js +775 -0
- package/dist/electron-build/network/agent-network.js.map +1 -0
- package/dist/electron-build/network/goal-event-bridge.js +62 -0
- package/dist/electron-build/network/goal-event-bridge.js.map +1 -0
- package/dist/electron-build/network/iroh-integration.js +117 -0
- package/dist/electron-build/network/iroh-integration.js.map +1 -0
- package/dist/electron-build/network/iroh-transport.js +550 -0
- package/dist/electron-build/network/iroh-transport.js.map +1 -0
- package/dist/electron-build/network/p2p.js +1103 -0
- package/dist/electron-build/network/p2p.js.map +1 -0
- package/dist/electron-build/network/storage/adapters/json-adapter.js +416 -0
- package/dist/electron-build/network/storage/adapters/json-adapter.js.map +1 -0
- package/dist/electron-build/network/storage/types.js +18 -0
- package/dist/electron-build/network/storage/types.js.map +1 -0
- package/dist/electron-build/orbitdb/agent-tools.js +402 -0
- package/dist/electron-build/orbitdb/agent-tools.js.map +1 -0
- package/dist/electron-build/orbitdb/cid-database.js +284 -0
- package/dist/electron-build/orbitdb/cid-database.js.map +1 -0
- package/dist/electron-build/orbitdb/context-store.js +99 -0
- package/dist/electron-build/orbitdb/context-store.js.map +1 -0
- package/dist/electron-build/orbitdb/ipfs-node.js +120 -0
- package/dist/electron-build/orbitdb/ipfs-node.js.map +1 -0
- package/dist/electron-build/orbitdb/kanban-store.js +299 -0
- package/dist/electron-build/orbitdb/kanban-store.js.map +1 -0
- package/dist/electron-build/orbitdb/task-store.js +155 -0
- package/dist/electron-build/orbitdb/task-store.js.map +1 -0
- package/dist/electron-build/orbitdb/trajectory-store.js +194 -0
- package/dist/electron-build/orbitdb/trajectory-store.js.map +1 -0
- package/dist/electron-build/orbitdb/ui-cid.js +77 -0
- package/dist/electron-build/orbitdb/ui-cid.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-a2ui/index.js +89 -0
- package/dist/electron-build/pi-ecosystem-a2ui/index.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-goals/index.js +512 -0
- package/dist/electron-build/pi-ecosystem-goals/index.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/adaptive-scan.js +325 -0
- package/dist/electron-build/pi-ecosystem-judgment/adaptive-scan.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/causal-judge.js +492 -0
- package/dist/electron-build/pi-ecosystem-judgment/causal-judge.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/cleanup.js +167 -0
- package/dist/electron-build/pi-ecosystem-judgment/cleanup.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/decision.js +321 -0
- package/dist/electron-build/pi-ecosystem-judgment/decision.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/detect-hook.js +175 -0
- package/dist/electron-build/pi-ecosystem-judgment/detect-hook.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/distill-prompt.js +232 -0
- package/dist/electron-build/pi-ecosystem-judgment/distill-prompt.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/distillation.js +304 -0
- package/dist/electron-build/pi-ecosystem-judgment/distillation.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/evolve-judgment.js +176 -0
- package/dist/electron-build/pi-ecosystem-judgment/evolve-judgment.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/human-value-pipeline.js +65 -0
- package/dist/electron-build/pi-ecosystem-judgment/human-value-pipeline.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/human-value-store.js +808 -0
- package/dist/electron-build/pi-ecosystem-judgment/human-value-store.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/index.js +508 -0
- package/dist/electron-build/pi-ecosystem-judgment/index.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/injection-gate.js +334 -0
- package/dist/electron-build/pi-ecosystem-judgment/injection-gate.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/monitor-gate.js +228 -0
- package/dist/electron-build/pi-ecosystem-judgment/monitor-gate.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-judgment/value-injection.js +598 -0
- package/dist/electron-build/pi-ecosystem-judgment/value-injection.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-mcp/index.js +643 -0
- package/dist/electron-build/pi-ecosystem-mcp/index.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-mcp/ui-tools.js +116 -0
- package/dist/electron-build/pi-ecosystem-mcp/ui-tools.js.map +1 -0
- package/dist/electron-build/pi-ecosystem-subagents/index.js +352 -0
- package/dist/electron-build/pi-ecosystem-subagents/index.js.map +1 -0
- package/dist/electron-build/security/builtin-guards.js +133 -0
- package/dist/electron-build/security/builtin-guards.js.map +1 -0
- package/dist/electron-build/security/context-router-tool.js +111 -0
- package/dist/electron-build/security/context-router-tool.js.map +1 -0
- package/dist/electron-build/security/input-scanner.js +263 -0
- package/dist/electron-build/security/input-scanner.js.map +1 -0
- package/dist/electron-build/security/react-harness.js +148 -0
- package/dist/electron-build/security/react-harness.js.map +1 -0
- package/dist/electron-build/security/tool-gate.js +287 -0
- package/dist/electron-build/security/tool-gate.js.map +1 -0
- package/dist/electron-build/setup/setup-store.js +648 -0
- package/dist/electron-build/setup/setup-store.js.map +1 -0
- package/dist/electron-build/social/channels/ChannelManager.js +444 -0
- package/dist/electron-build/social/channels/ChannelManager.js.map +1 -0
- package/dist/electron-build/social/channels/DiapChannelBridge.js +451 -0
- package/dist/electron-build/social/channels/DiapChannelBridge.js.map +1 -0
- package/dist/electron-build/social/channels/InterestMatcher.js +135 -0
- package/dist/electron-build/social/channels/InterestMatcher.js.map +1 -0
- package/dist/electron-build/social/channels/types.js +21 -0
- package/dist/electron-build/social/channels/types.js.map +1 -0
- package/dist/electron-build/social/global-shared-context.js +368 -0
- package/dist/electron-build/social/global-shared-context.js.map +1 -0
- package/dist/electron-build/social/heartbeat.js +882 -0
- package/dist/electron-build/social/heartbeat.js.map +1 -0
- package/dist/electron-build/storage/did-catalog-bridge.js +314 -0
- package/dist/electron-build/storage/did-catalog-bridge.js.map +1 -0
- package/dist/electron-build/storage/did-catalog.js +272 -0
- package/dist/electron-build/storage/did-catalog.js.map +1 -0
- package/dist/electron-build/utils/auto-update.js +140 -558
- package/dist/electron-build/utils/auto-update.js.map +1 -1
- package/dist/electron-build/utils/module-context.js +98 -0
- package/dist/electron-build/utils/module-context.js.map +1 -0
- package/dist/electron-build/utils/runtime-bootstrap.js +745 -0
- package/dist/electron-build/utils/runtime-bootstrap.js.map +1 -0
- package/dist/electron-build/utils/update-manager.js +770 -0
- package/dist/electron-build/utils/update-manager.js.map +1 -0
- package/dist/electron-build/utils/update-state.js +406 -0
- package/dist/electron-build/utils/update-state.js.map +1 -0
- package/dist/electron-build/utils/version-info.js +562 -0
- package/dist/electron-build/utils/version-info.js.map +1 -0
- package/dist/electron-build/web/i18n.js +146 -0
- package/dist/electron-build/web/i18n.js.map +1 -0
- package/dist/electron-build/web/routes-x402-info.js +232 -0
- package/dist/electron-build/web/routes-x402-info.js.map +1 -0
- package/dist/electron-build/web/server-storage.js +390 -0
- package/dist/electron-build/web/server-storage.js.map +1 -0
- package/dist/electron-build/web/server-types.js +52 -0
- package/dist/electron-build/web/server-types.js.map +1 -0
- package/dist/electron-build/web/task-deps.js +41 -0
- package/dist/electron-build/web/task-deps.js.map +1 -0
- package/dist/index.js +28 -27
- package/dist/llm/system-prompt/registry.js +6 -3
- package/dist/utils/auto-update.js +138 -525
- package/dist/utils/module-context.js +59 -0
- package/dist/utils/runtime-bootstrap.js +682 -0
- package/dist/utils/update-cli.js +82 -0
- package/dist/utils/update-health.js +401 -0
- package/dist/utils/update-manager.js +716 -0
- package/dist/utils/update-state.js +353 -0
- package/dist/utils/version-info.js +510 -0
- package/package.json +1 -1
- package/scripts/build-cli.js +32 -151
- package/scripts/postinstall.js +153 -76
|
@@ -0,0 +1,745 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* runtime-bootstrap.ts — **运行时安装与配置的唯一管理器** (2026-09-19, leo 计划 Phase 0-8)
|
|
4
|
+
*
|
|
5
|
+
* 新的完成定义 (冻结):
|
|
6
|
+
* **Bolloon 安装完成 = Node/npm、Git、Python 三个运行时都已可执行、版本可验证、路径已配置。**
|
|
7
|
+
* 任何一个必需运行时不可用 → 整个安装**不能**宣布成功。
|
|
8
|
+
*
|
|
9
|
+
* 为什么需要它: 此前 `install.sh` 只查 Node/npm, `postinstall.js` 不查 Git/Python,
|
|
10
|
+
* `version-info.ts` 只"探测"Python 不负责配置, PATH 没有任何统一来源 —— 于是
|
|
11
|
+
* "装上但不可用 / 看似成功实际缺失" 这类状态没有任何事实可查。
|
|
12
|
+
*
|
|
13
|
+
* 边界 (冻结):
|
|
14
|
+
* - **不偷偷 sudo / 不静默高权限**: 需要管理员权限时进 `needsAdmin` + 只在显式 `allowSudo` 才执行;
|
|
15
|
+
* - **不覆盖用户已有运行时**: 已满足最低版本一律 `reuse`;
|
|
16
|
+
* - **不写用户配置里除 `runtime.*` 之外的任何字段**;
|
|
17
|
+
* - **每次启动重新验证**, 不盲信配置文件 (配置只是"优先探测路径")。
|
|
18
|
+
*
|
|
19
|
+
* 命令构造与执行分离: 纯函数 (探测/计划/报告) 可单测; 真执行只在 `bootstrapRuntimes` 里发生。
|
|
20
|
+
*/
|
|
21
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
24
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
25
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperty(o, k2, desc);
|
|
28
|
+
}) : (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
o[k2] = m[k];
|
|
31
|
+
}));
|
|
32
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34
|
+
}) : function(o, v) {
|
|
35
|
+
o["default"] = v;
|
|
36
|
+
});
|
|
37
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
38
|
+
var ownKeys = function(o) {
|
|
39
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
40
|
+
var ar = [];
|
|
41
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
return ownKeys(o);
|
|
45
|
+
};
|
|
46
|
+
return function (mod) {
|
|
47
|
+
if (mod && mod.__esModule) return mod;
|
|
48
|
+
var result = {};
|
|
49
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
50
|
+
__setModuleDefault(result, mod);
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
})();
|
|
54
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
+
exports.SUPPORTED_PLATFORMS = exports.RUNTIME_MIN = void 0;
|
|
56
|
+
exports.parseVersionString = parseVersionString;
|
|
57
|
+
exports.versionAtLeast = versionAtLeast;
|
|
58
|
+
exports.findExecutable = findExecutable;
|
|
59
|
+
exports.looksLikeStoreAlias = looksLikeStoreAlias;
|
|
60
|
+
exports.probeRuntime = probeRuntime;
|
|
61
|
+
exports.packageManagerFor = packageManagerFor;
|
|
62
|
+
exports.detectPackageManager = detectPackageManager;
|
|
63
|
+
exports.detectLinuxDistro = detectLinuxDistro;
|
|
64
|
+
exports.planBootstrap = planBootstrap;
|
|
65
|
+
exports.manualAdvice = manualAdvice;
|
|
66
|
+
exports.renderBootstrapPlan = renderBootstrapPlan;
|
|
67
|
+
exports.verifyGitUsable = verifyGitUsable;
|
|
68
|
+
exports.verifyPythonUsable = verifyPythonUsable;
|
|
69
|
+
exports.verifyNodeLoadsCli = verifyNodeLoadsCli;
|
|
70
|
+
exports.verifyNpmUsable = verifyNpmUsable;
|
|
71
|
+
exports.verifyRuntimesDeep = verifyRuntimesDeep;
|
|
72
|
+
exports.buildRuntimeConfig = buildRuntimeConfig;
|
|
73
|
+
exports.writeRuntimeConfig = writeRuntimeConfig;
|
|
74
|
+
exports.readRuntimeConfig = readRuntimeConfig;
|
|
75
|
+
exports.readRuntimeConfigWithFallback = readRuntimeConfigWithFallback;
|
|
76
|
+
exports.evaluateCapabilities = evaluateCapabilities;
|
|
77
|
+
exports.detectRuntimeReport = detectRuntimeReport;
|
|
78
|
+
exports.bootstrapRuntimes = bootstrapRuntimes;
|
|
79
|
+
exports.renderRuntimeReport = renderRuntimeReport;
|
|
80
|
+
exports.readIncompleteMarker = readIncompleteMarker;
|
|
81
|
+
exports.renderRuntimeLines = renderRuntimeLines;
|
|
82
|
+
const os = __importStar(require("os"));
|
|
83
|
+
const path = __importStar(require("path"));
|
|
84
|
+
const fs = __importStar(require("fs"));
|
|
85
|
+
const fsp = __importStar(require("fs/promises"));
|
|
86
|
+
const child_process_1 = require("child_process");
|
|
87
|
+
const setup_store_js_1 = require("../setup/setup-store.js");
|
|
88
|
+
exports.RUNTIME_MIN = {
|
|
89
|
+
node: { min: '18.0.0', why: 'Bolloon CLI 与依赖 (ESM / 全局 fetch / node: 前缀) 的运行时' },
|
|
90
|
+
npm: { min: '9.0.0', why: '随 Node 18+ 发布; 全局安装与 `update now` 的安装通道' },
|
|
91
|
+
git: { min: '2.20.0', why: '`git -C` / `--porcelain` / worktree —— 源码更新与协作通道' },
|
|
92
|
+
python: { min: '3.8.0', why: 'scripts/** (wiki 门禁/消融夹具) 与 Python Skill 执行' },
|
|
93
|
+
};
|
|
94
|
+
/** Phase 0 平台范围: 三个平台都在内; 未列出的平台 → `unsupported` (不假装能装)。 */
|
|
95
|
+
exports.SUPPORTED_PLATFORMS = ['darwin', 'linux', 'win32'];
|
|
96
|
+
// ── 版本比较 (自己实现, 不引依赖) ──────────────────────────────────────────
|
|
97
|
+
function parseVersionString(raw) {
|
|
98
|
+
if (!raw)
|
|
99
|
+
return null;
|
|
100
|
+
const m = String(raw).match(/\d+\.\d+(\.\d+)?/);
|
|
101
|
+
return m ? m[0] : null;
|
|
102
|
+
}
|
|
103
|
+
function versionAtLeast(version, min) {
|
|
104
|
+
if (!version)
|
|
105
|
+
return false;
|
|
106
|
+
const a = version.split('.').map((n) => parseInt(n, 10) || 0);
|
|
107
|
+
const b = min.split('.').map((n) => parseInt(n, 10) || 0);
|
|
108
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
109
|
+
const x = a[i] ?? 0;
|
|
110
|
+
const y = b[i] ?? 0;
|
|
111
|
+
if (x > y)
|
|
112
|
+
return true;
|
|
113
|
+
if (x < y)
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
// ── 探测 (纯执行 + 纯解析) ─────────────────────────────────────────────────
|
|
119
|
+
/** 在 PATH + 平台默认目录里找可执行文件 (找不到返回 null, 不猜)。 */
|
|
120
|
+
function findExecutable(names, envPath = process.env.PATH || '') {
|
|
121
|
+
const exts = process.platform === 'win32' ? ['.exe', '.cmd', '.bat', ''] : [''];
|
|
122
|
+
const dirs = envPath.split(path.delimiter).filter(Boolean);
|
|
123
|
+
if (process.platform === 'win32') {
|
|
124
|
+
const extra = [process.env.ProgramFiles, process.env['ProgramFiles(x86)'], process.env.LOCALAPPDATA]
|
|
125
|
+
.filter(Boolean).map(String);
|
|
126
|
+
for (const e of extra)
|
|
127
|
+
dirs.push(path.join(e, 'Git', 'cmd'), path.join(e, 'Programs', 'Python'));
|
|
128
|
+
}
|
|
129
|
+
for (const dir of dirs) {
|
|
130
|
+
for (const name of names) {
|
|
131
|
+
for (const ext of exts) {
|
|
132
|
+
const p = path.join(dir, name + ext);
|
|
133
|
+
try {
|
|
134
|
+
const st = fs.statSync(p);
|
|
135
|
+
if (st.isFile())
|
|
136
|
+
return p;
|
|
137
|
+
}
|
|
138
|
+
catch { /* 继续 */ }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function runVersion(cmd, args, timeoutMs = 8000) {
|
|
145
|
+
const t0 = Date.now();
|
|
146
|
+
try {
|
|
147
|
+
const out = (0, child_process_1.execFileSync)(cmd, args, { encoding: 'utf-8', timeout: timeoutMs, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
148
|
+
return { ok: true, out: String(out).trim(), err: '', ms: Date.now() - t0 };
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
return { ok: false, out: String(e?.stdout || '').trim(), err: String(e?.stderr || e?.message || '').trim(), ms: Date.now() - t0 };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Windows "App Execution Aliases" 会拦 Python: 路径在 WindowsApps 下且跑不起来/跑成 0 字节。 */
|
|
155
|
+
function looksLikeStoreAlias(p) {
|
|
156
|
+
if (!p)
|
|
157
|
+
return false;
|
|
158
|
+
return /WindowsApps[\\/]python/i.test(p);
|
|
159
|
+
}
|
|
160
|
+
/** 探测单个运行时: 真执行 `--version` 拿版本 + 绝对路径。 */
|
|
161
|
+
function probeRuntime(id, opts = {}) {
|
|
162
|
+
const startedAt = new Date().toISOString();
|
|
163
|
+
const notes = [];
|
|
164
|
+
const min = exports.RUNTIME_MIN[id].min;
|
|
165
|
+
const base = {
|
|
166
|
+
runtime: id, status: 'missing', path: null, version: null, source: 'existing',
|
|
167
|
+
meetsMinimum: false, installedByBolloon: false, startedAt, notes,
|
|
168
|
+
};
|
|
169
|
+
// 候选命令: 配置里的绝对路径优先, 然后是 PATH 常见名
|
|
170
|
+
const candidates = [];
|
|
171
|
+
if (opts.preferredPath)
|
|
172
|
+
candidates.push({ cmd: opts.preferredPath, args: id === 'python' ? ['--version'] : ['--version'] });
|
|
173
|
+
if (id === 'node')
|
|
174
|
+
candidates.push({ cmd: 'node', args: ['--version'] });
|
|
175
|
+
if (id === 'npm')
|
|
176
|
+
candidates.push({ cmd: 'npm', args: ['--version'] });
|
|
177
|
+
if (id === 'git')
|
|
178
|
+
candidates.push({ cmd: 'git', args: ['--version'] });
|
|
179
|
+
if (id === 'python') {
|
|
180
|
+
candidates.push({ cmd: 'python3', args: ['--version'] }, { cmd: 'python', args: ['--version'] });
|
|
181
|
+
if (process.platform === 'win32')
|
|
182
|
+
candidates.push({ cmd: 'py', args: ['-3', '--version'] });
|
|
183
|
+
}
|
|
184
|
+
for (const c of candidates) {
|
|
185
|
+
const r = runVersion(c.cmd, c.args);
|
|
186
|
+
const rawVersion = parseVersionString(r.out || r.err);
|
|
187
|
+
const resolved = findExecutable([path.basename(c.cmd)]) || (opts.preferredPath === c.cmd ? c.cmd : null);
|
|
188
|
+
if (!r.ok || !rawVersion) {
|
|
189
|
+
if (looksLikeStoreAlias(resolved)) {
|
|
190
|
+
notes.push('命令指向 Windows Store alias —— 这不是真的 Python 解释器');
|
|
191
|
+
}
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (id === 'python' && looksLikeStoreAlias(resolved)) {
|
|
195
|
+
base.error = 'python 命令指向 Microsoft Store alias';
|
|
196
|
+
notes.push('Windows App Execution Aliases 拦截: 需在「应用执行别名」里关掉 python.exe 或改用官方安装器');
|
|
197
|
+
base.status = 'missing';
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const meets = versionAtLeast(rawVersion, min);
|
|
201
|
+
return {
|
|
202
|
+
...base,
|
|
203
|
+
status: meets ? 'found' : 'failed',
|
|
204
|
+
path: resolved || c.cmd,
|
|
205
|
+
version: rawVersion,
|
|
206
|
+
meetsMinimum: meets,
|
|
207
|
+
verified: false,
|
|
208
|
+
error: meets ? undefined : `${id} ${rawVersion} 低于最低要求 ${min} (${exports.RUNTIME_MIN[id].why})`,
|
|
209
|
+
notes: [
|
|
210
|
+
...notes,
|
|
211
|
+
...(opts.preferredPath && resolved && path.resolve(opts.preferredPath) !== path.resolve(resolved)
|
|
212
|
+
? ['配置里的路径已失效, 已按 PATH 重新发现'] : []),
|
|
213
|
+
...(opts.preferredPath && !resolved ? ['配置里的路径不可用'] : []),
|
|
214
|
+
],
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
base.error = `找不到可用的 ${id} 命令`;
|
|
218
|
+
return base;
|
|
219
|
+
}
|
|
220
|
+
const PKG_NAME = {
|
|
221
|
+
// 每个包管理器里运行时的包名 (Linux 由发行版适配器决定, 见 Phase 2)
|
|
222
|
+
node: { brew: ['node'], apt: ['nodejs'], dnf: ['nodejs'], yum: ['nodejs'], pacman: ['nodejs'], zypper: ['nodejs'], apk: ['nodejs'], winget: ['OpenJS.NodeJS.LTS'], choco: ['nodejs-lts'] },
|
|
223
|
+
npm: { apt: ['npm'], dnf: ['npm'], yum: ['npm'], pacman: ['npm'], zypper: ['npm'], apk: ['npm'] },
|
|
224
|
+
git: { brew: ['git'], apt: ['git'], dnf: ['git'], yum: ['git'], pacman: ['git'], zypper: ['git'], apk: ['git'], winget: ['Git.Git'], choco: ['git'] },
|
|
225
|
+
python: { brew: ['python'], apt: ['python3', 'python3-venv'], dnf: ['python3', 'python3-pip'], yum: ['python3'], pacman: ['python'], zypper: ['python3'], apk: ['python3'], winget: ['Python.Python.3.12'], choco: ['python3'] },
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* 由包管理器种类构造管理器对象 (**纯函数**)。
|
|
229
|
+
* 抽出来的理由: winget/choco 的命令形状必须在 Linux/macOS 上也能被单测覆盖 ——
|
|
230
|
+
* 不然"Windows 支持"就只能靠嘴说。
|
|
231
|
+
*/
|
|
232
|
+
function packageManagerFor(kind, pmPath) {
|
|
233
|
+
const needsAdmin = kind === 'apt' || kind === 'dnf' || kind === 'yum' || kind === 'pacman' || kind === 'zypper' || kind === 'apk' || kind === 'choco';
|
|
234
|
+
return {
|
|
235
|
+
kind,
|
|
236
|
+
path: pmPath,
|
|
237
|
+
needsAdmin,
|
|
238
|
+
installCmd: (pkgs) => {
|
|
239
|
+
switch (kind) {
|
|
240
|
+
case 'brew': return ['brew', 'install', ...pkgs];
|
|
241
|
+
case 'choco': return ['choco', 'install', ...pkgs, '-y'];
|
|
242
|
+
case 'winget': return ['winget', 'install', '--silent', '--accept-package-agreements', '--accept-source-agreements', ...pkgs.flatMap((x) => ['--id', x])];
|
|
243
|
+
case 'apt': return ['apt-get', 'install', '-y', ...pkgs];
|
|
244
|
+
case 'pacman': return ['pacman', '-S', '--noconfirm', ...pkgs];
|
|
245
|
+
case 'zypper': return ['zypper', '--non-interactive', 'install', ...pkgs];
|
|
246
|
+
case 'apk': return ['apk', 'add', ...pkgs];
|
|
247
|
+
default: return [kind, 'install', '-y', ...pkgs];
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function detectPackageManager(platform = process.platform, envPath = process.env.PATH || '') {
|
|
253
|
+
const defs = platform === 'darwin' ? [{ kind: 'brew', bins: ['brew'] }]
|
|
254
|
+
: platform === 'win32' ? [{ kind: 'winget', bins: ['winget'] }, { kind: 'choco', bins: ['choco'] }]
|
|
255
|
+
: [
|
|
256
|
+
{ kind: 'apt', bins: ['apt-get'] },
|
|
257
|
+
{ kind: 'dnf', bins: ['dnf'] },
|
|
258
|
+
{ kind: 'yum', bins: ['yum'] },
|
|
259
|
+
{ kind: 'pacman', bins: ['pacman'] },
|
|
260
|
+
{ kind: 'zypper', bins: ['zypper'] },
|
|
261
|
+
{ kind: 'apk', bins: ['apk'] },
|
|
262
|
+
];
|
|
263
|
+
for (const d of defs) {
|
|
264
|
+
const p = findExecutable(d.bins, envPath);
|
|
265
|
+
if (!p)
|
|
266
|
+
continue;
|
|
267
|
+
return packageManagerFor(d.kind, p);
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
/** 发行版识别 (Linux 适配器用; 只读 /etc/os-release)。 */
|
|
272
|
+
function detectLinuxDistro() {
|
|
273
|
+
try {
|
|
274
|
+
const txt = fs.readFileSync('/etc/os-release', 'utf-8');
|
|
275
|
+
const id = /^ID=(.+)$/m.exec(txt)?.[1]?.replace(/"/g, '') || '';
|
|
276
|
+
const ver = /^VERSION_ID=(.+)$/m.exec(txt)?.[1]?.replace(/"/g, '');
|
|
277
|
+
return id ? { id, version: ver } : null;
|
|
278
|
+
}
|
|
279
|
+
catch {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function planBootstrap(facts, opts = {}) {
|
|
284
|
+
const platform = opts.platform || process.platform;
|
|
285
|
+
const manager = opts.manager !== undefined ? opts.manager : detectPackageManager(platform, opts.envPath);
|
|
286
|
+
const supported = exports.SUPPORTED_PLATFORMS.includes(platform);
|
|
287
|
+
const missing = facts.filter((f) => f.status === 'missing').map((f) => f.runtime);
|
|
288
|
+
const belowMinimum = facts.filter((f) => f.status === 'failed').map((f) => f.runtime);
|
|
289
|
+
const present = facts.filter((f) => f.status === 'found').map((f) => f.runtime);
|
|
290
|
+
const steps = [];
|
|
291
|
+
const blockers = [];
|
|
292
|
+
const advice = [];
|
|
293
|
+
let needsAdmin = false;
|
|
294
|
+
let pathChanges = false;
|
|
295
|
+
if (!supported) {
|
|
296
|
+
for (const f of facts) {
|
|
297
|
+
steps.push({
|
|
298
|
+
runtime: f.runtime, action: 'unsupported', command: null,
|
|
299
|
+
note: `平台 ${platform} 未在支持矩阵内 (${exports.SUPPORTED_PLATFORMS.join('/')}) —— 不自动安装, 请手动准备运行时`,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
return { platform, present, missing, belowMinimum, manager: manager ? { kind: manager.kind, path: manager.path } : null, steps, needsAdmin: false, pathChanges: false, canAutoInstall: false, blockers: [`不支持的平台 ${platform}`], advice };
|
|
303
|
+
}
|
|
304
|
+
for (const f of facts) {
|
|
305
|
+
if (f.status === 'found') {
|
|
306
|
+
steps.push({ runtime: f.runtime, action: 'reuse', command: null, note: `已有 ${f.version} (${f.path}) —— 复用, 不覆盖用户已有运行时` });
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
const pkgs = PKG_NAME[f.runtime]?.[manager?.kind || ''] || [];
|
|
310
|
+
if (!manager) {
|
|
311
|
+
steps.push({
|
|
312
|
+
runtime: f.runtime, action: 'manual', command: null,
|
|
313
|
+
note: platform === 'darwin'
|
|
314
|
+
? '没有 Homebrew —— 不静默安装 Homebrew (会写 /opt/homebrew 或 /usr/local 并可能要管理员密码); 请手动安装 git/python 或先装 Homebrew'
|
|
315
|
+
: '没有可用的包管理器 —— 请手动安装后重跑',
|
|
316
|
+
});
|
|
317
|
+
advice.push(manualAdvice(f.runtime, platform));
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (pkgs.length === 0) {
|
|
321
|
+
steps.push({ runtime: f.runtime, action: 'manual', command: null, note: `${manager.kind} 里没有 ${f.runtime} 的映射包名` });
|
|
322
|
+
advice.push(manualAdvice(f.runtime, platform));
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
const needsElevation = manager.needsAdmin && typeof process.getuid === 'function' && process.getuid() !== 0;
|
|
326
|
+
const base = manager.installCmd(pkgs);
|
|
327
|
+
const command = needsElevation ? ['sudo', ...base] : base;
|
|
328
|
+
steps.push({
|
|
329
|
+
runtime: f.runtime, action: 'install', command,
|
|
330
|
+
note: needsElevation ? `需要管理员权限 (会执行 sudo, 只在显式同意后)` : `用 ${manager.kind} 安装: ${pkgs.join(', ')}`,
|
|
331
|
+
});
|
|
332
|
+
needsAdmin = needsAdmin || needsElevation;
|
|
333
|
+
pathChanges = true;
|
|
334
|
+
}
|
|
335
|
+
// Python 安装后 PATH 可能变 (brew/pyenv/Windows); node/npm 同理标注
|
|
336
|
+
const canAutoInstall = steps.some((s) => s.action === 'install') && !blockers.length;
|
|
337
|
+
if (missing.includes('git'))
|
|
338
|
+
advice.push('Git 缺失会让「源码更新」与「协作」能力不可用 —— 不把缺 Git 隐藏成后续运行时错误');
|
|
339
|
+
if (missing.includes('python'))
|
|
340
|
+
advice.push('Python 缺失会让 wiki 门禁脚本与 Python Skill 不可用');
|
|
341
|
+
return { platform, distro: platform === 'linux' ? detectLinuxDistro() : null, present, missing, belowMinimum, manager: manager ? { kind: manager.kind, path: manager.path } : null, steps, needsAdmin, pathChanges, canAutoInstall, blockers, advice };
|
|
342
|
+
}
|
|
343
|
+
function manualAdvice(id, platform) {
|
|
344
|
+
if (platform === 'darwin') {
|
|
345
|
+
return id === 'python'
|
|
346
|
+
? 'macOS: 装 Homebrew 后 `brew install python`, 或用 python.org 官方安装器 (https://www.python.org/downloads/macos/)'
|
|
347
|
+
: id === 'git' ? 'macOS: `brew install git`, 或 `xcode-select --install` (Command Line Tools 自带 git)'
|
|
348
|
+
: `macOS: \`brew install ${id}\` 或官方安装器`;
|
|
349
|
+
}
|
|
350
|
+
if (platform === 'win32') {
|
|
351
|
+
return id === 'python'
|
|
352
|
+
? 'Windows: `winget install Python.Python.3.12` (装完到「应用执行别名」关掉 python.exe, 避免 Store alias 劫持)'
|
|
353
|
+
: `Windows: \`winget install ${id === 'git' ? 'Git.Git' : id === 'node' ? 'OpenJS.NodeJS.LTS' : id}\``;
|
|
354
|
+
}
|
|
355
|
+
return `Linux: 用发行版包管理器安装 ${id} (apt: \`sudo apt-get install -y ${id === 'python' ? 'python3' : id === 'node' ? 'nodejs' : id}\`)`;
|
|
356
|
+
}
|
|
357
|
+
function renderBootstrapPlan(plan) {
|
|
358
|
+
const L = [];
|
|
359
|
+
L.push('运行时预检结果:');
|
|
360
|
+
L.push(` 平台: ${plan.platform}${plan.distro ? ` (${plan.distro.id}${plan.distro.version ? ' ' + plan.distro.version : ''})` : ''}`);
|
|
361
|
+
L.push(` 已就绪: ${plan.present.join(', ') || '(无)'}`);
|
|
362
|
+
if (plan.missing.length)
|
|
363
|
+
L.push(` 缺失: ${plan.missing.join(', ')}`);
|
|
364
|
+
if (plan.belowMinimum.length)
|
|
365
|
+
L.push(` 版本不足: ${plan.belowMinimum.join(', ')}`);
|
|
366
|
+
L.push(` 包管理器: ${plan.manager ? `${plan.manager.kind} (${plan.manager.path})` : '(无)'}`);
|
|
367
|
+
L.push('');
|
|
368
|
+
for (const s of plan.steps) {
|
|
369
|
+
L.push(` [${s.action}] ${s.runtime}: ${s.note}`);
|
|
370
|
+
if (s.command)
|
|
371
|
+
L.push(` ${s.command.join(' ')}`);
|
|
372
|
+
}
|
|
373
|
+
L.push('');
|
|
374
|
+
L.push(` 需要管理员权限: ${plan.needsAdmin ? '是' : '否'}`);
|
|
375
|
+
L.push(` 将修改 PATH: ${plan.pathChanges ? '是' : '否'}`);
|
|
376
|
+
if (plan.blockers.length)
|
|
377
|
+
L.push(` 阻塞: ${plan.blockers.join('; ')}`);
|
|
378
|
+
for (const a of plan.advice)
|
|
379
|
+
L.push(` ⚠ ${a}`);
|
|
380
|
+
return L.join('\n');
|
|
381
|
+
}
|
|
382
|
+
/** git: 真建一个临时仓库并读状态。 */
|
|
383
|
+
function verifyGitUsable(gitPath) {
|
|
384
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'bolloon-git-check-'));
|
|
385
|
+
try {
|
|
386
|
+
const init = (0, child_process_1.spawnSync)(gitPath, ['init', '-q'], { cwd: dir, encoding: 'utf-8', timeout: 20000 });
|
|
387
|
+
if (init.status !== 0)
|
|
388
|
+
return { ok: false, detail: `git init 失败: ${(init.stderr || '').slice(0, 200)}` };
|
|
389
|
+
fs.writeFileSync(path.join(dir, 'f.txt'), 'x');
|
|
390
|
+
(0, child_process_1.spawnSync)(gitPath, ['add', 'f.txt'], { cwd: dir, encoding: 'utf-8', timeout: 20000 });
|
|
391
|
+
const st = (0, child_process_1.spawnSync)(gitPath, ['status', '--porcelain'], { cwd: dir, encoding: 'utf-8', timeout: 20000 });
|
|
392
|
+
const out = String(st.stdout || '').trim();
|
|
393
|
+
if (!/^A\s+f\.txt/m.test(out))
|
|
394
|
+
return { ok: false, detail: `git status 读到 "${out}" (期望 A f.txt)` };
|
|
395
|
+
const cfg = (0, child_process_1.spawnSync)(gitPath, ['-C', dir, 'rev-parse', '--is-inside-work-tree'], { encoding: 'utf-8', timeout: 20000 });
|
|
396
|
+
if (!/true/.test(String(cfg.stdout)))
|
|
397
|
+
return { ok: false, detail: 'git -C 不可用' };
|
|
398
|
+
return { ok: true, detail: 'git init/add/status/`-C` 真跑通过' };
|
|
399
|
+
}
|
|
400
|
+
finally {
|
|
401
|
+
try {
|
|
402
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
403
|
+
}
|
|
404
|
+
catch { /* 忽略 */ }
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/** python: 真跑一段最小脚本。 */
|
|
408
|
+
function verifyPythonUsable(pyPath) {
|
|
409
|
+
const r = (0, child_process_1.spawnSync)(pyPath, ['-c', 'import sys; sys.stdout.write(str(6*7))'], { encoding: 'utf-8', timeout: 20000 });
|
|
410
|
+
if (r.status !== 0)
|
|
411
|
+
return { ok: false, detail: `执行失败: ${(r.stderr || '').slice(0, 200)}` };
|
|
412
|
+
const out = String(r.stdout || '').trim();
|
|
413
|
+
if (out !== '42')
|
|
414
|
+
return { ok: false, detail: `输出 "${out}" (期望 42)` };
|
|
415
|
+
return { ok: true, detail: 'python -c 真跑通过 (6*7=42)' };
|
|
416
|
+
}
|
|
417
|
+
/** node: 真加载 Bolloon CLI 入口并读回版本 (不是只跑 node --version)。 */
|
|
418
|
+
function verifyNodeLoadsCli(nodePath, entryPath) {
|
|
419
|
+
const r = (0, child_process_1.spawnSync)(nodePath, [entryPath, '--version', 'json'], { encoding: 'utf-8', timeout: 180000, maxBuffer: 8 * 1024 * 1024 });
|
|
420
|
+
if (r.status !== 0)
|
|
421
|
+
return { ok: false, detail: `CLI 启动失败 (exit ${r.status}): ${String(r.stderr || '').slice(0, 200)}` };
|
|
422
|
+
const s = String(r.stdout || '');
|
|
423
|
+
const i = s.indexOf('{');
|
|
424
|
+
if (i < 0)
|
|
425
|
+
return { ok: false, detail: 'CLI 没有输出可解析的版本 JSON' };
|
|
426
|
+
try {
|
|
427
|
+
const v = JSON.parse(s.slice(i));
|
|
428
|
+
return { ok: true, detail: `CLI 加载成功, 报出版本 ${v.packageVersion}` };
|
|
429
|
+
}
|
|
430
|
+
catch {
|
|
431
|
+
return { ok: false, detail: '版本 JSON 无法解析' };
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/** npm: 读本地全局安装信息 (网络查询交给 update 检查, 不在这里重复打 registry)。 */
|
|
435
|
+
function verifyNpmUsable(npmPath) {
|
|
436
|
+
const r = (0, child_process_1.spawnSync)(npmPath, ['ls', '-g', '--depth=0', '--json'], { encoding: 'utf-8', timeout: 60000, maxBuffer: 16 * 1024 * 1024 });
|
|
437
|
+
const out = String(r.stdout || '').trim();
|
|
438
|
+
if (!out)
|
|
439
|
+
return { ok: false, detail: `npm ls -g 无输出: ${String(r.stderr || '').slice(0, 200)}` };
|
|
440
|
+
try {
|
|
441
|
+
const data = JSON.parse(out);
|
|
442
|
+
return { ok: true, detail: `npm 可执行, 全局依赖 ${Object.keys(data.dependencies || {}).length} 个` };
|
|
443
|
+
}
|
|
444
|
+
catch {
|
|
445
|
+
return { ok: false, detail: 'npm ls -g 输出无法解析' };
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
/** 四个运行时一起做真执行验证。 */
|
|
449
|
+
async function verifyRuntimesDeep(facts, entryPath) {
|
|
450
|
+
const byId = new Map(facts.map((f) => [f.runtime, f]));
|
|
451
|
+
const out = [];
|
|
452
|
+
for (const f of facts) {
|
|
453
|
+
if (f.status !== 'found' || !f.path) {
|
|
454
|
+
out.push(f);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
const at = new Date().toISOString();
|
|
458
|
+
let v = { ok: false, detail: '未验证' };
|
|
459
|
+
if (f.runtime === 'git')
|
|
460
|
+
v = verifyGitUsable(f.path);
|
|
461
|
+
else if (f.runtime === 'python')
|
|
462
|
+
v = verifyPythonUsable(f.path);
|
|
463
|
+
else if (f.runtime === 'npm')
|
|
464
|
+
v = verifyNpmUsable(f.path);
|
|
465
|
+
else if (f.runtime === 'node') {
|
|
466
|
+
v = entryPath ? verifyNodeLoadsCli(f.path, entryPath) : { ok: true, detail: 'node --version 通过 (未提供 CLI 入口)' };
|
|
467
|
+
}
|
|
468
|
+
out.push({
|
|
469
|
+
...f,
|
|
470
|
+
verified: v.ok,
|
|
471
|
+
lastVerifiedAt: at,
|
|
472
|
+
notes: [...f.notes, v.ok ? v.detail : `真执行验证失败: ${v.detail}`],
|
|
473
|
+
status: v.ok ? f.status : 'failed',
|
|
474
|
+
...(v.ok ? {} : { meetsMinimum: false, error: v.detail }),
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
void byId;
|
|
478
|
+
return out;
|
|
479
|
+
}
|
|
480
|
+
function buildRuntimeConfig(facts) {
|
|
481
|
+
const out = {};
|
|
482
|
+
for (const f of facts) {
|
|
483
|
+
out[f.runtime] = {
|
|
484
|
+
path: f.path, version: f.version, source: f.source,
|
|
485
|
+
installedByBolloon: f.installedByBolloon,
|
|
486
|
+
lastVerifiedAt: f.lastVerifiedAt || null,
|
|
487
|
+
meetsMinimum: f.meetsMinimum,
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
return out;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* 写入 `~/.bolloon/config.json` 的 `runtime` 字段。
|
|
494
|
+
* **只动 runtime 一个键**; 文件不存在时创建 (与 postinstall 同一份默认形状); 其余字段原样保留。
|
|
495
|
+
*/
|
|
496
|
+
async function writeRuntimeConfig(home, facts) {
|
|
497
|
+
const configPath = path.join(home, 'config.json');
|
|
498
|
+
let cfg;
|
|
499
|
+
let created = false;
|
|
500
|
+
try {
|
|
501
|
+
cfg = JSON.parse(await fsp.readFile(configPath, 'utf8'));
|
|
502
|
+
}
|
|
503
|
+
catch {
|
|
504
|
+
cfg = { version: 'unknown', initializedAt: new Date().toISOString(), updateChannel: 'stable', checkUpdates: true, autoInstall: false, autoRestart: false };
|
|
505
|
+
created = true;
|
|
506
|
+
}
|
|
507
|
+
cfg.runtime = buildRuntimeConfig(facts);
|
|
508
|
+
cfg.runtimeUpdatedAt = new Date().toISOString();
|
|
509
|
+
await fsp.mkdir(home, { recursive: true });
|
|
510
|
+
const tmp = `${configPath}.tmp-${process.pid}`;
|
|
511
|
+
await fsp.writeFile(tmp, JSON.stringify(cfg, null, 2), 'utf8');
|
|
512
|
+
await fsp.rename(tmp, configPath);
|
|
513
|
+
return { written: true, configPath, created };
|
|
514
|
+
}
|
|
515
|
+
async function readRuntimeConfig(home = (0, setup_store_js_1.resolveBolloonHome)()) {
|
|
516
|
+
try {
|
|
517
|
+
const p = path.join(home, 'config.json');
|
|
518
|
+
const cfg = JSON.parse(await fsp.readFile(p, 'utf8'));
|
|
519
|
+
return (cfg?.runtime && typeof cfg.runtime === 'object') ? cfg.runtime : {};
|
|
520
|
+
}
|
|
521
|
+
catch {
|
|
522
|
+
return {};
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/** 兼容入口: 有些安装只写 bolloon-config.json (正式配置文件) —— runtime.* 也读它作为回退。 */
|
|
526
|
+
async function readRuntimeConfigWithFallback(home = (0, setup_store_js_1.resolveBolloonHome)()) {
|
|
527
|
+
const a = await readRuntimeConfig(home);
|
|
528
|
+
if (Object.keys(a).length)
|
|
529
|
+
return a;
|
|
530
|
+
try {
|
|
531
|
+
const p = path.join(home, setup_store_js_1.CANONICAL_CONFIG_FILE);
|
|
532
|
+
const cfg = JSON.parse(await fsp.readFile(p, 'utf8'));
|
|
533
|
+
return (cfg?.runtime && typeof cfg.runtime === 'object') ? cfg.runtime : {};
|
|
534
|
+
}
|
|
535
|
+
catch {
|
|
536
|
+
return {};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
// ── 能力矩阵 (Phase 5/8 的六行输出) ────────────────────────────────────────
|
|
540
|
+
function evaluateCapabilities(facts) {
|
|
541
|
+
const ok = (id) => {
|
|
542
|
+
const f = facts.find((x) => x.runtime === id);
|
|
543
|
+
return !!f && f.status === 'found' && f.meetsMinimum && f.verified !== false;
|
|
544
|
+
};
|
|
545
|
+
const core = ok('node') && ok('npm');
|
|
546
|
+
const git = ok('git');
|
|
547
|
+
const py = ok('python');
|
|
548
|
+
return {
|
|
549
|
+
core,
|
|
550
|
+
sourceUpdate: core && git,
|
|
551
|
+
gitCollaboration: core && git,
|
|
552
|
+
pythonSkill: core && py,
|
|
553
|
+
wikiTools: core && git && py,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
/** 探测四个运行时 (Phase 1 的统一出口; install.sh / postinstall / doctor / --version 都走它)。 */
|
|
557
|
+
async function detectRuntimeReport(opts = {}) {
|
|
558
|
+
const home = opts.home || (0, setup_store_js_1.resolveBolloonHome)();
|
|
559
|
+
const cfg = opts.useConfig === false ? {} : await readRuntimeConfigWithFallback(home);
|
|
560
|
+
const facts = ['node', 'npm', 'git', 'python'].map((id) => probeRuntime(id, { preferredPath: cfg[id]?.path ?? null, envPath: opts.envPath }));
|
|
561
|
+
const checkedAt = new Date().toISOString();
|
|
562
|
+
const withVerify = opts.deep ? await verifyRuntimesDeep(facts, opts.entryPath) : facts;
|
|
563
|
+
const caps = evaluateCapabilities(withVerify);
|
|
564
|
+
const missing = withVerify.filter((f) => f.status === 'missing').map((f) => f.runtime);
|
|
565
|
+
const below = withVerify.filter((f) => f.status === 'failed' && !(f.verified === false)).map((f) => f.runtime);
|
|
566
|
+
const failedStage = withVerify.find((f) => f.status === 'failed');
|
|
567
|
+
const ok = missing.length === 0 && withVerify.every((f) => f.status === 'found' && f.meetsMinimum);
|
|
568
|
+
const advice = [];
|
|
569
|
+
for (const f of withVerify) {
|
|
570
|
+
if (f.status === 'found')
|
|
571
|
+
continue;
|
|
572
|
+
advice.push(`${f.runtime}: ${f.error || '不可用'} → ${manualAdvice(f.runtime, process.platform)}`);
|
|
573
|
+
}
|
|
574
|
+
return {
|
|
575
|
+
schema: 'bolloon-runtime/1',
|
|
576
|
+
platform: process.platform,
|
|
577
|
+
arch: process.arch,
|
|
578
|
+
facts: withVerify,
|
|
579
|
+
ok,
|
|
580
|
+
missing,
|
|
581
|
+
belowMinimum: below,
|
|
582
|
+
failedStage: ok ? null : (failedStage ? `${failedStage.runtime} 验证` : (missing.length ? `${missing.join('/')} 缺失` : '运行时检查')),
|
|
583
|
+
advice,
|
|
584
|
+
capabilities: caps,
|
|
585
|
+
checkedAt,
|
|
586
|
+
installed: [],
|
|
587
|
+
dryRun: false,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function defaultRun(cmd, args) {
|
|
591
|
+
const r = (0, child_process_1.spawnSync)(cmd, args, { encoding: 'utf-8', timeout: 1800_000, maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
592
|
+
return { code: r.status ?? 1, out: String(r.stdout || ''), err: String(r.stderr || r.error?.message || '') };
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* 运行时安装 (Phase 1/2/3/4/5)。
|
|
596
|
+
* 顺序: 探测 → 计划 → (dryRun 停) → 逐项安装 → 重新探测 → 真执行验证 → 写配置。
|
|
597
|
+
* 不满足任何一个必需运行时 → 报告 `ok:false` + `failedStage` + `advice` (退出码由调用方给非 0)。
|
|
598
|
+
*/
|
|
599
|
+
async function bootstrapRuntimes(opts = {}) {
|
|
600
|
+
const home = opts.home || (0, setup_store_js_1.resolveBolloonHome)();
|
|
601
|
+
const log = opts.onProgress || (() => { });
|
|
602
|
+
const envPath = opts.envPath || process.env.PATH || '';
|
|
603
|
+
const manager = detectPackageManager(process.platform, envPath);
|
|
604
|
+
const run = opts.run || defaultRun;
|
|
605
|
+
const before = await detectRuntimeReport({ home, useConfig: true, envPath });
|
|
606
|
+
const plan = planBootstrap(before.facts, { manager, envPath });
|
|
607
|
+
const actions = [];
|
|
608
|
+
if (opts.dryRun) {
|
|
609
|
+
log('[dry-run] 只显示计划, 不执行任何安装');
|
|
610
|
+
return {
|
|
611
|
+
...before, plan, actions, dryRun: true,
|
|
612
|
+
advice: [...before.advice, ...plan.advice.filter((a) => !before.advice.includes(a))],
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
if (!opts.yes) {
|
|
616
|
+
log('未获得显式同意 (需要 --yes / 交互确认) —— 不执行安装');
|
|
617
|
+
return {
|
|
618
|
+
...before, plan, actions,
|
|
619
|
+
advice: [...before.advice, ...plan.advice.filter((a) => !before.advice.includes(a)),
|
|
620
|
+
before.ok ? '' : '确认后重跑: bolloon runtime install (或 install.sh --yes)'].filter(Boolean),
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
const installed = [];
|
|
624
|
+
for (const step of plan.steps) {
|
|
625
|
+
if (step.action !== 'install' || !step.command)
|
|
626
|
+
continue;
|
|
627
|
+
const needsSudo = step.command[0] === 'sudo';
|
|
628
|
+
if (needsSudo && !opts.allowSudo) {
|
|
629
|
+
actions.push({ runtime: step.runtime, command: step.command, code: null, action: 'skipped-needs-sudo' });
|
|
630
|
+
log(`跳过 ${step.runtime}: 需要管理员权限, 未显式允许 sudo (不偷偷提权)`);
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
log(`安装 ${step.runtime}: ${step.command.join(' ')}`);
|
|
634
|
+
const t0 = new Date().toISOString();
|
|
635
|
+
const r = run(step.command[0], step.command.slice(1));
|
|
636
|
+
const t1 = new Date().toISOString();
|
|
637
|
+
actions.push({ runtime: step.runtime, command: step.command, code: r.code, action: 'install' });
|
|
638
|
+
if (r.code !== 0) {
|
|
639
|
+
log(`安装 ${step.runtime} 失败 (exit ${r.code}): ${(r.err || r.out).slice(0, 300)}`);
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
installed.push(step.runtime);
|
|
643
|
+
}
|
|
644
|
+
void t0;
|
|
645
|
+
void t1;
|
|
646
|
+
}
|
|
647
|
+
// 重新探测 (PATH 可能变) + 真执行验证
|
|
648
|
+
const after = await detectRuntimeReport({ home, useConfig: true, deep: true, entryPath: opts.entryPath, envPath });
|
|
649
|
+
const merged = {
|
|
650
|
+
...after,
|
|
651
|
+
facts: after.facts.map((f) => installed.includes(f.runtime)
|
|
652
|
+
? { ...f, status: (f.status === 'found' ? 'installed' : f.status), source: manager?.kind || 'official-installer', installedByBolloon: f.status === 'found' }
|
|
653
|
+
: f),
|
|
654
|
+
installed,
|
|
655
|
+
dryRun: false,
|
|
656
|
+
};
|
|
657
|
+
// 能力矩阵要用最终状态重算
|
|
658
|
+
merged.capabilities = evaluateCapabilities(merged.facts);
|
|
659
|
+
const stillMissing = merged.facts.filter((f) => f.status !== 'found');
|
|
660
|
+
merged.ok = stillMissing.length === 0;
|
|
661
|
+
merged.missing = merged.facts.filter((f) => f.status === 'missing').map((f) => f.runtime);
|
|
662
|
+
merged.failedStage = merged.ok ? null : `运行时验证 (${stillMissing.map((f) => f.runtime).join('/')})`;
|
|
663
|
+
const extraAdvice = stillMissing.map((f) => `${f.runtime}: ${f.error || '仍不可用'} → ${manualAdvice(f.runtime, process.platform)}`);
|
|
664
|
+
merged.advice = Array.from(new Set([...merged.advice, ...plan.advice, ...extraAdvice]));
|
|
665
|
+
if (opts.configurePath !== false) {
|
|
666
|
+
try {
|
|
667
|
+
await writeRuntimeConfig(home, merged.facts);
|
|
668
|
+
log(`已写入运行时配置: ${path.join(home, 'config.json')} (只动 runtime 字段)`);
|
|
669
|
+
}
|
|
670
|
+
catch (e) {
|
|
671
|
+
merged.advice.push(`写运行时配置失败: ${e?.message || e}`);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
// 运行时补齐成功 → 清掉 postinstall 留下的"安装未完成"标记
|
|
675
|
+
if (merged.ok) {
|
|
676
|
+
try {
|
|
677
|
+
await fsp.unlink(path.join(home, 'install-incomplete.json'));
|
|
678
|
+
}
|
|
679
|
+
catch { /* 没有就算了 */ }
|
|
680
|
+
}
|
|
681
|
+
return { ...merged, plan, actions };
|
|
682
|
+
}
|
|
683
|
+
// ── 报告渲染 (Phase 5 的两种形状) ──────────────────────────────────────────
|
|
684
|
+
const CAP_LABEL = {
|
|
685
|
+
core: '核心运行', sourceUpdate: '源码更新', gitCollaboration: 'Git 协作',
|
|
686
|
+
pythonSkill: 'Python Skill', wikiTools: 'Wiki 工具',
|
|
687
|
+
};
|
|
688
|
+
function renderRuntimeReport(rep, opts = {}) {
|
|
689
|
+
const L = [];
|
|
690
|
+
const nameOf = { node: 'Node.js', npm: 'npm', git: 'Git', python: 'Python' };
|
|
691
|
+
if (!rep.ok) {
|
|
692
|
+
const bad = rep.facts.filter((f) => f.status !== 'found');
|
|
693
|
+
L.push('Bolloon 安装未完成');
|
|
694
|
+
L.push(`失败阶段: ${rep.failedStage || '运行时检查'}`);
|
|
695
|
+
for (const f of bad)
|
|
696
|
+
L.push(`${nameOf[f.runtime]}: ${f.error || '不可用'}${f.path ? ` (路径 ${f.path})` : ''}`);
|
|
697
|
+
if (rep.advice.length) {
|
|
698
|
+
L.push('处理建议:');
|
|
699
|
+
for (const a of rep.advice)
|
|
700
|
+
L.push(` - ${a}`);
|
|
701
|
+
}
|
|
702
|
+
L.push('');
|
|
703
|
+
L.push('(模拟/联调提示: 修复后重跑 `bolloon runtime check`, 或 `bolloon runtime install`)');
|
|
704
|
+
return L.join('\n');
|
|
705
|
+
}
|
|
706
|
+
L.push(rep.installed.length ? 'Bolloon 安装完成 (含本次安装的运行时)' : 'Bolloon 运行时检查通过');
|
|
707
|
+
L.push('');
|
|
708
|
+
for (const f of rep.facts) {
|
|
709
|
+
const extra = opts.verbose ? ` ${f.path || ''} [${f.source}${f.installedByBolloon ? ', 由 Bolloon 安装' : ''}${f.lastVerifiedAt ? `, 验证于 ${f.lastVerifiedAt}` : ''}]` : '';
|
|
710
|
+
L.push(`${nameOf[f.runtime].padEnd(8)} ✓ ${(f.version || '?').padEnd(10)}${extra}`);
|
|
711
|
+
}
|
|
712
|
+
L.push('');
|
|
713
|
+
for (const [k, label] of Object.entries(CAP_LABEL)) {
|
|
714
|
+
L.push(`${label.padEnd(14)} ${rep.capabilities[k] ? '可用' : '不可用'}`);
|
|
715
|
+
}
|
|
716
|
+
return L.join('\n');
|
|
717
|
+
}
|
|
718
|
+
/** `bolloon --version` 的运行时一节 (leo: 展示安装信息时要展示这些配置)。 */
|
|
719
|
+
async function readIncompleteMarker(home = (0, setup_store_js_1.resolveBolloonHome)()) {
|
|
720
|
+
try {
|
|
721
|
+
return JSON.parse(await fsp.readFile(path.join(home, 'install-incomplete.json'), 'utf8'));
|
|
722
|
+
}
|
|
723
|
+
catch {
|
|
724
|
+
return null;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function renderRuntimeLines(rep, opts = {}) {
|
|
728
|
+
const nameOf = { node: 'Node.js', npm: 'npm', git: 'Git', python: 'Python' };
|
|
729
|
+
const L = [];
|
|
730
|
+
// 配置里还没写 runtime.* 时不要假装"来自配置" —— 那是实时探测的结果
|
|
731
|
+
L.push(opts.configBacked
|
|
732
|
+
? '运行时配置: (来自 ~/.bolloon/config.json 的 runtime.*, 每次启动重新验证)'
|
|
733
|
+
: '运行时配置: (实时探测 — 配置里还没有 runtime.*; 跑 `bolloon runtime` 会写入)');
|
|
734
|
+
for (const f of rep.facts) {
|
|
735
|
+
const mark = f.status === 'found' ? '✓' : '✗';
|
|
736
|
+
const src = f.installedByBolloon ? '由 Bolloon 安装' : f.source === 'existing' ? '已有' : f.source;
|
|
737
|
+
L.push(` ${mark} ${nameOf[f.runtime].padEnd(8)} ${(f.version || '未找到').padEnd(10)} ${f.path || '-'} [${src}]`);
|
|
738
|
+
}
|
|
739
|
+
if (opts.verbose) {
|
|
740
|
+
L.push(` 能力: 核心运行=${rep.capabilities.core ? '可用' : '不可用'} · 源码更新=${rep.capabilities.sourceUpdate ? '可用' : '不可用'} · Python Skill=${rep.capabilities.pythonSkill ? '可用' : '不可用'} · Wiki 工具=${rep.capabilities.wikiTools ? '可用' : '不可用'}`);
|
|
741
|
+
L.push(` 检查时间: ${rep.checkedAt}`);
|
|
742
|
+
}
|
|
743
|
+
return L;
|
|
744
|
+
}
|
|
745
|
+
//# sourceMappingURL=runtime-bootstrap.js.map
|