kenso 0.1.43 → 0.1.45

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
@@ -1292,7 +1292,7 @@ var require_jmespath = __commonJS({
1292
1292
  }
1293
1293
  },
1294
1294
  _parseSliceExpression: function() {
1295
- var parts = [null, null, null];
1295
+ var parts2 = [null, null, null];
1296
1296
  var index = 0;
1297
1297
  var currentToken = this._lookahead(0);
1298
1298
  while (currentToken !== TOK_RBRACKET && index < 3) {
@@ -1300,7 +1300,7 @@ var require_jmespath = __commonJS({
1300
1300
  index++;
1301
1301
  this._advance();
1302
1302
  } else if (currentToken === TOK_NUMBER) {
1303
- parts[index] = this._lookaheadToken(0).value;
1303
+ parts2[index] = this._lookaheadToken(0).value;
1304
1304
  this._advance();
1305
1305
  } else {
1306
1306
  var t = this._lookahead(0);
@@ -1313,7 +1313,7 @@ var require_jmespath = __commonJS({
1313
1313
  this._match(TOK_RBRACKET);
1314
1314
  return {
1315
1315
  type: "Slice",
1316
- children: parts
1316
+ children: parts2
1317
1317
  };
1318
1318
  },
1319
1319
  _parseComparator: function(left, comparator) {
@@ -2413,7 +2413,7 @@ var VERSION;
2413
2413
  var init_version = __esm({
2414
2414
  "src/core/version.ts"() {
2415
2415
  "use strict";
2416
- VERSION = true ? "0.1.43" : "0.0.0-dev";
2416
+ VERSION = true ? "0.1.45" : "0.0.0-dev";
2417
2417
  }
2418
2418
  });
2419
2419
 
@@ -3639,9 +3639,9 @@ async function readRunDir(dir) {
3639
3639
  return null;
3640
3640
  }
3641
3641
  if (!raw) return null;
3642
- const { runId, command: command35, createdAt, status } = raw;
3642
+ const { runId, command: command36, createdAt, status } = raw;
3643
3643
  if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
3644
- if (typeof command35 !== "string" || typeof createdAt !== "string") return null;
3644
+ if (typeof command36 !== "string" || typeof createdAt !== "string") return null;
3645
3645
  if (typeof status !== "string" || !STATUSES.includes(status)) return null;
3646
3646
  let chunksDone = chunkList(raw.chunksDone) ?? [];
3647
3647
  try {
@@ -3652,7 +3652,7 @@ async function readRunDir(dir) {
3652
3652
  const record = {
3653
3653
  ...raw,
3654
3654
  runId,
3655
- command: command35,
3655
+ command: command36,
3656
3656
  args: asRecord3(raw.args) ?? {},
3657
3657
  createdAt,
3658
3658
  status,
@@ -3707,11 +3707,11 @@ async function loadRun(runId, env = process.env) {
3707
3707
  }
3708
3708
  return run;
3709
3709
  }
3710
- async function findIdentical(command35, args, inputSha256, env, workspaceId, anyWorkspace = false) {
3710
+ async function findIdentical(command36, args, inputSha256, env, workspaceId, anyWorkspace = false) {
3711
3711
  const identity = argsIdentity(args);
3712
3712
  const runs = await listRuns(env);
3713
3713
  return runs.filter(
3714
- (run) => run.command === command35 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
3714
+ (run) => run.command === command36 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
3715
3715
  );
3716
3716
  }
3717
3717
  function isOtherLiveProcess(pid) {
@@ -3846,13 +3846,13 @@ async function dryRun(spec, ctx, plan) {
3846
3846
  };
3847
3847
  await writeJsonAtomic(files.planJson, planBody);
3848
3848
  if (plan.invalid.length > 0) await writeFileAtomic(files.invalidCsv, resultsToCsv(byRow(plan.invalid)));
3849
- const done = plan.finished ? 0 : plan.resumable?.chunksDone.length ?? 0;
3849
+ const done2 = plan.finished ? 0 : plan.resumable?.chunksDone.length ?? 0;
3850
3850
  const summary = {
3851
3851
  run: runId,
3852
3852
  ...planBody,
3853
3853
  plan: files.planJson,
3854
3854
  ...plan.invalid.length > 0 ? { invalidRows: files.invalidCsv } : {},
3855
- ...done > 0 ? { chunksDone: done } : {},
3855
+ ...done2 > 0 ? { chunksDone: done2 } : {},
3856
3856
  // The apply would change nothing: this run already finished every row.
3857
3857
  ...plan.finished ? { alreadyDone: true } : {}
3858
3858
  };
@@ -6183,16 +6183,16 @@ function eachArgs(op, values, file) {
6183
6183
  return args;
6184
6184
  }
6185
6185
  function commandLine(op, args, ctx, extra) {
6186
- const parts = [`kenso ${op.resource} ${op.action}`];
6186
+ const parts2 = [`kenso ${op.resource} ${op.action}`];
6187
6187
  for (const [flag, value] of Object.entries(args)) {
6188
- if (value === true) parts.push(`--${flag}`);
6189
- else for (const item of Array.isArray(value) ? value : [value]) parts.push(`--${flag}`, shellQuote(String(item)));
6188
+ if (value === true) parts2.push(`--${flag}`);
6189
+ else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${flag}`, shellQuote(String(item)));
6190
6190
  }
6191
6191
  for (const name of ["profile", "workspace"]) {
6192
6192
  const value = ctx.flags[name];
6193
- if (value !== void 0) parts.push(`--${name}`, shellQuote(value));
6193
+ if (value !== void 0) parts2.push(`--${name}`, shellQuote(value));
6194
6194
  }
6195
- return [...parts, ...extra].join(" ");
6195
+ return [...parts2, ...extra].join(" ");
6196
6196
  }
6197
6197
  function rateLimitRemaining(headers) {
6198
6198
  const value = Number(headers.get("ratelimit-remaining") ?? "");
@@ -6528,11 +6528,11 @@ function shellQuote2(value) {
6528
6528
  return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
6529
6529
  }
6530
6530
  function sameCommand(ctx, op, flags) {
6531
- const parts = [commandOf(op)];
6531
+ const parts2 = [commandOf(op)];
6532
6532
  for (const [name, value] of Object.entries(flags)) {
6533
6533
  if (value === void 0 || value === false || ["cursor", "all", "each"].includes(name)) continue;
6534
- if (value === true) parts.push(`--${name}`);
6535
- else for (const item of Array.isArray(value) ? value : [value]) parts.push(`--${name}`, shellQuote2(item));
6534
+ if (value === true) parts2.push(`--${name}`);
6535
+ else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${name}`, shellQuote2(item));
6536
6536
  }
6537
6537
  const globals = [
6538
6538
  ["profile", ctx.flags.profile],
@@ -6541,8 +6541,8 @@ function sameCommand(ctx, op, flags) {
6541
6541
  ["fields", ctx.flags.fields],
6542
6542
  ["query", ctx.flags.query]
6543
6543
  ];
6544
- for (const [name, value] of globals) if (value !== void 0) parts.push(`--${name}`, shellQuote2(value));
6545
- return parts.join(" ");
6544
+ for (const [name, value] of globals) if (value !== void 0) parts2.push(`--${name}`, shellQuote2(value));
6545
+ return parts2.join(" ");
6546
6546
  }
6547
6547
  function describeRequest(req) {
6548
6548
  const out = { method: req.method, path: req.path };
@@ -6808,16 +6808,16 @@ function idValue(value, field) {
6808
6808
  function shellQuote3(arg) {
6809
6809
  return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
6810
6810
  }
6811
- function commandLine2(ctx, command35, args, extra = []) {
6812
- const parts = ["kenso", ...command35.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
6811
+ function commandLine2(ctx, command36, args, extra = []) {
6812
+ const parts2 = ["kenso", ...command36.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
6813
6813
  for (const [name, value] of Object.entries(args.flags)) {
6814
6814
  if (value === void 0 || value === false) continue;
6815
- if (value === true) parts.push(`--${name}`);
6816
- else for (const item of Array.isArray(value) ? value : [value]) parts.push(`--${name}`, shellQuote3(item));
6815
+ if (value === true) parts2.push(`--${name}`);
6816
+ else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${name}`, shellQuote3(item));
6817
6817
  }
6818
- if (ctx.flags.profile) parts.push("--profile", shellQuote3(ctx.flags.profile));
6819
- if (ctx.flags.workspace) parts.push("--workspace", shellQuote3(ctx.flags.workspace));
6820
- return [...parts, ...extra].join(" ");
6818
+ if (ctx.flags.profile) parts2.push("--profile", shellQuote3(ctx.flags.profile));
6819
+ if (ctx.flags.workspace) parts2.push("--workspace", shellQuote3(ctx.flags.workspace));
6820
+ return [...parts2, ...extra].join(" ");
6821
6821
  }
6822
6822
  function rateLimitRemaining2(headers) {
6823
6823
  const raw = headers.get("ratelimit-remaining");
@@ -6906,8 +6906,8 @@ __export(import_exports, {
6906
6906
  function domainsOf(row, columns2) {
6907
6907
  const list2 = firstValue(row, columns2.sources.get("domains"));
6908
6908
  if (list2 !== void 0) {
6909
- const parts = Array.isArray(list2) ? list2.map((v) => textValue(v, "domains") ?? "") : (textValue(list2, "domains") ?? "").split(/[,;]/);
6910
- return parts.map((p) => p.trim()).filter((p) => p !== "");
6909
+ const parts2 = Array.isArray(list2) ? list2.map((v) => textValue(v, "domains") ?? "") : (textValue(list2, "domains") ?? "").split(/[,;]/);
6910
+ return parts2.map((p) => p.trim()).filter((p) => p !== "");
6911
6911
  }
6912
6912
  const one = textValue(firstValue(row, columns2.sources.get("domain")), "domain");
6913
6913
  return one ? [one] : [];
@@ -7109,7 +7109,7 @@ var init_accounts = __esm({
7109
7109
  var agents_default;
7110
7110
  var init_agents = __esm({
7111
7111
  "docs/agents.md"() {
7112
- agents_default = '# Coding agents\n\nThe CLI is built to be driven by a coding agent: Claude Code, Codex, Cursor, Gemini CLI or anything else that runs shell commands. An agent learns it from the Agent Skill, `kenso --help` and `kenso describe`, and never needs these web pages.\n\n## Set up an agent in three steps\n\n1. Install the CLI where the agent runs: `npm i -g kenso` (Node 22 or newer). Without a global install, `npx -y kenso@latest <command>` runs any command.\n2. Give it a key. Either set `KENSO_API_KEY` (and `KENSO_WORKSPACE_ID` when the key reaches several workspaces) in the agent\'s environment, or log in once on that machine:\n\n```bash\nkenso auth login\nkenso workspace use 1234\n```\n\n3. Install the Agent Skill and connect the Kenso MCP server in one step, then check everything:\n\n```bash\nkenso agent setup\nkenso agent setup -y\nkenso doctor\n```\n\nTo hand the whole setup to an agent, give it https://ken.so/get-started.md: it runs these steps and stops only where a person has to act.\n\n## kenso agent setup\n\n`kenso agent setup` installs the `kenso-cli` skill (as `kenso skill install` does) and registers the Kenso MCP server, `https://mcp.ken.so/mcp`, with each coding agent:\n\n| Agent | `--client` | MCP server added with |\n|---|---|---|\n| Claude Code | `claude-code` | `claude mcp add --scope user --transport http kenso https://mcp.ken.so/mcp` |\n| Codex | `codex` | `codex mcp add kenso --url https://mcp.ken.so/mcp` |\n| Cursor | `cursor` | a `kenso` entry in `~/.cursor/mcp.json` |\n| Gemini CLI | `gemini` | `gemini mcp add --scope user --transport http kenso https://mcp.ken.so/mcp` |\n| OpenCode | `opencode` | a `kenso` entry in `~/.config/opencode/opencode.json` |\n\n```bash\nkenso agent setup --client claude-code -y\nkenso agent setup --client all -y\nkenso agent setup --status --json\n```\n\n- Without `--client`, it sets up the agent that runs it, else every agent found on the machine (its command on `PATH` or its config folder present).\n- Without `-y` it prints the plan and changes nothing; the plan\'s `next` applies it. `--status` reports, for every agent, whether the skill is `installed`, `missing` or `different` and whether the MCP server is `registered`, `missing`, in `conflict` or `unknown` (a config file it cannot read as JSON), and changes nothing. `--json` prints JSON on a terminal too.\n- An MCP entry with the Kenso URL under another name (such as `ken-ai` from the plugin) counts as registered, and nothing is added. A `kenso` entry pointing at another URL is left alone (`conflict`). A config file that is not plain JSON (it has comments) is left alone (`skipped`), and so is an agent whose command is not on `PATH`: their `next` is the command or edit to make by hand.\n- A different `SKILL.md` in the way stops the run before any change (exit 7) until you add `--force`.\n- It exits 1 when any agent was not fully set up. The MCP server signs in with your Kenso account in the browser the first time the agent uses it; each agent\'s `next` says how (in Claude Code, `/mcp`).\n\n## An AGENTS.md section for your repo\n\nPaste this into the `AGENTS.md` (or `CLAUDE.md`) of a repo whose agents work in Kenso:\n\n```markdown\n## Kenso\n\n- Kenso is our outbound platform. One record or a question: use the Kenso MCP server (https://mcp.ken.so/mcp). A file or more than about 50 records: use the `kenso` CLI.\n- Setup: `npm i -g kenso`, `kenso auth login` (a person approves in the browser), `kenso agent setup -y`, `kenso doctor`.\n- Every write runs first with `--dry-run`; apply with the plan\'s `next`. Never put an API key in a flag, a file or the chat: use `KENSO_API_KEY`.\n- Code that calls the API: send `Authorization: Bearer $KENSO_API_KEY`, `Ken-Version` and `X-Ken-Workspace-Id`. Reference: https://ken.so/docs.md; the kenso-api skill: https://ken.so/.well-known/skills/index.json.\n```\n\n## The Agent Skill\n\n`kenso skill install` writes the skill `kenso-cli` (one `SKILL.md`) where each agent looks for skills:\n\n| Agent | `--client` | Folder |\n|---|---|---|\n| Claude Code | `claude-code` | `~/.claude/skills/kenso-cli/` |\n| Codex | `codex` | `~/.agents/skills/kenso-cli/` |\n| Cursor | `cursor` | `~/.cursor/skills/kenso-cli/` |\n| Gemini CLI | `gemini` | `~/.gemini/skills/kenso-cli/` |\n| OpenCode | `opencode` | `~/.config/opencode/skills/kenso-cli/` |\n\nClaude Code\'s folder follows `CLAUDE_CONFIG_DIR` when that is set. Without `--client`, it installs for the agent that runs it when that is Claude Code, Codex or Cursor (detected from the environment, see below), else for all five. It prints what it wrote:\n\n```json\n{"installed":[{"client":"claude-code","path":"/home/you/.claude/skills/kenso-cli/SKILL.md","status":"created"}]}\n```\n\n```bash\nkenso skill install --client claude-code\nkenso skill install --client all\nkenso skill install --dir .claude/skills/kenso-cli\nkenso skill install --force\n```\n\n- `--dir` writes the skill into that folder instead, for example a project\'s own skills folder. Name the folder `kenso-cli`, as agents expect the folder to match the skill name.\n- A different `SKILL.md` already in a target folder is replaced only with `--force`; without it the command exits 7, writes nothing, and its `next` adds `--force`. The same file is left alone (`"status":"unchanged"`).\n- `--dry-run` writes nothing and exits 0. It prints each target\'s status (`replaced` marks a different file there) and a `next` that applies it, with `--force` when a file would be replaced.\n- Cursor also reads `~/.claude/skills/` and `~/.agents/skills/` (Gemini CLI and OpenCode read `~/.agents/skills/` too), so after a default install for all of them an agent may list `kenso-cli` more than once. To avoid that, install with `--client cursor` only, or remove the copies you do not need.\n\nThe skill also ships in the Kenso plugin for Claude Code (`Ken-Technology/ken-ai-plugin`), so `npx skills add Ken-Technology/ken-ai-plugin` installs it along with the MCP skills. The plugin\'s copy is this file byte for byte. To read it without installing, open `skill/kenso-cli/SKILL.md` in the package.\n\n## Rules the skill teaches\n\n- **Data is on stdout, as JSON when piped.** Progress, warnings and errors are on stderr. Parse stdout; read stderr when the exit code is not 0.\n- **Plan, then apply.** Run a write with `--dry-run`, read the plan, then run the exact command in its `next` (the same command with `--yes`). A command with no dry run refuses `--dry-run` with `usage_error` and does nothing.\n- **Pass files, not rows.** Never paste a CSV into the conversation. Write the file, pass its path with `--file`, and read the summary.\n- **Read failures only.** If the summary\'s `failed`, `notFound` and `invalid` are 0, the work is done. Otherwise read just the problem rows from `results.csv` or `invalid.csv`.\n- **Follow `next`.** Every error with a known fix carries the exact command to run.\n- **Branch on the exit code:** 0 ok, 2 fix the command, 3 fix the key, 5 some rows failed, 6 wait or raise a limit, 130 resume.\n- **Look things up, do not guess.** `kenso describe <resource> <action>` prints any command\'s flags and body schema as JSON.\n\n## The token-saving pattern\n\nAdding 5,000 leads through the MCP sends every lead through the model, hundreds of thousands of tokens. Through the CLI it is two commands and two short JSON objects:\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\nThen, only if the summary shows failures:\n\n```bash\ngrep -E \'^[0-9]+,(failed|not_found|invalid),\' ~/.kenso/runs/r_tdi5cdnx/results.csv | head -50\n```\n\n## Environment variables\n\n| Variable | What it does |\n|---|---|\n| `KENSO_API_KEY` | The API key. Wins over any saved profile |\n| `KENSO_WORKSPACE_ID` | The workspace for every command. `--workspace` wins over it |\n| `KENSO_PROFILE` | The saved profile to use. `--profile` wins over it |\n| `KENSO_API_URL` | The API, default `https://api.ken.so` |\n| `KENSO_CONFIG_DIR` | Where the config file and cache live, default `~/.kenso` |\n| `KENSO_RUNS_DIR` | Where run folders live, default `<config dir>/runs` |\n| `KENSO_MCP_URL` | The MCP for `kenso mcp`, default `https://mcp.ken.so/mcp` |\n\n## Cloud sandboxes\n\nCloud agents (Claude Code on the web, Codex cloud, Cursor background agents and similar) often run with a network allowlist. Allow:\n\n- `api.ken.so`: every command\n- `mcp.ken.so`: only `kenso mcp tools` and `kenso mcp call`\n- `registry.npmjs.org`: to install the CLI with npm\n\nStore the key as the platform\'s secret and expose it as `KENSO_API_KEY`. Run `kenso doctor` as the first command: it checks Node, the config, that the API is reachable and that the key works, and exits 0 when all four pass.\n\n```bash\nkenso doctor\n```\n\nPoint the run folders at the workspace if the home folder does not persist between sessions: `KENSO_RUNS_DIR=./.kenso-runs`. Keep that folder out of git.\n\n## How Kenso knows an agent ran a command\n\nThe CLI checks these environment variables, in this order: `CLAUDECODE` and `CLAUDE_CODE_ENTRYPOINT` (Claude Code), `CODEX_SANDBOX` and `CODEX_THREAD_ID` (Codex), `CURSOR_AGENT` (Cursor), `GEMINI_CLI` (Gemini CLI), `OPENCODE` (OpenCode), then `AI_AGENT`, a free-form name any other agent can set. When one is set:\n\n- every request carries `X-Ken-Client: Kenso CLI via <agent>`, and writes carry `X-Ken-Actor: agent`, so Kenso shows the change as made by you through that agent;\n- help ends with a short "For agents" block;\n- browser login never opens a browser itself: it prints the link for you to open.\n\n`kenso doctor` shows the agent it detected.\n\n## MCP-only tools\n\nA few Kenso MCP tools have no API route, such as the skills Kenso\'s own agents use. Reach them from the shell with the same key:\n\n```bash\nkenso mcp tools\nkenso mcp call list_skills\nkenso mcp call load_skill --args \'{"name":"create-campaign"}\'\nkenso mcp call contacts_read --operation list --args \'{"limit":5}\'\n```\n\n`mcp call` prints the tool\'s structured result, else its text parsed as JSON, else the text. A tool error exits 1 with `mcp_tool_error`.\n';
7112
+ agents_default = '# Coding agents\n\nThe CLI is built to be driven by a coding agent: Claude Code, Codex, Cursor, Gemini CLI or anything else that runs shell commands. An agent learns it from the Agent Skill, `kenso --help` and `kenso describe`, and never needs these web pages.\n\n## Set up an agent in three steps\n\n1. Install the CLI where the agent runs: `npm i -g kenso` (Node 22 or newer). Without a global install, `npx -y kenso@latest <command>` runs any command.\n2. Give it a key. Either set `KENSO_API_KEY` (and `KENSO_WORKSPACE_ID` when the key reaches several workspaces) in the agent\'s environment, or log in once on that machine:\n\n```bash\nkenso auth login\nkenso workspace use 1234\n```\n\n3. Install the Agent Skill and connect the Kenso MCP server in one step, then check everything:\n\n```bash\nkenso agent setup\nkenso agent setup -y\nkenso doctor\n```\n\nTo hand the whole setup to an agent, give it [ken.so/get-started.md](https://ken.so/get-started.md): it runs these steps and stops only where a person has to act.\n\n## kenso agent setup\n\n`kenso agent setup` installs the `kenso-cli` skill (as `kenso skill install` does) and registers the Kenso MCP server, `https://mcp.ken.so/mcp`, with each coding agent:\n\n| Agent | `--client` | MCP server added with |\n|---|---|---|\n| Claude Code | `claude-code` | `claude mcp add --scope user --transport http kenso https://mcp.ken.so/mcp` |\n| Codex | `codex` | `codex mcp add kenso --url https://mcp.ken.so/mcp` |\n| Cursor | `cursor` | a `kenso` entry in `~/.cursor/mcp.json` |\n| Gemini CLI | `gemini` | `gemini mcp add --scope user --transport http kenso https://mcp.ken.so/mcp` |\n| OpenCode | `opencode` | a `kenso` entry in `~/.config/opencode/opencode.json` |\n\n```bash\nkenso agent setup --client claude-code -y\nkenso agent setup --client all -y\nkenso agent setup --status --json\n```\n\n- Without `--client`, it sets up the agent that runs it, else every agent found on the machine (its command on `PATH` or its config folder present).\n- Without `-y` it prints the plan and changes nothing; the plan\'s `next` applies it. `--status` reports, for every agent, whether the skill is `installed`, `missing` or `different` and whether the MCP server is `registered`, `missing`, in `conflict` or `unknown` (a config file it cannot read as JSON), and changes nothing. `--json` prints JSON on a terminal too.\n- An MCP entry with the Kenso URL under another name (such as `ken-ai` from the plugin) counts as registered, and nothing is added. A `kenso` entry pointing at another URL is left alone (`conflict`). A config file that is not plain JSON (it has comments) is left alone (`skipped`), and so is an agent whose command is not on `PATH`: their `next` is the command or edit to make by hand.\n- A different `SKILL.md` in the way stops the run before any change (exit 7) until you add `--force`.\n- It exits 1 when any agent was not fully set up. The MCP server signs in with your Kenso account in the browser the first time the agent uses it; each agent\'s `next` says how (in Claude Code, `/mcp`).\n\n## An AGENTS.md section for your repo\n\nPaste this into the `AGENTS.md` (or `CLAUDE.md`) of a repo whose agents work in Kenso:\n\n```markdown\n## Kenso\n\n- Kenso is our outbound platform. One record or a question: use the Kenso MCP server (https://mcp.ken.so/mcp). A file or more than about 50 records: use the `kenso` CLI.\n- Setup: `npm i -g kenso`, `kenso auth login` (a person approves in the browser), `kenso agent setup -y`, `kenso doctor`.\n- Every write runs first with `--dry-run`; apply with the plan\'s `next`. Never put an API key in a flag, a file or the chat: use `KENSO_API_KEY`.\n- Code that calls the API: send `Authorization: Bearer $KENSO_API_KEY`, `Ken-Version` and `X-Ken-Workspace-Id`. Reference: ken.so/docs.md; the kenso-api skill is listed at ken.so/.well-known/skills/index.json.\n```\n\n## The Agent Skill\n\n`kenso skill install` writes the skill `kenso-cli` (one `SKILL.md`) where each agent looks for skills:\n\n| Agent | `--client` | Folder |\n|---|---|---|\n| Claude Code | `claude-code` | `~/.claude/skills/kenso-cli/` |\n| Codex | `codex` | `~/.agents/skills/kenso-cli/` |\n| Cursor | `cursor` | `~/.cursor/skills/kenso-cli/` |\n| Gemini CLI | `gemini` | `~/.gemini/skills/kenso-cli/` |\n| OpenCode | `opencode` | `~/.config/opencode/skills/kenso-cli/` |\n\nClaude Code\'s folder follows `CLAUDE_CONFIG_DIR` when that is set. Without `--client`, it installs for the agent that runs it when that is Claude Code, Codex or Cursor (detected from the environment, see below), else for all five. It prints what it wrote:\n\n```json\n{"installed":[{"client":"claude-code","path":"/home/you/.claude/skills/kenso-cli/SKILL.md","status":"created"}]}\n```\n\n```bash\nkenso skill install --client claude-code\nkenso skill install --client all\nkenso skill install --dir .claude/skills/kenso-cli\nkenso skill install --force\n```\n\n- `--dir` writes the skill into that folder instead, for example a project\'s own skills folder. Name the folder `kenso-cli`, as agents expect the folder to match the skill name.\n- A different `SKILL.md` already in a target folder is replaced only with `--force`; without it the command exits 7, writes nothing, and its `next` adds `--force`. The same file is left alone (`"status":"unchanged"`).\n- `--dry-run` writes nothing and exits 0. It prints each target\'s status (`replaced` marks a different file there) and a `next` that applies it, with `--force` when a file would be replaced.\n- Cursor also reads `~/.claude/skills/` and `~/.agents/skills/` (Gemini CLI and OpenCode read `~/.agents/skills/` too), so after a default install for all of them an agent may list `kenso-cli` more than once. To avoid that, install with `--client cursor` only, or remove the copies you do not need.\n\nThe skill also ships in the Kenso plugin for Claude Code (`Ken-Technology/ken-ai-plugin`), so `npx skills add Ken-Technology/ken-ai-plugin` installs it along with the MCP skills. The plugin\'s copy is this file byte for byte. To read it without installing, open `skill/kenso-cli/SKILL.md` in the package.\n\n## Rules the skill teaches\n\n- **Data is on stdout, as JSON when piped.** Progress, warnings and errors are on stderr. Parse stdout; read stderr when the exit code is not 0.\n- **Plan, then apply.** Run a write with `--dry-run`, read the plan, then run the exact command in its `next` (the same command with `--yes`). A command with no dry run refuses `--dry-run` with `usage_error` and does nothing.\n- **Pass files, not rows.** Never paste a CSV into the conversation. Write the file, pass its path with `--file`, and read the summary.\n- **Read failures only.** If the summary\'s `failed`, `notFound` and `invalid` are 0, the work is done. Otherwise read just the problem rows from `results.csv` or `invalid.csv`.\n- **Follow `next`.** Every error with a known fix carries the exact command to run.\n- **Branch on the exit code:** 0 ok, 2 fix the command, 3 fix the key, 5 some rows failed, 6 wait or raise a limit, 130 resume.\n- **Look things up, do not guess.** `kenso describe <resource> <action>` prints any command\'s flags and body schema as JSON.\n\n## The token-saving pattern\n\nAdding 5,000 leads through the MCP sends every lead through the model, hundreds of thousands of tokens. Through the CLI it is two commands and two short JSON objects:\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\nThen, only if the summary shows failures:\n\n```bash\ngrep -E \'^[0-9]+,(failed|not_found|invalid),\' ~/.kenso/runs/r_tdi5cdnx/results.csv | head -50\n```\n\n## Environment variables\n\n| Variable | What it does |\n|---|---|\n| `KENSO_API_KEY` | The API key. Wins over any saved profile |\n| `KENSO_WORKSPACE_ID` | The workspace for every command. `--workspace` wins over it |\n| `KENSO_PROFILE` | The saved profile to use. `--profile` wins over it |\n| `KENSO_API_URL` | The API, default `https://api.ken.so` |\n| `KENSO_CONFIG_DIR` | Where the config file and cache live, default `~/.kenso` |\n| `KENSO_RUNS_DIR` | Where run folders live, default `<config dir>/runs` |\n| `KENSO_MCP_URL` | The MCP for `kenso mcp`, default `https://mcp.ken.so/mcp` |\n| `KENSO_NO_UPDATE_NOTIFIER` | Set to `1` to turn off the weekly "a newer kenso is out" line on stderr. It never shows under a detected agent, in CI or when stderr is not a terminal |\n\n## Cloud sandboxes\n\nCloud agents (Claude Code on the web, Codex cloud, Cursor background agents and similar) often run with a network allowlist. Allow:\n\n- `api.ken.so`: every command\n- `mcp.ken.so`: only `kenso mcp tools` and `kenso mcp call`\n- `registry.npmjs.org`: to install the CLI with npm\n\nStore the key as the platform\'s secret and expose it as `KENSO_API_KEY`. Run `kenso doctor` as the first command: it checks Node, the config, that the API is reachable and that the key works, and exits 0 when all four pass.\n\n```bash\nkenso doctor\n```\n\nPoint the run folders at the workspace if the home folder does not persist between sessions: `KENSO_RUNS_DIR=./.kenso-runs`. Keep that folder out of git.\n\n## How Kenso knows an agent ran a command\n\nThe CLI checks these environment variables, in this order: `CLAUDECODE` and `CLAUDE_CODE_ENTRYPOINT` (Claude Code), `CODEX_SANDBOX` and `CODEX_THREAD_ID` (Codex), `CURSOR_AGENT` (Cursor), `GEMINI_CLI` (Gemini CLI), `OPENCODE` (OpenCode), then `AI_AGENT`, a free-form name any other agent can set. When one is set:\n\n- every request carries `X-Ken-Client: Kenso CLI via <agent>`, and writes carry `X-Ken-Actor: agent`, so Kenso shows the change as made by you through that agent;\n- help ends with a short "For agents" block;\n- browser login never opens a browser itself: it prints the link for you to open.\n\n`kenso doctor` shows the agent it detected.\n\n## MCP-only tools\n\nA few Kenso MCP tools have no API route, such as the skills Kenso\'s own agents use. Reach them from the shell with the same key:\n\n```bash\nkenso mcp tools\nkenso mcp call list_skills\nkenso mcp call load_skill --args \'{"name":"create-campaign"}\'\nkenso mcp call contacts_read --operation list --args \'{"limit":5}\'\n```\n\n`mcp call` prints the tool\'s structured result, else its text parsed as JSON, else the text. A tool error exits 1 with `mcp_tool_error`.\n';
7113
7113
  }
7114
7114
  });
7115
7115
 
@@ -7117,7 +7117,7 @@ var init_agents = __esm({
7117
7117
  var auth_default;
7118
7118
  var init_auth = __esm({
7119
7119
  "docs/auth.md"() {
7120
- auth_default = '# Authentication\n\nThe CLI calls the Kenso API with a Kenso API key (`ken_` plus 43 characters). It sends the key as `Authorization: Bearer <key>` and never prints it, logs it or puts it in an error.\n\n`kenso login`, `kenso logout` and `kenso whoami` are the same commands as `kenso auth login`, `kenso auth logout` and `kenso auth status`.\n\n## Log in with an API key\n\n1. In app.ken.so, go to Settings > Integrations > API keys and create a key.\n2. Pipe it to `kenso auth login --with-key`. The key is read from stdin, never from a flag, so it stays out of your shell history and process list.\n\n```bash\necho $KEY | kenso auth login --with-key\nkenso auth login --with-key --profile client-a --workspace 1234 < key.txt\n```\n\nThe CLI checks the key with `GET /v1/me`, then saves it to `~/.kenso/config.json` (file mode 0600, folder mode 0700). It prints:\n\n```json\n{"profile":"default","email":"you@acme.io","workspaceId":"1234","workspaceCount":1}\n```\n\nWhen the key reaches several workspaces and you did not pass `--workspace`, no workspace is saved and the output carries `"next":"kenso workspace list --search <name>"`. A key in the wrong format exits 2 (`invalid_key_format`). A key Kenso rejects exits 3.\n\n## Browser login\n\n```bash\nkenso auth login\nkenso auth login --no-browser --device-name "build box"\n```\n\nBrowser login is available to every workspace. The CLI prints a link and a code on stderr. You open the link, sign in to app.ken.so, check that the code matches the one in your terminal, pick the workspace to start in and approve. The CLI then saves a new API key to the profile and prints:\n\n```json\n{"profile":"default","email":"you@acme.io","workspaceId":"1234","keyExpiresAt":"2027-02-02T06:26:59Z"}\n```\n\nThe key is the same kind you create in the app. It is named `Kenso CLI - <device name>` (`--device-name`, else `kenso-cli on <hostname>`), lasts 90 days, and shows in your API key list at Settings > Integrations > API keys, where you can revoke it. The CLI opens the browser itself only when no coding agent is detected and the machine has a display. An agent prints the link and asks you to open it. The login expires after 10 minutes (`login_expired`, exit 3), and a denied login exits 3 with `access_denied`. If the API answers that browser login is off (`browser_login_unavailable`, exit 3, `"next":"kenso auth login --with-key"`), log in with an API key as above.\n\n## CI, scripts and agents: use the environment\n\nYou do not need to log in on a machine that has the key in its environment:\n\n```bash\nexport KENSO_API_KEY=ken_...\nexport KENSO_WORKSPACE_ID=1234\nkenso auth status\n```\n\n`KENSO_API_KEY` wins over any saved profile. Store it as a secret in your CI or agent platform, never in a file in the repo.\n\n## Workspaces\n\nA key reaches every workspace its user belongs to. Each command runs in one workspace, picked in this order:\n\n1. `--workspace <id>` on the command\n2. `KENSO_WORKSPACE_ID`\n3. the workspace saved in the profile (`kenso workspace use`)\n\n```bash\nkenso workspace list --search acme\nkenso workspace use 1234\nkenso campaigns list --workspace 5678\n```\n\n`workspace list` prints one page and says on stderr when there are more: add `--all` for every page. A command that needs a workspace when none is picked fails with `workspace_required` (exit 2) and `"next":"kenso workspace list --search <name>"`.\n\n## Profiles\n\nA profile holds a key, a workspace, an optional API URL and the email. Use one per client or per key:\n\n```bash\nkenso auth login --with-key --profile client-a < client-a-key.txt\nkenso campaigns list --profile client-a\nKENSO_PROFILE=client-a kenso auth status\n```\n\nThe profile is `--profile`, else `KENSO_PROFILE`, else the active one (the last one you logged in to).\n\n## Check the setup\n\n```bash\nkenso auth status\nkenso doctor\n```\n\n`auth status` prints who the key belongs to and when it expires, and warns on stderr when that is within 14 days:\n\n```json\n{"email":"you@acme.io","workspaceCount":3,"activeWorkspace":{"id":"1234","name":"Acme"},"keyExpiresAt":"2027-01-31T00:00:00Z","keySource":"profile","profile":"default"}\n```\n\n`doctor` prints the version, Node, the config folder, the profile, the key source, the API URL, the workspace and the detected agent, then four checks: `node_version`, `config_permissions`, `api_reachable` and `key_valid`. It exits 0 when every check passes, 3 when the key is missing or rejected, else 1.\n\n## Log out\n\n```bash\nkenso auth logout\nkenso auth logout --profile client-a\n```\n\nThis removes the profile and its key from this machine. The key itself stays valid until you revoke it at Settings > Integrations > API keys.\n\n## Where things live\n\n| What | Default | Override |\n|---|---|---|\n| Config file with profiles and keys | `~/.kenso/config.json` | `KENSO_CONFIG_DIR` |\n| Run folders | `~/.kenso/runs/` | `KENSO_RUNS_DIR` |\n| Cached workspace features (1 hour) | `~/.kenso/cache/` | follows `KENSO_CONFIG_DIR` |\n| API | `https://api.ken.so` | `KENSO_API_URL` |\n| MCP (for `kenso mcp`) | `https://mcp.ken.so/mcp` | `KENSO_MCP_URL` |\n\n`--verbose` prints each request line to stderr with the key redacted.\n';
7120
+ auth_default = '# Authentication\n\nThe CLI calls the Kenso API with a Kenso API key (`ken_` plus 43 characters). It sends the key as `Authorization: Bearer <key>` and never prints it, logs it or puts it in an error.\n\n`kenso login`, `kenso logout` and `kenso whoami` are the same commands as `kenso auth login`, `kenso auth logout` and `kenso auth status`.\n\n## Log in with an API key\n\n1. In app.ken.so, go to Settings > Integrations > API keys and create a key.\n2. Pipe it to `kenso auth login --with-key`. The key is read from stdin, never from a flag, so it stays out of your shell history and process list.\n\n```bash\necho $KEY | kenso auth login --with-key\nkenso auth login --with-key --profile client-a --workspace 1234 < key.txt\n```\n\nThe CLI checks the key with `GET /v1/me`, then saves it to `~/.kenso/config.json` (file mode 0600, folder mode 0700). It prints:\n\n```json\n{"profile":"default","email":"you@acme.io","workspaceId":"1234","workspaceCount":1}\n```\n\nWhen the key reaches several workspaces and you did not pass `--workspace`, no workspace is saved and the output carries `"next":"kenso workspace list --search <name>"`. A key in the wrong format exits 2 (`invalid_key_format`). A key Kenso rejects exits 3.\n\n## Browser login\n\n```bash\nkenso auth login\nkenso auth login --no-browser --device-name "build box"\n```\n\nBrowser login is available to every workspace. The CLI prints a link and a code on stderr. You open the link, sign in to app.ken.so, check that the code matches the one in your terminal, pick the workspace to start in and approve. The CLI then saves a new API key to the profile and prints:\n\n```json\n{"profile":"default","email":"you@acme.io","workspaceId":"1234","keyExpiresAt":"2027-02-02T06:26:59Z"}\n```\n\nThe key is the same kind you create in the app. It is named `Kenso CLI - <device name>` (`--device-name`, else `kenso-cli on <hostname>`), lasts 90 days, and shows in your API key list at Settings > Integrations > API keys, where you can revoke it. The CLI opens the browser itself only when no coding agent is detected and the machine has a display. An agent prints the link and asks you to open it. The login expires after 10 minutes (`login_expired`, exit 3), and a denied login exits 3 with `access_denied`. If the API answers that browser login is off (`browser_login_unavailable`, exit 3, `"next":"kenso auth login --with-key"`), log in with an API key as above.\n\n## CI, scripts and agents: use the environment\n\nYou do not need to log in on a machine that has the key in its environment:\n\n```bash\nexport KENSO_API_KEY=ken_...\nexport KENSO_WORKSPACE_ID=1234\nkenso auth status\n```\n\n`KENSO_API_KEY` wins over any saved profile. Store it as a secret in your CI or agent platform, never in a file in the repo.\n\n## Workspaces\n\nA key reaches every workspace its user belongs to. Each command runs in one workspace, picked in this order:\n\n1. `--workspace <id>` on the command\n2. `KENSO_WORKSPACE_ID`\n3. the workspace saved in the profile (`kenso workspace use`)\n\n```bash\nkenso workspace list --search acme\nkenso workspace use 1234\nkenso campaigns list --workspace 5678\n```\n\n`workspace list` prints one page and says on stderr when there are more: add `--all` for every page. A command that needs a workspace when none is picked fails with `workspace_required` (exit 2) and `"next":"kenso workspace list --search <name>"`.\n\n## Profiles\n\nA profile holds a key, a workspace, an optional API URL and the email. Use one per client or per key:\n\n```bash\nkenso auth login --with-key --profile client-a < client-a-key.txt\nkenso campaigns list --profile client-a\nKENSO_PROFILE=client-a kenso auth status\n```\n\nThe profile is `--profile`, else `KENSO_PROFILE`, else the active one (the last one you logged in to).\n\n## Check the setup\n\n```bash\nkenso auth status\nkenso doctor\n```\n\n`auth status` prints who the key belongs to and when it expires, and warns on stderr when that is within 14 days:\n\n```json\n{"email":"you@acme.io","workspaceCount":3,"activeWorkspace":{"id":"1234","name":"Acme"},"keyExpiresAt":"2027-01-31T00:00:00Z","keySource":"profile","profile":"default"}\n```\n\n`doctor` prints the version, Node, the config folder, the profile, the key source, the API URL, the workspace and the detected agent, then four checks: `node_version`, `config_permissions`, `api_reachable` and `key_valid`. It exits 0 when every check passes, 3 when the key is missing or rejected, else 1.\n\n## Log out\n\n```bash\nkenso auth logout\nkenso auth logout --profile client-a\n```\n\nThis removes the profile and its key from this machine. The key itself stays valid until you revoke it at Settings > Integrations > API keys.\n\n## Where things live\n\n| What | Default | Override |\n|---|---|---|\n| Config file with profiles and keys | `~/.kenso/config.json` | `KENSO_CONFIG_DIR` |\n| Run folders | `~/.kenso/runs/` | `KENSO_RUNS_DIR` |\n| Cached workspace features (1 hour) | `~/.kenso/cache/` | follows `KENSO_CONFIG_DIR` |\n| Last update check (once every 7 days) | `~/.kenso/update-check.json` | follows `KENSO_CONFIG_DIR`; `KENSO_NO_UPDATE_NOTIFIER=1` turns the check off |\n| API | `https://api.ken.so` | `KENSO_API_URL` |\n| MCP (for `kenso mcp`) | `https://mcp.ken.so/mcp` | `KENSO_MCP_URL` |\n\n`--verbose` prints each request line to stderr with the key redacted.\n';
7121
7121
  }
7122
7122
  });
7123
7123
 
@@ -7157,7 +7157,7 @@ var init_output_and_errors = __esm({
7157
7157
  var README_default;
7158
7158
  var init_README = __esm({
7159
7159
  "docs/README.md"() {
7160
- README_default = '# Kenso CLI\n\nThe Kenso CLI (`kenso`) is the command line for Kenso. It does bulk work in your Kenso workspace from files: add thousands of leads to a campaign, update or clean them up, import accounts and people, and build Studio templates. It is made for coding agents (Claude Code, Codex, Cursor) and the people who drive them: JSON on stdout, fixed exit codes, a dry run before every bulk write, and runs you can resume.\n\nEvery API operation a workspace member can call is also a command, such as `kenso campaigns list` or `kenso tags create`. So the CLI reaches what the Kenso MCP reaches, straight against `https://api.ken.so`.\n\n## Install\n\nYou need Node 22 or newer.\n\n```bash\nnpm i -g kenso\nkenso --version\n```\n\nTo run it once without installing, use `npx kenso --version`.\n\n## 60-second quickstart\n\n1. Create an API key in app.ken.so at Settings > Integrations > API keys.\n2. Save the key, pick a workspace, then plan and apply a CSV import:\n\n```bash\necho $KEY | kenso auth login --with-key\nkenso workspace list --search acme\nkenso workspace use 1234\nkenso campaigns list --limit 5\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\n`workspace list` and `workspace use` are only needed when your key reaches more than one workspace.\n\nThe dry run reads the file, maps the columns, checks every row, asks Kenso for a credit estimate, and writes nothing. It prints the plan, with the exact apply command in `next`:\n\n```json\n{"run":"r_tdi5cdnx","dryRun":true,"command":"contacts import","rows":4,"valid":2,"invalid":2,"chunks":1,"chunkSize":1000,"campaignId":812,"mapping":{"Email":"email","First Name":"firstName","Last Name":"lastName","Company":"companyName","Pain Point":"customVariables.pain_point"},"customVariableKeys":["pain_point"],"estimate":{"kind":"leads","totalMillicredits":2000,"availableMillicredits":500000,"sufficient":true},"credits":{"needed":2,"available":500,"sufficient":true},"next":"kenso contacts import --campaign 812 --file leads.csv --yes","plan":"/home/you/.kenso/runs/r_tdi5cdnx/plan.json","invalidRows":"/home/you/.kenso/runs/r_tdi5cdnx/invalid.csv"}\n```\n\nThe apply sends the rows and prints one summary. Every input row has one line in `results.csv`:\n\n```json\n{"run":"r_tdi5cdnx","rows":4,"ok":0,"created":1,"updated":0,"skipped":{"duplicate":1},"failed":0,"notFound":0,"invalid":2,"changed":1,"results":"/home/you/.kenso/runs/r_tdi5cdnx/results.csv","resultsNdjson":"/home/you/.kenso/runs/r_tdi5cdnx/results.ndjson","invalidRows":"/home/you/.kenso/runs/r_tdi5cdnx/invalid.csv","resumed":false,"durationMs":1840,"campaignId":812,"notSendable":0}\n```\n\nThis run exits 5 because two rows were invalid: open `invalid.csv` to see why, fix those rows, and import them again. Running the same command again is safe: an email that is already in the campaign comes back `updated` or `skipped`, never as a second lead.\n\n## CLI or MCP\n\n- **Use the CLI for volume:** anything that starts from a file, anything over about 50 records, anything you may need to rerun or resume. Records never pass through the model\'s context: the agent passes a file path and reads a short summary.\n- **Use the MCP for conversation and single records:** look up a campaign, draft a reply, read a report. The MCP is at `https://mcp.ken.so/mcp`, signs in with OAuth and needs no install ([connection guide](https://ken.so/mcp)).\n- **Both use the same API and the same permissions.** `kenso mcp call` reaches MCP-only tools, such as skills, from the shell.\n\n## Docs\n\nEvery page is in the package and prints offline with `kenso docs <topic>`.\n\n| Page | Topic | What it covers |\n|---|---|---|\n| [Authentication](auth.md) | `auth` | API keys, browser login, profiles, workspaces, `doctor` |\n| [Leads](leads.md) | `leads` | Import, update, remove, pause, tag and export leads, with recipes |\n| [Batch runs](batch.md) | `batch` | Dry run and apply, run folders, results files, resume, rate limits, `--each` |\n| [Output and errors](output-and-errors.md) | `output-and-errors` | The output contract, error JSON, error codes, exit codes |\n| [CRM (beta)](crm.md) | `crm` | Accounts, people, opportunities and CRM sync |\n| [Studio (beta)](studio.md) | `studio` | Pull, push, validate, preview and fill templates |\n| [Agent work (beta)](work.md) | `work` | My agent: your own coding agent writes Kenso AI work with `kenso work run`, or pull and submit |\n| [Webhooks](webhooks.md) | `webhooks` | Build a webhook handler locally: `kenso webhooks listen --forward-to`, `trigger`, the signature |\n| [Coding agents](agents.md) | `agents` | Claude Code, Codex, Cursor, the Agent Skill, environment variables, sandboxes |\n| Command reference | `reference` | Every command with its flags, generated from the CLI at build time: `kenso docs reference`, or `docs/reference.md` in the installed package |\n\n```bash\nkenso docs\nkenso docs leads\n```\n\nFor machine-readable help, run `kenso describe`: it prints every command, its flags and its body schema as JSON.\n';
7160
+ README_default = '# Kenso CLI\n\nThe Kenso CLI (`kenso`) is the command line for Kenso. It does bulk work in your Kenso workspace from files: add thousands of leads to a campaign, update or clean them up, import accounts and people, and build Studio templates. It is made for coding agents (Claude Code, Codex, Cursor) and the people who drive them: JSON on stdout, fixed exit codes, a dry run before every bulk write, and runs you can resume.\n\nEvery API operation a workspace member can call is also a command, such as `kenso campaigns list` or `kenso tags create`. So the CLI reaches what the Kenso MCP reaches, straight against `https://api.ken.so`.\n\n## Install\n\nYou need Node 22 or newer.\n\n```bash\nnpm i -g kenso\nkenso --version\n```\n\nTo run it once without installing, use `npx kenso --version`.\n\n### Tab completion\n\nTab completes resources, actions and flags once you install the script for your shell. The script asks `kenso` for the candidates on each Tab, so it stays right as the CLI updates: install it once.\n\n```bash\n# zsh: add this line to ~/.zshrc\nsource <(kenso completion zsh)\n# bash: add this line to ~/.bashrc (on bash 3.2, the macOS default, use: eval "$(kenso completion bash)")\nsource <(kenso completion bash)\n# fish: save the script once\nkenso completion fish > ~/.config/fish/completions/kenso.fish\n```\n\n### Update notice\n\nWhen a newer version is out, `kenso` says so on stderr after the command\'s own output, at most once a week: `kenso 0.1.40 is out (you have 0.1.35): npm i -g kenso@latest`. It checks `registry.npmjs.org` at most once every 7 days and never delays a command by more than about a second. It stays quiet when stderr is not a terminal, in CI (`CI` set) and under a coding agent. Set `KENSO_NO_UPDATE_NOTIFIER=1` to turn it off.\n\n## 60-second quickstart\n\n1. Create an API key in app.ken.so at Settings > Integrations > API keys.\n2. Save the key, pick a workspace, then plan and apply a CSV import:\n\n```bash\necho $KEY | kenso auth login --with-key\nkenso workspace list --search acme\nkenso workspace use 1234\nkenso campaigns list --limit 5\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\n`workspace list` and `workspace use` are only needed when your key reaches more than one workspace.\n\nThe dry run reads the file, maps the columns, checks every row, asks Kenso for a credit estimate, and writes nothing. It prints the plan, with the exact apply command in `next`:\n\n```json\n{"run":"r_tdi5cdnx","dryRun":true,"command":"contacts import","rows":4,"valid":2,"invalid":2,"chunks":1,"chunkSize":1000,"campaignId":812,"mapping":{"Email":"email","First Name":"firstName","Last Name":"lastName","Company":"companyName","Pain Point":"customVariables.pain_point"},"customVariableKeys":["pain_point"],"estimate":{"kind":"leads","totalMillicredits":2000,"availableMillicredits":500000,"sufficient":true},"credits":{"needed":2,"available":500,"sufficient":true},"next":"kenso contacts import --campaign 812 --file leads.csv --yes","plan":"/home/you/.kenso/runs/r_tdi5cdnx/plan.json","invalidRows":"/home/you/.kenso/runs/r_tdi5cdnx/invalid.csv"}\n```\n\nThe apply sends the rows and prints one summary. Every input row has one line in `results.csv`:\n\n```json\n{"run":"r_tdi5cdnx","rows":4,"ok":0,"created":1,"updated":0,"skipped":{"duplicate":1},"failed":0,"notFound":0,"invalid":2,"changed":1,"results":"/home/you/.kenso/runs/r_tdi5cdnx/results.csv","resultsNdjson":"/home/you/.kenso/runs/r_tdi5cdnx/results.ndjson","invalidRows":"/home/you/.kenso/runs/r_tdi5cdnx/invalid.csv","resumed":false,"durationMs":1840,"campaignId":812,"notSendable":0}\n```\n\nThis run exits 5 because two rows were invalid: open `invalid.csv` to see why, fix those rows, and import them again. Running the same command again is safe: an email that is already in the campaign comes back `updated` or `skipped`, never as a second lead.\n\n## CLI or MCP\n\n- **Use the CLI for volume:** anything that starts from a file, anything over about 50 records, anything you may need to rerun or resume. Records never pass through the model\'s context: the agent passes a file path and reads a short summary.\n- **Use the MCP for conversation and single records:** look up a campaign, draft a reply, read a report. The MCP is at `https://mcp.ken.so/mcp`, signs in with OAuth and needs no install ([connection guide](https://ken.so/mcp)).\n- **Both use the same API and the same permissions.** `kenso mcp call` reaches MCP-only tools, such as skills, from the shell.\n\n## Docs\n\nEvery page is in the package and prints offline with `kenso docs <topic>`.\n\n| Page | Topic | What it covers |\n|---|---|---|\n| [Authentication](auth.md) | `auth` | API keys, browser login, profiles, workspaces, `doctor` |\n| [Leads](leads.md) | `leads` | Import, update, remove, pause, tag and export leads, with recipes |\n| [Batch runs](batch.md) | `batch` | Dry run and apply, run folders, results files, resume, rate limits, `--each` |\n| [Output and errors](output-and-errors.md) | `output-and-errors` | The output contract, error JSON, error codes, exit codes |\n| [CRM (beta)](crm.md) | `crm` | Accounts, people, opportunities and CRM sync |\n| [Studio (beta)](studio.md) | `studio` | Pull, push, validate, preview and fill templates |\n| [Agent work (beta)](work.md) | `work` | My agent: your own coding agent writes Kenso AI work with `kenso work run`, or pull and submit |\n| [Webhooks](webhooks.md) | `webhooks` | Build a webhook handler locally: `kenso webhooks listen --forward-to`, `trigger`, the signature |\n| [Coding agents](agents.md) | `agents` | Claude Code, Codex, Cursor, the Agent Skill, environment variables, sandboxes |\n| Command reference | `reference` | Every command with its flags, generated from the CLI at build time: `kenso docs reference`, or `docs/reference.md` in the installed package |\n\n```bash\nkenso docs\nkenso docs leads\n```\n\nFor machine-readable help, run `kenso describe`: it prints every command, its flags and its body schema as JSON.\n';
7161
7161
  }
7162
7162
  });
7163
7163
 
@@ -7427,7 +7427,7 @@ var init_client = __esm({
7427
7427
  };
7428
7428
  try {
7429
7429
  for (; ; ) {
7430
- const { done, value } = await reader.read();
7430
+ const { done: done2, value } = await reader.read();
7431
7431
  if (value) buffer = (buffer + decoder.decode(value, { stream: true })).replace(/\r\n/g, "\n");
7432
7432
  let boundary = buffer.indexOf("\n\n");
7433
7433
  while (boundary >= 0) {
@@ -7436,7 +7436,7 @@ var init_client = __esm({
7436
7436
  if (found) return found;
7437
7437
  boundary = buffer.indexOf("\n\n");
7438
7438
  }
7439
- if (done) return buffer.trim() === "" ? void 0 : take(buffer);
7439
+ if (done2) return buffer.trim() === "" ? void 0 : take(buffer);
7440
7440
  }
7441
7441
  } catch (err) {
7442
7442
  if (this.opts.signal?.aborted) throw interrupted2();
@@ -7534,11 +7534,11 @@ function folders(ctx, client, dir) {
7534
7534
  return clients.map((c) => ({ client: c, folder: join8(skillsFolder(c, ctx.env), SKILL_NAME) }));
7535
7535
  }
7536
7536
  function installCommand(opts) {
7537
- const parts = ["kenso skill install"];
7538
- if (opts.client !== void 0) parts.push("--client", quote(opts.client));
7539
- if (opts.dir !== void 0) parts.push("--dir", quote(opts.dir));
7540
- if (opts.force) parts.push("--force");
7541
- return parts.join(" ");
7537
+ const parts2 = ["kenso skill install"];
7538
+ if (opts.client !== void 0) parts2.push("--client", quote(opts.client));
7539
+ if (opts.dir !== void 0) parts2.push("--dir", quote(opts.dir));
7540
+ if (opts.force) parts2.push("--force");
7541
+ return parts2.join(" ");
7542
7542
  }
7543
7543
  var SKILL_NAME, AGENT_CLIENTS2, command2, install_default;
7544
7544
  var init_install = __esm({
@@ -7892,10 +7892,10 @@ var init_setup = __esm({
7892
7892
  }
7893
7893
  const different = rows.filter((r) => r.skill.status === "different");
7894
7894
  const pinned = clientFlag ?? (clients.length === 1 ? clients[0] : void 0);
7895
- const parts = ["kenso agent setup"];
7896
- if (pinned !== void 0) parts.push("--client", quote2(pinned));
7897
- if (force || different.length > 0) parts.push("--force");
7898
- const apply = [...parts, "-y"].join(" ");
7895
+ const parts2 = ["kenso agent setup"];
7896
+ if (pinned !== void 0) parts2.push("--client", quote2(pinned));
7897
+ if (force || different.length > 0) parts2.push("--force");
7898
+ const apply = [...parts2, "-y"].join(" ");
7899
7899
  if (!ctx.flags.yes) {
7900
7900
  print({ dryRun: true, mcpUrl: url, clients: rows, next: apply });
7901
7901
  return ExitCode.Ok;
@@ -8246,8 +8246,8 @@ var init_browser_login = __esm({
8246
8246
  defaultDeps = {
8247
8247
  sleep: (ms, signal) => delay2(ms, void 0, signal ? { signal } : void 0),
8248
8248
  now: () => Date.now(),
8249
- spawn: (command35, args) => {
8250
- const child = nodeSpawn(command35, args, { detached: true, stdio: "ignore" });
8249
+ spawn: (command36, args) => {
8250
+ const child = nodeSpawn(command36, args, { detached: true, stdio: "ignore" });
8251
8251
  child.on("error", () => {
8252
8252
  });
8253
8253
  child.unref();
@@ -8517,6 +8517,119 @@ var init_auth2 = __esm({
8517
8517
  }
8518
8518
  });
8519
8519
 
8520
+ // src/commands/completion/completion.ts
8521
+ var completion_exports = {};
8522
+ __export(completion_exports, {
8523
+ SCRIPTS: () => SCRIPTS,
8524
+ default: () => completion_default
8525
+ });
8526
+ var ZSH, BASH, FISH, SCRIPTS, command8, completion_default;
8527
+ var init_completion = __esm({
8528
+ "src/commands/completion/completion.ts"() {
8529
+ "use strict";
8530
+ init_errors();
8531
+ init_exit_codes();
8532
+ ZSH = `#compdef kenso
8533
+ # Tab completion for kenso in zsh. Add this line to ~/.zshrc:
8534
+ # source <(kenso completion zsh)
8535
+ # kenso lists the candidates itself (kenso __complete), so this script stays right as kenso updates.
8536
+ _kenso() {
8537
+ local -a candidates
8538
+ candidates=(\${(f)"$(kenso __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)"})
8539
+ if (( \${#candidates} )); then
8540
+ compadd -a candidates
8541
+ else
8542
+ _files
8543
+ fi
8544
+ }
8545
+ if [[ "\${funcstack[1]}" == "_kenso" ]]; then
8546
+ _kenso "$@"
8547
+ else
8548
+ (( \${+functions[compdef]} )) || { autoload -Uz compinit && compinit }
8549
+ compdef _kenso kenso
8550
+ fi
8551
+ `;
8552
+ BASH = `# Tab completion for kenso in bash. Add this line to ~/.bashrc:
8553
+ # source <(kenso completion bash)
8554
+ # kenso lists the candidates itself (kenso __complete), so this script stays right as kenso updates.
8555
+ _kenso() {
8556
+ # The words up to the cursor, split on blanks only: COMP_WORDS also splits --output=json at the "=".
8557
+ local line="\${COMP_LINE:0:COMP_POINT}" IFS=$' \\t\\n'
8558
+ local -a words candidates
8559
+ read -ra words <<< "$line"
8560
+ case "$line" in *[[:space:]]) words+=("") ;; esac
8561
+ local cur="\${words[\${#words[@]}-1]}"
8562
+ IFS=$'\\n'
8563
+ candidates=($(kenso __complete "\${words[@]:1}" 2>/dev/null))
8564
+ # Bash completes only the text after the "=" of --flag=value, so the candidates drop the "--flag=" too.
8565
+ if [[ "$cur" == *=* && "$COMP_WORDBREAKS" == *=* ]]; then
8566
+ candidates=("\${candidates[@]#"\${cur%%=*}="}")
8567
+ cur="\${cur#*=}"
8568
+ fi
8569
+ COMPREPLY=($(compgen -W "\${candidates[*]}" -- "$cur"))
8570
+ }
8571
+ complete -o default -F _kenso kenso
8572
+ `;
8573
+ FISH = `# Tab completion for kenso in fish. Save it once:
8574
+ # kenso completion fish > ~/.config/fish/completions/kenso.fish
8575
+ # kenso lists the candidates itself (kenso __complete), so this file stays right as kenso updates.
8576
+ function __kenso_complete
8577
+ set -l words (commandline -opc)
8578
+ set -e words[1]
8579
+ set -l current (commandline -ct)
8580
+ set -l candidates (kenso __complete $words "$current" 2>/dev/null)
8581
+ if set -q candidates[1]
8582
+ printf '%s\\n' $candidates
8583
+ else
8584
+ __fish_complete_path "$current"
8585
+ end
8586
+ end
8587
+ complete -c kenso -f -a '(__kenso_complete)'
8588
+ `;
8589
+ SCRIPTS = { bash: BASH, zsh: ZSH, fish: FISH };
8590
+ command8 = {
8591
+ resource: "completion",
8592
+ action: "",
8593
+ summary: "Print the tab-completion script for bash, zsh or fish",
8594
+ brief: "",
8595
+ description: "Prints a script that makes Tab complete kenso's resources, actions and flags. The script asks kenso for the candidates on each Tab, so it stays right as kenso updates: install it once.",
8596
+ flags: {},
8597
+ positionals: [{ name: "shell", required: true, description: "bash, zsh or fish" }],
8598
+ examples: ["kenso completion zsh", "kenso completion bash", "kenso completion fish > ~/.config/fish/completions/kenso.fish"],
8599
+ helpFooter: [
8600
+ "Install it once:",
8601
+ " zsh: add source <(kenso completion zsh) to ~/.zshrc",
8602
+ ' bash: add source <(kenso completion bash) to ~/.bashrc (on bash 3.2: eval "$(kenso completion bash)")',
8603
+ " fish: kenso completion fish > ~/.config/fish/completions/kenso.fish"
8604
+ ],
8605
+ operationIds: [],
8606
+ // It needs no key: reading no config means a broken config file never breaks a shell's startup.
8607
+ ownCredential: () => true,
8608
+ async run(ctx, args) {
8609
+ const shell = args.positionals[0];
8610
+ const script = Object.hasOwn(SCRIPTS, shell) ? SCRIPTS[shell] : void 0;
8611
+ if (script === void 0) {
8612
+ throw usageError(`kenso completion takes bash, zsh or fish (got "${shell}").`, { field: "shell", next: "kenso completion --help" });
8613
+ }
8614
+ ctx.output.writeRaw(script);
8615
+ return ExitCode.Ok;
8616
+ }
8617
+ };
8618
+ completion_default = command8;
8619
+ }
8620
+ });
8621
+
8622
+ // src/commands/completion/index.ts
8623
+ var actions5;
8624
+ var init_completion2 = __esm({
8625
+ "src/commands/completion/index.ts"() {
8626
+ "use strict";
8627
+ actions5 = {
8628
+ "": () => Promise.resolve().then(() => (init_completion(), completion_exports)).then((m) => m.default)
8629
+ };
8630
+ }
8631
+ });
8632
+
8520
8633
  // src/commands/contacts/common.ts
8521
8634
  import { createHash as createHash3 } from "node:crypto";
8522
8635
  import { readFile as readFile5 } from "node:fs/promises";
@@ -8527,9 +8640,9 @@ function stringFlag2(flags, name) {
8527
8640
  const text3 = value.trim();
8528
8641
  return text3 === "" ? void 0 : text3;
8529
8642
  }
8530
- function requireFlag(flags, name, command35, hint) {
8643
+ function requireFlag(flags, name, command36, hint) {
8531
8644
  const value = stringFlag2(flags, name);
8532
- if (value === void 0) throw usageError(`--${name} is required for ${command35}.`, { field: name, next: `${command35} --help`, ...hint ? { hint } : {} });
8645
+ if (value === void 0) throw usageError(`--${name} is required for ${command36}.`, { field: name, next: `${command36} --help`, ...hint ? { hint } : {} });
8533
8646
  return value;
8534
8647
  }
8535
8648
  function positiveId(value) {
@@ -8538,8 +8651,8 @@ function positiveId(value) {
8538
8651
  const id = Number(text3);
8539
8652
  return Number.isSafeInteger(id) && id > 0 ? id : void 0;
8540
8653
  }
8541
- function idFlag(flags, name, command35) {
8542
- const raw = requireFlag(flags, name, command35);
8654
+ function idFlag(flags, name, command36) {
8655
+ const raw = requireFlag(flags, name, command36);
8543
8656
  const id = positiveId(raw);
8544
8657
  if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
8545
8658
  return id;
@@ -8559,19 +8672,19 @@ function isDryRun(ctx) {
8559
8672
  function shellQuote4(value) {
8560
8673
  return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
8561
8674
  }
8562
- function sameCommand2(command35, flags, ctx, extra = []) {
8563
- const parts = [command35];
8675
+ function sameCommand2(command36, flags, ctx, extra = []) {
8676
+ const parts2 = [command36];
8564
8677
  for (const [name, value] of Object.entries(flags)) {
8565
8678
  if (value === void 0 || value === false) continue;
8566
- if (value === true) parts.push(`--${name}`);
8567
- else for (const item of Array.isArray(value) ? value : [value]) parts.push(`--${name}`, shellQuote4(item));
8679
+ if (value === true) parts2.push(`--${name}`);
8680
+ else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${name}`, shellQuote4(item));
8568
8681
  }
8569
8682
  for (const name of ["profile", "workspace"]) {
8570
8683
  const value = ctx.flags[name];
8571
- if (value !== void 0) parts.push(`--${name}`, shellQuote4(value));
8684
+ if (value !== void 0) parts2.push(`--${name}`, shellQuote4(value));
8572
8685
  }
8573
- parts.push(...extra);
8574
- return parts.join(" ");
8686
+ parts2.push(...extra);
8687
+ return parts2.join(" ");
8575
8688
  }
8576
8689
  async function fileSha256(path) {
8577
8690
  return createHash3("sha256").update(await readFile5(resolve5(path))).digest("hex");
@@ -9160,7 +9273,7 @@ function parseDuration(text3) {
9160
9273
  const ms = Number(match[1]) * (UNIT_MS[(match[2] || "s").toLowerCase()] ?? 1e3);
9161
9274
  return Number.isFinite(ms) ? Math.round(ms) : void 0;
9162
9275
  }
9163
- var UNIT_MS, command8, wait_default;
9276
+ var UNIT_MS, command9, wait_default;
9164
9277
  var init_wait = __esm({
9165
9278
  "src/commands/jobs/wait.ts"() {
9166
9279
  "use strict";
@@ -9168,7 +9281,7 @@ var init_wait = __esm({
9168
9281
  init_errors();
9169
9282
  init_exit_codes();
9170
9283
  UNIT_MS = { s: 1e3, m: 6e4, h: 36e5 };
9171
- command8 = {
9284
+ command9 = {
9172
9285
  resource: "jobs",
9173
9286
  action: "wait",
9174
9287
  summary: "Wait for a background job and print it",
@@ -9194,8 +9307,8 @@ var init_wait = __esm({
9194
9307
  timeoutMs,
9195
9308
  signal: ctx.signal,
9196
9309
  onProgress: (j) => {
9197
- const done = j.progress ? `, ${j.progress.completed}/${j.progress.total ?? "?"}` : "";
9198
- ctx.output.progress(`job ${j.id}: ${j.status}${done}`);
9310
+ const done2 = j.progress ? `, ${j.progress.completed}/${j.progress.total ?? "?"}` : "";
9311
+ ctx.output.progress(`job ${j.id}: ${j.status}${done2}`);
9199
9312
  }
9200
9313
  });
9201
9314
  ctx.output.object(job);
@@ -9207,7 +9320,7 @@ var init_wait = __esm({
9207
9320
  });
9208
9321
  }
9209
9322
  };
9210
- wait_default = command8;
9323
+ wait_default = command9;
9211
9324
  }
9212
9325
  });
9213
9326
 
@@ -9389,7 +9502,7 @@ function summarize2(campaignId) {
9389
9502
  notSendable: results.filter((r) => (r.status === "created" || r.status === "updated") && r.sendable === false).length
9390
9503
  });
9391
9504
  }
9392
- var COMMAND2, CHUNK_SIZE2, LINKEDIN_ONLY_CHANNELS, TEMPLATE_HEADER, command9, import_default2;
9505
+ var COMMAND2, CHUNK_SIZE2, LINKEDIN_ONLY_CHANNELS, TEMPLATE_HEADER, command10, import_default2;
9393
9506
  var init_import2 = __esm({
9394
9507
  "src/commands/contacts/import.ts"() {
9395
9508
  "use strict";
@@ -9408,7 +9521,7 @@ var init_import2 = __esm({
9408
9521
  CHUNK_SIZE2 = 1e3;
9409
9522
  LINKEDIN_ONLY_CHANNELS = /* @__PURE__ */ new Set(["linkedin", "linkedin_only"]);
9410
9523
  TEMPLATE_HEADER = `${CONTACT_FIELDS.join(",")},<your custom columns>`;
9411
- command9 = {
9524
+ command10 = {
9412
9525
  resource: "contacts",
9413
9526
  action: "import",
9414
9527
  summary: "Add leads from a CSV or JSONL file to a campaign",
@@ -9497,7 +9610,7 @@ var init_import2 = __esm({
9497
9610
  return outcome.exitCode;
9498
9611
  }
9499
9612
  };
9500
- import_default2 = command9;
9613
+ import_default2 = command10;
9501
9614
  }
9502
9615
  });
9503
9616
 
@@ -9601,7 +9714,7 @@ async function sendUpdateChunk(chunk, ctx) {
9601
9714
  });
9602
9715
  return { results: mapUpdateAnswer(chunk, res.body), rateLimitRemaining: rateLimitRemaining3(res.headers) };
9603
9716
  }
9604
- var COMMAND3, CHUNK_SIZE3, PAGE_SIZE, command10, update_default;
9717
+ var COMMAND3, CHUNK_SIZE3, PAGE_SIZE, command11, update_default;
9605
9718
  var init_update = __esm({
9606
9719
  "src/commands/contacts/update.ts"() {
9607
9720
  "use strict";
@@ -9615,7 +9728,7 @@ var init_update = __esm({
9615
9728
  COMMAND3 = "kenso contacts update";
9616
9729
  CHUNK_SIZE3 = 1e3;
9617
9730
  PAGE_SIZE = 200;
9618
- command10 = {
9731
+ command11 = {
9619
9732
  resource: "contacts",
9620
9733
  action: "update",
9621
9734
  summary: "Edit leads from a CSV or JSONL file, by id or email (also one lead)",
@@ -9686,7 +9799,7 @@ var init_update = __esm({
9686
9799
  return outcome.exitCode;
9687
9800
  }
9688
9801
  };
9689
- update_default = command10;
9802
+ update_default = command11;
9690
9803
  }
9691
9804
  });
9692
9805
 
@@ -9697,12 +9810,12 @@ import { join as join11 } from "node:path";
9697
9810
  function whereDir(env) {
9698
9811
  return join11(runsRoot(env), WHERE_DIR);
9699
9812
  }
9700
- async function unfinishedWhereIds(ctx, command35, args) {
9813
+ async function unfinishedWhereIds(ctx, command36, args) {
9701
9814
  const dir = whereDir(ctx.env);
9702
9815
  const identity = argsIdentity(args);
9703
9816
  const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
9704
9817
  for (const run of await listRuns(ctx.env)) {
9705
- if (run.command !== command35 || run.status === "done" || run.status === "planned") continue;
9818
+ if (run.command !== command36 || run.status === "done" || run.status === "planned") continue;
9706
9819
  if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
9707
9820
  if (run.inputPath?.startsWith(`${dir}/`) && existsSync5(run.inputPath)) return run.inputPath;
9708
9821
  }
@@ -9848,14 +9961,14 @@ async function idsFromRun(ctx, runId) {
9848
9961
  return { ...idItems(ids2), source: "run" };
9849
9962
  }
9850
9963
  async function collectIds(ctx, flags, kind, dryRun2) {
9851
- const command35 = `kenso contacts ${kind}`;
9964
+ const command36 = `kenso contacts ${kind}`;
9852
9965
  const ids2 = stringFlag2(flags, "ids");
9853
9966
  const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
9854
9967
  const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
9855
9968
  const given = [ids2, where, run].filter((v) => v !== void 0).length;
9856
9969
  if (given !== 1) {
9857
9970
  const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
9858
- throw usageError(`${command35} needs exactly one of ${choices}.`, { field: "ids", next: `${command35} --help` });
9971
+ throw usageError(`${command36} needs exactly one of ${choices}.`, { field: "ids", next: `${command36} --help` });
9859
9972
  }
9860
9973
  if (ids2 !== void 0) return idsFromFile(ctx, ids2);
9861
9974
  if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
@@ -10157,7 +10270,7 @@ async function download(ctx, job, exportId, out) {
10157
10270
  }
10158
10271
  return { rows: countRows(body), path };
10159
10272
  }
10160
- var COMMAND4, JOB_TYPE, DEFAULT_TIMEOUT2, CONTENT_PATH, command11, export_default;
10273
+ var COMMAND4, JOB_TYPE, DEFAULT_TIMEOUT2, CONTENT_PATH, command12, export_default;
10161
10274
  var init_export = __esm({
10162
10275
  "src/commands/contacts/export.ts"() {
10163
10276
  "use strict";
@@ -10172,7 +10285,7 @@ var init_export = __esm({
10172
10285
  JOB_TYPE = "contact_export";
10173
10286
  DEFAULT_TIMEOUT2 = "30m";
10174
10287
  CONTENT_PATH = /\/v1\/contact-exports\/([0-9]+)\/content/;
10175
- command11 = {
10288
+ command12 = {
10176
10289
  resource: "contacts",
10177
10290
  action: "export",
10178
10291
  summary: "Export a campaign's contacts to CSV (a segment: contact-exports create)",
@@ -10230,16 +10343,16 @@ var init_export = __esm({
10230
10343
  return ExitCode.Ok;
10231
10344
  }
10232
10345
  };
10233
- export_default = command11;
10346
+ export_default = command12;
10234
10347
  }
10235
10348
  });
10236
10349
 
10237
10350
  // src/commands/contacts/index.ts
10238
- var actions5;
10351
+ var actions6;
10239
10352
  var init_contacts = __esm({
10240
10353
  "src/commands/contacts/index.ts"() {
10241
10354
  "use strict";
10242
- actions5 = {
10355
+ actions6 = {
10243
10356
  import: () => Promise.resolve().then(() => (init_import2(), import_exports2)).then((m) => m.default),
10244
10357
  update: () => Promise.resolve().then(() => (init_update(), update_exports)).then((m) => m.default),
10245
10358
  remove: () => Promise.resolve().then(() => (init_bulk_ids(), bulk_ids_exports)).then((m) => m.remove),
@@ -10354,7 +10467,7 @@ function unknown(words) {
10354
10467
  next: "kenso describe"
10355
10468
  });
10356
10469
  }
10357
- var command12, describe_default;
10470
+ var command13, describe_default;
10358
10471
  var init_describe = __esm({
10359
10472
  "src/commands/describe/describe.ts"() {
10360
10473
  "use strict";
@@ -10367,7 +10480,7 @@ var init_describe = __esm({
10367
10480
  init_manifest();
10368
10481
  init_help();
10369
10482
  init_registry();
10370
- command12 = {
10483
+ command13 = {
10371
10484
  resource: "describe",
10372
10485
  action: "",
10373
10486
  summary: "The command map as JSON: commands, flags, body schemas",
@@ -10408,16 +10521,16 @@ var init_describe = __esm({
10408
10521
  return ExitCode.Ok;
10409
10522
  }
10410
10523
  };
10411
- describe_default = command12;
10524
+ describe_default = command13;
10412
10525
  }
10413
10526
  });
10414
10527
 
10415
10528
  // src/commands/describe/index.ts
10416
- var actions6;
10529
+ var actions7;
10417
10530
  var init_describe2 = __esm({
10418
10531
  "src/commands/describe/index.ts"() {
10419
10532
  "use strict";
10420
- actions6 = {
10533
+ actions7 = {
10421
10534
  "": () => Promise.resolve().then(() => (init_describe(), describe_exports)).then((m) => m.default)
10422
10535
  };
10423
10536
  }
@@ -10432,7 +10545,7 @@ function findTopic(input) {
10432
10545
  const name = input.trim().toLowerCase().replace(/\.md$/, "");
10433
10546
  return TOPICS.find((t) => t.topic === name);
10434
10547
  }
10435
- var NAMES, command13, docs_default;
10548
+ var NAMES, command14, docs_default;
10436
10549
  var init_docs = __esm({
10437
10550
  "src/commands/docs/docs.ts"() {
10438
10551
  "use strict";
@@ -10440,7 +10553,7 @@ var init_docs = __esm({
10440
10553
  init_exit_codes();
10441
10554
  init_content();
10442
10555
  NAMES = TOPICS.map((t) => t.topic).join(", ");
10443
- command13 = {
10556
+ command14 = {
10444
10557
  resource: "docs",
10445
10558
  action: "",
10446
10559
  summary: "Offline docs: the topic list, or one topic",
@@ -10481,16 +10594,16 @@ var init_docs = __esm({
10481
10594
  return ExitCode.Ok;
10482
10595
  }
10483
10596
  };
10484
- docs_default = command13;
10597
+ docs_default = command14;
10485
10598
  }
10486
10599
  });
10487
10600
 
10488
10601
  // src/commands/docs/index.ts
10489
- var actions7;
10602
+ var actions8;
10490
10603
  var init_docs2 = __esm({
10491
10604
  "src/commands/docs/index.ts"() {
10492
10605
  "use strict";
10493
- actions7 = {
10606
+ actions8 = {
10494
10607
  "": () => Promise.resolve().then(() => (init_docs(), docs_exports)).then((m) => m.default)
10495
10608
  };
10496
10609
  }
@@ -10519,7 +10632,7 @@ function configCheck(env) {
10519
10632
  const octal = mode.toString(8).padStart(4, "0");
10520
10633
  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}` };
10521
10634
  }
10522
- var MIN_NODE_MAJOR, command14, actions8;
10635
+ var MIN_NODE_MAJOR, command15, actions9;
10523
10636
  var init_doctor = __esm({
10524
10637
  "src/commands/doctor/index.ts"() {
10525
10638
  "use strict";
@@ -10528,7 +10641,7 @@ var init_doctor = __esm({
10528
10641
  init_exit_codes();
10529
10642
  init_http();
10530
10643
  MIN_NODE_MAJOR = 22;
10531
- command14 = {
10644
+ command15 = {
10532
10645
  resource: "doctor",
10533
10646
  action: "",
10534
10647
  summary: "Check Node, the config, the API and the key",
@@ -10592,18 +10705,18 @@ var init_doctor = __esm({
10592
10705
  return keyFailed ? ExitCode.Auth : ExitCode.Error;
10593
10706
  }
10594
10707
  };
10595
- actions8 = {
10596
- "": async () => command14
10708
+ actions9 = {
10709
+ "": async () => command15
10597
10710
  };
10598
10711
  }
10599
10712
  });
10600
10713
 
10601
10714
  // src/commands/jobs/index.ts
10602
- var actions9;
10715
+ var actions10;
10603
10716
  var init_jobs2 = __esm({
10604
10717
  "src/commands/jobs/index.ts"() {
10605
10718
  "use strict";
10606
- actions9 = {
10719
+ actions10 = {
10607
10720
  wait: () => Promise.resolve().then(() => (init_wait(), wait_exports)).then((m) => m.default)
10608
10721
  };
10609
10722
  }
@@ -10659,7 +10772,7 @@ function isRecord6(value) {
10659
10772
  function textOf(result) {
10660
10773
  return (result.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
10661
10774
  }
10662
- var command15, call_default;
10775
+ var command16, call_default;
10663
10776
  var init_call = __esm({
10664
10777
  "src/commands/mcp/call.ts"() {
10665
10778
  "use strict";
@@ -10667,7 +10780,7 @@ var init_call = __esm({
10667
10780
  init_exit_codes();
10668
10781
  init_input();
10669
10782
  init_connect();
10670
- command15 = {
10783
+ command16 = {
10671
10784
  resource: "mcp",
10672
10785
  action: "call",
10673
10786
  summary: "Call a hosted Kenso MCP tool, such as list_skills",
@@ -10720,7 +10833,7 @@ var init_call = __esm({
10720
10833
  return ExitCode.Ok;
10721
10834
  }
10722
10835
  };
10723
- call_default = command15;
10836
+ call_default = command16;
10724
10837
  }
10725
10838
  });
10726
10839
 
@@ -10729,13 +10842,13 @@ var tools_exports = {};
10729
10842
  __export(tools_exports, {
10730
10843
  default: () => tools_default
10731
10844
  });
10732
- var command16, tools_default;
10845
+ var command17, tools_default;
10733
10846
  var init_tools = __esm({
10734
10847
  "src/commands/mcp/tools.ts"() {
10735
10848
  "use strict";
10736
10849
  init_exit_codes();
10737
10850
  init_connect();
10738
- command16 = {
10851
+ command17 = {
10739
10852
  resource: "mcp",
10740
10853
  action: "tools",
10741
10854
  summary: "List the hosted Kenso MCP's tools",
@@ -10750,16 +10863,16 @@ var init_tools = __esm({
10750
10863
  return ExitCode.Ok;
10751
10864
  }
10752
10865
  };
10753
- tools_default = command16;
10866
+ tools_default = command17;
10754
10867
  }
10755
10868
  });
10756
10869
 
10757
10870
  // src/commands/mcp/index.ts
10758
- var actions10;
10871
+ var actions11;
10759
10872
  var init_mcp = __esm({
10760
10873
  "src/commands/mcp/index.ts"() {
10761
10874
  "use strict";
10762
- actions10 = {
10875
+ actions11 = {
10763
10876
  call: () => Promise.resolve().then(() => (init_call(), call_exports)).then((m) => m.default),
10764
10877
  tools: () => Promise.resolve().then(() => (init_tools(), tools_exports)).then((m) => m.default)
10765
10878
  };
@@ -10837,7 +10950,7 @@ function summarize3(results) {
10837
10950
  }
10838
10951
  return { matched, addedToAccounts, emailFindsQueued };
10839
10952
  }
10840
- var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command17, import_default3;
10953
+ var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command18, import_default3;
10841
10954
  var init_import3 = __esm({
10842
10955
  "src/commands/people/import.ts"() {
10843
10956
  "use strict";
@@ -10869,7 +10982,7 @@ var init_import3 = __esm({
10869
10982
  };
10870
10983
  PERSON_FIELDS = ["email", "fullName", "firstName", "lastName", "linkedinUrl", "title"];
10871
10984
  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.";
10872
- command17 = {
10985
+ command18 = {
10873
10986
  resource: "people",
10874
10987
  action: "import",
10875
10988
  summary: "Create or match people from a CSV or JSONL file, optionally onto accounts",
@@ -10934,16 +11047,16 @@ var init_import3 = __esm({
10934
11047
  return outcome.exitCode;
10935
11048
  }
10936
11049
  };
10937
- import_default3 = command17;
11050
+ import_default3 = command18;
10938
11051
  }
10939
11052
  });
10940
11053
 
10941
11054
  // src/commands/people/index.ts
10942
- var actions11;
11055
+ var actions12;
10943
11056
  var init_people = __esm({
10944
11057
  "src/commands/people/index.ts"() {
10945
11058
  "use strict";
10946
- actions11 = {
11059
+ actions12 = {
10947
11060
  import: () => Promise.resolve().then(() => (init_import3(), import_exports3)).then((m) => m.default)
10948
11061
  };
10949
11062
  }
@@ -10954,14 +11067,14 @@ var list_exports = {};
10954
11067
  __export(list_exports, {
10955
11068
  default: () => list_default
10956
11069
  });
10957
- var command18, list_default;
11070
+ var command19, list_default;
10958
11071
  var init_list = __esm({
10959
11072
  "src/commands/runs/list.ts"() {
10960
11073
  "use strict";
10961
11074
  init_runs();
10962
11075
  init_errors();
10963
11076
  init_exit_codes();
10964
- command18 = {
11077
+ command19 = {
10965
11078
  resource: "runs",
10966
11079
  action: "list",
10967
11080
  summary: "List batch runs, newest first (finds an interrupted run)",
@@ -10982,7 +11095,7 @@ var init_list = __esm({
10982
11095
  return ExitCode.Ok;
10983
11096
  }
10984
11097
  };
10985
- list_default = command18;
11098
+ list_default = command19;
10986
11099
  }
10987
11100
  });
10988
11101
 
@@ -10993,7 +11106,7 @@ __export(show_exports, {
10993
11106
  });
10994
11107
  import { existsSync as existsSync6, readFileSync as readFileSync9 } from "node:fs";
10995
11108
  import { join as join12 } from "node:path";
10996
- var FILES, command19, show_default;
11109
+ var FILES, command20, show_default;
10997
11110
  var init_show = __esm({
10998
11111
  "src/commands/runs/show.ts"() {
10999
11112
  "use strict";
@@ -11008,7 +11121,7 @@ var init_show = __esm({
11008
11121
  ["plan", "plan.json"],
11009
11122
  ["summary", "summary.json"]
11010
11123
  ];
11011
- command19 = {
11124
+ command20 = {
11012
11125
  resource: "runs",
11013
11126
  action: "show",
11014
11127
  summary: "Show one batch run and its files",
@@ -11035,7 +11148,7 @@ var init_show = __esm({
11035
11148
  return ExitCode.Ok;
11036
11149
  }
11037
11150
  };
11038
- show_default = command19;
11151
+ show_default = command20;
11039
11152
  }
11040
11153
  });
11041
11154
 
@@ -11094,14 +11207,14 @@ function resumeArgv(run, globals = {}) {
11094
11207
  async function sha256(path) {
11095
11208
  return createHash5("sha256").update(await readFile8(path)).digest("hex");
11096
11209
  }
11097
- var SKIPPED_KEYS, command20, resume_default;
11210
+ var SKIPPED_KEYS, command21, resume_default;
11098
11211
  var init_resume = __esm({
11099
11212
  "src/commands/runs/resume.ts"() {
11100
11213
  "use strict";
11101
11214
  init_runs();
11102
11215
  init_errors();
11103
11216
  SKIPPED_KEYS = /* @__PURE__ */ new Set(["positionals", "yes", "dryRun", "dry-run", "help", "version"]);
11104
- command20 = {
11217
+ command21 = {
11105
11218
  resource: "runs",
11106
11219
  action: "resume",
11107
11220
  summary: "Continue an interrupted batch run (its command with --yes, no dry run)",
@@ -11156,16 +11269,16 @@ var init_resume = __esm({
11156
11269
  }
11157
11270
  }
11158
11271
  };
11159
- resume_default = command20;
11272
+ resume_default = command21;
11160
11273
  }
11161
11274
  });
11162
11275
 
11163
11276
  // src/commands/runs/index.ts
11164
- var actions12;
11277
+ var actions13;
11165
11278
  var init_runs2 = __esm({
11166
11279
  "src/commands/runs/index.ts"() {
11167
11280
  "use strict";
11168
- actions12 = {
11281
+ actions13 = {
11169
11282
  list: () => Promise.resolve().then(() => (init_list(), list_exports)).then((m) => m.default),
11170
11283
  show: () => Promise.resolve().then(() => (init_show(), show_exports)).then((m) => m.default),
11171
11284
  resume: () => Promise.resolve().then(() => (init_resume(), resume_exports)).then((m) => m.default)
@@ -11174,11 +11287,11 @@ var init_runs2 = __esm({
11174
11287
  });
11175
11288
 
11176
11289
  // src/commands/skill/index.ts
11177
- var actions13;
11290
+ var actions14;
11178
11291
  var init_skill = __esm({
11179
11292
  "src/commands/skill/index.ts"() {
11180
11293
  "use strict";
11181
- actions13 = {
11294
+ actions14 = {
11182
11295
  install: () => Promise.resolve().then(() => (init_install(), install_exports)).then((m) => m.default)
11183
11296
  };
11184
11297
  }
@@ -11414,7 +11527,7 @@ __export(pull_exports, {
11414
11527
  });
11415
11528
  import { mkdir, writeFile as writeFile4 } from "node:fs/promises";
11416
11529
  import { dirname as dirname2, resolve as resolve11 } from "node:path";
11417
- var command21, pull_default;
11530
+ var command22, pull_default;
11418
11531
  var init_pull = __esm({
11419
11532
  "src/commands/studio/pull.ts"() {
11420
11533
  "use strict";
@@ -11424,7 +11537,7 @@ var init_pull = __esm({
11424
11537
  init_common2();
11425
11538
  init_folder();
11426
11539
  init_transfer();
11427
- command21 = {
11540
+ command22 = {
11428
11541
  resource: "studio",
11429
11542
  action: "pull",
11430
11543
  summary: "Write a template version's files to a folder",
@@ -11471,7 +11584,7 @@ var init_pull = __esm({
11471
11584
  return ExitCode.Ok;
11472
11585
  }
11473
11586
  };
11474
- pull_default = command21;
11587
+ pull_default = command22;
11475
11588
  }
11476
11589
  });
11477
11590
 
@@ -11504,7 +11617,7 @@ var push_exports = {};
11504
11617
  __export(push_exports, {
11505
11618
  default: () => push_default
11506
11619
  });
11507
- var BUILT_BY, DEFAULT_MESSAGE, command22, push_default;
11620
+ var BUILT_BY, DEFAULT_MESSAGE, command23, push_default;
11508
11621
  var init_push = __esm({
11509
11622
  "src/commands/studio/push.ts"() {
11510
11623
  "use strict";
@@ -11516,7 +11629,7 @@ var init_push = __esm({
11516
11629
  init_read();
11517
11630
  BUILT_BY = "customer_agent";
11518
11631
  DEFAULT_MESSAGE = "Pushed with the Kenso CLI";
11519
- command22 = {
11632
+ command23 = {
11520
11633
  resource: "studio",
11521
11634
  action: "push",
11522
11635
  summary: "Save a folder's files to a template's draft and print the validation",
@@ -11608,7 +11721,7 @@ var init_push = __esm({
11608
11721
  );
11609
11722
  }
11610
11723
  };
11611
- push_default = command22;
11724
+ push_default = command23;
11612
11725
  }
11613
11726
  });
11614
11727
 
@@ -11617,7 +11730,7 @@ var validate_exports = {};
11617
11730
  __export(validate_exports, {
11618
11731
  default: () => validate_default
11619
11732
  });
11620
- var command23, validate_default;
11733
+ var command24, validate_default;
11621
11734
  var init_validate = __esm({
11622
11735
  "src/commands/studio/validate.ts"() {
11623
11736
  "use strict";
@@ -11626,7 +11739,7 @@ var init_validate = __esm({
11626
11739
  init_columns();
11627
11740
  init_common2();
11628
11741
  init_read();
11629
- command23 = {
11742
+ command24 = {
11630
11743
  resource: "studio",
11631
11744
  action: "validate",
11632
11745
  summary: "Validate a folder's files against a template without saving them",
@@ -11655,7 +11768,7 @@ var init_validate = __esm({
11655
11768
  throw validationFailed(validation, "The files have validation errors", commandLine2(ctx, "studio validate", args));
11656
11769
  }
11657
11770
  };
11658
- validate_default = command23;
11771
+ validate_default = command24;
11659
11772
  }
11660
11773
  });
11661
11774
 
@@ -11688,12 +11801,12 @@ async function warnIfFolderDiffers(ctx, templateId, dir, versionId, push) {
11688
11801
  const onlySaved = Object.keys(saved).filter((path) => !localPaths.has(path)).sort();
11689
11802
  const total = changed.length + onlyLocal.length + onlySaved.length;
11690
11803
  if (total === 0) return;
11691
- const parts = [
11804
+ const parts2 = [
11692
11805
  changed.length ? `changed: ${list(changed)}` : "",
11693
11806
  onlyLocal.length ? `only in the folder: ${list(onlyLocal)}` : "",
11694
11807
  onlySaved.length ? `only saved: ${list(onlySaved)}` : ""
11695
11808
  ].filter(Boolean);
11696
- ctx.output.warn(`The preview renders the saved version, not your folder: ${total} file${total === 1 ? "" : "s"} differ (${parts.join("; ")}). Push first: ${push}`);
11809
+ ctx.output.warn(`The preview renders the saved version, not your folder: ${total} file${total === 1 ? "" : "s"} differ (${parts2.join("; ")}). Push first: ${push}`);
11697
11810
  }
11698
11811
  function accountIds(value) {
11699
11812
  if (value === void 0) return void 0;
@@ -11704,7 +11817,7 @@ function accountIds(value) {
11704
11817
  }
11705
11818
  return ids2.map(Number);
11706
11819
  }
11707
- var SHOWN, command24, preview_default;
11820
+ var SHOWN, command25, preview_default;
11708
11821
  var init_preview = __esm({
11709
11822
  "src/commands/studio/preview.ts"() {
11710
11823
  "use strict";
@@ -11716,7 +11829,7 @@ var init_preview = __esm({
11716
11829
  init_common2();
11717
11830
  init_folder();
11718
11831
  SHOWN = 5;
11719
- command24 = {
11832
+ command25 = {
11720
11833
  resource: "studio",
11721
11834
  action: "preview",
11722
11835
  summary: "Render a saved version for up to 3 accounts; for local edits, studio push them to the draft first",
@@ -11765,14 +11878,14 @@ var init_preview = __esm({
11765
11878
  return ExitCode.Ok;
11766
11879
  }
11767
11880
  };
11768
- preview_default = command24;
11881
+ preview_default = command25;
11769
11882
  }
11770
11883
  });
11771
11884
 
11772
11885
  // src/commands/studio/fill-runs.ts
11773
11886
  import { setTimeout as delay5 } from "node:timers/promises";
11774
11887
  async function estimateFill(ctx, templateId, count) {
11775
- const parts = [];
11888
+ const parts2 = [];
11776
11889
  for (let left = count; left > 0; left -= RUN_SIZE) {
11777
11890
  const res = await ctx.client.request({
11778
11891
  method: "POST",
@@ -11780,22 +11893,22 @@ async function estimateFill(ctx, templateId, count) {
11780
11893
  body: { templateId, accountCount: Math.min(left, RUN_SIZE) },
11781
11894
  signal: ctx.signal
11782
11895
  });
11783
- parts.push(unwrap(res.body) ?? {});
11896
+ parts2.push(unwrap(res.body) ?? {});
11784
11897
  }
11785
- const millicredits = parts.reduce((sum, p) => sum + (p.millicredits ?? 0), 0);
11898
+ const millicredits = parts2.reduce((sum, p) => sum + (p.millicredits ?? 0), 0);
11786
11899
  const breakdown = /* @__PURE__ */ new Map();
11787
- for (const line of parts.flatMap((p) => p.breakdown ?? [])) {
11900
+ for (const line of parts2.flatMap((p) => p.breakdown ?? [])) {
11788
11901
  const item = line.item ?? "";
11789
11902
  breakdown.set(item, (breakdown.get(item) ?? 0) + (line.millicredits ?? 0));
11790
11903
  }
11791
11904
  return {
11792
11905
  templateId,
11793
- templateVersionId: parts[0]?.templateVersionId,
11794
- executor: parts[0]?.executor,
11906
+ templateVersionId: parts2[0]?.templateVersionId,
11907
+ executor: parts2[0]?.executor,
11795
11908
  accountCount: count,
11796
11909
  millicredits,
11797
11910
  credits: millicredits / 1e3,
11798
- perAccountMillicredits: parts[0]?.perAccountMillicredits,
11911
+ perAccountMillicredits: parts2[0]?.perAccountMillicredits,
11799
11912
  breakdown: [...breakdown.entries()].map(([item, sum]) => ({ item, millicredits: sum }))
11800
11913
  };
11801
11914
  }
@@ -11966,7 +12079,7 @@ function estimateOutput(templateId, target, estimate2) {
11966
12079
  ...target.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
11967
12080
  };
11968
12081
  }
11969
- var COMMAND6, sha2562, command25, fill_default;
12082
+ var COMMAND6, sha2562, command26, fill_default;
11970
12083
  var init_fill = __esm({
11971
12084
  "src/commands/studio/fill.ts"() {
11972
12085
  "use strict";
@@ -11982,7 +12095,7 @@ var init_fill = __esm({
11982
12095
  init_fill_runs();
11983
12096
  COMMAND6 = "studio fill";
11984
12097
  sha2562 = (data) => createHash8("sha256").update(data).digest("hex");
11985
- command25 = {
12098
+ command26 = {
11986
12099
  resource: "studio",
11987
12100
  action: "fill",
11988
12101
  summary: "Fill a template on many accounts or campaign leads (estimate first)",
@@ -12042,16 +12155,16 @@ var init_fill = __esm({
12042
12155
  return outcome.exitCode;
12043
12156
  }
12044
12157
  };
12045
- fill_default = command25;
12158
+ fill_default = command26;
12046
12159
  }
12047
12160
  });
12048
12161
 
12049
12162
  // src/commands/studio/index.ts
12050
- var actions14;
12163
+ var actions15;
12051
12164
  var init_studio2 = __esm({
12052
12165
  "src/commands/studio/index.ts"() {
12053
12166
  "use strict";
12054
- actions14 = {
12167
+ actions15 = {
12055
12168
  pull: () => Promise.resolve().then(() => (init_pull(), pull_exports)).then((m) => m.default),
12056
12169
  push: () => Promise.resolve().then(() => (init_push(), push_exports)).then((m) => m.default),
12057
12170
  validate: () => Promise.resolve().then(() => (init_validate(), validate_exports)).then((m) => m.default),
@@ -12193,7 +12306,7 @@ function readBody(req) {
12193
12306
  function reply(res, status, body) {
12194
12307
  res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(body));
12195
12308
  }
12196
- var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command26, listen_default;
12309
+ var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command27, listen_default;
12197
12310
  var init_listen = __esm({
12198
12311
  "src/commands/webhooks/listen.ts"() {
12199
12312
  "use strict";
@@ -12204,7 +12317,7 @@ var init_listen = __esm({
12204
12317
  MIN_POLL_MS = 1e3;
12205
12318
  MAX_POLL_MS = 6e4;
12206
12319
  MAX_TRIGGER_BYTES = 1e6;
12207
- command26 = {
12320
+ command27 = {
12208
12321
  resource: "webhooks",
12209
12322
  action: "listen",
12210
12323
  summary: "Stream the workspace's events and forward them, signed, to a local handler",
@@ -12310,7 +12423,7 @@ var init_listen = __esm({
12310
12423
  return ExitCode.Ok;
12311
12424
  }
12312
12425
  };
12313
- listen_default = command26;
12426
+ listen_default = command27;
12314
12427
  }
12315
12428
  });
12316
12429
 
@@ -12329,7 +12442,7 @@ function notRunning() {
12329
12442
  next: LISTEN_NEXT
12330
12443
  });
12331
12444
  }
12332
- var LISTEN_NEXT, command27, trigger_default;
12445
+ var LISTEN_NEXT, command28, trigger_default;
12333
12446
  var init_trigger = __esm({
12334
12447
  "src/commands/webhooks/trigger.ts"() {
12335
12448
  "use strict";
@@ -12338,7 +12451,7 @@ var init_trigger = __esm({
12338
12451
  init_http();
12339
12452
  init_local();
12340
12453
  LISTEN_NEXT = "kenso webhooks listen --forward-to http://localhost:3000/hook";
12341
- command27 = {
12454
+ command28 = {
12342
12455
  resource: "webhooks",
12343
12456
  action: "trigger",
12344
12457
  summary: "Send a sample event of one type through the running kenso webhooks listen",
@@ -12395,16 +12508,16 @@ var init_trigger = __esm({
12395
12508
  return ExitCode.Ok;
12396
12509
  }
12397
12510
  };
12398
- trigger_default = command27;
12511
+ trigger_default = command28;
12399
12512
  }
12400
12513
  });
12401
12514
 
12402
12515
  // src/commands/webhooks/index.ts
12403
- var actions15;
12516
+ var actions16;
12404
12517
  var init_webhooks2 = __esm({
12405
12518
  "src/commands/webhooks/index.ts"() {
12406
12519
  "use strict";
12407
- actions15 = {
12520
+ actions16 = {
12408
12521
  listen: () => Promise.resolve().then(() => (init_listen(), listen_exports)).then((m) => m.default),
12409
12522
  trigger: () => Promise.resolve().then(() => (init_trigger(), trigger_exports)).then((m) => m.default)
12410
12523
  };
@@ -12591,14 +12704,14 @@ var status_exports2 = {};
12591
12704
  __export(status_exports2, {
12592
12705
  default: () => status_default2
12593
12706
  });
12594
- var command28, status_default2;
12707
+ var command29, status_default2;
12595
12708
  var init_status2 = __esm({
12596
12709
  "src/commands/work/status.ts"() {
12597
12710
  "use strict";
12598
12711
  init_exit_codes();
12599
12712
  init_http();
12600
12713
  init_common3();
12601
- command28 = {
12714
+ command29 = {
12602
12715
  resource: "work",
12603
12716
  action: "status",
12604
12717
  summary: "Show the Kenso AI work waiting for your own agent, per kind",
@@ -12631,7 +12744,7 @@ var init_status2 = __esm({
12631
12744
  return ExitCode.Ok;
12632
12745
  }
12633
12746
  };
12634
- status_default2 = command28;
12747
+ status_default2 = command29;
12635
12748
  }
12636
12749
  });
12637
12750
 
@@ -12763,9 +12876,9 @@ var init_files = __esm({
12763
12876
  import { execFile, spawnSync as spawnSync2 } from "node:child_process";
12764
12877
  import { readFileSync as readFileSync12 } from "node:fs";
12765
12878
  import { isAbsolute as isAbsolute2 } from "node:path";
12766
- function sudoArgs(user, command35, args, keep = [], set = {}) {
12879
+ function sudoArgs(user, command36, args, keep = [], set = {}) {
12767
12880
  const assignments = Object.entries(set).map(([name, value]) => `${name}=${value}`);
12768
- return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command35, ...args];
12881
+ return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command36, ...args];
12769
12882
  }
12770
12883
  function agentKensoEnv(opts) {
12771
12884
  return {
@@ -12775,12 +12888,12 @@ function agentKensoEnv(opts) {
12775
12888
  AI_AGENT: opts.agentName
12776
12889
  };
12777
12890
  }
12778
- function sudoExec(user, command35, args, opts = {}) {
12891
+ function sudoExec(user, command36, args, opts = {}) {
12779
12892
  const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
12780
12893
  return new Promise((resolve16) => {
12781
12894
  execFile(
12782
12895
  sudo,
12783
- [...lead, ...sudoArgs(user.name, command35, args)],
12896
+ [...lead, ...sudoArgs(user.name, command36, args)],
12784
12897
  { env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
12785
12898
  (err, stdout, stderr) => {
12786
12899
  const code = err ? err.code : 0;
@@ -12890,9 +13003,9 @@ var init_folder2 = __esm({
12890
13003
  init_redact();
12891
13004
  init_agent_user();
12892
13005
  WorkRunFolder = class {
12893
- constructor(ctx, command35, args, outDir, shared = false) {
13006
+ constructor(ctx, command36, args, outDir, shared = false) {
12894
13007
  this.ctx = ctx;
12895
- this.command = command35;
13008
+ this.command = command36;
12896
13009
  this.args = args;
12897
13010
  this.outDir = outDir;
12898
13011
  this.shared = shared;
@@ -13007,7 +13120,7 @@ var pull_exports2 = {};
13007
13120
  __export(pull_exports2, {
13008
13121
  default: () => pull_default2
13009
13122
  });
13010
- var MAX_FILES, command29, pull_default2;
13123
+ var MAX_FILES, command30, pull_default2;
13011
13124
  var init_pull2 = __esm({
13012
13125
  "src/commands/work/pull.ts"() {
13013
13126
  "use strict";
@@ -13016,7 +13129,7 @@ var init_pull2 = __esm({
13016
13129
  init_common3();
13017
13130
  init_folder2();
13018
13131
  MAX_FILES = 100;
13019
- command29 = {
13132
+ command30 = {
13020
13133
  resource: "work",
13021
13134
  action: "pull",
13022
13135
  summary: "Claim waiting work into local work files, to answer by hand",
@@ -13092,7 +13205,7 @@ var init_pull2 = __esm({
13092
13205
  return interrupted6 ? ExitCode.Interrupted : ExitCode.Ok;
13093
13206
  }
13094
13207
  };
13095
- pull_default2 = command29;
13208
+ pull_default2 = command30;
13096
13209
  }
13097
13210
  });
13098
13211
 
@@ -13234,7 +13347,7 @@ __export(submit_exports, {
13234
13347
  default: () => submit_default
13235
13348
  });
13236
13349
  import { resolve as resolve14 } from "node:path";
13237
- var command30, submit_default;
13350
+ var command31, submit_default;
13238
13351
  var init_submit = __esm({
13239
13352
  "src/commands/work/submit.ts"() {
13240
13353
  "use strict";
@@ -13243,7 +13356,7 @@ var init_submit = __esm({
13243
13356
  init_files();
13244
13357
  init_answers();
13245
13358
  init_common3();
13246
- command30 = {
13359
+ command31 = {
13247
13360
  resource: "work",
13248
13361
  action: "submit",
13249
13362
  summary: "Send answers files to Kenso and write each one's results",
@@ -13275,7 +13388,7 @@ var init_submit = __esm({
13275
13388
  return totals.rejected > 0 ? ExitCode.Partial : ExitCode.Ok;
13276
13389
  }
13277
13390
  };
13278
- submit_default = command30;
13391
+ submit_default = command31;
13279
13392
  }
13280
13393
  });
13281
13394
 
@@ -13296,7 +13409,7 @@ function claimIdOf(arg) {
13296
13409
  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..." });
13297
13410
  return arg;
13298
13411
  }
13299
- var CLAIM_ID, command31, release_default;
13412
+ var CLAIM_ID, command32, release_default;
13300
13413
  var init_release = __esm({
13301
13414
  "src/commands/work/release.ts"() {
13302
13415
  "use strict";
@@ -13305,7 +13418,7 @@ var init_release = __esm({
13305
13418
  init_files();
13306
13419
  init_common3();
13307
13420
  CLAIM_ID = /^[A-Za-z0-9_-]{1,64}$/;
13308
- command31 = {
13421
+ command32 = {
13309
13422
  resource: "work",
13310
13423
  action: "release",
13311
13424
  summary: "Give claimed work back to the queue now",
@@ -13324,7 +13437,7 @@ var init_release = __esm({
13324
13437
  return ExitCode.Ok;
13325
13438
  }
13326
13439
  };
13327
- release_default = command31;
13440
+ release_default = command32;
13328
13441
  }
13329
13442
  });
13330
13443
 
@@ -13663,12 +13776,12 @@ function plain(text3) {
13663
13776
  return text3.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
13664
13777
  }
13665
13778
  function runStatus(bin, args, env, adapter, runAs) {
13666
- const command35 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
13779
+ const command36 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
13667
13780
  const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
13668
13781
  const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
13669
13782
  return new Promise((resolve16) => {
13670
13783
  execFile2(
13671
- command35,
13784
+ command36,
13672
13785
  commandArgs2,
13673
13786
  { ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
13674
13787
  (err, stdout, stderr) => {
@@ -14302,8 +14415,8 @@ import { closeSync as closeSync2, fchmodSync as fchmodSync2, openSync as openSyn
14302
14415
  import { join as join23 } from "node:path";
14303
14416
  function agentGuide(opts) {
14304
14417
  const browser = opts.browser ?? findOperation("browser-runs", "create") !== void 0;
14305
- const parts = opts.kensoKey ? [JOB, KENSO, ...browser ? [BROWSER] : [], NEVER] : [JOB, NO_KENSO, NEVER];
14306
- return parts.join("\n");
14418
+ const parts2 = opts.kensoKey ? [JOB, KENSO, ...browser ? [BROWSER] : [], NEVER] : [JOB, NO_KENSO, NEVER];
14419
+ return parts2.join("\n");
14307
14420
  }
14308
14421
  function writeAgentGuide(dir, text3, mode = WORK_FILE_MODE) {
14309
14422
  for (const name of GUIDE_FILES) {
@@ -14748,7 +14861,7 @@ var run_exports = {};
14748
14861
  __export(run_exports, {
14749
14862
  default: () => run_default
14750
14863
  });
14751
- var FAILURES_IN_A_ROW, command32, run_default;
14864
+ var FAILURES_IN_A_ROW, command33, run_default;
14752
14865
  var init_run = __esm({
14753
14866
  "src/commands/work/run.ts"() {
14754
14867
  "use strict";
@@ -14769,7 +14882,7 @@ var init_run = __esm({
14769
14882
  init_folder2();
14770
14883
  init_stop();
14771
14884
  FAILURES_IN_A_ROW = 3;
14772
- command32 = {
14885
+ command33 = {
14773
14886
  resource: "work",
14774
14887
  action: "run",
14775
14888
  summary: "Run your own coding agent on the waiting work until the queue is empty",
@@ -14980,7 +15093,7 @@ var init_run = __esm({
14980
15093
  return;
14981
15094
  }
14982
15095
  const jobTotals = zeroTotals();
14983
- let done = 0;
15096
+ let done2 = 0;
14984
15097
  let submitError;
14985
15098
  let kept;
14986
15099
  let refused;
@@ -14994,7 +15107,7 @@ var init_run = __esm({
14994
15107
  ...scanner ? { check: (answers, agent) => scanner.check(answers, agent) } : {}
14995
15108
  });
14996
15109
  addTotals(jobTotals, sent.totals);
14997
- done = settled(sent.results);
15110
+ done2 = settled(sent.results);
14998
15111
  } catch (err) {
14999
15112
  if (err instanceof AnswerRefusedError) {
15000
15113
  refused = err;
@@ -15006,7 +15119,7 @@ var init_run = __esm({
15006
15119
  }
15007
15120
  }
15008
15121
  }
15009
- const giveBack = kept === void 0 && (done < claim.items.length || stop.signal.aborted);
15122
+ const giveBack = kept === void 0 && (done2 < claim.items.length || stop.signal.aborted);
15010
15123
  if (giveBack) await releaseOnce(claim.id);
15011
15124
  else open.delete(claim.id);
15012
15125
  if (kept !== void 0) {
@@ -15092,16 +15205,16 @@ var init_run = __esm({
15092
15205
  return exitCodeFor(reason, totals.rejected > 0 || jobsFailed > 0);
15093
15206
  }
15094
15207
  };
15095
- run_default = command32;
15208
+ run_default = command33;
15096
15209
  }
15097
15210
  });
15098
15211
 
15099
15212
  // src/commands/work/index.ts
15100
- var actions16;
15213
+ var actions17;
15101
15214
  var init_work2 = __esm({
15102
15215
  "src/commands/work/index.ts"() {
15103
15216
  "use strict";
15104
- actions16 = {
15217
+ actions17 = {
15105
15218
  status: () => Promise.resolve().then(() => (init_status2(), status_exports2)).then((m) => m.default),
15106
15219
  pull: () => Promise.resolve().then(() => (init_pull2(), pull_exports2)).then((m) => m.default),
15107
15220
  submit: () => Promise.resolve().then(() => (init_submit(), submit_exports)).then((m) => m.default),
@@ -15125,14 +15238,14 @@ function parseLimit(value) {
15125
15238
  }
15126
15239
  return limit;
15127
15240
  }
15128
- var MAX_LIMIT, command33, list_default2;
15241
+ var MAX_LIMIT, command34, list_default2;
15129
15242
  var init_list2 = __esm({
15130
15243
  "src/commands/workspace/list.ts"() {
15131
15244
  "use strict";
15132
15245
  init_errors();
15133
15246
  init_exit_codes();
15134
15247
  MAX_LIMIT = 200;
15135
- command33 = {
15248
+ command34 = {
15136
15249
  resource: "workspace",
15137
15250
  action: "list",
15138
15251
  summary: "List the workspaces your key can use",
@@ -15160,7 +15273,7 @@ var init_list2 = __esm({
15160
15273
  return ExitCode.Ok;
15161
15274
  }
15162
15275
  };
15163
- list_default2 = command33;
15276
+ list_default2 = command34;
15164
15277
  }
15165
15278
  });
15166
15279
 
@@ -15169,7 +15282,7 @@ var use_exports = {};
15169
15282
  __export(use_exports, {
15170
15283
  default: () => use_default
15171
15284
  });
15172
- var command34, use_default;
15285
+ var command35, use_default;
15173
15286
  var init_use = __esm({
15174
15287
  "src/commands/workspace/use.ts"() {
15175
15288
  "use strict";
@@ -15177,7 +15290,7 @@ var init_use = __esm({
15177
15290
  init_errors();
15178
15291
  init_exit_codes();
15179
15292
  init_http();
15180
- command34 = {
15293
+ command35 = {
15181
15294
  resource: "workspace",
15182
15295
  action: "use",
15183
15296
  summary: "Set the profile's default workspace",
@@ -15234,16 +15347,16 @@ var init_use = __esm({
15234
15347
  return ExitCode.Ok;
15235
15348
  }
15236
15349
  };
15237
- use_default = command34;
15350
+ use_default = command35;
15238
15351
  }
15239
15352
  });
15240
15353
 
15241
15354
  // src/commands/workspace/index.ts
15242
- var actions17;
15355
+ var actions18;
15243
15356
  var init_workspace = __esm({
15244
15357
  "src/commands/workspace/index.ts"() {
15245
15358
  "use strict";
15246
- actions17 = {
15359
+ actions18 = {
15247
15360
  list: () => Promise.resolve().then(() => (init_list2(), list_exports2)).then((m) => m.default),
15248
15361
  use: () => Promise.resolve().then(() => (init_use(), use_exports)).then((m) => m.default)
15249
15362
  };
@@ -15267,6 +15380,7 @@ var init_registry = __esm({
15267
15380
  init_agent2();
15268
15381
  init_api3();
15269
15382
  init_auth2();
15383
+ init_completion2();
15270
15384
  init_contacts();
15271
15385
  init_describe2();
15272
15386
  init_docs2();
@@ -15285,22 +15399,23 @@ var init_registry = __esm({
15285
15399
  agent: actions2,
15286
15400
  api: actions3,
15287
15401
  auth: actions4,
15288
- contacts: actions5,
15289
- describe: actions6,
15290
- docs: actions7,
15291
- doctor: actions8,
15292
- jobs: actions9,
15402
+ completion: actions5,
15403
+ contacts: actions6,
15404
+ describe: actions7,
15405
+ docs: actions8,
15406
+ doctor: actions9,
15407
+ jobs: actions10,
15293
15408
  login: topLevel("login", actions4.login, "kenso auth login"),
15294
15409
  logout: topLevel("logout", actions4.logout, "kenso auth logout"),
15295
- mcp: actions10,
15296
- people: actions11,
15297
- runs: actions12,
15298
- skill: actions13,
15299
- studio: actions14,
15300
- webhooks: actions15,
15410
+ mcp: actions11,
15411
+ people: actions12,
15412
+ runs: actions13,
15413
+ skill: actions14,
15414
+ studio: actions15,
15415
+ webhooks: actions16,
15301
15416
  whoami: topLevel("whoami", actions4.status, "kenso auth status"),
15302
- work: actions16,
15303
- workspace: actions17
15417
+ work: actions17,
15418
+ workspace: actions18
15304
15419
  };
15305
15420
  resourceAliases = { leads: "contacts" };
15306
15421
  }
@@ -15322,10 +15437,10 @@ function lazyFeatures(opts) {
15322
15437
  };
15323
15438
  }
15324
15439
  function describeGates(gates) {
15325
- const parts = [];
15326
- if (gates.all?.length) parts.push(gates.all.join(" and "));
15327
- if (gates.any?.length) parts.push(gates.any.length === 1 ? gates.any[0] : `one of ${gates.any.join(", ")}`);
15328
- return parts.join(" and ");
15440
+ const parts2 = [];
15441
+ if (gates.all?.length) parts2.push(gates.all.join(" and "));
15442
+ if (gates.any?.length) parts2.push(gates.any.length === 1 ? gates.any[0] : `one of ${gates.any.join(", ")}`);
15443
+ return parts2.join(" and ");
15329
15444
  }
15330
15445
  async function visibleSpecs(specs, opts, getFeatures, hidden) {
15331
15446
  const visible = [];
@@ -15388,10 +15503,10 @@ function commandName(spec) {
15388
15503
  return spec.action ? `kenso ${spec.resource} ${spec.action}` : `kenso ${spec.resource}`;
15389
15504
  }
15390
15505
  function usageLine2(spec) {
15391
- const parts = [commandName(spec)];
15392
- for (const p of spec.positionals ?? []) parts.push(`${p.required ? `<${p.name}>` : `[${p.name}]`}${p.variadic ? "..." : ""}`);
15393
- if (Object.keys(spec.flags).length > 0) parts.push("[flags]");
15394
- return parts.join(" ");
15506
+ const parts2 = [commandName(spec)];
15507
+ for (const p of spec.positionals ?? []) parts2.push(`${p.required ? `<${p.name}>` : `[${p.name}]`}${p.variadic ? "..." : ""}`);
15508
+ if (Object.keys(spec.flags).length > 0) parts2.push("[flags]");
15509
+ return parts2.join(" ");
15395
15510
  }
15396
15511
  function flagLabel(name, flag) {
15397
15512
  const long = `--${name}${flag.type === "string" ? " <value>" : ""}`;
@@ -15437,8 +15552,8 @@ async function renderTopHelp(opts) {
15437
15552
  names.push(withPositionals(spec, spec.action));
15438
15553
  groups.set(hint, names);
15439
15554
  }
15440
- const actions18 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
15441
- if (actions18.length > 0) rows.push([resource, actions18.join(", ")]);
15555
+ const actions20 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
15556
+ if (actions20.length > 0) rows.push([resource, actions20.join(", ")]);
15442
15557
  }
15443
15558
  const at = 4 + Math.min(22, Math.max(0, ...rows.map(([left]) => left.length)));
15444
15559
  lines.push(
@@ -15451,7 +15566,7 @@ async function renderTopHelp(opts) {
15451
15566
  const [area = "", action = ""] = name.split(" ");
15452
15567
  byArea.set(area, [...byArea.get(area) ?? [], action]);
15453
15568
  }
15454
- const named = [...byArea.entries()].map(([area, actions18]) => `${area} ${actions18.join("|")}`);
15569
+ const named = [...byArea.entries()].map(([area, actions20]) => `${area} ${actions20.join("|")}`);
15455
15570
  lines.push(wrap(`Beta, hidden here but they run (the server decides): ${named.join(", ")}.`, " "));
15456
15571
  }
15457
15572
  const generated = await listGenerated({ features: opts.allCommands ? [] : getFeatures, env: opts.env });
@@ -15459,16 +15574,16 @@ async function renderTopHelp(opts) {
15459
15574
  if (visible.length > 0) {
15460
15575
  const byResource = /* @__PURE__ */ new Map();
15461
15576
  for (const g of visible) {
15462
- const actions18 = byResource.get(g.resource) ?? [];
15463
- actions18.push(`${g.action}${g.beta ? " (beta)" : ""}`);
15464
- byResource.set(g.resource, actions18);
15577
+ const actions20 = byResource.get(g.resource) ?? [];
15578
+ actions20.push(`${g.action}${g.beta ? " (beta)" : ""}`);
15579
+ byResource.set(g.resource, actions20);
15465
15580
  }
15466
- const sorted = [...byResource.entries()].sort(([a], [b]) => a.localeCompare(b));
15581
+ const sorted2 = [...byResource.entries()].sort(([a], [b]) => a.localeCompare(b));
15467
15582
  if (opts.allCommands) {
15468
- const generatedRows = sorted.map(([resource, actions18]) => [resource, actions18.sort().join(", ")]);
15583
+ const generatedRows = sorted2.map(([resource, actions20]) => [resource, actions20.sort().join(", ")]);
15469
15584
  lines.push("", "API resources (kenso <resource> <action>):", columns(generatedRows));
15470
15585
  } else {
15471
- const names = new Set(sorted.map(([resource]) => resource));
15586
+ const names = new Set(sorted2.map(([resource]) => resource));
15472
15587
  const common = COMMON_RESOURCES.filter((r) => names.has(r)).join(", ");
15473
15588
  const hidden = generated.length - visible.length + hiddenSpecs.count;
15474
15589
  lines.push(
@@ -15606,6 +15721,27 @@ var init_help = __esm({
15606
15721
  }
15607
15722
  });
15608
15723
 
15724
+ // src/core/closed-pipe.ts
15725
+ function guardClosedPipe(stream) {
15726
+ if (guardedStreams.has(stream)) return;
15727
+ guardedStreams.add(stream);
15728
+ stream.on("error", (err) => {
15729
+ if (err.code === "EPIPE") {
15730
+ process.exit(ExitCode.Ok);
15731
+ return;
15732
+ }
15733
+ throw err;
15734
+ });
15735
+ }
15736
+ var guardedStreams;
15737
+ var init_closed_pipe = __esm({
15738
+ "src/core/closed-pipe.ts"() {
15739
+ "use strict";
15740
+ init_exit_codes();
15741
+ guardedStreams = /* @__PURE__ */ new WeakSet();
15742
+ }
15743
+ });
15744
+
15609
15745
  // src/core/flag-names.ts
15610
15746
  function distance(a, b) {
15611
15747
  let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
@@ -15655,13 +15791,234 @@ var init_flag_names = __esm({
15655
15791
  }
15656
15792
  });
15657
15793
 
15794
+ // src/core/invoked.ts
15795
+ import { realpathSync } from "node:fs";
15796
+ import { pathToFileURL } from "node:url";
15797
+ function invokedDirectly(moduleUrl) {
15798
+ const script = process.argv[1];
15799
+ if (!script) return false;
15800
+ try {
15801
+ return moduleUrl === pathToFileURL(realpathSync(script)).href;
15802
+ } catch {
15803
+ return false;
15804
+ }
15805
+ }
15806
+ var init_invoked = __esm({
15807
+ "src/core/invoked.ts"() {
15808
+ "use strict";
15809
+ }
15810
+ });
15811
+
15812
+ // src/core/update-notice.ts
15813
+ import { mkdirSync as mkdirSync5, readFileSync as readFileSync13, renameSync as renameSync4, writeFileSync as writeFileSync7 } from "node:fs";
15814
+ import { dirname as dirname5, join as join24 } from "node:path";
15815
+ function readCheck(file) {
15816
+ try {
15817
+ const parsed2 = JSON.parse(readFileSync13(file, "utf8"));
15818
+ if (typeof parsed2?.checkedAt !== "string") return void 0;
15819
+ return { checkedAt: parsed2.checkedAt, ...typeof parsed2.latest === "string" ? { latest: parsed2.latest } : {} };
15820
+ } catch {
15821
+ return void 0;
15822
+ }
15823
+ }
15824
+ function writeCheck(file, check) {
15825
+ try {
15826
+ mkdirSync5(dirname5(file), { recursive: true, mode: 448 });
15827
+ const temp = `${file}.${process.pid}.tmp`;
15828
+ writeFileSync7(temp, `${JSON.stringify(check)}
15829
+ `, { mode: 384 });
15830
+ renameSync4(temp, file);
15831
+ } catch {
15832
+ }
15833
+ }
15834
+ function parts(version) {
15835
+ const match = RELEASE.exec(version);
15836
+ return match ? match.slice(1).map(Number) : void 0;
15837
+ }
15838
+ function isNewer(latest, current) {
15839
+ const a = parts(latest);
15840
+ const b = parts(current);
15841
+ if (!a || !b) return false;
15842
+ for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i];
15843
+ return false;
15844
+ }
15845
+ async function fetchLatest(fetchImpl, signal) {
15846
+ const res = await fetchImpl(REGISTRY_URL, { signal, headers: { accept: "application/json" } });
15847
+ if (!res.ok) return void 0;
15848
+ const body = await res.json();
15849
+ return typeof body?.version === "string" && RELEASE.test(body.version) ? body.version : void 0;
15850
+ }
15851
+ function startUpdateNotice(argv, opts = {}) {
15852
+ try {
15853
+ const env = opts.env ?? process.env;
15854
+ const version = opts.version ?? VERSION;
15855
+ const stderr = opts.stderr ?? process.stderr;
15856
+ 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));
15857
+ if (!wanted) return done;
15858
+ const file = join24(configDir(env), UPDATE_CHECK_FILE);
15859
+ const now = (opts.now ?? Date.now)();
15860
+ const cached = readCheck(file);
15861
+ const checkedAt = Date.parse(cached?.checkedAt ?? "");
15862
+ if (checkedAt <= now && now - checkedAt < CHECK_EVERY_MS) return done;
15863
+ writeCheck(file, { checkedAt: new Date(now).toISOString(), ...cached?.latest ? { latest: cached.latest } : {} });
15864
+ const stop = new AbortController();
15865
+ const signal = AbortSignal.any([AbortSignal.timeout(REQUEST_TIMEOUT_MS3), stop.signal]);
15866
+ const latest = fetchLatest(opts.fetchImpl ?? fetch, signal).catch(() => void 0);
15867
+ return async () => {
15868
+ try {
15869
+ const timer = setTimeout(() => stop.abort(), opts.waitMs ?? WAIT_AFTER_COMMAND_MS);
15870
+ timer.unref();
15871
+ const found = await latest;
15872
+ clearTimeout(timer);
15873
+ if (!found) return;
15874
+ writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
15875
+ if (isNewer(found, version)) {
15876
+ stderr.write(`kenso ${found} is out (you have ${version}): npm i -g kenso@latest
15877
+ Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
15878
+ `);
15879
+ }
15880
+ } catch {
15881
+ }
15882
+ };
15883
+ } catch {
15884
+ return done;
15885
+ }
15886
+ }
15887
+ var UPDATE_CHECK_FILE, REGISTRY_URL, CHECK_EVERY_MS, REQUEST_TIMEOUT_MS3, WAIT_AFTER_COMMAND_MS, QUIET_COMMANDS, RELEASE, done;
15888
+ var init_update_notice = __esm({
15889
+ "src/core/update-notice.ts"() {
15890
+ "use strict";
15891
+ init_agent();
15892
+ init_config();
15893
+ init_version();
15894
+ UPDATE_CHECK_FILE = "update-check.json";
15895
+ REGISTRY_URL = "https://registry.npmjs.org/kenso/latest";
15896
+ CHECK_EVERY_MS = 7 * 24 * 60 * 60 * 1e3;
15897
+ REQUEST_TIMEOUT_MS3 = 5e3;
15898
+ WAIT_AFTER_COMMAND_MS = 1e3;
15899
+ QUIET_COMMANDS = /* @__PURE__ */ new Set(["completion", "__complete"]);
15900
+ RELEASE = /^(\d+)\.(\d+)\.([1-9]\d*)$/;
15901
+ done = async () => {
15902
+ };
15903
+ }
15904
+ });
15905
+
15906
+ // src/commands/completion/complete.ts
15907
+ var complete_exports = {};
15908
+ __export(complete_exports, {
15909
+ COMPLETE_COMMAND: () => COMPLETE_COMMAND,
15910
+ completions: () => completions,
15911
+ printCompletions: () => printCompletions
15912
+ });
15913
+ function resources() {
15914
+ const names = Object.entries(handWritten).filter(([, area]) => Object.keys(area).length > 0).map(([resource]) => resource);
15915
+ return sorted([...names, ...Object.keys(resourceAliases), ...loadManifest().operations.map((op) => op.resource)]);
15916
+ }
15917
+ function actions19(resource) {
15918
+ const own = Object.keys(handWritten[resource] ?? {}).filter((action) => action !== "");
15919
+ return sorted([...own, ...loadManifest().operations.filter((op) => op.resource === resource).map((op) => op.action)]);
15920
+ }
15921
+ function flagName(word, spec, globals) {
15922
+ if (word.startsWith("--")) return word.slice(2).split("=")[0];
15923
+ if (word.length !== 2) return void 0;
15924
+ const letter = word[1];
15925
+ const own = spec ? Object.entries(spec.flags).find(([, flag]) => flag.short === letter)?.[0] : void 0;
15926
+ return own ?? Object.entries(globals).find(([, option]) => option.short === letter)?.[0];
15927
+ }
15928
+ function optionOf(name, spec, globals) {
15929
+ const flags = spec?.flags ?? {};
15930
+ return flags[name] ?? Object.values(flags).find((flag) => flag.aliases?.includes(name)) ?? globals[name];
15931
+ }
15932
+ function flagsOf2(spec, globals, commandless) {
15933
+ const global = Object.keys(globals).filter((name) => commandless || name !== "version" && (name !== "dry-run" || spec?.dryRun === true));
15934
+ return sorted([...Object.keys(spec?.flags ?? {}), ...global].map((name) => `--${name}`));
15935
+ }
15936
+ async function completions(words, globals) {
15937
+ const current = words.at(-1) ?? "";
15938
+ const positionals = [];
15939
+ let spec;
15940
+ let commandWords = 0;
15941
+ let valueFor;
15942
+ let afterDashes = false;
15943
+ let help = false;
15944
+ for (const word of words.slice(0, -1)) {
15945
+ if (valueFor !== void 0) {
15946
+ valueFor = void 0;
15947
+ continue;
15948
+ }
15949
+ if (!afterDashes && word === "--") {
15950
+ afterDashes = true;
15951
+ continue;
15952
+ }
15953
+ if (!afterDashes && word.startsWith("-") && word !== "-") {
15954
+ const name = flagName(word, spec, globals);
15955
+ if (name !== void 0 && !word.includes("=") && optionOf(name, spec, globals)?.type === "string") valueFor = name;
15956
+ continue;
15957
+ }
15958
+ if (positionals.length === 0 && word === "help" && !help) {
15959
+ help = true;
15960
+ continue;
15961
+ }
15962
+ positionals.push(word);
15963
+ if (spec) continue;
15964
+ const resource = resourceAliases[positionals[0]] ?? positionals[0];
15965
+ const area = handWritten[resource] ?? {};
15966
+ if (positionals.length === 1 && area[""]) {
15967
+ spec = await area[""]();
15968
+ commandWords = 1;
15969
+ } else if (positionals.length === 2) {
15970
+ const loader = area[positionals[1]];
15971
+ spec = (loader ? await loader() : await resolveGenerated(resource, positionals[1])) ?? void 0;
15972
+ commandWords = 2;
15973
+ }
15974
+ }
15975
+ if (valueFor !== void 0) return [...FLAG_VALUES[valueFor] ?? []];
15976
+ if (!afterDashes && current.startsWith("-")) {
15977
+ const inline = /^--([^=]+)=/.exec(current);
15978
+ if (inline) return (FLAG_VALUES[inline[1]] ?? []).map((value) => `--${inline[1]}=${value}`);
15979
+ return flagsOf2(spec, globals, positionals.length === 0);
15980
+ }
15981
+ if (positionals.length === 0) return resources();
15982
+ if (!spec) return positionals.length === 1 ? actions19(resourceAliases[positionals[0]] ?? positionals[0]) : [];
15983
+ const given = positionals.length - commandWords;
15984
+ const declared = spec.positionals ?? [];
15985
+ if (given < declared.length || declared.at(-1)?.variadic === true) {
15986
+ return given === 0 ? [...POSITIONAL_VALUES[spec.resource] ?? []] : [];
15987
+ }
15988
+ return flagsOf2(spec, globals, false);
15989
+ }
15990
+ async function printCompletions(words, globals, stdout) {
15991
+ let candidates;
15992
+ try {
15993
+ candidates = await completions(words, globals);
15994
+ } catch {
15995
+ candidates = [];
15996
+ }
15997
+ if (candidates.length > 0) stdout.write(`${candidates.join("\n")}
15998
+ `);
15999
+ return ExitCode.Ok;
16000
+ }
16001
+ var COMPLETE_COMMAND, FLAG_VALUES, POSITIONAL_VALUES, sorted;
16002
+ var init_complete = __esm({
16003
+ "src/commands/completion/complete.ts"() {
16004
+ "use strict";
16005
+ init_exit_codes();
16006
+ init_output();
16007
+ init_manifest();
16008
+ init_generated_hook();
16009
+ init_registry();
16010
+ COMPLETE_COMMAND = "__complete";
16011
+ FLAG_VALUES = { output: OUTPUT_FORMATS };
16012
+ POSITIONAL_VALUES = { completion: ["bash", "zsh", "fish"] };
16013
+ sorted = (values) => [...new Set(values)].sort();
16014
+ }
16015
+ });
16016
+
15658
16017
  // src/main.ts
15659
16018
  var main_exports = {};
15660
16019
  __export(main_exports, {
15661
16020
  main: () => main
15662
16021
  });
15663
- import { realpathSync } from "node:fs";
15664
- import { pathToFileURL } from "node:url";
15665
16022
  import { parseArgs } from "node:util";
15666
16023
  function onSigint() {
15667
16024
  if (sigintCount > 0) process.exit(ExitCode.Interrupted);
@@ -15685,17 +16042,6 @@ function leaveRun(active) {
15685
16042
  graceTimer = void 0;
15686
16043
  }
15687
16044
  }
15688
- function guardClosedPipe(stream) {
15689
- if (guardedStreams.has(stream)) return;
15690
- guardedStreams.add(stream);
15691
- stream.on("error", (err) => {
15692
- if (err.code === "EPIPE") {
15693
- process.exit(ExitCode.Ok);
15694
- return;
15695
- }
15696
- throw err;
15697
- });
15698
- }
15699
16045
  function normalizeBooleans(argv, names, strict) {
15700
16046
  const out = [];
15701
16047
  for (let i = 0; i < argv.length; i++) {
@@ -15727,9 +16073,9 @@ function normalizeBooleans(argv, names, strict) {
15727
16073
  async function knownCommands() {
15728
16074
  const commands = /* @__PURE__ */ new Set();
15729
16075
  for (const [resource, area] of Object.entries(handWritten)) {
15730
- const actions18 = Object.keys(area);
15731
- if (actions18.length > 0) commands.add(resource);
15732
- for (const action of actions18) commands.add(action ? `${resource} ${action}` : resource);
16076
+ const actions20 = Object.keys(area);
16077
+ if (actions20.length > 0) commands.add(resource);
16078
+ for (const action of actions20) commands.add(action ? `${resource} ${action}` : resource);
15733
16079
  }
15734
16080
  for (const g of await listGenerated({ features: [] })) {
15735
16081
  commands.add(g.resource);
@@ -15871,16 +16217,17 @@ function commandArgs(spec, parsed2, tokens) {
15871
16217
  });
15872
16218
  }
15873
16219
  const flags = {};
15874
- for (const [flagName, flag] of Object.entries(spec.flags)) {
15875
- const value = parsed2.values[flagName];
15876
- flags[flagName] = Array.isArray(value) ? value.map(String) : value;
15877
- if (flag.required && value === void 0) throw usageError(`--${flagName} is required for ${name}.`, { field: flagName, next: `${name} --help` });
16220
+ for (const [flagName2, flag] of Object.entries(spec.flags)) {
16221
+ const value = parsed2.values[flagName2];
16222
+ flags[flagName2] = Array.isArray(value) ? value.map(String) : value;
16223
+ if (flag.required && value === void 0) throw usageError(`--${flagName2} is required for ${name}.`, { field: flagName2, next: `${name} --help` });
15878
16224
  }
15879
16225
  return { flags, positionals };
15880
16226
  }
15881
16227
  async function main(argv, env = process.env, overrides = {}) {
15882
16228
  const stdout = overrides.stdout ?? process.stdout;
15883
16229
  guardClosedPipe(stdout);
16230
+ if (argv[0] === "__complete") return (await Promise.resolve().then(() => (init_complete(), complete_exports))).printCompletions(argv.slice(1), GLOBAL_OPTIONS, stdout);
15884
16231
  let output = new Output({ stdout: overrides.stdout, stderr: overrides.stderr, stdoutIsTTY: overrides.stdoutIsTTY, stderrIsTTY: overrides.stderrIsTTY });
15885
16232
  const agent = detectAgent(env);
15886
16233
  const controller = new AbortController();
@@ -15976,28 +16323,22 @@ async function main(argv, env = process.env, overrides = {}) {
15976
16323
  return error.exitCode;
15977
16324
  }
15978
16325
  }
15979
- function invokedDirectly() {
15980
- const script = process.argv[1];
15981
- if (!script) return false;
15982
- try {
15983
- return import.meta.url === pathToFileURL(realpathSync(script)).href;
15984
- } catch {
15985
- return false;
15986
- }
15987
- }
15988
- var GLOBAL_OPTIONS, INTERRUPT_GRACE_MS, GLOBAL_BOOLEANS, COMMAND_GLOBAL_OPTIONS, COMMAND_GLOBAL_BOOLEANS, activeRuns, sigintCount, graceTimer, lookupFailed, LINGERING_REQUEST_GRACE_MS, guardedStreams, JQ_HINT;
16326
+ var GLOBAL_OPTIONS, INTERRUPT_GRACE_MS, GLOBAL_BOOLEANS, COMMAND_GLOBAL_OPTIONS, COMMAND_GLOBAL_BOOLEANS, activeRuns, sigintCount, graceTimer, lookupFailed, LINGERING_REQUEST_GRACE_MS, JQ_HINT;
15989
16327
  var init_main = __esm({
15990
16328
  "src/main.ts"() {
15991
16329
  init_generated_hook();
15992
16330
  init_help();
15993
16331
  init_registry();
15994
16332
  init_agent();
16333
+ init_closed_pipe();
15995
16334
  init_context();
15996
16335
  init_errors();
15997
16336
  init_exit_codes();
15998
16337
  init_flag_names();
16338
+ init_invoked();
15999
16339
  init_output();
16000
16340
  init_redact();
16341
+ init_update_notice();
16001
16342
  init_version();
16002
16343
  GLOBAL_OPTIONS = {
16003
16344
  profile: { type: "string" },
@@ -16022,11 +16363,12 @@ var init_main = __esm({
16022
16363
  sigintCount = 0;
16023
16364
  lookupFailed = false;
16024
16365
  LINGERING_REQUEST_GRACE_MS = 50;
16025
- guardedStreams = /* @__PURE__ */ new WeakSet();
16026
16366
  JQ_HINT = "kenso has no --jq: --query filters the output with a JMESPath expression, for example --query '[].id'.";
16027
- if (invokedDirectly()) {
16028
- void main(process.argv.slice(2)).then((code) => {
16367
+ if (invokedDirectly(import.meta.url)) {
16368
+ const updateNotice = startUpdateNotice(process.argv.slice(2));
16369
+ void main(process.argv.slice(2)).then(async (code) => {
16029
16370
  process.exitCode = code;
16371
+ if (code !== ExitCode.Interrupted) await updateNotice();
16030
16372
  if (code === ExitCode.Interrupted) setTimeout(() => process.exit(code), INTERRUPT_GRACE_MS).unref();
16031
16373
  else if (lookupFailed) setTimeout(() => process.exit(code), LINGERING_REQUEST_GRACE_MS).unref();
16032
16374
  });