hookstride-cli 0.3.0__tar.gz → 0.3.2__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.

Potentially problematic release.


This version of hookstride-cli might be problematic. Click here for more details.

@@ -0,0 +1,412 @@
1
+ Metadata-Version: 2.5
2
+ Name: hookstride-cli
3
+ Version: 0.3.2
4
+ Summary: Manage Hookstride projects and destinations, inspect webhook activity and billing.
5
+ License: Proprietary
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: click<9,>=8.1
8
+ Requires-Dist: httpx<1,>=0.28
9
+ Requires-Dist: prompt-toolkit<4,>=3.0.52
10
+ Requires-Dist: rich<15,>=14
11
+ Requires-Dist: typer<1,>=0.20
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Hookstride CLI
15
+
16
+ Hookstride CLI lets you manage projects and webhook destinations, inspect delivery activity, and view billing records. It includes an interactive console with the same selected-project commands.
17
+
18
+ Version 0.3.2 adds queue metrics, redacted JSON exports and explicitly confirmed actions, and fixes missing-argument console exits. It also supports signed test-event sending, optional delivery-status polling, and project/destination management. Upgrade an older installation to use the new commands with a compatible backend. Billing and credential management remain outside the confirmed-action interface. Check [PyPI](https://pypi.org/project/hookstride-cli/) for package availability.
19
+
20
+ ## Installation
21
+
22
+
23
+ Requires Python 3.11 or later.
24
+
25
+ ```bash
26
+ uv tool install hookstride-cli
27
+ ```
28
+
29
+ Alternatively, use `pipx install hookstride-cli`.
30
+
31
+ ```bash
32
+ hookstride --version
33
+ hookstride status
34
+ hookstride console
35
+ ```
36
+
37
+ Upgrade an existing installation with `uv tool upgrade hookstride-cli`.
38
+
39
+ ## Authentication
40
+
41
+ Authenticated commands require a **Control API token** (`whrctl_`), available from your Hookstride dashboard. Project delivery API keys (`whrk_`) do not grant CLI access.
42
+
43
+ In an interactive console, run `auth login` and enter the token at the hidden prompt:
44
+
45
+ ```bash
46
+ hookstride console
47
+ ```
48
+
49
+ For one-off commands, set `HOOKSTRIDE_CONTROL_TOKEN` in your shell without entering it on the command line:
50
+
51
+ ```bash
52
+ read -rs "HOOKSTRIDE_CONTROL_TOKEN?Control token: "
53
+ echo
54
+ export HOOKSTRIDE_CONTROL_TOKEN
55
+ hookstride auth status
56
+ ```
57
+
58
+ The `read` example above works in **zsh**. In Bash, use `read -rs -p "Control token: " HOOKSTRIDE_CONTROL_TOKEN` followed by `echo` and `export HOOKSTRIDE_CONTROL_TOKEN`.
59
+
60
+ Tokens entered through `auth login` are retained only for the interactive console session. The CLI does not write tokens to its settings file.
61
+
62
+ ## Commands
63
+
64
+ ```bash
65
+ hookstride status
66
+ hookstride auth status
67
+ hookstride projects list
68
+ hookstride projects use PROJECT_UUID
69
+ hookstride projects create --account ACCOUNT_UUID --name "Staging" --slug staging
70
+ hookstride projects update PROJECT_UUID --name "Production EU"
71
+
72
+ hookstride destinations list
73
+ hookstride destinations create --name "Webhook receiver" --url "https://app.example.com/webhooks/hookstride"
74
+ hookstride destinations update DESTINATION_UUID --url "https://api.example.com/webhooks/hookstride"
75
+ hookstride destinations update DESTINATION_UUID --pause
76
+ hookstride destinations update DESTINATION_UUID --resume
77
+ hookstride keys list
78
+ hookstride events list --status failed
79
+ hookstride events show EVENT_UUID
80
+ hookstride events send DESTINATION_UUID --type webhook.test --wait
81
+ hookstride stats
82
+
83
+ hookstride incoming sources
84
+ hookstride incoming routes
85
+ hookstride incoming bindings
86
+ hookstride incoming registration-keys
87
+
88
+ hookstride billing status
89
+ hookstride billing history
90
+ hookstride config show
91
+ ```
92
+
93
+ Replace the example UUIDs with identifiers from your account. Find your workspace's `account_id` with `hookstride --json projects list`; that ID is required for project creation. Project creation and renaming require an admin/owner role. Destination changes require developer access or higher.
94
+
95
+ Commands that operate on a project use the selected project. You can override the selection for an individual command:
96
+
97
+ ```bash
98
+ hookstride --project PROJECT_UUID events list
99
+ ```
100
+
101
+ ### Interactive console
102
+
103
+ ```bash
104
+ hookstride console
105
+ ```
106
+
107
+ Use `help` to view commands, Tab for completion, and `exit` or Ctrl+D to leave. The console also supports `show projects`, `show events`, `show destinations`, `use PROJECT_UUID`, `back`, and `set env dev|production`. The same `projects create/update`, `destinations create/update`, and `events send` commands work inside the console. Commands with customer-provided names and URLs are not saved to console history.
108
+
109
+ ### JSON output
110
+
111
+ Use `--json` before a command to retrieve structured data for scripts:
112
+
113
+ ```bash
114
+ hookstride --json projects list
115
+ hookstride --project PROJECT_UUID --json events list --status failed
116
+ hookstride --env production --json billing history
117
+ ```
118
+
119
+ Errors go to standard error; unsuccessful requests return a nonzero exit code. When creating a destination, the server returns a signing secret **once**. Save it securely immediately. Both terminal output and `--json` deliberately include that one-time secret, so avoid piping creation output into logs or public CI artifacts.
120
+
121
+ ### Send a test event
122
+
123
+ Use an existing active destination from `hookstride destinations list`.
124
+ The command securely prompts for a project delivery API key (`whrk_`). It cannot use a
125
+ Control API token (`whrctl_`); these credentials have different permissions.
126
+
127
+ ```bash
128
+ hookstride --env production projects use PROJECT_UUID
129
+ hookstride --env production events send DESTINATION_UUID --wait
130
+ hookstride --env production events show EVENT_UUID
131
+ ```
132
+
133
+ The event type defaults to `webhook.test`, with a harmless JSON payload:
134
+ `{"message":"Hookstride CLI delivery test","source":"cli"}`.
135
+ To send a different JSON object without placing its contents in shell history:
136
+
137
+ ```bash
138
+ hookstride --env production events send DESTINATION_UUID --type demo.delivery --payload-file ./demo-payload.json --wait
139
+ ```
140
+
141
+ To avoid the hidden prompt, set `HOOKSTRIDE_PRODUCTION_API_KEY` or
142
+ `HOOKSTRIDE_DEV_API_KEY` for the matching environment only.
143
+ Never add keys to CLI arguments, commit them to Git, or paste them into a public CI log.
144
+ The CLI does not save delivery keys or their prompts in its configuration or history.
145
+ The `--wait` flag polls for a terminal status and exits nonzero if delivery fails.
146
+ A non-delivered event can be examined using `events show` with the usual Control token.
147
+
148
+ ## Environments and local settings
149
+
150
+ The CLI connects to the production API by default: `https://api.hookstride.com`.
151
+ A new release must be published to PyPI before existing installations receive this change.
152
+
153
+ To inspect the development API explicitly, select it:
154
+
155
+ ```bash
156
+ hookstride --env dev console
157
+ ```
158
+
159
+ Development requests use `https://api-dev.hookstride.com`. Use a Control API token issued for the selected environment. A custom HTTPS API origin can be supplied with `--api-url`.
160
+
161
+ Project selections are stored separately by environment in `~/.config/hookstride/settings.json`. This file contains project identifiers, **not authentication tokens**. Console tokens and command history remain in memory and are discarded at exit.
162
+
163
+ ## Documentation
164
+
165
+ Documentation: https://hookstride.com
166
+
167
+ ## Capability boundaries
168
+
169
+ The CLI supports project/destination creation and updates, event submission and
170
+ inspection, incoming configuration inspection, billing history and statistics.
171
+ Version 0.3.2 adds JSON exports and confirmed configuration, replay, team and
172
+ alert actions. Use the dashboard for CSV exports, purchasing, credential
173
+ management, MFA/ownership controls and Support tickets. Billing output
174
+ preserves the actual recorded currency; it does not
175
+ convert historical payments into display estimates. `status` checks API and
176
+ dependency readiness. Version 0.3.2 adds `status --pipeline` for the
177
+ worker-readiness check. Neither mode proves signed delivery or historical uptime.
178
+
179
+ ### Delivery metrics — version 0.3.2
180
+
181
+ Inspect the dashboard's queue-health measurements:
182
+
183
+ ```bash
184
+ hookstride --project PROJECT_UUID metrics --days 1
185
+ hookstride --project PROJECT_UUID --json metrics --days 7
186
+ ```
187
+
188
+ Windows are 1, 7 or 30 rolling UTC days. Completed delivery success excludes
189
+ waiting events; the current queue includes all accepted dates. `stats` retains
190
+ its existing lifetime response and labels its denominator as delivered/all,
191
+ including pending events. Neither command measures service uptime or quota usage.
192
+ The interactive console supports `metrics --days 7` and `show metrics` too.
193
+ This command needs version 0.3.2 or later and a backend with the delivery-metrics
194
+ endpoint. Select `--env dev` when using a separate development project/token.
195
+
196
+ ### JSON event export — version 0.3.2
197
+
198
+ ```bash
199
+ hookstride --project PROJECT_UUID --json events export --status failed > ./failed-events.json
200
+ ```
201
+
202
+ This uses the dashboard's tenant-scoped redaction and export rules, including
203
+ recorded attempts. JSON is limited to 200 matching events; the response retains
204
+ `truncated` and `limit`, and the CLI reports truncation on stderr. Narrow status,
205
+ `--origin` or `--type` filters when needed. CSV remains available in the dashboard.
206
+
207
+ ## Confirmed actions — version 0.3.2
208
+
209
+ The CLI exposes the same role-scoped, reviewed actions as Support,
210
+ without making AI calls. Inspect what this backend permits:
211
+
212
+ ```bash
213
+ hookstride --project PROJECT_UUID actions list
214
+ hookstride actions workspaces
215
+ ```
216
+
217
+ `actions context` shows authorized resource IDs, current settings, remaining
218
+ allowance and masked metadata for preparing inputs. It never retrieves raw
219
+ API keys or stored signing credentials. The response is scoped to your project
220
+ and role; payment history and team details keep their existing permissions.
221
+
222
+ | Action | Payload fields |
223
+ | --- | --- |
224
+ | `project.create` | `account_id`, `name`, optional `slug` (no project selection needed) |
225
+ | `project.configure` | `name` and/or `slug`, `expected_name`, `expected_slug` |
226
+ | `event.test` | `destination_id` |
227
+ | `event.replay` | `event_id` (delivered or failed) |
228
+ | `binding.create` | `source`, `endpoint`, `reference` |
229
+ | `destination.delivery` | `destination_id`, `payload_format`, `field_map`, `expected_payload_format`, `expected_field_map` |
230
+ | `team.invite` | `email`, `role` |
231
+ | `team.member` | `member_id`, `action` (`role` or `remove`), `expected_role`; `role` for role changes |
232
+ | `team.resend` / `team.revoke` | `invite_id`, `expected_email`, `expected_role` |
233
+ | `alerts.update` | `enabled`, `expected_enabled` (booleans) |
234
+ | `alerts.test` | Empty object |
235
+
236
+ Expected values come from the current context. Changes between preview and
237
+ confirmation are rechecked. Other existing destination/source/route operations
238
+ are also available when advertised by the backend; the dashboard remains the
239
+ guided interface for those resource-specific forms.
240
+
241
+ Write a non-secret JSON object to a private local file. For example, a replay
242
+ payload contains `{"event_id":"EVENT_UUID"}`. Then review and explicitly apply:
243
+
244
+ ```bash
245
+ hookstride --env dev --project PROJECT_UUID actions preview event.replay --input-file ./replay.json
246
+ hookstride --env dev --project PROJECT_UUID actions apply event.replay --input-file ./replay.json
247
+ ```
248
+
249
+ Apply obtains a fresh five-minute, single-use approval, displays the effect and
250
+ asks for confirmation. Scripts must provide `--confirm`; `--json` execution
251
+ requires that explicit flag. Cancellation never confirms or dispatches the
252
+ operation. First-project creation uses `project.create` with an `account_id`,
253
+ `name` and optional `slug` in the file and does not require a selected project.
254
+
255
+ Supported actions depend on the current role and backend: project setup,
256
+ destinations, incoming sources/routes, reference registration, delivery format,
257
+ test events/replay, workspace invitations/member access and failure alerts.
258
+ Billing and key-management actions are absent. Normal delivery actions still
259
+ consume the applicable event units; replay does not imply free processing.
260
+ Existing server validation, MFA, tenant isolation, quotas and email throttles
261
+ apply. No command can choose an arbitrary API path. Action payload files and
262
+ commands containing them are never retained in console history. Resource
263
+ creation can return a one-time signing secret outside chat: save it privately
264
+ and do not pipe creation output into logs or public artifacts.
265
+
266
+ ## Server-gated preview: local webhook forwarding
267
+
268
+ Version 0.3.2 includes the opt-in listener from issue #163. **The server feature
269
+ remains disabled by default; inclusion of the command does not enable it in
270
+ production.** Use a separately configured development backend for verification.
271
+ Older installations must be upgraded to receive the command.
272
+
273
+ The backend requires the new ingress migration and both
274
+ `WEBHOOK_INGRESS_ENABLED=1` and `WEBHOOK_LOCAL_FORWARDING_ENABLED=1`. Local
275
+ forwarding is disabled by default. Enable it only after reviewing this change;
276
+ do not change production ingress/egress security gates to test it. An operator
277
+ must schedule `python manage.py prune_local_sessions` regularly (for example,
278
+ every minute); it removes at most 500 expired, revoked or idle sessions per run.
279
+ It does not delete incoming events, destinations, or billing records.
280
+
281
+ From a source checkout, install the CLI's locked development dependencies:
282
+
283
+ ```bash
284
+ uv sync --frozen --group dev --project cli
285
+ uv run --project cli hookstride --env dev projects list
286
+ uv run --project cli hookstride --env dev projects use PROJECT_UUID
287
+ uv run --project cli hookstride --env dev incoming sources
288
+ ```
289
+
290
+ Use an MFA-verified Control API token where the account role requires MFA, as
291
+ explained under Authentication above. Developer access or higher is required.
292
+ Select an existing incoming connection in a dedicated development project. Its
293
+ provider signing secret must already be configured through the existing source
294
+ setup; the CLI never fetches it. A production destination is not needed, and the
295
+ listener never adds or edits routing. A subscription to a source is an explicit
296
+ opt-in to preview all newly verified events accepted for that project/source,
297
+ independently of its production rule/reference destinations. Select a test
298
+ source if its payloads must not be copied to a development machine.
299
+
300
+ Start your local HTTP receiver on **127.0.0.1**, then run:
301
+
302
+ ```bash
303
+ hookstride listen 8000 --path /webhooks
304
+ ```
305
+
306
+ The project must have been explicitly selected already. An interactive terminal
307
+ lists incoming sources and asks for the source UUID; it never auto-selects a
308
+ source. For scripts or the interactive console, supply it explicitly:
309
+
310
+ ```bash
311
+ hookstride --env dev --project PROJECT_UUID listen 8000 --path /webhooks --source SOURCE_UUID
312
+ ```
313
+
314
+ For source-checkout testing, prefix these examples with `uv run --project cli`.
315
+ A custom development API may be selected with the existing global `--api-url`;
316
+ remote origins require HTTPS. The local receiver URL is always
317
+ `http://127.0.0.1:8000/webhooks`. Paths cannot select a different host, include
318
+ queries/fragments or contain traversal. Proxy environment variables are ignored
319
+ for the receiver, redirects are never followed, receiver requests time out after
320
+ five seconds, and receiver response bodies are never read or printed.
321
+
322
+ The console shows connection/reconnection state, stable event IDs, attempts,
323
+ forwarding results and bounded failure messages. It never prints provider
324
+ credentials, management tokens, request payloads, or receiver response bodies.
325
+ Listener commands/paths are not added to console command history. `--json` is
326
+ not supported for a continuous listener.
327
+
328
+ ### Local delivery contract and duplicate handling
329
+
330
+ A forwarded POST contains a **new JSON envelope**, not the provider's original
331
+ signed request:
332
+
333
+ ```json
334
+ {
335
+ "id": "STABLE_INCOMING_MESSAGE_UUID",
336
+ "source_id": "SOURCE_UUID",
337
+ "type": "example.created",
338
+ "received_at": "2026-11-09T00:00:00+00:00",
339
+ "data": {"original": "parsed incoming JSON object"}
340
+ }
341
+ ```
342
+
343
+ `X-Hookstride-Local-Event-Id` is the same stable `id` and
344
+ `X-Hookstride-Local-Session-Id` identifies the temporary session. No provider
345
+ signature or upstream authorization header is forwarded. Do not attempt provider
346
+ raw-body signature verification on this envelope or accept these local-only
347
+ headers as production authentication. The trust boundary is the authenticated
348
+ CLI and the explicitly selected loopback development receiver; another process
349
+ on the same machine can also send localhost requests.
350
+
351
+ Only newly accepted events that passed the existing provider signature and
352
+ project/source checks enter a session queue. History, provider duplicates,
353
+ redispatch, and ordinary outbound test events are not added. Each session has
354
+ its own queue, so multiple listeners can preview the same new event independently.
355
+ Normal ingress quota accounting still occurs once per new incoming event;
356
+ preview polling, local HTTP attempts and ACKs create no delivery jobs or charges.
357
+
358
+ Delivery is **at least once within the session's lifetime and resource limits**.
359
+ The CLI acknowledges only after a local HTTP 2xx. A 500, redirect, network error,
360
+ or timeout remains unacknowledged and becomes eligible again after a 60-second
361
+ lease. A lost ACK response is retried idempotently before another poll. A crash
362
+ or a timeout after your receiver has committed can still cause a duplicate:
363
+ receivers must atomically deduplicate by envelope `id` before applying side
364
+ effects. Do not claim exactly-once behavior.
365
+
366
+ Poll requests return immediately with up to five events; empty results are
367
+ paced client-side every two seconds so synchronous API workers remain free. The
368
+ CLI reconnects with capped backoff. A session lasts at most one hour (`--ttl 60` through
369
+ `--ttl 3600`), and expires after two idle minutes. The same creating Control token
370
+ is checked on every API request, and every poll rechecks token/MFA, membership,
371
+ role, project, source, revocation and expiry before returning events. Revocation
372
+ cannot recall bytes already returned to a client.
373
+
374
+ Ctrl+C revokes the session. If the process is killed before it can revoke, its
375
+ session expires automatically. You can resume that still-active session with the
376
+ same token, project, source and receiver before its two-minute idle timeout:
377
+
378
+ ```bash
379
+ hookstride --env dev --project PROJECT_UUID listen 8000 --path /webhooks --source SOURCE_UUID --resume SESSION_UUID
380
+ ```
381
+
382
+ The session UUID is shown on connection and is not an authentication credential.
383
+ Credentials and payloads are never saved locally. Resume does not extend the
384
+ original expiry or recover expired/revoked events, and does not create a
385
+ replacement session if the original is unavailable. Starting a fresh session
386
+ subscribes only to future events.
387
+
388
+ ### Limits and troubleshooting
389
+
390
+ - Three active sessions per project, across all sources/users; one active poll
391
+ per session; 120 requests/minute per user across local-session operations.
392
+ - 64 KiB maximum serialized envelope, 256 unacknowledged events per session,
393
+ and 20 offers per event. Payload, backlog, or attempt overflow stops the
394
+ session explicitly; it never silently evicts pending events. Normal incoming
395
+ acceptance and production destination delivery continue unchanged.
396
+ - On a connection interruption, keep the listener running to reconnect. Long
397
+ outages can exceed idle expiry; start a new session only if you accept that
398
+ events during the gap will not be replayed.
399
+ - HTTP 401/403: check the environment's Control token, revocation/expiry, MFA and
400
+ developer membership. Delivery API keys cannot create or read sessions.
401
+ - HTTP 404: check project/source selection and the backend's feature flags and
402
+ migration. HTTP 410 means the temporary session stopped or expired.
403
+ - Queue full or retry-limit feedback: fix the receiver, then start a new session.
404
+ Unforwarded events from the old session are not moved into a new one.
405
+ - Local connection errors: bind the receiver to `127.0.0.1`, confirm the port and
406
+ path, and return a prompt 2xx. Redirects (including to another localhost URL)
407
+ are failures. Check your receiver's own development logs; Hookstride does not
408
+ display its response content.
409
+
410
+ Production release and remote Coolify staging verification remain separate
411
+ release gates. Do not send synthetic provider events to production/customer
412
+ sources or destinations to verify this preview.