kenso 0.1.120 → 0.1.122
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 +2 -0
- package/dist/kenso.js +181 -66
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/docs/batch.md +3 -1
- package/docs/crm.md +1 -1
- package/docs/reference.md +2 -2
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -2481,7 +2481,7 @@ var VERSION;
|
|
|
2481
2481
|
var init_version = __esm({
|
|
2482
2482
|
"src/core/version.ts"() {
|
|
2483
2483
|
"use strict";
|
|
2484
|
-
VERSION = true ? "0.1.
|
|
2484
|
+
VERSION = true ? "0.1.122" : "0.0.0-dev";
|
|
2485
2485
|
}
|
|
2486
2486
|
});
|
|
2487
2487
|
|
|
@@ -4152,8 +4152,8 @@ var init_results = __esm({
|
|
|
4152
4152
|
|
|
4153
4153
|
// src/batch/runs.ts
|
|
4154
4154
|
import { randomBytes } from "node:crypto";
|
|
4155
|
-
import { chmodSync as chmodSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
4156
|
-
import {
|
|
4155
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync2, statSync } from "node:fs";
|
|
4156
|
+
import { open, readdir, realpath, rename, stat, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
4157
4157
|
import { join as join5, resolve as resolve2 } from "node:path";
|
|
4158
4158
|
function runsRoot(env = process.env) {
|
|
4159
4159
|
const override2 = env.KENSO_RUNS_DIR?.trim();
|
|
@@ -4190,12 +4190,60 @@ function argsIdentity(args) {
|
|
|
4190
4190
|
}
|
|
4191
4191
|
return JSON.stringify(stable(kept));
|
|
4192
4192
|
}
|
|
4193
|
+
function currentUid() {
|
|
4194
|
+
return process.getuid?.();
|
|
4195
|
+
}
|
|
4196
|
+
function modeText(stats) {
|
|
4197
|
+
return (stats.mode & 4095).toString(8);
|
|
4198
|
+
}
|
|
4199
|
+
function notOurs(stats) {
|
|
4200
|
+
const uid = currentUid();
|
|
4201
|
+
if (uid === void 0) return void 0;
|
|
4202
|
+
if (stats.uid !== uid) return `another user (uid ${stats.uid}) owns it`;
|
|
4203
|
+
if ((stats.mode & 18) !== 0) return `other users can write it (mode ${modeText(stats)})`;
|
|
4204
|
+
return void 0;
|
|
4205
|
+
}
|
|
4206
|
+
function rootRefusal(stats) {
|
|
4207
|
+
const uid = currentUid();
|
|
4208
|
+
if (uid === void 0) return void 0;
|
|
4209
|
+
const sticky = (stats.mode & 512) !== 0;
|
|
4210
|
+
if (stats.uid !== uid && !(stats.uid === 0 && sticky)) return `another user (uid ${stats.uid}) owns it`;
|
|
4211
|
+
if ((stats.mode & 18) !== 0 && !sticky) return `other users can write it (mode ${modeText(stats)})`;
|
|
4212
|
+
return void 0;
|
|
4213
|
+
}
|
|
4214
|
+
function notPrivateError(dir2, reason) {
|
|
4215
|
+
return usageError(`kenso will not keep runs in ${dir2}: ${reason}.`, {
|
|
4216
|
+
hint: "Use a folder only you own and can write (chmod 700 it), or leave KENSO_RUNS_DIR and --out unset to use ~/.kenso/runs."
|
|
4217
|
+
});
|
|
4218
|
+
}
|
|
4193
4219
|
function ensureDir(dir2, mode) {
|
|
4194
4220
|
mkdirSync2(dir2, { recursive: true, mode: mode & 511 });
|
|
4221
|
+
const uid = currentUid();
|
|
4195
4222
|
try {
|
|
4196
4223
|
chmodSync2(dir2, mode);
|
|
4224
|
+
} catch (err) {
|
|
4225
|
+
if (uid === void 0) return;
|
|
4226
|
+
throw notPrivateError(dir2, `kenso cannot set its mode (${err.code ?? String(err)})`);
|
|
4227
|
+
}
|
|
4228
|
+
if (uid === void 0) return;
|
|
4229
|
+
const stats = statSync(dir2);
|
|
4230
|
+
if (stats.uid !== uid) throw notPrivateError(dir2, `another user (uid ${stats.uid}) owns it`);
|
|
4231
|
+
if ((stats.mode & 18 & ~mode) !== 0) throw notPrivateError(dir2, `its mode stayed ${modeText(stats)} after kenso set it`);
|
|
4232
|
+
}
|
|
4233
|
+
async function checkRoot(root2) {
|
|
4234
|
+
let stats;
|
|
4235
|
+
try {
|
|
4236
|
+
stats = await stat(root2);
|
|
4197
4237
|
} catch {
|
|
4238
|
+
return false;
|
|
4198
4239
|
}
|
|
4240
|
+
if (rootRefusal(stats) !== void 0 && stats.uid === currentUid()) {
|
|
4241
|
+
ensurePrivateDir2(root2);
|
|
4242
|
+
stats = await stat(root2);
|
|
4243
|
+
}
|
|
4244
|
+
const refusal2 = rootRefusal(stats);
|
|
4245
|
+
if (refusal2) throw notPrivateError(root2, refusal2);
|
|
4246
|
+
return true;
|
|
4199
4247
|
}
|
|
4200
4248
|
function ensurePrivateDir2(dir2) {
|
|
4201
4249
|
ensureDir(dir2, 448);
|
|
@@ -4218,8 +4266,25 @@ async function writeRunRecord(record3) {
|
|
|
4218
4266
|
const { dir: dir2, ...rest } = record3;
|
|
4219
4267
|
await writeJsonAtomic(join5(dir2, "run.json"), rest);
|
|
4220
4268
|
}
|
|
4221
|
-
|
|
4222
|
-
return
|
|
4269
|
+
function notYoursError(path, reason) {
|
|
4270
|
+
return new KensoError({
|
|
4271
|
+
code: "run_not_private",
|
|
4272
|
+
message: `kenso will not read the run in ${path}: ${reason}.`,
|
|
4273
|
+
exitCode: ExitCode.Usage,
|
|
4274
|
+
field: "runId",
|
|
4275
|
+
hint: "A run folder and its run.json must belong to you and be writable only by you. If you did not make this run, remove it.",
|
|
4276
|
+
next: "kenso runs list"
|
|
4277
|
+
});
|
|
4278
|
+
}
|
|
4279
|
+
async function readOwnJson(path) {
|
|
4280
|
+
const handle = await open(path, "r");
|
|
4281
|
+
try {
|
|
4282
|
+
const refusal2 = notOurs(await handle.stat());
|
|
4283
|
+
if (refusal2) throw notYoursError(path, refusal2);
|
|
4284
|
+
return JSON.parse(await handle.readFile("utf8"));
|
|
4285
|
+
} finally {
|
|
4286
|
+
await handle.close();
|
|
4287
|
+
}
|
|
4223
4288
|
}
|
|
4224
4289
|
function asRecord3(value) {
|
|
4225
4290
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
@@ -4228,13 +4293,22 @@ function chunkList(value) {
|
|
|
4228
4293
|
if (!Array.isArray(value)) return void 0;
|
|
4229
4294
|
return value.filter((n) => Number.isInteger(n) && n >= 0);
|
|
4230
4295
|
}
|
|
4231
|
-
async function
|
|
4232
|
-
let
|
|
4296
|
+
async function readRun(dir2) {
|
|
4297
|
+
let dirStats;
|
|
4233
4298
|
try {
|
|
4234
|
-
|
|
4299
|
+
dirStats = await stat(dir2);
|
|
4235
4300
|
} catch {
|
|
4236
4301
|
return null;
|
|
4237
4302
|
}
|
|
4303
|
+
const refusal2 = notOurs(dirStats);
|
|
4304
|
+
if (refusal2) throw notYoursError(dir2, refusal2);
|
|
4305
|
+
let raw;
|
|
4306
|
+
try {
|
|
4307
|
+
raw = asRecord3(await readOwnJson(join5(dir2, "run.json")));
|
|
4308
|
+
} catch (err) {
|
|
4309
|
+
if (err instanceof KensoError) throw err;
|
|
4310
|
+
return null;
|
|
4311
|
+
}
|
|
4238
4312
|
if (!raw) return null;
|
|
4239
4313
|
const { runId, command: command69, createdAt, status } = raw;
|
|
4240
4314
|
if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
|
|
@@ -4242,7 +4316,7 @@ async function readRunDir(dir2) {
|
|
|
4242
4316
|
if (typeof status !== "string" || !STATUSES.includes(status)) return null;
|
|
4243
4317
|
let chunksDone = chunkList(raw.chunksDone) ?? [];
|
|
4244
4318
|
try {
|
|
4245
|
-
const state = asRecord3(await
|
|
4319
|
+
const state = asRecord3(await readOwnJson(join5(dir2, "state.json")));
|
|
4246
4320
|
chunksDone = chunkList(state?.chunksDone) ?? chunksDone;
|
|
4247
4321
|
} catch {
|
|
4248
4322
|
}
|
|
@@ -4259,8 +4333,12 @@ async function readRunDir(dir2) {
|
|
|
4259
4333
|
};
|
|
4260
4334
|
return record3;
|
|
4261
4335
|
}
|
|
4336
|
+
async function readRunDir(dir2) {
|
|
4337
|
+
return readRun(dir2).catch(() => null);
|
|
4338
|
+
}
|
|
4262
4339
|
async function listRuns(env = process.env) {
|
|
4263
4340
|
const root2 = runsRoot(env);
|
|
4341
|
+
if (!await checkRoot(root2)) return [];
|
|
4264
4342
|
let names;
|
|
4265
4343
|
try {
|
|
4266
4344
|
names = await readdir(root2);
|
|
@@ -4288,11 +4366,12 @@ async function loadRun(runId, env = process.env) {
|
|
|
4288
4366
|
}
|
|
4289
4367
|
let dir2;
|
|
4290
4368
|
try {
|
|
4291
|
-
dir2 = await realpath(join5(runsRoot(env), id));
|
|
4292
|
-
} catch {
|
|
4369
|
+
if (await checkRoot(runsRoot(env))) dir2 = await realpath(join5(runsRoot(env), id));
|
|
4370
|
+
} catch (err) {
|
|
4371
|
+
if (err instanceof KensoError) throw err;
|
|
4293
4372
|
dir2 = void 0;
|
|
4294
4373
|
}
|
|
4295
|
-
const run = dir2 ? await
|
|
4374
|
+
const run = dir2 ? await readRun(dir2) : null;
|
|
4296
4375
|
if (!run || run.runId !== id) {
|
|
4297
4376
|
throw new KensoError({
|
|
4298
4377
|
code: "run_not_found",
|
|
@@ -6535,7 +6614,7 @@ var init_sync2 = __esm({
|
|
|
6535
6614
|
|
|
6536
6615
|
// src/batch/input.ts
|
|
6537
6616
|
import { createHash as createHash2 } from "node:crypto";
|
|
6538
|
-
import { readFile as
|
|
6617
|
+
import { readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
6539
6618
|
import { extname as extname2, resolve as resolve4 } from "node:path";
|
|
6540
6619
|
function tooLarge(source) {
|
|
6541
6620
|
return usageError(`${source} is larger than 200 MB, the most the CLI reads in one run.`, {
|
|
@@ -6559,10 +6638,10 @@ async function readRaw(pathOrDash, stdin) {
|
|
|
6559
6638
|
if (pathOrDash.trim() === "") throw usageError("Name an input file, or - for stdin.", { field: "file" });
|
|
6560
6639
|
const path = resolve4(pathOrDash);
|
|
6561
6640
|
try {
|
|
6562
|
-
const info = await
|
|
6641
|
+
const info = await stat2(path);
|
|
6563
6642
|
if (info.isDirectory()) throw fileUnreadable(pathOrDash, { code: "EISDIR" });
|
|
6564
6643
|
if (info.size > MAX_INPUT_BYTES) throw tooLarge(pathOrDash);
|
|
6565
|
-
return { path, bytes: await
|
|
6644
|
+
return { path, bytes: await readFile4(path) };
|
|
6566
6645
|
} catch (err) {
|
|
6567
6646
|
if (err instanceof KensoError) throw err;
|
|
6568
6647
|
throw fileUnreadable(pathOrDash, err);
|
|
@@ -7811,6 +7890,7 @@ var init_import = __esm({
|
|
|
7811
7890
|
beta: { featureGates: { all: ["accounts"] } },
|
|
7812
7891
|
operationIds: ["accounts.bulk-create", "credit-estimates.create"],
|
|
7813
7892
|
dryRun: true,
|
|
7893
|
+
batch: true,
|
|
7814
7894
|
async run(ctx, args) {
|
|
7815
7895
|
const { flags } = args;
|
|
7816
7896
|
const concurrency2 = concurrencyOf(flags.concurrency);
|
|
@@ -7863,7 +7943,7 @@ var init_import = __esm({
|
|
|
7863
7943
|
|
|
7864
7944
|
// src/commands/contacts/common.ts
|
|
7865
7945
|
import { createHash as createHash3 } from "node:crypto";
|
|
7866
|
-
import { readFile as
|
|
7946
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
7867
7947
|
import { resolve as resolve5 } from "node:path";
|
|
7868
7948
|
function stringFlag2(flags, name) {
|
|
7869
7949
|
const value = flags[name];
|
|
@@ -7918,7 +7998,7 @@ function sameCommand2(command69, flags, ctx, extra = []) {
|
|
|
7918
7998
|
return parts2.join(" ");
|
|
7919
7999
|
}
|
|
7920
8000
|
async function fileSha256(path) {
|
|
7921
|
-
return createHash3("sha256").update(await
|
|
8001
|
+
return createHash3("sha256").update(await readFile5(resolve5(path))).digest("hex");
|
|
7922
8002
|
}
|
|
7923
8003
|
function rateLimitRemaining3(headers) {
|
|
7924
8004
|
const raw = headers.get("ratelimit-remaining");
|
|
@@ -8772,7 +8852,7 @@ var init_auth = __esm({
|
|
|
8772
8852
|
var batch_default;
|
|
8773
8853
|
var init_batch = __esm({
|
|
8774
8854
|
"docs/batch.md"() {
|
|
8775
|
-
batch_default = '# Batch runs\n\nA batch command takes a file, sends its rows to Kenso in chunks, and prints one JSON summary. Every input row gets one line in a results file, every run can be resumed, and nothing is written until you pass `--yes`.\n\nThe batch commands:\n\n- `contacts import`, `update`, `remove`, `restore`, `pause`, `resume`, `tag`, `untag` ([Leads](leads.md))\n- `people import` and `accounts import` ([CRM](crm.md), beta)\n- `studio fill` ([Studio](studio.md), beta)\n- any generated command run with `--each <file>`, once per row (see below)\n\n## Plan, then apply\n\nWithout `--yes` a batch command plans and changes nothing. `--dry-run` asks for the plan explicitly. `--yes` applies. Passing both is a usage error. Two exceptions to the plan below: `studio fill` without `--yes` prints its credit estimate and `next`, with no run or `plan.json` ([Studio](studio.md)), and a non-GET `--each` without `--yes` or `--dry-run` is a usage error (exit 2) rather than a plan.\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\nThe dry run parses and checks every row, may call read-only endpoints (a campaign read, a credit estimate, a contacts search for `--where`), writes `plan.json`, and prints the plan:\n\n```json\n{"run":"r_ubqu7wtx","dryRun":true,"command":"contacts remove","rows":3,"valid":3,"invalid":0,"chunks":1,"chunkSize":1000,"source":"ids","count":3,"firstIds":[11,12,13],"next":"kenso contacts remove --ids ids.txt --yes","plan":"/home/you/.kenso/runs/r_ubqu7wtx/plan.json"}\n```\n\nEvery plan has `run`, `dryRun`, `command`, `rows`, `valid`, `invalid`, `chunks`, `chunkSize`, `next` (the exact command that applies it) and `plan` (the file), plus fields of its own command. It adds `invalidRows` when rows were refused, `chunksDone` when it continues an unfinished run, and `alreadyDone: true` when the apply would change nothing.\n\nA file the CLI cannot read stops the run before anything is planned, with `file_unreadable` (exit 2), the line at fault and a hint: `leads.csv line 3: a quote is not closed.`, `leads.csv does not exist.`, `rows.jsonl line 7 is not valid JSON.`\n\n## The summary\n\nAn applied run prints one JSON object:\n\n```json\n{"run":"r_ubqu7wtx","rows":3,"ok":2,"created":0,"updated":0,"skipped":{},"failed":0,"notFound":1,"invalid":0,"changed":2,"results":"/home/you/.kenso/runs/r_ubqu7wtx/results.csv","resultsNdjson":"/home/you/.kenso/runs/r_ubqu7wtx/results.ndjson","resumed":false,"durationMs":412,"undo":"kenso contacts restore --run r_ubqu7wtx"}\n```\n\n| Field | Meaning |\n|---|---|\n| `run` | The run id: `r_` and 8 characters |\n| `rows` | Input rows |\n| `ok`, `created`, `updated` | Rows that succeeded, by kind |\n| `skipped` | Rows Kenso left alone on purpose, counted by reason, for example `{"duplicate":12}` |\n| `failed`, `notFound`, `invalid` | Rows that did not go through: refused or errored, id not found, refused locally |\n| `changed` | Rows this invocation changed. 0 when a rerun had nothing left to do |\n| `results`, `resultsNdjson` | Absolute paths of the results files |\n| `invalidRows` | Path of `invalid.csv`, when rows were refused locally |\n| `resumed` | True when this invocation continued an earlier run |\n| `durationMs` | Wall time of this invocation |\n| `pending` | Rows without a result yet, when the run did not finish |\n| `stopped` | `{code, message, hint}` when a stop condition ended the run (for example `limit_reached`) |\n| `interrupted` | True after Ctrl-C |\n| `next` | `kenso runs resume <runId>` when the run can continue |\n\nCommands add their own fields: `contacts import` adds `campaignId` and `notSendable`, `contacts remove` adds `undo`, `people import` adds `matched`, `addedToAccounts` and `emailFindsQueued`, `accounts import` adds `researchQueued` and `researchWaitingCredits`, `studio fill` adds `templateId`, `runs` and the estimate.\n\nExit codes: 0 when every row succeeded or was skipped, 5 when some rows are `failed`, `not_found` or `invalid`, 6 when a limit stopped the run, 130 after Ctrl-C. The full table is in [Output and errors](output-and-errors.md).\n\n## The run folder\n\nEach run keeps its files in `~/.kenso/runs/<runId>/` (`KENSO_RUNS_DIR` moves the root), or in `--out <dir>` when you pass it. A run in `--out` is also linked under the runs folder, so `kenso runs` finds it. The folder is mode 0700 and its files 0600.\n\n| File | What it holds |\n|---|---|\n| `run.json` | The command, its arguments, the input path and SHA-256, the workspace, the chunk plan and the status (`planned`, `running`, `done`, `failed`, `interrupted`) |\n| `state.json` | The chunks done so far, rewritten after every chunk |\n| `results.csv` | One line per input row: `row,status,id,reason,error`, then extra columns such as `email` or `sendable` |\n| `results.ndjson` | The same rows as JSON lines |\n| `invalid.csv` | Rows refused before sending, with the reason |\n| `plan.json` | The last dry run\'s plan |\n| `summary.json` | The last summary printed |\n\n`row` is the 1-based number of the data row in the input (the CSV header is not counted). `status` is one of `created`, `updated`, `ok`, `skipped`, `failed`, `not_found` or `invalid`.\n\n```bash\nkenso runs list\nkenso runs list --limit 5 -o json\nkenso runs show r_ubqu7wtx\n```\n\n## Rerun and resume\n\nA run is identified by its command, its arguments, the SHA-256 of its input file, the workspace and the chunk size. `--yes`, `--dry-run`, `--wait`, `--concurrency` and the output flags are not part of it. Running the same command again on the same file:\n\n- **continues an unfinished run** (interrupted, stopped or crashed): finished chunks are skipped and the summary says `"resumed":true`.\n- **answers from a finished run where every row succeeded:** it prints that run\'s summary with `"changed":0` and `"alreadyDone":true`, sends no writes and exits 0 (a command may still read first: `contacts import` reads the campaign, and `contacts update --match email` looks up the campaign\'s contacts).\n- **starts a new run** when the last one finished with failed or invalid rows, or when the file changed. Lead, people and account writes match existing records (an email in a campaign, a person by email or LinkedIn URL, an account by domain), so sending a row twice never creates a duplicate.\n\n`kenso runs resume <runId>` does the same from the run id: it rebuilds the command from `run.json` and runs it with `--yes` from the folder it started in. It refuses when the input was stdin, or the file is gone or changed. Two processes cannot work on one run: the second gets `run_in_progress` (exit 7).\n\n```bash\nkenso runs resume r_ubqu7wtx\n```\n\n`studio fill` is the exception: a fill charges for every page it builds, so it never fills the same ids twice. See [Studio](studio.md).\n\n## Ctrl-C\n\nThe first Ctrl-C cancels the requests in flight and starts no new chunks. The CLI writes the state and prints the summary with `"interrupted":true` and `"next":"kenso runs resume <runId>"`, then exits 130. A chunk that did not finish is sent again when you resume, which is safe because the writes match existing records. A second Ctrl-C quits at once.\n\n## Chunks, concurrency and rate limits\n\n| Command | Rows per call | At once |\n|---|---|---|\n| `contacts import` | 1,000 | 1 per campaign |\n| `contacts update`, `remove`, `restore`, `pause`, `resume` | 1,000 | 4 (`--concurrency`) |\n| `contacts tag`, `untag` | 250 | 4 (`--concurrency`) |\n| `people import` | 200 | 4 (`--concurrency`) |\n| `accounts import` | 100 | 4 (`--concurrency`) |\n| `studio fill` | 500 ids per fill run | 1 |\n| `--each` | 1 | 4 (`--concurrency`) |\n\n`--concurrency` takes 1 to 16. When the API\'s `RateLimit-Remaining` header drops below 10, the CLI sends one chunk at a time until it is back above 30.\n\nRetries:\n\n- **429:** the CLI waits for `Retry-After` (at least 1 second, at most 60 seconds) plus a random 0 to 20%, so several agents on one key do not all retry at the same moment, and tries again, with up to 15 minutes of waiting per command. After that it exits 6 (`rate_limited`).\n- **502, 503, 504 and network errors:** up to 3 retries with backoff, for GET, PUT, PATCH and DELETE, and for the POST routes the CLI knows are safe to repeat.\n- **`contacts import`:** no quick retry. After a 5xx or a dropped connection it waits 130 seconds, longer than the gateway\'s request timeout, and resends the chunk once.\n- **`contacts remove`:** after a 5xx or a dropped connection it waits 2 seconds and resends once. Ids the first call already removed are reported `ok` (reason `already_removed`), so the undo still restores them.\n- **Other 4xx answers:** never retried. The row or chunk is marked `failed` with the API\'s code.\n\nKenso answers a bulk call with 200 even when some items fail, so the CLI reads each item\'s result and never trusts the HTTP status alone.\n\n## Progress\n\nProgress goes to stderr, at most one line every 2 seconds (`chunk 7/20, 7000 rows, 6 failed`), and only when stderr is a terminal or you pass `--progress`. An agent gets only the summary.\n\n## Run any API operation once per row: --each\n\nEvery generated command takes `--each <file>`, a CSV or JSONL file or `-` for stdin. The command runs once per row through the same engine: one results line per row, resume, `--concurrency`. Row keys fill the route, query and body by API name (`accountId`) or flag name (`account-id`). A blank cell is left out and the literal `null` sends null. A GET runs right away; any other method needs `--yes` or `--dry-run`.\n\n```bash\nkenso accounts update --each stages.csv --dry-run\nkenso accounts update --each stages.csv --yes --concurrency 8\n```\n\nWith `stages.csv`:\n\n```csv\naccountId,stage,overwritePinned\n501,engaged,true\n502,customer,true\n```\n\nEach row is `ok` on a 2xx answer (with the created or returned id), `not_found` on 404, `failed` otherwise, or `invalid` when a required value is missing.\n\n## The token-saving pattern for agents\n\n1. Pass a file path, never the rows: `--file leads.csv`.\n2. Run `--dry-run`, read the plan, then run its `next`.\n3. Read the summary. If `failed`, `notFound` and `invalid` are 0, you are done.\n4. Otherwise read only the problem rows, for example `grep -E \'^[0-9]+,(failed|not_found|invalid),\' results.csv | head -50`, or `invalid.csv`.\n';
|
|
8855
|
+
batch_default = '# Batch runs\n\nA batch command takes a file, sends its rows to Kenso in chunks, and prints one JSON summary. Every input row gets one line in a results file, every run can be resumed, and nothing is written until you pass `--yes`.\n\nThe batch commands:\n\n- `contacts import`, `update`, `remove`, `restore`, `pause`, `resume`, `tag`, `untag` ([Leads](leads.md))\n- `people import` and `accounts import` ([CRM](crm.md), beta)\n- `studio fill` ([Studio](studio.md), beta)\n- any generated command run with `--each <file>`, once per row (see below)\n\n## Plan, then apply\n\nWithout `--yes` a batch command plans and changes nothing. `--dry-run` asks for the plan explicitly. `--yes` applies. Passing both is a usage error. Two exceptions to the plan below: `studio fill` without `--yes` prints its credit estimate and `next`, with no run or `plan.json` ([Studio](studio.md)), and a non-GET `--each` without `--yes` or `--dry-run` is a usage error (exit 2) rather than a plan.\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\nThe dry run parses and checks every row, may call read-only endpoints (a campaign read, a credit estimate, a contacts search for `--where`), writes `plan.json`, and prints the plan:\n\n```json\n{"run":"r_ubqu7wtx","dryRun":true,"command":"contacts remove","rows":3,"valid":3,"invalid":0,"chunks":1,"chunkSize":1000,"source":"ids","count":3,"firstIds":[11,12,13],"next":"kenso contacts remove --ids ids.txt --yes","plan":"/home/you/.kenso/runs/r_ubqu7wtx/plan.json"}\n```\n\nEvery plan has `run`, `dryRun`, `command`, `rows`, `valid`, `invalid`, `chunks`, `chunkSize`, `next` (the exact command that applies it) and `plan` (the file), plus fields of its own command. It adds `invalidRows` when rows were refused, `chunksDone` when it continues an unfinished run, and `alreadyDone: true` when the apply would change nothing.\n\nA file the CLI cannot read stops the run before anything is planned, with `file_unreadable` (exit 2), the line at fault and a hint: `leads.csv line 3: a quote is not closed.`, `leads.csv does not exist.`, `rows.jsonl line 7 is not valid JSON.`\n\n## The summary\n\nAn applied run prints one JSON object:\n\n```json\n{"run":"r_ubqu7wtx","rows":3,"ok":2,"created":0,"updated":0,"skipped":{},"failed":0,"notFound":1,"invalid":0,"changed":2,"results":"/home/you/.kenso/runs/r_ubqu7wtx/results.csv","resultsNdjson":"/home/you/.kenso/runs/r_ubqu7wtx/results.ndjson","resumed":false,"durationMs":412,"undo":"kenso contacts restore --run r_ubqu7wtx"}\n```\n\n| Field | Meaning |\n|---|---|\n| `run` | The run id: `r_` and 8 characters |\n| `rows` | Input rows |\n| `ok`, `created`, `updated` | Rows that succeeded, by kind |\n| `skipped` | Rows Kenso left alone on purpose, counted by reason, for example `{"duplicate":12}` |\n| `failed`, `notFound`, `invalid` | Rows that did not go through: refused or errored, id not found, refused locally |\n| `changed` | Rows this invocation changed. 0 when a rerun had nothing left to do |\n| `results`, `resultsNdjson` | Absolute paths of the results files |\n| `invalidRows` | Path of `invalid.csv`, when rows were refused locally |\n| `resumed` | True when this invocation continued an earlier run |\n| `durationMs` | Wall time of this invocation |\n| `pending` | Rows without a result yet, when the run did not finish |\n| `stopped` | `{code, message, hint}` when a stop condition ended the run (for example `limit_reached`) |\n| `interrupted` | True after Ctrl-C |\n| `next` | `kenso runs resume <runId>` when the run can continue |\n\nCommands add their own fields: `contacts import` adds `campaignId` and `notSendable`, `contacts remove` adds `undo`, `people import` adds `matched`, `addedToAccounts` and `emailFindsQueued`, `accounts import` adds `researchQueued` and `researchWaitingCredits`, `studio fill` adds `templateId`, `runs` and the estimate.\n\nExit codes: 0 when every row succeeded or was skipped, 5 when some rows are `failed`, `not_found` or `invalid`, 6 when a limit stopped the run, 130 after Ctrl-C. The full table is in [Output and errors](output-and-errors.md).\n\n## The run folder\n\nEach run keeps its files in `~/.kenso/runs/<runId>/` (`KENSO_RUNS_DIR` moves the root), or in `--out <dir>` when you pass it. A run in `--out` is also linked under the runs folder, so `kenso runs` finds it. The folder is mode 0700 and its files 0600.\n\nThe CLI refuses (exit 2) a runs folder or `--out` folder that another user owns or that it cannot make 0700 (a runs folder of yours that others can write is made 0700 first; a sticky runs folder root owns, such as a Kenso sandbox\'s, passes). `kenso runs list` leaves out, and `kenso runs show` and `resume` refuse with `run_not_private`, a run whose folder or `run.json` another user owns or can write. On Windows, which has no such owners and modes, these checks are skipped.\n\n| File | What it holds |\n|---|---|\n| `run.json` | The command, its arguments, the input path and SHA-256, the workspace, the chunk plan and the status (`planned`, `running`, `done`, `failed`, `interrupted`) |\n| `state.json` | The chunks done so far, rewritten after every chunk |\n| `results.csv` | One line per input row: `row,status,id,reason,error`, then extra columns such as `email` or `sendable` |\n| `results.ndjson` | The same rows as JSON lines |\n| `invalid.csv` | Rows refused before sending, with the reason |\n| `plan.json` | The last dry run\'s plan |\n| `summary.json` | The last summary printed |\n\n`row` is the 1-based number of the data row in the input (the CSV header is not counted). `status` is one of `created`, `updated`, `ok`, `skipped`, `failed`, `not_found` or `invalid`.\n\n```bash\nkenso runs list\nkenso runs list --limit 5 -o json\nkenso runs show r_ubqu7wtx\n```\n\n## Rerun and resume\n\nA run is identified by its command, its arguments, the SHA-256 of its input file, the workspace and the chunk size. `--yes`, `--dry-run`, `--wait`, `--concurrency` and the output flags are not part of it. Running the same command again on the same file:\n\n- **continues an unfinished run** (interrupted, stopped or crashed): finished chunks are skipped and the summary says `"resumed":true`.\n- **answers from a finished run where every row succeeded:** it prints that run\'s summary with `"changed":0` and `"alreadyDone":true`, sends no writes and exits 0 (a command may still read first: `contacts import` reads the campaign, and `contacts update --match email` looks up the campaign\'s contacts).\n- **starts a new run** when the last one finished with failed or invalid rows, or when the file changed. Lead, people and account writes match existing records (an email in a campaign, a person by email or LinkedIn URL, an account by domain), so sending a row twice never creates a duplicate.\n\n`kenso runs resume <runId>` does the same from the run id: it rebuilds the command from `run.json` and runs it with `--yes` from the folder it started in. It replays only a batch command (`contacts import`, `update`, `remove`, `restore`, `pause`, `resume`, `tag` and `untag`, `people import`, `accounts import`, `studio fill`, or a command run with `--each`) and only the flags that command takes, never a `kenso work` run. It refuses when the input was stdin, or the file is gone or changed. Two processes cannot work on one run: the second gets `run_in_progress` (exit 7).\n\n```bash\nkenso runs resume r_ubqu7wtx\n```\n\n`studio fill` is the exception: a fill charges for every page it builds, so it never fills the same ids twice. See [Studio](studio.md).\n\n## Ctrl-C\n\nThe first Ctrl-C cancels the requests in flight and starts no new chunks. The CLI writes the state and prints the summary with `"interrupted":true` and `"next":"kenso runs resume <runId>"`, then exits 130. A chunk that did not finish is sent again when you resume, which is safe because the writes match existing records. A second Ctrl-C quits at once.\n\n## Chunks, concurrency and rate limits\n\n| Command | Rows per call | At once |\n|---|---|---|\n| `contacts import` | 1,000 | 1 per campaign |\n| `contacts update`, `remove`, `restore`, `pause`, `resume` | 1,000 | 4 (`--concurrency`) |\n| `contacts tag`, `untag` | 250 | 4 (`--concurrency`) |\n| `people import` | 200 | 4 (`--concurrency`) |\n| `accounts import` | 100 | 4 (`--concurrency`) |\n| `studio fill` | 500 ids per fill run | 1 |\n| `--each` | 1 | 4 (`--concurrency`) |\n\n`--concurrency` takes 1 to 16. When the API\'s `RateLimit-Remaining` header drops below 10, the CLI sends one chunk at a time until it is back above 30.\n\nRetries:\n\n- **429:** the CLI waits for `Retry-After` (at least 1 second, at most 60 seconds) plus a random 0 to 20%, so several agents on one key do not all retry at the same moment, and tries again, with up to 15 minutes of waiting per command. After that it exits 6 (`rate_limited`).\n- **502, 503, 504 and network errors:** up to 3 retries with backoff, for GET, PUT, PATCH and DELETE, and for the POST routes the CLI knows are safe to repeat.\n- **`contacts import`:** no quick retry. After a 5xx or a dropped connection it waits 130 seconds, longer than the gateway\'s request timeout, and resends the chunk once.\n- **`contacts remove`:** after a 5xx or a dropped connection it waits 2 seconds and resends once. Ids the first call already removed are reported `ok` (reason `already_removed`), so the undo still restores them.\n- **Other 4xx answers:** never retried. The row or chunk is marked `failed` with the API\'s code.\n\nKenso answers a bulk call with 200 even when some items fail, so the CLI reads each item\'s result and never trusts the HTTP status alone.\n\n## Progress\n\nProgress goes to stderr, at most one line every 2 seconds (`chunk 7/20, 7000 rows, 6 failed`), and only when stderr is a terminal or you pass `--progress`. An agent gets only the summary.\n\n## Run any API operation once per row: --each\n\nEvery generated command takes `--each <file>`, a CSV or JSONL file or `-` for stdin. The command runs once per row through the same engine: one results line per row, resume, `--concurrency`. Row keys fill the route, query and body by API name (`accountId`) or flag name (`account-id`). A blank cell is left out and the literal `null` sends null. A GET runs right away; any other method needs `--yes` or `--dry-run`.\n\n```bash\nkenso accounts update --each stages.csv --dry-run\nkenso accounts update --each stages.csv --yes --concurrency 8\n```\n\nWith `stages.csv`:\n\n```csv\naccountId,stage,overwritePinned\n501,engaged,true\n502,customer,true\n```\n\nEach row is `ok` on a 2xx answer (with the created or returned id), `not_found` on 404, `failed` otherwise, or `invalid` when a required value is missing.\n\n## The token-saving pattern for agents\n\n1. Pass a file path, never the rows: `--file leads.csv`.\n2. Run `--dry-run`, read the plan, then run its `next`.\n3. Read the summary. If `failed`, `notFound` and `invalid` are 0, you are done.\n4. Otherwise read only the problem rows, for example `grep -E \'^[0-9]+,(failed|not_found|invalid),\' results.csv | head -50`, or `invalid.csv`.\n';
|
|
8776
8856
|
}
|
|
8777
8857
|
});
|
|
8778
8858
|
|
|
@@ -8788,7 +8868,7 @@ var init_connect = __esm({
|
|
|
8788
8868
|
var crm_default;
|
|
8789
8869
|
var init_crm = __esm({
|
|
8790
8870
|
"docs/crm.md"() {
|
|
8791
|
-
crm_default = '# CRM (beta)\n\nThe CRM commands work on Kenso\'s Accounts lane: accounts (companies), the people on them, and opportunities. They are beta: they need the `accounts` feature flag on your workspace (opportunities need `opportunities`, CRM sync needs `ingestion`). Help and `kenso describe` hide them until your workspace has the flag; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `accounts import` | Create accounts from a CSV or JSONL file. Research is charged per created account |\n| `people import` | Create or match people from a file, optionally onto accounts |\n| `import accounts <file.csv>`, `import people <file.csv>`, `import deals <file.csv>` | Import a CSV export of another CRM, up to 50,000 rows: Kenso proposes the mapping, you approve once, it runs in the background and can be undone for 30 days |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts bulk-update`, `people bulk-update`, `opportunities bulk-update` | Set the same fields on many records at once, by ids or by a filter, with a preview first. Needs `bulk_edit` too |\n| `accounts bulk-delete`, `people bulk-delete`, `opportunities bulk-delete` | Delete many records at once, by ids or by a filter, with a preview first. Not undone. Needs `bulk_edit` too |\n| `changes list`, `get`, `rows`, `apply`, `cancel`, `undo` | Follow a bulk change, read what each record got, stop it, or put the old values back for 30 days |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities move <id> [--stage <key>] [--pipeline <pipelineId>] [--reason <key>]` | Move a deal to a stage or another pipeline, with its won or lost reason; a field the stage asks for never stops it |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `notes list`, `notes add`, `notes edit`, `notes delete` | Notes and comments on accounts, people and deals (needs `record_notes`) |\n| `deleted-accounts list`, `accounts restore --account-id <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `accounts duplicates`, `accounts merge <id> --into <id>`, `accounts merges list` | The pairs that look like one company, merging a pair, and the log of merges |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved view (`--view <id>`), or what the filters match |\n| `capture status` | Your captured mailbox, its backfill progress and what teammates see of a captured email. Needs the `crm_capture` flag |\n| `capture connect` | Turn capture on for your own mailbox. `--private` starts it hidden from teammates; `--provider google` prints a sign-in link when no account is connected yet |\n| `capture private on\\|off` | Hide your captured email from teammates, or show it again. Email only: meetings stay visible. `--thread <id>` sets the switch for one thread |\n| `capture thread <threadId>` | One captured email thread: subject, people, time, Ken\'s summary, the members whose mailboxes hold it, and each body you may open. The id is `capturedThread.id` on a timeline row |\n| `views pin <viewId>`, `views unpin <viewId>` | Pin a saved view to your own sidebar, or take it off. Needs the `shared_views` flag |\n| `capture sync` | Read your captured mailbox now, instead of waiting for the next two-minute poll. Prints what the pass read, logged and created |\n| `capture disconnect` | Turn capture off and delete your stored email bodies. Asks first; `--yes` skips the question |\n| `capture teammates-see summary\\|full_email` | Workspace admin: what teammates see of captured email |\n| `pipelines stage-rules` | List or set the fields a deal should have in each stage |\n| `opportunity-reasons get`, `opportunity-reasons replace` | List or edit why deals are lost and won |\n| `layouts show\\|set\\|reset <object>` | How every account, person or deal page in the workspace lays out its fields: header, rail sections and hidden fields (needs `record_layout`) |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n| `tasks add`, `tasks done`, `tasks assign`, `tasks queue` | Add a to-do for a member on an account, person or deal, complete it, hand it on, or read your open work (needs `tasks`) |\n| `fields list`, `create`, `update`, `archive` | The built-in and custom fields of accounts, people and deals, and adding your own (needs `custom_fields`) |\n| `field-fill-settings`, `suggestions`, `fields fill` | How Ken fills each field from email, calls and meetings, the values it waits on you for, and filling a deal field for existing deals (needs `ken_field_fill`) |\n| `views list`, `create`, `run`, `update`, `delete` | Saved views of accounts, people and deals, private or shared with the workspace (needs `shared_views`) |\n| `reports summary`, `reports run <report>`, `reports query`, `dashboards` | Pipeline reports over your deals, your own counts and sums, and dashboards of saved charts (needs `opportunities` and `reports`) |\n| `forecast show`, `quotas list`, `set`, `propose` | Closed won, commit and best case against each member\'s quota for a month or quarter (needs `opportunities` and `forecast`) |\n\nImport accounts first, then people: `people import` never creates an account.\n\n## Import accounts\n\n```bash\nkenso accounts import --file accounts.csv\nkenso accounts import --file accounts.csv --yes\n```\n\n```csv\nname,domain,industry,employeeCount\nAcme,acme.io,Software,120\nGlobex,globex.com,Manufacturing,"1,200"\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `name` (or `company`, `companyName`, `accountName`), `domains` (several, split on `,` or `;`) or one `domain` (or `website`, `companyDomain`), `industry`, `employeeCount`, `hqLocation`, `linkedinUrl`, `stage`, `angle`, `whyNow`, `fitScore`, `fundingRound`, `cadenceDays`, `ownerMemberId`, `kenCompanyId`, `sendsFromInboxId`, `sendsFromLinkedInAccountId` and `source`.\n- **A domain is required.** A file with no domain column is a usage error, and a row without a domain is `invalid` (`domain_required`).\n- **The dry run prices the research.** It asks for a credit estimate per 1,000 accounts and puts the sum in the plan: `kind`, `accountCount`, `totalMillicredits`, `availableMillicredits` and `sufficient`.\n- **Rows go 100 per call** to `POST /v1/accounts/bulk-create`.\n\nEach row comes back `created` (`id` is the new account; its research is queued, `researchQueued`, or waits for credits, `researchWaitingCredits`), `skipped` with reason `domain_taken` (already an account; `id` is that account) or `failed` (`reason` is the API\'s code, `error` names the field; an item Kenso failed to save is sent once more first). Rerunning the same file is safe: accounts that exist come back `domain_taken`.\n\n## Import people\n\n```bash\nkenso people import --file people.csv\nkenso people import --file people.csv --find-emails --yes\nkenso people import --file people.jsonl --dry-run\n```\n\n```csv\nfullName,email,title,accountDomain,role\nAnn Lee,ann@acme.io,VP Sales,acme.io,champion\nBob Ray,,CTO,acme.io,\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `email`, `fullName` (or `name`), `firstName`, `lastName`, `title`, `linkedinUrl` (or `linkedin`, `profileUrl`), `accountDomain` (or `domain`, `website`, `companyDomain`), `accountId`, `role` and `priority`. Other columns are ignored with one warning.\n- **A person needs a name:** `fullName`, or `firstName`, `lastName` or both (the CLI joins them). A row with none of them is `invalid` (`name_required`).\n- **To put a person on an account,** give `accountDomain` or `accountId`. A row with both sends only `accountId`.\n- **`--find-emails`** queues an email find (charged in credits) for each person without an email.\n- **Rows go 200 per call** to `POST /v1/people/batch`.\n\nPeople already in the workspace are matched by email, then LinkedIn URL, so running the same file again creates nobody twice. A row comes back `created` (a new person), `updated` (an existing person added to the account), `skipped` with reason `already_on_account`, `matched` (no account asked) or `previously_removed`, or `failed`: `account_not_found` saves the person without an account (import the account, then rerun to place them), any other reason is the API\'s. The summary adds `matched`, `addedToAccounts` and `emailFindsQueued`.\n\n## List and search accounts\n\n`accounts list` and `accounts search` sort and page on the server, so they reach every account in the workspace, however many there are.\n\n```bash\nkenso accounts list --sort score:desc --limit 100 # one page; the output\'s next: line is the following one\nkenso accounts list --sort score:desc --limit 100 --all # every page, to the end\nkenso accounts search --search hiring --sort latestSignalAt:desc --data \'{"qFields": ["name", "latestSignal"]}\'\nkenso accounts search --limit 1 --data \'{"countBy": ["stage"]}\' # how many accounts sit in each stage\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}]}, "sort": "tier,-pipelineAmount"}\' --all\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "hqLocation", "operator": "contains", "values": ["Germany"]}]}}\' --all\n# my accounts with a meeting this quarter: me is whoever runs it, so a saved view with it lists each member\'s own\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "owner", "operator": "is", "values": ["me"]}, {"field": "lastMeeting", "operator": "in_period", "values": ["this_quarter"]}]}}\' --all\n# tier 1 accounts with no meeting in 30 days: none since then, or none ever\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}, {"match": "any", "conditions": [{"field": "lastMeeting", "operator": "older_than_days", "values": ["30"]}, {"field": "lastMeeting", "operator": "is_empty"}]}]}}\' --all\n```\n\n- **`--sort`** takes up to 3 comma-separated keys, each `field` (ascending), `field:asc` or `field:desc`. The API\'s `-field` form needs the equals sign here, `--sort=-score`, because a value that starts with a dash reads as a flag. Fields: `createdAt`, `name`, `score`, `tier` (ascending is tier 1 first), `latestSignalAt`, `committee`, `pipelineAmount`, `nextTouchAt`, `lastTouchAt`. An account with no value for a key comes last in both directions. The default is `-createdAt`.\n- **`--limit`** is 1 to 1000 (default 50). `--cursor` takes the previous page\'s `nextCursor` with the same filters and sort; `--all` follows the cursors for you.\n- **`--search`** (also `--q`) matches the name or a domain.\n- **Lists and objects go in `--data`** on `search`, as the API takes them (`kenso describe accounts search`); a flag beside it sets or replaces one key:\n - `qFields` picks where the search text looks: `name`, `domain`, `latestSignal` (the latest signal\'s title).\n - `countBy` (`stage`, `stageGroup`) adds `counts` to the output: every value with the number of matching accounts that hold it, whatever the page. The output is then one object: `data`, `pagination` and `counts`.\n - `filters` and `where` narrow the accounts.\n\nAn account\'s timeline pages the same way. `kenso accounts activity --account-id 812` returns the newest 100 earlier rows and, when older ones exist, `data.nextCursor`. Pass it back as `--cursor` (with the same `--category`) for the rows before them, until a page comes without one.\n\n## Edit accounts, people and opportunities\n\nTo set the same fields on many records, use `bulk-update` (below; it needs the `bulk_edit` flag). When every row gets its own values, or the workspace has no `bulk_edit`, run the generated `update` command once per row with `--each`. Columns are the command\'s flags by API name or flag name, and the id column fills the route:\n\n```bash\nkenso accounts update --each accounts-edit.csv --dry-run # then the same with --yes\nkenso people update --each people-edit.csv --dry-run\nkenso opportunities update --each deals.csv --dry-run\n```\n\n```csv\naccountId,stage,ownerMemberId,overwritePinned\n501,engaged,42,true\n502,customer,42,true\n```\n\nA row that changes a field someone pinned in the app fails as a whole (`409 conflict`, `pinned_by_user`: nothing on that record changes, the other fields of the row included), unless the row sets `overwritePinned` to `true` (or you pass `--overwrite-pinned`, only with the person\'s OK). Every flag of an update command: `kenso accounts update --help`.\n\n## Change many accounts at once\n\n```bash\nkenso accounts bulk-update --filter \'{"filters":[{"field":"stage","operator":"is","values":["new"]}]}\' --set owner=42 --dry-run\nkenso changes apply --change-id 31\nkenso accounts bulk-update --ids 812,813 --set stage=engaged --set tier=2 --yes\nkenso changes get --change-id 31\n```\n\n`accounts bulk-update` sets the same fields on every account you name: `--ids` (1,000 at most), everything a `--filter` matches (the body `kenso accounts search --data` takes: `filters`, `where`, `q`; up to 50,000), or `--all`. A filter that holds only options and no condition (`--filter \'{"includeImportOnly":true}\'`) takes `--all` beside it. `--exclude-ids` leaves some of a filter\'s accounts out. `--set field=value` takes `ownerMemberId` (or `owner`), `stage`, `tierOverride` (or `tier`), `industry`, `fundingRound`, `employeeCount`, `hqLocation` and `cadenceDays`, and a custom field as `custom.<key>` (`--set custom.region=EMEA`; `kenso api GET \'/v1/fields?object=account\'` gives the keys); a value of `null` clears the field. `--add-tag 12,14` and `--remove-tag 13` put tags on every account or take them off (`kenso tags list` gives the ids); each tag is one row per account from `false` to `true` or back, so `kenso changes undo` takes off only the tags the change put on. People take them too; deals have no tags. A text field\'s value is sent as you type it (`--set hqLocation=10001` is the text "10001"); a custom field\'s type is not known to the CLI, so quote its text when it reads as a number or as true or false: `--set \'custom.code="10001"\'`. Use `accounts update --each` when every row gets its own values.\n\nIt makes a change set: the accounts it names and, for each, the field, its value before and its value after. Without `--yes` (or with `--dry-run`) it previews: it prints `count` and a `sample`, writes nothing, and `next` is the `kenso changes apply` command that writes exactly those accounts. With `--yes` it writes in the background and waits (`--timeout`, default 10m), then prints the change with its `counts`: `applied`, `unchanged` (already had the value), `conflict` (the account changed after the preview, so it was left alone) and `failed` (for example `pinned`: a person set the field by hand; `--overwrite-pinned` replaces it). Exit 5 when some accounts failed or conflicted. It needs the `bulk_edit` flag as well as `accounts`.\n\n`kenso accounts bulk-update` used to be the generated command for the route\'s older one-field body, which sets one `accountType` on up to 500 accounts and needs only `accounts`. The route still takes that body, but this command no longer sends it: use `kenso accounts update --each` with an `accountType` column, or `kenso api POST /v1/accounts/bulk-update --data \'{"accountIds":[812,813],"accountType":"lost"}\'`.\n\n`people bulk-update` and `opportunities bulk-update` work the same way. People take `--set` for `ownerMemberId` (or `owner`), `leadStatus`, `title`, `seniority`, `department` and `location`, and a `--filter` of `kenso people search --data` fields (`leadStatus`, `roles`, `tagIds`, `q` and the rest). Deals take `stage` (a live stage key), `ownerMemberId` (or `owner`), `closeDate` (or `close`), `amount`, `dealType` and `nextStep`, and a `--filter` of `kenso opportunities search --data` fields (`filters`, `accountId`, `pipelineId`, `q`, `missingFields`). A stage belongs to one pipeline, and a bulk stage change keeps every deal in its own: `"pipelineId"` in the filter names one pipeline\'s deals, and a deal of another pipeline is counted under `failed` with the row code `other_pipeline` and is not moved (`kenso opportunities update` moves one deal to another pipeline):\n\n```bash\nkenso opportunities bulk-update --filter \'{"pipelineId":3,"filters":[{"field":"stageCategory","operator":"is","values":["open"]}]}\' --set stage=proposal --dry-run\nkenso people bulk-update --ids 501,502 --set owner=42 --yes\n```\n\n### Delete many records at once\n\n```bash\nkenso people bulk-delete --filter \'{"onAccount":"none","leadStatus":["disqualified"]}\' --dry-run\nkenso changes apply --change-id 32\nkenso opportunities bulk-delete --ids 71,72,73 --yes\n```\n\n`accounts bulk-delete`, `people bulk-delete` and `opportunities bulk-delete` name their records the way `bulk-update` does (`--ids`, `--filter`, `--all`, `--exclude-ids`) and take no `--set`. Without `--yes` they preview: `count`, a `sample`, and `next` is the `kenso changes apply` command that deletes exactly those records. The API itself previews a delete whose body leaves `dryRun` out, so `--yes` sends `dryRun: false`. Each record is deleted as its own `delete` command deletes it, so one that cannot be deleted (a person still on an account) is counted as `failed` and the rest go on. A delete is not undone with `kenso changes undo`.\n\n### Follow, stop and undo a change\n\n```bash\nkenso changes list --object accounts\nkenso changes rows --change-id 31 --status conflict,failed\nkenso changes cancel --change-id 31\nkenso changes undo --change-id 31\n```\n\n`changes list` shows the workspace\'s bulk changes, newest first, whoever made them. `changes rows` lists a change\'s records with the value before (`from`) and after (`to`) and a `status`; `--status conflict,failed` reads what a change missed. `changes cancel` drops a preview or stops a change that is still writing; what it already wrote stays. `changes undo` puts the old value back on every record that still holds the value the change wrote, for 30 days after it was applied (`undoUntil`). A record someone changed again since keeps its newer value: `counts.undone` is how many went back, `counts.applied` how many still hold the change. Undo answers `409 invalid_state` with `undo_expired`, `still_running`, `nothing_applied` or `not_undoable` when there is nothing it can put back.\n\n## Search opportunities\n\n`kenso opportunities search` works as `accounts search` does: it takes `--search`, `--sort`, `--limit`, `--cursor`, `--all`, and its lists in `--data`.\n\n```bash\nkenso opportunities search --data \'{"filters": [{"field": "stageCategory", "operator": "is", "values": ["open"]}]}\' --all\nkenso opportunities search --data \'{"filters": [{"field": "ownerMemberId", "operator": "is", "values": ["none"]}, {"field": "closeDate", "operator": "is", "values": ["past_due", "next_30_days"]}]}\'\nkenso opportunities search --limit 1 --data \'{"countBy": ["stage", "ownerMemberId"]}\' # how many opportunities hold each value\n```\n\n- **`filters`** is a list of `{field, operator, values}`, all of which must hold. Fields: `stage` (a stage key), `stageCategory` (`open`, `won`, `lost`), `ownerMemberId` (member ids, or `me` for whoever runs it), `closeDate` (`past_due`, `next_30_days`, `later`, `none`, or a period such as `this_week` or `next_quarter`), `sourceCampaignId`, `closedAt` and `createdAt` (periods). `operator` is `is` or `is_not`; the values of one condition are OR. `none` in `values` matches an opportunity with no owner, no source campaign or no close date.\n- **`countBy`** takes the same field names and adds `counts` to the output: per field, every value with the number of matching opportunities that hold it.\n- `--account-id` keeps the search to one account. `closeDate` counts days in the member\'s app time zone.\n\nOne person\'s deals, meetings and campaign contacts, as their person page lists them:\n\n```bash\nkenso opportunities list --person-id 9001 # the deals they are on, or are the primary person of\nkenso meetings list --person-id 9001 # the meetings they attend, among the ones you can see\nkenso contacts list --person-id 9001 # their contact in each campaign they are in\n```\n\n## Write research you gathered\n\n`accounts write-research` and `people write-research` store research you gathered outside Kenso as the record\'s latest research (`PUT /v1/accounts/{accountId}/research`, `PUT /v1/people/{personId}/research`). The Research tab shows it like a Ken run, with `trigger: agent` and `researchedAt` now. Nothing is charged, and no account or person field changes: set an account\'s own `fitScore`, `whyNow` or `angle` with `accounts update`. They need the `accounts_research` flag and accounts edit.\n\nThe body is the research block `accounts get --expand research` (or `people get-research`) returns, without its read-only fields: leave out `id`, `status`, `trigger`, `errorCode`, `researchedAt`, `isStale` and `appliedPrompt` (for a person also `mode`, `requestedAt`, `researchedMode`, `firecrawlCredits` and `webNote`), or the write fails with `unknown_field`. Pass it with `--data @file`:\n\n```bash\nkenso accounts write-research --account-id 501 --data @acme-dossier.json\nkenso people write-research --person-id 9001 --data @jane.json\n```\n\n```json\n{\n "tagline": { "text": "Payroll for EU contractors", "sourceUrls": ["https://acme.example"] },\n "description": { "text": "Acme runs payroll and compliance for companies hiring contractors in 30 EU countries.", "sourceUrls": ["https://acme.example"] },\n "links": { "website": "https://acme.example" },\n "whyNow": { "text": "Raised a $40M Series B in October", "sourceUrls": ["https://news.example/acme-b"], "date": "2026-10" },\n "fitScore": 82,\n "angle": "Lead with contractor onboarding time."\n}\n```\n\nMany records: one JSONL line per record, with the id next to the block\'s fields. Nested objects are sent as written. Use JSONL, not CSV: the block\'s fields are objects and lists, which a CSV cell cannot carry.\n\n```bash\nkenso accounts write-research --each dossiers.jsonl --dry-run # then the same with --yes\nkenso people write-research --each people-research.jsonl --yes --concurrency 8\n```\n\n```jsonl\n{"accountId": 501, "tagline": {"text": "Payroll for EU contractors"}, "links": {"website": "https://acme.example"}}\n{"accountId": 502, "description": {"text": "Cloud cost tooling for retailers."}, "links": {"website": "https://beta.example"}}\n```\n\nA row fails as a whole with the API\'s code: `validation_failed` (an unknown field is `unknown_field`, and `error.details` names every bad field), `research_in_progress` (`409`: Ken is researching that record now, write it again once the run ends; an account run waiting for credits counts too: it runs once the workspace has credits, and the write stays refused until that run ends) or `not_found`. Rerunning a file is safe: each write replaces the record\'s research shown.\n\n## CRM sync\n\nCRM sync has generated commands only: read connections, preview, start an import, and work through sync issues. Connect the CRM itself in the app.\n\n```bash\nkenso crm-connections list\nkenso crm-connections get --connection-id 7\nkenso crm-imports create --connection-id 7 --dry-run\nkenso crm-sync-issues list --connection-id 7 --all\n```\n\nRun `kenso crm-connections --help` (or add `--all-commands` when the actions are hidden) to see every action.\n\n## Pipelines\n\nA workspace with the `pipelines` flag on can run several deal pipelines, each with its own stages. These are generated commands (beta):\n\n```bash\nkenso pipelines list\nkenso pipelines list --query "[].{id: id, name: name, default: isDefault, stages: stages[].key}"\nkenso pipelines get --pipeline-id 5\n```\n\n`list` prints every pipeline in display order, archived ones included: `id`, `name`, `routingRule` (the one sentence Ken reads to decide whether a new deal belongs there), `isDefault`, `isArchived`, `position`, `opportunityCount`, `amountTotal` and `stages`, each stage as `kenso opportunity-stages list` prints it. A stage key is unique in the workspace, across pipelines, so a deal\'s `stage` names its pipeline and its `pipelineId` repeats it. The first read turns the workspace\'s stage list into its default pipeline, named Sales, with every deal in it. The same rows as the MCP\'s `pipelines(operation="list")`.\n\nShaping them needs the `workspace_settings` permission:\n\n```bash\nkenso pipelines create --name Renewals --routing-rule "The account is already a customer" --data \'{"stages": [{"label": "Up for renewal", "category": "open"}, {"label": "Won", "category": "won"}, {"label": "Lost", "category": "lost"}]}\'\nkenso pipelines update --pipeline-id 6 --name Expansion --position 0\nkenso pipelines update --pipeline-id 6 --data @stages.json\nkenso pipelines archive --pipeline-id 6\nkenso pipelines restore --pipeline-id 6\nkenso pipelines propose --description "upsells and renewals for customers"\n```\n\n- **`create`** takes a unique `name`, the pipeline\'s `stages` in display order (at least one `open`, one `won` and one `lost`) and an optional `routingRule`: one sentence that says which deals belong there, which Ken reads to route a new deal that names no pipeline. Each stage gets a key from its label; a key another pipeline already uses gets the pipeline\'s name in front (`renewals_won`). A workspace has at most 10 pipelines.\n- **`update`** changes what you send. `stages` is the pipeline\'s whole stage list: read it with `pipelines get`, keep each stage\'s `key`, and add a new stage without one. A stage with live deals in it cannot be left out; archive it with `"isArchived": true` instead.\n- **`propose`** asks Ken to draft a pipeline from one sentence: a `name`, a `routingRule` and `stages`, in the shape `create` takes. It saves nothing. Read it, change what you want, and send it to `create`.\n- **`archive`** stops new deals from entering a pipeline and keeps the deals in it. The default pipeline cannot be archived, and nothing is deleted: `restore` brings a pipeline back.\n\n## Deals in a pipeline\n\nA deal\'s stage names its pipeline, and the deal\'s `pipelineId` repeats it. To work one pipeline\'s deals, or move a deal between pipelines:\n\n```bash\nkenso opportunities list --pipeline-id 6\nkenso opportunities search --pipeline-id 6 --data \'{"countBy": ["stage"]}\'\nkenso opportunities create --account-id 501 --pipeline-id 6\nkenso opportunities move 77 --pipeline 6\nkenso opportunities move 77 --pipeline 6 --stage negotiating\n```\n\n- **`create --pipeline-id`** opens the deal in that pipeline\'s first live open stage. Without it, and without a `stage`, Ken reads each pipeline\'s `routingRule` and opens the deal in the pipeline whose rule clearly fits the account, else in the default pipeline. A pipeline you name always wins.\n- **`move --pipeline`** alone keeps the deal\'s category (`open`, `won` or `lost`): it lands in that pipeline\'s live stage of the category with the same label as its stage now, else in the category\'s first live stage. The printed deal says where it landed. With `--stage`, the stage must be that pipeline\'s; the error lists the pipeline\'s stage keys otherwise.\n- An archived pipeline takes no deal from another pipeline (`pipeline_archived`). The deals already in it still move between its stages.\n- A move is a stage change: it writes the same history, and a stage a person set is refused with `pinned_by_user` unless you pass `--overwrite-pinned`.\n\n## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore --account-id 812\n```\n\nA deleted account can be restored for 30 days. `deleted-accounts list` shows each one with who deleted it, `expiresAt` (restore works until then) and what comes back: `personCount`, `opportunityCount` and `touchCount`. `accounts restore --account-id <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. Its Studio pages, committee seats and Knowledge facts do not come back: the delete purged them. A domain another account took since stays with that account and is listed in `domainsTaken`. A merged account is not listed and cannot be restored: a merge has no undo. Both commands are behind the `crm_import_export` feature flag (`404` while it is off).\n\n## Import a CSV export of another CRM\n\n```bash\nkenso import accounts companies.csv\nkenso import accounts companies.csv --map "Company=name" --map "Notes=" --yes\nkenso import accounts --id 42 --yes\nkenso record-import-rows list --import-id 42 --outcome skipped\nkenso record-imports undo --import-id 42\n```\n\n`kenso import accounts <file.csv>` uploads the file (a header row, at most 50,000 rows) and prints Kenso\'s plan: which field each column fills, which columns it skips, how owner and stage values are read (`valueMaps`) and what it could not settle (`questions`). Headers of Kenso, Twenty, HubSpot, Attio and Salesforce exports are recognized. Nothing is written to your accounts yet. `--map "Header=field"` changes a column and `--map "Header="` skips it. A column fills a custom field with `--map "Header=custom.<key>"` (`kenso fields list --object account` has the keys; people are `person`, deals `opportunity`), and `--map "Header=new"` adds the custom field Kenso proposes for a column no field matches (`new:text` picks the type), and a column whose header is a custom field\'s label is mapped to it already; owner and stage values change with `kenso record-imports update --import-id <id>`.\n\nWith `--yes` the import starts and the command waits for it (`--timeout`, default 30m; the import keeps running on the server either way), then prints how many rows were created, updated, restored, left unchanged and skipped. Without `--yes` it stops at the plan and prints the command that starts that import (`--id <importId> --yes`), so the file is uploaded once. `--dry-run` sends nothing: with a file it prints the upload it would make, since the plan needs the upload, and with `--id` it reads the planned import and prints what `--map`, `--source` and `--research` would change on it. `--source twenty` names the system the file\'s record ids come from: pass the same one for every file of an export, so the people and deals files find the accounts by their old ids. `kenso record-imports delete --import-id <id>` discards an import that was planned and never started; one left planned for 30 days is discarded by itself.\n\nPer row: a domain no account has creates an account; a domain that is already an account fills only that account\'s empty fields, so nothing you entered is overwritten; an account deleted in the last 30 days is restored; a row with no usable domain is skipped, and `kenso record-import-rows list --import-id <id> --outcome skipped` says why. Research of new accounts is off unless you pass `--research`, which is charged per account. It needs the `accounts` and `crm_import_export` flags. This is a different command from `accounts import`, which creates accounts row by row from the machine running the CLI.\n\n`kenso record-imports undo --import-id <id>` takes a finished import back in the background (`kenso record-imports get --import-id <id>` reads `undoing`, then `undone`): an account the import created is deleted, and can be restored for 30 days, unless someone changed it since, it holds a deal, a person was added to it since, or it was merged; a field the import filled is emptied while it still holds the imported value. `kenso record-import-rows list --import-id <id>` shows each row\'s `undoOutcome`.\n\n`kenso import people <file.csv>` works the same way for people. Import the accounts file first: a people row\'s company id (Twenty\'s `Company Id`, HubSpot\'s associated company id) places the person on the account that kept that id, and without one the person goes on the account that holds their email\'s or company\'s domain. A people import never creates an account; a person whose company is no account comes in without one and the row says so. A row matches a person by email, then LinkedIn URL, then name on the company, as every other way into People does; a matched person gets only their empty fields filled (a phone only when they have none). A row with none of the three is skipped, and a row with only a name needs a company that is an account with a domain. `kenso record-imports undo --import-id <id>` takes a people import back too: a person it created leaves the accounts the row placed them on and is deleted, unless someone changed them since, they were contacted or have a touch planned, or they are on an open deal; a field it filled is emptied while it still holds the imported value. `kenso people import` stays the JSONL and enrichment path (`--find-emails`); `kenso import people` is the CRM file with a plan, a row report and one approval.\n\n`kenso import deals <file.csv>` works the same way for deals, after the accounts file and the people file. A row opens a deal on the account that kept its company id (Twenty\'s `Company Id`, HubSpot\'s associated company id), else on the account that holds its company domain; a row whose account Kenso does not know is skipped and says so. Its contact is the person a people import kept the row\'s contact id for (Twenty\'s `Point of Contact Id`). The plan maps each stage in the file to one of the workspace\'s deal stages (`valueMaps`, field `stage`): a stage\'s key or label matches by itself, Closed Won and Closed Lost go to the first won and lost stage, and a value with no match opens in the first open stage until you pick one with `kenso record-imports update`. Amounts stay in the workspace currency: an amount in another currency is left out with a warning, never converted. A row whose deal id an earlier import kept is that deal and only gets its empty fields filled; a file with no id column opens every deal again each time it is imported, and the plan says so (`no_source_id`). `kenso record-imports undo --import-id <id>` takes a deals import back: a deal it opened is deleted unless someone changed it since, and a field it filled is emptied while it still holds the imported value. Undo in the reverse order of the imports (deals, then people, then accounts): an account that holds a deal is kept.\n\n## Export accounts, people or deals\n\n```bash\nkenso export accounts --out accounts.csv\nkenso export accounts --view 12 --out tier-1.csv\nkenso export deals --view 40 --out pipeline.csv\nkenso export deals --filters \'[{"field":"stageCategory","operator":"is","values":["open"]}]\' > open-deals.csv\n```\n\nIt writes the CSV that `POST /v1/accounts/export`, `/v1/people/export` or `/v1/opportunities/export` returns, to stdout or to `--out` (then it prints the file and its row count). With no filter it exports every record. More than 50,000 rows is refused: narrow the filters. `--view <id>` exports a saved view of that object, your own or one shared with the workspace (`kenso views list --object account` shows the ids; people are `person`, deals `opportunity`): the file holds the rows the view lists, in its sort, so its row count is the view\'s count. `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields; given with `--view`, each replaces that key of the view. The accounts and deals files start with `id` and import back as they are. Each export writes an audit-log entry and needs the export permission. Accounts and deals also need the `crm_import_export` flag while it is in beta.\n\n## Duplicates and merges\n\n```bash\nkenso accounts duplicates --scan\nkenso accounts merge 812 --into 77 --dry-run\nkenso accounts merge 812 --into 77 --yes\nkenso accounts merges list --merged-by system\nkenso accounts merges 41\n```\n\nThese need the `crm_import_export` flag beside `accounts`. `accounts duplicates` lists the pairs of accounts that look like one company: both accounts, why they were paired (`reasons`: `domain`, `linkedin`, `name`) and `isCertain`, true when the two share the name and the domain apart from its ending (acme.com and acme.co). `--scan` compares every account first; a scan also runs after each accounts import. `--status dismissed` or `merged` shows the answered pairs. `kenso account-duplicates dismiss --duplicate-id <duplicateId>` answers that a pair is not a duplicate, for good.\n\n`accounts merge <accountId> --into <id>` merges the first account into the second, the one you keep. A merge cannot be undone, so look first: `--dry-run` prints `mergeSummary` (each field that changes with its value before and after, and how many people, deals, touches and domains move) and writes nothing. The merge itself needs `--yes` when no person is at the terminal. It answers the kept account with the same summary and a `mergeId`.\n\n`accounts merges list` is the log, newest first, and `accounts merges <mergeId>` opens one merge with `mergedValues`: the merged-away account as it was. `--merged-by system` shows the merges Ken made itself. Where automatic merging is on for the workspace, Ken merges only certain pairs, keeps the customer, then the owned, then the last touched account, and leaves a pair for you when both are customers, the two have different owners, or one is being worked and the other is set aside (`heldReason` on the pair says which). That job is off unless it was turned on for the workspace.\n\n## A deal\'s stage history\n\n```bash\nkenso opportunities stage-history 77\nkenso opportunities stage-history 77 --query "entries[].{to: stageLabel, at: enteredAt, by: changedBy}"\n```\n\nIt prints `GET /v1/opportunities/{id}/stage-history` as it is, the same rows as the deal page and the MCP\'s `opportunities(operation="get-stage-history")`: the stage now, `isComplete` and `entries`, oldest first, each with `fromStage`, `stage`, `stageLabel`, `enteredAt`, `leftAt`, `durationSeconds`, `actorKind`, `actorMemberId` and Ken\'s `reason` on a move its stage judge made. With the `deal_stage_rules` flag on, each entry also has `changedBy` (`member`, `agent`, `api_key`, `workflow`, `stage_judge`, `crm_sync` or `ken_automation`), `crmProvider` on a CRM sync, and on a move `fromStageLabel` and `fromStageDurationSeconds`, how long the deal sat in the stage it left. `isComplete` false means Kenso has no record of part of the history.\n\n## Notes on accounts, people and deals\n\nWith the `record_notes` feature on, everyone who can see a record reads its notes. Name the record with exactly one of `--account`, `--person` and `--deal`:\n\n```bash\nkenso notes list --account 5\nkenso notes add --account 5 --body \'Budget approved, @[Jane Doe](41) please send the DPA\'\nkenso notes add --parent 900 --body \'Sent it this morning\' # a comment under note 900\ncat call-notes.md | kenso notes add --deal 77 --body - # the body from stdin\nkenso notes edit 900 --body \'Budget approved for Q1\' # the author only\nkenso notes edit 900 --pin\nkenso notes delete 900 --yes # kenso notes restore --note-id 900 brings it back\n```\n\nThe body is markdown, up to 20,000 characters. Mention a teammate as `@[Name](memberId)`: they get a notification that opens the note. A note shows on the record\'s Notes tab and its Activity timeline, and Ken\'s account brief quotes the account\'s notes. The MCP\'s `notes` tool does the same. A note on an account needs the accounts plan feature; people and deals work on every plan.\n\n## Required fields per stage\n\n```bash\nkenso pipelines stage-rules\nkenso pipelines stage-rules --pipeline 6\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier --dry-run\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier\nkenso pipelines stage-rules proposal --none\nkenso pipelines stage-rules lost --default\n```\n\nWith the `deal_stage_rules` flag on, each stage can name the fields a deal should have in it. Without a stage the command prints every stage\'s `key`, `label`, `category`, `isArchived`, `requiredFields` and `isDefault`, plus `requirableFields`: `amount`, `closeDate`, `ownerMemberId`, `primaryPersonId`, `nextStep`, `lostReasonKey`, `wonReasonKey` and `custom.<key>` for each custom deal field. `--require` sets the stage\'s whole list, in order, at most 10. `--none` requires nothing, and `--default` goes back to the default: a lost stage asks for `lostReasonKey`, any other stage nothing. Without `--pipeline` the list is the default pipeline\'s stages; `--pipeline <id>` lists that pipeline\'s. A stage key is unique across pipelines, so a stage of any pipeline is set by its key, and with `--pipeline` the command first checks the stage is that pipeline\'s. Setting a rule needs the `workspace_settings` permission. The same as the MCP\'s `opportunities(operation="stages-set-required-fields")`.\n\nA missing field never stops a move. The deal moves, and it is flagged Missing on the board, the list and the deal page until the field is filled. A rule also applies to deals already in the stage.\n\n```bash\nkenso opportunities update --opportunity-id 4401 --stage proposal\nkenso opportunities list --missing-fields\n```\n\nEvery deal then carries `missingFields` (`[{field, label}]`). A create, or an update that sends a stage, answers `warnings` beside the deal for each field the stage asks for that the deal leaves empty: each prints on stderr as `warning: <message>`, stdout stays the deal and the exit code stays 0. `--missing-fields` keeps only the deals flagged Missing (also `missingFields: true` on `kenso opportunities search`).\n\n## Won and lost reasons\n\n```bash\nkenso opportunity-reasons get\nkenso opportunity-reasons replace --kind lost --data \'{"reasons":[{"key":"no_budget","label":"No budget"},{"label":"Built it in-house"}]}\'\nkenso opportunities move 4401 --stage lost --reason built_it_in_house\n```\n\n`kenso opportunities move <id> --stage <key> [--reason <key>]` sends the reason as `lostReasonKey` for a lost stage or `wonReasonKey` for a won stage; an open stage takes none. Each field the new stage asks for that the deal leaves empty prints a warning on stderr, and the move still goes through.\n\nWith the `deal_stage_rules` flag on, each workspace edits why its deals are lost and won. `get` prints `lost` and `won`, each `{isDefault, reasons: [{key, label, isArchived}]}`. `replace` takes a kind\'s whole list in order, as `get` prints it: keep a reason by its `key`, leave `key` out for a new one, and set `isArchived` to archive a reason or bring one back. A reason left out is archived too: deals keep it, and no write can pick it again. At least one reason stays live and at most 30, and labels stay unique, archived ones included. A deal takes a live key in `lostReasonKey` (a lost stage) or `wonReasonKey` (a won stage). A move to Lost without a reason still goes through, with a warning and "Missing: Lost reason" on the deal. Editing the lists needs the `workspace_settings` permission. The same as the MCP\'s `pipelines(operation="reasons-get")` and `reasons-replace`.\n\n## Record page layouts\n\n```bash\nkenso layouts show account\nkenso layouts set account --header tier,ownerMemberId,score,custom.arr\nkenso layouts show account > layout.json && kenso layouts set account --data @layout.json\nkenso layouts reset account --dry-run\nkenso layouts reset account --yes\n```\n\nWith the `record_layout` flag on, a workspace lays out each record page once, for every member: `account`, `person` or `opportunity` (a deal). `show` prints `GET /v1/record-layouts/{object}`: `isDefault`, `version`, `headerFields` (up to 6, pinned under the record\'s name), `railSections` (`{name, fields}`), `hiddenFields` (under the rail\'s More), `sections` (`{key, label, placement, locked, hidden}`, in page order) and `availableFields`. Field keys are the field catalog\'s (`ownerMemberId`, `closeDate`, `primaryDomain`); a custom field is `custom.<field_key>`, and a new one joins the last rail section.\n\n`set --header` pins up to 6 fields and keeps the rest of the saved layout; the fields it unpins go to the top of the first rail section. `set --data` saves a whole layout, so group the rail into sections or hide a section that way, starting from `show`. A save made after someone else\'s answers a conflict: show it again. `reset` puts the page back to Kenso\'s default for every member, so it needs `--yes` (save the layout with `show` first). `set` and `reset` print the request with `--dry-run` and change nothing. Saving needs the `workspace_settings` permission, and the account page also needs the `accounts` plan. The same as the MCP\'s `account_views` operations `record-layouts-get`, `record-layouts-replace` and `record-layouts-reset`.\n\n## Pin a saved view\n\n```bash\nkenso views pin 118\nkenso views unpin 118\n```\n\nWith the `shared_views` flag on, `views pin` adds a saved view to your own sidebar, nested under its list (an account view under Accounts, a person view under People, a deal view under Deals). It is `kenso pins add --kind view --view-id <viewId>` under the name you would try: it prints the pin, and a view already pinned answers the pin it has. Pins are yours alone: pinning a shared view does not pin it for a teammate. `views unpin` finds your pin of the view and removes it, and prints `{"viewId": ..., "removed": true}`; a view you had not pinned prints `removed: false` and changes nothing. The view itself stays either way. `kenso pins list` shows every pin you have.\n\n## Tasks\n\nTasks are to-dos a member owes: a title, an optional due day or time, an assignee and at most one account, person or deal. They need the `tasks` flag. The app calls deals "Deals"; the CLI keeps `--deal` for an opportunity id.\n\n```bash\nkenso tasks add "Send the deck" --due tomorrow --account 812\nkenso tasks add "Call Ada back" --due friday --at 16:00 --person 501 --assignee ada@acme.com\nkenso tasks list --assignee me --due overdue,today\nkenso tasks queue --scope mine\nkenso tasks assign 7 me\nkenso tasks done 7 8 9\nkenso tasks done 7 --undo\n```\n\n- `tasks add` sends `POST /v1/tasks`. `--due` takes `today`, `tomorrow`, a weekday (the next one: `friday` or `fri`), a day (`2026-11-20`) or an ISO 8601 time with its offset (`2026-11-20T15:00:00Z`); `--at HH:MM` puts a time on that day (today without `--due`). Day words and `--at` read this computer\'s clock and time zone (`TZ`); a time\'s day is read in the assignee\'s app time zone. `--assignee` takes `me`, a member id or an email; without it the task is yours.\n- `tasks done` completes each task it names, in order (`PATCH /v1/tasks/{id}` with `status: done`); `--undo` reopens them. When one fails, its error names the tasks before it, which are already changed. `tasks assign` gives a task to `me`, a member id or a member\'s email; that member gets a `task_assigned` notification.\n- `tasks queue` is `task-queue list` under the name you would try: the Tasks screen\'s open work by due day, with `--scope mine|assigned_by_me|everyone`. It lists tasks, manual touches, call tasks, inbox threads with a reminder due (when you can view the Inbox) and Ken\'s follow-ups to you, each with the app path in `href` (null for a task, which opens in its panel).\n- `tasks list`, `get`, `update`, `delete`, `restore` and `task-queue list` are generated from the API: `kenso tasks --help` lists them.\n\n## Custom fields\n\n```bash\nkenso fields list --object account\nkenso fields create --object account --type select --label Region --data \'{"options":["EMEA","North America"]}\' --dry-run\nkenso fields create --object account --type select --label Region --data \'{"options":["EMEA","North America"]}\'\nkenso fields update --field-id 412 --label "Sales region"\nkenso fields archive --field-id 412 --yes\n```\n\nWith the `custom_fields` flag on, each workspace adds its own fields to accounts, people and deals (`--object account`, `person` or `opportunity`). `fields list` prints the built-in and custom fields; a custom field is `custom.<key>`, the name `customFields`, `bulk-update --set`, stage rules, layouts and imports use. Run it before you add a field that may already exist.\n\n- **`create`** takes `--object`, `--type` (`text`, `number`, `boolean`, `date`, `json`, `select`, `multi_select`, `currency`, `url` or `user`; fixed once created) and `--label`. `--key` is made from the label when you leave it out ("Contract value" is `contract_value`). `--description` says what the field means; Ken reads it when it fills the field. A select or multi_select takes its choices in `--data` as `options`, each a label or `{label, color, key}`, up to 200.\n- **`update`** changes the label, the description or the options. `options` in `--data` is the whole list: keep an option by its `key`, and one you leave out is archived, never deleted, so the records that hold it keep it.\n- **`archive`** hides a field from the pickers, the columns and the record rail and keeps every value, so it asks for `--yes`. `kenso fields update --field-id 412 --no-is-archived` brings it back. An object holds at most 100 live custom fields.\n\n## Field-fill settings and Ken\'s suggestions\n\n```bash\nkenso field-fill-settings list\nkenso field-fill-settings update --object opportunity --field amount --mode suggest --instruction "Budget the buyer named, in USD"\nkenso suggestions list --account-id 812\nkenso suggestions approve --suggestion-id 31\nkenso suggestions reject --suggestion-id 32 --reason "That was last year\'s budget"\nkenso fields fill --object opportunity --field nextStep --all\n```\n\nWith the `ken_field_fill` flag on, Ken reads email, calls and meetings and fills record fields. `field-fill-settings list` shows each field Ken can fill with its `mode`: `default` (Ken fills an empty field and suggests a change to a filled one), `off`, `suggest` (every value waits for a person) or `auto`. `update` sets a field\'s mode and an `--instruction` of up to 500 characters that tells Ken what to look for. A new mode applies to the next email, call or meeting Ken reads.\n\nA value that waits for a person is a suggestion: the field, its value now (`from`), Ken\'s value (`to`), the quote and its source. `suggestions list` shows the pending ones; narrow it with `--status`, `--object` and `--record-id` (one record), `--account-id` (the account, its people and its deals) or `--meeting-id`. `approve` writes Ken\'s value to the record (`--data \'{"value": ...}\'` writes yours instead) and `reject` leaves the record as it is. Both are a person\'s call: run them on the user\'s word.\n\n`fields fill` fills one deal field for the deals that have none, from their recorded meetings and captured email. As written above it only answers how many deals have no value and what filling them costs, and starts nothing; `--no-body-dry-run` starts it. It needs `bulk_edit` too, and works on deal fields only.\n\n## Saved views\n\n```bash\nkenso views list --object account\nkenso views create --object account --name "Tier 1, no meeting in 30 days" --visibility workspace --data @view.json --dry-run\nkenso views run --view-id 140 --limit 100 --include-total\nkenso views update --view-id 140 --name "Tier 1, quiet for 30 days"\nkenso views delete --view-id 140 --yes\n```\n\nWith the `shared_views` flag on, a saved view is a name, its object\'s search `filter` and `sort`, `columns` and a `layout` (`list` or `board`), private to its maker or shared with the workspace (`--visibility workspace`). `view.json` holds `filter` and `sort` in the shape the object\'s search takes (`filters`, `where`, `q`), so try it with `kenso accounts search --data` first. `views list` shows the workspace\'s shared views and your private ones. `run` lists a view\'s records exactly as its object\'s search returns them, page by page. `update` changes what you send, and `filter` replaces the whole filter. Any member changes or deletes a shared view, but only its maker makes it private. `delete` asks for `--yes` and takes the view off every member\'s sidebar. `kenso views pin` (above) pins one.\n\n## Reports and dashboards\n\n```bash\nkenso reports summary\nkenso reports list\nkenso reports run won_by_month --period this_year --owner 41\nkenso reports query --data \'{"measures":[{"op":"sum","field":"amount"}],"dimensions":[{"field":"stage"}]}\'\nkenso dashboards create --name "Q4 pipeline" --visibility workspace\nkenso dashboards add-chart --dashboard-id 3 --title "Won by month" --data \'{"report":{"key":"won_by_month","period":"this_year"}}\'\n```\n\nWith the `opportunities` and `reports` flags on, reports count and sum your deals. `reports summary` prints where the period stands (closed won, open pipeline, weighted pipeline, win rate) and what needs you, then one row per stock report. `reports run <report>` prints one stock report as a table: `pipeline_by_stage`, `won_by_month`, `stage_conversion`, `time_in_stage`, `won_by_source_campaign` or `activity_by_member`. Each takes `--period` (`this_quarter` by default, a month such as `2026-03`, a quarter, a year or a day range), `--owner` and `--pipeline`, and `--full` prints the whole answer with each bucket\'s filter for `opportunities search`.\n\n`reports query` asks your own question: `measures` (1 to 4 of `count`, `sum`, `avg` or `weighted_sum` of `amount`), `dimensions` (up to 2 of `stage`, `stageCategory`, `ownerMemberId`, `sourceCampaignId`, `closedAt`, `createdAt` or `closeDate`, the dates by `month`, `quarter` or `year`) and a `filter` as `opportunities search` takes it. It only reads.\n\nA dashboard keeps charts, up to 12, private to its owner or shared with the workspace. A chart is a stock report (`report`: its `key`, `period`, `ownerMemberId`, `pipelineId`) or a `query`, drawn as `bars` or a `trend`. `dashboards get --dashboard-id 3` reads one, and `update`, `remove-chart` and `delete` change it (the last two ask for `--yes`).\n\n## Forecast and quotas\n\n```bash\nkenso forecast show --period 2026-Q4\nkenso forecast show --period 2026-11 --include-deals\nkenso quotas list --period 2026-Q4\nkenso quotas propose --period 2027-Q1 --uplift-percent 15\nkenso quotas propose --period 2027-Q1 --uplift-percent 15 --apply\nkenso quotas set --period 2027-Q1 --member-id 41 --amount 120000\n```\n\nWith the `opportunities` and `forecast` flags on, `forecast show` reads closed won, commit and best case for a quarter (`2026-Q4`) or a month (`2026-11`), per member and for the team, each against its quota. Without `--period` it reads the current quarter. `--include-deals` adds the deals it counted. `quotas propose` works out each member\'s quota from what they closed won in the quarter before the period (or the last quarter that has ended) plus `--uplift-percent` (0 to 200, default 15), and writes nothing; with `--apply` it saves those amounts. `quotas set` sets one member\'s quota in the workspace currency, and `--data \'{"memberId":41,"amount":null}\'` removes it.\n';
|
|
8871
|
+
crm_default = '# CRM (beta)\n\nThe CRM commands work on Kenso\'s Accounts lane: accounts (companies), the people on them, and opportunities. They are beta: they need the `accounts` feature flag on your workspace (opportunities need `opportunities`, CRM sync needs `ingestion`). Help and `kenso describe` hide them until your workspace has the flag; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `accounts import` | Create accounts from a CSV or JSONL file. Research is charged per created account |\n| `people import` | Create or match people from a file, optionally onto accounts |\n| `import accounts <file.csv>`, `import people <file.csv>`, `import deals <file.csv>` | Import a CSV export of another CRM, up to 50,000 rows: Kenso proposes the mapping, you approve once, it runs in the background and can be undone for 30 days |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts bulk-update`, `people bulk-update`, `opportunities bulk-update` | Set the same fields on many records at once, by ids or by a filter, with a preview first. Needs `bulk_edit` too |\n| `accounts bulk-delete`, `people bulk-delete`, `opportunities bulk-delete` | Delete many records at once, by ids or by a filter, with a preview first. Not undone. Needs `bulk_edit` too |\n| `changes list`, `get`, `rows`, `apply`, `cancel`, `undo` | Follow a bulk change, read what each record got, stop it, or put the old values back for 30 days |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities move <id> [--stage <key>] [--pipeline <pipelineId>] [--reason <key>]` | Move a deal to a stage or another pipeline, with its won or lost reason; a field the stage asks for never stops it |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `notes list`, `notes add`, `notes edit`, `notes delete` | Notes and comments on accounts, people and deals (needs `record_notes`) |\n| `deleted-accounts list`, `accounts restore --account-id <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `accounts duplicates`, `accounts merge <id> --into <id>`, `accounts merges list` | The pairs that look like one company, merging a pair, and the log of merges |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved view (`--view <id>`), or what the filters match |\n| `capture status` | Your captured mailbox, its backfill progress and what teammates see of a captured email. Needs the `crm_capture` flag |\n| `capture connect` | Turn capture on for your own mailbox. `--private` starts it hidden from teammates; `--provider google` prints a sign-in link when no account is connected yet |\n| `capture private on\\|off` | Hide your captured email from teammates, or show it again. Email only: meetings stay visible. `--thread <id>` sets the switch for one thread |\n| `capture thread <threadId>` | One captured email thread: subject, people, time, Ken\'s summary, the members whose mailboxes hold it, and each body you may open. The id is `capturedThread.id` on a timeline row |\n| `views pin <viewId>`, `views unpin <viewId>` | Pin a saved view to your own sidebar, or take it off. Needs the `shared_views` flag |\n| `capture sync` | Read your captured mailbox now, instead of waiting for the next two-minute poll. Prints what the pass read, logged and created |\n| `capture disconnect` | Turn capture off and delete your stored email bodies. Asks first; `--yes` skips the question |\n| `capture teammates-see summary\\|full_email` | Workspace admin: what teammates see of captured email |\n| `pipelines stage-rules` | List or set the fields a deal should have in each stage |\n| `opportunity-reasons get`, `opportunity-reasons replace` | List or edit why deals are lost and won |\n| `layouts show\\|set\\|reset <object>` | How every account, person or deal page in the workspace lays out its fields: header, rail sections and hidden fields (needs `record_layout`) |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n| `tasks add`, `tasks done`, `tasks assign`, `tasks queue` | Add a to-do for a member on an account, person or deal, complete it, hand it on, or read your open work (needs `tasks`) |\n| `fields list`, `create`, `update`, `archive` | The built-in and custom fields of accounts, people and deals, and adding your own (needs `custom_fields`) |\n| `field-fill-settings`, `suggestions`, `fields fill` | How Ken fills each field from email, calls and meetings, the values it waits on you for, and filling a deal field for existing deals (needs `ken_field_fill`) |\n| `views list`, `create`, `run`, `update`, `delete` | Saved views of accounts, people and deals, private or shared with the workspace (needs `shared_views`) |\n| `reports summary`, `reports run <report>`, `reports query`, `dashboards` | Pipeline reports over your deals, your own counts and sums, and dashboards of saved charts (needs `opportunities` and `reports`) |\n| `forecast show`, `quotas list`, `set`, `propose` | Closed won, commit and best case against each member\'s quota for a month or quarter (needs `opportunities` and `forecast`) |\n\nImport accounts first, then people: `people import` never creates an account.\n\n## Import accounts\n\n```bash\nkenso accounts import --file accounts.csv\nkenso accounts import --file accounts.csv --yes\n```\n\n```csv\nname,domain,industry,employeeCount\nAcme,acme.io,Software,120\nGlobex,globex.com,Manufacturing,"1,200"\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `name` (or `company`, `companyName`, `accountName`), `domains` (several, split on `,` or `;`) or one `domain` (or `website`, `companyDomain`), `industry`, `employeeCount`, `hqLocation`, `linkedinUrl`, `stage`, `angle`, `whyNow`, `fitScore`, `fundingRound`, `cadenceDays`, `ownerMemberId`, `kenCompanyId`, `sendsFromInboxId`, `sendsFromLinkedInAccountId` and `source`.\n- **A domain is required.** A file with no domain column is a usage error, and a row without a domain is `invalid` (`domain_required`).\n- **The dry run prices the research.** It asks for a credit estimate per 1,000 accounts and puts the sum in the plan: `kind`, `accountCount`, `totalMillicredits`, `availableMillicredits` and `sufficient`.\n- **Rows go 100 per call** to `POST /v1/accounts/bulk-create`.\n\nEach row comes back `created` (`id` is the new account; its research is queued, `researchQueued`, or waits for credits, `researchWaitingCredits`), `skipped` with reason `domain_taken` (already an account; `id` is that account) or `failed` (`reason` is the API\'s code, `error` names the field; an item Kenso failed to save is sent once more first). Rerunning the same file is safe: accounts that exist come back `domain_taken`.\n\n## Import people\n\n```bash\nkenso people import --file people.csv\nkenso people import --file people.csv --find-emails --yes\nkenso people import --file people.jsonl --dry-run\n```\n\n```csv\nfullName,email,title,accountDomain,role\nAnn Lee,ann@acme.io,VP Sales,acme.io,champion\nBob Ray,,CTO,acme.io,\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `email`, `fullName` (or `name`), `firstName`, `lastName`, `title`, `linkedinUrl` (or `linkedin`, `profileUrl`), `accountDomain` (or `domain`, `website`, `companyDomain`), `accountId`, `role` and `priority`. Other columns are ignored with one warning.\n- **A person needs a name:** `fullName`, or `firstName`, `lastName` or both (the CLI joins them). A row with none of them is `invalid` (`name_required`).\n- **To put a person on an account,** give `accountDomain` or `accountId`. A row with both sends only `accountId`.\n- **`--find-emails`** queues an email find (charged in credits) for each person without an email.\n- **Rows go 200 per call** to `POST /v1/people/batch`.\n\nPeople already in the workspace are matched by email, then LinkedIn URL, so running the same file again creates nobody twice. A row comes back `created` (a new person), `updated` (an existing person added to the account), `skipped` with reason `already_on_account`, `matched` (no account asked) or `previously_removed`, or `failed`: `account_not_found` saves the person without an account (import the account, then rerun to place them), any other reason is the API\'s. The summary adds `matched`, `addedToAccounts` and `emailFindsQueued`.\n\n## List and search accounts\n\n`accounts list` and `accounts search` sort and page on the server, so they reach every account in the workspace, however many there are.\n\n```bash\nkenso accounts list --sort score:desc --limit 100 # one page; the output\'s next: line is the following one\nkenso accounts list --sort score:desc --limit 100 --all # every page, to the end\nkenso accounts search --search hiring --sort latestSignalAt:desc --data \'{"qFields": ["name", "latestSignal"]}\'\nkenso accounts search --limit 1 --data \'{"countBy": ["stage"]}\' # how many accounts sit in each stage\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}]}, "sort": "tier,-pipelineAmount"}\' --all\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "hqLocation", "operator": "contains", "values": ["Germany"]}]}}\' --all\n# my accounts with a meeting this quarter: me is whoever runs it, so a saved view with it lists each member\'s own\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "owner", "operator": "is", "values": ["me"]}, {"field": "lastMeeting", "operator": "in_period", "values": ["this_quarter"]}]}}\' --all\n# tier 1 accounts with no meeting in 30 days: none since then, or none ever\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}, {"match": "any", "conditions": [{"field": "lastMeeting", "operator": "older_than_days", "values": ["30"]}, {"field": "lastMeeting", "operator": "is_empty"}]}]}}\' --all\n```\n\n- **`--sort`** takes up to 3 comma-separated keys, each `field` (ascending), `field:asc` or `field:desc`. The API\'s `-field` form needs the equals sign here, `--sort=-score`, because a value that starts with a dash reads as a flag. Fields: `createdAt`, `name`, `score`, `tier` (ascending is tier 1 first), `latestSignalAt`, `committee`, `pipelineAmount`, `nextTouchAt`, `lastTouchAt`. An account with no value for a key comes last in both directions. The default is `-createdAt`.\n- **`--limit`** is 1 to 1000 (default 50). `--cursor` takes the previous page\'s `nextCursor` with the same filters and sort; `--all` follows the cursors for you.\n- **`--search`** (also `--q`) matches the name or a domain.\n- **Lists and objects go in `--data`** on `search`, as the API takes them (`kenso describe accounts search`); a flag beside it sets or replaces one key:\n - `qFields` picks where the search text looks: `name`, `domain`, `latestSignal` (the latest signal\'s title).\n - `countBy` (`stage`, `stageGroup`) adds `counts` to the output: every value with the number of matching accounts that hold it, whatever the page. The output is then one object: `data`, `pagination` and `counts`.\n - `filters` and `where` narrow the accounts.\n\nAn account\'s timeline pages the same way. `kenso accounts activity --account-id 812` returns the newest 100 earlier rows and, when older ones exist, `data.nextCursor`. Pass it back as `--cursor` (with the same `--category`) for the rows before them, until a page comes without one.\n\n## Edit accounts, people and opportunities\n\nTo set the same fields on many records, use `bulk-update` (below; it needs the `bulk_edit` flag). When every row gets its own values, or the workspace has no `bulk_edit`, run the generated `update` command once per row with `--each`. Columns are the command\'s flags by API name or flag name, and the id column fills the route:\n\n```bash\nkenso accounts update --each accounts-edit.csv --dry-run # then the same with --yes\nkenso people update --each people-edit.csv --dry-run\nkenso opportunities update --each deals.csv --dry-run\n```\n\n```csv\naccountId,stage,ownerMemberId,overwritePinned\n501,engaged,42,true\n502,customer,42,true\n```\n\nA row that changes a field someone pinned in the app fails as a whole (`409 conflict`, `pinned_by_user`: nothing on that record changes, the other fields of the row included), unless the row sets `overwritePinned` to `true` (or you pass `--overwrite-pinned`, only with the person\'s OK). Every flag of an update command: `kenso accounts update --help`.\n\n## Change many accounts at once\n\n```bash\nkenso accounts bulk-update --filter \'{"filters":[{"field":"stage","operator":"is","values":["new"]}]}\' --set owner=42 --dry-run\nkenso changes apply --change-id 31\nkenso accounts bulk-update --ids 812,813 --set stage=engaged --set tier=2 --yes\nkenso changes get --change-id 31\n```\n\n`accounts bulk-update` sets the same fields on every account you name: `--ids` (1,000 at most), everything a `--filter` matches (the body `kenso accounts search --data` takes: `filters`, `where`, `q`; up to 50,000), or `--all`. A filter that holds only options and no condition (`--filter \'{"includeImportOnly":true}\'`) takes `--all` beside it. `--exclude-ids` leaves some of a filter\'s accounts out. `--set field=value` takes `ownerMemberId` (or `owner`), `stage`, `tierOverride` (or `tier`), `industry`, `fundingRound`, `employeeCount`, `hqLocation` and `cadenceDays`, and a custom field as `custom.<key>` (`--set custom.region=EMEA`; `kenso api GET \'/v1/fields?object=account\'` gives the keys); a value of `null` clears the field. `--add-tag 12,14` and `--remove-tag 13` put tags on every account or take them off (`kenso tags list` gives the ids); each tag is one row per account from `false` to `true` or back, so `kenso changes undo` takes off only the tags the change put on. People take them too; deals have no tags. A text field\'s value is sent as you type it (`--set hqLocation=10001` is the text "10001"); a custom field\'s type is not known to the CLI, so quote its text when it reads as a number or as true or false: `--set \'custom.code="10001"\'`. Use `accounts update --each` when every row gets its own values.\n\nIt makes a change set: the accounts it names and, for each, the field, its value before and its value after. Without `--yes` (or with `--dry-run`) it previews: it prints `count` and a `sample`, writes nothing, and `next` is the `kenso changes apply` command that writes exactly those accounts. With `--yes` it writes in the background and waits (`--timeout`, default 10m), then prints the change with its `counts`: `applied`, `unchanged` (already had the value), `conflict` (the account changed after the preview, so it was left alone) and `failed` (for example `pinned`: a person set the field by hand; `--overwrite-pinned` replaces it). Exit 5 when some accounts failed or conflicted. It needs the `bulk_edit` flag as well as `accounts`.\n\n`kenso accounts bulk-update` used to be the generated command for the route\'s older one-field body, which sets one `accountType` on up to 500 accounts and needs only `accounts`. The route still takes that body, but this command no longer sends it: use `kenso accounts update --each` with an `accountType` column, or `kenso api POST /v1/accounts/bulk-update --data \'{"accountIds":[812,813],"accountType":"lost"}\'`.\n\n`people bulk-update` and `opportunities bulk-update` work the same way. People take `--set` for `ownerMemberId` (or `owner`), `leadStatus`, `title`, `seniority`, `department` and `location`, and a `--filter` of `kenso people search --data` fields (`leadStatus`, `roles`, `tagIds`, `q` and the rest). Deals take `stage` (a live stage key), `ownerMemberId` (or `owner`), `closeDate` (or `close`), `amount`, `dealType` and `nextStep`, and a `--filter` of `kenso opportunities search --data` fields (`filters`, `accountId`, `pipelineId`, `q`, `missingFields`). A stage belongs to one pipeline, and a bulk stage change keeps every deal in its own: `"pipelineId"` in the filter names one pipeline\'s deals, and a deal of another pipeline is counted under `failed` with the row code `other_pipeline` and is not moved (`kenso opportunities update` moves one deal to another pipeline):\n\n```bash\nkenso opportunities bulk-update --filter \'{"pipelineId":3,"filters":[{"field":"stageCategory","operator":"is","values":["open"]}]}\' --set stage=proposal --dry-run\nkenso people bulk-update --ids 501,502 --set owner=42 --yes\n```\n\n### Delete many records at once\n\n```bash\nkenso people bulk-delete --filter \'{"onAccount":"none","leadStatus":["disqualified"]}\' --dry-run\nkenso changes apply --change-id 32\nkenso opportunities bulk-delete --ids 71,72,73 --yes\n```\n\n`accounts bulk-delete`, `people bulk-delete` and `opportunities bulk-delete` name their records the way `bulk-update` does (`--ids`, `--filter`, `--all`, `--exclude-ids`) and take no `--set`. Without `--yes` they preview: `count`, a `sample`, and `next` is the `kenso changes apply` command that deletes exactly those records. The API itself previews a delete whose body leaves `dryRun` out, so `--yes` sends `dryRun: false`. Each record is deleted as its own `delete` command deletes it, so one that cannot be deleted (a person still on an account) is counted as `failed` and the rest go on. A delete is not undone with `kenso changes undo`.\n\n### Follow, stop and undo a change\n\n```bash\nkenso changes list --object accounts\nkenso changes rows --change-id 31 --status conflict,failed\nkenso changes cancel --change-id 31\nkenso changes undo --change-id 31\n```\n\n`changes list` shows the workspace\'s bulk changes, newest first, whoever made them. `changes rows` lists a change\'s records with the value before (`from`) and after (`to`) and a `status`; `--status conflict,failed` reads what a change missed. `changes cancel` drops a preview or stops a change that is still writing; what it already wrote stays. `changes undo` puts the old value back on every record that still holds the value the change wrote, for 30 days after it was applied (`undoUntil`). A record someone changed again since keeps its newer value: `counts.undone` is how many went back, `counts.applied` how many still hold the change. Undo answers `409 invalid_state` with `undo_expired`, `still_running`, `nothing_applied` or `not_undoable` when there is nothing it can put back.\n\n## Search opportunities\n\n`kenso opportunities search` works as `accounts search` does: it takes `--search`, `--sort`, `--limit`, `--cursor`, `--all`, and its lists in `--data`.\n\n```bash\nkenso opportunities search --data \'{"filters": [{"field": "stageCategory", "operator": "is", "values": ["open"]}]}\' --all\nkenso opportunities search --data \'{"filters": [{"field": "ownerMemberId", "operator": "is", "values": ["none"]}, {"field": "closeDate", "operator": "is", "values": ["past_due", "next_30_days"]}]}\'\nkenso opportunities search --limit 1 --data \'{"countBy": ["stage", "ownerMemberId"]}\' # how many opportunities hold each value\n```\n\n- **`filters`** is a list of `{field, operator, values}`, all of which must hold. Fields: `stage` (a stage key), `stageCategory` (`open`, `won`, `lost`), `ownerMemberId` (member ids, or `me` for whoever runs it), `closeDate` (`past_due`, `next_30_days`, `later`, `none`, or a period such as `this_week` or `next_quarter`), `sourceCampaignId`, `closedAt` and `createdAt` (periods). `operator` is `is` or `is_not`; the values of one condition are OR. `none` in `values` matches an opportunity with no owner, no source campaign or no close date.\n- **`countBy`** takes the same field names and adds `counts` to the output: per field, every value with the number of matching opportunities that hold it.\n- `--account-id` keeps the search to one account. `closeDate` counts days in the member\'s app time zone.\n\nOne person\'s deals, meetings and campaign contacts, as their person page lists them:\n\n```bash\nkenso opportunities list --person-id 9001 # the deals they are on, or are the primary person of\nkenso meetings list --person-id 9001 # the meetings they attend, among the ones you can see\nkenso contacts list --person-id 9001 # their contact in each campaign they are in\n```\n\n## Write research you gathered\n\n`accounts write-research` and `people write-research` store research you gathered outside Kenso as the record\'s latest research (`PUT /v1/accounts/{accountId}/research`, `PUT /v1/people/{personId}/research`). The Research tab shows it like a Ken run, with `trigger: agent` and `researchedAt` now. Nothing is charged, and no account or person field changes: set an account\'s own `fitScore`, `whyNow` or `angle` with `accounts update`. They need the `accounts_research` flag and accounts edit.\n\nThe body is the research block `accounts get --expand research` (or `people get-research`) returns, without its read-only fields: leave out `id`, `status`, `trigger`, `errorCode`, `researchedAt`, `isStale` and `appliedPrompt` (for a person also `mode`, `requestedAt`, `researchedMode`, `firecrawlCredits` and `webNote`), or the write fails with `unknown_field`. Pass it with `--data @file`:\n\n```bash\nkenso accounts write-research --account-id 501 --data @acme-dossier.json\nkenso people write-research --person-id 9001 --data @jane.json\n```\n\n```json\n{\n "tagline": { "text": "Payroll for EU contractors", "sourceUrls": ["https://acme.example"] },\n "description": { "text": "Acme runs payroll and compliance for companies hiring contractors in 30 EU countries.", "sourceUrls": ["https://acme.example"] },\n "links": { "website": "https://acme.example" },\n "whyNow": { "text": "Raised a $40M Series B in October", "sourceUrls": ["https://news.example/acme-b"], "date": "2026-10" },\n "fitScore": 82,\n "angle": "Lead with contractor onboarding time."\n}\n```\n\nMany records: one JSONL line per record, with the id next to the block\'s fields. Nested objects are sent as written. Use JSONL, not CSV: the block\'s fields are objects and lists, which a CSV cell cannot carry.\n\n```bash\nkenso accounts write-research --each dossiers.jsonl --dry-run # then the same with --yes\nkenso people write-research --each people-research.jsonl --yes --concurrency 8\n```\n\n```jsonl\n{"accountId": 501, "tagline": {"text": "Payroll for EU contractors"}, "links": {"website": "https://acme.example"}}\n{"accountId": 502, "description": {"text": "Cloud cost tooling for retailers."}, "links": {"website": "https://beta.example"}}\n```\n\nA row fails as a whole with the API\'s code: `validation_failed` (an unknown field is `unknown_field`, and `error.details` names every bad field), `research_in_progress` (`409`: Ken is researching that record now, write it again once the run ends; an account run waiting for credits counts too: it runs once the workspace has credits, and the write stays refused until that run ends) or `not_found`. Rerunning a file is safe: each write replaces the record\'s research shown.\n\n## CRM sync\n\nCRM sync has generated commands only: read connections, preview, start an import, and work through sync issues. Connect the CRM itself in the app.\n\n```bash\nkenso crm-connections list\nkenso crm-connections get --connection-id 7\nkenso crm-imports create --connection-id 7 --dry-run\nkenso crm-sync-issues list --connection-id 7 --all\n```\n\nRun `kenso crm-connections --help` (or add `--all-commands` when the actions are hidden) to see every action.\n\n## Pipelines\n\nA workspace with the `pipelines` flag on can run several deal pipelines, each with its own stages. These are generated commands (beta):\n\n```bash\nkenso pipelines list\nkenso pipelines list --query "[].{id: id, name: name, default: isDefault, stages: stages[].key}"\nkenso pipelines get --pipeline-id 5\n```\n\n`list` prints every pipeline in display order, archived ones included: `id`, `name`, `routingRule` (the one sentence Ken reads to decide whether a new deal belongs there), `isDefault`, `isArchived`, `position`, `opportunityCount`, `amountTotal` and `stages`, each stage as `kenso opportunity-stages list` prints it. A stage key is unique in the workspace, across pipelines, so a deal\'s `stage` names its pipeline and its `pipelineId` repeats it. The first read turns the workspace\'s stage list into its default pipeline, named Sales, with every deal in it. The same rows as the MCP\'s `pipelines(operation="list")`.\n\nShaping them needs the `workspace_settings` permission:\n\n```bash\nkenso pipelines create --name Renewals --routing-rule "The account is already a customer" --data \'{"stages": [{"label": "Up for renewal", "category": "open"}, {"label": "Won", "category": "won"}, {"label": "Lost", "category": "lost"}]}\'\nkenso pipelines update --pipeline-id 6 --name Expansion --position 0\nkenso pipelines update --pipeline-id 6 --data @stages.json\nkenso pipelines archive --pipeline-id 6\nkenso pipelines restore --pipeline-id 6\nkenso pipelines propose --description "upsells and renewals for customers"\n```\n\n- **`create`** takes a unique `name`, the pipeline\'s `stages` in display order (at least one `open`, one `won` and one `lost`) and an optional `routingRule`: one sentence that says which deals belong there, which Ken reads to route a new deal that names no pipeline. Each stage gets a key from its label; a key another pipeline already uses gets the pipeline\'s name in front (`renewals_won`). A workspace has at most 10 pipelines.\n- **`update`** changes what you send. `stages` is the pipeline\'s whole stage list: read it with `pipelines get`, keep each stage\'s `key`, and add a new stage without one. A stage with live deals in it cannot be left out; archive it with `"isArchived": true` instead.\n- **`propose`** asks Ken to draft a pipeline from one sentence: a `name`, a `routingRule` and `stages`, in the shape `create` takes. It saves nothing. Read it, change what you want, and send it to `create`.\n- **`archive`** stops new deals from entering a pipeline and keeps the deals in it. The default pipeline cannot be archived, and nothing is deleted: `restore` brings a pipeline back.\n\n## Deals in a pipeline\n\nA deal\'s stage names its pipeline, and the deal\'s `pipelineId` repeats it. To work one pipeline\'s deals, or move a deal between pipelines:\n\n```bash\nkenso opportunities list --pipeline-id 6\nkenso opportunities search --pipeline-id 6 --data \'{"countBy": ["stage"]}\'\nkenso opportunities create --account-id 501 --pipeline-id 6\nkenso opportunities move 77 --pipeline 6\nkenso opportunities move 77 --pipeline 6 --stage negotiating\n```\n\n- **`create --pipeline-id`** opens the deal in that pipeline\'s first live open stage. Without it, and without a `stage`, Ken reads each pipeline\'s `routingRule` and opens the deal in the pipeline whose rule clearly fits the account, else in the default pipeline. A pipeline you name always wins.\n- **`move --pipeline`** alone keeps the deal\'s category (`open`, `won` or `lost`): it lands in that pipeline\'s live stage of the category with the same label as its stage now, else in the category\'s first live stage. The printed deal says where it landed. With `--stage`, the stage must be that pipeline\'s; the error lists the pipeline\'s stage keys otherwise.\n- An archived pipeline takes no deal from another pipeline (`pipeline_archived`). The deals already in it still move between its stages.\n- A move is a stage change: it writes the same history, and a stage a person set is refused with `pinned_by_user` unless you pass `--overwrite-pinned`.\n\n## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore --account-id 812\n```\n\nA deleted account can be restored for 30 days. `deleted-accounts list` shows each one with who deleted it, `expiresAt` (restore works until then) and what comes back: `personCount`, `opportunityCount` and `touchCount`. `accounts restore --account-id <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. Its Studio pages, committee seats and Knowledge facts do not come back: the delete purged them. A domain another account took since stays with that account and is listed in `domainsTaken`. A merged account is not listed and cannot be restored: a merge has no undo. Both commands are behind the `crm_import_export` feature flag (`404` while it is off).\n\n## Import a CSV export of another CRM\n\n```bash\nkenso import accounts companies.csv\nkenso import accounts companies.csv --map "Company=name" --map "Notes=" --yes\nkenso import accounts --id 42 --yes\nkenso record-import-rows list --import-id 42 --outcome skipped\nkenso record-imports undo --import-id 42\n```\n\n`kenso import accounts <file.csv>` uploads the file (a header row, at most 50,000 rows) and prints Kenso\'s plan: which field each column fills, which columns it skips, how owner and stage values are read (`valueMaps`) and what it could not settle (`questions`). Headers of Kenso, Twenty, HubSpot, Attio and Salesforce exports are recognized. Nothing is written to your accounts yet. `--map "Header=field"` changes a column and `--map "Header="` skips it. A column fills a custom field with `--map "Header=custom.<key>"` (`kenso fields list --object account` has the keys; people are `person`, deals `opportunity`), and `--map "Header=new"` adds the custom field Kenso proposes for a column no field matches (`new:text` picks the type), and a column whose header is a custom field\'s label is mapped to it already; owner and stage values change with `kenso record-imports update --import-id <id>`.\n\nWith `--yes` the import starts and the command waits for it (`--timeout`, default 30m; the import keeps running on the server either way), then prints how many rows were created, updated, restored, left unchanged and skipped. Without `--yes` it stops at the plan and prints the command that starts that import (`--id <importId> --yes`), so the file is uploaded once. `--dry-run` sends nothing: with a file it prints the upload it would make, since the plan needs the upload, and with `--id` it reads the planned import and prints what `--map`, `--source` and `--research` would change on it. `--source twenty` names the system the file\'s record ids come from: pass the same one for every file of an export, so the people and deals files find the accounts by their old ids. `kenso record-imports delete --import-id <id>` discards an import that was planned and never started; one left planned for 30 days is discarded by itself.\n\nPer row: a domain no account has creates an account; a domain that is already an account fills only that account\'s empty fields, so nothing you entered is overwritten; an account deleted in the last 30 days is restored; a row with no usable domain is skipped, and `kenso record-import-rows list --import-id <id> --outcome skipped` says why. Research of new accounts is off unless you pass `--research`, which is charged per account. It needs the `accounts` and `crm_import_export` flags. This is a different command from `accounts import`, which creates accounts row by row from the machine running the CLI.\n\n`kenso record-imports undo --import-id <id>` takes a finished import back in the background (`kenso record-imports get --import-id <id>` reads `undoing`, then `undone`): an account the import created is deleted, and can be restored for 30 days, unless someone changed it since, it holds a deal, a person was added to it since, or it was merged; a field the import filled is emptied while it still holds the imported value. `kenso record-import-rows list --import-id <id>` shows each row\'s `undoOutcome`.\n\n`kenso import people <file.csv>` works the same way for people. Import the accounts file first: a people row\'s company id (Twenty\'s `Company Id`, HubSpot\'s associated company id) places the person on the account that kept that id, and without one the person goes on the account that holds their email\'s or company\'s domain. A people import never creates an account; a person whose company is no account comes in without one and the row says so. A row matches a person by email, then LinkedIn URL, then name on the company, as every other way into People does; a matched person gets only their empty fields filled (a phone only when they have none). A row with none of the three is skipped, and a row with only a name needs a company that is an account with a domain. `kenso record-imports undo --import-id <id>` takes a people import back too: a person it created leaves the accounts the row placed them on and is deleted, unless someone changed them since, they were contacted or have a touch planned, or they are on an open deal; a field it filled is emptied while it still holds the imported value. `kenso people import` stays the JSONL and enrichment path (`--find-emails`); `kenso import people` is the CRM file with a plan, a row report and one approval.\n\n`kenso import deals <file.csv>` works the same way for deals, after the accounts file and the people file. A row opens a deal on the account that kept its company id (Twenty\'s `Company Id`, HubSpot\'s associated company id), else on the account that holds its company domain; a row whose account Kenso does not know is skipped and says so. Its contact is the person a people import kept the row\'s contact id for (Twenty\'s `Point of Contact Id`). The plan maps each stage in the file to one of the workspace\'s deal stages (`valueMaps`, field `stage`): a stage\'s key or label matches by itself, Closed Won and Closed Lost go to the first won and lost stage, and a value with no match opens in the first open stage until you pick one with `kenso record-imports update`. Amounts stay in the workspace currency: an amount in another currency is left out with a warning, never converted. A row whose deal id an earlier import kept is that deal and only gets its empty fields filled; a file with no id column opens every deal again each time it is imported, and the plan says so (`no_source_id`). `kenso record-imports undo --import-id <id>` takes a deals import back: a deal it opened is deleted unless someone changed it since, and a field it filled is emptied while it still holds the imported value. Undo in the reverse order of the imports (deals, then people, then accounts): an account that holds a deal is kept.\n\n## Export accounts, people or deals\n\n```bash\nkenso export accounts --out accounts.csv\nkenso export accounts --view 12 --out tier-1.csv\nkenso export deals --view 40 --out pipeline.csv\nkenso export deals --filters \'[{"field":"stageCategory","operator":"is","values":["open"]}]\' > open-deals.csv\n```\n\nIt writes the CSV that `POST /v1/accounts/export`, `/v1/people/export` or `/v1/opportunities/export` returns, to stdout or to `--out` (then it prints the file and its row count). With no filter it exports every record. More than 50,000 rows is refused: narrow the filters. `--view <id>` exports a saved view of that object, your own or one shared with the workspace (`kenso views list --object account` shows the ids; people are `person`, deals `opportunity`): the file holds the rows the view lists, in its sort, so its row count is the view\'s count. `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields; given with `--view`, each replaces that key of the view. The accounts and deals files start with `id` and import back as they are. Each export writes an audit-log entry and needs the export permission. Accounts and deals also need the `crm_import_export` flag while it is in beta.\n\n## Duplicates and merges\n\n```bash\nkenso accounts duplicates --scan\nkenso accounts merge 812 --into 77 --dry-run\nkenso accounts merge 812 --into 77 --yes\nkenso accounts merges list --merged-by system\nkenso accounts merges 41\n```\n\nThese need the `crm_import_export` flag beside `accounts`. `accounts duplicates` lists the pairs of accounts that look like one company: both accounts, why they were paired (`reasons`: `domain`, `linkedin`, `name`) and `isCertain`, true when the two share the name and the domain apart from its ending (acme.com and acme.co). `--scan` compares every account first; a scan also runs after each accounts import. `--status dismissed` or `merged` shows the answered pairs. `kenso account-duplicates dismiss --duplicate-id <duplicateId>` answers that a pair is not a duplicate, for good.\n\n`accounts merge <accountId> --into <id>` merges the first account into the second, the one you keep. A merge cannot be undone, so look first: `--dry-run` prints `mergeSummary` (each field that changes with its value before and after, and how many people, deals, touches and domains move) and writes nothing. The merge itself needs `--yes` when no person is at the terminal. It answers the kept account with the same summary and a `mergeId`.\n\n`accounts merges list` is the log, newest first, and `accounts merges <mergeId>` opens one merge with `mergedValues`: the merged-away account as it was. `--merged-by system` shows the merges Ken made itself. Where automatic merging is on for the workspace, Ken merges only certain pairs, keeps the customer, then the owned, then the last touched account, and leaves a pair for you when both are customers, the two have different owners, or one is being worked and the other is set aside (`heldReason` on the pair says which). That job is off unless it was turned on for the workspace.\n\n## A deal\'s stage history\n\n```bash\nkenso opportunities stage-history 77\nkenso opportunities stage-history 77 --query "entries[].{to: stageLabel, at: enteredAt, by: changedBy}"\n```\n\nIt prints `GET /v1/opportunities/{id}/stage-history` as it is, the same rows as the deal page and the MCP\'s `opportunities(operation="get-stage-history")`: the stage now, `isComplete` and `entries`, oldest first, each with `fromStage`, `stage`, `stageLabel`, `enteredAt`, `leftAt`, `durationSeconds`, `actorKind`, `actorMemberId` and Ken\'s `reason` on a move its stage judge made. The created entry of a deal a CSV import brought in has `imported: true`; one imported in a won or lost stage entered it on its file\'s close date, which is its `enteredAt`. With the `deal_stage_rules` flag on, each entry also has `changedBy` (`member`, `agent`, `api_key`, `workflow`, `stage_judge`, `crm_sync` or `ken_automation`), `crmProvider` on a CRM sync, and on a move `fromStageLabel` and `fromStageDurationSeconds`, how long the deal sat in the stage it left. `isComplete` false means Kenso has no record of part of the history.\n\n## Notes on accounts, people and deals\n\nWith the `record_notes` feature on, everyone who can see a record reads its notes. Name the record with exactly one of `--account`, `--person` and `--deal`:\n\n```bash\nkenso notes list --account 5\nkenso notes add --account 5 --body \'Budget approved, @[Jane Doe](41) please send the DPA\'\nkenso notes add --parent 900 --body \'Sent it this morning\' # a comment under note 900\ncat call-notes.md | kenso notes add --deal 77 --body - # the body from stdin\nkenso notes edit 900 --body \'Budget approved for Q1\' # the author only\nkenso notes edit 900 --pin\nkenso notes delete 900 --yes # kenso notes restore --note-id 900 brings it back\n```\n\nThe body is markdown, up to 20,000 characters. Mention a teammate as `@[Name](memberId)`: they get a notification that opens the note. A note shows on the record\'s Notes tab and its Activity timeline, and Ken\'s account brief quotes the account\'s notes. The MCP\'s `notes` tool does the same. A note on an account needs the accounts plan feature; people and deals work on every plan.\n\n## Required fields per stage\n\n```bash\nkenso pipelines stage-rules\nkenso pipelines stage-rules --pipeline 6\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier --dry-run\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier\nkenso pipelines stage-rules proposal --none\nkenso pipelines stage-rules lost --default\n```\n\nWith the `deal_stage_rules` flag on, each stage can name the fields a deal should have in it. Without a stage the command prints every stage\'s `key`, `label`, `category`, `isArchived`, `requiredFields` and `isDefault`, plus `requirableFields`: `amount`, `closeDate`, `ownerMemberId`, `primaryPersonId`, `nextStep`, `lostReasonKey`, `wonReasonKey` and `custom.<key>` for each custom deal field. `--require` sets the stage\'s whole list, in order, at most 10. `--none` requires nothing, and `--default` goes back to the default: a lost stage asks for `lostReasonKey`, any other stage nothing. Without `--pipeline` the list is the default pipeline\'s stages; `--pipeline <id>` lists that pipeline\'s. A stage key is unique across pipelines, so a stage of any pipeline is set by its key, and with `--pipeline` the command first checks the stage is that pipeline\'s. Setting a rule needs the `workspace_settings` permission. The same as the MCP\'s `opportunities(operation="stages-set-required-fields")`.\n\nA missing field never stops a move. The deal moves, and it is flagged Missing on the board, the list and the deal page until the field is filled. A rule also applies to deals already in the stage.\n\n```bash\nkenso opportunities update --opportunity-id 4401 --stage proposal\nkenso opportunities list --missing-fields\n```\n\nEvery deal then carries `missingFields` (`[{field, label}]`). A create, or an update that sends a stage, answers `warnings` beside the deal for each field the stage asks for that the deal leaves empty: each prints on stderr as `warning: <message>`, stdout stays the deal and the exit code stays 0. `--missing-fields` keeps only the deals flagged Missing (also `missingFields: true` on `kenso opportunities search`).\n\n## Won and lost reasons\n\n```bash\nkenso opportunity-reasons get\nkenso opportunity-reasons replace --kind lost --data \'{"reasons":[{"key":"no_budget","label":"No budget"},{"label":"Built it in-house"}]}\'\nkenso opportunities move 4401 --stage lost --reason built_it_in_house\n```\n\n`kenso opportunities move <id> --stage <key> [--reason <key>]` sends the reason as `lostReasonKey` for a lost stage or `wonReasonKey` for a won stage; an open stage takes none. Each field the new stage asks for that the deal leaves empty prints a warning on stderr, and the move still goes through.\n\nWith the `deal_stage_rules` flag on, each workspace edits why its deals are lost and won. `get` prints `lost` and `won`, each `{isDefault, reasons: [{key, label, isArchived}]}`. `replace` takes a kind\'s whole list in order, as `get` prints it: keep a reason by its `key`, leave `key` out for a new one, and set `isArchived` to archive a reason or bring one back. A reason left out is archived too: deals keep it, and no write can pick it again. At least one reason stays live and at most 30, and labels stay unique, archived ones included. A deal takes a live key in `lostReasonKey` (a lost stage) or `wonReasonKey` (a won stage). A move to Lost without a reason still goes through, with a warning and "Missing: Lost reason" on the deal. Editing the lists needs the `workspace_settings` permission. The same as the MCP\'s `pipelines(operation="reasons-get")` and `reasons-replace`.\n\n## Record page layouts\n\n```bash\nkenso layouts show account\nkenso layouts set account --header tier,ownerMemberId,score,custom.arr\nkenso layouts show account > layout.json && kenso layouts set account --data @layout.json\nkenso layouts reset account --dry-run\nkenso layouts reset account --yes\n```\n\nWith the `record_layout` flag on, a workspace lays out each record page once, for every member: `account`, `person` or `opportunity` (a deal). `show` prints `GET /v1/record-layouts/{object}`: `isDefault`, `version`, `headerFields` (up to 6, pinned under the record\'s name), `railSections` (`{name, fields}`), `hiddenFields` (under the rail\'s More), `sections` (`{key, label, placement, locked, hidden}`, in page order) and `availableFields`. Field keys are the field catalog\'s (`ownerMemberId`, `closeDate`, `primaryDomain`); a custom field is `custom.<field_key>`, and a new one joins the last rail section.\n\n`set --header` pins up to 6 fields and keeps the rest of the saved layout; the fields it unpins go to the top of the first rail section. `set --data` saves a whole layout, so group the rail into sections or hide a section that way, starting from `show`. A save made after someone else\'s answers a conflict: show it again. `reset` puts the page back to Kenso\'s default for every member, so it needs `--yes` (save the layout with `show` first). `set` and `reset` print the request with `--dry-run` and change nothing. Saving needs the `workspace_settings` permission, and the account page also needs the `accounts` plan. The same as the MCP\'s `account_views` operations `record-layouts-get`, `record-layouts-replace` and `record-layouts-reset`.\n\n## Pin a saved view\n\n```bash\nkenso views pin 118\nkenso views unpin 118\n```\n\nWith the `shared_views` flag on, `views pin` adds a saved view to your own sidebar, nested under its list (an account view under Accounts, a person view under People, a deal view under Deals). It is `kenso pins add --kind view --view-id <viewId>` under the name you would try: it prints the pin, and a view already pinned answers the pin it has. Pins are yours alone: pinning a shared view does not pin it for a teammate. `views unpin` finds your pin of the view and removes it, and prints `{"viewId": ..., "removed": true}`; a view you had not pinned prints `removed: false` and changes nothing. The view itself stays either way. `kenso pins list` shows every pin you have.\n\n## Tasks\n\nTasks are to-dos a member owes: a title, an optional due day or time, an assignee and at most one account, person or deal. They need the `tasks` flag. The app calls deals "Deals"; the CLI keeps `--deal` for an opportunity id.\n\n```bash\nkenso tasks add "Send the deck" --due tomorrow --account 812\nkenso tasks add "Call Ada back" --due friday --at 16:00 --person 501 --assignee ada@acme.com\nkenso tasks list --assignee me --due overdue,today\nkenso tasks queue --scope mine\nkenso tasks assign 7 me\nkenso tasks done 7 8 9\nkenso tasks done 7 --undo\n```\n\n- `tasks add` sends `POST /v1/tasks`. `--due` takes `today`, `tomorrow`, a weekday (the next one: `friday` or `fri`), a day (`2026-11-20`) or an ISO 8601 time with its offset (`2026-11-20T15:00:00Z`); `--at HH:MM` puts a time on that day (today without `--due`). Day words and `--at` read this computer\'s clock and time zone (`TZ`); a time\'s day is read in the assignee\'s app time zone. `--assignee` takes `me`, a member id or an email; without it the task is yours.\n- `tasks done` completes each task it names, in order (`PATCH /v1/tasks/{id}` with `status: done`); `--undo` reopens them. When one fails, its error names the tasks before it, which are already changed. `tasks assign` gives a task to `me`, a member id or a member\'s email; that member gets a `task_assigned` notification.\n- `tasks queue` is `task-queue list` under the name you would try: the Tasks screen\'s open work by due day, with `--scope mine|assigned_by_me|everyone`. It lists tasks, manual touches, call tasks, inbox threads with a reminder due (when you can view the Inbox) and Ken\'s follow-ups to you, each with the app path in `href` (null for a task, which opens in its panel).\n- `tasks list`, `get`, `update`, `delete`, `restore` and `task-queue list` are generated from the API: `kenso tasks --help` lists them.\n\n## Custom fields\n\n```bash\nkenso fields list --object account\nkenso fields create --object account --type select --label Region --data \'{"options":["EMEA","North America"]}\' --dry-run\nkenso fields create --object account --type select --label Region --data \'{"options":["EMEA","North America"]}\'\nkenso fields update --field-id 412 --label "Sales region"\nkenso fields archive --field-id 412 --yes\n```\n\nWith the `custom_fields` flag on, each workspace adds its own fields to accounts, people and deals (`--object account`, `person` or `opportunity`). `fields list` prints the built-in and custom fields; a custom field is `custom.<key>`, the name `customFields`, `bulk-update --set`, stage rules, layouts and imports use. Run it before you add a field that may already exist.\n\n- **`create`** takes `--object`, `--type` (`text`, `number`, `boolean`, `date`, `json`, `select`, `multi_select`, `currency`, `url` or `user`; fixed once created) and `--label`. `--key` is made from the label when you leave it out ("Contract value" is `contract_value`). `--description` says what the field means; Ken reads it when it fills the field. A select or multi_select takes its choices in `--data` as `options`, each a label or `{label, color, key}`, up to 200.\n- **`update`** changes the label, the description or the options. `options` in `--data` is the whole list: keep an option by its `key`, and one you leave out is archived, never deleted, so the records that hold it keep it.\n- **`archive`** hides a field from the pickers, the columns and the record rail and keeps every value, so it asks for `--yes`. `kenso fields update --field-id 412 --no-is-archived` brings it back. An object holds at most 100 live custom fields.\n\n## Field-fill settings and Ken\'s suggestions\n\n```bash\nkenso field-fill-settings list\nkenso field-fill-settings update --object opportunity --field amount --mode suggest --instruction "Budget the buyer named, in USD"\nkenso suggestions list --account-id 812\nkenso suggestions approve --suggestion-id 31\nkenso suggestions reject --suggestion-id 32 --reason "That was last year\'s budget"\nkenso fields fill --object opportunity --field nextStep --all\n```\n\nWith the `ken_field_fill` flag on, Ken reads email, calls and meetings and fills record fields. `field-fill-settings list` shows each field Ken can fill with its `mode`: `default` (Ken fills an empty field and suggests a change to a filled one), `off`, `suggest` (every value waits for a person) or `auto`. `update` sets a field\'s mode and an `--instruction` of up to 500 characters that tells Ken what to look for. A new mode applies to the next email, call or meeting Ken reads.\n\nA value that waits for a person is a suggestion: the field, its value now (`from`), Ken\'s value (`to`), the quote and its source. `suggestions list` shows the pending ones; narrow it with `--status`, `--object` and `--record-id` (one record), `--account-id` (the account, its people and its deals) or `--meeting-id`. `approve` writes Ken\'s value to the record (`--data \'{"value": ...}\'` writes yours instead) and `reject` leaves the record as it is. Both are a person\'s call: run them on the user\'s word.\n\n`fields fill` fills one deal field for the deals that have none, from their recorded meetings and captured email. As written above it only answers how many deals have no value and what filling them costs, and starts nothing; `--no-body-dry-run` starts it. It needs `bulk_edit` too, and works on deal fields only.\n\n## Saved views\n\n```bash\nkenso views list --object account\nkenso views create --object account --name "Tier 1, no meeting in 30 days" --visibility workspace --data @view.json --dry-run\nkenso views run --view-id 140 --limit 100 --include-total\nkenso views update --view-id 140 --name "Tier 1, quiet for 30 days"\nkenso views delete --view-id 140 --yes\n```\n\nWith the `shared_views` flag on, a saved view is a name, its object\'s search `filter` and `sort`, `columns` and a `layout` (`list` or `board`), private to its maker or shared with the workspace (`--visibility workspace`). `view.json` holds `filter` and `sort` in the shape the object\'s search takes (`filters`, `where`, `q`), so try it with `kenso accounts search --data` first. `views list` shows the workspace\'s shared views and your private ones. `run` lists a view\'s records exactly as its object\'s search returns them, page by page. `update` changes what you send, and `filter` replaces the whole filter. Any member changes or deletes a shared view, but only its maker makes it private. `delete` asks for `--yes` and takes the view off every member\'s sidebar. `kenso views pin` (above) pins one.\n\n## Reports and dashboards\n\n```bash\nkenso reports summary\nkenso reports list\nkenso reports run won_by_month --period this_year --owner 41\nkenso reports query --data \'{"measures":[{"op":"sum","field":"amount"}],"dimensions":[{"field":"stage"}]}\'\nkenso dashboards create --name "Q4 pipeline" --visibility workspace\nkenso dashboards add-chart --dashboard-id 3 --title "Won by month" --data \'{"report":{"key":"won_by_month","period":"this_year"}}\'\n```\n\nWith the `opportunities` and `reports` flags on, reports count and sum your deals. `reports summary` prints where the period stands (closed won, open pipeline, weighted pipeline, win rate) and what needs you, then one row per stock report. `reports run <report>` prints one stock report as a table: `pipeline_by_stage`, `won_by_month`, `stage_conversion`, `time_in_stage`, `won_by_source_campaign` or `activity_by_member`. Each takes `--period` (`this_quarter` by default, a month such as `2026-03`, a quarter, a year or a day range), `--owner` and `--pipeline`, and `--full` prints the whole answer with each bucket\'s filter for `opportunities search`.\n\n`reports query` asks your own question: `measures` (1 to 4 of `count`, `sum`, `avg` or `weighted_sum` of `amount`), `dimensions` (up to 2 of `stage`, `stageCategory`, `ownerMemberId`, `sourceCampaignId`, `closedAt`, `createdAt` or `closeDate`, the dates by `month`, `quarter` or `year`) and a `filter` as `opportunities search` takes it. It only reads.\n\nA dashboard keeps charts, up to 12, private to its owner or shared with the workspace. A chart is a stock report (`report`: its `key`, `period`, `ownerMemberId`, `pipelineId`) or a `query`, drawn as `bars` or a `trend`. `dashboards get --dashboard-id 3` reads one, and `update`, `remove-chart` and `delete` change it (the last two ask for `--yes`).\n\n## Forecast and quotas\n\n```bash\nkenso forecast show --period 2026-Q4\nkenso forecast show --period 2026-11 --include-deals\nkenso quotas list --period 2026-Q4\nkenso quotas propose --period 2027-Q1 --uplift-percent 15\nkenso quotas propose --period 2027-Q1 --uplift-percent 15 --apply\nkenso quotas set --period 2027-Q1 --member-id 41 --amount 120000\n```\n\nWith the `opportunities` and `forecast` flags on, `forecast show` reads closed won, commit and best case for a quarter (`2026-Q4`) or a month (`2026-11`), per member and for the team, each against its quota. Without `--period` it reads the current quarter. `--include-deals` adds the deals it counted. `quotas propose` works out each member\'s quota from what they closed won in the quarter before the period (or the last quarter that has ended) plus `--uplift-percent` (0 to 200, default 15), and writes nothing; with `--apply` it saves those amounts. `quotas set` sets one member\'s quota in the workspace currency, and `--data \'{"memberId":41,"amount":null}\'` removes it.\n';
|
|
8792
8872
|
}
|
|
8793
8873
|
});
|
|
8794
8874
|
|
|
@@ -9318,7 +9398,7 @@ function servers(record3, keys = ["url"]) {
|
|
|
9318
9398
|
});
|
|
9319
9399
|
}
|
|
9320
9400
|
function mcpServersOf(text4, keys) {
|
|
9321
|
-
const doc =
|
|
9401
|
+
const doc = readJson(text4);
|
|
9322
9402
|
return doc === void 0 ? void 0 : servers(doc.mcpServers, keys);
|
|
9323
9403
|
}
|
|
9324
9404
|
function tomlServers(text4) {
|
|
@@ -9415,7 +9495,7 @@ function addMcp(client, env, url) {
|
|
|
9415
9495
|
function signInStep(client) {
|
|
9416
9496
|
return TARGETS[client].signIn;
|
|
9417
9497
|
}
|
|
9418
|
-
var SERVER_NAME, isDoc,
|
|
9498
|
+
var SERVER_NAME, isDoc, readJson, TARGETS;
|
|
9419
9499
|
var init_mcp_config = __esm({
|
|
9420
9500
|
"src/commands/agent/mcp-config.ts"() {
|
|
9421
9501
|
"use strict";
|
|
@@ -9423,7 +9503,7 @@ var init_mcp_config = __esm({
|
|
|
9423
9503
|
init_install();
|
|
9424
9504
|
SERVER_NAME = "kenso";
|
|
9425
9505
|
isDoc = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
9426
|
-
|
|
9506
|
+
readJson = (text4) => parse2(text4) ?? parse2(stripJsonc(text4));
|
|
9427
9507
|
TARGETS = {
|
|
9428
9508
|
"claude-code": {
|
|
9429
9509
|
bins: ["claude"],
|
|
@@ -9468,7 +9548,7 @@ var init_mcp_config = __esm({
|
|
|
9468
9548
|
file: opencodeFile,
|
|
9469
9549
|
// OpenCode 1.x lists servers under mcp; newer configs nest them under mcp.servers.
|
|
9470
9550
|
entries: (text4) => {
|
|
9471
|
-
const doc =
|
|
9551
|
+
const doc = readJson(text4);
|
|
9472
9552
|
if (doc === void 0) return void 0;
|
|
9473
9553
|
return [...servers(doc.mcp), ...isDoc(doc.mcp) ? servers(doc.mcp.servers) : []];
|
|
9474
9554
|
},
|
|
@@ -11782,7 +11862,7 @@ var init_import_send = __esm({
|
|
|
11782
11862
|
});
|
|
11783
11863
|
|
|
11784
11864
|
// src/commands/contacts/server-import.ts
|
|
11785
|
-
import { readFile as
|
|
11865
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
11786
11866
|
import { basename as basename3, extname as extname3, resolve as resolve7 } from "node:path";
|
|
11787
11867
|
function csvTargetOf(header, mapping) {
|
|
11788
11868
|
if (mapping.dropped[header] !== "reserved_name") return void 0;
|
|
@@ -11812,7 +11892,7 @@ async function readUpload2(file) {
|
|
|
11812
11892
|
}
|
|
11813
11893
|
const path = resolve7(file);
|
|
11814
11894
|
try {
|
|
11815
|
-
const bytes = await
|
|
11895
|
+
const bytes = await readFile6(path);
|
|
11816
11896
|
const name = ext === ".csv" ? basename3(path) : `${basename3(path, extname3(path))}.csv`;
|
|
11817
11897
|
return { bytes, name, path };
|
|
11818
11898
|
} catch (err) {
|
|
@@ -12000,6 +12080,7 @@ var init_import2 = __esm({
|
|
|
12000
12080
|
],
|
|
12001
12081
|
operationIds: ["contacts.create", "campaigns.get", "credit-estimates.create", "contact-imports.create", "jobs.get"],
|
|
12002
12082
|
dryRun: true,
|
|
12083
|
+
batch: true,
|
|
12003
12084
|
async run(ctx, { flags }) {
|
|
12004
12085
|
if (flags.template === true) {
|
|
12005
12086
|
ctx.output.object(template());
|
|
@@ -12207,6 +12288,7 @@ var init_update = __esm({
|
|
|
12207
12288
|
],
|
|
12208
12289
|
operationIds: ["contacts.bulk-update", "contacts.list"],
|
|
12209
12290
|
dryRun: true,
|
|
12291
|
+
batch: true,
|
|
12210
12292
|
async run(ctx, { flags }) {
|
|
12211
12293
|
const file = requireFlag(flags, "file", COMMAND3);
|
|
12212
12294
|
const match = requireFlag(flags, "match", COMMAND3, "Use --match id or --match email --campaign <id>.");
|
|
@@ -12262,7 +12344,7 @@ var init_update = __esm({
|
|
|
12262
12344
|
|
|
12263
12345
|
// src/commands/contacts/bulk-store.ts
|
|
12264
12346
|
import { existsSync as existsSync6 } from "node:fs";
|
|
12265
|
-
import { appendFile as appendFile2, readFile as
|
|
12347
|
+
import { appendFile as appendFile2, readFile as readFile7, writeFile as writeFile3 } from "node:fs/promises";
|
|
12266
12348
|
import { join as join13 } from "node:path";
|
|
12267
12349
|
function whereDir(env) {
|
|
12268
12350
|
return join13(runsRoot(env), WHERE_DIR);
|
|
@@ -12291,7 +12373,7 @@ function chunkAttempts(env) {
|
|
|
12291
12373
|
return async (runId, chunkIndex) => {
|
|
12292
12374
|
earlier ??= (async () => {
|
|
12293
12375
|
const path2 = join13(runsRoot(env), runId, ATTEMPTS_FILE);
|
|
12294
|
-
const text4 = await
|
|
12376
|
+
const text4 = await readFile7(path2, "utf8").catch(() => "");
|
|
12295
12377
|
const indexes3 = new Set(
|
|
12296
12378
|
text4.split("\n").filter((line) => line.trim() !== "").map(Number)
|
|
12297
12379
|
);
|
|
@@ -12484,6 +12566,7 @@ function bulkCommand(kind) {
|
|
|
12484
12566
|
...kind === "pause" ? { beta: { featureGates: { all: ["pause_leads"] } } } : {},
|
|
12485
12567
|
operationIds: kind === "restore" ? [route.operationId] : [route.operationId, "contacts.search"],
|
|
12486
12568
|
dryRun: true,
|
|
12569
|
+
batch: true,
|
|
12487
12570
|
async run(ctx, { flags: given }) {
|
|
12488
12571
|
const dryRun2 = isDryRun(ctx);
|
|
12489
12572
|
const collected = await collectIds(ctx, given, kind, dryRun2);
|
|
@@ -12647,6 +12730,7 @@ function tagCommand(kind) {
|
|
|
12647
12730
|
examples: [`kenso contacts ${kind} --tag 31 --ids ids.txt --dry-run`, `kenso contacts ${kind} --tag 31 --ids ids.txt --yes`],
|
|
12648
12731
|
operationIds: [kind === "tag" ? "tags.bulk-assign" : "tags.bulk-unassign"],
|
|
12649
12732
|
dryRun: true,
|
|
12733
|
+
batch: true,
|
|
12650
12734
|
async run(ctx, { flags }) {
|
|
12651
12735
|
const tagId = idFlag(flags, "tag", name);
|
|
12652
12736
|
const collected = await idsFromFile(ctx, requireFlag(flags, "ids", name, "Pass a file of contact ids, or - for stdin."));
|
|
@@ -13163,7 +13247,7 @@ var init_docs2 = __esm({
|
|
|
13163
13247
|
});
|
|
13164
13248
|
|
|
13165
13249
|
// src/commands/doctor/index.ts
|
|
13166
|
-
import { statSync } from "node:fs";
|
|
13250
|
+
import { statSync as statSync2 } from "node:fs";
|
|
13167
13251
|
function nodeCheck() {
|
|
13168
13252
|
const major = Number(process.versions.node.split(".")[0]);
|
|
13169
13253
|
return {
|
|
@@ -13176,7 +13260,7 @@ function configCheck(env) {
|
|
|
13176
13260
|
const file = configPath(env);
|
|
13177
13261
|
let mode;
|
|
13178
13262
|
try {
|
|
13179
|
-
mode =
|
|
13263
|
+
mode = statSync2(file).mode & 511;
|
|
13180
13264
|
} catch (err) {
|
|
13181
13265
|
if (err.code === "ENOENT") return { name: "config_permissions", ok: true, detail: `no config file at ${file}` };
|
|
13182
13266
|
return { name: "config_permissions", ok: false, detail: `cannot read ${file}: ${err.message}` };
|
|
@@ -13452,7 +13536,7 @@ __export(import_exports3, {
|
|
|
13452
13536
|
columnChanges: () => columnChanges,
|
|
13453
13537
|
default: () => import_default3
|
|
13454
13538
|
});
|
|
13455
|
-
import { readFile as
|
|
13539
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
13456
13540
|
import { basename as basename4, extname as extname5, resolve as resolve9 } from "node:path";
|
|
13457
13541
|
import { setTimeout as delay8 } from "node:timers/promises";
|
|
13458
13542
|
async function readUpload3(file) {
|
|
@@ -13460,7 +13544,7 @@ async function readUpload3(file) {
|
|
|
13460
13544
|
if (extname5(file).toLowerCase() !== ".csv") throw usageError("An import takes a .csv file with a header row.", { field: "file" });
|
|
13461
13545
|
const path = resolve9(file);
|
|
13462
13546
|
try {
|
|
13463
|
-
return { bytes: await
|
|
13547
|
+
return { bytes: await readFile8(path), name: basename4(path), path };
|
|
13464
13548
|
} catch (err) {
|
|
13465
13549
|
const code = err.code;
|
|
13466
13550
|
throw new KensoError({ code: "file_unreadable", message: `Cannot read ${file}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Usage, field: "file" });
|
|
@@ -14494,7 +14578,7 @@ var init_stage_history = __esm({
|
|
|
14494
14578
|
resource: "opportunities",
|
|
14495
14579
|
action: "stage-history",
|
|
14496
14580
|
summary: "Show a deal's stage history: each stage, when, who moved it and how long it sat there",
|
|
14497
|
-
description: "Reads GET /v1/opportunities/{opportunityId}/stage-history and prints it: the stage now, isComplete and entries, oldest first. Each entry has kind (created, stage_changed, won, lost), fromStage, stage, stageLabel, enteredAt, leftAt, durationSeconds, actorKind, actorMemberId and, on a move Ken's stage judge made, reason. With the deal_stage_rules flag on, each entry also says who changed it (changedBy: member, agent, api_key, workflow, stage_judge, crm_sync or ken_automation, with crmProvider on a CRM sync) and, on a move, fromStageLabel and fromStageDurationSeconds (how long the deal sat in the stage it left). isComplete false means Kenso has no record of part of the history.",
|
|
14581
|
+
description: "Reads GET /v1/opportunities/{opportunityId}/stage-history and prints it: the stage now, isComplete and entries, oldest first. Each entry has kind (created, stage_changed, won, lost), fromStage, stage, stageLabel, enteredAt, leftAt, durationSeconds, actorKind, actorMemberId and, on a move Ken's stage judge made, reason. The created entry of a deal a CSV import brought in has imported: true, entered on the file's close date when it came in closed. With the deal_stage_rules flag on, each entry also says who changed it (changedBy: member, agent, api_key, workflow, stage_judge, crm_sync or ken_automation, with crmProvider on a CRM sync) and, on a move, fromStageLabel and fromStageDurationSeconds (how long the deal sat in the stage it left). isComplete false means Kenso has no record of part of the history.",
|
|
14498
14582
|
flags: {},
|
|
14499
14583
|
positionals: [{ name: "opportunityId", required: true, description: "The deal (opportunity) id" }],
|
|
14500
14584
|
examples: ["kenso opportunities stage-history 77", "kenso opportunities stage-history 77 --query 'entries[].{stage: stage, changedBy: changedBy}'"],
|
|
@@ -14706,6 +14790,7 @@ var init_import5 = __esm({
|
|
|
14706
14790
|
beta: { featureGates: { all: ["accounts"] } },
|
|
14707
14791
|
operationIds: ["people.batch"],
|
|
14708
14792
|
dryRun: true,
|
|
14793
|
+
batch: true,
|
|
14709
14794
|
async run(ctx, args) {
|
|
14710
14795
|
const { flags } = args;
|
|
14711
14796
|
const findEmails = flags["find-emails"] === true;
|
|
@@ -15210,11 +15295,14 @@ __export(resume_exports, {
|
|
|
15210
15295
|
});
|
|
15211
15296
|
import { createHash as createHash5 } from "node:crypto";
|
|
15212
15297
|
import { existsSync as existsSync8 } from "node:fs";
|
|
15213
|
-
import { readFile as
|
|
15298
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
15214
15299
|
import { resolve as resolve10 } from "node:path";
|
|
15215
15300
|
function kebab(key) {
|
|
15216
15301
|
return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
15217
15302
|
}
|
|
15303
|
+
function commandWords(command69) {
|
|
15304
|
+
return command69.trim().split(/\s+/).filter((t) => t !== "");
|
|
15305
|
+
}
|
|
15218
15306
|
function flagValue(value) {
|
|
15219
15307
|
return typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
15220
15308
|
}
|
|
@@ -15223,7 +15311,7 @@ function pushFlag(argv, flag, value) {
|
|
|
15223
15311
|
else argv.push(`--${flag}`, value);
|
|
15224
15312
|
}
|
|
15225
15313
|
function resumeArgv(run, globals = {}) {
|
|
15226
|
-
const argv = run.command
|
|
15314
|
+
const argv = commandWords(run.command);
|
|
15227
15315
|
const args = run.args;
|
|
15228
15316
|
const positionals = Array.isArray(args.positionals) ? args.positionals.map(flagValue) : [];
|
|
15229
15317
|
const afterDashes = positionals.some((p) => p.startsWith("-"));
|
|
@@ -15255,7 +15343,36 @@ function resumeArgv(run, globals = {}) {
|
|
|
15255
15343
|
return argv;
|
|
15256
15344
|
}
|
|
15257
15345
|
async function sha256(path) {
|
|
15258
|
-
return createHash5("sha256").update(await
|
|
15346
|
+
return createHash5("sha256").update(await readFile9(path)).digest("hex");
|
|
15347
|
+
}
|
|
15348
|
+
async function refuseUnlessBatch(run, next) {
|
|
15349
|
+
const words = commandWords(run.command);
|
|
15350
|
+
const name = words.join(" ");
|
|
15351
|
+
if (words[0] === "work") {
|
|
15352
|
+
throw usageError(`Run ${run.runId} is a kenso ${name} run, which cannot be resumed: its claims were released or expire on their own.`, {
|
|
15353
|
+
hint: name === "work pull" ? `Answer its work files in ${run.dir}, then send them with kenso work submit. New work: run kenso work pull again.` : "Run kenso work run again: it takes the work that waits now.",
|
|
15354
|
+
next: "kenso work status"
|
|
15355
|
+
});
|
|
15356
|
+
}
|
|
15357
|
+
const [resourceWord = "", action = ""] = words;
|
|
15358
|
+
const resource = resourceAliases[resourceWord] ?? resourceWord;
|
|
15359
|
+
const area = Object.hasOwn(handWritten, resource) ? handWritten[resource] : {};
|
|
15360
|
+
let spec = null;
|
|
15361
|
+
if (words.length === 2 && !Object.hasOwn(area, "")) {
|
|
15362
|
+
const loader = Object.hasOwn(area, action) ? area[action] : void 0;
|
|
15363
|
+
spec = loader ? await loader() : await resolveGenerated(resource, action);
|
|
15364
|
+
}
|
|
15365
|
+
const batch = spec !== null && (spec.batch === true || typeof run.args.each === "string" && Object.hasOwn(spec.flags, "each"));
|
|
15366
|
+
if (!spec || !batch) {
|
|
15367
|
+
throw usageError(`Run ${run.runId} is a kenso ${name} run, which kenso runs resume does not replay: it continues batch runs only.`, {
|
|
15368
|
+
hint: "Run the command again yourself if you mean it.",
|
|
15369
|
+
next
|
|
15370
|
+
});
|
|
15371
|
+
}
|
|
15372
|
+
const undeclared = Object.keys(run.args).filter((key) => !SKIPPED_KEYS.has(key)).map(kebab).filter((flag) => !Object.hasOwn(spec.flags, flag));
|
|
15373
|
+
if (undeclared.length > 0) {
|
|
15374
|
+
throw usageError(`Run ${run.runId} names flags kenso ${name} does not take (--${undeclared.join(", --")}), so it is not replayed.`, { next });
|
|
15375
|
+
}
|
|
15259
15376
|
}
|
|
15260
15377
|
var SKIPPED_KEYS, command44, resume_default;
|
|
15261
15378
|
var init_resume = __esm({
|
|
@@ -15263,25 +15380,22 @@ var init_resume = __esm({
|
|
|
15263
15380
|
"use strict";
|
|
15264
15381
|
init_runs();
|
|
15265
15382
|
init_errors();
|
|
15383
|
+
init_generated_hook();
|
|
15384
|
+
init_registry();
|
|
15266
15385
|
SKIPPED_KEYS = /* @__PURE__ */ new Set(["positionals", "yes", "dryRun", "dry-run", "help", "version"]);
|
|
15267
15386
|
command44 = {
|
|
15268
15387
|
resource: "runs",
|
|
15269
15388
|
action: "resume",
|
|
15270
15389
|
summary: "Continue an interrupted batch run (its command with --yes, no dry run)",
|
|
15271
15390
|
brief: "with --yes, no dry run",
|
|
15272
|
-
description: "Rebuilds the run's command from run.json and runs it with --yes from the directory it started in. The engine finds the run by its identity and skips the chunks already done. Refused when the input file is gone or changed.",
|
|
15391
|
+
description: "Rebuilds the run's command from run.json and runs it with --yes from the directory it started in. The engine finds the run by its identity and skips the chunks already done. Refused when the input file is gone or changed, when the run is not a batch run or names a flag its command does not take, and when its folder or run.json is not yours alone.",
|
|
15273
15392
|
flags: {},
|
|
15274
15393
|
positionals: [{ name: "runId", required: true, description: "The run id (see kenso runs list)" }],
|
|
15275
15394
|
examples: ["kenso runs resume r_ab3dxk2q"],
|
|
15276
15395
|
async run(ctx, { positionals }) {
|
|
15277
15396
|
const run = await loadRun(positionals[0] ?? "", ctx.env);
|
|
15278
15397
|
const next = `kenso runs show ${run.runId}`;
|
|
15279
|
-
|
|
15280
|
-
throw usageError(`Run ${run.runId} is a kenso ${run.command} run, which cannot be resumed: its claims were released or expire on their own.`, {
|
|
15281
|
-
hint: run.command === "work pull" ? `Answer its work files in ${run.dir}, then send them with kenso work submit. New work: run kenso work pull again.` : "Run kenso work run again: it takes the work that waits now.",
|
|
15282
|
-
next: "kenso work status"
|
|
15283
|
-
});
|
|
15284
|
-
}
|
|
15398
|
+
await refuseUnlessBatch(run, next);
|
|
15285
15399
|
if (run.inputPath === "-") {
|
|
15286
15400
|
throw usageError(`Run ${run.runId} read its input from stdin, so it cannot be resumed by id.`, {
|
|
15287
15401
|
hint: "Pipe the same input into the original command again: it continues the run by itself.",
|
|
@@ -15683,7 +15797,7 @@ var init_common3 = __esm({
|
|
|
15683
15797
|
|
|
15684
15798
|
// src/commands/studio/folder.ts
|
|
15685
15799
|
import { createHash as createHash6 } from "node:crypto";
|
|
15686
|
-
import { lstat, readdir as readdir2, readFile as
|
|
15800
|
+
import { lstat, readdir as readdir2, readFile as readFile10, stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
|
|
15687
15801
|
import { extname as extname6, isAbsolute, join as join15, relative, resolve as resolve11, sep } from "node:path";
|
|
15688
15802
|
function textOf2(bytes) {
|
|
15689
15803
|
if (bytes.length >= TEXT_MAX_BYTES || bytes.includes(0)) return void 0;
|
|
@@ -15695,7 +15809,7 @@ function textOf2(bytes) {
|
|
|
15695
15809
|
}
|
|
15696
15810
|
async function existingDir(dir2) {
|
|
15697
15811
|
const abs = resolve11(dir2);
|
|
15698
|
-
const info = await
|
|
15812
|
+
const info = await stat3(abs).catch(() => void 0);
|
|
15699
15813
|
if (!info?.isDirectory()) throw usageError(`${dir2} is not a directory.`, { field: "dir" });
|
|
15700
15814
|
return abs;
|
|
15701
15815
|
}
|
|
@@ -15710,7 +15824,7 @@ async function readFolder(dir2) {
|
|
|
15710
15824
|
if (entry.isDirectory()) await walk(abs);
|
|
15711
15825
|
else if (entry.isFile()) {
|
|
15712
15826
|
if (extname6(entry.name).toLowerCase() === ".md" && !(folder === root2 && TEMPLATE_MARKDOWN.has(entry.name))) continue;
|
|
15713
|
-
const bytes = await
|
|
15827
|
+
const bytes = await readFile10(abs);
|
|
15714
15828
|
files.push({ path: relative(root2, abs).split(sep).join("/"), bytes, text: textOf2(bytes) });
|
|
15715
15829
|
}
|
|
15716
15830
|
}
|
|
@@ -15744,7 +15858,7 @@ async function existingFileNoLinks(root2, target2, bundlePath) {
|
|
|
15744
15858
|
}
|
|
15745
15859
|
async function readPullState(root2) {
|
|
15746
15860
|
try {
|
|
15747
|
-
const files = JSON.parse(await
|
|
15861
|
+
const files = JSON.parse(await readFile10(join15(root2, PULL_STATE), "utf8"))?.files;
|
|
15748
15862
|
if (typeof files !== "object" || files === null) return {};
|
|
15749
15863
|
return Object.fromEntries(Object.entries(files).filter((entry) => typeof entry[1] === "string"));
|
|
15750
15864
|
} catch {
|
|
@@ -15919,7 +16033,7 @@ var pull_exports = {};
|
|
|
15919
16033
|
__export(pull_exports, {
|
|
15920
16034
|
default: () => pull_default
|
|
15921
16035
|
});
|
|
15922
|
-
import { mkdir, readFile as
|
|
16036
|
+
import { mkdir, readFile as readFile11, writeFile as writeFile5 } from "node:fs/promises";
|
|
15923
16037
|
import { dirname as dirname2, join as join16, resolve as resolve12 } from "node:path";
|
|
15924
16038
|
var command50, pull_default;
|
|
15925
16039
|
var init_pull = __esm({
|
|
@@ -15973,7 +16087,7 @@ var init_pull = __esm({
|
|
|
15973
16087
|
const conflicts = [];
|
|
15974
16088
|
for (const { path, file, target: target2 } of files) {
|
|
15975
16089
|
if (!await existingFileNoLinks(dir2, target2, path)) continue;
|
|
15976
|
-
const current = sha2562(await
|
|
16090
|
+
const current = sha2562(await readFile11(target2));
|
|
15977
16091
|
const next = typeof file.text === "string" ? sha2562(Buffer.from(file.text, "utf8")) : file.sha256?.toLowerCase();
|
|
15978
16092
|
if (current !== next && current !== state[path]) conflicts.push(path);
|
|
15979
16093
|
}
|
|
@@ -16417,7 +16531,7 @@ __export(fill_exports, {
|
|
|
16417
16531
|
default: () => fill_default
|
|
16418
16532
|
});
|
|
16419
16533
|
import { createHash as createHash9 } from "node:crypto";
|
|
16420
|
-
import { readFile as
|
|
16534
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
16421
16535
|
import { join as join17, resolve as resolve14 } from "node:path";
|
|
16422
16536
|
async function readTarget(ctx, flags) {
|
|
16423
16537
|
const accounts = stringFlag(flags.accounts);
|
|
@@ -16451,7 +16565,7 @@ async function readTarget(ctx, flags) {
|
|
|
16451
16565
|
items: [...firstRow].map(([id, row]) => ({ id, row })),
|
|
16452
16566
|
duplicates: raw.length - firstRow.size,
|
|
16453
16567
|
...campaign !== void 0 ? { campaignId: positiveId3(campaign, "campaign") } : {},
|
|
16454
|
-
input: source === "-" ? { path: "-", sha256: sha2563(raw.join("\n")) } : { path: resolve14(source), sha256: sha2563(await
|
|
16568
|
+
input: source === "-" ? { path: "-", sha256: sha2563(raw.join("\n")) } : { path: resolve14(source), sha256: sha2563(await readFile12(resolve14(source))) }
|
|
16455
16569
|
};
|
|
16456
16570
|
}
|
|
16457
16571
|
async function refuseRefill(ctx, args, target2) {
|
|
@@ -16549,6 +16663,7 @@ var init_fill = __esm({
|
|
|
16549
16663
|
beta: { featureGates: STUDIO_GATES },
|
|
16550
16664
|
operationIds: ["asset-runs.estimate", "asset-runs.create", "asset-runs.get"],
|
|
16551
16665
|
dryRun: true,
|
|
16666
|
+
batch: true,
|
|
16552
16667
|
async run(ctx, args) {
|
|
16553
16668
|
const { flags, positionals } = args;
|
|
16554
16669
|
const templateId = positiveId3(positionals[0], "templateId");
|
|
@@ -17437,9 +17552,9 @@ function readRegularFile(path, what) {
|
|
|
17437
17552
|
if (!lstatSync(path).isFile()) return notPlain;
|
|
17438
17553
|
const fd = openSync2(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
17439
17554
|
try {
|
|
17440
|
-
const
|
|
17441
|
-
if (!
|
|
17442
|
-
if (
|
|
17555
|
+
const stat4 = fstatSync(fd);
|
|
17556
|
+
if (!stat4.isFile()) return notPlain;
|
|
17557
|
+
if (stat4.size > MAX_ANSWERS_FILE_BYTES) return { ok: false, error: `the ${what} is too large` };
|
|
17443
17558
|
return readFileSync11(fd, "utf8");
|
|
17444
17559
|
} finally {
|
|
17445
17560
|
closeSync2(fd);
|
|
@@ -18098,7 +18213,7 @@ var init_release = __esm({
|
|
|
18098
18213
|
|
|
18099
18214
|
// src/work/job.ts
|
|
18100
18215
|
import { spawn as nodeSpawn3 } from "node:child_process";
|
|
18101
|
-
import { rmSync as rmSync3, statSync as
|
|
18216
|
+
import { rmSync as rmSync3, statSync as statSync3 } from "node:fs";
|
|
18102
18217
|
import { access, constants as constants2 } from "node:fs/promises";
|
|
18103
18218
|
import { delimiter as delimiter2, join as join22 } from "node:path";
|
|
18104
18219
|
import { setTimeout as delay12 } from "node:timers/promises";
|
|
@@ -18117,7 +18232,7 @@ function childEnv(parent, adapter, extra) {
|
|
|
18117
18232
|
async function isExecutableFile(path) {
|
|
18118
18233
|
try {
|
|
18119
18234
|
await access(path, constants2.X_OK);
|
|
18120
|
-
return
|
|
18235
|
+
return statSync3(path).isFile();
|
|
18121
18236
|
} catch {
|
|
18122
18237
|
return false;
|
|
18123
18238
|
}
|
|
@@ -19630,12 +19745,12 @@ var init_run3 = __esm({
|
|
|
19630
19745
|
let inARow = 0;
|
|
19631
19746
|
let released = 0;
|
|
19632
19747
|
const unsent = [];
|
|
19633
|
-
const
|
|
19748
|
+
const open2 = /* @__PURE__ */ new Map();
|
|
19634
19749
|
const releasing = /* @__PURE__ */ new Map();
|
|
19635
19750
|
const releaseOnce = (claimId) => {
|
|
19636
19751
|
let pending = releasing.get(claimId);
|
|
19637
19752
|
if (!pending) {
|
|
19638
|
-
|
|
19753
|
+
open2.delete(claimId);
|
|
19639
19754
|
pending = releaseClaim(ctx, claimId, headers).then(
|
|
19640
19755
|
(n) => {
|
|
19641
19756
|
released += n;
|
|
@@ -19649,7 +19764,7 @@ var init_run3 = __esm({
|
|
|
19649
19764
|
const abortRun = (reason2, why) => {
|
|
19650
19765
|
halt(reason2, why);
|
|
19651
19766
|
stop.abort();
|
|
19652
|
-
for (const [claimId, phase] of [...
|
|
19767
|
+
for (const [claimId, phase] of [...open2]) if (phase === "agent") void releaseOnce(claimId);
|
|
19653
19768
|
};
|
|
19654
19769
|
const onStop = () => abortRun("interrupted");
|
|
19655
19770
|
if (ctx.signal.aborted) onStop();
|
|
@@ -19700,7 +19815,7 @@ var init_run3 = __esm({
|
|
|
19700
19815
|
}
|
|
19701
19816
|
claims++;
|
|
19702
19817
|
items += claim.items.length;
|
|
19703
|
-
|
|
19818
|
+
open2.set(claim.id, "agent");
|
|
19704
19819
|
if (quit.signal.aborted) {
|
|
19705
19820
|
await releaseOnce(claim.id);
|
|
19706
19821
|
return null;
|
|
@@ -19757,7 +19872,7 @@ var init_run3 = __esm({
|
|
|
19757
19872
|
let kept;
|
|
19758
19873
|
let refused;
|
|
19759
19874
|
if (result.answersPath !== void 0 && (result.outcome === "ok" || result.outcome === "timeout")) {
|
|
19760
|
-
|
|
19875
|
+
open2.set(claim.id, "submitting");
|
|
19761
19876
|
try {
|
|
19762
19877
|
const sent = await submitAnswersFile(ctx, result.answersPath, work, {
|
|
19763
19878
|
headers,
|
|
@@ -19780,7 +19895,7 @@ var init_run3 = __esm({
|
|
|
19780
19895
|
}
|
|
19781
19896
|
const giveBack = kept === void 0 && (done2 < claim.items.length || stop.signal.aborted);
|
|
19782
19897
|
if (giveBack) await releaseOnce(claim.id);
|
|
19783
|
-
else
|
|
19898
|
+
else open2.delete(claim.id);
|
|
19784
19899
|
if (kept !== void 0) {
|
|
19785
19900
|
unsent.push(kept);
|
|
19786
19901
|
ctx.output.warn(`Kenso did not take the answers for claim ${claim.id}: they are in ${kept}, and the claim holds its items until ${claim.expiresAt}. Send them with kenso work submit.`);
|
|
@@ -19832,7 +19947,7 @@ var init_run3 = __esm({
|
|
|
19832
19947
|
};
|
|
19833
19948
|
try {
|
|
19834
19949
|
await runPool({ parallel, next: nextJob, run: runJob, signal: quit.signal });
|
|
19835
|
-
await Promise.all([...
|
|
19950
|
+
await Promise.all([...open2.keys()].map(releaseOnce));
|
|
19836
19951
|
await Promise.all(releasing.values());
|
|
19837
19952
|
} finally {
|
|
19838
19953
|
process.off("SIGTERM", onTerm);
|
|
@@ -20746,7 +20861,7 @@ async function completions(words, globals) {
|
|
|
20746
20861
|
const current = words.at(-1) ?? "";
|
|
20747
20862
|
const positionals = [];
|
|
20748
20863
|
let spec;
|
|
20749
|
-
let
|
|
20864
|
+
let commandWords2 = 0;
|
|
20750
20865
|
let valueFor;
|
|
20751
20866
|
let afterDashes = false;
|
|
20752
20867
|
let help = false;
|
|
@@ -20774,11 +20889,11 @@ async function completions(words, globals) {
|
|
|
20774
20889
|
const area = handWritten[resource] ?? {};
|
|
20775
20890
|
if (positionals.length === 1 && area[""]) {
|
|
20776
20891
|
spec = await area[""]();
|
|
20777
|
-
|
|
20892
|
+
commandWords2 = 1;
|
|
20778
20893
|
} else if (positionals.length === 2) {
|
|
20779
20894
|
const loader = area[positionals[1]];
|
|
20780
20895
|
spec = (loader ? await loader() : await resolveGenerated(resource, positionals[1])) ?? void 0;
|
|
20781
|
-
|
|
20896
|
+
commandWords2 = 2;
|
|
20782
20897
|
}
|
|
20783
20898
|
}
|
|
20784
20899
|
if (valueFor !== void 0) return [...FLAG_VALUES[valueFor] ?? []];
|
|
@@ -20789,7 +20904,7 @@ async function completions(words, globals) {
|
|
|
20789
20904
|
}
|
|
20790
20905
|
if (positionals.length === 0) return resources();
|
|
20791
20906
|
if (!spec) return positionals.length === 1 ? actions33(resourceAliases[positionals[0]] ?? positionals[0]) : [];
|
|
20792
|
-
const given = positionals.length -
|
|
20907
|
+
const given = positionals.length - commandWords2;
|
|
20793
20908
|
const declared = spec.positionals ?? [];
|
|
20794
20909
|
if (given < declared.length || declared.at(-1)?.variadic === true) {
|
|
20795
20910
|
return given === 0 ? [...POSITIONAL_VALUES[spec.resource] ?? []] : [];
|