clawdbot 2026.1.4-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/LICENSE +21 -0
- package/README-header.png +0 -0
- package/README.md +297 -0
- package/dist/agents/agent-paths.js +17 -0
- package/dist/agents/bash-process-registry.js +126 -0
- package/dist/agents/bash-tools.js +837 -0
- package/dist/agents/clawdbot-tools.js +30 -0
- package/dist/agents/clawdis-tools.js +27 -0
- package/dist/agents/context.js +34 -0
- package/dist/agents/defaults.js +6 -0
- package/dist/agents/model-auth.js +112 -0
- package/dist/agents/model-catalog.js +55 -0
- package/dist/agents/model-fallback.js +191 -0
- package/dist/agents/model-scan.js +263 -0
- package/dist/agents/model-selection.js +116 -0
- package/dist/agents/models-config.js +49 -0
- package/dist/agents/pi-embedded-helpers.js +74 -0
- package/dist/agents/pi-embedded-runner.js +407 -0
- package/dist/agents/pi-embedded-subscribe.js +568 -0
- package/dist/agents/pi-embedded-utils.js +20 -0
- package/dist/agents/pi-embedded.js +1 -0
- package/dist/agents/pi-oauth.js +88 -0
- package/dist/agents/pi-tools.js +433 -0
- package/dist/agents/sandbox-paths.js +68 -0
- package/dist/agents/sandbox.js +644 -0
- package/dist/agents/shell-utils.js +53 -0
- package/dist/agents/skills-install.js +244 -0
- package/dist/agents/skills-status.js +157 -0
- package/dist/agents/skills.js +470 -0
- package/dist/agents/steerable-agent-loop.js +338 -0
- package/dist/agents/steerable-provider-transport.js +48 -0
- package/dist/agents/system-prompt.js +104 -0
- package/dist/agents/tool-display.js +162 -0
- package/dist/agents/tool-images.js +138 -0
- package/dist/agents/tools/browser-tool.js +339 -0
- package/dist/agents/tools/canvas-tool.js +193 -0
- package/dist/agents/tools/common.js +88 -0
- package/dist/agents/tools/cron-tool.js +124 -0
- package/dist/agents/tools/discord-actions-guild.js +186 -0
- package/dist/agents/tools/discord-actions-messaging.js +285 -0
- package/dist/agents/tools/discord-actions-moderation.js +70 -0
- package/dist/agents/tools/discord-actions.js +56 -0
- package/dist/agents/tools/discord-schema.js +199 -0
- package/dist/agents/tools/discord-tool.js +16 -0
- package/dist/agents/tools/gateway-tool.js +46 -0
- package/dist/agents/tools/gateway.js +27 -0
- package/dist/agents/tools/image-tool.js +132 -0
- package/dist/agents/tools/nodes-tool.js +413 -0
- package/dist/agents/tools/nodes-utils.js +92 -0
- package/dist/agents/tools/sessions-helpers.js +88 -0
- package/dist/agents/tools/sessions-history-tool.js +53 -0
- package/dist/agents/tools/sessions-list-tool.js +143 -0
- package/dist/agents/tools/sessions-send-helpers.js +100 -0
- package/dist/agents/tools/sessions-send-tool.js +347 -0
- package/dist/agents/tools/slack-actions.js +129 -0
- package/dist/agents/tools/slack-schema.js +59 -0
- package/dist/agents/tools/slack-tool.js +16 -0
- package/dist/agents/usage.js +39 -0
- package/dist/agents/workspace.js +241 -0
- package/dist/auto-reply/chunk.js +76 -0
- package/dist/auto-reply/envelope.js +38 -0
- package/dist/auto-reply/group-activation.js +20 -0
- package/dist/auto-reply/heartbeat.js +57 -0
- package/dist/auto-reply/model.js +14 -0
- package/dist/auto-reply/reply/abort.js +14 -0
- package/dist/auto-reply/reply/agent-runner.js +371 -0
- package/dist/auto-reply/reply/block-streaming.js +34 -0
- package/dist/auto-reply/reply/body.js +29 -0
- package/dist/auto-reply/reply/commands.js +207 -0
- package/dist/auto-reply/reply/directive-handling.js +361 -0
- package/dist/auto-reply/reply/directives.js +47 -0
- package/dist/auto-reply/reply/followup-runner.js +149 -0
- package/dist/auto-reply/reply/groups.js +91 -0
- package/dist/auto-reply/reply/mentions.js +38 -0
- package/dist/auto-reply/reply/model-selection.js +114 -0
- package/dist/auto-reply/reply/queue.js +399 -0
- package/dist/auto-reply/reply/reply-tags.js +26 -0
- package/dist/auto-reply/reply/session-updates.js +87 -0
- package/dist/auto-reply/reply/session.js +160 -0
- package/dist/auto-reply/reply/typing.js +75 -0
- package/dist/auto-reply/reply.js +535 -0
- package/dist/auto-reply/send-policy.js +28 -0
- package/dist/auto-reply/status.js +158 -0
- package/dist/auto-reply/templating.js +9 -0
- package/dist/auto-reply/thinking.js +49 -0
- package/dist/auto-reply/tokens.js +2 -0
- package/dist/auto-reply/tool-meta.js +74 -0
- package/dist/auto-reply/transcription.js +57 -0
- package/dist/auto-reply/types.js +1 -0
- package/dist/browser/bridge-server.js +37 -0
- package/dist/browser/cdp.js +382 -0
- package/dist/browser/chrome.js +432 -0
- package/dist/browser/client-actions-core.js +67 -0
- package/dist/browser/client-actions-observe.js +24 -0
- package/dist/browser/client-actions-types.js +1 -0
- package/dist/browser/client-actions.js +3 -0
- package/dist/browser/client-fetch.js +43 -0
- package/dist/browser/client.js +105 -0
- package/dist/browser/config.js +140 -0
- package/dist/browser/constants.js +4 -0
- package/dist/browser/profiles-service.js +122 -0
- package/dist/browser/profiles.js +85 -0
- package/dist/browser/pw-ai.js +2 -0
- package/dist/browser/pw-session.js +144 -0
- package/dist/browser/pw-tools-core.js +363 -0
- package/dist/browser/routes/agent.js +535 -0
- package/dist/browser/routes/basic.js +155 -0
- package/dist/browser/routes/index.js +8 -0
- package/dist/browser/routes/tabs.js +105 -0
- package/dist/browser/routes/utils.js +62 -0
- package/dist/browser/screenshot.js +40 -0
- package/dist/browser/server-context.js +377 -0
- package/dist/browser/server.js +81 -0
- package/dist/browser/target-id.js +18 -0
- package/dist/browser/trash.js +21 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17768 -0
- package/dist/canvas-host/a2ui/index.html +246 -0
- package/dist/canvas-host/a2ui.js +187 -0
- package/dist/canvas-host/server.js +382 -0
- package/dist/cli/browser-cli-actions-input.js +459 -0
- package/dist/cli/browser-cli-actions-observe.js +56 -0
- package/dist/cli/browser-cli-examples.js +31 -0
- package/dist/cli/browser-cli-inspect.js +97 -0
- package/dist/cli/browser-cli-manage.js +286 -0
- package/dist/cli/browser-cli-shared.js +1 -0
- package/dist/cli/browser-cli.js +26 -0
- package/dist/cli/canvas-cli.js +416 -0
- package/dist/cli/cron-cli.js +454 -0
- package/dist/cli/deps.js +17 -0
- package/dist/cli/dns-cli.js +180 -0
- package/dist/cli/gateway-cli.js +489 -0
- package/dist/cli/gateway-rpc.js +20 -0
- package/dist/cli/hooks-cli.js +135 -0
- package/dist/cli/models-cli.js +248 -0
- package/dist/cli/nodes-camera.js +57 -0
- package/dist/cli/nodes-canvas.js +26 -0
- package/dist/cli/nodes-cli.js +946 -0
- package/dist/cli/nodes-screen.js +37 -0
- package/dist/cli/parse-duration.js +20 -0
- package/dist/cli/ports.js +97 -0
- package/dist/cli/program.js +406 -0
- package/dist/cli/prompt.js +19 -0
- package/dist/cli/tui-cli.js +35 -0
- package/dist/cli/wait.js +8 -0
- package/dist/commands/agent.js +645 -0
- package/dist/commands/antigravity-oauth.js +327 -0
- package/dist/commands/configure.js +480 -0
- package/dist/commands/doctor.js +484 -0
- package/dist/commands/health.js +108 -0
- package/dist/commands/models/aliases.js +64 -0
- package/dist/commands/models/fallbacks.js +99 -0
- package/dist/commands/models/image-fallbacks.js +99 -0
- package/dist/commands/models/list.js +323 -0
- package/dist/commands/models/scan.js +266 -0
- package/dist/commands/models/set-image.js +23 -0
- package/dist/commands/models/set.js +23 -0
- package/dist/commands/models/shared.js +72 -0
- package/dist/commands/models.js +7 -0
- package/dist/commands/onboard-auth.js +70 -0
- package/dist/commands/onboard-helpers.js +295 -0
- package/dist/commands/onboard-interactive.js +17 -0
- package/dist/commands/onboard-non-interactive.js +202 -0
- package/dist/commands/onboard-providers.js +634 -0
- package/dist/commands/onboard-remote.js +120 -0
- package/dist/commands/onboard-skills.js +148 -0
- package/dist/commands/onboard-types.js +1 -0
- package/dist/commands/onboard.js +12 -0
- package/dist/commands/send.js +124 -0
- package/dist/commands/sessions.js +212 -0
- package/dist/commands/setup.js +58 -0
- package/dist/commands/signal-install.js +135 -0
- package/dist/commands/status.js +207 -0
- package/dist/commands/update.js +16 -0
- package/dist/config/config.js +6 -0
- package/dist/config/defaults.js +61 -0
- package/dist/config/io.js +147 -0
- package/dist/config/legacy-migrate.js +13 -0
- package/dist/config/legacy.js +159 -0
- package/dist/config/paths.js +71 -0
- package/dist/config/schema.js +150 -0
- package/dist/config/sessions.js +282 -0
- package/dist/config/talk.js +31 -0
- package/dist/config/types.js +1 -0
- package/dist/config/validation.js +29 -0
- package/dist/config/zod-schema.js +831 -0
- package/dist/control-ui/assets/index-BFID3yAA.css +1 -0
- package/dist/control-ui/assets/index-CE_axlTS.js +2235 -0
- package/dist/control-ui/assets/index-CE_axlTS.js.map +1 -0
- package/dist/control-ui/index.html +15 -0
- package/dist/cron/isolated-agent.js +499 -0
- package/dist/cron/run-log.js +72 -0
- package/dist/cron/schedule.js +24 -0
- package/dist/cron/service.js +471 -0
- package/dist/cron/store.js +43 -0
- package/dist/cron/types.js +1 -0
- package/dist/daemon/constants.js +10 -0
- package/dist/daemon/launchd.js +276 -0
- package/dist/daemon/legacy.js +63 -0
- package/dist/daemon/program-args.js +76 -0
- package/dist/daemon/schtasks.js +257 -0
- package/dist/daemon/service.js +60 -0
- package/dist/daemon/systemd.js +266 -0
- package/dist/discord/index.js +2 -0
- package/dist/discord/monitor.js +1188 -0
- package/dist/discord/probe.js +54 -0
- package/dist/discord/send.js +577 -0
- package/dist/discord/token.js +8 -0
- package/dist/gateway/auth.js +121 -0
- package/dist/gateway/call.js +94 -0
- package/dist/gateway/chat-attachments.js +41 -0
- package/dist/gateway/client.js +180 -0
- package/dist/gateway/config-reload.js +274 -0
- package/dist/gateway/control-ui.js +184 -0
- package/dist/gateway/hooks-mapping.js +282 -0
- package/dist/gateway/hooks.js +168 -0
- package/dist/gateway/net.js +29 -0
- package/dist/gateway/protocol/index.js +61 -0
- package/dist/gateway/protocol/schema.js +560 -0
- package/dist/gateway/server-bridge-subscriptions.js +93 -0
- package/dist/gateway/server-bridge.js +1013 -0
- package/dist/gateway/server-browser.js +12 -0
- package/dist/gateway/server-chat.js +159 -0
- package/dist/gateway/server-constants.js +8 -0
- package/dist/gateway/server-discovery.js +62 -0
- package/dist/gateway/server-http.js +165 -0
- package/dist/gateway/server-methods/agent-job.js +125 -0
- package/dist/gateway/server-methods/agent.js +250 -0
- package/dist/gateway/server-methods/chat.js +200 -0
- package/dist/gateway/server-methods/config.js +50 -0
- package/dist/gateway/server-methods/connect.js +6 -0
- package/dist/gateway/server-methods/cron.js +83 -0
- package/dist/gateway/server-methods/health.js +28 -0
- package/dist/gateway/server-methods/models.js +16 -0
- package/dist/gateway/server-methods/nodes.js +294 -0
- package/dist/gateway/server-methods/providers.js +217 -0
- package/dist/gateway/server-methods/send.js +166 -0
- package/dist/gateway/server-methods/sessions.js +305 -0
- package/dist/gateway/server-methods/skills.js +83 -0
- package/dist/gateway/server-methods/system.js +118 -0
- package/dist/gateway/server-methods/talk.js +22 -0
- package/dist/gateway/server-methods/types.js +1 -0
- package/dist/gateway/server-methods/voicewake.js +30 -0
- package/dist/gateway/server-methods/web.js +58 -0
- package/dist/gateway/server-methods/wizard.js +100 -0
- package/dist/gateway/server-methods.js +53 -0
- package/dist/gateway/server-providers.js +644 -0
- package/dist/gateway/server-shared.js +1 -0
- package/dist/gateway/server-utils.js +35 -0
- package/dist/gateway/server.js +1437 -0
- package/dist/gateway/session-utils.js +216 -0
- package/dist/gateway/ws-log.js +349 -0
- package/dist/gateway/ws-logging.js +8 -0
- package/dist/globals.js +41 -0
- package/dist/hooks/gmail-ops.js +236 -0
- package/dist/hooks/gmail-setup-utils.js +278 -0
- package/dist/hooks/gmail-watcher.js +175 -0
- package/dist/hooks/gmail.js +177 -0
- package/dist/imessage/client.js +165 -0
- package/dist/imessage/index.js +3 -0
- package/dist/imessage/monitor.js +272 -0
- package/dist/imessage/probe.js +26 -0
- package/dist/imessage/send.js +83 -0
- package/dist/imessage/targets.js +176 -0
- package/dist/index.js +50 -0
- package/dist/infra/agent-events.js +46 -0
- package/dist/infra/binaries.js +9 -0
- package/dist/infra/bonjour-discovery.js +163 -0
- package/dist/infra/bonjour.js +200 -0
- package/dist/infra/bridge/server.js +562 -0
- package/dist/infra/canvas-host-url.js +54 -0
- package/dist/infra/env.js +8 -0
- package/dist/infra/errors.js +28 -0
- package/dist/infra/gateway-lock.js +8 -0
- package/dist/infra/heartbeat-events.js +21 -0
- package/dist/infra/heartbeat-runner.js +453 -0
- package/dist/infra/heartbeat-wake.js +61 -0
- package/dist/infra/is-main.js +37 -0
- package/dist/infra/machine-name.js +40 -0
- package/dist/infra/node-pairing.js +211 -0
- package/dist/infra/pam.js +42 -0
- package/dist/infra/path-env.js +92 -0
- package/dist/infra/ports.js +87 -0
- package/dist/infra/provider-summary.js +80 -0
- package/dist/infra/restart.js +29 -0
- package/dist/infra/retry.js +16 -0
- package/dist/infra/runtime-guard.js +59 -0
- package/dist/infra/system-events.js +44 -0
- package/dist/infra/system-presence.js +216 -0
- package/dist/infra/tailnet.js +46 -0
- package/dist/infra/tailscale.js +149 -0
- package/dist/infra/voicewake.js +77 -0
- package/dist/infra/widearea-dns.js +123 -0
- package/dist/infra/ws.js +13 -0
- package/dist/logger.js +52 -0
- package/dist/logging.js +490 -0
- package/dist/macos/gateway-daemon.js +141 -0
- package/dist/macos/relay.js +46 -0
- package/dist/media/constants.js +33 -0
- package/dist/media/host.js +42 -0
- package/dist/media/image-ops.js +121 -0
- package/dist/media/mime.js +115 -0
- package/dist/media/parse.js +81 -0
- package/dist/media/server.js +64 -0
- package/dist/media/store.js +139 -0
- package/dist/process/command-queue.js +97 -0
- package/dist/process/exec.js +75 -0
- package/dist/protocol.schema.json +2918 -0
- package/dist/provider-web.js +8 -0
- package/dist/providers/web/index.js +2 -0
- package/dist/runtime.js +8 -0
- package/dist/sessions/send-policy.js +68 -0
- package/dist/signal/client.js +134 -0
- package/dist/signal/daemon.js +69 -0
- package/dist/signal/index.js +3 -0
- package/dist/signal/monitor.js +336 -0
- package/dist/signal/probe.js +46 -0
- package/dist/signal/send.js +91 -0
- package/dist/slack/actions.js +97 -0
- package/dist/slack/index.js +5 -0
- package/dist/slack/monitor.js +1029 -0
- package/dist/slack/probe.js +47 -0
- package/dist/slack/send.js +131 -0
- package/dist/slack/token.js +10 -0
- package/dist/telegram/bot.js +394 -0
- package/dist/telegram/download.js +34 -0
- package/dist/telegram/index.js +4 -0
- package/dist/telegram/monitor.js +47 -0
- package/dist/telegram/probe.js +63 -0
- package/dist/telegram/proxy.js +9 -0
- package/dist/telegram/send.js +138 -0
- package/dist/telegram/token.js +30 -0
- package/dist/telegram/webhook-set.js +12 -0
- package/dist/telegram/webhook.js +56 -0
- package/dist/tui/commands.js +74 -0
- package/dist/tui/components/assistant-message.js +16 -0
- package/dist/tui/components/chat-log.js +92 -0
- package/dist/tui/components/custom-editor.js +53 -0
- package/dist/tui/components/selectors.js +8 -0
- package/dist/tui/components/tool-execution.js +111 -0
- package/dist/tui/components/user-message.js +17 -0
- package/dist/tui/gateway-chat.js +140 -0
- package/dist/tui/layout.js +41 -0
- package/dist/tui/message-list.js +57 -0
- package/dist/tui/theme/theme.js +80 -0
- package/dist/tui/theme.js +25 -0
- package/dist/tui/tui.js +708 -0
- package/dist/utils.js +133 -0
- package/dist/version.js +18 -0
- package/dist/web/active-listener.js +7 -0
- package/dist/web/auto-reply.js +1203 -0
- package/dist/web/inbound.js +481 -0
- package/dist/web/login-qr.js +204 -0
- package/dist/web/login.js +59 -0
- package/dist/web/media.js +148 -0
- package/dist/web/outbound.js +67 -0
- package/dist/web/qr-image.js +97 -0
- package/dist/web/reconnect.js +60 -0
- package/dist/web/reply-heartbeat-wake.js +61 -0
- package/dist/web/session.js +346 -0
- package/dist/wizard/clack-prompter.js +56 -0
- package/dist/wizard/onboarding.js +452 -0
- package/dist/wizard/prompts.js +6 -0
- package/dist/wizard/session.js +203 -0
- package/docs/AGENTS.default.md +116 -0
- package/docs/CNAME +1 -0
- package/docs/RELEASING.md +64 -0
- package/docs/_config.yml +51 -0
- package/docs/_layouts/default.html +145 -0
- package/docs/agent-send.md +21 -0
- package/docs/agent.md +104 -0
- package/docs/android/connect.md +131 -0
- package/docs/architecture.md +89 -0
- package/docs/assets/markdown.css +130 -0
- package/docs/assets/pixel-lobster.svg +60 -0
- package/docs/assets/terminal.css +497 -0
- package/docs/assets/theme.js +55 -0
- package/docs/audio.md +50 -0
- package/docs/background-process.md +74 -0
- package/docs/bash.md +32 -0
- package/docs/bonjour.md +159 -0
- package/docs/browser.md +289 -0
- package/docs/camera.md +152 -0
- package/docs/clawd.md +199 -0
- package/docs/clawdbot-mac.md +104 -0
- package/docs/configuration.md +1177 -0
- package/docs/control-api.md +49 -0
- package/docs/control-ui.md +83 -0
- package/docs/cron.md +374 -0
- package/docs/dashboard.md +17 -0
- package/docs/device-models.md +46 -0
- package/docs/discord.md +293 -0
- package/docs/discovery.md +112 -0
- package/docs/docker.md +251 -0
- package/docs/docs.json +86 -0
- package/docs/doctor.md +47 -0
- package/docs/elevated.md +31 -0
- package/docs/faq.md +640 -0
- package/docs/gateway/pairing.md +109 -0
- package/docs/gateway-lock.md +28 -0
- package/docs/gateway.md +174 -0
- package/docs/gmail-pubsub.md +191 -0
- package/docs/grammy.md +27 -0
- package/docs/group-messages.md +71 -0
- package/docs/groups.md +78 -0
- package/docs/health.md +28 -0
- package/docs/heartbeat.md +64 -0
- package/docs/images.md +52 -0
- package/docs/imessage.md +63 -0
- package/docs/index.md +182 -0
- package/docs/ios/connect.md +177 -0
- package/docs/ios/spec.md +236 -0
- package/docs/location-command.md +95 -0
- package/docs/logging.md +99 -0
- package/docs/lore.md +131 -0
- package/docs/mac/bun.md +133 -0
- package/docs/mac/canvas.md +161 -0
- package/docs/mac/child-process.md +72 -0
- package/docs/mac/dev-setup.md +81 -0
- package/docs/mac/health.md +28 -0
- package/docs/mac/icon.md +26 -0
- package/docs/mac/logging.md +51 -0
- package/docs/mac/menu-bar.md +69 -0
- package/docs/mac/peekaboo.md +170 -0
- package/docs/mac/permissions.md +40 -0
- package/docs/mac/release.md +76 -0
- package/docs/mac/remote.md +57 -0
- package/docs/mac/signing.md +41 -0
- package/docs/mac/skills.md +27 -0
- package/docs/mac/voice-overlay.md +52 -0
- package/docs/mac/voicewake.md +56 -0
- package/docs/mac/webchat.md +27 -0
- package/docs/mac/xpc.md +40 -0
- package/docs/models.md +90 -0
- package/docs/nix.md +49 -0
- package/docs/nodes.md +157 -0
- package/docs/onboarding-config-protocol.md +29 -0
- package/docs/onboarding.md +185 -0
- package/docs/presence.md +133 -0
- package/docs/queue.md +78 -0
- package/docs/refactor/browser-control-simplification.md +58 -0
- package/docs/refactor/canvas-a2ui.md +93 -0
- package/docs/refactor/cli-unification.md +64 -0
- package/docs/refactor/gateway-client.md +31 -0
- package/docs/refactor/gateway.md +99 -0
- package/docs/refactor/new-arch.md +171 -0
- package/docs/refactor/tui.md +26 -0
- package/docs/refactor/web-gateway-troubleshooting.md +37 -0
- package/docs/refactor/webagent-session.md +46 -0
- package/docs/remote-gateway-readme.md +148 -0
- package/docs/remote.md +66 -0
- package/docs/research/memory.md +227 -0
- package/docs/rpc.md +35 -0
- package/docs/security.md +168 -0
- package/docs/session-tool.md +119 -0
- package/docs/session.md +84 -0
- package/docs/sessions.md +8 -0
- package/docs/setup.md +118 -0
- package/docs/signal.md +113 -0
- package/docs/skills-config.md +58 -0
- package/docs/skills.md +149 -0
- package/docs/slack.md +158 -0
- package/docs/surface.md +20 -0
- package/docs/tailscale.md +71 -0
- package/docs/talk.md +79 -0
- package/docs/telegram.md +90 -0
- package/docs/templates/AGENTS.md +126 -0
- package/docs/templates/BOOTSTRAP.md +53 -0
- package/docs/templates/IDENTITY.md +17 -0
- package/docs/templates/SOUL.md +41 -0
- package/docs/templates/TOOLS.md +41 -0
- package/docs/templates/USER.md +22 -0
- package/docs/test.md +35 -0
- package/docs/thinking.md +46 -0
- package/docs/tools.md +248 -0
- package/docs/troubleshooting.md +227 -0
- package/docs/tui.md +69 -0
- package/docs/typebox.md +42 -0
- package/docs/voicewake.md +61 -0
- package/docs/web.md +115 -0
- package/docs/webchat.md +34 -0
- package/docs/webhook.md +132 -0
- package/docs/whatsapp-clawd.jpg +0 -0
- package/docs/whatsapp.md +142 -0
- package/docs/wizard.md +158 -0
- package/package.json +186 -0
- package/skills/apple-notes/SKILL.md +50 -0
- package/skills/apple-reminders/SKILL.md +67 -0
- package/skills/bear-notes/SKILL.md +79 -0
- package/skills/bird/SKILL.md +25 -0
- package/skills/blogwatcher/SKILL.md +46 -0
- package/skills/blucli/SKILL.md +27 -0
- package/skills/brave-search/SKILL.md +30 -0
- package/skills/brave-search/scripts/content.mjs +53 -0
- package/skills/brave-search/scripts/search.mjs +79 -0
- package/skills/camsnap/SKILL.md +25 -0
- package/skills/clawdhub/SKILL.md +53 -0
- package/skills/coding-agent/SKILL.md +275 -0
- package/skills/discord/SKILL.md +369 -0
- package/skills/eightctl/SKILL.md +29 -0
- package/skills/food-order/SKILL.md +41 -0
- package/skills/gemini/SKILL.md +23 -0
- package/skills/gifgrep/SKILL.md +47 -0
- package/skills/github/SKILL.md +47 -0
- package/skills/gog/SKILL.md +36 -0
- package/skills/goplaces/SKILL.md +30 -0
- package/skills/imsg/SKILL.md +25 -0
- package/skills/local-places/SERVER_README.md +101 -0
- package/skills/local-places/SKILL.md +91 -0
- package/skills/local-places/pyproject.toml +27 -0
- package/skills/local-places/src/local_places/__init__.py +2 -0
- package/skills/local-places/src/local_places/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/local-places/src/local_places/__pycache__/google_places.cpython-314.pyc +0 -0
- package/skills/local-places/src/local_places/__pycache__/main.cpython-314.pyc +0 -0
- package/skills/local-places/src/local_places/__pycache__/schemas.cpython-314.pyc +0 -0
- package/skills/local-places/src/local_places/google_places.py +314 -0
- package/skills/local-places/src/local_places/main.py +65 -0
- package/skills/local-places/src/local_places/schemas.py +107 -0
- package/skills/mcporter/SKILL.md +38 -0
- package/skills/nano-banana-pro/SKILL.md +29 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +167 -0
- package/skills/nano-pdf/SKILL.md +20 -0
- package/skills/notion/SKILL.md +156 -0
- package/skills/obsidian/SKILL.md +55 -0
- package/skills/openai-image-gen/SKILL.md +31 -0
- package/skills/openai-image-gen/scripts/gen.py +173 -0
- package/skills/openai-whisper/SKILL.md +19 -0
- package/skills/openai-whisper-api/SKILL.md +43 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
- package/skills/openhue/SKILL.md +30 -0
- package/skills/oracle/SKILL.md +105 -0
- package/skills/ordercli/SKILL.md +47 -0
- package/skills/peekaboo/SKILL.md +153 -0
- package/skills/qmd/SKILL.md +26 -0
- package/skills/sag/SKILL.md +62 -0
- package/skills/slack/SKILL.md +143 -0
- package/skills/songsee/SKILL.md +29 -0
- package/skills/sonoscli/SKILL.md +26 -0
- package/skills/spotify-player/SKILL.md +34 -0
- package/skills/summarize/SKILL.md +49 -0
- package/skills/things-mac/SKILL.md +61 -0
- package/skills/tmux/SKILL.md +121 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +84 -0
- package/skills/video-frames/SKILL.md +29 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/wacli/SKILL.md +42 -0
- package/skills/weather/SKILL.md +49 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { approveNodePairing, listNodePairing, rejectNodePairing, renamePairedNode, requestNodePairing, verifyNodeToken, } from "../../infra/node-pairing.js";
|
|
2
|
+
import { ErrorCodes, errorShape, formatValidationErrors, validateNodeDescribeParams, validateNodeInvokeParams, validateNodeListParams, validateNodePairApproveParams, validateNodePairListParams, validateNodePairRejectParams, validateNodePairRequestParams, validateNodePairVerifyParams, validateNodeRenameParams, } from "../protocol/index.js";
|
|
3
|
+
import { formatForLog } from "../ws-log.js";
|
|
4
|
+
export const nodeHandlers = {
|
|
5
|
+
"node.pair.request": async ({ params, respond, context }) => {
|
|
6
|
+
if (!validateNodePairRequestParams(params)) {
|
|
7
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.pair.request params: ${formatValidationErrors(validateNodePairRequestParams.errors)}`));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const p = params;
|
|
11
|
+
try {
|
|
12
|
+
const result = await requestNodePairing({
|
|
13
|
+
nodeId: p.nodeId,
|
|
14
|
+
displayName: p.displayName,
|
|
15
|
+
platform: p.platform,
|
|
16
|
+
version: p.version,
|
|
17
|
+
deviceFamily: p.deviceFamily,
|
|
18
|
+
modelIdentifier: p.modelIdentifier,
|
|
19
|
+
caps: p.caps,
|
|
20
|
+
commands: p.commands,
|
|
21
|
+
remoteIp: p.remoteIp,
|
|
22
|
+
silent: p.silent,
|
|
23
|
+
});
|
|
24
|
+
if (result.status === "pending" && result.created) {
|
|
25
|
+
context.broadcast("node.pair.requested", result.request, {
|
|
26
|
+
dropIfSlow: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
respond(true, result, undefined);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"node.pair.list": async ({ params, respond }) => {
|
|
36
|
+
if (!validateNodePairListParams(params)) {
|
|
37
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.pair.list params: ${formatValidationErrors(validateNodePairListParams.errors)}`));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const list = await listNodePairing();
|
|
42
|
+
respond(true, list, undefined);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"node.pair.approve": async ({ params, respond, context }) => {
|
|
49
|
+
if (!validateNodePairApproveParams(params)) {
|
|
50
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.pair.approve params: ${formatValidationErrors(validateNodePairApproveParams.errors)}`));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const { requestId } = params;
|
|
54
|
+
try {
|
|
55
|
+
const approved = await approveNodePairing(requestId);
|
|
56
|
+
if (!approved) {
|
|
57
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "unknown requestId"));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
context.broadcast("node.pair.resolved", {
|
|
61
|
+
requestId,
|
|
62
|
+
nodeId: approved.node.nodeId,
|
|
63
|
+
decision: "approved",
|
|
64
|
+
ts: Date.now(),
|
|
65
|
+
}, { dropIfSlow: true });
|
|
66
|
+
respond(true, approved, undefined);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"node.pair.reject": async ({ params, respond, context }) => {
|
|
73
|
+
if (!validateNodePairRejectParams(params)) {
|
|
74
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.pair.reject params: ${formatValidationErrors(validateNodePairRejectParams.errors)}`));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const { requestId } = params;
|
|
78
|
+
try {
|
|
79
|
+
const rejected = await rejectNodePairing(requestId);
|
|
80
|
+
if (!rejected) {
|
|
81
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "unknown requestId"));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
context.broadcast("node.pair.resolved", {
|
|
85
|
+
requestId,
|
|
86
|
+
nodeId: rejected.nodeId,
|
|
87
|
+
decision: "rejected",
|
|
88
|
+
ts: Date.now(),
|
|
89
|
+
}, { dropIfSlow: true });
|
|
90
|
+
respond(true, rejected, undefined);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"node.pair.verify": async ({ params, respond }) => {
|
|
97
|
+
if (!validateNodePairVerifyParams(params)) {
|
|
98
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.pair.verify params: ${formatValidationErrors(validateNodePairVerifyParams.errors)}`));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const { nodeId, token } = params;
|
|
102
|
+
try {
|
|
103
|
+
const result = await verifyNodeToken(nodeId, token);
|
|
104
|
+
respond(true, result, undefined);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"node.rename": async ({ params, respond }) => {
|
|
111
|
+
if (!validateNodeRenameParams(params)) {
|
|
112
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.rename params: ${formatValidationErrors(validateNodeRenameParams.errors)}`));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const { nodeId, displayName } = params;
|
|
116
|
+
try {
|
|
117
|
+
const trimmed = displayName.trim();
|
|
118
|
+
if (!trimmed) {
|
|
119
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "displayName required"));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const updated = await renamePairedNode(nodeId, trimmed);
|
|
123
|
+
if (!updated) {
|
|
124
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "unknown nodeId"));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
respond(true, { nodeId: updated.nodeId, displayName: updated.displayName }, undefined);
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"node.list": async ({ params, respond, context }) => {
|
|
134
|
+
if (!validateNodeListParams(params)) {
|
|
135
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.list params: ${formatValidationErrors(validateNodeListParams.errors)}`));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
const list = await listNodePairing();
|
|
140
|
+
const pairedById = new Map(list.paired.map((n) => [n.nodeId, n]));
|
|
141
|
+
const connected = context.bridge?.listConnected?.() ?? [];
|
|
142
|
+
const connectedById = new Map(connected.map((n) => [n.nodeId, n]));
|
|
143
|
+
const nodeIds = new Set([
|
|
144
|
+
...pairedById.keys(),
|
|
145
|
+
...connectedById.keys(),
|
|
146
|
+
]);
|
|
147
|
+
const nodes = [...nodeIds].map((nodeId) => {
|
|
148
|
+
const paired = pairedById.get(nodeId);
|
|
149
|
+
const live = connectedById.get(nodeId);
|
|
150
|
+
const caps = [
|
|
151
|
+
...new Set((live?.caps ?? paired?.caps ?? [])
|
|
152
|
+
.map((c) => String(c).trim())
|
|
153
|
+
.filter(Boolean)),
|
|
154
|
+
].sort();
|
|
155
|
+
const commands = [
|
|
156
|
+
...new Set((live?.commands ?? paired?.commands ?? [])
|
|
157
|
+
.map((c) => String(c).trim())
|
|
158
|
+
.filter(Boolean)),
|
|
159
|
+
].sort();
|
|
160
|
+
return {
|
|
161
|
+
nodeId,
|
|
162
|
+
displayName: live?.displayName ?? paired?.displayName,
|
|
163
|
+
platform: live?.platform ?? paired?.platform,
|
|
164
|
+
version: live?.version ?? paired?.version,
|
|
165
|
+
deviceFamily: live?.deviceFamily ?? paired?.deviceFamily,
|
|
166
|
+
modelIdentifier: live?.modelIdentifier ?? paired?.modelIdentifier,
|
|
167
|
+
remoteIp: live?.remoteIp ?? paired?.remoteIp,
|
|
168
|
+
caps,
|
|
169
|
+
commands,
|
|
170
|
+
permissions: live?.permissions ?? paired?.permissions,
|
|
171
|
+
paired: Boolean(paired),
|
|
172
|
+
connected: Boolean(live),
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
nodes.sort((a, b) => {
|
|
176
|
+
if (a.connected !== b.connected)
|
|
177
|
+
return a.connected ? -1 : 1;
|
|
178
|
+
const an = (a.displayName ?? a.nodeId).toLowerCase();
|
|
179
|
+
const bn = (b.displayName ?? b.nodeId).toLowerCase();
|
|
180
|
+
if (an < bn)
|
|
181
|
+
return -1;
|
|
182
|
+
if (an > bn)
|
|
183
|
+
return 1;
|
|
184
|
+
return a.nodeId.localeCompare(b.nodeId);
|
|
185
|
+
});
|
|
186
|
+
respond(true, { ts: Date.now(), nodes }, undefined);
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
189
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"node.describe": async ({ params, respond, context }) => {
|
|
193
|
+
if (!validateNodeDescribeParams(params)) {
|
|
194
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.describe params: ${formatValidationErrors(validateNodeDescribeParams.errors)}`));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const { nodeId } = params;
|
|
198
|
+
const id = String(nodeId ?? "").trim();
|
|
199
|
+
if (!id) {
|
|
200
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "nodeId required"));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const list = await listNodePairing();
|
|
205
|
+
const paired = list.paired.find((n) => n.nodeId === id);
|
|
206
|
+
const connected = context.bridge?.listConnected?.() ?? [];
|
|
207
|
+
const live = connected.find((n) => n.nodeId === id);
|
|
208
|
+
if (!paired && !live) {
|
|
209
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "unknown nodeId"));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const caps = [
|
|
213
|
+
...new Set((live?.caps ?? paired?.caps ?? [])
|
|
214
|
+
.map((c) => String(c).trim())
|
|
215
|
+
.filter(Boolean)),
|
|
216
|
+
].sort();
|
|
217
|
+
const commands = [
|
|
218
|
+
...new Set((live?.commands ?? paired?.commands ?? [])
|
|
219
|
+
.map((c) => String(c).trim())
|
|
220
|
+
.filter(Boolean)),
|
|
221
|
+
].sort();
|
|
222
|
+
respond(true, {
|
|
223
|
+
ts: Date.now(),
|
|
224
|
+
nodeId: id,
|
|
225
|
+
displayName: live?.displayName ?? paired?.displayName,
|
|
226
|
+
platform: live?.platform ?? paired?.platform,
|
|
227
|
+
version: live?.version ?? paired?.version,
|
|
228
|
+
deviceFamily: live?.deviceFamily ?? paired?.deviceFamily,
|
|
229
|
+
modelIdentifier: live?.modelIdentifier ?? paired?.modelIdentifier,
|
|
230
|
+
remoteIp: live?.remoteIp ?? paired?.remoteIp,
|
|
231
|
+
caps,
|
|
232
|
+
commands,
|
|
233
|
+
permissions: live?.permissions ?? paired?.permissions,
|
|
234
|
+
paired: Boolean(paired),
|
|
235
|
+
connected: Boolean(live),
|
|
236
|
+
}, undefined);
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
"node.invoke": async ({ params, respond, context }) => {
|
|
243
|
+
if (!validateNodeInvokeParams(params)) {
|
|
244
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid node.invoke params: ${formatValidationErrors(validateNodeInvokeParams.errors)}`));
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (!context.bridge) {
|
|
248
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, "bridge not running"));
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const p = params;
|
|
252
|
+
const nodeId = String(p.nodeId ?? "").trim();
|
|
253
|
+
const command = String(p.command ?? "").trim();
|
|
254
|
+
if (!nodeId || !command) {
|
|
255
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "nodeId and command required"));
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
const paramsJSON = "params" in p && p.params !== undefined
|
|
260
|
+
? JSON.stringify(p.params)
|
|
261
|
+
: null;
|
|
262
|
+
const res = await context.bridge.invoke({
|
|
263
|
+
nodeId,
|
|
264
|
+
command,
|
|
265
|
+
paramsJSON,
|
|
266
|
+
timeoutMs: p.timeoutMs,
|
|
267
|
+
});
|
|
268
|
+
if (!res.ok) {
|
|
269
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, res.error?.message ?? "node invoke failed", { details: { nodeError: res.error ?? null } }));
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const payload = typeof res.payloadJSON === "string" && res.payloadJSON.trim()
|
|
273
|
+
? (() => {
|
|
274
|
+
try {
|
|
275
|
+
return JSON.parse(res.payloadJSON);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return { payloadJSON: res.payloadJSON };
|
|
279
|
+
}
|
|
280
|
+
})()
|
|
281
|
+
: undefined;
|
|
282
|
+
respond(true, {
|
|
283
|
+
ok: true,
|
|
284
|
+
nodeId,
|
|
285
|
+
command,
|
|
286
|
+
payload,
|
|
287
|
+
payloadJSON: res.payloadJSON ?? null,
|
|
288
|
+
}, undefined);
|
|
289
|
+
}
|
|
290
|
+
catch (err) {
|
|
291
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { loadConfig, readConfigFileSnapshot, writeConfigFile, } from "../../config/config.js";
|
|
2
|
+
import { probeDiscord } from "../../discord/probe.js";
|
|
3
|
+
import { probeIMessage } from "../../imessage/probe.js";
|
|
4
|
+
import { webAuthExists } from "../../providers/web/index.js";
|
|
5
|
+
import { probeSignal } from "../../signal/probe.js";
|
|
6
|
+
import { probeSlack } from "../../slack/probe.js";
|
|
7
|
+
import { resolveSlackAppToken, resolveSlackBotToken, } from "../../slack/token.js";
|
|
8
|
+
import { probeTelegram } from "../../telegram/probe.js";
|
|
9
|
+
import { resolveTelegramToken } from "../../telegram/token.js";
|
|
10
|
+
import { getWebAuthAgeMs, readWebSelfId } from "../../web/session.js";
|
|
11
|
+
import { ErrorCodes, errorShape, formatValidationErrors, validateProvidersStatusParams, } from "../protocol/index.js";
|
|
12
|
+
import { formatForLog } from "../ws-log.js";
|
|
13
|
+
export const providersHandlers = {
|
|
14
|
+
"providers.status": async ({ params, respond, context }) => {
|
|
15
|
+
if (!validateProvidersStatusParams(params)) {
|
|
16
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid providers.status params: ${formatValidationErrors(validateProvidersStatusParams.errors)}`));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const probe = params.probe === true;
|
|
20
|
+
const timeoutMsRaw = params.timeoutMs;
|
|
21
|
+
const timeoutMs = typeof timeoutMsRaw === "number" ? Math.max(1000, timeoutMsRaw) : 10_000;
|
|
22
|
+
const cfg = loadConfig();
|
|
23
|
+
const telegramCfg = cfg.telegram;
|
|
24
|
+
const telegramEnabled = Boolean(telegramCfg) && telegramCfg?.enabled !== false;
|
|
25
|
+
const { token: telegramToken, source: tokenSource } = telegramEnabled
|
|
26
|
+
? resolveTelegramToken(cfg)
|
|
27
|
+
: { token: "", source: "none" };
|
|
28
|
+
let telegramProbe;
|
|
29
|
+
let lastProbeAt = null;
|
|
30
|
+
if (probe && telegramToken && telegramEnabled) {
|
|
31
|
+
telegramProbe = await probeTelegram(telegramToken, timeoutMs, telegramCfg?.proxy);
|
|
32
|
+
lastProbeAt = Date.now();
|
|
33
|
+
}
|
|
34
|
+
const discordCfg = cfg.discord;
|
|
35
|
+
const discordEnabled = Boolean(discordCfg) && discordCfg?.enabled !== false;
|
|
36
|
+
const discordEnvToken = discordEnabled
|
|
37
|
+
? process.env.DISCORD_BOT_TOKEN?.trim()
|
|
38
|
+
: "";
|
|
39
|
+
const discordConfigToken = discordEnabled ? discordCfg?.token?.trim() : "";
|
|
40
|
+
const discordToken = discordEnvToken || discordConfigToken || "";
|
|
41
|
+
const discordTokenSource = discordEnvToken
|
|
42
|
+
? "env"
|
|
43
|
+
: discordConfigToken
|
|
44
|
+
? "config"
|
|
45
|
+
: "none";
|
|
46
|
+
let discordProbe;
|
|
47
|
+
let discordLastProbeAt = null;
|
|
48
|
+
if (probe && discordToken && discordEnabled) {
|
|
49
|
+
discordProbe = await probeDiscord(discordToken, timeoutMs);
|
|
50
|
+
discordLastProbeAt = Date.now();
|
|
51
|
+
}
|
|
52
|
+
const slackCfg = cfg.slack;
|
|
53
|
+
const slackEnabled = slackCfg?.enabled !== false;
|
|
54
|
+
const slackBotEnvToken = slackEnabled
|
|
55
|
+
? resolveSlackBotToken(process.env.SLACK_BOT_TOKEN)
|
|
56
|
+
: undefined;
|
|
57
|
+
const slackBotConfigToken = slackEnabled
|
|
58
|
+
? resolveSlackBotToken(slackCfg?.botToken)
|
|
59
|
+
: undefined;
|
|
60
|
+
const slackBotToken = slackBotEnvToken ?? slackBotConfigToken ?? "";
|
|
61
|
+
const slackBotTokenSource = slackBotEnvToken
|
|
62
|
+
? "env"
|
|
63
|
+
: slackBotConfigToken
|
|
64
|
+
? "config"
|
|
65
|
+
: "none";
|
|
66
|
+
const slackAppEnvToken = slackEnabled
|
|
67
|
+
? resolveSlackAppToken(process.env.SLACK_APP_TOKEN)
|
|
68
|
+
: undefined;
|
|
69
|
+
const slackAppConfigToken = slackEnabled
|
|
70
|
+
? resolveSlackAppToken(slackCfg?.appToken)
|
|
71
|
+
: undefined;
|
|
72
|
+
const slackAppToken = slackAppEnvToken ?? slackAppConfigToken ?? "";
|
|
73
|
+
const slackAppTokenSource = slackAppEnvToken
|
|
74
|
+
? "env"
|
|
75
|
+
: slackAppConfigToken
|
|
76
|
+
? "config"
|
|
77
|
+
: "none";
|
|
78
|
+
const slackConfigured = slackEnabled && Boolean(slackBotToken) && Boolean(slackAppToken);
|
|
79
|
+
let slackProbe;
|
|
80
|
+
let slackLastProbeAt = null;
|
|
81
|
+
if (probe && slackConfigured) {
|
|
82
|
+
slackProbe = await probeSlack(slackBotToken, timeoutMs);
|
|
83
|
+
slackLastProbeAt = Date.now();
|
|
84
|
+
}
|
|
85
|
+
const signalCfg = cfg.signal;
|
|
86
|
+
const signalEnabled = signalCfg?.enabled !== false;
|
|
87
|
+
const signalHost = signalCfg?.httpHost?.trim() || "127.0.0.1";
|
|
88
|
+
const signalPort = signalCfg?.httpPort ?? 8080;
|
|
89
|
+
const signalBaseUrl = signalCfg?.httpUrl?.trim() || `http://${signalHost}:${signalPort}`;
|
|
90
|
+
const signalConfigured = Boolean(signalCfg) &&
|
|
91
|
+
signalEnabled &&
|
|
92
|
+
Boolean(signalCfg?.account?.trim() ||
|
|
93
|
+
signalCfg?.httpUrl?.trim() ||
|
|
94
|
+
signalCfg?.cliPath?.trim() ||
|
|
95
|
+
signalCfg?.httpHost?.trim() ||
|
|
96
|
+
typeof signalCfg?.httpPort === "number" ||
|
|
97
|
+
typeof signalCfg?.autoStart === "boolean");
|
|
98
|
+
let signalProbe;
|
|
99
|
+
let signalLastProbeAt = null;
|
|
100
|
+
if (probe && signalConfigured) {
|
|
101
|
+
signalProbe = await probeSignal(signalBaseUrl, timeoutMs);
|
|
102
|
+
signalLastProbeAt = Date.now();
|
|
103
|
+
}
|
|
104
|
+
const imessageCfg = cfg.imessage;
|
|
105
|
+
const imessageEnabled = imessageCfg?.enabled !== false;
|
|
106
|
+
const imessageConfigured = Boolean(imessageCfg) && imessageEnabled;
|
|
107
|
+
let imessageProbe;
|
|
108
|
+
let imessageLastProbeAt = null;
|
|
109
|
+
if (probe && imessageConfigured) {
|
|
110
|
+
imessageProbe = await probeIMessage(timeoutMs);
|
|
111
|
+
imessageLastProbeAt = Date.now();
|
|
112
|
+
}
|
|
113
|
+
const linked = await webAuthExists();
|
|
114
|
+
const authAgeMs = getWebAuthAgeMs();
|
|
115
|
+
const self = readWebSelfId();
|
|
116
|
+
const runtime = context.getRuntimeSnapshot();
|
|
117
|
+
respond(true, {
|
|
118
|
+
ts: Date.now(),
|
|
119
|
+
whatsapp: {
|
|
120
|
+
configured: linked,
|
|
121
|
+
linked,
|
|
122
|
+
authAgeMs,
|
|
123
|
+
self,
|
|
124
|
+
running: runtime.whatsapp.running,
|
|
125
|
+
connected: runtime.whatsapp.connected,
|
|
126
|
+
lastConnectedAt: runtime.whatsapp.lastConnectedAt ?? null,
|
|
127
|
+
lastDisconnect: runtime.whatsapp.lastDisconnect ?? null,
|
|
128
|
+
reconnectAttempts: runtime.whatsapp.reconnectAttempts,
|
|
129
|
+
lastMessageAt: runtime.whatsapp.lastMessageAt ?? null,
|
|
130
|
+
lastEventAt: runtime.whatsapp.lastEventAt ?? null,
|
|
131
|
+
lastError: runtime.whatsapp.lastError ?? null,
|
|
132
|
+
},
|
|
133
|
+
telegram: {
|
|
134
|
+
configured: telegramEnabled && Boolean(telegramToken),
|
|
135
|
+
tokenSource,
|
|
136
|
+
running: runtime.telegram.running,
|
|
137
|
+
mode: runtime.telegram.mode ?? null,
|
|
138
|
+
lastStartAt: runtime.telegram.lastStartAt ?? null,
|
|
139
|
+
lastStopAt: runtime.telegram.lastStopAt ?? null,
|
|
140
|
+
lastError: runtime.telegram.lastError ?? null,
|
|
141
|
+
probe: telegramProbe,
|
|
142
|
+
lastProbeAt,
|
|
143
|
+
},
|
|
144
|
+
discord: {
|
|
145
|
+
configured: discordEnabled && Boolean(discordToken),
|
|
146
|
+
tokenSource: discordTokenSource,
|
|
147
|
+
running: runtime.discord.running,
|
|
148
|
+
lastStartAt: runtime.discord.lastStartAt ?? null,
|
|
149
|
+
lastStopAt: runtime.discord.lastStopAt ?? null,
|
|
150
|
+
lastError: runtime.discord.lastError ?? null,
|
|
151
|
+
probe: discordProbe,
|
|
152
|
+
lastProbeAt: discordLastProbeAt,
|
|
153
|
+
},
|
|
154
|
+
slack: {
|
|
155
|
+
configured: slackConfigured,
|
|
156
|
+
botTokenSource: slackBotTokenSource,
|
|
157
|
+
appTokenSource: slackAppTokenSource,
|
|
158
|
+
running: runtime.slack.running,
|
|
159
|
+
lastStartAt: runtime.slack.lastStartAt ?? null,
|
|
160
|
+
lastStopAt: runtime.slack.lastStopAt ?? null,
|
|
161
|
+
lastError: runtime.slack.lastError ?? null,
|
|
162
|
+
probe: slackProbe,
|
|
163
|
+
lastProbeAt: slackLastProbeAt,
|
|
164
|
+
},
|
|
165
|
+
signal: {
|
|
166
|
+
configured: signalConfigured,
|
|
167
|
+
baseUrl: signalBaseUrl,
|
|
168
|
+
running: runtime.signal.running,
|
|
169
|
+
lastStartAt: runtime.signal.lastStartAt ?? null,
|
|
170
|
+
lastStopAt: runtime.signal.lastStopAt ?? null,
|
|
171
|
+
lastError: runtime.signal.lastError ?? null,
|
|
172
|
+
probe: signalProbe,
|
|
173
|
+
lastProbeAt: signalLastProbeAt,
|
|
174
|
+
},
|
|
175
|
+
imessage: {
|
|
176
|
+
configured: imessageConfigured,
|
|
177
|
+
running: runtime.imessage.running,
|
|
178
|
+
lastStartAt: runtime.imessage.lastStartAt ?? null,
|
|
179
|
+
lastStopAt: runtime.imessage.lastStopAt ?? null,
|
|
180
|
+
lastError: runtime.imessage.lastError ?? null,
|
|
181
|
+
cliPath: runtime.imessage.cliPath ?? null,
|
|
182
|
+
dbPath: runtime.imessage.dbPath ?? null,
|
|
183
|
+
probe: imessageProbe,
|
|
184
|
+
lastProbeAt: imessageLastProbeAt,
|
|
185
|
+
},
|
|
186
|
+
}, undefined);
|
|
187
|
+
},
|
|
188
|
+
"telegram.logout": async ({ respond, context }) => {
|
|
189
|
+
try {
|
|
190
|
+
await context.stopTelegramProvider();
|
|
191
|
+
const snapshot = await readConfigFileSnapshot();
|
|
192
|
+
if (!snapshot.valid) {
|
|
193
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "config invalid; fix it before logging out"));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const cfg = snapshot.config ?? {};
|
|
197
|
+
const envToken = process.env.TELEGRAM_BOT_TOKEN?.trim() ?? "";
|
|
198
|
+
const hadToken = Boolean(cfg.telegram?.botToken);
|
|
199
|
+
const nextTelegram = cfg.telegram ? { ...cfg.telegram } : undefined;
|
|
200
|
+
if (nextTelegram) {
|
|
201
|
+
delete nextTelegram.botToken;
|
|
202
|
+
}
|
|
203
|
+
const nextCfg = { ...cfg };
|
|
204
|
+
if (nextTelegram && Object.keys(nextTelegram).length > 0) {
|
|
205
|
+
nextCfg.telegram = nextTelegram;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
delete nextCfg.telegram;
|
|
209
|
+
}
|
|
210
|
+
await writeConfigFile(nextCfg);
|
|
211
|
+
respond(true, { cleared: hadToken, envToken: Boolean(envToken) }, undefined);
|
|
212
|
+
}
|
|
213
|
+
catch (err) {
|
|
214
|
+
respond(false, undefined, errorShape(ErrorCodes.UNAVAILABLE, formatForLog(err)));
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { loadConfig } from "../../config/config.js";
|
|
2
|
+
import { sendMessageDiscord } from "../../discord/index.js";
|
|
3
|
+
import { shouldLogVerbose } from "../../globals.js";
|
|
4
|
+
import { sendMessageIMessage } from "../../imessage/index.js";
|
|
5
|
+
import { sendMessageSignal } from "../../signal/index.js";
|
|
6
|
+
import { sendMessageSlack } from "../../slack/send.js";
|
|
7
|
+
import { sendMessageTelegram } from "../../telegram/send.js";
|
|
8
|
+
import { resolveTelegramToken } from "../../telegram/token.js";
|
|
9
|
+
import { sendMessageWhatsApp } from "../../web/outbound.js";
|
|
10
|
+
import { ErrorCodes, errorShape, formatValidationErrors, validateSendParams, } from "../protocol/index.js";
|
|
11
|
+
import { formatForLog } from "../ws-log.js";
|
|
12
|
+
export const sendHandlers = {
|
|
13
|
+
send: async ({ params, respond, context }) => {
|
|
14
|
+
const p = params;
|
|
15
|
+
if (!validateSendParams(p)) {
|
|
16
|
+
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, `invalid send params: ${formatValidationErrors(validateSendParams.errors)}`));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const request = p;
|
|
20
|
+
const idem = request.idempotencyKey;
|
|
21
|
+
const cached = context.dedupe.get(`send:${idem}`);
|
|
22
|
+
if (cached) {
|
|
23
|
+
respond(cached.ok, cached.payload, cached.error, {
|
|
24
|
+
cached: true,
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const to = request.to.trim();
|
|
29
|
+
const message = request.message.trim();
|
|
30
|
+
const providerRaw = (request.provider ?? "whatsapp").toLowerCase();
|
|
31
|
+
const provider = providerRaw === "imsg" ? "imessage" : providerRaw;
|
|
32
|
+
try {
|
|
33
|
+
if (provider === "telegram") {
|
|
34
|
+
const cfg = loadConfig();
|
|
35
|
+
const { token } = resolveTelegramToken(cfg);
|
|
36
|
+
const result = await sendMessageTelegram(to, message, {
|
|
37
|
+
mediaUrl: request.mediaUrl,
|
|
38
|
+
verbose: shouldLogVerbose(),
|
|
39
|
+
token: token || undefined,
|
|
40
|
+
});
|
|
41
|
+
const payload = {
|
|
42
|
+
runId: idem,
|
|
43
|
+
messageId: result.messageId,
|
|
44
|
+
chatId: result.chatId,
|
|
45
|
+
provider,
|
|
46
|
+
};
|
|
47
|
+
context.dedupe.set(`send:${idem}`, {
|
|
48
|
+
ts: Date.now(),
|
|
49
|
+
ok: true,
|
|
50
|
+
payload,
|
|
51
|
+
});
|
|
52
|
+
respond(true, payload, undefined, { provider });
|
|
53
|
+
}
|
|
54
|
+
else if (provider === "discord") {
|
|
55
|
+
const result = await sendMessageDiscord(to, message, {
|
|
56
|
+
mediaUrl: request.mediaUrl,
|
|
57
|
+
token: process.env.DISCORD_BOT_TOKEN,
|
|
58
|
+
});
|
|
59
|
+
const payload = {
|
|
60
|
+
runId: idem,
|
|
61
|
+
messageId: result.messageId,
|
|
62
|
+
channelId: result.channelId,
|
|
63
|
+
provider,
|
|
64
|
+
};
|
|
65
|
+
context.dedupe.set(`send:${idem}`, {
|
|
66
|
+
ts: Date.now(),
|
|
67
|
+
ok: true,
|
|
68
|
+
payload,
|
|
69
|
+
});
|
|
70
|
+
respond(true, payload, undefined, { provider });
|
|
71
|
+
}
|
|
72
|
+
else if (provider === "slack") {
|
|
73
|
+
const result = await sendMessageSlack(to, message, {
|
|
74
|
+
mediaUrl: request.mediaUrl,
|
|
75
|
+
});
|
|
76
|
+
const payload = {
|
|
77
|
+
runId: idem,
|
|
78
|
+
messageId: result.messageId,
|
|
79
|
+
channelId: result.channelId,
|
|
80
|
+
provider,
|
|
81
|
+
};
|
|
82
|
+
context.dedupe.set(`send:${idem}`, {
|
|
83
|
+
ts: Date.now(),
|
|
84
|
+
ok: true,
|
|
85
|
+
payload,
|
|
86
|
+
});
|
|
87
|
+
respond(true, payload, undefined, { provider });
|
|
88
|
+
}
|
|
89
|
+
else if (provider === "signal") {
|
|
90
|
+
const cfg = loadConfig();
|
|
91
|
+
const host = cfg.signal?.httpHost?.trim() || "127.0.0.1";
|
|
92
|
+
const port = cfg.signal?.httpPort ?? 8080;
|
|
93
|
+
const baseUrl = cfg.signal?.httpUrl?.trim() || `http://${host}:${port}`;
|
|
94
|
+
const result = await sendMessageSignal(to, message, {
|
|
95
|
+
mediaUrl: request.mediaUrl,
|
|
96
|
+
baseUrl,
|
|
97
|
+
account: cfg.signal?.account,
|
|
98
|
+
});
|
|
99
|
+
const payload = {
|
|
100
|
+
runId: idem,
|
|
101
|
+
messageId: result.messageId,
|
|
102
|
+
provider,
|
|
103
|
+
};
|
|
104
|
+
context.dedupe.set(`send:${idem}`, {
|
|
105
|
+
ts: Date.now(),
|
|
106
|
+
ok: true,
|
|
107
|
+
payload,
|
|
108
|
+
});
|
|
109
|
+
respond(true, payload, undefined, { provider });
|
|
110
|
+
}
|
|
111
|
+
else if (provider === "imessage") {
|
|
112
|
+
const cfg = loadConfig();
|
|
113
|
+
const result = await sendMessageIMessage(to, message, {
|
|
114
|
+
mediaUrl: request.mediaUrl,
|
|
115
|
+
cliPath: cfg.imessage?.cliPath,
|
|
116
|
+
dbPath: cfg.imessage?.dbPath,
|
|
117
|
+
maxBytes: cfg.imessage?.mediaMaxMb
|
|
118
|
+
? cfg.imessage.mediaMaxMb * 1024 * 1024
|
|
119
|
+
: undefined,
|
|
120
|
+
});
|
|
121
|
+
const payload = {
|
|
122
|
+
runId: idem,
|
|
123
|
+
messageId: result.messageId,
|
|
124
|
+
provider,
|
|
125
|
+
};
|
|
126
|
+
context.dedupe.set(`send:${idem}`, {
|
|
127
|
+
ts: Date.now(),
|
|
128
|
+
ok: true,
|
|
129
|
+
payload,
|
|
130
|
+
});
|
|
131
|
+
respond(true, payload, undefined, { provider });
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const result = await sendMessageWhatsApp(to, message, {
|
|
135
|
+
mediaUrl: request.mediaUrl,
|
|
136
|
+
verbose: shouldLogVerbose(),
|
|
137
|
+
gifPlayback: request.gifPlayback,
|
|
138
|
+
});
|
|
139
|
+
const payload = {
|
|
140
|
+
runId: idem,
|
|
141
|
+
messageId: result.messageId,
|
|
142
|
+
toJid: result.toJid ?? `${to}@s.whatsapp.net`,
|
|
143
|
+
provider,
|
|
144
|
+
};
|
|
145
|
+
context.dedupe.set(`send:${idem}`, {
|
|
146
|
+
ts: Date.now(),
|
|
147
|
+
ok: true,
|
|
148
|
+
payload,
|
|
149
|
+
});
|
|
150
|
+
respond(true, payload, undefined, { provider });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
const error = errorShape(ErrorCodes.UNAVAILABLE, String(err));
|
|
155
|
+
context.dedupe.set(`send:${idem}`, {
|
|
156
|
+
ts: Date.now(),
|
|
157
|
+
ok: false,
|
|
158
|
+
error,
|
|
159
|
+
});
|
|
160
|
+
respond(false, undefined, error, {
|
|
161
|
+
provider,
|
|
162
|
+
error: formatForLog(err),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
};
|