@elizaos/agent 0.25.8 → 2.0.0-alpha.83
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/LICENSE +1 -1
- package/package.json +994 -34
- package/packages/agent/src/actions/emote.d.ts +14 -0
- package/packages/agent/src/actions/emote.d.ts.map +1 -0
- package/packages/agent/src/actions/emote.js +91 -0
- package/packages/agent/src/actions/restart.d.ts +19 -0
- package/packages/agent/src/actions/restart.d.ts.map +1 -0
- package/packages/agent/src/actions/restart.js +86 -0
- package/packages/agent/src/actions/send-message.d.ts +3 -0
- package/packages/agent/src/actions/send-message.d.ts.map +1 -0
- package/packages/agent/src/actions/send-message.js +144 -0
- package/packages/agent/src/actions/stream-control.d.ts +15 -0
- package/packages/agent/src/actions/stream-control.d.ts.map +1 -0
- package/packages/agent/src/actions/stream-control.js +357 -0
- package/packages/agent/src/actions/switch-stream-source.d.ts +16 -0
- package/packages/agent/src/actions/switch-stream-source.d.ts.map +1 -0
- package/packages/agent/src/actions/switch-stream-source.js +94 -0
- package/packages/agent/src/actions/terminal.d.ts +14 -0
- package/packages/agent/src/actions/terminal.d.ts.map +1 -0
- package/packages/agent/src/actions/terminal.js +154 -0
- package/packages/agent/src/api/agent-admin-routes.d.ts +38 -0
- package/packages/agent/src/api/agent-admin-routes.d.ts.map +1 -0
- package/packages/agent/src/api/agent-admin-routes.js +93 -0
- package/packages/agent/src/api/agent-lifecycle-routes.d.ts +16 -0
- package/packages/agent/src/api/agent-lifecycle-routes.d.ts.map +1 -0
- package/packages/agent/src/api/agent-lifecycle-routes.js +80 -0
- package/packages/agent/src/api/agent-model.d.ts +12 -0
- package/packages/agent/src/api/agent-model.d.ts.map +1 -0
- package/packages/agent/src/api/agent-model.js +123 -0
- package/packages/agent/src/api/agent-transfer-routes.d.ts +16 -0
- package/packages/agent/src/api/agent-transfer-routes.d.ts.map +1 -0
- package/packages/agent/src/api/agent-transfer-routes.js +124 -0
- package/packages/agent/src/api/apps-routes.d.ts +19 -0
- package/packages/agent/src/api/apps-routes.d.ts.map +1 -0
- package/packages/agent/src/api/apps-routes.js +128 -0
- package/packages/agent/src/api/auth-routes.d.ts +11 -0
- package/packages/agent/src/api/auth-routes.d.ts.map +1 -0
- package/packages/agent/src/api/auth-routes.js +54 -0
- package/packages/agent/src/api/bsc-trade.d.ts +34 -0
- package/packages/agent/src/api/bsc-trade.d.ts.map +1 -0
- package/packages/agent/src/api/bsc-trade.js +567 -0
- package/packages/agent/src/api/bug-report-routes.d.ts +7 -0
- package/packages/agent/src/api/bug-report-routes.d.ts.map +1 -0
- package/packages/agent/src/api/bug-report-routes.js +124 -0
- package/packages/agent/src/api/character-routes.d.ts +50 -0
- package/packages/agent/src/api/character-routes.d.ts.map +1 -0
- package/packages/agent/src/api/character-routes.js +302 -0
- package/packages/agent/src/api/cloud-billing-routes.d.ts +14 -0
- package/packages/agent/src/api/cloud-billing-routes.d.ts.map +1 -0
- package/packages/agent/src/api/cloud-billing-routes.js +400 -0
- package/packages/agent/src/api/cloud-compat-routes.d.ts +15 -0
- package/packages/agent/src/api/cloud-compat-routes.d.ts.map +1 -0
- package/packages/agent/src/api/cloud-compat-routes.js +131 -0
- package/packages/agent/src/api/cloud-routes.d.ts +62 -0
- package/packages/agent/src/api/cloud-routes.d.ts.map +1 -0
- package/packages/agent/src/api/cloud-routes.js +339 -0
- package/packages/agent/src/api/cloud-status-routes.d.ts +15 -0
- package/packages/agent/src/api/cloud-status-routes.d.ts.map +1 -0
- package/packages/agent/src/api/cloud-status-routes.js +165 -0
- package/packages/agent/src/api/compat-utils.d.ts +49 -0
- package/packages/agent/src/api/compat-utils.d.ts.map +1 -0
- package/packages/agent/src/api/compat-utils.js +126 -0
- package/packages/agent/src/api/connector-health.d.ts +34 -0
- package/packages/agent/src/api/connector-health.d.ts.map +1 -0
- package/packages/agent/src/api/connector-health.js +109 -0
- package/packages/agent/src/api/coordinator-wiring.d.ts +46 -0
- package/packages/agent/src/api/coordinator-wiring.d.ts.map +1 -0
- package/packages/agent/src/api/coordinator-wiring.js +101 -0
- package/packages/agent/src/api/credit-detection.d.ts +9 -0
- package/packages/agent/src/api/credit-detection.d.ts.map +1 -0
- package/packages/agent/src/api/credit-detection.js +41 -0
- package/packages/agent/src/api/database.d.ts +33 -0
- package/packages/agent/src/api/database.d.ts.map +1 -0
- package/packages/agent/src/api/database.js +1019 -0
- package/packages/agent/src/api/diagnostics-routes.d.ts +46 -0
- package/packages/agent/src/api/diagnostics-routes.d.ts.map +1 -0
- package/packages/agent/src/api/diagnostics-routes.js +241 -0
- package/packages/agent/src/api/drop-service.d.ts +26 -0
- package/packages/agent/src/api/drop-service.d.ts.map +1 -0
- package/packages/agent/src/api/drop-service.js +134 -0
- package/packages/agent/src/api/early-logs.d.ts +29 -0
- package/packages/agent/src/api/early-logs.d.ts.map +1 -0
- package/packages/agent/src/api/early-logs.js +96 -0
- package/packages/agent/src/api/http-helpers.d.ts +50 -0
- package/packages/agent/src/api/http-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/http-helpers.js +145 -0
- package/packages/agent/src/api/index.d.ts +61 -0
- package/packages/agent/src/api/index.d.ts.map +1 -0
- package/packages/agent/src/api/index.js +59 -0
- package/packages/agent/src/api/knowledge-routes.d.ts +23 -0
- package/packages/agent/src/api/knowledge-routes.d.ts.map +1 -0
- package/packages/agent/src/api/knowledge-routes.js +931 -0
- package/packages/agent/src/api/knowledge-service-loader.d.ts +51 -0
- package/packages/agent/src/api/knowledge-service-loader.d.ts.map +1 -0
- package/packages/agent/src/api/knowledge-service-loader.js +34 -0
- package/packages/agent/src/api/memory-bounds.d.ts +51 -0
- package/packages/agent/src/api/memory-bounds.d.ts.map +1 -0
- package/packages/agent/src/api/memory-bounds.js +81 -0
- package/packages/agent/src/api/memory-routes.d.ts +9 -0
- package/packages/agent/src/api/memory-routes.d.ts.map +1 -0
- package/packages/agent/src/api/memory-routes.js +241 -0
- package/packages/agent/src/api/merkle-tree.d.ts +90 -0
- package/packages/agent/src/api/merkle-tree.d.ts.map +1 -0
- package/packages/agent/src/api/merkle-tree.js +174 -0
- package/packages/agent/src/api/models-routes.d.ts +14 -0
- package/packages/agent/src/api/models-routes.d.ts.map +1 -0
- package/packages/agent/src/api/models-routes.js +37 -0
- package/packages/agent/src/api/nfa-routes.d.ts +5 -0
- package/packages/agent/src/api/nfa-routes.d.ts.map +1 -0
- package/packages/agent/src/api/nfa-routes.js +125 -0
- package/packages/agent/src/api/og-tracker.d.ts +28 -0
- package/packages/agent/src/api/og-tracker.d.ts.map +1 -0
- package/packages/agent/src/api/og-tracker.js +60 -0
- package/packages/agent/src/api/parse-action-block.d.ts +36 -0
- package/packages/agent/src/api/parse-action-block.d.ts.map +1 -0
- package/packages/agent/src/api/parse-action-block.js +110 -0
- package/packages/agent/src/api/permissions-routes.d.ts +32 -0
- package/packages/agent/src/api/permissions-routes.d.ts.map +1 -0
- package/packages/agent/src/api/permissions-routes.js +149 -0
- package/packages/agent/src/api/plugin-validation.d.ts +86 -0
- package/packages/agent/src/api/plugin-validation.d.ts.map +1 -0
- package/packages/agent/src/api/plugin-validation.js +259 -0
- package/packages/agent/src/api/provider-switch-config.d.ts +37 -0
- package/packages/agent/src/api/provider-switch-config.d.ts.map +1 -0
- package/packages/agent/src/api/provider-switch-config.js +317 -0
- package/packages/agent/src/api/registry-routes.d.ts +26 -0
- package/packages/agent/src/api/registry-routes.d.ts.map +1 -0
- package/packages/agent/src/api/registry-routes.js +90 -0
- package/packages/agent/src/api/registry-service.d.ts +77 -0
- package/packages/agent/src/api/registry-service.d.ts.map +1 -0
- package/packages/agent/src/api/registry-service.js +190 -0
- package/packages/agent/src/api/route-helpers.d.ts +16 -0
- package/packages/agent/src/api/route-helpers.d.ts.map +1 -0
- package/packages/agent/src/api/route-helpers.js +1 -0
- package/packages/agent/src/api/sandbox-routes.d.ts +12 -0
- package/packages/agent/src/api/sandbox-routes.d.ts.map +1 -0
- package/packages/agent/src/api/sandbox-routes.js +1334 -0
- package/packages/agent/src/api/server.d.ts +418 -0
- package/packages/agent/src/api/server.d.ts.map +1 -0
- package/packages/agent/src/api/server.js +13614 -0
- package/packages/agent/src/api/signal-routes.d.ts +39 -0
- package/packages/agent/src/api/signal-routes.d.ts.map +1 -0
- package/packages/agent/src/api/signal-routes.js +168 -0
- package/packages/agent/src/api/stream-persistence.d.ts +64 -0
- package/packages/agent/src/api/stream-persistence.d.ts.map +1 -0
- package/packages/agent/src/api/stream-persistence.js +231 -0
- package/packages/agent/src/api/stream-route-state.d.ts +50 -0
- package/packages/agent/src/api/stream-route-state.d.ts.map +1 -0
- package/packages/agent/src/api/stream-route-state.js +1 -0
- package/packages/agent/src/api/stream-routes.d.ts +45 -0
- package/packages/agent/src/api/stream-routes.d.ts.map +1 -0
- package/packages/agent/src/api/stream-routes.js +809 -0
- package/packages/agent/src/api/stream-voice-routes.d.ts +36 -0
- package/packages/agent/src/api/stream-voice-routes.d.ts.map +1 -0
- package/packages/agent/src/api/stream-voice-routes.js +133 -0
- package/packages/agent/src/api/streaming-text.d.ts +9 -0
- package/packages/agent/src/api/streaming-text.d.ts.map +1 -0
- package/packages/agent/src/api/streaming-text.js +85 -0
- package/packages/agent/src/api/streaming-types.d.ts +30 -0
- package/packages/agent/src/api/streaming-types.d.ts.map +1 -0
- package/packages/agent/src/api/streaming-types.js +1 -0
- package/packages/agent/src/api/subscription-routes.d.ts +20 -0
- package/packages/agent/src/api/subscription-routes.d.ts.map +1 -0
- package/packages/agent/src/api/subscription-routes.js +191 -0
- package/packages/agent/src/api/terminal-run-limits.d.ts +5 -0
- package/packages/agent/src/api/terminal-run-limits.d.ts.map +1 -0
- package/packages/agent/src/api/terminal-run-limits.js +22 -0
- package/packages/agent/src/api/training-backend-check.d.ts +8 -0
- package/packages/agent/src/api/training-backend-check.d.ts.map +1 -0
- package/packages/agent/src/api/training-backend-check.js +28 -0
- package/packages/agent/src/api/training-routes.d.ts +44 -0
- package/packages/agent/src/api/training-routes.d.ts.map +1 -0
- package/packages/agent/src/api/training-routes.js +195 -0
- package/packages/agent/src/api/training-service-like.d.ts +38 -0
- package/packages/agent/src/api/training-service-like.d.ts.map +1 -0
- package/packages/agent/src/api/training-service-like.js +1 -0
- package/packages/agent/src/api/trajectory-routes.d.ts +17 -0
- package/packages/agent/src/api/trajectory-routes.d.ts.map +1 -0
- package/packages/agent/src/api/trajectory-routes.js +405 -0
- package/packages/agent/src/api/trigger-routes.d.ts +72 -0
- package/packages/agent/src/api/trigger-routes.d.ts.map +1 -0
- package/packages/agent/src/api/trigger-routes.js +268 -0
- package/packages/agent/src/api/twitter-verify.d.ts +25 -0
- package/packages/agent/src/api/twitter-verify.d.ts.map +1 -0
- package/packages/agent/src/api/twitter-verify.js +168 -0
- package/packages/agent/src/api/tx-service.d.ts +47 -0
- package/packages/agent/src/api/tx-service.d.ts.map +1 -0
- package/packages/agent/src/api/tx-service.js +156 -0
- package/packages/agent/src/api/wallet-dex-prices.d.ts +43 -0
- package/packages/agent/src/api/wallet-dex-prices.d.ts.map +1 -0
- package/packages/agent/src/api/wallet-dex-prices.js +149 -0
- package/packages/agent/src/api/wallet-evm-balance.d.ts +65 -0
- package/packages/agent/src/api/wallet-evm-balance.d.ts.map +1 -0
- package/packages/agent/src/api/wallet-evm-balance.js +663 -0
- package/packages/agent/src/api/wallet-routes.d.ts +33 -0
- package/packages/agent/src/api/wallet-routes.d.ts.map +1 -0
- package/packages/agent/src/api/wallet-routes.js +292 -0
- package/packages/agent/src/api/wallet-rpc.d.ts +61 -0
- package/packages/agent/src/api/wallet-rpc.d.ts.map +1 -0
- package/packages/agent/src/api/wallet-rpc.js +367 -0
- package/packages/agent/src/api/wallet-trading-profile.d.ts +51 -0
- package/packages/agent/src/api/wallet-trading-profile.d.ts.map +1 -0
- package/packages/agent/src/api/wallet-trading-profile.js +547 -0
- package/packages/agent/src/api/wallet.d.ts +31 -0
- package/packages/agent/src/api/wallet.d.ts.map +1 -0
- package/packages/agent/src/api/wallet.js +513 -0
- package/packages/agent/src/api/whatsapp-routes.d.ts +39 -0
- package/packages/agent/src/api/whatsapp-routes.d.ts.map +1 -0
- package/packages/agent/src/api/whatsapp-routes.js +182 -0
- package/packages/agent/src/api/zip-utils.d.ts +8 -0
- package/packages/agent/src/api/zip-utils.d.ts.map +1 -0
- package/packages/agent/src/api/zip-utils.js +115 -0
- package/packages/agent/src/auth/anthropic.d.ts +25 -0
- package/packages/agent/src/auth/anthropic.d.ts.map +1 -0
- package/packages/agent/src/auth/anthropic.js +40 -0
- package/packages/agent/src/auth/apply-stealth.d.ts +8 -0
- package/packages/agent/src/auth/apply-stealth.d.ts.map +1 -0
- package/packages/agent/src/auth/apply-stealth.js +35 -0
- package/packages/agent/src/auth/claude-code-stealth.d.ts +2 -0
- package/packages/agent/src/auth/claude-code-stealth.d.ts.map +1 -0
- package/packages/agent/src/auth/claude-code-stealth.js +104 -0
- package/packages/agent/src/auth/credentials.d.ts +55 -0
- package/packages/agent/src/auth/credentials.d.ts.map +1 -0
- package/packages/agent/src/auth/credentials.js +182 -0
- package/packages/agent/src/auth/index.d.ts +7 -0
- package/packages/agent/src/auth/index.d.ts.map +1 -0
- package/packages/agent/src/auth/index.js +3 -0
- package/packages/agent/src/auth/openai-codex.d.ts +27 -0
- package/packages/agent/src/auth/openai-codex.d.ts.map +1 -0
- package/packages/agent/src/auth/openai-codex.js +72 -0
- package/packages/agent/src/auth/types.d.ts +18 -0
- package/packages/agent/src/auth/types.d.ts.map +1 -0
- package/packages/agent/src/auth/types.js +8 -0
- package/packages/agent/src/awareness/registry.d.ts +27 -0
- package/packages/agent/src/awareness/registry.d.ts.map +1 -0
- package/packages/agent/src/awareness/registry.js +161 -0
- package/packages/agent/src/benchmark-server.d.ts +2 -0
- package/packages/agent/src/benchmark-server.d.ts.map +1 -0
- package/packages/agent/src/benchmark-server.js +773 -0
- package/packages/agent/src/bin.d.ts +3 -0
- package/packages/agent/src/bin.d.ts.map +1 -0
- package/packages/agent/src/bin.js +6 -0
- package/packages/agent/src/cli/index.d.ts +2 -0
- package/packages/agent/src/cli/index.d.ts.map +1 -0
- package/packages/agent/src/cli/index.js +40 -0
- package/packages/agent/src/cli/parse-duration.d.ts +5 -0
- package/packages/agent/src/cli/parse-duration.d.ts.map +1 -0
- package/packages/agent/src/cli/parse-duration.js +27 -0
- package/packages/agent/src/cloud/auth.d.ts +19 -0
- package/packages/agent/src/cloud/auth.d.ts.map +1 -0
- package/packages/agent/src/cloud/auth.js +107 -0
- package/packages/agent/src/cloud/backup.d.ts +18 -0
- package/packages/agent/src/cloud/backup.d.ts.map +1 -0
- package/packages/agent/src/cloud/backup.js +42 -0
- package/packages/agent/src/cloud/base-url.d.ts +3 -0
- package/packages/agent/src/cloud/base-url.d.ts.map +1 -0
- package/packages/agent/src/cloud/base-url.js +40 -0
- package/packages/agent/src/cloud/bridge-client.d.ts +56 -0
- package/packages/agent/src/cloud/bridge-client.d.ts.map +1 -0
- package/packages/agent/src/cloud/bridge-client.js +190 -0
- package/packages/agent/src/cloud/cloud-manager.d.ts +32 -0
- package/packages/agent/src/cloud/cloud-manager.d.ts.map +1 -0
- package/packages/agent/src/cloud/cloud-manager.js +119 -0
- package/packages/agent/src/cloud/cloud-proxy.d.ts +20 -0
- package/packages/agent/src/cloud/cloud-proxy.d.ts.map +1 -0
- package/packages/agent/src/cloud/cloud-proxy.js +34 -0
- package/packages/agent/src/cloud/index.d.ts +7 -0
- package/packages/agent/src/cloud/index.d.ts.map +1 -0
- package/packages/agent/src/cloud/index.js +6 -0
- package/packages/agent/src/cloud/reconnect.d.ts +26 -0
- package/packages/agent/src/cloud/reconnect.d.ts.map +1 -0
- package/packages/agent/src/cloud/reconnect.js +86 -0
- package/packages/agent/src/cloud/validate-url.d.ts +2 -0
- package/packages/agent/src/cloud/validate-url.d.ts.map +1 -0
- package/packages/agent/src/cloud/validate-url.js +162 -0
- package/packages/agent/src/config/character-schema.d.ts +25 -0
- package/packages/agent/src/config/character-schema.d.ts.map +1 -0
- package/packages/agent/src/config/character-schema.js +39 -0
- package/packages/agent/src/config/config.d.ts +6 -0
- package/packages/agent/src/config/config.d.ts.map +1 -0
- package/packages/agent/src/config/config.js +118 -0
- package/packages/agent/src/config/env-vars.d.ts +3 -0
- package/packages/agent/src/config/env-vars.d.ts.map +1 -0
- package/packages/agent/src/config/env-vars.js +76 -0
- package/packages/agent/src/config/includes.d.ts +26 -0
- package/packages/agent/src/config/includes.d.ts.map +1 -0
- package/packages/agent/src/config/includes.js +148 -0
- package/packages/agent/src/config/index.d.ts +16 -0
- package/packages/agent/src/config/index.d.ts.map +1 -0
- package/packages/agent/src/config/index.js +15 -0
- package/packages/agent/src/config/object-utils.d.ts +2 -0
- package/packages/agent/src/config/object-utils.d.ts.map +1 -0
- package/packages/agent/src/config/object-utils.js +6 -0
- package/packages/agent/src/config/paths.d.ts +13 -0
- package/packages/agent/src/config/paths.d.ts.map +1 -0
- package/packages/agent/src/config/paths.js +67 -0
- package/packages/agent/src/config/plugin-auto-enable.d.ts +16 -0
- package/packages/agent/src/config/plugin-auto-enable.d.ts.map +1 -0
- package/packages/agent/src/config/plugin-auto-enable.js +384 -0
- package/packages/agent/src/config/schema.d.ts +87 -0
- package/packages/agent/src/config/schema.d.ts.map +1 -0
- package/packages/agent/src/config/schema.js +928 -0
- package/packages/agent/src/config/telegram-custom-commands.d.ts +25 -0
- package/packages/agent/src/config/telegram-custom-commands.d.ts.map +1 -0
- package/packages/agent/src/config/telegram-custom-commands.js +71 -0
- package/packages/agent/src/config/types.agent-defaults.d.ts +331 -0
- package/packages/agent/src/config/types.agent-defaults.d.ts.map +1 -0
- package/packages/agent/src/config/types.agent-defaults.js +1 -0
- package/packages/agent/src/config/types.agents.d.ts +110 -0
- package/packages/agent/src/config/types.agents.d.ts.map +1 -0
- package/packages/agent/src/config/types.agents.js +1 -0
- package/packages/agent/src/config/types.d.ts +8 -0
- package/packages/agent/src/config/types.d.ts.map +1 -0
- package/packages/agent/src/config/types.eliza.d.ts +636 -0
- package/packages/agent/src/config/types.eliza.d.ts.map +1 -0
- package/packages/agent/src/config/types.eliza.js +1 -0
- package/packages/agent/src/config/types.gateway.d.ts +216 -0
- package/packages/agent/src/config/types.gateway.d.ts.map +1 -0
- package/packages/agent/src/config/types.gateway.js +1 -0
- package/packages/agent/src/config/types.hooks.d.ts +107 -0
- package/packages/agent/src/config/types.hooks.d.ts.map +1 -0
- package/packages/agent/src/config/types.hooks.js +1 -0
- package/packages/agent/src/config/types.js +7 -0
- package/packages/agent/src/config/types.messages.d.ts +176 -0
- package/packages/agent/src/config/types.messages.d.ts.map +1 -0
- package/packages/agent/src/config/types.messages.js +1 -0
- package/packages/agent/src/config/types.tools.d.ts +400 -0
- package/packages/agent/src/config/types.tools.d.ts.map +1 -0
- package/packages/agent/src/config/types.tools.js +1 -0
- package/packages/agent/src/config/zod-schema.agent-runtime.d.ts +1062 -0
- package/packages/agent/src/config/zod-schema.agent-runtime.d.ts.map +1 -0
- package/packages/agent/src/config/zod-schema.agent-runtime.js +721 -0
- package/packages/agent/src/config/zod-schema.core.d.ts +1021 -0
- package/packages/agent/src/config/zod-schema.core.d.ts.map +1 -0
- package/packages/agent/src/config/zod-schema.core.js +694 -0
- package/packages/agent/src/config/zod-schema.d.ts +4817 -0
- package/packages/agent/src/config/zod-schema.d.ts.map +1 -0
- package/packages/agent/src/config/zod-schema.hooks.d.ts +88 -0
- package/packages/agent/src/config/zod-schema.hooks.d.ts.map +1 -0
- package/packages/agent/src/config/zod-schema.hooks.js +133 -0
- package/packages/agent/src/config/zod-schema.js +778 -0
- package/packages/agent/src/config/zod-schema.providers-core.d.ts +2976 -0
- package/packages/agent/src/config/zod-schema.providers-core.d.ts.map +1 -0
- package/packages/agent/src/config/zod-schema.providers-core.js +1006 -0
- package/packages/agent/src/config/zod-schema.session.d.ts +183 -0
- package/packages/agent/src/config/zod-schema.session.d.ts.map +1 -0
- package/packages/agent/src/config/zod-schema.session.js +86 -0
- package/packages/agent/src/contracts/apps.d.ts +42 -0
- package/packages/agent/src/contracts/apps.d.ts.map +1 -0
- package/packages/agent/src/contracts/apps.js +4 -0
- package/packages/agent/src/contracts/awareness.d.ts +38 -0
- package/packages/agent/src/contracts/awareness.d.ts.map +1 -0
- package/packages/agent/src/contracts/awareness.js +7 -0
- package/packages/agent/src/contracts/config.d.ts +146 -0
- package/packages/agent/src/contracts/config.d.ts.map +1 -0
- package/packages/agent/src/contracts/config.js +4 -0
- package/packages/agent/src/contracts/drop.d.ts +20 -0
- package/packages/agent/src/contracts/drop.d.ts.map +1 -0
- package/packages/agent/src/contracts/drop.js +4 -0
- package/packages/agent/src/contracts/index.d.ts +9 -0
- package/packages/agent/src/contracts/index.d.ts.map +1 -0
- package/packages/agent/src/contracts/index.js +8 -0
- package/packages/agent/src/contracts/onboarding.d.ts +379 -0
- package/packages/agent/src/contracts/onboarding.d.ts.map +1 -0
- package/packages/agent/src/contracts/onboarding.js +290 -0
- package/packages/agent/src/contracts/permissions.d.ts +35 -0
- package/packages/agent/src/contracts/permissions.d.ts.map +1 -0
- package/packages/agent/src/contracts/permissions.js +4 -0
- package/packages/agent/src/contracts/verification.d.ts +9 -0
- package/packages/agent/src/contracts/verification.d.ts.map +1 -0
- package/packages/agent/src/contracts/verification.js +4 -0
- package/packages/agent/src/contracts/wallet.d.ts +409 -0
- package/packages/agent/src/contracts/wallet.d.ts.map +1 -0
- package/packages/agent/src/contracts/wallet.js +60 -0
- package/packages/agent/src/diagnostics/integration-observability.d.ts +40 -0
- package/packages/agent/src/diagnostics/integration-observability.d.ts.map +1 -0
- package/packages/agent/src/diagnostics/integration-observability.js +68 -0
- package/packages/agent/src/emotes/catalog.d.ts +31 -0
- package/packages/agent/src/emotes/catalog.d.ts.map +1 -0
- package/packages/agent/src/emotes/catalog.js +618 -0
- package/packages/agent/src/hooks/discovery.d.ts +13 -0
- package/packages/agent/src/hooks/discovery.d.ts.map +1 -0
- package/packages/agent/src/hooks/discovery.js +184 -0
- package/packages/agent/src/hooks/eligibility.d.ts +12 -0
- package/packages/agent/src/hooks/eligibility.d.ts.map +1 -0
- package/packages/agent/src/hooks/eligibility.js +100 -0
- package/packages/agent/src/hooks/index.d.ts +3 -0
- package/packages/agent/src/hooks/index.d.ts.map +1 -0
- package/packages/agent/src/hooks/index.js +2 -0
- package/packages/agent/src/hooks/loader.d.ts +34 -0
- package/packages/agent/src/hooks/loader.d.ts.map +1 -0
- package/packages/agent/src/hooks/loader.js +176 -0
- package/packages/agent/src/hooks/registry.d.ts +11 -0
- package/packages/agent/src/hooks/registry.d.ts.map +1 -0
- package/packages/agent/src/hooks/registry.js +58 -0
- package/packages/agent/src/hooks/types.d.ts +104 -0
- package/packages/agent/src/hooks/types.d.ts.map +1 -0
- package/packages/agent/src/hooks/types.js +8 -0
- package/packages/agent/src/index.d.ts +20 -0
- package/packages/agent/src/index.d.ts.map +1 -0
- package/packages/agent/src/index.js +19 -0
- package/packages/agent/src/onboarding-presets.d.ts +78 -0
- package/packages/agent/src/onboarding-presets.d.ts.map +1 -0
- package/packages/agent/src/onboarding-presets.js +1352 -0
- package/packages/agent/src/plugins/custom-rtmp/index.d.ts +12 -0
- package/packages/agent/src/plugins/custom-rtmp/index.d.ts.map +1 -0
- package/packages/agent/src/plugins/custom-rtmp/index.js +26 -0
- package/packages/agent/src/providers/admin-trust.d.ts +4 -0
- package/packages/agent/src/providers/admin-trust.d.ts.map +1 -0
- package/packages/agent/src/providers/admin-trust.js +53 -0
- package/packages/agent/src/providers/session-bridge.d.ts +24 -0
- package/packages/agent/src/providers/session-bridge.d.ts.map +1 -0
- package/packages/agent/src/providers/session-bridge.js +85 -0
- package/packages/agent/src/providers/session-utils.d.ts +20 -0
- package/packages/agent/src/providers/session-utils.d.ts.map +1 -0
- package/packages/agent/src/providers/session-utils.js +33 -0
- package/packages/agent/src/providers/simple-mode.d.ts +4 -0
- package/packages/agent/src/providers/simple-mode.d.ts.map +1 -0
- package/packages/agent/src/providers/simple-mode.js +85 -0
- package/packages/agent/src/providers/ui-catalog.d.ts +3 -0
- package/packages/agent/src/providers/ui-catalog.d.ts.map +1 -0
- package/packages/agent/src/providers/ui-catalog.js +123 -0
- package/packages/agent/src/providers/workspace-provider.d.ts +22 -0
- package/packages/agent/src/providers/workspace-provider.d.ts.map +1 -0
- package/packages/agent/src/providers/workspace-provider.js +167 -0
- package/packages/agent/src/providers/workspace.d.ts +54 -0
- package/packages/agent/src/providers/workspace.d.ts.map +1 -0
- package/packages/agent/src/providers/workspace.js +405 -0
- package/packages/agent/src/runtime/agent-event-service.d.ts +35 -0
- package/packages/agent/src/runtime/agent-event-service.d.ts.map +1 -0
- package/packages/agent/src/runtime/agent-event-service.js +16 -0
- package/packages/agent/src/runtime/cloud-onboarding.d.ts +55 -0
- package/packages/agent/src/runtime/cloud-onboarding.d.ts.map +1 -0
- package/packages/agent/src/runtime/cloud-onboarding.js +279 -0
- package/packages/agent/src/runtime/core-plugins.d.ts +14 -0
- package/packages/agent/src/runtime/core-plugins.d.ts.map +1 -0
- package/packages/agent/src/runtime/core-plugins.js +51 -0
- package/packages/agent/src/runtime/custom-actions.d.ts +40 -0
- package/packages/agent/src/runtime/custom-actions.d.ts.map +1 -0
- package/packages/agent/src/runtime/custom-actions.js +454 -0
- package/packages/agent/src/runtime/eliza-plugin.d.ts +16 -0
- package/packages/agent/src/runtime/eliza-plugin.d.ts.map +1 -0
- package/packages/agent/src/runtime/eliza-plugin.js +108 -0
- package/packages/agent/src/runtime/eliza.d.ts +205 -0
- package/packages/agent/src/runtime/eliza.d.ts.map +1 -0
- package/packages/agent/src/runtime/eliza.js +3935 -0
- package/packages/agent/src/runtime/embedding-presets.d.ts +19 -0
- package/packages/agent/src/runtime/embedding-presets.d.ts.map +1 -0
- package/packages/agent/src/runtime/embedding-presets.js +53 -0
- package/packages/agent/src/runtime/index.d.ts +9 -0
- package/packages/agent/src/runtime/index.d.ts.map +1 -0
- package/packages/agent/src/runtime/index.js +8 -0
- package/packages/agent/src/runtime/onboarding-names.d.ts +11 -0
- package/packages/agent/src/runtime/onboarding-names.d.ts.map +1 -0
- package/packages/agent/src/runtime/onboarding-names.js +74 -0
- package/packages/agent/src/runtime/release-plugin-policy.d.ts +20 -0
- package/packages/agent/src/runtime/release-plugin-policy.d.ts.map +1 -0
- package/packages/agent/src/runtime/release-plugin-policy.js +87 -0
- package/packages/agent/src/runtime/restart.d.ts +45 -0
- package/packages/agent/src/runtime/restart.d.ts.map +1 -0
- package/packages/agent/src/runtime/restart.js +45 -0
- package/packages/agent/src/runtime/trajectory-persistence.d.ts +214 -0
- package/packages/agent/src/runtime/trajectory-persistence.d.ts.map +1 -0
- package/packages/agent/src/runtime/trajectory-persistence.js +1957 -0
- package/packages/agent/src/runtime/version.d.ts +2 -0
- package/packages/agent/src/runtime/version.d.ts.map +1 -0
- package/packages/agent/src/runtime/version.js +5 -0
- package/packages/agent/src/security/audit-log.d.ts +49 -0
- package/packages/agent/src/security/audit-log.d.ts.map +1 -0
- package/packages/agent/src/security/audit-log.js +161 -0
- package/packages/agent/src/security/network-policy.d.ts +6 -0
- package/packages/agent/src/security/network-policy.d.ts.map +1 -0
- package/packages/agent/src/security/network-policy.js +85 -0
- package/packages/agent/src/server/index.d.ts +3 -0
- package/packages/agent/src/server/index.d.ts.map +1 -0
- package/packages/agent/src/server/index.js +1 -0
- package/packages/agent/src/services/agent-export.d.ts +100 -0
- package/packages/agent/src/services/agent-export.d.ts.map +1 -0
- package/packages/agent/src/services/agent-export.js +729 -0
- package/packages/agent/src/services/app-manager.d.ts +34 -0
- package/packages/agent/src/services/app-manager.d.ts.map +1 -0
- package/packages/agent/src/services/app-manager.js +425 -0
- package/packages/agent/src/services/browser-capture.d.ts +39 -0
- package/packages/agent/src/services/browser-capture.d.ts.map +1 -0
- package/packages/agent/src/services/browser-capture.js +162 -0
- package/packages/agent/src/services/coding-agent-context.d.ts +310 -0
- package/packages/agent/src/services/coding-agent-context.d.ts.map +1 -0
- package/packages/agent/src/services/coding-agent-context.js +281 -0
- package/packages/agent/src/services/fallback-training-service.d.ts +78 -0
- package/packages/agent/src/services/fallback-training-service.d.ts.map +1 -0
- package/packages/agent/src/services/fallback-training-service.js +126 -0
- package/packages/agent/src/services/index.d.ts +18 -0
- package/packages/agent/src/services/index.d.ts.map +1 -0
- package/packages/agent/src/services/index.js +17 -0
- package/packages/agent/src/services/mcp-marketplace.d.ts +89 -0
- package/packages/agent/src/services/mcp-marketplace.d.ts.map +1 -0
- package/packages/agent/src/services/mcp-marketplace.js +200 -0
- package/packages/agent/src/services/plugin-manager-types.d.ts +139 -0
- package/packages/agent/src/services/plugin-manager-types.d.ts.map +1 -0
- package/packages/agent/src/services/plugin-manager-types.js +18 -0
- package/packages/agent/src/services/privy-wallets.d.ts +18 -0
- package/packages/agent/src/services/privy-wallets.d.ts.map +1 -0
- package/packages/agent/src/services/privy-wallets.js +225 -0
- package/packages/agent/src/services/registry-client-app-meta.d.ts +6 -0
- package/packages/agent/src/services/registry-client-app-meta.d.ts.map +1 -0
- package/packages/agent/src/services/registry-client-app-meta.js +147 -0
- package/packages/agent/src/services/registry-client-endpoints.d.ts +7 -0
- package/packages/agent/src/services/registry-client-endpoints.d.ts.map +1 -0
- package/packages/agent/src/services/registry-client-endpoints.js +183 -0
- package/packages/agent/src/services/registry-client-local.d.ts +4 -0
- package/packages/agent/src/services/registry-client-local.d.ts.map +1 -0
- package/packages/agent/src/services/registry-client-local.js +377 -0
- package/packages/agent/src/services/registry-client-network.d.ts +9 -0
- package/packages/agent/src/services/registry-client-network.d.ts.map +1 -0
- package/packages/agent/src/services/registry-client-network.js +109 -0
- package/packages/agent/src/services/registry-client-queries.d.ts +15 -0
- package/packages/agent/src/services/registry-client-queries.d.ts.map +1 -0
- package/packages/agent/src/services/registry-client-queries.js +150 -0
- package/packages/agent/src/services/registry-client-types.d.ts +115 -0
- package/packages/agent/src/services/registry-client-types.d.ts.map +1 -0
- package/packages/agent/src/services/registry-client-types.js +1 -0
- package/packages/agent/src/services/registry-client.d.ts +39 -0
- package/packages/agent/src/services/registry-client.d.ts.map +1 -0
- package/packages/agent/src/services/registry-client.js +249 -0
- package/packages/agent/src/services/remote-signing-service.d.ts +58 -0
- package/packages/agent/src/services/remote-signing-service.d.ts.map +1 -0
- package/packages/agent/src/services/remote-signing-service.js +185 -0
- package/packages/agent/src/services/sandbox-engine.d.ts +96 -0
- package/packages/agent/src/services/sandbox-engine.d.ts.map +1 -0
- package/packages/agent/src/services/sandbox-engine.js +604 -0
- package/packages/agent/src/services/sandbox-manager.d.ts +104 -0
- package/packages/agent/src/services/sandbox-manager.d.ts.map +1 -0
- package/packages/agent/src/services/sandbox-manager.js +353 -0
- package/packages/agent/src/services/self-updater.d.ts +21 -0
- package/packages/agent/src/services/self-updater.d.ts.map +1 -0
- package/packages/agent/src/services/self-updater.js +162 -0
- package/packages/agent/src/services/signal-pairing.d.ts +37 -0
- package/packages/agent/src/services/signal-pairing.d.ts.map +1 -0
- package/packages/agent/src/services/signal-pairing.js +124 -0
- package/packages/agent/src/services/signing-policy.d.ts +44 -0
- package/packages/agent/src/services/signing-policy.d.ts.map +1 -0
- package/packages/agent/src/services/signing-policy.js +165 -0
- package/packages/agent/src/services/skill-catalog-client.d.ts +47 -0
- package/packages/agent/src/services/skill-catalog-client.d.ts.map +1 -0
- package/packages/agent/src/services/skill-catalog-client.js +130 -0
- package/packages/agent/src/services/skill-marketplace.d.ts +42 -0
- package/packages/agent/src/services/skill-marketplace.d.ts.map +1 -0
- package/packages/agent/src/services/skill-marketplace.js +680 -0
- package/packages/agent/src/services/stream-manager.d.ts +121 -0
- package/packages/agent/src/services/stream-manager.d.ts.map +1 -0
- package/packages/agent/src/services/stream-manager.js +604 -0
- package/packages/agent/src/services/tts-stream-bridge.d.ts +83 -0
- package/packages/agent/src/services/tts-stream-bridge.d.ts.map +1 -0
- package/packages/agent/src/services/tts-stream-bridge.js +349 -0
- package/packages/agent/src/services/update-checker.d.ts +29 -0
- package/packages/agent/src/services/update-checker.d.ts.map +1 -0
- package/packages/agent/src/services/update-checker.js +134 -0
- package/packages/agent/src/services/version-compat.d.ts +99 -0
- package/packages/agent/src/services/version-compat.d.ts.map +1 -0
- package/packages/agent/src/services/version-compat.js +195 -0
- package/packages/agent/src/services/whatsapp-pairing.d.ts +41 -0
- package/packages/agent/src/services/whatsapp-pairing.d.ts.map +1 -0
- package/packages/agent/src/services/whatsapp-pairing.js +209 -0
- package/packages/agent/src/shared/ui-catalog-prompt.d.ts +52 -0
- package/packages/agent/src/shared/ui-catalog-prompt.d.ts.map +1 -0
- package/packages/agent/src/shared/ui-catalog-prompt.js +1028 -0
- package/packages/agent/src/test-support/process-helpers.d.ts +13 -0
- package/packages/agent/src/test-support/process-helpers.d.ts.map +1 -0
- package/packages/agent/src/test-support/process-helpers.js +23 -0
- package/packages/agent/src/test-support/route-test-helpers.d.ts +37 -0
- package/packages/agent/src/test-support/route-test-helpers.d.ts.map +1 -0
- package/packages/agent/src/test-support/route-test-helpers.js +54 -0
- package/packages/agent/src/test-support/test-helpers.d.ts +77 -0
- package/packages/agent/src/test-support/test-helpers.d.ts.map +1 -0
- package/packages/agent/src/test-support/test-helpers.js +210 -0
- package/packages/agent/src/testing/index.d.ts +4 -0
- package/packages/agent/src/testing/index.d.ts.map +1 -0
- package/packages/agent/src/testing/index.js +3 -0
- package/packages/agent/src/triggers/action.d.ts +3 -0
- package/packages/agent/src/triggers/action.d.ts.map +1 -0
- package/packages/agent/src/triggers/action.js +267 -0
- package/packages/agent/src/triggers/runtime.d.ts +24 -0
- package/packages/agent/src/triggers/runtime.d.ts.map +1 -0
- package/packages/agent/src/triggers/runtime.js +322 -0
- package/packages/agent/src/triggers/scheduling.d.ts +70 -0
- package/packages/agent/src/triggers/scheduling.d.ts.map +1 -0
- package/packages/agent/src/triggers/scheduling.js +355 -0
- package/packages/agent/src/triggers/types.d.ts +115 -0
- package/packages/agent/src/triggers/types.d.ts.map +1 -0
- package/packages/agent/src/triggers/types.js +1 -0
- package/packages/agent/src/utils/exec-safety.d.ts +2 -0
- package/packages/agent/src/utils/exec-safety.d.ts.map +1 -0
- package/packages/agent/src/utils/exec-safety.js +21 -0
- package/packages/agent/src/utils/number-parsing.d.ts +26 -0
- package/packages/agent/src/utils/number-parsing.d.ts.map +1 -0
- package/packages/agent/src/utils/number-parsing.js +52 -0
- package/packages/agent/src/utils/spoken-text.d.ts +2 -0
- package/packages/agent/src/utils/spoken-text.d.ts.map +1 -0
- package/packages/agent/src/utils/spoken-text.js +56 -0
- package/packages/agent/src/version-resolver.d.ts +3 -0
- package/packages/agent/src/version-resolver.d.ts.map +1 -0
- package/packages/agent/src/version-resolver.js +51 -0
- package/jest.config.js +0 -17
- package/src/__tests__/client-type-identification.test.ts +0 -59
- package/src/defaultCharacter.ts +0 -530
- package/src/index.ts +0 -865
- package/tsconfig.json +0 -16
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream Manager — cross-platform RTMP streaming via FFmpeg.
|
|
3
|
+
*
|
|
4
|
+
* Supports multiple input modes:
|
|
5
|
+
* - "pipe": Receives JPEG frames via writeFrame() → FFmpeg stdin (image2pipe).
|
|
6
|
+
* Used for streaming desktop window contents captured by the host bridge.
|
|
7
|
+
* - "avfoundation" / "screen": macOS native screen capture.
|
|
8
|
+
* - "x11grab": Linux virtual display capture (Xvfb). Like Hyperscape's approach.
|
|
9
|
+
* - "file": Reads a continuously-updated JPEG file (browser-capture).
|
|
10
|
+
* - "testsrc": Solid color test pattern (default fallback).
|
|
11
|
+
*
|
|
12
|
+
* Audio support:
|
|
13
|
+
* - "silent": Synthetic silent audio (anullsrc) — default.
|
|
14
|
+
* - "system": System/desktop audio capture.
|
|
15
|
+
* - "microphone": Microphone input.
|
|
16
|
+
* - File path: Play an audio file as stream audio.
|
|
17
|
+
*
|
|
18
|
+
* Volume control:
|
|
19
|
+
* - setVolume(0-100), mute(), unmute() — restarts FFmpeg to apply.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* import { streamManager } from "./services/stream-manager";
|
|
23
|
+
* await streamManager.start({ rtmpUrl, rtmpKey, inputMode: "pipe" });
|
|
24
|
+
* streamManager.writeFrame(jpegBuffer); // called from frame capture
|
|
25
|
+
* streamManager.setVolume(50); // adjust volume mid-stream
|
|
26
|
+
* await streamManager.stop();
|
|
27
|
+
*
|
|
28
|
+
* @module services/stream-manager
|
|
29
|
+
*/
|
|
30
|
+
import { execSync, spawn } from "node:child_process";
|
|
31
|
+
import { logger } from "@elizaos/core";
|
|
32
|
+
import { ttsStreamBridge } from "./tts-stream-bridge";
|
|
33
|
+
const TAG = "[StreamManager]";
|
|
34
|
+
class StreamManager {
|
|
35
|
+
ffmpeg = null;
|
|
36
|
+
_running = false;
|
|
37
|
+
startedAt = null;
|
|
38
|
+
_frameCount = 0;
|
|
39
|
+
/** Current stream config — stored for restart on volume/audio changes. */
|
|
40
|
+
_config = null;
|
|
41
|
+
/** Current volume level (0–100). */
|
|
42
|
+
_volume = 80;
|
|
43
|
+
/** Whether audio is muted. */
|
|
44
|
+
_muted = false;
|
|
45
|
+
/** Auto-restart state. */
|
|
46
|
+
_restartAttempts = 0;
|
|
47
|
+
_maxRestartAttempts = 5;
|
|
48
|
+
_restartDecayTimer = null;
|
|
49
|
+
_intentionalStop = false;
|
|
50
|
+
/** Pending auto-restart timer — cleared in stop() to prevent races. */
|
|
51
|
+
_restartTimer = null;
|
|
52
|
+
/** Guard: prevents concurrent start() calls from orphaning FFmpeg. */
|
|
53
|
+
_starting = false;
|
|
54
|
+
isRunning() {
|
|
55
|
+
return this._running;
|
|
56
|
+
}
|
|
57
|
+
getUptime() {
|
|
58
|
+
if (!this.startedAt)
|
|
59
|
+
return 0;
|
|
60
|
+
return Math.floor((Date.now() - this.startedAt) / 1000);
|
|
61
|
+
}
|
|
62
|
+
getHealth() {
|
|
63
|
+
return {
|
|
64
|
+
running: this._running,
|
|
65
|
+
ffmpegAlive: this.ffmpeg !== null &&
|
|
66
|
+
this.ffmpeg.exitCode === null &&
|
|
67
|
+
!this.ffmpeg.killed,
|
|
68
|
+
uptime: this.getUptime(),
|
|
69
|
+
frameCount: this._frameCount,
|
|
70
|
+
volume: this._volume,
|
|
71
|
+
muted: this._muted,
|
|
72
|
+
audioSource: this._config?.audioSource || "silent",
|
|
73
|
+
inputMode: this._config?.inputMode || null,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
getVolume() {
|
|
77
|
+
return this._muted ? 0 : this._volume;
|
|
78
|
+
}
|
|
79
|
+
isMuted() {
|
|
80
|
+
return this._muted;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Set volume (0–100). Restarts FFmpeg if currently streaming to apply the change.
|
|
84
|
+
*/
|
|
85
|
+
async setVolume(level) {
|
|
86
|
+
this._volume = Math.max(0, Math.min(100, Math.round(level)));
|
|
87
|
+
logger.info(`${TAG} Volume set to ${this._volume}`);
|
|
88
|
+
if (this._running && this._config) {
|
|
89
|
+
await this.restart();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Mute audio. Restarts FFmpeg if currently streaming. */
|
|
93
|
+
async mute() {
|
|
94
|
+
if (this._muted)
|
|
95
|
+
return;
|
|
96
|
+
this._muted = true;
|
|
97
|
+
logger.info(`${TAG} Audio muted`);
|
|
98
|
+
if (this._running && this._config) {
|
|
99
|
+
await this.restart();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** Unmute audio. Restarts FFmpeg if currently streaming. */
|
|
103
|
+
async unmute() {
|
|
104
|
+
if (!this._muted)
|
|
105
|
+
return;
|
|
106
|
+
this._muted = false;
|
|
107
|
+
logger.info(`${TAG} Audio unmuted (volume: ${this._volume})`);
|
|
108
|
+
if (this._running && this._config) {
|
|
109
|
+
await this.restart();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Restart the stream with updated config (preserves uptime tracking). */
|
|
113
|
+
async restart() {
|
|
114
|
+
if (!this._config)
|
|
115
|
+
return;
|
|
116
|
+
const savedStartedAt = this.startedAt;
|
|
117
|
+
const savedFrameCount = this._frameCount;
|
|
118
|
+
// Detach TTS bridge before stopping FFmpeg
|
|
119
|
+
ttsStreamBridge.detach();
|
|
120
|
+
// Stop FFmpeg without resetting tracking
|
|
121
|
+
if (this.ffmpeg && !this.ffmpeg.killed && this.ffmpeg.exitCode === null) {
|
|
122
|
+
if (this.ffmpeg.stdin) {
|
|
123
|
+
try {
|
|
124
|
+
this.ffmpeg.stdin.end();
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
/* ignore */
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
this.ffmpeg.kill("SIGTERM");
|
|
131
|
+
await Promise.race([
|
|
132
|
+
new Promise((resolve) => this.ffmpeg?.on("exit", resolve)),
|
|
133
|
+
new Promise((resolve) => setTimeout(resolve, 2000)),
|
|
134
|
+
]);
|
|
135
|
+
if (this.ffmpeg?.exitCode === null) {
|
|
136
|
+
this.ffmpeg.kill("SIGKILL");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
this.ffmpeg = null;
|
|
140
|
+
this._running = false;
|
|
141
|
+
// Restart with current volume/mute applied
|
|
142
|
+
const config = {
|
|
143
|
+
...this._config,
|
|
144
|
+
volume: this._volume,
|
|
145
|
+
muted: this._muted,
|
|
146
|
+
};
|
|
147
|
+
await this.start(config);
|
|
148
|
+
// Restore tracking
|
|
149
|
+
this.startedAt = savedStartedAt;
|
|
150
|
+
this._frameCount = savedFrameCount;
|
|
151
|
+
logger.info(`${TAG} Stream restarted (volume=${this._volume}, muted=${this._muted})`);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Write a JPEG frame to FFmpeg's stdin (only works in "pipe" mode).
|
|
155
|
+
* Returns true if the frame was accepted.
|
|
156
|
+
*/
|
|
157
|
+
writeFrame(jpegData) {
|
|
158
|
+
if (!this._running || !this.ffmpeg || !this.ffmpeg.stdin)
|
|
159
|
+
return false;
|
|
160
|
+
if (this.ffmpeg.killed || this.ffmpeg.exitCode !== null)
|
|
161
|
+
return false;
|
|
162
|
+
try {
|
|
163
|
+
this.ffmpeg.stdin.write(jpegData);
|
|
164
|
+
this._frameCount++;
|
|
165
|
+
if (this._frameCount % 150 === 0) {
|
|
166
|
+
logger.info(`${TAG} Piped ${this._frameCount} frames to FFmpeg`);
|
|
167
|
+
}
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async start(config) {
|
|
175
|
+
if (this._running || this._starting) {
|
|
176
|
+
logger.warn(`${TAG} Already running or starting — stop first`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this._starting = true;
|
|
180
|
+
try {
|
|
181
|
+
await this._startInner(config);
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
this._starting = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async _startInner(config) {
|
|
188
|
+
// Pre-flight: ensure FFmpeg is installed
|
|
189
|
+
try {
|
|
190
|
+
execSync("ffmpeg -version", { stdio: "ignore", timeout: 5000 });
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
const installHint = process.platform === "darwin"
|
|
194
|
+
? "Install with: brew install ffmpeg"
|
|
195
|
+
: process.platform === "linux"
|
|
196
|
+
? "Install with: sudo apt install ffmpeg (or your distro's package manager)"
|
|
197
|
+
: "Download from https://ffmpeg.org/download.html";
|
|
198
|
+
throw new Error(`FFmpeg not found. Streaming requires FFmpeg to be installed.\n${installHint}`);
|
|
199
|
+
}
|
|
200
|
+
this._config = config;
|
|
201
|
+
this._frameCount = 0;
|
|
202
|
+
this._volume = config.volume ?? this._volume;
|
|
203
|
+
this._muted = config.muted ?? this._muted;
|
|
204
|
+
const resolution = config.resolution || "1280x720";
|
|
205
|
+
const bitrate = config.bitrate || "2500k";
|
|
206
|
+
const framerate = config.framerate || 15;
|
|
207
|
+
const rtmpTarget = `${config.rtmpUrl}/${config.rtmpKey}`;
|
|
208
|
+
const bufsize = `${parseInt(bitrate, 10) * 2}k`;
|
|
209
|
+
const mode = config.inputMode || "testsrc";
|
|
210
|
+
// Build FFmpeg args based on input mode
|
|
211
|
+
const videoInputArgs = this.buildVideoInputArgs(config, resolution, framerate);
|
|
212
|
+
const audioInputArgs = this.buildAudioInputArgs(config);
|
|
213
|
+
const isPipe = mode === "pipe";
|
|
214
|
+
const isScreenCapture = mode === "avfoundation" || mode === "screen" || mode === "x11grab";
|
|
215
|
+
// Effective volume: 0 when muted, otherwise 0–1.0 scale
|
|
216
|
+
const effectiveVolume = this._muted ? 0 : this._volume / 100;
|
|
217
|
+
// FFmpeg arg order: all inputs first, then filters, then encoding/output
|
|
218
|
+
const ffmpegArgs = [
|
|
219
|
+
"-thread_queue_size",
|
|
220
|
+
"512",
|
|
221
|
+
// Video input
|
|
222
|
+
...videoInputArgs,
|
|
223
|
+
// Audio input
|
|
224
|
+
...audioInputArgs,
|
|
225
|
+
// Video filter: scale for screen capture modes
|
|
226
|
+
...(isScreenCapture
|
|
227
|
+
? ["-vf", `scale=${resolution.replace("x", ":")}:flags=fast_bilinear`]
|
|
228
|
+
: []),
|
|
229
|
+
// Audio filter: volume control
|
|
230
|
+
"-af",
|
|
231
|
+
`volume=${effectiveVolume.toFixed(2)}`,
|
|
232
|
+
// Video encoding (platform-specific)
|
|
233
|
+
...(process.platform === "darwin"
|
|
234
|
+
? [
|
|
235
|
+
"-c:v",
|
|
236
|
+
"h264_videotoolbox",
|
|
237
|
+
"-realtime",
|
|
238
|
+
"1",
|
|
239
|
+
"-b:v",
|
|
240
|
+
bitrate,
|
|
241
|
+
"-maxrate",
|
|
242
|
+
bitrate,
|
|
243
|
+
"-bufsize",
|
|
244
|
+
bufsize,
|
|
245
|
+
]
|
|
246
|
+
: [
|
|
247
|
+
"-c:v",
|
|
248
|
+
"libx264",
|
|
249
|
+
"-preset",
|
|
250
|
+
"veryfast",
|
|
251
|
+
"-tune",
|
|
252
|
+
"zerolatency",
|
|
253
|
+
"-b:v",
|
|
254
|
+
bitrate,
|
|
255
|
+
"-maxrate",
|
|
256
|
+
bitrate,
|
|
257
|
+
"-bufsize",
|
|
258
|
+
bufsize,
|
|
259
|
+
]),
|
|
260
|
+
"-s",
|
|
261
|
+
resolution,
|
|
262
|
+
"-pix_fmt",
|
|
263
|
+
"yuv420p",
|
|
264
|
+
"-g",
|
|
265
|
+
"60",
|
|
266
|
+
// Audio encoding
|
|
267
|
+
"-c:a",
|
|
268
|
+
"aac",
|
|
269
|
+
"-b:a",
|
|
270
|
+
"128k",
|
|
271
|
+
// Output
|
|
272
|
+
"-f",
|
|
273
|
+
"flv",
|
|
274
|
+
rtmpTarget,
|
|
275
|
+
];
|
|
276
|
+
const audioSrc = config.audioSource || "silent";
|
|
277
|
+
logger.info(`${TAG} Starting FFmpeg RTMP stream (video=${mode}, audio=${audioSrc}, vol=${this._volume}${this._muted ? " MUTED" : ""}) → ${config.rtmpUrl}`);
|
|
278
|
+
logger.info(`${TAG} Resolution: ${resolution}, Bitrate: ${bitrate}, FPS: ${framerate}`);
|
|
279
|
+
const isTts = (config.audioSource || "silent") === "tts";
|
|
280
|
+
// In pipe mode, FFmpeg reads from stdin; otherwise stdin is ignored.
|
|
281
|
+
// TTS mode adds a 4th stdio fd (pipe:3) for raw PCM audio input.
|
|
282
|
+
this.ffmpeg = spawn("ffmpeg", ["-y", ...ffmpegArgs], {
|
|
283
|
+
stdio: [
|
|
284
|
+
isPipe ? "pipe" : "ignore",
|
|
285
|
+
"pipe",
|
|
286
|
+
"pipe",
|
|
287
|
+
...(isTts ? ["pipe"] : []),
|
|
288
|
+
],
|
|
289
|
+
});
|
|
290
|
+
// Log all FFmpeg stderr for debugging
|
|
291
|
+
this.ffmpeg.stderr?.on("data", (chunk) => {
|
|
292
|
+
const line = chunk.toString().trim();
|
|
293
|
+
if (line) {
|
|
294
|
+
console.log(`[FFmpeg] ${line}`);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
this.ffmpeg.on("exit", (code, signal) => {
|
|
298
|
+
if (this._running) {
|
|
299
|
+
logger.warn(`${TAG} FFmpeg exited unexpectedly (code=${code}, signal=${signal})`);
|
|
300
|
+
this._running = false;
|
|
301
|
+
if (!this._intentionalStop && this._config) {
|
|
302
|
+
this.autoRestart();
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
this.startedAt = null;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
// Handle stdin errors gracefully in pipe mode
|
|
310
|
+
if (isPipe && this.ffmpeg.stdin) {
|
|
311
|
+
this.ffmpeg.stdin.on("error", (err) => {
|
|
312
|
+
logger.warn(`${TAG} FFmpeg stdin error: ${err.message}`);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
// Attach TTS bridge to pipe:3 for PCM audio
|
|
316
|
+
if (isTts && this.ffmpeg.stdio[3]) {
|
|
317
|
+
const pipe3 = this.ffmpeg.stdio[3];
|
|
318
|
+
ttsStreamBridge.attach(pipe3);
|
|
319
|
+
logger.info(`${TAG} TTS bridge attached to pipe:3`);
|
|
320
|
+
}
|
|
321
|
+
// Wait a moment to confirm it started
|
|
322
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
323
|
+
if (this.ffmpeg.exitCode !== null) {
|
|
324
|
+
const exitCode = this.ffmpeg.exitCode;
|
|
325
|
+
this.ffmpeg = null;
|
|
326
|
+
throw new Error(`${TAG} FFmpeg exited immediately with code ${exitCode}`);
|
|
327
|
+
}
|
|
328
|
+
this._running = true;
|
|
329
|
+
this.startedAt = Date.now();
|
|
330
|
+
this._intentionalStop = false;
|
|
331
|
+
// Decay restart counter every 30s of healthy running
|
|
332
|
+
if (this._restartDecayTimer)
|
|
333
|
+
clearInterval(this._restartDecayTimer);
|
|
334
|
+
this._restartDecayTimer = setInterval(() => {
|
|
335
|
+
if (this._restartAttempts > 0) {
|
|
336
|
+
this._restartAttempts = Math.max(0, this._restartAttempts - 1);
|
|
337
|
+
logger.info(`${TAG} Restart counter decayed to ${this._restartAttempts}`);
|
|
338
|
+
}
|
|
339
|
+
}, 30_000);
|
|
340
|
+
logger.info(`${TAG} FFmpeg streaming to RTMP — stream should be live`);
|
|
341
|
+
}
|
|
342
|
+
async stop() {
|
|
343
|
+
const uptime = this.getUptime();
|
|
344
|
+
const frames = this._frameCount;
|
|
345
|
+
// Detach TTS bridge before killing FFmpeg
|
|
346
|
+
ttsStreamBridge.detach();
|
|
347
|
+
if (this.ffmpeg && !this.ffmpeg.killed && this.ffmpeg.exitCode === null) {
|
|
348
|
+
const ffmpegProc = this.ffmpeg;
|
|
349
|
+
// Close stdin first in pipe mode to signal EOF
|
|
350
|
+
if (ffmpegProc.stdin) {
|
|
351
|
+
try {
|
|
352
|
+
ffmpegProc.stdin.end();
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
/* ignore */
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
ffmpegProc.kill("SIGTERM");
|
|
359
|
+
await Promise.race([
|
|
360
|
+
new Promise((resolve) => ffmpegProc.on("exit", resolve)),
|
|
361
|
+
new Promise((resolve) => setTimeout(resolve, 3000)),
|
|
362
|
+
]);
|
|
363
|
+
if (ffmpegProc.exitCode === null) {
|
|
364
|
+
ffmpegProc.kill("SIGKILL");
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
this._intentionalStop = true;
|
|
368
|
+
if (this._restartTimer) {
|
|
369
|
+
clearTimeout(this._restartTimer);
|
|
370
|
+
this._restartTimer = null;
|
|
371
|
+
}
|
|
372
|
+
if (this._restartDecayTimer) {
|
|
373
|
+
clearInterval(this._restartDecayTimer);
|
|
374
|
+
this._restartDecayTimer = null;
|
|
375
|
+
}
|
|
376
|
+
this.ffmpeg = null;
|
|
377
|
+
this._running = false;
|
|
378
|
+
this.startedAt = null;
|
|
379
|
+
this._frameCount = 0;
|
|
380
|
+
this._restartAttempts = 0;
|
|
381
|
+
this._config = null;
|
|
382
|
+
logger.info(`${TAG} Stream stopped (uptime: ${uptime}s, frames: ${frames})`);
|
|
383
|
+
return { uptime };
|
|
384
|
+
}
|
|
385
|
+
/** Attempt to restart FFmpeg after unexpected exit with exponential backoff. */
|
|
386
|
+
autoRestart() {
|
|
387
|
+
if (this._restartAttempts >= this._maxRestartAttempts) {
|
|
388
|
+
logger.error(`${TAG} Max restart attempts (${this._maxRestartAttempts}) reached — giving up`);
|
|
389
|
+
this.startedAt = null;
|
|
390
|
+
if (this._restartDecayTimer) {
|
|
391
|
+
clearInterval(this._restartDecayTimer);
|
|
392
|
+
this._restartDecayTimer = null;
|
|
393
|
+
}
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
this._restartAttempts++;
|
|
397
|
+
const delay = Math.min(1000 * 2 ** (this._restartAttempts - 1), 60_000);
|
|
398
|
+
logger.info(`${TAG} Auto-restart attempt ${this._restartAttempts}/${this._maxRestartAttempts} in ${delay}ms`);
|
|
399
|
+
this._restartTimer = setTimeout(async () => {
|
|
400
|
+
this._restartTimer = null;
|
|
401
|
+
if (this._intentionalStop || !this._config)
|
|
402
|
+
return;
|
|
403
|
+
const savedStartedAt = this.startedAt;
|
|
404
|
+
const savedFrameCount = this._frameCount;
|
|
405
|
+
try {
|
|
406
|
+
this.ffmpeg = null;
|
|
407
|
+
await this.start({
|
|
408
|
+
...this._config,
|
|
409
|
+
volume: this._volume,
|
|
410
|
+
muted: this._muted,
|
|
411
|
+
});
|
|
412
|
+
// Restore tracking so uptime is continuous
|
|
413
|
+
this.startedAt = savedStartedAt;
|
|
414
|
+
this._frameCount = savedFrameCount;
|
|
415
|
+
logger.info(`${TAG} Auto-restart successful`);
|
|
416
|
+
}
|
|
417
|
+
catch (err) {
|
|
418
|
+
logger.error(`${TAG} Auto-restart failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
419
|
+
// start() failed before spawning FFmpeg — no exit event will fire,
|
|
420
|
+
// so manually chain the next restart attempt if retries remain.
|
|
421
|
+
if (!this._intentionalStop && this._config) {
|
|
422
|
+
this.autoRestart();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}, delay);
|
|
426
|
+
}
|
|
427
|
+
// ---------------------------------------------------------------------------
|
|
428
|
+
// Video input args
|
|
429
|
+
// ---------------------------------------------------------------------------
|
|
430
|
+
buildVideoInputArgs(config, resolution, framerate) {
|
|
431
|
+
const mode = config.inputMode || "testsrc";
|
|
432
|
+
switch (mode) {
|
|
433
|
+
case "pipe": {
|
|
434
|
+
// Read JPEG frames from stdin via image2pipe.
|
|
435
|
+
// -c:v mjpeg is mandatory: image2pipe cannot auto-detect JPEG from piped data.
|
|
436
|
+
// -probesize/-analyzeduration eliminate the default 5MB probe buffer that
|
|
437
|
+
// causes FFmpeg to stall for ~100 frames before decoding starts.
|
|
438
|
+
return [
|
|
439
|
+
"-probesize",
|
|
440
|
+
"32",
|
|
441
|
+
"-analyzeduration",
|
|
442
|
+
"0",
|
|
443
|
+
"-f",
|
|
444
|
+
"image2pipe",
|
|
445
|
+
"-c:v",
|
|
446
|
+
"mjpeg",
|
|
447
|
+
"-framerate",
|
|
448
|
+
String(framerate),
|
|
449
|
+
"-i",
|
|
450
|
+
"pipe:0",
|
|
451
|
+
];
|
|
452
|
+
}
|
|
453
|
+
case "avfoundation":
|
|
454
|
+
case "screen": {
|
|
455
|
+
// macOS native screen capture via avfoundation.
|
|
456
|
+
// videoDevice "3" = Capture screen 0; ":none" = no audio from avfoundation.
|
|
457
|
+
const videoDevice = config.videoDevice || "3";
|
|
458
|
+
return [
|
|
459
|
+
"-f",
|
|
460
|
+
"avfoundation",
|
|
461
|
+
"-framerate",
|
|
462
|
+
String(framerate),
|
|
463
|
+
"-pixel_format",
|
|
464
|
+
"nv12",
|
|
465
|
+
"-capture_cursor",
|
|
466
|
+
"1",
|
|
467
|
+
"-i",
|
|
468
|
+
`${videoDevice}:none`,
|
|
469
|
+
];
|
|
470
|
+
}
|
|
471
|
+
case "x11grab": {
|
|
472
|
+
// Linux virtual display capture (Xvfb) — the Hyperscape approach.
|
|
473
|
+
// Requires: Xvfb :99 -screen 0 1280x720x24 -ac &
|
|
474
|
+
// Then run a browser/TUI on display :99.
|
|
475
|
+
const display = config.display || ":99";
|
|
476
|
+
return [
|
|
477
|
+
"-f",
|
|
478
|
+
"x11grab",
|
|
479
|
+
"-video_size",
|
|
480
|
+
resolution,
|
|
481
|
+
"-framerate",
|
|
482
|
+
String(framerate),
|
|
483
|
+
"-draw_mouse",
|
|
484
|
+
"0",
|
|
485
|
+
"-i",
|
|
486
|
+
display,
|
|
487
|
+
];
|
|
488
|
+
}
|
|
489
|
+
case "file": {
|
|
490
|
+
// Read from a continuously-updated JPEG file (written by browser-capture).
|
|
491
|
+
const framePath = config.frameFile || "/tmp/eliza-stream-frame.jpg";
|
|
492
|
+
return [
|
|
493
|
+
"-probesize",
|
|
494
|
+
"32",
|
|
495
|
+
"-analyzeduration",
|
|
496
|
+
"0",
|
|
497
|
+
"-loop",
|
|
498
|
+
"1",
|
|
499
|
+
"-f",
|
|
500
|
+
"image2",
|
|
501
|
+
"-c:v",
|
|
502
|
+
"mjpeg",
|
|
503
|
+
"-framerate",
|
|
504
|
+
String(framerate),
|
|
505
|
+
"-i",
|
|
506
|
+
framePath,
|
|
507
|
+
];
|
|
508
|
+
}
|
|
509
|
+
default: {
|
|
510
|
+
// Solid color test pattern (dark navy)
|
|
511
|
+
return [
|
|
512
|
+
"-f",
|
|
513
|
+
"lavfi",
|
|
514
|
+
"-i",
|
|
515
|
+
`color=c=0x1a1a2e:s=${resolution}:r=${framerate}`,
|
|
516
|
+
];
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
// ---------------------------------------------------------------------------
|
|
521
|
+
// Audio input args
|
|
522
|
+
// ---------------------------------------------------------------------------
|
|
523
|
+
buildAudioInputArgs(config) {
|
|
524
|
+
const source = config.audioSource || "silent";
|
|
525
|
+
switch (source) {
|
|
526
|
+
case "tts": {
|
|
527
|
+
// Raw PCM from TTS bridge via pipe:3 (4th stdio fd).
|
|
528
|
+
// Format must match tts-stream-bridge output: s16le, 24kHz, mono.
|
|
529
|
+
// -use_wallclock_as_timestamps 1: raw PCM has no timestamps, so FFmpeg
|
|
530
|
+
// uses wall-clock time to sync with the video stream.
|
|
531
|
+
// -probesize/-analyzeduration: eliminate probe buffering for immediate start.
|
|
532
|
+
// -thread_queue_size: prevent queue overflow from high-frequency tick writes.
|
|
533
|
+
return [
|
|
534
|
+
"-use_wallclock_as_timestamps",
|
|
535
|
+
"1",
|
|
536
|
+
"-probesize",
|
|
537
|
+
"32",
|
|
538
|
+
"-analyzeduration",
|
|
539
|
+
"0",
|
|
540
|
+
"-thread_queue_size",
|
|
541
|
+
"512",
|
|
542
|
+
"-f",
|
|
543
|
+
"s16le",
|
|
544
|
+
"-ar",
|
|
545
|
+
"24000",
|
|
546
|
+
"-ac",
|
|
547
|
+
"1",
|
|
548
|
+
"-i",
|
|
549
|
+
"pipe:3",
|
|
550
|
+
];
|
|
551
|
+
}
|
|
552
|
+
case "silent": {
|
|
553
|
+
// Synthetic silent audio — always works, no hardware required.
|
|
554
|
+
return [
|
|
555
|
+
"-f",
|
|
556
|
+
"lavfi",
|
|
557
|
+
"-i",
|
|
558
|
+
"anullsrc=channel_layout=stereo:sample_rate=44100",
|
|
559
|
+
];
|
|
560
|
+
}
|
|
561
|
+
case "system": {
|
|
562
|
+
// System/desktop audio capture.
|
|
563
|
+
if (process.platform === "darwin") {
|
|
564
|
+
// macOS: requires BlackHole or similar virtual audio device.
|
|
565
|
+
// audioDevice is the avfoundation audio device index (e.g., "2").
|
|
566
|
+
const device = config.audioDevice || "0";
|
|
567
|
+
return ["-f", "avfoundation", "-i", `none:${device}`];
|
|
568
|
+
}
|
|
569
|
+
// Linux: PulseAudio monitor source captures desktop audio.
|
|
570
|
+
const device = config.audioDevice || "default";
|
|
571
|
+
return ["-f", "pulse", "-i", device];
|
|
572
|
+
}
|
|
573
|
+
case "microphone": {
|
|
574
|
+
// Microphone input.
|
|
575
|
+
if (process.platform === "darwin") {
|
|
576
|
+
const device = config.audioDevice || "0";
|
|
577
|
+
return ["-f", "avfoundation", "-i", `none:${device}`];
|
|
578
|
+
}
|
|
579
|
+
const device = config.audioDevice || "default";
|
|
580
|
+
return ["-f", "pulse", "-i", device];
|
|
581
|
+
}
|
|
582
|
+
default: {
|
|
583
|
+
// Treat as a file path — play audio file as stream audio.
|
|
584
|
+
// Supports mp3, wav, ogg, flac, etc.
|
|
585
|
+
if (source.startsWith("/") || source.startsWith("./")) {
|
|
586
|
+
return ["-stream_loop", "-1", "-i", source];
|
|
587
|
+
}
|
|
588
|
+
// Fallback to silent if source is unrecognized.
|
|
589
|
+
return [
|
|
590
|
+
"-f",
|
|
591
|
+
"lavfi",
|
|
592
|
+
"-i",
|
|
593
|
+
"anullsrc=channel_layout=stereo:sample_rate=44100",
|
|
594
|
+
];
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
/** Get the TTS stream bridge for external speak triggers. */
|
|
599
|
+
getTtsBridge() {
|
|
600
|
+
return ttsStreamBridge;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
// Module singleton
|
|
604
|
+
export const streamManager = new StreamManager();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TTS Stream Bridge — generates TTS audio server-side and pipes PCM data
|
|
3
|
+
* into FFmpeg's audio track for RTMP streaming.
|
|
4
|
+
*
|
|
5
|
+
* Uses pipe:3 (a 4th stdio fd) as the audio input to FFmpeg. Writes PCM
|
|
6
|
+
* silence when idle and decoded TTS audio when speaking. This avoids FIFO
|
|
7
|
+
* complexity and works cross-platform.
|
|
8
|
+
*
|
|
9
|
+
* @module services/tts-stream-bridge
|
|
10
|
+
*/
|
|
11
|
+
import type { Writable } from "node:stream";
|
|
12
|
+
import type { TtsConfig, TtsProvider } from "../config/types.messages";
|
|
13
|
+
/** Resolved TTS configuration for a speak() call. */
|
|
14
|
+
export interface ResolvedTtsConfig {
|
|
15
|
+
provider: TtsProvider;
|
|
16
|
+
elevenlabs?: {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
voiceId: string;
|
|
19
|
+
modelId: string;
|
|
20
|
+
voiceSettings?: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
openai?: {
|
|
23
|
+
apiKey: string;
|
|
24
|
+
model: string;
|
|
25
|
+
voice: string;
|
|
26
|
+
};
|
|
27
|
+
edge?: {
|
|
28
|
+
voice: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Public interface for the TTS stream bridge. */
|
|
32
|
+
export interface ITtsStreamBridge {
|
|
33
|
+
attach(stream: Writable): void;
|
|
34
|
+
detach(): void;
|
|
35
|
+
isAttached(): boolean;
|
|
36
|
+
isSpeaking(): boolean;
|
|
37
|
+
speak(text: string, config: ResolvedTtsConfig): Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
declare class TtsStreamBridge implements ITtsStreamBridge {
|
|
40
|
+
private writeStream;
|
|
41
|
+
private tickTimer;
|
|
42
|
+
private pcmQueue;
|
|
43
|
+
private _speaking;
|
|
44
|
+
private silenceChunk;
|
|
45
|
+
constructor();
|
|
46
|
+
/** Attach the bridge to an FFmpeg stdio pipe (pipe:3). */
|
|
47
|
+
attach(stream: Writable): void;
|
|
48
|
+
/** Detach from FFmpeg — stops tick loop and clears queue. */
|
|
49
|
+
detach(): void;
|
|
50
|
+
/** Whether the bridge is currently attached to an FFmpeg process. */
|
|
51
|
+
isAttached(): boolean;
|
|
52
|
+
/** Whether TTS audio is currently being played. */
|
|
53
|
+
isSpeaking(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Generate TTS for the given text and queue PCM audio for playback.
|
|
56
|
+
* Non-blocking — queues audio and returns immediately after generation.
|
|
57
|
+
*/
|
|
58
|
+
speak(text: string, config: ResolvedTtsConfig): Promise<boolean>;
|
|
59
|
+
/** Called every CHUNK_MS — writes next PCM chunk (TTS or silence) to FFmpeg. */
|
|
60
|
+
private tick;
|
|
61
|
+
private generateTts;
|
|
62
|
+
private generateElevenlabs;
|
|
63
|
+
private generateOpenai;
|
|
64
|
+
private generateEdge;
|
|
65
|
+
/** Decode MP3 audio to raw s16le PCM using an FFmpeg subprocess. */
|
|
66
|
+
private decodeMp3ToPcm;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Resolve TTS configuration from eliza config, finding the best available
|
|
70
|
+
* provider with valid API keys.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveTtsConfig(ttsConfig: TtsConfig | undefined): ResolvedTtsConfig | null;
|
|
73
|
+
/**
|
|
74
|
+
* Get a summary of available TTS providers and their status.
|
|
75
|
+
*/
|
|
76
|
+
export declare function getTtsProviderStatus(ttsConfig: TtsConfig | undefined): {
|
|
77
|
+
configuredProvider: string | null;
|
|
78
|
+
hasApiKey: boolean;
|
|
79
|
+
resolvedProvider: string | null;
|
|
80
|
+
};
|
|
81
|
+
export declare const ttsStreamBridge: TtsStreamBridge;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=tts-stream-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tts-stream-bridge.d.ts","sourceRoot":"","sources":["../../../../../src/services/tts-stream-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAiBvE,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACzC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC/B,MAAM,IAAI,IAAI,CAAC;IACf,UAAU,IAAI,OAAO,CAAC;IACtB,UAAU,IAAI,OAAO,CAAC;IACtB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAClE;AAED,cAAM,eAAgB,YAAW,gBAAgB;IAC/C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,SAAS,CAA+C;IAChE,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAS;;IAO7B,0DAA0D;IAC1D,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI;IAW9B,6DAA6D;IAC7D,MAAM,IAAI,IAAI;IAUd,qEAAqE;IACrE,UAAU,IAAI,OAAO;IAIrB,mDAAmD;IACnD,UAAU,IAAI,OAAO;IAIrB;;;OAGG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;IAgDtE,gFAAgF;IAChF,OAAO,CAAC,IAAI;YAuBE,WAAW;YAgBX,kBAAkB;YAyClB,cAAc;YAoCd,YAAY;IA6B1B,oEAAoE;IACpE,OAAO,CAAC,cAAc;CAgCvB;AAuBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,iBAAiB,GAAG,IAAI,CA2D1B;AAwBD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG;IACtE,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAOA;AAGD,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
|