@theowlops/boombot 0.0.0-stage → 1.1.0
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 +230 -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,563 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { EXTRA_COMMAND_DEFS as CHANNEL_EXTRA_COMMAND_DEFS } from "./commands-channels.js";
|
|
3
|
+
import { EXTRA_COMMAND_DEFS as SCHEDULER_EXTRA_COMMAND_DEFS } from "./commands-scheduler.js";
|
|
4
|
+
import { ProtocolError } from "./errors.js";
|
|
5
|
+
/**
|
|
6
|
+
* Typed command schemas for every command the web UI (phase 1) needs.
|
|
7
|
+
*
|
|
8
|
+
* Each command definition carries a literal `type`, a zod `payload` schema
|
|
9
|
+
* (what the client sends inside the envelope) and a zod `response` schema
|
|
10
|
+
* (what the gateway returns inside the response envelope).
|
|
11
|
+
*
|
|
12
|
+
* Wire-evolution rule (additive-first): payloads and responses only ever gain
|
|
13
|
+
* OPTIONAL fields. Unknown fields are stripped, never rejected, so a newer
|
|
14
|
+
* server can talk to an older client within the same wire version.
|
|
15
|
+
*/
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Shared shapes
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Provider kind on the wire. Accepts any non-empty string — the gateway's
|
|
21
|
+
* provider service validates it against the live profile registry (built-ins
|
|
22
|
+
* plus user-defined custom providers from `custom-providers.json`), so the
|
|
23
|
+
* wire schema stays permissive while the service stays strict.
|
|
24
|
+
*/
|
|
25
|
+
export const providerKindSchema = z.string().min(1);
|
|
26
|
+
/** Per-model reasoning knobs. Each wire protocol maps them its own way. */
|
|
27
|
+
export const reasoningProfileSchema = z.object({
|
|
28
|
+
/** OpenAI-style reasoning effort (sent as `reasoning_effort` on OpenAI-compatible kinds). */
|
|
29
|
+
effort: z.string().min(1).optional(),
|
|
30
|
+
/** Anthropic-style thinking budget in tokens (sent as `thinking.budget_tokens`). */
|
|
31
|
+
budgetTokens: z.number().int().positive().optional(),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Request profile: per-request overrides merged in three tiers —
|
|
35
|
+
* kind defaults < provider.extra < per-model override. Stored in
|
|
36
|
+
* providers.json, applied by the gateway when building provider requests.
|
|
37
|
+
*/
|
|
38
|
+
export const requestProfileSchema = z.object({
|
|
39
|
+
maxTokens: z.number().int().positive().optional(),
|
|
40
|
+
temperature: z.number().min(0).optional(),
|
|
41
|
+
topP: z.number().min(0).max(1).optional(),
|
|
42
|
+
/** Extra HTTP headers merged over (but never overriding) the auth headers. */
|
|
43
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
44
|
+
/** Extra top-level fields merged into the JSON request body. */
|
|
45
|
+
extraBody: z.record(z.string(), z.unknown()).optional(),
|
|
46
|
+
reasoning: reasoningProfileSchema.optional(),
|
|
47
|
+
});
|
|
48
|
+
export const providerSchema = z.object({
|
|
49
|
+
id: z.string().min(1),
|
|
50
|
+
name: z.string().min(1),
|
|
51
|
+
kind: providerKindSchema,
|
|
52
|
+
baseUrl: z.string().url().optional(),
|
|
53
|
+
hasKey: z.boolean(),
|
|
54
|
+
/** Number of API keys in the provider's KeyRoulette ring. */
|
|
55
|
+
keyCount: z.number().int().nonnegative(),
|
|
56
|
+
/** Key-rotation cursor: index of the ring entry tried first (operational state). */
|
|
57
|
+
keyCursor: z.number().int().nonnegative().optional(),
|
|
58
|
+
active: z.boolean(),
|
|
59
|
+
/** Default chat model for turns. Never overwritten by probe discovery. */
|
|
60
|
+
model: z.string().min(1).optional(),
|
|
61
|
+
models: z.array(z.string()).optional(),
|
|
62
|
+
/** Provider-level request profile (tier 2 of 3). */
|
|
63
|
+
extra: requestProfileSchema.optional(),
|
|
64
|
+
/** Per-model request profile overrides (tier 3 of 3), keyed by model id. */
|
|
65
|
+
modelProfiles: z.record(z.string(), requestProfileSchema).optional(),
|
|
66
|
+
});
|
|
67
|
+
/** Provider record as sent by the client on `provider.save`. `apiKey`/`apiKeys` are write-only and never echoed back. */
|
|
68
|
+
export const providerInputSchema = providerSchema
|
|
69
|
+
.omit({ hasKey: true, active: true, keyCount: true, keyCursor: true })
|
|
70
|
+
.extend({
|
|
71
|
+
hasKey: z.boolean().optional(),
|
|
72
|
+
/** Server default when omitted. */
|
|
73
|
+
active: z.boolean().optional(),
|
|
74
|
+
apiKey: z.string().min(1).optional(),
|
|
75
|
+
/**
|
|
76
|
+
* Replace the whole key ring. Mutually exclusive with `apiKey`;
|
|
77
|
+
* omitted = keep stored keys, `[]` = clear.
|
|
78
|
+
*/
|
|
79
|
+
apiKeys: z.array(z.string().min(1)).max(32).optional(),
|
|
80
|
+
});
|
|
81
|
+
export const sessionConfigSnapshotSchema = z.object({
|
|
82
|
+
model: z.string().min(1).optional(),
|
|
83
|
+
provider: z.string().min(1).optional(),
|
|
84
|
+
toolsEnabled: z.number().int().nonnegative(),
|
|
85
|
+
systemPromptHash: z.string().min(1),
|
|
86
|
+
});
|
|
87
|
+
export const sessionSchema = z.object({
|
|
88
|
+
id: z.string().min(1),
|
|
89
|
+
title: z.string(),
|
|
90
|
+
createdAt: z.string(),
|
|
91
|
+
updatedAt: z.string(),
|
|
92
|
+
messageCount: z.number().int().nonnegative(),
|
|
93
|
+
/** P1-7: point-in-time config serving the session's turns; absent until the first turn. */
|
|
94
|
+
configSnapshot: sessionConfigSnapshotSchema.optional(),
|
|
95
|
+
});
|
|
96
|
+
export const messageSchema = z.object({
|
|
97
|
+
id: z.string().min(1),
|
|
98
|
+
role: z.enum(["user", "assistant", "system", "tool"]),
|
|
99
|
+
content: z.string(),
|
|
100
|
+
createdAt: z.string(),
|
|
101
|
+
toolCallId: z.string().optional(),
|
|
102
|
+
toolName: z.string().optional(),
|
|
103
|
+
/** P1-6: context checkpoint flag — prompt projection starts here. */
|
|
104
|
+
isCheckpoint: z.boolean().optional(),
|
|
105
|
+
/**
|
|
106
|
+
* P2-3: active variant index the read resolved to. Present and > 0 when a
|
|
107
|
+
* variant's content is shown; absent means the base row's content.
|
|
108
|
+
*/
|
|
109
|
+
variantIndex: z.number().int().nonnegative().optional(),
|
|
110
|
+
});
|
|
111
|
+
/** P2-3: one alternate content stored at a message position. */
|
|
112
|
+
export const variantSchema = z.object({
|
|
113
|
+
id: z.string().min(1),
|
|
114
|
+
sessionId: z.string().min(1),
|
|
115
|
+
messageId: z.string().min(1),
|
|
116
|
+
variantIndex: z.number().int().positive(),
|
|
117
|
+
content: z.string(),
|
|
118
|
+
createdAt: z.string(),
|
|
119
|
+
});
|
|
120
|
+
export const scheduleSchema = z.object({
|
|
121
|
+
id: z.string().min(1),
|
|
122
|
+
name: z.string().min(1),
|
|
123
|
+
cron: z.string().min(1),
|
|
124
|
+
prompt: z.string().min(1),
|
|
125
|
+
enabled: z.boolean(),
|
|
126
|
+
nextRunAt: z.string().optional(),
|
|
127
|
+
});
|
|
128
|
+
export const memoryHitSchema = z.object({
|
|
129
|
+
id: z.string().min(1),
|
|
130
|
+
excerpt: z.string(),
|
|
131
|
+
score: z.number(),
|
|
132
|
+
});
|
|
133
|
+
export const channelSchema = z.object({
|
|
134
|
+
id: z.string().min(1),
|
|
135
|
+
kind: z.string().min(1),
|
|
136
|
+
status: z.enum(["connected", "disconnected", "error", "pending"]),
|
|
137
|
+
displayName: z.string(),
|
|
138
|
+
});
|
|
139
|
+
export const attachmentSchema = z.object({
|
|
140
|
+
id: z.string().min(1),
|
|
141
|
+
name: z.string(),
|
|
142
|
+
mimeType: z.string(),
|
|
143
|
+
sizeBytes: z.number().int().nonnegative(),
|
|
144
|
+
ref: z.string(),
|
|
145
|
+
});
|
|
146
|
+
export const turnStatusSchema = z.enum([
|
|
147
|
+
"queued",
|
|
148
|
+
"running",
|
|
149
|
+
"completed",
|
|
150
|
+
"cancelled",
|
|
151
|
+
"failed",
|
|
152
|
+
]);
|
|
153
|
+
const okSchema = z.object({ ok: z.boolean() });
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// Background task runner (wire v1 additive).
|
|
156
|
+
//
|
|
157
|
+
// Schemas for long-running background tasks (`task.*` commands below).
|
|
158
|
+
// Additive-first: these only add new command/event types; no existing field
|
|
159
|
+
// or schema is touched, so older wire v1 clients keep working unchanged.
|
|
160
|
+
// ---------------------------------------------------------------------------
|
|
161
|
+
export const taskStatusSchema = z.enum([
|
|
162
|
+
"queued",
|
|
163
|
+
"running",
|
|
164
|
+
"paused",
|
|
165
|
+
"awaiting_approval",
|
|
166
|
+
"completed",
|
|
167
|
+
"failed",
|
|
168
|
+
"cancelled",
|
|
169
|
+
"interrupted",
|
|
170
|
+
]);
|
|
171
|
+
export const taskStepSchema = z.object({
|
|
172
|
+
id: z.string().min(1),
|
|
173
|
+
index: z.number().int().nonnegative(),
|
|
174
|
+
kind: z.literal("turn"),
|
|
175
|
+
prompt: z.string().min(1),
|
|
176
|
+
status: z.enum(["pending", "running", "done", "failed", "skipped"]),
|
|
177
|
+
attempts: z.number().int().nonnegative(),
|
|
178
|
+
output: z.string().optional(),
|
|
179
|
+
error: z.string().optional(),
|
|
180
|
+
});
|
|
181
|
+
export const taskSchema = z.object({
|
|
182
|
+
id: z.string().min(1),
|
|
183
|
+
title: z.string().min(1),
|
|
184
|
+
sessionId: z.string().min(1).optional(),
|
|
185
|
+
status: taskStatusSchema,
|
|
186
|
+
steps: z.array(taskStepSchema),
|
|
187
|
+
currentStepIndex: z.number().int().nonnegative(),
|
|
188
|
+
approval: z
|
|
189
|
+
.object({
|
|
190
|
+
runId: z.string().min(1),
|
|
191
|
+
toolName: z.string().min(1),
|
|
192
|
+
reason: z.string(),
|
|
193
|
+
})
|
|
194
|
+
.optional(),
|
|
195
|
+
createdAt: z.string(),
|
|
196
|
+
updatedAt: z.string(),
|
|
197
|
+
error: z.string().optional(),
|
|
198
|
+
});
|
|
199
|
+
const agentTurnSubmit = {
|
|
200
|
+
type: "agent.turn.submit",
|
|
201
|
+
payload: z.object({
|
|
202
|
+
sessionId: z.string().min(1).optional(),
|
|
203
|
+
message: z.string().min(1),
|
|
204
|
+
attachments: z.array(attachmentSchema).optional(),
|
|
205
|
+
}),
|
|
206
|
+
response: z.object({
|
|
207
|
+
turnId: z.string().min(1),
|
|
208
|
+
status: turnStatusSchema,
|
|
209
|
+
}),
|
|
210
|
+
};
|
|
211
|
+
const agentTurnCancel = {
|
|
212
|
+
type: "agent.turn.cancel",
|
|
213
|
+
payload: z.object({ turnId: z.string().min(1) }),
|
|
214
|
+
response: z.object({
|
|
215
|
+
turnId: z.string().min(1),
|
|
216
|
+
status: turnStatusSchema,
|
|
217
|
+
}),
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* `turn.approve` — answers a `turn.approval_required` event (HITL).
|
|
221
|
+
*
|
|
222
|
+
* The client sends `approved` plus optionally `editedArgs` (rewritten tool
|
|
223
|
+
* arguments the gateway must use instead of the proposed ones). The gateway
|
|
224
|
+
* answers `resumed: true` when the turn continues after the decision, or
|
|
225
|
+
* `resumed: false` when the runId is no longer pending (timed out or already
|
|
226
|
+
* handled).
|
|
227
|
+
*/
|
|
228
|
+
const turnApprove = {
|
|
229
|
+
type: "turn.approve",
|
|
230
|
+
payload: z.object({
|
|
231
|
+
/** The runId from the matching `turn.approval_required` event. */
|
|
232
|
+
runId: z.string().min(1),
|
|
233
|
+
approved: z.boolean(),
|
|
234
|
+
editedArgs: z.record(z.string(), z.unknown()).optional(),
|
|
235
|
+
}),
|
|
236
|
+
response: z.object({
|
|
237
|
+
runId: z.string(),
|
|
238
|
+
approved: z.boolean(),
|
|
239
|
+
resumed: z.boolean(),
|
|
240
|
+
}),
|
|
241
|
+
};
|
|
242
|
+
const sessionList = {
|
|
243
|
+
type: "session.list",
|
|
244
|
+
payload: z.object({}),
|
|
245
|
+
response: z.object({ sessions: z.array(sessionSchema) }),
|
|
246
|
+
};
|
|
247
|
+
const sessionGet = {
|
|
248
|
+
type: "session.get",
|
|
249
|
+
payload: z.object({ sessionId: z.string().min(1) }),
|
|
250
|
+
response: z.object({ session: sessionSchema, messages: z.array(messageSchema) }),
|
|
251
|
+
};
|
|
252
|
+
const sessionCreate = {
|
|
253
|
+
type: "session.create",
|
|
254
|
+
payload: z.object({ title: z.string().min(1).optional() }),
|
|
255
|
+
response: z.object({ session: sessionSchema }),
|
|
256
|
+
};
|
|
257
|
+
const sessionDelete = {
|
|
258
|
+
type: "session.delete",
|
|
259
|
+
payload: z.object({ sessionId: z.string().min(1) }),
|
|
260
|
+
response: okSchema,
|
|
261
|
+
};
|
|
262
|
+
const sessionRename = {
|
|
263
|
+
type: "session.rename",
|
|
264
|
+
payload: z.object({ sessionId: z.string().min(1), title: z.string().min(1).max(200) }),
|
|
265
|
+
response: z.object({ session: sessionSchema }),
|
|
266
|
+
};
|
|
267
|
+
const sessionUndo = {
|
|
268
|
+
type: "session.undo",
|
|
269
|
+
payload: z.object({ sessionId: z.string().min(1) }),
|
|
270
|
+
response: z.object({ removedCount: z.number().int().nonnegative() }),
|
|
271
|
+
};
|
|
272
|
+
const sessionBranch = {
|
|
273
|
+
type: "session.branch",
|
|
274
|
+
payload: z.object({
|
|
275
|
+
sessionId: z.string().min(1),
|
|
276
|
+
title: z.string().min(1).max(200).optional(),
|
|
277
|
+
}),
|
|
278
|
+
response: z.object({ session: sessionSchema }),
|
|
279
|
+
};
|
|
280
|
+
const sessionCheckpoint = {
|
|
281
|
+
type: "session.checkpoint",
|
|
282
|
+
payload: z.object({
|
|
283
|
+
sessionId: z.string().min(1),
|
|
284
|
+
/** Omit to checkpoint the latest message. */
|
|
285
|
+
messageId: z.string().min(1).optional(),
|
|
286
|
+
}),
|
|
287
|
+
response: z.object({ message: messageSchema }),
|
|
288
|
+
};
|
|
289
|
+
const sessionVariantCreate = {
|
|
290
|
+
type: "session.variant.create",
|
|
291
|
+
payload: z.object({
|
|
292
|
+
sessionId: z.string().min(1),
|
|
293
|
+
messageId: z.string().min(1),
|
|
294
|
+
content: z.string(),
|
|
295
|
+
}),
|
|
296
|
+
response: z.object({ variant: variantSchema }),
|
|
297
|
+
};
|
|
298
|
+
const sessionVariantSelect = {
|
|
299
|
+
type: "session.variant.select",
|
|
300
|
+
payload: z.object({
|
|
301
|
+
sessionId: z.string().min(1),
|
|
302
|
+
messageId: z.string().min(1),
|
|
303
|
+
/** 0 re-selects the base row. */
|
|
304
|
+
variantIndex: z.number().int().nonnegative(),
|
|
305
|
+
}),
|
|
306
|
+
response: z.object({ message: messageSchema }),
|
|
307
|
+
};
|
|
308
|
+
const sessionVariantList = {
|
|
309
|
+
type: "session.variant.list",
|
|
310
|
+
payload: z.object({
|
|
311
|
+
sessionId: z.string().min(1),
|
|
312
|
+
messageId: z.string().min(1),
|
|
313
|
+
}),
|
|
314
|
+
response: z.object({ variants: z.array(variantSchema) }),
|
|
315
|
+
};
|
|
316
|
+
const providerList = {
|
|
317
|
+
type: "provider.list",
|
|
318
|
+
payload: z.object({}),
|
|
319
|
+
response: z.object({ providers: z.array(providerSchema) }),
|
|
320
|
+
};
|
|
321
|
+
const providerSave = {
|
|
322
|
+
type: "provider.save",
|
|
323
|
+
payload: z.object({ provider: providerInputSchema }),
|
|
324
|
+
response: z.object({ provider: providerSchema }),
|
|
325
|
+
};
|
|
326
|
+
const providerTest = {
|
|
327
|
+
type: "provider.test",
|
|
328
|
+
payload: z.object({ id: z.string().min(1) }),
|
|
329
|
+
response: z.object({
|
|
330
|
+
ok: z.boolean(),
|
|
331
|
+
latencyMs: z.number().int().nonnegative().optional(),
|
|
332
|
+
detail: z.string().optional(),
|
|
333
|
+
}),
|
|
334
|
+
};
|
|
335
|
+
const providerActivate = {
|
|
336
|
+
type: "provider.activate",
|
|
337
|
+
payload: z.object({ id: z.string().min(1) }),
|
|
338
|
+
response: z.object({ provider: providerSchema }),
|
|
339
|
+
};
|
|
340
|
+
const providerDelete = {
|
|
341
|
+
type: "provider.delete",
|
|
342
|
+
payload: z.object({ id: z.string().min(1) }),
|
|
343
|
+
response: okSchema,
|
|
344
|
+
};
|
|
345
|
+
const scheduleList = {
|
|
346
|
+
type: "schedule.list",
|
|
347
|
+
payload: z.object({}),
|
|
348
|
+
response: z.object({ schedules: z.array(scheduleSchema) }),
|
|
349
|
+
};
|
|
350
|
+
const scheduleCreate = {
|
|
351
|
+
type: "schedule.create",
|
|
352
|
+
payload: z.object({
|
|
353
|
+
name: z.string().min(1),
|
|
354
|
+
cron: z.string().min(1),
|
|
355
|
+
prompt: z.string().min(1),
|
|
356
|
+
enabled: z.boolean().optional(),
|
|
357
|
+
}),
|
|
358
|
+
response: z.object({ schedule: scheduleSchema }),
|
|
359
|
+
};
|
|
360
|
+
const scheduleUpdate = {
|
|
361
|
+
type: "schedule.update",
|
|
362
|
+
payload: z.object({
|
|
363
|
+
id: z.string().min(1),
|
|
364
|
+
name: z.string().min(1).optional(),
|
|
365
|
+
cron: z.string().min(1).optional(),
|
|
366
|
+
prompt: z.string().min(1).optional(),
|
|
367
|
+
enabled: z.boolean().optional(),
|
|
368
|
+
}),
|
|
369
|
+
response: z.object({ schedule: scheduleSchema }),
|
|
370
|
+
};
|
|
371
|
+
const scheduleDelete = {
|
|
372
|
+
type: "schedule.delete",
|
|
373
|
+
payload: z.object({ id: z.string().min(1) }),
|
|
374
|
+
response: okSchema,
|
|
375
|
+
};
|
|
376
|
+
const scheduleToggle = {
|
|
377
|
+
type: "schedule.toggle",
|
|
378
|
+
payload: z.object({
|
|
379
|
+
id: z.string().min(1),
|
|
380
|
+
enabled: z.boolean(),
|
|
381
|
+
}),
|
|
382
|
+
response: z.object({ schedule: scheduleSchema }),
|
|
383
|
+
};
|
|
384
|
+
const memorySearch = {
|
|
385
|
+
type: "memory.search",
|
|
386
|
+
payload: z.object({
|
|
387
|
+
query: z.string().min(1),
|
|
388
|
+
limit: z.number().int().positive().max(100).optional(),
|
|
389
|
+
}),
|
|
390
|
+
response: z.object({ results: z.array(memoryHitSchema) }),
|
|
391
|
+
};
|
|
392
|
+
const memoryNote = {
|
|
393
|
+
type: "memory.note",
|
|
394
|
+
payload: z.object({
|
|
395
|
+
text: z.string().min(1).max(65_536).refine((text) => new TextEncoder().encode(text).byteLength <= 65_536, "text must not exceed 64 KiB"),
|
|
396
|
+
meta: z.record(z.string(), z.string()).refine((meta) => Object.keys(meta).length <= 32, "meta must not exceed 32 entries").optional(),
|
|
397
|
+
}),
|
|
398
|
+
response: z.object({ ok: z.literal(true), id: z.string().min(1) }),
|
|
399
|
+
};
|
|
400
|
+
const channelList = {
|
|
401
|
+
type: "channel.list",
|
|
402
|
+
payload: z.object({}),
|
|
403
|
+
response: z.object({ channels: z.array(channelSchema) }),
|
|
404
|
+
};
|
|
405
|
+
const gatewayHealth = {
|
|
406
|
+
type: "gateway.health",
|
|
407
|
+
payload: z.object({}),
|
|
408
|
+
response: z.object({
|
|
409
|
+
ok: z.boolean(),
|
|
410
|
+
version: z.string(),
|
|
411
|
+
wireVersion: z.number().int(),
|
|
412
|
+
}),
|
|
413
|
+
};
|
|
414
|
+
// ---------------------------------------------------------------------------
|
|
415
|
+
// Background task runner commands (wire v1 additive).
|
|
416
|
+
// ---------------------------------------------------------------------------
|
|
417
|
+
/**
|
|
418
|
+
* `task.create` — enqueue a new background task: an ordered list of agent
|
|
419
|
+
* turns (steps) the gateway runs one after another, emitting `task.*` events.
|
|
420
|
+
* The response carries the full task record, with server-generated step ids.
|
|
421
|
+
*/
|
|
422
|
+
const taskCreate = {
|
|
423
|
+
type: "task.create",
|
|
424
|
+
payload: z.object({
|
|
425
|
+
title: z.string().min(1),
|
|
426
|
+
steps: z.array(z.object({ prompt: z.string().min(1) })).min(1),
|
|
427
|
+
}),
|
|
428
|
+
response: z.object({ task: taskSchema }),
|
|
429
|
+
};
|
|
430
|
+
const taskList = {
|
|
431
|
+
type: "task.list",
|
|
432
|
+
payload: z.object({}),
|
|
433
|
+
response: z.object({ tasks: z.array(taskSchema) }),
|
|
434
|
+
};
|
|
435
|
+
const taskGet = {
|
|
436
|
+
type: "task.get",
|
|
437
|
+
payload: z.object({ id: z.string().min(1) }),
|
|
438
|
+
response: z.object({ task: taskSchema }),
|
|
439
|
+
};
|
|
440
|
+
/**
|
|
441
|
+
* `task.pause` — pause a queued/running task between steps. A paused task
|
|
442
|
+
* emits no further turn activity until `task.resume`.
|
|
443
|
+
*/
|
|
444
|
+
const taskPause = {
|
|
445
|
+
type: "task.pause",
|
|
446
|
+
payload: z.object({ id: z.string().min(1) }),
|
|
447
|
+
response: z.object({ task: taskSchema }),
|
|
448
|
+
};
|
|
449
|
+
/**
|
|
450
|
+
* `task.resume` — resume a paused task, or answer a task's
|
|
451
|
+
* `task.awaiting_approval` checkpoint (HITL): `approved` plus optional
|
|
452
|
+
* `editedArgs` mirror `turn.approve`. Both fields are optional so a plain
|
|
453
|
+
* resume needs only the task id.
|
|
454
|
+
*/
|
|
455
|
+
const taskResume = {
|
|
456
|
+
type: "task.resume",
|
|
457
|
+
payload: z.object({
|
|
458
|
+
id: z.string().min(1),
|
|
459
|
+
approved: z.boolean().optional(),
|
|
460
|
+
editedArgs: z.record(z.string(), z.unknown()).optional(),
|
|
461
|
+
}),
|
|
462
|
+
response: z.object({ task: taskSchema }),
|
|
463
|
+
};
|
|
464
|
+
const taskCancel = {
|
|
465
|
+
type: "task.cancel",
|
|
466
|
+
payload: z.object({ id: z.string().min(1) }),
|
|
467
|
+
response: okSchema,
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* `task.redirect` — steer a running task: the gateway injects `message` as
|
|
471
|
+
* additional context before the next step starts.
|
|
472
|
+
*/
|
|
473
|
+
const taskRedirect = {
|
|
474
|
+
type: "task.redirect",
|
|
475
|
+
payload: z.object({
|
|
476
|
+
id: z.string().min(1),
|
|
477
|
+
message: z.string().min(1),
|
|
478
|
+
}),
|
|
479
|
+
response: z.object({ task: taskSchema }),
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* `task.retry` — re-run a failed (or interrupted) task starting at `fromStep`
|
|
483
|
+
* (default: the failed step). Steps already done are not re-run.
|
|
484
|
+
*/
|
|
485
|
+
const taskRetry = {
|
|
486
|
+
type: "task.retry",
|
|
487
|
+
payload: z.object({
|
|
488
|
+
id: z.string().min(1),
|
|
489
|
+
fromStep: z.number().int().nonnegative().optional(),
|
|
490
|
+
}),
|
|
491
|
+
response: z.object({ task: taskSchema }),
|
|
492
|
+
};
|
|
493
|
+
/** Every known command type, mapped to its payload/response schemas. */
|
|
494
|
+
export const COMMAND_SCHEMAS = {
|
|
495
|
+
"agent.turn.submit": agentTurnSubmit,
|
|
496
|
+
"agent.turn.cancel": agentTurnCancel,
|
|
497
|
+
"turn.approve": turnApprove,
|
|
498
|
+
"session.list": sessionList,
|
|
499
|
+
"session.get": sessionGet,
|
|
500
|
+
"session.create": sessionCreate,
|
|
501
|
+
"session.delete": sessionDelete,
|
|
502
|
+
"session.rename": sessionRename,
|
|
503
|
+
"session.undo": sessionUndo,
|
|
504
|
+
"session.branch": sessionBranch,
|
|
505
|
+
"session.checkpoint": sessionCheckpoint,
|
|
506
|
+
"session.variant.create": sessionVariantCreate,
|
|
507
|
+
"session.variant.select": sessionVariantSelect,
|
|
508
|
+
"session.variant.list": sessionVariantList,
|
|
509
|
+
"provider.list": providerList,
|
|
510
|
+
"provider.save": providerSave,
|
|
511
|
+
"provider.test": providerTest,
|
|
512
|
+
"provider.activate": providerActivate,
|
|
513
|
+
"provider.delete": providerDelete,
|
|
514
|
+
"schedule.list": scheduleList,
|
|
515
|
+
"schedule.create": scheduleCreate,
|
|
516
|
+
"schedule.update": scheduleUpdate,
|
|
517
|
+
"schedule.delete": scheduleDelete,
|
|
518
|
+
"schedule.toggle": scheduleToggle,
|
|
519
|
+
"memory.search": memorySearch,
|
|
520
|
+
"memory.note": memoryNote,
|
|
521
|
+
"channel.list": channelList,
|
|
522
|
+
"gateway.health": gatewayHealth,
|
|
523
|
+
"task.create": taskCreate,
|
|
524
|
+
"task.list": taskList,
|
|
525
|
+
"task.get": taskGet,
|
|
526
|
+
"task.pause": taskPause,
|
|
527
|
+
"task.resume": taskResume,
|
|
528
|
+
"task.cancel": taskCancel,
|
|
529
|
+
"task.redirect": taskRedirect,
|
|
530
|
+
"task.retry": taskRetry,
|
|
531
|
+
// Additive extra commands (each module documents its own defs).
|
|
532
|
+
...SCHEDULER_EXTRA_COMMAND_DEFS,
|
|
533
|
+
...CHANNEL_EXTRA_COMMAND_DEFS,
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* Validate an envelope's payload against the schema registered for its `type`.
|
|
537
|
+
* Throws {@link ProtocolError}:
|
|
538
|
+
* - UNKNOWN_COMMAND when `type` is not registered,
|
|
539
|
+
* - INVALID_PAYLOAD when the payload fails its schema (zod issues in `details`).
|
|
540
|
+
*/
|
|
541
|
+
export function parseCommand(envelope) {
|
|
542
|
+
const def = COMMAND_SCHEMAS[envelope.type];
|
|
543
|
+
if (!def) {
|
|
544
|
+
throw new ProtocolError("UNKNOWN_COMMAND", `Unknown command type: ${envelope.type}`, { type: envelope.type });
|
|
545
|
+
}
|
|
546
|
+
const result = def.payload.safeParse(envelope.payload);
|
|
547
|
+
if (!result.success) {
|
|
548
|
+
throw new ProtocolError("INVALID_PAYLOAD", `Invalid payload for command ${def.type}: ${result.error.message}`, { type: def.type, issues: result.error.issues });
|
|
549
|
+
}
|
|
550
|
+
return { type: def.type, payload: result.data };
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Validate a raw response body for a given command type.
|
|
554
|
+
* Throws {@link ProtocolError} with code INVALID_PAYLOAD on schema mismatch.
|
|
555
|
+
*/
|
|
556
|
+
export function parseCommandResponse(type, raw) {
|
|
557
|
+
const def = COMMAND_SCHEMAS[type];
|
|
558
|
+
const result = def.response.safeParse(raw);
|
|
559
|
+
if (!result.success) {
|
|
560
|
+
throw new ProtocolError("INVALID_PAYLOAD", `Invalid response for command ${type}: ${result.error.message}`, { type, issues: result.error.issues });
|
|
561
|
+
}
|
|
562
|
+
return result.data;
|
|
563
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire envelope. Every command sent to `POST /v1/commands` is wrapped in
|
|
3
|
+
* this envelope; the gateway replies with the same envelope shape, where
|
|
4
|
+
* `type` is the response's command type and `payload` the response body.
|
|
5
|
+
*
|
|
6
|
+
* `protocolVersion` is a literal: any value other than {@link WIRE_VERSION}
|
|
7
|
+
* is rejected with a VERSION_MISMATCH error (see `parseEnvelope`).
|
|
8
|
+
*/
|
|
9
|
+
export interface Envelope<TType extends string, TPayload> {
|
|
10
|
+
protocolVersion: 1;
|
|
11
|
+
requestId: string;
|
|
12
|
+
type: TType;
|
|
13
|
+
payload: TPayload;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Current wire version. Independent from the product version: bumping the
|
|
17
|
+
* product does NOT change this value; only a breaking protocol change does.
|
|
18
|
+
*/
|
|
19
|
+
export declare const WIRE_VERSION: 1;
|
|
20
|
+
/**
|
|
21
|
+
* Build a request envelope. A `requestId` is generated with
|
|
22
|
+
* `crypto.randomUUID()` when not supplied; clients should keep it stable
|
|
23
|
+
* across retries so the gateway can deduplicate.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createEnvelope<TType extends string, TPayload>(type: TType, payload: TPayload, requestId?: string): Envelope<TType, TPayload>;
|
|
26
|
+
/**
|
|
27
|
+
* Validate a raw value as an envelope. Accepts parsed JSON (objects) or a
|
|
28
|
+
* JSON string. Throws {@link ProtocolError} with code:
|
|
29
|
+
* - INVALID_ENVELOPE: not an object, or missing/invalid `requestId` / `type` / `payload`.
|
|
30
|
+
* - VERSION_MISMATCH: `protocolVersion` present but not equal to {@link WIRE_VERSION}.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseEnvelope(raw: unknown): Envelope<string, unknown>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { ProtocolError } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Current wire version. Independent from the product version: bumping the
|
|
5
|
+
* product does NOT change this value; only a breaking protocol change does.
|
|
6
|
+
*/
|
|
7
|
+
export const WIRE_VERSION = 1;
|
|
8
|
+
/**
|
|
9
|
+
* Build a request envelope. A `requestId` is generated with
|
|
10
|
+
* `crypto.randomUUID()` when not supplied; clients should keep it stable
|
|
11
|
+
* across retries so the gateway can deduplicate.
|
|
12
|
+
*/
|
|
13
|
+
export function createEnvelope(type, payload, requestId) {
|
|
14
|
+
return {
|
|
15
|
+
protocolVersion: WIRE_VERSION,
|
|
16
|
+
requestId: requestId ?? randomUUID(),
|
|
17
|
+
type,
|
|
18
|
+
payload,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function isRecord(value) {
|
|
22
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Validate a raw value as an envelope. Accepts parsed JSON (objects) or a
|
|
26
|
+
* JSON string. Throws {@link ProtocolError} with code:
|
|
27
|
+
* - INVALID_ENVELOPE: not an object, or missing/invalid `requestId` / `type` / `payload`.
|
|
28
|
+
* - VERSION_MISMATCH: `protocolVersion` present but not equal to {@link WIRE_VERSION}.
|
|
29
|
+
*/
|
|
30
|
+
export function parseEnvelope(raw) {
|
|
31
|
+
let value = raw;
|
|
32
|
+
if (typeof raw === "string") {
|
|
33
|
+
try {
|
|
34
|
+
value = JSON.parse(raw);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw new ProtocolError("INVALID_ENVELOPE", "Envelope is not valid JSON");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!isRecord(value)) {
|
|
41
|
+
throw new ProtocolError("INVALID_ENVELOPE", "Envelope must be an object");
|
|
42
|
+
}
|
|
43
|
+
if (value.protocolVersion !== WIRE_VERSION) {
|
|
44
|
+
throw new ProtocolError("VERSION_MISMATCH", `Unsupported protocol version: expected ${WIRE_VERSION}, got ${String(value.protocolVersion)}`, { expected: WIRE_VERSION, received: value.protocolVersion });
|
|
45
|
+
}
|
|
46
|
+
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
47
|
+
throw new ProtocolError("INVALID_ENVELOPE", "Envelope must have a non-empty string requestId");
|
|
48
|
+
}
|
|
49
|
+
if (typeof value.type !== "string" || value.type.length === 0) {
|
|
50
|
+
throw new ProtocolError("INVALID_ENVELOPE", "Envelope must have a non-empty string type");
|
|
51
|
+
}
|
|
52
|
+
if (!("payload" in value)) {
|
|
53
|
+
throw new ProtocolError("INVALID_ENVELOPE", "Envelope must have a payload");
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
protocolVersion: WIRE_VERSION,
|
|
57
|
+
requestId: value.requestId,
|
|
58
|
+
type: value.type,
|
|
59
|
+
payload: value.payload,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol-level errors shared by every command/event parser in this package.
|
|
3
|
+
*
|
|
4
|
+
* Every parse helper throws {@link ProtocolError} on invalid input so that
|
|
5
|
+
* callers (gateway server, web client) only have to handle one error type.
|
|
6
|
+
*/
|
|
7
|
+
/** Machine-readable protocol error codes. Additive-first: new codes are added, never renamed. */
|
|
8
|
+
export type ProtocolErrorCode = "INVALID_ENVELOPE" | "UNKNOWN_COMMAND" | "INVALID_PAYLOAD" | "INVALID_EVENT" | "VERSION_MISMATCH" | "NOT_CONFIGURED" | "SESSION_NOT_FOUND";
|
|
9
|
+
export declare class ProtocolError extends Error {
|
|
10
|
+
readonly code: ProtocolErrorCode;
|
|
11
|
+
readonly details?: unknown;
|
|
12
|
+
constructor(code: ProtocolErrorCode, message: string, details?: unknown);
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol-level errors shared by every command/event parser in this package.
|
|
3
|
+
*
|
|
4
|
+
* Every parse helper throws {@link ProtocolError} on invalid input so that
|
|
5
|
+
* callers (gateway server, web client) only have to handle one error type.
|
|
6
|
+
*/
|
|
7
|
+
export class ProtocolError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
details;
|
|
10
|
+
constructor(code, message, details) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "ProtocolError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.details = details;
|
|
15
|
+
}
|
|
16
|
+
}
|