kenso 0.1.138 → 0.1.141

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
@@ -282,18 +282,18 @@ function readConfig(env = process.env) {
282
282
  }
283
283
  return config;
284
284
  }
285
- function ensurePrivateDir(dir2) {
286
- mkdirSync(dir2, { recursive: true, mode: 448 });
285
+ function ensurePrivateDir(dir3) {
286
+ mkdirSync(dir3, { recursive: true, mode: 448 });
287
287
  try {
288
- chmodSync(dir2, 448);
288
+ chmodSync(dir3, 448);
289
289
  } catch {
290
290
  }
291
291
  }
292
292
  function writeConfig(config, env) {
293
- const dir2 = configDir(env);
294
- ensurePrivateDir(dir2);
295
- const file = join(dir2, CONFIG_FILE);
296
- const temp = join(dir2, `.${CONFIG_FILE}.${process.pid}.${Date.now()}.tmp`);
293
+ const dir3 = configDir(env);
294
+ ensurePrivateDir(dir3);
295
+ const file = join(dir3, CONFIG_FILE);
296
+ const temp = join(dir3, `.${CONFIG_FILE}.${process.pid}.${Date.now()}.tmp`);
297
297
  try {
298
298
  writeFileSync(temp, `${JSON.stringify(config, null, 2)}
299
299
  `, { mode: 384 });
@@ -321,13 +321,13 @@ function removeProfile(name, env = process.env) {
321
321
  writeConfig(config, env);
322
322
  }
323
323
  function cacheDir(env = process.env) {
324
- const dir2 = join(configDir(env), "cache");
325
- ensurePrivateDir(dir2);
326
- return dir2;
324
+ const dir3 = join(configDir(env), "cache");
325
+ ensurePrivateDir(dir3);
326
+ return dir3;
327
327
  }
328
328
  function clearCache(env = process.env) {
329
- const dir2 = join(configDir(env), "cache");
330
- if (existsSync(dir2)) rmSync(dir2, { recursive: true, force: true });
329
+ const dir3 = join(configDir(env), "cache");
330
+ if (existsSync(dir3)) rmSync(dir3, { recursive: true, force: true });
331
331
  }
332
332
  function nonEmpty(value) {
333
333
  const trimmed = value?.trim();
@@ -2485,23 +2485,23 @@ var VERSION;
2485
2485
  var init_version = __esm({
2486
2486
  "src/core/version.ts"() {
2487
2487
  "use strict";
2488
- VERSION = true ? "0.1.138" : "0.0.0-dev";
2488
+ VERSION = true ? "0.1.141" : "0.0.0-dev";
2489
2489
  }
2490
2490
  });
2491
2491
 
2492
2492
  // src/core/context.ts
2493
- function createContext(flags, env = process.env, overrides) {
2493
+ function createContext(flags, env = process.env, overrides2) {
2494
2494
  const agent = detectAgent(env);
2495
- const signal = overrides?.signal ?? new AbortController().signal;
2496
- const auth = overrides?.noConfig ? authWithoutConfig({ workspace: flags.workspace }, env) : resolveAuth({ profile: flags.profile, workspace: flags.workspace }, env);
2495
+ const signal = overrides2?.signal ?? new AbortController().signal;
2496
+ const auth = overrides2?.noConfig ? authWithoutConfig({ workspace: flags.workspace }, env) : resolveAuth({ profile: flags.profile, workspace: flags.workspace }, env);
2497
2497
  const output = new Output({
2498
2498
  format: flags.output,
2499
2499
  fields: flags.fields?.split(","),
2500
2500
  query: flags.query,
2501
- stdout: overrides?.stdout,
2502
- stderr: overrides?.stderr,
2503
- stdoutIsTTY: overrides?.stdoutIsTTY,
2504
- stderrIsTTY: overrides?.stderrIsTTY,
2501
+ stdout: overrides2?.stdout,
2502
+ stderr: overrides2?.stderr,
2503
+ stdoutIsTTY: overrides2?.stdoutIsTTY,
2504
+ stderrIsTTY: overrides2?.stderrIsTTY,
2505
2505
  progress: flags.progress
2506
2506
  });
2507
2507
  const client = new KensoClient({
@@ -2510,8 +2510,8 @@ function createContext(flags, env = process.env, overrides) {
2510
2510
  workspaceId: auth.workspaceId,
2511
2511
  agent,
2512
2512
  version: VERSION,
2513
- fetchImpl: overrides?.fetchImpl,
2514
- sleep: overrides?.sleep,
2513
+ fetchImpl: overrides2?.fetchImpl,
2514
+ sleep: overrides2?.sleep,
2515
2515
  signal,
2516
2516
  onRetry: ({ status, waitMs }) => {
2517
2517
  const seconds = Math.max(1, Math.round(waitMs / 1e3));
@@ -2532,7 +2532,7 @@ function createContext(flags, env = process.env, overrides) {
2532
2532
  agent,
2533
2533
  version: VERSION,
2534
2534
  signal,
2535
- stdin: overrides?.stdin
2535
+ stdin: overrides2?.stdin
2536
2536
  };
2537
2537
  }
2538
2538
  var init_context = __esm({
@@ -2574,14 +2574,14 @@ async function loadWorkspaceFeatures(ctx, opts = {}) {
2574
2574
  if (!key) return { features: [] };
2575
2575
  const now = Date.now();
2576
2576
  let file;
2577
- let cache = {};
2577
+ let cache2 = {};
2578
2578
  try {
2579
2579
  file = join2(cacheDir(ctx.env), CACHE_FILE);
2580
- cache = readCache(file);
2580
+ cache2 = readCache(file);
2581
2581
  } catch {
2582
2582
  file = void 0;
2583
2583
  }
2584
- const hit = cache[key];
2584
+ const hit = cache2[key];
2585
2585
  if (isFresh(hit, now)) return { features: hit.features.filter((f) => typeof f === "string") };
2586
2586
  const timeoutMs2 = opts.timeoutMs ?? FETCH_TIMEOUT_MS;
2587
2587
  const timeout = AbortSignal.timeout(timeoutMs2);
@@ -2598,7 +2598,7 @@ async function loadWorkspaceFeatures(ctx, opts = {}) {
2598
2598
  if (file) {
2599
2599
  try {
2600
2600
  const kept = {};
2601
- for (const [k, entry] of Object.entries(cache)) if (isFresh(entry, now)) kept[k] = entry;
2601
+ for (const [k, entry] of Object.entries(cache2)) if (isFresh(entry, now)) kept[k] = entry;
2602
2602
  kept[key] = { features, fetchedAt: new Date(now).toISOString() };
2603
2603
  const temp = `${file}.${process.pid}.tmp`;
2604
2604
  writeFileSync2(temp, `${JSON.stringify(kept)}
@@ -2639,6 +2639,7 @@ __export(manifest_exports, {
2639
2639
  findOperationById: () => findOperationById,
2640
2640
  listOperations: () => listOperations,
2641
2641
  loadManifest: () => loadManifest,
2642
+ routeEffect: () => routeEffect,
2642
2643
  useManifestDirForTest: () => useManifestDirForTest,
2643
2644
  useManifestForTest: () => useManifestForTest
2644
2645
  });
@@ -2676,6 +2677,25 @@ function listOperations() {
2676
2677
  if (override) return override.operations;
2677
2678
  return loadIndex()?.operations ?? loadManifest().operations;
2678
2679
  }
2680
+ function routeEffect(method, path) {
2681
+ const fold2 = (segment) => {
2682
+ try {
2683
+ return decodeURIComponent(segment).toLowerCase();
2684
+ } catch {
2685
+ return segment.toLowerCase();
2686
+ }
2687
+ };
2688
+ const segments = path.split(/[?#]/, 1)[0].replace(/\/+$/, "").split("/").map(fold2);
2689
+ let best;
2690
+ for (const op of listOperations()) {
2691
+ const template2 = op.path.split("/");
2692
+ if (op.method !== method || template2.length !== segments.length) continue;
2693
+ const literals = template2.filter((part) => !part.startsWith("{")).length;
2694
+ const fits = template2.every((part, i) => part.startsWith("{") ? segments[i] !== "" : part.toLowerCase() === segments[i]);
2695
+ if (fits && (!best || literals > best.literals)) best = { effect: op.effect ?? "write", literals };
2696
+ }
2697
+ return best?.effect;
2698
+ }
2679
2699
  function indexes() {
2680
2700
  if (!byCommand || !byId) {
2681
2701
  const operations = listOperations();
@@ -4031,15 +4051,15 @@ import { createHash } from "node:crypto";
4031
4051
  import { readFileSync as readFileSync5 } from "node:fs";
4032
4052
  import { readFile as readFile3 } from "node:fs/promises";
4033
4053
  import { join as join4 } from "node:path";
4034
- function filesOf(dir2) {
4054
+ function filesOf(dir3) {
4035
4055
  return {
4036
- runJson: join4(dir2, "run.json"),
4037
- stateJson: join4(dir2, "state.json"),
4038
- resultsCsv: join4(dir2, "results.csv"),
4039
- resultsNdjson: join4(dir2, "results.ndjson"),
4040
- invalidCsv: join4(dir2, "invalid.csv"),
4041
- planJson: join4(dir2, "plan.json"),
4042
- summaryJson: join4(dir2, "summary.json")
4056
+ runJson: join4(dir3, "run.json"),
4057
+ stateJson: join4(dir3, "state.json"),
4058
+ resultsCsv: join4(dir3, "results.csv"),
4059
+ resultsNdjson: join4(dir3, "results.ndjson"),
4060
+ invalidCsv: join4(dir3, "invalid.csv"),
4061
+ planJson: join4(dir3, "plan.json"),
4062
+ summaryJson: join4(dir3, "summary.json")
4043
4063
  };
4044
4064
  }
4045
4065
  function hashItems(items) {
@@ -4215,24 +4235,24 @@ function rootRefusal(stats) {
4215
4235
  if ((stats.mode & 18) !== 0 && !sticky) return `other users can write it (mode ${modeText(stats)})`;
4216
4236
  return void 0;
4217
4237
  }
4218
- function notPrivateError(dir2, reason) {
4219
- return usageError(`kenso will not keep runs in ${dir2}: ${reason}.`, {
4238
+ function notPrivateError(dir3, reason) {
4239
+ return usageError(`kenso will not keep runs in ${dir3}: ${reason}.`, {
4220
4240
  hint: "Use a folder only you own and can write (chmod 700 it), or leave KENSO_RUNS_DIR and --out unset to use ~/.kenso/runs."
4221
4241
  });
4222
4242
  }
4223
- function ensureDir(dir2, mode) {
4224
- mkdirSync2(dir2, { recursive: true, mode: mode & 511 });
4243
+ function ensureDir(dir3, mode) {
4244
+ mkdirSync2(dir3, { recursive: true, mode: mode & 511 });
4225
4245
  const uid = currentUid();
4226
4246
  try {
4227
- chmodSync2(dir2, mode);
4247
+ chmodSync2(dir3, mode);
4228
4248
  } catch (err) {
4229
4249
  if (uid === void 0) return;
4230
- throw notPrivateError(dir2, `kenso cannot set its mode (${err.code ?? String(err)})`);
4250
+ throw notPrivateError(dir3, `kenso cannot set its mode (${err.code ?? String(err)})`);
4231
4251
  }
4232
4252
  if (uid === void 0) return;
4233
- const stats = statSync(dir2);
4234
- if (stats.uid !== uid) throw notPrivateError(dir2, `another user (uid ${stats.uid}) owns it`);
4235
- if ((stats.mode & 18 & ~mode) !== 0) throw notPrivateError(dir2, `its mode stayed ${modeText(stats)} after kenso set it`);
4253
+ const stats = statSync(dir3);
4254
+ if (stats.uid !== uid) throw notPrivateError(dir3, `another user (uid ${stats.uid}) owns it`);
4255
+ if ((stats.mode & 18 & ~mode) !== 0) throw notPrivateError(dir3, `its mode stayed ${modeText(stats)} after kenso set it`);
4236
4256
  }
4237
4257
  async function checkRoot(root2) {
4238
4258
  let stats;
@@ -4249,8 +4269,8 @@ async function checkRoot(root2) {
4249
4269
  if (refusal2) throw notPrivateError(root2, refusal2);
4250
4270
  return true;
4251
4271
  }
4252
- function ensurePrivateDir2(dir2) {
4253
- ensureDir(dir2, 448);
4272
+ function ensurePrivateDir2(dir3) {
4273
+ ensureDir(dir3, 448);
4254
4274
  }
4255
4275
  async function writeFileAtomic(path, content) {
4256
4276
  const temp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
@@ -4267,8 +4287,8 @@ async function writeJsonAtomic(path, value) {
4267
4287
  `);
4268
4288
  }
4269
4289
  async function writeRunRecord(record3) {
4270
- const { dir: dir2, ...rest } = record3;
4271
- await writeJsonAtomic(join5(dir2, "run.json"), rest);
4290
+ const { dir: dir3, ...rest } = record3;
4291
+ await writeJsonAtomic(join5(dir3, "run.json"), rest);
4272
4292
  }
4273
4293
  function notYoursError(path, reason) {
4274
4294
  return new KensoError({
@@ -4297,48 +4317,48 @@ function chunkList(value) {
4297
4317
  if (!Array.isArray(value)) return void 0;
4298
4318
  return value.filter((n) => Number.isInteger(n) && n >= 0);
4299
4319
  }
4300
- async function readRun(dir2) {
4320
+ async function readRun(dir3) {
4301
4321
  let dirStats;
4302
4322
  try {
4303
- dirStats = await stat(dir2);
4323
+ dirStats = await stat(dir3);
4304
4324
  } catch {
4305
4325
  return null;
4306
4326
  }
4307
4327
  const refusal2 = notOurs(dirStats);
4308
- if (refusal2) throw notYoursError(dir2, refusal2);
4328
+ if (refusal2) throw notYoursError(dir3, refusal2);
4309
4329
  let raw;
4310
4330
  try {
4311
- raw = asRecord3(await readOwnJson(join5(dir2, "run.json")));
4331
+ raw = asRecord3(await readOwnJson(join5(dir3, "run.json")));
4312
4332
  } catch (err) {
4313
4333
  if (err instanceof KensoError) throw err;
4314
4334
  return null;
4315
4335
  }
4316
4336
  if (!raw) return null;
4317
- const { runId, command: command70, createdAt, status } = raw;
4337
+ const { runId, command: command71, createdAt, status } = raw;
4318
4338
  if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
4319
- if (typeof command70 !== "string" || typeof createdAt !== "string") return null;
4339
+ if (typeof command71 !== "string" || typeof createdAt !== "string") return null;
4320
4340
  if (typeof status !== "string" || !STATUSES.includes(status)) return null;
4321
4341
  let chunksDone = chunkList(raw.chunksDone) ?? [];
4322
4342
  try {
4323
- const state = asRecord3(await readOwnJson(join5(dir2, "state.json")));
4343
+ const state = asRecord3(await readOwnJson(join5(dir3, "state.json")));
4324
4344
  chunksDone = chunkList(state?.chunksDone) ?? chunksDone;
4325
4345
  } catch {
4326
4346
  }
4327
4347
  const record3 = {
4328
4348
  ...raw,
4329
4349
  runId,
4330
- command: command70,
4350
+ command: command71,
4331
4351
  args: asRecord3(raw.args) ?? {},
4332
4352
  createdAt,
4333
4353
  status,
4334
4354
  chunkCount: typeof raw.chunkCount === "number" ? raw.chunkCount : 0,
4335
4355
  chunksDone: [...new Set(chunksDone)].sort((a, b) => a - b),
4336
- dir: dir2
4356
+ dir: dir3
4337
4357
  };
4338
4358
  return record3;
4339
4359
  }
4340
- async function readRunDir(dir2) {
4341
- return readRun(dir2).catch(() => null);
4360
+ async function readRunDir(dir3) {
4361
+ return readRun(dir3).catch(() => null);
4342
4362
  }
4343
4363
  async function listRuns(env = process.env) {
4344
4364
  const root2 = runsRoot(env);
@@ -4352,13 +4372,13 @@ async function listRuns(env = process.env) {
4352
4372
  const runs = [];
4353
4373
  for (const name of names) {
4354
4374
  if (!RUN_ID_PATTERN.test(name)) continue;
4355
- let dir2;
4375
+ let dir3;
4356
4376
  try {
4357
- dir2 = await realpath(join5(root2, name));
4377
+ dir3 = await realpath(join5(root2, name));
4358
4378
  } catch {
4359
4379
  continue;
4360
4380
  }
4361
- const run = await readRunDir(dir2);
4381
+ const run = await readRunDir(dir3);
4362
4382
  if (run && run.runId === name) runs.push(run);
4363
4383
  }
4364
4384
  return runs.sort((a, b) => a.createdAt === b.createdAt ? b.runId.localeCompare(a.runId) : b.createdAt.localeCompare(a.createdAt));
@@ -4368,14 +4388,14 @@ async function loadRun(runId, env = process.env) {
4368
4388
  if (!RUN_ID_PATTERN.test(id)) {
4369
4389
  throw usageError(`"${runId}" is not a run id: run ids look like r_ab3dxk2q.`, { field: "runId", next: "kenso runs list" });
4370
4390
  }
4371
- let dir2;
4391
+ let dir3;
4372
4392
  try {
4373
- if (await checkRoot(runsRoot(env))) dir2 = await realpath(join5(runsRoot(env), id));
4393
+ if (await checkRoot(runsRoot(env))) dir3 = await realpath(join5(runsRoot(env), id));
4374
4394
  } catch (err) {
4375
4395
  if (err instanceof KensoError) throw err;
4376
- dir2 = void 0;
4396
+ dir3 = void 0;
4377
4397
  }
4378
- const run = dir2 ? await readRun(dir2) : null;
4398
+ const run = dir3 ? await readRun(dir3) : null;
4379
4399
  if (!run || run.runId !== id) {
4380
4400
  throw new KensoError({
4381
4401
  code: "run_not_found",
@@ -4387,11 +4407,11 @@ async function loadRun(runId, env = process.env) {
4387
4407
  }
4388
4408
  return run;
4389
4409
  }
4390
- async function findIdentical(command70, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4410
+ async function findIdentical(command71, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4391
4411
  const identity = argsIdentity(args);
4392
4412
  const runs = await listRuns(env);
4393
4413
  return runs.filter(
4394
- (run) => run.command === command70 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4414
+ (run) => run.command === command71 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4395
4415
  );
4396
4416
  }
4397
4417
  function isOtherLiveProcess(pid) {
@@ -4424,30 +4444,30 @@ import { join as join6, resolve as resolve3 } from "node:path";
4424
4444
  async function prepareRunDir(outDir, runId, identical, ctx) {
4425
4445
  const root2 = runsRoot(ctx.env);
4426
4446
  if (outDir === void 0) {
4427
- const dir3 = join6(root2, runId);
4447
+ const dir4 = join6(root2, runId);
4428
4448
  ensurePrivateDir2(root2);
4429
- ensurePrivateDir2(dir3);
4430
- return dir3;
4449
+ ensurePrivateDir2(dir4);
4450
+ return dir4;
4431
4451
  }
4432
- const dir2 = resolve3(outDir);
4433
- const existing = existsSync3(join6(dir2, "run.json")) ? await readRunDir(dir2) : null;
4452
+ const dir3 = resolve3(outDir);
4453
+ const existing = existsSync3(join6(dir3, "run.json")) ? await readRunDir(dir3) : null;
4434
4454
  if (existing && !identical.some((run) => run.runId === existing.runId)) {
4435
- throw usageError(`${dir2} already holds run ${existing.runId} (${existing.command}).`, {
4455
+ throw usageError(`${dir3} already holds run ${existing.runId} (${existing.command}).`, {
4436
4456
  field: "out",
4437
4457
  hint: "Pick an empty --out directory, or leave --out off to keep the run under the runs directory."
4438
4458
  });
4439
4459
  }
4440
- ensurePrivateDir2(dir2);
4460
+ ensurePrivateDir2(dir3);
4441
4461
  for (const name of ["results.csv", "invalid.csv", "plan.json", "summary.json", "state.json"]) {
4442
- await unlink2(join6(dir2, name)).catch(() => void 0);
4462
+ await unlink2(join6(dir3, name)).catch(() => void 0);
4443
4463
  }
4444
4464
  try {
4445
4465
  ensurePrivateDir2(root2);
4446
- await symlink(dir2, join6(root2, runId), "junction");
4466
+ await symlink(dir3, join6(root2, runId), "junction");
4447
4467
  } catch (err) {
4448
- ctx.output.warn(`Could not link ${dir2} into ${root2} (${errorText(err)}): kenso runs will not list this run.`);
4468
+ ctx.output.warn(`Could not link ${dir3} into ${root2} (${errorText(err)}): kenso runs will not list this run.`);
4449
4469
  }
4450
- return dir2;
4470
+ return dir3;
4451
4471
  }
4452
4472
  async function allSucceeded(run, totalRows) {
4453
4473
  const previous = await readResults(filesOf(run.dir).resultsNdjson);
@@ -4484,14 +4504,14 @@ async function alreadyDone(run, totalRows, started, ctx) {
4484
4504
  }
4485
4505
  async function dryRun(spec, ctx, plan) {
4486
4506
  let runId;
4487
- let dir2;
4507
+ let dir3;
4488
4508
  const target2 = plan.finished ?? plan.resumable;
4489
4509
  if (target2) {
4490
4510
  runId = target2.runId;
4491
- dir2 = target2.dir;
4511
+ dir3 = target2.dir;
4492
4512
  } else {
4493
4513
  runId = newRunId();
4494
- dir2 = await prepareRunDir(spec.outDir, runId, plan.identical, ctx);
4514
+ dir3 = await prepareRunDir(spec.outDir, runId, plan.identical, ctx);
4495
4515
  const now = (/* @__PURE__ */ new Date()).toISOString();
4496
4516
  await writeRunRecord({
4497
4517
  runId,
@@ -4504,7 +4524,7 @@ async function dryRun(spec, ctx, plan) {
4504
4524
  status: "planned",
4505
4525
  chunkCount: plan.chunkCount,
4506
4526
  chunksDone: [],
4507
- dir: dir2,
4527
+ dir: dir3,
4508
4528
  rows: plan.totalRows,
4509
4529
  chunkSize: spec.chunkSize,
4510
4530
  itemsSha256: plan.itemsSha256,
@@ -4512,7 +4532,7 @@ async function dryRun(spec, ctx, plan) {
4512
4532
  updatedAt: now
4513
4533
  });
4514
4534
  }
4515
- const files = filesOf(dir2);
4535
+ const files = filesOf(dir3);
4516
4536
  const planBody = {
4517
4537
  dryRun: true,
4518
4538
  command: spec.command,
@@ -4539,7 +4559,7 @@ async function dryRun(spec, ctx, plan) {
4539
4559
  ctx.output.summary(summary);
4540
4560
  return {
4541
4561
  runId,
4542
- dir: dir2,
4562
+ dir: dir3,
4543
4563
  resultsCsv: files.resultsCsv,
4544
4564
  resultsNdjson: files.resultsNdjson,
4545
4565
  invalidCsv: plan.invalid.length > 0 ? files.invalidCsv : void 0,
@@ -4618,7 +4638,7 @@ async function runBatch(spec, ctx) {
4618
4638
  };
4619
4639
  } else {
4620
4640
  const runId = newRunId();
4621
- const dir2 = await prepareRunDir(spec.outDir, runId, identical, ctx);
4641
+ const dir3 = await prepareRunDir(spec.outDir, runId, identical, ctx);
4622
4642
  record3 = {
4623
4643
  runId,
4624
4644
  command: spec.command,
@@ -4630,7 +4650,7 @@ async function runBatch(spec, ctx) {
4630
4650
  status: "running",
4631
4651
  chunkCount,
4632
4652
  chunksDone: [],
4633
- dir: dir2,
4653
+ dir: dir3,
4634
4654
  rows: totalRows,
4635
4655
  chunkSize: spec.chunkSize,
4636
4656
  itemsSha256,
@@ -7615,9 +7635,9 @@ async function resolveGenerated(resource, action) {
7615
7635
  const { operationToCommand: operationToCommand2 } = await Promise.resolve().then(() => (init_execute(), execute_exports));
7616
7636
  return operationToCommand2(op);
7617
7637
  }
7618
- async function featuresFromEnv(env, flags = {}, overrides = {}) {
7638
+ async function featuresFromEnv(env, flags = {}, overrides2 = {}) {
7619
7639
  try {
7620
- const ctx = createContext(flags, env, { ...overrides, stdout: DISCARD, stderr: DISCARD });
7640
+ const ctx = createContext(flags, env, { ...overrides2, stdout: DISCARD, stderr: DISCARD });
7621
7641
  return await loadWorkspaceFeatures(ctx, { timeoutMs: HELP_FEATURES_TIMEOUT_MS });
7622
7642
  } catch {
7623
7643
  return { features: [] };
@@ -7637,6 +7657,7 @@ async function listGenerated(opts = {}) {
7637
7657
  resource: op.resource,
7638
7658
  action: op.action,
7639
7659
  summary: op.summary ?? `${op.method} ${op.path}`,
7660
+ effect: op.effect ?? "write",
7640
7661
  beta: !gateSatisfied(op.featureGates, features),
7641
7662
  ...op.featureGates ? { featureGates: op.featureGates } : {}
7642
7663
  }));
@@ -7655,6 +7676,187 @@ var init_generated_hook = __esm({
7655
7676
  }
7656
7677
  });
7657
7678
 
7679
+ // src/manifest/data.ts
7680
+ import { readFileSync as readFileSync6 } from "node:fs";
7681
+ function readDataFile(name) {
7682
+ if (overrides.has(name)) return overrides.get(name);
7683
+ if (!cache.has(name)) {
7684
+ let value;
7685
+ try {
7686
+ value = JSON.parse(readFileSync6(new URL(name, dir2), "utf8"));
7687
+ } catch {
7688
+ value = void 0;
7689
+ }
7690
+ cache.set(name, value);
7691
+ }
7692
+ return cache.get(name);
7693
+ }
7694
+ var dir2, cache, overrides;
7695
+ var init_data = __esm({
7696
+ "src/manifest/data.ts"() {
7697
+ "use strict";
7698
+ dir2 = new URL("./", import.meta.url);
7699
+ cache = /* @__PURE__ */ new Map();
7700
+ overrides = /* @__PURE__ */ new Map();
7701
+ }
7702
+ });
7703
+
7704
+ // src/core/rate-card.ts
7705
+ import { readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
7706
+ import { join as join8 } from "node:path";
7707
+ import { Writable as Writable2 } from "node:stream";
7708
+ function cleanItems(value) {
7709
+ if (!Array.isArray(value)) return [];
7710
+ const out = [];
7711
+ for (const raw of value) {
7712
+ if (raw === null || typeof raw !== "object" || typeof raw.action !== "string") continue;
7713
+ const item = {};
7714
+ for (const key of ITEM_KEYS) {
7715
+ const field = raw[key];
7716
+ if (typeof field === "string" || typeof field === "number") item[key] = field;
7717
+ }
7718
+ out.push(item);
7719
+ }
7720
+ return out;
7721
+ }
7722
+ function bundledCards() {
7723
+ const data = readDataFile(DATA_FILE);
7724
+ const cards = [];
7725
+ for (const card of Array.isArray(data?.cards) ? data.cards : []) {
7726
+ if (typeof card.version === "number") cards.push({ version: card.version, source: "bundled", items: cleanItems(card.items) });
7727
+ }
7728
+ return cards;
7729
+ }
7730
+ function readCache2(file) {
7731
+ try {
7732
+ const parsed2 = JSON.parse(readFileSync7(file, "utf8"));
7733
+ return parsed2 !== null && typeof parsed2 === "object" && !Array.isArray(parsed2) ? parsed2 : {};
7734
+ } catch {
7735
+ return {};
7736
+ }
7737
+ }
7738
+ function isFresh2(entry, now) {
7739
+ if (!entry || typeof entry.version !== "number" || !Array.isArray(entry.items)) return false;
7740
+ const at = Date.parse(entry.fetchedAt);
7741
+ return Number.isFinite(at) && now - at >= 0 && now - at < TTL_MS2;
7742
+ }
7743
+ function writeCache(file, cache2, key, entry, now) {
7744
+ try {
7745
+ const kept = {};
7746
+ for (const [k, old] of Object.entries(cache2)) if (isFresh2(old, now)) kept[k] = old;
7747
+ kept[key] = entry;
7748
+ const temp = `${file}.${process.pid}.tmp`;
7749
+ writeFileSync3(temp, `${JSON.stringify(kept)}
7750
+ `, { mode: 384 });
7751
+ renameSync3(temp, file);
7752
+ } catch {
7753
+ }
7754
+ }
7755
+ async function loadRateCards(ctx, opts = {}) {
7756
+ const key = featureCacheKey(ctx.auth);
7757
+ if (!key) return bundledCards();
7758
+ const now = Date.now();
7759
+ let file;
7760
+ let cache2 = {};
7761
+ try {
7762
+ file = join8(cacheDir(ctx.env), CACHE_FILE2);
7763
+ cache2 = readCache2(file);
7764
+ } catch {
7765
+ file = void 0;
7766
+ }
7767
+ const entry = cache2[key];
7768
+ const hit = isFresh2(entry, now) ? entry : void 0;
7769
+ const offline = () => hit ? [{ version: hit.version, source: "cache", items: cleanItems(hit.items) }] : bundledCards();
7770
+ if (opts.live === false || opts.live === void 0 && hit) return offline();
7771
+ try {
7772
+ const signal = AbortSignal.any([ctx.signal, AbortSignal.timeout(opts.timeoutMs ?? FETCH_TIMEOUT_MS2)]);
7773
+ const res = await ctx.client.request({ method: "GET", path: "/v1/credits/rate-card", signal });
7774
+ const card = unwrap(res.body);
7775
+ if (!card || typeof card.version !== "number") return offline();
7776
+ const items = cleanItems(card.items);
7777
+ if (file) writeCache(file, cache2, key, { version: card.version, items, fetchedAt: new Date(now).toISOString() }, now);
7778
+ return [{ version: card.version, source: "live", items }];
7779
+ } catch {
7780
+ return offline();
7781
+ }
7782
+ }
7783
+ async function rateCardsForHelp(env, flags = {}, overrides2 = {}) {
7784
+ try {
7785
+ const ctx = createContext(flags, env, { ...overrides2, stdout: DISCARD2, stderr: DISCARD2 });
7786
+ return await loadRateCards(ctx, { timeoutMs: HELP_RATE_CARD_TIMEOUT_MS });
7787
+ } catch {
7788
+ return bundledCards();
7789
+ }
7790
+ }
7791
+ function credits(millicredits) {
7792
+ return String(Number((millicredits / 1e3).toFixed(3)));
7793
+ }
7794
+ function unitPrice(item, line) {
7795
+ if ((item.millicreditsPerUnit ?? 0) === 0) {
7796
+ const note = (item.note ?? "").replace(/^not charged in credits\.?\s*/i, "").replace(/\.$/, "");
7797
+ return `not charged in credits${note ? ` (${note})` : ""}`;
7798
+ }
7799
+ const amount = credits(item.millicreditsPerUnit ?? 0);
7800
+ const billing = item.billing ?? line.billing;
7801
+ const period = billing === "monthly" ? " per month" : billing === "yearly" ? " per year" : "";
7802
+ return `${amount} ${amount === "1" ? "credit" : "credits"} per ${item.unit ?? line.unit ?? "unit"}${period}`;
7803
+ }
7804
+ function priceLine(line, cards) {
7805
+ if (line.pricing === "varies") return `${line.action}: price depends on the work; --dry-run prints the estimate where the command has one`;
7806
+ const priced = [];
7807
+ for (const card of cards) {
7808
+ const item = card.items.find((candidate2) => candidate2.action === line.action && (candidate2.pricing ?? "fixed") === "fixed");
7809
+ if (item) priced.push({ card, item });
7810
+ }
7811
+ if (priced.length === 0) return `${line.action}: charged, not on the rate card (${RATE_CARD_COMMAND})`;
7812
+ const named = cards.length > 1;
7813
+ return `${line.action}: ${priced.map(({ card, item }) => `${unitPrice(item, line)}${named ? ` (rate card v${card.version})` : ""}`).join(", ")}`;
7814
+ }
7815
+ var CACHE_FILE2, DATA_FILE, TTL_MS2, FETCH_TIMEOUT_MS2, ITEM_KEYS, HELP_RATE_CARD_TIMEOUT_MS, RATE_CARD_COMMAND, DISCARD2;
7816
+ var init_rate_card = __esm({
7817
+ "src/core/rate-card.ts"() {
7818
+ "use strict";
7819
+ init_data();
7820
+ init_config();
7821
+ init_context();
7822
+ init_features();
7823
+ init_http();
7824
+ CACHE_FILE2 = "rate-card.json";
7825
+ DATA_FILE = "pricing.json";
7826
+ TTL_MS2 = 24 * 60 * 60 * 1e3;
7827
+ FETCH_TIMEOUT_MS2 = 5e3;
7828
+ ITEM_KEYS = ["action", "unit", "unitSize", "millicreditsPerUnit", "billing", "pricing", "note"];
7829
+ HELP_RATE_CARD_TIMEOUT_MS = 1500;
7830
+ RATE_CARD_COMMAND = "kenso credit-rate-card get";
7831
+ DISCARD2 = new Writable2({
7832
+ write(_chunk, _encoding, callback) {
7833
+ callback();
7834
+ }
7835
+ });
7836
+ }
7837
+ });
7838
+
7839
+ // src/commands/help-effect.ts
7840
+ function effectAndCost(spec, rateCards) {
7841
+ const lines = [`Effect: ${spec.effect ?? "write"}.`];
7842
+ if (spec.cost && spec.cost.length > 0) {
7843
+ const cards = rateCards ?? bundledCards();
7844
+ lines.push(`Cost: ${spec.cost.map((line) => priceLine(line, cards)).join("; ")}.`);
7845
+ } else if (spec.doc?.cost) {
7846
+ lines.push(`Cost: ${spec.doc.cost}`);
7847
+ }
7848
+ return lines;
7849
+ }
7850
+ function effectMark(effect) {
7851
+ return (effect ?? "write") === "read" ? "" : ` (${effect ?? "write"})`;
7852
+ }
7853
+ var init_help_effect = __esm({
7854
+ "src/commands/help-effect.ts"() {
7855
+ "use strict";
7856
+ init_rate_card();
7857
+ }
7858
+ });
7859
+
7658
7860
  // src/commands/people/columns.ts
7659
7861
  function normalizeHeader(header) {
7660
7862
  return header.toLowerCase().replace(/[^a-z0-9]/g, "");
@@ -7714,8 +7916,8 @@ function idValue(value, field) {
7714
7916
  function shellQuote3(arg) {
7715
7917
  return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
7716
7918
  }
7717
- function commandLine2(ctx, command70, args, extra = []) {
7718
- const parts2 = ["kenso", ...command70.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
7919
+ function commandLine2(ctx, command71, args, extra = []) {
7920
+ const parts2 = ["kenso", ...command71.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
7719
7921
  for (const [name, value] of Object.entries(args.flags)) {
7720
7922
  if (value === void 0 || value === false) continue;
7721
7923
  if (value === true) parts2.push(`--${name}`);
@@ -8012,9 +8214,9 @@ function stringFlag2(flags, name) {
8012
8214
  const text4 = value.trim();
8013
8215
  return text4 === "" ? void 0 : text4;
8014
8216
  }
8015
- function requireFlag(flags, name, command70, hint) {
8217
+ function requireFlag(flags, name, command71, hint) {
8016
8218
  const value = stringFlag2(flags, name);
8017
- if (value === void 0) throw usageError(`--${name} is required for ${command70}.`, { field: name, next: `${command70} --help`, ...hint ? { hint } : {} });
8219
+ if (value === void 0) throw usageError(`--${name} is required for ${command71}.`, { field: name, next: `${command71} --help`, ...hint ? { hint } : {} });
8018
8220
  return value;
8019
8221
  }
8020
8222
  function positiveId(value) {
@@ -8023,8 +8225,8 @@ function positiveId(value) {
8023
8225
  const id = Number(text4);
8024
8226
  return Number.isSafeInteger(id) && id > 0 ? id : void 0;
8025
8227
  }
8026
- function idFlag(flags, name, command70) {
8027
- const raw = requireFlag(flags, name, command70);
8228
+ function idFlag(flags, name, command71) {
8229
+ const raw = requireFlag(flags, name, command71);
8028
8230
  const id = positiveId(raw);
8029
8231
  if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
8030
8232
  return id;
@@ -8044,8 +8246,8 @@ function isDryRun(ctx) {
8044
8246
  function shellQuote4(value) {
8045
8247
  return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
8046
8248
  }
8047
- function sameCommand2(command70, flags, ctx, extra = []) {
8048
- const parts2 = [command70];
8249
+ function sameCommand2(command71, flags, ctx, extra = []) {
8250
+ const parts2 = [command71];
8049
8251
  for (const [name, value] of Object.entries(flags)) {
8050
8252
  if (value === void 0 || value === false) continue;
8051
8253
  if (value === true) parts2.push(`--${name}`);
@@ -8277,12 +8479,12 @@ function filterBody(flags) {
8277
8479
  }
8278
8480
  return parsed2;
8279
8481
  }
8280
- function targetBody(flags, target2, command70) {
8482
+ function targetBody(flags, target2, command71) {
8281
8483
  const ids2 = idList(flags, "ids");
8282
8484
  const filter = filterBody(flags);
8283
8485
  const everything = flags.all === true;
8284
8486
  if (ids2 !== void 0 === (filter !== void 0 || everything)) {
8285
- throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command70} --help` });
8487
+ throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command71} --help` });
8286
8488
  }
8287
8489
  const exclude = idList(flags, "exclude-ids");
8288
8490
  if (exclude !== void 0 && ids2 !== void 0) throw usageError("--exclude-ids goes with --filter or --all.", { field: "exclude-ids" });
@@ -8303,14 +8505,14 @@ function tagSet(flags) {
8303
8505
  return set2;
8304
8506
  }
8305
8507
  function requestBody(flags, target2, dryRun2) {
8306
- const command70 = `kenso ${target2.resource} bulk-update`;
8508
+ const command71 = `kenso ${target2.resource} bulk-update`;
8307
8509
  const pairs = Array.isArray(flags.set) ? flags.set : typeof flags.set === "string" ? [flags.set] : [];
8308
8510
  const tags = target2.tags ? tagSet(flags) : {};
8309
8511
  if (pairs.length === 0 && Object.keys(tags).length === 0) {
8310
- throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${command70}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command70} --help` });
8512
+ throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${command71}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command71} --help` });
8311
8513
  }
8312
8514
  return {
8313
- ...targetBody(flags, target2, command70),
8515
+ ...targetBody(flags, target2, command71),
8314
8516
  set: { ...parseSet(pairs, target2.aliases, target2.textFields), ...tags },
8315
8517
  ...dryRun2 ? { dryRun: true } : {},
8316
8518
  ...flags["overwrite-pinned"] === true ? { overwritePinned: true } : {}
@@ -8376,7 +8578,7 @@ function bulkUpdateCommand(target2) {
8376
8578
  };
8377
8579
  }
8378
8580
  function bulkDeleteCommand(target2) {
8379
- const command70 = `kenso ${target2.resource} bulk-delete`;
8581
+ const command71 = `kenso ${target2.resource} bulk-delete`;
8380
8582
  return {
8381
8583
  resource: target2.resource,
8382
8584
  action: "bulk-delete",
@@ -8396,7 +8598,7 @@ function bulkDeleteCommand(target2) {
8396
8598
  beta: { featureGates: { all: target2.featureGates } },
8397
8599
  operationIds: [`${target2.resource}.bulk-delete`, "changes.get"],
8398
8600
  dryRun: true,
8399
- run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command70), dryRun: dryRun2 }))
8601
+ run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command71), dryRun: dryRun2 }))
8400
8602
  };
8401
8603
  }
8402
8604
  async function runChange(ctx, flags, path, body2) {
@@ -8558,7 +8760,7 @@ var init_merge = __esm({
8558
8760
 
8559
8761
  // src/commands/work/common.ts
8560
8762
  import { randomUUID } from "node:crypto";
8561
- import { join as join8 } from "node:path";
8763
+ import { join as join9 } from "node:path";
8562
8764
  import { setTimeout as delay4 } from "node:timers/promises";
8563
8765
  function unavailable(err) {
8564
8766
  return err instanceof KensoError && (err.code === "network_error" || err.httpStatus === 502 || err.httpStatus === 503 || err.httpStatus === 504);
@@ -8632,8 +8834,8 @@ function leaseMinutes(flags) {
8632
8834
  function shellQuote5(value) {
8633
8835
  return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
8634
8836
  }
8635
- function submitCommand(dir2) {
8636
- return `kenso work submit ${shellQuote5(join8(dir2, "/"))}*.answers.json`;
8837
+ function submitCommand(dir3) {
8838
+ return `kenso work submit ${shellQuote5(join9(dir3, "/"))}*.answers.json`;
8637
8839
  }
8638
8840
  function explainNotFound(err) {
8639
8841
  if (!(err instanceof KensoError) || err.httpStatus !== 404 || err.hint !== void 0) return err;
@@ -8761,6 +8963,7 @@ var init_duplicates = __esm({
8761
8963
  action: "duplicates",
8762
8964
  summary: "List the account pairs that look like duplicates. --scan looks for new pairs first",
8763
8965
  effect: "write",
8966
+ effectFor: ({ flags }) => flags.scan === true ? "write" : "read",
8764
8967
  description: "Reads GET /v1/account-duplicates: each pair with both accounts (account and otherAccount: name, domain, stage, owner, last touch), why they were paired (reasons: domain, linkedin, name) and isCertain (same domain and same name, the pairs Ken merges itself where that is on; heldReason says why Ken left one). --status picks open (the default), dismissed or merged. --scan sends POST /v1/account-duplicates/scan first, which compares every account of the workspace and needs a plan with accounts. Merge a pair with `kenso accounts merge <accountId> --into <id>`, or answer that it is not a duplicate with `kenso account-duplicates dismiss --duplicate-id <duplicateId>`.",
8765
8968
  flags: {
8766
8969
  status: { type: "string", description: "open (default), dismissed or merged" },
@@ -9045,10 +9248,10 @@ var init_embedded = __esm({
9045
9248
  });
9046
9249
 
9047
9250
  // src/commands/docs/content.ts
9048
- import { readFileSync as readFileSync6 } from "node:fs";
9251
+ import { readFileSync as readFileSync8 } from "node:fs";
9049
9252
  function readOptional(url) {
9050
9253
  try {
9051
- return readFileSync6(url, "utf8");
9254
+ return readFileSync8(url, "utf8");
9052
9255
  } catch {
9053
9256
  return void 0;
9054
9257
  }
@@ -9059,7 +9262,7 @@ async function topicText(topic) {
9059
9262
  }
9060
9263
  async function skillText() {
9061
9264
  if (!fromSource) return (await Promise.resolve().then(() => (init_embedded(), embedded_exports))).SKILL;
9062
- return readFileSync6(new URL("skill/kenso-cli/SKILL.md", root), "utf8");
9265
+ return readFileSync8(new URL("skill/kenso-cli/SKILL.md", root), "utf8");
9063
9266
  }
9064
9267
  var TOPICS, fromSource, root;
9065
9268
  var init_content = __esm({
@@ -9268,28 +9471,28 @@ var init_client = __esm({
9268
9471
 
9269
9472
  // src/commands/skill/clients.ts
9270
9473
  import { homedir as homedir2 } from "node:os";
9271
- import { join as join9 } from "node:path";
9474
+ import { join as join10 } from "node:path";
9272
9475
  function home(env) {
9273
9476
  return env.HOME?.trim() || env.USERPROFILE?.trim() || homedir2();
9274
9477
  }
9275
9478
  function claudeDir(env) {
9276
- return env.CLAUDE_CONFIG_DIR?.trim() || join9(home(env), ".claude");
9479
+ return env.CLAUDE_CONFIG_DIR?.trim() || join10(home(env), ".claude");
9277
9480
  }
9278
9481
  function xdgConfigDir(env) {
9279
- return env.XDG_CONFIG_HOME?.trim() || join9(home(env), ".config");
9482
+ return env.XDG_CONFIG_HOME?.trim() || join10(home(env), ".config");
9280
9483
  }
9281
9484
  function skillsFolder(client, env) {
9282
9485
  switch (client) {
9283
9486
  case "claude-code":
9284
- return join9(claudeDir(env), "skills");
9487
+ return join10(claudeDir(env), "skills");
9285
9488
  case "codex":
9286
- return join9(home(env), ".agents", "skills");
9489
+ return join10(home(env), ".agents", "skills");
9287
9490
  case "cursor":
9288
- return join9(home(env), ".cursor", "skills");
9491
+ return join10(home(env), ".cursor", "skills");
9289
9492
  case "gemini":
9290
- return join9(home(env), ".gemini", "skills");
9493
+ return join10(home(env), ".gemini", "skills");
9291
9494
  case "opencode":
9292
- return join9(xdgConfigDir(env), "opencode", "skills");
9495
+ return join10(xdgConfigDir(env), "opencode", "skills");
9293
9496
  }
9294
9497
  }
9295
9498
  var CLIENTS, CLIENT_CHOICES, CLIENT_NAMES, AGENT_CLIENTS;
@@ -9319,15 +9522,15 @@ __export(install_exports, {
9319
9522
  readExisting: () => readExisting,
9320
9523
  write: () => write
9321
9524
  });
9322
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
9323
- import { basename as basename2, dirname, join as join10, resolve as resolve6 } from "node:path";
9525
+ import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync9, renameSync as renameSync4, writeFileSync as writeFileSync4 } from "node:fs";
9526
+ import { basename as basename2, dirname, join as join11, resolve as resolve6 } from "node:path";
9324
9527
  function quote(value) {
9325
9528
  return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
9326
9529
  }
9327
9530
  function readExisting(path) {
9328
9531
  if (!existsSync4(path)) return void 0;
9329
9532
  try {
9330
- return readFileSync7(path, "utf8");
9533
+ return readFileSync9(path, "utf8");
9331
9534
  } catch (err) {
9332
9535
  const code = err.code;
9333
9536
  throw new KensoError({ code: "file_unreadable", message: `Cannot read ${path}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Usage });
@@ -9337,17 +9540,17 @@ function write(path, text4) {
9337
9540
  try {
9338
9541
  mkdirSync3(dirname(path), { recursive: true });
9339
9542
  const temp = `${path}.${process.pid}.tmp`;
9340
- writeFileSync3(temp, text4);
9341
- renameSync3(temp, path);
9543
+ writeFileSync4(temp, text4);
9544
+ renameSync4(temp, path);
9342
9545
  } catch (err) {
9343
9546
  const code = err.code;
9344
9547
  throw new KensoError({ code: "file_unwritable", message: `Cannot write ${path}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Error });
9345
9548
  }
9346
9549
  }
9347
- function folders(ctx, client, dir2) {
9348
- if (dir2 !== void 0) return [{ client, folder: resolve6(dir2) }];
9550
+ function folders(ctx, client, dir3) {
9551
+ if (dir3 !== void 0) return [{ client, folder: resolve6(dir3) }];
9349
9552
  const clients = client === "all" ? CLIENTS : [client];
9350
- return clients.map((c) => ({ client: c, folder: join10(skillsFolder(c, ctx.env), SKILL_NAME) }));
9553
+ return clients.map((c) => ({ client: c, folder: join11(skillsFolder(c, ctx.env), SKILL_NAME) }));
9351
9554
  }
9352
9555
  function installCommand(opts) {
9353
9556
  const parts2 = ["kenso skill install"];
@@ -9382,21 +9585,21 @@ var init_install = __esm({
9382
9585
  dryRun: true,
9383
9586
  async run(ctx, { flags }) {
9384
9587
  const clientFlag = typeof flags.client === "string" ? flags.client.trim() : void 0;
9385
- const dir2 = typeof flags.dir === "string" && flags.dir.trim() !== "" ? flags.dir : void 0;
9588
+ const dir3 = typeof flags.dir === "string" && flags.dir.trim() !== "" ? flags.dir : void 0;
9386
9589
  if (clientFlag !== void 0 && !CLIENT_CHOICES.includes(clientFlag)) {
9387
9590
  throw usageError(`--client must be one of ${CLIENT_CHOICES.join(", ")} (got "${clientFlag}").`, { field: "client", next: "kenso skill install --help" });
9388
9591
  }
9389
9592
  const client = clientFlag ?? (ctx.agent ? AGENT_CLIENTS2[ctx.agent.name] : void 0) ?? "all";
9390
9593
  const text4 = await skillText();
9391
- const targets = folders(ctx, client, dir2).map(({ client: c, folder }) => {
9392
- const path = join10(folder, "SKILL.md");
9594
+ const targets = folders(ctx, client, dir3).map(({ client: c, folder }) => {
9595
+ const path = join11(folder, "SKILL.md");
9393
9596
  const existing = readExisting(path);
9394
9597
  const status = existing === void 0 ? "created" : existing === text4 ? "unchanged" : "replaced";
9395
9598
  return { client: c, path, status };
9396
9599
  });
9397
9600
  const conflicts = targets.filter((t) => t.status === "replaced");
9398
9601
  const needsForce = conflicts.length > 0 || flags.force === true;
9399
- const next = installCommand({ client: dir2 === void 0 ? client : clientFlag, dir: dir2, force: needsForce });
9602
+ const next = installCommand({ client: dir3 === void 0 ? client : clientFlag, dir: dir3, force: needsForce });
9400
9603
  if (ctx.flags.dryRun) {
9401
9604
  ctx.output.object({ dryRun: true, installed: targets, next });
9402
9605
  return ExitCode.Ok;
@@ -9414,8 +9617,8 @@ var init_install = __esm({
9414
9617
  for (const target2 of targets) {
9415
9618
  if (target2.status !== "unchanged") write(target2.path, text4);
9416
9619
  }
9417
- if (dir2 !== void 0 && basename2(resolve6(dir2)) !== SKILL_NAME) {
9418
- ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve6(dir2)} is not.`);
9620
+ if (dir3 !== void 0 && basename2(resolve6(dir3)) !== SKILL_NAME) {
9621
+ ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve6(dir3)} is not.`);
9419
9622
  }
9420
9623
  ctx.output.object({ installed: targets });
9421
9624
  return ExitCode.Ok;
@@ -9427,8 +9630,8 @@ var init_install = __esm({
9427
9630
 
9428
9631
  // src/commands/agent/mcp-config.ts
9429
9632
  import { spawnSync } from "node:child_process";
9430
- import { existsSync as existsSync5, readFileSync as readFileSync8 } from "node:fs";
9431
- import { delimiter, join as join11 } from "node:path";
9633
+ import { existsSync as existsSync5, readFileSync as readFileSync10 } from "node:fs";
9634
+ import { delimiter, join as join12 } from "node:path";
9432
9635
  function parse2(text4) {
9433
9636
  try {
9434
9637
  const doc = JSON.parse(text4);
@@ -9485,9 +9688,9 @@ function tomlServers(text4) {
9485
9688
  return entries2;
9486
9689
  }
9487
9690
  function opencodeFile(env) {
9488
- const dir2 = join11(xdgConfigDir(env), "opencode");
9489
- const existing = ["opencode.jsonc", "opencode.json", "config.json"].map((f) => join11(dir2, f)).find((f) => existsSync5(f));
9490
- return existing ?? join11(dir2, "opencode.json");
9691
+ const dir3 = join12(xdgConfigDir(env), "opencode");
9692
+ const existing = ["opencode.jsonc", "opencode.json", "config.json"].map((f) => join12(dir3, f)).find((f) => existsSync5(f));
9693
+ return existing ?? join12(dir3, "opencode.json");
9491
9694
  }
9492
9695
  function canonical(url) {
9493
9696
  try {
@@ -9499,7 +9702,7 @@ function canonical(url) {
9499
9702
  }
9500
9703
  function onPath(bin, env) {
9501
9704
  const names = process.platform === "win32" ? [`${bin}.cmd`, `${bin}.exe`, bin] : [bin];
9502
- return (env.PATH ?? env.Path ?? "").split(delimiter).some((dir2) => dir2 !== "" && names.some((n) => existsSync5(join11(dir2, n))));
9705
+ return (env.PATH ?? env.Path ?? "").split(delimiter).some((dir3) => dir3 !== "" && names.some((n) => existsSync5(join12(dir3, n))));
9503
9706
  }
9504
9707
  function isPresent(client, env) {
9505
9708
  const t = TARGETS[client];
@@ -9507,7 +9710,7 @@ function isPresent(client, env) {
9507
9710
  }
9508
9711
  function readText2(path) {
9509
9712
  try {
9510
- return readFileSync8(path, "utf8");
9713
+ return readFileSync10(path, "utf8");
9511
9714
  } catch {
9512
9715
  return void 0;
9513
9716
  }
@@ -9576,7 +9779,7 @@ var init_mcp_config = __esm({
9576
9779
  "claude-code": {
9577
9780
  bins: ["claude"],
9578
9781
  folder: claudeDir,
9579
- file: (env) => env.CLAUDE_CONFIG_DIR?.trim() ? join11(env.CLAUDE_CONFIG_DIR.trim(), ".claude.json") : join11(home(env), ".claude.json"),
9782
+ file: (env) => env.CLAUDE_CONFIG_DIR?.trim() ? join12(env.CLAUDE_CONFIG_DIR.trim(), ".claude.json") : join12(home(env), ".claude.json"),
9580
9783
  // User scope only: that is where setup adds it, and it reaches every project.
9581
9784
  entries: (text4) => mcpServersOf(text4),
9582
9785
  command: (url) => ["claude", "mcp", "add", "--scope", "user", "--transport", "http", SERVER_NAME, url],
@@ -9584,16 +9787,16 @@ var init_mcp_config = __esm({
9584
9787
  },
9585
9788
  codex: {
9586
9789
  bins: ["codex"],
9587
- folder: (env) => env.CODEX_HOME?.trim() || join11(home(env), ".codex"),
9588
- file: (env) => join11(env.CODEX_HOME?.trim() || join11(home(env), ".codex"), "config.toml"),
9790
+ folder: (env) => env.CODEX_HOME?.trim() || join12(home(env), ".codex"),
9791
+ file: (env) => join12(env.CODEX_HOME?.trim() || join12(home(env), ".codex"), "config.toml"),
9589
9792
  entries: tomlServers,
9590
9793
  command: (url) => ["codex", "mcp", "add", SERVER_NAME, "--url", url],
9591
9794
  signIn: "Run codex mcp login kenso."
9592
9795
  },
9593
9796
  cursor: {
9594
9797
  bins: ["cursor", "cursor-agent"],
9595
- folder: (env) => join11(home(env), ".cursor"),
9596
- file: (env) => join11(home(env), ".cursor", "mcp.json"),
9798
+ folder: (env) => join12(home(env), ".cursor"),
9799
+ file: (env) => join12(home(env), ".cursor", "mcp.json"),
9597
9800
  entries: (text4) => mcpServersOf(text4),
9598
9801
  merge: (doc, url) => {
9599
9802
  const all = isDoc(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
@@ -9603,8 +9806,8 @@ var init_mcp_config = __esm({
9603
9806
  },
9604
9807
  gemini: {
9605
9808
  bins: ["gemini"],
9606
- folder: (env) => join11(home(env), ".gemini"),
9607
- file: (env) => join11(home(env), ".gemini", "settings.json"),
9809
+ folder: (env) => join12(home(env), ".gemini"),
9810
+ file: (env) => join12(home(env), ".gemini", "settings.json"),
9608
9811
  // httpUrl is Gemini CLI's Streamable HTTP key; url is SSE.
9609
9812
  entries: (text4) => mcpServersOf(text4, ["httpUrl", "url"]),
9610
9813
  command: (url) => ["gemini", "mcp", "add", "--scope", "user", "--transport", "http", SERVER_NAME, url],
@@ -9612,7 +9815,7 @@ var init_mcp_config = __esm({
9612
9815
  },
9613
9816
  opencode: {
9614
9817
  bins: ["opencode"],
9615
- folder: (env) => join11(xdgConfigDir(env), "opencode"),
9818
+ folder: (env) => join12(xdgConfigDir(env), "opencode"),
9616
9819
  file: opencodeFile,
9617
9820
  // OpenCode 1.x lists servers under mcp; newer configs nest them under mcp.servers.
9618
9821
  entries: (text4) => {
@@ -9636,7 +9839,7 @@ var setup_exports = {};
9636
9839
  __export(setup_exports, {
9637
9840
  default: () => setup_default
9638
9841
  });
9639
- import { join as join12 } from "node:path";
9842
+ import { join as join13 } from "node:path";
9640
9843
  function quote2(value) {
9641
9844
  return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
9642
9845
  }
@@ -9697,7 +9900,7 @@ var init_setup = __esm({
9697
9900
  const clients = pickClients(ctx, clientFlag, status);
9698
9901
  const text4 = await skillText();
9699
9902
  const rows = clients.map((client) => {
9700
- const path = join12(skillsFolder(client, ctx.env), SKILL_NAME, "SKILL.md");
9903
+ const path = join13(skillsFolder(client, ctx.env), SKILL_NAME, "SKILL.md");
9701
9904
  const existing = readExisting(path);
9702
9905
  const skill = existing === void 0 ? "missing" : existing === text4 ? "installed" : "different";
9703
9906
  return { client, present: isPresent(client, ctx.env), skill: { path, status: skill }, mcp: mcpState(client, ctx.env, url) };
@@ -9805,6 +10008,7 @@ var init_api3 = __esm({
9805
10008
  init_exit_codes();
9806
10009
  init_input();
9807
10010
  init_transfer();
10011
+ init_manifest();
9808
10012
  METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
9809
10013
  DEFAULT_FILE_FIELD = "file";
9810
10014
  command8 = {
@@ -9813,6 +10017,14 @@ var init_api3 = __esm({
9813
10017
  summary: "Call any API route, only when no command fits",
9814
10018
  brief: "only when no command fits",
9815
10019
  effect: "destructive",
10020
+ // The effect of the route the call reaches (a GET that charges is a spend); a route the manifest does not know
10021
+ // goes by its method.
10022
+ effectFor({ positionals }) {
10023
+ const method = (positionals[0] ?? "").toUpperCase();
10024
+ const raw = positionals[1] ?? "";
10025
+ const path = URL.canParse(raw, "http://kenso.invalid") ? new URL(raw, "http://kenso.invalid").pathname : raw;
10026
+ return routeEffect(method, path) ?? (method === "GET" ? "read" : method === "DELETE" ? "destructive" : "write");
10027
+ },
9816
10028
  description: "The raw escape hatch: sends Authorization, Ken-Version: 1.1 and X-Ken-Workspace-Id, prints the full JSON body. It reaches the legacy routes that have no command. The path may carry a query string. --all (GET only) follows pagination.nextCursor and prints the data[] items as a list. --file sends a multipart upload. An answer that is not JSON (a CSV, an image, a ZIP) prints as it came; --out saves it byte for byte, and a binary one is never printed to a terminal. POST, PUT and PATCH send at once; DELETE needs --yes (on a terminal it asks). --dry-run prints the request (method, path, body) and sends nothing.",
9817
10029
  flags: {
9818
10030
  data: { type: "string", description: "Request body: inline JSON, @file or - for stdin. With --file, its keys are form fields" },
@@ -9998,8 +10210,8 @@ async function wait(ms, ctx, deps) {
9998
10210
  }
9999
10211
  if (ctx.signal.aborted) throw interrupted4();
10000
10212
  }
10001
- async function browserLogin(ctx, opts, overrides) {
10002
- const deps = { ...defaultDeps, ...overrides };
10213
+ async function browserLogin(ctx, opts, overrides2) {
10214
+ const deps = { ...defaultDeps, ...overrides2 };
10003
10215
  let started;
10004
10216
  try {
10005
10217
  const res = await ctx.client.request({
@@ -10130,8 +10342,8 @@ var init_browser_login = __esm({
10130
10342
  defaultDeps = {
10131
10343
  sleep: (ms, signal) => delay5(ms, void 0, signal ? { signal } : void 0),
10132
10344
  now: () => Date.now(),
10133
- spawn: (command70, args) => {
10134
- const child = nodeSpawn(command70, args, { detached: true, stdio: "ignore" });
10345
+ spawn: (command71, args) => {
10346
+ const child = nodeSpawn(command71, args, { detached: true, stdio: "ignore" });
10135
10347
  child.on("error", () => {
10136
10348
  });
10137
10349
  child.unref();
@@ -11360,8 +11572,8 @@ function announce(ctx, kind, flags, link, answer, waiting, limitMs, deps) {
11360
11572
  }
11361
11573
  if (link && !ctx.agent && flags["no-browser"] !== true && hasDisplay(ctx.env, deps.platform)) openBrowser(link, deps);
11362
11574
  }
11363
- async function runConnect(ctx, kind, flags, overrides) {
11364
- const deps = { ...defaultDeps2, ...overrides };
11575
+ async function runConnect(ctx, kind, flags, overrides2) {
11576
+ const deps = { ...defaultDeps2, ...overrides2 };
11365
11577
  const limitMs = timeoutMs(flags);
11366
11578
  kind.manual?.check(flags);
11367
11579
  const start = kind.start?.(flags);
@@ -11444,8 +11656,8 @@ var init_run = __esm({
11444
11656
  defaultDeps2 = {
11445
11657
  sleep: (ms, signal) => delay6(ms, void 0, signal ? { signal } : void 0),
11446
11658
  now: () => Date.now(),
11447
- spawn: (command70, args) => {
11448
- const child = nodeSpawn2(command70, args, { detached: true, stdio: "ignore" });
11659
+ spawn: (command71, args) => {
11660
+ const child = nodeSpawn2(command71, args, { detached: true, stdio: "ignore" });
11449
11661
  child.on("error", () => {
11450
11662
  });
11451
11663
  child.unref();
@@ -11457,7 +11669,7 @@ var init_run = __esm({
11457
11669
  "no-wait": { type: "boolean", description: "Print the link as JSON and end, without waiting for the connection" },
11458
11670
  "no-browser": { type: "boolean", description: "Print the link only; never open a browser" }
11459
11671
  };
11460
- KIND_EFFECTS = { linkedin: "spend", whatsapp: "spend", video: "read", github: "read" };
11672
+ KIND_EFFECTS = { linkedin: "spend", whatsapp: "spend", facebook: "spend", video: "read", github: "read" };
11461
11673
  }
11462
11674
  });
11463
11675
 
@@ -11468,8 +11680,8 @@ var init_connect3 = __esm({
11468
11680
  "use strict";
11469
11681
  KIND_NAMES = ["inbox", "calendar", "video", "crm", "hubspot-knowledge", "github", "migration", "linkedin", "whatsapp", "facebook", "instagram"];
11470
11682
  load = (name) => async () => {
11471
- const [{ KINDS: KINDS2 }, { connectCommand: connectCommand2 }] = await Promise.all([Promise.resolve().then(() => (init_kinds(), kinds_exports)), Promise.resolve().then(() => (init_run(), run_exports))]);
11472
- const kind = KINDS2.find((k) => k.name === name);
11683
+ const [{ KINDS: KINDS3 }, { connectCommand: connectCommand2 }] = await Promise.all([Promise.resolve().then(() => (init_kinds(), kinds_exports)), Promise.resolve().then(() => (init_run(), run_exports))]);
11684
+ const kind = KINDS3.find((k) => k.name === name);
11473
11685
  if (!kind) throw new Error(`no connect kind ${name}`);
11474
11686
  return connectCommand2(kind);
11475
11687
  };
@@ -11499,10 +11711,10 @@ async function ask(ctx, path, body2, read2) {
11499
11711
  }
11500
11712
  async function creditEstimate(ctx, body2) {
11501
11713
  return ask(ctx, "/v1/credits/estimates", body2, (data) => {
11502
- const credits = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
11714
+ const credits2 = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
11503
11715
  return {
11504
- needed: credits("totalMillicredits"),
11505
- available: credits("availableMillicredits"),
11716
+ needed: credits2("totalMillicredits"),
11717
+ available: credits2("availableMillicredits"),
11506
11718
  sufficient: typeof data.sufficient === "boolean" ? data.sufficient : null
11507
11719
  };
11508
11720
  });
@@ -11687,14 +11899,14 @@ function overrideTarget(column, value, mode) {
11687
11899
  }
11688
11900
  return { field };
11689
11901
  }
11690
- function overrideFor(header, overrides) {
11691
- if (Object.hasOwn(overrides, header)) return { found: true, value: overrides[header] ?? null };
11902
+ function overrideFor(header, overrides2) {
11903
+ if (Object.hasOwn(overrides2, header)) return { found: true, value: overrides2[header] ?? null };
11692
11904
  const wanted = header.trim().toLowerCase();
11693
- for (const [key, value] of Object.entries(overrides)) if (key.trim().toLowerCase() === wanted) return { found: true, value };
11905
+ for (const [key, value] of Object.entries(overrides2)) if (key.trim().toLowerCase() === wanted) return { found: true, value };
11694
11906
  return { found: false, value: null };
11695
11907
  }
11696
- function buildMapping(headers, overrides, mode) {
11697
- const unknown2 = Object.keys(overrides).filter((key) => !headers.some((h) => h === key || h.trim().toLowerCase() === key.trim().toLowerCase()));
11908
+ function buildMapping(headers, overrides2, mode) {
11909
+ const unknown2 = Object.keys(overrides2).filter((key) => !headers.some((h) => h === key || h.trim().toLowerCase() === key.trim().toLowerCase()));
11698
11910
  if (unknown2.length > 0) {
11699
11911
  throw usageError(`--map names column${unknown2.length === 1 ? "" : "s"} ${unknown2.map((k) => `"${k}"`).join(", ")} that the file does not have.`, {
11700
11912
  field: "map",
@@ -11707,7 +11919,7 @@ function buildMapping(headers, overrides, mode) {
11707
11919
  result.dropped[header] = reason;
11708
11920
  };
11709
11921
  for (const header of headers) {
11710
- const override2 = overrideFor(header, overrides);
11922
+ const override2 = overrideFor(header, overrides2);
11711
11923
  let target2;
11712
11924
  if (override2.found) {
11713
11925
  if (override2.value === null) {
@@ -12195,20 +12407,20 @@ var init_import2 = __esm({
12195
12407
  }
12196
12408
  const campaignId = idFlag(flags, "campaign", COMMAND2);
12197
12409
  const file = requireFlag(flags, "file", COMMAND2, "Pass a CSV or JSONL file, or - for stdin. kenso contacts import --template shows the columns.");
12198
- const overrides = await readOverrides(ctx, flags, file);
12410
+ const overrides2 = await readOverrides(ctx, flags, file);
12199
12411
  const dryRun2 = isDryRun(ctx);
12200
12412
  const applyCommand = sameCommand2(COMMAND2, flags, ctx, ["--yes"]);
12201
12413
  if (flags["server-import"] === true) {
12202
12414
  let mapping2;
12203
- if (overrides) {
12415
+ if (overrides2) {
12204
12416
  const head = await readInput(file, { stdin: ctx.stdin });
12205
- mapping2 = buildMapping(head.headers, overrides, "import");
12417
+ mapping2 = buildMapping(head.headers, overrides2, "import");
12206
12418
  warnDropped(ctx, { ...mapping2, dropped: notUploaded(mapping2) });
12207
12419
  }
12208
12420
  return serverImport(ctx, { campaignId, file, mapping: mapping2, timeout: stringFlag2(flags, "timeout"), dryRun: dryRun2, applyCommand });
12209
12421
  }
12210
12422
  const input = await readInput(file, { stdin: ctx.stdin });
12211
- const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows), overrides ?? {}, "import");
12423
+ const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows), overrides2 ?? {}, "import");
12212
12424
  warnDropped(ctx, mapping);
12213
12425
  const { linkedInOnly } = await readCampaign(ctx, campaignId);
12214
12426
  if (input.rows.length > 0 && !mapping.fields.has("email") && !(linkedInOnly !== false && mapping.fields.has("linkedInUrl"))) {
@@ -12404,9 +12616,9 @@ var init_update = __esm({
12404
12616
  const campaignId = match === "email" ? idFlag(flags, "campaign", `${COMMAND3} --match email`) : void 0;
12405
12617
  const map = stringFlag2(flags, "map");
12406
12618
  if (map === "-" && file === "-") throw usageError("--map and --file cannot both read stdin.", { field: "map" });
12407
- const overrides = map === void 0 ? {} : parseMapOverrides(await readDataArg(map, ctx.stdin));
12619
+ const overrides2 = map === void 0 ? {} : parseMapOverrides(await readDataArg(map, ctx.stdin));
12408
12620
  const input = await readInput(file, { stdin: ctx.stdin });
12409
- const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows), overrides, "update");
12621
+ const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows), overrides2, "update");
12410
12622
  warnDropped(ctx, mapping);
12411
12623
  const key = match === "id" ? "id" : "email";
12412
12624
  if (input.rows.length > 0 && !mapping.fields.has(key)) {
@@ -12453,25 +12665,25 @@ var init_update = __esm({
12453
12665
  // src/commands/contacts/bulk-store.ts
12454
12666
  import { existsSync as existsSync6 } from "node:fs";
12455
12667
  import { appendFile as appendFile2, readFile as readFile7, writeFile as writeFile3 } from "node:fs/promises";
12456
- import { join as join13 } from "node:path";
12668
+ import { join as join14 } from "node:path";
12457
12669
  function whereDir(env) {
12458
- return join13(runsRoot(env), WHERE_DIR);
12670
+ return join14(runsRoot(env), WHERE_DIR);
12459
12671
  }
12460
- async function unfinishedWhereIds(ctx, command70, args) {
12461
- const dir2 = whereDir(ctx.env);
12672
+ async function unfinishedWhereIds(ctx, command71, args) {
12673
+ const dir3 = whereDir(ctx.env);
12462
12674
  const identity = argsIdentity(args);
12463
12675
  const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
12464
12676
  for (const run of await listRuns(ctx.env)) {
12465
- if (run.command !== command70 || run.status === "done" || run.status === "planned") continue;
12677
+ if (run.command !== command71 || run.status === "done" || run.status === "planned") continue;
12466
12678
  if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
12467
- if (run.inputPath?.startsWith(`${dir2}/`) && existsSync6(run.inputPath)) return run.inputPath;
12679
+ if (run.inputPath?.startsWith(`${dir3}/`) && existsSync6(run.inputPath)) return run.inputPath;
12468
12680
  }
12469
12681
  return void 0;
12470
12682
  }
12471
12683
  async function saveWhereIds(ctx, kind, ids2) {
12472
- const dir2 = whereDir(ctx.env);
12473
- ensurePrivateDir2(dir2);
12474
- const path = join13(dir2, `${kind}-${Date.now()}-${newRunId().slice(2)}.txt`);
12684
+ const dir3 = whereDir(ctx.env);
12685
+ ensurePrivateDir2(dir3);
12686
+ const path = join14(dir3, `${kind}-${Date.now()}-${newRunId().slice(2)}.txt`);
12475
12687
  await writeFile3(path, ids2.map((id) => `${id}
12476
12688
  `).join(""), { mode: 384 });
12477
12689
  return path;
@@ -12480,7 +12692,7 @@ function chunkAttempts(env) {
12480
12692
  let earlier;
12481
12693
  return async (runId, chunkIndex) => {
12482
12694
  earlier ??= (async () => {
12483
- const path2 = join13(runsRoot(env), runId, ATTEMPTS_FILE);
12695
+ const path2 = join14(runsRoot(env), runId, ATTEMPTS_FILE);
12484
12696
  const text4 = await readFile7(path2, "utf8").catch(() => "");
12485
12697
  const indexes3 = new Set(
12486
12698
  text4.split("\n").filter((line) => line.trim() !== "").map(Number)
@@ -12608,14 +12820,14 @@ async function idsFromRun(ctx, runId) {
12608
12820
  return { ...idItems(ids2), source: "run" };
12609
12821
  }
12610
12822
  async function collectIds(ctx, flags, kind, dryRun2) {
12611
- const command70 = `kenso contacts ${kind}`;
12823
+ const command71 = `kenso contacts ${kind}`;
12612
12824
  const ids2 = stringFlag2(flags, "ids");
12613
12825
  const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
12614
12826
  const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
12615
12827
  const given = [ids2, where, run].filter((v) => v !== void 0).length;
12616
12828
  if (given !== 1) {
12617
12829
  const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
12618
- throw usageError(`${command70} needs exactly one of ${choices}.`, { field: "ids", next: `${command70} --help` });
12830
+ throw usageError(`${command71} needs exactly one of ${choices}.`, { field: "ids", next: `${command71} --help` });
12619
12831
  }
12620
12832
  if (ids2 !== void 0) return idsFromFile(ctx, ids2);
12621
12833
  if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
@@ -13122,10 +13334,10 @@ var describe_exports = {};
13122
13334
  __export(describe_exports, {
13123
13335
  default: () => describe_default
13124
13336
  });
13125
- import { Writable as Writable2 } from "node:stream";
13337
+ import { Writable as Writable3 } from "node:stream";
13126
13338
  function printJson(ctx, value) {
13127
13339
  const chunks = [];
13128
- const collect = new Writable2({
13340
+ const collect = new Writable3({
13129
13341
  write(chunk, _encoding, callback) {
13130
13342
  chunks.push(chunk.toString());
13131
13343
  callback();
@@ -13180,12 +13392,18 @@ function flagsOf(entry) {
13180
13392
  ...flag.multiple ? { multiple: true } : {}
13181
13393
  }));
13182
13394
  }
13395
+ function effectOf(entry) {
13396
+ return (entry.op ? entry.op.effect : entry.spec?.effect) ?? "write";
13397
+ }
13398
+ function creditLines(entry) {
13399
+ return entry.op?.credits ?? entry.spec?.cost ?? [];
13400
+ }
13183
13401
  function summaryOf(entry, withFlags) {
13184
- const out = { command: entry.command, summary: entry.summary, beta: entry.gates !== void 0, handWritten: entry.spec !== void 0 };
13402
+ const out = { command: entry.command, summary: entry.summary, effect: effectOf(entry), beta: entry.gates !== void 0, handWritten: entry.spec !== void 0 };
13185
13403
  if (withFlags) out.flags = flagsOf(entry);
13186
13404
  return out;
13187
13405
  }
13188
- function detailOf(entry) {
13406
+ function detailOf(entry, cards) {
13189
13407
  const spec = entry.spec;
13190
13408
  const ids2 = entry.op ? [entry.op.id] : spec?.operationIds ?? [];
13191
13409
  const op = entry.op ?? (ids2.length === 1 ? findOperationById(ids2[0]) : void 0);
@@ -13193,6 +13411,7 @@ function detailOf(entry) {
13193
13411
  const out = {
13194
13412
  command: entry.command,
13195
13413
  summary: entry.summary,
13414
+ effect: effectOf(entry),
13196
13415
  description: entry.op ? entry.op.description ?? null : spec?.description ?? null,
13197
13416
  method: op?.method ?? null,
13198
13417
  path: op?.path ?? null,
@@ -13214,12 +13433,16 @@ function detailOf(entry) {
13214
13433
  };
13215
13434
  if (entry.gates) out.featureGates = entry.gates;
13216
13435
  if (entry.op?.download) out.download = entry.op.download;
13436
+ if (cards) {
13437
+ const lines = creditLines(entry);
13438
+ out.cost = lines.length > 0 ? { lines: lines.map((line) => ({ ...line, price: priceLine(line, cards) })), rateCard: { source: cards[0]?.source ?? "bundled", versions: cards.map((card) => card.version) } } : effectOf(entry) === "spend" ? { lines: [], rateCard: null } : null;
13439
+ }
13217
13440
  return out;
13218
13441
  }
13219
- function unknown(words) {
13442
+ function unknown(words2) {
13220
13443
  return new KensoError({
13221
13444
  code: "unknown_command",
13222
- message: `Unknown command "kenso ${words.join(" ")}".`,
13445
+ message: `Unknown command "kenso ${words2.join(" ")}".`,
13223
13446
  exitCode: ExitCode.Usage,
13224
13447
  hint: "Run kenso describe to list the commands.",
13225
13448
  next: "kenso describe"
@@ -13233,6 +13456,7 @@ var init_describe = __esm({
13233
13456
  init_exit_codes();
13234
13457
  init_features();
13235
13458
  init_output();
13459
+ init_rate_card();
13236
13460
  init_version();
13237
13461
  init_execute();
13238
13462
  init_manifest();
@@ -13244,7 +13468,7 @@ var init_describe = __esm({
13244
13468
  summary: "The command map as JSON: commands, flags, body schemas",
13245
13469
  brief: "",
13246
13470
  effect: "read",
13247
- description: "Always JSON. No arguments: every command with its summary. A resource: its commands with their flags. A resource and an action: one command in full (method, path, flags, body schema, examples). Beta commands your workspace has not enabled are left out unless --all-commands; calling one still works.",
13471
+ description: "Always JSON. No arguments: every command with its summary. A resource: its commands with their flags. A resource and an action: one command in full (method, path, flags, body schema, examples). Beta commands your workspace has not enabled are left out unless --all-commands; calling one still works. Every command has an effect (read, write, spend, send or destructive), and one command in full has its cost in credits on your rate card.",
13248
13472
  flags: {
13249
13473
  // Used by scripts/build-reference.ts to write docs/reference.md in one call.
13250
13474
  full: { type: "boolean", description: "Every listed command in full (method, path, flags, body schema, examples), for the docs build" }
@@ -13254,6 +13478,7 @@ var init_describe = __esm({
13254
13478
  { name: "action", description: "One command in full" }
13255
13479
  ],
13256
13480
  examples: ["kenso describe", "kenso describe contacts", "kenso describe contacts bulk-update", "kenso describe --all-commands"],
13481
+ operationIds: ["me.get", "credit-rate-card.get"],
13257
13482
  async run(ctx, { flags, positionals }) {
13258
13483
  const [resourceArg, action] = positionals;
13259
13484
  const resource = resourceArg === void 0 ? void 0 : resourceAliases[resourceArg] ?? resourceArg;
@@ -13262,7 +13487,8 @@ var init_describe = __esm({
13262
13487
  if (resource !== void 0 && action !== void 0) {
13263
13488
  const entry = all.find((e) => e.resource === resource && e.action === action);
13264
13489
  if (!entry) throw unknown([resourceArg, action]);
13265
- printJson(ctx, detailOf(entry));
13490
+ const cards = creditLines(entry).length > 0 ? await loadRateCards(ctx, { timeoutMs: HELP_RATE_CARD_TIMEOUT_MS }) : [];
13491
+ printJson(ctx, detailOf(entry, cards));
13266
13492
  return ExitCode.Ok;
13267
13493
  }
13268
13494
  const scoped = resource === void 0 ? all : all.filter((e) => e.resource === resource);
@@ -13295,12 +13521,299 @@ var init_describe2 = __esm({
13295
13521
  }
13296
13522
  });
13297
13523
 
13524
+ // scripts/discover-synonyms.ts
13525
+ function stem(word) {
13526
+ if (word.length > 4 && word.endsWith("ies")) return `${word.slice(0, -3)}y`;
13527
+ if (word.length > 3 && word.endsWith("s") && !word.endsWith("ss")) return word.slice(0, -1);
13528
+ return word;
13529
+ }
13530
+ function words(text4) {
13531
+ return text4.replace(/linkedin/gi, "linkedin").replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter((word) => word.length > 1 && !STOP_WORDS.has(word)).map(stem);
13532
+ }
13533
+ function termsOf(...texts) {
13534
+ const out = /* @__PURE__ */ new Set();
13535
+ for (const text4 of texts) {
13536
+ for (const word of words(text4 ?? "")) {
13537
+ out.add(word);
13538
+ for (const other of FOLDED.get(word) ?? []) out.add(other);
13539
+ }
13540
+ }
13541
+ return [...out];
13542
+ }
13543
+ var SYNONYMS, STOP_WORDS, FOLDED;
13544
+ var init_discover_synonyms = __esm({
13545
+ "scripts/discover-synonyms.ts"() {
13546
+ "use strict";
13547
+ SYNONYMS = [
13548
+ ["lead", "contact"],
13549
+ ["prospect", "contact"],
13550
+ ["company", "account"],
13551
+ ["organization", "account"],
13552
+ ["people", "person"],
13553
+ ["delete", "remove"],
13554
+ ["email", "mail"],
13555
+ ["inbox", "mailbox"],
13556
+ ["sequence", "cadence"],
13557
+ ["step", "node"],
13558
+ ["log", "trace"],
13559
+ ["run", "execution"],
13560
+ ["pause", "stop"],
13561
+ ["resume", "unpause"],
13562
+ ["launch", "start"],
13563
+ ["reply", "response"],
13564
+ ["reply", "answer"],
13565
+ ["find", "search"],
13566
+ ["search", "lookup"],
13567
+ ["enrich", "enrichment"],
13568
+ ["verify", "validate"],
13569
+ ["check", "validate"],
13570
+ ["export", "download"],
13571
+ ["import", "upload"],
13572
+ ["csv", "file"],
13573
+ ["credit", "cost"],
13574
+ ["price", "cost"],
13575
+ ["spend", "charge"],
13576
+ ["balance", "credit"],
13577
+ ["domain", "website"],
13578
+ ["website", "site"],
13579
+ ["url", "link"],
13580
+ ["job", "hiring"],
13581
+ ["funding", "raise"],
13582
+ ["signal", "trigger"],
13583
+ ["workflow", "automation"],
13584
+ ["tag", "label"],
13585
+ ["segment", "audience"],
13586
+ ["meeting", "call"],
13587
+ ["deal", "opportunity"],
13588
+ ["phone", "mobile"],
13589
+ ["key", "token"],
13590
+ ["login", "auth"],
13591
+ ["workspace", "client"],
13592
+ ["schedule", "cron"],
13593
+ ["bounce", "deliverability"]
13594
+ ];
13595
+ STOP_WORDS = /* @__PURE__ */ new Set([
13596
+ "a",
13597
+ "an",
13598
+ "the",
13599
+ "of",
13600
+ "to",
13601
+ "for",
13602
+ "in",
13603
+ "on",
13604
+ "and",
13605
+ "or",
13606
+ "with",
13607
+ "by",
13608
+ "from",
13609
+ "my",
13610
+ "me",
13611
+ "our",
13612
+ "your",
13613
+ "their",
13614
+ "its",
13615
+ "is",
13616
+ "are",
13617
+ "be",
13618
+ "it",
13619
+ "as",
13620
+ "at",
13621
+ "this",
13622
+ "that",
13623
+ "these",
13624
+ "those",
13625
+ "each",
13626
+ "every",
13627
+ "all",
13628
+ "any",
13629
+ "into",
13630
+ "how",
13631
+ "what",
13632
+ "which",
13633
+ "who",
13634
+ "do",
13635
+ "can",
13636
+ "we",
13637
+ "you"
13638
+ ]);
13639
+ FOLDED = /* @__PURE__ */ new Map();
13640
+ for (const [a, b] of SYNONYMS) {
13641
+ const [x, y] = [stem(a), stem(b)];
13642
+ FOLDED.set(x, [...FOLDED.get(x) ?? [], y]);
13643
+ FOLDED.set(y, [...FOLDED.get(y) ?? [], x]);
13644
+ }
13645
+ }
13646
+ });
13647
+
13648
+ // src/commands/discover/discover.ts
13649
+ var discover_exports = {};
13650
+ __export(discover_exports, {
13651
+ default: () => discover_default
13652
+ });
13653
+ function candidate(entry, costNote) {
13654
+ return { entry, strong: new Set(termsOf(entry.id, entry.summary)), terms: new Set(entry.terms), costNote };
13655
+ }
13656
+ function specEntry(spec) {
13657
+ if (spec.brief?.startsWith("same as ")) return void 0;
13658
+ const id = commandName(spec).slice("kenso ".length);
13659
+ const credits2 = spec.cost ?? [];
13660
+ const actions39 = credits2.map((c) => c.action);
13661
+ return {
13662
+ kind: "command",
13663
+ id,
13664
+ summary: spec.summary,
13665
+ terms: termsOf(id, spec.summary, spec.description, spec.doc?.when, Object.keys(spec.flags).join(" "), actions39.join(" ")),
13666
+ effect: spec.effect,
13667
+ ...credits2.length > 0 ? { costActions: actions39, credits: credits2 } : {},
13668
+ ...spec.beta ? { beta: true } : {},
13669
+ describe: `kenso describe ${id}`
13670
+ };
13671
+ }
13672
+ function handWrittenTakes(id) {
13673
+ const [resource = "", action = ""] = id.split(" ");
13674
+ const area = handWritten[resource];
13675
+ return area !== void 0 && (area[action] !== void 0 || area[""] !== void 0);
13676
+ }
13677
+ function skillFallback(entry) {
13678
+ return entry.bundled ? "kenso docs agents" : `kenso mcp call load_skill --args '{"name":"${entry.id}"}'`;
13679
+ }
13680
+ async function candidates() {
13681
+ const out = [];
13682
+ for (const area of Object.values(handWritten)) {
13683
+ for (const load2 of Object.values(area)) {
13684
+ const spec = await load2();
13685
+ const entry = specEntry(spec);
13686
+ if (entry) out.push(candidate(entry, spec.cost ? void 0 : spec.doc?.cost));
13687
+ }
13688
+ }
13689
+ const hasSkillShow = handWritten.skill?.show !== void 0;
13690
+ for (const entry of readDataFile(INDEX_FILE2)?.entries ?? []) {
13691
+ if (entry.kind === "command" && handWrittenTakes(entry.id)) continue;
13692
+ out.push(candidate(entry.kind === "skill" && !hasSkillShow ? { ...entry, describe: skillFallback(entry) } : entry));
13693
+ }
13694
+ for (const topic of TOPICS) {
13695
+ const summary = `${topic.title} - ${topic.description}`;
13696
+ out.push(candidate({ kind: "doc", id: topic.topic, summary, terms: termsOf(topic.topic, summary), describe: `kenso docs ${topic.topic}` }));
13697
+ }
13698
+ return out;
13699
+ }
13700
+ function score(c, tokens) {
13701
+ let points = 0;
13702
+ let matched = 0;
13703
+ for (const token of new Set(tokens)) {
13704
+ const weight = c.strong.has(token) ? 2 : c.terms.has(token) ? 1 : 0;
13705
+ points += weight;
13706
+ if (weight > 0) matched++;
13707
+ }
13708
+ return { points, matched };
13709
+ }
13710
+ function rank(all, query, kind) {
13711
+ const arrow = query.indexOf("->");
13712
+ const have = words(arrow < 0 ? query : query.slice(0, arrow));
13713
+ const need = arrow < 0 ? [] : words(query.slice(arrow + 2));
13714
+ const out = [];
13715
+ for (const c of all) {
13716
+ if (kind !== void 0 && c.entry.kind !== kind) continue;
13717
+ const a = score(c, have);
13718
+ const b = score(c, need);
13719
+ if (a.points + b.points === 0) continue;
13720
+ out.push({ candidate: c, both: arrow < 0 || a.points > 0 && b.points > 0, matched: a.matched + b.matched, points: a.points + b.points });
13721
+ }
13722
+ return out.sort(
13723
+ (x, y) => Number(y.both) - Number(x.both) || y.matched - x.matched || y.points - x.points || x.candidate.terms.size - y.candidate.terms.size || x.candidate.entry.id.localeCompare(y.candidate.entry.id)
13724
+ );
13725
+ }
13726
+ function parseKind(value) {
13727
+ if (value === void 0) return void 0;
13728
+ if (!KINDS2.includes(value)) {
13729
+ throw usageError(`--kind must be one of ${KINDS2.join(", ")}.`, { field: "kind", next: "kenso discover --help" });
13730
+ }
13731
+ return value;
13732
+ }
13733
+ function parseLimit(value) {
13734
+ if (value === void 0) return DEFAULT_LIMIT;
13735
+ if (!/^\d+$/.test(value) || Number(value) < 1) {
13736
+ throw usageError("--limit must be a whole number of 1 or more.", { field: "limit", next: "kenso discover --help" });
13737
+ }
13738
+ return Number(value);
13739
+ }
13740
+ var INDEX_FILE2, KINDS2, DEFAULT_LIMIT, MAX_LIMIT, command25, discover_default;
13741
+ var init_discover = __esm({
13742
+ "src/commands/discover/discover.ts"() {
13743
+ "use strict";
13744
+ init_discover_synonyms();
13745
+ init_errors();
13746
+ init_exit_codes();
13747
+ init_rate_card();
13748
+ init_data();
13749
+ init_content();
13750
+ init_help();
13751
+ init_registry();
13752
+ INDEX_FILE2 = "discover.json";
13753
+ KINDS2 = ["command", "step", "doc", "skill"];
13754
+ DEFAULT_LIMIT = 5;
13755
+ MAX_LIMIT = 10;
13756
+ command25 = {
13757
+ resource: "discover",
13758
+ action: "",
13759
+ summary: "Find the command, docs topic, skill or workflow step for a request, offline",
13760
+ description: `Each argument is one request in plain words, or "<have> -> <need>" (hits that match both sides rank first). Searches this CLI's commands, its docs topics, the Kenso skills and the workflow step and trigger types, with no sign-in and no network. Prints one object per request (NDJSON when piped, one row per hit at a terminal): its hits, each with kind, id, summary, effect, cost (in credits, from the cached or bundled rate card) and describe, the command that tells you more.`,
13761
+ flags: {
13762
+ kind: { type: "string", description: "Only hits of one kind: command, step, doc or skill" },
13763
+ limit: { type: "string", description: "Hits per request, 1 to 10 (5 when not given)" }
13764
+ },
13765
+ positionals: [{ name: "query", required: true, variadic: true, description: 'A request in plain words, or "<have> -> <need>"' }],
13766
+ examples: ['kenso discover "linkedin url -> email"', 'kenso discover "pause a campaign" "run logs"', 'kenso discover "qualify accounts" --kind step'],
13767
+ effect: "read",
13768
+ doc: {
13769
+ when: "You know what you want done but not which command, docs topic, skill or workflow step does it.",
13770
+ next: "Run the hit's describe command, then the command itself, with --dry-run when it changes anything."
13771
+ },
13772
+ async run(ctx, { flags, positionals }) {
13773
+ const kind = parseKind(typeof flags.kind === "string" ? flags.kind : void 0);
13774
+ const asked = parseLimit(typeof flags.limit === "string" ? flags.limit : void 0);
13775
+ const limit = Math.min(asked, MAX_LIMIT);
13776
+ if (asked > MAX_LIMIT) ctx.output.info(`--limit is capped at ${MAX_LIMIT} (asked for ${asked}).`);
13777
+ const all = await candidates();
13778
+ const ranked = positionals.map((query) => ({ query, list: rank(all, query, kind) }));
13779
+ const priced = ranked.some((r) => r.list.slice(0, limit).some((x) => (x.candidate.entry.credits?.length ?? 0) > 0));
13780
+ const cards = priced ? await loadRateCards(ctx, { live: false }) : [];
13781
+ const results = ranked.map(({ query, list: list2 }) => ({
13782
+ query,
13783
+ hits: list2.slice(0, limit).map(({ candidate: c }) => ({
13784
+ kind: c.entry.kind,
13785
+ id: c.entry.id,
13786
+ summary: c.entry.summary,
13787
+ effect: c.entry.effect ?? null,
13788
+ cost: c.entry.credits?.length ? c.entry.credits.map((line) => priceLine(line, cards)).join("; ") : c.costNote ?? null,
13789
+ describe: c.entry.describe
13790
+ })),
13791
+ more: Math.max(0, list2.length - limit)
13792
+ }));
13793
+ if (ctx.output.stdoutIsTTY && ctx.flags.output === void 0 && ctx.flags.query === void 0) {
13794
+ const rows = results.flatMap((r) => r.hits.map((h) => ({ query: r.query, kind: h.kind, id: h.id, effect: h.effect, cost: h.cost, describe: h.describe })));
13795
+ if (rows.length > 0) await ctx.output.list(rows);
13796
+ } else if (results.length === 1) {
13797
+ ctx.output.object(results[0]);
13798
+ } else {
13799
+ await ctx.output.list(results);
13800
+ }
13801
+ if (results.some((r) => r.hits.length === 0)) ctx.output.info("No match. Try other words, or kenso describe for the full command map.");
13802
+ return ExitCode.Ok;
13803
+ }
13804
+ };
13805
+ discover_default = command25;
13806
+ }
13807
+ });
13808
+
13298
13809
  // src/commands/discover/index.ts
13299
13810
  var actions12;
13300
- var init_discover = __esm({
13811
+ var init_discover2 = __esm({
13301
13812
  "src/commands/discover/index.ts"() {
13302
13813
  "use strict";
13303
- actions12 = {};
13814
+ actions12 = {
13815
+ "": () => Promise.resolve().then(() => (init_discover(), discover_exports)).then((m) => m.default)
13816
+ };
13304
13817
  }
13305
13818
  });
13306
13819
 
@@ -13313,7 +13826,7 @@ function findTopic(input) {
13313
13826
  const name = input.trim().toLowerCase().replace(/\.md$/, "");
13314
13827
  return TOPICS.find((t) => t.topic === name);
13315
13828
  }
13316
- var NAMES, command25, docs_default;
13829
+ var NAMES, command26, docs_default;
13317
13830
  var init_docs = __esm({
13318
13831
  "src/commands/docs/docs.ts"() {
13319
13832
  "use strict";
@@ -13321,7 +13834,7 @@ var init_docs = __esm({
13321
13834
  init_exit_codes();
13322
13835
  init_content();
13323
13836
  NAMES = TOPICS.map((t) => t.topic).join(", ");
13324
- command25 = {
13837
+ command26 = {
13325
13838
  resource: "docs",
13326
13839
  action: "",
13327
13840
  summary: "Offline docs: the topic list, or one topic",
@@ -13363,7 +13876,7 @@ var init_docs = __esm({
13363
13876
  return ExitCode.Ok;
13364
13877
  }
13365
13878
  };
13366
- docs_default = command25;
13879
+ docs_default = command26;
13367
13880
  }
13368
13881
  });
13369
13882
 
@@ -13401,7 +13914,7 @@ function configCheck(env) {
13401
13914
  const octal = mode.toString(8).padStart(4, "0");
13402
13915
  return mode === 384 ? { name: "config_permissions", ok: true, detail: `${file} is ${octal}` } : { name: "config_permissions", ok: false, detail: `${file} is ${octal}: run chmod 600 ${file}` };
13403
13916
  }
13404
- var MIN_NODE_MAJOR, command26, actions14;
13917
+ var MIN_NODE_MAJOR, command27, actions14;
13405
13918
  var init_doctor = __esm({
13406
13919
  "src/commands/doctor/index.ts"() {
13407
13920
  "use strict";
@@ -13410,7 +13923,7 @@ var init_doctor = __esm({
13410
13923
  init_exit_codes();
13411
13924
  init_http();
13412
13925
  MIN_NODE_MAJOR = 22;
13413
- command26 = {
13926
+ command27 = {
13414
13927
  resource: "doctor",
13415
13928
  action: "",
13416
13929
  summary: "Check Node, the config, the API and the key",
@@ -13476,7 +13989,7 @@ var init_doctor = __esm({
13476
13989
  }
13477
13990
  };
13478
13991
  actions14 = {
13479
- "": async () => command26
13992
+ "": async () => command27
13480
13993
  };
13481
13994
  }
13482
13995
  });
@@ -13557,7 +14070,7 @@ async function viewBody(ctx, id, object) {
13557
14070
  if (typeof view.sort === "string" && view.sort.trim() !== "") body2.sort = view.sort;
13558
14071
  return body2;
13559
14072
  }
13560
- var OBJECTS, VIEW_EXPORTS, command27, export_default2;
14073
+ var OBJECTS, VIEW_EXPORTS, command28, export_default2;
13561
14074
  var init_export2 = __esm({
13562
14075
  "src/commands/export/export.ts"() {
13563
14076
  "use strict";
@@ -13573,7 +14086,7 @@ var init_export2 = __esm({
13573
14086
  opportunities: { resource: "opportunities", noun: "deals", viewObject: "opportunity" }
13574
14087
  };
13575
14088
  VIEW_EXPORTS = { account: "accounts", person: "people", opportunity: "deals" };
13576
- command27 = {
14089
+ command28 = {
13577
14090
  resource: "export",
13578
14091
  action: "",
13579
14092
  summary: "Export accounts, people or deals as CSV: everything, a saved view, or what the filters match",
@@ -13649,7 +14162,7 @@ var init_export2 = __esm({
13649
14162
  return ExitCode.Ok;
13650
14163
  }
13651
14164
  };
13652
- export_default2 = command27;
14165
+ export_default2 = command28;
13653
14166
  }
13654
14167
  });
13655
14168
 
@@ -13753,7 +14266,7 @@ async function waitUntilFinished(ctx, id, timeoutMs2) {
13753
14266
  await delay8(POLL_MS2, void 0, { signal: ctx.signal });
13754
14267
  }
13755
14268
  }
13756
- var OBJECTS2, DEFAULT_TIMEOUT3, POLL_MS2, FINISHED, command28, import_default3;
14269
+ var OBJECTS2, DEFAULT_TIMEOUT3, POLL_MS2, FINISHED, command29, import_default3;
13757
14270
  var init_import3 = __esm({
13758
14271
  "src/commands/import/import.ts"() {
13759
14272
  "use strict";
@@ -13766,7 +14279,7 @@ var init_import3 = __esm({
13766
14279
  DEFAULT_TIMEOUT3 = "30m";
13767
14280
  POLL_MS2 = 2e3;
13768
14281
  FINISHED = /* @__PURE__ */ new Set(["done", "failed"]);
13769
- command28 = {
14282
+ command29 = {
13770
14283
  resource: "import",
13771
14284
  action: "",
13772
14285
  summary: "Import accounts, people or deals from a CSV file: Kenso proposes the mapping, you approve, it runs in the background",
@@ -13873,7 +14386,7 @@ var init_import3 = __esm({
13873
14386
  return finished.status === "done" ? ExitCode.Ok : ExitCode.Error;
13874
14387
  }
13875
14388
  };
13876
- import_default3 = command28;
14389
+ import_default3 = command29;
13877
14390
  }
13878
14391
  });
13879
14392
 
@@ -14082,7 +14595,7 @@ function readable(row) {
14082
14595
  const parts2 = [time, `[${row.status}]`, row.method, row.pathTemplate, row.errorCode, `${row.durationMs}ms`, row.apiKeyId, row.requestId];
14083
14596
  return parts2.filter((p) => p !== void 0 && p !== "").join(" ");
14084
14597
  }
14085
- var MIN_INTERVAL_MS, MAX_INTERVAL_MS, MAX_SINCE_MS, OVERLAP_MS, MAX_PAGES, RATE_LIMITED_WAIT_MS, isOwnPoll, pad, command29, tail_default;
14598
+ var MIN_INTERVAL_MS, MAX_INTERVAL_MS, MAX_SINCE_MS, OVERLAP_MS, MAX_PAGES, RATE_LIMITED_WAIT_MS, isOwnPoll, pad, command30, tail_default;
14086
14599
  var init_tail = __esm({
14087
14600
  "src/commands/logs/tail.ts"() {
14088
14601
  "use strict";
@@ -14098,7 +14611,7 @@ var init_tail = __esm({
14098
14611
  RATE_LIMITED_WAIT_MS = 3e4;
14099
14612
  isOwnPoll = (row) => row.method === "GET" && row.pathTemplate === "/v1/api-requests" && row.userAgent?.startsWith("kenso-cli/") === true;
14100
14613
  pad = (n) => String(n).padStart(2, "0");
14101
- command29 = {
14614
+ command30 = {
14102
14615
  resource: "logs",
14103
14616
  action: "tail",
14104
14617
  summary: "Stream your workspace's new API request log rows",
@@ -14205,7 +14718,7 @@ var init_tail = __esm({
14205
14718
  return ExitCode.Ok;
14206
14719
  }
14207
14720
  };
14208
- tail_default = command29;
14721
+ tail_default = command30;
14209
14722
  }
14210
14723
  });
14211
14724
 
@@ -14270,7 +14783,7 @@ function isRecord9(value) {
14270
14783
  function textOf(result) {
14271
14784
  return (result.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
14272
14785
  }
14273
- var command30, call_default;
14786
+ var command31, call_default;
14274
14787
  var init_call = __esm({
14275
14788
  "src/commands/mcp/call.ts"() {
14276
14789
  "use strict";
@@ -14278,12 +14791,14 @@ var init_call = __esm({
14278
14791
  init_exit_codes();
14279
14792
  init_input();
14280
14793
  init_connect4();
14281
- command30 = {
14794
+ command31 = {
14282
14795
  resource: "mcp",
14283
14796
  action: "call",
14284
14797
  summary: "Call a hosted Kenso MCP tool, such as list_skills",
14285
14798
  brief: "list_skills runs directly",
14286
14799
  effect: "destructive",
14800
+ // The two skill tools only read; any other tool can do whatever the API can.
14801
+ effectFor: ({ positionals }) => positionals[0] === "list_skills" || positionals[0] === "load_skill" ? "read" : "destructive",
14287
14802
  description: "Calls one Kenso MCP tool with the same API key and prints its result: structuredContent when the tool returns it, else its text parsed as JSON, else the text. Covers MCP-only tools, such as the skills: list_skills and load_skill take no kenso mcp tools first. A tool error exits 1 with the tool's message. A facade tool takes its operation with --operation. --dry-run prints the tools/call request (tool and arguments) and sends nothing.",
14288
14803
  flags: {
14289
14804
  operation: { type: "string", description: "The facade operation, for example list" },
@@ -14332,7 +14847,7 @@ var init_call = __esm({
14332
14847
  return ExitCode.Ok;
14333
14848
  }
14334
14849
  };
14335
- call_default = command30;
14850
+ call_default = command31;
14336
14851
  }
14337
14852
  });
14338
14853
 
@@ -14341,13 +14856,13 @@ var tools_exports = {};
14341
14856
  __export(tools_exports, {
14342
14857
  default: () => tools_default
14343
14858
  });
14344
- var command31, tools_default;
14859
+ var command32, tools_default;
14345
14860
  var init_tools = __esm({
14346
14861
  "src/commands/mcp/tools.ts"() {
14347
14862
  "use strict";
14348
14863
  init_exit_codes();
14349
14864
  init_connect4();
14350
- command31 = {
14865
+ command32 = {
14351
14866
  resource: "mcp",
14352
14867
  action: "tools",
14353
14868
  summary: "List the hosted Kenso MCP's tools",
@@ -14363,7 +14878,7 @@ var init_tools = __esm({
14363
14878
  return ExitCode.Ok;
14364
14879
  }
14365
14880
  };
14366
- tools_default = command31;
14881
+ tools_default = command32;
14367
14882
  }
14368
14883
  });
14369
14884
 
@@ -14416,14 +14931,14 @@ var list_exports = {};
14416
14931
  __export(list_exports, {
14417
14932
  default: () => list_default
14418
14933
  });
14419
- var command32, list_default;
14934
+ var command33, list_default;
14420
14935
  var init_list = __esm({
14421
14936
  "src/commands/notes/list.ts"() {
14422
14937
  "use strict";
14423
14938
  init_errors();
14424
14939
  init_exit_codes();
14425
14940
  init_target();
14426
- command32 = {
14941
+ command33 = {
14427
14942
  resource: "notes",
14428
14943
  action: "list",
14429
14944
  summary: "List the notes on an account, a person or a deal, or every comment under one note",
@@ -14457,7 +14972,7 @@ var init_list = __esm({
14457
14972
  return ExitCode.Ok;
14458
14973
  }
14459
14974
  };
14460
- list_default = command32;
14975
+ list_default = command33;
14461
14976
  }
14462
14977
  });
14463
14978
 
@@ -14472,7 +14987,7 @@ async function bodyText(ctx, value, next) {
14472
14987
  if (text4.trim() === "") throw usageError("--body cannot be empty: the note's text, in markdown (--body - reads stdin).", { field: "body", next });
14473
14988
  return text4;
14474
14989
  }
14475
- var command33, add_default;
14990
+ var command34, add_default;
14476
14991
  var init_add = __esm({
14477
14992
  "src/commands/notes/add.ts"() {
14478
14993
  "use strict";
@@ -14482,7 +14997,7 @@ var init_add = __esm({
14482
14997
  init_http();
14483
14998
  init_input();
14484
14999
  init_target();
14485
- command33 = {
15000
+ command34 = {
14486
15001
  resource: "notes",
14487
15002
  action: "add",
14488
15003
  summary: "Write a note on an account, a person or a deal, or a comment under a note",
@@ -14516,7 +15031,7 @@ var init_add = __esm({
14516
15031
  return ExitCode.Ok;
14517
15032
  }
14518
15033
  };
14519
- add_default = command33;
15034
+ add_default = command34;
14520
15035
  }
14521
15036
  });
14522
15037
 
@@ -14525,7 +15040,7 @@ var edit_exports = {};
14525
15040
  __export(edit_exports, {
14526
15041
  default: () => edit_default
14527
15042
  });
14528
- var command34, edit_default;
15043
+ var command35, edit_default;
14529
15044
  var init_edit = __esm({
14530
15045
  "src/commands/notes/edit.ts"() {
14531
15046
  "use strict";
@@ -14535,7 +15050,7 @@ var init_edit = __esm({
14535
15050
  init_http();
14536
15051
  init_add();
14537
15052
  init_target();
14538
- command34 = {
15053
+ command35 = {
14539
15054
  resource: "notes",
14540
15055
  action: "edit",
14541
15056
  summary: "Change a note's text, or pin or unpin it",
@@ -14566,7 +15081,7 @@ var init_edit = __esm({
14566
15081
  return ExitCode.Ok;
14567
15082
  }
14568
15083
  };
14569
- edit_default = command34;
15084
+ edit_default = command35;
14570
15085
  }
14571
15086
  });
14572
15087
 
@@ -14575,7 +15090,7 @@ var delete_exports = {};
14575
15090
  __export(delete_exports, {
14576
15091
  default: () => delete_default
14577
15092
  });
14578
- var command35, delete_default;
15093
+ var command36, delete_default;
14579
15094
  var init_delete = __esm({
14580
15095
  "src/commands/notes/delete.ts"() {
14581
15096
  "use strict";
@@ -14583,7 +15098,7 @@ var init_delete = __esm({
14583
15098
  init_dry_run();
14584
15099
  init_exit_codes();
14585
15100
  init_target();
14586
- command35 = {
15101
+ command36 = {
14587
15102
  resource: "notes",
14588
15103
  action: "delete",
14589
15104
  summary: "Delete a note or a comment (its author or a workspace admin)",
@@ -14605,7 +15120,7 @@ var init_delete = __esm({
14605
15120
  return ExitCode.Ok;
14606
15121
  }
14607
15122
  };
14608
- delete_default = command35;
15123
+ delete_default = command36;
14609
15124
  }
14610
15125
  });
14611
15126
 
@@ -14641,7 +15156,7 @@ async function categoryOf(ctx, stage) {
14641
15156
  throw err;
14642
15157
  }
14643
15158
  }
14644
- var KEY, ID, command36, move_default;
15159
+ var KEY, ID, command37, move_default;
14645
15160
  var init_move = __esm({
14646
15161
  "src/commands/opportunities/move.ts"() {
14647
15162
  "use strict";
@@ -14651,7 +15166,7 @@ var init_move = __esm({
14651
15166
  init_http();
14652
15167
  KEY = /^[a-z][a-z0-9_]{0,62}$/;
14653
15168
  ID = /^[1-9]\d*$/;
14654
- command36 = {
15169
+ command37 = {
14655
15170
  resource: "opportunities",
14656
15171
  action: "move",
14657
15172
  summary: "Move a deal to a stage or another pipeline, with its won or lost reason",
@@ -14720,7 +15235,7 @@ var init_move = __esm({
14720
15235
  return ExitCode.Ok;
14721
15236
  }
14722
15237
  };
14723
- move_default = command36;
15238
+ move_default = command37;
14724
15239
  }
14725
15240
  });
14726
15241
 
@@ -14729,14 +15244,14 @@ var stage_history_exports = {};
14729
15244
  __export(stage_history_exports, {
14730
15245
  default: () => stage_history_default
14731
15246
  });
14732
- var command37, stage_history_default;
15247
+ var command38, stage_history_default;
14733
15248
  var init_stage_history = __esm({
14734
15249
  "src/commands/opportunities/stage-history.ts"() {
14735
15250
  "use strict";
14736
15251
  init_errors();
14737
15252
  init_exit_codes();
14738
15253
  init_http();
14739
- command37 = {
15254
+ command38 = {
14740
15255
  resource: "opportunities",
14741
15256
  action: "stage-history",
14742
15257
  summary: "Show a deal's stage history: each stage, when, who moved it and how long it sat there",
@@ -14761,7 +15276,7 @@ var init_stage_history = __esm({
14761
15276
  return ExitCode.Ok;
14762
15277
  }
14763
15278
  };
14764
- stage_history_default = command37;
15279
+ stage_history_default = command38;
14765
15280
  }
14766
15281
  });
14767
15282
 
@@ -14901,7 +15416,7 @@ function summarize3(results) {
14901
15416
  }
14902
15417
  return { matched, addedToAccounts, emailFindsQueued };
14903
15418
  }
14904
- var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command38, import_default4;
15419
+ var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command39, import_default4;
14905
15420
  var init_import5 = __esm({
14906
15421
  "src/commands/people/import.ts"() {
14907
15422
  "use strict";
@@ -14933,7 +15448,7 @@ var init_import5 = __esm({
14933
15448
  };
14934
15449
  PERSON_FIELDS = ["email", "fullName", "firstName", "lastName", "linkedinUrl", "title"];
14935
15450
  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.";
14936
- command38 = {
15451
+ command39 = {
14937
15452
  resource: "people",
14938
15453
  action: "import",
14939
15454
  summary: "Create or match people from a CSV or JSONL file, optionally onto accounts",
@@ -15000,7 +15515,7 @@ var init_import5 = __esm({
15000
15515
  return outcome.exitCode;
15001
15516
  }
15002
15517
  };
15003
- import_default4 = command38;
15518
+ import_default4 = command39;
15004
15519
  }
15005
15520
  });
15006
15521
 
@@ -15061,7 +15576,7 @@ var merge_exports2 = {};
15061
15576
  __export(merge_exports2, {
15062
15577
  default: () => merge_default2
15063
15578
  });
15064
- var command39, merge_default2;
15579
+ var command40, merge_default2;
15065
15580
  var init_merge2 = __esm({
15066
15581
  "src/commands/people/merge.ts"() {
15067
15582
  "use strict";
@@ -15070,7 +15585,7 @@ var init_merge2 = __esm({
15070
15585
  init_exit_codes();
15071
15586
  init_http();
15072
15587
  init_common();
15073
- command39 = {
15588
+ command40 = {
15074
15589
  resource: "people",
15075
15590
  action: "merge",
15076
15591
  summary: "Merge a person into the one you keep. --dry-run shows what would move and writes nothing",
@@ -15117,7 +15632,7 @@ var init_merge2 = __esm({
15117
15632
  return ExitCode.Ok;
15118
15633
  }
15119
15634
  };
15120
- merge_default2 = command39;
15635
+ merge_default2 = command40;
15121
15636
  }
15122
15637
  });
15123
15638
 
@@ -15155,7 +15670,7 @@ function rule(stage) {
15155
15670
  isDefault: stage.isDefaultRequiredFields
15156
15671
  };
15157
15672
  }
15158
- var ID2, command40, stage_rules_default;
15673
+ var ID2, command41, stage_rules_default;
15159
15674
  var init_stage_rules = __esm({
15160
15675
  "src/commands/pipelines/stage-rules.ts"() {
15161
15676
  "use strict";
@@ -15164,11 +15679,12 @@ var init_stage_rules = __esm({
15164
15679
  init_exit_codes();
15165
15680
  init_http();
15166
15681
  ID2 = /^[1-9]\d*$/;
15167
- command40 = {
15682
+ command41 = {
15168
15683
  resource: "pipelines",
15169
15684
  action: "stage-rules",
15170
15685
  summary: "List or set the fields a deal should have in each stage",
15171
15686
  effect: "write",
15687
+ effectFor: ({ positionals }) => positionals.length === 0 ? "read" : "write",
15172
15688
  description: "Without a stage, reads GET /v1/opportunity-stages (the default pipeline's stages; --pipeline <id> reads that pipeline's from GET /v1/pipelines/{pipelineId}) and prints each stage's key, label, category, isArchived, requiredFields and isDefault, plus requirableFields: every field a stage can require (amount, closeDate, ownerMemberId, primaryPersonId, nextStep, lostReasonKey, wonReasonKey, and custom.<key> for each custom deal field). With a stage and --require, --default or --none, sends PUT /v1/opportunity-stages/{stageKey}/required-fields and prints that stage's rule. --require is the stage's whole list, in order, at most 10. --default puts it back on the default: a lost stage asks for lostReasonKey, any other stage nothing. A missing field never stops a move: the deal moves, the move prints a warning, and the deal is flagged Missing until the field is filled. Setting a rule needs the workspace_settings permission. A stage key is unique across pipelines, so it sets a stage of any pipeline; with --pipeline it first checks the stage is that pipeline's. --dry-run prints the PUT and changes nothing.",
15173
15689
  flags: {
15174
15690
  require: { type: "string", description: "Comma-separated field ids the stage requires, in order (amount,closeDate,custom.tier)" },
@@ -15237,7 +15753,7 @@ var init_stage_rules = __esm({
15237
15753
  return ExitCode.Ok;
15238
15754
  }
15239
15755
  };
15240
- stage_rules_default = command40;
15756
+ stage_rules_default = command41;
15241
15757
  }
15242
15758
  });
15243
15759
 
@@ -15257,7 +15773,7 @@ var run_exports2 = {};
15257
15773
  __export(run_exports2, {
15258
15774
  default: () => run_default
15259
15775
  });
15260
- var REPORTS, command41, run_default;
15776
+ var REPORTS, command42, run_default;
15261
15777
  var init_run2 = __esm({
15262
15778
  "src/commands/reports/run.ts"() {
15263
15779
  "use strict";
@@ -15265,7 +15781,7 @@ var init_run2 = __esm({
15265
15781
  init_exit_codes();
15266
15782
  init_http();
15267
15783
  REPORTS = ["pipeline_by_stage", "won_by_month", "stage_conversion", "time_in_stage", "won_by_source_campaign", "activity_by_member"];
15268
- command41 = {
15784
+ command42 = {
15269
15785
  resource: "reports",
15270
15786
  action: "run",
15271
15787
  summary: "Run a stock pipeline report and print its table",
@@ -15337,7 +15853,7 @@ var init_run2 = __esm({
15337
15853
  return ExitCode.Ok;
15338
15854
  }
15339
15855
  };
15340
- run_default = command41;
15856
+ run_default = command42;
15341
15857
  }
15342
15858
  });
15343
15859
 
@@ -15346,14 +15862,14 @@ var summary_exports = {};
15346
15862
  __export(summary_exports, {
15347
15863
  default: () => summary_default
15348
15864
  });
15349
- var command42, summary_default;
15865
+ var command43, summary_default;
15350
15866
  var init_summary = __esm({
15351
15867
  "src/commands/reports/summary.ts"() {
15352
15868
  "use strict";
15353
15869
  init_errors();
15354
15870
  init_exit_codes();
15355
15871
  init_http();
15356
- command42 = {
15872
+ command43 = {
15357
15873
  resource: "reports",
15358
15874
  action: "summary",
15359
15875
  summary: "Read where the period stands and what needs you",
@@ -15415,7 +15931,7 @@ var init_summary = __esm({
15415
15931
  return ExitCode.Ok;
15416
15932
  }
15417
15933
  };
15418
- summary_default = command42;
15934
+ summary_default = command43;
15419
15935
  }
15420
15936
  });
15421
15937
 
@@ -15436,14 +15952,14 @@ var list_exports2 = {};
15436
15952
  __export(list_exports2, {
15437
15953
  default: () => list_default2
15438
15954
  });
15439
- var command43, list_default2;
15955
+ var command44, list_default2;
15440
15956
  var init_list2 = __esm({
15441
15957
  "src/commands/runs/list.ts"() {
15442
15958
  "use strict";
15443
15959
  init_runs();
15444
15960
  init_errors();
15445
15961
  init_exit_codes();
15446
- command43 = {
15962
+ command44 = {
15447
15963
  resource: "runs",
15448
15964
  action: "list",
15449
15965
  summary: "List batch runs, newest first (finds an interrupted run)",
@@ -15465,7 +15981,7 @@ var init_list2 = __esm({
15465
15981
  return ExitCode.Ok;
15466
15982
  }
15467
15983
  };
15468
- list_default2 = command43;
15984
+ list_default2 = command44;
15469
15985
  }
15470
15986
  });
15471
15987
 
@@ -15474,9 +15990,9 @@ var show_exports2 = {};
15474
15990
  __export(show_exports2, {
15475
15991
  default: () => show_default2
15476
15992
  });
15477
- import { existsSync as existsSync7, readFileSync as readFileSync9 } from "node:fs";
15478
- import { join as join14 } from "node:path";
15479
- var FILES, command44, show_default2;
15993
+ import { existsSync as existsSync7, readFileSync as readFileSync11 } from "node:fs";
15994
+ import { join as join15 } from "node:path";
15995
+ var FILES, command45, show_default2;
15480
15996
  var init_show2 = __esm({
15481
15997
  "src/commands/runs/show.ts"() {
15482
15998
  "use strict";
@@ -15491,7 +16007,7 @@ var init_show2 = __esm({
15491
16007
  ["plan", "plan.json"],
15492
16008
  ["summary", "summary.json"]
15493
16009
  ];
15494
- command44 = {
16010
+ command45 = {
15495
16011
  resource: "runs",
15496
16012
  action: "show",
15497
16013
  summary: "Show one batch run and its files",
@@ -15501,16 +16017,16 @@ var init_show2 = __esm({
15501
16017
  examples: ["kenso runs show r_ab3dxk2q"],
15502
16018
  async run(ctx, { positionals }) {
15503
16019
  const run = await loadRun(positionals[0] ?? "", ctx.env);
15504
- const { dir: dir2, ...record3 } = run;
15505
- const files = { dir: dir2 };
16020
+ const { dir: dir3, ...record3 } = run;
16021
+ const files = { dir: dir3 };
15506
16022
  for (const [key, name] of FILES) {
15507
- const path = join14(dir2, name);
16023
+ const path = join15(dir3, name);
15508
16024
  if (existsSync7(path)) files[key] = path;
15509
16025
  }
15510
16026
  let summary;
15511
16027
  if (files.summary) {
15512
16028
  try {
15513
- summary = JSON.parse(readFileSync9(files.summary, "utf8"));
16029
+ summary = JSON.parse(readFileSync11(files.summary, "utf8"));
15514
16030
  } catch {
15515
16031
  summary = void 0;
15516
16032
  }
@@ -15519,7 +16035,7 @@ var init_show2 = __esm({
15519
16035
  return ExitCode.Ok;
15520
16036
  }
15521
16037
  };
15522
- show_default2 = command44;
16038
+ show_default2 = command45;
15523
16039
  }
15524
16040
  });
15525
16041
 
@@ -15536,8 +16052,8 @@ import { resolve as resolve10 } from "node:path";
15536
16052
  function kebab(key) {
15537
16053
  return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
15538
16054
  }
15539
- function commandWords(command70) {
15540
- return command70.trim().split(/\s+/).filter((t) => t !== "");
16055
+ function commandWords(command71) {
16056
+ return command71.trim().split(/\s+/).filter((t) => t !== "");
15541
16057
  }
15542
16058
  function flagValue(value) {
15543
16059
  return typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value);
@@ -15582,19 +16098,19 @@ async function sha256(path) {
15582
16098
  return createHash5("sha256").update(await readFile9(path)).digest("hex");
15583
16099
  }
15584
16100
  async function refuseUnlessBatch(run, next) {
15585
- const words = commandWords(run.command);
15586
- const name = words.join(" ");
15587
- if (words[0] === "work") {
16101
+ const words2 = commandWords(run.command);
16102
+ const name = words2.join(" ");
16103
+ if (words2[0] === "work") {
15588
16104
  throw usageError(`Run ${run.runId} is a kenso ${name} run, which cannot be resumed: its claims were released or expire on their own.`, {
15589
16105
  hint: name === "work pull" ? `Answer its work files in ${run.dir}, then send them with kenso work submit. New work: run kenso work pull again.` : "Run kenso work run again: it takes the work that waits now.",
15590
16106
  next: "kenso work status"
15591
16107
  });
15592
16108
  }
15593
- const [resourceWord = "", action = ""] = words;
16109
+ const [resourceWord = "", action = ""] = words2;
15594
16110
  const resource = resourceAliases[resourceWord] ?? resourceWord;
15595
16111
  const area = Object.hasOwn(handWritten, resource) ? handWritten[resource] : {};
15596
16112
  let spec = null;
15597
- if (words.length === 2 && !Object.hasOwn(area, "")) {
16113
+ if (words2.length === 2 && !Object.hasOwn(area, "")) {
15598
16114
  const loader = Object.hasOwn(area, action) ? area[action] : void 0;
15599
16115
  spec = loader ? await loader() : await resolveGenerated(resource, action);
15600
16116
  }
@@ -15610,7 +16126,7 @@ async function refuseUnlessBatch(run, next) {
15610
16126
  throw usageError(`Run ${run.runId} names flags kenso ${name} does not take (--${undeclared.join(", --")}), so it is not replayed.`, { next });
15611
16127
  }
15612
16128
  }
15613
- var SKIPPED_KEYS, command45, resume_default;
16129
+ var SKIPPED_KEYS, command46, resume_default;
15614
16130
  var init_resume = __esm({
15615
16131
  "src/commands/runs/resume.ts"() {
15616
16132
  "use strict";
@@ -15619,7 +16135,7 @@ var init_resume = __esm({
15619
16135
  init_generated_hook();
15620
16136
  init_registry();
15621
16137
  SKIPPED_KEYS = /* @__PURE__ */ new Set(["positionals", "yes", "dryRun", "dry-run", "help", "version"]);
15622
- command45 = {
16138
+ command46 = {
15623
16139
  resource: "runs",
15624
16140
  action: "resume",
15625
16141
  summary: "Continue an interrupted batch run (its command with --yes, no dry run)",
@@ -15670,7 +16186,7 @@ var init_resume = __esm({
15670
16186
  }
15671
16187
  }
15672
16188
  };
15673
- resume_default = command45;
16189
+ resume_default = command46;
15674
16190
  }
15675
16191
  });
15676
16192
 
@@ -15778,7 +16294,7 @@ var create_exports = {};
15778
16294
  __export(create_exports, {
15779
16295
  default: () => create_default
15780
16296
  });
15781
- var command46, create_default;
16297
+ var command47, create_default;
15782
16298
  var init_create = __esm({
15783
16299
  "src/commands/sandbox/create.ts"() {
15784
16300
  "use strict";
@@ -15786,7 +16302,7 @@ var init_create = __esm({
15786
16302
  init_exit_codes();
15787
16303
  init_http();
15788
16304
  init_shared();
15789
- command46 = {
16305
+ command47 = {
15790
16306
  resource: "sandbox",
15791
16307
  action: "create",
15792
16308
  summary: "Create your developer sandbox and save its test key as the sandbox profile",
@@ -15829,7 +16345,7 @@ var init_create = __esm({
15829
16345
  return ExitCode.Ok;
15830
16346
  }
15831
16347
  };
15832
- create_default = command46;
16348
+ create_default = command47;
15833
16349
  }
15834
16350
  });
15835
16351
 
@@ -15838,7 +16354,7 @@ var delete_exports2 = {};
15838
16354
  __export(delete_exports2, {
15839
16355
  default: () => delete_default2
15840
16356
  });
15841
- var command47, delete_default2;
16357
+ var command48, delete_default2;
15842
16358
  var init_delete2 = __esm({
15843
16359
  "src/commands/sandbox/delete.ts"() {
15844
16360
  "use strict";
@@ -15846,7 +16362,7 @@ var init_delete2 = __esm({
15846
16362
  init_confirm();
15847
16363
  init_exit_codes();
15848
16364
  init_shared();
15849
- command47 = {
16365
+ command48 = {
15850
16366
  resource: "sandbox",
15851
16367
  action: "delete",
15852
16368
  summary: "Delete your sandbox and its test keys",
@@ -15874,7 +16390,7 @@ var init_delete2 = __esm({
15874
16390
  return ExitCode.Ok;
15875
16391
  }
15876
16392
  };
15877
- delete_default2 = command47;
16393
+ delete_default2 = command48;
15878
16394
  }
15879
16395
  });
15880
16396
 
@@ -15883,14 +16399,14 @@ var key_exports = {};
15883
16399
  __export(key_exports, {
15884
16400
  default: () => key_default
15885
16401
  });
15886
- var command48, key_default;
16402
+ var command49, key_default;
15887
16403
  var init_key = __esm({
15888
16404
  "src/commands/sandbox/key.ts"() {
15889
16405
  "use strict";
15890
16406
  init_exit_codes();
15891
16407
  init_http();
15892
16408
  init_shared();
15893
- command48 = {
16409
+ command49 = {
15894
16410
  resource: "sandbox",
15895
16411
  action: "key",
15896
16412
  summary: "Create a new test key for your sandbox and save it as the sandbox profile",
@@ -15911,7 +16427,7 @@ var init_key = __esm({
15911
16427
  return ExitCode.Ok;
15912
16428
  }
15913
16429
  };
15914
- key_default = command48;
16430
+ key_default = command49;
15915
16431
  }
15916
16432
  });
15917
16433
 
@@ -15920,13 +16436,13 @@ var list_exports3 = {};
15920
16436
  __export(list_exports3, {
15921
16437
  default: () => list_default3
15922
16438
  });
15923
- var command49, list_default3;
16439
+ var command50, list_default3;
15924
16440
  var init_list3 = __esm({
15925
16441
  "src/commands/sandbox/list.ts"() {
15926
16442
  "use strict";
15927
16443
  init_exit_codes();
15928
16444
  init_shared();
15929
- command49 = {
16445
+ command50 = {
15930
16446
  resource: "sandbox",
15931
16447
  action: "list",
15932
16448
  summary: "List your developer sandbox",
@@ -15943,7 +16459,7 @@ var init_list3 = __esm({
15943
16459
  return ExitCode.Ok;
15944
16460
  }
15945
16461
  };
15946
- list_default3 = command49;
16462
+ list_default3 = command50;
15947
16463
  }
15948
16464
  });
15949
16465
 
@@ -15952,14 +16468,14 @@ var reset_exports = {};
15952
16468
  __export(reset_exports, {
15953
16469
  default: () => reset_default
15954
16470
  });
15955
- var command50, reset_default;
16471
+ var command51, reset_default;
15956
16472
  var init_reset = __esm({
15957
16473
  "src/commands/sandbox/reset.ts"() {
15958
16474
  "use strict";
15959
16475
  init_exit_codes();
15960
16476
  init_http();
15961
16477
  init_shared();
15962
- command50 = {
16478
+ command51 = {
15963
16479
  resource: "sandbox",
15964
16480
  action: "reset",
15965
16481
  summary: "Reset your sandbox to its seed data",
@@ -15978,7 +16494,7 @@ var init_reset = __esm({
15978
16494
  return ExitCode.Ok;
15979
16495
  }
15980
16496
  };
15981
- reset_default = command50;
16497
+ reset_default = command51;
15982
16498
  }
15983
16499
  });
15984
16500
 
@@ -16049,7 +16565,7 @@ var init_common3 = __esm({
16049
16565
  // src/commands/studio/folder.ts
16050
16566
  import { createHash as createHash6 } from "node:crypto";
16051
16567
  import { lstat, readdir as readdir2, readFile as readFile10, stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
16052
- import { extname as extname6, isAbsolute, join as join15, relative, resolve as resolve11, sep } from "node:path";
16568
+ import { extname as extname6, isAbsolute, join as join16, relative, resolve as resolve11, sep } from "node:path";
16053
16569
  function textOf2(bytes) {
16054
16570
  if (bytes.length >= TEXT_MAX_BYTES || bytes.includes(0)) return void 0;
16055
16571
  try {
@@ -16058,10 +16574,10 @@ function textOf2(bytes) {
16058
16574
  return void 0;
16059
16575
  }
16060
16576
  }
16061
- async function existingDir(dir2) {
16062
- const abs = resolve11(dir2);
16577
+ async function existingDir(dir3) {
16578
+ const abs = resolve11(dir3);
16063
16579
  const info = await stat3(abs).catch(() => void 0);
16064
- if (!info?.isDirectory()) throw usageError(`${dir2} is not a directory.`, { field: "dir" });
16580
+ if (!info?.isDirectory()) throw usageError(`${dir3} is not a directory.`, { field: "dir" });
16065
16581
  return abs;
16066
16582
  }
16067
16583
  function inBundleLayout(bundlePath) {
@@ -16072,14 +16588,14 @@ function inBundleLayout(bundlePath) {
16072
16588
  const name = segments[1];
16073
16589
  return segments[0] === "samples" && segments.length === 2 && SAMPLE_NAME.test(name) && !TOOL_CONFIG_NAMES.has(name.toLowerCase());
16074
16590
  }
16075
- async function readFolder(dir2, skipped = []) {
16076
- const root2 = await existingDir(dir2);
16591
+ async function readFolder(dir3, skipped = []) {
16592
+ const root2 = await existingDir(dir3);
16077
16593
  const files = [];
16078
16594
  const walk = async (folder) => {
16079
16595
  const entries2 = await readdir2(folder, { withFileTypes: true });
16080
16596
  for (const entry of entries2) {
16081
16597
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
16082
- const abs = join15(folder, entry.name);
16598
+ const abs = join16(folder, entry.name);
16083
16599
  const path = relative(root2, abs).split(sep).join("/");
16084
16600
  if (entry.isDirectory()) {
16085
16601
  if (path === "assets" || path.startsWith("assets/") || path === "samples") await walk(abs);
@@ -16111,7 +16627,7 @@ async function existingFileNoLinks(root2, target2, bundlePath) {
16111
16627
  const parts2 = relative(root2, target2).split(sep);
16112
16628
  let at = root2;
16113
16629
  for (const [i, part] of parts2.entries()) {
16114
- at = join15(at, part);
16630
+ at = join16(at, part);
16115
16631
  const info = await lstat(at).catch(() => void 0);
16116
16632
  if (!info) return false;
16117
16633
  if (info.isSymbolicLink()) throw unsafePath(bundlePath, `${at} is a symbolic link`);
@@ -16124,7 +16640,7 @@ async function existingFileNoLinks(root2, target2, bundlePath) {
16124
16640
  }
16125
16641
  async function readPullState(root2) {
16126
16642
  try {
16127
- const files = JSON.parse(await readFile10(join15(root2, PULL_STATE), "utf8"))?.files;
16643
+ const files = JSON.parse(await readFile10(join16(root2, PULL_STATE), "utf8"))?.files;
16128
16644
  if (typeof files !== "object" || files === null) return {};
16129
16645
  return Object.fromEntries(Object.entries(files).filter((entry) => typeof entry[1] === "string"));
16130
16646
  } catch {
@@ -16132,7 +16648,7 @@ async function readPullState(root2) {
16132
16648
  }
16133
16649
  }
16134
16650
  async function recordPullState(root2, entries2) {
16135
- const path = join15(root2, PULL_STATE);
16651
+ const path = join16(root2, PULL_STATE);
16136
16652
  await existingFileNoLinks(root2, path, PULL_STATE);
16137
16653
  const files = { ...await readPullState(root2), ...Object.fromEntries(entries2) };
16138
16654
  await writeFile4(path, `${JSON.stringify({ files }, null, 2)}
@@ -16342,8 +16858,8 @@ __export(pull_exports, {
16342
16858
  default: () => pull_default
16343
16859
  });
16344
16860
  import { mkdir, readFile as readFile11, writeFile as writeFile5 } from "node:fs/promises";
16345
- import { dirname as dirname2, join as join16, resolve as resolve12 } from "node:path";
16346
- var command51, pull_default;
16861
+ import { dirname as dirname2, join as join17, resolve as resolve12 } from "node:path";
16862
+ var command52, pull_default;
16347
16863
  var init_pull = __esm({
16348
16864
  "src/commands/studio/pull.ts"() {
16349
16865
  "use strict";
@@ -16354,7 +16870,7 @@ var init_pull = __esm({
16354
16870
  init_common3();
16355
16871
  init_folder();
16356
16872
  init_transfer2();
16357
- command51 = {
16873
+ command52 = {
16358
16874
  resource: "studio",
16359
16875
  action: "pull",
16360
16876
  summary: "Write a template version's files to a folder",
@@ -16377,7 +16893,7 @@ var init_pull = __esm({
16377
16893
  if (version !== void 0 && !/^(draft|latest|\d+)$/.test(version)) {
16378
16894
  throw usageError(`--template-version must be draft, latest or a version id (got "${version}").`, { field: "template-version" });
16379
16895
  }
16380
- const dir2 = resolve12(String(flags.dir));
16896
+ const dir3 = resolve12(String(flags.dir));
16381
16897
  const res = await ctx.client.request({
16382
16898
  method: "GET",
16383
16899
  path: `/v1/asset-templates/${templateId}/pull`,
@@ -16388,17 +16904,17 @@ var init_pull = __esm({
16388
16904
  if (pulled.skipped?.length) {
16389
16905
  ctx.output.warn(`Kenso left out ${pulled.skipped.length} stored file${pulled.skipped.length === 1 ? "" : "s"} outside the bundle layout: ${pulled.skipped.join(", ")}.`);
16390
16906
  }
16391
- const files = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(dir2, path) }));
16907
+ const files = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(dir3, path) }));
16392
16908
  const missing2 = files.find(({ file }) => typeof file.text !== "string" && !file.downloadUrl);
16393
16909
  if (missing2) {
16394
16910
  throw new KensoError({ code: "pull_incomplete", message: `${missing2.path} came back with neither text nor a download link.`, exitCode: ExitCode.Server });
16395
16911
  }
16396
- const statePath2 = join16(dir2, PULL_STATE);
16397
- await existingFileNoLinks(dir2, statePath2, PULL_STATE);
16398
- const state = await readPullState(dir2);
16912
+ const statePath2 = join17(dir3, PULL_STATE);
16913
+ await existingFileNoLinks(dir3, statePath2, PULL_STATE);
16914
+ const state = await readPullState(dir3);
16399
16915
  const conflicts = [];
16400
16916
  for (const { path, file, target: target2 } of files) {
16401
- if (!await existingFileNoLinks(dir2, target2, path)) continue;
16917
+ if (!await existingFileNoLinks(dir3, target2, path)) continue;
16402
16918
  const current = sha2562(await readFile11(target2));
16403
16919
  const next = typeof file.text === "string" ? sha2562(Buffer.from(file.text, "utf8")) : file.sha256?.toLowerCase();
16404
16920
  if (current !== next && current !== state[path]) conflicts.push(path);
@@ -16408,7 +16924,7 @@ var init_pull = __esm({
16408
16924
  dryRun: true,
16409
16925
  templateId,
16410
16926
  versionId: pulled.versionId,
16411
- dir: dir2,
16927
+ dir: dir3,
16412
16928
  files: files.map(({ path }) => path),
16413
16929
  ...conflicts.length > 0 ? { conflicts } : {}
16414
16930
  });
@@ -16417,48 +16933,48 @@ var init_pull = __esm({
16417
16933
  if (conflicts.length > 0 && flags.force !== true) {
16418
16934
  throw new KensoError({
16419
16935
  code: "local_changes",
16420
- message: `Pulling would replace ${conflicts.length} file${conflicts.length === 1 ? "" : "s"} in ${dir2} that no earlier pull wrote or push sent, or that changed since: ${conflicts.join(", ")}.`,
16936
+ message: `Pulling would replace ${conflicts.length} file${conflicts.length === 1 ? "" : "s"} in ${dir3} that no earlier pull wrote or push sent, or that changed since: ${conflicts.join(", ")}.`,
16421
16937
  exitCode: ExitCode.Conflict,
16422
16938
  field: "force",
16423
16939
  hint: "They are files you added or changed since the last pull or push. Move them away or compare them with the template first, or add --force to replace them with the template's version. Nothing was written.",
16424
16940
  next: commandLine2(ctx, "studio pull", { flags: { ...flags, force: true }, positionals })
16425
16941
  });
16426
16942
  }
16427
- await mkdir(dir2, { recursive: true });
16943
+ await mkdir(dir3, { recursive: true });
16428
16944
  const written = await mapLimit(files, PARALLEL_TRANSFERS, async ({ path, file, target: target2 }) => {
16429
16945
  const content = typeof file.text === "string" ? Buffer.from(file.text, "utf8") : await download2(file.downloadUrl, path, file.sha256, ctx.signal);
16430
16946
  await mkdir(dirname2(target2), { recursive: true });
16431
16947
  await writeFile5(target2, content);
16432
16948
  return [path, sha2562(content)];
16433
16949
  });
16434
- await recordPullState(dir2, written);
16435
- ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir: dir2, ...conflicts.length > 0 ? { replaced: conflicts } : {} });
16950
+ await recordPullState(dir3, written);
16951
+ ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir: dir3, ...conflicts.length > 0 ? { replaced: conflicts } : {} });
16436
16952
  return ExitCode.Ok;
16437
16953
  }
16438
16954
  };
16439
- pull_default = command51;
16955
+ pull_default = command52;
16440
16956
  }
16441
16957
  });
16442
16958
 
16443
16959
  // src/commands/studio/read.ts
16444
- async function readLocalTemplate(ctx, templateId, dir2) {
16960
+ async function readLocalTemplate(ctx, templateId, dir3) {
16445
16961
  const skipped = [];
16446
- const files = await readFolder(dir2, skipped);
16962
+ const files = await readFolder(dir3, skipped);
16447
16963
  if (skipped.length > 0) {
16448
16964
  const shown = skipped.length > SHOWN ? `${skipped.slice(0, SHOWN).join(", ")} and ${skipped.length - SHOWN} more` : skipped.join(", ");
16449
16965
  ctx.output.warn(`Skipped what is not part of a Studio bundle: ${shown}. A bundle holds only ${LAYOUT}.`);
16450
16966
  }
16451
16967
  if (files.length === 0) {
16452
- throw usageError(`${dir2} has no template files (only ${LAYOUT} are read; dotfiles and node_modules are skipped).`, {
16968
+ throw usageError(`${dir3} has no template files (only ${LAYOUT} are read; dotfiles and node_modules are skipped).`, {
16453
16969
  field: "dir",
16454
- next: `kenso studio pull ${templateId} --dir ${dir2}`
16970
+ next: `kenso studio pull ${templateId} --dir ${dir3}`
16455
16971
  });
16456
16972
  }
16457
16973
  refuseOversize(files);
16458
16974
  return files;
16459
16975
  }
16460
- async function readTemplateFolder(ctx, templateId, dir2) {
16461
- return bundleFiles(ctx, templateId, await readLocalTemplate(ctx, templateId, dir2));
16976
+ async function readTemplateFolder(ctx, templateId, dir3) {
16977
+ return bundleFiles(ctx, templateId, await readLocalTemplate(ctx, templateId, dir3));
16462
16978
  }
16463
16979
  var SHOWN;
16464
16980
  var init_read = __esm({
@@ -16477,7 +16993,7 @@ __export(push_exports, {
16477
16993
  default: () => push_default
16478
16994
  });
16479
16995
  import { resolve as resolve13 } from "node:path";
16480
- var BUILT_BY, DEFAULT_MESSAGE, command52, push_default;
16996
+ var BUILT_BY, DEFAULT_MESSAGE, command53, push_default;
16481
16997
  var init_push = __esm({
16482
16998
  "src/commands/studio/push.ts"() {
16483
16999
  "use strict";
@@ -16491,7 +17007,7 @@ var init_push = __esm({
16491
17007
  init_transfer2();
16492
17008
  BUILT_BY = "customer_agent";
16493
17009
  DEFAULT_MESSAGE = "Pushed with the Kenso CLI";
16494
- command52 = {
17010
+ command53 = {
16495
17011
  resource: "studio",
16496
17012
  action: "push",
16497
17013
  summary: "Save a folder's files to a template's draft and print the validation",
@@ -16586,7 +17102,7 @@ var init_push = __esm({
16586
17102
  );
16587
17103
  }
16588
17104
  };
16589
- push_default = command52;
17105
+ push_default = command53;
16590
17106
  }
16591
17107
  });
16592
17108
 
@@ -16595,7 +17111,7 @@ var validate_exports = {};
16595
17111
  __export(validate_exports, {
16596
17112
  default: () => validate_default
16597
17113
  });
16598
- var command53, validate_default;
17114
+ var command54, validate_default;
16599
17115
  var init_validate = __esm({
16600
17116
  "src/commands/studio/validate.ts"() {
16601
17117
  "use strict";
@@ -16604,7 +17120,7 @@ var init_validate = __esm({
16604
17120
  init_columns();
16605
17121
  init_common3();
16606
17122
  init_read();
16607
- command53 = {
17123
+ command54 = {
16608
17124
  resource: "studio",
16609
17125
  action: "validate",
16610
17126
  summary: "Validate a folder's files against a template without saving them",
@@ -16634,7 +17150,7 @@ var init_validate = __esm({
16634
17150
  throw validationFailed(validation, "The files have validation errors", commandLine2(ctx, "studio validate", args));
16635
17151
  }
16636
17152
  };
16637
- validate_default = command53;
17153
+ validate_default = command54;
16638
17154
  }
16639
17155
  });
16640
17156
 
@@ -16647,8 +17163,8 @@ import { createHash as createHash8 } from "node:crypto";
16647
17163
  function list(paths) {
16648
17164
  return paths.length > SHOWN2 ? `${paths.slice(0, SHOWN2).join(", ")} and ${paths.length - SHOWN2} more` : paths.join(", ");
16649
17165
  }
16650
- async function warnIfFolderDiffers(ctx, templateId, dir2, versionId, push) {
16651
- const local = await readFolder(dir2);
17166
+ async function warnIfFolderDiffers(ctx, templateId, dir3, versionId, push) {
17167
+ const local = await readFolder(dir3);
16652
17168
  const res = await ctx.client.request({
16653
17169
  method: "GET",
16654
17170
  path: `/v1/asset-templates/${templateId}/pull`,
@@ -16683,7 +17199,7 @@ function accountIds(value) {
16683
17199
  }
16684
17200
  return ids2.map(Number);
16685
17201
  }
16686
- var SHOWN2, command54, preview_default;
17202
+ var SHOWN2, command55, preview_default;
16687
17203
  var init_preview = __esm({
16688
17204
  "src/commands/studio/preview.ts"() {
16689
17205
  "use strict";
@@ -16695,7 +17211,7 @@ var init_preview = __esm({
16695
17211
  init_common3();
16696
17212
  init_folder();
16697
17213
  SHOWN2 = 5;
16698
- command54 = {
17214
+ command55 = {
16699
17215
  resource: "studio",
16700
17216
  action: "preview",
16701
17217
  summary: "Render a saved version for up to 3 accounts; for local edits, studio push them to the draft first",
@@ -16722,10 +17238,10 @@ var init_preview = __esm({
16722
17238
  const ids2 = accountIds(stringFlag(flags["account-ids"]));
16723
17239
  const interact = flags.interact !== void 0 ? await readDataArg(String(flags.interact), ctx.stdin) : void 0;
16724
17240
  if (interact !== void 0 && !Array.isArray(interact)) throw usageError("--interact must be a JSON array of steps.", { field: "interact" });
16725
- const dir2 = stringFlag(flags.dir);
16726
- if (dir2 !== void 0) {
16727
- const push = commandLine2(ctx, "studio push", { flags: { dir: dir2 }, positionals: [String(templateId)] });
16728
- await warnIfFolderDiffers(ctx, templateId, dir2, versionId, push);
17241
+ const dir3 = stringFlag(flags.dir);
17242
+ if (dir3 !== void 0) {
17243
+ const push = commandLine2(ctx, "studio push", { flags: { dir: dir3 }, positionals: [String(templateId)] });
17244
+ await warnIfFolderDiffers(ctx, templateId, dir3, versionId, push);
16729
17245
  }
16730
17246
  const mode = stringFlag(flags.mode);
16731
17247
  const sample = stringFlag(flags.sample);
@@ -16745,7 +17261,7 @@ var init_preview = __esm({
16745
17261
  return ExitCode.Ok;
16746
17262
  }
16747
17263
  };
16748
- preview_default = command54;
17264
+ preview_default = command55;
16749
17265
  }
16750
17266
  });
16751
17267
 
@@ -16854,7 +17370,7 @@ __export(fill_exports, {
16854
17370
  });
16855
17371
  import { createHash as createHash9 } from "node:crypto";
16856
17372
  import { readFile as readFile12 } from "node:fs/promises";
16857
- import { join as join17, resolve as resolve14 } from "node:path";
17373
+ import { join as join18, resolve as resolve14 } from "node:path";
16858
17374
  async function readTarget(ctx, flags) {
16859
17375
  const accounts = stringFlag(flags.accounts);
16860
17376
  const campaign = stringFlag(flags.campaign);
@@ -16905,7 +17421,7 @@ async function refuseRefill(ctx, args, target2) {
16905
17421
  code: "already_filled",
16906
17422
  exitCode: ExitCode.Conflict,
16907
17423
  message: unfinished ? `Run ${earlier.runId} is already filling these ${ids2} (${earlier.status}).` : `Run ${earlier.runId} already filled these ${ids2}.`,
16908
- 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 ${join17(earlier.dir, "results.csv")} in a file and fill that file.`,
17424
+ 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 ${join18(earlier.dir, "results.csv")} in a file and fill that file.`,
16909
17425
  next: unfinished ? `kenso runs resume ${earlier.runId}` : `kenso runs show ${earlier.runId}`
16910
17426
  });
16911
17427
  }
@@ -16946,7 +17462,7 @@ function estimateOutput(templateId, target2, estimate) {
16946
17462
  ...target2.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
16947
17463
  };
16948
17464
  }
16949
- var COMMAND6, sha2563, command55, fill_default;
17465
+ var COMMAND6, sha2563, command56, fill_default;
16950
17466
  var init_fill = __esm({
16951
17467
  "src/commands/studio/fill.ts"() {
16952
17468
  "use strict";
@@ -16962,7 +17478,7 @@ var init_fill = __esm({
16962
17478
  init_fill_runs();
16963
17479
  COMMAND6 = "studio fill";
16964
17480
  sha2563 = (data) => createHash9("sha256").update(data).digest("hex");
16965
- command55 = {
17481
+ command56 = {
16966
17482
  resource: "studio",
16967
17483
  action: "fill",
16968
17484
  summary: "Fill a template on many accounts or campaign leads (estimate first)",
@@ -17024,7 +17540,7 @@ var init_fill = __esm({
17024
17540
  return outcome.exitCode;
17025
17541
  }
17026
17542
  };
17027
- fill_default = command55;
17543
+ fill_default = command56;
17028
17544
  }
17029
17545
  });
17030
17546
 
@@ -17131,7 +17647,7 @@ var add_exports2 = {};
17131
17647
  __export(add_exports2, {
17132
17648
  default: () => add_default2
17133
17649
  });
17134
- var NEXT, command56, add_default2;
17650
+ var NEXT, command57, add_default2;
17135
17651
  var init_add2 = __esm({
17136
17652
  "src/commands/tasks/add.ts"() {
17137
17653
  "use strict";
@@ -17141,7 +17657,7 @@ var init_add2 = __esm({
17141
17657
  init_http();
17142
17658
  init_shared2();
17143
17659
  NEXT = 'kenso tasks add "Send the deck" --due tomorrow --account 812';
17144
- command56 = {
17660
+ command57 = {
17145
17661
  resource: "tasks",
17146
17662
  action: "add",
17147
17663
  summary: "Add a task: a title, an optional due day and time, assignee and the account, person or deal it is about",
@@ -17179,7 +17695,7 @@ var init_add2 = __esm({
17179
17695
  return ExitCode.Ok;
17180
17696
  }
17181
17697
  };
17182
- add_default2 = command56;
17698
+ add_default2 = command57;
17183
17699
  }
17184
17700
  });
17185
17701
 
@@ -17216,7 +17732,7 @@ function stoppedAt(error, id, finished, status) {
17216
17732
  details: error.details
17217
17733
  });
17218
17734
  }
17219
- var command57, done_default;
17735
+ var command58, done_default;
17220
17736
  var init_done = __esm({
17221
17737
  "src/commands/tasks/done.ts"() {
17222
17738
  "use strict";
@@ -17225,7 +17741,7 @@ var init_done = __esm({
17225
17741
  init_exit_codes();
17226
17742
  init_http();
17227
17743
  init_shared2();
17228
- command57 = {
17744
+ command58 = {
17229
17745
  resource: "tasks",
17230
17746
  action: "done",
17231
17747
  summary: "Complete one or more tasks (--undo reopens them)",
@@ -17259,7 +17775,7 @@ var init_done = __esm({
17259
17775
  return ExitCode.Ok;
17260
17776
  }
17261
17777
  };
17262
- done_default = command57;
17778
+ done_default = command58;
17263
17779
  }
17264
17780
  });
17265
17781
 
@@ -17268,7 +17784,7 @@ var assign_exports = {};
17268
17784
  __export(assign_exports, {
17269
17785
  default: () => assign_default
17270
17786
  });
17271
- var NEXT2, command58, assign_default;
17787
+ var NEXT2, command59, assign_default;
17272
17788
  var init_assign = __esm({
17273
17789
  "src/commands/tasks/assign.ts"() {
17274
17790
  "use strict";
@@ -17277,7 +17793,7 @@ var init_assign = __esm({
17277
17793
  init_done();
17278
17794
  init_shared2();
17279
17795
  NEXT2 = "kenso tasks assign <taskId> <me|memberId|email>";
17280
- command58 = {
17796
+ command59 = {
17281
17797
  resource: "tasks",
17282
17798
  action: "assign",
17283
17799
  summary: "Give a task to a member",
@@ -17301,7 +17817,7 @@ var init_assign = __esm({
17301
17817
  return ExitCode.Ok;
17302
17818
  }
17303
17819
  };
17304
- assign_default = command58;
17820
+ assign_default = command59;
17305
17821
  }
17306
17822
  });
17307
17823
 
@@ -17310,14 +17826,14 @@ var queue_exports = {};
17310
17826
  __export(queue_exports, {
17311
17827
  default: () => queue_default
17312
17828
  });
17313
- var SCOPES, command59, queue_default;
17829
+ var SCOPES, command60, queue_default;
17314
17830
  var init_queue = __esm({
17315
17831
  "src/commands/tasks/queue.ts"() {
17316
17832
  "use strict";
17317
17833
  init_errors();
17318
17834
  init_exit_codes();
17319
17835
  SCOPES = ["mine", "assigned_by_me", "everyone"];
17320
- command59 = {
17836
+ command60 = {
17321
17837
  resource: "tasks",
17322
17838
  action: "queue",
17323
17839
  summary: "Your open work by due day: tasks, touches, call tasks, reply reminders and Ken follow-ups",
@@ -17339,7 +17855,7 @@ var init_queue = __esm({
17339
17855
  return ExitCode.Ok;
17340
17856
  }
17341
17857
  };
17342
- queue_default = command59;
17858
+ queue_default = command60;
17343
17859
  }
17344
17860
  });
17345
17861
 
@@ -17447,25 +17963,25 @@ var init_views = __esm({
17447
17963
 
17448
17964
  // src/commands/webhooks/local.ts
17449
17965
  import { createHmac, randomBytes as randomBytes2 } from "node:crypto";
17450
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync10, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
17451
- import { join as join18 } from "node:path";
17966
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync12, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "node:fs";
17967
+ import { join as join19 } from "node:path";
17452
17968
  function webhooksDir(env) {
17453
- const dir2 = join18(configDir(env), "webhooks");
17454
- mkdirSync4(dir2, { recursive: true, mode: 448 });
17455
- return dir2;
17969
+ const dir3 = join19(configDir(env), "webhooks");
17970
+ mkdirSync4(dir3, { recursive: true, mode: 448 });
17971
+ return dir3;
17456
17972
  }
17457
17973
  function signingSecretPath(env) {
17458
- return join18(webhooksDir(env), "signing-secret");
17974
+ return join19(webhooksDir(env), "signing-secret");
17459
17975
  }
17460
17976
  function signingSecret(env) {
17461
17977
  const file = signingSecretPath(env);
17462
17978
  try {
17463
- const saved = readFileSync10(file, "utf8").trim();
17979
+ const saved = readFileSync12(file, "utf8").trim();
17464
17980
  if (/^whsec_[A-Za-z0-9+/]{32,}={0,2}$/.test(saved)) return saved;
17465
17981
  } catch {
17466
17982
  }
17467
17983
  const secret = `whsec_${randomBytes2(24).toString("base64")}`;
17468
- writeFileSync4(file, `${secret}
17984
+ writeFileSync5(file, `${secret}
17469
17985
  `, { mode: 384 });
17470
17986
  return secret;
17471
17987
  }
@@ -17506,15 +18022,15 @@ async function forward(url, event, secret, signal) {
17506
18022
  }
17507
18023
  }
17508
18024
  function statePath(env, workspaceId) {
17509
- return join18(webhooksDir(env), `listener-${(workspaceId ?? "default").replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
18025
+ return join19(webhooksDir(env), `listener-${(workspaceId ?? "default").replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
17510
18026
  }
17511
18027
  function writeListenerState(env, workspaceId, state) {
17512
- writeFileSync4(statePath(env, workspaceId), `${JSON.stringify(state)}
18028
+ writeFileSync5(statePath(env, workspaceId), `${JSON.stringify(state)}
17513
18029
  `, { mode: 384 });
17514
18030
  }
17515
18031
  function readListenerState(env, workspaceId) {
17516
18032
  try {
17517
- const state = JSON.parse(readFileSync10(statePath(env, workspaceId), "utf8"));
18033
+ const state = JSON.parse(readFileSync12(statePath(env, workspaceId), "utf8"));
17518
18034
  return typeof state.url === "string" && typeof state.token === "string" ? state : void 0;
17519
18035
  } catch {
17520
18036
  return void 0;
@@ -17577,7 +18093,7 @@ function readBody(req) {
17577
18093
  function reply(res, status, body2) {
17578
18094
  res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(body2));
17579
18095
  }
17580
- var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command60, listen_default;
18096
+ var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command61, listen_default;
17581
18097
  var init_listen = __esm({
17582
18098
  "src/commands/webhooks/listen.ts"() {
17583
18099
  "use strict";
@@ -17588,7 +18104,7 @@ var init_listen = __esm({
17588
18104
  MIN_POLL_MS = 1e3;
17589
18105
  MAX_POLL_MS = 6e4;
17590
18106
  MAX_TRIGGER_BYTES = 1e6;
17591
- command60 = {
18107
+ command61 = {
17592
18108
  resource: "webhooks",
17593
18109
  action: "listen",
17594
18110
  summary: "Stream the workspace's events and forward them, signed, to a local handler",
@@ -17695,7 +18211,7 @@ var init_listen = __esm({
17695
18211
  return ExitCode.Ok;
17696
18212
  }
17697
18213
  };
17698
- listen_default = command60;
18214
+ listen_default = command61;
17699
18215
  }
17700
18216
  });
17701
18217
 
@@ -17714,7 +18230,7 @@ function notRunning() {
17714
18230
  next: LISTEN_NEXT
17715
18231
  });
17716
18232
  }
17717
- var LISTEN_NEXT, command61, trigger_default;
18233
+ var LISTEN_NEXT, command62, trigger_default;
17718
18234
  var init_trigger = __esm({
17719
18235
  "src/commands/webhooks/trigger.ts"() {
17720
18236
  "use strict";
@@ -17723,7 +18239,7 @@ var init_trigger = __esm({
17723
18239
  init_http();
17724
18240
  init_local();
17725
18241
  LISTEN_NEXT = "kenso webhooks listen --forward-to http://localhost:3000/hook";
17726
- command61 = {
18242
+ command62 = {
17727
18243
  resource: "webhooks",
17728
18244
  action: "trigger",
17729
18245
  summary: "Send a sample event of one type through the running kenso webhooks listen",
@@ -17781,7 +18297,7 @@ var init_trigger = __esm({
17781
18297
  return ExitCode.Ok;
17782
18298
  }
17783
18299
  };
17784
- trigger_default = command61;
18300
+ trigger_default = command62;
17785
18301
  }
17786
18302
  });
17787
18303
 
@@ -17802,14 +18318,14 @@ var status_exports3 = {};
17802
18318
  __export(status_exports3, {
17803
18319
  default: () => status_default3
17804
18320
  });
17805
- var command62, status_default3;
18321
+ var command63, status_default3;
17806
18322
  var init_status3 = __esm({
17807
18323
  "src/commands/work/status.ts"() {
17808
18324
  "use strict";
17809
18325
  init_exit_codes();
17810
18326
  init_http();
17811
18327
  init_common2();
17812
- command62 = {
18328
+ command63 = {
17813
18329
  resource: "work",
17814
18330
  action: "status",
17815
18331
  summary: "Show the Kenso AI work waiting for your own agent, per kind",
@@ -17844,13 +18360,13 @@ var init_status3 = __esm({
17844
18360
  return ExitCode.Ok;
17845
18361
  }
17846
18362
  };
17847
- status_default3 = command62;
18363
+ status_default3 = command63;
17848
18364
  }
17849
18365
  });
17850
18366
 
17851
18367
  // src/work/files.ts
17852
- import { closeSync as closeSync2, constants, fchmodSync, fstatSync, lstatSync, openSync as openSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync5 } from "node:fs";
17853
- import { join as join19 } from "node:path";
18368
+ import { closeSync as closeSync2, constants, fchmodSync, fstatSync, lstatSync, openSync as openSync2, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "node:fs";
18369
+ import { join as join20 } from "node:path";
17854
18370
  function agentName(value) {
17855
18371
  if (typeof value !== "string") return void 0;
17856
18372
  const name = value.trim().slice(0, MAX_AGENT_NAME);
@@ -17866,13 +18382,13 @@ function workFileName(claimId) {
17866
18382
  if (!isPlainFileName(claimId)) throw new Error("claimId is not a plain file name");
17867
18383
  return `${claimId}.work.json`;
17868
18384
  }
17869
- function writeWorkFile(dir2, work, mode = 384) {
18385
+ function writeWorkFile(dir3, work, mode = 384) {
17870
18386
  const name = workFileName(work.claimId);
17871
18387
  if (!isPlainFileName(work.answersFile)) throw new Error("answersFile is not a plain file name");
17872
- const path = join19(dir2, name);
18388
+ const path = join20(dir3, name);
17873
18389
  const fd = openSync2(path, "wx", mode);
17874
18390
  try {
17875
- writeFileSync5(fd, JSON.stringify(work, null, 2) + "\n", "utf8");
18391
+ writeFileSync6(fd, JSON.stringify(work, null, 2) + "\n", "utf8");
17876
18392
  fchmodSync(fd, mode);
17877
18393
  } finally {
17878
18394
  closeSync2(fd);
@@ -17887,7 +18403,7 @@ function readRegularFile(path, what) {
17887
18403
  const stat4 = fstatSync(fd);
17888
18404
  if (!stat4.isFile()) return notPlain;
17889
18405
  if (stat4.size > MAX_ANSWERS_FILE_BYTES) return { ok: false, error: `the ${what} is too large` };
17890
- return readFileSync11(fd, "utf8");
18406
+ return readFileSync13(fd, "utf8");
17891
18407
  } finally {
17892
18408
  closeSync2(fd);
17893
18409
  }
@@ -17974,11 +18490,11 @@ var init_files = __esm({
17974
18490
 
17975
18491
  // src/work/agent-user.ts
17976
18492
  import { execFile, spawnSync as spawnSync2 } from "node:child_process";
17977
- import { readFileSync as readFileSync12 } from "node:fs";
18493
+ import { readFileSync as readFileSync14 } from "node:fs";
17978
18494
  import { isAbsolute as isAbsolute2 } from "node:path";
17979
- function sudoArgs(user, command70, args, keep = [], set2 = {}) {
18495
+ function sudoArgs(user, command71, args, keep = [], set2 = {}) {
17980
18496
  const assignments = Object.entries(set2).map(([name, value]) => `${name}=${value}`);
17981
- return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command70, ...args];
18497
+ return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command71, ...args];
17982
18498
  }
17983
18499
  function agentKensoEnv(opts) {
17984
18500
  return {
@@ -17988,12 +18504,12 @@ function agentKensoEnv(opts) {
17988
18504
  AI_AGENT: opts.agentName
17989
18505
  };
17990
18506
  }
17991
- function sudoExec(user, command70, args, opts = {}) {
18507
+ function sudoExec(user, command71, args, opts = {}) {
17992
18508
  const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
17993
18509
  return new Promise((resolve18) => {
17994
18510
  execFile(
17995
18511
  sudo,
17996
- [...lead, ...sudoArgs(user.name, command70, args)],
18512
+ [...lead, ...sudoArgs(user.name, command71, args)],
17997
18513
  { env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
17998
18514
  (err, stdout, stderr) => {
17999
18515
  const code = err ? err.code : 0;
@@ -18031,7 +18547,7 @@ function ids(status, field) {
18031
18547
  }
18032
18548
  function sudoGids(groupFile) {
18033
18549
  const gids = /* @__PURE__ */ new Set([0]);
18034
- for (const line of readFileSync12(groupFile, "utf8").split("\n")) {
18550
+ for (const line of readFileSync14(groupFile, "utf8").split("\n")) {
18035
18551
  const [group, , gid] = line.split(":");
18036
18552
  if (group !== void 0 && SUDO_GROUPS.has(group) && /^\d+$/.test(gid ?? "")) gids.add(Number(gid));
18037
18553
  }
@@ -18093,7 +18609,7 @@ var init_agent_user = __esm({
18093
18609
  // src/commands/work/folder.ts
18094
18610
  import { existsSync as existsSync9 } from "node:fs";
18095
18611
  import { appendFile as appendFile3, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
18096
- import { dirname as dirname3, join as join20, resolve as resolve15 } from "node:path";
18612
+ import { dirname as dirname3, join as join21, resolve as resolve15 } from "node:path";
18097
18613
  var WorkRunFolder;
18098
18614
  var init_folder2 = __esm({
18099
18615
  "src/commands/work/folder.ts"() {
@@ -18103,9 +18619,9 @@ var init_folder2 = __esm({
18103
18619
  init_redact();
18104
18620
  init_agent_user();
18105
18621
  WorkRunFolder = class {
18106
- constructor(ctx, command70, args, outDir, shared = false) {
18622
+ constructor(ctx, command71, args, outDir, shared = false) {
18107
18623
  this.ctx = ctx;
18108
- this.command = command70;
18624
+ this.command = command71;
18109
18625
  this.args = args;
18110
18626
  this.outDir = outDir;
18111
18627
  this.shared = shared;
@@ -18133,32 +18649,32 @@ var init_folder2 = __esm({
18133
18649
  async make() {
18134
18650
  const root2 = runsRoot(this.ctx.env);
18135
18651
  const makeDir = (path) => this.shared ? ensureDir(path, SHARED_DIR_MODE) : ensurePrivateDir2(path);
18136
- let dir2;
18652
+ let dir3;
18137
18653
  if (this.outDir === void 0) {
18138
- dir2 = join20(root2, this.runId);
18654
+ dir3 = join21(root2, this.runId);
18139
18655
  if (!this.shared) ensurePrivateDir2(root2);
18140
- makeDir(dir2);
18656
+ makeDir(dir3);
18141
18657
  } else {
18142
- dir2 = resolve15(this.outDir);
18143
- const existing = existsSync9(join20(dir2, "run.json")) ? await readRunDir(dir2) : null;
18658
+ dir3 = resolve15(this.outDir);
18659
+ const existing = existsSync9(join21(dir3, "run.json")) ? await readRunDir(dir3) : null;
18144
18660
  if (existing && !existing.command.startsWith("work ")) {
18145
- throw usageError(`${dir2} already holds run ${existing.runId} (${existing.command}).`, {
18661
+ throw usageError(`${dir3} already holds run ${existing.runId} (${existing.command}).`, {
18146
18662
  field: "out",
18147
18663
  hint: "Pick another --out directory, or leave --out off to keep the work under the runs directory."
18148
18664
  });
18149
18665
  }
18150
- makeDir(dir2);
18151
- for (const name of ["results.ndjson", "summary.json"]) await unlink3(join20(dir2, name)).catch(() => void 0);
18666
+ makeDir(dir3);
18667
+ for (const name of ["results.ndjson", "summary.json"]) await unlink3(join21(dir3, name)).catch(() => void 0);
18152
18668
  try {
18153
18669
  if (!this.shared) ensurePrivateDir2(root2);
18154
- await symlink2(dir2, join20(root2, this.runId), "junction");
18670
+ await symlink2(dir3, join21(root2, this.runId), "junction");
18155
18671
  } catch (err) {
18156
- this.ctx.output.warn(`Could not link ${dir2} into ${root2} (${err.message}): kenso runs will not list this run.`);
18672
+ this.ctx.output.warn(`Could not link ${dir3} into ${root2} (${err.message}): kenso runs will not list this run.`);
18157
18673
  }
18158
18674
  }
18159
- this.dir = dir2;
18675
+ this.dir = dir3;
18160
18676
  if (this.shared) {
18161
- this.tmpDir = join20(dir2, "tmp");
18677
+ this.tmpDir = join21(dir3, "tmp");
18162
18678
  ensureDir(this.tmpDir, JOB_DIR_MODE);
18163
18679
  }
18164
18680
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -18171,28 +18687,28 @@ var init_folder2 = __esm({
18171
18687
  status: "running",
18172
18688
  chunkCount: 0,
18173
18689
  chunksDone: [],
18174
- dir: dir2,
18690
+ dir: dir3,
18175
18691
  rows: 0,
18176
18692
  cwd: process.cwd(),
18177
18693
  pid: process.pid,
18178
18694
  updatedAt: now
18179
18695
  };
18180
18696
  await writeRunRecord(this.record);
18181
- return dir2;
18697
+ return dir3;
18182
18698
  }
18183
18699
  /**
18184
18700
  * A job's folder, jobs/<claimId> (a plain file name): private, or with --agent-user one the agent user's group
18185
18701
  * writes (3770) under a jobs folder it can only pass through (2750).
18186
18702
  */
18187
18703
  async jobDir(claimId) {
18188
- const dir2 = join20(await this.ensure(), "jobs", claimId);
18704
+ const dir3 = join21(await this.ensure(), "jobs", claimId);
18189
18705
  if (this.shared) {
18190
- ensureDir(dirname3(dir2), SHARED_DIR_MODE);
18191
- ensureDir(dir2, JOB_DIR_MODE);
18706
+ ensureDir(dirname3(dir3), SHARED_DIR_MODE);
18707
+ ensureDir(dir3, JOB_DIR_MODE);
18192
18708
  } else {
18193
- ensurePrivateDir2(dir2);
18709
+ ensurePrivateDir2(dir3);
18194
18710
  }
18195
- return dir2;
18711
+ return dir3;
18196
18712
  }
18197
18713
  /**
18198
18714
  * One line of results.ndjson, each string redacted: a failed job's detail is the agent's own stderr, which can hold
@@ -18201,13 +18717,13 @@ var init_folder2 = __esm({
18201
18717
  async append(line) {
18202
18718
  if (!this.dir) return;
18203
18719
  const json = JSON.stringify(line, (_key, value) => typeof value === "string" ? redact(value) : value);
18204
- await appendFile3(join20(this.dir, "results.ndjson"), `${json}
18720
+ await appendFile3(join21(this.dir, "results.ndjson"), `${json}
18205
18721
  `, { mode: 384 });
18206
18722
  }
18207
18723
  /** summary.json, and run.json with the final status, the claims (chunkCount) and the items (rows). */
18208
18724
  async finish(status, claims, items, summary) {
18209
18725
  if (!this.dir || !this.record) return;
18210
- await writeJsonAtomic(join20(this.dir, "summary.json"), summary);
18726
+ await writeJsonAtomic(join21(this.dir, "summary.json"), summary);
18211
18727
  this.record = { ...this.record, status, chunkCount: claims, rows: items, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
18212
18728
  await writeRunRecord(this.record);
18213
18729
  }
@@ -18220,7 +18736,7 @@ var pull_exports2 = {};
18220
18736
  __export(pull_exports2, {
18221
18737
  default: () => pull_default2
18222
18738
  });
18223
- var MAX_FILES, command63, pull_default2;
18739
+ var MAX_FILES, command64, pull_default2;
18224
18740
  var init_pull2 = __esm({
18225
18741
  "src/commands/work/pull.ts"() {
18226
18742
  "use strict";
@@ -18229,7 +18745,7 @@ var init_pull2 = __esm({
18229
18745
  init_common2();
18230
18746
  init_folder2();
18231
18747
  MAX_FILES = 100;
18232
- command63 = {
18748
+ command64 = {
18233
18749
  resource: "work",
18234
18750
  action: "pull",
18235
18751
  summary: "Claim waiting work into local work files, to answer by hand",
@@ -18308,14 +18824,14 @@ var init_pull2 = __esm({
18308
18824
  return interrupted7 ? ExitCode.Interrupted : ExitCode.Ok;
18309
18825
  }
18310
18826
  };
18311
- pull_default2 = command63;
18827
+ pull_default2 = command64;
18312
18828
  }
18313
18829
  });
18314
18830
 
18315
18831
  // src/commands/work/answers.ts
18316
18832
  import { randomUUID as randomUUID3 } from "node:crypto";
18317
18833
  import { existsSync as existsSync10 } from "node:fs";
18318
- import { basename as basename5, dirname as dirname4, join as join21 } from "node:path";
18834
+ import { basename as basename5, dirname as dirname4, join as join22 } from "node:path";
18319
18835
  function zeroTotals() {
18320
18836
  return { accepted: 0, rejected: 0, expired: 0, duplicate: 0, dropped: 0 };
18321
18837
  }
@@ -18387,7 +18903,7 @@ function droppedResult(d) {
18387
18903
  return { itemId: d.itemId ?? null, status: "dropped", reason: d.reason, message: `Answer ${d.index + 1} of the file was not sent: ${d.reason.replace(/_/g, " ")}.` };
18388
18904
  }
18389
18905
  async function writeResults(answersPath, claimId, results, totals) {
18390
- const path = join21(dirname4(answersPath), `${claimId}.results.json`);
18906
+ const path = join22(dirname4(answersPath), `${claimId}.results.json`);
18391
18907
  await writeJsonAtomic(path, { version: 1, claimId, submittedAt: (/* @__PURE__ */ new Date()).toISOString(), ...totals, results });
18392
18908
  return path;
18393
18909
  }
@@ -18416,7 +18932,7 @@ function workFileNextTo(answersPath) {
18416
18932
  hint: "Write the answers to <claimId>.answers.json next to its <claimId>.work.json, as the work file's rules say."
18417
18933
  });
18418
18934
  }
18419
- const workPath = join21(dirname4(answersPath), `${claimId}.work.json`);
18935
+ const workPath = join22(dirname4(answersPath), `${claimId}.work.json`);
18420
18936
  if (!existsSync10(workPath)) {
18421
18937
  throw usageError(`${workPath} is missing: kenso work submit reads it next to the answers file.`, { field: "answers-file" });
18422
18938
  }
@@ -18450,7 +18966,7 @@ __export(submit_exports, {
18450
18966
  default: () => submit_default
18451
18967
  });
18452
18968
  import { resolve as resolve16 } from "node:path";
18453
- var command64, submit_default;
18969
+ var command65, submit_default;
18454
18970
  var init_submit = __esm({
18455
18971
  "src/commands/work/submit.ts"() {
18456
18972
  "use strict";
@@ -18459,7 +18975,7 @@ var init_submit = __esm({
18459
18975
  init_files();
18460
18976
  init_answers();
18461
18977
  init_common2();
18462
- command64 = {
18978
+ command65 = {
18463
18979
  resource: "work",
18464
18980
  action: "submit",
18465
18981
  summary: "Send answers files to Kenso and write each one's results",
@@ -18492,7 +19008,7 @@ var init_submit = __esm({
18492
19008
  return totals.rejected > 0 ? ExitCode.Partial : ExitCode.Ok;
18493
19009
  }
18494
19010
  };
18495
- submit_default = command64;
19011
+ submit_default = command65;
18496
19012
  }
18497
19013
  });
18498
19014
 
@@ -18513,7 +19029,7 @@ function claimIdOf(arg) {
18513
19029
  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..." });
18514
19030
  return arg;
18515
19031
  }
18516
- var CLAIM_ID, command65, release_default;
19032
+ var CLAIM_ID, command66, release_default;
18517
19033
  var init_release = __esm({
18518
19034
  "src/commands/work/release.ts"() {
18519
19035
  "use strict";
@@ -18522,7 +19038,7 @@ var init_release = __esm({
18522
19038
  init_files();
18523
19039
  init_common2();
18524
19040
  CLAIM_ID = /^[A-Za-z0-9_-]{1,64}$/;
18525
- command65 = {
19041
+ command66 = {
18526
19042
  resource: "work",
18527
19043
  action: "release",
18528
19044
  summary: "Give claimed work back to the queue now",
@@ -18542,7 +19058,7 @@ var init_release = __esm({
18542
19058
  return ExitCode.Ok;
18543
19059
  }
18544
19060
  };
18545
- release_default = command65;
19061
+ release_default = command66;
18546
19062
  }
18547
19063
  });
18548
19064
 
@@ -18550,7 +19066,7 @@ var init_release = __esm({
18550
19066
  import { spawn as nodeSpawn3 } from "node:child_process";
18551
19067
  import { rmSync as rmSync3, statSync as statSync3 } from "node:fs";
18552
19068
  import { access, constants as constants2 } from "node:fs/promises";
18553
- import { delimiter as delimiter2, join as join22 } from "node:path";
19069
+ import { delimiter as delimiter2, join as join23 } from "node:path";
18554
19070
  import { setTimeout as delay12 } from "node:timers/promises";
18555
19071
  function childEnv(parent, adapter, extra) {
18556
19072
  const scrub = new Set(adapter.scrubEnv.map((name) => name.toUpperCase()));
@@ -18575,7 +19091,7 @@ async function isExecutableFile(path) {
18575
19091
  function pathDirs(env) {
18576
19092
  const key = Object.keys(env).find((name) => name.toUpperCase() === "PATH");
18577
19093
  const value = key ? env[key] : void 0;
18578
- return (value ?? "").split(delimiter2).filter((dir2) => dir2 !== "");
19094
+ return (value ?? "").split(delimiter2).filter((dir3) => dir3 !== "");
18579
19095
  }
18580
19096
  async function resolveBinary(adapter, env, override2) {
18581
19097
  const names = override2 !== void 0 && override2 !== "" ? [override2] : adapter.binaries;
@@ -18585,10 +19101,10 @@ async function resolveBinary(adapter, env, override2) {
18585
19101
  if (await isExecutableFile(name)) return name;
18586
19102
  continue;
18587
19103
  }
18588
- for (const dir2 of pathDirs(env)) {
19104
+ for (const dir3 of pathDirs(env)) {
18589
19105
  for (const ext of extensions) {
18590
- const candidate = join22(dir2, name + ext);
18591
- if (await isExecutableFile(candidate)) return candidate;
19106
+ const candidate2 = join23(dir3, name + ext);
19107
+ if (await isExecutableFile(candidate2)) return candidate2;
18592
19108
  }
18593
19109
  }
18594
19110
  }
@@ -18753,11 +19269,11 @@ async function runAgentJob(adapter, job, deps) {
18753
19269
  }
18754
19270
  let work;
18755
19271
  try {
18756
- work = readWorkFile(join22(job.cwd, job.workFile));
19272
+ work = readWorkFile(join23(job.cwd, job.workFile));
18757
19273
  } catch (err) {
18758
19274
  return result("fatal", null, `the work file could not be read: ${err.message}`);
18759
19275
  }
18760
- const answersPath = join22(job.cwd, job.answersFile);
19276
+ const answersPath = join23(job.cwd, job.answersFile);
18761
19277
  try {
18762
19278
  rmSync3(answersPath, { force: true });
18763
19279
  } catch (err) {
@@ -18881,12 +19397,12 @@ function plain(text4) {
18881
19397
  return text4.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
18882
19398
  }
18883
19399
  function runStatus(bin, args, env, adapter, runAs) {
18884
- const command70 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
19400
+ const command71 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
18885
19401
  const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
18886
19402
  const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
18887
19403
  return new Promise((resolve18) => {
18888
19404
  execFile2(
18889
- command70,
19405
+ command71,
18890
19406
  commandArgs2,
18891
19407
  { ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
18892
19408
  (err, stdout, stderr) => {
@@ -19167,7 +19683,7 @@ ${out.stderr}`;
19167
19683
  });
19168
19684
 
19169
19685
  // src/work/adapters/opencode.ts
19170
- import { basename as basename6, join as join23 } from "node:path";
19686
+ import { basename as basename6, join as join24 } from "node:path";
19171
19687
  var opencode;
19172
19688
  var init_opencode = __esm({
19173
19689
  "src/work/adapters/opencode.ts"() {
@@ -19211,7 +19727,7 @@ ${out.stderr}`);
19211
19727
  if (job.model) args.push("--model", job.model);
19212
19728
  args.push(job.instruction);
19213
19729
  const env = { OPENCODE_CONFIG_CONTENT: JSON.stringify(config) };
19214
- if (job.tmpDir !== void 0) env.OPENCODE_DB = join23(job.tmpDir, `opencode-${basename6(job.cwd)}.db`);
19730
+ if (job.tmpDir !== void 0) env.OPENCODE_DB = join24(job.tmpDir, `opencode-${basename6(job.cwd)}.db`);
19215
19731
  return { args, env };
19216
19732
  },
19217
19733
  classify: classifyByExit
@@ -19416,7 +19932,7 @@ var init_scan = __esm({
19416
19932
 
19417
19933
  // src/work/credentials.ts
19418
19934
  import { createHash as createHash10 } from "node:crypto";
19419
- import { join as join24 } from "node:path";
19935
+ import { join as join25 } from "node:path";
19420
19936
  function unreadable(why) {
19421
19937
  return new KensoError({
19422
19938
  code: "credentials_unreadable",
@@ -19504,7 +20020,7 @@ var init_credentials = __esm({
19504
20020
  }
19505
20021
  }
19506
20022
  async read(rel) {
19507
- const r = await sudoExec(this.user, CAT, [join24(this.user.home, rel)], { maxBuffer: MAX_CREDENTIAL_BYTES });
20023
+ const r = await sudoExec(this.user, CAT, [join25(this.user.home, rel)], { maxBuffer: MAX_CREDENTIAL_BYTES });
19508
20024
  if (r.exitCode !== 0) return /No such file or directory/.test(r.stderr) ? "missing" : "unreadable";
19509
20025
  const digest = createHash10("sha256").update(r.stdout).digest("hex");
19510
20026
  if (this.seen.get(rel) !== digest) {
@@ -19518,18 +20034,18 @@ var init_credentials = __esm({
19518
20034
  });
19519
20035
 
19520
20036
  // src/work/guide.ts
19521
- import { closeSync as closeSync3, fchmodSync as fchmodSync2, openSync as openSync3, writeFileSync as writeFileSync6 } from "node:fs";
19522
- import { join as join25 } from "node:path";
20037
+ import { closeSync as closeSync3, fchmodSync as fchmodSync2, openSync as openSync3, writeFileSync as writeFileSync7 } from "node:fs";
20038
+ import { join as join26 } from "node:path";
19523
20039
  function agentGuide(opts) {
19524
20040
  const browser = opts.browser ?? findOperation("browser-runs", "create") !== void 0;
19525
20041
  const parts2 = opts.kensoKey ? [JOB, KENSO, ...browser ? [BROWSER] : [], NEVER] : [JOB, NO_KENSO, NEVER];
19526
20042
  return parts2.join("\n");
19527
20043
  }
19528
- function writeAgentGuide(dir2, text4, mode = WORK_FILE_MODE) {
20044
+ function writeAgentGuide(dir3, text4, mode = WORK_FILE_MODE) {
19529
20045
  for (const name of GUIDE_FILES) {
19530
- const fd = openSync3(join25(dir2, name), "wx", mode);
20046
+ const fd = openSync3(join26(dir3, name), "wx", mode);
19531
20047
  try {
19532
- writeFileSync6(fd, text4, "utf8");
20048
+ writeFileSync7(fd, text4, "utf8");
19533
20049
  fchmodSync2(fd, mode);
19534
20050
  } finally {
19535
20051
  closeSync3(fd);
@@ -19968,7 +20484,7 @@ var run_exports3 = {};
19968
20484
  __export(run_exports3, {
19969
20485
  default: () => run_default2
19970
20486
  });
19971
- var FAILURES_IN_A_ROW, command66, run_default2;
20487
+ var FAILURES_IN_A_ROW, command67, run_default2;
19972
20488
  var init_run3 = __esm({
19973
20489
  "src/commands/work/run.ts"() {
19974
20490
  "use strict";
@@ -19989,7 +20505,7 @@ var init_run3 = __esm({
19989
20505
  init_folder2();
19990
20506
  init_stop();
19991
20507
  FAILURES_IN_A_ROW = 3;
19992
- command66 = {
20508
+ command67 = {
19993
20509
  resource: "work",
19994
20510
  action: "run",
19995
20511
  summary: "Run your own coding agent on the waiting work until the queue is empty",
@@ -20158,11 +20674,11 @@ var init_run3 = __esm({
20158
20674
  }
20159
20675
  try {
20160
20676
  workFileName(claim.id);
20161
- const dir2 = await folder.jobDir(claim.id);
20677
+ const dir3 = await folder.jobDir(claim.id);
20162
20678
  const work = workFileOf(claim);
20163
- writeWorkFile(dir2, work, runAs ? WORK_FILE_MODE : void 0);
20164
- if (tools) writeAgentGuide(dir2, tools.guide);
20165
- return { claim, work, dir: dir2 };
20679
+ writeWorkFile(dir3, work, runAs ? WORK_FILE_MODE : void 0);
20680
+ if (tools) writeAgentGuide(dir3, tools.guide);
20681
+ return { claim, work, dir: dir3 };
20166
20682
  } catch (err) {
20167
20683
  await releaseOnce(claim.id);
20168
20684
  error = err instanceof KensoError ? err : new KensoError({ code: "work_file_failed", message: `Could not write the work file: ${err.message}`, exitCode: ExitCode.Error });
@@ -20315,7 +20831,7 @@ var init_run3 = __esm({
20315
20831
  return exitCodeFor(reason, totals.rejected > 0 || jobsFailed > 0);
20316
20832
  }
20317
20833
  };
20318
- run_default2 = command66;
20834
+ run_default2 = command67;
20319
20835
  }
20320
20836
  });
20321
20837
 
@@ -20380,20 +20896,20 @@ __export(keys_exports, {
20380
20896
  function usage(message, field) {
20381
20897
  return new KensoError({ code: "usage_error", message, exitCode: ExitCode.Usage, field });
20382
20898
  }
20383
- function rewrap(err, overrides) {
20899
+ function rewrap(err, overrides2) {
20384
20900
  return new KensoError({
20385
20901
  code: err.code,
20386
- message: overrides.message ?? err.message,
20902
+ message: overrides2.message ?? err.message,
20387
20903
  exitCode: err.exitCode,
20388
20904
  httpStatus: err.httpStatus,
20389
20905
  field: err.field,
20390
20906
  hint: err.hint,
20391
- next: overrides.next ?? err.next,
20907
+ next: overrides2.next ?? err.next,
20392
20908
  requestId: err.requestId,
20393
20909
  details: err.details
20394
20910
  });
20395
20911
  }
20396
- var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command67, keys_default;
20912
+ var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command68, keys_default;
20397
20913
  var init_keys = __esm({
20398
20914
  "src/commands/workspace/keys.ts"() {
20399
20915
  "use strict";
@@ -20403,7 +20919,7 @@ var init_keys = __esm({
20403
20919
  TEMPLATES = ["admin", "editor", "viewer"];
20404
20920
  APP_NEXT_STEP = "A workspace admin can create it in the app: Settings > API keys > Workspace keys";
20405
20921
  NOT_AVAILABLE = "Workspace keys are not available for this workspace yet.";
20406
- command67 = {
20922
+ command68 = {
20407
20923
  resource: "workspace",
20408
20924
  action: "keys",
20409
20925
  summary: "Create an API key the workspace owns",
@@ -20465,7 +20981,7 @@ var init_keys = __esm({
20465
20981
  return ExitCode.Ok;
20466
20982
  }
20467
20983
  };
20468
- keys_default = command67;
20984
+ keys_default = command68;
20469
20985
  }
20470
20986
  });
20471
20987
 
@@ -20474,23 +20990,23 @@ var list_exports4 = {};
20474
20990
  __export(list_exports4, {
20475
20991
  default: () => list_default4
20476
20992
  });
20477
- function parseLimit(value) {
20993
+ function parseLimit2(value) {
20478
20994
  if (value === void 0) return void 0;
20479
20995
  const text4 = String(value).trim();
20480
20996
  const limit = Number(text4);
20481
- if (!/^\d+$/.test(text4) || limit < 1 || limit > MAX_LIMIT) {
20482
- throw usageError(`--limit must be a whole number from 1 to ${MAX_LIMIT}.`, { field: "limit" });
20997
+ if (!/^\d+$/.test(text4) || limit < 1 || limit > MAX_LIMIT2) {
20998
+ throw usageError(`--limit must be a whole number from 1 to ${MAX_LIMIT2}.`, { field: "limit" });
20483
20999
  }
20484
21000
  return limit;
20485
21001
  }
20486
- var MAX_LIMIT, command68, list_default4;
21002
+ var MAX_LIMIT2, command69, list_default4;
20487
21003
  var init_list4 = __esm({
20488
21004
  "src/commands/workspace/list.ts"() {
20489
21005
  "use strict";
20490
21006
  init_errors();
20491
21007
  init_exit_codes();
20492
- MAX_LIMIT = 200;
20493
- command68 = {
21008
+ MAX_LIMIT2 = 200;
21009
+ command69 = {
20494
21010
  resource: "workspace",
20495
21011
  action: "list",
20496
21012
  summary: "List the workspaces your key can use",
@@ -20498,17 +21014,17 @@ var init_list4 = __esm({
20498
21014
  description: "Calls GET /v1/workspaces. Kenso staff are members of many workspaces, so filter by name with --search. Without --all it prints one page and says on stderr when there are more.",
20499
21015
  flags: {
20500
21016
  search: { type: "string", description: "Only workspaces whose name matches this text", aliases: ["q"] },
20501
- limit: { type: "string", description: `Page size, 1 to ${MAX_LIMIT} (default 50)` },
21017
+ limit: { type: "string", description: `Page size, 1 to ${MAX_LIMIT2} (default 50)` },
20502
21018
  all: { type: "boolean", description: "Follow every page" }
20503
21019
  },
20504
21020
  examples: ["kenso workspace list --search acme", "kenso workspace list --all --output ids"],
20505
21021
  operationIds: ["workspaces.list"],
20506
21022
  async run(ctx, { flags }) {
20507
21023
  const q = typeof flags.search === "string" && flags.search.trim() !== "" ? flags.search.trim() : void 0;
20508
- const limit = parseLimit(flags.limit);
21024
+ const limit = parseLimit2(flags.limit);
20509
21025
  const req = { method: "GET", path: "/v1/workspaces", query: { q }, noWorkspace: true, signal: ctx.signal };
20510
21026
  if (flags.all === true) {
20511
- await ctx.output.list(ctx.client.paginate(req, { pageSize: limit ?? MAX_LIMIT }));
21027
+ await ctx.output.list(ctx.client.paginate(req, { pageSize: limit ?? MAX_LIMIT2 }));
20512
21028
  return ExitCode.Ok;
20513
21029
  }
20514
21030
  const res = await ctx.client.request({ ...req, query: { q, limit } });
@@ -20519,7 +21035,7 @@ var init_list4 = __esm({
20519
21035
  return ExitCode.Ok;
20520
21036
  }
20521
21037
  };
20522
- list_default4 = command68;
21038
+ list_default4 = command69;
20523
21039
  }
20524
21040
  });
20525
21041
 
@@ -20528,7 +21044,7 @@ var use_exports = {};
20528
21044
  __export(use_exports, {
20529
21045
  default: () => use_default
20530
21046
  });
20531
- var command69, use_default;
21047
+ var command70, use_default;
20532
21048
  var init_use = __esm({
20533
21049
  "src/commands/workspace/use.ts"() {
20534
21050
  "use strict";
@@ -20536,7 +21052,7 @@ var init_use = __esm({
20536
21052
  init_errors();
20537
21053
  init_exit_codes();
20538
21054
  init_http();
20539
- command69 = {
21055
+ command70 = {
20540
21056
  resource: "workspace",
20541
21057
  action: "use",
20542
21058
  summary: "Set the profile's default workspace",
@@ -20594,7 +21110,7 @@ var init_use = __esm({
20594
21110
  return ExitCode.Ok;
20595
21111
  }
20596
21112
  };
20597
- use_default = command69;
21113
+ use_default = command70;
20598
21114
  }
20599
21115
  });
20600
21116
 
@@ -20635,7 +21151,7 @@ var init_registry = __esm({
20635
21151
  init_credits();
20636
21152
  init_dashboards();
20637
21153
  init_describe2();
20638
- init_discover();
21154
+ init_discover2();
20639
21155
  init_docs2();
20640
21156
  init_doctor();
20641
21157
  init_export3();
@@ -20911,8 +21427,10 @@ async function renderResourceHelp(resource, opts) {
20911
21427
  });
20912
21428
  }
20913
21429
  const rows = [
20914
- ...specs.map((s) => [usageLine2(s).slice(`kenso ${resource} `.length).replace(/ ?\[flags\]$/, ""), `${s.summary}${s.beta ? " (beta)" : ""}`]),
20915
- ...generated.map((g) => [g.action, `${g.summary}${g.beta ? " (beta)" : ""}`])
21430
+ ...specs.map(
21431
+ (s) => [usageLine2(s).slice(`kenso ${resource} `.length).replace(/ ?\[flags\]$/, ""), `${s.summary}${s.beta ? " (beta)" : ""}${effectMark(s.effect)}`]
21432
+ ),
21433
+ ...generated.map((g) => [g.action, `${g.summary}${g.beta ? " (beta)" : ""}${effectMark(g.effect)}`])
20916
21434
  ].sort(([a], [b]) => a.localeCompare(b));
20917
21435
  const lines = [`Usage: kenso ${resource} <action> [flags]`, "", "Actions:", columns(rows)];
20918
21436
  const hiddenActions = [
@@ -20927,7 +21445,7 @@ async function renderResourceHelp(resource, opts) {
20927
21445
  return withAgentBlock(lines.join("\n"), opts.agent);
20928
21446
  }
20929
21447
  function renderCommandHelp(spec, opts) {
20930
- const lines = [`Usage: ${usageLine2(spec)}`, "", `${spec.summary}${spec.beta ? " (beta)" : ""}`];
21448
+ const lines = [`Usage: ${usageLine2(spec)}`, "", `${spec.summary}${spec.beta ? " (beta)" : ""}`, ...effectAndCost(spec, opts.rateCards)];
20931
21449
  if (spec.description) lines.push("", spec.description);
20932
21450
  if (spec.positionals && spec.positionals.length > 0) {
20933
21451
  lines.push("", "Arguments:", columns(spec.positionals.map((p) => [`<${p.name}>${p.variadic ? "..." : ""}`, `${p.description}${p.required ? "" : " (optional)"}`])));
@@ -20948,33 +21466,40 @@ function renderCommandHelp(spec, opts) {
20948
21466
  if (spec.examples.length > 0) lines.push("", "Examples:", ...spec.examples.map((e) => ` ${e}`));
20949
21467
  return withAgentBlock(lines.join("\n"), opts.agent);
20950
21468
  }
20951
- var GLOBAL_FLAG_HELP, GLOBAL_FLAGS_LINE, GLOBAL_FLAGS_LINE_NO_DRY_RUN, COMMON_RESOURCES, EXIT_CODES, FOR_AGENTS;
21469
+ var FORMATS_PIPED, FORMATS_WORDS, GLOBAL_FLAG_HELP, GLOBAL_FLAGS_TAIL, GLOBAL_FLAGS_LINE, GLOBAL_FLAGS_LINE_NO_DRY_RUN, COMMON_RESOURCES, EXIT_CODES, FOR_AGENTS;
20952
21470
  var init_help = __esm({
20953
21471
  "src/commands/help.ts"() {
20954
21472
  "use strict";
20955
21473
  init_errors();
20956
21474
  init_exit_codes();
20957
21475
  init_features();
21476
+ init_output();
20958
21477
  init_version();
20959
21478
  init_generated_hook();
21479
+ init_help_effect();
20960
21480
  init_registry();
21481
+ FORMATS_PIPED = OUTPUT_FORMATS.join("|");
21482
+ FORMATS_WORDS = `${OUTPUT_FORMATS.slice(0, -1).join(", ")} or ${OUTPUT_FORMATS[OUTPUT_FORMATS.length - 1]}`;
20961
21483
  GLOBAL_FLAG_HELP = [
20962
21484
  ["--profile <name>", "Use a saved profile (or KENSO_PROFILE)"],
20963
21485
  ["--workspace <id>", "Workspace for this command (or KENSO_WORKSPACE_ID)"],
20964
- ["-o, --output <format>", "json, ndjson, table or ids (default: table on a terminal, JSON when piped)"],
21486
+ ["-o, --output <format>", `${FORMATS_WORDS} (default: table on a terminal, JSON when piped)`],
20965
21487
  ["--json", "Same as -o json"],
20966
21488
  ["--fields <a,b.c>", "Keep only these fields"],
20967
21489
  ["--query <JMESPath>", "Filter or reshape the output in-process"],
20968
21490
  ["-v, --verbose", "Print each request to stderr (keys redacted)"],
20969
21491
  ["-y, --yes", "Apply a write; a delete, archive or remove needs it"],
20970
21492
  ["--dry-run", "Show what a write would do and change nothing"],
21493
+ ["--read-only", "Refuse every command that is not a read (or KENSO_READ_ONLY=1)"],
20971
21494
  ["--progress", "Print progress to stderr even when it is not a terminal"],
20972
21495
  ["--all-commands", "Show beta commands in help"],
20973
21496
  ["-h, --help", "Show help"],
20974
21497
  ["--version", "Print the CLI version (only on its own: kenso --version)"]
20975
21498
  ];
20976
- GLOBAL_FLAGS_LINE = "Global flags: --dry-run, -y/--yes, --profile <name>, --workspace <id>, -o json|ndjson|table|ids, --json, --fields, --query, -v.";
20977
- GLOBAL_FLAGS_LINE_NO_DRY_RUN = "Global flags: -y/--yes, --profile <name>, --workspace <id>, -o json|ndjson|table|ids, --json, --fields, --query, -v.\nNo --dry-run: this command runs for real, so --dry-run is refused.";
21499
+ GLOBAL_FLAGS_TAIL = `--read-only, --profile <name>, --workspace <id>, -o ${FORMATS_PIPED}, --json, --fields, --query, -v.`;
21500
+ GLOBAL_FLAGS_LINE = `Global flags: --dry-run, -y/--yes, ${GLOBAL_FLAGS_TAIL}`;
21501
+ GLOBAL_FLAGS_LINE_NO_DRY_RUN = `Global flags: -y/--yes, ${GLOBAL_FLAGS_TAIL}
21502
+ No --dry-run: this command runs for real, so --dry-run is refused.`;
20978
21503
  COMMON_RESOURCES = [
20979
21504
  "accounts",
20980
21505
  "analytics",
@@ -21040,13 +21565,13 @@ function distance(a, b) {
21040
21565
  }
21041
21566
  return previous[b.length];
21042
21567
  }
21043
- function closest(typed, candidates) {
21568
+ function closest(typed, candidates2) {
21044
21569
  let best;
21045
21570
  let bestDistance = Number.POSITIVE_INFINITY;
21046
- for (const candidate of candidates) {
21047
- const d = distance(typed, candidate);
21571
+ for (const candidate2 of candidates2) {
21572
+ const d = distance(typed, candidate2);
21048
21573
  if (d < bestDistance) {
21049
- best = candidate;
21574
+ best = candidate2;
21050
21575
  bestDistance = d;
21051
21576
  }
21052
21577
  }
@@ -21071,9 +21596,39 @@ function applyAliases(argv, spec) {
21071
21596
  }
21072
21597
  return out;
21073
21598
  }
21599
+ function normalizeBooleans(argv, names, strict) {
21600
+ const out = [];
21601
+ for (let i = 0; i < argv.length; i++) {
21602
+ const arg = argv[i];
21603
+ if (arg === "--") {
21604
+ out.push(...argv.slice(i));
21605
+ break;
21606
+ }
21607
+ const match = /^--([^=]+)=([\s\S]*)$/.exec(arg);
21608
+ if (!match || !names.has(match[1])) {
21609
+ out.push(arg);
21610
+ continue;
21611
+ }
21612
+ const [, name, value] = match;
21613
+ if (value === "true") out.push(`--${name}`);
21614
+ else if (value === "false") out.push(`--no-${name}`);
21615
+ else if (strict) {
21616
+ throw new KensoError({
21617
+ code: "invalid_flag_value",
21618
+ message: `--${name} takes true or false (got "${value}"). Use --${name}, --no-${name}, --${name}=true or --${name}=false.`,
21619
+ exitCode: ExitCode.Usage,
21620
+ field: name,
21621
+ next: `${strict.command} --help`
21622
+ });
21623
+ } else out.push(arg);
21624
+ }
21625
+ return out;
21626
+ }
21074
21627
  var init_flag_names = __esm({
21075
21628
  "src/core/flag-names.ts"() {
21076
21629
  "use strict";
21630
+ init_errors();
21631
+ init_exit_codes();
21077
21632
  }
21078
21633
  });
21079
21634
 
@@ -21096,23 +21651,67 @@ var init_invoked = __esm({
21096
21651
  });
21097
21652
 
21098
21653
  // src/core/pre-run.ts
21099
- async function beforeRun(_ctx, _spec, _args) {
21654
+ function readOnlySource(ctx) {
21655
+ const value = (ctx.env.KENSO_READ_ONLY ?? "").trim().toLowerCase();
21656
+ if (value !== "" && value !== "0" && value !== "false") return "env";
21657
+ return ctx.flags.readOnly === true ? "flag" : void 0;
21658
+ }
21659
+ function effectOf2(spec, args) {
21660
+ return spec.effectFor?.(args) ?? spec.effect ?? "write";
21661
+ }
21662
+ function shellQuote6(value) {
21663
+ return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
21664
+ }
21665
+ function readOnlyError(spec, effect, source, argv) {
21666
+ const name = spec.action ? `kenso ${spec.resource} ${spec.action}` : `kenso ${spec.resource}`;
21667
+ const message = `${name} is a ${effect} command, and this session is read-only.`;
21668
+ if (source === "env") {
21669
+ return new KensoError({ code: "read_only", message, exitCode: ExitCode.Usage, hint: "KENSO_READ_ONLY is set: unset it to run this command." });
21670
+ }
21671
+ if (spec.flags["body-read-only"]) {
21672
+ const hint = "Read-only is on through --read-only, the global flag. This command's own read-only option is --body-read-only.";
21673
+ return new KensoError({ code: "read_only", message, exitCode: ExitCode.Usage, hint });
21674
+ }
21675
+ const end = argv?.indexOf("--") ?? -1;
21676
+ const head = (end === -1 ? argv : argv?.slice(0, end)) ?? [];
21677
+ if (spec.dryRun !== true || !argv || head.some((token) => /^-[A-Za-z]{2,}$/.test(token) && token.includes("y"))) {
21678
+ return new KensoError({ code: "read_only", message, exitCode: ExitCode.Usage, hint: "Read-only is on through --read-only: run the command again without --read-only to make the change." });
21679
+ }
21680
+ const kept = head.filter((token) => token !== "--yes" && token !== "-y" && !token.startsWith("--yes="));
21681
+ const withDryRun = [...kept, "--dry-run", ...end === -1 ? [] : argv.slice(end)];
21682
+ return new KensoError({
21683
+ code: "read_only",
21684
+ message,
21685
+ exitCode: ExitCode.Usage,
21686
+ hint: "Read-only is on through --read-only: next prints the plan. Run the command again without --read-only to make the change.",
21687
+ next: ["kenso", ...withDryRun.map(shellQuote6)].join(" ")
21688
+ });
21689
+ }
21690
+ async function beforeRun(ctx, spec, args, argv) {
21691
+ const source = readOnlySource(ctx);
21692
+ if (!source) return;
21693
+ const effect = effectOf2(spec, args);
21694
+ if (effect === "read") return;
21695
+ if (ctx.flags.dryRun === true && spec.dryRun === true) return;
21696
+ throw readOnlyError(spec, effect, source, argv);
21100
21697
  }
21101
21698
  var init_pre_run = __esm({
21102
21699
  "src/core/pre-run.ts"() {
21103
21700
  "use strict";
21701
+ init_errors();
21702
+ init_exit_codes();
21104
21703
  }
21105
21704
  });
21106
21705
 
21107
21706
  // src/core/update-notice.ts
21108
- import { mkdirSync as mkdirSync5, readFileSync as readFileSync13, realpathSync as realpathSync2, renameSync as renameSync4, writeFileSync as writeFileSync7 } from "node:fs";
21109
- import { dirname as dirname5, join as join26, sep as sep3 } from "node:path";
21707
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync15, realpathSync as realpathSync2, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "node:fs";
21708
+ import { dirname as dirname5, join as join27, sep as sep3 } from "node:path";
21110
21709
  function installKind(script = process.argv[1], execPath = process.execPath, platform = process.platform) {
21111
21710
  try {
21112
21711
  if (!script) return "npm";
21113
21712
  const bundle = realpathSync2(script);
21114
21713
  const lib = dirname5(dirname5(dirname5(bundle)));
21115
- if (execPath !== join26(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
21714
+ if (execPath !== join27(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
21116
21715
  return bundle.includes(`${sep3}Cellar${sep3}kenso${sep3}`) ? "homebrew" : "standalone";
21117
21716
  } catch {
21118
21717
  return "npm";
@@ -21125,7 +21724,7 @@ function updateCommand(install, platform) {
21125
21724
  }
21126
21725
  function readCheck(file) {
21127
21726
  try {
21128
- const parsed2 = JSON.parse(readFileSync13(file, "utf8"));
21727
+ const parsed2 = JSON.parse(readFileSync15(file, "utf8"));
21129
21728
  if (typeof parsed2?.checkedAt !== "string") return void 0;
21130
21729
  return { checkedAt: parsed2.checkedAt, ...typeof parsed2.latest === "string" ? { latest: parsed2.latest } : {} };
21131
21730
  } catch {
@@ -21136,9 +21735,9 @@ function writeCheck(file, check) {
21136
21735
  try {
21137
21736
  mkdirSync5(dirname5(file), { recursive: true, mode: 448 });
21138
21737
  const temp = `${file}.${process.pid}.tmp`;
21139
- writeFileSync7(temp, `${JSON.stringify(check)}
21738
+ writeFileSync8(temp, `${JSON.stringify(check)}
21140
21739
  `, { mode: 384 });
21141
- renameSync4(temp, file);
21740
+ renameSync5(temp, file);
21142
21741
  } catch {
21143
21742
  }
21144
21743
  }
@@ -21172,7 +21771,7 @@ function startUpdateNotice(argv, opts = {}) {
21172
21771
  const stderr = opts.stderr ?? process.stderr;
21173
21772
  const wanted = (opts.stderrIsTTY ?? process.stderr.isTTY === true) && detectAgent(env) === null && env.CI === void 0 && !env.KENSO_NO_UPDATE_NOTIFIER && RELEASE.test(version) && !argv.some((word) => QUIET_COMMANDS.has(word));
21174
21773
  if (!wanted) return done;
21175
- const file = join26(configDir(env), UPDATE_CHECK_FILE);
21774
+ const file = join27(configDir(env), UPDATE_CHECK_FILE);
21176
21775
  const now = (opts.now ?? Date.now)();
21177
21776
  const cached = readCheck(file);
21178
21777
  const checkedAt = Date.parse(cached?.checkedAt ?? "");
@@ -21191,8 +21790,8 @@ function startUpdateNotice(argv, opts = {}) {
21191
21790
  if (!found) return;
21192
21791
  writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
21193
21792
  if (isNewer(found, version)) {
21194
- const command70 = updateCommand(install, opts.platform ?? process.platform);
21195
- stderr.write(`kenso ${found} is out (you have ${version}): ${command70}
21793
+ const command71 = updateCommand(install, opts.platform ?? process.platform);
21794
+ stderr.write(`kenso ${found} is out (you have ${version}): ${command71}
21196
21795
  Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
21197
21796
  `);
21198
21797
  }
@@ -21253,15 +21852,15 @@ function flagsOf2(spec, globals, commandless) {
21253
21852
  const global = Object.keys(globals).filter((name) => commandless || name !== "version" && (name !== "dry-run" || spec?.dryRun === true));
21254
21853
  return sorted([...Object.keys(spec?.flags ?? {}), ...global].map((name) => `--${name}`));
21255
21854
  }
21256
- async function completions(words, globals) {
21257
- const current = words.at(-1) ?? "";
21855
+ async function completions(words2, globals) {
21856
+ const current = words2.at(-1) ?? "";
21258
21857
  const positionals = [];
21259
21858
  let spec;
21260
21859
  let commandWords2 = 0;
21261
21860
  let valueFor;
21262
21861
  let afterDashes = false;
21263
21862
  let help = false;
21264
- for (const word of words.slice(0, -1)) {
21863
+ for (const word of words2.slice(0, -1)) {
21265
21864
  if (valueFor !== void 0) {
21266
21865
  valueFor = void 0;
21267
21866
  continue;
@@ -21307,14 +21906,14 @@ async function completions(words, globals) {
21307
21906
  }
21308
21907
  return flagsOf2(spec, globals, false);
21309
21908
  }
21310
- async function printCompletions(words, globals, stdout) {
21311
- let candidates;
21909
+ async function printCompletions(words2, globals, stdout) {
21910
+ let candidates2;
21312
21911
  try {
21313
- candidates = await completions(words, globals);
21912
+ candidates2 = await completions(words2, globals);
21314
21913
  } catch {
21315
- candidates = [];
21914
+ candidates2 = [];
21316
21915
  }
21317
- if (candidates.length > 0) stdout.write(`${candidates.join("\n")}
21916
+ if (candidates2.length > 0) stdout.write(`${candidates2.join("\n")}
21318
21917
  `);
21319
21918
  return ExitCode.Ok;
21320
21919
  }
@@ -21362,34 +21961,6 @@ function leaveRun(active) {
21362
21961
  graceTimer = void 0;
21363
21962
  }
21364
21963
  }
21365
- function normalizeBooleans(argv, names, strict) {
21366
- const out = [];
21367
- for (let i = 0; i < argv.length; i++) {
21368
- const arg = argv[i];
21369
- if (arg === "--") {
21370
- out.push(...argv.slice(i));
21371
- break;
21372
- }
21373
- const match = /^--([^=]+)=([\s\S]*)$/.exec(arg);
21374
- if (!match || !names.has(match[1])) {
21375
- out.push(arg);
21376
- continue;
21377
- }
21378
- const [, name, value] = match;
21379
- if (value === "true") out.push(`--${name}`);
21380
- else if (value === "false") out.push(`--no-${name}`);
21381
- else if (strict) {
21382
- throw new KensoError({
21383
- code: "invalid_flag_value",
21384
- message: `--${name} takes true or false (got "${value}"). Use --${name}, --no-${name}, --${name}=true or --${name}=false.`,
21385
- exitCode: ExitCode.Usage,
21386
- field: name,
21387
- next: `${strict.command} --help`
21388
- });
21389
- } else out.push(arg);
21390
- }
21391
- return out;
21392
- }
21393
21964
  async function knownCommands() {
21394
21965
  const commands = /* @__PURE__ */ new Set();
21395
21966
  for (const [resource, area] of Object.entries(handWritten)) {
@@ -21504,6 +22075,7 @@ function globalFlags(values) {
21504
22075
  verbose: values.verbose === true,
21505
22076
  yes: values.yes === true,
21506
22077
  dryRun: values["dry-run"] === true,
22078
+ readOnly: values["read-only"] === true,
21507
22079
  progress: values.progress === true,
21508
22080
  allCommands: values["all-commands"] === true
21509
22081
  };
@@ -21544,11 +22116,11 @@ function commandArgs(spec, parsed2, tokens) {
21544
22116
  }
21545
22117
  return { flags, positionals };
21546
22118
  }
21547
- async function main(argv, env = process.env, overrides = {}) {
21548
- const stdout = overrides.stdout ?? process.stdout;
22119
+ async function main(argv, env = process.env, overrides2 = {}) {
22120
+ const stdout = overrides2.stdout ?? process.stdout;
21549
22121
  guardClosedPipe(stdout);
21550
22122
  if (argv[0] === "__complete") return (await Promise.resolve().then(() => (init_complete(), complete_exports))).printCompletions(argv.slice(1), GLOBAL_OPTIONS, stdout);
21551
- let output = new Output({ stdout: overrides.stdout, stderr: overrides.stderr, stdoutIsTTY: overrides.stdoutIsTTY, stderrIsTTY: overrides.stderrIsTTY });
22123
+ let output = new Output({ stdout: overrides2.stdout, stderr: overrides2.stderr, stdoutIsTTY: overrides2.stdoutIsTTY, stderrIsTTY: overrides2.stderrIsTTY });
21552
22124
  const agent = detectAgent(env);
21553
22125
  const controller = new AbortController();
21554
22126
  const active = { controller, info: (message) => output.info(message) };
@@ -21563,12 +22135,14 @@ async function main(argv, env = process.env, overrides = {}) {
21563
22135
  }
21564
22136
  verbose = loose.values.verbose === true;
21565
22137
  const text4 = (value) => typeof value === "string" ? value : void 0;
22138
+ const lookupFlags = { profile: text4(loose.values.profile), workspace: text4(loose.values.workspace) };
22139
+ const lookupOverrides = { fetchImpl: overrides2.fetchImpl, sleep: overrides2.sleep, signal: controller.signal };
21566
22140
  const helpOptions = {
21567
22141
  agent,
21568
22142
  allCommands: loose.values["all-commands"] === true,
21569
22143
  env,
21570
- // Cached features, else GET /v1/me with a 1,500 ms timeout, with main's env, flags and test overrides.
21571
- loadFeatures: () => featuresFromEnv(env, { profile: text4(loose.values.profile), workspace: text4(loose.values.workspace) }, { fetchImpl: overrides.fetchImpl, sleep: overrides.sleep, signal: controller.signal }),
22144
+ // Cached features, else GET /v1/me with a 1,500 ms timeout.
22145
+ loadFeatures: () => featuresFromEnv(env, lookupFlags, lookupOverrides),
21572
22146
  warn: (message) => {
21573
22147
  lookupFailed = true;
21574
22148
  output.info(message);
@@ -21607,17 +22181,19 @@ async function main(argv, env = process.env, overrides = {}) {
21607
22181
  commandTokens = [resourceToken, actionToken];
21608
22182
  }
21609
22183
  if (wantHelp) {
21610
- stdout.write(renderCommandHelp(spec, helpOptions));
22184
+ const rateCards = spec.cost?.length ? await rateCardsForHelp(env, lookupFlags, lookupOverrides) : void 0;
22185
+ if (rateCards?.[0]?.source === "bundled") lookupFailed = true;
22186
+ stdout.write(renderCommandHelp(spec, { ...helpOptions, rateCards }));
21611
22187
  return ExitCode.Ok;
21612
22188
  }
21613
22189
  const parsed2 = strictParse(argv, spec);
21614
22190
  const flags = globalFlags(parsed2.values);
21615
22191
  if (flags.dryRun && spec.dryRun !== true) throw noDryRun(spec);
21616
22192
  const args = commandArgs(spec, parsed2, commandTokens);
21617
- const ctx = createContext(flags, env, { ...overrides, signal: controller.signal, noConfig: spec.ownCredential?.(args.flags) === true });
22193
+ const ctx = createContext(flags, env, { ...overrides2, signal: controller.signal, noConfig: spec.ownCredential?.(args.flags) === true });
21618
22194
  output = ctx.output;
21619
22195
  active.graceMs = spec.interruptGraceMs;
21620
- await beforeRun(ctx, spec, args);
22196
+ await beforeRun(ctx, spec, args, argv);
21621
22197
  enterRun(active);
21622
22198
  try {
21623
22199
  const code = await spec.run(ctx, args);
@@ -21659,6 +22235,7 @@ var init_main = __esm({
21659
22235
  init_invoked();
21660
22236
  init_output();
21661
22237
  init_pre_run();
22238
+ init_rate_card();
21662
22239
  init_redact();
21663
22240
  init_update_notice();
21664
22241
  init_version();
@@ -21672,6 +22249,7 @@ var init_main = __esm({
21672
22249
  verbose: { type: "boolean", short: "v" },
21673
22250
  yes: { type: "boolean", short: "y" },
21674
22251
  "dry-run": { type: "boolean" },
22252
+ "read-only": { type: "boolean" },
21675
22253
  progress: { type: "boolean" },
21676
22254
  "all-commands": { type: "boolean" },
21677
22255
  help: { type: "boolean", short: "h" },