kenso 0.1.93 → 0.1.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/kenso.js CHANGED
@@ -21,9 +21,9 @@ var __commonJS = (cb, mod) => function __require() {
21
21
  throw mod = 0, e;
22
22
  }
23
23
  };
24
- var __export = (target, all) => {
24
+ var __export = (target2, all) => {
25
25
  for (var name in all)
26
- __defProp(target, name, { get: all[name], enumerable: true });
26
+ __defProp(target2, name, { get: all[name], enumerable: true });
27
27
  };
28
28
  var __copyProps = (to, from, except, desc) => {
29
29
  if (from && typeof from === "object" || typeof from === "function") {
@@ -33,12 +33,12 @@ var __copyProps = (to, from, except, desc) => {
33
33
  }
34
34
  return to;
35
35
  };
36
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
+ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
37
  // If the importer is in node compatibility mode or this is not an ESM
38
38
  // file that has been converted to a CommonJS file using a Babel-
39
39
  // compatible transform (i.e. "__esModule" has not been set), then set
40
40
  // "default" to the CommonJS "module.exports" for node compatibility.
41
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
42
42
  mod
43
43
  ));
44
44
 
@@ -2215,12 +2215,12 @@ function pickFields(value, paths) {
2215
2215
  for (const path of paths) {
2216
2216
  const { found, value: picked } = getPath(value, path);
2217
2217
  if (!found) continue;
2218
- let target = out;
2218
+ let target2 = out;
2219
2219
  for (const segment of path.slice(0, -1)) {
2220
- if (!isRecord(target[segment])) target[segment] = {};
2221
- target = target[segment];
2220
+ if (!isRecord(target2[segment])) target2[segment] = {};
2221
+ target2 = target2[segment];
2222
2222
  }
2223
- target[path[path.length - 1]] = picked;
2223
+ target2[path[path.length - 1]] = picked;
2224
2224
  }
2225
2225
  return out;
2226
2226
  }
@@ -2477,7 +2477,7 @@ var VERSION;
2477
2477
  var init_version = __esm({
2478
2478
  "src/core/version.ts"() {
2479
2479
  "use strict";
2480
- VERSION = true ? "0.1.93" : "0.0.0-dev";
2480
+ VERSION = true ? "0.1.95" : "0.0.0-dev";
2481
2481
  }
2482
2482
  });
2483
2483
 
@@ -4174,9 +4174,9 @@ async function readRunDir(dir) {
4174
4174
  return null;
4175
4175
  }
4176
4176
  if (!raw) return null;
4177
- const { runId, command: command61, createdAt, status } = raw;
4177
+ const { runId, command: command65, createdAt, status } = raw;
4178
4178
  if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
4179
- if (typeof command61 !== "string" || typeof createdAt !== "string") return null;
4179
+ if (typeof command65 !== "string" || typeof createdAt !== "string") return null;
4180
4180
  if (typeof status !== "string" || !STATUSES.includes(status)) return null;
4181
4181
  let chunksDone = chunkList(raw.chunksDone) ?? [];
4182
4182
  try {
@@ -4187,7 +4187,7 @@ async function readRunDir(dir) {
4187
4187
  const record = {
4188
4188
  ...raw,
4189
4189
  runId,
4190
- command: command61,
4190
+ command: command65,
4191
4191
  args: asRecord3(raw.args) ?? {},
4192
4192
  createdAt,
4193
4193
  status,
@@ -4242,11 +4242,11 @@ async function loadRun(runId, env = process.env) {
4242
4242
  }
4243
4243
  return run;
4244
4244
  }
4245
- async function findIdentical(command61, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4245
+ async function findIdentical(command65, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4246
4246
  const identity = argsIdentity(args);
4247
4247
  const runs = await listRuns(env);
4248
4248
  return runs.filter(
4249
- (run) => run.command === command61 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4249
+ (run) => run.command === command65 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4250
4250
  );
4251
4251
  }
4252
4252
  function isOtherLiveProcess(pid) {
@@ -4340,10 +4340,10 @@ async function alreadyDone(run, totalRows, started, ctx) {
4340
4340
  async function dryRun(spec, ctx, plan) {
4341
4341
  let runId;
4342
4342
  let dir;
4343
- const target = plan.finished ?? plan.resumable;
4344
- if (target) {
4345
- runId = target.runId;
4346
- dir = target.dir;
4343
+ const target2 = plan.finished ?? plan.resumable;
4344
+ if (target2) {
4345
+ runId = target2.runId;
4346
+ dir = target2.dir;
4347
4347
  } else {
4348
4348
  runId = newRunId();
4349
4349
  dir = await prepareRunDir(spec.outDir, runId, plan.identical, ctx);
@@ -7458,8 +7458,8 @@ function idValue(value, field) {
7458
7458
  function shellQuote3(arg) {
7459
7459
  return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
7460
7460
  }
7461
- function commandLine2(ctx, command61, args, extra = []) {
7462
- const parts2 = ["kenso", ...command61.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
7461
+ function commandLine2(ctx, command65, args, extra = []) {
7462
+ const parts2 = ["kenso", ...command65.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
7463
7463
  for (const [name, value] of Object.entries(args.flags)) {
7464
7464
  if (value === void 0 || value === false) continue;
7465
7465
  if (value === true) parts2.push(`--${name}`);
@@ -7744,13 +7744,475 @@ var init_import = __esm({
7744
7744
  }
7745
7745
  });
7746
7746
 
7747
+ // src/commands/contacts/common.ts
7748
+ import { createHash as createHash3 } from "node:crypto";
7749
+ import { readFile as readFile6 } from "node:fs/promises";
7750
+ import { resolve as resolve5 } from "node:path";
7751
+ function stringFlag2(flags, name) {
7752
+ const value = flags[name];
7753
+ if (typeof value !== "string") return void 0;
7754
+ const text4 = value.trim();
7755
+ return text4 === "" ? void 0 : text4;
7756
+ }
7757
+ function requireFlag(flags, name, command65, hint) {
7758
+ const value = stringFlag2(flags, name);
7759
+ if (value === void 0) throw usageError(`--${name} is required for ${command65}.`, { field: name, next: `${command65} --help`, ...hint ? { hint } : {} });
7760
+ return value;
7761
+ }
7762
+ function positiveId(value) {
7763
+ const text4 = value.trim();
7764
+ if (!/^[0-9]+$/.test(text4)) return void 0;
7765
+ const id = Number(text4);
7766
+ return Number.isSafeInteger(id) && id > 0 ? id : void 0;
7767
+ }
7768
+ function idFlag(flags, name, command65) {
7769
+ const raw = requireFlag(flags, name, command65);
7770
+ const id = positiveId(raw);
7771
+ if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
7772
+ return id;
7773
+ }
7774
+ function concurrency(flags) {
7775
+ const raw = stringFlag2(flags, "concurrency");
7776
+ if (raw === void 0) return void 0;
7777
+ const value = Number(raw);
7778
+ if (!Number.isInteger(value) || value < 1 || value > 16) {
7779
+ throw usageError(`--concurrency must be a whole number from 1 to 16 (got "${raw}").`, { field: "concurrency" });
7780
+ }
7781
+ return value;
7782
+ }
7783
+ function isDryRun(ctx) {
7784
+ return ctx.flags.yes !== true;
7785
+ }
7786
+ function shellQuote4(value) {
7787
+ return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
7788
+ }
7789
+ function sameCommand2(command65, flags, ctx, extra = []) {
7790
+ const parts2 = [command65];
7791
+ for (const [name, value] of Object.entries(flags)) {
7792
+ if (value === void 0 || value === false) continue;
7793
+ if (value === true) parts2.push(`--${name}`);
7794
+ else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${name}`, shellQuote4(item));
7795
+ }
7796
+ for (const name of ["profile", "workspace"]) {
7797
+ const value = ctx.flags[name];
7798
+ if (value !== void 0) parts2.push(`--${name}`, shellQuote4(value));
7799
+ }
7800
+ parts2.push(...extra);
7801
+ return parts2.join(" ");
7802
+ }
7803
+ async function fileSha256(path) {
7804
+ return createHash3("sha256").update(await readFile6(resolve5(path))).digest("hex");
7805
+ }
7806
+ function rateLimitRemaining3(headers) {
7807
+ const raw = headers.get("ratelimit-remaining");
7808
+ if (raw === null || raw.trim() === "") return void 0;
7809
+ const value = Number(raw);
7810
+ return Number.isFinite(value) ? value : void 0;
7811
+ }
7812
+ function rethrowIfRunStopping(err) {
7813
+ if (!(err instanceof KensoError)) return;
7814
+ if (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.RateLimited || err.exitCode === ExitCode.Interrupted) throw err;
7815
+ }
7816
+ function failedRow(row, err, extra = {}) {
7817
+ const reason = err instanceof KensoError ? err.code : "failed";
7818
+ const error = err instanceof Error ? err.message : String(err);
7819
+ return { row, status: "failed", reason, error, ...extra };
7820
+ }
7821
+ function invalidRow(row, reason, error, extra = {}) {
7822
+ return { row, status: "invalid", reason, ...error ? { error } : {}, ...extra };
7823
+ }
7824
+ function isRecord4(value) {
7825
+ return value !== null && typeof value === "object" && !Array.isArray(value);
7826
+ }
7827
+ function warnDropped(ctx, mapping) {
7828
+ const dropped = Object.entries(mapping.dropped).filter(([, reason]) => reason !== "mapped_to_null");
7829
+ if (dropped.length === 0) return;
7830
+ const list2 = dropped.map(([header, reason]) => `"${header}" (${reason})`).join(", ");
7831
+ ctx.output.warn(`Not sent: ${list2}. Rename a column with --map '{"<column>": "customVariables.<name>"}'.`);
7832
+ }
7833
+ var OUT_FLAG2, CONCURRENCY_FLAG;
7834
+ var init_common = __esm({
7835
+ "src/commands/contacts/common.ts"() {
7836
+ "use strict";
7837
+ init_errors();
7838
+ init_exit_codes();
7839
+ OUT_FLAG2 = { type: "string", description: "Keep the run's files (results.csv, invalid.csv, plan.json) in this directory" };
7840
+ CONCURRENCY_FLAG = { type: "string", description: "Requests in flight at once (default 4, max 16)" };
7841
+ }
7842
+ });
7843
+
7844
+ // src/batch/jobs.ts
7845
+ import { setTimeout as delay2 } from "node:timers/promises";
7846
+ function interrupted2() {
7847
+ return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
7848
+ }
7849
+ async function defaultSleep(ms, signal) {
7850
+ try {
7851
+ await delay2(ms, void 0, signal ? { signal } : void 0);
7852
+ } catch (err) {
7853
+ if (signal?.aborted) throw interrupted2();
7854
+ throw err;
7855
+ }
7856
+ }
7857
+ function toJob(body2, jobId, type) {
7858
+ const data = unwrap(body2);
7859
+ const record = data !== null && typeof data === "object" && !Array.isArray(data) ? data : {};
7860
+ const rawId = record.id;
7861
+ return {
7862
+ ...record,
7863
+ id: typeof rawId === "number" || typeof rawId === "string" && rawId !== "" ? String(rawId) : jobId,
7864
+ type: typeof record.type === "string" && record.type !== "" ? record.type : type,
7865
+ status: typeof record.status === "string" ? record.status : "queued"
7866
+ };
7867
+ }
7868
+ async function waitForJob(client, jobId, type, opts = {}) {
7869
+ const id = String(jobId).trim();
7870
+ if (id === "") throw usageError("Name the job id.", { field: "jobId" });
7871
+ const timeoutMs2 = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
7872
+ const intervalMs = opts.intervalMs ?? DEFAULT_INTERVAL_MS;
7873
+ const now = opts.now ?? Date.now;
7874
+ const sleep = opts.sleep ?? ((ms) => defaultSleep(ms, opts.signal));
7875
+ const started = now();
7876
+ for (; ; ) {
7877
+ if (opts.signal?.aborted) throw interrupted2();
7878
+ const res = await client.request({ method: "GET", path: `/v1/jobs/${encodeURIComponent(id)}`, query: { type }, signal: opts.signal });
7879
+ const job = toJob(res.body, id, type);
7880
+ if (TERMINAL_JOB_STATUSES.includes(job.status)) return job;
7881
+ opts.onProgress?.(job);
7882
+ const elapsed = now() - started;
7883
+ if (elapsed >= timeoutMs2) {
7884
+ throw new KensoError({
7885
+ code: "job_timeout",
7886
+ message: `Job ${id} is still ${job.status} after ${Math.round(timeoutMs2 / 1e3)} s.`,
7887
+ exitCode: ExitCode.Error,
7888
+ hint: "The job keeps running on the server. Wait for it again.",
7889
+ next: `kenso jobs wait ${id} --type ${type}`
7890
+ });
7891
+ }
7892
+ const interval = elapsed >= FAST_PHASE_MS ? Math.max(intervalMs, SLOW_INTERVAL_MS) : intervalMs;
7893
+ await sleep(Math.min(interval, Math.max(0, timeoutMs2 - elapsed)));
7894
+ }
7895
+ }
7896
+ var TERMINAL_JOB_STATUSES, DEFAULT_TIMEOUT_MS, DEFAULT_INTERVAL_MS, SLOW_INTERVAL_MS, FAST_PHASE_MS;
7897
+ var init_jobs = __esm({
7898
+ "src/batch/jobs.ts"() {
7899
+ "use strict";
7900
+ init_errors();
7901
+ init_exit_codes();
7902
+ init_http();
7903
+ TERMINAL_JOB_STATUSES = ["succeeded", "failed", "canceled"];
7904
+ DEFAULT_TIMEOUT_MS = 10 * 6e4;
7905
+ DEFAULT_INTERVAL_MS = 2e3;
7906
+ SLOW_INTERVAL_MS = 1e4;
7907
+ FAST_PHASE_MS = 6e4;
7908
+ }
7909
+ });
7910
+
7911
+ // src/commands/jobs/wait.ts
7912
+ var wait_exports = {};
7913
+ __export(wait_exports, {
7914
+ default: () => wait_default,
7915
+ parseDuration: () => parseDuration
7916
+ });
7917
+ function parseDuration(text4) {
7918
+ const match = /^(\d+(?:\.\d+)?)\s*([smh]?)$/i.exec(text4.trim());
7919
+ if (!match) return void 0;
7920
+ const ms = Number(match[1]) * (UNIT_MS[(match[2] || "s").toLowerCase()] ?? 1e3);
7921
+ return Number.isFinite(ms) ? Math.round(ms) : void 0;
7922
+ }
7923
+ var UNIT_MS, command2, wait_default;
7924
+ var init_wait = __esm({
7925
+ "src/commands/jobs/wait.ts"() {
7926
+ "use strict";
7927
+ init_jobs();
7928
+ init_errors();
7929
+ init_exit_codes();
7930
+ UNIT_MS = { s: 1e3, m: 6e4, h: 36e5 };
7931
+ command2 = {
7932
+ resource: "jobs",
7933
+ action: "wait",
7934
+ summary: "Wait for a background job and print it",
7935
+ description: "Polls GET /v1/jobs/{jobId}?type=<type> every 2 s (every 10 s after the first minute) until the job succeeds, fails or is canceled, then prints the job. Exit 0 when it succeeded, 1 when it failed, was canceled or is still running when --timeout passes.",
7936
+ flags: {
7937
+ type: { type: "string", required: true, description: "The job type, for example contact_import or contact_export" },
7938
+ timeout: { type: "string", default: "10m", description: "How long to wait: 90s, 10m, 1h or a number of seconds (default 10m)" }
7939
+ },
7940
+ positionals: [{ name: "jobId", required: true, description: "The job id" }],
7941
+ examples: ["kenso jobs wait 4821 --type contact_import", "kenso jobs wait 4821 --type contact_export --timeout 30m"],
7942
+ operationIds: ["jobs.get"],
7943
+ async run(ctx, { flags, positionals }) {
7944
+ const jobId = (positionals[0] ?? "").trim();
7945
+ if (jobId === "") throw usageError("Name the job id.", { field: "jobId", next: "kenso jobs wait <jobId> --type <type>" });
7946
+ const type = typeof flags.type === "string" ? flags.type.trim() : "";
7947
+ if (type === "") throw usageError("--type needs a value, for example contact_import.", { field: "type" });
7948
+ const timeoutText = typeof flags.timeout === "string" ? flags.timeout : "10m";
7949
+ const timeoutMs2 = parseDuration(timeoutText);
7950
+ if (timeoutMs2 === void 0) {
7951
+ throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
7952
+ }
7953
+ const job = await waitForJob(ctx.client, jobId, type, {
7954
+ timeoutMs: timeoutMs2,
7955
+ signal: ctx.signal,
7956
+ onProgress: (j) => {
7957
+ const done2 = j.progress ? `, ${j.progress.completed}/${j.progress.total ?? "?"}` : "";
7958
+ ctx.output.progress(`job ${j.id}: ${j.status}${done2}`);
7959
+ }
7960
+ });
7961
+ ctx.output.object(job);
7962
+ if (job.status === "succeeded") return ExitCode.Ok;
7963
+ throw new KensoError({
7964
+ code: job.error?.code || (job.status === "canceled" ? "job_canceled" : "job_failed"),
7965
+ message: job.error?.message || `Job ${job.id} ${job.status === "canceled" ? "was canceled" : "failed"}.`,
7966
+ exitCode: ExitCode.Error
7967
+ });
7968
+ }
7969
+ };
7970
+ wait_default = command2;
7971
+ }
7972
+ });
7973
+
7974
+ // src/commands/changes/bulk-update.ts
7975
+ import { setTimeout as delay3 } from "node:timers/promises";
7976
+ function idList(flags, name) {
7977
+ const raw = stringFlag2(flags, name);
7978
+ if (raw === void 0) return void 0;
7979
+ const ids2 = raw.split(/[\s,]+/).filter((part) => part !== "").map(positiveId);
7980
+ if (ids2.length === 0 || ids2.length > MAX_IDS || ids2.some((id) => id === void 0)) {
7981
+ throw usageError(`--${name} takes 1 to ${MAX_IDS} positive ids, comma-separated (got "${raw}").`, { field: name });
7982
+ }
7983
+ return [...new Set(ids2)];
7984
+ }
7985
+ function parseSet(pairs, aliases) {
7986
+ const set = {};
7987
+ for (const pair of pairs) {
7988
+ const at = pair.indexOf("=");
7989
+ const key = at > 0 ? pair.slice(0, at).trim() : "";
7990
+ if (key === "") throw usageError(`--set takes field=value (got "${pair}").`, { field: "set", hint: "For example --set stage=engaged." });
7991
+ const text4 = pair.slice(at + 1).trim();
7992
+ let value = text4;
7993
+ try {
7994
+ value = JSON.parse(text4);
7995
+ } catch {
7996
+ }
7997
+ const field = aliases[key] ?? key;
7998
+ if (field in set) throw usageError(`--set names ${field} twice.`, { field: "set" });
7999
+ set[field] = value;
8000
+ }
8001
+ return set;
8002
+ }
8003
+ function filterBody(flags) {
8004
+ const raw = stringFlag2(flags, "filter");
8005
+ if (raw === void 0) return void 0;
8006
+ let parsed2;
8007
+ try {
8008
+ parsed2 = JSON.parse(raw);
8009
+ } catch {
8010
+ parsed2 = void 0;
8011
+ }
8012
+ if (!isRecord4(parsed2)) {
8013
+ throw usageError("--filter takes the search body as a JSON object.", { field: "filter", hint: `For example --filter '{"q": "acme"}'.` });
8014
+ }
8015
+ return parsed2;
8016
+ }
8017
+ function targetBody(flags, target2, command65) {
8018
+ const ids2 = idList(flags, "ids");
8019
+ const filter = filterBody(flags);
8020
+ const everything = flags.all === true;
8021
+ if ([ids2 !== void 0, filter !== void 0, everything].filter(Boolean).length !== 1) {
8022
+ throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command65} --help` });
8023
+ }
8024
+ const exclude = idList(flags, "exclude-ids");
8025
+ if (exclude !== void 0 && ids2 !== void 0) throw usageError("--exclude-ids goes with --filter or --all.", { field: "exclude-ids" });
8026
+ const label = stringFlag2(flags, "label");
8027
+ return {
8028
+ ...ids2 !== void 0 ? { ids: ids2 } : { filter: filter ?? {}, ...everything ? { all: true } : {}, ...exclude ? { excludeIds: exclude } : {} },
8029
+ ...label !== void 0 ? { label } : {}
8030
+ };
8031
+ }
8032
+ function requestBody(flags, target2, dryRun2) {
8033
+ const command65 = `kenso ${target2.resource} bulk-update`;
8034
+ const pairs = Array.isArray(flags.set) ? flags.set : typeof flags.set === "string" ? [flags.set] : [];
8035
+ if (pairs.length === 0) throw usageError(`--set is required for ${command65}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command65} --help` });
8036
+ return {
8037
+ ...targetBody(flags, target2, command65),
8038
+ set: parseSet(pairs, target2.aliases),
8039
+ ...dryRun2 ? { dryRun: true } : {},
8040
+ ...flags["overwrite-pinned"] === true ? { overwritePinned: true } : {}
8041
+ };
8042
+ }
8043
+ async function waitForChange(ctx, first, timeoutMs2) {
8044
+ const started = Date.now();
8045
+ let change = first;
8046
+ while (WORKING.has(change.status)) {
8047
+ const res = await ctx.client.request({ method: "GET", path: `/v1/changes/${change.id}`, signal: ctx.signal });
8048
+ change = unwrap(res.body);
8049
+ if (!WORKING.has(change.status)) break;
8050
+ if (Date.now() - started >= timeoutMs2) {
8051
+ throw new KensoError({
8052
+ code: "change_timeout",
8053
+ message: `Change ${change.id} is still ${change.status} after ${Math.round(timeoutMs2 / 1e3)} s.`,
8054
+ exitCode: ExitCode.Error,
8055
+ hint: "It keeps running on the server.",
8056
+ next: `kenso changes get --change-id ${change.id}`
8057
+ });
8058
+ }
8059
+ ctx.output.progress(`change ${change.id}: ${change.status}`);
8060
+ try {
8061
+ await delay3(POLL_MS, void 0, { signal: ctx.signal });
8062
+ } catch (err) {
8063
+ if (ctx.signal.aborted) throw new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
8064
+ throw err;
8065
+ }
8066
+ }
8067
+ return change;
8068
+ }
8069
+ function bulkUpdateCommand(target2) {
8070
+ return {
8071
+ resource: target2.resource,
8072
+ action: "bulk-update",
8073
+ summary: `Change fields on many ${target2.plural} at once: by --ids, or everything a --filter matches`,
8074
+ brief: "--filter --set",
8075
+ description: `Calls POST /v1/${target2.resource}/bulk-update, which makes a change set: the ${target2.plural} it names and, for each, the field, its value before and its value after. Without --yes (or with --dry-run) it only previews: it prints count and a sample, writes nothing, and names the command that applies exactly those ${target2.plural}. With --yes it writes them in the background and waits. Fields for --set: ${target2.fields.join(", ")}${Object.keys(target2.aliases).length > 0 ? ` (${Object.entries(target2.aliases).map(([short, field]) => `${short} = ${field}`).join(", ")})` : ""}. A value of null clears the field. A ${target2.noun} that changed after the preview is left alone and counted as a conflict. Exit 5 when some records failed or conflicted.`,
8076
+ flags: {
8077
+ ids: FLAGS.ids(target2),
8078
+ filter: FLAGS.filter(target2),
8079
+ all: FLAGS.all(target2),
8080
+ "exclude-ids": FLAGS.excludeIds,
8081
+ set: { type: "string", multiple: true, description: "field=value; repeat it for more fields (up to 10)" },
8082
+ label: FLAGS.label,
8083
+ "overwrite-pinned": { type: "boolean", description: "Also replace a value a person set by hand" },
8084
+ timeout: FLAGS.timeout
8085
+ },
8086
+ examples: target2.examples,
8087
+ beta: { featureGates: { all: target2.featureGates } },
8088
+ operationIds: [`${target2.resource}.bulk-update`, "changes.get"],
8089
+ dryRun: true,
8090
+ run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-update`, (dryRun2) => requestBody(flags, target2, dryRun2))
8091
+ };
8092
+ }
8093
+ function bulkDeleteCommand(target2) {
8094
+ const command65 = `kenso ${target2.resource} bulk-delete`;
8095
+ return {
8096
+ resource: target2.resource,
8097
+ action: "bulk-delete",
8098
+ summary: `Delete many ${target2.plural} at once: by --ids, or everything a --filter matches`,
8099
+ brief: "--filter --yes",
8100
+ description: `Calls POST /v1/${target2.resource}/bulk-delete, which makes a change set that lists every ${target2.noun} it would delete. Without --yes (or with --dry-run) it only previews: it prints count and a sample, deletes nothing, and names the command that deletes exactly those ${target2.plural}. With --yes it deletes them in the background and waits. Each ${target2.noun} is deleted as kenso ${target2.resource} delete deletes it, so one that cannot be deleted is counted as failed and the rest go on. A delete is not undone with kenso changes undo. Exit 5 when some records failed.`,
8101
+ flags: {
8102
+ ids: FLAGS.ids(target2),
8103
+ filter: FLAGS.filter(target2),
8104
+ all: FLAGS.all(target2),
8105
+ "exclude-ids": FLAGS.excludeIds,
8106
+ label: FLAGS.label,
8107
+ timeout: FLAGS.timeout
8108
+ },
8109
+ examples: target2.examples,
8110
+ beta: { featureGates: { all: target2.featureGates } },
8111
+ operationIds: [`${target2.resource}.bulk-delete`, "changes.get"],
8112
+ dryRun: true,
8113
+ run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command65), dryRun: dryRun2 }))
8114
+ };
8115
+ }
8116
+ async function runChange(ctx, flags, path, body2) {
8117
+ const dryRun2 = ctx.flags.yes !== true || ctx.flags.dryRun === true;
8118
+ const timeoutText = stringFlag2(flags, "timeout") ?? "10m";
8119
+ const timeoutMs2 = parseDuration(timeoutText);
8120
+ if (timeoutMs2 === void 0) throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
8121
+ const res = await ctx.client.request({ method: "POST", path, body: body2(dryRun2), signal: ctx.signal });
8122
+ const change = await waitForChange(ctx, unwrap(res.body), timeoutMs2);
8123
+ if (change.status === "previewed") {
8124
+ ctx.output.object({ ...change, next: sameCommand2("kenso changes apply", { "change-id": String(change.id) }, ctx) });
8125
+ return ExitCode.Ok;
8126
+ }
8127
+ ctx.output.object(change);
8128
+ if (change.status !== "done") {
8129
+ throw new KensoError({ code: `change_${change.status}`, message: change.error || `Change ${change.id} ended ${change.status}.`, exitCode: ExitCode.Error });
8130
+ }
8131
+ return (change.counts?.failed ?? 0) + (change.counts?.conflict ?? 0) > 0 ? ExitCode.Partial : ExitCode.Ok;
8132
+ }
8133
+ var POLL_MS, MAX_IDS, WORKING, FLAGS;
8134
+ var init_bulk_update = __esm({
8135
+ "src/commands/changes/bulk-update.ts"() {
8136
+ "use strict";
8137
+ init_errors();
8138
+ init_exit_codes();
8139
+ init_http();
8140
+ init_common();
8141
+ init_wait();
8142
+ POLL_MS = 2e3;
8143
+ MAX_IDS = 1e3;
8144
+ WORKING = /* @__PURE__ */ new Set(["resolving", "running"]);
8145
+ FLAGS = {
8146
+ ids: (target2) => ({ type: "string", description: `${target2.noun} ids, comma-separated (up to 1,000)` }),
8147
+ filter: (target2) => ({ type: "string", description: `The search body as JSON, as kenso ${target2.resource} search --data takes it (filters, where, q): everything it matches` }),
8148
+ all: (target2) => ({ type: "boolean", description: `Every ${target2.noun} in the workspace` }),
8149
+ excludeIds: { type: "string", description: "Ids to leave out of --filter or --all, comma-separated (up to 1,000)" },
8150
+ label: { type: "string", description: "A name for the change in kenso changes list" },
8151
+ timeout: { type: "string", default: "10m", description: "How long to wait for the change: 90s, 10m, 1h (default 10m)" }
8152
+ };
8153
+ }
8154
+ });
8155
+
8156
+ // src/commands/accounts/bulk-update.ts
8157
+ var bulk_update_exports = {};
8158
+ __export(bulk_update_exports, {
8159
+ default: () => bulk_update_default
8160
+ });
8161
+ var bulk_update_default;
8162
+ var init_bulk_update2 = __esm({
8163
+ "src/commands/accounts/bulk-update.ts"() {
8164
+ "use strict";
8165
+ init_bulk_update();
8166
+ bulk_update_default = bulkUpdateCommand({
8167
+ resource: "accounts",
8168
+ noun: "account",
8169
+ plural: "accounts",
8170
+ aliases: { owner: "ownerMemberId", tier: "tierOverride" },
8171
+ fields: ["ownerMemberId", "stage", "tierOverride", "industry", "fundingRound", "employeeCount", "hqLocation", "cadenceDays"],
8172
+ featureGates: ["accounts", "bulk_edit"],
8173
+ examples: [
8174
+ `kenso accounts bulk-update --filter '{"filters":[{"field":"stage","operator":"is","values":["new"]}]}' --set owner=42 --dry-run`,
8175
+ "kenso accounts bulk-update --ids 812,813 --set stage=engaged --set tier=2 --yes",
8176
+ "kenso changes apply --change-id 31"
8177
+ ]
8178
+ });
8179
+ }
8180
+ });
8181
+
8182
+ // src/commands/accounts/bulk-delete.ts
8183
+ var bulk_delete_exports = {};
8184
+ __export(bulk_delete_exports, {
8185
+ default: () => bulk_delete_default
8186
+ });
8187
+ var bulk_delete_default;
8188
+ var init_bulk_delete = __esm({
8189
+ "src/commands/accounts/bulk-delete.ts"() {
8190
+ "use strict";
8191
+ init_bulk_update();
8192
+ bulk_delete_default = bulkDeleteCommand({
8193
+ resource: "accounts",
8194
+ noun: "account",
8195
+ plural: "accounts",
8196
+ featureGates: ["accounts", "bulk_edit"],
8197
+ examples: [
8198
+ `kenso accounts bulk-delete --filter '{"filters":[{"field":"stage","operator":"is","values":["not_a_fit"]}]}' --dry-run`,
8199
+ "kenso accounts bulk-delete --ids 812,813 --yes",
8200
+ "kenso changes apply --change-id 31"
8201
+ ]
8202
+ });
8203
+ }
8204
+ });
8205
+
7747
8206
  // src/commands/accounts/index.ts
7748
8207
  var actions;
7749
8208
  var init_accounts = __esm({
7750
8209
  "src/commands/accounts/index.ts"() {
7751
8210
  "use strict";
7752
8211
  actions = {
7753
- import: () => Promise.resolve().then(() => (init_import(), import_exports)).then((m) => m.default)
8212
+ import: () => Promise.resolve().then(() => (init_import(), import_exports)).then((m) => m.default),
8213
+ // Replaces the generated accounts bulk-update: its body's dryRun would collide with the global --dry-run (DEV-11162).
8214
+ "bulk-update": () => Promise.resolve().then(() => (init_bulk_update2(), bulk_update_exports)).then((m) => m.default),
8215
+ "bulk-delete": () => Promise.resolve().then(() => (init_bulk_delete(), bulk_delete_exports)).then((m) => m.default)
7754
8216
  };
7755
8217
  }
7756
8218
  });
@@ -7791,7 +8253,7 @@ var init_connect = __esm({
7791
8253
  var crm_default;
7792
8254
  var init_crm = __esm({
7793
8255
  "docs/crm.md"() {
7794
- 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| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\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> [--reason <key>]` | Move a deal, 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| `deleted-accounts list`, `accounts restore <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved Accounts view, 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, and each body you may open. The id is `capturedThread.id` on a timeline row |\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| `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\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# 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 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\nApart from `accounts bulk-update`, which sets one `accountType` on up to 500 accounts, there is no bulk edit route, so 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## 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`, `closeDate` (`past_due`, `next_30_days`, `later`, `none`) and `sourceCampaignId`. `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\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- **`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## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore 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 <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. 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## 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 --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 Accounts view (`kenso account-views list` shows the ids). `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields, so a deals or people view exports with its filters and sort. 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## 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## Required fields per stage\n\n```bash\nkenso pipelines stage-rules\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. 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## 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; `--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. `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';
8256
+ 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| `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> [--reason <key>]` | Move a deal, 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 <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved Accounts view, 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, and each body you may open. The id is `capturedThread.id` on a timeline row |\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| `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\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# 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 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` (up to 1,000), everything a `--filter` matches (the body `kenso accounts search --data` takes: `filters`, `where`, `q`; up to 50,000), or `--all`. `--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`; a value of `null` clears the field. 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`, `q`):\n\n```bash\nkenso opportunities bulk-update --filter \'{"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`, `closeDate` (`past_due`, `next_30_days`, `later`, `none`) and `sourceCampaignId`. `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\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- **`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## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore 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 <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. 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## 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 --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 Accounts view (`kenso account-views list` shows the ids). `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields, so a deals or people view exports with its filters and sort. 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## 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 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 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. 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## 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; `--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. `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';
7795
8257
  }
7796
8258
  });
7797
8259
 
@@ -7942,7 +8404,7 @@ var init_content = __esm({
7942
8404
  });
7943
8405
 
7944
8406
  // src/commands/mcp/client.ts
7945
- function isRecord4(value) {
8407
+ function isRecord5(value) {
7946
8408
  return value !== null && typeof value === "object" && !Array.isArray(value);
7947
8409
  }
7948
8410
  function parseJson(text4) {
@@ -7958,10 +8420,10 @@ function eventData(event) {
7958
8420
  return lines.map((line) => line.slice(5).replace(/^ /, "")).join("\n");
7959
8421
  }
7960
8422
  function asMessages(value) {
7961
- if (Array.isArray(value)) return value.filter(isRecord4);
7962
- return isRecord4(value) ? [value] : [];
8423
+ if (Array.isArray(value)) return value.filter(isRecord5);
8424
+ return isRecord5(value) ? [value] : [];
7963
8425
  }
7964
- function interrupted2() {
8426
+ function interrupted3() {
7965
8427
  return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
7966
8428
  }
7967
8429
  var DEFAULT_MCP_URL, MCP_PROTOCOL_VERSION, REQUEST_TIMEOUT_MS2, McpClient;
@@ -7993,7 +8455,7 @@ var init_client = __esm({
7993
8455
  capabilities: {},
7994
8456
  clientInfo: { name: "kenso-cli", version: this.opts.version }
7995
8457
  });
7996
- const negotiated = isRecord4(result) && typeof result.protocolVersion === "string" ? result.protocolVersion : MCP_PROTOCOL_VERSION;
8458
+ const negotiated = isRecord5(result) && typeof result.protocolVersion === "string" ? result.protocolVersion : MCP_PROTOCOL_VERSION;
7997
8459
  this.protocolVersion = negotiated;
7998
8460
  await this.notify("notifications/initialized");
7999
8461
  this.initialized = true;
@@ -8006,9 +8468,9 @@ var init_client = __esm({
8006
8468
  let cursor2;
8007
8469
  for (; ; ) {
8008
8470
  const result = await this.rpc("tools/list", cursor2 === void 0 ? {} : { cursor: cursor2 });
8009
- const page = isRecord4(result) && Array.isArray(result.tools) ? result.tools : [];
8010
- for (const tool of page) if (isRecord4(tool) && typeof tool.name === "string") tools.push(tool);
8011
- const next = isRecord4(result) ? result.nextCursor : void 0;
8471
+ const page = isRecord5(result) && Array.isArray(result.tools) ? result.tools : [];
8472
+ for (const tool of page) if (isRecord5(tool) && typeof tool.name === "string") tools.push(tool);
8473
+ const next = isRecord5(result) ? result.nextCursor : void 0;
8012
8474
  if (typeof next !== "string" || next === "" || seen.has(next)) return tools;
8013
8475
  seen.add(next);
8014
8476
  cursor2 = next;
@@ -8017,7 +8479,7 @@ var init_client = __esm({
8017
8479
  async callTool(name, args) {
8018
8480
  await this.initialize();
8019
8481
  const result = await this.rpc("tools/call", { name, arguments: args });
8020
- return isRecord4(result) ? result : {};
8482
+ return isRecord5(result) ? result : {};
8021
8483
  }
8022
8484
  headers() {
8023
8485
  const { agent, apiKey, version, workspaceId } = this.opts;
@@ -8035,7 +8497,7 @@ var init_client = __esm({
8035
8497
  }
8036
8498
  async post(method, message) {
8037
8499
  const callerSignal = this.opts.signal;
8038
- if (callerSignal?.aborted) throw interrupted2();
8500
+ if (callerSignal?.aborted) throw interrupted3();
8039
8501
  const timeout = AbortSignal.timeout(REQUEST_TIMEOUT_MS2);
8040
8502
  const signal = callerSignal ? AbortSignal.any([callerSignal, timeout]) : timeout;
8041
8503
  const started = Date.now();
@@ -8044,7 +8506,7 @@ var init_client = __esm({
8044
8506
  this.opts.onResponse?.({ method, status: res.status, ms: Date.now() - started });
8045
8507
  return res;
8046
8508
  } catch (err) {
8047
- if (callerSignal?.aborted) throw interrupted2();
8509
+ if (callerSignal?.aborted) throw interrupted3();
8048
8510
  const reason = err instanceof Error ? err.name === "TimeoutError" ? `no answer within ${REQUEST_TIMEOUT_MS2 / 1e3} s` : err.message : String(err);
8049
8511
  this.opts.onResponse?.({ method, ms: Date.now() - started, error: reason });
8050
8512
  throw new KensoError({
@@ -8111,7 +8573,7 @@ var init_client = __esm({
8111
8573
  if (done2) return buffer.trim() === "" ? void 0 : take(buffer);
8112
8574
  }
8113
8575
  } catch (err) {
8114
- if (this.opts.signal?.aborted) throw interrupted2();
8576
+ if (this.opts.signal?.aborted) throw interrupted3();
8115
8577
  throw err;
8116
8578
  } finally {
8117
8579
  reader.cancel().catch(() => {
@@ -8176,7 +8638,7 @@ __export(install_exports, {
8176
8638
  write: () => write
8177
8639
  });
8178
8640
  import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
8179
- import { basename as basename2, dirname, join as join8, resolve as resolve5 } from "node:path";
8641
+ import { basename as basename2, dirname, join as join8, resolve as resolve6 } from "node:path";
8180
8642
  function quote(value) {
8181
8643
  return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
8182
8644
  }
@@ -8201,7 +8663,7 @@ function write(path, text4) {
8201
8663
  }
8202
8664
  }
8203
8665
  function folders(ctx, client, dir) {
8204
- if (dir !== void 0) return [{ client, folder: resolve5(dir) }];
8666
+ if (dir !== void 0) return [{ client, folder: resolve6(dir) }];
8205
8667
  const clients = client === "all" ? CLIENTS : [client];
8206
8668
  return clients.map((c) => ({ client: c, folder: join8(skillsFolder(c, ctx.env), SKILL_NAME) }));
8207
8669
  }
@@ -8212,7 +8674,7 @@ function installCommand(opts) {
8212
8674
  if (opts.force) parts2.push("--force");
8213
8675
  return parts2.join(" ");
8214
8676
  }
8215
- var SKILL_NAME, AGENT_CLIENTS2, command2, install_default;
8677
+ var SKILL_NAME, AGENT_CLIENTS2, command3, install_default;
8216
8678
  var init_install = __esm({
8217
8679
  "src/commands/skill/install.ts"() {
8218
8680
  "use strict";
@@ -8222,7 +8684,7 @@ var init_install = __esm({
8222
8684
  init_clients();
8223
8685
  SKILL_NAME = "kenso-cli";
8224
8686
  AGENT_CLIENTS2 = { "Claude Code": "claude-code", Codex: "codex", Cursor: "cursor" };
8225
- command2 = {
8687
+ command3 = {
8226
8688
  resource: "skill",
8227
8689
  action: "install",
8228
8690
  summary: "Install the kenso-cli skill for Claude Code, Codex, Cursor, Gemini CLI or OpenCode",
@@ -8266,17 +8728,17 @@ var init_install = __esm({
8266
8728
  next
8267
8729
  });
8268
8730
  }
8269
- for (const target of targets) {
8270
- if (target.status !== "unchanged") write(target.path, text4);
8731
+ for (const target2 of targets) {
8732
+ if (target2.status !== "unchanged") write(target2.path, text4);
8271
8733
  }
8272
- if (dir !== void 0 && basename2(resolve5(dir)) !== SKILL_NAME) {
8273
- ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve5(dir)} is not.`);
8734
+ if (dir !== void 0 && basename2(resolve6(dir)) !== SKILL_NAME) {
8735
+ ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve6(dir)} is not.`);
8274
8736
  }
8275
8737
  ctx.output.object({ installed: targets });
8276
8738
  return ExitCode.Ok;
8277
8739
  }
8278
8740
  };
8279
- install_default = command2;
8741
+ install_default = command3;
8280
8742
  }
8281
8743
  });
8282
8744
 
@@ -8511,7 +8973,7 @@ function pickClients(ctx, clientFlag, status) {
8511
8973
  next: "kenso agent setup --client claude-code"
8512
8974
  });
8513
8975
  }
8514
- var command3, setup_default;
8976
+ var command4, setup_default;
8515
8977
  var init_setup = __esm({
8516
8978
  "src/commands/agent/setup.ts"() {
8517
8979
  "use strict";
@@ -8522,7 +8984,7 @@ var init_setup = __esm({
8522
8984
  init_clients();
8523
8985
  init_install();
8524
8986
  init_mcp_config();
8525
- command3 = {
8987
+ command4 = {
8526
8988
  resource: "agent",
8527
8989
  action: "setup",
8528
8990
  summary: "Set up a coding agent for Kenso: the kenso-cli skill and the Kenso MCP server",
@@ -8594,7 +9056,7 @@ var init_setup = __esm({
8594
9056
  return ok ? ExitCode.Ok : ExitCode.Error;
8595
9057
  }
8596
9058
  };
8597
- setup_default = command3;
9059
+ setup_default = command4;
8598
9060
  }
8599
9061
  });
8600
9062
 
@@ -8650,7 +9112,7 @@ function multipartBody(files, data) {
8650
9112
  }
8651
9113
  return form;
8652
9114
  }
8653
- var METHODS, DEFAULT_FILE_FIELD, command4, actions3;
9115
+ var METHODS, DEFAULT_FILE_FIELD, command5, actions3;
8654
9116
  var init_api3 = __esm({
8655
9117
  "src/commands/api/index.ts"() {
8656
9118
  "use strict";
@@ -8661,7 +9123,7 @@ var init_api3 = __esm({
8661
9123
  init_transfer();
8662
9124
  METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
8663
9125
  DEFAULT_FILE_FIELD = "file";
8664
- command4 = {
9126
+ command5 = {
8665
9127
  resource: "api",
8666
9128
  action: "",
8667
9129
  summary: "Call any API route, only when no command fits",
@@ -8734,7 +9196,7 @@ var init_api3 = __esm({
8734
9196
  }
8735
9197
  };
8736
9198
  actions3 = {
8737
- "": async () => command4
9199
+ "": async () => command5
8738
9200
  };
8739
9201
  }
8740
9202
  });
@@ -8786,8 +9248,8 @@ var init_browser = __esm({
8786
9248
  // src/commands/auth/browser-login.ts
8787
9249
  import { spawn as nodeSpawn } from "node:child_process";
8788
9250
  import { hostname as osHostname } from "node:os";
8789
- import { setTimeout as delay2 } from "node:timers/promises";
8790
- function interrupted3() {
9251
+ import { setTimeout as delay4 } from "node:timers/promises";
9252
+ function interrupted4() {
8791
9253
  return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
8792
9254
  }
8793
9255
  function expired() {
@@ -8842,14 +9304,14 @@ function parsePickedUp(body2, status) {
8842
9304
  };
8843
9305
  }
8844
9306
  async function wait(ms, ctx, deps) {
8845
- if (ctx.signal.aborted) throw interrupted3();
9307
+ if (ctx.signal.aborted) throw interrupted4();
8846
9308
  try {
8847
9309
  await deps.sleep(ms, ctx.signal);
8848
9310
  } catch (err) {
8849
- if (ctx.signal.aborted) throw interrupted3();
9311
+ if (ctx.signal.aborted) throw interrupted4();
8850
9312
  throw err;
8851
9313
  }
8852
- if (ctx.signal.aborted) throw interrupted3();
9314
+ if (ctx.signal.aborted) throw interrupted4();
8853
9315
  }
8854
9316
  async function browserLogin(ctx, opts, overrides) {
8855
9317
  const deps = { ...defaultDeps, ...overrides };
@@ -8981,10 +9443,10 @@ var init_browser_login = __esm({
8981
9443
  RETRY_LOGIN = "kenso auth login";
8982
9444
  WITH_KEY = "kenso auth login --with-key";
8983
9445
  defaultDeps = {
8984
- sleep: (ms, signal) => delay2(ms, void 0, signal ? { signal } : void 0),
9446
+ sleep: (ms, signal) => delay4(ms, void 0, signal ? { signal } : void 0),
8985
9447
  now: () => Date.now(),
8986
- spawn: (command61, args) => {
8987
- const child = nodeSpawn(command61, args, { detached: true, stdio: "ignore" });
9448
+ spawn: (command65, args) => {
9449
+ const child = nodeSpawn(command65, args, { detached: true, stdio: "ignore" });
8988
9450
  child.on("error", () => {
8989
9451
  });
8990
9452
  child.unref();
@@ -9033,7 +9495,7 @@ function invalidKey(message) {
9033
9495
  next: PIPE_EXAMPLE
9034
9496
  });
9035
9497
  }
9036
- var MAX_KEY_INPUT_BYTES, PIPE_EXAMPLE, command5, login_default;
9498
+ var MAX_KEY_INPUT_BYTES, PIPE_EXAMPLE, command6, login_default;
9037
9499
  var init_login = __esm({
9038
9500
  "src/commands/auth/login.ts"() {
9039
9501
  "use strict";
@@ -9046,7 +9508,7 @@ var init_login = __esm({
9046
9508
  init_browser_login();
9047
9509
  MAX_KEY_INPUT_BYTES = 4096;
9048
9510
  PIPE_EXAMPLE = `printf '%s' "$KENSO_API_KEY" | kenso auth login --with-key`;
9049
- command5 = {
9511
+ command6 = {
9050
9512
  resource: "auth",
9051
9513
  action: "login",
9052
9514
  summary: "Log in through the browser, or save an API key from stdin with --with-key",
@@ -9148,7 +9610,7 @@ var init_login = __esm({
9148
9610
  return ExitCode.Ok;
9149
9611
  }
9150
9612
  };
9151
- login_default = command5;
9613
+ login_default = command6;
9152
9614
  }
9153
9615
  });
9154
9616
 
@@ -9182,7 +9644,7 @@ async function revoke(ctx, apiKey, keyId, savedWorkspaceId) {
9182
9644
  return false;
9183
9645
  }
9184
9646
  }
9185
- var command6, logout_default;
9647
+ var command7, logout_default;
9186
9648
  var init_logout = __esm({
9187
9649
  "src/commands/auth/logout.ts"() {
9188
9650
  "use strict";
@@ -9190,7 +9652,7 @@ var init_logout = __esm({
9190
9652
  init_errors();
9191
9653
  init_http();
9192
9654
  init_exit_codes();
9193
- command6 = {
9655
+ command7 = {
9194
9656
  resource: "auth",
9195
9657
  action: "logout",
9196
9658
  summary: "Remove a saved profile, and revoke the key browser login made",
@@ -9212,7 +9674,7 @@ var init_logout = __esm({
9212
9674
  return ExitCode.Ok;
9213
9675
  }
9214
9676
  };
9215
- logout_default = command6;
9677
+ logout_default = command7;
9216
9678
  }
9217
9679
  });
9218
9680
 
@@ -9221,7 +9683,7 @@ var status_exports = {};
9221
9683
  __export(status_exports, {
9222
9684
  default: () => status_default
9223
9685
  });
9224
- var EXPIRY_WARNING_DAYS, DAY_MS, command7, status_default;
9686
+ var EXPIRY_WARNING_DAYS, DAY_MS, command8, status_default;
9225
9687
  var init_status = __esm({
9226
9688
  "src/commands/auth/status.ts"() {
9227
9689
  "use strict";
@@ -9232,7 +9694,7 @@ var init_status = __esm({
9232
9694
  init_http();
9233
9695
  EXPIRY_WARNING_DAYS = 14;
9234
9696
  DAY_MS = 24 * 60 * 60 * 1e3;
9235
- command7 = {
9697
+ command8 = {
9236
9698
  resource: "auth",
9237
9699
  action: "status",
9238
9700
  summary: "Show the key's user, workspace and expiry",
@@ -9309,7 +9771,7 @@ var init_status = __esm({
9309
9771
  return ExitCode.Ok;
9310
9772
  }
9311
9773
  };
9312
- status_default = command7;
9774
+ status_default = command8;
9313
9775
  }
9314
9776
  });
9315
9777
 
@@ -9331,13 +9793,13 @@ var status_exports2 = {};
9331
9793
  __export(status_exports2, {
9332
9794
  default: () => status_default2
9333
9795
  });
9334
- var command8, status_default2;
9796
+ var command9, status_default2;
9335
9797
  var init_status2 = __esm({
9336
9798
  "src/commands/capture/status.ts"() {
9337
9799
  "use strict";
9338
9800
  init_exit_codes();
9339
9801
  init_http();
9340
- command8 = {
9802
+ command9 = {
9341
9803
  resource: "capture",
9342
9804
  action: "status",
9343
9805
  summary: "Show your captured mailbox, its backfill progress and what teammates see of a captured email",
@@ -9352,7 +9814,7 @@ var init_status2 = __esm({
9352
9814
  return ExitCode.Ok;
9353
9815
  }
9354
9816
  };
9355
- status_default2 = command8;
9817
+ status_default2 = command9;
9356
9818
  }
9357
9819
  });
9358
9820
 
@@ -9361,7 +9823,7 @@ var connect_exports = {};
9361
9823
  __export(connect_exports, {
9362
9824
  default: () => connect_default2
9363
9825
  });
9364
- var PROVIDERS, command9, connect_default2;
9826
+ var PROVIDERS, command10, connect_default2;
9365
9827
  var init_connect2 = __esm({
9366
9828
  "src/commands/capture/connect.ts"() {
9367
9829
  "use strict";
@@ -9369,7 +9831,7 @@ var init_connect2 = __esm({
9369
9831
  init_exit_codes();
9370
9832
  init_http();
9371
9833
  PROVIDERS = ["google", "microsoft"];
9372
- command9 = {
9834
+ command10 = {
9373
9835
  resource: "capture",
9374
9836
  action: "connect",
9375
9837
  summary: "Turn capture on for your own mailbox",
@@ -9419,7 +9881,7 @@ var init_connect2 = __esm({
9419
9881
  }
9420
9882
  }
9421
9883
  };
9422
- connect_default2 = command9;
9884
+ connect_default2 = command10;
9423
9885
  }
9424
9886
  });
9425
9887
 
@@ -9435,14 +9897,14 @@ function threadId(value, from = { field: "threadId", example: "kenso capture thr
9435
9897
  }
9436
9898
  return value;
9437
9899
  }
9438
- var command10, thread_default;
9900
+ var command11, thread_default;
9439
9901
  var init_thread = __esm({
9440
9902
  "src/commands/capture/thread.ts"() {
9441
9903
  "use strict";
9442
9904
  init_errors();
9443
9905
  init_exit_codes();
9444
9906
  init_http();
9445
- command10 = {
9907
+ command11 = {
9446
9908
  resource: "capture",
9447
9909
  action: "thread",
9448
9910
  summary: "Read one captured email thread",
@@ -9458,7 +9920,7 @@ var init_thread = __esm({
9458
9920
  return ExitCode.Ok;
9459
9921
  }
9460
9922
  };
9461
- thread_default = command10;
9923
+ thread_default = command11;
9462
9924
  }
9463
9925
  });
9464
9926
 
@@ -9467,7 +9929,7 @@ var private_exports = {};
9467
9929
  __export(private_exports, {
9468
9930
  default: () => private_default
9469
9931
  });
9470
- var THREAD_FLAG, command11, private_default;
9932
+ var THREAD_FLAG, command12, private_default;
9471
9933
  var init_private = __esm({
9472
9934
  "src/commands/capture/private.ts"() {
9473
9935
  "use strict";
@@ -9476,7 +9938,7 @@ var init_private = __esm({
9476
9938
  init_http();
9477
9939
  init_thread();
9478
9940
  THREAD_FLAG = { field: "thread", example: "kenso capture private on --thread 4821" };
9479
- command11 = {
9941
+ command12 = {
9480
9942
  resource: "capture",
9481
9943
  action: "private",
9482
9944
  summary: "Hide your captured email from teammates, or show it again",
@@ -9501,7 +9963,7 @@ var init_private = __esm({
9501
9963
  return ExitCode.Ok;
9502
9964
  }
9503
9965
  };
9504
- private_default = command11;
9966
+ private_default = command12;
9505
9967
  }
9506
9968
  });
9507
9969
 
@@ -9510,13 +9972,13 @@ var sync_exports = {};
9510
9972
  __export(sync_exports, {
9511
9973
  default: () => sync_default
9512
9974
  });
9513
- var command12, sync_default;
9975
+ var command13, sync_default;
9514
9976
  var init_sync3 = __esm({
9515
9977
  "src/commands/capture/sync.ts"() {
9516
9978
  "use strict";
9517
9979
  init_exit_codes();
9518
9980
  init_http();
9519
- command12 = {
9981
+ command13 = {
9520
9982
  resource: "capture",
9521
9983
  action: "sync",
9522
9984
  summary: "Read your captured mailbox now",
@@ -9531,7 +9993,7 @@ var init_sync3 = __esm({
9531
9993
  return ExitCode.Ok;
9532
9994
  }
9533
9995
  };
9534
- sync_default = command12;
9996
+ sync_default = command13;
9535
9997
  }
9536
9998
  });
9537
9999
 
@@ -9540,13 +10002,13 @@ var disconnect_exports = {};
9540
10002
  __export(disconnect_exports, {
9541
10003
  default: () => disconnect_default
9542
10004
  });
9543
- var command13, disconnect_default;
10005
+ var command14, disconnect_default;
9544
10006
  var init_disconnect = __esm({
9545
10007
  "src/commands/capture/disconnect.ts"() {
9546
10008
  "use strict";
9547
10009
  init_confirm();
9548
10010
  init_exit_codes();
9549
- command13 = {
10011
+ command14 = {
9550
10012
  resource: "capture",
9551
10013
  action: "disconnect",
9552
10014
  summary: "Turn capture off for your own mailbox and delete its stored email bodies",
@@ -9562,7 +10024,7 @@ var init_disconnect = __esm({
9562
10024
  return ExitCode.Ok;
9563
10025
  }
9564
10026
  };
9565
- disconnect_default = command13;
10027
+ disconnect_default = command14;
9566
10028
  }
9567
10029
  });
9568
10030
 
@@ -9571,7 +10033,7 @@ var teammates_see_exports = {};
9571
10033
  __export(teammates_see_exports, {
9572
10034
  default: () => teammates_see_default
9573
10035
  });
9574
- var VALUES, command14, teammates_see_default;
10036
+ var VALUES, command15, teammates_see_default;
9575
10037
  var init_teammates_see = __esm({
9576
10038
  "src/commands/capture/teammates-see.ts"() {
9577
10039
  "use strict";
@@ -9579,7 +10041,7 @@ var init_teammates_see = __esm({
9579
10041
  init_exit_codes();
9580
10042
  init_http();
9581
10043
  VALUES = ["summary", "full_email"];
9582
- command14 = {
10044
+ command15 = {
9583
10045
  resource: "capture",
9584
10046
  action: "teammates-see",
9585
10047
  summary: "Pick what teammates see of captured email: the summary, or the full email (workspace admin)",
@@ -9599,7 +10061,7 @@ var init_teammates_see = __esm({
9599
10061
  return ExitCode.Ok;
9600
10062
  }
9601
10063
  };
9602
- teammates_see_default = command14;
10064
+ teammates_see_default = command15;
9603
10065
  }
9604
10066
  });
9605
10067
 
@@ -9626,7 +10088,7 @@ __export(completion_exports, {
9626
10088
  SCRIPTS: () => SCRIPTS,
9627
10089
  default: () => completion_default
9628
10090
  });
9629
- var ZSH, BASH, FISH, SCRIPTS, command15, completion_default;
10091
+ var ZSH, BASH, FISH, SCRIPTS, command16, completion_default;
9630
10092
  var init_completion = __esm({
9631
10093
  "src/commands/completion/completion.ts"() {
9632
10094
  "use strict";
@@ -9690,7 +10152,7 @@ end
9690
10152
  complete -c kenso -f -a '(__kenso_complete)'
9691
10153
  `;
9692
10154
  SCRIPTS = { bash: BASH, zsh: ZSH, fish: FISH };
9693
- command15 = {
10155
+ command16 = {
9694
10156
  resource: "completion",
9695
10157
  action: "",
9696
10158
  summary: "Print the tab-completion script for bash, zsh or fish",
@@ -9718,7 +10180,7 @@ complete -c kenso -f -a '(__kenso_complete)'
9718
10180
  return ExitCode.Ok;
9719
10181
  }
9720
10182
  };
9721
- completion_default = command15;
10183
+ completion_default = command16;
9722
10184
  }
9723
10185
  });
9724
10186
 
@@ -10024,11 +10486,11 @@ __export(run_exports, {
10024
10486
  runConnect: () => runConnect
10025
10487
  });
10026
10488
  import { spawn as nodeSpawn2 } from "node:child_process";
10027
- import { setTimeout as delay3 } from "node:timers/promises";
10028
- function interrupted4() {
10489
+ import { setTimeout as delay5 } from "node:timers/promises";
10490
+ function interrupted5() {
10029
10491
  return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
10030
10492
  }
10031
- function isRecord5(value) {
10493
+ function isRecord6(value) {
10032
10494
  return value !== null && typeof value === "object" && !Array.isArray(value);
10033
10495
  }
10034
10496
  function keyText(value) {
@@ -10065,12 +10527,12 @@ async function read(ctx, kind, flags, rowId) {
10065
10527
  if (rowId !== void 0) {
10066
10528
  const res = await ctx.client.request({ method: "GET", path: kind.watch.path.replace("{id}", encodeURIComponent(rowId)), signal: ctx.signal });
10067
10529
  const row = unwrap(res.body);
10068
- return isRecord5(row) ? [row] : [];
10530
+ return isRecord6(row) ? [row] : [];
10069
10531
  }
10070
10532
  const items = [];
10071
10533
  const page = kind.watch.pageSize !== void 0 ? { pageSize: kind.watch.pageSize } : void 0;
10072
10534
  for await (const item of ctx.client.paginate({ method: "GET", path: kind.watch.path, signal: ctx.signal }, page)) {
10073
- if (isRecord5(item) && (!kind.watch.filter || kind.watch.filter(item, flags))) items.push(item);
10535
+ if (isRecord6(item) && (!kind.watch.filter || kind.watch.filter(item, flags))) items.push(item);
10074
10536
  }
10075
10537
  return items;
10076
10538
  }
@@ -10106,14 +10568,14 @@ function transient(err) {
10106
10568
  return err.code === "network_error" || err.httpStatus !== void 0 && err.httpStatus >= 500;
10107
10569
  }
10108
10570
  async function wait2(ms, ctx, deps) {
10109
- if (ctx.signal.aborted) throw interrupted4();
10571
+ if (ctx.signal.aborted) throw interrupted5();
10110
10572
  try {
10111
10573
  await deps.sleep(ms, ctx.signal);
10112
10574
  } catch (err) {
10113
- if (ctx.signal.aborted) throw interrupted4();
10575
+ if (ctx.signal.aborted) throw interrupted5();
10114
10576
  throw err;
10115
10577
  }
10116
- if (ctx.signal.aborted) throw interrupted4();
10578
+ if (ctx.signal.aborted) throw interrupted5();
10117
10579
  }
10118
10580
  async function watch(ctx, kind, flags, rowId, baseline, limitMs, deps) {
10119
10581
  const deadline = deps.now() + limitMs;
@@ -10135,7 +10597,7 @@ async function watch(ctx, kind, flags, rowId, baseline, limitMs, deps) {
10135
10597
  });
10136
10598
  }
10137
10599
  } catch (err) {
10138
- if (ctx.signal.aborted) throw interrupted4();
10600
+ if (ctx.signal.aborted) throw interrupted5();
10139
10601
  if (!transient(err) || ++failures >= MAX_POLL_FAILURES) throw err;
10140
10602
  ctx.output.warn(`Checking the connection failed (${err.message}); trying again.`);
10141
10603
  }
@@ -10190,7 +10652,7 @@ async function runConnect(ctx, kind, flags, overrides) {
10190
10652
  if (start) {
10191
10653
  const res = await ctx.client.request({ ...start, signal: ctx.signal });
10192
10654
  const data = unwrap(res.body);
10193
- answer = isRecord5(data) ? data : {};
10655
+ answer = isRecord6(data) ? data : {};
10194
10656
  link = linkOf(answer);
10195
10657
  if (!link) {
10196
10658
  if (keyText(answer[kind.watch.key]) !== void 0) {
@@ -10225,155 +10687,58 @@ function connectCommand(kind) {
10225
10687
  summary: kind.summary,
10226
10688
  description: `${kind.description}
10227
10689
 
10228
- The connect finishes in a browser: Kenso refuses to complete a sign-in for an API key or an agent, so the person you work for opens the link. It prints the link on stderr (and opens it at a desktop when no coding agent runs it), checks every ${POLL_INTERVAL_MS / 1e3} s, and prints {connected, kind, connection} on stdout once the connection shows up. --no-wait prints the start answer, link included, and ends.`,
10229
- flags: { ...kind.flags, ...COMMON_FLAGS },
10230
- examples: [...kind.examples, `${kind.examples[0] ?? `kenso connect ${kind.name}`} --no-wait`],
10231
- operationIds: kind.operationIds,
10232
- dryRun: true,
10233
- run: (ctx, args) => runConnect(ctx, kind, args.flags)
10234
- };
10235
- }
10236
- var POLL_INTERVAL_MS, DEFAULT_TIMEOUT_SECONDS, MAX_POLL_FAILURES, LINK_FIELDS, defaultDeps2, COMMON_FLAGS;
10237
- var init_run = __esm({
10238
- "src/commands/connect/run.ts"() {
10239
- "use strict";
10240
- init_browser();
10241
- init_errors();
10242
- init_exit_codes();
10243
- init_http();
10244
- POLL_INTERVAL_MS = 5e3;
10245
- DEFAULT_TIMEOUT_SECONDS = 600;
10246
- MAX_POLL_FAILURES = 5;
10247
- LINK_FIELDS = ["authorizationUrl", "authorizeUrl", "installUrl", "url"];
10248
- defaultDeps2 = {
10249
- sleep: (ms, signal) => delay3(ms, void 0, signal ? { signal } : void 0),
10250
- now: () => Date.now(),
10251
- spawn: (command61, args) => {
10252
- const child = nodeSpawn2(command61, args, { detached: true, stdio: "ignore" });
10253
- child.on("error", () => {
10254
- });
10255
- child.unref();
10256
- },
10257
- platform: process.platform
10258
- };
10259
- COMMON_FLAGS = {
10260
- timeout: { type: "string", description: `Seconds to wait for the connection (default ${DEFAULT_TIMEOUT_SECONDS})` },
10261
- "no-wait": { type: "boolean", description: "Print the link as JSON and end, without waiting for the connection" },
10262
- "no-browser": { type: "boolean", description: "Print the link only; never open a browser" }
10263
- };
10264
- }
10265
- });
10266
-
10267
- // src/commands/connect/index.ts
10268
- var KIND_NAMES, load, actions7;
10269
- var init_connect3 = __esm({
10270
- "src/commands/connect/index.ts"() {
10271
- "use strict";
10272
- KIND_NAMES = ["inbox", "calendar", "video", "crm", "hubspot-knowledge", "github", "migration", "linkedin", "whatsapp", "facebook", "instagram"];
10273
- load = (name) => async () => {
10274
- const [{ KINDS: KINDS2 }, { connectCommand: connectCommand2 }] = await Promise.all([Promise.resolve().then(() => (init_kinds(), kinds_exports)), Promise.resolve().then(() => (init_run(), run_exports))]);
10275
- const kind = KINDS2.find((k) => k.name === name);
10276
- if (!kind) throw new Error(`no connect kind ${name}`);
10277
- return connectCommand2(kind);
10278
- };
10279
- actions7 = Object.fromEntries(KIND_NAMES.map((name) => [name, load(name)]));
10280
- }
10281
- });
10282
-
10283
- // src/commands/contacts/common.ts
10284
- import { createHash as createHash3 } from "node:crypto";
10285
- import { readFile as readFile6 } from "node:fs/promises";
10286
- import { resolve as resolve6 } from "node:path";
10287
- function stringFlag2(flags, name) {
10288
- const value = flags[name];
10289
- if (typeof value !== "string") return void 0;
10290
- const text4 = value.trim();
10291
- return text4 === "" ? void 0 : text4;
10292
- }
10293
- function requireFlag(flags, name, command61, hint) {
10294
- const value = stringFlag2(flags, name);
10295
- if (value === void 0) throw usageError(`--${name} is required for ${command61}.`, { field: name, next: `${command61} --help`, ...hint ? { hint } : {} });
10296
- return value;
10297
- }
10298
- function positiveId(value) {
10299
- const text4 = value.trim();
10300
- if (!/^[0-9]+$/.test(text4)) return void 0;
10301
- const id = Number(text4);
10302
- return Number.isSafeInteger(id) && id > 0 ? id : void 0;
10303
- }
10304
- function idFlag(flags, name, command61) {
10305
- const raw = requireFlag(flags, name, command61);
10306
- const id = positiveId(raw);
10307
- if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
10308
- return id;
10309
- }
10310
- function concurrency(flags) {
10311
- const raw = stringFlag2(flags, "concurrency");
10312
- if (raw === void 0) return void 0;
10313
- const value = Number(raw);
10314
- if (!Number.isInteger(value) || value < 1 || value > 16) {
10315
- throw usageError(`--concurrency must be a whole number from 1 to 16 (got "${raw}").`, { field: "concurrency" });
10316
- }
10317
- return value;
10318
- }
10319
- function isDryRun(ctx) {
10320
- return ctx.flags.yes !== true;
10321
- }
10322
- function shellQuote4(value) {
10323
- return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
10324
- }
10325
- function sameCommand2(command61, flags, ctx, extra = []) {
10326
- const parts2 = [command61];
10327
- for (const [name, value] of Object.entries(flags)) {
10328
- if (value === void 0 || value === false) continue;
10329
- if (value === true) parts2.push(`--${name}`);
10330
- else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${name}`, shellQuote4(item));
10331
- }
10332
- for (const name of ["profile", "workspace"]) {
10333
- const value = ctx.flags[name];
10334
- if (value !== void 0) parts2.push(`--${name}`, shellQuote4(value));
10335
- }
10336
- parts2.push(...extra);
10337
- return parts2.join(" ");
10338
- }
10339
- async function fileSha256(path) {
10340
- return createHash3("sha256").update(await readFile6(resolve6(path))).digest("hex");
10341
- }
10342
- function rateLimitRemaining3(headers) {
10343
- const raw = headers.get("ratelimit-remaining");
10344
- if (raw === null || raw.trim() === "") return void 0;
10345
- const value = Number(raw);
10346
- return Number.isFinite(value) ? value : void 0;
10347
- }
10348
- function rethrowIfRunStopping(err) {
10349
- if (!(err instanceof KensoError)) return;
10350
- if (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.RateLimited || err.exitCode === ExitCode.Interrupted) throw err;
10351
- }
10352
- function failedRow(row, err, extra = {}) {
10353
- const reason = err instanceof KensoError ? err.code : "failed";
10354
- const error = err instanceof Error ? err.message : String(err);
10355
- return { row, status: "failed", reason, error, ...extra };
10356
- }
10357
- function invalidRow(row, reason, error, extra = {}) {
10358
- return { row, status: "invalid", reason, ...error ? { error } : {}, ...extra };
10359
- }
10360
- function isRecord6(value) {
10361
- return value !== null && typeof value === "object" && !Array.isArray(value);
10362
- }
10363
- function warnDropped(ctx, mapping) {
10364
- const dropped = Object.entries(mapping.dropped).filter(([, reason]) => reason !== "mapped_to_null");
10365
- if (dropped.length === 0) return;
10366
- const list2 = dropped.map(([header, reason]) => `"${header}" (${reason})`).join(", ");
10367
- ctx.output.warn(`Not sent: ${list2}. Rename a column with --map '{"<column>": "customVariables.<name>"}'.`);
10690
+ The connect finishes in a browser: Kenso refuses to complete a sign-in for an API key or an agent, so the person you work for opens the link. It prints the link on stderr (and opens it at a desktop when no coding agent runs it), checks every ${POLL_INTERVAL_MS / 1e3} s, and prints {connected, kind, connection} on stdout once the connection shows up. --no-wait prints the start answer, link included, and ends.`,
10691
+ flags: { ...kind.flags, ...COMMON_FLAGS },
10692
+ examples: [...kind.examples, `${kind.examples[0] ?? `kenso connect ${kind.name}`} --no-wait`],
10693
+ operationIds: kind.operationIds,
10694
+ dryRun: true,
10695
+ run: (ctx, args) => runConnect(ctx, kind, args.flags)
10696
+ };
10368
10697
  }
10369
- var OUT_FLAG2, CONCURRENCY_FLAG;
10370
- var init_common = __esm({
10371
- "src/commands/contacts/common.ts"() {
10698
+ var POLL_INTERVAL_MS, DEFAULT_TIMEOUT_SECONDS, MAX_POLL_FAILURES, LINK_FIELDS, defaultDeps2, COMMON_FLAGS;
10699
+ var init_run = __esm({
10700
+ "src/commands/connect/run.ts"() {
10372
10701
  "use strict";
10702
+ init_browser();
10373
10703
  init_errors();
10374
10704
  init_exit_codes();
10375
- OUT_FLAG2 = { type: "string", description: "Keep the run's files (results.csv, invalid.csv, plan.json) in this directory" };
10376
- CONCURRENCY_FLAG = { type: "string", description: "Requests in flight at once (default 4, max 16)" };
10705
+ init_http();
10706
+ POLL_INTERVAL_MS = 5e3;
10707
+ DEFAULT_TIMEOUT_SECONDS = 600;
10708
+ MAX_POLL_FAILURES = 5;
10709
+ LINK_FIELDS = ["authorizationUrl", "authorizeUrl", "installUrl", "url"];
10710
+ defaultDeps2 = {
10711
+ sleep: (ms, signal) => delay5(ms, void 0, signal ? { signal } : void 0),
10712
+ now: () => Date.now(),
10713
+ spawn: (command65, args) => {
10714
+ const child = nodeSpawn2(command65, args, { detached: true, stdio: "ignore" });
10715
+ child.on("error", () => {
10716
+ });
10717
+ child.unref();
10718
+ },
10719
+ platform: process.platform
10720
+ };
10721
+ COMMON_FLAGS = {
10722
+ timeout: { type: "string", description: `Seconds to wait for the connection (default ${DEFAULT_TIMEOUT_SECONDS})` },
10723
+ "no-wait": { type: "boolean", description: "Print the link as JSON and end, without waiting for the connection" },
10724
+ "no-browser": { type: "boolean", description: "Print the link only; never open a browser" }
10725
+ };
10726
+ }
10727
+ });
10728
+
10729
+ // src/commands/connect/index.ts
10730
+ var KIND_NAMES, load, actions7;
10731
+ var init_connect3 = __esm({
10732
+ "src/commands/connect/index.ts"() {
10733
+ "use strict";
10734
+ KIND_NAMES = ["inbox", "calendar", "video", "crm", "hubspot-knowledge", "github", "migration", "linkedin", "whatsapp", "facebook", "instagram"];
10735
+ load = (name) => async () => {
10736
+ const [{ KINDS: KINDS2 }, { connectCommand: connectCommand2 }] = await Promise.all([Promise.resolve().then(() => (init_kinds(), kinds_exports)), Promise.resolve().then(() => (init_run(), run_exports))]);
10737
+ const kind = KINDS2.find((k) => k.name === name);
10738
+ if (!kind) throw new Error(`no connect kind ${name}`);
10739
+ return connectCommand2(kind);
10740
+ };
10741
+ actions7 = Object.fromEntries(KIND_NAMES.map((name) => [name, load(name)]));
10377
10742
  }
10378
10743
  });
10379
10744
 
@@ -10516,16 +10881,16 @@ function parseMapOverrides(value) {
10516
10881
  });
10517
10882
  }
10518
10883
  const out = {};
10519
- for (const [column, target] of Object.entries(value)) {
10520
- if (target !== null && typeof target !== "string") {
10884
+ for (const [column, target2] of Object.entries(value)) {
10885
+ if (target2 !== null && typeof target2 !== "string") {
10521
10886
  throw usageError(`--map "${column}" must name a field, customVariables.<key>, or null.`, { field: "map" });
10522
10887
  }
10523
- out[column] = target;
10888
+ out[column] = target2;
10524
10889
  }
10525
10890
  return out;
10526
10891
  }
10527
- function targetName(target) {
10528
- return "field" in target ? target.field : `${CUSTOM_PREFIX}${target.customKey}`;
10892
+ function targetName(target2) {
10893
+ return "field" in target2 ? target2.field : `${CUSTOM_PREFIX}${target2.customKey}`;
10529
10894
  }
10530
10895
  function overrideTarget(column, value, mode) {
10531
10896
  const text4 = value.trim();
@@ -10569,13 +10934,13 @@ function buildMapping(headers, overrides, mode) {
10569
10934
  };
10570
10935
  for (const header of headers) {
10571
10936
  const override2 = overrideFor(header, overrides);
10572
- let target;
10937
+ let target2;
10573
10938
  if (override2.found) {
10574
10939
  if (override2.value === null) {
10575
10940
  drop(header, "mapped_to_null");
10576
10941
  continue;
10577
10942
  }
10578
- target = overrideTarget(header, override2.value, mode);
10943
+ target2 = overrideTarget(header, override2.value, mode);
10579
10944
  } else {
10580
10945
  const field = fieldOf(header);
10581
10946
  const custom = CUSTOM_HEADER.exec(header)?.[1];
@@ -10585,7 +10950,7 @@ function buildMapping(headers, overrides, mode) {
10585
10950
  drop(header, problem);
10586
10951
  continue;
10587
10952
  }
10588
- target = { customKey: normalizeVariableName(custom) };
10953
+ target2 = { customKey: normalizeVariableName(custom) };
10589
10954
  } else if (isBagHeader(header)) {
10590
10955
  drop(header, "not_an_object");
10591
10956
  continue;
@@ -10594,20 +10959,20 @@ function buildMapping(headers, overrides, mode) {
10594
10959
  drop(header, "not_updatable");
10595
10960
  continue;
10596
10961
  }
10597
- target = { field };
10962
+ target2 = { field };
10598
10963
  } else {
10599
10964
  const problem = customVariableKeyProblem(header);
10600
10965
  if (problem) {
10601
10966
  drop(header, problem);
10602
10967
  continue;
10603
10968
  }
10604
- target = { customKey: normalizeVariableName(header) };
10969
+ target2 = { customKey: normalizeVariableName(header) };
10605
10970
  }
10606
10971
  }
10607
- result.columns.push({ header, target });
10608
- result.mapping[header] = targetName(target);
10609
- if ("field" in target) result.fields.add(target.field);
10610
- else if (!result.customVariableKeys.includes(target.customKey)) result.customVariableKeys.push(target.customKey);
10972
+ result.columns.push({ header, target: target2 });
10973
+ result.mapping[header] = targetName(target2);
10974
+ if ("field" in target2) result.fields.add(target2.field);
10975
+ else if (!result.customVariableKeys.includes(target2.customKey)) result.customVariableKeys.push(target2.customKey);
10611
10976
  }
10612
10977
  return result;
10613
10978
  }
@@ -10621,15 +10986,15 @@ function readCell(value) {
10621
10986
  }
10622
10987
  function rowValues(row, mapping, mode) {
10623
10988
  const out = { fields: {}, customVariables: {} };
10624
- for (const { header, target } of mapping.columns) {
10989
+ for (const { header, target: target2 } of mapping.columns) {
10625
10990
  const cell2 = readCell(row[header]);
10626
10991
  if (cell2.kind === "blank") continue;
10627
10992
  const value = cell2.kind === "null" ? null : cell2.text;
10628
- if ("field" in target) {
10993
+ if ("field" in target2) {
10629
10994
  if (value === null && mode === "import") continue;
10630
- if (!Object.hasOwn(out.fields, target.field)) out.fields[target.field] = value;
10631
- } else if (!Object.hasOwn(out.customVariables, target.customKey)) {
10632
- out.customVariables[target.customKey] = value;
10995
+ if (!Object.hasOwn(out.fields, target2.field)) out.fields[target2.field] = value;
10996
+ } else if (!Object.hasOwn(out.customVariables, target2.customKey)) {
10997
+ out.customVariables[target2.customKey] = value;
10633
10998
  }
10634
10999
  }
10635
11000
  return out;
@@ -10742,10 +11107,10 @@ var init_import_rows = __esm({
10742
11107
  });
10743
11108
 
10744
11109
  // src/commands/contacts/import-send.ts
10745
- import { setTimeout as delay4 } from "node:timers/promises";
11110
+ import { setTimeout as delay6 } from "node:timers/promises";
10746
11111
  async function abortableSleep(ms, signal) {
10747
11112
  try {
10748
- await delay4(ms, void 0, { signal });
11113
+ await delay6(ms, void 0, { signal });
10749
11114
  } catch (err) {
10750
11115
  if (signal.aborted) throw new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
10751
11116
  throw err;
@@ -10759,13 +11124,13 @@ function idText2(value) {
10759
11124
  }
10760
11125
  function mapCreateAnswer(chunk, body2) {
10761
11126
  const data = unwrap(body2);
10762
- const record = isRecord6(data) ? data : {};
11127
+ const record = isRecord4(data) ? data : {};
10763
11128
  const results = [];
10764
11129
  let limitMessage;
10765
11130
  const email = (item) => item.contact.email ? { email: item.contact.email } : {};
10766
11131
  if (Array.isArray(record.results)) {
10767
11132
  for (const entry of record.results) {
10768
- if (!isRecord6(entry) || typeof entry.index !== "number") continue;
11133
+ if (!isRecord4(entry) || typeof entry.index !== "number") continue;
10769
11134
  const item = chunk[entry.index];
10770
11135
  if (!item) continue;
10771
11136
  const reason = text2(entry.reason);
@@ -10790,8 +11155,8 @@ function mapCreateAnswer(chunk, body2) {
10790
11155
  }
10791
11156
  const failed = /* @__PURE__ */ new Map();
10792
11157
  for (const entry of Array.isArray(record.failed) ? record.failed : []) {
10793
- if (!isRecord6(entry) || typeof entry.index !== "number") continue;
10794
- const error = isRecord6(entry.error) ? entry.error : entry;
11158
+ if (!isRecord4(entry) || typeof entry.index !== "number") continue;
11159
+ const error = isRecord4(entry.error) ? entry.error : entry;
10795
11160
  failed.set(entry.index, { code: text2(error.code) ?? "failed", message: text2(error.message) });
10796
11161
  }
10797
11162
  chunk.forEach((item, index) => {
@@ -10844,136 +11209,6 @@ var init_import_send = __esm({
10844
11209
  }
10845
11210
  });
10846
11211
 
10847
- // src/batch/jobs.ts
10848
- import { setTimeout as delay5 } from "node:timers/promises";
10849
- function interrupted5() {
10850
- return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
10851
- }
10852
- async function defaultSleep(ms, signal) {
10853
- try {
10854
- await delay5(ms, void 0, signal ? { signal } : void 0);
10855
- } catch (err) {
10856
- if (signal?.aborted) throw interrupted5();
10857
- throw err;
10858
- }
10859
- }
10860
- function toJob(body2, jobId, type) {
10861
- const data = unwrap(body2);
10862
- const record = data !== null && typeof data === "object" && !Array.isArray(data) ? data : {};
10863
- const rawId = record.id;
10864
- return {
10865
- ...record,
10866
- id: typeof rawId === "number" || typeof rawId === "string" && rawId !== "" ? String(rawId) : jobId,
10867
- type: typeof record.type === "string" && record.type !== "" ? record.type : type,
10868
- status: typeof record.status === "string" ? record.status : "queued"
10869
- };
10870
- }
10871
- async function waitForJob(client, jobId, type, opts = {}) {
10872
- const id = String(jobId).trim();
10873
- if (id === "") throw usageError("Name the job id.", { field: "jobId" });
10874
- const timeoutMs2 = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
10875
- const intervalMs = opts.intervalMs ?? DEFAULT_INTERVAL_MS;
10876
- const now = opts.now ?? Date.now;
10877
- const sleep = opts.sleep ?? ((ms) => defaultSleep(ms, opts.signal));
10878
- const started = now();
10879
- for (; ; ) {
10880
- if (opts.signal?.aborted) throw interrupted5();
10881
- const res = await client.request({ method: "GET", path: `/v1/jobs/${encodeURIComponent(id)}`, query: { type }, signal: opts.signal });
10882
- const job = toJob(res.body, id, type);
10883
- if (TERMINAL_JOB_STATUSES.includes(job.status)) return job;
10884
- opts.onProgress?.(job);
10885
- const elapsed = now() - started;
10886
- if (elapsed >= timeoutMs2) {
10887
- throw new KensoError({
10888
- code: "job_timeout",
10889
- message: `Job ${id} is still ${job.status} after ${Math.round(timeoutMs2 / 1e3)} s.`,
10890
- exitCode: ExitCode.Error,
10891
- hint: "The job keeps running on the server. Wait for it again.",
10892
- next: `kenso jobs wait ${id} --type ${type}`
10893
- });
10894
- }
10895
- const interval = elapsed >= FAST_PHASE_MS ? Math.max(intervalMs, SLOW_INTERVAL_MS) : intervalMs;
10896
- await sleep(Math.min(interval, Math.max(0, timeoutMs2 - elapsed)));
10897
- }
10898
- }
10899
- var TERMINAL_JOB_STATUSES, DEFAULT_TIMEOUT_MS, DEFAULT_INTERVAL_MS, SLOW_INTERVAL_MS, FAST_PHASE_MS;
10900
- var init_jobs = __esm({
10901
- "src/batch/jobs.ts"() {
10902
- "use strict";
10903
- init_errors();
10904
- init_exit_codes();
10905
- init_http();
10906
- TERMINAL_JOB_STATUSES = ["succeeded", "failed", "canceled"];
10907
- DEFAULT_TIMEOUT_MS = 10 * 6e4;
10908
- DEFAULT_INTERVAL_MS = 2e3;
10909
- SLOW_INTERVAL_MS = 1e4;
10910
- FAST_PHASE_MS = 6e4;
10911
- }
10912
- });
10913
-
10914
- // src/commands/jobs/wait.ts
10915
- var wait_exports = {};
10916
- __export(wait_exports, {
10917
- default: () => wait_default,
10918
- parseDuration: () => parseDuration
10919
- });
10920
- function parseDuration(text4) {
10921
- const match = /^(\d+(?:\.\d+)?)\s*([smh]?)$/i.exec(text4.trim());
10922
- if (!match) return void 0;
10923
- const ms = Number(match[1]) * (UNIT_MS[(match[2] || "s").toLowerCase()] ?? 1e3);
10924
- return Number.isFinite(ms) ? Math.round(ms) : void 0;
10925
- }
10926
- var UNIT_MS, command16, wait_default;
10927
- var init_wait = __esm({
10928
- "src/commands/jobs/wait.ts"() {
10929
- "use strict";
10930
- init_jobs();
10931
- init_errors();
10932
- init_exit_codes();
10933
- UNIT_MS = { s: 1e3, m: 6e4, h: 36e5 };
10934
- command16 = {
10935
- resource: "jobs",
10936
- action: "wait",
10937
- summary: "Wait for a background job and print it",
10938
- description: "Polls GET /v1/jobs/{jobId}?type=<type> every 2 s (every 10 s after the first minute) until the job succeeds, fails or is canceled, then prints the job. Exit 0 when it succeeded, 1 when it failed, was canceled or is still running when --timeout passes.",
10939
- flags: {
10940
- type: { type: "string", required: true, description: "The job type, for example contact_import or contact_export" },
10941
- timeout: { type: "string", default: "10m", description: "How long to wait: 90s, 10m, 1h or a number of seconds (default 10m)" }
10942
- },
10943
- positionals: [{ name: "jobId", required: true, description: "The job id" }],
10944
- examples: ["kenso jobs wait 4821 --type contact_import", "kenso jobs wait 4821 --type contact_export --timeout 30m"],
10945
- operationIds: ["jobs.get"],
10946
- async run(ctx, { flags, positionals }) {
10947
- const jobId = (positionals[0] ?? "").trim();
10948
- if (jobId === "") throw usageError("Name the job id.", { field: "jobId", next: "kenso jobs wait <jobId> --type <type>" });
10949
- const type = typeof flags.type === "string" ? flags.type.trim() : "";
10950
- if (type === "") throw usageError("--type needs a value, for example contact_import.", { field: "type" });
10951
- const timeoutText = typeof flags.timeout === "string" ? flags.timeout : "10m";
10952
- const timeoutMs2 = parseDuration(timeoutText);
10953
- if (timeoutMs2 === void 0) {
10954
- throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
10955
- }
10956
- const job = await waitForJob(ctx.client, jobId, type, {
10957
- timeoutMs: timeoutMs2,
10958
- signal: ctx.signal,
10959
- onProgress: (j) => {
10960
- const done2 = j.progress ? `, ${j.progress.completed}/${j.progress.total ?? "?"}` : "";
10961
- ctx.output.progress(`job ${j.id}: ${j.status}${done2}`);
10962
- }
10963
- });
10964
- ctx.output.object(job);
10965
- if (job.status === "succeeded") return ExitCode.Ok;
10966
- throw new KensoError({
10967
- code: job.error?.code || (job.status === "canceled" ? "job_canceled" : "job_failed"),
10968
- message: job.error?.message || `Job ${job.id} ${job.status === "canceled" ? "was canceled" : "failed"}.`,
10969
- exitCode: ExitCode.Error
10970
- });
10971
- }
10972
- };
10973
- wait_default = command16;
10974
- }
10975
- });
10976
-
10977
11212
  // src/commands/contacts/server-import.ts
10978
11213
  import { readFile as readFile7 } from "node:fs/promises";
10979
11214
  import { basename as basename3, extname as extname3, resolve as resolve7 } from "node:path";
@@ -10986,10 +11221,10 @@ function columnMappings(mapping) {
10986
11221
  const sent = new Map(mapping.columns.map((column) => [column.header, column.target]));
10987
11222
  const out = [];
10988
11223
  for (const header of Object.keys(mapping.mapping)) {
10989
- const target = sent.get(header);
10990
- const csvTarget = target ? void 0 : csvTargetOf(header, mapping);
10991
- if (target && "field" in target) out.push({ csvColumn: header, targetField: TARGET_FIELDS[target.field] ?? target.field });
10992
- else if (target) out.push({ csvColumn: header, targetField: "custom_variable", customVariableName: target.customKey });
11224
+ const target2 = sent.get(header);
11225
+ const csvTarget = target2 ? void 0 : csvTargetOf(header, mapping);
11226
+ if (target2 && "field" in target2) out.push({ csvColumn: header, targetField: TARGET_FIELDS[target2.field] ?? target2.field });
11227
+ else if (target2) out.push({ csvColumn: header, targetField: "custom_variable", customVariableName: target2.customKey });
10993
11228
  else if (csvTarget) out.push({ csvColumn: header, targetField: csvTarget });
10994
11229
  }
10995
11230
  return out;
@@ -11051,7 +11286,7 @@ async function serverImport(ctx, opts) {
11051
11286
  form.append("file", new Blob([upload2.bytes], { type: "text/csv" }), upload2.name);
11052
11287
  const res = await ctx.client.request({ method: "POST", path: "/v1/contact-imports", form, signal: ctx.signal });
11053
11288
  const created = unwrap(res.body);
11054
- const jobId = isRecord6(created) ? created.id : void 0;
11289
+ const jobId = isRecord4(created) ? created.id : void 0;
11055
11290
  if (typeof jobId !== "number" && (typeof jobId !== "string" || jobId === "")) {
11056
11291
  throw new KensoError({ code: "unexpected_response", message: "The import was accepted, but the answer had no job id.", exitCode: ExitCode.Error });
11057
11292
  }
@@ -11126,7 +11361,7 @@ async function readOverrides(ctx, flags, file) {
11126
11361
  async function readCampaign(ctx, campaignId) {
11127
11362
  const res = await ctx.client.request({ method: "GET", path: `/v1/campaigns/${campaignId}` });
11128
11363
  const campaign = unwrap(res.body);
11129
- const channel = isRecord6(campaign) && typeof campaign.channel === "string" ? campaign.channel.toLowerCase() : "";
11364
+ const channel = isRecord4(campaign) && typeof campaign.channel === "string" ? campaign.channel.toLowerCase() : "";
11130
11365
  return { linkedInOnly: LINKEDIN_ONLY_CHANNELS.has(channel) ? true : void 0 };
11131
11366
  }
11132
11367
  async function estimate(ctx, leadCount) {
@@ -11134,7 +11369,7 @@ async function estimate(ctx, leadCount) {
11134
11369
  try {
11135
11370
  const res = await ctx.client.request({ method: "POST", path: "/v1/credits/estimates", body: { kind: "leads", leadCount } });
11136
11371
  const data = unwrap(res.body);
11137
- if (!isRecord6(data)) return { estimate: data ?? null };
11372
+ if (!isRecord4(data)) return { estimate: data ?? null };
11138
11373
  const credits = (key) => typeof data[key] === "number" ? data[key] / 1e3 : void 0;
11139
11374
  return {
11140
11375
  estimate: data,
@@ -11277,7 +11512,7 @@ async function emailIndex(ctx, campaignId) {
11277
11512
  for await (const contact of ctx.client.paginate({ method: "GET", path: "/v1/contacts", query: { campaignId } }, { pageSize: PAGE_SIZE })) {
11278
11513
  read2++;
11279
11514
  if (read2 % 2e3 === 0) ctx.output.progress(`read ${read2} contacts of campaign ${campaignId}`);
11280
- if (!isRecord6(contact)) continue;
11515
+ if (!isRecord4(contact)) continue;
11281
11516
  const email = typeof contact.email === "string" ? contact.email.trim().toLowerCase() : "";
11282
11517
  const id = typeof contact.id === "number" ? contact.id : typeof contact.id === "string" ? positiveId(contact.id) : void 0;
11283
11518
  if (email !== "" && id !== void 0 && !index.has(email)) index.set(email, id);
@@ -11338,11 +11573,11 @@ function planUpdate(rows, mapping, match, emails) {
11338
11573
  }
11339
11574
  function mapUpdateAnswer(chunk, body2) {
11340
11575
  const data = unwrap(body2);
11341
- const entries2 = isRecord6(data) && Array.isArray(data.results) ? data.results : [];
11576
+ const entries2 = isRecord4(data) && Array.isArray(data.results) ? data.results : [];
11342
11577
  const rowOf = new Map(chunk.map((u) => [u.item.contactId, u.row]));
11343
11578
  const results = [];
11344
11579
  for (const entry of entries2) {
11345
- if (!isRecord6(entry)) continue;
11580
+ if (!isRecord4(entry)) continue;
11346
11581
  const contactId = typeof entry.contactId === "number" ? entry.contactId : Number(entry.contactId);
11347
11582
  const row = rowOf.get(contactId);
11348
11583
  if (row === void 0) continue;
@@ -11460,12 +11695,12 @@ import { join as join11 } from "node:path";
11460
11695
  function whereDir(env) {
11461
11696
  return join11(runsRoot(env), WHERE_DIR);
11462
11697
  }
11463
- async function unfinishedWhereIds(ctx, command61, args) {
11698
+ async function unfinishedWhereIds(ctx, command65, args) {
11464
11699
  const dir = whereDir(ctx.env);
11465
11700
  const identity = argsIdentity(args);
11466
11701
  const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
11467
11702
  for (const run of await listRuns(ctx.env)) {
11468
- if (run.command !== command61 || run.status === "done" || run.status === "planned") continue;
11703
+ if (run.command !== command65 || run.status === "done" || run.status === "planned") continue;
11469
11704
  if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
11470
11705
  if (run.inputPath?.startsWith(`${dir}/`) && existsSync6(run.inputPath)) return run.inputPath;
11471
11706
  }
@@ -11559,7 +11794,7 @@ async function idsFromFile(ctx, path) {
11559
11794
  }
11560
11795
  async function searchIds(ctx, where) {
11561
11796
  const filters = await readDataArg(where, ctx.stdin);
11562
- if (!isRecord6(filters)) throw usageError("--where must be a JSON object of contacts search filters.", { field: "where" });
11797
+ if (!isRecord4(filters)) throw usageError("--where must be a JSON object of contacts search filters.", { field: "where" });
11563
11798
  const body2 = { ...filters };
11564
11799
  delete body2.cursor;
11565
11800
  delete body2.limit;
@@ -11575,10 +11810,10 @@ async function searchIds(ctx, where) {
11575
11810
  retrySafe: true
11576
11811
  });
11577
11812
  const page = unwrap(res.body);
11578
- const data = isRecord6(res.body) && Array.isArray(res.body.data) ? res.body.data : Array.isArray(page) ? page : [];
11579
- for (const contact of data) if (isRecord6(contact) && (typeof contact.id === "number" || typeof contact.id === "string")) ids2.push(String(contact.id));
11813
+ const data = isRecord4(res.body) && Array.isArray(res.body.data) ? res.body.data : Array.isArray(page) ? page : [];
11814
+ for (const contact of data) if (isRecord4(contact) && (typeof contact.id === "number" || typeof contact.id === "string")) ids2.push(String(contact.id));
11580
11815
  ctx.output.progress(`found ${ids2.length} contacts`);
11581
- const pagination = isRecord6(res.body) && isRecord6(res.body.pagination) ? res.body.pagination : void 0;
11816
+ const pagination = isRecord4(res.body) && isRecord4(res.body.pagination) ? res.body.pagination : void 0;
11582
11817
  const next = pagination?.nextCursor;
11583
11818
  if (pagination?.hasMore !== true || typeof next !== "string" || next === "" || seen.has(next)) break;
11584
11819
  seen.add(next);
@@ -11611,14 +11846,14 @@ async function idsFromRun(ctx, runId) {
11611
11846
  return { ...idItems(ids2), source: "run" };
11612
11847
  }
11613
11848
  async function collectIds(ctx, flags, kind, dryRun2) {
11614
- const command61 = `kenso contacts ${kind}`;
11849
+ const command65 = `kenso contacts ${kind}`;
11615
11850
  const ids2 = stringFlag2(flags, "ids");
11616
11851
  const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
11617
11852
  const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
11618
11853
  const given = [ids2, where, run].filter((v) => v !== void 0).length;
11619
11854
  if (given !== 1) {
11620
11855
  const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
11621
- throw usageError(`${command61} needs exactly one of ${choices}.`, { field: "ids", next: `${command61} --help` });
11856
+ throw usageError(`${command65} needs exactly one of ${choices}.`, { field: "ids", next: `${command65} --help` });
11622
11857
  }
11623
11858
  if (ids2 !== void 0) return idsFromFile(ctx, ids2);
11624
11859
  if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
@@ -11626,12 +11861,12 @@ async function collectIds(ctx, flags, kind, dryRun2) {
11626
11861
  }
11627
11862
  function mapBulkAnswer(chunk, body2) {
11628
11863
  const data = unwrap(body2);
11629
- const record = isRecord6(data) ? data : {};
11864
+ const record = isRecord4(data) ? data : {};
11630
11865
  const succeeded = new Set((Array.isArray(record.succeeded) ? record.succeeded : []).map((id) => String(id)));
11631
11866
  const failed = /* @__PURE__ */ new Map();
11632
11867
  for (const entry of Array.isArray(record.failed) ? record.failed : []) {
11633
- if (!isRecord6(entry) || entry.id === void 0 || entry.id === null) continue;
11634
- const error = isRecord6(entry.error) ? entry.error : entry;
11868
+ if (!isRecord4(entry) || entry.id === void 0 || entry.id === null) continue;
11869
+ const error = isRecord4(entry.error) ? entry.error : entry;
11635
11870
  const code = typeof error.code === "string" && error.code !== "" ? error.code : "failed";
11636
11871
  failed.set(String(entry.id), { code, ...typeof error.message === "string" && error.message !== "" ? { message: error.message } : {} });
11637
11872
  }
@@ -11877,7 +12112,7 @@ function idText3(value) {
11877
12112
  return typeof value === "number" || typeof value === "string" && value !== "" ? String(value) : void 0;
11878
12113
  }
11879
12114
  function exportIdOf(job) {
11880
- const resource = isRecord6(job.resource) ? idText3(job.resource.id) : void 0;
12115
+ const resource = isRecord4(job.resource) ? idText3(job.resource.id) : void 0;
11881
12116
  if (resource) return resource;
11882
12117
  const url = typeof job.downloadUrl === "string" ? CONTENT_PATH.exec(job.downloadUrl)?.[1] : void 0;
11883
12118
  return url ?? String(job.id);
@@ -11948,8 +12183,8 @@ var init_export = __esm({
11948
12183
  if (timeoutMs2 === void 0) throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
11949
12184
  const res = await ctx.client.request({ method: "POST", path: "/v1/contact-exports", body: { kind: "contacts", campaignId }, signal: ctx.signal });
11950
12185
  const created = unwrap(res.body);
11951
- const jobId = isRecord6(created) ? idText3(created.id) : void 0;
11952
- if (!isRecord6(created) || jobId === void 0) {
12186
+ const jobId = isRecord4(created) ? idText3(created.id) : void 0;
12187
+ if (!isRecord4(created) || jobId === void 0) {
11953
12188
  throw new KensoError({ code: "unexpected_response", message: "The export was created, but the answer had no job id.", exitCode: ExitCode.Error });
11954
12189
  }
11955
12190
  if (out === void 0 && flags.wait !== true) {
@@ -12604,7 +12839,7 @@ var tail_exports = {};
12604
12839
  __export(tail_exports, {
12605
12840
  default: () => tail_default
12606
12841
  });
12607
- import { setTimeout as delay6 } from "node:timers/promises";
12842
+ import { setTimeout as delay7 } from "node:timers/promises";
12608
12843
  function duration(text4) {
12609
12844
  const days = /^(\d+(?:\.\d+)?)\s*d$/i.exec(text4.trim());
12610
12845
  return days ? Math.round(Number(days[1]) * 864e5) : parseDuration(text4);
@@ -12743,7 +12978,7 @@ var init_tail = __esm({
12743
12978
  backoffMs2 = err instanceof KensoError && err.exitCode === ExitCode.RateLimited ? Math.max(intervalMs, RATE_LIMITED_WAIT_MS) : intervalMs;
12744
12979
  ctx.output.warn(`Polling failed (${err.message}); trying again in ${backoffMs2 / 1e3} s.`);
12745
12980
  }
12746
- await delay6(backoffMs2, void 0, { signal: ctx.signal }).catch(() => void 0);
12981
+ await delay7(backoffMs2, void 0, { signal: ctx.signal }).catch(() => void 0);
12747
12982
  }
12748
12983
  return ExitCode.Ok;
12749
12984
  }
@@ -12870,52 +13105,265 @@ var init_call = __esm({
12870
13105
  writeRaw(ctx, text4);
12871
13106
  return ExitCode.Ok;
12872
13107
  }
12873
- ctx.output.object(parsed2);
13108
+ ctx.output.object(parsed2);
13109
+ return ExitCode.Ok;
13110
+ }
13111
+ };
13112
+ call_default = command26;
13113
+ }
13114
+ });
13115
+
13116
+ // src/commands/mcp/tools.ts
13117
+ var tools_exports = {};
13118
+ __export(tools_exports, {
13119
+ default: () => tools_default
13120
+ });
13121
+ var command27, tools_default;
13122
+ var init_tools = __esm({
13123
+ "src/commands/mcp/tools.ts"() {
13124
+ "use strict";
13125
+ init_exit_codes();
13126
+ init_connect4();
13127
+ command27 = {
13128
+ resource: "mcp",
13129
+ action: "tools",
13130
+ summary: "List the hosted Kenso MCP's tools",
13131
+ brief: "only to find a tool name",
13132
+ description: "Lists every tool of the Kenso MCP (KENSO_MCP_URL, default https://mcp.ken.so/mcp) as { name, description }, with the same API key. Call one with kenso mcp call <tool>.",
13133
+ flags: {},
13134
+ examples: ["kenso mcp tools", "kenso mcp tools --fields name"],
13135
+ operationIds: [],
13136
+ async run(ctx) {
13137
+ const tools = await mcpClient(ctx).listTools();
13138
+ await ctx.output.list(tools.map((tool) => ({ name: tool.name, description: tool.description ?? null })));
13139
+ return ExitCode.Ok;
13140
+ }
13141
+ };
13142
+ tools_default = command27;
13143
+ }
13144
+ });
13145
+
13146
+ // src/commands/mcp/index.ts
13147
+ var actions16;
13148
+ var init_mcp = __esm({
13149
+ "src/commands/mcp/index.ts"() {
13150
+ "use strict";
13151
+ actions16 = {
13152
+ call: () => Promise.resolve().then(() => (init_call(), call_exports)).then((m) => m.default),
13153
+ tools: () => Promise.resolve().then(() => (init_tools(), tools_exports)).then((m) => m.default)
13154
+ };
13155
+ }
13156
+ });
13157
+
13158
+ // src/commands/notes/target.ts
13159
+ function positiveId2(value, field, next) {
13160
+ const text4 = String(value ?? "").trim();
13161
+ const id = /^\d+$/.test(text4) ? Number(text4) : Number.NaN;
13162
+ if (!Number.isSafeInteger(id) || id < 1) {
13163
+ throw usageError(`${field} must be a positive whole number (got "${text4}").`, { field, next });
13164
+ }
13165
+ return id;
13166
+ }
13167
+ function target(flags, next, allowNone = false) {
13168
+ const given = ["account", "person", "deal"].filter((name2) => flags[name2] !== void 0);
13169
+ if (given.length === 0 && allowNone) return {};
13170
+ if (given.length !== 1) {
13171
+ throw usageError("Name the record with exactly one of --account, --person and --deal.", { field: "account", next });
13172
+ }
13173
+ const name = given[0];
13174
+ const key = name === "deal" ? "opportunityId" : `${name}Id`;
13175
+ return { [key]: positiveId2(flags[name], name, next) };
13176
+ }
13177
+ var targetFlags;
13178
+ var init_target = __esm({
13179
+ "src/commands/notes/target.ts"() {
13180
+ "use strict";
13181
+ init_errors();
13182
+ targetFlags = {
13183
+ account: { type: "string", description: "The account id", aliases: ["account-id"] },
13184
+ person: { type: "string", description: "The person id", aliases: ["person-id"] },
13185
+ deal: { type: "string", description: "The deal (opportunity) id", aliases: ["opportunity", "opportunity-id"] }
13186
+ };
13187
+ }
13188
+ });
13189
+
13190
+ // src/commands/notes/list.ts
13191
+ var list_exports = {};
13192
+ __export(list_exports, {
13193
+ default: () => list_default
13194
+ });
13195
+ var command28, list_default;
13196
+ var init_list = __esm({
13197
+ "src/commands/notes/list.ts"() {
13198
+ "use strict";
13199
+ init_exit_codes();
13200
+ init_target();
13201
+ command28 = {
13202
+ resource: "notes",
13203
+ action: "list",
13204
+ summary: "List the notes on an account, a person or a deal, pinned first, then newest",
13205
+ description: "Reads GET /v1/notes for the one record you name and follows every page. Each note has id, body (markdown, mentions as @[Name](memberId)), mentions, isPinned, createdBy, createdAt, editedAt, commentCount and its first 50 comments, oldest first. A record outside your workspace or account scope is not_found.",
13206
+ flags: targetFlags,
13207
+ examples: [
13208
+ "kenso notes list --account 5",
13209
+ "kenso notes list --deal 77 --query '[].{id: id, by: createdBy.name, body: body}'"
13210
+ ],
13211
+ beta: { featureGates: { all: ["record_notes"] } },
13212
+ operationIds: ["notes.list"],
13213
+ async run(ctx, { flags }) {
13214
+ const query = target(flags, "kenso notes list --account <accountId>");
13215
+ await ctx.output.list(ctx.client.paginate({ method: "GET", path: "/v1/notes", query, signal: ctx.signal }));
13216
+ return ExitCode.Ok;
13217
+ }
13218
+ };
13219
+ list_default = command28;
13220
+ }
13221
+ });
13222
+
13223
+ // src/commands/notes/add.ts
13224
+ var add_exports = {};
13225
+ __export(add_exports, {
13226
+ bodyText: () => bodyText,
13227
+ default: () => add_default
13228
+ });
13229
+ async function bodyText(ctx, value, next) {
13230
+ const text4 = value === "-" ? await readStream(ctx.stdin ?? process.stdin) : String(value ?? "");
13231
+ if (text4.trim() === "") throw usageError("--body cannot be empty: the note's text, in markdown (--body - reads stdin).", { field: "body", next });
13232
+ return text4;
13233
+ }
13234
+ var command29, add_default;
13235
+ var init_add = __esm({
13236
+ "src/commands/notes/add.ts"() {
13237
+ "use strict";
13238
+ init_errors();
13239
+ init_exit_codes();
13240
+ init_http();
13241
+ init_input();
13242
+ init_target();
13243
+ command29 = {
13244
+ resource: "notes",
13245
+ action: "add",
13246
+ summary: "Write a note on an account, a person or a deal, or a comment under a note",
13247
+ description: "Sends POST /v1/notes and prints the note. Name the record with one of --account, --person and --deal, or answer a note with --parent. The body is markdown, up to 20,000 characters; mention a teammate as @[Name](memberId) and they are notified. The note shows on the record's Notes tab and its Activity timeline. A note on an account needs the accounts plan feature.",
13248
+ flags: {
13249
+ ...targetFlags,
13250
+ parent: { type: "string", description: "The note to comment on (instead of a record flag)" },
13251
+ body: { type: "string", required: true, description: "The text, in markdown. - reads it from stdin" }
13252
+ },
13253
+ examples: [
13254
+ "kenso notes add --account 5 --body 'Budget approved, @[Jane Doe](41) please send the DPA'",
13255
+ "kenso notes add --parent 900 --body 'Sent it this morning'",
13256
+ "cat call-notes.md | kenso notes add --deal 77 --body -"
13257
+ ],
13258
+ beta: { featureGates: { all: ["record_notes"] } },
13259
+ operationIds: ["notes.create"],
13260
+ async run(ctx, { flags }) {
13261
+ const next = "kenso notes add --account <accountId> --body <text>";
13262
+ const record = target(flags, next, flags.parent !== void 0);
13263
+ if (flags.parent !== void 0 && Object.keys(record).length > 0) {
13264
+ throw usageError("A comment takes --parent alone: its note decides the record.", { field: "parent", next });
13265
+ }
13266
+ const parent = flags.parent === void 0 ? {} : { parentNoteId: positiveId2(flags.parent, "parent", next) };
13267
+ const body2 = await bodyText(ctx, flags.body, next);
13268
+ const res = await ctx.client.request({ method: "POST", path: "/v1/notes", body: { ...record, ...parent, body: body2 }, signal: ctx.signal });
13269
+ ctx.output.object(unwrap(res.body));
12874
13270
  return ExitCode.Ok;
12875
13271
  }
12876
13272
  };
12877
- call_default = command26;
13273
+ add_default = command29;
12878
13274
  }
12879
13275
  });
12880
13276
 
12881
- // src/commands/mcp/tools.ts
12882
- var tools_exports = {};
12883
- __export(tools_exports, {
12884
- default: () => tools_default
13277
+ // src/commands/notes/edit.ts
13278
+ var edit_exports = {};
13279
+ __export(edit_exports, {
13280
+ default: () => edit_default
13281
+ });
13282
+ var command30, edit_default;
13283
+ var init_edit = __esm({
13284
+ "src/commands/notes/edit.ts"() {
13285
+ "use strict";
13286
+ init_errors();
13287
+ init_exit_codes();
13288
+ init_http();
13289
+ init_add();
13290
+ init_target();
13291
+ command30 = {
13292
+ resource: "notes",
13293
+ action: "edit",
13294
+ summary: "Change a note's text, or pin or unpin it",
13295
+ description: "Sends PATCH /v1/notes/{noteId} and prints the note. Only the note's author changes its text; anyone who can edit accounts pins or unpins a note (not a comment). Teammates a new text mentions for the first time are notified.",
13296
+ flags: {
13297
+ body: { type: "string", description: "The new text, in markdown. - reads it from stdin" },
13298
+ pin: { type: "boolean", description: "Pin the note to the top of the record's notes" },
13299
+ unpin: { type: "boolean", description: "Unpin the note" }
13300
+ },
13301
+ positionals: [{ name: "noteId", required: true, description: "The note or comment id" }],
13302
+ examples: ["kenso notes edit 900 --body 'Budget approved for Q1'", "kenso notes edit 900 --pin"],
13303
+ beta: { featureGates: { all: ["record_notes"] } },
13304
+ operationIds: ["notes.update"],
13305
+ async run(ctx, { flags, positionals }) {
13306
+ const next = "kenso notes edit <noteId> --body <text>";
13307
+ const id = positiveId2(positionals[0], "noteId", next);
13308
+ if (flags.pin === true && flags.unpin === true) throw usageError("Pass --pin or --unpin, not both.", { field: "pin", next });
13309
+ const patch = {};
13310
+ if (flags.body !== void 0) patch.body = await bodyText(ctx, flags.body, next);
13311
+ if (flags.pin === true || flags.unpin === true) patch.isPinned = flags.pin === true;
13312
+ if (Object.keys(patch).length === 0) throw usageError("Pass --body, --pin or --unpin.", { field: "body", next });
13313
+ const res = await ctx.client.request({ method: "PATCH", path: `/v1/notes/${id}`, body: patch, signal: ctx.signal });
13314
+ ctx.output.object(unwrap(res.body));
13315
+ return ExitCode.Ok;
13316
+ }
13317
+ };
13318
+ edit_default = command30;
13319
+ }
12885
13320
  });
12886
- var command27, tools_default;
12887
- var init_tools = __esm({
12888
- "src/commands/mcp/tools.ts"() {
13321
+
13322
+ // src/commands/notes/delete.ts
13323
+ var delete_exports = {};
13324
+ __export(delete_exports, {
13325
+ default: () => delete_default
13326
+ });
13327
+ var command31, delete_default;
13328
+ var init_delete = __esm({
13329
+ "src/commands/notes/delete.ts"() {
12889
13330
  "use strict";
13331
+ init_confirm();
12890
13332
  init_exit_codes();
12891
- init_connect4();
12892
- command27 = {
12893
- resource: "mcp",
12894
- action: "tools",
12895
- summary: "List the hosted Kenso MCP's tools",
12896
- brief: "only to find a tool name",
12897
- description: "Lists every tool of the Kenso MCP (KENSO_MCP_URL, default https://mcp.ken.so/mcp) as { name, description }, with the same API key. Call one with kenso mcp call <tool>.",
13333
+ init_target();
13334
+ command31 = {
13335
+ resource: "notes",
13336
+ action: "delete",
13337
+ summary: "Delete a note or a comment (its author or a workspace admin)",
13338
+ description: "Sends DELETE /v1/notes/{noteId}. The note leaves the record's Notes tab and Activity timeline; `kenso notes restore <noteId>` brings it back. Needs --yes, or a yes at the prompt.",
12898
13339
  flags: {},
12899
- examples: ["kenso mcp tools", "kenso mcp tools --fields name"],
12900
- operationIds: [],
12901
- async run(ctx) {
12902
- const tools = await mcpClient(ctx).listTools();
12903
- await ctx.output.list(tools.map((tool) => ({ name: tool.name, description: tool.description ?? null })));
13340
+ positionals: [{ name: "noteId", required: true, description: "The note or comment id" }],
13341
+ examples: ["kenso notes delete 900 --yes"],
13342
+ beta: { featureGates: { all: ["record_notes"] } },
13343
+ operationIds: ["notes.delete"],
13344
+ async run(ctx, { positionals }) {
13345
+ const next = "kenso notes delete <noteId> --yes";
13346
+ const id = positiveId2(positionals[0], "noteId", next);
13347
+ await confirmDestructive(ctx, `This deletes note ${id}`, `kenso notes delete ${id} --yes`);
13348
+ await ctx.client.request({ method: "DELETE", path: `/v1/notes/${id}`, signal: ctx.signal });
13349
+ ctx.output.object({ id, deleted: true });
12904
13350
  return ExitCode.Ok;
12905
13351
  }
12906
13352
  };
12907
- tools_default = command27;
13353
+ delete_default = command31;
12908
13354
  }
12909
13355
  });
12910
13356
 
12911
- // src/commands/mcp/index.ts
12912
- var actions16;
12913
- var init_mcp = __esm({
12914
- "src/commands/mcp/index.ts"() {
13357
+ // src/commands/notes/index.ts
13358
+ var actions17;
13359
+ var init_notes = __esm({
13360
+ "src/commands/notes/index.ts"() {
12915
13361
  "use strict";
12916
- actions16 = {
12917
- call: () => Promise.resolve().then(() => (init_call(), call_exports)).then((m) => m.default),
12918
- tools: () => Promise.resolve().then(() => (init_tools(), tools_exports)).then((m) => m.default)
13362
+ actions17 = {
13363
+ list: () => Promise.resolve().then(() => (init_list(), list_exports)).then((m) => m.default),
13364
+ add: () => Promise.resolve().then(() => (init_add(), add_exports)).then((m) => m.default),
13365
+ edit: () => Promise.resolve().then(() => (init_edit(), edit_exports)).then((m) => m.default),
13366
+ delete: () => Promise.resolve().then(() => (init_delete(), delete_exports)).then((m) => m.default)
12919
13367
  };
12920
13368
  }
12921
13369
  });
@@ -12938,7 +13386,7 @@ async function categoryOf(ctx, stage) {
12938
13386
  throw err;
12939
13387
  }
12940
13388
  }
12941
- var KEY, command28, move_default;
13389
+ var KEY, command32, move_default;
12942
13390
  var init_move = __esm({
12943
13391
  "src/commands/opportunities/move.ts"() {
12944
13392
  "use strict";
@@ -12946,7 +13394,7 @@ var init_move = __esm({
12946
13394
  init_exit_codes();
12947
13395
  init_http();
12948
13396
  KEY = /^[a-z][a-z0-9_]{0,62}$/;
12949
- command28 = {
13397
+ command32 = {
12950
13398
  resource: "opportunities",
12951
13399
  action: "move",
12952
13400
  summary: "Move a deal to a stage, with its won or lost reason",
@@ -12992,7 +13440,7 @@ var init_move = __esm({
12992
13440
  return ExitCode.Ok;
12993
13441
  }
12994
13442
  };
12995
- move_default = command28;
13443
+ move_default = command32;
12996
13444
  }
12997
13445
  });
12998
13446
 
@@ -13001,14 +13449,14 @@ var stage_history_exports = {};
13001
13449
  __export(stage_history_exports, {
13002
13450
  default: () => stage_history_default
13003
13451
  });
13004
- var command29, stage_history_default;
13452
+ var command33, stage_history_default;
13005
13453
  var init_stage_history = __esm({
13006
13454
  "src/commands/opportunities/stage-history.ts"() {
13007
13455
  "use strict";
13008
13456
  init_errors();
13009
13457
  init_exit_codes();
13010
13458
  init_http();
13011
- command29 = {
13459
+ command33 = {
13012
13460
  resource: "opportunities",
13013
13461
  action: "stage-history",
13014
13462
  summary: "Show a deal's stage history: each stage, when, who moved it and how long it sat there",
@@ -13032,18 +13480,70 @@ var init_stage_history = __esm({
13032
13480
  return ExitCode.Ok;
13033
13481
  }
13034
13482
  };
13035
- stage_history_default = command29;
13483
+ stage_history_default = command33;
13484
+ }
13485
+ });
13486
+
13487
+ // src/commands/opportunities/bulk-update.ts
13488
+ var bulk_update_exports2 = {};
13489
+ __export(bulk_update_exports2, {
13490
+ default: () => bulk_update_default2
13491
+ });
13492
+ var bulk_update_default2;
13493
+ var init_bulk_update3 = __esm({
13494
+ "src/commands/opportunities/bulk-update.ts"() {
13495
+ "use strict";
13496
+ init_bulk_update();
13497
+ bulk_update_default2 = bulkUpdateCommand({
13498
+ resource: "opportunities",
13499
+ noun: "deal",
13500
+ plural: "deals",
13501
+ aliases: { owner: "ownerMemberId", close: "closeDate" },
13502
+ fields: ["stage", "ownerMemberId", "closeDate", "amount", "dealType", "nextStep"],
13503
+ featureGates: ["opportunities", "bulk_edit"],
13504
+ examples: [
13505
+ `kenso opportunities bulk-update --filter '{"filters":[{"field":"stageCategory","operator":"is","values":["open"]}]}' --set stage=proposal --dry-run`,
13506
+ "kenso opportunities bulk-update --ids 71,72,73 --set close=2026-12-31 --yes",
13507
+ "kenso changes undo --change-id 31"
13508
+ ]
13509
+ });
13510
+ }
13511
+ });
13512
+
13513
+ // src/commands/opportunities/bulk-delete.ts
13514
+ var bulk_delete_exports2 = {};
13515
+ __export(bulk_delete_exports2, {
13516
+ default: () => bulk_delete_default2
13517
+ });
13518
+ var bulk_delete_default2;
13519
+ var init_bulk_delete2 = __esm({
13520
+ "src/commands/opportunities/bulk-delete.ts"() {
13521
+ "use strict";
13522
+ init_bulk_update();
13523
+ bulk_delete_default2 = bulkDeleteCommand({
13524
+ resource: "opportunities",
13525
+ noun: "deal",
13526
+ plural: "deals",
13527
+ featureGates: ["opportunities", "bulk_edit"],
13528
+ examples: [
13529
+ `kenso opportunities bulk-delete --filter '{"accountId":812}' --dry-run`,
13530
+ "kenso opportunities bulk-delete --ids 71,72,73 --yes",
13531
+ "kenso changes apply --change-id 31"
13532
+ ]
13533
+ });
13036
13534
  }
13037
13535
  });
13038
13536
 
13039
13537
  // src/commands/opportunities/index.ts
13040
- var actions17;
13538
+ var actions18;
13041
13539
  var init_opportunities = __esm({
13042
13540
  "src/commands/opportunities/index.ts"() {
13043
13541
  "use strict";
13044
- actions17 = {
13542
+ actions18 = {
13045
13543
  move: () => Promise.resolve().then(() => (init_move(), move_exports)).then((m) => m.default),
13046
- "stage-history": () => Promise.resolve().then(() => (init_stage_history(), stage_history_exports)).then((m) => m.default)
13544
+ "stage-history": () => Promise.resolve().then(() => (init_stage_history(), stage_history_exports)).then((m) => m.default),
13545
+ "bulk-update": () => Promise.resolve().then(() => (init_bulk_update3(), bulk_update_exports2)).then((m) => m.default),
13546
+ "bulk-delete": () => Promise.resolve().then(() => (init_bulk_delete2(), bulk_delete_exports2)).then((m) => m.default)
13047
13547
  };
13048
13548
  }
13049
13549
  });
@@ -13119,7 +13619,7 @@ function summarize3(results) {
13119
13619
  }
13120
13620
  return { matched, addedToAccounts, emailFindsQueued };
13121
13621
  }
13122
- var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command30, import_default3;
13622
+ var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command34, import_default3;
13123
13623
  var init_import3 = __esm({
13124
13624
  "src/commands/people/import.ts"() {
13125
13625
  "use strict";
@@ -13151,7 +13651,7 @@ var init_import3 = __esm({
13151
13651
  };
13152
13652
  PERSON_FIELDS = ["email", "fullName", "firstName", "lastName", "linkedinUrl", "title"];
13153
13653
  ACCOUNT_NOT_FOUND = "No account in this workspace has that domain. The person was saved without an account: add the account (kenso accounts import) and run the same command again.";
13154
- command30 = {
13654
+ command34 = {
13155
13655
  resource: "people",
13156
13656
  action: "import",
13157
13657
  summary: "Create or match people from a CSV or JSONL file, optionally onto accounts",
@@ -13216,17 +13716,69 @@ var init_import3 = __esm({
13216
13716
  return outcome.exitCode;
13217
13717
  }
13218
13718
  };
13219
- import_default3 = command30;
13719
+ import_default3 = command34;
13720
+ }
13721
+ });
13722
+
13723
+ // src/commands/people/bulk-update.ts
13724
+ var bulk_update_exports3 = {};
13725
+ __export(bulk_update_exports3, {
13726
+ default: () => bulk_update_default3
13727
+ });
13728
+ var bulk_update_default3;
13729
+ var init_bulk_update4 = __esm({
13730
+ "src/commands/people/bulk-update.ts"() {
13731
+ "use strict";
13732
+ init_bulk_update();
13733
+ bulk_update_default3 = bulkUpdateCommand({
13734
+ resource: "people",
13735
+ noun: "person",
13736
+ plural: "people",
13737
+ aliases: { owner: "ownerMemberId" },
13738
+ fields: ["ownerMemberId", "leadStatus", "title", "seniority", "department", "location"],
13739
+ featureGates: ["accounts", "bulk_edit"],
13740
+ examples: [
13741
+ `kenso people bulk-update --filter '{"leadStatus":["working"]}' --set owner=42 --dry-run`,
13742
+ "kenso people bulk-update --ids 501,502 --set seniority=VP --yes",
13743
+ "kenso changes undo --change-id 31"
13744
+ ]
13745
+ });
13746
+ }
13747
+ });
13748
+
13749
+ // src/commands/people/bulk-delete.ts
13750
+ var bulk_delete_exports3 = {};
13751
+ __export(bulk_delete_exports3, {
13752
+ default: () => bulk_delete_default3
13753
+ });
13754
+ var bulk_delete_default3;
13755
+ var init_bulk_delete3 = __esm({
13756
+ "src/commands/people/bulk-delete.ts"() {
13757
+ "use strict";
13758
+ init_bulk_update();
13759
+ bulk_delete_default3 = bulkDeleteCommand({
13760
+ resource: "people",
13761
+ noun: "person",
13762
+ plural: "people",
13763
+ featureGates: ["accounts", "bulk_edit"],
13764
+ examples: [
13765
+ `kenso people bulk-delete --filter '{"onAccount":"none","leadStatus":["disqualified"]}' --dry-run`,
13766
+ "kenso people bulk-delete --ids 501,502 --yes",
13767
+ "kenso changes apply --change-id 31"
13768
+ ]
13769
+ });
13220
13770
  }
13221
13771
  });
13222
13772
 
13223
13773
  // src/commands/people/index.ts
13224
- var actions18;
13774
+ var actions19;
13225
13775
  var init_people = __esm({
13226
13776
  "src/commands/people/index.ts"() {
13227
13777
  "use strict";
13228
- actions18 = {
13229
- import: () => Promise.resolve().then(() => (init_import3(), import_exports3)).then((m) => m.default)
13778
+ actions19 = {
13779
+ import: () => Promise.resolve().then(() => (init_import3(), import_exports3)).then((m) => m.default),
13780
+ "bulk-update": () => Promise.resolve().then(() => (init_bulk_update4(), bulk_update_exports3)).then((m) => m.default),
13781
+ "bulk-delete": () => Promise.resolve().then(() => (init_bulk_delete3(), bulk_delete_exports3)).then((m) => m.default)
13230
13782
  };
13231
13783
  }
13232
13784
  });
@@ -13246,14 +13798,14 @@ function rule(stage) {
13246
13798
  isDefault: stage.isDefaultRequiredFields
13247
13799
  };
13248
13800
  }
13249
- var command31, stage_rules_default;
13801
+ var command35, stage_rules_default;
13250
13802
  var init_stage_rules = __esm({
13251
13803
  "src/commands/pipelines/stage-rules.ts"() {
13252
13804
  "use strict";
13253
13805
  init_errors();
13254
13806
  init_exit_codes();
13255
13807
  init_http();
13256
- command31 = {
13808
+ command35 = {
13257
13809
  resource: "pipelines",
13258
13810
  action: "stage-rules",
13259
13811
  summary: "List or set the fields a deal should have in each stage",
@@ -13306,16 +13858,16 @@ var init_stage_rules = __esm({
13306
13858
  return ExitCode.Ok;
13307
13859
  }
13308
13860
  };
13309
- stage_rules_default = command31;
13861
+ stage_rules_default = command35;
13310
13862
  }
13311
13863
  });
13312
13864
 
13313
13865
  // src/commands/pipelines/index.ts
13314
- var actions19;
13866
+ var actions20;
13315
13867
  var init_pipelines = __esm({
13316
13868
  "src/commands/pipelines/index.ts"() {
13317
13869
  "use strict";
13318
- actions19 = {
13870
+ actions20 = {
13319
13871
  "stage-rules": () => Promise.resolve().then(() => (init_stage_rules(), stage_rules_exports)).then((m) => m.default)
13320
13872
  };
13321
13873
  }
@@ -13326,7 +13878,7 @@ var run_exports2 = {};
13326
13878
  __export(run_exports2, {
13327
13879
  default: () => run_default
13328
13880
  });
13329
- var REPORTS, command32, run_default;
13881
+ var REPORTS, command36, run_default;
13330
13882
  var init_run2 = __esm({
13331
13883
  "src/commands/reports/run.ts"() {
13332
13884
  "use strict";
@@ -13334,7 +13886,7 @@ var init_run2 = __esm({
13334
13886
  init_exit_codes();
13335
13887
  init_http();
13336
13888
  REPORTS = ["pipeline_by_stage", "won_by_month", "stage_conversion", "time_in_stage", "won_by_source_campaign", "activity_by_member"];
13337
- command32 = {
13889
+ command36 = {
13338
13890
  resource: "reports",
13339
13891
  action: "run",
13340
13892
  summary: "Run a stock pipeline report and print its table",
@@ -13396,7 +13948,7 @@ var init_run2 = __esm({
13396
13948
  return ExitCode.Ok;
13397
13949
  }
13398
13950
  };
13399
- run_default = command32;
13951
+ run_default = command36;
13400
13952
  }
13401
13953
  });
13402
13954
 
@@ -13405,14 +13957,14 @@ var summary_exports = {};
13405
13957
  __export(summary_exports, {
13406
13958
  default: () => summary_default
13407
13959
  });
13408
- var command33, summary_default;
13960
+ var command37, summary_default;
13409
13961
  var init_summary = __esm({
13410
13962
  "src/commands/reports/summary.ts"() {
13411
13963
  "use strict";
13412
13964
  init_errors();
13413
13965
  init_exit_codes();
13414
13966
  init_http();
13415
- command33 = {
13967
+ command37 = {
13416
13968
  resource: "reports",
13417
13969
  action: "summary",
13418
13970
  summary: "Read where the period stands and what needs you",
@@ -13467,16 +14019,16 @@ var init_summary = __esm({
13467
14019
  return ExitCode.Ok;
13468
14020
  }
13469
14021
  };
13470
- summary_default = command33;
14022
+ summary_default = command37;
13471
14023
  }
13472
14024
  });
13473
14025
 
13474
14026
  // src/commands/reports/index.ts
13475
- var actions20;
14027
+ var actions21;
13476
14028
  var init_reports = __esm({
13477
14029
  "src/commands/reports/index.ts"() {
13478
14030
  "use strict";
13479
- actions20 = {
14031
+ actions21 = {
13480
14032
  run: () => Promise.resolve().then(() => (init_run2(), run_exports2)).then((m) => m.default),
13481
14033
  summary: () => Promise.resolve().then(() => (init_summary(), summary_exports)).then((m) => m.default)
13482
14034
  };
@@ -13484,18 +14036,18 @@ var init_reports = __esm({
13484
14036
  });
13485
14037
 
13486
14038
  // src/commands/runs/list.ts
13487
- var list_exports = {};
13488
- __export(list_exports, {
13489
- default: () => list_default
14039
+ var list_exports2 = {};
14040
+ __export(list_exports2, {
14041
+ default: () => list_default2
13490
14042
  });
13491
- var command34, list_default;
13492
- var init_list = __esm({
14043
+ var command38, list_default2;
14044
+ var init_list2 = __esm({
13493
14045
  "src/commands/runs/list.ts"() {
13494
14046
  "use strict";
13495
14047
  init_runs();
13496
14048
  init_errors();
13497
14049
  init_exit_codes();
13498
- command34 = {
14050
+ command38 = {
13499
14051
  resource: "runs",
13500
14052
  action: "list",
13501
14053
  summary: "List batch runs, newest first (finds an interrupted run)",
@@ -13516,7 +14068,7 @@ var init_list = __esm({
13516
14068
  return ExitCode.Ok;
13517
14069
  }
13518
14070
  };
13519
- list_default = command34;
14071
+ list_default2 = command38;
13520
14072
  }
13521
14073
  });
13522
14074
 
@@ -13527,7 +14079,7 @@ __export(show_exports2, {
13527
14079
  });
13528
14080
  import { existsSync as existsSync7, readFileSync as readFileSync9 } from "node:fs";
13529
14081
  import { join as join12 } from "node:path";
13530
- var FILES, command35, show_default2;
14082
+ var FILES, command39, show_default2;
13531
14083
  var init_show2 = __esm({
13532
14084
  "src/commands/runs/show.ts"() {
13533
14085
  "use strict";
@@ -13542,7 +14094,7 @@ var init_show2 = __esm({
13542
14094
  ["plan", "plan.json"],
13543
14095
  ["summary", "summary.json"]
13544
14096
  ];
13545
- command35 = {
14097
+ command39 = {
13546
14098
  resource: "runs",
13547
14099
  action: "show",
13548
14100
  summary: "Show one batch run and its files",
@@ -13569,7 +14121,7 @@ var init_show2 = __esm({
13569
14121
  return ExitCode.Ok;
13570
14122
  }
13571
14123
  };
13572
- show_default2 = command35;
14124
+ show_default2 = command39;
13573
14125
  }
13574
14126
  });
13575
14127
 
@@ -13628,14 +14180,14 @@ function resumeArgv(run, globals = {}) {
13628
14180
  async function sha256(path) {
13629
14181
  return createHash5("sha256").update(await readFile9(path)).digest("hex");
13630
14182
  }
13631
- var SKIPPED_KEYS, command36, resume_default;
14183
+ var SKIPPED_KEYS, command40, resume_default;
13632
14184
  var init_resume = __esm({
13633
14185
  "src/commands/runs/resume.ts"() {
13634
14186
  "use strict";
13635
14187
  init_runs();
13636
14188
  init_errors();
13637
14189
  SKIPPED_KEYS = /* @__PURE__ */ new Set(["positionals", "yes", "dryRun", "dry-run", "help", "version"]);
13638
- command36 = {
14190
+ command40 = {
13639
14191
  resource: "runs",
13640
14192
  action: "resume",
13641
14193
  summary: "Continue an interrupted batch run (its command with --yes, no dry run)",
@@ -13690,17 +14242,17 @@ var init_resume = __esm({
13690
14242
  }
13691
14243
  }
13692
14244
  };
13693
- resume_default = command36;
14245
+ resume_default = command40;
13694
14246
  }
13695
14247
  });
13696
14248
 
13697
14249
  // src/commands/runs/index.ts
13698
- var actions21;
14250
+ var actions22;
13699
14251
  var init_runs2 = __esm({
13700
14252
  "src/commands/runs/index.ts"() {
13701
14253
  "use strict";
13702
- actions21 = {
13703
- list: () => Promise.resolve().then(() => (init_list(), list_exports)).then((m) => m.default),
14254
+ actions22 = {
14255
+ list: () => Promise.resolve().then(() => (init_list2(), list_exports2)).then((m) => m.default),
13704
14256
  show: () => Promise.resolve().then(() => (init_show2(), show_exports2)).then((m) => m.default),
13705
14257
  resume: () => Promise.resolve().then(() => (init_resume(), resume_exports)).then((m) => m.default)
13706
14258
  };
@@ -13798,7 +14350,7 @@ var create_exports = {};
13798
14350
  __export(create_exports, {
13799
14351
  default: () => create_default
13800
14352
  });
13801
- var command37, create_default;
14353
+ var command41, create_default;
13802
14354
  var init_create = __esm({
13803
14355
  "src/commands/sandbox/create.ts"() {
13804
14356
  "use strict";
@@ -13806,7 +14358,7 @@ var init_create = __esm({
13806
14358
  init_exit_codes();
13807
14359
  init_http();
13808
14360
  init_shared();
13809
- command37 = {
14361
+ command41 = {
13810
14362
  resource: "sandbox",
13811
14363
  action: "create",
13812
14364
  summary: "Create your developer sandbox and save its test key as the sandbox profile",
@@ -13848,24 +14400,24 @@ var init_create = __esm({
13848
14400
  return ExitCode.Ok;
13849
14401
  }
13850
14402
  };
13851
- create_default = command37;
14403
+ create_default = command41;
13852
14404
  }
13853
14405
  });
13854
14406
 
13855
14407
  // src/commands/sandbox/delete.ts
13856
- var delete_exports = {};
13857
- __export(delete_exports, {
13858
- default: () => delete_default
14408
+ var delete_exports2 = {};
14409
+ __export(delete_exports2, {
14410
+ default: () => delete_default2
13859
14411
  });
13860
- var command38, delete_default;
13861
- var init_delete = __esm({
14412
+ var command42, delete_default2;
14413
+ var init_delete2 = __esm({
13862
14414
  "src/commands/sandbox/delete.ts"() {
13863
14415
  "use strict";
13864
14416
  init_config();
13865
14417
  init_confirm();
13866
14418
  init_exit_codes();
13867
14419
  init_shared();
13868
- command38 = {
14420
+ command42 = {
13869
14421
  resource: "sandbox",
13870
14422
  action: "delete",
13871
14423
  summary: "Delete your sandbox and its test keys",
@@ -13892,7 +14444,7 @@ var init_delete = __esm({
13892
14444
  return ExitCode.Ok;
13893
14445
  }
13894
14446
  };
13895
- delete_default = command38;
14447
+ delete_default2 = command42;
13896
14448
  }
13897
14449
  });
13898
14450
 
@@ -13901,14 +14453,14 @@ var key_exports = {};
13901
14453
  __export(key_exports, {
13902
14454
  default: () => key_default
13903
14455
  });
13904
- var command39, key_default;
14456
+ var command43, key_default;
13905
14457
  var init_key = __esm({
13906
14458
  "src/commands/sandbox/key.ts"() {
13907
14459
  "use strict";
13908
14460
  init_exit_codes();
13909
14461
  init_http();
13910
14462
  init_shared();
13911
- command39 = {
14463
+ command43 = {
13912
14464
  resource: "sandbox",
13913
14465
  action: "key",
13914
14466
  summary: "Create a new test key for your sandbox and save it as the sandbox profile",
@@ -13928,22 +14480,22 @@ var init_key = __esm({
13928
14480
  return ExitCode.Ok;
13929
14481
  }
13930
14482
  };
13931
- key_default = command39;
14483
+ key_default = command43;
13932
14484
  }
13933
14485
  });
13934
14486
 
13935
14487
  // src/commands/sandbox/list.ts
13936
- var list_exports2 = {};
13937
- __export(list_exports2, {
13938
- default: () => list_default2
14488
+ var list_exports3 = {};
14489
+ __export(list_exports3, {
14490
+ default: () => list_default3
13939
14491
  });
13940
- var command40, list_default2;
13941
- var init_list2 = __esm({
14492
+ var command44, list_default3;
14493
+ var init_list3 = __esm({
13942
14494
  "src/commands/sandbox/list.ts"() {
13943
14495
  "use strict";
13944
14496
  init_exit_codes();
13945
14497
  init_shared();
13946
- command40 = {
14498
+ command44 = {
13947
14499
  resource: "sandbox",
13948
14500
  action: "list",
13949
14501
  summary: "List your developer sandbox",
@@ -13959,7 +14511,7 @@ var init_list2 = __esm({
13959
14511
  return ExitCode.Ok;
13960
14512
  }
13961
14513
  };
13962
- list_default2 = command40;
14514
+ list_default3 = command44;
13963
14515
  }
13964
14516
  });
13965
14517
 
@@ -13968,14 +14520,14 @@ var reset_exports = {};
13968
14520
  __export(reset_exports, {
13969
14521
  default: () => reset_default
13970
14522
  });
13971
- var command41, reset_default;
14523
+ var command45, reset_default;
13972
14524
  var init_reset = __esm({
13973
14525
  "src/commands/sandbox/reset.ts"() {
13974
14526
  "use strict";
13975
14527
  init_exit_codes();
13976
14528
  init_http();
13977
14529
  init_shared();
13978
- command41 = {
14530
+ command45 = {
13979
14531
  resource: "sandbox",
13980
14532
  action: "reset",
13981
14533
  summary: "Reset your sandbox to its seed data",
@@ -13993,38 +14545,38 @@ var init_reset = __esm({
13993
14545
  return ExitCode.Ok;
13994
14546
  }
13995
14547
  };
13996
- reset_default = command41;
14548
+ reset_default = command45;
13997
14549
  }
13998
14550
  });
13999
14551
 
14000
14552
  // src/commands/sandbox/index.ts
14001
- var actions22;
14553
+ var actions23;
14002
14554
  var init_sandbox2 = __esm({
14003
14555
  "src/commands/sandbox/index.ts"() {
14004
14556
  "use strict";
14005
- actions22 = {
14557
+ actions23 = {
14006
14558
  create: () => Promise.resolve().then(() => (init_create(), create_exports)).then((m) => m.default),
14007
- delete: () => Promise.resolve().then(() => (init_delete(), delete_exports)).then((m) => m.default),
14559
+ delete: () => Promise.resolve().then(() => (init_delete2(), delete_exports2)).then((m) => m.default),
14008
14560
  key: () => Promise.resolve().then(() => (init_key(), key_exports)).then((m) => m.default),
14009
- list: () => Promise.resolve().then(() => (init_list2(), list_exports2)).then((m) => m.default),
14561
+ list: () => Promise.resolve().then(() => (init_list3(), list_exports3)).then((m) => m.default),
14010
14562
  reset: () => Promise.resolve().then(() => (init_reset(), reset_exports)).then((m) => m.default)
14011
14563
  };
14012
14564
  }
14013
14565
  });
14014
14566
 
14015
14567
  // src/commands/skill/index.ts
14016
- var actions23;
14568
+ var actions24;
14017
14569
  var init_skill = __esm({
14018
14570
  "src/commands/skill/index.ts"() {
14019
14571
  "use strict";
14020
- actions23 = {
14572
+ actions24 = {
14021
14573
  install: () => Promise.resolve().then(() => (init_install(), install_exports)).then((m) => m.default)
14022
14574
  };
14023
14575
  }
14024
14576
  });
14025
14577
 
14026
14578
  // src/commands/studio/common.ts
14027
- function positiveId2(value, field) {
14579
+ function positiveId3(value, field) {
14028
14580
  const text4 = (value ?? "").trim();
14029
14581
  const id = /^\d+$/.test(text4) ? Number(text4) : Number.NaN;
14030
14582
  if (!Number.isSafeInteger(id) || id < 1) throw usageError(`${field} must be a positive whole number (got "${text4}").`, { field });
@@ -14090,8 +14642,8 @@ async function readFolder(dir) {
14090
14642
  function safeJoin(root2, bundlePath) {
14091
14643
  const segments = bundlePath.split("/");
14092
14644
  const bad = bundlePath === "" || isAbsolute(bundlePath) || /^[A-Za-z]:/.test(bundlePath) || bundlePath.includes("\\") || bundlePath.includes("\0") || segments.some((s) => s === "" || s === "." || s === "..");
14093
- const target = resolve10(root2, ...segments);
14094
- if (bad || !target.startsWith(root2.endsWith(sep) ? root2 : root2 + sep)) {
14645
+ const target2 = resolve10(root2, ...segments);
14646
+ if (bad || !target2.startsWith(root2.endsWith(sep) ? root2 : root2 + sep)) {
14095
14647
  throw new KensoError({
14096
14648
  code: "unsafe_path",
14097
14649
  message: `Refusing to write "${bundlePath}": it is not a plain relative path inside ${root2}.`,
@@ -14099,7 +14651,7 @@ function safeJoin(root2, bundlePath) {
14099
14651
  hint: "The template holds a file path the CLI will not write. Nothing was written."
14100
14652
  });
14101
14653
  }
14102
- return target;
14654
+ return target2;
14103
14655
  }
14104
14656
  function contentTypeOf(path) {
14105
14657
  return CONTENT_TYPES2[extname5(path).toLowerCase()] ?? "application/octet-stream";
@@ -14192,13 +14744,13 @@ async function upload(ctx, templateId, file) {
14192
14744
  body: { path: file.path, contentType: contentTypeOf(file.path), bytes: file.bytes.length },
14193
14745
  signal: ctx.signal
14194
14746
  });
14195
- const target = unwrap(res.body);
14196
- if (!target?.uploadId || !target.url) {
14747
+ const target2 = unwrap(res.body);
14748
+ if (!target2?.uploadId || !target2.url) {
14197
14749
  throw new KensoError({ code: "upload_failed", message: `No upload URL came back for ${file.path}.`, exitCode: ExitCode.Server });
14198
14750
  }
14199
- const method = typeof target.method === "string" && target.method.trim() !== "" ? target.method.toUpperCase() : "PUT";
14200
- await presigned(target.url, { method, headers: target.headers ?? {}, body: new Uint8Array(file.bytes) }, `Uploading ${file.path}`, "upload_failed", ctx.signal);
14201
- return target.uploadId;
14751
+ const method = typeof target2.method === "string" && target2.method.trim() !== "" ? target2.method.toUpperCase() : "PUT";
14752
+ await presigned(target2.url, { method, headers: target2.headers ?? {}, body: new Uint8Array(file.bytes) }, `Uploading ${file.path}`, "upload_failed", ctx.signal);
14753
+ return target2.uploadId;
14202
14754
  }
14203
14755
  function refuseOversize(files) {
14204
14756
  const tooBig = files.filter((f) => f.text === void 0 && f.bytes.length > UPLOAD_MAX_BYTES);
@@ -14253,7 +14805,7 @@ __export(pull_exports, {
14253
14805
  });
14254
14806
  import { mkdir, writeFile as writeFile4 } from "node:fs/promises";
14255
14807
  import { dirname as dirname2, resolve as resolve11 } from "node:path";
14256
- var command42, pull_default;
14808
+ var command46, pull_default;
14257
14809
  var init_pull = __esm({
14258
14810
  "src/commands/studio/pull.ts"() {
14259
14811
  "use strict";
@@ -14263,7 +14815,7 @@ var init_pull = __esm({
14263
14815
  init_common2();
14264
14816
  init_folder();
14265
14817
  init_transfer2();
14266
- command42 = {
14818
+ command46 = {
14267
14819
  resource: "studio",
14268
14820
  action: "pull",
14269
14821
  summary: "Write a template version's files to a folder",
@@ -14278,7 +14830,7 @@ var init_pull = __esm({
14278
14830
  operationIds: ["asset-templates.pull"],
14279
14831
  dryRun: true,
14280
14832
  async run(ctx, { flags, positionals }) {
14281
- const templateId = positiveId2(positionals[0], "templateId");
14833
+ const templateId = positiveId3(positionals[0], "templateId");
14282
14834
  const version = typeof flags["template-version"] === "string" ? flags["template-version"].trim() : void 0;
14283
14835
  if (version !== void 0 && !/^(draft|latest|\d+)$/.test(version)) {
14284
14836
  throw usageError(`--template-version must be draft, latest or a version id (got "${version}").`, { field: "template-version" });
@@ -14301,16 +14853,16 @@ var init_pull = __esm({
14301
14853
  return ExitCode.Ok;
14302
14854
  }
14303
14855
  await mkdir(dir, { recursive: true });
14304
- await mapLimit(files, PARALLEL_TRANSFERS, async ({ path, file, target }) => {
14856
+ await mapLimit(files, PARALLEL_TRANSFERS, async ({ path, file, target: target2 }) => {
14305
14857
  const content = typeof file.text === "string" ? file.text : await download2(file.downloadUrl, path, file.sha256, ctx.signal);
14306
- await mkdir(dirname2(target), { recursive: true });
14307
- await writeFile4(target, content);
14858
+ await mkdir(dirname2(target2), { recursive: true });
14859
+ await writeFile4(target2, content);
14308
14860
  });
14309
14861
  ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir });
14310
14862
  return ExitCode.Ok;
14311
14863
  }
14312
14864
  };
14313
- pull_default = command42;
14865
+ pull_default = command46;
14314
14866
  }
14315
14867
  });
14316
14868
 
@@ -14343,7 +14895,7 @@ var push_exports = {};
14343
14895
  __export(push_exports, {
14344
14896
  default: () => push_default
14345
14897
  });
14346
- var BUILT_BY, DEFAULT_MESSAGE, command43, push_default;
14898
+ var BUILT_BY, DEFAULT_MESSAGE, command47, push_default;
14347
14899
  var init_push = __esm({
14348
14900
  "src/commands/studio/push.ts"() {
14349
14901
  "use strict";
@@ -14355,7 +14907,7 @@ var init_push = __esm({
14355
14907
  init_read();
14356
14908
  BUILT_BY = "customer_agent";
14357
14909
  DEFAULT_MESSAGE = "Pushed with the Kenso CLI";
14358
- command43 = {
14910
+ command47 = {
14359
14911
  resource: "studio",
14360
14912
  action: "push",
14361
14913
  summary: "Save a folder's files to a template's draft and print the validation",
@@ -14373,7 +14925,7 @@ var init_push = __esm({
14373
14925
  dryRun: true,
14374
14926
  async run(ctx, args) {
14375
14927
  const { flags, positionals } = args;
14376
- const templateId = positiveId2(positionals[0], "templateId");
14928
+ const templateId = positiveId3(positionals[0], "templateId");
14377
14929
  const message = typeof flags.message === "string" && flags.message.trim() !== "" ? flags.message : DEFAULT_MESSAGE;
14378
14930
  if (ctx.flags.dryRun) {
14379
14931
  const local = await readLocalTemplate(templateId, String(flags.dir));
@@ -14447,7 +14999,7 @@ var init_push = __esm({
14447
14999
  );
14448
15000
  }
14449
15001
  };
14450
- push_default = command43;
15002
+ push_default = command47;
14451
15003
  }
14452
15004
  });
14453
15005
 
@@ -14456,7 +15008,7 @@ var validate_exports = {};
14456
15008
  __export(validate_exports, {
14457
15009
  default: () => validate_default
14458
15010
  });
14459
- var command44, validate_default;
15011
+ var command48, validate_default;
14460
15012
  var init_validate = __esm({
14461
15013
  "src/commands/studio/validate.ts"() {
14462
15014
  "use strict";
@@ -14465,7 +15017,7 @@ var init_validate = __esm({
14465
15017
  init_columns();
14466
15018
  init_common2();
14467
15019
  init_read();
14468
- command44 = {
15020
+ command48 = {
14469
15021
  resource: "studio",
14470
15022
  action: "validate",
14471
15023
  summary: "Validate a folder's files against a template without saving them",
@@ -14480,7 +15032,7 @@ var init_validate = __esm({
14480
15032
  operationIds: ["asset-templates.create-upload-url", "asset-templates.validate"],
14481
15033
  async run(ctx, args) {
14482
15034
  const { flags, positionals } = args;
14483
- const templateId = positiveId2(positionals[0], "templateId");
15035
+ const templateId = positiveId3(positionals[0], "templateId");
14484
15036
  const files = await readTemplateFolder(ctx, templateId, String(flags.dir));
14485
15037
  const res = await ctx.client.request({
14486
15038
  method: "POST",
@@ -14494,7 +15046,7 @@ var init_validate = __esm({
14494
15046
  throw validationFailed(validation, "The files have validation errors", commandLine2(ctx, "studio validate", args));
14495
15047
  }
14496
15048
  };
14497
- validate_default = command44;
15049
+ validate_default = command48;
14498
15050
  }
14499
15051
  });
14500
15052
 
@@ -14543,7 +15095,7 @@ function accountIds(value) {
14543
15095
  }
14544
15096
  return ids2.map(Number);
14545
15097
  }
14546
- var SHOWN, command45, preview_default;
15098
+ var SHOWN, command49, preview_default;
14547
15099
  var init_preview = __esm({
14548
15100
  "src/commands/studio/preview.ts"() {
14549
15101
  "use strict";
@@ -14555,7 +15107,7 @@ var init_preview = __esm({
14555
15107
  init_common2();
14556
15108
  init_folder();
14557
15109
  SHOWN = 5;
14558
- command45 = {
15110
+ command49 = {
14559
15111
  resource: "studio",
14560
15112
  action: "preview",
14561
15113
  summary: "Render a saved version for up to 3 accounts; for local edits, studio push them to the draft first",
@@ -14575,9 +15127,9 @@ var init_preview = __esm({
14575
15127
  operationIds: ["asset-templates.preview", "asset-templates.pull"],
14576
15128
  async run(ctx, args) {
14577
15129
  const { flags, positionals } = args;
14578
- const templateId = positiveId2(positionals[0], "templateId");
15130
+ const templateId = positiveId3(positionals[0], "templateId");
14579
15131
  const versionText = stringFlag(flags["version-id"]);
14580
- const versionId = versionText !== void 0 ? positiveId2(versionText, "version-id") : void 0;
15132
+ const versionId = versionText !== void 0 ? positiveId3(versionText, "version-id") : void 0;
14581
15133
  const ids2 = accountIds(stringFlag(flags["account-ids"]));
14582
15134
  const interact = flags.interact !== void 0 ? await readDataArg(String(flags.interact), ctx.stdin) : void 0;
14583
15135
  if (interact !== void 0 && !Array.isArray(interact)) throw usageError("--interact must be a JSON array of steps.", { field: "interact" });
@@ -14604,12 +15156,12 @@ var init_preview = __esm({
14604
15156
  return ExitCode.Ok;
14605
15157
  }
14606
15158
  };
14607
- preview_default = command45;
15159
+ preview_default = command49;
14608
15160
  }
14609
15161
  });
14610
15162
 
14611
15163
  // src/commands/studio/fill-runs.ts
14612
- import { setTimeout as delay7 } from "node:timers/promises";
15164
+ import { setTimeout as delay8 } from "node:timers/promises";
14613
15165
  async function estimateFill(ctx, templateId, count) {
14614
15166
  const parts2 = [];
14615
15167
  for (let left = count; left > 0; left -= RUN_SIZE) {
@@ -14641,7 +15193,7 @@ async function estimateFill(ctx, templateId, count) {
14641
15193
  async function waitForRun(client, runId, opts) {
14642
15194
  const sleep = opts.sleep ?? (async (ms) => {
14643
15195
  try {
14644
- await delay7(ms, void 0, { signal: opts.signal });
15196
+ await delay8(ms, void 0, { signal: opts.signal });
14645
15197
  } catch (err) {
14646
15198
  if (opts.signal.aborted) throw new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
14647
15199
  throw err;
@@ -14745,35 +15297,35 @@ async function readTarget(ctx, flags) {
14745
15297
  flag,
14746
15298
  items: [...firstRow].map(([id, row]) => ({ id, row })),
14747
15299
  duplicates: raw.length - firstRow.size,
14748
- ...campaign !== void 0 ? { campaignId: positiveId2(campaign, "campaign") } : {},
15300
+ ...campaign !== void 0 ? { campaignId: positiveId3(campaign, "campaign") } : {},
14749
15301
  input: source === "-" ? { path: "-", sha256: sha2562(raw.join("\n")) } : { path: resolve12(source), sha256: sha2562(await readFile11(resolve12(source))) }
14750
15302
  };
14751
15303
  }
14752
- async function refuseRefill(ctx, args, target) {
15304
+ async function refuseRefill(ctx, args, target2) {
14753
15305
  const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
14754
15306
  const sameFill = (a) => argsIdentity({ ...a, wait: void 0 });
14755
15307
  const earlier = (await listRuns(ctx.env)).find(
14756
- (run) => run.command === COMMAND6 && run.status !== "planned" && run.inputSha256 === target.input.sha256 && (run.workspaceId || void 0) === (workspaceId || void 0) && sameFill(run.args) === sameFill(args)
15308
+ (run) => run.command === COMMAND6 && run.status !== "planned" && run.inputSha256 === target2.input.sha256 && (run.workspaceId || void 0) === (workspaceId || void 0) && sameFill(run.args) === sameFill(args)
14757
15309
  );
14758
15310
  if (!earlier) return;
14759
15311
  const unfinished = earlier.status !== "done";
14760
- const succeeded = !unfinished && await allSucceeded(earlier, target.items.length);
15312
+ const succeeded = !unfinished && await allSucceeded(earlier, target2.items.length);
14761
15313
  if (argsIdentity(earlier.args) === argsIdentity(args) && (unfinished || succeeded)) return;
14762
- const ids2 = target.flag === "accounts" ? "accounts" : "leads";
15314
+ const ids2 = target2.flag === "accounts" ? "accounts" : "leads";
14763
15315
  throw new KensoError({
14764
15316
  code: "already_filled",
14765
15317
  exitCode: ExitCode.Conflict,
14766
15318
  message: unfinished ? `Run ${earlier.runId} is already filling these ${ids2} (${earlier.status}).` : `Run ${earlier.runId} already filled these ${ids2}.`,
14767
- hint: unfinished ? "Continue that run instead: a new fill would create every fill run again." : succeeded ? "Every page was filled. Filling again rebuilds and charges every page that is not building or live; to do that anyway, use kenso asset-runs create." : `Filling again rebuilds and charges every page that is not building or live. To retry only the failed ones, put the ${target.key} values of the failed rows in ${join14(earlier.dir, "results.csv")} in a file and fill that file.`,
15319
+ hint: unfinished ? "Continue that run instead: a new fill would create every fill run again." : succeeded ? "Every page was filled. Filling again rebuilds and charges every page that is not building or live; to do that anyway, use kenso asset-runs create." : `Filling again rebuilds and charges every page that is not building or live. To retry only the failed ones, put the ${target2.key} values of the failed rows in ${join14(earlier.dir, "results.csv")} in a file and fill that file.`,
14768
15320
  next: unfinished ? `kenso runs resume ${earlier.runId}` : `kenso runs show ${earlier.runId}`
14769
15321
  });
14770
15322
  }
14771
- async function fillChunk(ctx, templateId, target, wait3, chunk, chunkCtx) {
15323
+ async function fillChunk(ctx, templateId, target2, wait3, chunk, chunkCtx) {
14772
15324
  const ids2 = chunk.map((item) => item.id);
14773
- const body2 = target.campaignId !== void 0 ? { templateId, campaignId: target.campaignId, contactIds: ids2 } : { templateId, accountIds: ids2 };
15325
+ const body2 = target2.campaignId !== void 0 ? { templateId, campaignId: target2.campaignId, contactIds: ids2 } : { templateId, accountIds: ids2 };
14774
15326
  const res = await chunkCtx.client.request({ method: "POST", path: "/v1/asset-runs", body: body2, signal: chunkCtx.signal });
14775
15327
  let run = unwrap(res.body) ?? {};
14776
- ctx.output.info(`Run ${run.id} started for ${ids2.length} ${target.flag} (${run.state ?? "queued"}).`);
15328
+ ctx.output.info(`Run ${run.id} started for ${ids2.length} ${target2.flag} (${run.state ?? "queued"}).`);
14777
15329
  if (wait3 && run.id !== void 0) {
14778
15330
  const created = run;
14779
15331
  try {
@@ -14792,20 +15344,20 @@ async function fillChunk(ctx, templateId, target, wait3, chunk, chunkCtx) {
14792
15344
  }
14793
15345
  }
14794
15346
  }
14795
- return { results: runResults(chunk, run, target.key) };
15347
+ return { results: runResults(chunk, run, target2.key) };
14796
15348
  }
14797
- function estimateOutput(templateId, target, estimate2) {
15349
+ function estimateOutput(templateId, target2, estimate2) {
14798
15350
  return {
14799
15351
  templateId,
14800
- ...target.campaignId !== void 0 ? { campaignId: target.campaignId } : {},
14801
- [target.flag]: target.items.length,
14802
- ...target.duplicates > 0 ? { duplicates: target.duplicates } : {},
14803
- runs: Math.ceil(target.items.length / RUN_SIZE),
15352
+ ...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
15353
+ [target2.flag]: target2.items.length,
15354
+ ...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
15355
+ runs: Math.ceil(target2.items.length / RUN_SIZE),
14804
15356
  estimate: estimate2,
14805
- ...target.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
15357
+ ...target2.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
14806
15358
  };
14807
15359
  }
14808
- var COMMAND6, sha2562, command46, fill_default;
15360
+ var COMMAND6, sha2562, command50, fill_default;
14809
15361
  var init_fill = __esm({
14810
15362
  "src/commands/studio/fill.ts"() {
14811
15363
  "use strict";
@@ -14821,7 +15373,7 @@ var init_fill = __esm({
14821
15373
  init_fill_runs();
14822
15374
  COMMAND6 = "studio fill";
14823
15375
  sha2562 = (data) => createHash8("sha256").update(data).digest("hex");
14824
- command46 = {
15376
+ command50 = {
14825
15377
  resource: "studio",
14826
15378
  action: "fill",
14827
15379
  summary: "Fill a template on many accounts or campaign leads (estimate first)",
@@ -14846,15 +15398,15 @@ var init_fill = __esm({
14846
15398
  dryRun: true,
14847
15399
  async run(ctx, args) {
14848
15400
  const { flags, positionals } = args;
14849
- const templateId = positiveId2(positionals[0], "templateId");
15401
+ const templateId = positiveId3(positionals[0], "templateId");
14850
15402
  if (flags.estimate === true && ctx.flags.yes === true) throw usageError("Pick one of --estimate and --yes.", { field: "estimate" });
14851
- const target = await readTarget(ctx, flags);
15403
+ const target2 = await readTarget(ctx, flags);
14852
15404
  const batchArgs = { ...flags, positionals };
14853
- if (ctx.flags.yes === true) await refuseRefill(ctx, batchArgs, target);
14854
- const estimate2 = await estimateFill(ctx, templateId, target.items.length);
15405
+ if (ctx.flags.yes === true) await refuseRefill(ctx, batchArgs, target2);
15406
+ const estimate2 = await estimateFill(ctx, templateId, target2.items.length);
14855
15407
  if (ctx.flags.yes !== true) {
14856
15408
  const next = commandLine2(ctx, COMMAND6, { flags: { ...flags, estimate: void 0 }, positionals }, ["--yes"]);
14857
- ctx.output.object({ ...estimateOutput(templateId, target, estimate2), next });
15409
+ ctx.output.object({ ...estimateOutput(templateId, target2, estimate2), next });
14858
15410
  return ExitCode.Ok;
14859
15411
  }
14860
15412
  const wait3 = flags.wait === true;
@@ -14862,16 +15414,16 @@ var init_fill = __esm({
14862
15414
  {
14863
15415
  command: COMMAND6,
14864
15416
  args: batchArgs,
14865
- input: target.input,
14866
- items: target.items,
15417
+ input: target2.input,
15418
+ items: target2.items,
14867
15419
  rowOf: (item) => item.row,
14868
15420
  chunkSize: RUN_SIZE,
14869
15421
  concurrency: 1,
14870
- execChunk: (chunk, chunkCtx) => fillChunk(ctx, templateId, target, wait3, chunk, chunkCtx),
15422
+ execChunk: (chunk, chunkCtx) => fillChunk(ctx, templateId, target2, wait3, chunk, chunkCtx),
14871
15423
  summarize: (results) => ({
14872
15424
  templateId,
14873
- ...target.campaignId !== void 0 ? { campaignId: target.campaignId } : {},
14874
- ...target.duplicates > 0 ? { duplicates: target.duplicates } : {},
15425
+ ...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
15426
+ ...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
14875
15427
  estimatedMillicredits: estimate2.millicredits,
14876
15428
  runs: runsOf(results)
14877
15429
  })
@@ -14881,16 +15433,16 @@ var init_fill = __esm({
14881
15433
  return outcome.exitCode;
14882
15434
  }
14883
15435
  };
14884
- fill_default = command46;
15436
+ fill_default = command50;
14885
15437
  }
14886
15438
  });
14887
15439
 
14888
15440
  // src/commands/studio/index.ts
14889
- var actions24;
15441
+ var actions25;
14890
15442
  var init_studio2 = __esm({
14891
15443
  "src/commands/studio/index.ts"() {
14892
15444
  "use strict";
14893
- actions24 = {
15445
+ actions25 = {
14894
15446
  pull: () => Promise.resolve().then(() => (init_pull(), pull_exports)).then((m) => m.default),
14895
15447
  push: () => Promise.resolve().then(() => (init_push(), push_exports)).then((m) => m.default),
14896
15448
  validate: () => Promise.resolve().then(() => (init_validate(), validate_exports)).then((m) => m.default),
@@ -14901,7 +15453,7 @@ var init_studio2 = __esm({
14901
15453
  });
14902
15454
 
14903
15455
  // src/commands/tasks/shared.ts
14904
- function positiveId3(text4, field, next) {
15456
+ function positiveId4(text4, field, next) {
14905
15457
  const value = (text4 ?? "").trim();
14906
15458
  const id = /^\d+$/.test(value) ? Number(value) : Number.NaN;
14907
15459
  if (!Number.isSafeInteger(id) || id < 1) throw usageError(`${field} must be a positive whole number (got "${value}").`, { field, next });
@@ -14961,7 +15513,7 @@ async function memberId(ctx, text4, field, next) {
14961
15513
  next: "kenso members list"
14962
15514
  });
14963
15515
  }
14964
- return positiveId3(value, field, next);
15516
+ return positiveId4(value, field, next);
14965
15517
  }
14966
15518
  var WEEKDAYS, DUE_NEXT, startOfDay, addDays, ymd;
14967
15519
  var init_shared2 = __esm({
@@ -14979,12 +15531,12 @@ var init_shared2 = __esm({
14979
15531
  });
14980
15532
 
14981
15533
  // src/commands/tasks/add.ts
14982
- var add_exports = {};
14983
- __export(add_exports, {
14984
- default: () => add_default
15534
+ var add_exports2 = {};
15535
+ __export(add_exports2, {
15536
+ default: () => add_default2
14985
15537
  });
14986
- var NEXT, command47, add_default;
14987
- var init_add = __esm({
15538
+ var NEXT, command51, add_default2;
15539
+ var init_add2 = __esm({
14988
15540
  "src/commands/tasks/add.ts"() {
14989
15541
  "use strict";
14990
15542
  init_errors();
@@ -14992,7 +15544,7 @@ var init_add = __esm({
14992
15544
  init_http();
14993
15545
  init_shared2();
14994
15546
  NEXT = 'kenso tasks add "Send the deck" --due tomorrow --account 812';
14995
- command47 = {
15547
+ command51 = {
14996
15548
  resource: "tasks",
14997
15549
  action: "add",
14998
15550
  summary: "Add a task: a title, an optional due day and time, assignee and the account, person or deal it is about",
@@ -15019,15 +15571,15 @@ var init_add = __esm({
15019
15571
  if (typeof flags.notes === "string") body2.notes = flags.notes;
15020
15572
  Object.assign(body2, due(typeof flags.due === "string" ? flags.due : void 0, typeof flags.at === "string" ? flags.at : void 0));
15021
15573
  if (typeof flags.assignee === "string") body2.assigneeMemberId = await memberId(ctx, flags.assignee, "assignee", NEXT);
15022
- if (typeof flags.account === "string") body2.accountId = positiveId3(flags.account, "account", NEXT);
15023
- if (typeof flags.person === "string") body2.personId = positiveId3(flags.person, "person", NEXT);
15024
- if (typeof flags.deal === "string") body2.opportunityId = positiveId3(flags.deal, "deal", NEXT);
15574
+ if (typeof flags.account === "string") body2.accountId = positiveId4(flags.account, "account", NEXT);
15575
+ if (typeof flags.person === "string") body2.personId = positiveId4(flags.person, "person", NEXT);
15576
+ if (typeof flags.deal === "string") body2.opportunityId = positiveId4(flags.deal, "deal", NEXT);
15025
15577
  const res = await ctx.client.request({ method: "POST", path: "/v1/tasks", body: body2, signal: ctx.signal });
15026
15578
  ctx.output.object(unwrap(res.body));
15027
15579
  return ExitCode.Ok;
15028
15580
  }
15029
15581
  };
15030
- add_default = command47;
15582
+ add_default2 = command51;
15031
15583
  }
15032
15584
  });
15033
15585
 
@@ -15046,7 +15598,7 @@ async function patchTask(ctx, taskId, change) {
15046
15598
  return unwrap((await send2()).body);
15047
15599
  }
15048
15600
  }
15049
- var command48, done_default;
15601
+ var command52, done_default;
15050
15602
  var init_done = __esm({
15051
15603
  "src/commands/tasks/done.ts"() {
15052
15604
  "use strict";
@@ -15054,7 +15606,7 @@ var init_done = __esm({
15054
15606
  init_exit_codes();
15055
15607
  init_http();
15056
15608
  init_shared2();
15057
- command48 = {
15609
+ command52 = {
15058
15610
  resource: "tasks",
15059
15611
  action: "done",
15060
15612
  summary: "Complete one or more tasks (--undo reopens them)",
@@ -15065,7 +15617,7 @@ var init_done = __esm({
15065
15617
  beta: { featureGates: { all: ["tasks"] } },
15066
15618
  operationIds: ["tasks.update"],
15067
15619
  async run(ctx, { flags, positionals }) {
15068
- const ids2 = [...new Set(positionals.map((text4) => positiveId3(text4, "taskId", "kenso tasks done <taskId>...")))];
15620
+ const ids2 = [...new Set(positionals.map((text4) => positiveId4(text4, "taskId", "kenso tasks done <taskId>...")))];
15069
15621
  const change = { status: flags.undo === true ? "open" : "done" };
15070
15622
  if (ids2.length === 1) ctx.output.object(await patchTask(ctx, ids2[0], change));
15071
15623
  else
@@ -15077,7 +15629,7 @@ var init_done = __esm({
15077
15629
  return ExitCode.Ok;
15078
15630
  }
15079
15631
  };
15080
- done_default = command48;
15632
+ done_default = command52;
15081
15633
  }
15082
15634
  });
15083
15635
 
@@ -15086,7 +15638,7 @@ var assign_exports = {};
15086
15638
  __export(assign_exports, {
15087
15639
  default: () => assign_default
15088
15640
  });
15089
- var NEXT2, command49, assign_default;
15641
+ var NEXT2, command53, assign_default;
15090
15642
  var init_assign = __esm({
15091
15643
  "src/commands/tasks/assign.ts"() {
15092
15644
  "use strict";
@@ -15094,7 +15646,7 @@ var init_assign = __esm({
15094
15646
  init_done();
15095
15647
  init_shared2();
15096
15648
  NEXT2 = "kenso tasks assign <taskId> <me|memberId|email>";
15097
- command49 = {
15649
+ command53 = {
15098
15650
  resource: "tasks",
15099
15651
  action: "assign",
15100
15652
  summary: "Give a task to a member",
@@ -15108,13 +15660,13 @@ var init_assign = __esm({
15108
15660
  beta: { featureGates: { all: ["tasks"] } },
15109
15661
  operationIds: ["tasks.update", "me.get", "members.list"],
15110
15662
  async run(ctx, { positionals }) {
15111
- const taskId = positiveId3(positionals[0], "taskId", NEXT2);
15663
+ const taskId = positiveId4(positionals[0], "taskId", NEXT2);
15112
15664
  const assignee = await memberId(ctx, positionals[1] ?? "", "member", NEXT2);
15113
15665
  ctx.output.object(await patchTask(ctx, taskId, { assigneeMemberId: assignee }));
15114
15666
  return ExitCode.Ok;
15115
15667
  }
15116
15668
  };
15117
- assign_default = command49;
15669
+ assign_default = command53;
15118
15670
  }
15119
15671
  });
15120
15672
 
@@ -15123,14 +15675,14 @@ var queue_exports = {};
15123
15675
  __export(queue_exports, {
15124
15676
  default: () => queue_default
15125
15677
  });
15126
- var SCOPES, command50, queue_default;
15678
+ var SCOPES, command54, queue_default;
15127
15679
  var init_queue = __esm({
15128
15680
  "src/commands/tasks/queue.ts"() {
15129
15681
  "use strict";
15130
15682
  init_errors();
15131
15683
  init_exit_codes();
15132
15684
  SCOPES = ["mine", "assigned_by_me", "everyone"];
15133
- command50 = {
15685
+ command54 = {
15134
15686
  resource: "tasks",
15135
15687
  action: "queue",
15136
15688
  summary: "Your open work by due day: tasks, touches, call tasks, reply reminders and Ken follow-ups",
@@ -15151,17 +15703,17 @@ var init_queue = __esm({
15151
15703
  return ExitCode.Ok;
15152
15704
  }
15153
15705
  };
15154
- queue_default = command50;
15706
+ queue_default = command54;
15155
15707
  }
15156
15708
  });
15157
15709
 
15158
15710
  // src/commands/tasks/index.ts
15159
- var actions25;
15711
+ var actions26;
15160
15712
  var init_tasks = __esm({
15161
15713
  "src/commands/tasks/index.ts"() {
15162
15714
  "use strict";
15163
- actions25 = {
15164
- add: () => Promise.resolve().then(() => (init_add(), add_exports)).then((m) => m.default),
15715
+ actions26 = {
15716
+ add: () => Promise.resolve().then(() => (init_add2(), add_exports2)).then((m) => m.default),
15165
15717
  done: () => Promise.resolve().then(() => (init_done(), done_exports)).then((m) => m.default),
15166
15718
  assign: () => Promise.resolve().then(() => (init_assign(), assign_exports)).then((m) => m.default),
15167
15719
  queue: () => Promise.resolve().then(() => (init_queue(), queue_exports)).then((m) => m.default)
@@ -15265,7 +15817,7 @@ __export(listen_exports, {
15265
15817
  liveBody: () => liveBody
15266
15818
  });
15267
15819
  import { randomBytes as randomBytes3 } from "node:crypto";
15268
- import { setTimeout as delay8 } from "node:timers/promises";
15820
+ import { setTimeout as delay9 } from "node:timers/promises";
15269
15821
  function eventTypes(value) {
15270
15822
  const list2 = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
15271
15823
  return list2.flatMap((item) => item.split(",")).map((item) => item.trim()).filter((item) => item !== "");
@@ -15301,7 +15853,7 @@ function readBody(req) {
15301
15853
  function reply(res, status, body2) {
15302
15854
  res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(body2));
15303
15855
  }
15304
- var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command51, listen_default;
15856
+ var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command55, listen_default;
15305
15857
  var init_listen = __esm({
15306
15858
  "src/commands/webhooks/listen.ts"() {
15307
15859
  "use strict";
@@ -15312,7 +15864,7 @@ var init_listen = __esm({
15312
15864
  MIN_POLL_MS = 1e3;
15313
15865
  MAX_POLL_MS = 6e4;
15314
15866
  MAX_TRIGGER_BYTES = 1e6;
15315
- command51 = {
15867
+ command55 = {
15316
15868
  resource: "webhooks",
15317
15869
  action: "listen",
15318
15870
  summary: "Stream the workspace's events and forward them, signed, to a local handler",
@@ -15338,17 +15890,17 @@ var init_listen = __esm({
15338
15890
  `);
15339
15891
  return ExitCode.Ok;
15340
15892
  }
15341
- const target = typeof flags["forward-to"] === "string" ? forwardUrl(flags["forward-to"]) : void 0;
15893
+ const target2 = typeof flags["forward-to"] === "string" ? forwardUrl(flags["forward-to"]) : void 0;
15342
15894
  const types = eventTypes(flags.events);
15343
15895
  const workspaceId = ctx.auth.workspaceId;
15344
15896
  if (ctx.flags.dryRun) {
15345
- const next = ["kenso webhooks listen", target ? `--forward-to ${target}` : "", types.length > 0 ? `--events ${types.join(",")}` : ""];
15346
- ctx.output.object({ dryRun: true, forwardTo: target ?? null, events: types.length > 0 ? types : "all", secretFile: signingSecretPath(ctx.env), next: next.filter((p) => p).join(" ") });
15897
+ const next = ["kenso webhooks listen", target2 ? `--forward-to ${target2}` : "", types.length > 0 ? `--events ${types.join(",")}` : ""];
15898
+ ctx.output.object({ dryRun: true, forwardTo: target2 ?? null, events: types.length > 0 ? types : "all", secretFile: signingSecretPath(ctx.env), next: next.filter((p) => p).join(" ") });
15347
15899
  return ExitCode.Ok;
15348
15900
  }
15349
15901
  const counts2 = { events: 0, forwarded: 0, failed: 0 };
15350
15902
  const deliver = async (event) => {
15351
- const result = target ? await forward(target, event, secret, ctx.signal) : void 0;
15903
+ const result = target2 ? await forward(target2, event, secret, ctx.signal) : void 0;
15352
15904
  counts2.events++;
15353
15905
  if (result?.status !== void 0 && result.status < 300) counts2.forwarded++;
15354
15906
  else if (result) counts2.failed++;
@@ -15384,9 +15936,9 @@ var init_listen = __esm({
15384
15936
  });
15385
15937
  await new Promise((resolve16) => server.listen(0, "127.0.0.1", resolve16));
15386
15938
  const url = `http://127.0.0.1:${server.address().port}/events`;
15387
- writeListenerState(ctx.env, workspaceId, { pid: process.pid, url, token, forwardTo: target, startedAt: (/* @__PURE__ */ new Date()).toISOString() });
15939
+ writeListenerState(ctx.env, workspaceId, { pid: process.pid, url, token, forwardTo: target2, startedAt: (/* @__PURE__ */ new Date()).toISOString() });
15388
15940
  try {
15389
- ctx.output.info(`Ready. ${target ? `Forwarding events to ${target}.` : "Printing events (add --forward-to to send them to your handler)."}`);
15941
+ ctx.output.info(`Ready. ${target2 ? `Forwarding events to ${target2}.` : "Printing events (add --forward-to to send them to your handler)."}`);
15390
15942
  ctx.output.info(`Signing secret: ${secret} (the same on every run; kept in ${signingSecretPath(ctx.env)}).`);
15391
15943
  ctx.output.info(`Send a sample: kenso webhooks trigger reply.received. Stop with Ctrl-C.`);
15392
15944
  while (!ctx.signal.aborted) {
@@ -15405,7 +15957,7 @@ var init_listen = __esm({
15405
15957
  ctx.output.warn(`Polling failed (${err.message}); trying again in ${MAX_POLL_MS / 1e3} s.`);
15406
15958
  }
15407
15959
  }
15408
- await delay8(waitMs, void 0, { signal: ctx.signal }).catch(() => void 0);
15960
+ await delay9(waitMs, void 0, { signal: ctx.signal }).catch(() => void 0);
15409
15961
  }
15410
15962
  } catch (err) {
15411
15963
  if (!ctx.signal.aborted) throw err;
@@ -15418,7 +15970,7 @@ var init_listen = __esm({
15418
15970
  return ExitCode.Ok;
15419
15971
  }
15420
15972
  };
15421
- listen_default = command51;
15973
+ listen_default = command55;
15422
15974
  }
15423
15975
  });
15424
15976
 
@@ -15437,7 +15989,7 @@ function notRunning() {
15437
15989
  next: LISTEN_NEXT
15438
15990
  });
15439
15991
  }
15440
- var LISTEN_NEXT, command52, trigger_default;
15992
+ var LISTEN_NEXT, command56, trigger_default;
15441
15993
  var init_trigger = __esm({
15442
15994
  "src/commands/webhooks/trigger.ts"() {
15443
15995
  "use strict";
@@ -15446,7 +15998,7 @@ var init_trigger = __esm({
15446
15998
  init_http();
15447
15999
  init_local();
15448
16000
  LISTEN_NEXT = "kenso webhooks listen --forward-to http://localhost:3000/hook";
15449
- command52 = {
16001
+ command56 = {
15450
16002
  resource: "webhooks",
15451
16003
  action: "trigger",
15452
16004
  summary: "Send a sample event of one type through the running kenso webhooks listen",
@@ -15503,16 +16055,16 @@ var init_trigger = __esm({
15503
16055
  return ExitCode.Ok;
15504
16056
  }
15505
16057
  };
15506
- trigger_default = command52;
16058
+ trigger_default = command56;
15507
16059
  }
15508
16060
  });
15509
16061
 
15510
16062
  // src/commands/webhooks/index.ts
15511
- var actions26;
16063
+ var actions27;
15512
16064
  var init_webhooks2 = __esm({
15513
16065
  "src/commands/webhooks/index.ts"() {
15514
16066
  "use strict";
15515
- actions26 = {
16067
+ actions27 = {
15516
16068
  listen: () => Promise.resolve().then(() => (init_listen(), listen_exports)).then((m) => m.default),
15517
16069
  trigger: () => Promise.resolve().then(() => (init_trigger(), trigger_exports)).then((m) => m.default)
15518
16070
  };
@@ -15522,14 +16074,14 @@ var init_webhooks2 = __esm({
15522
16074
  // src/commands/work/common.ts
15523
16075
  import { randomUUID as randomUUID2 } from "node:crypto";
15524
16076
  import { join as join16 } from "node:path";
15525
- import { setTimeout as delay9 } from "node:timers/promises";
16077
+ import { setTimeout as delay10 } from "node:timers/promises";
15526
16078
  function unavailable(err) {
15527
16079
  return err instanceof KensoError && (err.code === "network_error" || err.httpStatus === 502 || err.httpStatus === 503 || err.httpStatus === 504);
15528
16080
  }
15529
16081
  async function pause3(ms, signal) {
15530
16082
  if (signal.aborted) return false;
15531
16083
  try {
15532
- await delay9(ms, void 0, { signal });
16084
+ await delay10(ms, void 0, { signal });
15533
16085
  return true;
15534
16086
  } catch {
15535
16087
  return false;
@@ -15707,14 +16259,14 @@ var status_exports3 = {};
15707
16259
  __export(status_exports3, {
15708
16260
  default: () => status_default3
15709
16261
  });
15710
- var command53, status_default3;
16262
+ var command57, status_default3;
15711
16263
  var init_status3 = __esm({
15712
16264
  "src/commands/work/status.ts"() {
15713
16265
  "use strict";
15714
16266
  init_exit_codes();
15715
16267
  init_http();
15716
16268
  init_common3();
15717
- command53 = {
16269
+ command57 = {
15718
16270
  resource: "work",
15719
16271
  action: "status",
15720
16272
  summary: "Show the Kenso AI work waiting for your own agent, per kind",
@@ -15748,7 +16300,7 @@ var init_status3 = __esm({
15748
16300
  return ExitCode.Ok;
15749
16301
  }
15750
16302
  };
15751
- status_default3 = command53;
16303
+ status_default3 = command57;
15752
16304
  }
15753
16305
  });
15754
16306
 
@@ -15880,9 +16432,9 @@ var init_files = __esm({
15880
16432
  import { execFile, spawnSync as spawnSync2 } from "node:child_process";
15881
16433
  import { readFileSync as readFileSync12 } from "node:fs";
15882
16434
  import { isAbsolute as isAbsolute2 } from "node:path";
15883
- function sudoArgs(user, command61, args, keep = [], set = {}) {
16435
+ function sudoArgs(user, command65, args, keep = [], set = {}) {
15884
16436
  const assignments = Object.entries(set).map(([name, value]) => `${name}=${value}`);
15885
- return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command61, ...args];
16437
+ return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command65, ...args];
15886
16438
  }
15887
16439
  function agentKensoEnv(opts) {
15888
16440
  return {
@@ -15892,12 +16444,12 @@ function agentKensoEnv(opts) {
15892
16444
  AI_AGENT: opts.agentName
15893
16445
  };
15894
16446
  }
15895
- function sudoExec(user, command61, args, opts = {}) {
16447
+ function sudoExec(user, command65, args, opts = {}) {
15896
16448
  const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
15897
16449
  return new Promise((resolve16) => {
15898
16450
  execFile(
15899
16451
  sudo,
15900
- [...lead, ...sudoArgs(user.name, command61, args)],
16452
+ [...lead, ...sudoArgs(user.name, command65, args)],
15901
16453
  { env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
15902
16454
  (err, stdout, stderr) => {
15903
16455
  const code = err ? err.code : 0;
@@ -16007,9 +16559,9 @@ var init_folder2 = __esm({
16007
16559
  init_redact();
16008
16560
  init_agent_user();
16009
16561
  WorkRunFolder = class {
16010
- constructor(ctx, command61, args, outDir, shared = false) {
16562
+ constructor(ctx, command65, args, outDir, shared = false) {
16011
16563
  this.ctx = ctx;
16012
- this.command = command61;
16564
+ this.command = command65;
16013
16565
  this.args = args;
16014
16566
  this.outDir = outDir;
16015
16567
  this.shared = shared;
@@ -16124,7 +16676,7 @@ var pull_exports2 = {};
16124
16676
  __export(pull_exports2, {
16125
16677
  default: () => pull_default2
16126
16678
  });
16127
- var MAX_FILES, command54, pull_default2;
16679
+ var MAX_FILES, command58, pull_default2;
16128
16680
  var init_pull2 = __esm({
16129
16681
  "src/commands/work/pull.ts"() {
16130
16682
  "use strict";
@@ -16133,7 +16685,7 @@ var init_pull2 = __esm({
16133
16685
  init_common3();
16134
16686
  init_folder2();
16135
16687
  MAX_FILES = 100;
16136
- command54 = {
16688
+ command58 = {
16137
16689
  resource: "work",
16138
16690
  action: "pull",
16139
16691
  summary: "Claim waiting work into local work files, to answer by hand",
@@ -16211,7 +16763,7 @@ var init_pull2 = __esm({
16211
16763
  return interrupted7 ? ExitCode.Interrupted : ExitCode.Ok;
16212
16764
  }
16213
16765
  };
16214
- pull_default2 = command54;
16766
+ pull_default2 = command58;
16215
16767
  }
16216
16768
  });
16217
16769
 
@@ -16353,7 +16905,7 @@ __export(submit_exports, {
16353
16905
  default: () => submit_default
16354
16906
  });
16355
16907
  import { resolve as resolve14 } from "node:path";
16356
- var command55, submit_default;
16908
+ var command59, submit_default;
16357
16909
  var init_submit = __esm({
16358
16910
  "src/commands/work/submit.ts"() {
16359
16911
  "use strict";
@@ -16362,7 +16914,7 @@ var init_submit = __esm({
16362
16914
  init_files();
16363
16915
  init_answers();
16364
16916
  init_common3();
16365
- command55 = {
16917
+ command59 = {
16366
16918
  resource: "work",
16367
16919
  action: "submit",
16368
16920
  summary: "Send answers files to Kenso and write each one's results",
@@ -16394,7 +16946,7 @@ var init_submit = __esm({
16394
16946
  return totals.rejected > 0 ? ExitCode.Partial : ExitCode.Ok;
16395
16947
  }
16396
16948
  };
16397
- submit_default = command55;
16949
+ submit_default = command59;
16398
16950
  }
16399
16951
  });
16400
16952
 
@@ -16415,7 +16967,7 @@ function claimIdOf(arg) {
16415
16967
  if (!CLAIM_ID.test(arg)) throw usageError(`"${arg}" is neither a claim id nor a work file.`, { field: "claim", hint: "Claim ids look like awc_8fK2..." });
16416
16968
  return arg;
16417
16969
  }
16418
- var CLAIM_ID, command56, release_default;
16970
+ var CLAIM_ID, command60, release_default;
16419
16971
  var init_release = __esm({
16420
16972
  "src/commands/work/release.ts"() {
16421
16973
  "use strict";
@@ -16424,7 +16976,7 @@ var init_release = __esm({
16424
16976
  init_files();
16425
16977
  init_common3();
16426
16978
  CLAIM_ID = /^[A-Za-z0-9_-]{1,64}$/;
16427
- command56 = {
16979
+ command60 = {
16428
16980
  resource: "work",
16429
16981
  action: "release",
16430
16982
  summary: "Give claimed work back to the queue now",
@@ -16443,7 +16995,7 @@ var init_release = __esm({
16443
16995
  return ExitCode.Ok;
16444
16996
  }
16445
16997
  };
16446
- release_default = command56;
16998
+ release_default = command60;
16447
16999
  }
16448
17000
  });
16449
17001
 
@@ -16452,7 +17004,7 @@ import { spawn as nodeSpawn3 } from "node:child_process";
16452
17004
  import { rmSync as rmSync3, statSync as statSync2 } from "node:fs";
16453
17005
  import { access, constants as constants2 } from "node:fs/promises";
16454
17006
  import { delimiter as delimiter2, join as join20 } from "node:path";
16455
- import { setTimeout as delay10 } from "node:timers/promises";
17007
+ import { setTimeout as delay11 } from "node:timers/promises";
16456
17008
  function childEnv(parent, adapter, extra) {
16457
17009
  const scrub = new Set(adapter.scrubEnv.map((name) => name.toUpperCase()));
16458
17010
  const env = {};
@@ -16545,7 +17097,7 @@ async function groupGone(pid, runAs) {
16545
17097
  while (Date.now() < deadline) {
16546
17098
  if (runAs) {
16547
17099
  if (!await sudoKill(runAs, "SIGKILL", pid)) return;
16548
- await delay10(100);
17100
+ await delay11(100);
16549
17101
  continue;
16550
17102
  }
16551
17103
  try {
@@ -16553,7 +17105,7 @@ async function groupGone(pid, runAs) {
16553
17105
  } catch {
16554
17106
  return;
16555
17107
  }
16556
- await delay10(25);
17108
+ await delay11(25);
16557
17109
  }
16558
17110
  }
16559
17111
  function runChild(spawnFn, bin, built, job, env, signal, runAs) {
@@ -16782,12 +17334,12 @@ function plain(text4) {
16782
17334
  return text4.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
16783
17335
  }
16784
17336
  function runStatus(bin, args, env, adapter, runAs) {
16785
- const command61 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
17337
+ const command65 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
16786
17338
  const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
16787
17339
  const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
16788
17340
  return new Promise((resolve16) => {
16789
17341
  execFile2(
16790
- command61,
17342
+ command65,
16791
17343
  commandArgs2,
16792
17344
  { ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
16793
17345
  (err, stdout, stderr) => {
@@ -17869,7 +18421,7 @@ var run_exports3 = {};
17869
18421
  __export(run_exports3, {
17870
18422
  default: () => run_default2
17871
18423
  });
17872
- var FAILURES_IN_A_ROW, command57, run_default2;
18424
+ var FAILURES_IN_A_ROW, command61, run_default2;
17873
18425
  var init_run3 = __esm({
17874
18426
  "src/commands/work/run.ts"() {
17875
18427
  "use strict";
@@ -17890,7 +18442,7 @@ var init_run3 = __esm({
17890
18442
  init_folder2();
17891
18443
  init_stop();
17892
18444
  FAILURES_IN_A_ROW = 3;
17893
- command57 = {
18445
+ command61 = {
17894
18446
  resource: "work",
17895
18447
  action: "run",
17896
18448
  summary: "Run your own coding agent on the waiting work until the queue is empty",
@@ -18215,16 +18767,16 @@ var init_run3 = __esm({
18215
18767
  return exitCodeFor(reason, totals.rejected > 0 || jobsFailed > 0);
18216
18768
  }
18217
18769
  };
18218
- run_default2 = command57;
18770
+ run_default2 = command61;
18219
18771
  }
18220
18772
  });
18221
18773
 
18222
18774
  // src/commands/work/index.ts
18223
- var actions27;
18775
+ var actions28;
18224
18776
  var init_work2 = __esm({
18225
18777
  "src/commands/work/index.ts"() {
18226
18778
  "use strict";
18227
- actions27 = {
18779
+ actions28 = {
18228
18780
  status: () => Promise.resolve().then(() => (init_status3(), status_exports3)).then((m) => m.default),
18229
18781
  pull: () => Promise.resolve().then(() => (init_pull2(), pull_exports2)).then((m) => m.default),
18230
18782
  submit: () => Promise.resolve().then(() => (init_submit(), submit_exports)).then((m) => m.default),
@@ -18255,7 +18807,7 @@ function rewrap(err, overrides) {
18255
18807
  details: err.details
18256
18808
  });
18257
18809
  }
18258
- var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command58, keys_default;
18810
+ var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command62, keys_default;
18259
18811
  var init_keys = __esm({
18260
18812
  "src/commands/workspace/keys.ts"() {
18261
18813
  "use strict";
@@ -18265,7 +18817,7 @@ var init_keys = __esm({
18265
18817
  TEMPLATES = ["admin", "editor", "viewer"];
18266
18818
  APP_NEXT_STEP = "A workspace admin can create it in the app: Settings > API keys > Workspace keys";
18267
18819
  NOT_AVAILABLE = "Workspace keys are not available for this workspace yet.";
18268
- command58 = {
18820
+ command62 = {
18269
18821
  resource: "workspace",
18270
18822
  action: "keys",
18271
18823
  summary: "Create an API key the workspace owns",
@@ -18326,14 +18878,14 @@ var init_keys = __esm({
18326
18878
  return ExitCode.Ok;
18327
18879
  }
18328
18880
  };
18329
- keys_default = command58;
18881
+ keys_default = command62;
18330
18882
  }
18331
18883
  });
18332
18884
 
18333
18885
  // src/commands/workspace/list.ts
18334
- var list_exports3 = {};
18335
- __export(list_exports3, {
18336
- default: () => list_default3
18886
+ var list_exports4 = {};
18887
+ __export(list_exports4, {
18888
+ default: () => list_default4
18337
18889
  });
18338
18890
  function parseLimit(value) {
18339
18891
  if (value === void 0) return void 0;
@@ -18344,14 +18896,14 @@ function parseLimit(value) {
18344
18896
  }
18345
18897
  return limit;
18346
18898
  }
18347
- var MAX_LIMIT, command59, list_default3;
18348
- var init_list3 = __esm({
18899
+ var MAX_LIMIT, command63, list_default4;
18900
+ var init_list4 = __esm({
18349
18901
  "src/commands/workspace/list.ts"() {
18350
18902
  "use strict";
18351
18903
  init_errors();
18352
18904
  init_exit_codes();
18353
18905
  MAX_LIMIT = 200;
18354
- command59 = {
18906
+ command63 = {
18355
18907
  resource: "workspace",
18356
18908
  action: "list",
18357
18909
  summary: "List the workspaces your key can use",
@@ -18379,7 +18931,7 @@ var init_list3 = __esm({
18379
18931
  return ExitCode.Ok;
18380
18932
  }
18381
18933
  };
18382
- list_default3 = command59;
18934
+ list_default4 = command63;
18383
18935
  }
18384
18936
  });
18385
18937
 
@@ -18388,7 +18940,7 @@ var use_exports = {};
18388
18940
  __export(use_exports, {
18389
18941
  default: () => use_default
18390
18942
  });
18391
- var command60, use_default;
18943
+ var command64, use_default;
18392
18944
  var init_use = __esm({
18393
18945
  "src/commands/workspace/use.ts"() {
18394
18946
  "use strict";
@@ -18396,7 +18948,7 @@ var init_use = __esm({
18396
18948
  init_errors();
18397
18949
  init_exit_codes();
18398
18950
  init_http();
18399
- command60 = {
18951
+ command64 = {
18400
18952
  resource: "workspace",
18401
18953
  action: "use",
18402
18954
  summary: "Set the profile's default workspace",
@@ -18453,18 +19005,18 @@ var init_use = __esm({
18453
19005
  return ExitCode.Ok;
18454
19006
  }
18455
19007
  };
18456
- use_default = command60;
19008
+ use_default = command64;
18457
19009
  }
18458
19010
  });
18459
19011
 
18460
19012
  // src/commands/workspace/index.ts
18461
- var actions28;
19013
+ var actions29;
18462
19014
  var init_workspace = __esm({
18463
19015
  "src/commands/workspace/index.ts"() {
18464
19016
  "use strict";
18465
- actions28 = {
19017
+ actions29 = {
18466
19018
  keys: () => Promise.resolve().then(() => (init_keys(), keys_exports)).then((m) => m.default),
18467
- list: () => Promise.resolve().then(() => (init_list3(), list_exports3)).then((m) => m.default),
19019
+ list: () => Promise.resolve().then(() => (init_list4(), list_exports4)).then((m) => m.default),
18468
19020
  use: () => Promise.resolve().then(() => (init_use(), use_exports)).then((m) => m.default)
18469
19021
  };
18470
19022
  }
@@ -18499,6 +19051,7 @@ var init_registry = __esm({
18499
19051
  init_jobs2();
18500
19052
  init_logs();
18501
19053
  init_mcp();
19054
+ init_notes();
18502
19055
  init_opportunities();
18503
19056
  init_people();
18504
19057
  init_pipelines();
@@ -18530,19 +19083,20 @@ var init_registry = __esm({
18530
19083
  logout: topLevel("logout", actions4.logout, "kenso auth logout"),
18531
19084
  logs: actions15,
18532
19085
  mcp: actions16,
18533
- opportunities: actions17,
18534
- people: actions18,
18535
- pipelines: actions19,
18536
- reports: actions20,
18537
- runs: actions21,
18538
- sandbox: actions22,
18539
- skill: actions23,
18540
- studio: actions24,
18541
- tasks: actions25,
18542
- webhooks: actions26,
19086
+ notes: actions17,
19087
+ opportunities: actions18,
19088
+ people: actions19,
19089
+ pipelines: actions20,
19090
+ reports: actions21,
19091
+ runs: actions22,
19092
+ sandbox: actions23,
19093
+ skill: actions24,
19094
+ studio: actions25,
19095
+ tasks: actions26,
19096
+ webhooks: actions27,
18543
19097
  whoami: topLevel("whoami", actions4.status, "kenso auth status"),
18544
- work: actions27,
18545
- workspace: actions28
19098
+ work: actions28,
19099
+ workspace: actions29
18546
19100
  };
18547
19101
  resourceAliases = { leads: "contacts" };
18548
19102
  }
@@ -18679,8 +19233,8 @@ async function renderTopHelp(opts) {
18679
19233
  names.push(withPositionals(spec, spec.action));
18680
19234
  groups.set(hint, names);
18681
19235
  }
18682
- const actions30 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
18683
- if (actions30.length > 0) rows.push([resource, actions30.join(", ")]);
19236
+ const actions31 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
19237
+ if (actions31.length > 0) rows.push([resource, actions31.join(", ")]);
18684
19238
  }
18685
19239
  const at = 4 + Math.min(22, Math.max(0, ...rows.map(([left]) => left.length)));
18686
19240
  lines.push(
@@ -18693,7 +19247,7 @@ async function renderTopHelp(opts) {
18693
19247
  const [area = "", action = ""] = name.split(" ");
18694
19248
  byArea.set(area, [...byArea.get(area) ?? [], action]);
18695
19249
  }
18696
- const named = [...byArea.entries()].map(([area, actions30]) => `${area} ${actions30.join("|")}`);
19250
+ const named = [...byArea.entries()].map(([area, actions31]) => `${area} ${actions31.join("|")}`);
18697
19251
  lines.push(wrap(`Beta, hidden here but they run (the server decides): ${named.join(", ")}.`, " "));
18698
19252
  }
18699
19253
  const generated = await listGenerated({ features: opts.allCommands ? [] : getFeatures, env: opts.env });
@@ -18701,13 +19255,13 @@ async function renderTopHelp(opts) {
18701
19255
  if (visible.length > 0) {
18702
19256
  const byResource = /* @__PURE__ */ new Map();
18703
19257
  for (const g of visible) {
18704
- const actions30 = byResource.get(g.resource) ?? [];
18705
- actions30.push(`${g.action}${g.beta ? " (beta)" : ""}`);
18706
- byResource.set(g.resource, actions30);
19258
+ const actions31 = byResource.get(g.resource) ?? [];
19259
+ actions31.push(`${g.action}${g.beta ? " (beta)" : ""}`);
19260
+ byResource.set(g.resource, actions31);
18707
19261
  }
18708
19262
  const sorted2 = [...byResource.entries()].sort(([a], [b]) => a.localeCompare(b));
18709
19263
  if (opts.allCommands) {
18710
- const generatedRows = sorted2.map(([resource, actions30]) => [resource, actions30.sort().join(", ")]);
19264
+ const generatedRows = sorted2.map(([resource, actions31]) => [resource, actions31.sort().join(", ")]);
18711
19265
  lines.push("", "API resources (kenso <resource> <action>):", columns(generatedRows));
18712
19266
  } else {
18713
19267
  const names = new Set(sorted2.map(([resource]) => resource));
@@ -19023,8 +19577,8 @@ function startUpdateNotice(argv, opts = {}) {
19023
19577
  if (!found) return;
19024
19578
  writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
19025
19579
  if (isNewer(found, version)) {
19026
- const command61 = updateCommand(install, opts.platform ?? process.platform);
19027
- stderr.write(`kenso ${found} is out (you have ${version}): ${command61}
19580
+ const command65 = updateCommand(install, opts.platform ?? process.platform);
19581
+ stderr.write(`kenso ${found} is out (you have ${version}): ${command65}
19028
19582
  Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
19029
19583
  `);
19030
19584
  }
@@ -19066,7 +19620,7 @@ function resources() {
19066
19620
  const names = Object.entries(handWritten).filter(([, area]) => Object.keys(area).length > 0).map(([resource]) => resource);
19067
19621
  return sorted([...names, ...Object.keys(resourceAliases), ...loadManifest().operations.map((op) => op.resource)]);
19068
19622
  }
19069
- function actions29(resource) {
19623
+ function actions30(resource) {
19070
19624
  const own = Object.keys(handWritten[resource] ?? {}).filter((action) => action !== "");
19071
19625
  return sorted([...own, ...loadManifest().operations.filter((op) => op.resource === resource).map((op) => op.action)]);
19072
19626
  }
@@ -19131,7 +19685,7 @@ async function completions(words, globals) {
19131
19685
  return flagsOf2(spec, globals, positionals.length === 0);
19132
19686
  }
19133
19687
  if (positionals.length === 0) return resources();
19134
- if (!spec) return positionals.length === 1 ? actions29(resourceAliases[positionals[0]] ?? positionals[0]) : [];
19688
+ if (!spec) return positionals.length === 1 ? actions30(resourceAliases[positionals[0]] ?? positionals[0]) : [];
19135
19689
  const given = positionals.length - commandWords;
19136
19690
  const declared = spec.positionals ?? [];
19137
19691
  if (given < declared.length || declared.at(-1)?.variadic === true) {
@@ -19225,9 +19779,9 @@ function normalizeBooleans(argv, names, strict) {
19225
19779
  async function knownCommands() {
19226
19780
  const commands = /* @__PURE__ */ new Set();
19227
19781
  for (const [resource, area] of Object.entries(handWritten)) {
19228
- const actions30 = Object.keys(area);
19229
- if (actions30.length > 0) commands.add(resource);
19230
- for (const action of actions30) commands.add(action ? `${resource} ${action}` : resource);
19782
+ const actions31 = Object.keys(area);
19783
+ if (actions31.length > 0) commands.add(resource);
19784
+ for (const action of actions31) commands.add(action ? `${resource} ${action}` : resource);
19231
19785
  }
19232
19786
  for (const g of await listGenerated({ features: [] })) {
19233
19787
  commands.add(g.resource);