kctl-waha 0.8.4__tar.gz

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.
Files changed (34) hide show
  1. kctl_waha-0.8.4/.gitignore +33 -0
  2. kctl_waha-0.8.4/PKG-INFO +17 -0
  3. kctl_waha-0.8.4/README.md +70 -0
  4. kctl_waha-0.8.4/pyproject.toml +45 -0
  5. kctl_waha-0.8.4/skills/waha-admin/SKILL.md +213 -0
  6. kctl_waha-0.8.4/src/kctl_waha/__init__.py +5 -0
  7. kctl_waha-0.8.4/src/kctl_waha/__main__.py +7 -0
  8. kctl_waha-0.8.4/src/kctl_waha/cli.py +132 -0
  9. kctl_waha-0.8.4/src/kctl_waha/commands/__init__.py +0 -0
  10. kctl_waha-0.8.4/src/kctl_waha/commands/bridge.py +177 -0
  11. kctl_waha-0.8.4/src/kctl_waha/commands/config_cmd.py +526 -0
  12. kctl_waha-0.8.4/src/kctl_waha/commands/dashboard.py +185 -0
  13. kctl_waha-0.8.4/src/kctl_waha/commands/doctor_cmd.py +57 -0
  14. kctl_waha-0.8.4/src/kctl_waha/commands/health.py +171 -0
  15. kctl_waha-0.8.4/src/kctl_waha/commands/messages.py +123 -0
  16. kctl_waha-0.8.4/src/kctl_waha/commands/sessions.py +359 -0
  17. kctl_waha-0.8.4/src/kctl_waha/commands/skill_cmd.py +76 -0
  18. kctl_waha-0.8.4/src/kctl_waha/commands/webhooks.py +123 -0
  19. kctl_waha-0.8.4/src/kctl_waha/core/__init__.py +0 -0
  20. kctl_waha-0.8.4/src/kctl_waha/core/callbacks.py +46 -0
  21. kctl_waha-0.8.4/src/kctl_waha/core/client.py +131 -0
  22. kctl_waha-0.8.4/src/kctl_waha/core/config.py +172 -0
  23. kctl_waha-0.8.4/src/kctl_waha/core/exceptions.py +23 -0
  24. kctl_waha-0.8.4/src/kctl_waha/core/output.py +7 -0
  25. kctl_waha-0.8.4/tests/conftest.py +69 -0
  26. kctl_waha-0.8.4/tests/test_client.py +45 -0
  27. kctl_waha-0.8.4/tests/test_config.py +38 -0
  28. kctl_waha-0.8.4/tests/test_exceptions.py +40 -0
  29. kctl_waha-0.8.4/tests/test_health.py +232 -0
  30. kctl_waha-0.8.4/tests/test_messages.py +232 -0
  31. kctl_waha-0.8.4/tests/test_sessions.py +386 -0
  32. kctl_waha-0.8.4/tests/test_smoke.py +21 -0
  33. kctl_waha-0.8.4/tests/test_standard.py +57 -0
  34. kctl_waha-0.8.4/tests/test_webhooks.py +287 -0
@@ -0,0 +1,33 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ *.egg
6
+ dist/
7
+ build/
8
+ .eggs/
9
+
10
+ # Virtual environments
11
+ .venv/
12
+ venv/
13
+
14
+ # IDE
15
+ .idea/
16
+ .vscode/
17
+ *.swp
18
+ *.swo
19
+
20
+ # Testing
21
+ .pytest_cache/
22
+ .coverage
23
+ htmlcov/
24
+ .mypy_cache/
25
+ .ruff_cache/
26
+
27
+ # OS
28
+ .DS_Store
29
+ Thumbs.db
30
+
31
+ # Environment
32
+ .env
33
+ .env.local
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: kctl-waha
3
+ Version: 0.8.4
4
+ Summary: Kodemeio WAHA CLI — manage WhatsApp HTTP API instances
5
+ Requires-Python: >=3.12
6
+ Requires-Dist: httpx>=0.28.0
7
+ Requires-Dist: kctl-lib>=0.12.0
8
+ Requires-Dist: pydantic>=2.10.0
9
+ Requires-Dist: pyyaml>=6.0.2
10
+ Requires-Dist: rich>=13.9.0
11
+ Requires-Dist: typer>=0.15.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: mypy>=1.14.0; extra == 'dev'
14
+ Requires-Dist: pytest-httpx>=0.35.0; extra == 'dev'
15
+ Requires-Dist: pytest>=8.3.0; extra == 'dev'
16
+ Requires-Dist: ruff>=0.9.0; extra == 'dev'
17
+ Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
@@ -0,0 +1,70 @@
1
+ # kctl-waha
2
+
3
+ Kodemeio WAHA CLI — manage WhatsApp HTTP API sessions and messaging.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ uv tool install .
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ kctl-waha config init
15
+ kctl-waha health
16
+ kctl-waha dashboard
17
+ kctl-waha sessions list
18
+ ```
19
+
20
+ ## Command Groups
21
+
22
+ | Group | Description |
23
+ |-------|-------------|
24
+ | `config` | Manage CLI configuration and profiles |
25
+ | `health` | Health checks and diagnostics |
26
+ | `dashboard` | System overview dashboard |
27
+ | `sessions` | Manage WhatsApp sessions |
28
+ | `messages` | Send WhatsApp messages |
29
+ | `webhooks` | Manage session webhooks |
30
+ | `bridge` | Manage WAHA bridge sidecar (Chatwoot/Odoo) |
31
+
32
+ ## Global Options
33
+
34
+ | Option | Short | Description |
35
+ |--------|-------|-------------|
36
+ | `--json` | | Output as JSON |
37
+ | `--quiet` | `-q` | Suppress info messages |
38
+ | `--profile` | `-p` | Config profile name |
39
+ | `--url` | | API URL override |
40
+ | `--api-key` | | API key override |
41
+ | `--bridge-url` | | Bridge URL override |
42
+ | `--version` | `-V` | Show version and exit |
43
+
44
+ ## Configuration
45
+
46
+ Config lives in `~/.config/kodemeio/config.yaml` under the `waha` service key.
47
+
48
+ ```bash
49
+ # Initialize default profile
50
+ kctl-waha config init
51
+
52
+ # Add a named profile
53
+ kctl-waha config add prod \
54
+ --url https://waha.example.com \
55
+ --api-key $WAHA_API_KEY
56
+
57
+ # Switch active profile
58
+ kctl-waha config use prod
59
+
60
+ # Show current profile (key masked)
61
+ kctl-waha config show
62
+ ```
63
+
64
+ ## Development
65
+
66
+ ```bash
67
+ uv run pytest tests/ -v
68
+ uv run ruff check src/
69
+ uv run mypy src/
70
+ ```
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "kctl-waha"
7
+ version = "0.8.4"
8
+ description = "Kodemeio WAHA CLI — manage WhatsApp HTTP API instances"
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "kctl-lib>=0.12.0",
12
+ "typer>=0.15.0",
13
+ "rich>=13.9.0",
14
+ "pydantic>=2.10.0",
15
+ "pyyaml>=6.0.2",
16
+ "httpx>=0.28.0",
17
+ ]
18
+
19
+ [project.optional-dependencies]
20
+ dev = [
21
+ "pytest>=8.3.0",
22
+ "pytest-httpx>=0.35.0",
23
+ "ruff>=0.9.0",
24
+ "mypy>=1.14.0",
25
+ "types-PyYAML>=6.0.0",
26
+ ]
27
+
28
+ [project.scripts]
29
+ kctl-waha = "kctl_waha.cli:_run"
30
+
31
+ [tool.uv.sources]
32
+ kctl-lib = { workspace = true }
33
+
34
+ [project.entry-points."kctl_waha.plugins"]
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/kctl_waha"]
38
+
39
+ [tool.ruff]
40
+ target-version = "py312"
41
+ line-length = 120
42
+
43
+ [tool.mypy]
44
+ python_version = "3.12"
45
+ strict = true
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: waha-admin
3
+ description: >
4
+ WAHA WhatsApp HTTP API administration via kctl-waha CLI (13 groups, ~36 commands). MUST use for ANY kctl-waha operation. See SKILL.md ## Triggers for keywords.
5
+ Auto-generated: 2026-05-22
6
+ registry_hash: df5921b2fc0d
7
+ ---
8
+
9
+ # waha-admin — kctl-waha CLI Reference
10
+
11
+ > Auto-generated from `kctl-waha` command registry. Do not edit manually.
12
+ > To regenerate: `kctl-waha skill generate`
13
+ > To add custom content: edit `SKILL.extra.md` in the same directory.
14
+
15
+ ## Overview
16
+
17
+ **CLI:** `kctl-waha`
18
+ **Command groups:** 13
19
+ **Total commands:** ~36
20
+ **Install:** `cd cli && uv tool install --editable .`
21
+
22
+ ## Global Options
23
+
24
+ | Flag | Description |
25
+ |------|-------------|
26
+ | `--json` | JSON output |
27
+ | `--quiet`, `-q` | Suppress info messages |
28
+ | `--format`, `-f` | Output format: pretty/json/csv/yaml |
29
+ | `--no-header` | Omit CSV header row |
30
+ | `--profile`, `-p` | Config profile name |
31
+ | `--version`, `-V` | Show version |
32
+
33
+ ## Quick Discovery (for AI agents)
34
+
35
+ **DO NOT GUESS command paths or flag names.** Before invoking `kctl-waha <group> <verb> ...`, use these AI-facing affordances:
36
+
37
+ 1. **Find a command by keyword** — substring filter, returns sorted leaf paths:
38
+ ```bash
39
+ kctl-waha commands list --filter <keyword>
40
+ ```
41
+ Example: `kctl-waha commands list --filter database` → all database-related commands in one call.
42
+
43
+ 2. **Inspect flags before invoking** — full param schema with
44
+ opts/defaults/required/choices/help:
45
+ ```bash
46
+ kctl-waha commands tree --json | jq '.. | objects | select(.name == "<verb>") | .params'
47
+ ```
48
+ Reading the `params` array tells you exact flag names (`--lang`), short aliases (`-l`), defaults, required-vs-optional, and choices — eliminating the `No such option '--xxx'` failure mode.
49
+
50
+ 3. **Preview destructive operations without executing** — `--explain` is supported on selected write commands:
51
+ ```bash
52
+ kctl-waha <group> <verb> <args> --explain
53
+ ```
54
+ Prints the planned action and exits 0. If `--explain` errors with "no such option", that command does not support it — fall back to verifying via `commands tree` schema inspection before running for real.
55
+
56
+ 4. **Errors are user-facing one-liners**, not Python tracebacks. A failed invocation shows `❌ <ErrorClass>: <message>` on stderr (or `{"error": ..., "message": ...}` JSON if `--json` was passed). Read the message — it usually tells you exactly what's missing.
57
+
58
+ ## Triggers
59
+
60
+ Auto-invoke this skill when the user references any of these keywords:
61
+
62
+ "bridge", "check", "commands", "completions", "config", "current", "dashboard", "doctor", "generate", "health", "init", "kctl-waha", "logout", "messages", "migrate", "profile", "profiles", "remove", "restart", "self-update", "send", "send-image", "sessions", "setup-chatwoot", "setup-webhook", "skill", "start", "stop", "test", "tree", "tui", "webhooks"
63
+
64
+ ## Command Reference
65
+
66
+ ### `kctl-waha bridge`
67
+
68
+ Manage WAHA bridge sidecar.
69
+
70
+ | Command | Description |
71
+ |---------|-------------|
72
+ | `bridge health` | Check bridge sidecar health. |
73
+ | `bridge setup-chatwoot [--name] [--callback_url]` | Setup Chatwoot inbox integration via bridge. |
74
+ | `bridge setup-webhook [--session] [--webhook_url]` | Setup WAHA webhook via bridge. |
75
+ | `bridge status` | Show bridge setup status (WAHA, Chatwoot, Odoo config). |
76
+
77
+ ### `kctl-waha commands`
78
+
79
+ Machine-readable command discovery (for AI agents).
80
+
81
+ | Command | Description |
82
+ |---------|-------------|
83
+ | `commands list [--json_flag] [--filter_substr]` | List all leaf commands as 'group verb' strings. |
84
+ | `commands tree [--json_flag]` | Dump the full command tree as JSON. |
85
+
86
+ ### `kctl-waha completions`
87
+
88
+ Generate or install shell completions.
89
+
90
+ Usage: `kctl-waha completions [--shell] [--install]`
91
+
92
+ ### `kctl-waha config`
93
+
94
+ Manage CLI configuration and profiles.
95
+
96
+ | Command | Description |
97
+ |---------|-------------|
98
+ | `config add <name> [--url] [--api_key] [--bridge_url] [--set_default]` | Add or update a profile's WAHA connection. |
99
+ | `config current` | Show the active profile and connection status. |
100
+ | `config init [--url] [--api_key] [--bridge_url] [--name]` | Initialize CLI configuration (interactive if no flags given). |
101
+ | `config migrate` | Migrate config from flat format to service-scoped format. |
102
+ | `config profiles` | List all profiles with WAHA connection status. |
103
+ | `config remove <name> [--force] [--service_only]` | Remove a profile or just its WAHA config. |
104
+ | `config set <key> <value> [--profile_arg]` | Set a configuration value for the current service. |
105
+ | `config show` | Show full configuration (API keys masked). |
106
+ | `config test` | Test API connection with current configuration. |
107
+ | `config use <name>` | Switch the default profile. |
108
+
109
+ **Examples:**
110
+ ```bash
111
+ kctl-waha config set url https://waha.new.io
112
+ kctl-waha config set api_key new-key-value
113
+ kctl-waha config set bridge_url http://localhost:3050
114
+ kctl-waha config set default_profile production
115
+ ```
116
+
117
+ ### `kctl-waha dashboard`
118
+
119
+ System overview dashboard.
120
+
121
+ ### `kctl-waha doctor`
122
+
123
+ Run diagnostic checks.
124
+
125
+ ### `kctl-waha health`
126
+
127
+ Health checks and diagnostics.
128
+
129
+ ### `kctl-waha messages`
130
+
131
+ Send WhatsApp messages.
132
+
133
+ | Command | Description |
134
+ |---------|-------------|
135
+ | `messages send <phone> <text> [--session]` | Send a text message. |
136
+ | `messages send-image <phone> <url> [--caption] [--session]` | Send an image message. |
137
+
138
+ **Examples:**
139
+ ```bash
140
+ kctl-waha messages send 6281234567890 "Hello!"
141
+ kctl-waha messages send +628123456 "Hi there" --session my-session
142
+ kctl-waha messages send-image 6281234567890 https://example.com/image.png
143
+ kctl-waha messages send-image 6281234567890 https://example.com/photo.jpg --caption "Check this out"
144
+ ```
145
+
146
+ ### `kctl-waha self-update`
147
+
148
+ Check for updates and upgrade kctl-waha.
149
+
150
+ ### `kctl-waha sessions`
151
+
152
+ Manage WhatsApp sessions.
153
+
154
+ | Command | Description |
155
+ |---------|-------------|
156
+ | `sessions delete <name> [--force]` | Delete a WhatsApp session. |
157
+ | `sessions get [--name]` | Show session details. |
158
+ | `sessions list [--all_sessions]` | List WhatsApp sessions. |
159
+ | `sessions logout [--name] [--force]` | Logout from a WhatsApp session. |
160
+ | `sessions me [--name]` | Show current session account info. |
161
+ | `sessions qr [--name]` | Get QR code for session authentication. |
162
+ | `sessions restart [--name]` | Restart a WhatsApp session (stop + start). |
163
+ | `sessions start [--name] [--engine]` | Start a WhatsApp session. |
164
+ | `sessions stop [--name]` | Stop a WhatsApp session. |
165
+
166
+ ### `kctl-waha skill`
167
+
168
+ Claude Code skill management.
169
+
170
+ | Command | Description |
171
+ |---------|-------------|
172
+ | `skill generate [--output] [--install] [--check]` | Auto-generate SKILL.md from CLI command registry. |
173
+
174
+ **Examples:**
175
+ ```bash
176
+ kctl-waha skill generate
177
+ kctl-waha skill generate --install
178
+ kctl-waha skill generate --check
179
+ ```
180
+
181
+ ### `kctl-waha tui`
182
+
183
+ Launch the interactive TUI.
184
+
185
+ Usage: `kctl-waha tui [--profile]`
186
+
187
+ ### `kctl-waha webhooks`
188
+
189
+ Manage session webhooks.
190
+
191
+ | Command | Description |
192
+ |---------|-------------|
193
+ | `webhooks list` | List webhook configurations for all sessions. |
194
+ | `webhooks set <session> <url> [--events] [--hmac_key]` | Set webhook configuration for a session. |
195
+
196
+ **Examples:**
197
+ ```bash
198
+ kctl-waha webhooks set default --url https://bridge.kodeme.io/webhook
199
+ kctl-waha webhooks set default --url https://n8n.kodeme.io/waha --events message,session.status
200
+ kctl-waha webhooks set default --url https://hook.io/waha --hmac-key mysecret
201
+ ```
202
+
203
+ ## Configuration
204
+
205
+ Shared config: `~/.config/kodemeio/config.yaml`
206
+
207
+ ```bash
208
+ kctl-waha config init # Interactive setup
209
+ kctl-waha config show # Show current config
210
+ kctl-waha config profiles # List profiles
211
+ kctl-waha config current # Show active profile
212
+ kctl-waha config validate # Verify config
213
+ ```
@@ -0,0 +1,5 @@
1
+ """Kodemeio WAHA CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __version__ = "0.8.4"
@@ -0,0 +1,7 @@
1
+ """Allow running as python -m kctl_waha."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from kctl_waha.cli import app
6
+
7
+ app()
@@ -0,0 +1,132 @@
1
+ """Main CLI entry point for kctl-waha."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ from typing import Annotated
7
+
8
+ import typer
9
+ from kctl_lib import KctlError, handle_cli_error
10
+ from kctl_lib import cli_entrypoint, register_introspection_commands
11
+
12
+ from kctl_waha import __version__
13
+ from kctl_waha.commands.bridge import app as bridge_app
14
+ from kctl_waha.commands.config_cmd import app as config_app
15
+ from kctl_waha.commands.dashboard import app as dashboard_app
16
+ from kctl_waha.commands.health import app as health_app
17
+ from kctl_waha.commands.messages import app as messages_app
18
+ from kctl_waha.commands.sessions import app as sessions_app
19
+ from kctl_waha.commands.webhooks import app as webhooks_app
20
+ from kctl_waha.core.callbacks import AppContext
21
+ from kctl_waha.commands.skill_cmd import app as skill_app
22
+ from kctl_waha.commands.doctor_cmd import app as doctor_app
23
+ from kctl_lib.self_update import notify_if_outdated
24
+ from kctl_lib.tui import add_tui_command
25
+
26
+
27
+ def version_callback(value: bool) -> None:
28
+ if value:
29
+ typer.echo(f"kctl-waha {__version__}")
30
+ raise typer.Exit()
31
+
32
+
33
+ app = typer.Typer(
34
+ name="kctl-waha",
35
+ help="Kodemeio WAHA CLI - manage WhatsApp HTTP API instances.",
36
+ no_args_is_help=True,
37
+ rich_markup_mode="rich",
38
+ pretty_exceptions_enable=False,
39
+ )
40
+
41
+
42
+ @app.callback()
43
+ def main(
44
+ ctx: typer.Context,
45
+ json_output: Annotated[bool, typer.Option("--json", help="Output as JSON")] = False,
46
+ quiet: Annotated[bool, typer.Option("--quiet", "-q", help="Suppress info messages")] = False,
47
+ profile: Annotated[str | None, typer.Option("--profile", "-p", help="Config profile name")] = None,
48
+ url: Annotated[str | None, typer.Option("--url", help="API URL override")] = None,
49
+ api_key: Annotated[str | None, typer.Option("--api-key", help="API key override")] = None,
50
+ bridge_url: Annotated[str | None, typer.Option("--bridge-url", help="Bridge URL override")] = None,
51
+ version: Annotated[
52
+ bool, typer.Option("--version", "-V", callback=version_callback, is_eager=True, help="Show version")
53
+ ] = False,
54
+ ) -> None:
55
+ """Kodemeio WAHA CLI."""
56
+ ctx.ensure_object(dict)
57
+ ctx.obj = AppContext(
58
+ json_mode=json_output,
59
+ quiet=quiet,
60
+ profile=profile,
61
+ url_override=url,
62
+ api_key_override=api_key,
63
+ bridge_url_override=bridge_url,
64
+ )
65
+ notify_if_outdated(ctx.obj.output, "kctl-waha", __version__)
66
+
67
+
68
+ # Register all command groups
69
+ app.add_typer(config_app, name="config")
70
+ app.add_typer(health_app, name="health")
71
+ app.add_typer(dashboard_app, name="dashboard")
72
+ app.add_typer(sessions_app, name="sessions")
73
+ app.add_typer(messages_app, name="messages")
74
+ app.add_typer(webhooks_app, name="webhooks")
75
+ app.add_typer(bridge_app, name="bridge")
76
+ app.add_typer(skill_app, name="skill", hidden=True)
77
+ app.add_typer(doctor_app, name="doctor")
78
+ add_tui_command(app, service_key="waha", version=__version__)
79
+
80
+
81
+ @app.command("self-update")
82
+ def self_update_cmd(ctx: typer.Context) -> None:
83
+ """Check for updates and upgrade kctl-waha."""
84
+ actx = ctx.obj
85
+ out = actx.output
86
+
87
+ from kctl_lib.self_update import check_update
88
+ from kctl_lib.self_update import update as do_update
89
+
90
+ latest = check_update("kctl-waha", __version__)
91
+ if latest:
92
+ out.info(f"Updating to {latest}...")
93
+ do_update("kctl-waha")
94
+ out.success(f"Updated to {latest}")
95
+ else:
96
+ out.success("Already up to date")
97
+
98
+
99
+ @app.command()
100
+ def completions(
101
+ shell: Annotated[str, typer.Argument(help="Shell type: zsh, bash, fish")] = "zsh",
102
+ install: Annotated[bool, typer.Option("--install", help="Install completions")] = False,
103
+ ) -> None:
104
+ """Generate or install shell completions."""
105
+ from kctl_lib.completions import get_completion_script, install_completions
106
+
107
+ if install:
108
+ path = install_completions("kctl-waha", shell)
109
+ if path:
110
+ typer.echo(f"Completions installed to {path}")
111
+ else:
112
+ typer.echo(f"Could not install completions for {shell}", err=True)
113
+ raise typer.Exit(code=1)
114
+ else:
115
+ script = get_completion_script("kctl-waha", shell)
116
+ typer.echo(script)
117
+
118
+
119
+ # Wrap app so KctlError subclasses surface as clean user-facing messages.
120
+ app = cli_entrypoint(app)
121
+ register_introspection_commands(app)
122
+
123
+ def _run() -> None:
124
+ """Entry point with error handling."""
125
+ try:
126
+ app()
127
+ except KctlError as e:
128
+ handle_cli_error(e)
129
+
130
+
131
+ if __name__ == "__main__":
132
+ _run()
File without changes