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,63 @@
|
|
|
1
|
+
import { makeProxyFetch } from "./proxy.js";
|
|
2
|
+
const TELEGRAM_API_BASE = "https://api.telegram.org";
|
|
3
|
+
async function fetchWithTimeout(url, timeoutMs, fetcher) {
|
|
4
|
+
const controller = new AbortController();
|
|
5
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
6
|
+
try {
|
|
7
|
+
return await fetcher(url, { signal: controller.signal });
|
|
8
|
+
}
|
|
9
|
+
finally {
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export async function probeTelegram(token, timeoutMs, proxyUrl) {
|
|
14
|
+
const started = Date.now();
|
|
15
|
+
const fetcher = proxyUrl ? makeProxyFetch(proxyUrl) : fetch;
|
|
16
|
+
const base = `${TELEGRAM_API_BASE}/bot${token}`;
|
|
17
|
+
const result = {
|
|
18
|
+
ok: false,
|
|
19
|
+
status: null,
|
|
20
|
+
error: null,
|
|
21
|
+
elapsedMs: 0,
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
const meRes = await fetchWithTimeout(`${base}/getMe`, timeoutMs, fetcher);
|
|
25
|
+
const meJson = (await meRes.json());
|
|
26
|
+
if (!meRes.ok || !meJson?.ok) {
|
|
27
|
+
result.status = meRes.status;
|
|
28
|
+
result.error = meJson?.description ?? `getMe failed (${meRes.status})`;
|
|
29
|
+
return { ...result, elapsedMs: Date.now() - started };
|
|
30
|
+
}
|
|
31
|
+
result.bot = {
|
|
32
|
+
id: meJson.result?.id ?? null,
|
|
33
|
+
username: meJson.result?.username ?? null,
|
|
34
|
+
};
|
|
35
|
+
// Try to fetch webhook info, but don't fail health if it errors.
|
|
36
|
+
try {
|
|
37
|
+
const webhookRes = await fetchWithTimeout(`${base}/getWebhookInfo`, timeoutMs, fetcher);
|
|
38
|
+
const webhookJson = (await webhookRes.json());
|
|
39
|
+
if (webhookRes.ok && webhookJson?.ok) {
|
|
40
|
+
result.webhook = {
|
|
41
|
+
url: webhookJson.result?.url ?? null,
|
|
42
|
+
hasCustomCert: webhookJson.result?.has_custom_certificate ?? null,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// ignore webhook errors for probe
|
|
48
|
+
}
|
|
49
|
+
result.ok = true;
|
|
50
|
+
result.status = null;
|
|
51
|
+
result.error = null;
|
|
52
|
+
result.elapsedMs = Date.now() - started;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
return {
|
|
57
|
+
...result,
|
|
58
|
+
status: err instanceof Response ? err.status : result.status,
|
|
59
|
+
error: err instanceof Error ? err.message : String(err),
|
|
60
|
+
elapsedMs: Date.now() - started,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { ProxyAgent } from "undici";
|
|
3
|
+
export function makeProxyFetch(proxyUrl) {
|
|
4
|
+
const agent = new ProxyAgent(proxyUrl);
|
|
5
|
+
return (input, init) => {
|
|
6
|
+
const base = init ? { ...init } : {};
|
|
7
|
+
return fetch(input, { ...base, dispatcher: agent });
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Bot, InputFile } from "grammy";
|
|
3
|
+
import { formatErrorMessage } from "../infra/errors.js";
|
|
4
|
+
import { mediaKindFromMime } from "../media/constants.js";
|
|
5
|
+
import { loadWebMedia } from "../web/media.js";
|
|
6
|
+
const PARSE_ERR_RE = /can't parse entities|parse entities|find end of the entity/i;
|
|
7
|
+
function resolveToken(explicit) {
|
|
8
|
+
const token = explicit ?? process.env.TELEGRAM_BOT_TOKEN;
|
|
9
|
+
if (!token) {
|
|
10
|
+
throw new Error("TELEGRAM_BOT_TOKEN is required for Telegram sends (Bot API)");
|
|
11
|
+
}
|
|
12
|
+
return token.trim();
|
|
13
|
+
}
|
|
14
|
+
function normalizeChatId(to) {
|
|
15
|
+
const trimmed = to.trim();
|
|
16
|
+
if (!trimmed)
|
|
17
|
+
throw new Error("Recipient is required for Telegram sends");
|
|
18
|
+
// Common internal prefixes that sometimes leak into outbound sends.
|
|
19
|
+
// - ctx.To uses `telegram:<id>`
|
|
20
|
+
// - group sessions often use `telegram:group:<id>`
|
|
21
|
+
let normalized = trimmed.replace(/^(telegram|tg|group):/i, "").trim();
|
|
22
|
+
// Accept t.me links for public chats/channels.
|
|
23
|
+
// (Invite links like `t.me/+...` are not resolvable via Bot API.)
|
|
24
|
+
const m = /^https?:\/\/t\.me\/([A-Za-z0-9_]+)$/i.exec(normalized) ??
|
|
25
|
+
/^t\.me\/([A-Za-z0-9_]+)$/i.exec(normalized);
|
|
26
|
+
if (m?.[1])
|
|
27
|
+
normalized = `@${m[1]}`;
|
|
28
|
+
if (!normalized)
|
|
29
|
+
throw new Error("Recipient is required for Telegram sends");
|
|
30
|
+
if (normalized.startsWith("@"))
|
|
31
|
+
return normalized;
|
|
32
|
+
if (/^-?\d+$/.test(normalized))
|
|
33
|
+
return normalized;
|
|
34
|
+
// If the user passed a username without `@`, assume they meant a public chat/channel.
|
|
35
|
+
if (/^[A-Za-z0-9_]{5,}$/i.test(normalized))
|
|
36
|
+
return `@${normalized}`;
|
|
37
|
+
return normalized;
|
|
38
|
+
}
|
|
39
|
+
export async function sendMessageTelegram(to, text, opts = {}) {
|
|
40
|
+
const token = resolveToken(opts.token);
|
|
41
|
+
const chatId = normalizeChatId(to);
|
|
42
|
+
const bot = opts.api ? null : new Bot(token);
|
|
43
|
+
const api = opts.api ?? bot?.api;
|
|
44
|
+
const mediaUrl = opts.mediaUrl?.trim();
|
|
45
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
46
|
+
const sendWithRetry = async (fn, label) => {
|
|
47
|
+
let lastErr;
|
|
48
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
49
|
+
try {
|
|
50
|
+
return await fn();
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
lastErr = err;
|
|
54
|
+
const errText = formatErrorMessage(err);
|
|
55
|
+
const terminal = attempt === 3 ||
|
|
56
|
+
!/429|timeout|connect|reset|closed|unavailable|temporarily/i.test(errText);
|
|
57
|
+
if (terminal)
|
|
58
|
+
break;
|
|
59
|
+
const backoff = 400 * attempt;
|
|
60
|
+
if (opts.verbose) {
|
|
61
|
+
console.warn(`telegram send retry ${attempt}/2 for ${label} in ${backoff}ms: ${errText}`);
|
|
62
|
+
}
|
|
63
|
+
await sleep(backoff);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw lastErr ?? new Error(`Telegram send failed (${label})`);
|
|
67
|
+
};
|
|
68
|
+
const wrapChatNotFound = (err) => {
|
|
69
|
+
if (!/400: Bad Request: chat not found/i.test(formatErrorMessage(err)))
|
|
70
|
+
return err;
|
|
71
|
+
return new Error([
|
|
72
|
+
`Telegram send failed: chat not found (chat_id=${chatId}).`,
|
|
73
|
+
"Likely: bot not started in DM, bot removed from group/channel, group migrated (new -100… id), or wrong bot token.",
|
|
74
|
+
`Input was: ${JSON.stringify(to)}.`,
|
|
75
|
+
].join(" "));
|
|
76
|
+
};
|
|
77
|
+
if (mediaUrl) {
|
|
78
|
+
const media = await loadWebMedia(mediaUrl, opts.maxBytes);
|
|
79
|
+
const kind = mediaKindFromMime(media.contentType ?? undefined);
|
|
80
|
+
const file = new InputFile(media.buffer, media.fileName ?? inferFilename(kind) ?? "file");
|
|
81
|
+
const caption = text?.trim() || undefined;
|
|
82
|
+
let result;
|
|
83
|
+
if (kind === "image") {
|
|
84
|
+
result = await sendWithRetry(() => api.sendPhoto(chatId, file, { caption }), "photo").catch((err) => {
|
|
85
|
+
throw wrapChatNotFound(err);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else if (kind === "video") {
|
|
89
|
+
result = await sendWithRetry(() => api.sendVideo(chatId, file, { caption }), "video").catch((err) => {
|
|
90
|
+
throw wrapChatNotFound(err);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else if (kind === "audio") {
|
|
94
|
+
result = await sendWithRetry(() => api.sendAudio(chatId, file, { caption }), "audio").catch((err) => {
|
|
95
|
+
throw wrapChatNotFound(err);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
result = await sendWithRetry(() => api.sendDocument(chatId, file, { caption }), "document").catch((err) => {
|
|
100
|
+
throw wrapChatNotFound(err);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const messageId = String(result?.message_id ?? "unknown");
|
|
104
|
+
return { messageId, chatId: String(result?.chat?.id ?? chatId) };
|
|
105
|
+
}
|
|
106
|
+
if (!text || !text.trim()) {
|
|
107
|
+
throw new Error("Message must be non-empty for Telegram sends");
|
|
108
|
+
}
|
|
109
|
+
const res = await sendWithRetry(() => api.sendMessage(chatId, text, { parse_mode: "Markdown" }), "message").catch(async (err) => {
|
|
110
|
+
// Telegram rejects malformed Markdown (e.g., unbalanced '_' or '*').
|
|
111
|
+
// When that happens, fall back to plain text so the message still delivers.
|
|
112
|
+
const errText = formatErrorMessage(err);
|
|
113
|
+
if (PARSE_ERR_RE.test(errText)) {
|
|
114
|
+
if (opts.verbose) {
|
|
115
|
+
console.warn(`telegram markdown parse failed, retrying as plain text: ${errText}`);
|
|
116
|
+
}
|
|
117
|
+
return await sendWithRetry(() => api.sendMessage(chatId, text), "message-plain").catch((err2) => {
|
|
118
|
+
throw wrapChatNotFound(err2);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
throw wrapChatNotFound(err);
|
|
122
|
+
});
|
|
123
|
+
const messageId = String(res?.message_id ?? "unknown");
|
|
124
|
+
return { messageId, chatId: String(res?.chat?.id ?? chatId) };
|
|
125
|
+
}
|
|
126
|
+
function inferFilename(kind) {
|
|
127
|
+
switch (kind) {
|
|
128
|
+
case "image":
|
|
129
|
+
return "image.jpg";
|
|
130
|
+
case "video":
|
|
131
|
+
return "video.mp4";
|
|
132
|
+
case "audio":
|
|
133
|
+
return "audio.ogg";
|
|
134
|
+
default:
|
|
135
|
+
return "file.bin";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// @ts-nocheck
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
export function resolveTelegramToken(cfg, opts = {}) {
|
|
3
|
+
const envToken = (opts.envToken ?? process.env.TELEGRAM_BOT_TOKEN)?.trim();
|
|
4
|
+
if (envToken) {
|
|
5
|
+
return { token: envToken, source: "env" };
|
|
6
|
+
}
|
|
7
|
+
const tokenFile = cfg?.telegram?.tokenFile?.trim();
|
|
8
|
+
if (tokenFile) {
|
|
9
|
+
if (!fs.existsSync(tokenFile)) {
|
|
10
|
+
opts.logMissingFile?.(`telegram.tokenFile not found: ${tokenFile}`);
|
|
11
|
+
return { token: "", source: "none" };
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const token = fs.readFileSync(tokenFile, "utf-8").trim();
|
|
15
|
+
if (token) {
|
|
16
|
+
return { token, source: "tokenFile" };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
opts.logMissingFile?.(`telegram.tokenFile read failed: ${String(err)}`);
|
|
21
|
+
return { token: "", source: "none" };
|
|
22
|
+
}
|
|
23
|
+
return { token: "", source: "none" };
|
|
24
|
+
}
|
|
25
|
+
const configToken = cfg?.telegram?.botToken?.trim();
|
|
26
|
+
if (configToken) {
|
|
27
|
+
return { token: configToken, source: "config" };
|
|
28
|
+
}
|
|
29
|
+
return { token: "", source: "none" };
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Bot } from "grammy";
|
|
2
|
+
export async function setTelegramWebhook(opts) {
|
|
3
|
+
const bot = new Bot(opts.token);
|
|
4
|
+
await bot.api.setWebhook(opts.url, {
|
|
5
|
+
secret_token: opts.secret,
|
|
6
|
+
drop_pending_updates: opts.dropPendingUpdates ?? false,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export async function deleteTelegramWebhook(opts) {
|
|
10
|
+
const bot = new Bot(opts.token);
|
|
11
|
+
await bot.api.deleteWebhook();
|
|
12
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import { webhookCallback } from "grammy";
|
|
3
|
+
import { formatErrorMessage } from "../infra/errors.js";
|
|
4
|
+
import { defaultRuntime } from "../runtime.js";
|
|
5
|
+
import { createTelegramBot } from "./bot.js";
|
|
6
|
+
export async function startTelegramWebhook(opts) {
|
|
7
|
+
const path = opts.path ?? "/telegram-webhook";
|
|
8
|
+
const healthPath = opts.healthPath ?? "/healthz";
|
|
9
|
+
const port = opts.port ?? 8787;
|
|
10
|
+
const host = opts.host ?? "0.0.0.0";
|
|
11
|
+
const runtime = opts.runtime ?? defaultRuntime;
|
|
12
|
+
const bot = createTelegramBot({
|
|
13
|
+
token: opts.token,
|
|
14
|
+
runtime,
|
|
15
|
+
proxyFetch: opts.fetch,
|
|
16
|
+
});
|
|
17
|
+
const handler = webhookCallback(bot, "http", {
|
|
18
|
+
secretToken: opts.secret,
|
|
19
|
+
});
|
|
20
|
+
const server = createServer((req, res) => {
|
|
21
|
+
if (req.url === healthPath) {
|
|
22
|
+
res.writeHead(200);
|
|
23
|
+
res.end("ok");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (req.url !== path || req.method !== "POST") {
|
|
27
|
+
res.writeHead(404);
|
|
28
|
+
res.end();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const handled = handler(req, res);
|
|
32
|
+
if (handled && typeof handled.catch === "function") {
|
|
33
|
+
void handled.catch((err) => {
|
|
34
|
+
runtime.log?.(`webhook handler failed: ${formatErrorMessage(err)}`);
|
|
35
|
+
if (!res.headersSent)
|
|
36
|
+
res.writeHead(500);
|
|
37
|
+
res.end();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const publicUrl = opts.publicUrl ??
|
|
42
|
+
`http://${host === "0.0.0.0" ? "localhost" : host}:${port}${path}`;
|
|
43
|
+
await bot.api.setWebhook(publicUrl, {
|
|
44
|
+
secret_token: opts.secret,
|
|
45
|
+
});
|
|
46
|
+
await new Promise((resolve) => server.listen(port, host, resolve));
|
|
47
|
+
runtime.log?.(`webhook listening on ${publicUrl}`);
|
|
48
|
+
const shutdown = () => {
|
|
49
|
+
server.close();
|
|
50
|
+
void bot.stop();
|
|
51
|
+
};
|
|
52
|
+
if (opts.abortSignal) {
|
|
53
|
+
opts.abortSignal.addEventListener("abort", shutdown, { once: true });
|
|
54
|
+
}
|
|
55
|
+
return { server, bot, stop: shutdown };
|
|
56
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const THINK_LEVELS = ["off", "minimal", "low", "medium", "high"];
|
|
2
|
+
const VERBOSE_LEVELS = ["on", "off"];
|
|
3
|
+
const ELEVATED_LEVELS = ["on", "off"];
|
|
4
|
+
const ACTIVATION_LEVELS = ["mention", "always"];
|
|
5
|
+
const TOGGLE = ["on", "off"];
|
|
6
|
+
export function parseCommand(input) {
|
|
7
|
+
const trimmed = input.replace(/^\//, "").trim();
|
|
8
|
+
if (!trimmed)
|
|
9
|
+
return { name: "", args: "" };
|
|
10
|
+
const [name, ...rest] = trimmed.split(/\s+/);
|
|
11
|
+
return { name: name.toLowerCase(), args: rest.join(" ").trim() };
|
|
12
|
+
}
|
|
13
|
+
export function getSlashCommands() {
|
|
14
|
+
return [
|
|
15
|
+
{ name: "help", description: "Show slash command help" },
|
|
16
|
+
{ name: "status", description: "Show gateway status summary" },
|
|
17
|
+
{ name: "session", description: "Switch session (or open picker)" },
|
|
18
|
+
{ name: "sessions", description: "Open session picker" },
|
|
19
|
+
{
|
|
20
|
+
name: "model",
|
|
21
|
+
description: "Set model (or open picker)",
|
|
22
|
+
},
|
|
23
|
+
{ name: "models", description: "Open model picker" },
|
|
24
|
+
{
|
|
25
|
+
name: "think",
|
|
26
|
+
description: "Set thinking level",
|
|
27
|
+
getArgumentCompletions: (prefix) => THINK_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({ value, label: value })),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "verbose",
|
|
31
|
+
description: "Set verbose on/off",
|
|
32
|
+
getArgumentCompletions: (prefix) => VERBOSE_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({ value, label: value })),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "elevated",
|
|
36
|
+
description: "Set elevated on/off",
|
|
37
|
+
getArgumentCompletions: (prefix) => ELEVATED_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({ value, label: value })),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "activation",
|
|
41
|
+
description: "Set group activation",
|
|
42
|
+
getArgumentCompletions: (prefix) => ACTIVATION_LEVELS.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({ value, label: value })),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "deliver",
|
|
46
|
+
description: "Toggle delivery of assistant replies",
|
|
47
|
+
getArgumentCompletions: (prefix) => TOGGLE.filter((v) => v.startsWith(prefix.toLowerCase())).map((value) => ({ value, label: value })),
|
|
48
|
+
},
|
|
49
|
+
{ name: "abort", description: "Abort active run" },
|
|
50
|
+
{ name: "new", description: "Reset the session" },
|
|
51
|
+
{ name: "reset", description: "Reset the session" },
|
|
52
|
+
{ name: "settings", description: "Open settings" },
|
|
53
|
+
{ name: "exit", description: "Exit the TUI" },
|
|
54
|
+
{ name: "quit", description: "Exit the TUI" },
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
export function helpText() {
|
|
58
|
+
return [
|
|
59
|
+
"Slash commands:",
|
|
60
|
+
"/help",
|
|
61
|
+
"/status",
|
|
62
|
+
"/session <key> (or /sessions)",
|
|
63
|
+
"/model <provider/model> (or /models)",
|
|
64
|
+
"/think <off|minimal|low|medium|high>",
|
|
65
|
+
"/verbose <on|off>",
|
|
66
|
+
"/elevated <on|off>",
|
|
67
|
+
"/activation <mention|always>",
|
|
68
|
+
"/deliver <on|off>",
|
|
69
|
+
"/new or /reset",
|
|
70
|
+
"/abort",
|
|
71
|
+
"/settings",
|
|
72
|
+
"/exit",
|
|
73
|
+
].join("\n");
|
|
74
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Container, Markdown, Spacer } from "@mariozechner/pi-tui";
|
|
2
|
+
import { markdownTheme, theme } from "../theme/theme.js";
|
|
3
|
+
export class AssistantMessageComponent extends Container {
|
|
4
|
+
body;
|
|
5
|
+
constructor(text) {
|
|
6
|
+
super();
|
|
7
|
+
this.body = new Markdown(text, 1, 0, markdownTheme, {
|
|
8
|
+
color: (line) => theme.fg(line),
|
|
9
|
+
});
|
|
10
|
+
this.addChild(new Spacer(1));
|
|
11
|
+
this.addChild(this.body);
|
|
12
|
+
}
|
|
13
|
+
setText(text) {
|
|
14
|
+
this.body.setText(text);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Container, Spacer, Text } from "@mariozechner/pi-tui";
|
|
2
|
+
import { theme } from "../theme/theme.js";
|
|
3
|
+
import { AssistantMessageComponent } from "./assistant-message.js";
|
|
4
|
+
import { ToolExecutionComponent } from "./tool-execution.js";
|
|
5
|
+
import { UserMessageComponent } from "./user-message.js";
|
|
6
|
+
export class ChatLog extends Container {
|
|
7
|
+
toolById = new Map();
|
|
8
|
+
streamingAssistant = null;
|
|
9
|
+
streamingRunId = null;
|
|
10
|
+
streamingText = null;
|
|
11
|
+
toolsExpanded = false;
|
|
12
|
+
clearAll() {
|
|
13
|
+
this.clear();
|
|
14
|
+
this.toolById.clear();
|
|
15
|
+
this.streamingAssistant = null;
|
|
16
|
+
this.streamingRunId = null;
|
|
17
|
+
this.streamingText = null;
|
|
18
|
+
}
|
|
19
|
+
addSystem(text) {
|
|
20
|
+
this.addChild(new Spacer(1));
|
|
21
|
+
this.addChild(new Text(theme.system(text), 1, 0));
|
|
22
|
+
}
|
|
23
|
+
addUser(text) {
|
|
24
|
+
this.addChild(new UserMessageComponent(text));
|
|
25
|
+
}
|
|
26
|
+
startAssistant(text, runId) {
|
|
27
|
+
const component = new AssistantMessageComponent(text);
|
|
28
|
+
this.streamingAssistant = component;
|
|
29
|
+
this.streamingRunId = runId ?? null;
|
|
30
|
+
this.streamingText = text;
|
|
31
|
+
this.addChild(component);
|
|
32
|
+
return component;
|
|
33
|
+
}
|
|
34
|
+
updateAssistant(text, runId) {
|
|
35
|
+
if (!this.streamingAssistant ||
|
|
36
|
+
(runId && this.streamingRunId && runId !== this.streamingRunId)) {
|
|
37
|
+
this.startAssistant(text, runId);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.streamingText = text;
|
|
41
|
+
this.streamingAssistant.setText(text);
|
|
42
|
+
}
|
|
43
|
+
finalizeAssistant(text, runId) {
|
|
44
|
+
if (this.streamingAssistant &&
|
|
45
|
+
(!runId || runId === this.streamingRunId || text === this.streamingText)) {
|
|
46
|
+
this.streamingText = text;
|
|
47
|
+
this.streamingAssistant.setText(text);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.startAssistant(text, runId);
|
|
51
|
+
}
|
|
52
|
+
this.streamingAssistant = null;
|
|
53
|
+
this.streamingRunId = null;
|
|
54
|
+
this.streamingText = null;
|
|
55
|
+
}
|
|
56
|
+
startTool(toolCallId, toolName, args) {
|
|
57
|
+
const existing = this.toolById.get(toolCallId);
|
|
58
|
+
if (existing) {
|
|
59
|
+
existing.setArgs(args);
|
|
60
|
+
return existing;
|
|
61
|
+
}
|
|
62
|
+
const component = new ToolExecutionComponent(toolName, args);
|
|
63
|
+
component.setExpanded(this.toolsExpanded);
|
|
64
|
+
this.toolById.set(toolCallId, component);
|
|
65
|
+
this.addChild(component);
|
|
66
|
+
return component;
|
|
67
|
+
}
|
|
68
|
+
updateToolArgs(toolCallId, args) {
|
|
69
|
+
const existing = this.toolById.get(toolCallId);
|
|
70
|
+
if (!existing)
|
|
71
|
+
return;
|
|
72
|
+
existing.setArgs(args);
|
|
73
|
+
}
|
|
74
|
+
updateToolResult(toolCallId, result, opts) {
|
|
75
|
+
const existing = this.toolById.get(toolCallId);
|
|
76
|
+
if (!existing)
|
|
77
|
+
return;
|
|
78
|
+
if (opts?.partial) {
|
|
79
|
+
existing.setPartialResult(result);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
existing.setResult(result, {
|
|
83
|
+
isError: opts?.isError,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
setToolsExpanded(expanded) {
|
|
87
|
+
this.toolsExpanded = expanded;
|
|
88
|
+
for (const tool of this.toolById.values()) {
|
|
89
|
+
tool.setExpanded(expanded);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Editor, isAltEnter, isCtrlC, isCtrlD, isCtrlL, isCtrlO, isCtrlP, isCtrlT, isEscape, isShiftTab, } from "@mariozechner/pi-tui";
|
|
2
|
+
export class CustomEditor extends Editor {
|
|
3
|
+
onEscape;
|
|
4
|
+
onCtrlC;
|
|
5
|
+
onCtrlD;
|
|
6
|
+
onCtrlL;
|
|
7
|
+
onCtrlO;
|
|
8
|
+
onCtrlP;
|
|
9
|
+
onCtrlT;
|
|
10
|
+
onShiftTab;
|
|
11
|
+
onAltEnter;
|
|
12
|
+
handleInput(data) {
|
|
13
|
+
if (isAltEnter(data) && this.onAltEnter) {
|
|
14
|
+
this.onAltEnter();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (isCtrlL(data) && this.onCtrlL) {
|
|
18
|
+
this.onCtrlL();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (isCtrlO(data) && this.onCtrlO) {
|
|
22
|
+
this.onCtrlO();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (isCtrlP(data) && this.onCtrlP) {
|
|
26
|
+
this.onCtrlP();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (isCtrlT(data) && this.onCtrlT) {
|
|
30
|
+
this.onCtrlT();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (isShiftTab(data) && this.onShiftTab) {
|
|
34
|
+
this.onShiftTab();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (isEscape(data) && this.onEscape && !this.isShowingAutocomplete()) {
|
|
38
|
+
this.onEscape();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (isCtrlC(data) && this.onCtrlC) {
|
|
42
|
+
this.onCtrlC();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (isCtrlD(data)) {
|
|
46
|
+
if (this.getText().length === 0 && this.onCtrlD) {
|
|
47
|
+
this.onCtrlD();
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
super.handleInput(data);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SelectList, SettingsList, } from "@mariozechner/pi-tui";
|
|
2
|
+
import { selectListTheme, settingsListTheme } from "../theme/theme.js";
|
|
3
|
+
export function createSelectList(items, maxVisible = 7) {
|
|
4
|
+
return new SelectList(items, maxVisible, selectListTheme);
|
|
5
|
+
}
|
|
6
|
+
export function createSettingsList(items, onChange, onCancel, maxVisible = 7) {
|
|
7
|
+
return new SettingsList(items, maxVisible, settingsListTheme, onChange, onCancel);
|
|
8
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Box, Container, Markdown, Spacer, Text } from "@mariozechner/pi-tui";
|
|
2
|
+
import { formatToolDetail, resolveToolDisplay, } from "../../agents/tool-display.js";
|
|
3
|
+
import { markdownTheme, theme } from "../theme/theme.js";
|
|
4
|
+
const PREVIEW_LINES = 12;
|
|
5
|
+
function formatArgs(toolName, args) {
|
|
6
|
+
const display = resolveToolDisplay({ name: toolName, args });
|
|
7
|
+
const detail = formatToolDetail(display);
|
|
8
|
+
if (detail)
|
|
9
|
+
return detail;
|
|
10
|
+
if (!args || typeof args !== "object")
|
|
11
|
+
return "";
|
|
12
|
+
try {
|
|
13
|
+
return JSON.stringify(args);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function extractText(result) {
|
|
20
|
+
if (!result?.content)
|
|
21
|
+
return "";
|
|
22
|
+
const lines = [];
|
|
23
|
+
for (const entry of result.content) {
|
|
24
|
+
if (entry.type === "text" && entry.text) {
|
|
25
|
+
lines.push(entry.text);
|
|
26
|
+
}
|
|
27
|
+
else if (entry.type === "image") {
|
|
28
|
+
const mime = entry.mimeType ?? "image";
|
|
29
|
+
const size = entry.bytes ? ` ${Math.round(entry.bytes / 1024)}kb` : "";
|
|
30
|
+
const omitted = entry.omitted ? " (omitted)" : "";
|
|
31
|
+
lines.push(`[${mime}${size}${omitted}]`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return lines.join("\n").trim();
|
|
35
|
+
}
|
|
36
|
+
export class ToolExecutionComponent extends Container {
|
|
37
|
+
box;
|
|
38
|
+
header;
|
|
39
|
+
argsLine;
|
|
40
|
+
output;
|
|
41
|
+
toolName;
|
|
42
|
+
args;
|
|
43
|
+
result;
|
|
44
|
+
expanded = false;
|
|
45
|
+
isError = false;
|
|
46
|
+
isPartial = true;
|
|
47
|
+
constructor(toolName, args) {
|
|
48
|
+
super();
|
|
49
|
+
this.toolName = toolName;
|
|
50
|
+
this.args = args;
|
|
51
|
+
this.box = new Box(1, 1, (line) => theme.toolPendingBg(line));
|
|
52
|
+
this.header = new Text("", 0, 0);
|
|
53
|
+
this.argsLine = new Text("", 0, 0);
|
|
54
|
+
this.output = new Markdown("", 0, 0, markdownTheme, {
|
|
55
|
+
color: (line) => theme.toolOutput(line),
|
|
56
|
+
});
|
|
57
|
+
this.addChild(new Spacer(1));
|
|
58
|
+
this.addChild(this.box);
|
|
59
|
+
this.box.addChild(this.header);
|
|
60
|
+
this.box.addChild(this.argsLine);
|
|
61
|
+
this.box.addChild(this.output);
|
|
62
|
+
this.refresh();
|
|
63
|
+
}
|
|
64
|
+
setArgs(args) {
|
|
65
|
+
this.args = args;
|
|
66
|
+
this.refresh();
|
|
67
|
+
}
|
|
68
|
+
setExpanded(expanded) {
|
|
69
|
+
this.expanded = expanded;
|
|
70
|
+
this.refresh();
|
|
71
|
+
}
|
|
72
|
+
setResult(result, opts) {
|
|
73
|
+
this.result = result;
|
|
74
|
+
this.isPartial = false;
|
|
75
|
+
this.isError = Boolean(opts?.isError);
|
|
76
|
+
this.refresh();
|
|
77
|
+
}
|
|
78
|
+
setPartialResult(result) {
|
|
79
|
+
this.result = result;
|
|
80
|
+
this.isPartial = true;
|
|
81
|
+
this.refresh();
|
|
82
|
+
}
|
|
83
|
+
refresh() {
|
|
84
|
+
const bg = this.isPartial
|
|
85
|
+
? theme.toolPendingBg
|
|
86
|
+
: this.isError
|
|
87
|
+
? theme.toolErrorBg
|
|
88
|
+
: theme.toolSuccessBg;
|
|
89
|
+
this.box.setBgFn((line) => bg(line));
|
|
90
|
+
const display = resolveToolDisplay({
|
|
91
|
+
name: this.toolName,
|
|
92
|
+
args: this.args,
|
|
93
|
+
});
|
|
94
|
+
const title = `${display.emoji} ${display.label}${this.isPartial ? " (running)" : ""}`;
|
|
95
|
+
this.header.setText(theme.toolTitle(theme.bold(title)));
|
|
96
|
+
const argLine = formatArgs(this.toolName, this.args);
|
|
97
|
+
this.argsLine.setText(argLine ? theme.dim(argLine) : theme.dim(" "));
|
|
98
|
+
const raw = extractText(this.result);
|
|
99
|
+
const text = raw || (this.isPartial ? "…" : "");
|
|
100
|
+
if (!this.expanded && text) {
|
|
101
|
+
const lines = text.split("\n");
|
|
102
|
+
const preview = lines.length > PREVIEW_LINES
|
|
103
|
+
? `${lines.slice(0, PREVIEW_LINES).join("\n")}\n…`
|
|
104
|
+
: text;
|
|
105
|
+
this.output.setText(preview);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.output.setText(text);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|