kenso 0.1.64 → 0.1.67

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
@@ -2421,7 +2421,7 @@ var VERSION;
2421
2421
  var init_version = __esm({
2422
2422
  "src/core/version.ts"() {
2423
2423
  "use strict";
2424
- VERSION = true ? "0.1.64" : "0.0.0-dev";
2424
+ VERSION = true ? "0.1.67" : "0.0.0-dev";
2425
2425
  }
2426
2426
  });
2427
2427
 
@@ -3714,9 +3714,9 @@ async function readRunDir(dir) {
3714
3714
  return null;
3715
3715
  }
3716
3716
  if (!raw) return null;
3717
- const { runId, command: command37, createdAt, status } = raw;
3717
+ const { runId, command: command44, createdAt, status } = raw;
3718
3718
  if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
3719
- if (typeof command37 !== "string" || typeof createdAt !== "string") return null;
3719
+ if (typeof command44 !== "string" || typeof createdAt !== "string") return null;
3720
3720
  if (typeof status !== "string" || !STATUSES.includes(status)) return null;
3721
3721
  let chunksDone = chunkList(raw.chunksDone) ?? [];
3722
3722
  try {
@@ -3727,7 +3727,7 @@ async function readRunDir(dir) {
3727
3727
  const record = {
3728
3728
  ...raw,
3729
3729
  runId,
3730
- command: command37,
3730
+ command: command44,
3731
3731
  args: asRecord3(raw.args) ?? {},
3732
3732
  createdAt,
3733
3733
  status,
@@ -3782,11 +3782,11 @@ async function loadRun(runId, env = process.env) {
3782
3782
  }
3783
3783
  return run;
3784
3784
  }
3785
- async function findIdentical(command37, args, inputSha256, env, workspaceId, anyWorkspace = false) {
3785
+ async function findIdentical(command44, args, inputSha256, env, workspaceId, anyWorkspace = false) {
3786
3786
  const identity = argsIdentity(args);
3787
3787
  const runs = await listRuns(env);
3788
3788
  return runs.filter(
3789
- (run) => run.command === command37 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
3789
+ (run) => run.command === command44 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
3790
3790
  );
3791
3791
  }
3792
3792
  function isOtherLiveProcess(pid) {
@@ -6938,8 +6938,8 @@ function idValue(value, field) {
6938
6938
  function shellQuote3(arg) {
6939
6939
  return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
6940
6940
  }
6941
- function commandLine2(ctx, command37, args, extra = []) {
6942
- const parts2 = ["kenso", ...command37.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
6941
+ function commandLine2(ctx, command44, args, extra = []) {
6942
+ const parts2 = ["kenso", ...command44.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
6943
6943
  for (const [name, value] of Object.entries(args.flags)) {
6944
6944
  if (value === void 0 || value === false) continue;
6945
6945
  if (value === true) parts2.push(`--${name}`);
@@ -7263,7 +7263,7 @@ var init_batch = __esm({
7263
7263
  var crm_default;
7264
7264
  var init_crm = __esm({
7265
7265
  "docs/crm.md"() {
7266
- crm_default = '# CRM (beta)\n\nThe CRM commands work on Kenso\'s Accounts lane: accounts (companies), the people on them, and opportunities. They are beta: they need the `accounts` feature flag on your workspace (opportunities need `opportunities`, CRM sync needs `ingestion`). Help and `kenso describe` hide them until your workspace has the flag; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `accounts import` | Create accounts from a CSV or JSONL file. Research is charged per created account |\n| `people import` | Create or match people from a file, optionally onto accounts |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n\nImport accounts first, then people: `people import` never creates an account.\n\n## Import accounts\n\n```bash\nkenso accounts import --file accounts.csv\nkenso accounts import --file accounts.csv --yes\n```\n\n```csv\nname,domain,industry,employeeCount\nAcme,acme.io,Software,120\nGlobex,globex.com,Manufacturing,"1,200"\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `name` (or `company`, `companyName`, `accountName`), `domains` (several, split on `,` or `;`) or one `domain` (or `website`, `companyDomain`), `industry`, `employeeCount`, `hqLocation`, `linkedinUrl`, `stage`, `angle`, `whyNow`, `fitScore`, `fundingRound`, `cadenceDays`, `ownerMemberId`, `kenCompanyId`, `sendsFromInboxId`, `sendsFromLinkedInAccountId` and `source`.\n- **A domain is required.** A file with no domain column is a usage error, and a row without a domain is `invalid` (`domain_required`).\n- **The dry run prices the research.** It asks for a credit estimate per 1,000 accounts and puts the sum in the plan: `kind`, `accountCount`, `totalMillicredits`, `availableMillicredits` and `sufficient`.\n- **Rows go 100 per call** to `POST /v1/accounts/bulk-create`.\n\nEach row comes back `created` (`id` is the new account; its research is queued, `researchQueued`, or waits for credits, `researchWaitingCredits`), `skipped` with reason `domain_taken` (already an account; `id` is that account) or `failed` (`reason` is the API\'s code, `error` names the field; an item Kenso failed to save is sent once more first). Rerunning the same file is safe: accounts that exist come back `domain_taken`.\n\n## Import people\n\n```bash\nkenso people import --file people.csv\nkenso people import --file people.csv --find-emails --yes\nkenso people import --file people.jsonl --dry-run\n```\n\n```csv\nfullName,email,title,accountDomain,role\nAnn Lee,ann@acme.io,VP Sales,acme.io,champion\nBob Ray,,CTO,acme.io,\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `email`, `fullName` (or `name`), `firstName`, `lastName`, `title`, `linkedinUrl` (or `linkedin`, `profileUrl`), `accountDomain` (or `domain`, `website`, `companyDomain`), `accountId`, `role` and `priority`. Other columns are ignored with one warning.\n- **A person needs a name:** `fullName`, or `firstName`, `lastName` or both (the CLI joins them). A row with none of them is `invalid` (`name_required`).\n- **To put a person on an account,** give `accountDomain` or `accountId`. A row with both sends only `accountId`.\n- **`--find-emails`** queues an email find (charged in credits) for each person without an email.\n- **Rows go 200 per call** to `POST /v1/people/batch`.\n\nPeople already in the workspace are matched by email, then LinkedIn URL, so running the same file again creates nobody twice. A row comes back `created` (a new person), `updated` (an existing person added to the account), `skipped` with reason `already_on_account`, `matched` (no account asked) or `previously_removed`, or `failed`: `account_not_found` saves the person without an account (import the account, then rerun to place them), any other reason is the API\'s. The summary adds `matched`, `addedToAccounts` and `emailFindsQueued`.\n\n## List and search accounts\n\n`accounts list` and `accounts search` sort and page on the server, so they reach every account in the workspace, however many there are.\n\n```bash\nkenso accounts list --sort score:desc --limit 100 # one page; the output\'s next: line is the following one\nkenso accounts list --sort score:desc --limit 100 --all # every page, to the end\nkenso accounts search --search hiring --sort latestSignalAt:desc --data \'{"qFields": ["name", "latestSignal"]}\'\nkenso accounts search --limit 1 --data \'{"countBy": ["stage"]}\' # how many accounts sit in each stage\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}]}, "sort": "tier,-pipelineAmount"}\' --all\n```\n\n- **`--sort`** takes up to 3 comma-separated keys, each `field` (ascending), `field:asc` or `field:desc`. The API\'s `-field` form needs the equals sign here, `--sort=-score`, because a value that starts with a dash reads as a flag. Fields: `createdAt`, `name`, `score`, `tier` (ascending is tier 1 first), `latestSignalAt`, `committee`, `pipelineAmount`, `nextTouchAt`, `lastTouchAt`. An account with no value for a key comes last in both directions. The default is `-createdAt`.\n- **`--limit`** is 1 to 1000 (default 50). `--cursor` takes the previous page\'s `nextCursor` with the same filters and sort; `--all` follows the cursors for you.\n- **`--search`** (also `--q`) matches the name or a domain.\n- **Lists and objects go in `--data`** on `search`, as the API takes them (`kenso describe accounts search`); a flag beside it sets or replaces one key:\n - `qFields` picks where the search text looks: `name`, `domain`, `latestSignal` (the latest signal\'s title).\n - `countBy` (`stage`, `stageGroup`) adds `counts` to the output: every value with the number of matching accounts that hold it, whatever the page. The output is then one object: `data`, `pagination` and `counts`.\n - `filters` and `where` narrow the accounts.\n\nAn account\'s timeline pages the same way. `kenso accounts activity 812` returns the newest 100 earlier rows and, when older ones exist, `data.nextCursor`. Pass it back as `--cursor` (with the same `--category`) for the rows before them, until a page comes without one.\n\n## Edit accounts, people and opportunities\n\nApart from `accounts bulk-update`, which sets one `accountType` on up to 500 accounts, there is no bulk edit route, so run the generated `update` command once per row with `--each`. Columns are the command\'s flags by API name or flag name, and the id column fills the route:\n\n```bash\nkenso accounts update --each accounts-edit.csv --dry-run # then the same with --yes\nkenso people update --each people-edit.csv --dry-run\nkenso opportunities update --each deals.csv --dry-run\n```\n\n```csv\naccountId,stage,ownerMemberId,overwritePinned\n501,engaged,42,true\n502,customer,42,true\n```\n\nA row that changes a field someone pinned in the app fails as a whole (`409 conflict`, `pinned_by_user`: nothing on that record changes, the other fields of the row included), unless the row sets `overwritePinned` to `true` (or you pass `--overwrite-pinned`, only with the person\'s OK). Every flag of an update command: `kenso accounts update --help`.\n\n## Search opportunities\n\n`kenso opportunities search` works as `accounts search` does: it takes `--search`, `--sort`, `--limit`, `--cursor`, `--all`, and its lists in `--data`.\n\n```bash\nkenso opportunities search --data \'{"filters": [{"field": "stageCategory", "operator": "is", "values": ["open"]}]}\' --all\nkenso opportunities search --data \'{"filters": [{"field": "ownerMemberId", "operator": "is", "values": ["none"]}, {"field": "closeDate", "operator": "is", "values": ["past_due", "next_30_days"]}]}\'\nkenso opportunities search --limit 1 --data \'{"countBy": ["stage", "ownerMemberId"]}\' # how many opportunities hold each value\n```\n\n- **`filters`** is a list of `{field, operator, values}`, all of which must hold. Fields: `stage` (a stage key), `stageCategory` (`open`, `won`, `lost`), `ownerMemberId`, `closeDate` (`past_due`, `next_30_days`, `later`, `none`) and `sourceCampaignId`. `operator` is `is` or `is_not`; the values of one condition are OR. `none` in `values` matches an opportunity with no owner, no source campaign or no close date.\n- **`countBy`** takes the same field names and adds `counts` to the output: per field, every value with the number of matching opportunities that hold it.\n- `--account-id` keeps the search to one account. `closeDate` counts days in the member\'s app time zone.\n\nOne person\'s deals, meetings and campaign contacts, as their person page lists them:\n\n```bash\nkenso opportunities list --person-id 9001 # the deals they are on, or are the primary person of\nkenso meetings list --person-id 9001 # the meetings they attend, among the ones you can see\nkenso contacts list --person-id 9001 # their contact in each campaign they are in\n```\n\n## Write research you gathered\n\n`accounts write-research` and `people write-research` store research you gathered outside Kenso as the record\'s latest research (`PUT /v1/accounts/{accountId}/research`, `PUT /v1/people/{personId}/research`). The Research tab shows it like a Ken run, with `trigger: agent` and `researchedAt` now. Nothing is charged, and no account or person field changes: set an account\'s own `fitScore`, `whyNow` or `angle` with `accounts update`. They need the `accounts_research` flag and accounts edit.\n\nThe body is the research block `accounts get --expand research` (or `people get-research`) returns, without its read-only fields: leave out `id`, `status`, `trigger`, `errorCode`, `researchedAt`, `isStale` and `appliedPrompt` (for a person also `mode`, `requestedAt`, `researchedMode`, `firecrawlCredits` and `webNote`), or the write fails with `unknown_field`. Pass it with `--data @file`:\n\n```bash\nkenso accounts write-research --account-id 501 --data @acme-dossier.json\nkenso people write-research --person-id 9001 --data @jane.json\n```\n\n```json\n{\n "tagline": { "text": "Payroll for EU contractors", "sourceUrls": ["https://acme.example"] },\n "description": { "text": "Acme runs payroll and compliance for companies hiring contractors in 30 EU countries.", "sourceUrls": ["https://acme.example"] },\n "links": { "website": "https://acme.example" },\n "whyNow": { "text": "Raised a $40M Series B in October", "sourceUrls": ["https://news.example/acme-b"], "date": "2026-10" },\n "fitScore": 82,\n "angle": "Lead with contractor onboarding time."\n}\n```\n\nMany records: one JSONL line per record, with the id next to the block\'s fields. Nested objects are sent as written. Use JSONL, not CSV: the block\'s fields are objects and lists, which a CSV cell cannot carry.\n\n```bash\nkenso accounts write-research --each dossiers.jsonl --dry-run # then the same with --yes\nkenso people write-research --each people-research.jsonl --yes --concurrency 8\n```\n\n```jsonl\n{"accountId": 501, "tagline": {"text": "Payroll for EU contractors"}, "links": {"website": "https://acme.example"}}\n{"accountId": 502, "description": {"text": "Cloud cost tooling for retailers."}, "links": {"website": "https://beta.example"}}\n```\n\nA row fails as a whole with the API\'s code: `validation_failed` (an unknown field is `unknown_field`, and `error.details` names every bad field), `research_in_progress` (`409`: Ken is researching that record now, write it again once the run ends; an account run waiting for credits counts too: it runs once the workspace has credits, and the write stays refused until that run ends) or `not_found`. Rerunning a file is safe: each write replaces the record\'s research shown.\n\n## CRM sync\n\nCRM sync has generated commands only: read connections, preview, start an import, and work through sync issues. Connect the CRM itself in the app.\n\n```bash\nkenso crm-connections list\nkenso crm-connections get --connection-id 7\nkenso crm-imports create --connection-id 7 --dry-run\nkenso crm-sync-issues list --connection-id 7 --all\n```\n\nRun `kenso crm-connections --help` (or add `--all-commands` when the actions are hidden) to see every action.\n\n## A deal\'s stage history\n\n```bash\nkenso opportunities stage-history 77\nkenso opportunities stage-history 77 --query "entries[].{to: stageLabel, at: enteredAt, by: changedBy}"\n```\n\nIt prints `GET /v1/opportunities/{id}/stage-history` as it is, the same rows as the deal page and the MCP\'s `opportunities(operation="get-stage-history")`: the stage now, `isComplete` and `entries`, oldest first, each with `fromStage`, `stage`, `stageLabel`, `enteredAt`, `leftAt`, `durationSeconds`, `actorKind`, `actorMemberId` and Ken\'s `reason` on a move its stage judge made. With the `deal_stage_rules` flag on, each entry also has `changedBy` (`member`, `agent`, `api_key`, `workflow`, `stage_judge`, `crm_sync` or `ken_automation`), `crmProvider` on a CRM sync, and on a move `fromStageLabel` and `fromStageDurationSeconds`, how long the deal sat in the stage it left. `isComplete` false means Kenso has no record of part of the history.\n';
7266
+ crm_default = '# CRM (beta)\n\nThe CRM commands work on Kenso\'s Accounts lane: accounts (companies), the people on them, and opportunities. They are beta: they need the `accounts` feature flag on your workspace (opportunities need `opportunities`, CRM sync needs `ingestion`). Help and `kenso describe` hide them until your workspace has the flag; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `accounts import` | Create accounts from a CSV or JSONL file. Research is charged per created account |\n| `people import` | Create or match people from a file, optionally onto accounts |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `capture status` | Your captured mailbox, its backfill progress and what teammates see of a captured email. Needs the `crm_capture` flag |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n\nImport accounts first, then people: `people import` never creates an account.\n\n## Import accounts\n\n```bash\nkenso accounts import --file accounts.csv\nkenso accounts import --file accounts.csv --yes\n```\n\n```csv\nname,domain,industry,employeeCount\nAcme,acme.io,Software,120\nGlobex,globex.com,Manufacturing,"1,200"\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `name` (or `company`, `companyName`, `accountName`), `domains` (several, split on `,` or `;`) or one `domain` (or `website`, `companyDomain`), `industry`, `employeeCount`, `hqLocation`, `linkedinUrl`, `stage`, `angle`, `whyNow`, `fitScore`, `fundingRound`, `cadenceDays`, `ownerMemberId`, `kenCompanyId`, `sendsFromInboxId`, `sendsFromLinkedInAccountId` and `source`.\n- **A domain is required.** A file with no domain column is a usage error, and a row without a domain is `invalid` (`domain_required`).\n- **The dry run prices the research.** It asks for a credit estimate per 1,000 accounts and puts the sum in the plan: `kind`, `accountCount`, `totalMillicredits`, `availableMillicredits` and `sufficient`.\n- **Rows go 100 per call** to `POST /v1/accounts/bulk-create`.\n\nEach row comes back `created` (`id` is the new account; its research is queued, `researchQueued`, or waits for credits, `researchWaitingCredits`), `skipped` with reason `domain_taken` (already an account; `id` is that account) or `failed` (`reason` is the API\'s code, `error` names the field; an item Kenso failed to save is sent once more first). Rerunning the same file is safe: accounts that exist come back `domain_taken`.\n\n## Import people\n\n```bash\nkenso people import --file people.csv\nkenso people import --file people.csv --find-emails --yes\nkenso people import --file people.jsonl --dry-run\n```\n\n```csv\nfullName,email,title,accountDomain,role\nAnn Lee,ann@acme.io,VP Sales,acme.io,champion\nBob Ray,,CTO,acme.io,\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `email`, `fullName` (or `name`), `firstName`, `lastName`, `title`, `linkedinUrl` (or `linkedin`, `profileUrl`), `accountDomain` (or `domain`, `website`, `companyDomain`), `accountId`, `role` and `priority`. Other columns are ignored with one warning.\n- **A person needs a name:** `fullName`, or `firstName`, `lastName` or both (the CLI joins them). A row with none of them is `invalid` (`name_required`).\n- **To put a person on an account,** give `accountDomain` or `accountId`. A row with both sends only `accountId`.\n- **`--find-emails`** queues an email find (charged in credits) for each person without an email.\n- **Rows go 200 per call** to `POST /v1/people/batch`.\n\nPeople already in the workspace are matched by email, then LinkedIn URL, so running the same file again creates nobody twice. A row comes back `created` (a new person), `updated` (an existing person added to the account), `skipped` with reason `already_on_account`, `matched` (no account asked) or `previously_removed`, or `failed`: `account_not_found` saves the person without an account (import the account, then rerun to place them), any other reason is the API\'s. The summary adds `matched`, `addedToAccounts` and `emailFindsQueued`.\n\n## List and search accounts\n\n`accounts list` and `accounts search` sort and page on the server, so they reach every account in the workspace, however many there are.\n\n```bash\nkenso accounts list --sort score:desc --limit 100 # one page; the output\'s next: line is the following one\nkenso accounts list --sort score:desc --limit 100 --all # every page, to the end\nkenso accounts search --search hiring --sort latestSignalAt:desc --data \'{"qFields": ["name", "latestSignal"]}\'\nkenso accounts search --limit 1 --data \'{"countBy": ["stage"]}\' # how many accounts sit in each stage\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}]}, "sort": "tier,-pipelineAmount"}\' --all\n```\n\n- **`--sort`** takes up to 3 comma-separated keys, each `field` (ascending), `field:asc` or `field:desc`. The API\'s `-field` form needs the equals sign here, `--sort=-score`, because a value that starts with a dash reads as a flag. Fields: `createdAt`, `name`, `score`, `tier` (ascending is tier 1 first), `latestSignalAt`, `committee`, `pipelineAmount`, `nextTouchAt`, `lastTouchAt`. An account with no value for a key comes last in both directions. The default is `-createdAt`.\n- **`--limit`** is 1 to 1000 (default 50). `--cursor` takes the previous page\'s `nextCursor` with the same filters and sort; `--all` follows the cursors for you.\n- **`--search`** (also `--q`) matches the name or a domain.\n- **Lists and objects go in `--data`** on `search`, as the API takes them (`kenso describe accounts search`); a flag beside it sets or replaces one key:\n - `qFields` picks where the search text looks: `name`, `domain`, `latestSignal` (the latest signal\'s title).\n - `countBy` (`stage`, `stageGroup`) adds `counts` to the output: every value with the number of matching accounts that hold it, whatever the page. The output is then one object: `data`, `pagination` and `counts`.\n - `filters` and `where` narrow the accounts.\n\nAn account\'s timeline pages the same way. `kenso accounts activity 812` returns the newest 100 earlier rows and, when older ones exist, `data.nextCursor`. Pass it back as `--cursor` (with the same `--category`) for the rows before them, until a page comes without one.\n\n## Edit accounts, people and opportunities\n\nApart from `accounts bulk-update`, which sets one `accountType` on up to 500 accounts, there is no bulk edit route, so run the generated `update` command once per row with `--each`. Columns are the command\'s flags by API name or flag name, and the id column fills the route:\n\n```bash\nkenso accounts update --each accounts-edit.csv --dry-run # then the same with --yes\nkenso people update --each people-edit.csv --dry-run\nkenso opportunities update --each deals.csv --dry-run\n```\n\n```csv\naccountId,stage,ownerMemberId,overwritePinned\n501,engaged,42,true\n502,customer,42,true\n```\n\nA row that changes a field someone pinned in the app fails as a whole (`409 conflict`, `pinned_by_user`: nothing on that record changes, the other fields of the row included), unless the row sets `overwritePinned` to `true` (or you pass `--overwrite-pinned`, only with the person\'s OK). Every flag of an update command: `kenso accounts update --help`.\n\n## Search opportunities\n\n`kenso opportunities search` works as `accounts search` does: it takes `--search`, `--sort`, `--limit`, `--cursor`, `--all`, and its lists in `--data`.\n\n```bash\nkenso opportunities search --data \'{"filters": [{"field": "stageCategory", "operator": "is", "values": ["open"]}]}\' --all\nkenso opportunities search --data \'{"filters": [{"field": "ownerMemberId", "operator": "is", "values": ["none"]}, {"field": "closeDate", "operator": "is", "values": ["past_due", "next_30_days"]}]}\'\nkenso opportunities search --limit 1 --data \'{"countBy": ["stage", "ownerMemberId"]}\' # how many opportunities hold each value\n```\n\n- **`filters`** is a list of `{field, operator, values}`, all of which must hold. Fields: `stage` (a stage key), `stageCategory` (`open`, `won`, `lost`), `ownerMemberId`, `closeDate` (`past_due`, `next_30_days`, `later`, `none`) and `sourceCampaignId`. `operator` is `is` or `is_not`; the values of one condition are OR. `none` in `values` matches an opportunity with no owner, no source campaign or no close date.\n- **`countBy`** takes the same field names and adds `counts` to the output: per field, every value with the number of matching opportunities that hold it.\n- `--account-id` keeps the search to one account. `closeDate` counts days in the member\'s app time zone.\n\nOne person\'s deals, meetings and campaign contacts, as their person page lists them:\n\n```bash\nkenso opportunities list --person-id 9001 # the deals they are on, or are the primary person of\nkenso meetings list --person-id 9001 # the meetings they attend, among the ones you can see\nkenso contacts list --person-id 9001 # their contact in each campaign they are in\n```\n\n## Write research you gathered\n\n`accounts write-research` and `people write-research` store research you gathered outside Kenso as the record\'s latest research (`PUT /v1/accounts/{accountId}/research`, `PUT /v1/people/{personId}/research`). The Research tab shows it like a Ken run, with `trigger: agent` and `researchedAt` now. Nothing is charged, and no account or person field changes: set an account\'s own `fitScore`, `whyNow` or `angle` with `accounts update`. They need the `accounts_research` flag and accounts edit.\n\nThe body is the research block `accounts get --expand research` (or `people get-research`) returns, without its read-only fields: leave out `id`, `status`, `trigger`, `errorCode`, `researchedAt`, `isStale` and `appliedPrompt` (for a person also `mode`, `requestedAt`, `researchedMode`, `firecrawlCredits` and `webNote`), or the write fails with `unknown_field`. Pass it with `--data @file`:\n\n```bash\nkenso accounts write-research --account-id 501 --data @acme-dossier.json\nkenso people write-research --person-id 9001 --data @jane.json\n```\n\n```json\n{\n "tagline": { "text": "Payroll for EU contractors", "sourceUrls": ["https://acme.example"] },\n "description": { "text": "Acme runs payroll and compliance for companies hiring contractors in 30 EU countries.", "sourceUrls": ["https://acme.example"] },\n "links": { "website": "https://acme.example" },\n "whyNow": { "text": "Raised a $40M Series B in October", "sourceUrls": ["https://news.example/acme-b"], "date": "2026-10" },\n "fitScore": 82,\n "angle": "Lead with contractor onboarding time."\n}\n```\n\nMany records: one JSONL line per record, with the id next to the block\'s fields. Nested objects are sent as written. Use JSONL, not CSV: the block\'s fields are objects and lists, which a CSV cell cannot carry.\n\n```bash\nkenso accounts write-research --each dossiers.jsonl --dry-run # then the same with --yes\nkenso people write-research --each people-research.jsonl --yes --concurrency 8\n```\n\n```jsonl\n{"accountId": 501, "tagline": {"text": "Payroll for EU contractors"}, "links": {"website": "https://acme.example"}}\n{"accountId": 502, "description": {"text": "Cloud cost tooling for retailers."}, "links": {"website": "https://beta.example"}}\n```\n\nA row fails as a whole with the API\'s code: `validation_failed` (an unknown field is `unknown_field`, and `error.details` names every bad field), `research_in_progress` (`409`: Ken is researching that record now, write it again once the run ends; an account run waiting for credits counts too: it runs once the workspace has credits, and the write stays refused until that run ends) or `not_found`. Rerunning a file is safe: each write replaces the record\'s research shown.\n\n## CRM sync\n\nCRM sync has generated commands only: read connections, preview, start an import, and work through sync issues. Connect the CRM itself in the app.\n\n```bash\nkenso crm-connections list\nkenso crm-connections get --connection-id 7\nkenso crm-imports create --connection-id 7 --dry-run\nkenso crm-sync-issues list --connection-id 7 --all\n```\n\nRun `kenso crm-connections --help` (or add `--all-commands` when the actions are hidden) to see every action.\n\n## A deal\'s stage history\n\n```bash\nkenso opportunities stage-history 77\nkenso opportunities stage-history 77 --query "entries[].{to: stageLabel, at: enteredAt, by: changedBy}"\n```\n\nIt prints `GET /v1/opportunities/{id}/stage-history` as it is, the same rows as the deal page and the MCP\'s `opportunities(operation="get-stage-history")`: the stage now, `isComplete` and `entries`, oldest first, each with `fromStage`, `stage`, `stageLabel`, `enteredAt`, `leftAt`, `durationSeconds`, `actorKind`, `actorMemberId` and Ken\'s `reason` on a move its stage judge made. With the `deal_stage_rules` flag on, each entry also has `changedBy` (`member`, `agent`, `api_key`, `workflow`, `stage_judge`, `crm_sync` or `ken_automation`), `crmProvider` on a CRM sync, and on a move `fromStageLabel` and `fromStageDurationSeconds`, how long the deal sat in the stage it left. `isComplete` false means Kenso has no record of part of the history.\n';
7267
7267
  }
7268
7268
  });
7269
7269
 
@@ -7287,7 +7287,15 @@ var init_output_and_errors = __esm({
7287
7287
  var README_default;
7288
7288
  var init_README = __esm({
7289
7289
  "docs/README.md"() {
7290
- 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\nOn macOS or Linux, with or without Node, run the [install script](https://ken.so/install.sh): fetch it with `curl -fsSL` and pipe it to `sh`. It installs a standalone build that brings its own Node.js, checks the download against the release\'s `SHA256SUMS`, puts the CLI in `~/.local/share/kenso` and links `~/.local/bin/kenso`. Run it again to update.\n\nWith Node 22 or newer, on any system, Windows included:\n\n```bash\nnpm i -g kenso\nkenso --version\n```\n\nTo run it once without installing, use `npx kenso --version`. On an older Node, kenso stops with one line that says so.\n\nEvery way to install:\n\n| Way | Systems | Needs |\n|---|---|---|\n| Install script, above | macOS, Linux (glibc) | Nothing |\n| npm, above | Any | Node 22 or newer |\n| Standalone build: unpack it and put its `bin` folder on your PATH | macOS, Linux, Windows | Nothing |\n\nThe standalone builds are at `https://downloads.ken.so/desktop/cli/<version>/`, one per system: `kenso-<version>-darwin-arm64.tar.gz`, `darwin-x64`, `linux-arm64`, `linux-x64` and `kenso-<version>-windows-x64.zip`, with their `SHA256SUMS`. `https://downloads.ken.so/desktop/cli/latest.yml` names the newest version. The builds come out nightly, so a command added that day reaches npm first.\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. A standalone build checks `latest.yml` on `downloads.ken.so` instead and names its own update: the install script, or `brew upgrade kenso` when Homebrew installed it. 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\'s 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';
7290
+ 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\nOn macOS or Linux, with or without Node, run the [install script](https://ken.so/install.sh): fetch it with `curl -fsSL` and pipe it to `sh`. It installs a standalone build that brings its own Node.js, checks the download against the release\'s `SHA256SUMS`, puts the CLI in `~/.local/share/kenso` and links `~/.local/bin/kenso`. Run it again to update.\n\nWith Node 22 or newer, on any system, Windows included:\n\n```bash\nnpm i -g kenso\nkenso --version\n```\n\nTo run it once without installing, use `npx kenso --version`. On an older Node, kenso stops with one line that says so.\n\nEvery way to install:\n\n| Way | Systems | Needs |\n|---|---|---|\n| Install script, above | macOS, Linux (glibc) | Nothing |\n| npm, above | Any | Node 22 or newer |\n| Standalone build: unpack it and put its `bin` folder on your PATH | macOS, Linux, Windows | Nothing |\n\nThe standalone builds are at `https://downloads.ken.so/desktop/cli/<version>/`, one per system: `kenso-<version>-darwin-arm64.tar.gz`, `darwin-x64`, `linux-arm64`, `linux-x64` and `kenso-<version>-windows-x64.zip`, with their `SHA256SUMS`. `https://downloads.ken.so/desktop/cli/latest.yml` names the newest version. The builds come out nightly, so a command added that day reaches npm first.\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. A standalone build checks `latest.yml` on `downloads.ken.so` instead and names its own update: the install script, or `brew upgrade kenso` when Homebrew installed it. 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\'s 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| [Developer sandbox](sandbox.md) | `sandbox` | `kenso sandbox`: a workspace of your own where sends are simulated, its test key, the reserved test leads |\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';
7291
+ }
7292
+ });
7293
+
7294
+ // docs/sandbox.md
7295
+ var sandbox_default;
7296
+ var init_sandbox = __esm({
7297
+ "docs/sandbox.md"() {
7298
+ sandbox_default = '# Developer sandbox\n\nA developer sandbox is a Kenso workspace of your own for building and testing an integration. It starts with example campaigns, contacts, inboxes and conversation threads, and everything in it is simulated: sends, orders and charges never reach a provider. Nothing leaves Kenso. Campaigns still plan and send in the sandbox, your webhook endpoints still receive its events, and a few reserved test addresses answer like real leads would.\n\nYou work in it with a test key: `kenso_test_` and 49 letters and digits. A test key works only in its sandbox, and only on `Ken-Version: 1.1` routes, which is what `kenso` sends: every other workspace answers 404, and a request without that version, or to a route that has no 1.1 form, answers 403. You have one sandbox at most.\n\nThis is not the cloud sandbox a coding agent runs in (`kenso work run`, see `kenso docs agents`).\n\nSandboxes are in beta: the commands work in workspaces where Kenso has turned them on.\n\n## Commands\n\nThe sandbox commands run with your live key, in your current workspace. Run with a test key, they stop before sending anything.\n\n| Command | What it does |\n|---|---|\n| `sandbox create` | Creates your sandbox and its first test key, and saves the key as the profile `sandbox` |\n| `sandbox list` | Lists your sandbox |\n| `sandbox reset [sandboxId]` | Deletes everything in the sandbox and seeds it again. Test keys and webhook endpoints stay |\n| `sandbox key [sandboxId]` | Creates another test key (5 active at most) and saves it as the profile `sandbox` |\n| `sandbox delete [sandboxId]` | Deletes the sandbox and revokes its test keys, then removes the profile `sandbox` |\n\nWithout an id, `reset`, `key` and `delete` use your one sandbox. `delete` asks first on a terminal; in a script or an agent it needs `--yes`, and `--dry-run` prints the request it would send.\n\n## Quick start\n\n```bash\nkenso sandbox create\n```\n\nIt prints the sandbox and its test key once, as JSON:\n\n```json\n{"sandboxId":20417,"name":"Sandbox (you@acme.com)","status":"ready","seed":{"campaigns":2,"contacts":25,"inboxes":2,"threads":4},"testKey":{"id":"apk_...","prefix":"kenso_test_AbCdE","secret":"kenso_test_...","expiresAt":"2027-02-13T18:00:00Z"},"profile":"sandbox"}\n```\n\nThe key is saved as the profile `sandbox`, and your active profile stays the live one. Add `--profile sandbox` to run any command in the sandbox:\n\n```bash\nkenso campaigns list --profile sandbox\nkenso auth status --profile sandbox\n```\n\n`KENSO_API_KEY` and `KENSO_WORKSPACE_ID` win over every profile, `--profile sandbox` included: while either is set, a command does not use the test key and its sandbox. Unset them, or set `KENSO_API_KEY=<the test key> KENSO_WORKSPACE_ID=<sandboxId>` to work in the sandbox. `sandbox create` and `sandbox key` warn when they are set, and `auth status` when they override the profile.\n\n`auth status` says `"keyKind":"test"` and names the sandbox. A test key expires after 90 days: `kenso sandbox key` makes a new one and saves it over the old one in the profile. To start over, `kenso sandbox reset`. When you are done, `kenso sandbox delete --yes`.\n\nYour code can use the same key without the CLI: send it as `Authorization: Bearer <key>` and the sandbox id as `X-Ken-Workspace-Id`.\n\n## Reserved test leads\n\nAdd a lead with one of these addresses to a sandbox campaign and launch it. After its simulated send, the lead gets that outcome. A `+label` before the `@` is ignored, so `replied-interested+signup@test.ken.so` works too.\n\n| Address | Outcome in a sandbox |\n|---|---|\n| `replied-interested@test.ken.so` | A reply classified Interested |\n| `bounced@test.ken.so` | A hard bounce |\n| `ooo@test.ken.so` | An out-of-office auto reply |\n| `unsubscribed@test.ken.so` | An unsubscribe |\n\nAny other address gets a simulated send and nothing after it.\n';
7291
7299
  }
7292
7300
  });
7293
7301
 
@@ -7303,7 +7311,7 @@ var init_studio = __esm({
7303
7311
  var webhooks_default;
7304
7312
  var init_webhooks = __esm({
7305
7313
  "docs/webhooks.md"() {
7306
- webhooks_default = '# Webhooks: listen and trigger\n\nBuild and test a webhook handler on your own machine, with no public tunnel and no webhook endpoint in Kenso. `kenso webhooks listen` streams your workspace\'s events, prints each one as JSON and forwards it to your handler, signed the way Kenso signs its deliveries. `kenso webhooks trigger` sends a sample event through the running listener.\n\n| Command | What it does |\n|---|---|\n| `webhooks listen --forward-to <url>` | Streams events, prints one JSON line each, and POSTs each to your handler |\n| `webhooks listen --print-secret` | Prints the local signing secret and exits |\n| `webhooks trigger <event-type>` | Sends that type\'s sample through the running listener |\n\n## Quick start\n\nIn one terminal:\n\n```bash\nkenso webhooks listen --forward-to http://localhost:3000/hook\n```\n\nIt prints its signing secret on stderr:\n\n```\nReady. Forwarding events to http://localhost:3000/hook.\nSigning secret: whsec_... (the same on every run; kept in ~/.kenso/webhooks/signing-secret).\n```\n\nPut that secret in your handler\'s config (for example `KENSO_WEBHOOK_SECRET`). In another terminal:\n\n```bash\nkenso webhooks trigger reply.received\n```\n\nThe listener prints the event and your handler receives it. `kenso webhook-event-types list` lists every type with its sample body.\n\n## What your handler receives\n\nEach forward is a `POST` with a JSON body shaped like a webhook delivery (no envelope, `eventType` at the top) and the headers a Kenso delivery carries. How full the body is depends on where the event came from:\n\n- **A trigger** sends the type\'s full sample body, the same shape a webhook endpoint receives in production.\n- **A live event** is sparse. The event log keeps only part of each delivery, so the body has `eventType`, `eventId`, `timestamp` and `clientId`, plus the ids, statuses and `links` at their delivery paths (`contact.id`, `campaign.id`, `reply.classification`, ...). Names, emails, reply text and the other fields are not there: read them with the API, or build that part of the handler against a trigger\'s sample.\n\nThe headers:\n\n| Header | Value |\n|---|---|\n| `svix-id` | The event\'s id. Dedupe on it |\n| `svix-timestamp` | Unix seconds of the send |\n| `svix-signature` | `v1,` and the base64 HMAC-SHA256 of `{svix-id}.{svix-timestamp}.{body}`, keyed by the secret |\n| `content-type` | `application/json` |\n\nSo the verification code you write for production works unchanged: the Svix libraries (`svix` for Node, Python, Go and others) and the check in the Webhooks section of the Kenso API docs accept these deliveries. Only the secret differs. The listener\'s secret is local: it is made on your machine the first time you run `listen`, stays the same on every run, and is never a real endpoint\'s secret. In production, use your endpoint\'s secret from `kenso webhook-endpoints get-signing-secret --webhook-endpoint-id <webhookEndpointId>`.\n\nFor scripts, take the secret without starting a listener:\n\n```bash\nexport KENSO_WEBHOOK_SECRET=$(kenso webhooks listen --print-secret)\n```\n\n## Output\n\nstdout gets one JSON line per event, for `jq` or an agent:\n\n```json\n{"eventId":"0b6f...","type":"reply.received","timestamp":"2026-11-15T10:00:00Z","source":"live","forward":{"url":"http://localhost:3000/hook","status":200,"ms":12},"data":{"eventType":"reply.received","...":"..."}}\n```\n\n- `source` is `live` for a real event and `trigger` for a sample.\n- `forward` is what your handler answered: `status`, or `error` (`ECONNREFUSED` when nothing listens there). It is absent without `--forward-to`.\n- `data` is the body your handler received (or would receive, without `--forward-to`).\n\nThe ready line, the secret and the summary at Ctrl-C go to stderr.\n\n## Live events\n\n`listen` reads the workspace\'s event log (`GET /v1/event-occurrences`), so it receives the types with `mcp: true` in `kenso webhook-event-types list` that your seat can see. It polls the log, so a real event arrives within about 30 s; a trigger arrives at once. `--events reply.received,meeting.booked` (or `--events` repeated) narrows the types.\n\nThe event log is not on for every workspace yet. Where it is off, `listen` says so in a warning and still forwards everything you trigger, so you can build the handler first.\n\n## Triggers\n\n`trigger` takes the type\'s sample from `GET /v1/webhook-event-types`, gives it a new `eventId` (`evt_test_...`) and the current `timestamp`, and hands it to the listener for this workspace, which prints and forwards it like a live event. It sends nothing to Kenso\'s event log, to your webhook endpoints or to anyone else. It exits 1 with `forward_failed` when your handler did not answer 2xx, and with `listener_not_running` when no listener runs for the workspace.\n\nTo send a sample to a real, deployed endpoint instead, use `kenso webhook-endpoints test --webhook-endpoint-id <webhookEndpointId> --event-type reply.received`.\n\n## Stopping\n\nCtrl-C stops the listener. `listen` creates no webhook endpoint, no event subscription and no tunnel, so there is nothing to delete in Kenso. Its polls do keep the workspace\'s event log recording: the log stops on its own 7 days after the last poll. A poll that fails (a network error, a 5xx) prints a warning and is tried again a minute later; a bad key or a refused request ends the listener. It removes its local state file (the address `trigger` uses) on the way out.\n';
7314
+ webhooks_default = '# Webhooks: listen and trigger\n\nBuild and test a webhook handler on your own machine, with no public tunnel and no webhook endpoint in Kenso. `kenso webhooks listen` streams your workspace\'s events, prints each one as JSON and forwards it to your handler, signed the way Kenso signs its deliveries. `kenso webhooks trigger` sends a sample event through the running listener.\n\n| Command | What it does |\n|---|---|\n| `webhooks listen --forward-to <url>` | Streams events, prints one JSON line each, and POSTs each to your handler |\n| `webhooks listen --print-secret` | Prints the local signing secret and exits |\n| `webhooks trigger <event-type>` | Sends that type\'s sample through the running listener |\n\n## Quick start\n\nIn one terminal:\n\n```bash\nkenso webhooks listen --forward-to http://localhost:3000/hook\n```\n\nIt prints its signing secret on stderr:\n\n```\nReady. Forwarding events to http://localhost:3000/hook.\nSigning secret: whsec_... (the same on every run; kept in ~/.kenso/webhooks/signing-secret).\n```\n\nPut that secret in your handler\'s config (for example `KENSO_WEBHOOK_SECRET`). In another terminal:\n\n```bash\nkenso webhooks trigger reply.received\n```\n\nThe listener prints the event and your handler receives it. `kenso webhook-event-types list` lists every type with its sample body.\n\n## What your handler receives\n\nEach forward is a `POST` with a JSON body shaped like a webhook delivery (no envelope, `eventType` at the top) and the headers a Kenso delivery carries. How full the body is depends on where the event came from:\n\n- **A trigger** sends the type\'s full sample body, the same shape a webhook endpoint receives in production.\n- **A live event** is sparse. The event log keeps only part of each delivery, so the body has `eventType`, `eventId`, `timestamp` and `clientId`, plus the ids, statuses and `links` at their delivery paths (`contact.id`, `campaign.id`, `reply.classification`, ...). Names, emails, reply text and the other fields are not there: read them with the API, or build that part of the handler against a trigger\'s sample.\n\nThe headers:\n\n| Header | Value |\n|---|---|\n| `svix-id` | The event\'s id. Dedupe on it |\n| `svix-timestamp` | Unix seconds of the send |\n| `svix-signature` | `v1,` and the base64 HMAC-SHA256 of `{svix-id}.{svix-timestamp}.{body}`, keyed by the secret |\n| `content-type` | `application/json` |\n\nSo the verification code you write for production works unchanged: the Svix libraries (`svix` for Node, Python, Go and others) and the check in the Webhooks section of the Kenso API docs accept these deliveries. Only the secret differs. The listener\'s secret is local: it is made on your machine the first time you run `listen`, stays the same on every run, and is never a real endpoint\'s secret. In production, use your endpoint\'s secret from `kenso webhook-endpoints get-signing-secret --webhook-endpoint-id <webhookEndpointId>`.\n\nFor scripts, take the secret without starting a listener:\n\n```bash\nexport KENSO_WEBHOOK_SECRET=$(kenso webhooks listen --print-secret)\n```\n\n## Output\n\nstdout gets one JSON line per event, for `jq` or an agent:\n\n```json\n{"eventId":"0b6f...","type":"reply.received","timestamp":"2026-11-15T10:00:00Z","source":"live","forward":{"url":"http://localhost:3000/hook","status":200,"ms":12},"data":{"eventType":"reply.received","...":"..."}}\n```\n\n- `source` is `live` for a real event and `trigger` for a sample.\n- `forward` is what your handler answered: `status`, or `error` (`ECONNREFUSED` when nothing listens there). It is absent without `--forward-to`.\n- `data` is the body your handler received (or would receive, without `--forward-to`).\n\nThe ready line, the secret and the summary at Ctrl-C go to stderr.\n\n## Live events\n\n`listen` reads the workspace\'s event log (`GET /v1/event-occurrences`), so it receives the types with `mcp: true` in `kenso webhook-event-types list` that your seat can see. It polls the log, so a real event arrives within about 30 s; a trigger arrives at once. `--events reply.received,meeting.booked` (or `--events` repeated) narrows the types.\n\nThe event log is not on for every workspace yet. Where it is off, `listen` says so in a warning and still forwards everything you trigger, so you can build the handler first.\n\n## Triggers\n\n`trigger` takes the type\'s sample from `GET /v1/webhook-event-types`, gives it a new `eventId` (`evt_test_...`) and the current `timestamp`, and hands it to the listener for this workspace, which prints and forwards it like a live event. It sends nothing to Kenso\'s event log, to your webhook endpoints or to anyone else. It exits 1 with `forward_failed` when your handler did not answer 2xx, and with `listener_not_running` when no listener runs for the workspace.\n\nTo send a sample to a real, deployed endpoint instead, use `kenso webhook-endpoints test --webhook-endpoint-id <webhookEndpointId> --event-type reply.received`.\n\n## Stopping\n\nCtrl-C stops the listener. `listen` creates no webhook endpoint, no event subscription and no tunnel, so there is nothing to delete in Kenso. Its polls do keep the workspace\'s event log recording: the log stops on its own 7 days after the last poll. A poll that fails (a network error, a 5xx) prints a warning and is tried again a minute later; a bad key or a refused request ends the listener. It removes its local state file (the address `trigger` uses) on the way out.\n\n## Related: your API request logs\n\n`kenso logs tail` follows the same polling pattern for your API calls: it prints each request made with a Kenso API key as it is logged, so you see a failed call as it happens.\n\n```bash\nkenso logs tail --status 4xx,5xx --since 10m\nkenso logs tail --key apk_3f9c -o json\n```\n\nOn a terminal each row is one line: time, `[status]`, method, path template, error code, duration, key id, request id. Piped, or with `-o json`, each row is one JSON object per line. A row is logged after its request finishes, so a slow request can print up to a minute out of order. Where request logs are not on for the workspace yet, it exits 4 with `Request logs are not on for this workspace yet.`\n';
7307
7315
  }
7308
7316
  });
7309
7317
 
@@ -7319,7 +7327,7 @@ var init_work = __esm({
7319
7327
  var SKILL_default;
7320
7328
  var init_SKILL = __esm({
7321
7329
  "skill/kenso-cli/SKILL.md"() {
7322
- SKILL_default = '---\nname: kenso-cli\ndescription: The Kenso CLI (kenso) for work from a file (of any size, even a few ids) or over about 50 records - import, update, remove (delete), pause, tag or export leads, import CRM accounts and people, edit Studio templates as local files and fill them, run an API operation per file row, resume an interrupted run, write the Kenso AI work a workspace gave to its own coding agent (My agent, with kenso work run, or work pull and submit with subagents), sign in with a key from a variable (pipe it to kenso auth login --with-key, no check first). For records listed in the message (under about 50), one record or a question, use the Kenso MCP.\n---\n\n1. Every write runs first with `--dry-run`; apply with the plan\'s `next` (a delete, archive or remove applies with `--yes`). `--yes` at once only to continue an interrupted run or apply what the person confirmed. A command with no dry run refuses `--dry-run` (exit 2, nothing ran): read its `--help`, then run it without.\n2. Many rows: one command on the file as it is (`--file`, `--ids`, `--each`). Run kenso only: no python, awk or shell tests, not even on a file or variable.\n3. Any output\'s `next` is the command to run; errors are JSON on stderr. `--force` only with the person\'s OK.\n4. Ids are flags: `--campaign-id 812` (or `--campaign 812`, the same flag). `--workspace <id>`; by name `kenso workspace list --search acme`. `--json` is `-o json`; `--query` takes JMESPath (there is no `--jq`). Other commands: `kenso --help`; `kenso api <METHOD> <path>` only when none fits.\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --dry-run # skips leads already in; --map \'{"Pain": "customVariables.pain_point", "Notes": null}\'; over 200 MB --server-import\nkenso contacts update --file edits.csv --match id --dry-run # also one lead; or --match email --campaign 812\nkenso contacts remove --ids ids.txt --dry-run # also pause, resume, restore; over 1,000: --confirm <count>\nkenso contacts remove --where \'{"campaignIds": [812], "filters": [{"conditions": {"field": "ContactCompany.Name", "operator": 2, "value": "acme"}}]}\' --dry-run # also pause, resume; 2 = contains; no search first\nkenso contacts tag --tag 31 --ids ids.txt --dry-run # tag, restore: --ids only, so first kenso contacts list --campaign-id 812 --all -o ids > ids.txt\nkenso contact-imports create --source campaign --source-campaign-id 10601 --campaign-id 812 --dry-run # copy another campaign\'s leads in\nkenso contacts export --campaign 812 --out leads.csv # a segment: kenso contact-exports create --segment-id 55\nkenso runs resume <runId> # an interrupted run; terminal lost: kenso runs list finds it. A changed file is a new run\nkenso accounts import --file accounts.csv --dry-run # companies; a file of people: kenso people import --file people.csv\nkenso studio push 12 --dir ./tpl # to preview local edits push first (draft; live needs --publish), then studio preview 12\nkenso studio fill 12 --accounts ids.txt --dry-run # or --campaign 10546 --contacts leads.csv\nkenso opportunities update --each rows.csv --dry-run # any API command on a file of rows (CSV or JSONL; keys fill flags and body). One record: kenso campaigns update --campaign-id 812 --name Q4 --dry-run\nkenso mcp call list_skills # only to list Ken\'s skills\n```\n\nCharges: `accounts import` per new account, `studio fill` per page (again for ids from another file): show the estimate. `pinned_by_user`: with the person\'s OK, rerun with `--overwrite-pinned`. Workflows: `kenso workflows brief` first; secrets only as `{{secrets.NAME}}`. Key: `KENSO_API_KEY`, or pipe a variable, no check: `printf \'%s\' "$KEY" | kenso auth login --with-key`; never in a flag, output or file.\n\n## Work (beta): My agent\n\nA workspace can set a kind of Kenso AI work (personalization, qualification, segmentation, rewriting, meeting brief, call brief, workflow prompt) to My agent in Settings > AI work: then it waits for the person\'s own coding agent, at 0 Kenso AI credits. The `kenso work` commands take no `--dry-run`. Never read the items\' text into the chat: the files carry it.\n\n```bash\nkenso work status # what waits, per kind\nkenso work run --agent claude # does it all: claims, runs headless agents, submits; stops when the queue is empty. Other agents need --allow-unconfined; exit 6 = the plan\'s usage limit\nkenso work pull --files 4 --per-file 10 # by hand: prints the work file paths, never the items\nkenso work submit <dir>/*.answers.json # pull\'s next; exit 5 = some answers rejected (see each <claimId>.results.json)\nkenso work release <claimId> # give back work you will not finish\n```\n\nBy hand in a chat: run `kenso work pull`, then give each work file to its own subagent with only its path ("Read this work file and write its answers file as its rules say"), then run pull\'s `next`. More: `kenso docs work`.\n\n## Setup\n\n`kenso` missing: `curl -fsSL https://ken.so/install.sh | sh` (macOS or Linux, no Node needed) or `npm i -g kenso` (Node 22 or newer), or run a command as `npx -y kenso@latest <command>`. Then `kenso auth login` (the person approves in the browser) and `kenso doctor`. `kenso agent setup -y` installs this skill and the Kenso MCP server (`https://mcp.ken.so/mcp`) for the agent; the person signs in to the MCP once in the agent.\n\n## No Kenso account yet\n\nThe CLI signs in with a Kenso API key. If the user has no Kenso account, send them to https://app.ken.so/get-started to create one, then create a key in Kenso at Settings > Integrations > API keys.\n';
7330
+ SKILL_default = '---\nname: kenso-cli\ndescription: The Kenso CLI (kenso) for work from a file (of any size, even a few ids) or over about 50 records - import, update, remove (delete), pause, tag or export leads, import CRM accounts and people, edit Studio templates as local files and fill them, run an API operation per file row, resume an interrupted run, write the Kenso AI work a workspace gave to its own coding agent (My agent, with kenso work run, or work pull and submit with subagents), sign in with a key from a variable (pipe it to kenso auth login --with-key, no check first). For records listed in the message (under about 50), one record or a question, use the Kenso MCP.\n---\n\n1. Every write runs first with `--dry-run`; apply with the plan\'s `next` (a delete, archive or remove applies with `--yes`). `--yes` at once only to continue an interrupted run or apply what the person confirmed. A command with no dry run refuses `--dry-run` (exit 2, nothing ran): read its `--help`, then run it without.\n2. Many rows: one command on the file as it is (`--file`, `--ids`, `--each`). Run kenso only: no python, awk or shell tests, not even on a file or variable.\n3. Any output\'s `next` is the command to run; errors are JSON on stderr. `--force` only with the person\'s OK.\n4. Ids are flags: `--campaign-id 812` (or `--campaign 812`, the same flag). `--workspace <id>`; by name `kenso workspace list --search acme`. `--json` is `-o json`; `--query` takes JMESPath (there is no `--jq`). Other commands: `kenso --help`; `kenso api <METHOD> <path>` only when none fits.\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --dry-run # skips leads already in; --map \'{"Pain": "customVariables.pain_point", "Notes": null}\'; over 200 MB --server-import\nkenso contacts update --file edits.csv --match id --dry-run # also one lead; or --match email --campaign 812\nkenso contacts remove --ids ids.txt --dry-run # also pause, resume, restore; over 1,000: --confirm <count>\nkenso contacts remove --where \'{"campaignIds": [812], "filters": [{"conditions": {"field": "ContactCompany.Name", "operator": 2, "value": "acme"}}]}\' --dry-run # also pause, resume; 2 = contains; no search first\nkenso contacts tag --tag 31 --ids ids.txt --dry-run # tag, restore: --ids only, so first kenso contacts list --campaign-id 812 --all -o ids > ids.txt\nkenso contact-imports create --source campaign --source-campaign-id 10601 --campaign-id 812 --dry-run # copy another campaign\'s leads in\nkenso contacts export --campaign 812 --out leads.csv # a segment: kenso contact-exports create --segment-id 55\nkenso runs resume <runId> # an interrupted run; terminal lost: kenso runs list finds it. A changed file is a new run\nkenso accounts import --file accounts.csv --dry-run # companies; a file of people: kenso people import --file people.csv\nkenso studio push 12 --dir ./tpl # to preview local edits push first (draft; live needs --publish), then studio preview 12\nkenso studio fill 12 --accounts ids.txt --dry-run # or --campaign 10546 --contacts leads.csv\nkenso opportunities update --each rows.csv --dry-run # any API command on a file of rows (CSV or JSONL; keys fill flags and body). One record: kenso campaigns update --campaign-id 812 --name Q4 --dry-run\nkenso mcp call list_skills # only to list Ken\'s skills\nkenso logs tail --status 4xx,5xx --since 10m # stream the workspace\'s failed API calls, one line each; Ctrl-C stops (exit 4 = not on for the workspace yet)\n```\n\nCharges: `accounts import` per new account, `studio fill` per page (again for ids from another file): show the estimate. `pinned_by_user`: with the person\'s OK, rerun with `--overwrite-pinned`. Workflows: `kenso workflows brief` first; secrets only as `{{secrets.NAME}}`. Key: `KENSO_API_KEY`, or pipe a variable, no check: `printf \'%s\' "$KEY" | kenso auth login --with-key`; never in a flag, output or file.\n\n## Work (beta): My agent\n\nA workspace can set a kind of Kenso AI work (personalization, qualification, segmentation, rewriting, meeting brief, call brief, workflow prompt) to My agent in Settings > AI work: then it waits for the person\'s own coding agent, at 0 Kenso AI credits. The `kenso work` commands take no `--dry-run`. Never read the items\' text into the chat: the files carry it.\n\n```bash\nkenso work status # what waits, per kind\nkenso work run --agent claude # does it all: claims, runs headless agents, submits; stops when the queue is empty. Other agents need --allow-unconfined; exit 6 = the plan\'s usage limit\nkenso work pull --files 4 --per-file 10 # by hand: prints the work file paths, never the items\nkenso work submit <dir>/*.answers.json # pull\'s next; exit 5 = some answers rejected (see each <claimId>.results.json)\nkenso work release <claimId> # give back work you will not finish\n```\n\nBy hand in a chat: run `kenso work pull`, then give each work file to its own subagent with only its path ("Read this work file and write its answers file as its rules say"), then run pull\'s `next`. More: `kenso docs work`.\n\n## Setup\n\n`kenso` missing: `curl -fsSL https://ken.so/install.sh | sh` (macOS or Linux, no Node needed) or `npm i -g kenso` (Node 22 or newer), or run a command as `npx -y kenso@latest <command>`. Then `kenso auth login` (the person approves in the browser) and `kenso doctor`. `kenso agent setup -y` installs this skill and the Kenso MCP server (`https://mcp.ken.so/mcp`) for the agent; the person signs in to the MCP once in the agent.\n\n## No Kenso account yet\n\nThe CLI signs in with a Kenso API key. If the user has no Kenso account, send them to https://app.ken.so/get-started to create one, then create a key in Kenso at Settings > Integrations > API keys.\n';
7323
7331
  }
7324
7332
  });
7325
7333
 
@@ -7340,6 +7348,7 @@ var init_embedded = __esm({
7340
7348
  init_leads();
7341
7349
  init_output_and_errors();
7342
7350
  init_README();
7351
+ init_sandbox();
7343
7352
  init_studio();
7344
7353
  init_webhooks();
7345
7354
  init_work();
@@ -7354,6 +7363,7 @@ var init_embedded = __esm({
7354
7363
  "studio.md": studio_default,
7355
7364
  "work.md": work_default,
7356
7365
  "webhooks.md": webhooks_default,
7366
+ "sandbox.md": sandbox_default,
7357
7367
  "agents.md": agents_default
7358
7368
  };
7359
7369
  SKILL = SKILL_default;
@@ -7391,6 +7401,7 @@ var init_content = __esm({
7391
7401
  { topic: "studio", file: "studio.md", title: "Studio (beta)", description: "Pull, push, validate, preview and fill templates" },
7392
7402
  { topic: "work", file: "work.md", title: "Agent work (beta)", description: "My agent: your own coding agent writes Kenso AI work with kenso work run, or pull and submit" },
7393
7403
  { topic: "webhooks", file: "webhooks.md", title: "Webhooks", description: "Build a webhook handler locally: kenso webhooks listen --forward-to, trigger, the signature" },
7404
+ { topic: "sandbox", file: "sandbox.md", title: "Developer sandbox", description: "kenso sandbox: a workspace of your own where sends are simulated, its test key, the reserved test leads" },
7394
7405
  { topic: "agents", file: "agents.md", title: "Coding agents", description: "kenso agent setup for Claude Code, Codex, Cursor, Gemini CLI and OpenCode, the Agent Skill, environment variables, sandboxes" },
7395
7406
  { topic: "reference", file: "reference.md", title: "Command reference", description: "Every command with its flags, generated from the CLI at build time" }
7396
7407
  ];
@@ -8154,11 +8165,15 @@ var init_api3 = __esm({
8154
8165
  });
8155
8166
 
8156
8167
  // src/core/api-key.ts
8157
- var API_KEY_PATTERN;
8168
+ function isTestKey(key) {
8169
+ return key?.startsWith(TEST_KEY_PREFIX) === true;
8170
+ }
8171
+ var API_KEY_PATTERN, TEST_KEY_PREFIX;
8158
8172
  var init_api_key = __esm({
8159
8173
  "src/core/api-key.ts"() {
8160
8174
  "use strict";
8161
8175
  API_KEY_PATTERN = /^(?:kenso_(?:live|test)_[A-Za-z0-9]{49}|ken_[A-Za-z0-9_-]{43})$/;
8176
+ TEST_KEY_PREFIX = "kenso_test_";
8162
8177
  }
8163
8178
  });
8164
8179
 
@@ -8385,8 +8400,8 @@ var init_browser_login = __esm({
8385
8400
  defaultDeps = {
8386
8401
  sleep: (ms, signal) => delay2(ms, void 0, signal ? { signal } : void 0),
8387
8402
  now: () => Date.now(),
8388
- spawn: (command37, args) => {
8389
- const child = nodeSpawn(command37, args, { detached: true, stdio: "ignore" });
8403
+ spawn: (command44, args) => {
8404
+ const child = nodeSpawn(command44, args, { detached: true, stdio: "ignore" });
8390
8405
  child.on("error", () => {
8391
8406
  });
8392
8407
  child.unref();
@@ -8431,7 +8446,7 @@ function invalidKey(message) {
8431
8446
  message,
8432
8447
  exitCode: ExitCode.Usage,
8433
8448
  field: "stdin",
8434
- hint: "A Kenso API key is kenso_live_ followed by 49 letters and digits (a key made before the change is ken_ followed by 43 letters, digits, _ or -). Create one at Settings > Integrations > API keys in app.ken.so.",
8449
+ hint: "A Kenso API key is kenso_live_ followed by 49 letters and digits (a sandbox test key starts kenso_test_ instead; a key made before the change is ken_ followed by 43 letters, digits, _ or -). Create one at Settings > Integrations > API keys in app.ken.so.",
8435
8450
  next: PIPE_EXAMPLE
8436
8451
  });
8437
8452
  }
@@ -8627,6 +8642,8 @@ var EXPIRY_WARNING_DAYS, DAY_MS, command7, status_default;
8627
8642
  var init_status = __esm({
8628
8643
  "src/commands/auth/status.ts"() {
8629
8644
  "use strict";
8645
+ init_api_key();
8646
+ init_config();
8630
8647
  init_errors();
8631
8648
  init_exit_codes();
8632
8649
  init_http();
@@ -8636,7 +8653,7 @@ var init_status = __esm({
8636
8653
  resource: "auth",
8637
8654
  action: "status",
8638
8655
  summary: "Show the key's user, workspace and expiry",
8639
- description: `Reads GET /v1/me for the email and workspaces, and GET /v1/api-keys for the key's expiry. Warns on stderr when the key expires within ${EXPIRY_WARNING_DAYS} days.`,
8656
+ description: `Reads GET /v1/me for the email and workspaces, and GET /v1/api-keys for the key's expiry. Warns on stderr when the key expires within ${EXPIRY_WARNING_DAYS} days. A sandbox test key (kenso_test_) adds keyKind "test" and the sandbox it works in.`,
8640
8657
  flags: {},
8641
8658
  examples: ["kenso auth status", "kenso auth status --profile client-a"],
8642
8659
  operationIds: ["me.get", "api-keys.list"],
@@ -8651,6 +8668,18 @@ var init_status = __esm({
8651
8668
  activeWorkspace = { id: activeId, name: match?.name ?? null };
8652
8669
  if (!match) ctx.output.warn(`The active workspace ${activeId} is not one of this key's workspaces.`);
8653
8670
  }
8671
+ const saved = readConfig(ctx.env).profiles[ctx.auth.profileName] ?? {};
8672
+ const envOverrides = [];
8673
+ if (ctx.auth.source === "env" && saved.apiKey && saved.apiKey !== ctx.auth.apiKey) envOverrides.push("KENSO_API_KEY");
8674
+ if (!ctx.flags.workspace?.trim() && ctx.env.KENSO_WORKSPACE_ID?.trim() && saved.workspaceId && saved.workspaceId !== activeId) {
8675
+ envOverrides.push("KENSO_WORKSPACE_ID");
8676
+ }
8677
+ if (envOverrides.length > 0) {
8678
+ const both = envOverrides.length > 1;
8679
+ ctx.output.warn(
8680
+ `${envOverrides.join(" and ")} ${both ? "are set and win" : "is set and wins"} over the profile "${ctx.auth.profileName}". Unset ${both ? "them" : "it"} to use what the profile saved.`
8681
+ );
8682
+ }
8654
8683
  const memberIds = workspaces.map((w) => String(w.id));
8655
8684
  const keysWorkspace = activeId && memberIds.includes(activeId) ? activeId : memberIds[0];
8656
8685
  let keyExpiresAt = null;
@@ -8689,7 +8718,10 @@ var init_status = __esm({
8689
8718
  activeWorkspace,
8690
8719
  keyExpiresAt,
8691
8720
  keySource: ctx.auth.source,
8692
- profile: ctx.auth.profileName
8721
+ profile: ctx.auth.profileName,
8722
+ // A test key reaches only the sandbox it was made for, which kenso sandbox create saved as the workspace.
8723
+ ...isTestKey(apiKey) ? { keyKind: "test", sandboxId: activeId ?? null } : {},
8724
+ ...envOverrides.length > 0 ? { envOverrides } : {}
8693
8725
  });
8694
8726
  return ExitCode.Ok;
8695
8727
  }
@@ -8711,13 +8743,54 @@ var init_auth2 = __esm({
8711
8743
  }
8712
8744
  });
8713
8745
 
8746
+ // src/commands/capture/status.ts
8747
+ var status_exports2 = {};
8748
+ __export(status_exports2, {
8749
+ default: () => status_default2
8750
+ });
8751
+ var command8, status_default2;
8752
+ var init_status2 = __esm({
8753
+ "src/commands/capture/status.ts"() {
8754
+ "use strict";
8755
+ init_exit_codes();
8756
+ init_http();
8757
+ command8 = {
8758
+ resource: "capture",
8759
+ action: "status",
8760
+ summary: "Show your captured mailbox, its backfill progress and what teammates see of a captured email",
8761
+ description: "Reads GET /v1/capture and prints it. mailbox is your own captured mailbox, or null when capture is not on for you: provider (google, microsoft), email, status (catching_up while the 90-day backfill runs, active, reconnect_needed, failed), failureReason, isPrivate (teammates see none of its email; meetings stay visible), connectedAt, lastSyncedAt and backfill (from, coveredFrom, isDone, messagesRead, messagesLogged). connection is the Google or Microsoft account you connected in Kenso with email access, or null: connect one in the app first. teammatesSee is summary (teammates read subject, people, time and Ken's summary; only the mailbox owner opens the body) or full_email. A workspace admin also gets members: every member's mailbox status, never mail. Needs an API key bound to a member (kenso auth login creates one).",
8762
+ flags: {},
8763
+ examples: ["kenso capture status", "kenso capture status --query 'mailbox.{status: status, read: backfill.messagesRead, logged: backfill.messagesLogged}'"],
8764
+ beta: { featureGates: { all: ["crm_capture"] } },
8765
+ operationIds: ["capture.get"],
8766
+ async run(ctx) {
8767
+ const res = await ctx.client.request({ method: "GET", path: "/v1/capture", signal: ctx.signal });
8768
+ ctx.output.object(unwrap(res.body));
8769
+ return ExitCode.Ok;
8770
+ }
8771
+ };
8772
+ status_default2 = command8;
8773
+ }
8774
+ });
8775
+
8776
+ // src/commands/capture/index.ts
8777
+ var actions5;
8778
+ var init_capture = __esm({
8779
+ "src/commands/capture/index.ts"() {
8780
+ "use strict";
8781
+ actions5 = {
8782
+ status: () => Promise.resolve().then(() => (init_status2(), status_exports2)).then((m) => m.default)
8783
+ };
8784
+ }
8785
+ });
8786
+
8714
8787
  // src/commands/completion/completion.ts
8715
8788
  var completion_exports = {};
8716
8789
  __export(completion_exports, {
8717
8790
  SCRIPTS: () => SCRIPTS,
8718
8791
  default: () => completion_default
8719
8792
  });
8720
- var ZSH, BASH, FISH, SCRIPTS, command8, completion_default;
8793
+ var ZSH, BASH, FISH, SCRIPTS, command9, completion_default;
8721
8794
  var init_completion = __esm({
8722
8795
  "src/commands/completion/completion.ts"() {
8723
8796
  "use strict";
@@ -8781,7 +8854,7 @@ end
8781
8854
  complete -c kenso -f -a '(__kenso_complete)'
8782
8855
  `;
8783
8856
  SCRIPTS = { bash: BASH, zsh: ZSH, fish: FISH };
8784
- command8 = {
8857
+ command9 = {
8785
8858
  resource: "completion",
8786
8859
  action: "",
8787
8860
  summary: "Print the tab-completion script for bash, zsh or fish",
@@ -8809,16 +8882,16 @@ complete -c kenso -f -a '(__kenso_complete)'
8809
8882
  return ExitCode.Ok;
8810
8883
  }
8811
8884
  };
8812
- completion_default = command8;
8885
+ completion_default = command9;
8813
8886
  }
8814
8887
  });
8815
8888
 
8816
8889
  // src/commands/completion/index.ts
8817
- var actions5;
8890
+ var actions6;
8818
8891
  var init_completion2 = __esm({
8819
8892
  "src/commands/completion/index.ts"() {
8820
8893
  "use strict";
8821
- actions5 = {
8894
+ actions6 = {
8822
8895
  "": () => Promise.resolve().then(() => (init_completion(), completion_exports)).then((m) => m.default)
8823
8896
  };
8824
8897
  }
@@ -8834,9 +8907,9 @@ function stringFlag2(flags, name) {
8834
8907
  const text3 = value.trim();
8835
8908
  return text3 === "" ? void 0 : text3;
8836
8909
  }
8837
- function requireFlag(flags, name, command37, hint) {
8910
+ function requireFlag(flags, name, command44, hint) {
8838
8911
  const value = stringFlag2(flags, name);
8839
- if (value === void 0) throw usageError(`--${name} is required for ${command37}.`, { field: name, next: `${command37} --help`, ...hint ? { hint } : {} });
8912
+ if (value === void 0) throw usageError(`--${name} is required for ${command44}.`, { field: name, next: `${command44} --help`, ...hint ? { hint } : {} });
8840
8913
  return value;
8841
8914
  }
8842
8915
  function positiveId(value) {
@@ -8845,8 +8918,8 @@ function positiveId(value) {
8845
8918
  const id = Number(text3);
8846
8919
  return Number.isSafeInteger(id) && id > 0 ? id : void 0;
8847
8920
  }
8848
- function idFlag(flags, name, command37) {
8849
- const raw = requireFlag(flags, name, command37);
8921
+ function idFlag(flags, name, command44) {
8922
+ const raw = requireFlag(flags, name, command44);
8850
8923
  const id = positiveId(raw);
8851
8924
  if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
8852
8925
  return id;
@@ -8866,8 +8939,8 @@ function isDryRun(ctx) {
8866
8939
  function shellQuote4(value) {
8867
8940
  return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
8868
8941
  }
8869
- function sameCommand2(command37, flags, ctx, extra = []) {
8870
- const parts2 = [command37];
8942
+ function sameCommand2(command44, flags, ctx, extra = []) {
8943
+ const parts2 = [command44];
8871
8944
  for (const [name, value] of Object.entries(flags)) {
8872
8945
  if (value === void 0 || value === false) continue;
8873
8946
  if (value === true) parts2.push(`--${name}`);
@@ -9467,7 +9540,7 @@ function parseDuration(text3) {
9467
9540
  const ms = Number(match[1]) * (UNIT_MS[(match[2] || "s").toLowerCase()] ?? 1e3);
9468
9541
  return Number.isFinite(ms) ? Math.round(ms) : void 0;
9469
9542
  }
9470
- var UNIT_MS, command9, wait_default;
9543
+ var UNIT_MS, command10, wait_default;
9471
9544
  var init_wait = __esm({
9472
9545
  "src/commands/jobs/wait.ts"() {
9473
9546
  "use strict";
@@ -9475,7 +9548,7 @@ var init_wait = __esm({
9475
9548
  init_errors();
9476
9549
  init_exit_codes();
9477
9550
  UNIT_MS = { s: 1e3, m: 6e4, h: 36e5 };
9478
- command9 = {
9551
+ command10 = {
9479
9552
  resource: "jobs",
9480
9553
  action: "wait",
9481
9554
  summary: "Wait for a background job and print it",
@@ -9514,7 +9587,7 @@ var init_wait = __esm({
9514
9587
  });
9515
9588
  }
9516
9589
  };
9517
- wait_default = command9;
9590
+ wait_default = command10;
9518
9591
  }
9519
9592
  });
9520
9593
 
@@ -9696,7 +9769,7 @@ function summarize2(campaignId) {
9696
9769
  notSendable: results.filter((r) => (r.status === "created" || r.status === "updated") && r.sendable === false).length
9697
9770
  });
9698
9771
  }
9699
- var COMMAND2, CHUNK_SIZE2, LINKEDIN_ONLY_CHANNELS, TEMPLATE_HEADER, command10, import_default2;
9772
+ var COMMAND2, CHUNK_SIZE2, LINKEDIN_ONLY_CHANNELS, TEMPLATE_HEADER, command11, import_default2;
9700
9773
  var init_import2 = __esm({
9701
9774
  "src/commands/contacts/import.ts"() {
9702
9775
  "use strict";
@@ -9715,7 +9788,7 @@ var init_import2 = __esm({
9715
9788
  CHUNK_SIZE2 = 1e3;
9716
9789
  LINKEDIN_ONLY_CHANNELS = /* @__PURE__ */ new Set(["linkedin", "linkedin_only"]);
9717
9790
  TEMPLATE_HEADER = `${CONTACT_FIELDS.join(",")},<your custom columns>`;
9718
- command10 = {
9791
+ command11 = {
9719
9792
  resource: "contacts",
9720
9793
  action: "import",
9721
9794
  summary: "Add leads from a CSV or JSONL file to a campaign",
@@ -9804,7 +9877,7 @@ var init_import2 = __esm({
9804
9877
  return outcome.exitCode;
9805
9878
  }
9806
9879
  };
9807
- import_default2 = command10;
9880
+ import_default2 = command11;
9808
9881
  }
9809
9882
  });
9810
9883
 
@@ -9908,7 +9981,7 @@ async function sendUpdateChunk(chunk, ctx) {
9908
9981
  });
9909
9982
  return { results: mapUpdateAnswer(chunk, res.body), rateLimitRemaining: rateLimitRemaining3(res.headers) };
9910
9983
  }
9911
- var COMMAND3, CHUNK_SIZE3, PAGE_SIZE, command11, update_default;
9984
+ var COMMAND3, CHUNK_SIZE3, PAGE_SIZE, command12, update_default;
9912
9985
  var init_update = __esm({
9913
9986
  "src/commands/contacts/update.ts"() {
9914
9987
  "use strict";
@@ -9922,7 +9995,7 @@ var init_update = __esm({
9922
9995
  COMMAND3 = "kenso contacts update";
9923
9996
  CHUNK_SIZE3 = 1e3;
9924
9997
  PAGE_SIZE = 200;
9925
- command11 = {
9998
+ command12 = {
9926
9999
  resource: "contacts",
9927
10000
  action: "update",
9928
10001
  summary: "Edit leads from a CSV or JSONL file, by id or email (also one lead)",
@@ -9993,7 +10066,7 @@ var init_update = __esm({
9993
10066
  return outcome.exitCode;
9994
10067
  }
9995
10068
  };
9996
- update_default = command11;
10069
+ update_default = command12;
9997
10070
  }
9998
10071
  });
9999
10072
 
@@ -10004,12 +10077,12 @@ import { join as join11 } from "node:path";
10004
10077
  function whereDir(env) {
10005
10078
  return join11(runsRoot(env), WHERE_DIR);
10006
10079
  }
10007
- async function unfinishedWhereIds(ctx, command37, args) {
10080
+ async function unfinishedWhereIds(ctx, command44, args) {
10008
10081
  const dir = whereDir(ctx.env);
10009
10082
  const identity = argsIdentity(args);
10010
10083
  const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
10011
10084
  for (const run of await listRuns(ctx.env)) {
10012
- if (run.command !== command37 || run.status === "done" || run.status === "planned") continue;
10085
+ if (run.command !== command44 || run.status === "done" || run.status === "planned") continue;
10013
10086
  if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
10014
10087
  if (run.inputPath?.startsWith(`${dir}/`) && existsSync5(run.inputPath)) return run.inputPath;
10015
10088
  }
@@ -10155,14 +10228,14 @@ async function idsFromRun(ctx, runId) {
10155
10228
  return { ...idItems(ids2), source: "run" };
10156
10229
  }
10157
10230
  async function collectIds(ctx, flags, kind, dryRun2) {
10158
- const command37 = `kenso contacts ${kind}`;
10231
+ const command44 = `kenso contacts ${kind}`;
10159
10232
  const ids2 = stringFlag2(flags, "ids");
10160
10233
  const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
10161
10234
  const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
10162
10235
  const given = [ids2, where, run].filter((v) => v !== void 0).length;
10163
10236
  if (given !== 1) {
10164
10237
  const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
10165
- throw usageError(`${command37} needs exactly one of ${choices}.`, { field: "ids", next: `${command37} --help` });
10238
+ throw usageError(`${command44} needs exactly one of ${choices}.`, { field: "ids", next: `${command44} --help` });
10166
10239
  }
10167
10240
  if (ids2 !== void 0) return idsFromFile(ctx, ids2);
10168
10241
  if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
@@ -10464,7 +10537,7 @@ async function download(ctx, job, exportId, out) {
10464
10537
  }
10465
10538
  return { rows: countRows(body), path };
10466
10539
  }
10467
- var COMMAND4, JOB_TYPE, DEFAULT_TIMEOUT2, CONTENT_PATH, command12, export_default;
10540
+ var COMMAND4, JOB_TYPE, DEFAULT_TIMEOUT2, CONTENT_PATH, command13, export_default;
10468
10541
  var init_export = __esm({
10469
10542
  "src/commands/contacts/export.ts"() {
10470
10543
  "use strict";
@@ -10479,7 +10552,7 @@ var init_export = __esm({
10479
10552
  JOB_TYPE = "contact_export";
10480
10553
  DEFAULT_TIMEOUT2 = "30m";
10481
10554
  CONTENT_PATH = /\/v1\/contact-exports\/([0-9]+)\/content/;
10482
- command12 = {
10555
+ command13 = {
10483
10556
  resource: "contacts",
10484
10557
  action: "export",
10485
10558
  summary: "Export a campaign's contacts to CSV (a segment: contact-exports create)",
@@ -10537,16 +10610,16 @@ var init_export = __esm({
10537
10610
  return ExitCode.Ok;
10538
10611
  }
10539
10612
  };
10540
- export_default = command12;
10613
+ export_default = command13;
10541
10614
  }
10542
10615
  });
10543
10616
 
10544
10617
  // src/commands/contacts/index.ts
10545
- var actions6;
10618
+ var actions7;
10546
10619
  var init_contacts = __esm({
10547
10620
  "src/commands/contacts/index.ts"() {
10548
10621
  "use strict";
10549
- actions6 = {
10622
+ actions7 = {
10550
10623
  import: () => Promise.resolve().then(() => (init_import2(), import_exports2)).then((m) => m.default),
10551
10624
  update: () => Promise.resolve().then(() => (init_update(), update_exports)).then((m) => m.default),
10552
10625
  remove: () => Promise.resolve().then(() => (init_bulk_ids(), bulk_ids_exports)).then((m) => m.remove),
@@ -10661,7 +10734,7 @@ function unknown(words) {
10661
10734
  next: "kenso describe"
10662
10735
  });
10663
10736
  }
10664
- var command13, describe_default;
10737
+ var command14, describe_default;
10665
10738
  var init_describe = __esm({
10666
10739
  "src/commands/describe/describe.ts"() {
10667
10740
  "use strict";
@@ -10674,7 +10747,7 @@ var init_describe = __esm({
10674
10747
  init_manifest();
10675
10748
  init_help();
10676
10749
  init_registry();
10677
- command13 = {
10750
+ command14 = {
10678
10751
  resource: "describe",
10679
10752
  action: "",
10680
10753
  summary: "The command map as JSON: commands, flags, body schemas",
@@ -10715,16 +10788,16 @@ var init_describe = __esm({
10715
10788
  return ExitCode.Ok;
10716
10789
  }
10717
10790
  };
10718
- describe_default = command13;
10791
+ describe_default = command14;
10719
10792
  }
10720
10793
  });
10721
10794
 
10722
10795
  // src/commands/describe/index.ts
10723
- var actions7;
10796
+ var actions8;
10724
10797
  var init_describe2 = __esm({
10725
10798
  "src/commands/describe/index.ts"() {
10726
10799
  "use strict";
10727
- actions7 = {
10800
+ actions8 = {
10728
10801
  "": () => Promise.resolve().then(() => (init_describe(), describe_exports)).then((m) => m.default)
10729
10802
  };
10730
10803
  }
@@ -10739,7 +10812,7 @@ function findTopic(input) {
10739
10812
  const name = input.trim().toLowerCase().replace(/\.md$/, "");
10740
10813
  return TOPICS.find((t) => t.topic === name);
10741
10814
  }
10742
- var NAMES, command14, docs_default;
10815
+ var NAMES, command15, docs_default;
10743
10816
  var init_docs = __esm({
10744
10817
  "src/commands/docs/docs.ts"() {
10745
10818
  "use strict";
@@ -10747,7 +10820,7 @@ var init_docs = __esm({
10747
10820
  init_exit_codes();
10748
10821
  init_content();
10749
10822
  NAMES = TOPICS.map((t) => t.topic).join(", ");
10750
- command14 = {
10823
+ command15 = {
10751
10824
  resource: "docs",
10752
10825
  action: "",
10753
10826
  summary: "Offline docs: the topic list, or one topic",
@@ -10788,16 +10861,16 @@ var init_docs = __esm({
10788
10861
  return ExitCode.Ok;
10789
10862
  }
10790
10863
  };
10791
- docs_default = command14;
10864
+ docs_default = command15;
10792
10865
  }
10793
10866
  });
10794
10867
 
10795
10868
  // src/commands/docs/index.ts
10796
- var actions8;
10869
+ var actions9;
10797
10870
  var init_docs2 = __esm({
10798
10871
  "src/commands/docs/index.ts"() {
10799
10872
  "use strict";
10800
- actions8 = {
10873
+ actions9 = {
10801
10874
  "": () => Promise.resolve().then(() => (init_docs(), docs_exports)).then((m) => m.default)
10802
10875
  };
10803
10876
  }
@@ -10826,7 +10899,7 @@ function configCheck(env) {
10826
10899
  const octal = mode.toString(8).padStart(4, "0");
10827
10900
  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}` };
10828
10901
  }
10829
- var MIN_NODE_MAJOR, command15, actions9;
10902
+ var MIN_NODE_MAJOR, command16, actions10;
10830
10903
  var init_doctor = __esm({
10831
10904
  "src/commands/doctor/index.ts"() {
10832
10905
  "use strict";
@@ -10835,7 +10908,7 @@ var init_doctor = __esm({
10835
10908
  init_exit_codes();
10836
10909
  init_http();
10837
10910
  MIN_NODE_MAJOR = 22;
10838
- command15 = {
10911
+ command16 = {
10839
10912
  resource: "doctor",
10840
10913
  action: "",
10841
10914
  summary: "Check Node, the config, the API and the key",
@@ -10899,23 +10972,187 @@ var init_doctor = __esm({
10899
10972
  return keyFailed ? ExitCode.Auth : ExitCode.Error;
10900
10973
  }
10901
10974
  };
10902
- actions9 = {
10903
- "": async () => command15
10975
+ actions10 = {
10976
+ "": async () => command16
10904
10977
  };
10905
10978
  }
10906
10979
  });
10907
10980
 
10908
10981
  // src/commands/jobs/index.ts
10909
- var actions10;
10982
+ var actions11;
10910
10983
  var init_jobs2 = __esm({
10911
10984
  "src/commands/jobs/index.ts"() {
10912
10985
  "use strict";
10913
- actions10 = {
10986
+ actions11 = {
10914
10987
  wait: () => Promise.resolve().then(() => (init_wait(), wait_exports)).then((m) => m.default)
10915
10988
  };
10916
10989
  }
10917
10990
  });
10918
10991
 
10992
+ // src/commands/logs/tail.ts
10993
+ var tail_exports = {};
10994
+ __export(tail_exports, {
10995
+ default: () => tail_default
10996
+ });
10997
+ import { setTimeout as delay5 } from "node:timers/promises";
10998
+ function duration(text3) {
10999
+ const days = /^(\d+(?:\.\d+)?)\s*d$/i.exec(text3.trim());
11000
+ return days ? Math.round(Number(days[1]) * 864e5) : parseDuration(text3);
11001
+ }
11002
+ function nonEmpty2(flags, name) {
11003
+ const value = flags[name];
11004
+ if (value === void 0) return void 0;
11005
+ if (typeof value !== "string" || value.trim() === "") throw usageError(`--${name} needs a value.`, { field: name });
11006
+ return value.trim();
11007
+ }
11008
+ function survivable(err) {
11009
+ if (!(err instanceof KensoError)) return false;
11010
+ const fatal = [ExitCode.Auth, ExitCode.Usage, ExitCode.NotFound];
11011
+ return !fatal.includes(err.exitCode);
11012
+ }
11013
+ function readable(row) {
11014
+ const at = new Date(row.occurredAt);
11015
+ const time = `${pad(at.getHours())}:${pad(at.getMinutes())}:${pad(at.getSeconds())}`;
11016
+ const parts2 = [time, `[${row.status}]`, row.method, row.pathTemplate, row.errorCode, `${row.durationMs}ms`, row.apiKeyId, row.requestId];
11017
+ return parts2.filter((p) => p !== void 0 && p !== "").join(" ");
11018
+ }
11019
+ var MIN_INTERVAL_MS, MAX_INTERVAL_MS, MAX_SINCE_MS, OVERLAP_MS, MAX_PAGES, RATE_LIMITED_WAIT_MS, isOwnPoll, pad, command17, tail_default;
11020
+ var init_tail = __esm({
11021
+ "src/commands/logs/tail.ts"() {
11022
+ "use strict";
11023
+ init_errors();
11024
+ init_exit_codes();
11025
+ init_http();
11026
+ init_wait();
11027
+ MIN_INTERVAL_MS = 1e3;
11028
+ MAX_INTERVAL_MS = 6e4;
11029
+ MAX_SINCE_MS = 30 * 864e5;
11030
+ OVERLAP_MS = 6e4;
11031
+ MAX_PAGES = 10;
11032
+ RATE_LIMITED_WAIT_MS = 3e4;
11033
+ isOwnPoll = (row) => row.method === "GET" && row.pathTemplate === "/v1/api-requests" && row.userAgent?.startsWith("kenso-cli/") === true;
11034
+ pad = (n) => String(n).padStart(2, "0");
11035
+ command17 = {
11036
+ resource: "logs",
11037
+ action: "tail",
11038
+ summary: "Stream your workspace's new API request log rows",
11039
+ brief: "--status, --key",
11040
+ description: "Polls GET /v1/api-requests and prints each new row as it is logged, oldest first within a poll: one line per request on a terminal (time, [status], method, path template, error code, duration, API key id, request id), one JSON object per line when piped or with -o json or -o ndjson. It starts from now; --since 10m starts earlier. A row is logged after its request finishes, so each poll looks 60 s back and a slow request can print up to a minute out of order.",
11041
+ flags: {
11042
+ status: { type: "string", description: "Only these statuses: codes or classes, comma-separated (429,5xx)" },
11043
+ key: { type: "string", description: "Only these API key ids (apk_...), comma-separated" },
11044
+ since: { type: "string", description: "Start this far back instead of from now: 90s, 10m, 1h or 7d (at most 30d)" },
11045
+ interval: { type: "string", default: "2s", description: "Time between polls: 1s to 60s (default 2s)" }
11046
+ },
11047
+ examples: ["kenso logs tail", "kenso logs tail --status 4xx,5xx --since 10m", "kenso logs tail --key apk_3f9c -o json"],
11048
+ helpFooter: ["Stop with Ctrl-C. Rows can print up to a minute out of order across polls."],
11049
+ operationIds: ["api-requests.list"],
11050
+ dryRun: true,
11051
+ async run(ctx, { flags }) {
11052
+ const intervalText = typeof flags.interval === "string" ? flags.interval : "2s";
11053
+ const intervalMs = duration(intervalText);
11054
+ if (intervalMs === void 0 || intervalMs < MIN_INTERVAL_MS || intervalMs > MAX_INTERVAL_MS) {
11055
+ throw usageError(`--interval "${intervalText}" is not between 1s and 60s.`, { field: "interval", hint: "Use 1s to 60s, for example 5s." });
11056
+ }
11057
+ const sinceText = nonEmpty2(flags, "since");
11058
+ const sinceMs = sinceText === void 0 ? 0 : duration(sinceText);
11059
+ if (sinceMs === void 0 || sinceMs > MAX_SINCE_MS) {
11060
+ throw usageError(`--since "${sinceText}" is not a duration of at most 30d.`, { field: "since", hint: "Use 90s, 10m, 1h or 7d." });
11061
+ }
11062
+ const status = nonEmpty2(flags, "status");
11063
+ const apiKeyId = nonEmpty2(flags, "key");
11064
+ const floor = Date.now() - sinceMs;
11065
+ const query = (after, cursor2) => ({ occurredAfter: new Date(after).toISOString(), limit: 200, status, apiKeyId, cursor: cursor2 });
11066
+ if (ctx.flags.dryRun) {
11067
+ ctx.output.object({ dryRun: true, request: { method: "GET", path: "/v1/api-requests", query: query(floor, void 0) }, intervalMs });
11068
+ return ExitCode.Ok;
11069
+ }
11070
+ const asJson = !ctx.output.stdoutIsTTY || ctx.flags.output === "json" || ctx.flags.output === "ndjson";
11071
+ const printed = /* @__PURE__ */ new Map();
11072
+ let newest;
11073
+ const fetchPage = async (after, cursor2) => {
11074
+ const res = await ctx.client.request({ method: "GET", path: "/v1/api-requests", query: query(after, cursor2) });
11075
+ const body = res.body;
11076
+ const rows = unwrap(res.body);
11077
+ const next = body?.pagination?.hasMore === true ? body.pagination.nextCursor : void 0;
11078
+ return { rows: Array.isArray(rows) ? rows : [], nextCursor: next || void 0 };
11079
+ };
11080
+ const pollOnce = async () => {
11081
+ const after = newest === void 0 ? floor : Math.max(floor, newest - OVERLAP_MS);
11082
+ const fresh = [];
11083
+ const seenCursors = /* @__PURE__ */ new Set();
11084
+ let cursor2;
11085
+ let pages = 0;
11086
+ do {
11087
+ let page;
11088
+ try {
11089
+ page = await fetchPage(after, cursor2);
11090
+ } catch (err) {
11091
+ if (pages === 0 || ctx.signal.aborted) throw err;
11092
+ ctx.output.warn(`A later page failed (${err.message}); older rows in this window were skipped.`);
11093
+ break;
11094
+ }
11095
+ pages++;
11096
+ const unseen = page.rows.filter((r) => !printed.has(r.id));
11097
+ fresh.push(...unseen);
11098
+ cursor2 = page.nextCursor && !seenCursors.has(page.nextCursor) ? page.nextCursor : void 0;
11099
+ if (cursor2) seenCursors.add(cursor2);
11100
+ if (page.rows.length > 0 && unseen.length === 0) break;
11101
+ if (cursor2 && pages >= MAX_PAGES) {
11102
+ ctx.output.warn(`Showing the newest ${pages * 200} rows; older rows were skipped. Use "kenso api-requests list" for history.`);
11103
+ break;
11104
+ }
11105
+ } while (cursor2 && !ctx.signal.aborted);
11106
+ fresh.sort((a, b) => Date.parse(a.occurredAt) - Date.parse(b.occurredAt) || a.id - b.id);
11107
+ for (const row of fresh) {
11108
+ if (printed.has(row.id)) continue;
11109
+ const at = Date.parse(row.occurredAt);
11110
+ printed.set(row.id, at);
11111
+ if (newest === void 0 || at > newest) newest = at;
11112
+ if (isOwnPoll(row)) continue;
11113
+ ctx.output.writeRaw(`${asJson ? JSON.stringify(row) : readable(row)}
11114
+ `);
11115
+ }
11116
+ if (newest !== void 0) {
11117
+ for (const [id, at] of printed) if (at < newest - OVERLAP_MS) printed.delete(id);
11118
+ }
11119
+ };
11120
+ let first = true;
11121
+ let backoffMs = intervalMs;
11122
+ while (!ctx.signal.aborted) {
11123
+ try {
11124
+ await pollOnce();
11125
+ first = false;
11126
+ backoffMs = intervalMs;
11127
+ } catch (err) {
11128
+ if (ctx.signal.aborted) break;
11129
+ if (first && err instanceof KensoError && err.httpStatus === 404 && err.field === void 0) {
11130
+ throw new KensoError({ code: "not_found", message: "Request logs are not on for this workspace yet.", exitCode: ExitCode.NotFound, httpStatus: 404 });
11131
+ }
11132
+ if (!survivable(err)) throw err;
11133
+ backoffMs = err instanceof KensoError && err.exitCode === ExitCode.RateLimited ? Math.max(intervalMs, RATE_LIMITED_WAIT_MS) : intervalMs;
11134
+ ctx.output.warn(`Polling failed (${err.message}); trying again in ${backoffMs / 1e3} s.`);
11135
+ }
11136
+ await delay5(backoffMs, void 0, { signal: ctx.signal }).catch(() => void 0);
11137
+ }
11138
+ return ExitCode.Ok;
11139
+ }
11140
+ };
11141
+ tail_default = command17;
11142
+ }
11143
+ });
11144
+
11145
+ // src/commands/logs/index.ts
11146
+ var actions12;
11147
+ var init_logs = __esm({
11148
+ "src/commands/logs/index.ts"() {
11149
+ "use strict";
11150
+ actions12 = {
11151
+ tail: () => Promise.resolve().then(() => (init_tail(), tail_exports)).then((m) => m.default)
11152
+ };
11153
+ }
11154
+ });
11155
+
10919
11156
  // src/commands/mcp/connect.ts
10920
11157
  function mcpUrl(ctx) {
10921
11158
  return ctx.env.KENSO_MCP_URL?.trim() || DEFAULT_MCP_URL;
@@ -10966,7 +11203,7 @@ function isRecord6(value) {
10966
11203
  function textOf(result) {
10967
11204
  return (result.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
10968
11205
  }
10969
- var command16, call_default;
11206
+ var command18, call_default;
10970
11207
  var init_call = __esm({
10971
11208
  "src/commands/mcp/call.ts"() {
10972
11209
  "use strict";
@@ -10974,7 +11211,7 @@ var init_call = __esm({
10974
11211
  init_exit_codes();
10975
11212
  init_input();
10976
11213
  init_connect();
10977
- command16 = {
11214
+ command18 = {
10978
11215
  resource: "mcp",
10979
11216
  action: "call",
10980
11217
  summary: "Call a hosted Kenso MCP tool, such as list_skills",
@@ -11027,7 +11264,7 @@ var init_call = __esm({
11027
11264
  return ExitCode.Ok;
11028
11265
  }
11029
11266
  };
11030
- call_default = command16;
11267
+ call_default = command18;
11031
11268
  }
11032
11269
  });
11033
11270
 
@@ -11036,13 +11273,13 @@ var tools_exports = {};
11036
11273
  __export(tools_exports, {
11037
11274
  default: () => tools_default
11038
11275
  });
11039
- var command17, tools_default;
11276
+ var command19, tools_default;
11040
11277
  var init_tools = __esm({
11041
11278
  "src/commands/mcp/tools.ts"() {
11042
11279
  "use strict";
11043
11280
  init_exit_codes();
11044
11281
  init_connect();
11045
- command17 = {
11282
+ command19 = {
11046
11283
  resource: "mcp",
11047
11284
  action: "tools",
11048
11285
  summary: "List the hosted Kenso MCP's tools",
@@ -11057,16 +11294,16 @@ var init_tools = __esm({
11057
11294
  return ExitCode.Ok;
11058
11295
  }
11059
11296
  };
11060
- tools_default = command17;
11297
+ tools_default = command19;
11061
11298
  }
11062
11299
  });
11063
11300
 
11064
11301
  // src/commands/mcp/index.ts
11065
- var actions11;
11302
+ var actions13;
11066
11303
  var init_mcp = __esm({
11067
11304
  "src/commands/mcp/index.ts"() {
11068
11305
  "use strict";
11069
- actions11 = {
11306
+ actions13 = {
11070
11307
  call: () => Promise.resolve().then(() => (init_call(), call_exports)).then((m) => m.default),
11071
11308
  tools: () => Promise.resolve().then(() => (init_tools(), tools_exports)).then((m) => m.default)
11072
11309
  };
@@ -11078,14 +11315,14 @@ var stage_history_exports = {};
11078
11315
  __export(stage_history_exports, {
11079
11316
  default: () => stage_history_default
11080
11317
  });
11081
- var command18, stage_history_default;
11318
+ var command20, stage_history_default;
11082
11319
  var init_stage_history = __esm({
11083
11320
  "src/commands/opportunities/stage-history.ts"() {
11084
11321
  "use strict";
11085
11322
  init_errors();
11086
11323
  init_exit_codes();
11087
11324
  init_http();
11088
- command18 = {
11325
+ command20 = {
11089
11326
  resource: "opportunities",
11090
11327
  action: "stage-history",
11091
11328
  summary: "Show a deal's stage history: each stage, when, who moved it and how long it sat there",
@@ -11109,16 +11346,16 @@ var init_stage_history = __esm({
11109
11346
  return ExitCode.Ok;
11110
11347
  }
11111
11348
  };
11112
- stage_history_default = command18;
11349
+ stage_history_default = command20;
11113
11350
  }
11114
11351
  });
11115
11352
 
11116
11353
  // src/commands/opportunities/index.ts
11117
- var actions12;
11354
+ var actions14;
11118
11355
  var init_opportunities = __esm({
11119
11356
  "src/commands/opportunities/index.ts"() {
11120
11357
  "use strict";
11121
- actions12 = {
11358
+ actions14 = {
11122
11359
  "stage-history": () => Promise.resolve().then(() => (init_stage_history(), stage_history_exports)).then((m) => m.default)
11123
11360
  };
11124
11361
  }
@@ -11195,7 +11432,7 @@ function summarize3(results) {
11195
11432
  }
11196
11433
  return { matched, addedToAccounts, emailFindsQueued };
11197
11434
  }
11198
- var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command19, import_default3;
11435
+ var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command21, import_default3;
11199
11436
  var init_import3 = __esm({
11200
11437
  "src/commands/people/import.ts"() {
11201
11438
  "use strict";
@@ -11227,7 +11464,7 @@ var init_import3 = __esm({
11227
11464
  };
11228
11465
  PERSON_FIELDS = ["email", "fullName", "firstName", "lastName", "linkedinUrl", "title"];
11229
11466
  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.";
11230
- command19 = {
11467
+ command21 = {
11231
11468
  resource: "people",
11232
11469
  action: "import",
11233
11470
  summary: "Create or match people from a CSV or JSONL file, optionally onto accounts",
@@ -11292,16 +11529,16 @@ var init_import3 = __esm({
11292
11529
  return outcome.exitCode;
11293
11530
  }
11294
11531
  };
11295
- import_default3 = command19;
11532
+ import_default3 = command21;
11296
11533
  }
11297
11534
  });
11298
11535
 
11299
11536
  // src/commands/people/index.ts
11300
- var actions13;
11537
+ var actions15;
11301
11538
  var init_people = __esm({
11302
11539
  "src/commands/people/index.ts"() {
11303
11540
  "use strict";
11304
- actions13 = {
11541
+ actions15 = {
11305
11542
  import: () => Promise.resolve().then(() => (init_import3(), import_exports3)).then((m) => m.default)
11306
11543
  };
11307
11544
  }
@@ -11312,14 +11549,14 @@ var list_exports = {};
11312
11549
  __export(list_exports, {
11313
11550
  default: () => list_default
11314
11551
  });
11315
- var command20, list_default;
11552
+ var command22, list_default;
11316
11553
  var init_list = __esm({
11317
11554
  "src/commands/runs/list.ts"() {
11318
11555
  "use strict";
11319
11556
  init_runs();
11320
11557
  init_errors();
11321
11558
  init_exit_codes();
11322
- command20 = {
11559
+ command22 = {
11323
11560
  resource: "runs",
11324
11561
  action: "list",
11325
11562
  summary: "List batch runs, newest first (finds an interrupted run)",
@@ -11340,7 +11577,7 @@ var init_list = __esm({
11340
11577
  return ExitCode.Ok;
11341
11578
  }
11342
11579
  };
11343
- list_default = command20;
11580
+ list_default = command22;
11344
11581
  }
11345
11582
  });
11346
11583
 
@@ -11351,7 +11588,7 @@ __export(show_exports, {
11351
11588
  });
11352
11589
  import { existsSync as existsSync6, readFileSync as readFileSync9 } from "node:fs";
11353
11590
  import { join as join12 } from "node:path";
11354
- var FILES, command21, show_default;
11591
+ var FILES, command23, show_default;
11355
11592
  var init_show = __esm({
11356
11593
  "src/commands/runs/show.ts"() {
11357
11594
  "use strict";
@@ -11366,7 +11603,7 @@ var init_show = __esm({
11366
11603
  ["plan", "plan.json"],
11367
11604
  ["summary", "summary.json"]
11368
11605
  ];
11369
- command21 = {
11606
+ command23 = {
11370
11607
  resource: "runs",
11371
11608
  action: "show",
11372
11609
  summary: "Show one batch run and its files",
@@ -11393,7 +11630,7 @@ var init_show = __esm({
11393
11630
  return ExitCode.Ok;
11394
11631
  }
11395
11632
  };
11396
- show_default = command21;
11633
+ show_default = command23;
11397
11634
  }
11398
11635
  });
11399
11636
 
@@ -11452,14 +11689,14 @@ function resumeArgv(run, globals = {}) {
11452
11689
  async function sha256(path) {
11453
11690
  return createHash5("sha256").update(await readFile9(path)).digest("hex");
11454
11691
  }
11455
- var SKIPPED_KEYS, command22, resume_default;
11692
+ var SKIPPED_KEYS, command24, resume_default;
11456
11693
  var init_resume = __esm({
11457
11694
  "src/commands/runs/resume.ts"() {
11458
11695
  "use strict";
11459
11696
  init_runs();
11460
11697
  init_errors();
11461
11698
  SKIPPED_KEYS = /* @__PURE__ */ new Set(["positionals", "yes", "dryRun", "dry-run", "help", "version"]);
11462
- command22 = {
11699
+ command24 = {
11463
11700
  resource: "runs",
11464
11701
  action: "resume",
11465
11702
  summary: "Continue an interrupted batch run (its command with --yes, no dry run)",
@@ -11514,16 +11751,16 @@ var init_resume = __esm({
11514
11751
  }
11515
11752
  }
11516
11753
  };
11517
- resume_default = command22;
11754
+ resume_default = command24;
11518
11755
  }
11519
11756
  });
11520
11757
 
11521
11758
  // src/commands/runs/index.ts
11522
- var actions14;
11759
+ var actions16;
11523
11760
  var init_runs2 = __esm({
11524
11761
  "src/commands/runs/index.ts"() {
11525
11762
  "use strict";
11526
- actions14 = {
11763
+ actions16 = {
11527
11764
  list: () => Promise.resolve().then(() => (init_list(), list_exports)).then((m) => m.default),
11528
11765
  show: () => Promise.resolve().then(() => (init_show(), show_exports)).then((m) => m.default),
11529
11766
  resume: () => Promise.resolve().then(() => (init_resume(), resume_exports)).then((m) => m.default)
@@ -11531,12 +11768,317 @@ var init_runs2 = __esm({
11531
11768
  }
11532
11769
  });
11533
11770
 
11771
+ // src/commands/sandbox/shared.ts
11772
+ function requireLiveKey(ctx) {
11773
+ if (!isTestKey(ctx.auth.apiKey)) return;
11774
+ throw new KensoError({
11775
+ code: "live_key_required",
11776
+ message: "Sandbox commands need your live key. Run them without --profile sandbox.",
11777
+ exitCode: ExitCode.Auth
11778
+ });
11779
+ }
11780
+ function hasDetailCode(err, code) {
11781
+ const details = err.details?.error?.details;
11782
+ return Array.isArray(details) && details.some((d) => d?.code === code);
11783
+ }
11784
+ async function sandboxIdOf(ctx, given) {
11785
+ if (given !== void 0) {
11786
+ const id = given.trim();
11787
+ if (!/^[1-9]\d*$/.test(id)) {
11788
+ throw usageError(`"${given}" is not a sandbox id: ids are positive whole numbers.`, { field: "sandboxId", next: "kenso sandbox list" });
11789
+ }
11790
+ return id;
11791
+ }
11792
+ const res = await ctx.client.request({ method: "GET", path: "/v1/sandboxes", signal: ctx.signal });
11793
+ const ids2 = (Array.isArray(res.body?.data) ? res.body.data : []).map((s) => String(s.id));
11794
+ if (ids2.length === 0) {
11795
+ throw new KensoError({
11796
+ code: "no_sandbox",
11797
+ message: "You have no sandbox.",
11798
+ exitCode: ExitCode.NotFound,
11799
+ hint: 'Run "kenso sandbox create" first.',
11800
+ next: "kenso sandbox create"
11801
+ });
11802
+ }
11803
+ if (ids2.length > 1) throw usageError(`You have ${ids2.length} sandboxes: name one.`, { field: "sandboxId", next: "kenso sandbox list" });
11804
+ return ids2[0];
11805
+ }
11806
+ function saveTestKey(ctx, sandboxId, key) {
11807
+ try {
11808
+ const profiles = readConfig(ctx.env).profiles;
11809
+ const held = profiles[SANDBOX_PROFILE]?.apiKey;
11810
+ if (held !== void 0 && !isTestKey(held)) {
11811
+ ctx.output.warn(`The profile "${SANDBOX_PROFILE}" holds a live key, so it was left unchanged. Copy the secret now: it is shown once.`);
11812
+ return;
11813
+ }
11814
+ const current = profiles[ctx.auth.profileName] ?? {};
11815
+ writeProfile(
11816
+ SANDBOX_PROFILE,
11817
+ {
11818
+ apiKey: key.secret,
11819
+ workspaceId: sandboxId,
11820
+ // The API the sandbox was made on, saved as login saves it: only when it is not the default.
11821
+ apiUrl: ctx.auth.apiUrl !== DEFAULT_API_URL ? ctx.auth.apiUrl : void 0,
11822
+ email: current.email,
11823
+ keyId: key.id
11824
+ },
11825
+ { env: ctx.env }
11826
+ );
11827
+ } catch (err) {
11828
+ ctx.output.warn(`Could not save the sandbox profile: ${err instanceof Error ? err.message : String(err)}. Copy the secret now: it is shown once.`);
11829
+ return;
11830
+ }
11831
+ ctx.output.info(`Saved as profile "${SANDBOX_PROFILE}". Run commands against it with --profile ${SANDBOX_PROFILE}. The key is shown once.`);
11832
+ const set = [ctx.auth.source === "env" ? "KENSO_API_KEY" : "", ctx.env.KENSO_WORKSPACE_ID?.trim() ? "KENSO_WORKSPACE_ID" : ""].filter((name) => name !== "");
11833
+ if (set.length > 0) {
11834
+ const both = set.length > 1;
11835
+ ctx.output.warn(
11836
+ `${set.join(" and ")} ${both ? "are set and win" : "is set and wins"} over the saved profile, so --profile ${SANDBOX_PROFILE} will not use the test key and its sandbox. To work in the sandbox, set KENSO_API_KEY=<the test key> KENSO_WORKSPACE_ID=${sandboxId}, or unset ${both ? "them" : "it"}.`
11837
+ );
11838
+ }
11839
+ }
11840
+ function keyOutput(key) {
11841
+ return { id: key.id, prefix: key.prefix, secret: key.secret, expiresAt: key.expiresAt ?? null };
11842
+ }
11843
+ var SANDBOX_PROFILE, SANDBOX_GATES, SANDBOX_ID_POSITIONAL;
11844
+ var init_shared = __esm({
11845
+ "src/commands/sandbox/shared.ts"() {
11846
+ "use strict";
11847
+ init_api_key();
11848
+ init_config();
11849
+ init_errors();
11850
+ init_exit_codes();
11851
+ SANDBOX_PROFILE = "sandbox";
11852
+ SANDBOX_GATES = { all: ["developer_sandboxes"] };
11853
+ SANDBOX_ID_POSITIONAL = { name: "sandboxId", description: "The sandbox id (default: your one sandbox)" };
11854
+ }
11855
+ });
11856
+
11857
+ // src/commands/sandbox/create.ts
11858
+ var create_exports = {};
11859
+ __export(create_exports, {
11860
+ default: () => create_default
11861
+ });
11862
+ var command25, create_default;
11863
+ var init_create = __esm({
11864
+ "src/commands/sandbox/create.ts"() {
11865
+ "use strict";
11866
+ init_errors();
11867
+ init_exit_codes();
11868
+ init_http();
11869
+ init_shared();
11870
+ command25 = {
11871
+ resource: "sandbox",
11872
+ action: "create",
11873
+ summary: "Create your developer sandbox and save its test key as the sandbox profile",
11874
+ description: `Calls POST /v1/sandboxes with your live key. Kenso creates a sandbox workspace of your own, seeds it with campaigns, contacts, inboxes and threads, and returns a test key (kenso_test_...) that works only there. The key is saved as the profile "${SANDBOX_PROFILE}" and the active profile stays as it is: add --profile ${SANDBOX_PROFILE} to run a command in the sandbox. In a sandbox, sends are simulated: nothing leaves Kenso.`,
11875
+ flags: {},
11876
+ examples: ["kenso sandbox create", "kenso campaigns list --profile sandbox"],
11877
+ beta: { featureGates: SANDBOX_GATES },
11878
+ operationIds: ["sandboxes.create"],
11879
+ async run(ctx) {
11880
+ requireLiveKey(ctx);
11881
+ let body;
11882
+ try {
11883
+ body = (await ctx.client.request({ method: "POST", path: "/v1/sandboxes", signal: ctx.signal })).body;
11884
+ } catch (err) {
11885
+ if (err instanceof KensoError && err.httpStatus === 409 && hasDetailCode(err, "sandbox_exists")) {
11886
+ throw new KensoError({
11887
+ code: err.code,
11888
+ message: err.message,
11889
+ exitCode: err.exitCode,
11890
+ httpStatus: err.httpStatus,
11891
+ hint: 'You already have a sandbox. Run "kenso sandbox list", or "kenso sandbox key" for a new test key.',
11892
+ next: "kenso sandbox key",
11893
+ requestId: err.requestId
11894
+ });
11895
+ }
11896
+ throw err;
11897
+ }
11898
+ const sandbox = unwrap(body) ?? {};
11899
+ const testKey = sandbox.testKey ?? {};
11900
+ saveTestKey(ctx, String(sandbox.id), testKey);
11901
+ ctx.output.object({
11902
+ sandboxId: sandbox.id ?? null,
11903
+ name: sandbox.name ?? null,
11904
+ status: sandbox.status ?? null,
11905
+ seed: sandbox.seed ?? null,
11906
+ testKey: keyOutput(testKey),
11907
+ profile: SANDBOX_PROFILE
11908
+ });
11909
+ return ExitCode.Ok;
11910
+ }
11911
+ };
11912
+ create_default = command25;
11913
+ }
11914
+ });
11915
+
11916
+ // src/commands/sandbox/delete.ts
11917
+ var delete_exports = {};
11918
+ __export(delete_exports, {
11919
+ default: () => delete_default
11920
+ });
11921
+ var command26, delete_default;
11922
+ var init_delete = __esm({
11923
+ "src/commands/sandbox/delete.ts"() {
11924
+ "use strict";
11925
+ init_config();
11926
+ init_confirm();
11927
+ init_exit_codes();
11928
+ init_shared();
11929
+ command26 = {
11930
+ resource: "sandbox",
11931
+ action: "delete",
11932
+ summary: "Delete your sandbox and its test keys",
11933
+ description: `Calls DELETE /v1/sandboxes/{sandboxId} with your live key: the sandbox's data is gone for good and its test keys are revoked. Then removes the profile "${SANDBOX_PROFILE}" when it holds this sandbox. Without an id it deletes your one sandbox. It asks first on a terminal; anywhere else it needs --yes.`,
11934
+ flags: {},
11935
+ positionals: [SANDBOX_ID_POSITIONAL],
11936
+ examples: ["kenso sandbox delete --dry-run", "kenso sandbox delete 20417 --yes"],
11937
+ beta: { featureGates: SANDBOX_GATES },
11938
+ operationIds: ["sandboxes.list", "sandboxes.delete"],
11939
+ dryRun: true,
11940
+ async run(ctx, { positionals }) {
11941
+ requireLiveKey(ctx);
11942
+ const id = await sandboxIdOf(ctx, positionals[0]);
11943
+ const path = `/v1/sandboxes/${id}`;
11944
+ if (ctx.flags.dryRun) {
11945
+ ctx.output.object({ dryRun: true, request: { method: "DELETE", path } });
11946
+ return ExitCode.Ok;
11947
+ }
11948
+ await confirmDestructive(ctx, `kenso sandbox delete deletes sandbox ${id} and everything in it`, `kenso sandbox delete ${id} --yes`);
11949
+ await ctx.client.request({ method: "DELETE", path, signal: ctx.signal });
11950
+ const profileRemoved = readConfig(ctx.env).profiles[SANDBOX_PROFILE]?.workspaceId === id;
11951
+ if (profileRemoved) removeProfile(SANDBOX_PROFILE, ctx.env);
11952
+ ctx.output.object({ sandboxId: Number(id), deleted: true, profileRemoved });
11953
+ return ExitCode.Ok;
11954
+ }
11955
+ };
11956
+ delete_default = command26;
11957
+ }
11958
+ });
11959
+
11960
+ // src/commands/sandbox/key.ts
11961
+ var key_exports = {};
11962
+ __export(key_exports, {
11963
+ default: () => key_default
11964
+ });
11965
+ var command27, key_default;
11966
+ var init_key = __esm({
11967
+ "src/commands/sandbox/key.ts"() {
11968
+ "use strict";
11969
+ init_exit_codes();
11970
+ init_http();
11971
+ init_shared();
11972
+ command27 = {
11973
+ resource: "sandbox",
11974
+ action: "key",
11975
+ summary: "Create a new test key for your sandbox and save it as the sandbox profile",
11976
+ description: `Calls POST /v1/sandboxes/{sandboxId}/test-keys with your live key and saves the new key as the profile "${SANDBOX_PROFILE}" (the active profile stays as it is). A sandbox has 5 active test keys at most. Without an id it uses your one sandbox.`,
11977
+ flags: {},
11978
+ positionals: [SANDBOX_ID_POSITIONAL],
11979
+ examples: ["kenso sandbox key", "kenso sandbox key 20417"],
11980
+ beta: { featureGates: SANDBOX_GATES },
11981
+ operationIds: ["sandboxes.list", "sandboxes.create-test-key"],
11982
+ async run(ctx, { positionals }) {
11983
+ requireLiveKey(ctx);
11984
+ const id = await sandboxIdOf(ctx, positionals[0]);
11985
+ const res = await ctx.client.request({ method: "POST", path: `/v1/sandboxes/${id}/test-keys`, signal: ctx.signal });
11986
+ const key = unwrap(res.body) ?? {};
11987
+ saveTestKey(ctx, id, key);
11988
+ ctx.output.object(keyOutput(key));
11989
+ return ExitCode.Ok;
11990
+ }
11991
+ };
11992
+ key_default = command27;
11993
+ }
11994
+ });
11995
+
11996
+ // src/commands/sandbox/list.ts
11997
+ var list_exports2 = {};
11998
+ __export(list_exports2, {
11999
+ default: () => list_default2
12000
+ });
12001
+ var command28, list_default2;
12002
+ var init_list2 = __esm({
12003
+ "src/commands/sandbox/list.ts"() {
12004
+ "use strict";
12005
+ init_exit_codes();
12006
+ init_shared();
12007
+ command28 = {
12008
+ resource: "sandbox",
12009
+ action: "list",
12010
+ summary: "List your developer sandbox",
12011
+ description: "Calls GET /v1/sandboxes with your live key. You have one sandbox at most, so this prints one row or none.",
12012
+ flags: {},
12013
+ examples: ["kenso sandbox list"],
12014
+ beta: { featureGates: SANDBOX_GATES },
12015
+ operationIds: ["sandboxes.list"],
12016
+ async run(ctx) {
12017
+ requireLiveKey(ctx);
12018
+ const res = await ctx.client.request({ method: "GET", path: "/v1/sandboxes", signal: ctx.signal });
12019
+ await ctx.output.list(Array.isArray(res.body?.data) ? res.body.data : []);
12020
+ return ExitCode.Ok;
12021
+ }
12022
+ };
12023
+ list_default2 = command28;
12024
+ }
12025
+ });
12026
+
12027
+ // src/commands/sandbox/reset.ts
12028
+ var reset_exports = {};
12029
+ __export(reset_exports, {
12030
+ default: () => reset_default
12031
+ });
12032
+ var command29, reset_default;
12033
+ var init_reset = __esm({
12034
+ "src/commands/sandbox/reset.ts"() {
12035
+ "use strict";
12036
+ init_exit_codes();
12037
+ init_http();
12038
+ init_shared();
12039
+ command29 = {
12040
+ resource: "sandbox",
12041
+ action: "reset",
12042
+ summary: "Reset your sandbox to its seed data",
12043
+ description: "Calls POST /v1/sandboxes/{sandboxId}/reset with your live key: everything in the sandbox is deleted and seeded again. Its test keys and webhook endpoints stay. Without an id it resets your one sandbox.",
12044
+ flags: {},
12045
+ positionals: [SANDBOX_ID_POSITIONAL],
12046
+ examples: ["kenso sandbox reset", "kenso sandbox reset 20417"],
12047
+ beta: { featureGates: SANDBOX_GATES },
12048
+ operationIds: ["sandboxes.list", "sandboxes.reset"],
12049
+ async run(ctx, { positionals }) {
12050
+ requireLiveKey(ctx);
12051
+ const id = await sandboxIdOf(ctx, positionals[0]);
12052
+ const res = await ctx.client.request({ method: "POST", path: `/v1/sandboxes/${id}/reset`, signal: ctx.signal });
12053
+ ctx.output.object(unwrap(res.body));
12054
+ return ExitCode.Ok;
12055
+ }
12056
+ };
12057
+ reset_default = command29;
12058
+ }
12059
+ });
12060
+
12061
+ // src/commands/sandbox/index.ts
12062
+ var actions17;
12063
+ var init_sandbox2 = __esm({
12064
+ "src/commands/sandbox/index.ts"() {
12065
+ "use strict";
12066
+ actions17 = {
12067
+ create: () => Promise.resolve().then(() => (init_create(), create_exports)).then((m) => m.default),
12068
+ delete: () => Promise.resolve().then(() => (init_delete(), delete_exports)).then((m) => m.default),
12069
+ key: () => Promise.resolve().then(() => (init_key(), key_exports)).then((m) => m.default),
12070
+ list: () => Promise.resolve().then(() => (init_list2(), list_exports2)).then((m) => m.default),
12071
+ reset: () => Promise.resolve().then(() => (init_reset(), reset_exports)).then((m) => m.default)
12072
+ };
12073
+ }
12074
+ });
12075
+
11534
12076
  // src/commands/skill/index.ts
11535
- var actions15;
12077
+ var actions18;
11536
12078
  var init_skill = __esm({
11537
12079
  "src/commands/skill/index.ts"() {
11538
12080
  "use strict";
11539
- actions15 = {
12081
+ actions18 = {
11540
12082
  install: () => Promise.resolve().then(() => (init_install(), install_exports)).then((m) => m.default)
11541
12083
  };
11542
12084
  }
@@ -11772,7 +12314,7 @@ __export(pull_exports, {
11772
12314
  });
11773
12315
  import { mkdir, writeFile as writeFile4 } from "node:fs/promises";
11774
12316
  import { dirname as dirname2, resolve as resolve11 } from "node:path";
11775
- var command23, pull_default;
12317
+ var command30, pull_default;
11776
12318
  var init_pull = __esm({
11777
12319
  "src/commands/studio/pull.ts"() {
11778
12320
  "use strict";
@@ -11782,7 +12324,7 @@ var init_pull = __esm({
11782
12324
  init_common2();
11783
12325
  init_folder();
11784
12326
  init_transfer();
11785
- command23 = {
12327
+ command30 = {
11786
12328
  resource: "studio",
11787
12329
  action: "pull",
11788
12330
  summary: "Write a template version's files to a folder",
@@ -11829,7 +12371,7 @@ var init_pull = __esm({
11829
12371
  return ExitCode.Ok;
11830
12372
  }
11831
12373
  };
11832
- pull_default = command23;
12374
+ pull_default = command30;
11833
12375
  }
11834
12376
  });
11835
12377
 
@@ -11862,7 +12404,7 @@ var push_exports = {};
11862
12404
  __export(push_exports, {
11863
12405
  default: () => push_default
11864
12406
  });
11865
- var BUILT_BY, DEFAULT_MESSAGE, command24, push_default;
12407
+ var BUILT_BY, DEFAULT_MESSAGE, command31, push_default;
11866
12408
  var init_push = __esm({
11867
12409
  "src/commands/studio/push.ts"() {
11868
12410
  "use strict";
@@ -11874,7 +12416,7 @@ var init_push = __esm({
11874
12416
  init_read();
11875
12417
  BUILT_BY = "customer_agent";
11876
12418
  DEFAULT_MESSAGE = "Pushed with the Kenso CLI";
11877
- command24 = {
12419
+ command31 = {
11878
12420
  resource: "studio",
11879
12421
  action: "push",
11880
12422
  summary: "Save a folder's files to a template's draft and print the validation",
@@ -11966,7 +12508,7 @@ var init_push = __esm({
11966
12508
  );
11967
12509
  }
11968
12510
  };
11969
- push_default = command24;
12511
+ push_default = command31;
11970
12512
  }
11971
12513
  });
11972
12514
 
@@ -11975,7 +12517,7 @@ var validate_exports = {};
11975
12517
  __export(validate_exports, {
11976
12518
  default: () => validate_default
11977
12519
  });
11978
- var command25, validate_default;
12520
+ var command32, validate_default;
11979
12521
  var init_validate = __esm({
11980
12522
  "src/commands/studio/validate.ts"() {
11981
12523
  "use strict";
@@ -11984,7 +12526,7 @@ var init_validate = __esm({
11984
12526
  init_columns();
11985
12527
  init_common2();
11986
12528
  init_read();
11987
- command25 = {
12529
+ command32 = {
11988
12530
  resource: "studio",
11989
12531
  action: "validate",
11990
12532
  summary: "Validate a folder's files against a template without saving them",
@@ -12013,7 +12555,7 @@ var init_validate = __esm({
12013
12555
  throw validationFailed(validation, "The files have validation errors", commandLine2(ctx, "studio validate", args));
12014
12556
  }
12015
12557
  };
12016
- validate_default = command25;
12558
+ validate_default = command32;
12017
12559
  }
12018
12560
  });
12019
12561
 
@@ -12062,7 +12604,7 @@ function accountIds(value) {
12062
12604
  }
12063
12605
  return ids2.map(Number);
12064
12606
  }
12065
- var SHOWN, command26, preview_default;
12607
+ var SHOWN, command33, preview_default;
12066
12608
  var init_preview = __esm({
12067
12609
  "src/commands/studio/preview.ts"() {
12068
12610
  "use strict";
@@ -12074,7 +12616,7 @@ var init_preview = __esm({
12074
12616
  init_common2();
12075
12617
  init_folder();
12076
12618
  SHOWN = 5;
12077
- command26 = {
12619
+ command33 = {
12078
12620
  resource: "studio",
12079
12621
  action: "preview",
12080
12622
  summary: "Render a saved version for up to 3 accounts; for local edits, studio push them to the draft first",
@@ -12123,12 +12665,12 @@ var init_preview = __esm({
12123
12665
  return ExitCode.Ok;
12124
12666
  }
12125
12667
  };
12126
- preview_default = command26;
12668
+ preview_default = command33;
12127
12669
  }
12128
12670
  });
12129
12671
 
12130
12672
  // src/commands/studio/fill-runs.ts
12131
- import { setTimeout as delay5 } from "node:timers/promises";
12673
+ import { setTimeout as delay6 } from "node:timers/promises";
12132
12674
  async function estimateFill(ctx, templateId, count) {
12133
12675
  const parts2 = [];
12134
12676
  for (let left = count; left > 0; left -= RUN_SIZE) {
@@ -12160,7 +12702,7 @@ async function estimateFill(ctx, templateId, count) {
12160
12702
  async function waitForRun(client, runId, opts) {
12161
12703
  const sleep = opts.sleep ?? (async (ms) => {
12162
12704
  try {
12163
- await delay5(ms, void 0, { signal: opts.signal });
12705
+ await delay6(ms, void 0, { signal: opts.signal });
12164
12706
  } catch (err) {
12165
12707
  if (opts.signal.aborted) throw new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
12166
12708
  throw err;
@@ -12324,7 +12866,7 @@ function estimateOutput(templateId, target, estimate2) {
12324
12866
  ...target.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
12325
12867
  };
12326
12868
  }
12327
- var COMMAND6, sha2562, command27, fill_default;
12869
+ var COMMAND6, sha2562, command34, fill_default;
12328
12870
  var init_fill = __esm({
12329
12871
  "src/commands/studio/fill.ts"() {
12330
12872
  "use strict";
@@ -12340,7 +12882,7 @@ var init_fill = __esm({
12340
12882
  init_fill_runs();
12341
12883
  COMMAND6 = "studio fill";
12342
12884
  sha2562 = (data) => createHash8("sha256").update(data).digest("hex");
12343
- command27 = {
12885
+ command34 = {
12344
12886
  resource: "studio",
12345
12887
  action: "fill",
12346
12888
  summary: "Fill a template on many accounts or campaign leads (estimate first)",
@@ -12400,16 +12942,16 @@ var init_fill = __esm({
12400
12942
  return outcome.exitCode;
12401
12943
  }
12402
12944
  };
12403
- fill_default = command27;
12945
+ fill_default = command34;
12404
12946
  }
12405
12947
  });
12406
12948
 
12407
12949
  // src/commands/studio/index.ts
12408
- var actions16;
12950
+ var actions19;
12409
12951
  var init_studio2 = __esm({
12410
12952
  "src/commands/studio/index.ts"() {
12411
12953
  "use strict";
12412
- actions16 = {
12954
+ actions19 = {
12413
12955
  pull: () => Promise.resolve().then(() => (init_pull(), pull_exports)).then((m) => m.default),
12414
12956
  push: () => Promise.resolve().then(() => (init_push(), push_exports)).then((m) => m.default),
12415
12957
  validate: () => Promise.resolve().then(() => (init_validate(), validate_exports)).then((m) => m.default),
@@ -12515,7 +13057,7 @@ __export(listen_exports, {
12515
13057
  liveBody: () => liveBody
12516
13058
  });
12517
13059
  import { randomBytes as randomBytes3 } from "node:crypto";
12518
- import { setTimeout as delay6 } from "node:timers/promises";
13060
+ import { setTimeout as delay7 } from "node:timers/promises";
12519
13061
  function eventTypes(value) {
12520
13062
  const list2 = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
12521
13063
  return list2.flatMap((item) => item.split(",")).map((item) => item.trim()).filter((item) => item !== "");
@@ -12526,7 +13068,7 @@ function liveBody(event, workspaceId) {
12526
13068
  const envelope = { eventType: event.name ?? "", eventId: event.eventId ?? "", timestamp: event.timestamp ?? "", ...clientId };
12527
13069
  return { ...envelope, ...data, ...envelope };
12528
13070
  }
12529
- function survivable(err) {
13071
+ function survivable2(err) {
12530
13072
  if (!(err instanceof KensoError)) return false;
12531
13073
  const fatal = [ExitCode.Auth, ExitCode.Usage, ExitCode.NotFound];
12532
13074
  return !fatal.includes(err.exitCode);
@@ -12551,7 +13093,7 @@ function readBody(req) {
12551
13093
  function reply(res, status, body) {
12552
13094
  res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(body));
12553
13095
  }
12554
- var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command28, listen_default;
13096
+ var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command35, listen_default;
12555
13097
  var init_listen = __esm({
12556
13098
  "src/commands/webhooks/listen.ts"() {
12557
13099
  "use strict";
@@ -12562,7 +13104,7 @@ var init_listen = __esm({
12562
13104
  MIN_POLL_MS = 1e3;
12563
13105
  MAX_POLL_MS = 6e4;
12564
13106
  MAX_TRIGGER_BYTES = 1e6;
12565
- command28 = {
13107
+ command35 = {
12566
13108
  resource: "webhooks",
12567
13109
  action: "listen",
12568
13110
  summary: "Stream the workspace's events and forward them, signed, to a local handler",
@@ -12615,7 +13157,7 @@ var init_listen = __esm({
12615
13157
  if (err instanceof KensoError && err.httpStatus === 404 && err.field === void 0) {
12616
13158
  live = false;
12617
13159
  ctx.output.warn(`Live events are not on for this workspace (${err.message}). Samples from kenso webhooks trigger still come through.`);
12618
- } else if (!ctx.signal.aborted && survivable(err)) {
13160
+ } else if (!ctx.signal.aborted && survivable2(err)) {
12619
13161
  ctx.output.warn(`Polling failed (${err.message}); trying again.`);
12620
13162
  } else {
12621
13163
  throw err;
@@ -12651,11 +13193,11 @@ var init_listen = __esm({
12651
13193
  cursor2 = page.cursor ?? cursor2;
12652
13194
  waitMs = page.hasMore ? 0 : Math.min(MAX_POLL_MS, Math.max(MIN_POLL_MS, page.nextPollMs ?? MAX_POLL_MS));
12653
13195
  } catch (err) {
12654
- if (ctx.signal.aborted || !survivable(err)) throw err;
13196
+ if (ctx.signal.aborted || !survivable2(err)) throw err;
12655
13197
  ctx.output.warn(`Polling failed (${err.message}); trying again in ${MAX_POLL_MS / 1e3} s.`);
12656
13198
  }
12657
13199
  }
12658
- await delay6(waitMs, void 0, { signal: ctx.signal }).catch(() => void 0);
13200
+ await delay7(waitMs, void 0, { signal: ctx.signal }).catch(() => void 0);
12659
13201
  }
12660
13202
  } catch (err) {
12661
13203
  if (!ctx.signal.aborted) throw err;
@@ -12668,7 +13210,7 @@ var init_listen = __esm({
12668
13210
  return ExitCode.Ok;
12669
13211
  }
12670
13212
  };
12671
- listen_default = command28;
13213
+ listen_default = command35;
12672
13214
  }
12673
13215
  });
12674
13216
 
@@ -12687,7 +13229,7 @@ function notRunning() {
12687
13229
  next: LISTEN_NEXT
12688
13230
  });
12689
13231
  }
12690
- var LISTEN_NEXT, command29, trigger_default;
13232
+ var LISTEN_NEXT, command36, trigger_default;
12691
13233
  var init_trigger = __esm({
12692
13234
  "src/commands/webhooks/trigger.ts"() {
12693
13235
  "use strict";
@@ -12696,7 +13238,7 @@ var init_trigger = __esm({
12696
13238
  init_http();
12697
13239
  init_local();
12698
13240
  LISTEN_NEXT = "kenso webhooks listen --forward-to http://localhost:3000/hook";
12699
- command29 = {
13241
+ command36 = {
12700
13242
  resource: "webhooks",
12701
13243
  action: "trigger",
12702
13244
  summary: "Send a sample event of one type through the running kenso webhooks listen",
@@ -12753,16 +13295,16 @@ var init_trigger = __esm({
12753
13295
  return ExitCode.Ok;
12754
13296
  }
12755
13297
  };
12756
- trigger_default = command29;
13298
+ trigger_default = command36;
12757
13299
  }
12758
13300
  });
12759
13301
 
12760
13302
  // src/commands/webhooks/index.ts
12761
- var actions17;
13303
+ var actions20;
12762
13304
  var init_webhooks2 = __esm({
12763
13305
  "src/commands/webhooks/index.ts"() {
12764
13306
  "use strict";
12765
- actions17 = {
13307
+ actions20 = {
12766
13308
  listen: () => Promise.resolve().then(() => (init_listen(), listen_exports)).then((m) => m.default),
12767
13309
  trigger: () => Promise.resolve().then(() => (init_trigger(), trigger_exports)).then((m) => m.default)
12768
13310
  };
@@ -12772,14 +13314,14 @@ var init_webhooks2 = __esm({
12772
13314
  // src/commands/work/common.ts
12773
13315
  import { randomUUID as randomUUID2 } from "node:crypto";
12774
13316
  import { join as join16 } from "node:path";
12775
- import { setTimeout as delay7 } from "node:timers/promises";
13317
+ import { setTimeout as delay8 } from "node:timers/promises";
12776
13318
  function unavailable(err) {
12777
13319
  return err instanceof KensoError && (err.code === "network_error" || err.httpStatus === 502 || err.httpStatus === 503 || err.httpStatus === 504);
12778
13320
  }
12779
13321
  async function pause2(ms, signal) {
12780
13322
  if (signal.aborted) return false;
12781
13323
  try {
12782
- await delay7(ms, void 0, { signal });
13324
+ await delay8(ms, void 0, { signal });
12783
13325
  return true;
12784
13326
  } catch {
12785
13327
  return false;
@@ -12953,18 +13495,18 @@ var init_common3 = __esm({
12953
13495
  });
12954
13496
 
12955
13497
  // src/commands/work/status.ts
12956
- var status_exports2 = {};
12957
- __export(status_exports2, {
12958
- default: () => status_default2
13498
+ var status_exports3 = {};
13499
+ __export(status_exports3, {
13500
+ default: () => status_default3
12959
13501
  });
12960
- var command30, status_default2;
12961
- var init_status2 = __esm({
13502
+ var command37, status_default3;
13503
+ var init_status3 = __esm({
12962
13504
  "src/commands/work/status.ts"() {
12963
13505
  "use strict";
12964
13506
  init_exit_codes();
12965
13507
  init_http();
12966
13508
  init_common3();
12967
- command30 = {
13509
+ command37 = {
12968
13510
  resource: "work",
12969
13511
  action: "status",
12970
13512
  summary: "Show the Kenso AI work waiting for your own agent, per kind",
@@ -12998,7 +13540,7 @@ var init_status2 = __esm({
12998
13540
  return ExitCode.Ok;
12999
13541
  }
13000
13542
  };
13001
- status_default2 = command30;
13543
+ status_default3 = command37;
13002
13544
  }
13003
13545
  });
13004
13546
 
@@ -13130,9 +13672,9 @@ var init_files = __esm({
13130
13672
  import { execFile, spawnSync as spawnSync2 } from "node:child_process";
13131
13673
  import { readFileSync as readFileSync12 } from "node:fs";
13132
13674
  import { isAbsolute as isAbsolute2 } from "node:path";
13133
- function sudoArgs(user, command37, args, keep = [], set = {}) {
13675
+ function sudoArgs(user, command44, args, keep = [], set = {}) {
13134
13676
  const assignments = Object.entries(set).map(([name, value]) => `${name}=${value}`);
13135
- return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command37, ...args];
13677
+ return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command44, ...args];
13136
13678
  }
13137
13679
  function agentKensoEnv(opts) {
13138
13680
  return {
@@ -13142,12 +13684,12 @@ function agentKensoEnv(opts) {
13142
13684
  AI_AGENT: opts.agentName
13143
13685
  };
13144
13686
  }
13145
- function sudoExec(user, command37, args, opts = {}) {
13687
+ function sudoExec(user, command44, args, opts = {}) {
13146
13688
  const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
13147
13689
  return new Promise((resolve16) => {
13148
13690
  execFile(
13149
13691
  sudo,
13150
- [...lead, ...sudoArgs(user.name, command37, args)],
13692
+ [...lead, ...sudoArgs(user.name, command44, args)],
13151
13693
  { env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
13152
13694
  (err, stdout, stderr) => {
13153
13695
  const code = err ? err.code : 0;
@@ -13257,9 +13799,9 @@ var init_folder2 = __esm({
13257
13799
  init_redact();
13258
13800
  init_agent_user();
13259
13801
  WorkRunFolder = class {
13260
- constructor(ctx, command37, args, outDir, shared = false) {
13802
+ constructor(ctx, command44, args, outDir, shared = false) {
13261
13803
  this.ctx = ctx;
13262
- this.command = command37;
13804
+ this.command = command44;
13263
13805
  this.args = args;
13264
13806
  this.outDir = outDir;
13265
13807
  this.shared = shared;
@@ -13374,7 +13916,7 @@ var pull_exports2 = {};
13374
13916
  __export(pull_exports2, {
13375
13917
  default: () => pull_default2
13376
13918
  });
13377
- var MAX_FILES, command31, pull_default2;
13919
+ var MAX_FILES, command38, pull_default2;
13378
13920
  var init_pull2 = __esm({
13379
13921
  "src/commands/work/pull.ts"() {
13380
13922
  "use strict";
@@ -13383,7 +13925,7 @@ var init_pull2 = __esm({
13383
13925
  init_common3();
13384
13926
  init_folder2();
13385
13927
  MAX_FILES = 100;
13386
- command31 = {
13928
+ command38 = {
13387
13929
  resource: "work",
13388
13930
  action: "pull",
13389
13931
  summary: "Claim waiting work into local work files, to answer by hand",
@@ -13461,7 +14003,7 @@ var init_pull2 = __esm({
13461
14003
  return interrupted6 ? ExitCode.Interrupted : ExitCode.Ok;
13462
14004
  }
13463
14005
  };
13464
- pull_default2 = command31;
14006
+ pull_default2 = command38;
13465
14007
  }
13466
14008
  });
13467
14009
 
@@ -13603,7 +14145,7 @@ __export(submit_exports, {
13603
14145
  default: () => submit_default
13604
14146
  });
13605
14147
  import { resolve as resolve14 } from "node:path";
13606
- var command32, submit_default;
14148
+ var command39, submit_default;
13607
14149
  var init_submit = __esm({
13608
14150
  "src/commands/work/submit.ts"() {
13609
14151
  "use strict";
@@ -13612,7 +14154,7 @@ var init_submit = __esm({
13612
14154
  init_files();
13613
14155
  init_answers();
13614
14156
  init_common3();
13615
- command32 = {
14157
+ command39 = {
13616
14158
  resource: "work",
13617
14159
  action: "submit",
13618
14160
  summary: "Send answers files to Kenso and write each one's results",
@@ -13644,7 +14186,7 @@ var init_submit = __esm({
13644
14186
  return totals.rejected > 0 ? ExitCode.Partial : ExitCode.Ok;
13645
14187
  }
13646
14188
  };
13647
- submit_default = command32;
14189
+ submit_default = command39;
13648
14190
  }
13649
14191
  });
13650
14192
 
@@ -13665,7 +14207,7 @@ function claimIdOf(arg) {
13665
14207
  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..." });
13666
14208
  return arg;
13667
14209
  }
13668
- var CLAIM_ID, command33, release_default;
14210
+ var CLAIM_ID, command40, release_default;
13669
14211
  var init_release = __esm({
13670
14212
  "src/commands/work/release.ts"() {
13671
14213
  "use strict";
@@ -13674,7 +14216,7 @@ var init_release = __esm({
13674
14216
  init_files();
13675
14217
  init_common3();
13676
14218
  CLAIM_ID = /^[A-Za-z0-9_-]{1,64}$/;
13677
- command33 = {
14219
+ command40 = {
13678
14220
  resource: "work",
13679
14221
  action: "release",
13680
14222
  summary: "Give claimed work back to the queue now",
@@ -13693,7 +14235,7 @@ var init_release = __esm({
13693
14235
  return ExitCode.Ok;
13694
14236
  }
13695
14237
  };
13696
- release_default = command33;
14238
+ release_default = command40;
13697
14239
  }
13698
14240
  });
13699
14241
 
@@ -13702,7 +14244,7 @@ import { spawn as nodeSpawn2 } from "node:child_process";
13702
14244
  import { rmSync as rmSync3, statSync as statSync2 } from "node:fs";
13703
14245
  import { access, constants as constants2 } from "node:fs/promises";
13704
14246
  import { delimiter as delimiter2, join as join20 } from "node:path";
13705
- import { setTimeout as delay8 } from "node:timers/promises";
14247
+ import { setTimeout as delay9 } from "node:timers/promises";
13706
14248
  function childEnv(parent, adapter, extra) {
13707
14249
  const scrub = new Set(adapter.scrubEnv.map((name) => name.toUpperCase()));
13708
14250
  const env = {};
@@ -13795,7 +14337,7 @@ async function groupGone(pid, runAs) {
13795
14337
  while (Date.now() < deadline) {
13796
14338
  if (runAs) {
13797
14339
  if (!await sudoKill(runAs, "SIGKILL", pid)) return;
13798
- await delay8(100);
14340
+ await delay9(100);
13799
14341
  continue;
13800
14342
  }
13801
14343
  try {
@@ -13803,7 +14345,7 @@ async function groupGone(pid, runAs) {
13803
14345
  } catch {
13804
14346
  return;
13805
14347
  }
13806
- await delay8(25);
14348
+ await delay9(25);
13807
14349
  }
13808
14350
  }
13809
14351
  function runChild(spawnFn, bin, built, job, env, signal, runAs) {
@@ -14032,12 +14574,12 @@ function plain(text3) {
14032
14574
  return text3.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
14033
14575
  }
14034
14576
  function runStatus(bin, args, env, adapter, runAs) {
14035
- const command37 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
14577
+ const command44 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
14036
14578
  const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
14037
14579
  const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
14038
14580
  return new Promise((resolve16) => {
14039
14581
  execFile2(
14040
- command37,
14582
+ command44,
14041
14583
  commandArgs2,
14042
14584
  { ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
14043
14585
  (err, stdout, stderr) => {
@@ -15119,7 +15661,7 @@ var run_exports = {};
15119
15661
  __export(run_exports, {
15120
15662
  default: () => run_default
15121
15663
  });
15122
- var FAILURES_IN_A_ROW, command34, run_default;
15664
+ var FAILURES_IN_A_ROW, command41, run_default;
15123
15665
  var init_run = __esm({
15124
15666
  "src/commands/work/run.ts"() {
15125
15667
  "use strict";
@@ -15140,7 +15682,7 @@ var init_run = __esm({
15140
15682
  init_folder2();
15141
15683
  init_stop();
15142
15684
  FAILURES_IN_A_ROW = 3;
15143
- command34 = {
15685
+ command41 = {
15144
15686
  resource: "work",
15145
15687
  action: "run",
15146
15688
  summary: "Run your own coding agent on the waiting work until the queue is empty",
@@ -15465,17 +16007,17 @@ var init_run = __esm({
15465
16007
  return exitCodeFor(reason, totals.rejected > 0 || jobsFailed > 0);
15466
16008
  }
15467
16009
  };
15468
- run_default = command34;
16010
+ run_default = command41;
15469
16011
  }
15470
16012
  });
15471
16013
 
15472
16014
  // src/commands/work/index.ts
15473
- var actions18;
16015
+ var actions21;
15474
16016
  var init_work2 = __esm({
15475
16017
  "src/commands/work/index.ts"() {
15476
16018
  "use strict";
15477
- actions18 = {
15478
- status: () => Promise.resolve().then(() => (init_status2(), status_exports2)).then((m) => m.default),
16019
+ actions21 = {
16020
+ status: () => Promise.resolve().then(() => (init_status3(), status_exports3)).then((m) => m.default),
15479
16021
  pull: () => Promise.resolve().then(() => (init_pull2(), pull_exports2)).then((m) => m.default),
15480
16022
  submit: () => Promise.resolve().then(() => (init_submit(), submit_exports)).then((m) => m.default),
15481
16023
  release: () => Promise.resolve().then(() => (init_release(), release_exports)).then((m) => m.default),
@@ -15485,9 +16027,9 @@ var init_work2 = __esm({
15485
16027
  });
15486
16028
 
15487
16029
  // src/commands/workspace/list.ts
15488
- var list_exports2 = {};
15489
- __export(list_exports2, {
15490
- default: () => list_default2
16030
+ var list_exports3 = {};
16031
+ __export(list_exports3, {
16032
+ default: () => list_default3
15491
16033
  });
15492
16034
  function parseLimit(value) {
15493
16035
  if (value === void 0) return void 0;
@@ -15498,14 +16040,14 @@ function parseLimit(value) {
15498
16040
  }
15499
16041
  return limit;
15500
16042
  }
15501
- var MAX_LIMIT, command35, list_default2;
15502
- var init_list2 = __esm({
16043
+ var MAX_LIMIT, command42, list_default3;
16044
+ var init_list3 = __esm({
15503
16045
  "src/commands/workspace/list.ts"() {
15504
16046
  "use strict";
15505
16047
  init_errors();
15506
16048
  init_exit_codes();
15507
16049
  MAX_LIMIT = 200;
15508
- command35 = {
16050
+ command42 = {
15509
16051
  resource: "workspace",
15510
16052
  action: "list",
15511
16053
  summary: "List the workspaces your key can use",
@@ -15533,7 +16075,7 @@ var init_list2 = __esm({
15533
16075
  return ExitCode.Ok;
15534
16076
  }
15535
16077
  };
15536
- list_default2 = command35;
16078
+ list_default3 = command42;
15537
16079
  }
15538
16080
  });
15539
16081
 
@@ -15542,7 +16084,7 @@ var use_exports = {};
15542
16084
  __export(use_exports, {
15543
16085
  default: () => use_default
15544
16086
  });
15545
- var command36, use_default;
16087
+ var command43, use_default;
15546
16088
  var init_use = __esm({
15547
16089
  "src/commands/workspace/use.ts"() {
15548
16090
  "use strict";
@@ -15550,7 +16092,7 @@ var init_use = __esm({
15550
16092
  init_errors();
15551
16093
  init_exit_codes();
15552
16094
  init_http();
15553
- command36 = {
16095
+ command43 = {
15554
16096
  resource: "workspace",
15555
16097
  action: "use",
15556
16098
  summary: "Set the profile's default workspace",
@@ -15607,17 +16149,17 @@ var init_use = __esm({
15607
16149
  return ExitCode.Ok;
15608
16150
  }
15609
16151
  };
15610
- use_default = command36;
16152
+ use_default = command43;
15611
16153
  }
15612
16154
  });
15613
16155
 
15614
16156
  // src/commands/workspace/index.ts
15615
- var actions19;
16157
+ var actions22;
15616
16158
  var init_workspace = __esm({
15617
16159
  "src/commands/workspace/index.ts"() {
15618
16160
  "use strict";
15619
- actions19 = {
15620
- list: () => Promise.resolve().then(() => (init_list2(), list_exports2)).then((m) => m.default),
16161
+ actions22 = {
16162
+ list: () => Promise.resolve().then(() => (init_list3(), list_exports3)).then((m) => m.default),
15621
16163
  use: () => Promise.resolve().then(() => (init_use(), use_exports)).then((m) => m.default)
15622
16164
  };
15623
16165
  }
@@ -15640,16 +16182,19 @@ var init_registry = __esm({
15640
16182
  init_agent2();
15641
16183
  init_api3();
15642
16184
  init_auth2();
16185
+ init_capture();
15643
16186
  init_completion2();
15644
16187
  init_contacts();
15645
16188
  init_describe2();
15646
16189
  init_docs2();
15647
16190
  init_doctor();
15648
16191
  init_jobs2();
16192
+ init_logs();
15649
16193
  init_mcp();
15650
16194
  init_opportunities();
15651
16195
  init_people();
15652
16196
  init_runs2();
16197
+ init_sandbox2();
15653
16198
  init_skill();
15654
16199
  init_studio2();
15655
16200
  init_webhooks2();
@@ -15660,24 +16205,27 @@ var init_registry = __esm({
15660
16205
  agent: actions2,
15661
16206
  api: actions3,
15662
16207
  auth: actions4,
15663
- completion: actions5,
15664
- contacts: actions6,
15665
- describe: actions7,
15666
- docs: actions8,
15667
- doctor: actions9,
15668
- jobs: actions10,
16208
+ capture: actions5,
16209
+ completion: actions6,
16210
+ contacts: actions7,
16211
+ describe: actions8,
16212
+ docs: actions9,
16213
+ doctor: actions10,
16214
+ jobs: actions11,
15669
16215
  login: topLevel("login", actions4.login, "kenso auth login"),
15670
16216
  logout: topLevel("logout", actions4.logout, "kenso auth logout"),
15671
- mcp: actions11,
15672
- opportunities: actions12,
15673
- people: actions13,
15674
- runs: actions14,
15675
- skill: actions15,
15676
- studio: actions16,
15677
- webhooks: actions17,
16217
+ logs: actions12,
16218
+ mcp: actions13,
16219
+ opportunities: actions14,
16220
+ people: actions15,
16221
+ runs: actions16,
16222
+ sandbox: actions17,
16223
+ skill: actions18,
16224
+ studio: actions19,
16225
+ webhooks: actions20,
15678
16226
  whoami: topLevel("whoami", actions4.status, "kenso auth status"),
15679
- work: actions18,
15680
- workspace: actions19
16227
+ work: actions21,
16228
+ workspace: actions22
15681
16229
  };
15682
16230
  resourceAliases = { leads: "contacts" };
15683
16231
  }
@@ -15814,8 +16362,8 @@ async function renderTopHelp(opts) {
15814
16362
  names.push(withPositionals(spec, spec.action));
15815
16363
  groups.set(hint, names);
15816
16364
  }
15817
- const actions21 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
15818
- if (actions21.length > 0) rows.push([resource, actions21.join(", ")]);
16365
+ const actions24 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
16366
+ if (actions24.length > 0) rows.push([resource, actions24.join(", ")]);
15819
16367
  }
15820
16368
  const at = 4 + Math.min(22, Math.max(0, ...rows.map(([left]) => left.length)));
15821
16369
  lines.push(
@@ -15828,7 +16376,7 @@ async function renderTopHelp(opts) {
15828
16376
  const [area = "", action = ""] = name.split(" ");
15829
16377
  byArea.set(area, [...byArea.get(area) ?? [], action]);
15830
16378
  }
15831
- const named = [...byArea.entries()].map(([area, actions21]) => `${area} ${actions21.join("|")}`);
16379
+ const named = [...byArea.entries()].map(([area, actions24]) => `${area} ${actions24.join("|")}`);
15832
16380
  lines.push(wrap(`Beta, hidden here but they run (the server decides): ${named.join(", ")}.`, " "));
15833
16381
  }
15834
16382
  const generated = await listGenerated({ features: opts.allCommands ? [] : getFeatures, env: opts.env });
@@ -15836,13 +16384,13 @@ async function renderTopHelp(opts) {
15836
16384
  if (visible.length > 0) {
15837
16385
  const byResource = /* @__PURE__ */ new Map();
15838
16386
  for (const g of visible) {
15839
- const actions21 = byResource.get(g.resource) ?? [];
15840
- actions21.push(`${g.action}${g.beta ? " (beta)" : ""}`);
15841
- byResource.set(g.resource, actions21);
16387
+ const actions24 = byResource.get(g.resource) ?? [];
16388
+ actions24.push(`${g.action}${g.beta ? " (beta)" : ""}`);
16389
+ byResource.set(g.resource, actions24);
15842
16390
  }
15843
16391
  const sorted2 = [...byResource.entries()].sort(([a], [b]) => a.localeCompare(b));
15844
16392
  if (opts.allCommands) {
15845
- const generatedRows = sorted2.map(([resource, actions21]) => [resource, actions21.sort().join(", ")]);
16393
+ const generatedRows = sorted2.map(([resource, actions24]) => [resource, actions24.sort().join(", ")]);
15846
16394
  lines.push("", "API resources (kenso <resource> <action>):", columns(generatedRows));
15847
16395
  } else {
15848
16396
  const names = new Set(sorted2.map(([resource]) => resource));
@@ -16158,8 +16706,8 @@ function startUpdateNotice(argv, opts = {}) {
16158
16706
  if (!found) return;
16159
16707
  writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
16160
16708
  if (isNewer(found, version)) {
16161
- const command37 = updateCommand(install, opts.platform ?? process.platform);
16162
- stderr.write(`kenso ${found} is out (you have ${version}): ${command37}
16709
+ const command44 = updateCommand(install, opts.platform ?? process.platform);
16710
+ stderr.write(`kenso ${found} is out (you have ${version}): ${command44}
16163
16711
  Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
16164
16712
  `);
16165
16713
  }
@@ -16201,7 +16749,7 @@ function resources() {
16201
16749
  const names = Object.entries(handWritten).filter(([, area]) => Object.keys(area).length > 0).map(([resource]) => resource);
16202
16750
  return sorted([...names, ...Object.keys(resourceAliases), ...loadManifest().operations.map((op) => op.resource)]);
16203
16751
  }
16204
- function actions20(resource) {
16752
+ function actions23(resource) {
16205
16753
  const own = Object.keys(handWritten[resource] ?? {}).filter((action) => action !== "");
16206
16754
  return sorted([...own, ...loadManifest().operations.filter((op) => op.resource === resource).map((op) => op.action)]);
16207
16755
  }
@@ -16266,7 +16814,7 @@ async function completions(words, globals) {
16266
16814
  return flagsOf2(spec, globals, positionals.length === 0);
16267
16815
  }
16268
16816
  if (positionals.length === 0) return resources();
16269
- if (!spec) return positionals.length === 1 ? actions20(resourceAliases[positionals[0]] ?? positionals[0]) : [];
16817
+ if (!spec) return positionals.length === 1 ? actions23(resourceAliases[positionals[0]] ?? positionals[0]) : [];
16270
16818
  const given = positionals.length - commandWords;
16271
16819
  const declared = spec.positionals ?? [];
16272
16820
  if (given < declared.length || declared.at(-1)?.variadic === true) {
@@ -16360,9 +16908,9 @@ function normalizeBooleans(argv, names, strict) {
16360
16908
  async function knownCommands() {
16361
16909
  const commands = /* @__PURE__ */ new Set();
16362
16910
  for (const [resource, area] of Object.entries(handWritten)) {
16363
- const actions21 = Object.keys(area);
16364
- if (actions21.length > 0) commands.add(resource);
16365
- for (const action of actions21) commands.add(action ? `${resource} ${action}` : resource);
16911
+ const actions24 = Object.keys(area);
16912
+ if (actions24.length > 0) commands.add(resource);
16913
+ for (const action of actions24) commands.add(action ? `${resource} ${action}` : resource);
16366
16914
  }
16367
16915
  for (const g of await listGenerated({ features: [] })) {
16368
16916
  commands.add(g.resource);