kenso 0.1.77 → 0.1.79

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/dist/kenso.js CHANGED
@@ -2477,7 +2477,7 @@ var VERSION;
2477
2477
  var init_version = __esm({
2478
2478
  "src/core/version.ts"() {
2479
2479
  "use strict";
2480
- VERSION = true ? "0.1.77" : "0.0.0-dev";
2480
+ VERSION = true ? "0.1.79" : "0.0.0-dev";
2481
2481
  }
2482
2482
  });
2483
2483
 
@@ -7832,7 +7832,7 @@ var init_studio = __esm({
7832
7832
  var webhooks_default;
7833
7833
  var init_webhooks = __esm({
7834
7834
  "docs/webhooks.md"() {
7835
- webhooks_default = '# Webhooks: listen and trigger\n\nBuild and test a webhook handler on your own machine, with no public tunnel and no webhook endpoint in Kenso. `kenso webhooks listen` streams your workspace\'s events, prints each one as JSON and forwards it to your handler, signed the way Kenso signs its deliveries. `kenso webhooks trigger` sends a sample event through the running listener.\n\n| Command | What it does |\n|---|---|\n| `webhooks listen --forward-to <url>` | Streams events, prints one JSON line each, and POSTs each to your handler |\n| `webhooks listen --print-secret` | Prints the local signing secret and exits |\n| `webhooks trigger <event-type>` | Sends that type\'s sample through the running listener |\n\n## Quick start\n\nIn one terminal:\n\n```bash\nkenso webhooks listen --forward-to http://localhost:3000/hook\n```\n\nIt prints its signing secret on stderr:\n\n```\nReady. Forwarding events to http://localhost:3000/hook.\nSigning secret: whsec_... (the same on every run; kept in ~/.kenso/webhooks/signing-secret).\n```\n\nPut that secret in your handler\'s config (for example `KENSO_WEBHOOK_SECRET`). In another terminal:\n\n```bash\nkenso webhooks trigger reply.received\n```\n\nThe listener prints the event and your handler receives it. `kenso webhook-event-types list` lists every type with its sample body.\n\n## What your handler receives\n\nEach forward is a `POST` with a JSON body shaped like a webhook delivery (no envelope, `eventType` at the top) and the headers a Kenso delivery carries. How full the body is depends on where the event came from:\n\n- **A trigger** sends the type\'s full sample body, the same shape a webhook endpoint receives in production.\n- **A live event** is sparse. The event log keeps only part of each delivery, so the body has `eventType`, `eventId`, `timestamp` and `clientId`, plus the ids, statuses and `links` at their delivery paths (`contact.id`, `campaign.id`, `reply.classification`, ...). Names, emails, reply text and the other fields are not there: read them with the API, or build that part of the handler against a trigger\'s sample.\n\nThe headers:\n\n| Header | Value |\n|---|---|\n| `svix-id` | The event\'s id. Dedupe on it |\n| `svix-timestamp` | Unix seconds of the send |\n| `svix-signature` | `v1,` and the base64 HMAC-SHA256 of `{svix-id}.{svix-timestamp}.{body}`, keyed by the secret |\n| `content-type` | `application/json` |\n\nSo the verification code you write for production works unchanged: the Svix libraries (`svix` for Node, Python, Go and others) and the check in the Webhooks section of the Kenso API docs accept these deliveries. Only the secret differs. The listener\'s secret is local: it is made on your machine the first time you run `listen`, stays the same on every run, and is never a real endpoint\'s secret. In production, use your endpoint\'s secret from `kenso webhook-endpoints get-signing-secret --webhook-endpoint-id <webhookEndpointId>`.\n\nFor scripts, take the secret without starting a listener:\n\n```bash\nexport KENSO_WEBHOOK_SECRET=$(kenso webhooks listen --print-secret)\n```\n\n## Output\n\nstdout gets one JSON line per event, for `jq` or an agent:\n\n```json\n{"eventId":"0b6f...","type":"reply.received","timestamp":"2026-11-15T10:00:00Z","source":"live","forward":{"url":"http://localhost:3000/hook","status":200,"ms":12},"data":{"eventType":"reply.received","...":"..."}}\n```\n\n- `source` is `live` for a real event and `trigger` for a sample.\n- `forward` is what your handler answered: `status`, or `error` (`ECONNREFUSED` when nothing listens there). It is absent without `--forward-to`.\n- `data` is the body your handler received (or would receive, without `--forward-to`).\n\nThe ready line, the secret and the summary at Ctrl-C go to stderr.\n\n## Live events\n\n`listen` reads the workspace\'s event log (`GET /v1/event-occurrences`), so it receives the types with `mcp: true` in `kenso webhook-event-types list` that your seat can see. It polls the log, so a real event arrives within about 30 s; a trigger arrives at once. `--events reply.received,meeting.booked` (or `--events` repeated) narrows the types.\n\nThe event log is not on for every workspace yet. Where it is off, `listen` says so in a warning and still forwards everything you trigger, so you can build the handler first.\n\n## Triggers\n\n`trigger` takes the type\'s sample from `GET /v1/webhook-event-types`, gives it a new `eventId` (`evt_test_...`) and the current `timestamp`, and hands it to the listener for this workspace, which prints and forwards it like a live event. It sends nothing to Kenso\'s event log, to your webhook endpoints or to anyone else. It exits 1 with `forward_failed` when your handler did not answer 2xx, and with `listener_not_running` when no listener runs for the workspace.\n\nTo send a sample to a real, deployed endpoint instead, use `kenso webhook-endpoints test --webhook-endpoint-id <webhookEndpointId> --event-type reply.received`.\n\n## Stopping\n\nCtrl-C stops the listener. `listen` creates no webhook endpoint, no event subscription and no tunnel, so there is nothing to delete in Kenso. Its polls do keep the workspace\'s event log recording: the log stops on its own 7 days after the last poll. A poll that fails (a network error, a 5xx) prints a warning and is tried again a minute later; a bad key or a refused request ends the listener. It removes its local state file (the address `trigger` uses) on the way out.\n\n## Related: your API request logs\n\n`kenso logs tail` follows the same polling pattern for your API calls: it prints each request made with a Kenso API key as it is logged, so you see a failed call as it happens.\n\n```bash\nkenso logs tail --status 4xx,5xx --since 10m\nkenso logs tail --key apk_3f9c -o json\n```\n\nOn a terminal each row is one line: time, `[status]`, method, path template, error code, duration, key id, request id. Piped, or with `-o json`, each row is one JSON object per line. A row is logged after its request finishes, so a slow request can print up to a minute out of order. Where request logs are not on for the workspace yet, it exits 4 with `Request logs are not on for this workspace yet.`\n';
7835
+ webhooks_default = '# Webhooks: listen and trigger\n\nBuild and test a webhook handler on your own machine, with no public tunnel and no webhook endpoint in Kenso. `kenso webhooks listen` streams your workspace\'s events, prints each one as JSON and forwards it to your handler, signed the way Kenso signs its deliveries. `kenso webhooks trigger` sends a sample event through the running listener.\n\n| Command | What it does |\n|---|---|\n| `webhooks listen --forward-to <url>` | Streams events, prints one JSON line each, and POSTs each to your handler |\n| `webhooks listen --print-secret` | Prints the local signing secret and exits |\n| `webhooks trigger <event-type>` | Sends that type\'s sample through the running listener |\n\n## Quick start\n\nIn one terminal:\n\n```bash\nkenso webhooks listen --forward-to http://localhost:3000/hook\n```\n\nIt prints its signing secret on stderr:\n\n```\nReady. Forwarding events to http://localhost:3000/hook.\nSigning secret: whsec_... (the same on every run; kept in ~/.kenso/webhooks/signing-secret).\n```\n\nPut that secret in your handler\'s config (for example `KENSO_WEBHOOK_SECRET`). In another terminal:\n\n```bash\nkenso webhooks trigger reply.received\n```\n\nThe listener prints the event and your handler receives it. `kenso webhook-event-types list` lists every type with its sample body.\n\n## What your handler receives\n\nEach forward is a `POST` with a JSON body shaped like a webhook delivery (no envelope, `eventType` at the top) and the headers a Kenso delivery carries. How full the body is depends on where the event came from:\n\n- **A trigger** sends the type\'s full sample body, the same shape a webhook endpoint receives in production.\n- **A live event** is sparse. The event log keeps only part of each delivery, so the body has `eventType`, `eventId`, `timestamp` and `clientId`, plus the ids, statuses and `links` at their delivery paths (`contact.id`, `campaign.id`, `reply.classification`, ...). Names, emails, reply text and the other fields are not there: read them with the API, or build that part of the handler against a trigger\'s sample.\n\nThe headers:\n\n| Header | Value |\n|---|---|\n| `svix-id` | The event\'s id. Dedupe on it |\n| `svix-timestamp` | Unix seconds of the send |\n| `svix-signature` | `v1,` and the base64 HMAC-SHA256 of `{svix-id}.{svix-timestamp}.{body}`, keyed by the secret |\n| `content-type` | `application/json` |\n\nSo the verification code you write for production works unchanged: the Svix libraries (`svix` for Node, Python, Go and others) and the check in the Webhooks section of the Kenso API docs accept these deliveries. Only the secret differs. The listener\'s secret is local: it is made on your machine the first time you run `listen`, stays the same on every run, and is never a real endpoint\'s secret. In production, use your endpoint\'s secret from `kenso webhook-endpoints get-signing-secret --webhook-endpoint-id <webhookEndpointId>`.\n\nFor scripts, take the secret without starting a listener:\n\n```bash\nexport KENSO_WEBHOOK_SECRET=$(kenso webhooks listen --print-secret)\n```\n\n## Output\n\nstdout gets one JSON line per event, for `jq` or an agent:\n\n```json\n{"eventId":"0b6f...","type":"reply.received","timestamp":"2026-11-15T10:00:00Z","source":"live","forward":{"url":"http://localhost:3000/hook","status":200,"ms":12},"data":{"eventType":"reply.received","...":"..."}}\n```\n\n- `source` is `live` for a real event and `trigger` for a sample.\n- `forward` is what your handler answered: `status`, or `error` (`ECONNREFUSED` when nothing listens there). It is absent without `--forward-to`.\n- `data` is the body your handler received (or would receive, without `--forward-to`).\n\nThe ready line, the secret and the summary at Ctrl-C go to stderr.\n\n## Live events\n\n`listen` reads the workspace\'s event log (`GET /v1/event-occurrences`), so it receives the types with `mcp: true` in `kenso webhook-event-types list` that your seat can see. It polls the log, so a real event arrives within about 30 s; a trigger arrives at once. `--events reply.received,meeting.booked` (or `--events` repeated) narrows the types.\n\nThe event log is on for every workspace. It records a workspace\'s events from its first poll, so an event from before `listen` started is not in it. If `listen` warns that live events are not on for the workspace, it still forwards everything you trigger, so you can build the handler first.\n\n## Triggers\n\n`trigger` takes the type\'s sample from `GET /v1/webhook-event-types`, gives it a new `eventId` (`evt_test_...`) and the current `timestamp`, and hands it to the listener for this workspace, which prints and forwards it like a live event. It sends nothing to Kenso\'s event log, to your webhook endpoints or to anyone else. It exits 1 with `forward_failed` when your handler did not answer 2xx, and with `listener_not_running` when no listener runs for the workspace.\n\nTo send a sample to a real, deployed endpoint instead, use `kenso webhook-endpoints test --webhook-endpoint-id <webhookEndpointId> --event-type reply.received`.\n\n## Stopping\n\nCtrl-C stops the listener. `listen` creates no webhook endpoint, no event subscription and no tunnel, so there is nothing to delete in Kenso. Its polls do keep the workspace\'s event log recording: the log stops on its own 7 days after the last poll. A poll that fails (a network error, a 5xx) prints a warning and is tried again a minute later; a bad key or a refused request ends the listener. It removes its local state file (the address `trigger` uses) on the way out.\n\n## Related: your API request logs\n\n`kenso logs tail` follows the same polling pattern for your API calls: it prints each request made with a Kenso API key as it is logged, so you see a failed call as it happens.\n\n```bash\nkenso logs tail --status 4xx,5xx --since 10m\nkenso logs tail --key apk_3f9c -o json\n```\n\nOn a terminal each row is one line: time, `[status]`, method, path template, error code, duration, key id, request id. Piped, or with `-o json`, each row is one JSON object per line. A row is logged after its request finishes, so a slow request can print up to a minute out of order. Where request logs are not on for the workspace yet, it exits 4 with `Request logs are not on for this workspace yet.`\n';
7836
7836
  }
7837
7837
  });
7838
7838
 
@@ -12988,7 +12988,8 @@ var init_run2 = __esm({
12988
12988
  const names = result.dimensions.map((d) => d.field);
12989
12989
  ctx.output.info(data.title + (data.period ? ` (${data.period.from} to ${data.period.to})` : ""));
12990
12990
  ctx.output.info(data.finding);
12991
- ctx.output.info(`Totals (${result.currency}): ${result.measures.map((m) => `${m.key} ${result.totals[m.key] ?? 0}`).join(", ")}`);
12991
+ const totals = result.measures.filter((m) => result.totals[m.key] !== void 0).map((m) => `${m.key} ${result.totals[m.key]}`);
12992
+ if (totals.length > 0) ctx.output.info(`Totals (${result.currency}): ${totals.join(", ")}`);
12992
12993
  await ctx.output.list(
12993
12994
  result.buckets.map((bucket) => ({
12994
12995
  ...Object.fromEntries(names.map((name, i) => [name, bucket.labels[i] ?? bucket.keys[i] ?? ""])),