kenso 0.1.152 → 0.1.153

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 CHANGED
@@ -4,6 +4,7 @@ What changed in the kenso CLI, newest first, by the day it changed. A new versio
4
4
 
5
5
  ## 2026-11-21
6
6
 
7
+ - accounts create --skip-research dry run charges 0 credits
7
8
  - a finished run answers alreadyDone before the out-of-credits check
8
9
  - never start a record twice when a rerun changes --max-credits or its people matches
9
10
  - a refused run start leaves its rows not_started and the run resumable
package/dist/kenso.js CHANGED
@@ -3389,7 +3389,7 @@ var VERSION;
3389
3389
  var init_version = __esm({
3390
3390
  "src/core/version.ts"() {
3391
3391
  "use strict";
3392
- VERSION = true ? "0.1.152" : "0.0.0-dev";
3392
+ VERSION = true ? "0.1.153" : "0.0.0-dev";
3393
3393
  }
3394
3394
  });
3395
3395
 
@@ -3720,6 +3720,69 @@ var init_confirm = __esm({
3720
3720
  }
3721
3721
  });
3722
3722
 
3723
+ // src/core/estimate.ts
3724
+ function isRecord2(value) {
3725
+ return value !== null && typeof value === "object" && !Array.isArray(value);
3726
+ }
3727
+ function mustRethrow(err) {
3728
+ return err instanceof KensoError && (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.Interrupted);
3729
+ }
3730
+ function creditsCheck(neededMillicredits, availableMillicredits2) {
3731
+ return {
3732
+ needed: neededMillicredits / 1e3,
3733
+ available: availableMillicredits2 === void 0 ? null : availableMillicredits2 / 1e3,
3734
+ sufficient: availableMillicredits2 === void 0 ? null : neededMillicredits <= availableMillicredits2
3735
+ };
3736
+ }
3737
+ async function ask(ctx, path, body2, read2) {
3738
+ try {
3739
+ const res = await ctx.client.request({ method: "POST", path, body: body2 });
3740
+ const data = unwrap(res.body);
3741
+ if (!isRecord2(data)) return { estimate: data ?? null };
3742
+ const estimate2 = Object.fromEntries(Object.entries(data).filter(([key]) => key !== "totalAmount" && !/usd/i.test(key)));
3743
+ return { estimate: estimate2, credits: await read2(data) };
3744
+ } catch (err) {
3745
+ if (mustRethrow(err)) throw err;
3746
+ ctx.output.warn(`Could not estimate the credits: ${err instanceof Error ? err.message : String(err)}`);
3747
+ return { estimate: null, estimateError: err instanceof KensoError ? { code: err.code, message: err.message } : { message: String(err) } };
3748
+ }
3749
+ }
3750
+ async function creditEstimate(ctx, body2) {
3751
+ return ask(ctx, "/v1/credits/estimates", body2, (data) => {
3752
+ const credits3 = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
3753
+ return {
3754
+ needed: credits3("totalMillicredits"),
3755
+ available: credits3("availableMillicredits"),
3756
+ sufficient: typeof data.sufficient === "boolean" ? data.sufficient : null
3757
+ };
3758
+ });
3759
+ }
3760
+ async function availableMillicredits(ctx) {
3761
+ try {
3762
+ const res = await ctx.client.request({ method: "GET", path: "/v1/credits" });
3763
+ const data = unwrap(res.body);
3764
+ return isRecord2(data) && typeof data.availableMillicredits === "number" ? data.availableMillicredits : void 0;
3765
+ } catch (err) {
3766
+ if (mustRethrow(err)) throw err;
3767
+ ctx.output.warn(`Could not read the credit balance: ${err instanceof Error ? err.message : String(err)}`);
3768
+ return void 0;
3769
+ }
3770
+ }
3771
+ async function workflowEstimate(ctx, body2) {
3772
+ return ask(ctx, "/v1/workflow-estimates", { ...body2 }, async (data) => {
3773
+ const max = data.bulkPriceApplies === true ? data.bulkMaxMillicredits : data.maxMillicredits;
3774
+ return typeof max === "number" ? creditsCheck(max, await availableMillicredits(ctx)) : { needed: null, available: null, sufficient: null };
3775
+ });
3776
+ }
3777
+ var init_estimate = __esm({
3778
+ "src/core/estimate.ts"() {
3779
+ "use strict";
3780
+ init_errors();
3781
+ init_exit_codes();
3782
+ init_http();
3783
+ }
3784
+ });
3785
+
3723
3786
  // src/core/input.ts
3724
3787
  import { readFile } from "node:fs/promises";
3725
3788
  function fileUnreadable(path, err, field = "file", hintOverride) {
@@ -7182,7 +7245,7 @@ __export(each_exports, {
7182
7245
  rowToValues: () => rowToValues,
7183
7246
  runEach: () => runEach
7184
7247
  });
7185
- function isRecord2(value) {
7248
+ function isRecord3(value) {
7186
7249
  return value !== null && typeof value === "object" && !Array.isArray(value);
7187
7250
  }
7188
7251
  function shellQuote(value) {
@@ -7274,7 +7337,7 @@ function rateLimitRemaining(headers) {
7274
7337
  return headers.has("ratelimit-remaining") && Number.isFinite(value) ? value : void 0;
7275
7338
  }
7276
7339
  function answerId(body2) {
7277
- const record3 = isRecord2(body2) ? isRecord2(body2.data) ? body2.data : body2 : void 0;
7340
+ const record3 = isRecord3(body2) ? isRecord3(body2.data) ? body2.data : body2 : void 0;
7278
7341
  const id = record3?.id;
7279
7342
  return typeof id === "number" || typeof id === "string" && id !== "" ? String(id) : void 0;
7280
7343
  }
@@ -7374,7 +7437,7 @@ __export(execute_exports, {
7374
7437
  operationToCommand: () => operationToCommand,
7375
7438
  secretParams: () => secretParams
7376
7439
  });
7377
- function isRecord3(value) {
7440
+ function isRecord4(value) {
7378
7441
  return value !== null && typeof value === "object" && !Array.isArray(value);
7379
7442
  }
7380
7443
  function commandOf(op) {
@@ -7566,7 +7629,7 @@ function buildRequest(op, values) {
7566
7629
  if (Object.keys(query).length > 0) request.query = query;
7567
7630
  if (!op.body) return request;
7568
7631
  const data = values[DATA_KEY];
7569
- const body2 = isRecord3(data) ? { ...data } : {};
7632
+ const body2 = isRecord4(data) ? { ...data } : {};
7570
7633
  for (const [key, value] of Object.entries(values)) {
7571
7634
  if (key === DATA_KEY || key === IDEMPOTENCY_KEY || routeNames.has(key) || queryNames.has(key) || value === void 0) continue;
7572
7635
  body2[key] = value;
@@ -7601,7 +7664,7 @@ function buildRequest(op, values) {
7601
7664
  request.form = form;
7602
7665
  return request;
7603
7666
  }
7604
- if (data !== void 0 && !isRecord3(data)) {
7667
+ if (data !== void 0 && !isRecord4(data)) {
7605
7668
  if (Object.keys(body2).length > 0) {
7606
7669
  throw usageError("--data is not a JSON object, so it cannot be combined with body flags.", { field: "data" });
7607
7670
  }
@@ -7675,7 +7738,7 @@ async function collectValues(ctx, op, flags) {
7675
7738
  }
7676
7739
  if (typeof flags.data === "string") {
7677
7740
  const data = await readDataArg(flags.data, ctx.stdin);
7678
- if (isRecord3(data)) values[DATA_KEY] = { ...data, ...bodyOnly };
7741
+ if (isRecord4(data)) values[DATA_KEY] = { ...data, ...bodyOnly };
7679
7742
  else if (Object.keys(bodyOnly).length > 0) throw usageError("--data is not a JSON object, so it cannot be combined with body flags.", { field: "data" });
7680
7743
  else values[DATA_KEY] = data;
7681
7744
  } else if (Object.keys(bodyOnly).length > 0) {
@@ -7726,15 +7789,15 @@ function secretParams(op) {
7726
7789
  return operationFlags(op).flatMap((f) => f.param && f.location === "body" && isSecretFlag(f.flag, f.type) ? [{ flag: f.flag, name: f.param.name }] : []);
7727
7790
  }
7728
7791
  function printWarnings(ctx, body2) {
7729
- if (!isRecord3(body2) || !Array.isArray(body2.warnings)) return;
7792
+ if (!isRecord4(body2) || !Array.isArray(body2.warnings)) return;
7730
7793
  for (const warning of body2.warnings) {
7731
- if (isRecord3(warning) && typeof warning.message === "string") ctx.output.warn(warning.message);
7794
+ if (isRecord4(warning) && typeof warning.message === "string") ctx.output.warn(warning.message);
7732
7795
  }
7733
7796
  }
7734
7797
  function compactRow(ctx, op, flags) {
7735
7798
  const fields = COMPACT_FIELDS[op.id];
7736
7799
  if (!fields || flags[FULL_FLAG] === true || ctx.flags.fields !== void 0 || ctx.flags.query !== void 0) return void 0;
7737
- return (row) => isRecord3(row) ? Object.fromEntries(fields.filter((field) => field in row).map((field) => [field, row[field]])) : row;
7800
+ return (row) => isRecord4(row) ? Object.fromEntries(fields.filter((field) => field in row).map((field) => [field, row[field]])) : row;
7738
7801
  }
7739
7802
  async function* mapRows(rows, shape) {
7740
7803
  for await (const row of rows) yield shape(row);
@@ -7750,7 +7813,7 @@ function leanValues(ctx, op, flags, values) {
7750
7813
  const printed = printedFields(ctx, op, flags);
7751
7814
  const lean = printed && LEAN_PARAMS[op.id]?.(printed, ctx.flags.fields !== void 0);
7752
7815
  const data = values[DATA_KEY] === void 0 ? {} : values[DATA_KEY];
7753
- if (!lean || !isRecord3(data) || Array.isArray(data.countBy) && data.countBy.length > 0) return void 0;
7816
+ if (!lean || !isRecord4(data) || Array.isArray(data.countBy) && data.countBy.length > 0) return void 0;
7754
7817
  const known = new Set([...op.queryParams, ...op.body?.props ?? []].map((p) => p.name));
7755
7818
  const add = Object.entries(lean).filter(([name]) => known.has(name) && values[name] === void 0 && data[name] === void 0);
7756
7819
  return add.length > 0 ? Object.fromEntries(add) : void 0;
@@ -7778,12 +7841,18 @@ async function* paginateLean(ctx, lean, plain2, opts) {
7778
7841
  yield* ctx.client.paginate(plain2, opts);
7779
7842
  }
7780
7843
  }
7781
- async function spendCost(ctx, op) {
7782
- if (!op.credits?.length) return { lines: [], rateCard: null };
7844
+ async function spendCost(ctx, op, req) {
7845
+ const skip = SKIPPED_CREDITS[op.id];
7846
+ const skipped = skip !== void 0 && req.query?.[skip.query] === skip.value;
7847
+ const lines = skipped ? (op.credits ?? []).filter((line) => !skip.drops.includes(line.action)) : op.credits ?? [];
7848
+ if (skipped && lines.length === 0) return { cost: { lines: [], text: `not charged in credits (${skip.why})`, rateCard: null }, credits: creditsCheck(0, void 0) };
7849
+ if (lines.length === 0) return { cost: { lines: [], rateCard: null } };
7783
7850
  const cards = await loadRateCards(ctx);
7784
7851
  return {
7785
- lines: op.credits.map((line) => ({ ...line, price: priceLine(line, cards) })),
7786
- rateCard: { source: cards[0]?.source ?? "bundled", versions: cards.map((card) => card.version) }
7852
+ cost: {
7853
+ lines: lines.map((line) => ({ ...line, price: priceLine(line, cards) })),
7854
+ rateCard: { source: cards[0]?.source ?? "bundled", versions: cards.map((card) => card.version) }
7855
+ }
7787
7856
  };
7788
7857
  }
7789
7858
  async function runOperation(ctx, op, flags) {
@@ -7804,7 +7873,7 @@ async function runOperation(ctx, op, flags) {
7804
7873
  const plain2 = buildRequest(op, values);
7805
7874
  const req = lean ? buildRequest(op, { ...values, ...lean }) : plain2;
7806
7875
  if (ctx.flags.dryRun) {
7807
- const cost = op.effect === "spend" ? { cost: await spendCost(ctx, op) } : {};
7876
+ const cost = op.effect === "spend" ? await spendCost(ctx, op, req) : {};
7808
7877
  ctx.output.object({ dryRun: true, operationId: op.id, request: describeRequest(req, op), ...cost });
7809
7878
  return ExitCode.Ok;
7810
7879
  }
@@ -7814,7 +7883,7 @@ async function runOperation(ctx, op, flags) {
7814
7883
  if (stream) return followEventStream(ctx, req, stream);
7815
7884
  const shape = compactRow(ctx, op, flags);
7816
7885
  if (op.list && flags.all === true) {
7817
- if (isRecord3(req.body) && Array.isArray(req.body.countBy) && req.body.countBy.length > 0) {
7886
+ if (isRecord4(req.body) && Array.isArray(req.body.countBy) && req.body.countBy.length > 0) {
7818
7887
  throw usageError("--all prints rows, not counts. Ask for countBy on one page (--limit 1), or leave it out.", { field: "all" });
7819
7888
  }
7820
7889
  const opts = op.method === "POST" ? { cursorIn: "body" } : void 0;
@@ -7833,13 +7902,13 @@ async function runOperation(ctx, op, flags) {
7833
7902
  return ExitCode.Ok;
7834
7903
  }
7835
7904
  printWarnings(ctx, res.body);
7836
- if (op.list && isRecord3(res.body) && Array.isArray(res.body.data)) {
7905
+ if (op.list && isRecord4(res.body) && Array.isArray(res.body.data)) {
7837
7906
  if (res.body.counts !== void 0) {
7838
7907
  ctx.output.object({ data: res.body.data, pagination: res.body.pagination, counts: res.body.counts });
7839
7908
  return ExitCode.Ok;
7840
7909
  }
7841
7910
  await ctx.output.list(shape ? res.body.data.map(shape) : res.body.data);
7842
- const pagination = isRecord3(res.body.pagination) ? res.body.pagination : void 0;
7911
+ const pagination = isRecord4(res.body.pagination) ? res.body.pagination : void 0;
7843
7912
  const next = pagination?.nextCursor;
7844
7913
  if (pagination?.hasMore === true && typeof next === "string" && next !== "") {
7845
7914
  ctx.output.info(`next: ${sameCommand(ctx, op, flags)} --cursor ${shellQuote2(next)}`);
@@ -7933,12 +8002,13 @@ ${api}` : api,
7933
8002
  run: (ctx, args) => runOperation(ctx, op, args.flags)
7934
8003
  };
7935
8004
  }
7936
- var STREAM_HELP, DATA_KEY, IDEMPOTENCY_KEY, IDEMPOTENCY_KEY_FLAG, SCALAR_TYPES, FLAG_ALIASES, OUT_FLAG, CONTACT_FIELDS, COMPACT_FIELDS, COMPACT_NOTES, FULL_FLAG, LEAN_PARAMS, LIST_PARAM_TEXT, HELP_NOTES_MAX, HELP_FLAG_MAX, FOOTER_FLAGS;
8005
+ var STREAM_HELP, DATA_KEY, IDEMPOTENCY_KEY, IDEMPOTENCY_KEY_FLAG, SCALAR_TYPES, FLAG_ALIASES, OUT_FLAG, CONTACT_FIELDS, COMPACT_FIELDS, COMPACT_NOTES, FULL_FLAG, LEAN_PARAMS, LIST_PARAM_TEXT, SKIPPED_CREDITS, HELP_NOTES_MAX, HELP_FLAG_MAX, FOOTER_FLAGS;
7937
8006
  var init_execute = __esm({
7938
8007
  "src/generated/execute.ts"() {
7939
8008
  "use strict";
7940
8009
  init_confirm();
7941
8010
  init_errors();
8011
+ init_estimate();
7942
8012
  init_exit_codes();
7943
8013
  init_http();
7944
8014
  init_input();
@@ -7998,6 +8068,15 @@ var init_execute = __esm({
7998
8068
  limit: "Page size.",
7999
8069
  cursor: "Start at this cursor (the next: hint of a previous page)."
8000
8070
  };
8071
+ SKIPPED_CREDITS = {
8072
+ // DEV-13853: skipResearch=true runs no research and no committee run, so the create charges none of its lines.
8073
+ "accounts.create": {
8074
+ query: "skipResearch",
8075
+ value: true,
8076
+ drops: ["account_research", "committee_mapping", "email_found", "web_scrape", "podcast_search", "social_data_record"],
8077
+ why: "--skip-research: no research or committee run"
8078
+ }
8079
+ };
8001
8080
  HELP_NOTES_MAX = 320;
8002
8081
  HELP_FLAG_MAX = 140;
8003
8082
  FOOTER_FLAGS = /* @__PURE__ */ new Set(["each", "concurrency", "data"]);
@@ -8183,69 +8262,6 @@ var init_help_effect = __esm({
8183
8262
  }
8184
8263
  });
8185
8264
 
8186
- // src/core/estimate.ts
8187
- function isRecord4(value) {
8188
- return value !== null && typeof value === "object" && !Array.isArray(value);
8189
- }
8190
- function mustRethrow(err) {
8191
- return err instanceof KensoError && (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.Interrupted);
8192
- }
8193
- function creditsCheck(neededMillicredits, availableMillicredits2) {
8194
- return {
8195
- needed: neededMillicredits / 1e3,
8196
- available: availableMillicredits2 === void 0 ? null : availableMillicredits2 / 1e3,
8197
- sufficient: availableMillicredits2 === void 0 ? null : neededMillicredits <= availableMillicredits2
8198
- };
8199
- }
8200
- async function ask(ctx, path, body2, read2) {
8201
- try {
8202
- const res = await ctx.client.request({ method: "POST", path, body: body2 });
8203
- const data = unwrap(res.body);
8204
- if (!isRecord4(data)) return { estimate: data ?? null };
8205
- const estimate2 = Object.fromEntries(Object.entries(data).filter(([key]) => key !== "totalAmount" && !/usd/i.test(key)));
8206
- return { estimate: estimate2, credits: await read2(data) };
8207
- } catch (err) {
8208
- if (mustRethrow(err)) throw err;
8209
- ctx.output.warn(`Could not estimate the credits: ${err instanceof Error ? err.message : String(err)}`);
8210
- return { estimate: null, estimateError: err instanceof KensoError ? { code: err.code, message: err.message } : { message: String(err) } };
8211
- }
8212
- }
8213
- async function creditEstimate(ctx, body2) {
8214
- return ask(ctx, "/v1/credits/estimates", body2, (data) => {
8215
- const credits3 = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
8216
- return {
8217
- needed: credits3("totalMillicredits"),
8218
- available: credits3("availableMillicredits"),
8219
- sufficient: typeof data.sufficient === "boolean" ? data.sufficient : null
8220
- };
8221
- });
8222
- }
8223
- async function availableMillicredits(ctx) {
8224
- try {
8225
- const res = await ctx.client.request({ method: "GET", path: "/v1/credits" });
8226
- const data = unwrap(res.body);
8227
- return isRecord4(data) && typeof data.availableMillicredits === "number" ? data.availableMillicredits : void 0;
8228
- } catch (err) {
8229
- if (mustRethrow(err)) throw err;
8230
- ctx.output.warn(`Could not read the credit balance: ${err instanceof Error ? err.message : String(err)}`);
8231
- return void 0;
8232
- }
8233
- }
8234
- async function workflowEstimate(ctx, body2) {
8235
- return ask(ctx, "/v1/workflow-estimates", { ...body2 }, async (data) => {
8236
- const max = data.bulkPriceApplies === true ? data.bulkMaxMillicredits : data.maxMillicredits;
8237
- return typeof max === "number" ? creditsCheck(max, await availableMillicredits(ctx)) : { needed: null, available: null, sufficient: null };
8238
- });
8239
- }
8240
- var init_estimate = __esm({
8241
- "src/core/estimate.ts"() {
8242
- "use strict";
8243
- init_errors();
8244
- init_exit_codes();
8245
- init_http();
8246
- }
8247
- });
8248
-
8249
8265
  // src/commands/people/columns.ts
8250
8266
  function normalizeHeader(header) {
8251
8267
  return header.toLowerCase().replace(/[^a-z0-9]/g, "");
@@ -9765,7 +9781,7 @@ var init_leads = __esm({
9765
9781
  var output_and_errors_default;
9766
9782
  var init_output_and_errors = __esm({
9767
9783
  "docs/output-and-errors.md"() {
9768
- output_and_errors_default = '# Output and errors\n\nEvery command follows one contract, so a script or an agent can parse any of them the same way.\n\n## stdout and stderr\n\n- **stdout carries data only.** Progress, warnings, notices and errors go to stderr.\n- No colors, spinners or pagers. On a terminal you get readable tables; in a pipe you get JSON.\n- A batch command (an import, update, remove, tag or `--each` write) takes `--yes`; without it, the command plans or refuses.\n- A command that deletes, archives, removes or merges, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive`, `kenso people merge` or `kenso api DELETE /v1/tags/7`, needs `--yes` too. Without it, a person at a terminal is asked to confirm; anywhere else (a pipe, a script, CI, a coding agent) it sends nothing and fails with `confirmation_required`, whose `next` is the same command with `--yes`.\n- Any other single write, such as `kenso tags create`, `kenso notes add` or a write through `kenso api` or `kenso mcp call`, sends at once: add `--dry-run` to print the request first (it sends nothing), then run the command without it. A command that reads before it writes (`kenso layouts set --header` reads the layout it edits) still reads with `--dry-run`, and prints the write it would send. A POST that changes nothing, such as `kenso accounts search` or `kenso reports query`, is a read like a GET.\n- A command with no dry run, such as `kenso contacts export`, `kenso auth logout` or `kenso workspace use`, refuses `--dry-run` with `usage_error` (exit 2) and does nothing. Its help ends with `No --dry-run`, or with `Read-only.` when the command only reads, and `kenso describe <resource> <action>` shows `"dryRun": false`. Every command that only reads, generated ones included, says `Read-only.` there.\n\n## Formats\n\n| What the command returns | stdout is a terminal | stdout is a pipe or file |\n|---|---|---|\n| One object | key-value lines | compact JSON on one line |\n| A list | a table (first 8 scalar fields, cells cut at 60 characters) | NDJSON: one JSON object per line |\n| A batch run | key-value lines | one JSON summary object |\n| No content (HTTP 204, such as a delete) | key-value lines: `ok`, `status`, `request` | `{"ok":true,"status":204,"request":{"method":"DELETE","path":"/v1/tasks/7"}}` |\n\n`-o` or `--output` picks the format: `json`, `ndjson`, `table` or `ids`. `--json` is the same as `-o json`.\n\n- `-o json` on a list prints one JSON array. On a terminal, `-o json` pretty-prints an object.\n- `-o ids` prints one id per line, ready for `--ids -`. Items without an `id` are skipped with one warning.\n\n```bash\nkenso campaigns list --limit 3\nkenso campaigns list --limit 3 -o json\nkenso contacts list --campaign-id 812 --all -o ids\n```\n\n## Shape the output\n\n- `--fields a,b.c` keeps only those fields (dots reach into nested objects).\n- `--query <JMESPath>` filters or reshapes in-process, so you need no `jq`. On a list it sees the whole list. There is no `--jq`: `--query` takes JMESPath, not jq syntax.\n- Neither applies to a batch summary, which always prints in full.\n- `threads list`, `contacts list` and `contacts search` print a short set of fields per row, in every format: a thread\'s id, channel, sender, subject, interest, read state, newest message time and preview, a contact\'s id, name, email, title, company and email validity, and a few more (the command\'s `--help` names them all). `--full` prints every field (`--full -o json` for a script that reads them all), `--fields` picks your own, and `--query` sees every field.\n- A thread list\'s `preview` is a one-line preview by default: the first 280 characters of the newest message\'s text (the API\'s `bodyFormat=snippet`), in every format. `--full`, or `--fields` that names `preview` or `htmlBody`, prints the whole message text, and `kenso threads list-messages --thread-id <id>` reads every message of a thread whole.\n- A contact list asks the API for only the fields it prints (the API\'s `fields`), so a page downloads what it shows. A thread list printed with `-o ids`, or with `--fields` that names neither `preview` nor `htmlBody`, asks for no message bodies (`bodyFormat=none`). `--full` and `--query` ask for every field, and `--param-fields` or `--body-format` sent by hand wins.\n\n```bash\nkenso campaigns list --fields id,name,status\nkenso campaigns list --all --query "[?status==\'active\'].id"\nkenso me get --query "length(features)"\nkenso threads list --folder inbox --fields id,subject,preview\nkenso threads list --folder inbox --full\n```\n\n## Lists and pages\n\nA list command prints one page. When there are more, it prints the command for the next page on stderr, for example `next: kenso tags list --limit 1 --cursor MQ`. `--all` follows every page and streams the items. `--limit` sets the page size and `--cursor` starts at a cursor.\n\n`accounts search`, `contacts search` and `people search` page the same way: one page with the `next:` command, or every page with `--all`. A search that asks for counts (`countBy` in `--data`) prints the whole answer instead: `data`, `pagination` and `counts`. Counts cover every match whatever the page, so ask for them on one page (`--limit 1`): `--all` with `countBy` is a usage error.\n\n```bash\nkenso tags list --limit 50\nkenso tags list --all\n```\n\n## Files: uploads and downloads\n\nA command whose API action takes a multipart upload takes `--file <path>`: the CLI reads the file and sends it in the form, with a content type from its extension (a `.png` goes as `image/png`), and the other flags as form fields. `--file <field>=<path>` names the form field, for a form with more than one file. An upload that also takes JSON, such as a logo from a URL instead of a file, sends JSON when you leave `--file` out.\n\nA command whose API action answers with a file (a CSV, an image, a ZIP) takes `--out <path>`: it saves the answer byte for byte (mode 0600) and prints `out`, `bytes` and `contentType`, so the file never passes through an agent\'s context. Without `--out`, a CSV prints as it came, and a binary file goes to stdout only when stdout is a pipe or a file: on a terminal it fails with `binary_output`, whose `next` adds `--out`.\n\n`kenso api` takes both, for any route: `--file` (repeat it for more files) sends multipart with the keys of a `--data` object as form fields, and `--out` saves any answer.\n\n```bash\nkenso saved-lists create-upload --saved-list-id 12 --file people.csv\nkenso workspaces replace-logo --workspace-id 42 --file ./logo.png\nkenso workspaces replace-logo --workspace-id 42 --source-url https://example.com/logo.png\nkenso attachments get-content --attachment-id att_123 --out ./invoice.pdf\nkenso api POST /v1/campaigns/812/email-sequence/images --file ./hero.png\nkenso api GET /v1/knowledge/exports/77/content --out knowledge.zip\n```\n\n## Live streams\n\n`kenso sync events` and `kenso onboarding-builds events` follow a live stream of server-sent events. They print one JSON line per event as it arrives, on a terminal too, with the event\'s name, its id when it has one, and its data:\n\n```json\n{"event":"hello","data":{"buildId":"obd_2x","status":"building","stage":"read","lastEventId":0}}\n{"event":"stage","id":"41","data":{"stage":"plan"}}\n{"event":"done","id":"42","data":{}}\n```\n\nA stream has no time limit while events arrive. The server ends each connection after 15 minutes with a `bye` event; the command then connects again at once, and after a dropped connection or 60 s without even a keepalive, after a second. A connection that brought nothing but `hello` and `bye` (a server that is restarting) backs off 1, 2, 4 ... 30 s. Once events carry an id (`onboarding-builds events`), it sends the last whole event\'s id as `Last-Event-ID`, so no event is lost or printed twice. A refusal (401, 403, 404) ends it at once; eight failed or empty connects in a row end it with the last error.\n\nIt runs until Ctrl-C (exit 130; every line printed is whole), or until one of these:\n\n| Flag | Ends the command |\n|---|---|\n| `--until <event>` | After the first event with that name; several names are comma-separated: `--until done,error` |\n| `--max-events <n>` | After n events, `hello` and `bye` included |\n| `--once` | When the server closes the connection, instead of connecting again |\n\n```bash\nkenso onboarding-builds events --build-id obd_2x --until done,error\nkenso sync events --max-events 2 # hello, then the first poke\n```\n\n`--output`, `--fields` and `--query` do not apply to a stream. `--last-event-id` starts an onboarding build stream after that id.\n\n## Errors\n\nWhen stderr is not a terminal, an error is one JSON line on stderr:\n\n```json\n{"error":{"code":"unknown_flag","message":"Unknown flag --fiel for kenso contacts import.","field":"fiel","hint":"did you mean --file?","next":"kenso contacts import --help"}}\n```\n\n| Key | Always there | Meaning |\n|---|---|---|\n| `code` | yes | A stable snake_case code to branch on |\n| `message` | yes | One sentence for a person |\n| `field` | no | The flag or input field at fault |\n| `hint` | no | What to change |\n| `next` | no | The exact command to run next, such as `kenso auth login`, `kenso workspace list --search <name>` or the same command with `--yes` |\n| `httpStatus` | no | The API\'s HTTP status, when the API answered |\n| `requestId` | no | The API\'s request id: quote it when you contact Kenso support |\n\nOn a terminal the same error prints as text: `Error: <message>`, then `field:`, `hint:`, `next:` and `requestId:` lines. The key never appears in an error.\n\n### How API errors map\n\nThe CLI looks at the HTTP status first, then at the API\'s own `error.code`, which wins when present.\n\n| HTTP status | Default code | Exit |\n|---|---|---|\n| 400, 422 | `validation_failed` | 2 |\n| 401 | `unauthorized` (`next`: `kenso auth login`) | 3 |\n| 403 | `forbidden`: the key\'s user or role cannot do this in this workspace | 3 |\n| 404 | `not_found` | 4 |\n| 409 | `conflict` | 7 |\n| 429 | `rate_limited`, after the CLI waited and retried | 6 |\n| 5xx | `server_error`, after retries where they are safe | 8 |\n| anything else | `http_error` | 1 |\n\nTwo API codes change the exit code: `workspace_required` exits 2 with `"next":"kenso workspace list --search <name>"`, and `limit_reached` (the plan\'s or the campaign\'s lead limit) exits 6.\n\n### Errors from the CLI itself\n\n| Code | Exit | When |\n|---|---|---|\n| `usage_error` | 2 | A required flag or argument is missing, two flags conflict (`--yes` with `--dry-run`), or `--dry-run` on a command that has no dry run |\n| `read_only` | 2 | `--read-only` or `KENSO_READ_ONLY` is on and the command is not a read: nothing was sent. `next` (with `--read-only` only, on a command with a dry run) is the same command with `--dry-run`, which prints the plan and changes nothing |\n| `unknown_command` | 2 | No such command; `hint` suggests the closest one |\n| `unknown_flag`, `invalid_flag`, `invalid_flag_value`, `unexpected_argument` | 2 | A flag or argument the command does not take |\n| `invalid_query` | 2 | `--query` is not valid JMESPath |\n| `confirmation_required` | 2 | A delete, archive or remove ran without `--yes` where nobody can confirm: nothing was sent; `next` adds `--yes` |\n| `cancelled` | 2 | A person answered no to the confirmation: nothing was sent |\n| `file_unreadable` | 2 | An input file is missing, is a folder, cannot be opened, or cannot be parsed; the message names the line, such as `leads.csv line 3: a quote is not closed.` |\n| `config_invalid` | 2 | `~/.kenso/config.json` is not valid JSON: fix or delete it |\n| `feature_not_enabled` | 2 | Every action of the resource is a beta command your workspace has not enabled |\n| `invalid_key_format`, `key_required` | 2 | `auth login --with-key` read something that is not a Kenso key, or stdin is a terminal instead of a pipe |\n| `invalid_workspace_id` | 2 | `kenso workspace use` got an id that is not a positive whole number |\n| `unknown_topic` | 2 | `kenso docs` got a topic it does not have; `hint` lists the topics |\n| `file_unwritable` | 2 or 1 | An output file cannot be written: `--out` on `contacts export`, `kenso api` or a download command (2), `skill install` (1) |\n| `binary_output` | 2 | The answer is a binary file and stdout is a terminal: nothing was printed; `next` saves it with `--out` |\n| `no_api_key` | 3 | No key in `KENSO_API_KEY` or the profile (`next`: `kenso auth login`) |\n| `browser_login_unavailable`, `access_denied`, `login_expired` | 3 | Browser login is off, was denied, or timed out |\n| `run_not_found` | 4 | `kenso runs show` or `resume` got an unknown run id |\n| `docs_not_found` | 4 | `kenso docs reference` before the reference was generated (a source checkout without `pnpm build`) |\n| `run_in_progress`, `already_filled` | 7 | Another process is working on the run, or `studio fill` already ran with this file and these flags |\n| `local_changes` | 7 | `studio pull` would replace files that no earlier pull wrote or push sent, or that changed since; nothing was written, and `next` adds `--force` to replace them |\n| `job_timeout`, `job_failed`, `job_canceled` | 1 | `kenso jobs wait` (or a command that waits on a job) ran out of time, or the job failed or was canceled |\n| `mcp_tool_error` | 1 | `kenso mcp call`: the MCP tool answered with an error |\n| `unsafe_path` | 1 | `studio pull` refused a file path that is not a file of the Studio bundle layout (such as a dotfile, `opencode.json` or `CLAUDE.md`), would land outside `--dir`, or passes through a symbolic link, or a `samples/*.json` that does not hold a sample |\n| `network_error` | 8 | The API could not be reached after retries |\n| `upload_failed`, `download_failed` | 8 or 1 | A signed upload or download of a Studio file failed: 8 when storage was unreachable or answered 5xx, 1 on a 4xx (often an expired link: run the command again) |\n| `pull_incomplete` | 8 | `studio pull`: a file came back with neither text nor a download link |\n| `unexpected_response` | 1 or 8 | The API answered something the CLI could not read |\n| `unexpected_error` | 1 | A bug: run again with `--verbose` and report it |\n| `interrupted` | 130 | Ctrl-C |\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | OK, including a batch where every row succeeded or was skipped |\n| 1 | Unexpected error |\n| 2 | Usage or input error: a bad flag, a bad file, a validation error |\n| 3 | Auth: no key, an invalid, revoked or expired key, or HTTP 401 or 403 |\n| 4 | Not found |\n| 5 | Partial: the batch finished and some rows failed, were not found or were invalid. See `results.csv` |\n| 6 | Rate limited after retries, or a plan or campaign lead limit stopped the run (`limit_reached`) |\n| 7 | Conflict or invalid state (HTTP 409), or a run another process holds |\n| 8 | Server error after retries (5xx), or the API is unreachable |\n| 9 | Answer refused: a Kenso sandbox run stopped because an answer held a credential or something shaped like one |\n| 130 | Interrupted. A batch run can be resumed: see its `next` |\n\nSkipped rows (duplicates, blocklisted, already contacted) are not failures: a batch with only created, updated and skipped rows exits 0.\n\n## Flags\n\n- Command flags go after the command: `kenso contacts import --campaign 812`. Global flags can go anywhere.\n- A boolean flag takes `--flag`, `--no-flag`, `--flag=true` and `--flag=false`.\n- A flag that carries a secret (`--password`, `--api-key`, `--api-secret`, any `--\u2026-token` or `--\u2026-secret`) also takes `-` (read stdin), `@file` (read the file) or `env:NAME` (read that environment variable), so the value stays out of shell history: `printf \'%s\' "$FATHOM_KEY" | kenso fathom-connection connect --api-key -`. A value typed on the command line still works and prints one warning. A typed secret that itself starts with `@` is written `@@` (`--password @@Spring2026` sends `@Spring2026`); one that is exactly `-` or starts with `env:` has to come through `@file` or `env:NAME`. `-` refuses a terminal, an empty value is refused, and only one flag can read stdin. `--dry-run` shows a secret as `***`. With `--each`, the plan, its `next` and the run record keep `@file` or `env:NAME` as typed and `kenso runs resume` reads it again; a secret from stdin is refused there.\n- `--help` on any command prints its flags, arguments and examples. `kenso describe <resource> <action>` prints the same as JSON, with the body schema.\n\n## Effect, cost and read-only mode\n\nEvery command has an effect: `read` (changes nothing, charges nothing), `write` (changes workspace data, charges nothing the API contract declares, nothing leaves Kenso), `spend` (can charge credits), `send` (sends an email, a LinkedIn message, a call or an invitation, or starts or resumes sending) or `destructive` (deletes, archives, removes or merges). Command help prints `Effect: <effect>.` under the summary, and a command that charges adds a `Cost:` line in credits from your workspace\'s rate card.\n\n`kenso describe <resource> <action>` adds `effect` and `cost` to its JSON. `cost` is `null` for a command that does not charge, else `{"lines": [...], "rateCard": {"source": ..., "versions": [...]}}`: each line is the command\'s credit line with its `price` text, and `source` is `live`, `cache` or `bundled`. A command that charges something no rate-card row prices has `{"lines": [], "rateCard": null}`, with `text` saying what it charges when the command states it. `kenso describe` and `kenso describe <resource>` add `effect` to each row.\n\n`--read-only`, or `KENSO_READ_ONLY=1` in the environment, refuses every command whose effect is not `read` before it sends a request, with exit 2:\n\n```json\n{"error":{"code":"read_only","message":"kenso campaigns launch is a send command, and this session is read-only.","hint":"Read-only is on through --read-only: next prints the plan. Run the command again without --read-only to make the change.","next":"kenso --read-only campaigns launch --campaign-id 1 --dry-run"}}\n```\n\n`next` never makes the change: on a command with a dry run it is the same command with `--dry-run` and without `--yes`, which prints the plan. A command with no dry run gets no `next`, and its hint says to run it again without `--read-only`. A command with its own `--body-read-only` option (`kenso api-keys create`) gets no `next` either, and its hint names that option. When the variable turned read-only on, the hint reads `KENSO_READ_ONLY is set: unset it to run this command.` and there is no `next`, so an agent that runs `next` cannot loop. A POST that only reads, such as `kenso contacts search`, still runs; a GET that charges, such as `kenso search get-place`, is refused; a command with a dry run still prints its plan with `--dry-run`; `kenso api` has the effect of the route it calls, and on a route this CLI does not know only a `GET` runs.\n\n```bash\nKENSO_READ_ONLY=1 kenso contacts search --limit 1\nkenso --read-only describe email-finds create\n```\n\n## Beta commands\n\nCommands that need a workspace feature flag (CRM, Studio and others) are beta. Help and `kenso describe` hide the ones your workspace has not enabled and say how many they hid; `--all-commands` shows them. Calling a hidden command still works: Kenso decides. `kenso <resource>` on a resource whose every action is hidden answers `feature_not_enabled` (exit 2) and names the flags it needs.\n\n```bash\nkenso --help --all-commands\nkenso describe --all-commands\n```\n\n## What the CLI sends\n\nEvery API call carries `Authorization: Bearer <key>`, `Ken-Version: 1.1`, `X-Ken-Workspace-Id` (when a workspace is picked), `User-Agent: kenso-cli/<version> (node <version>; <platform>)` and `X-Ken-Client: Kenso CLI`. When a coding agent runs the CLI, `X-Ken-Client` names it (`Kenso CLI via Claude Code`) and writes carry `X-Ken-Actor: agent`, so Kenso\'s activity log shows who made a change.\n';
9784
+ output_and_errors_default = '# Output and errors\n\nEvery command follows one contract, so a script or an agent can parse any of them the same way.\n\n## stdout and stderr\n\n- **stdout carries data only.** Progress, warnings, notices and errors go to stderr.\n- No colors, spinners or pagers. On a terminal you get readable tables; in a pipe you get JSON.\n- A batch command (an import, update, remove, tag or `--each` write) takes `--yes`; without it, the command plans or refuses.\n- A command that deletes, archives, removes or merges, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive`, `kenso people merge` or `kenso api DELETE /v1/tags/7`, needs `--yes` too. Without it, a person at a terminal is asked to confirm; anywhere else (a pipe, a script, CI, a coding agent) it sends nothing and fails with `confirmation_required`, whose `next` is the same command with `--yes`.\n- Any other single write, such as `kenso tags create`, `kenso notes add` or a write through `kenso api` or `kenso mcp call`, sends at once: add `--dry-run` to print the request first (it sends nothing), then run the command without it. A command that reads before it writes (`kenso layouts set --header` reads the layout it edits) still reads with `--dry-run`, and prints the write it would send. A POST that changes nothing, such as `kenso accounts search` or `kenso reports query`, is a read like a GET.\n- A command with no dry run, such as `kenso contacts export`, `kenso auth logout` or `kenso workspace use`, refuses `--dry-run` with `usage_error` (exit 2) and does nothing. Its help ends with `No --dry-run`, or with `Read-only.` when the command only reads, and `kenso describe <resource> <action>` shows `"dryRun": false`. Every command that only reads, generated ones included, says `Read-only.` there.\n\n## Formats\n\n| What the command returns | stdout is a terminal | stdout is a pipe or file |\n|---|---|---|\n| One object | key-value lines | compact JSON on one line |\n| A list | a table (first 8 scalar fields, cells cut at 60 characters) | NDJSON: one JSON object per line |\n| A batch run | key-value lines | one JSON summary object |\n| No content (HTTP 204, such as a delete) | key-value lines: `ok`, `status`, `request` | `{"ok":true,"status":204,"request":{"method":"DELETE","path":"/v1/tasks/7"}}` |\n\n`-o` or `--output` picks the format: `json`, `ndjson`, `table` or `ids`. `--json` is the same as `-o json`.\n\n- `-o json` on a list prints one JSON array. On a terminal, `-o json` pretty-prints an object.\n- `-o ids` prints one id per line, ready for `--ids -`. Items without an `id` are skipped with one warning.\n\n```bash\nkenso campaigns list --limit 3\nkenso campaigns list --limit 3 -o json\nkenso contacts list --campaign-id 812 --all -o ids\n```\n\n## Shape the output\n\n- `--fields a,b.c` keeps only those fields (dots reach into nested objects).\n- `--query <JMESPath>` filters or reshapes in-process, so you need no `jq`. On a list it sees the whole list. There is no `--jq`: `--query` takes JMESPath, not jq syntax.\n- Neither applies to a batch summary, which always prints in full.\n- `threads list`, `contacts list` and `contacts search` print a short set of fields per row, in every format: a thread\'s id, channel, sender, subject, interest, read state, newest message time and preview, a contact\'s id, name, email, title, company and email validity, and a few more (the command\'s `--help` names them all). `--full` prints every field (`--full -o json` for a script that reads them all), `--fields` picks your own, and `--query` sees every field.\n- A thread list\'s `preview` is a one-line preview by default: the first 280 characters of the newest message\'s text (the API\'s `bodyFormat=snippet`), in every format. `--full`, or `--fields` that names `preview` or `htmlBody`, prints the whole message text, and `kenso threads list-messages --thread-id <id>` reads every message of a thread whole.\n- A contact list asks the API for only the fields it prints (the API\'s `fields`), so a page downloads what it shows. A thread list printed with `-o ids`, or with `--fields` that names neither `preview` nor `htmlBody`, asks for no message bodies (`bodyFormat=none`). `--full` and `--query` ask for every field, and `--param-fields` or `--body-format` sent by hand wins.\n\n```bash\nkenso campaigns list --fields id,name,status\nkenso campaigns list --all --query "[?status==\'active\'].id"\nkenso me get --query "length(features)"\nkenso threads list --folder inbox --fields id,subject,preview\nkenso threads list --folder inbox --full\n```\n\n## Lists and pages\n\nA list command prints one page. When there are more, it prints the command for the next page on stderr, for example `next: kenso tags list --limit 1 --cursor MQ`. `--all` follows every page and streams the items. `--limit` sets the page size and `--cursor` starts at a cursor.\n\n`accounts search`, `contacts search` and `people search` page the same way: one page with the `next:` command, or every page with `--all`. A search that asks for counts (`countBy` in `--data`) prints the whole answer instead: `data`, `pagination` and `counts`. Counts cover every match whatever the page, so ask for them on one page (`--limit 1`): `--all` with `countBy` is a usage error.\n\n```bash\nkenso tags list --limit 50\nkenso tags list --all\n```\n\n## Files: uploads and downloads\n\nA command whose API action takes a multipart upload takes `--file <path>`: the CLI reads the file and sends it in the form, with a content type from its extension (a `.png` goes as `image/png`), and the other flags as form fields. `--file <field>=<path>` names the form field, for a form with more than one file. An upload that also takes JSON, such as a logo from a URL instead of a file, sends JSON when you leave `--file` out.\n\nA command whose API action answers with a file (a CSV, an image, a ZIP) takes `--out <path>`: it saves the answer byte for byte (mode 0600) and prints `out`, `bytes` and `contentType`, so the file never passes through an agent\'s context. Without `--out`, a CSV prints as it came, and a binary file goes to stdout only when stdout is a pipe or a file: on a terminal it fails with `binary_output`, whose `next` adds `--out`.\n\n`kenso api` takes both, for any route: `--file` (repeat it for more files) sends multipart with the keys of a `--data` object as form fields, and `--out` saves any answer.\n\n```bash\nkenso saved-lists create-upload --saved-list-id 12 --file people.csv\nkenso workspaces replace-logo --workspace-id 42 --file ./logo.png\nkenso workspaces replace-logo --workspace-id 42 --source-url https://example.com/logo.png\nkenso attachments get-content --attachment-id att_123 --out ./invoice.pdf\nkenso api POST /v1/campaigns/812/email-sequence/images --file ./hero.png\nkenso api GET /v1/knowledge/exports/77/content --out knowledge.zip\n```\n\n## Live streams\n\n`kenso sync events` and `kenso onboarding-builds events` follow a live stream of server-sent events. They print one JSON line per event as it arrives, on a terminal too, with the event\'s name, its id when it has one, and its data:\n\n```json\n{"event":"hello","data":{"buildId":"obd_2x","status":"building","stage":"read","lastEventId":0}}\n{"event":"stage","id":"41","data":{"stage":"plan"}}\n{"event":"done","id":"42","data":{}}\n```\n\nA stream has no time limit while events arrive. The server ends each connection after 15 minutes with a `bye` event; the command then connects again at once, and after a dropped connection or 60 s without even a keepalive, after a second. A connection that brought nothing but `hello` and `bye` (a server that is restarting) backs off 1, 2, 4 ... 30 s. Once events carry an id (`onboarding-builds events`), it sends the last whole event\'s id as `Last-Event-ID`, so no event is lost or printed twice. A refusal (401, 403, 404) ends it at once; eight failed or empty connects in a row end it with the last error.\n\nIt runs until Ctrl-C (exit 130; every line printed is whole), or until one of these:\n\n| Flag | Ends the command |\n|---|---|\n| `--until <event>` | After the first event with that name; several names are comma-separated: `--until done,error` |\n| `--max-events <n>` | After n events, `hello` and `bye` included |\n| `--once` | When the server closes the connection, instead of connecting again |\n\n```bash\nkenso onboarding-builds events --build-id obd_2x --until done,error\nkenso sync events --max-events 2 # hello, then the first poke\n```\n\n`--output`, `--fields` and `--query` do not apply to a stream. `--last-event-id` starts an onboarding build stream after that id.\n\n## Errors\n\nWhen stderr is not a terminal, an error is one JSON line on stderr:\n\n```json\n{"error":{"code":"unknown_flag","message":"Unknown flag --fiel for kenso contacts import.","field":"fiel","hint":"did you mean --file?","next":"kenso contacts import --help"}}\n```\n\n| Key | Always there | Meaning |\n|---|---|---|\n| `code` | yes | A stable snake_case code to branch on |\n| `message` | yes | One sentence for a person |\n| `field` | no | The flag or input field at fault |\n| `hint` | no | What to change |\n| `next` | no | The exact command to run next, such as `kenso auth login`, `kenso workspace list --search <name>` or the same command with `--yes` |\n| `httpStatus` | no | The API\'s HTTP status, when the API answered |\n| `requestId` | no | The API\'s request id: quote it when you contact Kenso support |\n\nOn a terminal the same error prints as text: `Error: <message>`, then `field:`, `hint:`, `next:` and `requestId:` lines. The key never appears in an error.\n\n### How API errors map\n\nThe CLI looks at the HTTP status first, then at the API\'s own `error.code`, which wins when present.\n\n| HTTP status | Default code | Exit |\n|---|---|---|\n| 400, 422 | `validation_failed` | 2 |\n| 401 | `unauthorized` (`next`: `kenso auth login`) | 3 |\n| 403 | `forbidden`: the key\'s user or role cannot do this in this workspace | 3 |\n| 404 | `not_found` | 4 |\n| 409 | `conflict` | 7 |\n| 429 | `rate_limited`, after the CLI waited and retried | 6 |\n| 5xx | `server_error`, after retries where they are safe | 8 |\n| anything else | `http_error` | 1 |\n\nTwo API codes change the exit code: `workspace_required` exits 2 with `"next":"kenso workspace list --search <name>"`, and `limit_reached` (the plan\'s or the campaign\'s lead limit) exits 6.\n\n### Errors from the CLI itself\n\n| Code | Exit | When |\n|---|---|---|\n| `usage_error` | 2 | A required flag or argument is missing, two flags conflict (`--yes` with `--dry-run`), or `--dry-run` on a command that has no dry run |\n| `read_only` | 2 | `--read-only` or `KENSO_READ_ONLY` is on and the command is not a read: nothing was sent. `next` (with `--read-only` only, on a command with a dry run) is the same command with `--dry-run`, which prints the plan and changes nothing |\n| `unknown_command` | 2 | No such command; `hint` suggests the closest one |\n| `unknown_flag`, `invalid_flag`, `invalid_flag_value`, `unexpected_argument` | 2 | A flag or argument the command does not take |\n| `invalid_query` | 2 | `--query` is not valid JMESPath |\n| `confirmation_required` | 2 | A delete, archive or remove ran without `--yes` where nobody can confirm: nothing was sent; `next` adds `--yes` |\n| `cancelled` | 2 | A person answered no to the confirmation: nothing was sent |\n| `file_unreadable` | 2 | An input file is missing, is a folder, cannot be opened, or cannot be parsed; the message names the line, such as `leads.csv line 3: a quote is not closed.` |\n| `config_invalid` | 2 | `~/.kenso/config.json` is not valid JSON: fix or delete it |\n| `feature_not_enabled` | 2 | Every action of the resource is a beta command your workspace has not enabled |\n| `invalid_key_format`, `key_required` | 2 | `auth login --with-key` read something that is not a Kenso key, or stdin is a terminal instead of a pipe |\n| `invalid_workspace_id` | 2 | `kenso workspace use` got an id that is not a positive whole number |\n| `unknown_topic` | 2 | `kenso docs` got a topic it does not have; `hint` lists the topics |\n| `file_unwritable` | 2 or 1 | An output file cannot be written: `--out` on `contacts export`, `kenso api` or a download command (2), `skill install` (1) |\n| `binary_output` | 2 | The answer is a binary file and stdout is a terminal: nothing was printed; `next` saves it with `--out` |\n| `no_api_key` | 3 | No key in `KENSO_API_KEY` or the profile (`next`: `kenso auth login`) |\n| `browser_login_unavailable`, `access_denied`, `login_expired` | 3 | Browser login is off, was denied, or timed out |\n| `run_not_found` | 4 | `kenso runs show` or `resume` got an unknown run id |\n| `docs_not_found` | 4 | `kenso docs reference` before the reference was generated (a source checkout without `pnpm build`) |\n| `run_in_progress`, `already_filled` | 7 | Another process is working on the run, or `studio fill` already ran with this file and these flags |\n| `local_changes` | 7 | `studio pull` would replace files that no earlier pull wrote or push sent, or that changed since; nothing was written, and `next` adds `--force` to replace them |\n| `job_timeout`, `job_failed`, `job_canceled` | 1 | `kenso jobs wait` (or a command that waits on a job) ran out of time, or the job failed or was canceled |\n| `mcp_tool_error` | 1 | `kenso mcp call`: the MCP tool answered with an error |\n| `unsafe_path` | 1 | `studio pull` refused a file path that is not a file of the Studio bundle layout (such as a dotfile, `opencode.json` or `CLAUDE.md`), would land outside `--dir`, or passes through a symbolic link, or a `samples/*.json` that does not hold a sample |\n| `network_error` | 8 | The API could not be reached after retries |\n| `upload_failed`, `download_failed` | 8 or 1 | A signed upload or download of a Studio file failed: 8 when storage was unreachable or answered 5xx, 1 on a 4xx (often an expired link: run the command again) |\n| `pull_incomplete` | 8 | `studio pull`: a file came back with neither text nor a download link |\n| `unexpected_response` | 1 or 8 | The API answered something the CLI could not read |\n| `unexpected_error` | 1 | A bug: run again with `--verbose` and report it |\n| `interrupted` | 130 | Ctrl-C |\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | OK, including a batch where every row succeeded or was skipped |\n| 1 | Unexpected error |\n| 2 | Usage or input error: a bad flag, a bad file, a validation error |\n| 3 | Auth: no key, an invalid, revoked or expired key, or HTTP 401 or 403 |\n| 4 | Not found |\n| 5 | Partial: the batch finished and some rows failed, were not found or were invalid. See `results.csv` |\n| 6 | Rate limited after retries, or a plan or campaign lead limit stopped the run (`limit_reached`) |\n| 7 | Conflict or invalid state (HTTP 409), or a run another process holds |\n| 8 | Server error after retries (5xx), or the API is unreachable |\n| 9 | Answer refused: a Kenso sandbox run stopped because an answer held a credential or something shaped like one |\n| 130 | Interrupted. A batch run can be resumed: see its `next` |\n\nSkipped rows (duplicates, blocklisted, already contacted) are not failures: a batch with only created, updated and skipped rows exits 0.\n\n## Flags\n\n- Command flags go after the command: `kenso contacts import --campaign 812`. Global flags can go anywhere.\n- A boolean flag takes `--flag`, `--no-flag`, `--flag=true` and `--flag=false`.\n- A flag that carries a secret (`--password`, `--api-key`, `--api-secret`, any `--\u2026-token` or `--\u2026-secret`) also takes `-` (read stdin), `@file` (read the file) or `env:NAME` (read that environment variable), so the value stays out of shell history: `printf \'%s\' "$FATHOM_KEY" | kenso fathom-connection connect --api-key -`. A value typed on the command line still works and prints one warning. A typed secret that itself starts with `@` is written `@@` (`--password @@Spring2026` sends `@Spring2026`); one that is exactly `-` or starts with `env:` has to come through `@file` or `env:NAME`. `-` refuses a terminal, an empty value is refused, and only one flag can read stdin. `--dry-run` shows a secret as `***`. With `--each`, the plan, its `next` and the run record keep `@file` or `env:NAME` as typed and `kenso runs resume` reads it again; a secret from stdin is refused there.\n- `--help` on any command prints its flags, arguments and examples. `kenso describe <resource> <action>` prints the same as JSON, with the body schema.\n\n## Effect, cost and read-only mode\n\nEvery command has an effect: `read` (changes nothing, charges nothing), `write` (changes workspace data, charges nothing the API contract declares, nothing leaves Kenso), `spend` (can charge credits), `send` (sends an email, a LinkedIn message, a call or an invitation, or starts or resumes sending) or `destructive` (deletes, archives, removes or merges). Command help prints `Effect: <effect>.` under the summary, and a command that charges adds a `Cost:` line in credits from your workspace\'s rate card.\n\n`kenso describe <resource> <action>` adds `effect` and `cost` to its JSON. `cost` is `null` for a command that does not charge, else `{"lines": [...], "rateCard": {"source": ..., "versions": [...]}}`: each line is the command\'s credit line with its `price` text, and `source` is `live`, `cache` or `bundled`. A command that charges something no rate-card row prices has `{"lines": [], "rateCard": null}`, with `text` saying what it charges when the command states it. `kenso describe` and `kenso describe <resource>` add `effect` to each row.\n\nA generated command that charges prints the same `cost` in its `--dry-run` plan, for the request it would send. A flag that turns off every charge says so: `kenso accounts create --skip-research --dry-run` prints `"cost": {"lines": [], "text": "not charged in credits (--skip-research: no research or committee run)", "rateCard": null}` and `"credits": {"needed": 0, "available": null, "sufficient": null}`, and reads nothing.\n\n`--read-only`, or `KENSO_READ_ONLY=1` in the environment, refuses every command whose effect is not `read` before it sends a request, with exit 2:\n\n```json\n{"error":{"code":"read_only","message":"kenso campaigns launch is a send command, and this session is read-only.","hint":"Read-only is on through --read-only: next prints the plan. Run the command again without --read-only to make the change.","next":"kenso --read-only campaigns launch --campaign-id 1 --dry-run"}}\n```\n\n`next` never makes the change: on a command with a dry run it is the same command with `--dry-run` and without `--yes`, which prints the plan. A command with no dry run gets no `next`, and its hint says to run it again without `--read-only`. A command with its own `--body-read-only` option (`kenso api-keys create`) gets no `next` either, and its hint names that option. When the variable turned read-only on, the hint reads `KENSO_READ_ONLY is set: unset it to run this command.` and there is no `next`, so an agent that runs `next` cannot loop. A POST that only reads, such as `kenso contacts search`, still runs; a GET that charges, such as `kenso search get-place`, is refused; a command with a dry run still prints its plan with `--dry-run`; `kenso api` has the effect of the route it calls, and on a route this CLI does not know only a `GET` runs.\n\n```bash\nKENSO_READ_ONLY=1 kenso contacts search --limit 1\nkenso --read-only describe email-finds create\n```\n\n## Beta commands\n\nCommands that need a workspace feature flag (CRM, Studio and others) are beta. Help and `kenso describe` hide the ones your workspace has not enabled and say how many they hid; `--all-commands` shows them. Calling a hidden command still works: Kenso decides. `kenso <resource>` on a resource whose every action is hidden answers `feature_not_enabled` (exit 2) and names the flags it needs.\n\n```bash\nkenso --help --all-commands\nkenso describe --all-commands\n```\n\n## What the CLI sends\n\nEvery API call carries `Authorization: Bearer <key>`, `Ken-Version: 1.1`, `X-Ken-Workspace-Id` (when a workspace is picked), `User-Agent: kenso-cli/<version> (node <version>; <platform>)` and `X-Ken-Client: Kenso CLI`. When a coding agent runs the CLI, `X-Ken-Client` names it (`Kenso CLI via Claude Code`) and writes carry `X-Ken-Actor: agent`, so Kenso\'s activity log shows who made a change.\n';
9769
9785
  }
9770
9786
  });
9771
9787