kenso 0.1.151 → 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.151" : "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 |\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
 
@@ -9789,7 +9805,7 @@ var init_sandbox = __esm({
9789
9805
  var studio_default;
9790
9806
  var init_studio = __esm({
9791
9807
  "docs/studio.md"() {
9792
- studio_default = "# Studio (beta)\n\nStudio templates are the pages, docs and other assets Kenso builds for each account or lead. The `kenso studio` commands let you edit a template as a folder of files on your machine, check it, preview it, and fill it for many accounts or leads at once. They are beta: they need the `studio` feature flag on your workspace. Help and `kenso describe` hide them until your workspace has it; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `studio pull <templateId> --dir <dir>` | Write a template version's files to a folder |\n| `studio push <templateId> --dir <dir>` | Save the folder's files to the template's draft and print the validation |\n| `studio validate <templateId> --dir <dir>` | Validate the folder against the template without saving |\n| `studio preview <templateId>` | Render a version for up to 3 accounts and print the preview links |\n| `studio fill <templateId>` | Fill the template for many accounts or campaign leads, estimate first |\n\nFind template ids with the generated commands:\n\n```bash\nkenso asset-templates list\n```\n\n## Edit a template locally\n\n```bash\nkenso studio pull 12 --dir ./my-template\nkenso studio validate 12 --dir ./my-template\nkenso studio push 12 --dir ./my-template\nkenso studio preview 12 --dir ./my-template --account-ids 501,502\nkenso studio push 12 --dir ./my-template --publish\n```\n\n### pull\n\n`pull` writes every file of the version under `--dir`: text files from the answer, binaries downloaded from signed links and checked against their SHA-256. It leaves other files in the folder alone. It checks every path before it writes anything, and refuses (`unsafe_path`) one that is not a file of the Studio bundle layout, one that would land outside `--dir`, and one that passes through a symbolic link. The layout is `studio.json`, `template.liquid`, `fallback.liquid`, `README.md`, `brief.md` and `ideas.md` at the top, images, fonts, pdf and csv files under `assets/`, and `.json` or `.csv` files directly in `samples/`, with names of letters, digits, `.`, `-` and `_` that neither start nor end with a dot and are not a Windows device name (`CON`, `NUL`, `COM1`). A sample is named in lowercase letters, digits, `-` and `_` (`samples/acme.json`), and never with a name a tool reads as its own config (`package.json`, `tsconfig.json`, `opencode.json`), so a tool started inside `samples/` finds none either. So pull never writes a hidden file (`.claude/`, `.mcp.json`), a tool's config file (`opencode.json`, `package.json`) or a coding agent's `CLAUDE.md` or `AGENTS.md`, which editors and coding agents read as their own settings, whatever the server sends. Studio stores nothing outside the layout; when a version stored before that rule holds such a file, the API leaves it out and pull prints a warning that names it.\n\n`pull` replaces a file that is already there only when an earlier pull wrote it or a push sent it and nobody changed it since, or when it already holds the new content. `.kenso-pull.json` at the top of the folder records what pulls wrote and pushes sent; push skips it like any dotfile. So pull, edit, push and pull again works as before, and a teammate's change replaces the files you did not change since your last pull or push. A file you added or changed and did not push stops the pull before anything is written: `local_changes` (exit 7) lists them. Move them away or compare them with the template, or add `--force` to replace them with the template's version. The first pull into a folder that an older version of the CLI pulled into may ask for `--force` once, for files that changed in the template since.\n\n`--template-version` picks the version: `draft`, `latest` (the latest published) or a version id. The default is the draft, else the latest published version. (The flag is not `--version`: after a command, `--version` fails with `unknown_flag` and points at `--template-version`.)\n\n```bash\nkenso studio pull 12 --dir ./v3 --template-version 345\nkenso studio pull 12 --dir ./my-template --dry-run\n```\n\nIt prints `{templateId, versionId, files, dir}`, plus `replaced` when `--force` replaced files. `--dry-run` lists the paths, and as `conflicts` the files it would not replace without `--force`, and writes nothing.\n\n### push\n\n`push` reads the files of the bundle layout in `--dir` (see pull) and skips everything else, so a folder that also holds a coding agent's `CLAUDE.md`, a `package.json` or a `src/` folder still pushes. It prints a warning naming each skipped file or folder; dotfiles, dot folders and `node_modules` are skipped without one. `validate` reads the folder the same way.\n\n- A text file (valid UTF-8, no NUL byte, under 1 MB) goes inline.\n- Any other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. A larger file is refused before any call.\n- One push then saves the files into the draft and prints `{templateId, versionId, versionNumber, validation, changed, deleted}`.\n\nFiles that are in the draft but not in the folder stay, unless you pass `--delete-missing`. `--message` describes the change (default \"Pushed with the Kenso CLI\"). With `--publish`, the new version is published when validation passes, and the output adds `published`.\n\n```bash\nkenso studio push 12 --dir ./my-template --message \"New hero copy\"\nkenso studio push 12 --dir ./my-template --delete-missing --publish\nkenso studio push 12 --dir ./my-template --dry-run\n```\n\nWhen validation finds errors, the draft is still saved: the result prints, then the error `validation_failed` (exit 2) with the first problem as its `hint`. When publishing fails after a good push, the push result still prints and the error says which version was saved. `--dry-run` lists what would be sent and calls nothing.\n\n### validate\n\n`validate` reads the folder the same way and checks the files laid over the draft, as a push would, without saving them. Binaries are uploaded so they can be checked. `--delete-missing` validates exactly the folder's files. It prints the validation and exits 2 when there are errors.\n\n### preview\n\n`preview` renders a saved version, not your local files: the draft, else the latest published version, or `--version-id`. It takes up to a minute per account.\n\n```bash\nkenso studio preview 12\nkenso studio preview 12 --account-ids 501,502,503 --mode render\nkenso studio preview 12 --sample samples/acme.json\nkenso studio preview 12 --mode interact --interact @steps.json\n```\n\n- `--account-ids` takes up to 3 ids. Without it, Kenso picks the 3 most recently touched accounts, else the template's samples.\n- `--mode` is `render` (default) or `interact`. `--interact` takes the click, type and wait steps as JSON, `@file` or `-` (up to 20).\n- With `--dir`, the CLI compares your folder to the version it renders and warns on stderr when they differ, naming the push command to run first.\n\nThe output lists each preview's link, screenshots, console errors and link issues.\n\n## Fill a template for many accounts or leads\n\n`fill` creates pages for a list of accounts, or for the leads of a campaign. A fill is charged per page, so it always prices the work first.\n\n```bash\nkenso studio fill 12 --accounts accounts.txt\nkenso studio fill 12 --accounts accounts.csv --column accountId --yes --wait\nkenso studio fill 12 --campaign 345 --contacts leads.csv --yes\n```\n\n- **Ids** come from `--accounts <file>`, or from `--contacts <file>` with `--campaign <id>`; `-` reads stdin. A file holds one id per line, or a CSV or JSONL with an id column (`--column`, else `id`, else `contactId`). Repeated ids are filled once.\n- **Without `--yes`** (or with `--estimate`) it prints the estimate and the apply command, and creates nothing. For a campaign, the estimate counts one page per lead; Kenso builds one page per company, so it is an upper bound.\n- **With `--yes`** it creates one fill run per 500 ids, one after another.\n- **With `--wait`** it follows each run every 5 seconds until it completes, fails or is cancelled. Without it, follow a run with `kenso asset-runs get --run-id <id>`.\n\nThe summary lists `runs: [{runId, state, rows}]`, and `results.csv` has one line per id with its page id and state.\n\n**The same fill never runs twice.** Rebuilding a page charges again, so when you rerun a fill with the same file (the same bytes) and the same flags:\n\n- an unfinished fill continues where it stopped;\n- a finished fill where every id succeeded answers from that run and changes nothing;\n- anything else is refused with `already_filled` (exit 7). To retry only the ids that failed, take them from the earlier run's `results.csv` into a new file and fill that file.\n\nThe guard compares the file and the flags, not the ids: the same ids in another file, or in another order, are filled and charged again. Keep one ids file per fill, and check `kenso runs list` before you fill ids from a new file.\n\n## Other Studio commands\n\nEverything else (create a template, list versions, restore a version, datasets, publish) is a generated command under `asset-templates`, `asset-runs` and `asset-template-datasets`:\n\n```bash\nkenso asset-templates --help --all-commands\nkenso describe asset-templates\n```\n";
9808
+ studio_default = "# Studio (beta)\n\nStudio templates are the pages, docs and other assets Kenso builds for each account or lead. The `kenso studio` commands let you edit a template as a folder of files on your machine, check it, preview it, and fill it for many accounts or leads at once. They are beta: they need the `studio` feature flag on your workspace. Help and `kenso describe` hide them until your workspace has it; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `studio pull <templateId> --dir <dir>` | Write a template version's files to a folder |\n| `studio push <templateId> --dir <dir>` | Save the folder's files to the template's draft and print the validation |\n| `studio validate <templateId> --dir <dir>` | Validate the folder against the template without saving |\n| `studio preview <templateId>` | Render a version for up to 3 accounts and print the preview links |\n| `studio fill <templateId>` | Fill the template for many accounts or campaign leads, estimate first |\n\nFind template ids with the generated commands:\n\n```bash\nkenso asset-templates list\n```\n\n## Edit a template locally\n\n```bash\nkenso studio pull 12 --dir ./my-template\nkenso studio validate 12 --dir ./my-template\nkenso studio push 12 --dir ./my-template\nkenso studio preview 12 --dir ./my-template --account-ids 501,502\nkenso studio push 12 --dir ./my-template --publish\n```\n\n### pull\n\n`pull` writes every file of the version under `--dir`: text files from the answer, binaries downloaded from signed links and checked against their SHA-256. It leaves other files in the folder alone. It checks every path before it writes anything, and refuses (`unsafe_path`) one that is not a file of the Studio bundle layout, one that would land outside `--dir`, and one that passes through a symbolic link. The layout is `studio.json`, `template.liquid`, `fallback.liquid`, `README.md`, `brief.md` and `ideas.md` at the top, images, fonts, pdf and csv files under `assets/`, and `.json` or `.csv` files directly in `samples/`, with names of letters, digits, `.`, `-` and `_` that neither start nor end with a dot and are not a Windows device name (`CON`, `NUL`, `COM1`). A sample is named in lowercase letters, digits, `-` and `_` (`samples/acme.json`), and never with a name a tool reads as its own config (`package.json`, `tsconfig.json`, `opencode.json`), so a tool started inside `samples/` finds none either. A sample `.json` is also judged by what it holds: one JSON object with only the top-level keys `account`, `person`, `sender`, `brand`, `link`, `data`, `role` and `roles`. Pull refuses any other (`unsafe_path`) before it writes anything, so no tool's configuration arrives under a sample name. So pull never writes a hidden file (`.claude/`, `.mcp.json`), a tool's config file (`opencode.json`, `package.json`) or a coding agent's `CLAUDE.md` or `AGENTS.md`, which editors and coding agents read as their own settings, whatever the server sends. Studio stores nothing outside the layout; when a version stored before that rule holds such a file, the API leaves it out and pull prints a warning that names it.\n\n`pull` replaces a file that is already there only when an earlier pull wrote it or a push sent it and nobody changed it since, or when it already holds the new content. `.kenso-pull.json` at the top of the folder records what pulls wrote and pushes sent; push skips it like any dotfile. So pull, edit, push and pull again works as before, and a teammate's change replaces the files you did not change since your last pull or push. A file you added or changed and did not push stops the pull before anything is written: `local_changes` (exit 7) lists them. Move them away or compare them with the template, or add `--force` to replace them with the template's version. The first pull into a folder that an older version of the CLI pulled into may ask for `--force` once, for files that changed in the template since.\n\n`--template-version` picks the version: `draft`, `latest` (the latest published) or a version id. The default is the draft, else the latest published version. (The flag is not `--version`: after a command, `--version` fails with `unknown_flag` and points at `--template-version`.)\n\n```bash\nkenso studio pull 12 --dir ./v3 --template-version 345\nkenso studio pull 12 --dir ./my-template --dry-run\n```\n\nIt prints `{templateId, versionId, files, dir}`, plus `replaced` when `--force` replaced files. `--dry-run` lists the paths, and as `conflicts` the files it would not replace without `--force`, and writes nothing.\n\n### push\n\n`push` reads the files of the bundle layout in `--dir` (see pull) and skips everything else, so a folder that also holds a coding agent's `CLAUDE.md`, a `package.json` or a `src/` folder still pushes. It prints a warning naming each skipped file or folder; dotfiles, dot folders and `node_modules` are skipped without one. A `samples/*.json` that is not one JSON object with only the keys `account`, `person`, `sender`, `brand`, `link`, `data`, `role` and `roles` is skipped with the same warning: the API refuses it (400 `content_mismatch`). `validate` reads the folder the same way.\n\n- A text file (valid UTF-8, no NUL byte, under 1 MB) goes inline.\n- Any other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. A larger file is refused before any call.\n- One push then saves the files into the draft and prints `{templateId, versionId, versionNumber, validation, changed, deleted}`.\n\nFiles that are in the draft but not in the folder stay, unless you pass `--delete-missing`. `--message` describes the change (default \"Pushed with the Kenso CLI\"). With `--publish`, the new version is published when validation passes, and the output adds `published`.\n\n```bash\nkenso studio push 12 --dir ./my-template --message \"New hero copy\"\nkenso studio push 12 --dir ./my-template --delete-missing --publish\nkenso studio push 12 --dir ./my-template --dry-run\n```\n\nWhen validation finds errors, the draft is still saved: the result prints, then the error `validation_failed` (exit 2) with the first problem as its `hint`. When publishing fails after a good push, the push result still prints and the error says which version was saved. `--dry-run` lists what would be sent and calls nothing.\n\n### validate\n\n`validate` reads the folder the same way and checks the files laid over the draft, as a push would, without saving them. Binaries are uploaded so they can be checked. `--delete-missing` validates exactly the folder's files. It prints the validation and exits 2 when there are errors.\n\n### preview\n\n`preview` renders a saved version, not your local files: the draft, else the latest published version, or `--version-id`. It takes up to a minute per account.\n\n```bash\nkenso studio preview 12\nkenso studio preview 12 --account-ids 501,502,503 --mode render\nkenso studio preview 12 --sample samples/acme.json\nkenso studio preview 12 --mode interact --interact @steps.json\n```\n\n- `--account-ids` takes up to 3 ids. Without it, Kenso picks the 3 most recently touched accounts, else the template's samples.\n- `--mode` is `render` (default) or `interact`. `--interact` takes the click, type and wait steps as JSON, `@file` or `-` (up to 20).\n- With `--dir`, the CLI compares your folder to the version it renders and warns on stderr when they differ, naming the push command to run first.\n\nThe output lists each preview's link, screenshots, console errors and link issues.\n\n## Fill a template for many accounts or leads\n\n`fill` creates pages for a list of accounts, or for the leads of a campaign. A fill is charged per page, so it always prices the work first.\n\n```bash\nkenso studio fill 12 --accounts accounts.txt\nkenso studio fill 12 --accounts accounts.csv --column accountId --yes --wait\nkenso studio fill 12 --campaign 345 --contacts leads.csv --yes\n```\n\n- **Ids** come from `--accounts <file>`, or from `--contacts <file>` with `--campaign <id>`; `-` reads stdin. A file holds one id per line, or a CSV or JSONL with an id column (`--column`, else `id`, else `contactId`). Repeated ids are filled once.\n- **Without `--yes`** (or with `--estimate`) it prints the estimate and the apply command, and creates nothing. For a campaign, the estimate counts one page per lead; Kenso builds one page per company, so it is an upper bound.\n- **With `--yes`** it creates one fill run per 500 ids, one after another.\n- **With `--wait`** it follows each run every 5 seconds until it completes, fails or is cancelled. Without it, follow a run with `kenso asset-runs get --run-id <id>`.\n\nThe summary lists `runs: [{runId, state, rows}]`, and `results.csv` has one line per id with its page id and state.\n\n**The same fill never runs twice.** Rebuilding a page charges again, so when you rerun a fill with the same file (the same bytes) and the same flags:\n\n- an unfinished fill continues where it stopped;\n- a finished fill where every id succeeded answers from that run and changes nothing;\n- anything else is refused with `already_filled` (exit 7). To retry only the ids that failed, take them from the earlier run's `results.csv` into a new file and fill that file.\n\nThe guard compares the file and the flags, not the ids: the same ids in another file, or in another order, are filled and charged again. Keep one ids file per fill, and check `kenso runs list` before you fill ids from a new file.\n\n## Other Studio commands\n\nEverything else (create a template, list versions, restore a version, datasets, publish) is a generated command under `asset-templates`, `asset-runs` and `asset-template-datasets`:\n\n```bash\nkenso asset-templates --help --all-commands\nkenso describe asset-templates\n```\n";
9793
9809
  }
9794
9810
  });
9795
9811
 
@@ -18099,6 +18115,16 @@ function inBundleLayout(bundlePath) {
18099
18115
  const name = segments[1];
18100
18116
  return segments[0] === "samples" && segments.length === 2 && SAMPLE_NAME.test(name) && !TOOL_CONFIG_NAMES.has(name.toLowerCase());
18101
18117
  }
18118
+ function sampleContentOk(bundlePath, content) {
18119
+ if (!SAMPLE_JSON.test(bundlePath)) return true;
18120
+ if (content.length > UPLOAD_MAX_BYTES) return false;
18121
+ try {
18122
+ const value = JSON.parse(typeof content === "string" ? content : strictUtf8.decode(content));
18123
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).every((key) => SAMPLE_KEYS.has(key));
18124
+ } catch {
18125
+ return false;
18126
+ }
18127
+ }
18102
18128
  async function readFolder(dir3, skipped = []) {
18103
18129
  const root2 = await existingDir(dir3);
18104
18130
  const files = [];
@@ -18117,7 +18143,12 @@ async function readFolder(dir3, skipped = []) {
18117
18143
  continue;
18118
18144
  }
18119
18145
  const bytes = await readFile10(abs);
18120
- files.push({ path, bytes, text: textOf2(bytes) });
18146
+ const text4 = textOf2(bytes);
18147
+ if (!sampleContentOk(path, text4 ?? bytes)) {
18148
+ skipped.push(path);
18149
+ continue;
18150
+ }
18151
+ files.push({ path, bytes, text: text4 });
18121
18152
  }
18122
18153
  }
18123
18154
  };
@@ -18165,6 +18196,12 @@ async function recordPullState(root2, entries2) {
18165
18196
  await writeFile4(path, `${JSON.stringify({ files }, null, 2)}
18166
18197
  `);
18167
18198
  }
18199
+ function checkPulledSample(bundlePath, text4) {
18200
+ if (!SAMPLE_JSON.test(bundlePath)) return;
18201
+ if (typeof text4 !== "string" || !sampleContentOk(bundlePath, Buffer.from(text4, "utf8"))) {
18202
+ throw unsafePath(bundlePath, "it does not hold a Studio sample (one JSON object with only the keys account, person, sender, brand, link, data, role and roles)");
18203
+ }
18204
+ }
18168
18205
  function unsafePath(bundlePath, why) {
18169
18206
  return new KensoError({
18170
18207
  code: "unsafe_path",
@@ -18194,7 +18231,7 @@ async function mapLimit(items, limit, fn) {
18194
18231
  await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
18195
18232
  return out;
18196
18233
  }
18197
- var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8, TOP_FILES, ASSET_TYPES, SAMPLE_NAME, TOOL_CONFIG_NAMES, NAME, WINDOWS_DEVICE, LAYOUT, PULL_STATE, sha2563, CONTENT_TYPES2;
18234
+ var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8, TOP_FILES, ASSET_TYPES, SAMPLE_NAME, TOOL_CONFIG_NAMES, SAMPLE_KEYS, SAMPLE_JSON, strictUtf8, NAME, WINDOWS_DEVICE, LAYOUT, PULL_STATE, sha2563, CONTENT_TYPES2;
18198
18235
  var init_folder2 = __esm({
18199
18236
  "src/commands/studio/folder.ts"() {
18200
18237
  "use strict";
@@ -18243,9 +18280,12 @@ var init_folder2 = __esm({
18243
18280
  "pyrightconfig.json",
18244
18281
  "cypress.json"
18245
18282
  ]);
18283
+ SAMPLE_KEYS = /* @__PURE__ */ new Set(["account", "person", "sender", "brand", "link", "data", "role", "roles"]);
18284
+ SAMPLE_JSON = /^samples\/[^/]+\.json$/i;
18285
+ strictUtf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
18246
18286
  NAME = /^[A-Za-z0-9_-](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?$/;
18247
18287
  WINDOWS_DEVICE = /^(?:CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(?:\.|$)/i;
18248
- LAYOUT = "studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase like acme.json, never a tool's config name such as package.json)";
18288
+ LAYOUT = "studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase like acme.json, never a tool's config name such as package.json; a .json there is one object with only the keys account, person, sender, brand, link, data, role and roles)";
18249
18289
  PULL_STATE = ".kenso-pull.json";
18250
18290
  sha2563 = (bytes) => createHash7("sha256").update(bytes).digest("hex");
18251
18291
  CONTENT_TYPES2 = {
@@ -18386,7 +18426,7 @@ var init_pull = __esm({
18386
18426
  action: "pull",
18387
18427
  summary: "Write a template version's files to a folder",
18388
18428
  effect: "read",
18389
- description: `Reads GET /v1/asset-templates/{templateId}/pull and writes every file under --dir: text files from the answer, binaries downloaded from their signed links. It replaces an existing file only when an earlier pull wrote it or a push sent it and it has not changed since (${PULL_STATE} in the folder records both), or with --force; other files in the folder are left alone. Every path is checked before anything is written: one that is not a file of the Studio bundle layout (studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/, samples/), would land outside --dir, or passes through a symbolic link is refused. --template-version picks the version: draft, latest (published) or a version id; the default is the draft, else the latest published version. --dry-run lists the paths, and the files it would not replace, without writing or downloading anything.`,
18429
+ description: `Reads GET /v1/asset-templates/{templateId}/pull and writes every file under --dir: text files from the answer, binaries downloaded from their signed links. It replaces an existing file only when an earlier pull wrote it or a push sent it and it has not changed since (${PULL_STATE} in the folder records both), or with --force; other files in the folder are left alone. Every path is checked before anything is written: one that is not a file of the Studio bundle layout (studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/, samples/), would land outside --dir, or passes through a symbolic link is refused, and so is a samples/ .json that is not one object with only the keys account, person, sender, brand, link, data, role and roles. --template-version picks the version: draft, latest (published) or a version id; the default is the draft, else the latest published version. --dry-run lists the paths, and the files it would not replace, without writing or downloading anything.`,
18390
18430
  flags: {
18391
18431
  dir: { type: "string", required: true, description: "The folder to write the files to (created when missing)" },
18392
18432
  "template-version": { type: "string", description: "draft, latest or a version id (default: the draft, else the latest published)" },
@@ -18413,9 +18453,10 @@ var init_pull = __esm({
18413
18453
  });
18414
18454
  const pulled = unwrap(res.body) ?? {};
18415
18455
  if (pulled.skipped?.length) {
18416
- ctx.output.warn(`Kenso left out ${pulled.skipped.length} stored file${pulled.skipped.length === 1 ? "" : "s"} outside the bundle layout: ${pulled.skipped.join(", ")}.`);
18456
+ ctx.output.warn(`Kenso left out ${pulled.skipped.length} stored file${pulled.skipped.length === 1 ? "" : "s"} that a push would refuse now (outside the bundle layout, or a sample .json that does not hold a sample): ${pulled.skipped.join(", ")}.`);
18417
18457
  }
18418
18458
  const files = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(dir3, path) }));
18459
+ for (const { path, file } of files) checkPulledSample(path, file.text);
18419
18460
  const missing2 = files.find(({ file }) => typeof file.text !== "string" && !file.downloadUrl);
18420
18461
  if (missing2) {
18421
18462
  throw new KensoError({ code: "pull_incomplete", message: `${missing2.path} came back with neither text nor a download link.`, exitCode: ExitCode.Server });
@@ -18523,7 +18564,7 @@ var init_push = __esm({
18523
18564
  action: "push",
18524
18565
  summary: "Save a folder's files to a template's draft and print the validation",
18525
18566
  effect: "write",
18526
- description: "Reads the files of the Studio bundle layout in --dir: studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase, never a tool's config name such as package.json). Anything else is skipped, with a note for each file or folder that is not a dotfile or node_modules. Text files (valid UTF-8, no NUL byte, under 1 MB) go inline; every other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. Then one push saves them into the draft and prints the validation result. Files not in the folder stay in the draft unless --delete-missing. With --publish, the new version is published when validation passes. Exit 2 when validation finds errors (the draft is still saved). --dry-run only lists the files a push would send; kenso studio validate checks them without saving.",
18567
+ description: "Reads the files of the Studio bundle layout in --dir: studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase, never a tool's config name such as package.json; a .json there is one object with only the keys account, person, sender, brand, link, data, role and roles). Anything else is skipped, with a note for each file or folder that is not a dotfile or node_modules. Text files (valid UTF-8, no NUL byte, under 1 MB) go inline; every other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. Then one push saves them into the draft and prints the validation result. Files not in the folder stay in the draft unless --delete-missing. With --publish, the new version is published when validation passes. Exit 2 when validation finds errors (the draft is still saved). --dry-run only lists the files a push would send; kenso studio validate checks them without saving.",
18527
18568
  flags: {
18528
18569
  dir: { type: "string", required: true, description: "The template folder" },
18529
18570
  "delete-missing": { type: "boolean", description: "Make the draft hold exactly the folder's files" },