@bolloon/bolloon-agent 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/client.js +2861 -3746
- package/dist/web/components/p2p/index.js +226 -264
- package/dist/web/ui/message-renderer.js +323 -434
- package/dist/web/ui/step-timeline.js +255 -351
- package/package.json +2 -2
- package/.auto-evolve-calls +0 -1
- package/.last-auto-evolve-baseline +0 -1
- package/.playwright-mcp/page-2026-06-16T07-51-45-706Z.yml +0 -130
- package/.playwright-mcp/page-2026-06-16T07-56-44-116Z.yml +0 -131
- package/Bolloon.md +0 -144
- package/Dive-into/CITATION.cff +0 -17
- package/Dive-into/LICENSE +0 -25
- package/Dive-into/README.md +0 -598
- package/Dive-into/README_zh.md +0 -599
- package/Dive-into/assets/context.png +0 -0
- package/Dive-into/assets/extensibility.png +0 -0
- package/Dive-into/assets/iteration.png +0 -0
- package/Dive-into/assets/layered_architecture.png +0 -0
- package/Dive-into/assets/main_structure.png +0 -0
- package/Dive-into/assets/permission.png +0 -0
- package/Dive-into/assets/session_compact.png +0 -0
- package/Dive-into/assets/subagent.png +0 -0
- package/Dive-into/paper/Dive_into_Claude_Code.pdf +0 -0
- package/dist/agents/constraint-layer.js.map +0 -1
- package/dist/agents/pi-sdk.js.map +0 -1
- package/dist/agents/workflow-engine.js.map +0 -1
- package/dist/bollharness/src/index.js +0 -5
- package/dist/bollharness/src/scripts/checks/check_adr_plan_numbering.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_api_types.js +0 -45
- package/dist/bollharness/src/scripts/checks/check_artifact_link.js +0 -146
- package/dist/bollharness/src/scripts/checks/check_bridge_deps.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_bugfix_binding_ci.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_file_references.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_doc_freshness.js +0 -135
- package/dist/bollharness/src/scripts/checks/check_doc_links.js +0 -31
- package/dist/bollharness/src/scripts/checks/check_file_existence_claims.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_fragment_integrity.js +0 -34
- package/dist/bollharness/src/scripts/checks/check_hook_installed.js +0 -63
- package/dist/bollharness/src/scripts/checks/check_issue_closure.js +0 -41
- package/dist/bollharness/src/scripts/checks/check_mcp_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_security.js +0 -48
- package/dist/bollharness/src/scripts/checks/check_skill_parity.js +0 -6
- package/dist/bollharness/src/scripts/checks/check_versions.js +0 -6
- package/dist/bollharness/src/scripts/checks/finding.js +0 -13
- package/dist/bollharness/src/scripts/checks/next_decision_number.js +0 -20
- package/dist/bollharness/src/scripts/checks/regenerate_magic_docs.js +0 -6
- package/dist/bollharness/src/scripts/ci/detect_rebaseline_triggers.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_subprocess_cfg.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_verify_artifacts.js +0 -8
- package/dist/bollharness/src/scripts/ci/scan_yaml_schema.js +0 -8
- package/dist/bollharness/src/scripts/context_router.js +0 -67
- package/dist/bollharness/src/scripts/deploy-guard.js +0 -157
- package/dist/bollharness/src/scripts/guard-feedback.js +0 -192
- package/dist/bollharness/src/scripts/guard_router.js +0 -158
- package/dist/bollharness/src/scripts/hooks/_hook_output.js +0 -6
- package/dist/bollharness/src/scripts/hooks/auto-python3.js +0 -6
- package/dist/bollharness/src/scripts/hooks/deploy-progress-on-session-end.js +0 -6
- package/dist/bollharness/src/scripts/hooks/failure-analyzer.js +0 -6
- package/dist/bollharness/src/scripts/hooks/gate-judgment-inject.js +0 -92
- package/dist/bollharness/src/scripts/hooks/gate-transition-judgment.js +0 -63
- package/dist/bollharness/src/scripts/hooks/inbox-ack.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-inject-on-start.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-validate.js +0 -6
- package/dist/bollharness/src/scripts/hooks/inbox-write-ledger.js +0 -6
- package/dist/bollharness/src/scripts/hooks/initializer-agent.js +0 -6
- package/dist/bollharness/src/scripts/hooks/loop-detection.js +0 -73
- package/dist/bollharness/src/scripts/hooks/owner-guard.js +0 -6
- package/dist/bollharness/src/scripts/hooks/precompact.js +0 -6
- package/dist/bollharness/src/scripts/hooks/review-agent-gatekeeper.js +0 -6
- package/dist/bollharness/src/scripts/hooks/risk-tracker.js +0 -108
- package/dist/bollharness/src/scripts/hooks/sanitize-on-read.js +0 -6
- package/dist/bollharness/src/scripts/hooks/session-reflection.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-magic-docs.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-reset-risk.js +0 -7
- package/dist/bollharness/src/scripts/hooks/session-start-toolkit-reminder.js +0 -7
- package/dist/bollharness/src/scripts/hooks/stop-evaluator.js +0 -157
- package/dist/bollharness/src/scripts/hooks/tool-call-counter.js +0 -6
- package/dist/bollharness/src/scripts/hooks/trace-analyzer.js +0 -10
- package/dist/bollharness/src/scripts/install/install-trust-token.js +0 -7
- package/dist/bollharness/src/scripts/install/multi_project_registry.js +0 -9
- package/dist/bollharness/src/scripts/install/phase2_auto.js +0 -21
- package/dist/bollharness/src/scripts/install/pre_commit_installer.js +0 -6
- package/dist/bollharness/src/scripts/install/tier_selector.js +0 -7
- package/dist/bollharness/src/scripts/install/transcript_miner.js +0 -7
- package/dist/bollharness/src/scripts/lib/claim_patterns.js +0 -10
- package/dist/bollharness/src/scripts/lib/sanitize_patterns.js +0 -12
- package/dist/bollharness/src/scripts/sanitize.js +0 -6
- package/dist/bollharness-integration/context-router-judgment.js.map +0 -1
- package/dist/bollharness-integration/context-router.js.map +0 -1
- package/dist/bollharness-integration/gate-state-machine.js.map +0 -1
- package/dist/bollharness-integration/gate-transition-hooks.js.map +0 -1
- package/dist/bollharness-integration/guard-checker.js.map +0 -1
- package/dist/bollharness-integration/index.js.map +0 -1
- package/dist/bollharness-integration/integration.js.map +0 -1
- package/dist/bollharness-integration/llm/pi-ai.d.ts +0 -60
- package/dist/bollharness-integration/pi-ecosystem-colony/index.d.ts +0 -153
- package/dist/bollharness-integration/pi-ecosystem-goals/index.d.ts +0 -136
- package/dist/bollharness-integration/pi-ecosystem-judgment/decision.d.ts +0 -117
- package/dist/bollharness-integration/pi-ecosystem-judgment/distillation.d.ts +0 -78
- package/dist/bollharness-integration/pi-ecosystem-judgment/index.d.ts +0 -139
- package/dist/bollharness-integration/pi-ecosystem-mcp/index.d.ts +0 -127
- package/dist/bollharness-integration/pi-ecosystem-subagents/index.d.ts +0 -95
- package/dist/bollharness-integration/skill-adapter.js.map +0 -1
- package/dist/constraint-runtime/src/_archive_helper.js +0 -9
- package/dist/constraint-runtime/src/agent/coordinator.js +0 -48
- package/dist/constraint-runtime/src/agent/index.js +0 -1
- package/dist/constraint-runtime/src/assistant/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap/index.js +0 -12
- package/dist/constraint-runtime/src/bootstrap_graph.js +0 -13
- package/dist/constraint-runtime/src/bridge/index.js +0 -12
- package/dist/constraint-runtime/src/buddy/index.js +0 -12
- package/dist/constraint-runtime/src/cli/index.js +0 -12
- package/dist/constraint-runtime/src/command_graph.js +0 -10
- package/dist/constraint-runtime/src/commands.js +0 -60
- package/dist/constraint-runtime/src/components/index.js +0 -12
- package/dist/constraint-runtime/src/constants/index.js +0 -12
- package/dist/constraint-runtime/src/constraint/budget.js +0 -22
- package/dist/constraint-runtime/src/constraint/budget.js.map +0 -1
- package/dist/constraint-runtime/src/constraint/index.js +0 -2
- package/dist/constraint-runtime/src/constraint/permission.js +0 -20
- package/dist/constraint-runtime/src/constraint/permission.js.map +0 -1
- package/dist/constraint-runtime/src/context.js +0 -30
- package/dist/constraint-runtime/src/coordinator/index.js +0 -12
- package/dist/constraint-runtime/src/cost_hook.js +0 -4
- package/dist/constraint-runtime/src/cost_tracker.js +0 -8
- package/dist/constraint-runtime/src/deferred_init.js +0 -10
- package/dist/constraint-runtime/src/direct_modes.js +0 -6
- package/dist/constraint-runtime/src/dynamic-tool-loader.js +0 -85
- package/dist/constraint-runtime/src/entrypoints/index.js +0 -12
- package/dist/constraint-runtime/src/execution_registry.js +0 -44
- package/dist/constraint-runtime/src/history.js +0 -9
- package/dist/constraint-runtime/src/hooks/index.js +0 -12
- package/dist/constraint-runtime/src/index.js +0 -26
- package/dist/constraint-runtime/src/ink.js +0 -4
- package/dist/constraint-runtime/src/keybindings/index.js +0 -12
- package/dist/constraint-runtime/src/memdir/index.js +0 -12
- package/dist/constraint-runtime/src/migrations/index.js +0 -12
- package/dist/constraint-runtime/src/models.js +0 -1
- package/dist/constraint-runtime/src/models.js.map +0 -1
- package/dist/constraint-runtime/src/moreright/index.js +0 -12
- package/dist/constraint-runtime/src/native_ts/index.js +0 -12
- package/dist/constraint-runtime/src/output_styles/index.js +0 -12
- package/dist/constraint-runtime/src/parity_audit.js +0 -12
- package/dist/constraint-runtime/src/plugins/index.js +0 -12
- package/dist/constraint-runtime/src/port_manifest.js +0 -11
- package/dist/constraint-runtime/src/prefetch.js +0 -9
- package/dist/constraint-runtime/src/query.js +0 -1
- package/dist/constraint-runtime/src/remote/index.js +0 -12
- package/dist/constraint-runtime/src/remote_runtime.js +0 -9
- package/dist/constraint-runtime/src/runtime/index.js +0 -1
- package/dist/constraint-runtime/src/runtime/session.js +0 -35
- package/dist/constraint-runtime/src/schemas/index.js +0 -12
- package/dist/constraint-runtime/src/screens/index.js +0 -12
- package/dist/constraint-runtime/src/server/index.js +0 -12
- package/dist/constraint-runtime/src/services/index.js +0 -12
- package/dist/constraint-runtime/src/session_store.js +0 -22
- package/dist/constraint-runtime/src/setup.js +0 -30
- package/dist/constraint-runtime/src/skills/index.js +0 -1
- package/dist/constraint-runtime/src/skills/skill-registry.js +0 -28
- package/dist/constraint-runtime/src/state/index.js +0 -12
- package/dist/constraint-runtime/src/system_init.js +0 -20
- package/dist/constraint-runtime/src/thinking/engine.js +0 -42
- package/dist/constraint-runtime/src/thinking/index.js +0 -1
- package/dist/constraint-runtime/src/tool_pool.js +0 -8
- package/dist/constraint-runtime/src/tools/OpenCLI/execAdapter.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/listAdapters.js +0 -7
- package/dist/constraint-runtime/src/tools/OpenCLI/runCommand.js +0 -7
- package/dist/constraint-runtime/src/tools/PolymarketSDK/cancelOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/createOrder.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getMarket.js +0 -5
- package/dist/constraint-runtime/src/tools/PolymarketSDK/getOrders.js +0 -6
- package/dist/constraint-runtime/src/tools/PolymarketSDK/listMarkets.js +0 -4
- package/dist/constraint-runtime/src/tools/SafeSDK/confirmTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/createTransaction.js +0 -8
- package/dist/constraint-runtime/src/tools/SafeSDK/deploySafe.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/executeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getBalance.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/getPendingTransactions.js +0 -6
- package/dist/constraint-runtime/src/tools/SafeSDK/proposeTransaction.js +0 -6
- package/dist/constraint-runtime/src/tools/WalletTools/autoPay.js +0 -29
- package/dist/constraint-runtime/src/tools/WalletTools/createWallet.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/getBalance.js +0 -13
- package/dist/constraint-runtime/src/tools/WalletTools/importWallet.js +0 -22
- package/dist/constraint-runtime/src/tools/WalletTools/sendTransaction.js +0 -25
- package/dist/constraint-runtime/src/tools/WalletTools/signMessage.js +0 -10
- package/dist/constraint-runtime/src/tools/WalletTools/transferToken.js +0 -25
- package/dist/constraint-runtime/src/tools.js +0 -80
- package/dist/constraint-runtime/src/transcript.js +0 -19
- package/dist/constraint-runtime/src/types/index.js +0 -12
- package/dist/constraint-runtime/src/upstream_proxy/index.js +0 -12
- package/dist/constraint-runtime/src/utils/index.js +0 -12
- package/dist/constraint-runtime/src/vim/index.js +0 -12
- package/dist/constraint-runtime/src/voice/index.js +0 -12
- package/dist/constraints/index.js.map +0 -1
- package/dist/documents/reader.js.map +0 -1
- package/dist/llm/config-store.js.map +0 -1
- package/dist/llm/pi-ai.js.map +0 -1
- package/dist/network/agent-network.js.map +0 -1
- package/dist/network/iroh-integration.js.map +0 -1
- package/dist/network/iroh-transport.js.map +0 -1
- package/dist/network/p2p.js.map +0 -1
- package/dist/network/storage/adapters/json-adapter.js.map +0 -1
- package/dist/pi-ecosystem-colony/index.js.map +0 -1
- package/dist/pi-ecosystem-goals/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/decision.js.map +0 -1
- package/dist/pi-ecosystem-judgment/distillation.js.map +0 -1
- package/dist/pi-ecosystem-judgment/human-value-store.js.map +0 -1
- package/dist/pi-ecosystem-judgment/index.js.map +0 -1
- package/dist/pi-ecosystem-judgment/value-injection.js.map +0 -1
- package/dist/pi-ecosystem-mcp/index.js.map +0 -1
- package/dist/pi-ecosystem-subagents/index.js.map +0 -1
- package/dist/social/ant-colony/AdaptiveHeartbeat.js.map +0 -1
- package/dist/social/ant-colony/PheromoneEngine.js.map +0 -1
- package/dist/social/ant-colony/types.js.map +0 -1
- package/dist/social/channels/ChannelManager.js.map +0 -1
- package/dist/social/channels/DiapChannelBridge.js.map +0 -1
- package/dist/social/channels/InterestMatcher.js.map +0 -1
- package/dist/social/channels/types.js.map +0 -1
- package/dist/social/global-shared-context.js.map +0 -1
- package/dist/social/heartbeat.js.map +0 -1
- package/dist/web/components/p2p/P2PModal.js +0 -188
- package/dist/web/components/p2p/p2p-modal.js +0 -657
- package/dist/web/components/p2p/p2p-tools.js +0 -248
- package/lefthook.yml +0 -33
- package/scripts/auto-evolve-loop.ts +0 -481
- package/scripts/auto-evolve-oneshot.sh +0 -155
- package/scripts/auto-evolve-snapshot.sh +0 -136
- package/scripts/build-cli.js +0 -216
- package/scripts/build-web.ts +0 -116
- package/scripts/detect-schema-changes.sh +0 -48
- package/scripts/diff-reviewer.ts +0 -159
- package/scripts/postinstall.js +0 -153
- package/scripts/validate-system-prompt.ts +0 -142
- package/scripts/weekly-report.ts +0 -364
- package/src/agents/agent-manifest-protocol.ts +0 -117
- package/src/agents/constraint-layer.ts +0 -309
- package/src/agents/iroh-secret.ts +0 -32
- package/src/agents/p2p-chat-tools.ts +0 -383
- package/src/agents/p2p-document-tools.ts +0 -347
- package/src/agents/permission-mode.ts +0 -127
- package/src/agents/pi-sdk.ts +0 -2895
- package/src/agents/pre-tool-validator.ts +0 -213
- package/src/agents/protocol.ts +0 -398
- package/src/agents/shell-guard.ts +0 -417
- package/src/agents/shell-tool.ts +0 -103
- package/src/agents/skill-loader.ts +0 -202
- package/src/agents/subagent-manager.ts +0 -553
- package/src/agents/workflow-engine.ts +0 -332
- package/src/agents/workflow-pivot-loop.ts +0 -766
- package/src/bollharness/.sanitize-report.json +0 -13
- package/src/bollharness/CLAUDE.md +0 -73
- package/src/bollharness/LICENSE +0 -21
- package/src/bollharness/README.md +0 -143
- package/src/bollharness/README.zh-CN.md +0 -131
- package/src/bollharness/package.json +0 -20
- package/src/bollharness/reference/SOURCE-COMMIT.txt +0 -3
- package/src/bollharness/reference/boll-reference/scripts/hooks/.sanitize-report.json +0 -12
- package/src/bollharness/reference/boll-reference/scripts/hooks/find-boll-root.sh +0 -27
- package/src/bollharness/reference/boll-reference/scripts/hooks/precompact.sh +0 -57
- package/src/bollharness/reference/boll-reference/scripts/hooks/stop-evaluator.md +0 -57
- package/src/bollharness/schemas/metrics-jsonl-allowlist.json +0 -67
- package/src/bollharness/scripts/checks/next_decision_number.sh +0 -48
- package/src/bollharness/scripts/ci/count-components.sh +0 -65
- package/src/bollharness/scripts/context-fragments/artifact-linkage.md +0 -14
- package/src/bollharness/scripts/context-fragments/auth-consumers.md +0 -17
- package/src/bollharness/scripts/context-fragments/bridge-constitution.md +0 -13
- package/src/bollharness/scripts/context-fragments/catalyst-distributed.md +0 -18
- package/src/bollharness/scripts/context-fragments/closure-checklist.md +0 -13
- package/src/bollharness/scripts/context-fragments/contract-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/db-shared-structures.md +0 -15
- package/src/bollharness/scripts/context-fragments/fixed-three-layers.md +0 -19
- package/src/bollharness/scripts/context-fragments/general-dev-principles.md +0 -11
- package/src/bollharness/scripts/context-fragments/issue-first.md +0 -8
- package/src/bollharness/scripts/context-fragments/mcp-parity.md +0 -16
- package/src/bollharness/scripts/context-fragments/pi-agent-operations.md +0 -108
- package/src/bollharness/scripts/context-fragments/protocol-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/run-events-consumers.md +0 -15
- package/src/bollharness/scripts/context-fragments/scene-fidelity.md +0 -13
- package/src/bollharness/scripts/context-fragments/truth-source-hierarchy.md +0 -15
- package/src/bollharness/scripts/context-fragments/two-language.md +0 -15
- package/src/bollharness/scripts/context-fragments/version-sources.md +0 -14
- package/src/bollharness/scripts/hooks/find-project-root.sh +0 -47
- package/src/bollharness/scripts/hooks/inbox-poll.sh +0 -78
- package/src/bollharness/scripts/hooks/precompact.sh +0 -56
- package/src/bollharness/scripts/hooks/stop-evaluator.md +0 -83
- package/src/bollharness/scripts/sync-from-upstream.sh +0 -281
- package/src/bollharness/src/index.ts +0 -5
- package/src/bollharness/src/scripts/checks/check_adr_plan_numbering.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_api_types.ts +0 -52
- package/src/bollharness/src/scripts/checks/check_artifact_link.ts +0 -156
- package/src/bollharness/src/scripts/checks/check_bridge_deps.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_bugfix_binding_ci.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_file_references.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_doc_freshness.ts +0 -141
- package/src/bollharness/src/scripts/checks/check_doc_links.ts +0 -36
- package/src/bollharness/src/scripts/checks/check_file_existence_claims.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_fragment_integrity.ts +0 -40
- package/src/bollharness/src/scripts/checks/check_hook_installed.ts +0 -70
- package/src/bollharness/src/scripts/checks/check_issue_closure.ts +0 -51
- package/src/bollharness/src/scripts/checks/check_mcp_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_security.ts +0 -54
- package/src/bollharness/src/scripts/checks/check_skill_parity.ts +0 -11
- package/src/bollharness/src/scripts/checks/check_versions.ts +0 -11
- package/src/bollharness/src/scripts/checks/finding.ts +0 -35
- package/src/bollharness/src/scripts/checks/next_decision_number.ts +0 -24
- package/src/bollharness/src/scripts/checks/regenerate_magic_docs.ts +0 -11
- package/src/bollharness/src/scripts/ci/detect_rebaseline_triggers.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_subprocess_cfg.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_verify_artifacts.ts +0 -14
- package/src/bollharness/src/scripts/ci/scan_yaml_schema.ts +0 -14
- package/src/bollharness/src/scripts/context_router.ts +0 -76
- package/src/bollharness/src/scripts/deploy-guard.ts +0 -182
- package/src/bollharness/src/scripts/guard-feedback.ts +0 -215
- package/src/bollharness/src/scripts/guard_router.ts +0 -194
- package/src/bollharness/src/scripts/hooks/_hook_output.js +0 -3
- package/src/bollharness/src/scripts/hooks/_hook_output.ts +0 -11
- package/src/bollharness/src/scripts/hooks/auto-python3.ts +0 -10
- package/src/bollharness/src/scripts/hooks/deploy-progress-on-session-end.ts +0 -10
- package/src/bollharness/src/scripts/hooks/failure-analyzer.ts +0 -10
- package/src/bollharness/src/scripts/hooks/gate-judgment-inject.ts +0 -111
- package/src/bollharness/src/scripts/hooks/gate-transition-judgment.ts +0 -74
- package/src/bollharness/src/scripts/hooks/inbox-ack.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-inject-on-start.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-validate.ts +0 -10
- package/src/bollharness/src/scripts/hooks/inbox-write-ledger.ts +0 -10
- package/src/bollharness/src/scripts/hooks/initializer-agent.ts +0 -10
- package/src/bollharness/src/scripts/hooks/loop-detection.ts +0 -83
- package/src/bollharness/src/scripts/hooks/owner-guard.ts +0 -10
- package/src/bollharness/src/scripts/hooks/precompact.ts +0 -10
- package/src/bollharness/src/scripts/hooks/review-agent-gatekeeper.ts +0 -10
- package/src/bollharness/src/scripts/hooks/risk-tracker.ts +0 -121
- package/src/bollharness/src/scripts/hooks/sanitize-on-read.ts +0 -10
- package/src/bollharness/src/scripts/hooks/session-reflection.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-magic-docs.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-reset-risk.ts +0 -12
- package/src/bollharness/src/scripts/hooks/session-start-toolkit-reminder.ts +0 -12
- package/src/bollharness/src/scripts/hooks/stop-evaluator.ts +0 -164
- package/src/bollharness/src/scripts/hooks/tool-call-counter.ts +0 -10
- package/src/bollharness/src/scripts/hooks/trace-analyzer.ts +0 -14
- package/src/bollharness/src/scripts/install/install-trust-token.ts +0 -13
- package/src/bollharness/src/scripts/install/multi_project_registry.ts +0 -13
- package/src/bollharness/src/scripts/install/phase2_auto.ts +0 -28
- package/src/bollharness/src/scripts/install/pre_commit_installer.ts +0 -10
- package/src/bollharness/src/scripts/install/tier_selector.ts +0 -10
- package/src/bollharness/src/scripts/install/transcript_miner.ts +0 -13
- package/src/bollharness/src/scripts/lib/claim_patterns.ts +0 -11
- package/src/bollharness/src/scripts/lib/sanitize_patterns.ts +0 -13
- package/src/bollharness/src/scripts/sanitize.ts +0 -9
- package/src/bollharness/templates/persona/default.json +0 -19
- package/src/bollharness/templates/scaffold/.gitignore.append +0 -16
- package/src/bollharness/templates/scaffold/CLAUDE.md +0 -89
- package/src/bollharness-integration/channel-judgment-engine.ts +0 -634
- package/src/bollharness-integration/context-chain-router.ts +0 -474
- package/src/bollharness-integration/context-router-judgment.ts +0 -339
- package/src/bollharness-integration/context-router.ts +0 -583
- package/src/bollharness-integration/gate-state-machine.ts +0 -444
- package/src/bollharness-integration/gate-transition-hooks.ts +0 -137
- package/src/bollharness-integration/guard-checker.ts +0 -451
- package/src/bollharness-integration/index.ts +0 -195
- package/src/bollharness-integration/integration.ts +0 -538
- package/src/bollharness-integration/judgment-prompts.yaml +0 -535
- package/src/bollharness-integration/llm-judgment-engine.ts +0 -712
- package/src/bollharness-integration/skill-adapter.ts +0 -646
- package/src/bootstrap/bootstrap.ts +0 -135
- package/src/bootstrap/context-collector.ts +0 -371
- package/src/bootstrap/context-hierarchy.ts +0 -283
- package/src/bootstrap/lifecycle-hooks.ts +0 -289
- package/src/bootstrap/project-context.ts +0 -171
- package/src/cli/interface.ts +0 -211
- package/src/cli-entry.ts +0 -304
- package/src/constraints/index.ts +0 -6
- package/src/context-compaction/auto-compact.ts +0 -153
- package/src/context-compaction/budget-gate.ts +0 -32
- package/src/context-compaction/budget-reduce.ts +0 -37
- package/src/context-compaction/context-collapse.ts +0 -72
- package/src/context-compaction/index.ts +0 -24
- package/src/context-compaction/microcompact.ts +0 -54
- package/src/context-compaction/pipeline.ts +0 -133
- package/src/context-compaction/snip.ts +0 -51
- package/src/context-compaction/token-estimator.ts +0 -36
- package/src/context-compaction/types.ts +0 -99
- package/src/documents/reader.ts +0 -85
- package/src/documents/store.ts +0 -252
- package/src/electron-preload.ts +0 -25
- package/src/electron.ts +0 -200
- package/src/heartbeat/DaemonManager.ts +0 -283
- package/src/heartbeat/HealthMonitor.ts +0 -317
- package/src/heartbeat/StartupVerifier.ts +0 -223
- package/src/heartbeat/Watchdog.ts +0 -208
- package/src/heartbeat/index.ts +0 -109
- package/src/heartbeat/self-improve-bus.ts +0 -110
- package/src/heartbeat/types.ts +0 -82
- package/src/index.ts +0 -1724
- package/src/llm/audio-config-store.ts +0 -246
- package/src/llm/config-store.ts +0 -400
- package/src/llm/llm-judgment-client.ts +0 -471
- package/src/llm/pi-ai.ts +0 -653
- package/src/llm/system-prompt/health.ts +0 -159
- package/src/llm/system-prompt/layers/channel/local.md +0 -14
- package/src/llm/system-prompt/layers/channel/p2p-agent.md +0 -18
- package/src/llm/system-prompt/layers/channel/p2p-visitor.md +0 -19
- package/src/llm/system-prompt/layers/core/artifacts_storage.md +0 -89
- package/src/llm/system-prompt/layers/core/evenhandedness.md +0 -21
- package/src/llm/system-prompt/layers/core/hibs_reminders.md +0 -15
- package/src/llm/system-prompt/layers/core/identity.md +0 -37
- package/src/llm/system-prompt/layers/core/knowledge.md +0 -17
- package/src/llm/system-prompt/layers/core/memory_system.md +0 -12
- package/src/llm/system-prompt/layers/core/network_filesystem.md +0 -28
- package/src/llm/system-prompt/layers/core/refusal.md +0 -37
- package/src/llm/system-prompt/layers/core/tone.md +0 -31
- package/src/llm/system-prompt/layers/core/tools.thin.md +0 -13
- package/src/llm/system-prompt/layers/core/wellbeing.md +0 -41
- package/src/llm/system-prompt/layers/role/architect.md +0 -20
- package/src/llm/system-prompt/layers/role/expert.md +0 -19
- package/src/llm/system-prompt/layers/role/implementer.md +0 -15
- package/src/llm/system-prompt/layers/role/security.md +0 -15
- package/src/llm/system-prompt/layers/tool/artifacts.md +0 -72
- package/src/llm/system-prompt/layers/tool/bash.md +0 -25
- package/src/llm/system-prompt/layers/tool/hibs_api.md +0 -171
- package/src/llm/system-prompt/layers/tool/image_search.md +0 -70
- package/src/llm/system-prompt/layers/tool/manifest.md +0 -89
- package/src/llm/system-prompt/layers/tool/mcp_apps.md +0 -53
- package/src/llm/system-prompt/layers/tool/web_search.md +0 -83
- package/src/llm/system-prompt/registry.ts +0 -325
- package/src/llm/system-prompt/strip-hibsml.ts +0 -52
- package/src/llm/tool-manifest/ask_user_input.ts +0 -37
- package/src/llm/tool-manifest/bash.ts +0 -25
- package/src/llm/tool-manifest/create_file.ts +0 -26
- package/src/llm/tool-manifest/fetch_sports_data.ts +0 -28
- package/src/llm/tool-manifest/image_search.ts +0 -26
- package/src/llm/tool-manifest/index.ts +0 -88
- package/src/llm/tool-manifest/mcp.ts +0 -46
- package/src/llm/tool-manifest/message_compose.ts +0 -33
- package/src/llm/tool-manifest/places.ts +0 -86
- package/src/llm/tool-manifest/present_files.ts +0 -23
- package/src/llm/tool-manifest/recipe.ts +0 -42
- package/src/llm/tool-manifest/recommend_apps.ts +0 -25
- package/src/llm/tool-manifest/str_replace.ts +0 -29
- package/src/llm/tool-manifest/types.ts +0 -52
- package/src/llm/tool-manifest/view.ts +0 -26
- package/src/llm/tool-manifest/weather.ts +0 -29
- package/src/llm/tool-manifest/web.ts +0 -54
- package/src/llm/video-config-store.ts +0 -257
- package/src/network/agent-network.ts +0 -800
- package/src/network/hybrid-messenger.ts +0 -199
- package/src/network/iroh-bootstrap.ts +0 -57
- package/src/network/iroh-discovery.ts +0 -208
- package/src/network/iroh-integration.ts +0 -158
- package/src/network/iroh-transport.ts +0 -637
- package/src/network/known-peers.ts +0 -102
- package/src/network/p2p-direct.ts +0 -262
- package/src/network/p2p-secret.ts +0 -153
- package/src/network/p2p.ts +0 -964
- package/src/network/source-intent-broadcaster.ts +0 -242
- package/src/network/source-intent.ts +0 -167
- package/src/network/storage/adapters/json-adapter.ts +0 -454
- package/src/network/storage/index.ts +0 -203
- package/src/network/storage/types.ts +0 -166
- package/src/security/builtin-guards.ts +0 -162
- package/src/security/context-router-tool.ts +0 -122
- package/src/security/input-scanner.ts +0 -287
- package/src/security/react-harness.ts +0 -177
- package/src/security/tool-gate.ts +0 -294
- package/src/social/ant-colony/index.js +0 -19
- package/src/social/channels/ChannelManager.ts +0 -485
- package/src/social/channels/DiapChannelBridge.ts +0 -501
- package/src/social/channels/InterestMatcher.ts +0 -189
- package/src/social/channels/agent-workflow-config.json +0 -214
- package/src/social/channels/agent-workflow-config.yaml +0 -334
- package/src/social/channels/channel-agent-session.ts +0 -407
- package/src/social/channels/channel-heartbeat-agent.ts +0 -622
- package/src/social/channels/diap-doc-parser.ts +0 -282
- package/src/social/channels/harness-workflow-integrator.ts +0 -594
- package/src/social/channels/index.ts +0 -22
- package/src/social/channels/types.ts +0 -115
- package/src/social/global-shared-context.ts +0 -506
- package/src/social/heartbeat.ts +0 -1057
- package/src/social/persona/enhanced-persona.ts +0 -359
- package/src/types.d.ts +0 -12
- package/src/utils/auto-evolve-policy.ts +0 -138
- package/src/utils/auto-update.ts +0 -482
- package/src/utils/clamp.ts +0 -5
- package/src/web/agent-delegate-server.ts +0 -148
- package/src/web/api-config.html +0 -520
- package/src/web/client.js +0 -2352
- package/src/web/client.ts +0 -4326
- package/src/web/components/p2p/P2PModal.tsx +0 -416
- package/src/web/components/p2p/index.ts +0 -566
- package/src/web/components/p2p/index.tsx +0 -297
- package/src/web/components/p2p/p2p-connection.ts +0 -338
- package/src/web/components/p2p/p2p-identity.ts +0 -92
- package/src/web/components/p2p/p2p-manager.ts +0 -147
- package/src/web/components/p2p/p2p-messages.ts +0 -219
- package/src/web/components/p2p/p2p-modal.ts +0 -685
- package/src/web/components/p2p/p2p-store-memory.ts +0 -162
- package/src/web/components/p2p/p2p-tools.ts +0 -315
- package/src/web/components/p2p/types.ts +0 -170
- package/src/web/components/wallet-viem.mjs +0 -118
- package/src/web/design.md +0 -99
- package/src/web/icons/apple-touch-icon.png +0 -0
- package/src/web/icons/favicon-16x16.png +0 -0
- package/src/web/icons/favicon-192x192.png +0 -0
- package/src/web/icons/favicon-32x32.png +0 -0
- package/src/web/icons/favicon-48x48.png +0 -0
- package/src/web/icons/favicon-512x512.png +0 -0
- package/src/web/icons/favicon.icns +0 -0
- package/src/web/icons/favicon.ico +0 -0
- package/src/web/icons/icon.png +0 -0
- package/src/web/icons/image.png +0 -0
- package/src/web/index.html +0 -373
- package/src/web/iroh-delegate-transport.ts +0 -139
- package/src/web/manifest.json +0 -21
- package/src/web/server.ts +0 -5731
- package/src/web/style.css +0 -4737
- package/src/web/ui/message-renderer.ts +0 -540
- package/src/web/ui/step-timeline.ts +0 -394
- package/staging/auto-evolve/clean-001/.review-verdict +0 -9
- package/staging/auto-evolve/clean-001/clean-001.patch +0 -14
- package/staging/auto-evolve/e2e-001/.patch-id +0 -1
- package/staging/auto-evolve/e2e-001/.review-verdict +0 -12
- package/staging/auto-evolve/e2e-001/e2e-001.patch +0 -11
- package/staging/auto-evolve/test-bad/.review-verdict +0 -12
- package/staging/auto-evolve/test-bad/test-bad.patch +0 -11
- package/test-results/.last-run.json +0 -6
- package/test-results/src-test-web-loop-status-b-5734c-atus-bar-/346/230/276/347/244/272-spinner-/344/270/215/346/230/276/347/244/272/345/276/252/347/216/257/350/256/241/346/225/260/error-context.md +0 -285
- package/tsconfig.cli.json +0 -16
- package/tsconfig.electron.json +0 -20
- package/tsconfig.json +0 -18
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-Compact — 第 5 层: LLM 摘要 (最后手段)
|
|
3
|
-
*
|
|
4
|
-
* 论文:
|
|
5
|
-
* - 兜底层, budget > 100% 时才触发
|
|
6
|
-
* - 用 LLM 生成完整摘要, 替代前 K 对 user/assistant
|
|
7
|
-
* - 摘要 prompt 明确要求"必须保留出现过的 tool names"
|
|
8
|
-
* - 缓存到 ~/.bolloon/sessions/<channel>/compaction-cache.json
|
|
9
|
-
* - LLM 失败 → fallback 保留原文
|
|
10
|
-
*
|
|
11
|
-
* 关键不变量: 这是**破坏性**的 (折叠 N 对成 1 条), 调用方接受新 history
|
|
12
|
-
*
|
|
13
|
-
* 失败静默: LLM 失败 → 返回原 history (与现状一致)
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import * as crypto from 'crypto';
|
|
17
|
-
import * as fs from 'fs/promises';
|
|
18
|
-
import * as os from 'os';
|
|
19
|
-
import * as path from 'path';
|
|
20
|
-
import type { Message, StageResult, StageOptions } from './types.js';
|
|
21
|
-
|
|
22
|
-
const DEFAULT_COLLAPSE_PAIRS = 5;
|
|
23
|
-
const CACHE_DIR = () => path.join(process.env.HOME || os.homedir() || '/tmp', '.bolloon', 'sessions', 'compaction-cache');
|
|
24
|
-
|
|
25
|
-
function cacheKey(history: Message[], collapsePairs: number): string {
|
|
26
|
-
const slice = history.slice(0, collapsePairs * 2);
|
|
27
|
-
const joined = slice.map((m) => `${m.role}:${m.content}`).join('|');
|
|
28
|
-
return crypto.createHash('sha1').update(joined).digest('hex').slice(0, 12);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function readCache(scope: string, key: string): Promise<string | null> {
|
|
32
|
-
try {
|
|
33
|
-
const file = path.join(CACHE_DIR(), `${scope}_${key}.json`);
|
|
34
|
-
const raw = await fs.readFile(file, 'utf-8');
|
|
35
|
-
const obj = JSON.parse(raw);
|
|
36
|
-
if (typeof obj.summary === 'string' && Date.now() - obj.ts < 24 * 60 * 60 * 1000) {
|
|
37
|
-
return obj.summary;
|
|
38
|
-
}
|
|
39
|
-
} catch { /* cache miss or parse err */ }
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function writeCache(scope: string, key: string, summary: string): Promise<void> {
|
|
44
|
-
try {
|
|
45
|
-
await fs.mkdir(CACHE_DIR(), { recursive: true });
|
|
46
|
-
const file = path.join(CACHE_DIR(), `${scope}_${key}.json`);
|
|
47
|
-
await fs.writeFile(file, JSON.stringify({ ts: Date.now(), summary, key }), 'utf-8');
|
|
48
|
-
} catch (err) {
|
|
49
|
-
console.warn('[compactor] cache write failed (silent):', err);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const SUMMARIZE_SYSTEM = `你是一个对话历史压缩助手.
|
|
54
|
-
你的任务: 把给定的对话历史压缩成 1-2 句话的摘要, 保留所有出现过的 tool names.
|
|
55
|
-
要求:
|
|
56
|
-
- 保留所有用户的关键需求
|
|
57
|
-
- 保留所有调用过的 tool names (例如 read_file, shell_exec, use_skill 等)
|
|
58
|
-
- 保留关键决策和发现
|
|
59
|
-
- 不要添加原对话中没有的信息
|
|
60
|
-
- 输出纯文本, 不要 JSON, 不要 markdown 标题`;
|
|
61
|
-
|
|
62
|
-
export async function autoCompact(history: Message[], opts: StageOptions = {}): Promise<StageResult> {
|
|
63
|
-
try {
|
|
64
|
-
if (opts.skip) return { history, applied: false, detail: 'skipped' };
|
|
65
|
-
const collapsePairs = opts.autoCompactCollapsePairs ?? DEFAULT_COLLAPSE_PAIRS;
|
|
66
|
-
|
|
67
|
-
// 找前 K 对的边界
|
|
68
|
-
let pairsFound = 0;
|
|
69
|
-
let cutTo = -1;
|
|
70
|
-
for (let i = 0; i < history.length; i++) {
|
|
71
|
-
if (history[i].role === 'user') {
|
|
72
|
-
pairsFound++;
|
|
73
|
-
if (pairsPairsOver(pairsFound, collapsePairs)) {
|
|
74
|
-
cutTo = i;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (cutTo <= 0) {
|
|
80
|
-
return { history, applied: false, detail: 'history too short' };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const toCollapse = history.slice(0, cutTo);
|
|
84
|
-
const remaining = history.slice(cutTo);
|
|
85
|
-
const scope = opts.cacheScope || 'default';
|
|
86
|
-
|
|
87
|
-
// 1. 查缓存 (key 基于实际被切的消息, 不用理论 collapsePairs)
|
|
88
|
-
const key = crypto.createHash('sha1').update(
|
|
89
|
-
toCollapse.map((m) => `${m.role}:${m.content}`).join('|')
|
|
90
|
-
).digest('hex').slice(0, 12);
|
|
91
|
-
let summary = await readCache(scope, key);
|
|
92
|
-
|
|
93
|
-
// 2. 没缓存就调 LLM
|
|
94
|
-
if (!summary) {
|
|
95
|
-
if (!opts.llmChat) {
|
|
96
|
-
// 没有 LLM 就 fallback 保留原文
|
|
97
|
-
console.warn('[compactor] autoCompact: no llmChat injected, returning original');
|
|
98
|
-
return { history, applied: false, detail: 'no llmChat available' };
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
const userPrompt = `以下是 ${cutTo} 条较早的对话历史, 请压缩为 1-2 句摘要:\n\n${formatForSummary(toCollapse)}`;
|
|
102
|
-
summary = await opts.llmChat(SUMMARIZE_SYSTEM, userPrompt);
|
|
103
|
-
if (!summary || summary.trim().length === 0) {
|
|
104
|
-
return { history, applied: false, detail: 'llm returned empty' };
|
|
105
|
-
}
|
|
106
|
-
// 写缓存 (静默, 但 await 确保测试可重现)
|
|
107
|
-
try { await writeCache(scope, key, summary); } catch { /* ignored */ }
|
|
108
|
-
} catch (err) {
|
|
109
|
-
console.warn('[compactor] autoCompact LLM call failed (silent, fallback):', err);
|
|
110
|
-
return { history, applied: false, detail: 'llm call failed' };
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 3. 折叠: 1 条 summary 消息替代 N 条原文
|
|
115
|
-
const summaryMsg: Message = {
|
|
116
|
-
role: 'system',
|
|
117
|
-
content: `[Auto-Compact Summary] ${summary}`,
|
|
118
|
-
} as any;
|
|
119
|
-
return {
|
|
120
|
-
history: [summaryMsg, ...remaining],
|
|
121
|
-
applied: true,
|
|
122
|
-
detail: `collapsed ${cutTo} messages into 1 summary (cache key: ${key})`,
|
|
123
|
-
};
|
|
124
|
-
} catch (err) {
|
|
125
|
-
console.warn('[compactor] autoCompact failed (silent, returning original):', err);
|
|
126
|
-
return { history, applied: false, detail: 'error' };
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function pairsPairsOver(found: number, target: number): boolean {
|
|
131
|
-
return found > target;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function formatForSummary(messages: Message[]): string {
|
|
135
|
-
return messages.map((m) => {
|
|
136
|
-
if (m.role === 'user') return `用户: ${m.content}`;
|
|
137
|
-
if (m.role === 'assistant') return `助手: ${m.content.substring(0, 500)}`;
|
|
138
|
-
if (m.role === 'tool') {
|
|
139
|
-
const r = (m as any).toolResult;
|
|
140
|
-
return `工具: ${typeof r === 'string' ? r : JSON.stringify(r).substring(0, 300)}`;
|
|
141
|
-
}
|
|
142
|
-
return m.content;
|
|
143
|
-
}).join('\n');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ============================================================
|
|
147
|
-
// 测试钩子
|
|
148
|
-
// ============================================================
|
|
149
|
-
|
|
150
|
-
export function _resetAutoCompactCacheForTest(): void {
|
|
151
|
-
// 实际缓存由 readCache/writeCache 管理, 这里只暴露接口
|
|
152
|
-
// 测试可以走 fs.rm CACHE_DIR() 清理
|
|
153
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Budget Gate — 预算判定 (不修改消息)
|
|
3
|
-
*
|
|
4
|
-
* 论文: 这是判定阶段, 不是压缩阶段. 触发条件:
|
|
5
|
-
* - ratio < 0.8 → fit, 不压缩
|
|
6
|
-
* - 0.8 ≤ ratio ≤ 1.0 → triggerNextLayer (跑下一层)
|
|
7
|
-
* - ratio > 1.0 → triggerNextLayer, 全部层都跑
|
|
8
|
-
*
|
|
9
|
-
* 失败静默: 任何异常 → 视为 fit (与现状一致, 不冒险压缩)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { Message } from './types.js';
|
|
13
|
-
import { estimateTokens } from './token-estimator.js';
|
|
14
|
-
import type { BudgetReport } from './types.js';
|
|
15
|
-
|
|
16
|
-
const FIT_THRESHOLD = 0.8;
|
|
17
|
-
|
|
18
|
-
export function budgetGate(history: Message[], maxTokens: number = 8000): BudgetReport {
|
|
19
|
-
try {
|
|
20
|
-
const estimatedTokens = estimateTokens(history as any);
|
|
21
|
-
const ratio = maxTokens > 0 ? estimatedTokens / maxTokens : 0;
|
|
22
|
-
return {
|
|
23
|
-
fit: ratio < FIT_THRESHOLD,
|
|
24
|
-
estimatedTokens,
|
|
25
|
-
ratio,
|
|
26
|
-
triggerNextLayer: ratio >= FIT_THRESHOLD,
|
|
27
|
-
};
|
|
28
|
-
} catch (err) {
|
|
29
|
-
console.warn('[compactor] budgetGate failed (silent, treating as fit):', err);
|
|
30
|
-
return { fit: true, estimatedTokens: 0, ratio: 0, triggerNextLayer: false };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Budget Reduction — 第 1 层: 单条消息大小限制
|
|
3
|
-
*
|
|
4
|
-
* 论文: 总是跑. 截断 > 阈值的单条消息, 加 ... [truncated, original=N chars]
|
|
5
|
-
*
|
|
6
|
-
* 关键: 不破坏 messageHistory 内存结构, 只改 buildContext 输出
|
|
7
|
-
* 但因为 buildContext 需要最终字符串, 这里实际返回新 history
|
|
8
|
-
* (内容相同的引用 = 内存未真正变更)
|
|
9
|
-
*
|
|
10
|
-
* 失败静默: 异常 → 返回原 history
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { Message, StageResult, StageOptions } from './types.js';
|
|
14
|
-
|
|
15
|
-
const DEFAULT_MAX_CHARS = 4000;
|
|
16
|
-
|
|
17
|
-
export function budgetReduce(history: Message[], opts: StageOptions = {}): StageResult {
|
|
18
|
-
try {
|
|
19
|
-
if (opts.skip) return { history, applied: false, detail: 'skipped' };
|
|
20
|
-
const maxChars = opts.budgetReduceMaxChars ?? DEFAULT_MAX_CHARS;
|
|
21
|
-
let changed = false;
|
|
22
|
-
const out: Message[] = history.map((m) => {
|
|
23
|
-
if (m.content && m.content.length > maxChars) {
|
|
24
|
-
changed = true;
|
|
25
|
-
return {
|
|
26
|
-
...m,
|
|
27
|
-
content: m.content.substring(0, maxChars) + `\n... [truncated, original=${m.content.length} chars]`,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
return m;
|
|
31
|
-
});
|
|
32
|
-
return { history: out, applied: changed, detail: changed ? `truncated >${maxChars} chars` : 'no oversized messages' };
|
|
33
|
-
} catch (err) {
|
|
34
|
-
console.warn('[compactor] budgetReduce failed (silent, returning original):', err);
|
|
35
|
-
return { history, applied: false, detail: 'error' };
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Collapse — 第 4 层: 读时虚拟投影 (非破坏)
|
|
3
|
-
*
|
|
4
|
-
* 论文:
|
|
5
|
-
* - 不修改 messageHistory
|
|
6
|
-
* - 在 buildContext() 输出阶段, 前 K 对 user/assistant 替换为 [collapsed: <summary>]
|
|
7
|
-
* - feature flag BOLLOON_CONTEXT_COLLAPSE 默认关闭
|
|
8
|
-
*
|
|
9
|
-
* 实现策略:
|
|
10
|
-
* - 由于 buildContext 阶段才输出最终字符串, 这里"虚拟投影"实际意味着:
|
|
11
|
-
* 返回一个新 history, 前 K 对用一个虚拟的 "collapsed" summary 消息替代
|
|
12
|
-
* - 但 memory 层的 messageHistory 不变 (由调用方负责回滚或仅在 buildContext 内用)
|
|
13
|
-
*
|
|
14
|
-
* 实践: 本 stage 返回一个标记 collapsed=true 的 history, 调用方可以选择:
|
|
15
|
-
* (a) 仅在 buildContext 字符串拼接时替换 (理想)
|
|
16
|
-
* (b) 临时替换 (本次 LLM call 结束后回滚)
|
|
17
|
-
* (c) 永久替换 (但这违背"非破坏"原则)
|
|
18
|
-
*
|
|
19
|
-
* 本模块选 (b): 返回新 history, 标记 collapsedMeta 字段, 文档说明调用方应仅用于构建 LLM 输入
|
|
20
|
-
*
|
|
21
|
-
* 失败静默: 异常 → 返回原 history
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import type { Message, StageResult, StageOptions } from './types.js';
|
|
25
|
-
|
|
26
|
-
const DEFAULT_COLLAPSE_PAIRS = 5;
|
|
27
|
-
const DEFAULT_SUMMARY = '[collapsed: N earlier rounds — summary not yet generated]';
|
|
28
|
-
|
|
29
|
-
export function isContextCollapseEnabled(): boolean {
|
|
30
|
-
return process.env.BOLLOON_CONTEXT_COLLAPSE === '1';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function contextCollapse(history: Message[], opts: StageOptions = {}): StageResult {
|
|
34
|
-
try {
|
|
35
|
-
if (opts.skip || !isContextCollapseEnabled()) {
|
|
36
|
-
return { history, applied: false, detail: isContextCollapseEnabled() ? 'skipped' : 'feature flag off' };
|
|
37
|
-
}
|
|
38
|
-
const collapsePairs = opts.contextCollapseCollapsePairs ?? DEFAULT_COLLAPSE_PAIRS;
|
|
39
|
-
|
|
40
|
-
// 找前 K 对 user/assistant 的边界
|
|
41
|
-
let pairsFound = 0;
|
|
42
|
-
let cutTo = -1;
|
|
43
|
-
for (let i = 0; i < history.length; i++) {
|
|
44
|
-
if (history[i].role === 'user') {
|
|
45
|
-
pairsFound++;
|
|
46
|
-
if (pairsFound > collapsePairs) {
|
|
47
|
-
cutTo = i;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (cutTo <= 0) {
|
|
53
|
-
return { history, applied: false, detail: 'history too short' };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 把前 cutTo 条压成 1 条 virtual summary message
|
|
57
|
-
const collapsedCount = cutTo;
|
|
58
|
-
const summaryMsg: Message = {
|
|
59
|
-
role: 'system',
|
|
60
|
-
content: `[collapsed: ${collapsedCount} earlier messages (${collapsePairs} pairs) — virtual projection, original history preserved]`,
|
|
61
|
-
} as any;
|
|
62
|
-
const out: Message[] = [summaryMsg, ...history.slice(cutTo)];
|
|
63
|
-
return {
|
|
64
|
-
history: out,
|
|
65
|
-
applied: true,
|
|
66
|
-
detail: `virtual-collapsed first ${collapsedCount} messages`,
|
|
67
|
-
};
|
|
68
|
-
} catch (err) {
|
|
69
|
-
console.warn('[compactor] contextCollapse failed (silent, returning original):', err);
|
|
70
|
-
return { history, applied: false, detail: 'error' };
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Compaction — 公共导出 (barrel)
|
|
3
|
-
*
|
|
4
|
-
* 设计: 严格对齐 Claude Code 论文 5 层压缩流水线
|
|
5
|
-
* 1. Budget Reduction (单条消息大小限制)
|
|
6
|
-
* 2. Snip (裁掉老历史, feature flag 关闭)
|
|
7
|
-
* 3. Microcompact (cache-aware 细粒度压缩)
|
|
8
|
-
* 4. Context Collapse (读时虚拟投影, feature flag 关闭)
|
|
9
|
-
* 5. Auto-Compact (LLM 摘要, 兜底)
|
|
10
|
-
*
|
|
11
|
-
* 主要入口: `compactPipeline(history, opts)`
|
|
12
|
-
* 失败静默: 任何 stage 抛错 → pipeline 返回原 history
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export type { Message, StageResult, StageOptions, PipelineResult, BudgetReport, CompactionContext } from './types.js';
|
|
16
|
-
|
|
17
|
-
export { compactPipeline, _resetPipelineForTest } from './pipeline.js';
|
|
18
|
-
export { budgetGate } from './budget-gate.js';
|
|
19
|
-
export { budgetReduce } from './budget-reduce.js';
|
|
20
|
-
export { snip, isSnipEnabled } from './snip.js';
|
|
21
|
-
export { microcompact } from './microcompact.js';
|
|
22
|
-
export { contextCollapse, isContextCollapseEnabled } from './context-collapse.js';
|
|
23
|
-
export { autoCompact, _resetAutoCompactCacheForTest } from './auto-compact.js';
|
|
24
|
-
export { estimateTokens, estimateStringTokens } from './token-estimator.js';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Microcompact — 第 3 层: cache-aware 细粒度压缩
|
|
3
|
-
*
|
|
4
|
-
* 论文: 总是跑 (时间触发), 关键作用是保留 prompt cache 命中
|
|
5
|
-
* 实现 (简化版): 把老的 toolResult 折叠为 "(tool result: <name>, N chars)"
|
|
6
|
-
* - 保留最近 N 条 tool_result 完整 (默认 3)
|
|
7
|
-
* - 之前的折叠
|
|
8
|
-
*
|
|
9
|
-
* 关键: 不破坏 messageHistory 内存结构
|
|
10
|
-
*
|
|
11
|
-
* 失败静默: 异常 → 返回原 history
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import type { Message, StageResult, StageOptions } from './types.js';
|
|
15
|
-
|
|
16
|
-
const DEFAULT_KEEP_RECENT = 3;
|
|
17
|
-
|
|
18
|
-
export function microcompact(history: Message[], opts: StageOptions = {}): StageResult {
|
|
19
|
-
try {
|
|
20
|
-
if (opts.skip) return { history, applied: false, detail: 'skipped' };
|
|
21
|
-
const keepRecent = opts.microcompactKeepRecent ?? DEFAULT_KEEP_RECENT;
|
|
22
|
-
|
|
23
|
-
// 找所有 tool 消息的索引
|
|
24
|
-
const toolIndices: number[] = [];
|
|
25
|
-
for (let i = 0; i < history.length; i++) {
|
|
26
|
-
if (history[i].role === 'tool') toolIndices.push(i);
|
|
27
|
-
}
|
|
28
|
-
if (toolIndices.length <= keepRecent) {
|
|
29
|
-
return { history, applied: false, detail: 'no old tool_results to fold' };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 要折叠的 = 前 (total - keepRecent) 条
|
|
33
|
-
const toFold = new Set(toolIndices.slice(0, toolIndices.length - keepRecent));
|
|
34
|
-
let changed = false;
|
|
35
|
-
const out: Message[] = history.map((m, i) => {
|
|
36
|
-
if (toFold.has(i) && m.role === 'tool') {
|
|
37
|
-
changed = true;
|
|
38
|
-
// 尝试从相邻的 assistant 消息拿 tool name
|
|
39
|
-
const name = (m as any).toolName || 'unknown';
|
|
40
|
-
const originalLen = m.content?.length || 0;
|
|
41
|
-
return {
|
|
42
|
-
...m,
|
|
43
|
-
content: `(tool result: ${name}, ${originalLen} chars — folded by microcompact)`,
|
|
44
|
-
toolResult: undefined,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return m;
|
|
48
|
-
});
|
|
49
|
-
return { history: out, applied: changed, detail: `folded ${toFold.size} old tool_results, kept last ${keepRecent}` };
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.warn('[compactor] microcompact failed (silent, returning original):', err);
|
|
52
|
-
return { history, applied: false, detail: 'error' };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context Compaction Pipeline — 5 层编排
|
|
3
|
-
*
|
|
4
|
-
* 严格对齐 Claude Code 论文: 每次 LLM call 前顺序执行 5 个 shaper, 由便宜到重, 任一层 fit 就短路.
|
|
5
|
-
*
|
|
6
|
-
* 1. Budget Reduction (总是, 截断 > 阈值的单条消息)
|
|
7
|
-
* 2. Snip (feature flag BOLLOON_SNIP_ENABLED)
|
|
8
|
-
* 3. Microcompact (总是, 折叠老 tool_result)
|
|
9
|
-
* 4. Context Collapse (feature flag BOLLOON_CONTEXT_COLLAPSE, 读时虚拟投影)
|
|
10
|
-
* 5. Auto-Compact (LLM 摘要, 兜底)
|
|
11
|
-
*
|
|
12
|
-
* 短路: 任一层后 budget fit (< 0.8) → 返回该层结果, 不跑后续.
|
|
13
|
-
*
|
|
14
|
-
* 关键不变量:
|
|
15
|
-
* - 任何异常 → 整 pipeline 返回原 history (与现状一致)
|
|
16
|
-
* - 第 1-3 层不破坏 messageHistory 内存引用 (内容可改)
|
|
17
|
-
* - 第 4 层读时投影, memory 不变
|
|
18
|
-
* - 第 5 层破坏性, 折叠 N 对成 1 条
|
|
19
|
-
*
|
|
20
|
-
* 失败静默: 整 pipeline 用 try/catch 包, 任何 stage 失败不影响整体
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import type { Message, StageResult, StageOptions, PipelineResult, CompactionContext } from './types.js';
|
|
24
|
-
import { budgetGate } from './budget-gate.js';
|
|
25
|
-
import { budgetReduce } from './budget-reduce.js';
|
|
26
|
-
import { snip, isSnipEnabled } from './snip.js';
|
|
27
|
-
import { microcompact } from './microcompact.js';
|
|
28
|
-
import { contextCollapse, isContextCollapseEnabled } from './context-collapse.js';
|
|
29
|
-
import { autoCompact } from './auto-compact.js';
|
|
30
|
-
|
|
31
|
-
const DEFAULT_MAX_TOKENS = 8000;
|
|
32
|
-
|
|
33
|
-
export async function compactPipeline(
|
|
34
|
-
history: Message[],
|
|
35
|
-
opts: StageOptions = {}
|
|
36
|
-
): Promise<PipelineResult> {
|
|
37
|
-
const maxTokens = opts.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
38
|
-
const ctx: CompactionContext = {
|
|
39
|
-
inputHistory: history,
|
|
40
|
-
history,
|
|
41
|
-
estimatedTokens: 0,
|
|
42
|
-
opts,
|
|
43
|
-
stages: [],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
// Stage 1: Budget Reduction
|
|
48
|
-
let result = budgetReduce(history, opts);
|
|
49
|
-
ctx.history = result.history;
|
|
50
|
-
ctx.stages.push(stageRecord('budgetReduce', result, history));
|
|
51
|
-
let gate = budgetGate(ctx.history, maxTokens);
|
|
52
|
-
ctx.estimatedTokens = gate.estimatedTokens;
|
|
53
|
-
if (gate.fit) return finalize(ctx, result.applied); // 短路但可能 budgetReduce 实际改了内容
|
|
54
|
-
|
|
55
|
-
// Stage 2: Snip (feature flag)
|
|
56
|
-
if (isSnipEnabled()) {
|
|
57
|
-
const before = ctx.history;
|
|
58
|
-
result = snip(ctx.history, opts);
|
|
59
|
-
ctx.history = result.history;
|
|
60
|
-
ctx.stages.push(stageRecord('snip', result, before));
|
|
61
|
-
gate = budgetGate(ctx.history, maxTokens);
|
|
62
|
-
ctx.estimatedTokens = gate.estimatedTokens;
|
|
63
|
-
if (gate.fit) return finalize(ctx, true);
|
|
64
|
-
} else {
|
|
65
|
-
ctx.stages.push({ stage: 'snip', applied: false, before: ctx.history.length, after: ctx.history.length, detail: 'feature flag off' });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Stage 3: Microcompact
|
|
69
|
-
const before3 = ctx.history;
|
|
70
|
-
result = microcompact(ctx.history, opts);
|
|
71
|
-
ctx.history = result.history;
|
|
72
|
-
ctx.stages.push(stageRecord('microcompact', result, before3));
|
|
73
|
-
gate = budgetGate(ctx.history, maxTokens);
|
|
74
|
-
ctx.estimatedTokens = gate.estimatedTokens;
|
|
75
|
-
if (gate.fit) return finalize(ctx, result.applied || true);
|
|
76
|
-
|
|
77
|
-
// Stage 4: Context Collapse (feature flag)
|
|
78
|
-
if (isContextCollapseEnabled()) {
|
|
79
|
-
const before4 = ctx.history;
|
|
80
|
-
result = contextCollapse(ctx.history, opts);
|
|
81
|
-
ctx.history = result.history;
|
|
82
|
-
ctx.stages.push(stageRecord('contextCollapse', result, before4));
|
|
83
|
-
gate = budgetGate(ctx.history, maxTokens);
|
|
84
|
-
ctx.estimatedTokens = gate.estimatedTokens;
|
|
85
|
-
if (gate.fit) return finalize(ctx, true);
|
|
86
|
-
} else {
|
|
87
|
-
ctx.stages.push({ stage: 'contextCollapse', applied: false, before: ctx.history.length, after: ctx.history.length, detail: 'feature flag off' });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Stage 5: Auto-Compact (兜底)
|
|
91
|
-
const before5 = ctx.history;
|
|
92
|
-
result = await autoCompact(ctx.history, opts);
|
|
93
|
-
ctx.history = result.history;
|
|
94
|
-
ctx.stages.push(stageRecord('autoCompact', result, before5));
|
|
95
|
-
|
|
96
|
-
return finalize(ctx, true);
|
|
97
|
-
} catch (err) {
|
|
98
|
-
console.warn('[compactor] pipeline failed (silent, returning original):', err);
|
|
99
|
-
return {
|
|
100
|
-
history,
|
|
101
|
-
estimatedTokens: 0,
|
|
102
|
-
stages: ctx.stages,
|
|
103
|
-
compacted: false,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function stageRecord(name: string, result: StageResult, before: Message[]) {
|
|
109
|
-
return {
|
|
110
|
-
stage: name,
|
|
111
|
-
applied: result.applied,
|
|
112
|
-
before: before.length,
|
|
113
|
-
after: result.history.length,
|
|
114
|
-
detail: result.detail,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function finalize(ctx: CompactionContext, compacted: boolean): PipelineResult {
|
|
119
|
-
return {
|
|
120
|
-
history: ctx.history,
|
|
121
|
-
estimatedTokens: ctx.estimatedTokens,
|
|
122
|
-
stages: ctx.stages,
|
|
123
|
-
compacted,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// ============================================================
|
|
128
|
-
// 测试钩子
|
|
129
|
-
// ============================================================
|
|
130
|
-
|
|
131
|
-
export function _resetPipelineForTest(): void {
|
|
132
|
-
// pipeline 是 stateless, 但保留 API 一致性
|
|
133
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snip — 第 2 层: 裁掉老 history
|
|
3
|
-
*
|
|
4
|
-
* 论文: feature flag 关闭 (默认), 用户开启后才生效
|
|
5
|
-
* 开启环境变量: BOLLOON_SNIP_ENABLED=1
|
|
6
|
-
*
|
|
7
|
-
* 行为: 只保留最近 N 对 user/assistant (默认 20 对)
|
|
8
|
-
* 工具结果消息按其所属 round 一起保留
|
|
9
|
-
*
|
|
10
|
-
* 失败静默: 异常 → 返回原 history
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { Message, StageResult, StageOptions } from './types.js';
|
|
14
|
-
|
|
15
|
-
const DEFAULT_KEEP_PAIRS = 20;
|
|
16
|
-
|
|
17
|
-
export function isSnipEnabled(): boolean {
|
|
18
|
-
return process.env.BOLLOON_SNIP_ENABLED === '1';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function snip(history: Message[], opts: StageOptions = {}): StageResult {
|
|
22
|
-
try {
|
|
23
|
-
if (opts.skip || !isSnipEnabled()) {
|
|
24
|
-
return { history, applied: false, detail: isSnipEnabled() ? 'skipped' : 'feature flag off' };
|
|
25
|
-
}
|
|
26
|
-
const keepPairs = opts.snipKeepPairs ?? DEFAULT_KEEP_PAIRS;
|
|
27
|
-
|
|
28
|
-
// 从后往前数 N 对 user/assistant 边界
|
|
29
|
-
let pairsFound = 0;
|
|
30
|
-
let cutFrom = -1;
|
|
31
|
-
for (let i = history.length - 1; i >= 0; i--) {
|
|
32
|
-
const m = history[i];
|
|
33
|
-
if (m.role === 'user') {
|
|
34
|
-
pairsFound++;
|
|
35
|
-
if (pairsFound >= keepPairs) {
|
|
36
|
-
cutFrom = i;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (cutFrom <= 0) {
|
|
43
|
-
return { history, applied: false, detail: 'history too short' };
|
|
44
|
-
}
|
|
45
|
-
const out = history.slice(cutFrom);
|
|
46
|
-
return { history: out, applied: true, detail: `kept last ${keepPairs} pairs, dropped ${cutFrom} older messages` };
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.warn('[compactor] snip failed (silent, returning original):', err);
|
|
49
|
-
return { history, applied: false, detail: 'error' };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token Estimator — 4 字符 ≈ 1 token 的粗估
|
|
3
|
-
*
|
|
4
|
-
* 为什么不引 tiktoken 依赖:
|
|
5
|
-
* - bolloon 默认 npm 用户, 引依赖增加 install 体积
|
|
6
|
-
* - Claude Code 论文也指出: 精确 token 计数不是关键, 渐进压缩才是
|
|
7
|
-
* - 4 字符/token 在中文/英文混合场景下误差约 ±20%, 对预算判定足够
|
|
8
|
-
*
|
|
9
|
-
* 失败静默: 任何异常 → 返回估算值 (不抛错)
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const CHARS_PER_TOKEN = 4;
|
|
13
|
-
|
|
14
|
-
export function estimateTokens(messages: Array<{ content: string; toolResult?: unknown; toolCall?: unknown }>): number {
|
|
15
|
-
let total = 0;
|
|
16
|
-
for (const m of messages) {
|
|
17
|
-
total += Math.ceil((m.content?.length || 0) / CHARS_PER_TOKEN);
|
|
18
|
-
if (m.toolResult) {
|
|
19
|
-
try {
|
|
20
|
-
const s = typeof m.toolResult === 'string' ? m.toolResult : JSON.stringify(m.toolResult);
|
|
21
|
-
total += Math.ceil(s.length / CHARS_PER_TOKEN);
|
|
22
|
-
} catch { /* circular ref, ignore */ }
|
|
23
|
-
}
|
|
24
|
-
if (m.toolCall) {
|
|
25
|
-
try {
|
|
26
|
-
const s = typeof m.toolCall === 'string' ? m.toolCall : JSON.stringify(m.toolCall);
|
|
27
|
-
total += Math.ceil(s.length / CHARS_PER_TOKEN);
|
|
28
|
-
} catch { /* ignore */ }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return total;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function estimateStringTokens(s: string): number {
|
|
35
|
-
return Math.ceil(s.length / CHARS_PER_TOKEN);
|
|
36
|
-
}
|