kenso 0.1.149 → 0.1.151

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
@@ -3389,7 +3389,7 @@ var VERSION;
3389
3389
  var init_version = __esm({
3390
3390
  "src/core/version.ts"() {
3391
3391
  "use strict";
3392
- VERSION = true ? "0.1.149" : "0.0.0-dev";
3392
+ VERSION = true ? "0.1.151" : "0.0.0-dev";
3393
3393
  }
3394
3394
  });
3395
3395
 
@@ -3684,9 +3684,9 @@ async function readAnswer(ctx) {
3684
3684
  const lines = createInterface({ input: ctx.stdin ?? process.stdin, terminal: false });
3685
3685
  let onAbort;
3686
3686
  try {
3687
- return await new Promise((resolve21, reject) => {
3688
- lines.once("line", resolve21);
3689
- lines.once("close", () => resolve21(""));
3687
+ return await new Promise((resolve22, reject) => {
3688
+ lines.once("line", resolve22);
3689
+ lines.once("close", () => resolve22(""));
3690
3690
  onAbort = () => reject(interrupted());
3691
3691
  ctx.signal.addEventListener("abort", onAbort, { once: true });
3692
3692
  });
@@ -4702,9 +4702,9 @@ async function readRun(dir3) {
4702
4702
  return null;
4703
4703
  }
4704
4704
  if (!raw) return null;
4705
- const { runId, command: command88, createdAt, status } = raw;
4705
+ const { runId, command: command89, createdAt, status } = raw;
4706
4706
  if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
4707
- if (typeof command88 !== "string" || typeof createdAt !== "string") return null;
4707
+ if (typeof command89 !== "string" || typeof createdAt !== "string") return null;
4708
4708
  if (typeof status !== "string" || !STATUSES.includes(status)) return null;
4709
4709
  let chunksDone = chunkList(raw.chunksDone) ?? [];
4710
4710
  try {
@@ -4715,7 +4715,7 @@ async function readRun(dir3) {
4715
4715
  const record3 = {
4716
4716
  ...raw,
4717
4717
  runId,
4718
- command: command88,
4718
+ command: command89,
4719
4719
  args: asRecord3(raw.args) ?? {},
4720
4720
  createdAt,
4721
4721
  status,
@@ -4775,11 +4775,11 @@ async function loadRun(runId, env = process.env) {
4775
4775
  }
4776
4776
  return run;
4777
4777
  }
4778
- async function findIdentical(command88, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4778
+ async function findIdentical(command89, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4779
4779
  const identity = argsIdentity(args);
4780
4780
  const runs = await listRuns(env);
4781
4781
  return runs.filter(
4782
- (run) => run.command === command88 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4782
+ (run) => run.command === command89 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4783
4783
  );
4784
4784
  }
4785
4785
  function isOtherLiveProcess(pid) {
@@ -8202,8 +8202,8 @@ async function ask(ctx, path, body2, read2) {
8202
8202
  const res = await ctx.client.request({ method: "POST", path, body: body2 });
8203
8203
  const data = unwrap(res.body);
8204
8204
  if (!isRecord4(data)) return { estimate: data ?? null };
8205
- const estimate = Object.fromEntries(Object.entries(data).filter(([key]) => key !== "totalAmount" && !/usd/i.test(key)));
8206
- return { estimate, credits: await read2(data) };
8205
+ const estimate2 = Object.fromEntries(Object.entries(data).filter(([key]) => key !== "totalAmount" && !/usd/i.test(key)));
8206
+ return { estimate: estimate2, credits: await read2(data) };
8207
8207
  } catch (err) {
8208
8208
  if (mustRethrow(err)) throw err;
8209
8209
  ctx.output.warn(`Could not estimate the credits: ${err instanceof Error ? err.message : String(err)}`);
@@ -8212,10 +8212,10 @@ async function ask(ctx, path, body2, read2) {
8212
8212
  }
8213
8213
  async function creditEstimate(ctx, body2) {
8214
8214
  return ask(ctx, "/v1/credits/estimates", body2, (data) => {
8215
- const credits2 = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
8215
+ const credits3 = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
8216
8216
  return {
8217
- needed: credits2("totalMillicredits"),
8218
- available: credits2("availableMillicredits"),
8217
+ needed: credits3("totalMillicredits"),
8218
+ available: credits3("availableMillicredits"),
8219
8219
  sufficient: typeof data.sufficient === "boolean" ? data.sufficient : null
8220
8220
  };
8221
8221
  });
@@ -8305,8 +8305,8 @@ function idValue(value, field) {
8305
8305
  function shellQuote3(arg) {
8306
8306
  return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
8307
8307
  }
8308
- function commandLine2(ctx, command88, args, extra = []) {
8309
- const parts2 = ["kenso", ...command88.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
8308
+ function commandLine2(ctx, command89, args, extra = []) {
8309
+ const parts2 = ["kenso", ...command89.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
8310
8310
  for (const [name, value] of Object.entries(args.flags)) {
8311
8311
  if (value === void 0 || value === false) continue;
8312
8312
  if (value === true) parts2.push(`--${name}`);
@@ -8581,8 +8581,8 @@ var init_import = __esm({
8581
8581
  });
8582
8582
  const dryRun2 = ctx.flags.dryRun === true || ctx.flags.yes !== true;
8583
8583
  const mapping = Object.fromEntries(Object.entries(columns2.mapping).map(([header, field]) => [header, field === "domain" ? "domains" : field]));
8584
- const estimate = dryRun2 ? await estimateAccounts(ctx, items.length) : null;
8585
- const credits2 = estimate ? { ...creditsCheck(estimate.totalMillicredits, estimate.availableMillicredits), sufficient: estimate.sufficient } : creditsCheck(0, void 0);
8584
+ const estimate2 = dryRun2 ? await estimateAccounts(ctx, items.length) : null;
8585
+ const credits3 = estimate2 ? { ...creditsCheck(estimate2.totalMillicredits, estimate2.availableMillicredits), sufficient: estimate2.sufficient } : creditsCheck(0, void 0);
8586
8586
  const outcome = await runBatch(
8587
8587
  {
8588
8588
  command: COMMAND,
@@ -8595,7 +8595,7 @@ var init_import = __esm({
8595
8595
  execChunk: sendChunk,
8596
8596
  invalid: invalid2,
8597
8597
  dryRun: dryRun2,
8598
- dryRunExtra: dryRun2 ? { mapping, ignoredColumns: columns2.ignored, estimate, credits: credits2 } : void 0,
8598
+ dryRunExtra: dryRun2 ? { mapping, ignoredColumns: columns2.ignored, estimate: estimate2, credits: credits3 } : void 0,
8599
8599
  applyCommand: commandLine2(ctx, COMMAND, args, ["--yes"]),
8600
8600
  outDir: stringFlag(flags.out),
8601
8601
  summarize
@@ -8619,9 +8619,9 @@ function stringFlag2(flags, name) {
8619
8619
  const text4 = value.trim();
8620
8620
  return text4 === "" ? void 0 : text4;
8621
8621
  }
8622
- function requireFlag(flags, name, command88, hint) {
8622
+ function requireFlag(flags, name, command89, hint) {
8623
8623
  const value = stringFlag2(flags, name);
8624
- if (value === void 0) throw usageError(`--${name} is required for ${command88}.`, { field: name, next: `${command88} --help`, ...hint ? { hint } : {} });
8624
+ if (value === void 0) throw usageError(`--${name} is required for ${command89}.`, { field: name, next: `${command89} --help`, ...hint ? { hint } : {} });
8625
8625
  return value;
8626
8626
  }
8627
8627
  function positiveId(value) {
@@ -8630,8 +8630,8 @@ function positiveId(value) {
8630
8630
  const id = Number(text4);
8631
8631
  return Number.isSafeInteger(id) && id > 0 ? id : void 0;
8632
8632
  }
8633
- function idFlag(flags, name, command88) {
8634
- const raw = requireFlag(flags, name, command88);
8633
+ function idFlag(flags, name, command89) {
8634
+ const raw = requireFlag(flags, name, command89);
8635
8635
  const id = positiveId(raw);
8636
8636
  if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
8637
8637
  return id;
@@ -8651,8 +8651,8 @@ function isDryRun(ctx) {
8651
8651
  function shellQuote4(value) {
8652
8652
  return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
8653
8653
  }
8654
- function sameCommand2(command88, flags, ctx, extra = []) {
8655
- const parts2 = [command88];
8654
+ function sameCommand2(command89, flags, ctx, extra = []) {
8655
+ const parts2 = [command89];
8656
8656
  for (const [name, value] of Object.entries(flags)) {
8657
8657
  if (value === void 0 || value === false) continue;
8658
8658
  if (value === true) parts2.push(`--${name}`);
@@ -8884,12 +8884,12 @@ function filterBody(flags) {
8884
8884
  }
8885
8885
  return parsed2;
8886
8886
  }
8887
- function targetBody(flags, target2, command88) {
8887
+ function targetBody(flags, target2, command89) {
8888
8888
  const ids2 = idList(flags, "ids");
8889
8889
  const filter = filterBody(flags);
8890
8890
  const everything = flags.all === true;
8891
8891
  if (ids2 !== void 0 === (filter !== void 0 || everything)) {
8892
- throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command88} --help` });
8892
+ throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command89} --help` });
8893
8893
  }
8894
8894
  const exclude = idList(flags, "exclude-ids");
8895
8895
  if (exclude !== void 0 && ids2 !== void 0) throw usageError("--exclude-ids goes with --filter or --all.", { field: "exclude-ids" });
@@ -8910,14 +8910,14 @@ function tagSet(flags) {
8910
8910
  return set2;
8911
8911
  }
8912
8912
  function requestBody(flags, target2, dryRun2) {
8913
- const command88 = `kenso ${target2.resource} bulk-update`;
8913
+ const command89 = `kenso ${target2.resource} bulk-update`;
8914
8914
  const pairs = Array.isArray(flags.set) ? flags.set : typeof flags.set === "string" ? [flags.set] : [];
8915
8915
  const tags = target2.tags ? tagSet(flags) : {};
8916
8916
  if (pairs.length === 0 && Object.keys(tags).length === 0) {
8917
- throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${command88}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command88} --help` });
8917
+ throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${command89}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command89} --help` });
8918
8918
  }
8919
8919
  return {
8920
- ...targetBody(flags, target2, command88),
8920
+ ...targetBody(flags, target2, command89),
8921
8921
  set: { ...parseSet(pairs, target2.aliases, target2.textFields), ...tags },
8922
8922
  ...dryRun2 ? { dryRun: true } : {},
8923
8923
  ...flags["overwrite-pinned"] === true ? { overwritePinned: true } : {}
@@ -8983,7 +8983,7 @@ function bulkUpdateCommand(target2) {
8983
8983
  };
8984
8984
  }
8985
8985
  function bulkDeleteCommand(target2) {
8986
- const command88 = `kenso ${target2.resource} bulk-delete`;
8986
+ const command89 = `kenso ${target2.resource} bulk-delete`;
8987
8987
  return {
8988
8988
  resource: target2.resource,
8989
8989
  action: "bulk-delete",
@@ -9007,7 +9007,7 @@ function bulkDeleteCommand(target2) {
9007
9007
  beta: { featureGates: { all: target2.featureGates } },
9008
9008
  operationIds: [`${target2.resource}.bulk-delete`, "changes.get"],
9009
9009
  dryRun: true,
9010
- run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command88), dryRun: dryRun2 }))
9010
+ run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command89), dryRun: dryRun2 }))
9011
9011
  };
9012
9012
  }
9013
9013
  async function runChange(ctx, flags, path, body2) {
@@ -11043,8 +11043,8 @@ var init_browser_login = __esm({
11043
11043
  defaultDeps = {
11044
11044
  sleep: (ms, signal) => delay5(ms, void 0, signal ? { signal } : void 0),
11045
11045
  now: () => Date.now(),
11046
- spawn: (command88, args) => {
11047
- const child = nodeSpawn(command88, args, { detached: true, stdio: "ignore" });
11046
+ spawn: (command89, args) => {
11047
+ const child = nodeSpawn(command89, args, { detached: true, stdio: "ignore" });
11048
11048
  child.on("error", () => {
11049
11049
  });
11050
11050
  child.unref();
@@ -12435,8 +12435,8 @@ var init_run = __esm({
12435
12435
  defaultDeps2 = {
12436
12436
  sleep: (ms, signal) => delay6(ms, void 0, signal ? { signal } : void 0),
12437
12437
  now: () => Date.now(),
12438
- spawn: (command88, args) => {
12439
- const child = nodeSpawn2(command88, args, { detached: true, stdio: "ignore" });
12438
+ spawn: (command89, args) => {
12439
+ const child = nodeSpawn2(command89, args, { detached: true, stdio: "ignore" });
12440
12440
  child.on("error", () => {
12441
12441
  });
12442
12442
  child.unref();
@@ -13414,12 +13414,12 @@ import { join as join17 } from "node:path";
13414
13414
  function whereDir(env) {
13415
13415
  return join17(runsRoot(env), WHERE_DIR);
13416
13416
  }
13417
- async function unfinishedWhereIds(ctx, command88, args) {
13417
+ async function unfinishedWhereIds(ctx, command89, args) {
13418
13418
  const dir3 = whereDir(ctx.env);
13419
13419
  const identity = argsIdentity(args);
13420
13420
  const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
13421
13421
  for (const run of await listRuns(ctx.env)) {
13422
- if (run.command !== command88 || run.status === "done" || run.status === "planned") continue;
13422
+ if (run.command !== command89 || run.status === "done" || run.status === "planned") continue;
13423
13423
  if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
13424
13424
  if (run.inputPath?.startsWith(`${dir3}/`) && existsSync7(run.inputPath)) return run.inputPath;
13425
13425
  }
@@ -13565,14 +13565,14 @@ async function idsFromRun(ctx, runId) {
13565
13565
  return { ...idItems(ids2), source: "run" };
13566
13566
  }
13567
13567
  async function collectIds(ctx, flags, kind, dryRun2) {
13568
- const command88 = `kenso contacts ${kind}`;
13568
+ const command89 = `kenso contacts ${kind}`;
13569
13569
  const ids2 = stringFlag2(flags, "ids");
13570
13570
  const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
13571
13571
  const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
13572
13572
  const given = [ids2, where, run].filter((v) => v !== void 0).length;
13573
13573
  if (given !== 1) {
13574
13574
  const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
13575
- throw usageError(`${command88} needs exactly one of ${choices}.`, { field: "ids", next: `${command88} --help` });
13575
+ throw usageError(`${command89} needs exactly one of ${choices}.`, { field: "ids", next: `${command89} --help` });
13576
13576
  }
13577
13577
  if (ids2 !== void 0) return idsFromFile(ctx, ids2);
13578
13578
  if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
@@ -14848,15 +14848,15 @@ function candidate(entry, costNote) {
14848
14848
  function specEntry(spec) {
14849
14849
  if (spec.brief?.startsWith("same as ")) return void 0;
14850
14850
  const id = commandName(spec).slice("kenso ".length);
14851
- const credits2 = spec.cost ?? [];
14852
- const actions39 = credits2.map((c) => c.action);
14851
+ const credits3 = spec.cost ?? [];
14852
+ const actions39 = credits3.map((c) => c.action);
14853
14853
  return {
14854
14854
  kind: "command",
14855
14855
  id,
14856
14856
  summary: spec.summary,
14857
14857
  terms: termsOf(id, spec.summary, spec.description, spec.doc?.when, Object.keys(spec.flags).join(" "), actions39.join(" ")),
14858
14858
  effect: spec.effect,
14859
- ...credits2.length > 0 ? { costActions: actions39, credits: credits2 } : {},
14859
+ ...credits3.length > 0 ? { costActions: actions39, credits: credits3 } : {},
14860
14860
  ...spec.beta ? { beta: true } : {},
14861
14861
  describe: `kenso describe ${id}`
14862
14862
  };
@@ -16611,8 +16611,10 @@ var init_opportunities = __esm({
16611
16611
  // src/commands/people/import.ts
16612
16612
  var import_exports4 = {};
16613
16613
  __export(import_exports4, {
16614
+ ALIASES: () => ALIASES3,
16614
16615
  default: () => import_default4,
16615
- personResult: () => personResult
16616
+ personResult: () => personResult,
16617
+ toBody: () => toBody2
16616
16618
  });
16617
16619
  function toBody2(row, columns2) {
16618
16620
  const value = (field) => firstValue(row, columns2.sources.get(field));
@@ -16685,8 +16687,8 @@ async function emailFindCredits(ctx, items, findEmails) {
16685
16687
  const price = unitMillicredits("email_found", await loadRateCards(ctx));
16686
16688
  const { available, estimateError } = await readAvailable(ctx);
16687
16689
  const check = creditsCheck(rows * (price ?? 0), available);
16688
- const credits2 = price === void 0 && rows > 0 ? { ...check, needed: null, sufficient: null } : check;
16689
- return { emailFindRows: rows, credits: credits2, ...estimateError ? { estimateError } : {} };
16690
+ const credits3 = price === void 0 && rows > 0 ? { ...check, needed: null, sufficient: null } : check;
16691
+ return { emailFindRows: rows, credits: credits3, ...estimateError ? { estimateError } : {} };
16690
16692
  }
16691
16693
  var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command46, import_default4;
16692
16694
  var init_import5 = __esm({
@@ -17338,8 +17340,8 @@ import { resolve as resolve11 } from "node:path";
17338
17340
  function kebab(key) {
17339
17341
  return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
17340
17342
  }
17341
- function commandWords(command88) {
17342
- return command88.trim().split(/\s+/).filter((t) => t !== "");
17343
+ function commandWords(command89) {
17344
+ return command89.trim().split(/\s+/).filter((t) => t !== "");
17343
17345
  }
17344
17346
  function flagValue(value) {
17345
17347
  return typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value);
@@ -18960,14 +18962,14 @@ async function fillChunk(ctx, templateId, target2, wait3, chunk, chunkCtx) {
18960
18962
  }
18961
18963
  return { results: runResults(chunk, run, target2.key) };
18962
18964
  }
18963
- function estimateOutput(templateId, target2, estimate) {
18965
+ function estimateOutput(templateId, target2, estimate2) {
18964
18966
  return {
18965
18967
  templateId,
18966
18968
  ...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
18967
18969
  [target2.flag]: target2.items.length,
18968
18970
  ...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
18969
18971
  runs: Math.ceil(target2.items.length / RUN_SIZE),
18970
- estimate,
18972
+ estimate: estimate2,
18971
18973
  ...target2.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
18972
18974
  };
18973
18975
  }
@@ -19026,12 +19028,12 @@ var init_fill = __esm({
19026
19028
  const target2 = await readTarget(ctx, flags);
19027
19029
  const batchArgs = { ...flags, positionals };
19028
19030
  if (ctx.flags.yes === true) await refuseRefill(ctx, batchArgs, target2);
19029
- const estimate = await estimateFill(ctx, templateId, target2.items.length);
19031
+ const estimate2 = await estimateFill(ctx, templateId, target2.items.length);
19030
19032
  if (ctx.flags.yes !== true) {
19031
19033
  const next = commandLine2(ctx, COMMAND6, { flags: { ...flags, estimate: void 0 }, positionals }, ["--yes"]);
19032
19034
  const { available, estimateError } = await readAvailable(ctx);
19033
- const credits2 = creditsCheck(estimate.millicredits, available);
19034
- ctx.output.object({ ...estimateOutput(templateId, target2, estimate), credits: credits2, ...estimateError ? { estimateError } : {}, next });
19035
+ const credits3 = creditsCheck(estimate2.millicredits, available);
19036
+ ctx.output.object({ ...estimateOutput(templateId, target2, estimate2), credits: credits3, ...estimateError ? { estimateError } : {}, next });
19035
19037
  return ExitCode.Ok;
19036
19038
  }
19037
19039
  const wait3 = flags.wait === true;
@@ -19049,7 +19051,7 @@ var init_fill = __esm({
19049
19051
  templateId,
19050
19052
  ...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
19051
19053
  ...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
19052
- estimatedMillicredits: estimate.millicredits,
19054
+ estimatedMillicredits: estimate2.millicredits,
19053
19055
  runs: runsOf(results)
19054
19056
  })
19055
19057
  },
@@ -19600,7 +19602,7 @@ async function poll2(ctx, types, cursor2) {
19600
19602
  return unwrap(res.body) ?? {};
19601
19603
  }
19602
19604
  function readBody(req) {
19603
- return new Promise((resolve21, reject) => {
19605
+ return new Promise((resolve22, reject) => {
19604
19606
  let size = 0;
19605
19607
  const chunks = [];
19606
19608
  req.on("data", (chunk) => {
@@ -19608,7 +19610,7 @@ function readBody(req) {
19608
19610
  if (size > MAX_TRIGGER_BYTES) req.destroy(new Error("too large"));
19609
19611
  else chunks.push(chunk);
19610
19612
  });
19611
- req.on("end", () => resolve21(Buffer.concat(chunks).toString("utf8")));
19613
+ req.on("end", () => resolve22(Buffer.concat(chunks).toString("utf8")));
19612
19614
  req.on("error", reject);
19613
19615
  });
19614
19616
  }
@@ -19697,7 +19699,7 @@ var init_listen = __esm({
19697
19699
  reply(res, 200, { forward: result ?? null });
19698
19700
  }).catch(() => reply(res, 400, { error: "invalid_event" }));
19699
19701
  });
19700
- await new Promise((resolve21) => server.listen(0, "127.0.0.1", resolve21));
19702
+ await new Promise((resolve22) => server.listen(0, "127.0.0.1", resolve22));
19701
19703
  const url = `http://127.0.0.1:${server.address().port}/events`;
19702
19704
  writeListenerState(ctx.env, workspaceId, { pid: process.pid, url, token, forwardTo: target2, startedAt: (/* @__PURE__ */ new Date()).toISOString() });
19703
19705
  try {
@@ -20014,9 +20016,9 @@ var init_files = __esm({
20014
20016
  import { execFile, spawnSync as spawnSync2 } from "node:child_process";
20015
20017
  import { readFileSync as readFileSync18 } from "node:fs";
20016
20018
  import { isAbsolute as isAbsolute2 } from "node:path";
20017
- function sudoArgs(user, command88, args, keep = [], set2 = {}) {
20019
+ function sudoArgs(user, command89, args, keep = [], set2 = {}) {
20018
20020
  const assignments = Object.entries(set2).map(([name, value]) => `${name}=${value}`);
20019
- return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command88, ...args];
20021
+ return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command89, ...args];
20020
20022
  }
20021
20023
  function agentKensoEnv(opts) {
20022
20024
  return {
@@ -20026,16 +20028,16 @@ function agentKensoEnv(opts) {
20026
20028
  AI_AGENT: opts.agentName
20027
20029
  };
20028
20030
  }
20029
- function sudoExec(user, command88, args, opts = {}) {
20031
+ function sudoExec(user, command89, args, opts = {}) {
20030
20032
  const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
20031
- return new Promise((resolve21) => {
20033
+ return new Promise((resolve22) => {
20032
20034
  execFile(
20033
20035
  sudo,
20034
- [...lead, ...sudoArgs(user.name, command88, args)],
20036
+ [...lead, ...sudoArgs(user.name, command89, args)],
20035
20037
  { env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
20036
20038
  (err, stdout, stderr) => {
20037
20039
  const code = err ? err.code : 0;
20038
- resolve21({ exitCode: typeof code === "number" ? code : null, stdout, stderr });
20040
+ resolve22({ exitCode: typeof code === "number" ? code : null, stdout, stderr });
20039
20041
  }
20040
20042
  );
20041
20043
  });
@@ -20141,9 +20143,9 @@ var init_folder3 = __esm({
20141
20143
  init_redact();
20142
20144
  init_agent_user();
20143
20145
  WorkRunFolder = class {
20144
- constructor(ctx, command88, args, outDir, shared = false) {
20146
+ constructor(ctx, command89, args, outDir, shared = false) {
20145
20147
  this.ctx = ctx;
20146
- this.command = command88;
20148
+ this.command = command89;
20147
20149
  this.args = args;
20148
20150
  this.outDir = outDir;
20149
20151
  this.shared = shared;
@@ -20694,7 +20696,7 @@ async function groupGone(pid, runAs) {
20694
20696
  }
20695
20697
  }
20696
20698
  function runChild(spawnFn, bin, built, job, env, signal, runAs) {
20697
- return new Promise((resolve21) => {
20699
+ return new Promise((resolve22) => {
20698
20700
  const stdout = new Tail(OUTPUT_CAP_BYTES);
20699
20701
  const stderr = new Tail(OUTPUT_CAP_BYTES);
20700
20702
  let child;
@@ -20709,7 +20711,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
20709
20711
  shell: false
20710
20712
  });
20711
20713
  } catch (err) {
20712
- resolve21({ exitCode: null, stdout: "", stderr: "", spawnError: err });
20714
+ resolve22({ exitCode: null, stdout: "", stderr: "", spawnError: err });
20713
20715
  return;
20714
20716
  }
20715
20717
  let stopped;
@@ -20727,7 +20729,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
20727
20729
  signal?.removeEventListener("abort", onAbort);
20728
20730
  void groupGone(pid, runAs).then(() => {
20729
20731
  if (pid !== void 0) liveGroups.delete(pid);
20730
- resolve21({ exitCode, stdout: stdout.text(), stderr: stderr.text(), stopped, spawnError });
20732
+ resolve22({ exitCode, stdout: stdout.text(), stderr: stderr.text(), stopped, spawnError });
20731
20733
  });
20732
20734
  };
20733
20735
  const stop = (why) => {
@@ -20919,25 +20921,25 @@ function plain(text4) {
20919
20921
  return text4.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
20920
20922
  }
20921
20923
  function runStatus(bin, args, env, adapter, runAs) {
20922
- const command88 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
20924
+ const command89 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
20923
20925
  const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
20924
20926
  const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
20925
- return new Promise((resolve21) => {
20927
+ return new Promise((resolve22) => {
20926
20928
  execFile2(
20927
- command88,
20929
+ command89,
20928
20930
  commandArgs2,
20929
20931
  { ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
20930
20932
  (err, stdout, stderr) => {
20931
20933
  if (err && typeof err.code === "string") {
20932
- resolve21(void 0);
20934
+ resolve22(void 0);
20933
20935
  return;
20934
20936
  }
20935
20937
  if (err && err.killed) {
20936
- resolve21(void 0);
20938
+ resolve22(void 0);
20937
20939
  return;
20938
20940
  }
20939
20941
  const exitCode = err ? err.code ?? null : 0;
20940
- resolve21({ exitCode: typeof exitCode === "number" ? exitCode : null, stdout: plain(String(stdout)), stderr: plain(String(stderr)) });
20942
+ resolve22({ exitCode: typeof exitCode === "number" ? exitCode : null, stdout: plain(String(stdout)), stderr: plain(String(stderr)) });
20941
20943
  }
20942
20944
  );
20943
20945
  });
@@ -21719,7 +21721,7 @@ var init_instruction = __esm({
21719
21721
  // src/work/pool.ts
21720
21722
  function runPool(opts) {
21721
21723
  const limit = Math.min(MAX_PARALLEL, Math.max(1, Math.floor(Number.isFinite(opts.parallel) ? opts.parallel : 1)));
21722
- return new Promise((resolve21, reject) => {
21724
+ return new Promise((resolve22, reject) => {
21723
21725
  let running = 0;
21724
21726
  let filling = false;
21725
21727
  let again = false;
@@ -21759,7 +21761,7 @@ function runPool(opts) {
21759
21761
  const stopping = empty || failure !== void 0 || opts.signal?.aborted === true;
21760
21762
  if (stopping && running === 0 && !again) {
21761
21763
  if (failure) reject(failure.error);
21762
- else resolve21();
21764
+ else resolve22();
21763
21765
  return;
21764
21766
  }
21765
21767
  } while (again);
@@ -22477,6 +22479,11 @@ async function getVersion(ctx, workflowId, number) {
22477
22479
  const res = await ctx.client.request({ method: "GET", path: `/v1/workflows/${workflowId}/versions/${number}`, signal: ctx.signal });
22478
22480
  return unwrap(res.body) ?? {};
22479
22481
  }
22482
+ async function publishedDefinition(ctx, workflow) {
22483
+ const number = workflow.published?.number;
22484
+ if (typeof number !== "number") return void 0;
22485
+ return (await getVersion(ctx, workflow.id, number)).definition ?? void 0;
22486
+ }
22480
22487
  function sortKeys(value) {
22481
22488
  if (Array.isArray(value)) return value.map(sortKeys);
22482
22489
  if (value !== null && typeof value === "object") {
@@ -22685,9 +22692,9 @@ function boundFile(ctx, file, action) {
22685
22692
  function currentHash(workflow) {
22686
22693
  return (workflow.draft ?? workflow.published)?.definitionHash ?? void 0;
22687
22694
  }
22688
- function perRecord(estimate) {
22689
- if (estimate === null || typeof estimate !== "object") return null;
22690
- const totals = estimate;
22695
+ function perRecord(estimate2) {
22696
+ if (estimate2 === null || typeof estimate2 !== "object") return null;
22697
+ const totals = estimate2;
22691
22698
  const bulk = totals.bulkPriceApplies === true;
22692
22699
  const expected = bulk ? totals.bulkExpectedMillicredits : totals.expectedMillicredits;
22693
22700
  const max = bulk ? totals.bulkMaxMillicredits : totals.maxMillicredits;
@@ -22728,7 +22735,7 @@ var init_check = __esm({
22728
22735
  signal: ctx.signal
22729
22736
  });
22730
22737
  const validation = unwrap(validated.body) ?? {};
22731
- const estimate = await workflowEstimate(ctx, { definition: target2.definition, records: 1 });
22738
+ const estimate2 = await workflowEstimate(ctx, { definition: target2.definition, records: 1 });
22732
22739
  const workflow = await getWorkflow(ctx, target2.workflowId);
22733
22740
  const valid = validation.valid === true;
22734
22741
  const inSync = sameDefinition(target2.definition, workflow.definition ?? {});
@@ -22736,8 +22743,8 @@ var init_check = __esm({
22736
22743
  ctx.output.object({
22737
22744
  valid,
22738
22745
  issues: (validation.issues ?? []).map((i) => ({ path: i.path, code: i.code, message: i.message, fix: i.fix ?? null, severity: i.severity })),
22739
- perRecord: perRecord(estimate.estimate),
22740
- ...estimate.estimateError ? { estimateError: estimate.estimateError } : {},
22746
+ perRecord: perRecord(estimate2.estimate),
22747
+ ...estimate2.estimateError ? { estimateError: estimate2.estimateError } : {},
22741
22748
  draftHash: currentHash(workflow) ?? null,
22742
22749
  inSync,
22743
22750
  next: !valid ? nextLine(ctx, "check", file, again) : nextLine(ctx, inSync ? "test" : "push", file)
@@ -23237,12 +23244,542 @@ var init_file_actions = __esm({
23237
23244
  }
23238
23245
  });
23239
23246
 
23247
+ // src/commands/workflows/run-cap.ts
23248
+ function credits2(value) {
23249
+ return Math.round(value * 1e3) / 1e3;
23250
+ }
23251
+ function maxCreditsOf(value) {
23252
+ if (value === void 0) return void 0;
23253
+ const number = typeof value === "string" && value.trim() !== "" ? Number(value) : Number.NaN;
23254
+ if (!Number.isFinite(number) || number <= 0) {
23255
+ throw usageError(`--max-credits must be a number above 0 (got "${String(value)}").`, { field: "max-credits" });
23256
+ }
23257
+ return number;
23258
+ }
23259
+ function hardCeiling(definition) {
23260
+ const value = definition?.limits?.creditsPerRun;
23261
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
23262
+ }
23263
+ function planCap(maxCredits, records, kind, ceiling, retry) {
23264
+ const willStart = ceiling <= 0 ? records : Math.min(records, Math.floor(maxCredits / ceiling + 1e-9));
23265
+ if (willStart === 0 && records > 0) {
23266
+ const smallest = Math.ceil(ceiling * 1e3) / 1e3;
23267
+ throw new KensoError({
23268
+ code: "cap_too_low",
23269
+ message: `--max-credits ${maxCredits} is below one record's ceiling of ${smallest} credits, so nothing would start.`,
23270
+ exitCode: ExitCode.RateLimited,
23271
+ field: "max-credits",
23272
+ next: retry(smallest)
23273
+ });
23274
+ }
23275
+ return { maxCredits, kind, perRecord: credits2(ceiling), willStart, notStarted: records - willStart };
23276
+ }
23277
+ var init_run_cap = __esm({
23278
+ "src/commands/workflows/run-cap.ts"() {
23279
+ "use strict";
23280
+ init_errors();
23281
+ init_exit_codes();
23282
+ }
23283
+ });
23284
+
23285
+ // src/commands/workflows/run-input.ts
23286
+ import { createHash as createHash12 } from "node:crypto";
23287
+ import { resolve as resolve21 } from "node:path";
23288
+ import { Readable as Readable2 } from "node:stream";
23289
+ function validId(id, type) {
23290
+ return type === "place" ? /^plc_[A-Za-z0-9_-]+$/.test(id) : /^[1-9]\d*$/.test(id);
23291
+ }
23292
+ function fromIds(ctx, raw, type) {
23293
+ const records = [];
23294
+ const invalid2 = [];
23295
+ const seen = /* @__PURE__ */ new Set();
23296
+ let repeats = 0;
23297
+ raw.forEach((id, i) => {
23298
+ const row = i + 1;
23299
+ if (!validId(id, type)) {
23300
+ invalid2.push({ row, status: "invalid", reason: "invalid_id", error: `"${id}" is not ${type === "place" ? "a place id (plc_...)" : `a ${type} id`}.` });
23301
+ } else if (seen.has(id)) {
23302
+ repeats++;
23303
+ } else {
23304
+ seen.add(id);
23305
+ records.push({ row, id });
23306
+ }
23307
+ });
23308
+ if (repeats > 0) ctx.output.warn(`${repeats} repeated id${repeats === 1 ? "" : "s"} left out: each record runs once.`);
23309
+ return { people: false, records, invalid: invalid2 };
23310
+ }
23311
+ async function readRunInput(ctx, opts) {
23312
+ const type = opts.recordType;
23313
+ if (opts.ids === "-") {
23314
+ const text4 = await readStream(ctx.stdin ?? process.stdin);
23315
+ const ids2 = await readIds("-", { stdin: Readable2.from([text4]) });
23316
+ return { input: { path: "-", sha256: createHash12("sha256").update(text4).digest("hex") }, ...fromIds(ctx, ids2, type) };
23317
+ }
23318
+ if (opts.ids !== void 0) {
23319
+ return { input: { path: resolve21(opts.ids), sha256: await fileSha256(opts.ids) }, ...fromIds(ctx, await readIds(opts.ids), type) };
23320
+ }
23321
+ const name = opts.file ?? "";
23322
+ const file = await readInput(name, { stdin: ctx.stdin });
23323
+ const input = { path: file.path, sha256: file.sha256 };
23324
+ const idColumn = file.headers.find((header) => header.trim().toLowerCase() === "id");
23325
+ if (idColumn !== void 0) {
23326
+ return { input, ...fromIds(ctx, file.rows.map((row) => String(row[idColumn] ?? "").trim()), type) };
23327
+ }
23328
+ if (type !== "person") {
23329
+ const importer = IMPORT_COMMANDS[type];
23330
+ throw new KensoError({
23331
+ code: "ids_required",
23332
+ message: `${name} has no id column, and only people can be matched from a file: a run on ${type} records needs their ids.`,
23333
+ exitCode: ExitCode.Usage,
23334
+ field: "file",
23335
+ hint: importer ? `${importer} creates the records and prints their ids.` : "Pass the ids with --ids, one per line.",
23336
+ ...importer ? { next: `${importer} --help` } : {}
23337
+ });
23338
+ }
23339
+ const columns2 = mapColumns(file.headers, ALIASES3);
23340
+ const records = [];
23341
+ const invalid2 = [];
23342
+ file.rows.forEach((row, i) => {
23343
+ try {
23344
+ records.push({ row: i + 1, person: toBody2(row, columns2) });
23345
+ } catch (err) {
23346
+ if (!(err instanceof RowInvalid)) throw err;
23347
+ invalid2.push({ row: i + 1, status: "invalid", reason: err.reason, error: err.message });
23348
+ }
23349
+ });
23350
+ return { input, people: true, records, invalid: invalid2 };
23351
+ }
23352
+ async function matchPeople(ctx, records) {
23353
+ const matched = [];
23354
+ const invalid2 = [];
23355
+ const seen = /* @__PURE__ */ new Set();
23356
+ for (let at = 0; at < records.length; at += PEOPLE_CHUNK) {
23357
+ const chunk = records.slice(at, at + PEOPLE_CHUNK);
23358
+ const res = await ctx.client.request({
23359
+ method: "POST",
23360
+ path: "/v1/people/batch",
23361
+ body: { rows: chunk.map((record3) => record3.person) },
23362
+ retrySafe: true,
23363
+ signal: ctx.signal
23364
+ });
23365
+ const byIndex = new Map((unwrap(res.body)?.results ?? []).map((result) => [result.index, result]));
23366
+ chunk.forEach((record3, index2) => {
23367
+ const saved = byIndex.get(index2);
23368
+ const id = saved?.personId !== void 0 && saved.personId !== null ? String(saved.personId) : void 0;
23369
+ if (id === void 0) {
23370
+ invalid2.push({ row: record3.row, status: "invalid", reason: saved?.reason || "person_not_saved", error: saved?.error || "The API saved no person for this row." });
23371
+ } else if (!seen.has(id)) {
23372
+ seen.add(id);
23373
+ matched.push({ row: record3.row, id });
23374
+ }
23375
+ });
23376
+ }
23377
+ return { records: matched, invalid: invalid2 };
23378
+ }
23379
+ var RECORD_TYPES3, PEOPLE_CHUNK, IMPORT_COMMANDS;
23380
+ var init_run_input = __esm({
23381
+ "src/commands/workflows/run-input.ts"() {
23382
+ "use strict";
23383
+ init_input2();
23384
+ init_errors();
23385
+ init_exit_codes();
23386
+ init_http();
23387
+ init_input();
23388
+ init_common();
23389
+ init_columns();
23390
+ init_import5();
23391
+ RECORD_TYPES3 = ["account", "person", "lead", "place"];
23392
+ PEOPLE_CHUNK = 200;
23393
+ IMPORT_COMMANDS = { lead: "kenso contacts import", account: "kenso accounts import" };
23394
+ }
23395
+ });
23396
+
23397
+ // src/commands/workflows/run-start.ts
23398
+ import { readFileSync as readFileSync21 } from "node:fs";
23399
+ import { unlink as unlink4 } from "node:fs/promises";
23400
+ import { join as join32 } from "node:path";
23401
+ function readJournal(file) {
23402
+ try {
23403
+ return JSON.parse(readFileSync21(file, "utf8"));
23404
+ } catch {
23405
+ return void 0;
23406
+ }
23407
+ }
23408
+ function unknownOutcome(workflowId, journal) {
23409
+ return {
23410
+ exitCode: ExitCode.Partial,
23411
+ code: "chunk_outcome_unknown",
23412
+ message: `Rows ${journal.firstRow} to ${journal.lastRow} were sent at ${journal.sentAt} and no answer was recorded, so they are not sent again.`,
23413
+ next: `kenso workflow-runs list --workflow-id ${workflowId} --created-after ${journal.sentAt}`
23414
+ };
23415
+ }
23416
+ function answeredJournals(run, workflowId) {
23417
+ if (run.status === "running" && isOtherLiveProcess(run.pid)) {
23418
+ const { runId, pid } = run;
23419
+ throw new KensoError({ code: "run_in_progress", message: `Run ${runId} on this input is running in process ${pid}.`, exitCode: ExitCode.Conflict, next: `kenso runs show ${runId}` });
23420
+ }
23421
+ const journals = [];
23422
+ for (let index2 = 0; index2 < run.chunkCount; index2++) {
23423
+ const journal = readJournal(journalFile(run.dir, index2));
23424
+ if (journal && journal.response === void 0) throw new KensoError(unknownOutcome(workflowId, journal));
23425
+ if (journal) journals.push(journal);
23426
+ }
23427
+ return journals;
23428
+ }
23429
+ async function earlierRun(ctx, args, sha2565, workflowId) {
23430
+ const earlier = (await findIdentical(COMMAND7, args, sha2565, ctx.env, ctx.client.workspaceId ?? ctx.auth.workspaceId)).filter((run) => run.status !== "planned");
23431
+ const open2 = earlier.find((run) => run.status !== "done");
23432
+ if (open2) {
23433
+ answeredJournals(open2, workflowId);
23434
+ return void 0;
23435
+ }
23436
+ const done2 = earlier[0];
23437
+ if (!done2) return void 0;
23438
+ const summary = readSummary(filesOf(done2.dir).summaryJson) ?? { run: done2.runId };
23439
+ ctx.output.info(`Run ${done2.runId} already finished on this input, so nothing was started again. To run the same records again, pass a changed input file.`);
23440
+ ctx.output.summary({ ...summary, alreadyDone: true });
23441
+ return Number(summary.notStarted ?? 0) + Number(summary.failed ?? 0) > 0 ? ExitCode.Partial : ExitCode.Ok;
23442
+ }
23443
+ async function refuseRestart(ctx, run) {
23444
+ const loose = (args) => argsIdentity({ ...args, "max-credits": void 0 });
23445
+ const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
23446
+ const itemsSha256 = hashItems(run.items);
23447
+ for (const earlier of await listRuns(ctx.env)) {
23448
+ if (earlier.command !== COMMAND7 || earlier.status === "planned" || earlier.inputSha256 !== run.sha256 || loose(earlier.args) !== loose(run.args)) continue;
23449
+ if ((earlier.workspaceId || void 0) !== (workspaceId || void 0)) continue;
23450
+ if (earlier.status !== "done" && argsIdentity(earlier.args) === argsIdentity(run.args) && (earlier.itemsSha256 ?? itemsSha256) === itemsSha256) continue;
23451
+ const sent = /* @__PURE__ */ new Set();
23452
+ for (const journal of answeredJournals(earlier, run.workflowId)) for (const item of run.items) if (item.row >= journal.firstRow && item.row <= journal.lastRow) sent.add(item.row);
23453
+ for (const [row, { status }] of await readResults(filesOf(earlier.dir).resultsNdjson)) if (!["not_started", "invalid"].includes(status)) sent.add(row);
23454
+ if (sent.size === 0) continue;
23455
+ const rest = run.items.filter((item) => !sent.has(item.row));
23456
+ const file = join32(earlier.dir, "not-started.txt");
23457
+ if (rest.length > 0) await writeFileAtomic(file, rest.map((item) => `${item.id}
23458
+ `).join(""));
23459
+ throw new KensoError({
23460
+ code: "already_started",
23461
+ message: `Run ${earlier.runId} already sent starts for ${sent.size} records of this input, so this run would start them twice.`,
23462
+ exitCode: ExitCode.Conflict,
23463
+ hint: rest.length > 0 ? `${file} holds the ${rest.length} ids that run did not start; next runs only those.` : "That run sent every record of this input.",
23464
+ next: rest.length > 0 ? run.rerun(file) : `kenso workflow-runs list --workflow-id ${run.workflowId}`
23465
+ });
23466
+ }
23467
+ }
23468
+ async function startChunk(chunk, cc, run) {
23469
+ const held = notStarted(chunk.filter((item) => !run.start.has(item.row)), "over --max-credits");
23470
+ const starters = chunk.filter((item) => run.start.has(item.row));
23471
+ if (starters.length === 0) return { results: held };
23472
+ const file = journalFile(run.dirOf(cc.runId), cc.chunkIndex);
23473
+ const stopOn = (sent) => {
23474
+ const { next, ...stop } = unknownOutcome(run.workflowId, sent);
23475
+ return { results: held, stop: { ...stop, hint: `See what started: ${next}` } };
23476
+ };
23477
+ let journal = readJournal(file);
23478
+ let remaining;
23479
+ if (journal?.response === void 0) {
23480
+ if (journal) return stopOn(journal);
23481
+ const sent = { sentAt: (/* @__PURE__ */ new Date()).toISOString(), firstRow: starters[0].row, lastRow: starters[starters.length - 1].row };
23482
+ await writeJsonAtomic(file, sent);
23483
+ try {
23484
+ const res = await cc.client.request({
23485
+ method: "POST",
23486
+ path: `/v1/workflows/${run.workflowId}/runs`,
23487
+ body: { records: starters.map(({ type, id }) => ({ type, id })) },
23488
+ signal: cc.signal
23489
+ });
23490
+ journal = { ...sent, response: unwrap(res.body) ?? {} };
23491
+ await writeJsonAtomic(file, journal);
23492
+ remaining = rateLimitRemaining2(res.headers);
23493
+ } catch (err) {
23494
+ const error = err instanceof KensoError ? err : void 0;
23495
+ if (error?.httpStatus !== void 0 && error.httpStatus < 500) {
23496
+ await unlink4(file).catch(() => void 0);
23497
+ const exitCode = error.httpStatus === 402 ? ExitCode.RateLimited : error.exitCode;
23498
+ const stop = { exitCode, code: error.code, message: error.message, ...error.hint ? { hint: error.hint } : {} };
23499
+ return { results: [...notStarted(starters, error.code), ...held], stop };
23500
+ }
23501
+ if (cc.signal.aborted || error?.exitCode === ExitCode.Interrupted) throw err;
23502
+ return stopOn(sent);
23503
+ }
23504
+ }
23505
+ const answers = journal.response?.results ?? [];
23506
+ const results = starters.map((item, i) => {
23507
+ const answer = answers[i];
23508
+ return {
23509
+ row: item.row,
23510
+ id: item.id,
23511
+ // The API's own status: started, deduplicated, over_limit, not_live, not_found or failed.
23512
+ status: answer?.status ?? "failed",
23513
+ ...answer?.runId !== void 0 && answer.runId !== null ? { runId: answer.runId } : {},
23514
+ ...answer?.status ? {} : { reason: "no_result" }
23515
+ };
23516
+ });
23517
+ return { results: [...results, ...held], rateLimitRemaining: remaining };
23518
+ }
23519
+ var COMMAND7, journalFile, notStarted;
23520
+ var init_run_start = __esm({
23521
+ "src/commands/workflows/run-start.ts"() {
23522
+ "use strict";
23523
+ init_results();
23524
+ init_runs();
23525
+ init_errors();
23526
+ init_exit_codes();
23527
+ init_http();
23528
+ init_columns();
23529
+ COMMAND7 = "workflows run";
23530
+ journalFile = (dir3, index2) => join32(dir3, `chunk-${index2}.json`);
23531
+ notStarted = (items, reason) => items.map((item) => ({ row: item.row, ...item.id ? { id: item.id } : {}, status: "not_started", reason }));
23532
+ }
23533
+ });
23534
+
23535
+ // src/commands/workflows/run.ts
23536
+ var run_exports4 = {};
23537
+ __export(run_exports4, {
23538
+ default: () => run_default3
23539
+ });
23540
+ import { join as join33 } from "node:path";
23541
+ async function resolveTarget(ctx, target2) {
23542
+ const isId = /^[1-9]\d*$/.test(target2);
23543
+ const file = isId ? void 0 : readWorkflowFile(target2).definition;
23544
+ const workflowId = isId ? Number(target2) : findBinding(target2, ctx.auth).workflowId;
23545
+ if (workflowId === void 0) throw notBoundError(target2, `${target2} is not bound to a workflow: run needs a published one.`);
23546
+ const workflow = await getWorkflow(ctx, workflowId);
23547
+ const published = await publishedDefinition(ctx, workflow);
23548
+ if (file !== void 0 && (published === void 0 || !sameDefinition(file, published))) {
23549
+ const hash = workflow.draft?.definitionHash;
23550
+ const inDraft = typeof hash === "string" && sameDefinition(file, workflow.definition);
23551
+ const push = `kenso workflows push ${shellQuote3(target2)}`;
23552
+ throw new KensoError({
23553
+ code: "unpublished_changes",
23554
+ message: "This file differs from the published version.",
23555
+ exitCode: ExitCode.Conflict,
23556
+ hint: inDraft ? "The saved draft holds this file: publish it once kenso workflows test passed on it." : "Save the file, test it, then publish it.",
23557
+ next: inDraft ? `${push} --publish --expected-hash ${hash}` : push
23558
+ });
23559
+ }
23560
+ if (workflow.status !== "live" || published === void 0) {
23561
+ throw new KensoError({ code: "invalid_state", message: `Workflow ${workflowId} is not live.`, exitCode: ExitCode.Conflict, next: `kenso workflows publish --workflow-id ${workflowId}` });
23562
+ }
23563
+ return { workflowId, definition: published };
23564
+ }
23565
+ function recordTypeOf(definition, flag) {
23566
+ const known = (value) => RECORD_TYPES3.includes(value);
23567
+ if (flag !== void 0) {
23568
+ if (!known(flag)) throw usageError(`--record-type must be one of ${RECORD_TYPES3.join(", ")} (got "${flag}").`, { field: "record-type" });
23569
+ return flag;
23570
+ }
23571
+ const trigger = definition?.trigger;
23572
+ const declared = trigger?.type === "trigger.manual@1" ? trigger.with?.recordType : loadStepTypes().find((type) => type.type === trigger?.type)?.recordType;
23573
+ if (known(declared)) return declared;
23574
+ throw new KensoError({
23575
+ code: "not_runnable_on_records",
23576
+ message: `The trigger ${trigger?.type ?? "of this workflow"} names no record type, so it cannot run on records.`,
23577
+ exitCode: ExitCode.Usage,
23578
+ field: "record-type",
23579
+ hint: `Pass --record-type ${RECORD_TYPES3.join(", ")} when the workflow can run on picked records.`
23580
+ });
23581
+ }
23582
+ function totalsOf(estimate2) {
23583
+ const e = estimate2 ?? {};
23584
+ const n = (key) => typeof e[key] === "number" ? e[key] : 0;
23585
+ return e.bulkPriceApplies === true ? { max: n("bulkMaxMillicredits"), expected: n("bulkExpectedMillicredits") } : { max: n("maxMillicredits"), expected: n("expectedMillicredits") };
23586
+ }
23587
+ async function estimate(ctx, target2, type, records, peopleRows) {
23588
+ if (peopleRows !== void 0) {
23589
+ if (peopleRows === 0) return { max: 0, expected: 0 };
23590
+ const result = await workflowEstimate(ctx, { definition: target2.definition, records: peopleRows });
23591
+ const failed = result.estimateError;
23592
+ if (failed) throw new KensoError({ code: failed.code ?? "estimate_failed", message: failed.message, exitCode: ExitCode.Error });
23593
+ return totalsOf(result.estimate);
23594
+ }
23595
+ const total = { max: 0, expected: 0 };
23596
+ for (let at = 0; at < records.length; at += CHUNK_SIZE7) {
23597
+ const res = await ctx.client.request({
23598
+ method: "POST",
23599
+ path: `/v1/workflows/${target2.workflowId}/runs`,
23600
+ body: { records: records.slice(at, at + CHUNK_SIZE7).map((record3) => ({ type, id: record3.id })), estimateOnly: true },
23601
+ retrySafe: true,
23602
+ signal: ctx.signal
23603
+ });
23604
+ const part = totalsOf(unwrap(res.body)?.estimate);
23605
+ total.max += part.max;
23606
+ total.expected += part.expected;
23607
+ }
23608
+ return total;
23609
+ }
23610
+ function summarize4(workflowId, records, cap) {
23611
+ return (results) => {
23612
+ const count = (...statuses) => results.filter((result) => statuses.includes(result.status)).length;
23613
+ return {
23614
+ workflowId,
23615
+ records,
23616
+ started: count("started"),
23617
+ deduplicated: count("deduplicated"),
23618
+ notStarted: count("not_started", "over_limit", "not_live", "not_found"),
23619
+ succeeded: 0,
23620
+ failed: count("failed", "invalid"),
23621
+ waiting: 0,
23622
+ missed: {},
23623
+ creditsCharged: "pending",
23624
+ cap: cap(),
23625
+ resultsCsv: null,
23626
+ appUrl: `${APP_URL}/workflows/${workflowId}`,
23627
+ next: `kenso workflow-runs list --workflow-id ${workflowId}`
23628
+ };
23629
+ };
23630
+ }
23631
+ var NAME2, CHUNK_SIZE7, APP_URL, LIST_HINT, command85, run_default3;
23632
+ var init_run4 = __esm({
23633
+ "src/commands/workflows/run.ts"() {
23634
+ "use strict";
23635
+ init_engine();
23636
+ init_runs();
23637
+ init_confirm();
23638
+ init_errors();
23639
+ init_estimate();
23640
+ init_exit_codes();
23641
+ init_http();
23642
+ init_step_types();
23643
+ init_columns();
23644
+ init_files2();
23645
+ init_run_cap();
23646
+ init_run_input();
23647
+ init_run_start();
23648
+ NAME2 = `kenso ${COMMAND7}`;
23649
+ CHUNK_SIZE7 = 1e3;
23650
+ APP_URL = "https://app.ken.so";
23651
+ LIST_HINT = "A saved list runs through a workflow whose trigger is trigger.saved_list@1 or trigger.csv@1; kenso workflows run takes --ids or --file.";
23652
+ command85 = {
23653
+ resource: "workflows",
23654
+ action: "run",
23655
+ summary: "Run a published workflow on records from an ids file or a CSV",
23656
+ brief: "on ids or a CSV",
23657
+ description: "Starts one run per record on the workflow's published version. The target is a workflow id, or a workflow file bound in kenso.json that equals the published version. --ids is one id per line; --file is a CSV with an id column, or for a workflow that runs on people a CSV of people (the columns of kenso people import), matched or created first. Without --yes it prints the plan with the credit estimate and starts nothing. --max-credits starts only as many records as the cap covers and reports the rest as not_started. The same command on the same input never starts its records twice; another --max-credits on that input is refused with an ids file of the records not started yet. Exit 5 when some records failed, were not found or were not started, 6 when the cap starts nothing or the workspace is out of credits, 7 when the file differs from the published version or the workflow is not live.",
23658
+ effect: "send",
23659
+ doc: {
23660
+ when: "You have a published workflow and the records to run it on.",
23661
+ cost: "the workflow's steps; --dry-run prints the estimate",
23662
+ next: "kenso workflow-runs list --workflow-id <id>"
23663
+ },
23664
+ flags: {
23665
+ ids: { type: "string", description: "A file with one record id per line, or - for stdin" },
23666
+ file: { type: "string", description: "A CSV with an id column, or a CSV of people for a workflow that runs on people" },
23667
+ "record-type": { type: "string", description: "account, person, lead or place (default: the type the trigger runs on)" },
23668
+ "max-credits": { type: "string", description: "Start only as many records as this many credits cover" },
23669
+ // Declared only so the refusal can carry its hint: main refuses an undeclared flag before the command runs.
23670
+ list: { type: "string", helpHidden: true, description: "Not a flag: a saved list runs through its own trigger" }
23671
+ },
23672
+ positionals: [{ name: "target", required: true, description: "A workflow file bound in kenso.json, or a workflow id" }],
23673
+ examples: [
23674
+ "kenso workflows run qualify.workflow.json --ids ids.txt --dry-run",
23675
+ "kenso workflows run qualify.workflow.json --ids ids.txt --max-credits 50 --yes",
23676
+ "kenso workflows run 412 --file people.csv --record-type person --dry-run"
23677
+ ],
23678
+ beta: { featureGates: WORKFLOWS_GATES },
23679
+ // workflow-runs.get is read by --wait.
23680
+ operationIds: ["workflows.get", "workflow-runs.run-on-records", "workflow-runs.get", "workflow-estimates.create", "credits.get", "people.batch", "workflow-versions.get"],
23681
+ dryRun: true,
23682
+ batch: true,
23683
+ async run(ctx, { flags, positionals }) {
23684
+ if (flags.list !== void 0) {
23685
+ throw new KensoError({ code: "unknown_flag", message: `Unknown flag --list for ${NAME2}.`, exitCode: ExitCode.Usage, field: "list", hint: LIST_HINT, next: `${NAME2} --help` });
23686
+ }
23687
+ const ids2 = stringFlag(flags.ids);
23688
+ const csv = stringFlag(flags.file);
23689
+ if (ids2 === void 0 === (csv === void 0)) throw usageError("Pass one of --ids and --file.", { field: "ids", next: `${NAME2} --help` });
23690
+ const maxCredits = maxCreditsOf(flags["max-credits"]);
23691
+ const apply = ctx.flags.yes === true;
23692
+ const target2 = await resolveTarget(ctx, positionals[0] ?? "");
23693
+ const { workflowId } = target2;
23694
+ const type = recordTypeOf(target2.definition, stringFlag(flags["record-type"]));
23695
+ const input = await readRunInput(ctx, { ids: ids2, file: csv, recordType: type });
23696
+ const rows = input.records.length + input.invalid.length;
23697
+ const basis = input.people ? rows : input.records.length;
23698
+ let totals;
23699
+ let check;
23700
+ let estimateError;
23701
+ try {
23702
+ totals = await estimate(ctx, target2, type, input.records, input.people ? rows : void 0);
23703
+ const balance = await ctx.client.request({ method: "GET", path: "/v1/credits", signal: ctx.signal });
23704
+ check = creditsCheck(totals.max, unwrap(balance.body)?.availableMillicredits);
23705
+ } catch (err) {
23706
+ if (apply || !(err instanceof KensoError) || err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.Interrupted) throw err;
23707
+ estimateError = { code: err.code, message: err.message };
23708
+ }
23709
+ const hard = hardCeiling(target2.definition);
23710
+ const ceiling = hard ?? (totals && basis > 0 ? totals.max / basis / 1e3 : void 0);
23711
+ const retry = (cap2) => commandLine2(ctx, COMMAND7, { flags: { ...flags, "max-credits": String(cap2) }, positionals });
23712
+ const capFor = (count) => maxCredits !== void 0 && ceiling !== void 0 ? planCap(maxCredits, count, hard !== void 0 ? "hard" : "estimate", ceiling, retry) : null;
23713
+ let cap = capFor(input.records.length);
23714
+ const args = { ...flags, positionals };
23715
+ const applyCommand = commandLine2(ctx, COMMAND7, { flags, positionals }, ["--yes"]);
23716
+ const plan2 = {
23717
+ workflowId,
23718
+ records: rows,
23719
+ recordType: type,
23720
+ ...check ? { credits: check } : {},
23721
+ perRecord: totals && basis > 0 ? { expectedCredits: credits2(totals.expected / basis / 1e3), maxCredits: credits2(totals.max / basis / 1e3) } : null,
23722
+ expectedCredits: totals ? credits2(totals.expected / 1e3) : null,
23723
+ cap,
23724
+ ...estimateError ? { estimateError } : {}
23725
+ };
23726
+ let start = /* @__PURE__ */ new Set();
23727
+ const spec = (dryRun2, records2, invalid3) => ({
23728
+ command: COMMAND7,
23729
+ args,
23730
+ input: input.input,
23731
+ items: records2.map((record3) => ({ row: record3.row, type, ...record3.id !== void 0 ? { id: record3.id } : {} })),
23732
+ rowOf: (item) => item.row,
23733
+ chunkSize: CHUNK_SIZE7,
23734
+ concurrency: 1,
23735
+ execChunk: (chunk, cc) => startChunk(chunk, cc, { dirOf: (runId) => join33(runsRoot(ctx.env), runId), workflowId, start }),
23736
+ invalid: invalid3,
23737
+ dryRun: dryRun2,
23738
+ dryRunExtra: plan2,
23739
+ applyCommand,
23740
+ summarize: summarize4(workflowId, records2.length + invalid3.length, () => cap)
23741
+ });
23742
+ if (!apply) {
23743
+ const planned = await runBatch(spec(true, input.records, input.invalid), ctx);
23744
+ if (ctx.flags.dryRun === true || !canAsk(ctx) || estimateError) return planned.exitCode;
23745
+ await confirmDestructive(ctx, `Start ${cap ? cap.willStart : input.records.length} of ${rows} records on workflow ${workflowId}`, applyCommand);
23746
+ }
23747
+ const answered = await earlierRun(ctx, args, input.input.sha256, workflowId);
23748
+ if (answered !== void 0) return answered;
23749
+ if (check?.available != null && check.available <= 0 && (check.needed ?? 0) > 0) {
23750
+ throw new KensoError({ code: "out_of_credits", message: "The workspace is out of credits, so nothing was started.", exitCode: ExitCode.RateLimited });
23751
+ }
23752
+ let records = input.records;
23753
+ let invalid2 = input.invalid;
23754
+ if (input.people) {
23755
+ const matched = await matchPeople(ctx, records);
23756
+ records = matched.records;
23757
+ invalid2 = [...invalid2, ...matched.invalid];
23758
+ cap = capFor(records.length);
23759
+ }
23760
+ start = new Set(records.slice(0, cap ? cap.willStart : records.length).map((record3) => record3.row));
23761
+ const applied = spec(false, records, invalid2);
23762
+ const rerun = (ids3) => commandLine2(ctx, COMMAND7, { flags: { ...flags, ids: ids3, file: void 0 }, positionals }, ["--yes"]);
23763
+ await refuseRestart(ctx, { args, sha256: input.input.sha256, workflowId, items: applied.items, rerun });
23764
+ const outcome = await runBatch(applied, ctx);
23765
+ const s = outcome.summary;
23766
+ ctx.output.info(`workflow ${workflowId}: ${s.started} started, ${s.deduplicated} deduplicated, ${s.notStarted} not started, ${s.failed} failed of ${s.records} records`);
23767
+ if (outcome.exitCode !== ExitCode.Ok) return outcome.exitCode;
23768
+ return Number(s.notStarted ?? 0) + Number(s.failed ?? 0) > 0 ? ExitCode.Partial : ExitCode.Ok;
23769
+ }
23770
+ };
23771
+ run_default3 = command85;
23772
+ }
23773
+ });
23774
+
23240
23775
  // src/commands/workflows/run-actions.ts
23241
23776
  var runActions;
23242
23777
  var init_run_actions = __esm({
23243
23778
  "src/commands/workflows/run-actions.ts"() {
23244
23779
  "use strict";
23245
- runActions = {};
23780
+ runActions = {
23781
+ run: () => Promise.resolve().then(() => (init_run4(), run_exports4)).then((m) => m.default)
23782
+ };
23246
23783
  }
23247
23784
  });
23248
23785
 
@@ -23278,7 +23815,7 @@ function rewrap(err, overrides2) {
23278
23815
  details: err.details
23279
23816
  });
23280
23817
  }
23281
- var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command85, keys_default;
23818
+ var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command86, keys_default;
23282
23819
  var init_keys = __esm({
23283
23820
  "src/commands/workspace/keys.ts"() {
23284
23821
  "use strict";
@@ -23288,7 +23825,7 @@ var init_keys = __esm({
23288
23825
  TEMPLATES = ["admin", "editor", "viewer"];
23289
23826
  APP_NEXT_STEP = "A workspace admin can create it in the app: Settings > API keys > Workspace keys";
23290
23827
  NOT_AVAILABLE = "Workspace keys are not available for this workspace yet.";
23291
- command85 = {
23828
+ command86 = {
23292
23829
  resource: "workspace",
23293
23830
  action: "keys",
23294
23831
  summary: "Create an API key the workspace owns",
@@ -23350,7 +23887,7 @@ var init_keys = __esm({
23350
23887
  return ExitCode.Ok;
23351
23888
  }
23352
23889
  };
23353
- keys_default = command85;
23890
+ keys_default = command86;
23354
23891
  }
23355
23892
  });
23356
23893
 
@@ -23368,14 +23905,14 @@ function parseLimit2(value) {
23368
23905
  }
23369
23906
  return limit;
23370
23907
  }
23371
- var MAX_LIMIT2, command86, list_default5;
23908
+ var MAX_LIMIT2, command87, list_default5;
23372
23909
  var init_list5 = __esm({
23373
23910
  "src/commands/workspace/list.ts"() {
23374
23911
  "use strict";
23375
23912
  init_errors();
23376
23913
  init_exit_codes();
23377
23914
  MAX_LIMIT2 = 200;
23378
- command86 = {
23915
+ command87 = {
23379
23916
  resource: "workspace",
23380
23917
  action: "list",
23381
23918
  summary: "List the workspaces your key can use",
@@ -23404,7 +23941,7 @@ var init_list5 = __esm({
23404
23941
  return ExitCode.Ok;
23405
23942
  }
23406
23943
  };
23407
- list_default5 = command86;
23944
+ list_default5 = command87;
23408
23945
  }
23409
23946
  });
23410
23947
 
@@ -23413,7 +23950,7 @@ var use_exports = {};
23413
23950
  __export(use_exports, {
23414
23951
  default: () => use_default
23415
23952
  });
23416
- var command87, use_default;
23953
+ var command88, use_default;
23417
23954
  var init_use = __esm({
23418
23955
  "src/commands/workspace/use.ts"() {
23419
23956
  "use strict";
@@ -23421,7 +23958,7 @@ var init_use = __esm({
23421
23958
  init_errors();
23422
23959
  init_exit_codes();
23423
23960
  init_http();
23424
- command87 = {
23961
+ command88 = {
23425
23962
  resource: "workspace",
23426
23963
  action: "use",
23427
23964
  summary: "Set the profile's default workspace",
@@ -23483,7 +24020,7 @@ var init_use = __esm({
23483
24020
  return ExitCode.Ok;
23484
24021
  }
23485
24022
  };
23486
- use_default = command87;
24023
+ use_default = command88;
23487
24024
  }
23488
24025
  });
23489
24026
 
@@ -24101,14 +24638,14 @@ var init_pre_run = __esm({
24101
24638
  });
24102
24639
 
24103
24640
  // src/core/update-notice.ts
24104
- import { mkdirSync as mkdirSync8, readFileSync as readFileSync21, realpathSync as realpathSync2, renameSync as renameSync8, writeFileSync as writeFileSync13 } from "node:fs";
24105
- import { dirname as dirname7, join as join32, sep as sep4 } from "node:path";
24641
+ import { mkdirSync as mkdirSync8, readFileSync as readFileSync22, realpathSync as realpathSync2, renameSync as renameSync8, writeFileSync as writeFileSync13 } from "node:fs";
24642
+ import { dirname as dirname7, join as join34, sep as sep4 } from "node:path";
24106
24643
  function installKind(script = process.argv[1], execPath = process.execPath, platform = process.platform) {
24107
24644
  try {
24108
24645
  if (!script) return "npm";
24109
24646
  const bundle = realpathSync2(script);
24110
24647
  const lib = dirname7(dirname7(dirname7(bundle)));
24111
- if (execPath !== join32(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
24648
+ if (execPath !== join34(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
24112
24649
  return bundle.includes(`${sep4}Cellar${sep4}kenso${sep4}`) ? "homebrew" : "standalone";
24113
24650
  } catch {
24114
24651
  return "npm";
@@ -24121,7 +24658,7 @@ function updateCommand(install, platform) {
24121
24658
  }
24122
24659
  function readCheck(file) {
24123
24660
  try {
24124
- const parsed2 = JSON.parse(readFileSync21(file, "utf8"));
24661
+ const parsed2 = JSON.parse(readFileSync22(file, "utf8"));
24125
24662
  if (typeof parsed2?.checkedAt !== "string") return void 0;
24126
24663
  return { checkedAt: parsed2.checkedAt, ...typeof parsed2.latest === "string" ? { latest: parsed2.latest } : {} };
24127
24664
  } catch {
@@ -24162,13 +24699,13 @@ async function fetchLatest(fetchImpl, signal, install) {
24162
24699
  return typeof body2?.version === "string" && RELEASE.test(body2.version) ? body2.version : void 0;
24163
24700
  }
24164
24701
  function agentNotice(env, agent, version, stderr, opts) {
24165
- const latest = readCheck(join32(configDir(env), UPDATE_CHECK_FILE))?.latest;
24702
+ const latest = readCheck(join34(configDir(env), UPDATE_CHECK_FILE))?.latest;
24166
24703
  if (latest === void 0 || !isNewer(latest, version)) return done;
24167
24704
  return async () => {
24168
24705
  try {
24169
24706
  if (!firstInSession(env, agent, "update")) return;
24170
- const command88 = updateCommand(opts.install ?? installKind(), opts.platform ?? process.platform);
24171
- stderr.write(`kenso ${latest} is out (you have ${version}): ${command88}
24707
+ const command89 = updateCommand(opts.install ?? installKind(), opts.platform ?? process.platform);
24708
+ stderr.write(`kenso ${latest} is out (you have ${version}): ${command89}
24172
24709
  `);
24173
24710
  } catch {
24174
24711
  }
@@ -24184,7 +24721,7 @@ function startUpdateNotice(argv, opts = {}) {
24184
24721
  const agent = detectAgent(env);
24185
24722
  if (agent !== null) return agentNotice(env, agent, version, stderr, opts);
24186
24723
  if (!(opts.stderrIsTTY ?? process.stderr.isTTY === true)) return done;
24187
- const file = join32(configDir(env), UPDATE_CHECK_FILE);
24724
+ const file = join34(configDir(env), UPDATE_CHECK_FILE);
24188
24725
  const now = (opts.now ?? Date.now)();
24189
24726
  const cached = readCheck(file);
24190
24727
  const checkedAt = Date.parse(cached?.checkedAt ?? "");
@@ -24203,8 +24740,8 @@ function startUpdateNotice(argv, opts = {}) {
24203
24740
  if (!found) return;
24204
24741
  writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
24205
24742
  if (isNewer(found, version)) {
24206
- const command88 = updateCommand(install, opts.platform ?? process.platform);
24207
- stderr.write(`kenso ${found} is out (you have ${version}): ${command88}
24743
+ const command89 = updateCommand(install, opts.platform ?? process.platform);
24744
+ stderr.write(`kenso ${found} is out (you have ${version}): ${command89}
24208
24745
  Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
24209
24746
  `);
24210
24747
  }