kenso 0.1.87 → 0.1.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,7 @@ What changed in the kenso CLI, newest first, by the day it changed. A new versio
11
11
 
12
12
  ## 2026-11-17
13
13
 
14
+ - kenso workspace keys create
14
15
  - refuse a JSON-only flag beside --file instead of dropping it
15
16
  - multipart uploads with --file, binary downloads with --out, and the legacy-route claim in the README
16
17
  - watch only the connection kenso connect started
package/README.md CHANGED
@@ -80,7 +80,7 @@ The dry run checks every row and prints the plan, the credit estimate and the ex
80
80
  | Live streams | `sync events`, `onboarding-builds events`: one JSON line per event, reconnecting with `Last-Event-ID`; `--until done` ends it |
81
81
  | Sandbox (beta) | `sandbox create`, `list`, `reset`, `key`, `delete`: a workspace of your own where sends are simulated, and its test key as the `sandbox` profile |
82
82
  | Runs | `runs list`, `show`, `resume`, `jobs wait` |
83
- | Setup | `auth login`, `logout`, `status`, `workspace list`, `use`, `doctor`, `agent setup`, `skill install`, `docs`, `completion` |
83
+ | Setup | `auth login`, `logout`, `status`, `workspace list`, `use`, `keys create` (beta), `doctor`, `agent setup`, `skill install`, `docs`, `completion` |
84
84
  | Everything else | `kenso <resource> <action>` for every canonical API operation, `kenso api <METHOD> <path>` for any route (legacy routes included), `kenso mcp tools`, `mcp call` |
85
85
  | Discovery | `kenso --help`, `kenso <resource> --help`, `kenso describe` (JSON) |
86
86
 
package/dist/kenso.js CHANGED
@@ -2477,7 +2477,7 @@ var VERSION;
2477
2477
  var init_version = __esm({
2478
2478
  "src/core/version.ts"() {
2479
2479
  "use strict";
2480
- VERSION = true ? "0.1.87" : "0.0.0-dev";
2480
+ VERSION = true ? "0.1.88" : "0.0.0-dev";
2481
2481
  }
2482
2482
  });
2483
2483
 
@@ -4174,9 +4174,9 @@ async function readRunDir(dir) {
4174
4174
  return null;
4175
4175
  }
4176
4176
  if (!raw) return null;
4177
- const { runId, command: command57, createdAt, status } = raw;
4177
+ const { runId, command: command58, createdAt, status } = raw;
4178
4178
  if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
4179
- if (typeof command57 !== "string" || typeof createdAt !== "string") return null;
4179
+ if (typeof command58 !== "string" || typeof createdAt !== "string") return null;
4180
4180
  if (typeof status !== "string" || !STATUSES.includes(status)) return null;
4181
4181
  let chunksDone = chunkList(raw.chunksDone) ?? [];
4182
4182
  try {
@@ -4187,7 +4187,7 @@ async function readRunDir(dir) {
4187
4187
  const record = {
4188
4188
  ...raw,
4189
4189
  runId,
4190
- command: command57,
4190
+ command: command58,
4191
4191
  args: asRecord3(raw.args) ?? {},
4192
4192
  createdAt,
4193
4193
  status,
@@ -4242,11 +4242,11 @@ async function loadRun(runId, env = process.env) {
4242
4242
  }
4243
4243
  return run;
4244
4244
  }
4245
- async function findIdentical(command57, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4245
+ async function findIdentical(command58, args, inputSha256, env, workspaceId, anyWorkspace = false) {
4246
4246
  const identity = argsIdentity(args);
4247
4247
  const runs = await listRuns(env);
4248
4248
  return runs.filter(
4249
- (run) => run.command === command57 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4249
+ (run) => run.command === command58 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
4250
4250
  );
4251
4251
  }
4252
4252
  function isOtherLiveProcess(pid) {
@@ -7451,8 +7451,8 @@ function idValue(value, field) {
7451
7451
  function shellQuote3(arg) {
7452
7452
  return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
7453
7453
  }
7454
- function commandLine2(ctx, command57, args, extra = []) {
7455
- const parts2 = ["kenso", ...command57.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
7454
+ function commandLine2(ctx, command58, args, extra = []) {
7455
+ const parts2 = ["kenso", ...command58.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
7456
7456
  for (const [name, value] of Object.entries(args.flags)) {
7457
7457
  if (value === void 0 || value === false) continue;
7458
7458
  if (value === true) parts2.push(`--${name}`);
@@ -7760,7 +7760,7 @@ var init_agents = __esm({
7760
7760
  var auth_default;
7761
7761
  var init_auth = __esm({
7762
7762
  "docs/auth.md"() {
7763
- auth_default = '# Authentication\n\nThe CLI calls the Kenso API with a Kenso API key (`kenso_live_` plus 49 characters, or an older 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\nA developer sandbox does not count here unless every workspace is one: a key whose user has one workspace and a sandbox saves that workspace. When 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=kenso_live_...\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\nkenso auth logout --keep-key\n```\n\nThis removes the profile and its key from this machine. When browser login made the key, logout revokes it first, so it stops working everywhere; `--keep-key` leaves it valid. If the revoke fails (no network, or the key was already revoked), logout warns and still removes the profile. A key you saved with `--with-key` was made by you in the app, so logout leaves it valid: revoke it at Settings > Integrations > API keys. The output adds `revoked: true` or `false`.\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';
7763
+ auth_default = '# Authentication\n\nThe CLI calls the Kenso API with a Kenso API key (`kenso_live_` plus 49 characters, or an older 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\nA developer sandbox does not count here unless every workspace is one: a key whose user has one workspace and a sandbox saves that workspace. When 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=kenso_live_...\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## Workspace-owned keys\n\nA workspace admin can create a key the workspace owns: it keeps working when the admin leaves and acts with exactly the permissions of its template (`admin`, `editor` or `viewer`). The feature is in beta and off by default, so `kenso --help` and `kenso workspace --help` hide the command until `workspace_api_keys` and `workspace_owned_api_keys` are both on for the workspace (`--all-commands` shows it, marked beta). It still runs when typed.\n\n```bash\nkenso workspace keys create --name "Zapier sync" --template editor --expires-in-days 90\n```\n\nToday workspace keys are off for every workspace: the API answers 404, so the command prints `not_found` with "Workspace keys are not available for this workspace yet." and exits 4.\n\nOnce they are on for a workspace, no API key may create a workspace key, the one the CLI logs in with included. The command then prints the API\'s refusal (`forbidden`) with `"next":"A workspace admin can create it in the app: Settings > API keys > Workspace keys"` and exits 3, without retrying. A member who is not a workspace admin gets the same 403 and next step. An admin creates the key there; the secret is shown once.\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\nkenso auth logout --keep-key\n```\n\nThis removes the profile and its key from this machine. When browser login made the key, logout revokes it first, so it stops working everywhere; `--keep-key` leaves it valid. If the revoke fails (no network, or the key was already revoked), logout warns and still removes the profile. A key you saved with `--with-key` was made by you in the app, so logout leaves it valid: revoke it at Settings > Integrations > API keys. The output adds `revoked: true` or `false`.\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';
7764
7764
  }
7765
7765
  });
7766
7766
 
@@ -8976,8 +8976,8 @@ var init_browser_login = __esm({
8976
8976
  defaultDeps = {
8977
8977
  sleep: (ms, signal) => delay2(ms, void 0, signal ? { signal } : void 0),
8978
8978
  now: () => Date.now(),
8979
- spawn: (command57, args) => {
8980
- const child = nodeSpawn(command57, args, { detached: true, stdio: "ignore" });
8979
+ spawn: (command58, args) => {
8980
+ const child = nodeSpawn(command58, args, { detached: true, stdio: "ignore" });
8981
8981
  child.on("error", () => {
8982
8982
  });
8983
8983
  child.unref();
@@ -10166,8 +10166,8 @@ var init_run = __esm({
10166
10166
  defaultDeps2 = {
10167
10167
  sleep: (ms, signal) => delay3(ms, void 0, signal ? { signal } : void 0),
10168
10168
  now: () => Date.now(),
10169
- spawn: (command57, args) => {
10170
- const child = nodeSpawn2(command57, args, { detached: true, stdio: "ignore" });
10169
+ spawn: (command58, args) => {
10170
+ const child = nodeSpawn2(command58, args, { detached: true, stdio: "ignore" });
10171
10171
  child.on("error", () => {
10172
10172
  });
10173
10173
  child.unref();
@@ -10208,9 +10208,9 @@ function stringFlag2(flags, name) {
10208
10208
  const text4 = value.trim();
10209
10209
  return text4 === "" ? void 0 : text4;
10210
10210
  }
10211
- function requireFlag(flags, name, command57, hint) {
10211
+ function requireFlag(flags, name, command58, hint) {
10212
10212
  const value = stringFlag2(flags, name);
10213
- if (value === void 0) throw usageError(`--${name} is required for ${command57}.`, { field: name, next: `${command57} --help`, ...hint ? { hint } : {} });
10213
+ if (value === void 0) throw usageError(`--${name} is required for ${command58}.`, { field: name, next: `${command58} --help`, ...hint ? { hint } : {} });
10214
10214
  return value;
10215
10215
  }
10216
10216
  function positiveId(value) {
@@ -10219,8 +10219,8 @@ function positiveId(value) {
10219
10219
  const id = Number(text4);
10220
10220
  return Number.isSafeInteger(id) && id > 0 ? id : void 0;
10221
10221
  }
10222
- function idFlag(flags, name, command57) {
10223
- const raw = requireFlag(flags, name, command57);
10222
+ function idFlag(flags, name, command58) {
10223
+ const raw = requireFlag(flags, name, command58);
10224
10224
  const id = positiveId(raw);
10225
10225
  if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
10226
10226
  return id;
@@ -10240,8 +10240,8 @@ function isDryRun(ctx) {
10240
10240
  function shellQuote4(value) {
10241
10241
  return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
10242
10242
  }
10243
- function sameCommand2(command57, flags, ctx, extra = []) {
10244
- const parts2 = [command57];
10243
+ function sameCommand2(command58, flags, ctx, extra = []) {
10244
+ const parts2 = [command58];
10245
10245
  for (const [name, value] of Object.entries(flags)) {
10246
10246
  if (value === void 0 || value === false) continue;
10247
10247
  if (value === true) parts2.push(`--${name}`);
@@ -11378,12 +11378,12 @@ import { join as join11 } from "node:path";
11378
11378
  function whereDir(env) {
11379
11379
  return join11(runsRoot(env), WHERE_DIR);
11380
11380
  }
11381
- async function unfinishedWhereIds(ctx, command57, args) {
11381
+ async function unfinishedWhereIds(ctx, command58, args) {
11382
11382
  const dir = whereDir(ctx.env);
11383
11383
  const identity = argsIdentity(args);
11384
11384
  const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
11385
11385
  for (const run of await listRuns(ctx.env)) {
11386
- if (run.command !== command57 || run.status === "done" || run.status === "planned") continue;
11386
+ if (run.command !== command58 || run.status === "done" || run.status === "planned") continue;
11387
11387
  if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
11388
11388
  if (run.inputPath?.startsWith(`${dir}/`) && existsSync6(run.inputPath)) return run.inputPath;
11389
11389
  }
@@ -11529,14 +11529,14 @@ async function idsFromRun(ctx, runId) {
11529
11529
  return { ...idItems(ids2), source: "run" };
11530
11530
  }
11531
11531
  async function collectIds(ctx, flags, kind, dryRun2) {
11532
- const command57 = `kenso contacts ${kind}`;
11532
+ const command58 = `kenso contacts ${kind}`;
11533
11533
  const ids2 = stringFlag2(flags, "ids");
11534
11534
  const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
11535
11535
  const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
11536
11536
  const given = [ids2, where, run].filter((v) => v !== void 0).length;
11537
11537
  if (given !== 1) {
11538
11538
  const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
11539
- throw usageError(`${command57} needs exactly one of ${choices}.`, { field: "ids", next: `${command57} --help` });
11539
+ throw usageError(`${command58} needs exactly one of ${choices}.`, { field: "ids", next: `${command58} --help` });
11540
11540
  }
11541
11541
  if (ids2 !== void 0) return idsFromFile(ctx, ids2);
11542
11542
  if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
@@ -15721,9 +15721,9 @@ var init_files = __esm({
15721
15721
  import { execFile, spawnSync as spawnSync2 } from "node:child_process";
15722
15722
  import { readFileSync as readFileSync12 } from "node:fs";
15723
15723
  import { isAbsolute as isAbsolute2 } from "node:path";
15724
- function sudoArgs(user, command57, args, keep = [], set = {}) {
15724
+ function sudoArgs(user, command58, args, keep = [], set = {}) {
15725
15725
  const assignments = Object.entries(set).map(([name, value]) => `${name}=${value}`);
15726
- return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command57, ...args];
15726
+ return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command58, ...args];
15727
15727
  }
15728
15728
  function agentKensoEnv(opts) {
15729
15729
  return {
@@ -15733,12 +15733,12 @@ function agentKensoEnv(opts) {
15733
15733
  AI_AGENT: opts.agentName
15734
15734
  };
15735
15735
  }
15736
- function sudoExec(user, command57, args, opts = {}) {
15736
+ function sudoExec(user, command58, args, opts = {}) {
15737
15737
  const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
15738
15738
  return new Promise((resolve16) => {
15739
15739
  execFile(
15740
15740
  sudo,
15741
- [...lead, ...sudoArgs(user.name, command57, args)],
15741
+ [...lead, ...sudoArgs(user.name, command58, args)],
15742
15742
  { env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
15743
15743
  (err, stdout, stderr) => {
15744
15744
  const code = err ? err.code : 0;
@@ -15848,9 +15848,9 @@ var init_folder2 = __esm({
15848
15848
  init_redact();
15849
15849
  init_agent_user();
15850
15850
  WorkRunFolder = class {
15851
- constructor(ctx, command57, args, outDir, shared = false) {
15851
+ constructor(ctx, command58, args, outDir, shared = false) {
15852
15852
  this.ctx = ctx;
15853
- this.command = command57;
15853
+ this.command = command58;
15854
15854
  this.args = args;
15855
15855
  this.outDir = outDir;
15856
15856
  this.shared = shared;
@@ -16623,12 +16623,12 @@ function plain(text4) {
16623
16623
  return text4.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
16624
16624
  }
16625
16625
  function runStatus(bin, args, env, adapter, runAs) {
16626
- const command57 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
16626
+ const command58 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
16627
16627
  const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
16628
16628
  const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
16629
16629
  return new Promise((resolve16) => {
16630
16630
  execFile2(
16631
- command57,
16631
+ command58,
16632
16632
  commandArgs2,
16633
16633
  { ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
16634
16634
  (err, stdout, stderr) => {
@@ -18075,6 +18075,102 @@ var init_work2 = __esm({
18075
18075
  }
18076
18076
  });
18077
18077
 
18078
+ // src/commands/workspace/keys.ts
18079
+ var keys_exports = {};
18080
+ __export(keys_exports, {
18081
+ default: () => keys_default
18082
+ });
18083
+ function usage(message, field) {
18084
+ return new KensoError({ code: "usage_error", message, exitCode: ExitCode.Usage, field });
18085
+ }
18086
+ function rewrap(err, overrides) {
18087
+ return new KensoError({
18088
+ code: err.code,
18089
+ message: overrides.message ?? err.message,
18090
+ exitCode: err.exitCode,
18091
+ httpStatus: err.httpStatus,
18092
+ field: err.field,
18093
+ hint: err.hint,
18094
+ next: overrides.next ?? err.next,
18095
+ requestId: err.requestId,
18096
+ details: err.details
18097
+ });
18098
+ }
18099
+ var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command55, keys_default;
18100
+ var init_keys = __esm({
18101
+ "src/commands/workspace/keys.ts"() {
18102
+ "use strict";
18103
+ init_errors();
18104
+ init_exit_codes();
18105
+ init_http();
18106
+ TEMPLATES = ["admin", "editor", "viewer"];
18107
+ APP_NEXT_STEP = "A workspace admin can create it in the app: Settings > API keys > Workspace keys";
18108
+ NOT_AVAILABLE = "Workspace keys are not available for this workspace yet.";
18109
+ command55 = {
18110
+ resource: "workspace",
18111
+ action: "keys",
18112
+ summary: "Create an API key the workspace owns",
18113
+ brief: "create",
18114
+ description: "Calls POST /v1/workspace-api-keys. The key belongs to the workspace, not to you: it keeps working when you leave and acts with exactly the permissions of the template it is held to (admin, editor or viewer). Workspace admins only. The secret is printed once. Workspace keys are off for every workspace for now: the API answers 404 and the command says they are not available yet (exit 4). Once they are on, no API key may create one (a CLI login key included), so the command reports the API's refusal and the app path (exit 3).",
18115
+ flags: {
18116
+ name: { type: "string", required: true, description: "The key's name, 1 to 100 characters" },
18117
+ template: { type: "string", required: true, description: "admin, editor or viewer" },
18118
+ "expires-in-days": { type: "string", description: "Days until the key expires, 1 to 90 (default: never)" }
18119
+ },
18120
+ positionals: [{ name: "action", required: true, description: "create" }],
18121
+ examples: ["kenso workspace keys create --name 'Zapier sync' --template editor --expires-in-days 90"],
18122
+ operationIds: ["workspace-api-keys.create"],
18123
+ beta: { featureGates: { all: ["workspace_api_keys", "workspace_owned_api_keys"] } },
18124
+ async run(ctx, { flags, positionals }) {
18125
+ if (positionals[0] !== "create") {
18126
+ throw usage(`Unknown workspace keys action "${positionals[0] ?? ""}". The one action is create.`, "action");
18127
+ }
18128
+ const template2 = String(flags.template ?? "").trim().toLowerCase();
18129
+ if (!TEMPLATES.includes(template2)) {
18130
+ throw usage(`--template must be admin, editor or viewer, not "${template2}".`, "template");
18131
+ }
18132
+ const rawDays = flags["expires-in-days"];
18133
+ let expiresInDays;
18134
+ if (rawDays !== void 0) {
18135
+ const text4 = String(rawDays).trim();
18136
+ if (!/^[1-9]\d*$/.test(text4)) {
18137
+ throw usage(`--expires-in-days must be a positive whole number, not "${text4}".`, "expires-in-days");
18138
+ }
18139
+ expiresInDays = Number(text4);
18140
+ }
18141
+ const request = { name: String(flags.name ?? "").trim(), template: template2, ...expiresInDays === void 0 ? {} : { expiresInDays } };
18142
+ let body2;
18143
+ try {
18144
+ body2 = (await ctx.client.request({ method: "POST", path: "/v1/workspace-api-keys", body: request, signal: ctx.signal })).body;
18145
+ } catch (err) {
18146
+ if (err instanceof KensoError && err.httpStatus === 404) {
18147
+ throw rewrap(err, { message: NOT_AVAILABLE });
18148
+ }
18149
+ if (err instanceof KensoError && err.httpStatus === 403) {
18150
+ throw rewrap(err, { next: APP_NEXT_STEP });
18151
+ }
18152
+ throw err;
18153
+ }
18154
+ const key = unwrap(body2) ?? {};
18155
+ ctx.output.warn("The secret is shown only now. Store it in your secret manager; Kenso cannot show it again.");
18156
+ ctx.output.object({
18157
+ id: key.id ?? null,
18158
+ name: key.name ?? null,
18159
+ prefix: key.prefix ?? null,
18160
+ secret: key.secret ?? null,
18161
+ ownerKind: key.ownerKind ?? null,
18162
+ template: key.template ?? null,
18163
+ createdBy: key.createdBy ?? null,
18164
+ createdAt: key.createdAt ?? null,
18165
+ expiresAt: key.expiresAt ?? null
18166
+ });
18167
+ return ExitCode.Ok;
18168
+ }
18169
+ };
18170
+ keys_default = command55;
18171
+ }
18172
+ });
18173
+
18078
18174
  // src/commands/workspace/list.ts
18079
18175
  var list_exports3 = {};
18080
18176
  __export(list_exports3, {
@@ -18089,14 +18185,14 @@ function parseLimit(value) {
18089
18185
  }
18090
18186
  return limit;
18091
18187
  }
18092
- var MAX_LIMIT, command55, list_default3;
18188
+ var MAX_LIMIT, command56, list_default3;
18093
18189
  var init_list3 = __esm({
18094
18190
  "src/commands/workspace/list.ts"() {
18095
18191
  "use strict";
18096
18192
  init_errors();
18097
18193
  init_exit_codes();
18098
18194
  MAX_LIMIT = 200;
18099
- command55 = {
18195
+ command56 = {
18100
18196
  resource: "workspace",
18101
18197
  action: "list",
18102
18198
  summary: "List the workspaces your key can use",
@@ -18124,7 +18220,7 @@ var init_list3 = __esm({
18124
18220
  return ExitCode.Ok;
18125
18221
  }
18126
18222
  };
18127
- list_default3 = command55;
18223
+ list_default3 = command56;
18128
18224
  }
18129
18225
  });
18130
18226
 
@@ -18133,7 +18229,7 @@ var use_exports = {};
18133
18229
  __export(use_exports, {
18134
18230
  default: () => use_default
18135
18231
  });
18136
- var command56, use_default;
18232
+ var command57, use_default;
18137
18233
  var init_use = __esm({
18138
18234
  "src/commands/workspace/use.ts"() {
18139
18235
  "use strict";
@@ -18141,7 +18237,7 @@ var init_use = __esm({
18141
18237
  init_errors();
18142
18238
  init_exit_codes();
18143
18239
  init_http();
18144
- command56 = {
18240
+ command57 = {
18145
18241
  resource: "workspace",
18146
18242
  action: "use",
18147
18243
  summary: "Set the profile's default workspace",
@@ -18198,7 +18294,7 @@ var init_use = __esm({
18198
18294
  return ExitCode.Ok;
18199
18295
  }
18200
18296
  };
18201
- use_default = command56;
18297
+ use_default = command57;
18202
18298
  }
18203
18299
  });
18204
18300
 
@@ -18208,6 +18304,7 @@ var init_workspace = __esm({
18208
18304
  "src/commands/workspace/index.ts"() {
18209
18305
  "use strict";
18210
18306
  actions28 = {
18307
+ keys: () => Promise.resolve().then(() => (init_keys(), keys_exports)).then((m) => m.default),
18211
18308
  list: () => Promise.resolve().then(() => (init_list3(), list_exports3)).then((m) => m.default),
18212
18309
  use: () => Promise.resolve().then(() => (init_use(), use_exports)).then((m) => m.default)
18213
18310
  };
@@ -18767,8 +18864,8 @@ function startUpdateNotice(argv, opts = {}) {
18767
18864
  if (!found) return;
18768
18865
  writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
18769
18866
  if (isNewer(found, version)) {
18770
- const command57 = updateCommand(install, opts.platform ?? process.platform);
18771
- stderr.write(`kenso ${found} is out (you have ${version}): ${command57}
18867
+ const command58 = updateCommand(install, opts.platform ?? process.platform);
18868
+ stderr.write(`kenso ${found} is out (you have ${version}): ${command58}
18772
18869
  Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
18773
18870
  `);
18774
18871
  }