@theowlops/boombot 0.0.0-stage → 1.1.1
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/README.md +69 -3
- package/dist/LICENSE +21 -0
- package/dist/bin/boombot.js +16 -0
- package/dist/cli/api-key.js +123 -0
- package/dist/cli/bin-bun.js +17 -0
- package/dist/cli/bin.js +34 -0
- package/dist/cli/cli/cli-error.js +61 -0
- package/dist/cli/cli/dispatch.js +138 -0
- package/dist/cli/cli/help.js +83 -0
- package/dist/cli/cli/parser.js +89 -0
- package/dist/cli/cli/registry.js +185 -0
- package/dist/cli/cli/spec.js +41 -0
- package/dist/cli/cli/suggest.js +125 -0
- package/dist/cli/cli/version.js +30 -0
- package/dist/cli/cli/vocabulary.js +87 -0
- package/dist/cli/commands/doctor.js +365 -0
- package/dist/cli/commands/gateway.js +290 -0
- package/dist/cli/commands/migrate.js +270 -0
- package/dist/cli/commands/plugin.js +97 -0
- package/dist/cli/commands/setup.js +244 -0
- package/dist/cli/config-file.js +133 -0
- package/dist/cli/master-key.js +78 -0
- package/dist/cli/open-browser.js +59 -0
- package/dist/cli/web-assets.js +58 -0
- package/dist/gateway/auth.js +46 -0
- package/dist/gateway/config-format.js +202 -0
- package/dist/gateway/config.js +427 -0
- package/dist/gateway/context.js +1 -0
- package/dist/gateway/env-file.js +129 -0
- package/dist/gateway/events.js +172 -0
- package/dist/gateway/guard/tagging.js +505 -0
- package/dist/gateway/handlers/index.js +66 -0
- package/dist/gateway/handlers/memory.js +54 -0
- package/dist/gateway/handlers/providers.js +73 -0
- package/dist/gateway/handlers/registry.js +39 -0
- package/dist/gateway/handlers/sessions.js +188 -0
- package/dist/gateway/handlers/system.js +12 -0
- package/dist/gateway/handlers/tasks.js +191 -0
- package/dist/gateway/handlers/turn.js +100 -0
- package/dist/gateway/index.js +126 -0
- package/dist/gateway/main.js +23 -0
- package/dist/gateway/server.js +354 -0
- package/dist/gateway/services/context-limits.js +75 -0
- package/dist/gateway/services/history-normalizer.js +42 -0
- package/dist/gateway/services/image-pipeline.js +56 -0
- package/dist/gateway/services/key-roulette-client.js +43 -0
- package/dist/gateway/services/llm-client.js +593 -0
- package/dist/gateway/services/llm-decoder.js +200 -0
- package/dist/gateway/services/local-fallback.js +135 -0
- package/dist/gateway/services/memory.js +511 -0
- package/dist/gateway/services/persistent-memory.js +196 -0
- package/dist/gateway/services/providers.js +44 -0
- package/dist/gateway/services/tasks.js +237 -0
- package/dist/gateway/services/verification.js +124 -0
- package/dist/gateway/services/vision-payload.js +48 -0
- package/dist/gateway/services.js +257 -0
- package/dist/gateway/session-snapshot.js +19 -0
- package/dist/gateway/sessions.js +701 -0
- package/dist/gateway/static.js +239 -0
- package/dist/gateway/turns/clarify-tool.js +57 -0
- package/dist/gateway/turns/cronjob-tool.js +96 -0
- package/dist/gateway/turns/deferred-tools.js +154 -0
- package/dist/gateway/turns/execute-code-tool.js +84 -0
- package/dist/gateway/turns/file-tool-defs.js +178 -0
- package/dist/gateway/turns/file-tool-ops.js +178 -0
- package/dist/gateway/turns/file-tool-scan.js +182 -0
- package/dist/gateway/turns/file-tool.js +302 -0
- package/dist/gateway/turns/index.js +416 -0
- package/dist/gateway/turns/jev-middleware.js +91 -0
- package/dist/gateway/turns/local-reply.js +156 -0
- package/dist/gateway/turns/mcp-client.js +643 -0
- package/dist/gateway/turns/memory-tool.js +171 -0
- package/dist/gateway/turns/middleware.js +96 -0
- package/dist/gateway/turns/python-core.js +397 -0
- package/dist/gateway/turns/routing/index.js +3 -0
- package/dist/gateway/turns/routing/intent-classifier.js +60 -0
- package/dist/gateway/turns/routing/planner-adapter.js +91 -0
- package/dist/gateway/turns/routing/types.js +1 -0
- package/dist/gateway/turns/runtime-deps.js +228 -0
- package/dist/gateway/turns/self-config-tool.js +277 -0
- package/dist/gateway/turns/service-types.js +11 -0
- package/dist/gateway/turns/service.js +820 -0
- package/dist/gateway/turns/session-adapter.js +158 -0
- package/dist/gateway/turns/session-tool.js +49 -0
- package/dist/gateway/turns/shell-tool.js +190 -0
- package/dist/gateway/turns/skill-tool.js +239 -0
- package/dist/gateway/turns/spillover.js +201 -0
- package/dist/gateway/turns/subagent-tool.js +140 -0
- package/dist/gateway/turns/system-prompt.js +121 -0
- package/dist/gateway/turns/tool-schema.js +90 -0
- package/dist/gateway/turns/turn-utils.js +58 -0
- package/dist/gateway/turns/vision-tool.js +120 -0
- package/dist/gateway/types.js +1 -0
- package/dist/native/win32-x64/boombot-native-host.exe +0 -0
- package/dist/node_modules/@boombot/channels/handlers.d.ts +9 -0
- package/dist/node_modules/@boombot/channels/handlers.js +109 -0
- package/dist/node_modules/@boombot/channels/index.d.ts +12 -0
- package/dist/node_modules/@boombot/channels/index.js +12 -0
- package/dist/node_modules/@boombot/channels/package.json +9 -0
- package/dist/node_modules/@boombot/channels/service.d.ts +62 -0
- package/dist/node_modules/@boombot/channels/service.js +608 -0
- package/dist/node_modules/@boombot/channels/tool.d.ts +10 -0
- package/dist/node_modules/@boombot/channels/tool.js +46 -0
- package/dist/node_modules/@boombot/channels/transports/common/dedup.d.ts +17 -0
- package/dist/node_modules/@boombot/channels/transports/common/dedup.js +42 -0
- package/dist/node_modules/@boombot/channels/transports/common/handoff.d.ts +19 -0
- package/dist/node_modules/@boombot/channels/transports/common/handoff.js +32 -0
- package/dist/node_modules/@boombot/channels/transports/common/index.d.ts +3 -0
- package/dist/node_modules/@boombot/channels/transports/common/index.js +3 -0
- package/dist/node_modules/@boombot/channels/transports/common/types.d.ts +99 -0
- package/dist/node_modules/@boombot/channels/transports/common/types.js +54 -0
- package/dist/node_modules/@boombot/channels/transports/common.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/common.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/dedup/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/dedup/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/dedup.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/dedup.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/discord/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/discord/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/discord/transport.d.ts +36 -0
- package/dist/node_modules/@boombot/channels/transports/discord/transport.js +199 -0
- package/dist/node_modules/@boombot/channels/transports/discord.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/discord.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/handoff.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/handoff.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/transport.d.ts +34 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/transport.js +180 -0
- package/dist/node_modules/@boombot/channels/transports/messenger.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/messenger.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/slack/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/slack/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/slack/transport.d.ts +35 -0
- package/dist/node_modules/@boombot/channels/transports/slack/transport.js +183 -0
- package/dist/node_modules/@boombot/channels/transports/slack.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/slack.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/streamer.d.ts +31 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/streamer.js +141 -0
- package/dist/node_modules/@boombot/channels/transports/streamer.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/streamer.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/transport.d.ts +75 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/transport.js +395 -0
- package/dist/node_modules/@boombot/channels/transports/telegram.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/telegram.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/transport.d.ts +27 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/transport.js +97 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/transport.d.ts +38 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/transport.js +189 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/index.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/index.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/oa.d.ts +28 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/oa.js +94 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/personal.d.ts +106 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/personal.js +171 -0
- package/dist/node_modules/@boombot/channels/transports/zalo-personal.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo-personal.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo.js +2 -0
- package/dist/node_modules/@boombot/core/agent-core/index.d.ts +12 -0
- package/dist/node_modules/@boombot/core/agent-core/index.js +12 -0
- package/dist/node_modules/@boombot/core/agent-core/middleware.d.ts +60 -0
- package/dist/node_modules/@boombot/core/agent-core/middleware.js +152 -0
- package/dist/node_modules/@boombot/core/agent-core/routing.d.ts +128 -0
- package/dist/node_modules/@boombot/core/agent-core/routing.js +437 -0
- package/dist/node_modules/@boombot/core/agent-core/runtime-deps.d.ts +88 -0
- package/dist/node_modules/@boombot/core/agent-core/runtime-deps.js +8 -0
- package/dist/node_modules/@boombot/core/agent-core/tool-errors.d.ts +44 -0
- package/dist/node_modules/@boombot/core/agent-core/tool-errors.js +60 -0
- package/dist/node_modules/@boombot/core/agent-core/turn-loop.d.ts +21 -0
- package/dist/node_modules/@boombot/core/agent-core/turn-loop.js +561 -0
- package/dist/node_modules/@boombot/core/agent-core/types.d.ts +189 -0
- package/dist/node_modules/@boombot/core/agent-core/types.js +7 -0
- package/dist/node_modules/@boombot/core/compaction/compactor.d.ts +19 -0
- package/dist/node_modules/@boombot/core/compaction/compactor.js +127 -0
- package/dist/node_modules/@boombot/core/compaction/estimator.d.ts +10 -0
- package/dist/node_modules/@boombot/core/compaction/estimator.js +48 -0
- package/dist/node_modules/@boombot/core/compaction/index.d.ts +3 -0
- package/dist/node_modules/@boombot/core/compaction/index.js +3 -0
- package/dist/node_modules/@boombot/core/compaction/types.d.ts +31 -0
- package/dist/node_modules/@boombot/core/compaction/types.js +7 -0
- package/dist/node_modules/@boombot/core/index.d.ts +9 -0
- package/dist/node_modules/@boombot/core/index.js +9 -0
- package/dist/node_modules/@boombot/core/jev/index.d.ts +2 -0
- package/dist/node_modules/@boombot/core/jev/index.js +2 -0
- package/dist/node_modules/@boombot/core/jev/jev.d.ts +30 -0
- package/dist/node_modules/@boombot/core/jev/jev.js +164 -0
- package/dist/node_modules/@boombot/core/jev/types.d.ts +22 -0
- package/dist/node_modules/@boombot/core/jev/types.js +1 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/budget.d.ts +63 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/budget.js +94 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/consolidator.d.ts +152 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/consolidator.js +318 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/index.d.ts +12 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/index.js +12 -0
- package/dist/node_modules/@boombot/core/memory/curation.d.ts +86 -0
- package/dist/node_modules/@boombot/core/memory/curation.js +120 -0
- package/dist/node_modules/@boombot/core/memory/errors.d.ts +12 -0
- package/dist/node_modules/@boombot/core/memory/errors.js +20 -0
- package/dist/node_modules/@boombot/core/memory/hybrid-search.d.ts +29 -0
- package/dist/node_modules/@boombot/core/memory/hybrid-search.js +52 -0
- package/dist/node_modules/@boombot/core/memory/index.d.ts +23 -0
- package/dist/node_modules/@boombot/core/memory/index.js +23 -0
- package/dist/node_modules/@boombot/core/memory/indexer.d.ts +47 -0
- package/dist/node_modules/@boombot/core/memory/indexer.js +138 -0
- package/dist/node_modules/@boombot/core/memory/lifecycle.d.ts +12 -0
- package/dist/node_modules/@boombot/core/memory/lifecycle.js +66 -0
- package/dist/node_modules/@boombot/core/memory/provider.d.ts +84 -0
- package/dist/node_modules/@boombot/core/memory/provider.js +117 -0
- package/dist/node_modules/@boombot/core/memory/recall.d.ts +7 -0
- package/dist/node_modules/@boombot/core/memory/recall.js +111 -0
- package/dist/node_modules/@boombot/core/memory/scope-resolver.d.ts +27 -0
- package/dist/node_modules/@boombot/core/memory/scope-resolver.js +60 -0
- package/dist/node_modules/@boombot/core/memory/search.d.ts +37 -0
- package/dist/node_modules/@boombot/core/memory/search.js +158 -0
- package/dist/node_modules/@boombot/core/memory/store.d.ts +60 -0
- package/dist/node_modules/@boombot/core/memory/store.js +289 -0
- package/dist/node_modules/@boombot/core/memory/types.d.ts +121 -0
- package/dist/node_modules/@boombot/core/memory/types.js +21 -0
- package/dist/node_modules/@boombot/core/memory/vector-index.d.ts +34 -0
- package/dist/node_modules/@boombot/core/memory/vector-index.js +65 -0
- package/dist/node_modules/@boombot/core/package.json +9 -0
- package/dist/node_modules/@boombot/core/reflection/classifier.d.ts +13 -0
- package/dist/node_modules/@boombot/core/reflection/classifier.js +77 -0
- package/dist/node_modules/@boombot/core/reflection/index.d.ts +2 -0
- package/dist/node_modules/@boombot/core/reflection/index.js +2 -0
- package/dist/node_modules/@boombot/core/reflection/types.d.ts +13 -0
- package/dist/node_modules/@boombot/core/reflection/types.js +4 -0
- package/dist/node_modules/@boombot/core/research/config.d.ts +89 -0
- package/dist/node_modules/@boombot/core/research/config.js +206 -0
- package/dist/node_modules/@boombot/core/research/crawl.d.ts +36 -0
- package/dist/node_modules/@boombot/core/research/crawl.js +179 -0
- package/dist/node_modules/@boombot/core/research/factory.d.ts +26 -0
- package/dist/node_modules/@boombot/core/research/factory.js +46 -0
- package/dist/node_modules/@boombot/core/research/http.d.ts +87 -0
- package/dist/node_modules/@boombot/core/research/http.js +250 -0
- package/dist/node_modules/@boombot/core/research/index.d.ts +17 -0
- package/dist/node_modules/@boombot/core/research/index.js +10 -0
- package/dist/node_modules/@boombot/core/research/orchestrator.d.ts +113 -0
- package/dist/node_modules/@boombot/core/research/orchestrator.js +252 -0
- package/dist/node_modules/@boombot/core/research/parse/docx.d.ts +24 -0
- package/dist/node_modules/@boombot/core/research/parse/docx.js +183 -0
- package/dist/node_modules/@boombot/core/research/parse/guards.d.ts +89 -0
- package/dist/node_modules/@boombot/core/research/parse/guards.js +171 -0
- package/dist/node_modules/@boombot/core/research/parse/index.d.ts +68 -0
- package/dist/node_modules/@boombot/core/research/parse/index.js +219 -0
- package/dist/node_modules/@boombot/core/research/parse/pdf.d.ts +38 -0
- package/dist/node_modules/@boombot/core/research/parse/pdf.js +567 -0
- package/dist/node_modules/@boombot/core/research/providers/arxiv.d.ts +9 -0
- package/dist/node_modules/@boombot/core/research/providers/arxiv.js +72 -0
- package/dist/node_modules/@boombot/core/research/providers/brave.d.ts +11 -0
- package/dist/node_modules/@boombot/core/research/providers/brave.js +36 -0
- package/dist/node_modules/@boombot/core/research/providers/duckduckgo.d.ts +9 -0
- package/dist/node_modules/@boombot/core/research/providers/duckduckgo.js +78 -0
- package/dist/node_modules/@boombot/core/research/providers/exa.d.ts +11 -0
- package/dist/node_modules/@boombot/core/research/providers/exa.js +34 -0
- package/dist/node_modules/@boombot/core/research/providers/firecrawl.d.ts +16 -0
- package/dist/node_modules/@boombot/core/research/providers/firecrawl.js +47 -0
- package/dist/node_modules/@boombot/core/research/providers/index.d.ts +17 -0
- package/dist/node_modules/@boombot/core/research/providers/index.js +11 -0
- package/dist/node_modules/@boombot/core/research/providers/jina.d.ts +13 -0
- package/dist/node_modules/@boombot/core/research/providers/jina.js +114 -0
- package/dist/node_modules/@boombot/core/research/providers/openalex.d.ts +14 -0
- package/dist/node_modules/@boombot/core/research/providers/openalex.js +66 -0
- package/dist/node_modules/@boombot/core/research/providers/semantic-scholar.d.ts +9 -0
- package/dist/node_modules/@boombot/core/research/providers/semantic-scholar.js +56 -0
- package/dist/node_modules/@boombot/core/research/providers/tavily.d.ts +11 -0
- package/dist/node_modules/@boombot/core/research/providers/tavily.js +35 -0
- package/dist/node_modules/@boombot/core/research/providers/wikipedia.d.ts +12 -0
- package/dist/node_modules/@boombot/core/research/providers/wikipedia.js +47 -0
- package/dist/node_modules/@boombot/core/research/tools.d.ts +27 -0
- package/dist/node_modules/@boombot/core/research/tools.js +251 -0
- package/dist/node_modules/@boombot/core/research/types.d.ts +133 -0
- package/dist/node_modules/@boombot/core/research/types.js +8 -0
- package/dist/node_modules/@boombot/core/research/wiring.d.ts +25 -0
- package/dist/node_modules/@boombot/core/research/wiring.js +51 -0
- package/dist/node_modules/@boombot/core/scheduler/cron.d.ts +34 -0
- package/dist/node_modules/@boombot/core/scheduler/cron.js +147 -0
- package/dist/node_modules/@boombot/core/scheduler/evaluator.d.ts +42 -0
- package/dist/node_modules/@boombot/core/scheduler/evaluator.js +148 -0
- package/dist/node_modules/@boombot/core/scheduler/index.d.ts +15 -0
- package/dist/node_modules/@boombot/core/scheduler/index.js +15 -0
- package/dist/node_modules/@boombot/core/scheduler/registry.d.ts +81 -0
- package/dist/node_modules/@boombot/core/scheduler/registry.js +263 -0
- package/dist/node_modules/@boombot/core/scheduler/runner.d.ts +59 -0
- package/dist/node_modules/@boombot/core/scheduler/runner.js +257 -0
- package/dist/node_modules/@boombot/core/scheduler/store.d.ts +150 -0
- package/dist/node_modules/@boombot/core/scheduler/store.js +526 -0
- package/dist/node_modules/@boombot/core/scheduler/timezone.d.ts +35 -0
- package/dist/node_modules/@boombot/core/scheduler/timezone.js +96 -0
- package/dist/node_modules/@boombot/core/scheduler/types.d.ts +157 -0
- package/dist/node_modules/@boombot/core/scheduler/types.js +89 -0
- package/dist/node_modules/@boombot/core/task-runner/index.d.ts +7 -0
- package/dist/node_modules/@boombot/core/task-runner/index.js +5 -0
- package/dist/node_modules/@boombot/core/task-runner/planner.d.ts +37 -0
- package/dist/node_modules/@boombot/core/task-runner/planner.js +154 -0
- package/dist/node_modules/@boombot/core/task-runner/runner.d.ts +8 -0
- package/dist/node_modules/@boombot/core/task-runner/runner.js +564 -0
- package/dist/node_modules/@boombot/core/task-runner/store.d.ts +28 -0
- package/dist/node_modules/@boombot/core/task-runner/store.js +126 -0
- package/dist/node_modules/@boombot/core/task-runner/types.d.ts +138 -0
- package/dist/node_modules/@boombot/core/task-runner/types.js +11 -0
- package/dist/node_modules/@boombot/core/workflow/dag.d.ts +16 -0
- package/dist/node_modules/@boombot/core/workflow/dag.js +109 -0
- package/dist/node_modules/@boombot/core/workflow/engine.d.ts +34 -0
- package/dist/node_modules/@boombot/core/workflow/engine.js +304 -0
- package/dist/node_modules/@boombot/core/workflow/index.d.ts +3 -0
- package/dist/node_modules/@boombot/core/workflow/index.js +3 -0
- package/dist/node_modules/@boombot/core/workflow/types.d.ts +98 -0
- package/dist/node_modules/@boombot/core/workflow/types.js +21 -0
- package/dist/node_modules/@boombot/cronjobs/handlers.d.ts +11 -0
- package/dist/node_modules/@boombot/cronjobs/handlers.js +174 -0
- package/dist/node_modules/@boombot/cronjobs/index.d.ts +2 -0
- package/dist/node_modules/@boombot/cronjobs/index.js +2 -0
- package/dist/node_modules/@boombot/cronjobs/package.json +9 -0
- package/dist/node_modules/@boombot/cronjobs/service.d.ts +53 -0
- package/dist/node_modules/@boombot/cronjobs/service.js +200 -0
- package/dist/node_modules/@boombot/plugins/index.d.ts +2 -0
- package/dist/node_modules/@boombot/plugins/index.js +2 -0
- package/dist/node_modules/@boombot/plugins/installer.d.ts +45 -0
- package/dist/node_modules/@boombot/plugins/installer.js +487 -0
- package/dist/node_modules/@boombot/plugins/manager.d.ts +23 -0
- package/dist/node_modules/@boombot/plugins/manager.js +243 -0
- package/dist/node_modules/@boombot/plugins/package.json +9 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-channels.d.ts +125 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-channels.js +76 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-plugins.d.ts +220 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-plugins.js +60 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-scheduler.d.ts +33 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-scheduler.js +25 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands.d.ts +4349 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands.js +563 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/envelope.d.ts +32 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/envelope.js +61 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/errors.d.ts +13 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/errors.js +16 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/events.d.ts +567 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/events.js +395 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/index.d.ts +20 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/index.js +13 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/types.d.ts +91 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/types.js +7 -0
- package/dist/node_modules/@boombot/protocol/index.d.ts +4 -0
- package/dist/node_modules/@boombot/protocol/index.js +3 -0
- package/dist/node_modules/@boombot/protocol/package.json +9 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/channel.d.ts +41 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/channel.js +17 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/index.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/index.js +10 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/manifest.d.ts +58 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/manifest.js +116 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/plugin.d.ts +25 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/plugin.js +1 -0
- package/dist/node_modules/@boombot/protocol/providers/cipher.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/cipher.js +52 -0
- package/dist/node_modules/@boombot/protocol/providers/index.d.ts +19 -0
- package/dist/node_modules/@boombot/protocol/providers/index.js +19 -0
- package/dist/node_modules/@boombot/protocol/providers/key-roulette.d.ts +79 -0
- package/dist/node_modules/@boombot/protocol/providers/key-roulette.js +81 -0
- package/dist/node_modules/@boombot/protocol/providers/probe.d.ts +29 -0
- package/dist/node_modules/@boombot/protocol/providers/probe.js +96 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/anthropic.d.ts +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/anthropic.js +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/custom.d.ts +22 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/custom.js +222 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/deepseek.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/deepseek.js +9 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/google.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/google.js +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/index.d.ts +31 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/index.js +56 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/local.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/local.js +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/mistral.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/mistral.js +9 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai-compatible.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai-compatible.js +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai.js +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/types.d.ts +58 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/types.js +1 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/xai.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/xai.js +10 -0
- package/dist/node_modules/@boombot/protocol/providers/request-profile.d.ts +102 -0
- package/dist/node_modules/@boombot/protocol/providers/request-profile.js +118 -0
- package/dist/node_modules/@boombot/protocol/providers/service.d.ts +2 -0
- package/dist/node_modules/@boombot/protocol/providers/service.js +418 -0
- package/dist/node_modules/@boombot/protocol/providers/types.d.ts +141 -0
- package/dist/node_modules/@boombot/protocol/providers/types.js +16 -0
- package/dist/node_modules/@boombot/sandbox/fs-path.d.ts +13 -0
- package/dist/node_modules/@boombot/sandbox/fs-path.js +79 -0
- package/dist/node_modules/@boombot/sandbox/index.d.ts +13 -0
- package/dist/node_modules/@boombot/sandbox/index.js +13 -0
- package/dist/node_modules/@boombot/sandbox/native.d.ts +39 -0
- package/dist/node_modules/@boombot/sandbox/native.js +224 -0
- package/dist/node_modules/@boombot/sandbox/package.json +9 -0
- package/dist/node_modules/@boombot/sandbox/sandbox.d.ts +92 -0
- package/dist/node_modules/@boombot/sandbox/sandbox.js +229 -0
- package/dist/node_modules/@boombot/security/harness-guard/boundary.d.ts +22 -0
- package/dist/node_modules/@boombot/security/harness-guard/boundary.js +105 -0
- package/dist/node_modules/@boombot/security/harness-guard/gates.d.ts +90 -0
- package/dist/node_modules/@boombot/security/harness-guard/gates.js +791 -0
- package/dist/node_modules/@boombot/security/harness-guard/index.d.ts +23 -0
- package/dist/node_modules/@boombot/security/harness-guard/index.js +23 -0
- package/dist/node_modules/@boombot/security/harness-guard/policy.d.ts +20 -0
- package/dist/node_modules/@boombot/security/harness-guard/policy.js +70 -0
- package/dist/node_modules/@boombot/security/harness-guard/sanitizer.d.ts +53 -0
- package/dist/node_modules/@boombot/security/harness-guard/sanitizer.js +145 -0
- package/dist/node_modules/@boombot/security/harness-guard/types.d.ts +71 -0
- package/dist/node_modules/@boombot/security/harness-guard/types.js +10 -0
- package/dist/node_modules/@boombot/security/harness-guard/verifier.d.ts +59 -0
- package/dist/node_modules/@boombot/security/harness-guard/verifier.js +169 -0
- package/dist/node_modules/@boombot/security/index.d.ts +5 -0
- package/dist/node_modules/@boombot/security/index.js +9 -0
- package/dist/node_modules/@boombot/security/package.json +9 -0
- package/dist/node_modules/@boombot/security/policy/approval.d.ts +117 -0
- package/dist/node_modules/@boombot/security/policy/approval.js +223 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/claim-extractor.d.ts +10 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/claim-extractor.js +124 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/evidence-ledger.d.ts +25 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/evidence-ledger.js +70 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/gate.d.ts +38 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/gate.js +61 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/grounding-check.d.ts +12 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/grounding-check.js +234 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/index.d.ts +17 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/index.js +13 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/policy.d.ts +15 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/policy.js +39 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/types.d.ts +46 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/types.js +7 -0
- package/dist/node_modules/@boombot/security/security/approval.d.ts +63 -0
- package/dist/node_modules/@boombot/security/security/approval.js +140 -0
- package/dist/node_modules/@boombot/security/security/audit.d.ts +39 -0
- package/dist/node_modules/@boombot/security/security/audit.js +70 -0
- package/dist/node_modules/@boombot/security/security/index.d.ts +12 -0
- package/dist/node_modules/@boombot/security/security/index.js +12 -0
- package/dist/node_modules/@boombot/security/security/trust.d.ts +79 -0
- package/dist/node_modules/@boombot/security/security/trust.js +87 -0
- package/dist/package.json +5 -0
- package/dist/proto/agent_core.proto +56 -0
- package/dist/python/agent-core-python/pyproject.toml +40 -0
- package/dist/python/agent-core-python/src/boombot_agent/__init__.py +5 -0
- package/dist/python/agent-core-python/src/boombot_agent/generated/__init__.py +0 -0
- package/dist/python/agent-core-python/src/boombot_agent/generated/agent_core_pb2.py +54 -0
- package/dist/python/agent-core-python/src/boombot_agent/generated/agent_core_pb2_grpc.py +140 -0
- package/dist/python/agent-core-python/src/boombot_agent/rpc.py +265 -0
- package/dist/python/agent-core-python/src/boombot_agent/turn.py +577 -0
- package/dist/python/agent-core-python/src/boombot_ml/__init__.py +12 -0
- package/dist/python/agent-core-python/src/boombot_ml/embeddings.py +58 -0
- package/dist/python/agent-core-python/src/boombot_ml/training.py +156 -0
- package/dist/python/agent-core-python/uv.lock +2856 -0
- package/dist/web/assets/ChatView-BZrSD-64.js +262 -0
- package/dist/web/assets/ChatView-Cahbjez6.css +1 -0
- package/dist/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/web/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/web/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/web/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/web/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/web/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/web/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/web/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/web/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/web/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/web/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/web/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/web/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/web/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/web/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/web/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/web/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/web/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/web/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/web/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/web/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/web/assets/MemoryView-BJbXqqs7.css +1 -0
- package/dist/web/assets/MemoryView-BfMq_6CD.js +1 -0
- package/dist/web/assets/SchedulesView-B22QmPR-.js +1 -0
- package/dist/web/assets/SchedulesView-C6XK7A8a.css +1 -0
- package/dist/web/assets/SessionsView-C1dqdhxI.css +1 -0
- package/dist/web/assets/SessionsView-DS0-aH2a.js +1 -0
- package/dist/web/assets/TasksView-Dtasg4hd.css +1 -0
- package/dist/web/assets/TasksView-ey0FLsW8.js +2 -0
- package/dist/web/assets/Textarea-DN3Zybl1.js +1 -0
- package/dist/web/assets/Tooltip-Bn2cqFPz.css +1 -0
- package/dist/web/assets/Tooltip-MzV2Gqnc.js +1 -0
- package/dist/web/assets/browser-Bnt73-Ub.js +8 -0
- package/dist/web/assets/index-BL8bi7Yt.css +1 -0
- package/dist/web/assets/index-CuPR73Tn.js +73 -0
- package/dist/web/favicon.svg +4 -0
- package/dist/web/index.html +26 -0
- package/dist/web/logo.jpg +0 -0
- package/dist/web/logo.png +0 -0
- package/package.json +51 -4
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { MessageDeduplicator, } from '../common/index.js';
|
|
3
|
+
const GRAPH_API_BASE = 'https://graph.facebook.com/v19.0';
|
|
4
|
+
export class MessengerTransport {
|
|
5
|
+
kind = 'messenger';
|
|
6
|
+
displayName = 'Messenger';
|
|
7
|
+
enabled;
|
|
8
|
+
pageAccessToken;
|
|
9
|
+
appSecret;
|
|
10
|
+
verifyToken;
|
|
11
|
+
allowlist;
|
|
12
|
+
deduplicator = new MessageDeduplicator();
|
|
13
|
+
pendingReplies = new Map();
|
|
14
|
+
log;
|
|
15
|
+
status = 'disconnected';
|
|
16
|
+
statusDetail = 'NOT_CONFIGURED';
|
|
17
|
+
turnService;
|
|
18
|
+
unsubscribeTurnDone;
|
|
19
|
+
constructor(config, log) {
|
|
20
|
+
this.enabled = config.enabled !== false;
|
|
21
|
+
this.pageAccessToken = config.pageAccessToken?.trim() || undefined;
|
|
22
|
+
this.appSecret = config.appSecret?.trim() || undefined;
|
|
23
|
+
this.verifyToken = config.verifyToken?.trim() || undefined;
|
|
24
|
+
this.allowlist = new Set((config.allowlistChatIds ?? []).map((id) => id.trim()).filter(Boolean));
|
|
25
|
+
this.turnService = config.turnService;
|
|
26
|
+
this.log = log;
|
|
27
|
+
if (config.subscribeTurnDone) {
|
|
28
|
+
this.unsubscribeTurnDone = config.subscribeTurnDone((payload) => {
|
|
29
|
+
const recipientId = this.pendingReplies.get(payload.turnId);
|
|
30
|
+
if (recipientId === undefined || payload.output === undefined)
|
|
31
|
+
return;
|
|
32
|
+
this.pendingReplies.delete(payload.turnId);
|
|
33
|
+
void this.send(recipientId, payload.output).catch((error) => {
|
|
34
|
+
this.log.error('messenger: failed to send turn reply', {
|
|
35
|
+
recipientId,
|
|
36
|
+
error: error instanceof Error ? error.message : String(error),
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async start() {
|
|
43
|
+
if (!this.enabled) {
|
|
44
|
+
this.statusDetail = 'DISABLED';
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (this.pageAccessToken === undefined) {
|
|
48
|
+
this.statusDetail = 'NOT_CONFIGURED';
|
|
49
|
+
this.log.info('messenger: missing pageAccessToken');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const response = await fetch(`${GRAPH_API_BASE}/me`, {
|
|
54
|
+
headers: { authorization: `Bearer ${this.pageAccessToken}` },
|
|
55
|
+
signal: AbortSignal.timeout(15_000),
|
|
56
|
+
});
|
|
57
|
+
if (!response.ok)
|
|
58
|
+
throw new Error(`HTTP ${response.status}`);
|
|
59
|
+
this.status = 'connected';
|
|
60
|
+
this.statusDetail = undefined;
|
|
61
|
+
this.log.info('messenger: connected (outbound only)');
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
this.status = 'error';
|
|
65
|
+
this.statusDetail =
|
|
66
|
+
error instanceof Error ? error.message : 'CONNECT_FAILED';
|
|
67
|
+
this.log.error('messenger: credential check failed', {
|
|
68
|
+
detail: this.statusDetail,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async stop() {
|
|
73
|
+
this.unsubscribeTurnDone?.();
|
|
74
|
+
this.unsubscribeTurnDone = undefined;
|
|
75
|
+
this.pendingReplies.clear();
|
|
76
|
+
if (this.status === 'connected') {
|
|
77
|
+
this.status = 'disconnected';
|
|
78
|
+
this.statusDetail = 'STOPPED';
|
|
79
|
+
}
|
|
80
|
+
this.log.info('messenger: stopped');
|
|
81
|
+
}
|
|
82
|
+
async handleWebhook(request) {
|
|
83
|
+
if (!this.enabled)
|
|
84
|
+
return { status: 503 };
|
|
85
|
+
if (request.method === 'GET') {
|
|
86
|
+
const valid = request.query.get('hub.mode') === 'subscribe' &&
|
|
87
|
+
this.verifyToken !== undefined &&
|
|
88
|
+
request.query.get('hub.verify_token') === this.verifyToken;
|
|
89
|
+
return valid
|
|
90
|
+
? { status: 200, contentType: 'text/plain; charset=utf-8', body: request.query.get('hub.challenge') ?? '' }
|
|
91
|
+
: { status: 401 };
|
|
92
|
+
}
|
|
93
|
+
if (this.appSecret !== undefined) {
|
|
94
|
+
const signatureValue = request.headers['x-hub-signature-256'];
|
|
95
|
+
const signature = typeof signatureValue === 'string' ? signatureValue : (signatureValue?.[0] ?? '');
|
|
96
|
+
const expected = `sha256=${createHmac('sha256', this.appSecret).update(request.rawBody).digest('hex')}`;
|
|
97
|
+
const actualBytes = Buffer.from(signature);
|
|
98
|
+
const expectedBytes = Buffer.from(expected);
|
|
99
|
+
if (actualBytes.length !== expectedBytes.length || !timingSafeEqual(actualBytes, expectedBytes)) {
|
|
100
|
+
return { status: 401 };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
let payload;
|
|
104
|
+
try {
|
|
105
|
+
payload = JSON.parse(request.rawBody.toString('utf8'));
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return { status: 400 };
|
|
109
|
+
}
|
|
110
|
+
if (!Array.isArray(payload.entry)) {
|
|
111
|
+
return { status: 200, body: 'EVENT_RECEIVED' };
|
|
112
|
+
}
|
|
113
|
+
for (const entry of payload.entry) {
|
|
114
|
+
if (!Array.isArray(entry.messaging))
|
|
115
|
+
continue;
|
|
116
|
+
for (const msg of entry.messaging) {
|
|
117
|
+
if (msg.message?.is_echo)
|
|
118
|
+
continue;
|
|
119
|
+
const senderId = msg.sender?.id;
|
|
120
|
+
const text = msg.message?.text?.trim();
|
|
121
|
+
const mid = msg.message?.mid;
|
|
122
|
+
if (!senderId || !text || !mid)
|
|
123
|
+
continue;
|
|
124
|
+
if (this.allowlist.size > 0 && !this.allowlist.has(senderId)) {
|
|
125
|
+
this.log.info('messenger: dropped message from sender outside allowlist', { senderId });
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (!this.deduplicator.checkAndRecord(mid))
|
|
129
|
+
continue;
|
|
130
|
+
if (this.turnService === undefined) {
|
|
131
|
+
this.log.error('messenger: turnService not set, cannot process message');
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const result = await this.turnService.submit({
|
|
136
|
+
input: text,
|
|
137
|
+
channel: 'messenger',
|
|
138
|
+
replyTo: senderId,
|
|
139
|
+
});
|
|
140
|
+
this.pendingReplies.set(result.turnId, senderId);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
this.log.error('messenger: turn submit failed', {
|
|
144
|
+
error: error instanceof Error ? error.message : String(error),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { status: 200, body: 'EVENT_RECEIVED' };
|
|
150
|
+
}
|
|
151
|
+
async send(target, text) {
|
|
152
|
+
if (!this.enabled)
|
|
153
|
+
throw new Error('DISABLED: messenger is disabled');
|
|
154
|
+
if (this.pageAccessToken === undefined) {
|
|
155
|
+
throw new Error('NOT_CONFIGURED: messenger missing pageAccessToken');
|
|
156
|
+
}
|
|
157
|
+
const recipient = target.trim();
|
|
158
|
+
if (recipient === '' || text.trim() === '') {
|
|
159
|
+
throw new Error('INVALID_ARGUMENT: target/text must not be empty');
|
|
160
|
+
}
|
|
161
|
+
const response = await fetch(`${GRAPH_API_BASE}/me/messages`, {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers: {
|
|
164
|
+
authorization: `Bearer ${this.pageAccessToken}`,
|
|
165
|
+
'content-type': 'application/json',
|
|
166
|
+
},
|
|
167
|
+
body: JSON.stringify({ recipient: { id: recipient }, message: { text } }),
|
|
168
|
+
signal: AbortSignal.timeout(15_000),
|
|
169
|
+
});
|
|
170
|
+
const data = (await response.json().catch(() => undefined));
|
|
171
|
+
if (!response.ok || data?.error !== undefined) {
|
|
172
|
+
throw new Error(`SEND_FAILED: ${data?.error?.message ?? `HTTP ${response.status}`}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
getStatus() {
|
|
176
|
+
return this.statusDetail === undefined
|
|
177
|
+
? { status: this.status }
|
|
178
|
+
: { status: this.status, detail: this.statusDetail };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './transport.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './transport.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ChannelKind } from '@boombot/protocol';
|
|
2
|
+
import { type ChannelLogger, type ChannelRuntimeStatus, type ChannelTransport, type ChannelWebhookRequest, type ChannelWebhookResponse, type InboundTransportOptions } from '../common/index.js';
|
|
3
|
+
export interface SlackTransportConfig {
|
|
4
|
+
readonly enabled?: boolean;
|
|
5
|
+
readonly botToken?: string;
|
|
6
|
+
readonly signingSecret?: string;
|
|
7
|
+
readonly allowlistChatIds?: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class SlackTransport implements ChannelTransport {
|
|
10
|
+
readonly kind: ChannelKind;
|
|
11
|
+
readonly displayName = "Slack";
|
|
12
|
+
private readonly enabled;
|
|
13
|
+
private readonly botToken;
|
|
14
|
+
private readonly signingSecret;
|
|
15
|
+
private readonly allowlist;
|
|
16
|
+
private readonly log;
|
|
17
|
+
private readonly turnService;
|
|
18
|
+
private readonly subscribeTurnDone;
|
|
19
|
+
private readonly pendingReplies;
|
|
20
|
+
private readonly deduplicator;
|
|
21
|
+
private unsubscribeTurnDone;
|
|
22
|
+
private status;
|
|
23
|
+
private statusDetail;
|
|
24
|
+
constructor(config: SlackTransportConfig, log: ChannelLogger, inbound?: InboundTransportOptions);
|
|
25
|
+
start(): Promise<void>;
|
|
26
|
+
stop(): Promise<void>;
|
|
27
|
+
getStatus(): {
|
|
28
|
+
status: ChannelRuntimeStatus;
|
|
29
|
+
detail?: string;
|
|
30
|
+
};
|
|
31
|
+
handleWebhook(request: ChannelWebhookRequest): Promise<ChannelWebhookResponse>;
|
|
32
|
+
send(target: string, text: string): Promise<void>;
|
|
33
|
+
private onTurnDone;
|
|
34
|
+
private callApi;
|
|
35
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import {} from '../common/index.js';
|
|
3
|
+
import { MessageDeduplicator } from '../common/index.js';
|
|
4
|
+
const SLACK_API_BASE = 'https://slack.com/api';
|
|
5
|
+
const MAX_TEXT_LENGTH = 4000;
|
|
6
|
+
const SIGNATURE_AGE_SECONDS = 300;
|
|
7
|
+
function header(request, name) {
|
|
8
|
+
const value = request.headers[name] ?? request.headers[name.toLowerCase()];
|
|
9
|
+
return typeof value === 'string' ? value : (value?.[0] ?? '');
|
|
10
|
+
}
|
|
11
|
+
export class SlackTransport {
|
|
12
|
+
kind = 'slack';
|
|
13
|
+
displayName = 'Slack';
|
|
14
|
+
enabled;
|
|
15
|
+
botToken;
|
|
16
|
+
signingSecret;
|
|
17
|
+
allowlist;
|
|
18
|
+
log;
|
|
19
|
+
turnService;
|
|
20
|
+
subscribeTurnDone;
|
|
21
|
+
pendingReplies = new Map();
|
|
22
|
+
deduplicator = new MessageDeduplicator();
|
|
23
|
+
unsubscribeTurnDone;
|
|
24
|
+
status = 'disconnected';
|
|
25
|
+
statusDetail = 'NOT_CONFIGURED';
|
|
26
|
+
constructor(config, log, inbound = {}) {
|
|
27
|
+
this.enabled = config.enabled !== false;
|
|
28
|
+
this.botToken = config.botToken?.trim() || undefined;
|
|
29
|
+
this.signingSecret = config.signingSecret?.trim() || undefined;
|
|
30
|
+
this.allowlist = new Set(config.allowlistChatIds ?? []);
|
|
31
|
+
this.log = log;
|
|
32
|
+
this.turnService = inbound.turnService;
|
|
33
|
+
this.subscribeTurnDone = inbound.subscribeTurnDone;
|
|
34
|
+
}
|
|
35
|
+
async start() {
|
|
36
|
+
if (!this.enabled) {
|
|
37
|
+
this.statusDetail = 'DISABLED';
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.unsubscribeTurnDone ??= this.subscribeTurnDone?.((payload) => this.onTurnDone(payload));
|
|
41
|
+
if (this.botToken === undefined) {
|
|
42
|
+
this.statusDetail = 'NOT_CONFIGURED';
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const data = await this.callApi('auth.test', {});
|
|
47
|
+
if (!data.ok)
|
|
48
|
+
throw new Error(data.error ?? 'auth.test failed');
|
|
49
|
+
this.status = 'connected';
|
|
50
|
+
this.statusDetail = undefined;
|
|
51
|
+
this.log.info('slack: connected');
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this.status = 'error';
|
|
55
|
+
this.statusDetail = error instanceof Error ? error.message : 'CONNECT_FAILED';
|
|
56
|
+
this.log.error('slack: credential check failed', { detail: this.statusDetail });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async stop() {
|
|
60
|
+
this.unsubscribeTurnDone?.();
|
|
61
|
+
this.unsubscribeTurnDone = undefined;
|
|
62
|
+
this.pendingReplies.clear();
|
|
63
|
+
if (this.status === 'connected') {
|
|
64
|
+
this.status = 'disconnected';
|
|
65
|
+
this.statusDetail = 'STOPPED';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
getStatus() {
|
|
69
|
+
return this.statusDetail === undefined
|
|
70
|
+
? { status: this.status }
|
|
71
|
+
: { status: this.status, detail: this.statusDetail };
|
|
72
|
+
}
|
|
73
|
+
async handleWebhook(request) {
|
|
74
|
+
if (request.method !== 'POST')
|
|
75
|
+
return { status: 405 };
|
|
76
|
+
if (!this.enabled || this.signingSecret === undefined || this.botToken === undefined)
|
|
77
|
+
return { status: 503 };
|
|
78
|
+
const timestamp = header(request, 'x-slack-request-timestamp');
|
|
79
|
+
const signature = header(request, 'x-slack-signature');
|
|
80
|
+
const seconds = Number(timestamp);
|
|
81
|
+
if (!Number.isFinite(seconds) || Math.abs(Date.now() / 1000 - seconds) > SIGNATURE_AGE_SECONDS) {
|
|
82
|
+
return { status: 401 };
|
|
83
|
+
}
|
|
84
|
+
const expected = `v0=${createHmac('sha256', this.signingSecret)
|
|
85
|
+
.update(`v0:${timestamp}:`)
|
|
86
|
+
.update(request.rawBody)
|
|
87
|
+
.digest('hex')}`;
|
|
88
|
+
const actualBytes = Buffer.from(signature);
|
|
89
|
+
const expectedBytes = Buffer.from(expected);
|
|
90
|
+
if (actualBytes.length !== expectedBytes.length || !timingSafeEqual(actualBytes, expectedBytes)) {
|
|
91
|
+
return { status: 401 };
|
|
92
|
+
}
|
|
93
|
+
let parsed;
|
|
94
|
+
try {
|
|
95
|
+
parsed = JSON.parse(request.rawBody.toString('utf8'));
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return { status: 400 };
|
|
99
|
+
}
|
|
100
|
+
if (!isRecord(parsed))
|
|
101
|
+
return { status: 400 };
|
|
102
|
+
const body = parsed;
|
|
103
|
+
if (body['type'] === 'url_verification' && typeof body['challenge'] === 'string') {
|
|
104
|
+
return { status: 200, contentType: 'text/plain; charset=utf-8', body: body['challenge'] };
|
|
105
|
+
}
|
|
106
|
+
const event = body['event'];
|
|
107
|
+
if (body['type'] !== 'event_callback' ||
|
|
108
|
+
!isRecord(event) ||
|
|
109
|
+
event['type'] !== 'message' ||
|
|
110
|
+
event['subtype'] !== undefined ||
|
|
111
|
+
event['bot_id'] !== undefined ||
|
|
112
|
+
typeof event['channel'] !== 'string' ||
|
|
113
|
+
typeof event['text'] !== 'string' ||
|
|
114
|
+
event['text'].trim() === '')
|
|
115
|
+
return { status: 200 };
|
|
116
|
+
const eventId = typeof body['event_id'] === 'string' ? body['event_id'] : '';
|
|
117
|
+
if (eventId === '' || !this.deduplicator.checkAndRecord(eventId))
|
|
118
|
+
return { status: 200 };
|
|
119
|
+
if (!this.allowlist.has(event['channel']) || this.turnService === undefined)
|
|
120
|
+
return { status: 200 };
|
|
121
|
+
try {
|
|
122
|
+
const result = await this.turnService.submit({
|
|
123
|
+
input: event['text'],
|
|
124
|
+
channel: 'slack',
|
|
125
|
+
replyTo: event['channel'],
|
|
126
|
+
});
|
|
127
|
+
this.pendingReplies.set(result.turnId, event['channel']);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
this.log.error('slack: submit failed', {
|
|
131
|
+
error: error instanceof Error ? error.message : String(error),
|
|
132
|
+
});
|
|
133
|
+
return { status: 500 };
|
|
134
|
+
}
|
|
135
|
+
return { status: 200 };
|
|
136
|
+
}
|
|
137
|
+
async send(target, text) {
|
|
138
|
+
if (this.botToken === undefined)
|
|
139
|
+
throw new Error('NOT_CONFIGURED: slack botToken missing');
|
|
140
|
+
const channel = target.trim();
|
|
141
|
+
if (channel === '' || text.trim() === '')
|
|
142
|
+
throw new Error('INVALID_ARGUMENT: target/text empty');
|
|
143
|
+
const points = Array.from(text);
|
|
144
|
+
for (let index = 0; index < points.length; index += MAX_TEXT_LENGTH) {
|
|
145
|
+
const data = await this.callApi('chat.postMessage', {
|
|
146
|
+
channel,
|
|
147
|
+
text: points.slice(index, index + MAX_TEXT_LENGTH).join(''),
|
|
148
|
+
});
|
|
149
|
+
if (!data.ok)
|
|
150
|
+
throw new Error(`SEND_FAILED: ${data.error ?? 'unknown error'}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
onTurnDone(payload) {
|
|
154
|
+
const target = this.pendingReplies.get(payload.turnId)
|
|
155
|
+
?? (payload.channel === 'slack' ? payload.replyTo : undefined);
|
|
156
|
+
if (target === undefined)
|
|
157
|
+
return;
|
|
158
|
+
this.pendingReplies.delete(payload.turnId);
|
|
159
|
+
void this.send(target, payload.status === 'completed'
|
|
160
|
+
? (payload.output?.trim() || '(empty response)')
|
|
161
|
+
: `Turn failed${payload.error ? `: ${payload.error}` : ''}.`).catch((error) => this.log.error('slack: reply failed', {
|
|
162
|
+
error: error instanceof Error ? error.message : String(error),
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
async callApi(method, body) {
|
|
166
|
+
if (this.botToken === undefined)
|
|
167
|
+
throw new Error('NOT_CONFIGURED');
|
|
168
|
+
const response = await fetch(`${SLACK_API_BASE}/${method}`, {
|
|
169
|
+
method: 'POST',
|
|
170
|
+
headers: { authorization: `Bearer ${this.botToken}`, 'content-type': 'application/json' },
|
|
171
|
+
body: JSON.stringify(body),
|
|
172
|
+
signal: AbortSignal.timeout(15_000),
|
|
173
|
+
});
|
|
174
|
+
const data = await response.json();
|
|
175
|
+
if (!isRecord(data) || typeof data['ok'] !== 'boolean') {
|
|
176
|
+
throw new Error(`Slack API returned an invalid response (${method})`);
|
|
177
|
+
}
|
|
178
|
+
return data;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function isRecord(value) {
|
|
182
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
183
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './streamer.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './streamer.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartStreamer — ported directly from ChannelHub concepts.
|
|
3
|
+
*
|
|
4
|
+
* Converts real-time LLM token streams into messaging platform updates:
|
|
5
|
+
* - When the transport supports in-place edits (Telegram, Discord):
|
|
6
|
+
* sends an initial placeholder, then debounces edits (e.g. every 1-2s).
|
|
7
|
+
* - When the transport does NOT support editing (Zalo, TikTok, WhatsApp, Messenger):
|
|
8
|
+
* accumulates tokens until a sentence boundary (., !, ?, \n) reaches
|
|
9
|
+
* minSentenceLength, then emits discrete messages.
|
|
10
|
+
*/
|
|
11
|
+
export interface StreamableTransport {
|
|
12
|
+
send(target: string, text: string): Promise<{
|
|
13
|
+
messageId?: string;
|
|
14
|
+
} | undefined>;
|
|
15
|
+
edit?(target: string, messageId: string, text: string): Promise<void>;
|
|
16
|
+
sendTyping?(target: string): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface SmartStreamerOptions {
|
|
19
|
+
editDebounceMs?: number;
|
|
20
|
+
typingIntervalMs?: number;
|
|
21
|
+
minSentenceLength?: number;
|
|
22
|
+
initialPlaceholder?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class SmartStreamer {
|
|
25
|
+
private readonly transport;
|
|
26
|
+
private readonly options;
|
|
27
|
+
constructor(transport: StreamableTransport, options?: SmartStreamerOptions);
|
|
28
|
+
stream(target: string, tokenStream: AsyncIterable<string>): Promise<string[]>;
|
|
29
|
+
private streamWithEdit;
|
|
30
|
+
private streamWithoutEdit;
|
|
31
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export class SmartStreamer {
|
|
2
|
+
transport;
|
|
3
|
+
options;
|
|
4
|
+
constructor(transport, options = {}) {
|
|
5
|
+
this.transport = transport;
|
|
6
|
+
this.options = {
|
|
7
|
+
editDebounceMs: 1200,
|
|
8
|
+
typingIntervalMs: 4000,
|
|
9
|
+
minSentenceLength: 60,
|
|
10
|
+
initialPlaceholder: '...',
|
|
11
|
+
...options,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
async stream(target, tokenStream) {
|
|
15
|
+
let typingActive = true;
|
|
16
|
+
const triggerTyping = async () => {
|
|
17
|
+
if (typeof this.transport.sendTyping === 'function') {
|
|
18
|
+
try {
|
|
19
|
+
await this.transport.sendTyping(target);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// ignore typing errors
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
void triggerTyping();
|
|
27
|
+
const typingTimer = setInterval(() => {
|
|
28
|
+
if (typingActive)
|
|
29
|
+
void triggerTyping();
|
|
30
|
+
}, this.options.typingIntervalMs);
|
|
31
|
+
try {
|
|
32
|
+
if (typeof this.transport.edit === 'function') {
|
|
33
|
+
return await this.streamWithEdit(target, tokenStream);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return await this.streamWithoutEdit(target, tokenStream);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
typingActive = false;
|
|
41
|
+
clearInterval(typingTimer);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async streamWithEdit(target, tokenStream) {
|
|
45
|
+
let accumulated = '';
|
|
46
|
+
let messageId;
|
|
47
|
+
let lastEditTime = 0;
|
|
48
|
+
let pendingTimeout = null;
|
|
49
|
+
let editQueue = Promise.resolve();
|
|
50
|
+
let editFailure;
|
|
51
|
+
const performEdit = async (text) => {
|
|
52
|
+
if (messageId && this.transport.edit) {
|
|
53
|
+
await this.transport.edit(target, messageId, text);
|
|
54
|
+
lastEditTime = Date.now();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const queueEdit = (text) => {
|
|
58
|
+
editQueue = editQueue
|
|
59
|
+
.then(async () => {
|
|
60
|
+
if (editFailure === undefined)
|
|
61
|
+
await performEdit(text);
|
|
62
|
+
})
|
|
63
|
+
.catch((error) => {
|
|
64
|
+
editFailure = { error };
|
|
65
|
+
});
|
|
66
|
+
return editQueue;
|
|
67
|
+
};
|
|
68
|
+
const throwEditFailure = () => {
|
|
69
|
+
if (editFailure !== undefined)
|
|
70
|
+
throw editFailure.error;
|
|
71
|
+
};
|
|
72
|
+
for await (const chunk of tokenStream) {
|
|
73
|
+
accumulated += chunk;
|
|
74
|
+
if (!messageId) {
|
|
75
|
+
const initial = accumulated.trim() || this.options.initialPlaceholder;
|
|
76
|
+
const res = await this.transport.send(target, initial);
|
|
77
|
+
messageId = res && typeof res === 'object' ? res.messageId : undefined;
|
|
78
|
+
lastEditTime = Date.now();
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const elapsed = Date.now() - lastEditTime;
|
|
82
|
+
if (elapsed >= this.options.editDebounceMs) {
|
|
83
|
+
if (pendingTimeout) {
|
|
84
|
+
clearTimeout(pendingTimeout);
|
|
85
|
+
pendingTimeout = null;
|
|
86
|
+
}
|
|
87
|
+
await queueEdit(accumulated);
|
|
88
|
+
throwEditFailure();
|
|
89
|
+
}
|
|
90
|
+
else if (!pendingTimeout) {
|
|
91
|
+
pendingTimeout = setTimeout(() => {
|
|
92
|
+
pendingTimeout = null;
|
|
93
|
+
void queueEdit(accumulated);
|
|
94
|
+
}, this.options.editDebounceMs - elapsed);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (pendingTimeout) {
|
|
98
|
+
clearTimeout(pendingTimeout);
|
|
99
|
+
}
|
|
100
|
+
await editQueue;
|
|
101
|
+
throwEditFailure();
|
|
102
|
+
if (messageId && this.transport.edit) {
|
|
103
|
+
await this.transport.edit(target, messageId, accumulated);
|
|
104
|
+
}
|
|
105
|
+
return messageId ? [messageId] : [];
|
|
106
|
+
}
|
|
107
|
+
async streamWithoutEdit(target, tokenStream) {
|
|
108
|
+
let buffer = '';
|
|
109
|
+
const sentIds = [];
|
|
110
|
+
const sentenceDelimiters = ['. ', '! ', '? ', '.\n', '!\n', '?\n', '\n\n'];
|
|
111
|
+
for await (const chunk of tokenStream) {
|
|
112
|
+
buffer += chunk;
|
|
113
|
+
if (buffer.length >= this.options.minSentenceLength) {
|
|
114
|
+
let splitIndex = -1;
|
|
115
|
+
for (const delim of sentenceDelimiters) {
|
|
116
|
+
const idx = buffer.indexOf(delim);
|
|
117
|
+
if (idx !== -1 && (splitIndex === -1 || idx < splitIndex)) {
|
|
118
|
+
splitIndex = idx + delim.length;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (splitIndex !== -1) {
|
|
122
|
+
const toSend = buffer.slice(0, splitIndex).trim();
|
|
123
|
+
buffer = buffer.slice(splitIndex);
|
|
124
|
+
if (toSend) {
|
|
125
|
+
const res = await this.transport.send(target, toSend);
|
|
126
|
+
if (res && typeof res === 'object' && res.messageId) {
|
|
127
|
+
sentIds.push(res.messageId);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (buffer.trim()) {
|
|
134
|
+
const res = await this.transport.send(target, buffer.trim());
|
|
135
|
+
if (res && typeof res === 'object' && res.messageId) {
|
|
136
|
+
sentIds.push(res.messageId);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return sentIds;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './transport.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './transport.js';
|