@poolzin/pool-bot 2026.2.17 → 2026.2.19
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/CHANGELOG.md +25 -0
- package/dist/agents/agent-scope.js +4 -0
- package/dist/agents/announce-idempotency.js +14 -0
- package/dist/agents/auth-profiles.resolve-auth-profile-order.fixtures.js +23 -0
- package/dist/agents/bash-tools.exec-runtime.js +438 -0
- package/dist/agents/bash-tools.shared.js +6 -0
- package/dist/agents/cli-runner/reliability.js +61 -0
- package/dist/agents/cli-watchdog-defaults.js +11 -0
- package/dist/agents/command-poll-backoff.js +63 -0
- package/dist/agents/current-time.js +16 -0
- package/dist/agents/model-alias-lines.js +18 -0
- package/dist/agents/model-auth-label.js +61 -0
- package/dist/agents/models-config.e2e-harness.js +115 -0
- package/dist/agents/ollama-stream.js +11 -3
- package/dist/agents/openclaw-tools.js +135 -0
- package/dist/agents/pi-auth-json.js +118 -0
- package/dist/agents/pi-embedded-runner/run.overflow-compaction.mocks.shared.js +147 -0
- package/dist/agents/pi-embedded-subscribe.e2e-harness.js +90 -0
- package/dist/agents/pi-embedded-subscribe.handlers.compaction.js +63 -0
- package/dist/agents/pi-embedded-subscribe.handlers.tools.media.test-helpers.js +30 -0
- package/dist/agents/pi-extensions/session-manager-runtime-registry.js +23 -0
- package/dist/agents/pi-tools.js +2 -0
- package/dist/agents/queued-file-writer.js +22 -0
- package/dist/agents/sandbox/docker.js +133 -40
- package/dist/agents/sandbox/fs-bridge.js +146 -0
- package/dist/agents/sandbox/fs-paths.js +205 -0
- package/dist/agents/sandbox/hash.js +4 -0
- package/dist/agents/sandbox-paths.js +3 -0
- package/dist/agents/session-dirs.js +20 -0
- package/dist/agents/skills/filter.js +24 -0
- package/dist/agents/skills/tools-dir.js +9 -0
- package/dist/agents/skills-install-download.js +290 -0
- package/dist/agents/skills-install-output.js +30 -0
- package/dist/agents/skills-install.download-test-utils.js +36 -0
- package/dist/agents/skills.e2e-test-helpers.js +13 -0
- package/dist/agents/subagent-announce-queue.js +59 -15
- package/dist/agents/subagent-depth.js +137 -0
- package/dist/agents/subagent-registry.js +448 -96
- package/dist/agents/subagent-spawn.js +262 -0
- package/dist/agents/test-helpers/fast-tool-stubs.js +18 -0
- package/dist/agents/test-helpers/host-sandbox-fs-bridge.js +74 -0
- package/dist/agents/tool-display-common.js +782 -0
- package/dist/agents/tools/image-tool.js +1 -1
- package/dist/agents/tools/sessions-access.js +178 -0
- package/dist/agents/tools/sessions-resolution.js +206 -0
- package/dist/agents/tools/subagents-tool.js +616 -0
- package/dist/agents/workspace-dir.js +18 -0
- package/dist/agents/workspace-dirs.js +14 -0
- package/dist/agents/workspace.js +70 -0
- package/dist/auto-reply/heartbeat-reply-payload.js +18 -0
- package/dist/auto-reply/reply/commands-export-session.js +163 -0
- package/dist/auto-reply/reply/commands-mesh.js +245 -0
- package/dist/auto-reply/reply/commands-setunset.js +28 -0
- package/dist/auto-reply/reply/commands-slash-parse.js +31 -0
- package/dist/auto-reply/reply/commands-system-prompt.js +117 -0
- package/dist/auto-reply/reply/directive-handling.levels.js +17 -0
- package/dist/auto-reply/reply/directive-handling.params.js +1 -0
- package/dist/auto-reply/reply/directive-parsing.js +36 -0
- package/dist/auto-reply/reply/dispatcher-registry.js +43 -0
- package/dist/auto-reply/reply/elevated-unavailable.js +20 -0
- package/dist/auto-reply/reply/reply-delivery.js +92 -0
- package/dist/auto-reply/reply/session-reset-prompt.js +1 -0
- package/dist/auto-reply/reply/session-run-accounting.js +33 -0
- package/dist/auto-reply/reply.directive.directive-behavior.e2e-harness.js +115 -0
- package/dist/auto-reply/reply.directive.directive-behavior.e2e-mocks.js +12 -0
- package/dist/browser/bridge-auth-registry.js +26 -0
- package/dist/browser/client-actions-url.js +10 -0
- package/dist/browser/control-auth.js +73 -0
- package/dist/browser/csrf.js +64 -0
- package/dist/browser/http-auth.js +52 -0
- package/dist/browser/paths.js +37 -0
- package/dist/browser/proxy-files.js +32 -0
- package/dist/browser/pw-ai-state.js +7 -0
- package/dist/browser/resolved-config-refresh.js +42 -0
- package/dist/browser/routes/path-output.js +1 -0
- package/dist/browser/server-context.chrome-test-harness.js +20 -0
- package/dist/browser/server-middleware.js +31 -0
- package/dist/browser/test-port.js +16 -0
- package/dist/build-info.json +3 -3
- package/dist/canvas-host/file-resolver.js +43 -0
- package/dist/channels/account-summary.js +19 -0
- package/dist/channels/draft-stream-loop.js +77 -0
- package/dist/channels/plugins/account-helpers.js +26 -0
- package/dist/channels/telegram/allow-from.js +10 -0
- package/dist/cli/browser-cli-resize.js +22 -0
- package/dist/cli/browser-cli-shared.js +8 -0
- package/dist/cli/clawbot-cli.js +5 -0
- package/dist/cli/completion-cli.js +566 -0
- package/dist/cli/config-cli.js +63 -5
- package/dist/cli/daemon-cli/lifecycle-core.js +256 -0
- package/dist/cli/daemon-cli/register-service-commands.js +60 -0
- package/dist/cli/daemon-cli-compat.js +80 -0
- package/dist/cli/nodes-cli/pairing-render.js +26 -0
- package/dist/cli/program/action-reparse.js +17 -0
- package/dist/cli/program/command-registry.js +17 -0
- package/dist/cli/program/program-context.js +8 -0
- package/dist/cli/program/register.subclis.js +7 -0
- package/dist/cli/program/routes.js +233 -0
- package/dist/cli/qr-cli.js +132 -0
- package/dist/cli/requirements-test-fixtures.js +17 -0
- package/dist/cli/respawn-policy.js +4 -0
- package/dist/cli/shared/parse-port.js +18 -0
- package/dist/cli/skills-cli.format.js +241 -0
- package/dist/cli/update-cli/progress.js +121 -0
- package/dist/cli/update-cli/restart-helper.js +108 -0
- package/dist/cli/update-cli/shared.js +196 -0
- package/dist/cli/update-cli/status.js +97 -0
- package/dist/cli/update-cli/suppress-deprecations.js +17 -0
- package/dist/cli/update-cli/update-command.js +506 -0
- package/dist/cli/update-cli/wizard.js +130 -0
- package/dist/cli/update-cli.js +3 -9
- package/dist/cli/windows-argv.js +69 -0
- package/dist/commands/auth-choice-legacy.js +20 -0
- package/dist/commands/auth-choice.apply-helpers.js +8 -0
- package/dist/commands/channel-test-helpers.js +19 -0
- package/dist/commands/cleanup-plan.js +10 -0
- package/dist/commands/cleanup-utils.js +7 -0
- package/dist/commands/config-validation.js +15 -0
- package/dist/commands/doctor-completion.js +112 -0
- package/dist/commands/doctor-memory-search.js +119 -0
- package/dist/commands/doctor-session-locks.js +73 -0
- package/dist/commands/doctor.e2e-harness.js +364 -0
- package/dist/commands/gateway-presence.js +19 -0
- package/dist/commands/model-default.js +35 -0
- package/dist/commands/models/fallbacks-shared.js +102 -0
- package/dist/commands/models/shared.js +24 -0
- package/dist/commands/onboard-auth.config-gateways.js +64 -0
- package/dist/commands/onboard-auth.config-litellm.js +45 -0
- package/dist/commands/onboard-auth.config-shared.js +116 -0
- package/dist/commands/onboard-config.js +16 -0
- package/dist/commands/onboard-non-interactive.test-helpers.js +31 -0
- package/dist/commands/onboard-provider-auth-flags.js +136 -0
- package/dist/commands/openai-codex-oauth.js +40 -0
- package/dist/commands/test-runtime-config-helpers.js +21 -0
- package/dist/commands/test-wizard-helpers.js +68 -0
- package/dist/commands/vllm-setup.js +66 -0
- package/dist/compat/legacy-names.js +2 -0
- package/dist/config/backup-rotation.js +19 -0
- package/dist/config/env-preserve.js +122 -0
- package/dist/config/includes-scan.js +78 -0
- package/dist/config/plugins-allowlist.js +13 -0
- package/dist/config/schema.help.js +256 -0
- package/dist/config/schema.hints.js +189 -0
- package/dist/config/schema.irc.js +20 -0
- package/dist/config/schema.labels.js +317 -0
- package/dist/config/sessions/delivery-info.js +40 -0
- package/dist/config/types.irc.js +1 -0
- package/dist/config/zod-schema.agent-model.js +10 -0
- package/dist/config/zod-schema.allowdeny.js +35 -0
- package/dist/config/zod-schema.sensitive.js +4 -0
- package/dist/control-ui/assets/index-HRr1grwl.js.map +1 -1
- package/dist/cron/isolated-agent/skills-snapshot.js +26 -0
- package/dist/cron/isolated-agent/subagent-followup.js +127 -0
- package/dist/cron/isolated-agent.mocks.js +12 -0
- package/dist/cron/isolated-agent.test-setup.js +22 -0
- package/dist/cron/legacy-delivery.js +43 -0
- package/dist/cron/webhook-url.js +22 -0
- package/dist/daemon/arg-split.js +40 -0
- package/dist/daemon/exec-file.js +23 -0
- package/dist/daemon/output.js +6 -0
- package/dist/daemon/runtime-format.js +31 -0
- package/dist/daemon/schtasks-exec.js +4 -0
- package/dist/daemon/service-audit.js +22 -0
- package/dist/discord/client.js +41 -0
- package/dist/discord/components-registry.js +57 -0
- package/dist/discord/components.js +816 -0
- package/dist/discord/guilds.js +12 -0
- package/dist/discord/monitor/gateway-plugin.js +48 -0
- package/dist/discord/monitor/presence.js +30 -0
- package/dist/discord/send.components.js +115 -0
- package/dist/discord/send.shared.js +4 -0
- package/dist/discord/ui.js +26 -0
- package/dist/discord/voice-message.js +254 -0
- package/dist/gateway/agent-event-assistant-text.js +5 -0
- package/dist/gateway/agent-prompt.js +33 -0
- package/dist/gateway/auth-rate-limit.js +136 -0
- package/dist/gateway/channel-health-monitor.js +114 -0
- package/dist/gateway/control-ui-contract.js +1 -0
- package/dist/gateway/control-ui-csp.js +15 -0
- package/dist/gateway/gateway-config-prompts.shared.js +25 -0
- package/dist/gateway/http-auth-helpers.js +18 -0
- package/dist/gateway/http-common.js +18 -0
- package/dist/gateway/http-endpoint-helpers.js +27 -0
- package/dist/gateway/node-invoke-sanitize.js +11 -0
- package/dist/gateway/node-invoke-system-run-approval.js +205 -0
- package/dist/gateway/probe-auth.js +21 -0
- package/dist/gateway/protocol/index.js +7 -2
- package/dist/gateway/protocol/schema/mesh.js +54 -0
- package/dist/gateway/protocol/schema/protocol-schemas.js +7 -0
- package/dist/gateway/protocol/schema.js +1 -0
- package/dist/gateway/server/ws-connection/auth-messages.js +54 -0
- package/dist/gateway/server-channels.js +11 -0
- package/dist/gateway/server-methods/attachment-normalize.js +16 -0
- package/dist/gateway/server-methods/base-hash.js +8 -0
- package/dist/gateway/server-methods/mesh.js +700 -0
- package/dist/gateway/server-methods/nodes.handlers.invoke-result.js +55 -0
- package/dist/gateway/server-methods/restart-request.js +13 -0
- package/dist/gateway/server-methods/validation.js +8 -0
- package/dist/gateway/server.agent.gateway-server-agent.mocks.js +35 -0
- package/dist/gateway/server.e2e-registry-helpers.js +1 -0
- package/dist/gateway/server.e2e-ws-harness.js +20 -0
- package/dist/gateway/test-helpers.js +2 -0
- package/dist/gateway/test-helpers.server.js +3 -1
- package/dist/gateway/test-http-response.js +12 -0
- package/dist/gateway/test-openai-responses-model.js +20 -0
- package/dist/gateway/test-temp-config.js +30 -0
- package/dist/gateway/test-with-server.js +32 -0
- package/dist/hooks/bundled/bootstrap-extra-files/handler.js +46 -0
- package/dist/imessage/monitor/abort-handler.js +23 -0
- package/dist/imessage/monitor/inbound-processing.js +346 -0
- package/dist/imessage/monitor/parse-notification.js +64 -0
- package/dist/imessage/target-parsing-helpers.js +92 -0
- package/dist/infra/archive.js +244 -20
- package/dist/infra/detect-package-manager.js +26 -0
- package/dist/infra/exec-approvals-allowlist.js +257 -0
- package/dist/infra/exec-approvals-analysis.js +770 -0
- package/dist/infra/exec-approvals.js +13 -0
- package/dist/infra/file-lock.js +1 -0
- package/dist/infra/gemini-auth.js +39 -0
- package/dist/infra/heartbeat-active-hours.js +85 -0
- package/dist/infra/heartbeat-events-filter.js +50 -0
- package/dist/infra/heartbeat-runner.test-utils.js +39 -0
- package/dist/infra/http-body.js +265 -0
- package/dist/infra/install-package-dir.js +50 -0
- package/dist/infra/install-safe-path.js +49 -0
- package/dist/infra/json-files.js +49 -0
- package/dist/infra/jsonl-socket.js +52 -0
- package/dist/infra/map-size.js +14 -0
- package/dist/infra/net/hostname.js +7 -0
- package/dist/infra/npm-registry-spec.js +39 -0
- package/dist/infra/openclaw-root.js +109 -0
- package/dist/infra/outbound/delivery-queue.js +214 -0
- package/dist/infra/outbound/identity.js +23 -0
- package/dist/infra/outbound/message-action-params.js +307 -0
- package/dist/infra/outbound/tool-payload.js +21 -0
- package/dist/infra/package-json.js +23 -0
- package/dist/infra/pairing-files.js +19 -0
- package/dist/infra/pairing-token.js +9 -0
- package/dist/infra/path-prepend.js +51 -0
- package/dist/infra/process-respawn.js +49 -0
- package/dist/infra/runtime-status.js +16 -0
- package/dist/infra/session-cost-usage.types.js +1 -0
- package/dist/infra/session-maintenance-warning.js +89 -0
- package/dist/infra/system-run-command.js +78 -0
- package/dist/infra/tmp-openclaw-dir.js +81 -0
- package/dist/infra/tmp-poolbot-dir.js +2 -0
- package/dist/infra/update-channels.js +19 -0
- package/dist/line/actions.js +45 -0
- package/dist/line/channel-access-token.js +9 -0
- package/dist/line/flex-templates/basic-cards.js +332 -0
- package/dist/line/flex-templates/common.js +18 -0
- package/dist/line/flex-templates/media-control-cards.js +453 -0
- package/dist/line/flex-templates/message.js +10 -0
- package/dist/line/flex-templates/schedule-cards.js +399 -0
- package/dist/line/flex-templates/types.js +1 -0
- package/dist/line/webhook-node.js +100 -0
- package/dist/line/webhook-utils.js +11 -0
- package/dist/logging/timestamps.js +14 -0
- package/dist/markdown/whatsapp.js +62 -0
- package/dist/media/base64.js +34 -0
- package/dist/media/local-roots.js +32 -0
- package/dist/media/outbound-attachment.js +10 -0
- package/dist/media/read-response-with-limit.js +41 -0
- package/dist/media/sniff-mime-from-base64.js +19 -0
- package/dist/media-understanding/audio-preflight.js +67 -0
- package/dist/media-understanding/fs.js +13 -0
- package/dist/media-understanding/output-extract.js +26 -0
- package/dist/media-understanding/providers/audio.test-helpers.js +34 -0
- package/dist/media-understanding/providers/google/inline-data.js +64 -0
- package/dist/media-understanding/providers/shared.js +7 -0
- package/dist/media-understanding/runner.entries.js +459 -0
- package/dist/memory/batch-error-utils.js +11 -0
- package/dist/memory/batch-http.js +27 -0
- package/dist/memory/batch-output.js +29 -0
- package/dist/memory/batch-runner.js +22 -0
- package/dist/memory/batch-upload.js +23 -0
- package/dist/memory/batch-utils.js +26 -0
- package/dist/memory/embeddings-debug.js +11 -0
- package/dist/memory/embeddings-remote-client.js +22 -0
- package/dist/memory/embeddings-remote-fetch.js +14 -0
- package/dist/memory/manager-embedding-ops.js +616 -0
- package/dist/memory/manager-sync-ops.js +953 -0
- package/dist/memory/qmd-manager.js +1061 -0
- package/dist/memory/qmd-query-parser.js +107 -0
- package/dist/memory/qmd-scope.js +93 -0
- package/dist/memory/search-manager.js +0 -1
- package/dist/memory/sync-index.js +21 -0
- package/dist/memory/sync-progress.js +22 -0
- package/dist/memory/sync-stale.js +30 -0
- package/dist/memory/test-embeddings-mock.js +16 -0
- package/dist/memory/test-manager-helpers.js +14 -0
- package/dist/memory/test-runtime-mocks.js +11 -0
- package/dist/node-host/invoke-browser.js +177 -0
- package/dist/node-host/invoke.js +685 -0
- package/dist/pairing/setup-code.js +285 -0
- package/dist/plugin-sdk/account-id.js +1 -0
- package/dist/plugin-sdk/agent-media-payload.js +13 -0
- package/dist/plugin-sdk/allow-from.js +47 -0
- package/dist/plugin-sdk/command-auth.js +23 -0
- package/dist/plugin-sdk/config-paths.js +9 -0
- package/dist/plugin-sdk/file-lock.js +116 -0
- package/dist/plugin-sdk/json-store.js +31 -0
- package/dist/plugin-sdk/onboarding.js +28 -0
- package/dist/plugin-sdk/provider-auth-result.js +29 -0
- package/dist/plugin-sdk/slack-message-actions.js +133 -0
- package/dist/plugin-sdk/status-helpers.js +35 -0
- package/dist/plugin-sdk/text-chunking.js +31 -0
- package/dist/plugin-sdk/tool-send.js +12 -0
- package/dist/plugin-sdk/webhook-path.js +27 -0
- package/dist/plugin-sdk/webhook-targets.js +34 -0
- package/dist/plugins/hooks.test-helpers.js +21 -0
- package/dist/plugins/uninstall.js +171 -0
- package/dist/process/supervisor/adapters/child.js +143 -0
- package/dist/process/supervisor/adapters/env.js +13 -0
- package/dist/process/supervisor/adapters/pty.js +148 -0
- package/dist/process/supervisor/index.js +10 -0
- package/dist/process/supervisor/registry.js +117 -0
- package/dist/process/supervisor/supervisor.js +244 -0
- package/dist/process/supervisor/types.js +1 -0
- package/dist/providers/google-shared.test-helpers.js +75 -0
- package/dist/security/audit-channel.js +419 -0
- package/dist/security/audit-tool-policy.js +1 -0
- package/dist/security/scan-paths.js +12 -0
- package/dist/sessions/input-provenance.js +55 -0
- package/dist/sessions/session-key-utils.js +7 -0
- package/dist/shared/chat-content.js +31 -0
- package/dist/shared/chat-envelope.js +45 -0
- package/dist/shared/config-eval.js +117 -0
- package/dist/shared/device-auth.js +16 -0
- package/dist/shared/entry-metadata.js +9 -0
- package/dist/shared/entry-status.js +25 -0
- package/dist/shared/frontmatter.js +98 -0
- package/dist/shared/model-param-b.js +19 -0
- package/dist/shared/net/ipv4.js +17 -0
- package/dist/shared/node-match.js +53 -0
- package/dist/shared/requirements.js +128 -0
- package/dist/shared/subagents-format.js +84 -0
- package/dist/shared/usage-aggregates.js +28 -0
- package/dist/signal/monitor/mentions.js +45 -0
- package/dist/signal/rpc-context.js +19 -0
- package/dist/slack/blocks-fallback.js +76 -0
- package/dist/slack/blocks-input.js +40 -0
- package/dist/slack/draft-stream.js +106 -0
- package/dist/slack/message-actions.js +51 -0
- package/dist/slack/modal-metadata.js +32 -0
- package/dist/slack/monitor/events/interactions.js +462 -0
- package/dist/slack/monitor/room-context.js +17 -0
- package/dist/slack/stream-mode.js +41 -0
- package/dist/telegram/bot-native-command-menu.js +64 -0
- package/dist/telegram/bot.media.e2e-harness.js +81 -0
- package/dist/telegram/button-types.js +1 -0
- package/dist/telegram/group-access.js +65 -0
- package/dist/telegram/outbound-params.js +21 -0
- package/dist/telegram/poll-vote-cache.js +21 -0
- package/dist/terminal/health-style.js +36 -0
- package/dist/test-utils/chunk-test-helpers.js +21 -0
- package/dist/test-utils/env.js +72 -0
- package/dist/test-utils/exec-assertions.js +12 -0
- package/dist/test-utils/imessage-test-plugin.js +54 -0
- package/dist/test-utils/mock-http-response.js +17 -0
- package/dist/test-utils/vitest-mock-fn.js +1 -0
- package/dist/tts/tts-core.js +550 -0
- package/dist/utils/chunk-items.js +10 -0
- package/dist/utils/reaction-level.js +52 -0
- package/dist/utils/safe-json.js +22 -0
- package/dist/utils/with-timeout.js +14 -0
- package/dist/web/media.js +17 -5
- package/dist/whatsapp/resolve-outbound-target.js +42 -0
- package/dist/wizard/onboarding.completion.js +74 -0
- package/extensions/bluebubbles/src/account-resolve.ts +29 -0
- package/extensions/bluebubbles/src/monitor-normalize.ts +796 -0
- package/extensions/bluebubbles/src/monitor-processing.ts +1007 -0
- package/extensions/bluebubbles/src/monitor-reply-cache.ts +185 -0
- package/extensions/bluebubbles/src/monitor-shared.ts +51 -0
- package/extensions/bluebubbles/src/multipart.ts +32 -0
- package/extensions/bluebubbles/src/send-helpers.ts +53 -0
- package/extensions/bluebubbles/src/test-harness.ts +50 -0
- package/extensions/bluebubbles/src/test-mocks.ts +11 -0
- package/extensions/device-pair/index.ts +554 -0
- package/extensions/device-pair/poolbot.plugin.json +20 -0
- package/extensions/discord/src/channel.js +366 -0
- package/extensions/discord/src/runtime.js +10 -0
- package/extensions/feishu/index.ts +63 -0
- package/extensions/feishu/package.json +37 -0
- package/extensions/feishu/poolbot.plugin.json +10 -0
- package/extensions/feishu/skills/feishu-doc/SKILL.md +105 -0
- package/extensions/feishu/skills/feishu-doc/references/block-types.md +103 -0
- package/extensions/feishu/skills/feishu-drive/SKILL.md +97 -0
- package/extensions/feishu/skills/feishu-perm/SKILL.md +119 -0
- package/extensions/feishu/skills/feishu-wiki/SKILL.md +111 -0
- package/extensions/feishu/src/accounts.ts +114 -0
- package/extensions/feishu/src/bitable.ts +739 -0
- package/extensions/feishu/src/bot.ts +965 -0
- package/extensions/feishu/src/channel.ts +351 -0
- package/extensions/feishu/src/client.ts +118 -0
- package/extensions/feishu/src/config-schema.ts +206 -0
- package/extensions/feishu/src/dedup.ts +33 -0
- package/extensions/feishu/src/directory.ts +177 -0
- package/extensions/feishu/src/doc-schema.ts +47 -0
- package/extensions/feishu/src/docx.ts +536 -0
- package/extensions/feishu/src/drive-schema.ts +46 -0
- package/extensions/feishu/src/drive.ts +227 -0
- package/extensions/feishu/src/dynamic-agent.ts +131 -0
- package/extensions/feishu/src/media.ts +449 -0
- package/extensions/feishu/src/mention.ts +126 -0
- package/extensions/feishu/src/monitor.ts +330 -0
- package/extensions/feishu/src/onboarding.ts +359 -0
- package/extensions/feishu/src/outbound.ts +55 -0
- package/extensions/feishu/src/perm-schema.ts +52 -0
- package/extensions/feishu/src/perm.ts +173 -0
- package/extensions/feishu/src/policy.ts +84 -0
- package/extensions/feishu/src/probe.ts +44 -0
- package/extensions/feishu/src/reactions.ts +160 -0
- package/extensions/feishu/src/reply-dispatcher.ts +239 -0
- package/extensions/feishu/src/runtime.ts +14 -0
- package/extensions/feishu/src/send-result.ts +29 -0
- package/extensions/feishu/src/send.ts +335 -0
- package/extensions/feishu/src/streaming-card.ts +223 -0
- package/extensions/feishu/src/targets.ts +78 -0
- package/extensions/feishu/src/tools-config.ts +21 -0
- package/extensions/feishu/src/types.ts +81 -0
- package/extensions/feishu/src/typing.ts +80 -0
- package/extensions/feishu/src/wiki-schema.ts +55 -0
- package/extensions/feishu/src/wiki.ts +232 -0
- package/extensions/imessage/src/channel.js +253 -0
- package/extensions/imessage/src/runtime.js +10 -0
- package/extensions/irc/index.ts +17 -0
- package/extensions/irc/package.json +14 -0
- package/extensions/irc/poolbot.plugin.json +9 -0
- package/extensions/irc/src/accounts.ts +268 -0
- package/extensions/irc/src/channel.ts +367 -0
- package/extensions/irc/src/client.ts +439 -0
- package/extensions/irc/src/config-schema.ts +97 -0
- package/extensions/irc/src/connect-options.ts +30 -0
- package/extensions/irc/src/control-chars.ts +22 -0
- package/extensions/irc/src/inbound.ts +334 -0
- package/extensions/irc/src/monitor.ts +147 -0
- package/extensions/irc/src/normalize.ts +117 -0
- package/extensions/irc/src/onboarding.ts +479 -0
- package/extensions/irc/src/policy.ts +157 -0
- package/extensions/irc/src/probe.ts +53 -0
- package/extensions/irc/src/protocol.ts +169 -0
- package/extensions/irc/src/runtime.ts +14 -0
- package/extensions/irc/src/send.ts +88 -0
- package/extensions/irc/src/types.ts +93 -0
- package/extensions/matrix/src/matrix/client-bootstrap.ts +39 -0
- package/extensions/mattermost/src/mattermost/monitor-onchar.ts +25 -0
- package/extensions/mattermost/src/mattermost/monitor-websocket.ts +221 -0
- package/extensions/mattermost/src/mattermost/reactions.ts +130 -0
- package/extensions/mattermost/src/mattermost/reconnect.ts +103 -0
- package/extensions/minimax-portal-auth/README.md +33 -0
- package/extensions/minimax-portal-auth/index.ts +161 -0
- package/extensions/minimax-portal-auth/oauth.ts +247 -0
- package/extensions/minimax-portal-auth/package.json +15 -0
- package/extensions/minimax-portal-auth/poolbot.plugin.json +9 -0
- package/extensions/msteams/src/file-lock.ts +1 -0
- package/extensions/msteams/src/graph.ts +92 -0
- package/extensions/msteams/src/mentions.ts +114 -0
- package/extensions/msteams/src/test-runtime.ts +16 -0
- package/extensions/openai-codex-auth/README.md +82 -0
- package/extensions/openai-codex-auth/index.ts +177 -0
- package/extensions/openai-codex-auth/package.json +15 -0
- package/extensions/openai-codex-auth/poolbot.plugin.json +9 -0
- package/extensions/phone-control/index.ts +421 -0
- package/extensions/phone-control/poolbot.plugin.json +10 -0
- package/extensions/shared/resolve-target-test-helpers.ts +66 -0
- package/extensions/signal/src/channel.js +273 -0
- package/extensions/signal/src/runtime.js +10 -0
- package/extensions/slack/src/channel.js +489 -0
- package/extensions/slack/src/runtime.js +10 -0
- package/extensions/talk-voice/index.ts +150 -0
- package/extensions/talk-voice/poolbot.plugin.json +10 -0
- package/extensions/telegram/src/channel.js +424 -0
- package/extensions/telegram/src/runtime.js +10 -0
- package/extensions/thread-ownership/index.ts +133 -0
- package/extensions/thread-ownership/poolbot.plugin.json +28 -0
- package/extensions/tlon/src/account-fields.ts +25 -0
- package/extensions/tlon/src/urbit/base-url.ts +57 -0
- package/extensions/tlon/src/urbit/channel-client.ts +157 -0
- package/extensions/tlon/src/urbit/channel-ops.ts +164 -0
- package/extensions/tlon/src/urbit/context.ts +47 -0
- package/extensions/tlon/src/urbit/errors.ts +51 -0
- package/extensions/tlon/src/urbit/fetch.ts +39 -0
- package/extensions/twitch/src/test-fixtures.ts +30 -0
- package/extensions/voice-call/src/allowlist.ts +19 -0
- package/extensions/whatsapp/src/channel.js +429 -0
- package/extensions/whatsapp/src/runtime.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import { rmSync } from "node:fs";
|
|
2
|
+
import { completeSimple } from "@mariozechner/pi-ai";
|
|
3
|
+
import { EdgeTTS } from "node-edge-tts";
|
|
4
|
+
import { getApiKeyForModel, requireApiKey } from "../agents/model-auth.js";
|
|
5
|
+
import { buildModelAliasIndex, resolveDefaultModelForAgent, resolveModelRefFromString, } from "../agents/model-selection.js";
|
|
6
|
+
import { resolveModel } from "../agents/pi-embedded-runner/model.js";
|
|
7
|
+
const DEFAULT_ELEVENLABS_BASE_URL = "https://api.elevenlabs.io";
|
|
8
|
+
const TEMP_FILE_CLEANUP_DELAY_MS = 5 * 60 * 1000; // 5 minutes
|
|
9
|
+
export function isValidVoiceId(voiceId) {
|
|
10
|
+
return /^[a-zA-Z0-9]{10,40}$/.test(voiceId);
|
|
11
|
+
}
|
|
12
|
+
function normalizeElevenLabsBaseUrl(baseUrl) {
|
|
13
|
+
const trimmed = baseUrl.trim();
|
|
14
|
+
if (!trimmed) {
|
|
15
|
+
return DEFAULT_ELEVENLABS_BASE_URL;
|
|
16
|
+
}
|
|
17
|
+
return trimmed.replace(/\/+$/, "");
|
|
18
|
+
}
|
|
19
|
+
function requireInRange(value, min, max, label) {
|
|
20
|
+
if (!Number.isFinite(value) || value < min || value > max) {
|
|
21
|
+
throw new Error(`${label} must be between ${min} and ${max}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function assertElevenLabsVoiceSettings(settings) {
|
|
25
|
+
requireInRange(settings.stability, 0, 1, "stability");
|
|
26
|
+
requireInRange(settings.similarityBoost, 0, 1, "similarityBoost");
|
|
27
|
+
requireInRange(settings.style, 0, 1, "style");
|
|
28
|
+
requireInRange(settings.speed, 0.5, 2, "speed");
|
|
29
|
+
}
|
|
30
|
+
function normalizeLanguageCode(code) {
|
|
31
|
+
const trimmed = code?.trim();
|
|
32
|
+
if (!trimmed) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const normalized = trimmed.toLowerCase();
|
|
36
|
+
if (!/^[a-z]{2}$/.test(normalized)) {
|
|
37
|
+
throw new Error("languageCode must be a 2-letter ISO 639-1 code (e.g. en, de, fr)");
|
|
38
|
+
}
|
|
39
|
+
return normalized;
|
|
40
|
+
}
|
|
41
|
+
function normalizeApplyTextNormalization(mode) {
|
|
42
|
+
const trimmed = mode?.trim();
|
|
43
|
+
if (!trimmed) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const normalized = trimmed.toLowerCase();
|
|
47
|
+
if (normalized === "auto" || normalized === "on" || normalized === "off") {
|
|
48
|
+
return normalized;
|
|
49
|
+
}
|
|
50
|
+
throw new Error("applyTextNormalization must be one of: auto, on, off");
|
|
51
|
+
}
|
|
52
|
+
function normalizeSeed(seed) {
|
|
53
|
+
if (seed == null) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const next = Math.floor(seed);
|
|
57
|
+
if (!Number.isFinite(next) || next < 0 || next > 4_294_967_295) {
|
|
58
|
+
throw new Error("seed must be between 0 and 4294967295");
|
|
59
|
+
}
|
|
60
|
+
return next;
|
|
61
|
+
}
|
|
62
|
+
function parseBooleanValue(value) {
|
|
63
|
+
const normalized = value.trim().toLowerCase();
|
|
64
|
+
if (["true", "1", "yes", "on"].includes(normalized)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (["false", "0", "no", "off"].includes(normalized)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
function parseNumberValue(value) {
|
|
73
|
+
const parsed = Number.parseFloat(value);
|
|
74
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
75
|
+
}
|
|
76
|
+
export function parseTtsDirectives(text, policy) {
|
|
77
|
+
if (!policy.enabled) {
|
|
78
|
+
return { cleanedText: text, overrides: {}, warnings: [], hasDirective: false };
|
|
79
|
+
}
|
|
80
|
+
const overrides = {};
|
|
81
|
+
const warnings = [];
|
|
82
|
+
let cleanedText = text;
|
|
83
|
+
let hasDirective = false;
|
|
84
|
+
const blockRegex = /\[\[tts:text\]\]([\s\S]*?)\[\[\/tts:text\]\]/gi;
|
|
85
|
+
cleanedText = cleanedText.replace(blockRegex, (_match, inner) => {
|
|
86
|
+
hasDirective = true;
|
|
87
|
+
if (policy.allowText && overrides.ttsText == null) {
|
|
88
|
+
overrides.ttsText = inner.trim();
|
|
89
|
+
}
|
|
90
|
+
return "";
|
|
91
|
+
});
|
|
92
|
+
const directiveRegex = /\[\[tts:([^\]]+)\]\]/gi;
|
|
93
|
+
cleanedText = cleanedText.replace(directiveRegex, (_match, body) => {
|
|
94
|
+
hasDirective = true;
|
|
95
|
+
const tokens = body.split(/\s+/).filter(Boolean);
|
|
96
|
+
for (const token of tokens) {
|
|
97
|
+
const eqIndex = token.indexOf("=");
|
|
98
|
+
if (eqIndex === -1) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const rawKey = token.slice(0, eqIndex).trim();
|
|
102
|
+
const rawValue = token.slice(eqIndex + 1).trim();
|
|
103
|
+
if (!rawKey || !rawValue) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const key = rawKey.toLowerCase();
|
|
107
|
+
try {
|
|
108
|
+
switch (key) {
|
|
109
|
+
case "provider":
|
|
110
|
+
if (!policy.allowProvider) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
if (rawValue === "openai" || rawValue === "elevenlabs" || rawValue === "edge") {
|
|
114
|
+
overrides.provider = rawValue;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
warnings.push(`unsupported provider "${rawValue}"`);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
case "voice":
|
|
121
|
+
case "openai_voice":
|
|
122
|
+
case "openaivoice":
|
|
123
|
+
if (!policy.allowVoice) {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
if (isValidOpenAIVoice(rawValue)) {
|
|
127
|
+
overrides.openai = { ...overrides.openai, voice: rawValue };
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
warnings.push(`invalid OpenAI voice "${rawValue}"`);
|
|
131
|
+
}
|
|
132
|
+
break;
|
|
133
|
+
case "voiceid":
|
|
134
|
+
case "voice_id":
|
|
135
|
+
case "elevenlabs_voice":
|
|
136
|
+
case "elevenlabsvoice":
|
|
137
|
+
if (!policy.allowVoice) {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (isValidVoiceId(rawValue)) {
|
|
141
|
+
overrides.elevenlabs = { ...overrides.elevenlabs, voiceId: rawValue };
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
warnings.push(`invalid ElevenLabs voiceId "${rawValue}"`);
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case "model":
|
|
148
|
+
case "modelid":
|
|
149
|
+
case "model_id":
|
|
150
|
+
case "elevenlabs_model":
|
|
151
|
+
case "elevenlabsmodel":
|
|
152
|
+
case "openai_model":
|
|
153
|
+
case "openaimodel":
|
|
154
|
+
if (!policy.allowModelId) {
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (isValidOpenAIModel(rawValue)) {
|
|
158
|
+
overrides.openai = { ...overrides.openai, model: rawValue };
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
overrides.elevenlabs = { ...overrides.elevenlabs, modelId: rawValue };
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case "stability":
|
|
165
|
+
if (!policy.allowVoiceSettings) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
{
|
|
169
|
+
const value = parseNumberValue(rawValue);
|
|
170
|
+
if (value == null) {
|
|
171
|
+
warnings.push("invalid stability value");
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
requireInRange(value, 0, 1, "stability");
|
|
175
|
+
overrides.elevenlabs = {
|
|
176
|
+
...overrides.elevenlabs,
|
|
177
|
+
voiceSettings: { ...overrides.elevenlabs?.voiceSettings, stability: value },
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case "similarity":
|
|
182
|
+
case "similarityboost":
|
|
183
|
+
case "similarity_boost":
|
|
184
|
+
if (!policy.allowVoiceSettings) {
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
{
|
|
188
|
+
const value = parseNumberValue(rawValue);
|
|
189
|
+
if (value == null) {
|
|
190
|
+
warnings.push("invalid similarityBoost value");
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
requireInRange(value, 0, 1, "similarityBoost");
|
|
194
|
+
overrides.elevenlabs = {
|
|
195
|
+
...overrides.elevenlabs,
|
|
196
|
+
voiceSettings: { ...overrides.elevenlabs?.voiceSettings, similarityBoost: value },
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case "style":
|
|
201
|
+
if (!policy.allowVoiceSettings) {
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
{
|
|
205
|
+
const value = parseNumberValue(rawValue);
|
|
206
|
+
if (value == null) {
|
|
207
|
+
warnings.push("invalid style value");
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
requireInRange(value, 0, 1, "style");
|
|
211
|
+
overrides.elevenlabs = {
|
|
212
|
+
...overrides.elevenlabs,
|
|
213
|
+
voiceSettings: { ...overrides.elevenlabs?.voiceSettings, style: value },
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
case "speed":
|
|
218
|
+
if (!policy.allowVoiceSettings) {
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
{
|
|
222
|
+
const value = parseNumberValue(rawValue);
|
|
223
|
+
if (value == null) {
|
|
224
|
+
warnings.push("invalid speed value");
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
requireInRange(value, 0.5, 2, "speed");
|
|
228
|
+
overrides.elevenlabs = {
|
|
229
|
+
...overrides.elevenlabs,
|
|
230
|
+
voiceSettings: { ...overrides.elevenlabs?.voiceSettings, speed: value },
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
break;
|
|
234
|
+
case "speakerboost":
|
|
235
|
+
case "speaker_boost":
|
|
236
|
+
case "usespeakerboost":
|
|
237
|
+
case "use_speaker_boost":
|
|
238
|
+
if (!policy.allowVoiceSettings) {
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
{
|
|
242
|
+
const value = parseBooleanValue(rawValue);
|
|
243
|
+
if (value == null) {
|
|
244
|
+
warnings.push("invalid useSpeakerBoost value");
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
overrides.elevenlabs = {
|
|
248
|
+
...overrides.elevenlabs,
|
|
249
|
+
voiceSettings: { ...overrides.elevenlabs?.voiceSettings, useSpeakerBoost: value },
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
break;
|
|
253
|
+
case "normalize":
|
|
254
|
+
case "applytextnormalization":
|
|
255
|
+
case "apply_text_normalization":
|
|
256
|
+
if (!policy.allowNormalization) {
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
overrides.elevenlabs = {
|
|
260
|
+
...overrides.elevenlabs,
|
|
261
|
+
applyTextNormalization: normalizeApplyTextNormalization(rawValue),
|
|
262
|
+
};
|
|
263
|
+
break;
|
|
264
|
+
case "language":
|
|
265
|
+
case "languagecode":
|
|
266
|
+
case "language_code":
|
|
267
|
+
if (!policy.allowNormalization) {
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
overrides.elevenlabs = {
|
|
271
|
+
...overrides.elevenlabs,
|
|
272
|
+
languageCode: normalizeLanguageCode(rawValue),
|
|
273
|
+
};
|
|
274
|
+
break;
|
|
275
|
+
case "seed":
|
|
276
|
+
if (!policy.allowSeed) {
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
overrides.elevenlabs = {
|
|
280
|
+
...overrides.elevenlabs,
|
|
281
|
+
seed: normalizeSeed(Number.parseInt(rawValue, 10)),
|
|
282
|
+
};
|
|
283
|
+
break;
|
|
284
|
+
default:
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
warnings.push(err.message);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return "";
|
|
293
|
+
});
|
|
294
|
+
return {
|
|
295
|
+
cleanedText,
|
|
296
|
+
ttsText: overrides.ttsText,
|
|
297
|
+
hasDirective,
|
|
298
|
+
overrides,
|
|
299
|
+
warnings,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
export const OPENAI_TTS_MODELS = ["gpt-4o-mini-tts", "tts-1", "tts-1-hd"];
|
|
303
|
+
/**
|
|
304
|
+
* Custom OpenAI-compatible TTS endpoint.
|
|
305
|
+
* When set, model/voice validation is relaxed to allow non-OpenAI models.
|
|
306
|
+
* Example: OPENAI_TTS_BASE_URL=http://localhost:8880/v1
|
|
307
|
+
*
|
|
308
|
+
* Note: Read at runtime (not module load) to support config.env loading.
|
|
309
|
+
*/
|
|
310
|
+
function getOpenAITtsBaseUrl() {
|
|
311
|
+
return (process.env.OPENAI_TTS_BASE_URL?.trim() || "https://api.openai.com/v1").replace(/\/+$/, "");
|
|
312
|
+
}
|
|
313
|
+
function isCustomOpenAIEndpoint() {
|
|
314
|
+
return getOpenAITtsBaseUrl() !== "https://api.openai.com/v1";
|
|
315
|
+
}
|
|
316
|
+
export const OPENAI_TTS_VOICES = [
|
|
317
|
+
"alloy",
|
|
318
|
+
"ash",
|
|
319
|
+
"ballad",
|
|
320
|
+
"cedar",
|
|
321
|
+
"coral",
|
|
322
|
+
"echo",
|
|
323
|
+
"fable",
|
|
324
|
+
"juniper",
|
|
325
|
+
"marin",
|
|
326
|
+
"onyx",
|
|
327
|
+
"nova",
|
|
328
|
+
"sage",
|
|
329
|
+
"shimmer",
|
|
330
|
+
"verse",
|
|
331
|
+
];
|
|
332
|
+
export function isValidOpenAIModel(model) {
|
|
333
|
+
// Allow any model when using custom endpoint (e.g., Kokoro, LocalAI)
|
|
334
|
+
if (isCustomOpenAIEndpoint()) {
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
return OPENAI_TTS_MODELS.includes(model);
|
|
338
|
+
}
|
|
339
|
+
export function isValidOpenAIVoice(voice) {
|
|
340
|
+
// Allow any voice when using custom endpoint (e.g., Kokoro Chinese voices)
|
|
341
|
+
if (isCustomOpenAIEndpoint()) {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
return OPENAI_TTS_VOICES.includes(voice);
|
|
345
|
+
}
|
|
346
|
+
function resolveSummaryModelRef(cfg, config) {
|
|
347
|
+
const defaultRef = resolveDefaultModelForAgent({ cfg });
|
|
348
|
+
const override = config.summaryModel?.trim();
|
|
349
|
+
if (!override) {
|
|
350
|
+
return { ref: defaultRef, source: "default" };
|
|
351
|
+
}
|
|
352
|
+
const aliasIndex = buildModelAliasIndex({ cfg, defaultProvider: defaultRef.provider });
|
|
353
|
+
const resolved = resolveModelRefFromString({
|
|
354
|
+
raw: override,
|
|
355
|
+
defaultProvider: defaultRef.provider,
|
|
356
|
+
aliasIndex,
|
|
357
|
+
});
|
|
358
|
+
if (!resolved) {
|
|
359
|
+
return { ref: defaultRef, source: "default" };
|
|
360
|
+
}
|
|
361
|
+
return { ref: resolved.ref, source: "summaryModel" };
|
|
362
|
+
}
|
|
363
|
+
function isTextContentBlock(block) {
|
|
364
|
+
return block.type === "text";
|
|
365
|
+
}
|
|
366
|
+
export async function summarizeText(params) {
|
|
367
|
+
const { text, targetLength, cfg, config, timeoutMs } = params;
|
|
368
|
+
if (targetLength < 100 || targetLength > 10_000) {
|
|
369
|
+
throw new Error(`Invalid targetLength: ${targetLength}`);
|
|
370
|
+
}
|
|
371
|
+
const startTime = Date.now();
|
|
372
|
+
const { ref } = resolveSummaryModelRef(cfg, config);
|
|
373
|
+
const resolved = resolveModel(ref.provider, ref.model, undefined, cfg);
|
|
374
|
+
if (!resolved.model) {
|
|
375
|
+
throw new Error(resolved.error ?? `Unknown summary model: ${ref.provider}/${ref.model}`);
|
|
376
|
+
}
|
|
377
|
+
const apiKey = requireApiKey(await getApiKeyForModel({ model: resolved.model, cfg }), ref.provider);
|
|
378
|
+
try {
|
|
379
|
+
const controller = new AbortController();
|
|
380
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
381
|
+
try {
|
|
382
|
+
const res = await completeSimple(resolved.model, {
|
|
383
|
+
messages: [
|
|
384
|
+
{
|
|
385
|
+
role: "user",
|
|
386
|
+
content: `You are an assistant that summarizes texts concisely while keeping the most important information. ` +
|
|
387
|
+
`Summarize the text to approximately ${targetLength} characters. Maintain the original tone and style. ` +
|
|
388
|
+
`Reply only with the summary, without additional explanations.\n\n` +
|
|
389
|
+
`<text_to_summarize>\n${text}\n</text_to_summarize>`,
|
|
390
|
+
timestamp: Date.now(),
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
}, {
|
|
394
|
+
apiKey,
|
|
395
|
+
maxTokens: Math.ceil(targetLength / 2),
|
|
396
|
+
temperature: 0.3,
|
|
397
|
+
signal: controller.signal,
|
|
398
|
+
});
|
|
399
|
+
const summary = res.content
|
|
400
|
+
.filter(isTextContentBlock)
|
|
401
|
+
.map((block) => block.text.trim())
|
|
402
|
+
.filter(Boolean)
|
|
403
|
+
.join(" ")
|
|
404
|
+
.trim();
|
|
405
|
+
if (!summary) {
|
|
406
|
+
throw new Error("No summary returned");
|
|
407
|
+
}
|
|
408
|
+
return {
|
|
409
|
+
summary,
|
|
410
|
+
latencyMs: Date.now() - startTime,
|
|
411
|
+
inputLength: text.length,
|
|
412
|
+
outputLength: summary.length,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
finally {
|
|
416
|
+
clearTimeout(timeout);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (err) {
|
|
420
|
+
const error = err;
|
|
421
|
+
if (error.name === "AbortError") {
|
|
422
|
+
throw new Error("Summarization timed out", { cause: err });
|
|
423
|
+
}
|
|
424
|
+
throw err;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
export function scheduleCleanup(tempDir, delayMs = TEMP_FILE_CLEANUP_DELAY_MS) {
|
|
428
|
+
const timer = setTimeout(() => {
|
|
429
|
+
try {
|
|
430
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
// ignore cleanup errors
|
|
434
|
+
}
|
|
435
|
+
}, delayMs);
|
|
436
|
+
timer.unref();
|
|
437
|
+
}
|
|
438
|
+
export async function elevenLabsTTS(params) {
|
|
439
|
+
const { text, apiKey, baseUrl, voiceId, modelId, outputFormat, seed, applyTextNormalization, languageCode, voiceSettings, timeoutMs, } = params;
|
|
440
|
+
if (!isValidVoiceId(voiceId)) {
|
|
441
|
+
throw new Error("Invalid voiceId format");
|
|
442
|
+
}
|
|
443
|
+
assertElevenLabsVoiceSettings(voiceSettings);
|
|
444
|
+
const normalizedLanguage = normalizeLanguageCode(languageCode);
|
|
445
|
+
const normalizedNormalization = normalizeApplyTextNormalization(applyTextNormalization);
|
|
446
|
+
const normalizedSeed = normalizeSeed(seed);
|
|
447
|
+
const controller = new AbortController();
|
|
448
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
449
|
+
try {
|
|
450
|
+
const url = new URL(`${normalizeElevenLabsBaseUrl(baseUrl)}/v1/text-to-speech/${voiceId}`);
|
|
451
|
+
if (outputFormat) {
|
|
452
|
+
url.searchParams.set("output_format", outputFormat);
|
|
453
|
+
}
|
|
454
|
+
const response = await fetch(url.toString(), {
|
|
455
|
+
method: "POST",
|
|
456
|
+
headers: {
|
|
457
|
+
"xi-api-key": apiKey,
|
|
458
|
+
"Content-Type": "application/json",
|
|
459
|
+
Accept: "audio/mpeg",
|
|
460
|
+
},
|
|
461
|
+
body: JSON.stringify({
|
|
462
|
+
text,
|
|
463
|
+
model_id: modelId,
|
|
464
|
+
seed: normalizedSeed,
|
|
465
|
+
apply_text_normalization: normalizedNormalization,
|
|
466
|
+
language_code: normalizedLanguage,
|
|
467
|
+
voice_settings: {
|
|
468
|
+
stability: voiceSettings.stability,
|
|
469
|
+
similarity_boost: voiceSettings.similarityBoost,
|
|
470
|
+
style: voiceSettings.style,
|
|
471
|
+
use_speaker_boost: voiceSettings.useSpeakerBoost,
|
|
472
|
+
speed: voiceSettings.speed,
|
|
473
|
+
},
|
|
474
|
+
}),
|
|
475
|
+
signal: controller.signal,
|
|
476
|
+
});
|
|
477
|
+
if (!response.ok) {
|
|
478
|
+
throw new Error(`ElevenLabs API error (${response.status})`);
|
|
479
|
+
}
|
|
480
|
+
return Buffer.from(await response.arrayBuffer());
|
|
481
|
+
}
|
|
482
|
+
finally {
|
|
483
|
+
clearTimeout(timeout);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
export async function openaiTTS(params) {
|
|
487
|
+
const { text, apiKey, model, voice, responseFormat, timeoutMs } = params;
|
|
488
|
+
if (!isValidOpenAIModel(model)) {
|
|
489
|
+
throw new Error(`Invalid model: ${model}`);
|
|
490
|
+
}
|
|
491
|
+
if (!isValidOpenAIVoice(voice)) {
|
|
492
|
+
throw new Error(`Invalid voice: ${voice}`);
|
|
493
|
+
}
|
|
494
|
+
const controller = new AbortController();
|
|
495
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
496
|
+
try {
|
|
497
|
+
const response = await fetch(`${getOpenAITtsBaseUrl()}/audio/speech`, {
|
|
498
|
+
method: "POST",
|
|
499
|
+
headers: {
|
|
500
|
+
Authorization: `Bearer ${apiKey}`,
|
|
501
|
+
"Content-Type": "application/json",
|
|
502
|
+
},
|
|
503
|
+
body: JSON.stringify({
|
|
504
|
+
model,
|
|
505
|
+
input: text,
|
|
506
|
+
voice,
|
|
507
|
+
response_format: responseFormat,
|
|
508
|
+
}),
|
|
509
|
+
signal: controller.signal,
|
|
510
|
+
});
|
|
511
|
+
if (!response.ok) {
|
|
512
|
+
throw new Error(`OpenAI TTS API error (${response.status})`);
|
|
513
|
+
}
|
|
514
|
+
return Buffer.from(await response.arrayBuffer());
|
|
515
|
+
}
|
|
516
|
+
finally {
|
|
517
|
+
clearTimeout(timeout);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
export function inferEdgeExtension(outputFormat) {
|
|
521
|
+
const normalized = outputFormat.toLowerCase();
|
|
522
|
+
if (normalized.includes("webm")) {
|
|
523
|
+
return ".webm";
|
|
524
|
+
}
|
|
525
|
+
if (normalized.includes("ogg")) {
|
|
526
|
+
return ".ogg";
|
|
527
|
+
}
|
|
528
|
+
if (normalized.includes("opus")) {
|
|
529
|
+
return ".opus";
|
|
530
|
+
}
|
|
531
|
+
if (normalized.includes("wav") || normalized.includes("riff") || normalized.includes("pcm")) {
|
|
532
|
+
return ".wav";
|
|
533
|
+
}
|
|
534
|
+
return ".mp3";
|
|
535
|
+
}
|
|
536
|
+
export async function edgeTTS(params) {
|
|
537
|
+
const { text, outputPath, config, timeoutMs } = params;
|
|
538
|
+
const tts = new EdgeTTS({
|
|
539
|
+
voice: config.voice,
|
|
540
|
+
lang: config.lang,
|
|
541
|
+
outputFormat: config.outputFormat,
|
|
542
|
+
saveSubtitles: config.saveSubtitles,
|
|
543
|
+
proxy: config.proxy,
|
|
544
|
+
rate: config.rate,
|
|
545
|
+
pitch: config.pitch,
|
|
546
|
+
volume: config.volume,
|
|
547
|
+
timeout: config.timeoutMs ?? timeoutMs,
|
|
548
|
+
});
|
|
549
|
+
await tts.ttsPromise(text, outputPath);
|
|
550
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const LEVELS = new Set(["off", "ack", "minimal", "extensive"]);
|
|
2
|
+
function parseLevel(value) {
|
|
3
|
+
if (value === undefined || value === null) {
|
|
4
|
+
return { kind: "missing" };
|
|
5
|
+
}
|
|
6
|
+
if (typeof value !== "string") {
|
|
7
|
+
return { kind: "invalid" };
|
|
8
|
+
}
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
if (!trimmed) {
|
|
11
|
+
return { kind: "missing" };
|
|
12
|
+
}
|
|
13
|
+
if (LEVELS.has(trimmed)) {
|
|
14
|
+
return { kind: "ok", value: trimmed };
|
|
15
|
+
}
|
|
16
|
+
return { kind: "invalid" };
|
|
17
|
+
}
|
|
18
|
+
export function resolveReactionLevel(params) {
|
|
19
|
+
const parsed = parseLevel(params.value);
|
|
20
|
+
const effective = parsed.kind === "ok"
|
|
21
|
+
? parsed.value
|
|
22
|
+
: parsed.kind === "missing"
|
|
23
|
+
? params.defaultLevel
|
|
24
|
+
: params.invalidFallback;
|
|
25
|
+
switch (effective) {
|
|
26
|
+
case "off":
|
|
27
|
+
return { level: "off", ackEnabled: false, agentReactionsEnabled: false };
|
|
28
|
+
case "ack":
|
|
29
|
+
return { level: "ack", ackEnabled: true, agentReactionsEnabled: false };
|
|
30
|
+
case "minimal":
|
|
31
|
+
return {
|
|
32
|
+
level: "minimal",
|
|
33
|
+
ackEnabled: false,
|
|
34
|
+
agentReactionsEnabled: true,
|
|
35
|
+
agentReactionGuidance: "minimal",
|
|
36
|
+
};
|
|
37
|
+
case "extensive":
|
|
38
|
+
return {
|
|
39
|
+
level: "extensive",
|
|
40
|
+
ackEnabled: false,
|
|
41
|
+
agentReactionsEnabled: true,
|
|
42
|
+
agentReactionGuidance: "extensive",
|
|
43
|
+
};
|
|
44
|
+
default:
|
|
45
|
+
return {
|
|
46
|
+
level: "minimal",
|
|
47
|
+
ackEnabled: false,
|
|
48
|
+
agentReactionsEnabled: true,
|
|
49
|
+
agentReactionGuidance: "minimal",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function safeJsonStringify(value) {
|
|
2
|
+
try {
|
|
3
|
+
return JSON.stringify(value, (_key, val) => {
|
|
4
|
+
if (typeof val === "bigint") {
|
|
5
|
+
return val.toString();
|
|
6
|
+
}
|
|
7
|
+
if (typeof val === "function") {
|
|
8
|
+
return "[Function]";
|
|
9
|
+
}
|
|
10
|
+
if (val instanceof Error) {
|
|
11
|
+
return { name: val.name, message: val.message, stack: val.stack };
|
|
12
|
+
}
|
|
13
|
+
if (val instanceof Uint8Array) {
|
|
14
|
+
return { type: "Uint8Array", data: Buffer.from(val).toString("base64") };
|
|
15
|
+
}
|
|
16
|
+
return val;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function withTimeout(promise, timeoutMs) {
|
|
2
|
+
if (!timeoutMs || timeoutMs <= 0) {
|
|
3
|
+
return promise;
|
|
4
|
+
}
|
|
5
|
+
let timer = null;
|
|
6
|
+
const timeout = new Promise((_, reject) => {
|
|
7
|
+
timer = setTimeout(() => reject(new Error("timeout")), timeoutMs);
|
|
8
|
+
});
|
|
9
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
10
|
+
if (timer) {
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
package/dist/web/media.js
CHANGED
|
@@ -155,15 +155,27 @@ async function loadWebMediaInternal(mediaUrl, options = {}) {
|
|
|
155
155
|
fileName,
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
export async function loadWebMedia(mediaUrl,
|
|
158
|
+
export async function loadWebMedia(mediaUrl, maxBytesOrOptions) {
|
|
159
|
+
if (typeof maxBytesOrOptions === "number" || maxBytesOrOptions === undefined) {
|
|
160
|
+
return await loadWebMediaInternal(mediaUrl, {
|
|
161
|
+
maxBytes: maxBytesOrOptions,
|
|
162
|
+
optimizeImages: true,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
159
165
|
return await loadWebMediaInternal(mediaUrl, {
|
|
160
|
-
|
|
161
|
-
optimizeImages: true,
|
|
166
|
+
...maxBytesOrOptions,
|
|
167
|
+
optimizeImages: maxBytesOrOptions.optimizeImages ?? true,
|
|
162
168
|
});
|
|
163
169
|
}
|
|
164
|
-
export async function loadWebMediaRaw(mediaUrl,
|
|
170
|
+
export async function loadWebMediaRaw(mediaUrl, maxBytesOrOptions) {
|
|
171
|
+
if (typeof maxBytesOrOptions === "number" || maxBytesOrOptions === undefined) {
|
|
172
|
+
return await loadWebMediaInternal(mediaUrl, {
|
|
173
|
+
maxBytes: maxBytesOrOptions,
|
|
174
|
+
optimizeImages: false,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
165
177
|
return await loadWebMediaInternal(mediaUrl, {
|
|
166
|
-
|
|
178
|
+
...maxBytesOrOptions,
|
|
167
179
|
optimizeImages: false,
|
|
168
180
|
});
|
|
169
181
|
}
|