kenso 0.1.113 → 0.1.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/kenso.js +227 -116
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/docs/crm.md +3 -2
- package/docs/output-and-errors.md +2 -1
- package/docs/reference.md +37 -10
- package/docs/studio.md +5 -3
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -2477,7 +2477,7 @@ var VERSION;
|
|
|
2477
2477
|
var init_version = __esm({
|
|
2478
2478
|
"src/core/version.ts"() {
|
|
2479
2479
|
"use strict";
|
|
2480
|
-
VERSION = true ? "0.1.
|
|
2480
|
+
VERSION = true ? "0.1.115" : "0.0.0-dev";
|
|
2481
2481
|
}
|
|
2482
2482
|
});
|
|
2483
2483
|
|
|
@@ -2752,9 +2752,9 @@ async function readAnswer(ctx) {
|
|
|
2752
2752
|
const lines = createInterface({ input: ctx.stdin ?? process.stdin, terminal: false });
|
|
2753
2753
|
let onAbort;
|
|
2754
2754
|
try {
|
|
2755
|
-
return await new Promise((
|
|
2756
|
-
lines.once("line",
|
|
2757
|
-
lines.once("close", () =>
|
|
2755
|
+
return await new Promise((resolve18, reject) => {
|
|
2756
|
+
lines.once("line", resolve18);
|
|
2757
|
+
lines.once("close", () => resolve18(""));
|
|
2758
2758
|
onAbort = () => reject(interrupted());
|
|
2759
2759
|
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
2760
2760
|
});
|
|
@@ -6632,12 +6632,12 @@ function parseJsonl(text4, source) {
|
|
|
6632
6632
|
}
|
|
6633
6633
|
async function readInput(pathOrDash, opts) {
|
|
6634
6634
|
const { path, bytes } = await readRaw(pathOrDash, opts?.stdin);
|
|
6635
|
-
const
|
|
6635
|
+
const sha2564 = createHash2("sha256").update(bytes).digest("hex");
|
|
6636
6636
|
const text4 = bytes.toString("utf8");
|
|
6637
6637
|
const source = path === "-" ? "stdin" : pathOrDash;
|
|
6638
6638
|
const format = detectFormat(path, text4);
|
|
6639
6639
|
const parsed2 = format === "csv" ? parseCsv(text4, source) : parseJsonl(text4, source);
|
|
6640
|
-
return { path, format, sha256:
|
|
6640
|
+
return { path, format, sha256: sha2564, ...parsed2 };
|
|
6641
6641
|
}
|
|
6642
6642
|
function idText(value) {
|
|
6643
6643
|
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
@@ -8777,7 +8777,7 @@ var init_connect = __esm({
|
|
|
8777
8777
|
var crm_default;
|
|
8778
8778
|
var init_crm = __esm({
|
|
8779
8779
|
"docs/crm.md"() {
|
|
8780
|
-
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| `import accounts <file.csv>`, `import people <file.csv>`, `import deals <file.csv>` | Import a CSV export of another CRM, up to 50,000 rows: Kenso proposes the mapping, you approve once, it runs in the background and can be undone for 30 days |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts bulk-update`, `people bulk-update`, `opportunities bulk-update` | Set the same fields on many records at once, by ids or by a filter, with a preview first. Needs `bulk_edit` too |\n| `accounts bulk-delete`, `people bulk-delete`, `opportunities bulk-delete` | Delete many records at once, by ids or by a filter, with a preview first. Not undone. Needs `bulk_edit` too |\n| `changes list`, `get`, `rows`, `apply`, `cancel`, `undo` | Follow a bulk change, read what each record got, stop it, or put the old values back for 30 days |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities move <id> [--stage <key>] [--pipeline <pipelineId>] [--reason <key>]` | Move a deal to a stage or another pipeline, with its won or lost reason; a field the stage asks for never stops it |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `notes list`, `notes add`, `notes edit`, `notes delete` | Notes and comments on accounts, people and deals (needs `record_notes`) |\n| `deleted-accounts list`, `accounts restore <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `accounts duplicates`, `accounts merge <id> --into <id>`, `accounts merges list` | The pairs that look like one company, merging a pair, and the log of merges |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved Accounts view, or what the filters match |\n| `capture status` | Your captured mailbox, its backfill progress and what teammates see of a captured email. Needs the `crm_capture` flag |\n| `capture connect` | Turn capture on for your own mailbox. `--private` starts it hidden from teammates; `--provider google` prints a sign-in link when no account is connected yet |\n| `capture private on\\|off` | Hide your captured email from teammates, or show it again. Email only: meetings stay visible. `--thread <id>` sets the switch for one thread |\n| `capture thread <threadId>` | One captured email thread: subject, people, time, Ken\'s summary, the members whose mailboxes hold it, and each body you may open. The id is `capturedThread.id` on a timeline row |\n| `views pin <viewId>`, `views unpin <viewId>` | Pin a saved view to your own sidebar, or take it off. Needs the `shared_views` flag |\n| `capture sync` | Read your captured mailbox now, instead of waiting for the next two-minute poll. Prints what the pass read, logged and created |\n| `capture disconnect` | Turn capture off and delete your stored email bodies. Asks first; `--yes` skips the question |\n| `capture teammates-see summary\\|full_email` | Workspace admin: what teammates see of captured email |\n| `pipelines stage-rules` | List or set the fields a deal should have in each stage |\n| `opportunity-reasons get`, `opportunity-reasons replace` | List or edit why deals are lost and won |\n| `layouts show\\|set\\|reset <object>` | How every account, person or deal page in the workspace lays out its fields: header, rail sections and hidden fields (needs `record_layout`) |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n| `tasks add`, `tasks done`, `tasks assign`, `tasks queue` | Add a to-do for a member on an account, person or deal, complete it, hand it on, or read your open work (needs `tasks`) |\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\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "hqLocation", "operator": "contains", "values": ["Germany"]}]}}\' --all\n# my accounts with a meeting this quarter: me is whoever runs it, so a saved view with it lists each member\'s own\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "owner", "operator": "is", "values": ["me"]}, {"field": "lastMeeting", "operator": "in_period", "values": ["this_quarter"]}]}}\' --all\n# tier 1 accounts with no meeting in 30 days: none since then, or none ever\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}, {"match": "any", "conditions": [{"field": "lastMeeting", "operator": "older_than_days", "values": ["30"]}, {"field": "lastMeeting", "operator": "is_empty"}]}]}}\' --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\nTo set the same fields on many records, use `bulk-update` (below; it needs the `bulk_edit` flag). When every row gets its own values, or the workspace has no `bulk_edit`, 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## Change many accounts at once\n\n```bash\nkenso accounts bulk-update --filter \'{"filters":[{"field":"stage","operator":"is","values":["new"]}]}\' --set owner=42 --dry-run\nkenso changes apply --change-id 31\nkenso accounts bulk-update --ids 812,813 --set stage=engaged --set tier=2 --yes\nkenso changes get --change-id 31\n```\n\n`accounts bulk-update` sets the same fields on every account you name: `--ids` (1,000 at most), everything a `--filter` matches (the body `kenso accounts search --data` takes: `filters`, `where`, `q`; up to 50,000), or `--all`. A filter that holds only options and no condition (`--filter \'{"includeImportOnly":true}\'`) takes `--all` beside it. `--exclude-ids` leaves some of a filter\'s accounts out. `--set field=value` takes `ownerMemberId` (or `owner`), `stage`, `tierOverride` (or `tier`), `industry`, `fundingRound`, `employeeCount`, `hqLocation` and `cadenceDays`, and a custom field as `custom.<key>` (`--set custom.region=EMEA`; `kenso api GET \'/v1/fields?object=account\'` gives the keys); a value of `null` clears the field. `--add-tag 12,14` and `--remove-tag 13` put tags on every account or take them off (`kenso tags list` gives the ids); each tag is one row per account from `false` to `true` or back, so `kenso changes undo` takes off only the tags the change put on. People take them too; deals have no tags. A text field\'s value is sent as you type it (`--set hqLocation=10001` is the text "10001"); a custom field\'s type is not known to the CLI, so quote its text when it reads as a number or as true or false: `--set \'custom.code="10001"\'`. Use `accounts update --each` when every row gets its own values.\n\nIt makes a change set: the accounts it names and, for each, the field, its value before and its value after. Without `--yes` (or with `--dry-run`) it previews: it prints `count` and a `sample`, writes nothing, and `next` is the `kenso changes apply` command that writes exactly those accounts. With `--yes` it writes in the background and waits (`--timeout`, default 10m), then prints the change with its `counts`: `applied`, `unchanged` (already had the value), `conflict` (the account changed after the preview, so it was left alone) and `failed` (for example `pinned`: a person set the field by hand; `--overwrite-pinned` replaces it). Exit 5 when some accounts failed or conflicted. It needs the `bulk_edit` flag as well as `accounts`.\n\n`kenso accounts bulk-update` used to be the generated command for the route\'s older one-field body, which sets one `accountType` on up to 500 accounts and needs only `accounts`. The route still takes that body, but this command no longer sends it: use `kenso accounts update --each` with an `accountType` column, or `kenso api POST /v1/accounts/bulk-update --data \'{"accountIds":[812,813],"accountType":"lost"}\'`.\n\n`people bulk-update` and `opportunities bulk-update` work the same way. People take `--set` for `ownerMemberId` (or `owner`), `leadStatus`, `title`, `seniority`, `department` and `location`, and a `--filter` of `kenso people search --data` fields (`leadStatus`, `roles`, `tagIds`, `q` and the rest). Deals take `stage` (a live stage key), `ownerMemberId` (or `owner`), `closeDate` (or `close`), `amount`, `dealType` and `nextStep`, and a `--filter` of `kenso opportunities search --data` fields (`filters`, `accountId`, `q`):\n\n```bash\nkenso opportunities bulk-update --filter \'{"filters":[{"field":"stageCategory","operator":"is","values":["open"]}]}\' --set stage=proposal --dry-run\nkenso people bulk-update --ids 501,502 --set owner=42 --yes\n```\n\n### Delete many records at once\n\n```bash\nkenso people bulk-delete --filter \'{"onAccount":"none","leadStatus":["disqualified"]}\' --dry-run\nkenso changes apply --change-id 32\nkenso opportunities bulk-delete --ids 71,72,73 --yes\n```\n\n`accounts bulk-delete`, `people bulk-delete` and `opportunities bulk-delete` name their records the way `bulk-update` does (`--ids`, `--filter`, `--all`, `--exclude-ids`) and take no `--set`. Without `--yes` they preview: `count`, a `sample`, and `next` is the `kenso changes apply` command that deletes exactly those records. The API itself previews a delete whose body leaves `dryRun` out, so `--yes` sends `dryRun: false`. Each record is deleted as its own `delete` command deletes it, so one that cannot be deleted (a person still on an account) is counted as `failed` and the rest go on. A delete is not undone with `kenso changes undo`.\n\n### Follow, stop and undo a change\n\n```bash\nkenso changes list --object accounts\nkenso changes rows --change-id 31 --status conflict,failed\nkenso changes cancel --change-id 31\nkenso changes undo --change-id 31\n```\n\n`changes list` shows the workspace\'s bulk changes, newest first, whoever made them. `changes rows` lists a change\'s records with the value before (`from`) and after (`to`) and a `status`; `--status conflict,failed` reads what a change missed. `changes cancel` drops a preview or stops a change that is still writing; what it already wrote stays. `changes undo` puts the old value back on every record that still holds the value the change wrote, for 30 days after it was applied (`undoUntil`). A record someone changed again since keeps its newer value: `counts.undone` is how many went back, `counts.applied` how many still hold the change. Undo answers `409 invalid_state` with `undo_expired`, `still_running`, `nothing_applied` or `not_undoable` when there is nothing it can put back.\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` (member ids, or `me` for whoever runs it), `closeDate` (`past_due`, `next_30_days`, `later`, `none`, or a period such as `this_week` or `next_quarter`), `sourceCampaignId`, `closedAt` and `createdAt` (periods). `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## Pipelines\n\nA workspace with the `pipelines` flag on can run several deal pipelines, each with its own stages. These are generated commands (beta):\n\n```bash\nkenso pipelines list\nkenso pipelines list --query "[].{id: id, name: name, default: isDefault, stages: stages[].key}"\nkenso pipelines get --pipeline-id 5\n```\n\n`list` prints every pipeline in display order, archived ones included: `id`, `name`, `routingRule` (the one sentence Ken reads to decide whether a new deal belongs there), `isDefault`, `isArchived`, `position`, `opportunityCount`, `amountTotal` and `stages`, each stage as `kenso opportunity-stages list` prints it. A stage key is unique in the workspace, across pipelines, so a deal\'s `stage` names its pipeline and its `pipelineId` repeats it. The first read turns the workspace\'s stage list into its default pipeline, named Sales, with every deal in it. The same rows as the MCP\'s `pipelines(operation="list")`.\n\nShaping them needs the `workspace_settings` permission:\n\n```bash\nkenso pipelines create --name Renewals --routing-rule "The account is already a customer" --data \'{"stages": [{"label": "Up for renewal", "category": "open"}, {"label": "Won", "category": "won"}, {"label": "Lost", "category": "lost"}]}\'\nkenso pipelines update --pipeline-id 6 --name Expansion --position 0\nkenso pipelines update --pipeline-id 6 --data @stages.json\nkenso pipelines archive --pipeline-id 6\nkenso pipelines restore --pipeline-id 6\nkenso pipelines propose --description "upsells and renewals for customers"\n```\n\n- **`create`** takes a unique `name`, the pipeline\'s `stages` in display order (at least one `open`, one `won` and one `lost`) and an optional `routingRule`: one sentence that says which deals belong there, which Ken reads to route a new deal that names no pipeline. Each stage gets a key from its label; a key another pipeline already uses gets the pipeline\'s name in front (`renewals_won`). A workspace has at most 10 pipelines.\n- **`update`** changes what you send. `stages` is the pipeline\'s whole stage list: read it with `pipelines get`, keep each stage\'s `key`, and add a new stage without one. A stage with live deals in it cannot be left out; archive it with `"isArchived": true` instead.\n- **`propose`** asks Ken to draft a pipeline from one sentence: a `name`, a `routingRule` and `stages`, in the shape `create` takes. It saves nothing. Read it, change what you want, and send it to `create`.\n- **`archive`** stops new deals from entering a pipeline and keeps the deals in it. The default pipeline cannot be archived, and nothing is deleted: `restore` brings a pipeline back.\n\n## Deals in a pipeline\n\nA deal\'s stage names its pipeline, and the deal\'s `pipelineId` repeats it. To work one pipeline\'s deals, or move a deal between pipelines:\n\n```bash\nkenso opportunities list --pipeline-id 6\nkenso opportunities search --pipeline-id 6 --data \'{"countBy": ["stage"]}\'\nkenso opportunities create --account-id 501 --pipeline-id 6\nkenso opportunities move 77 --pipeline 6\nkenso opportunities move 77 --pipeline 6 --stage negotiating\n```\n\n- **`create --pipeline-id`** opens the deal in that pipeline\'s first live open stage. Without it, and without a `stage`, Ken reads each pipeline\'s `routingRule` and opens the deal in the pipeline whose rule clearly fits the account, else in the default pipeline. A pipeline you name always wins.\n- **`move --pipeline`** alone keeps the deal\'s category (`open`, `won` or `lost`): it lands in that pipeline\'s live stage of the category with the same label as its stage now, else in the category\'s first live stage. The printed deal says where it landed. With `--stage`, the stage must be that pipeline\'s; the error lists the pipeline\'s stage keys otherwise.\n- An archived pipeline takes no deal from another pipeline (`pipeline_archived`). The deals already in it still move between its stages.\n- A move is a stage change: it writes the same history, and a stage a person set is refused with `pinned_by_user` unless you pass `--overwrite-pinned`.\n\n## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore 812\n```\n\nA deleted account can be restored for 30 days. `deleted-accounts list` shows each one with who deleted it, `expiresAt` (restore works until then) and what comes back: `personCount`, `opportunityCount` and `touchCount`. `accounts restore <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. A domain another account took since stays with that account and is listed in `domainsTaken`. A merged account is not listed and cannot be restored: a merge has no undo. Both commands are behind the `crm_import_export` feature flag (`404` while it is off).\n\n## Import a CSV export of another CRM\n\n```bash\nkenso import accounts companies.csv\nkenso import accounts companies.csv --map "Company=name" --map "Notes=" --yes\nkenso import accounts --id 42 --yes\nkenso record-import-rows list --import-id 42 --outcome skipped\nkenso record-imports undo --import-id 42\n```\n\n`kenso import accounts <file.csv>` uploads the file (a header row, at most 50,000 rows) and prints Kenso\'s plan: which field each column fills, which columns it skips, how owner and stage values are read (`valueMaps`) and what it could not settle (`questions`). Headers of Kenso, Twenty, HubSpot, Attio and Salesforce exports are recognized. Nothing is written to your accounts yet. `--map "Header=field"` changes a column and `--map "Header="` skips it. A column fills a custom field with `--map "Header=custom.<key>"` (`kenso fields list --object account` has the keys; people are `person`, deals `opportunity`), and `--map "Header=new"` adds the custom field Kenso proposes for a column no field matches (`new:text` picks the type), and a column whose header is a custom field\'s label is mapped to it already; owner and stage values change with `kenso record-imports update --import-id <id>`.\n\nWith `--yes` the import starts and the command waits for it (`--timeout`, default 30m; the import keeps running on the server either way), then prints how many rows were created, updated, restored, left unchanged and skipped. Without `--yes` it stops at the plan and prints the command that starts that import (`--id <importId> --yes`), so the file is uploaded once. `--dry-run` sends nothing: with a file it prints the upload it would make, since the plan needs the upload, and with `--id` it reads the planned import and prints what `--map`, `--source` and `--research` would change on it. `--source twenty` names the system the file\'s record ids come from: pass the same one for every file of an export, so the people and deals files find the accounts by their old ids. `kenso record-imports delete --import-id <id>` discards an import that was planned and never started; one left planned for 30 days is discarded by itself.\n\nPer row: a domain no account has creates an account; a domain that is already an account fills only that account\'s empty fields, so nothing you entered is overwritten; an account deleted in the last 30 days is restored; a row with no usable domain is skipped, and `kenso record-import-rows list --import-id <id> --outcome skipped` says why. Research of new accounts is off unless you pass `--research`, which is charged per account. It needs the `accounts` and `crm_import_export` flags. This is a different command from `accounts import`, which creates accounts row by row from the machine running the CLI.\n\n`kenso record-imports undo --import-id <id>` takes a finished import back in the background (`kenso record-imports get --import-id <id>` reads `undoing`, then `undone`): an account the import created is deleted, and can be restored for 30 days, unless someone changed it since, it holds a deal, a person was added to it since, or it was merged; a field the import filled is emptied while it still holds the imported value. `kenso record-import-rows list --import-id <id>` shows each row\'s `undoOutcome`.\n\n`kenso import people <file.csv>` works the same way for people. Import the accounts file first: a people row\'s company id (Twenty\'s `Company Id`, HubSpot\'s associated company id) places the person on the account that kept that id, and without one the person goes on the account that holds their email\'s or company\'s domain. A people import never creates an account; a person whose company is no account comes in without one and the row says so. A row matches a person by email, then LinkedIn URL, then name on the company, as every other way into People does; a matched person gets only their empty fields filled (a phone only when they have none). A row with none of the three is skipped, and a row with only a name needs a company that is an account with a domain. `kenso record-imports undo --import-id <id>` takes a people import back too: a person it created leaves the accounts the row placed them on and is deleted, unless someone changed them since, they were contacted or have a touch planned, or they are on an open deal; a field it filled is emptied while it still holds the imported value. `kenso people import` stays the JSONL and enrichment path (`--find-emails`); `kenso import people` is the CRM file with a plan, a row report and one approval.\n\n`kenso import deals <file.csv>` works the same way for deals, after the accounts file and the people file. A row opens a deal on the account that kept its company id (Twenty\'s `Company Id`, HubSpot\'s associated company id), else on the account that holds its company domain; a row whose account Kenso does not know is skipped and says so. Its contact is the person a people import kept the row\'s contact id for (Twenty\'s `Point of Contact Id`). The plan maps each stage in the file to one of the workspace\'s deal stages (`valueMaps`, field `stage`): a stage\'s key or label matches by itself, Closed Won and Closed Lost go to the first won and lost stage, and a value with no match opens in the first open stage until you pick one with `kenso record-imports update`. Amounts stay in the workspace currency: an amount in another currency is left out with a warning, never converted. A row whose deal id an earlier import kept is that deal and only gets its empty fields filled; a file with no id column opens every deal again each time it is imported, and the plan says so (`no_source_id`). `kenso record-imports undo --import-id <id>` takes a deals import back: a deal it opened is deleted unless someone changed it since, and a field it filled is emptied while it still holds the imported value. Undo in the reverse order of the imports (deals, then people, then accounts): an account that holds a deal is kept.\n\n## Export accounts, people or deals\n\n```bash\nkenso export accounts --out accounts.csv\nkenso export accounts --view 12 --out tier-1.csv\nkenso export deals --filters \'[{"field":"stageCategory","operator":"is","values":["open"]}]\' > open-deals.csv\n```\n\nIt writes the CSV that `POST /v1/accounts/export`, `/v1/people/export` or `/v1/opportunities/export` returns, to stdout or to `--out` (then it prints the file and its row count). With no filter it exports every record. More than 50,000 rows is refused: narrow the filters. `--view <id>` exports a saved Accounts view (`kenso account-views list` shows the ids). `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields, so a deals or people view exports with its filters and sort. The accounts and deals files start with `id` and import back as they are. Each export writes an audit-log entry and needs the export permission. Accounts and deals also need the `crm_import_export` flag while it is in beta.\n\n## Duplicates and merges\n\n```bash\nkenso accounts duplicates --scan\nkenso accounts merge 812 --into 77 --dry-run\nkenso accounts merge 812 --into 77 --yes\nkenso accounts merges list --merged-by system\nkenso accounts merges 41\n```\n\nThese need the `crm_import_export` flag beside `accounts`. `accounts duplicates` lists the pairs of accounts that look like one company: both accounts, why they were paired (`reasons`: `domain`, `linkedin`, `name`) and `isCertain`, true when the two share the name and the domain apart from its ending (acme.com and acme.co). `--scan` compares every account first; a scan also runs after each accounts import. `--status dismissed` or `merged` shows the answered pairs. `kenso account-duplicates dismiss --duplicate-id <duplicateId>` answers that a pair is not a duplicate, for good.\n\n`accounts merge <accountId> --into <id>` merges the first account into the second, the one you keep. A merge cannot be undone, so look first: `--dry-run` prints `mergeSummary` (each field that changes with its value before and after, and how many people, deals, touches and domains move) and writes nothing. The merge itself needs `--yes` when no person is at the terminal. It answers the kept account with the same summary and a `mergeId`.\n\n`accounts merges list` is the log, newest first, and `accounts merges <mergeId>` opens one merge with `mergedValues`: the merged-away account as it was. `--merged-by system` shows the merges Ken made itself. Where automatic merging is on for the workspace, Ken merges only certain pairs, keeps the customer, then the owned, then the last touched account, and leaves a pair for you when both are customers, the two have different owners, or one is being worked and the other is set aside (`heldReason` on the pair says which). That job is off unless it was turned on for the workspace.\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\n## Notes on accounts, people and deals\n\nWith the `record_notes` feature on, everyone who can see a record reads its notes. Name the record with exactly one of `--account`, `--person` and `--deal`:\n\n```bash\nkenso notes list --account 5\nkenso notes add --account 5 --body \'Budget approved, @[Jane Doe](41) please send the DPA\'\nkenso notes add --parent 900 --body \'Sent it this morning\' # a comment under note 900\ncat call-notes.md | kenso notes add --deal 77 --body - # the body from stdin\nkenso notes edit 900 --body \'Budget approved for Q1\' # the author only\nkenso notes edit 900 --pin\nkenso notes delete 900 --yes # kenso notes restore 900 brings it back\n```\n\nThe body is markdown, up to 20,000 characters. Mention a teammate as `@[Name](memberId)`: they get a notification that opens the note. A note shows on the record\'s Notes tab and its Activity timeline, and Ken\'s account brief quotes the account\'s notes. The MCP\'s `notes` tool does the same. A note on an account needs the accounts plan feature; people and deals work on every plan.\n\n## Required fields per stage\n\n```bash\nkenso pipelines stage-rules\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier\nkenso pipelines stage-rules proposal --none\nkenso pipelines stage-rules lost --default\n```\n\nWith the `deal_stage_rules` flag on, each stage can name the fields a deal should have in it. Without a stage the command prints every stage\'s `key`, `label`, `category`, `isArchived`, `requiredFields` and `isDefault`, plus `requirableFields`: `amount`, `closeDate`, `ownerMemberId`, `primaryPersonId`, `nextStep`, `lostReasonKey`, `wonReasonKey` and `custom.<key>` for each custom deal field. `--require` sets the stage\'s whole list, in order, at most 10. `--none` requires nothing, and `--default` goes back to the default: a lost stage asks for `lostReasonKey`, any other stage nothing. Setting a rule needs the `workspace_settings` permission. The same as the MCP\'s `opportunities(operation="stages-set-required-fields")`.\n\nA missing field never stops a move. The deal moves, and it is flagged Missing on the board, the list and the deal page until the field is filled. A rule also applies to deals already in the stage.\n\n```bash\nkenso opportunities update --opportunity-id 4401 --stage proposal\nkenso opportunities list --missing-fields\n```\n\nEvery deal then carries `missingFields` (`[{field, label}]`). A create, or an update that sends a stage, answers `warnings` beside the deal for each field the stage asks for that the deal leaves empty: each prints on stderr as `warning: <message>`, stdout stays the deal and the exit code stays 0. `--missing-fields` keeps only the deals flagged Missing (also `missingFields: true` on `kenso opportunities search`).\n\n## Won and lost reasons\n\n```bash\nkenso opportunity-reasons get\nkenso opportunity-reasons replace --kind lost --data \'{"reasons":[{"key":"no_budget","label":"No budget"},{"label":"Built it in-house"}]}\'\nkenso opportunities move 4401 --stage lost --reason built_it_in_house\n```\n\n`kenso opportunities move <id> --stage <key> [--reason <key>]` sends the reason as `lostReasonKey` for a lost stage or `wonReasonKey` for a won stage; an open stage takes none. Each field the new stage asks for that the deal leaves empty prints a warning on stderr, and the move still goes through.\n\nWith the `deal_stage_rules` flag on, each workspace edits why its deals are lost and won. `get` prints `lost` and `won`, each `{isDefault, reasons: [{key, label, isArchived}]}`. `replace` takes a kind\'s whole list in order, as `get` prints it: keep a reason by its `key`, leave `key` out for a new one, and set `isArchived` to archive a reason or bring one back. A reason left out is archived too: deals keep it, and no write can pick it again. At least one reason stays live and at most 30, and labels stay unique, archived ones included. A deal takes a live key in `lostReasonKey` (a lost stage) or `wonReasonKey` (a won stage). A move to Lost without a reason still goes through, with a warning and "Missing: Lost reason" on the deal. Editing the lists needs the `workspace_settings` permission. The same as the MCP\'s `pipelines(operation="reasons-get")` and `reasons-replace`.\n\n## Record page layouts\n\n```bash\nkenso layouts show account\nkenso layouts set account --header tier,ownerMemberId,score,custom.arr\nkenso layouts show account > layout.json && kenso layouts set account --data @layout.json\nkenso layouts reset account\n```\n\nWith the `record_layout` flag on, a workspace lays out each record page once, for every member: `account`, `person` or `opportunity` (a deal). `show` prints `GET /v1/record-layouts/{object}`: `isDefault`, `version`, `headerFields` (up to 6, pinned under the record\'s name), `railSections` (`{name, fields}`), `hiddenFields` (under the rail\'s More), `sections` (`{key, label, placement, locked, hidden}`, in page order) and `availableFields`. Field keys are the field catalog\'s (`ownerMemberId`, `closeDate`, `primaryDomain`); a custom field is `custom.<field_key>`, and a new one joins the last rail section.\n\n`set --header` pins up to 6 fields and keeps the rest of the saved layout; the fields it unpins go to the top of the first rail section. `set --data` saves a whole layout, so group the rail into sections or hide a section that way, starting from `show`. A save made after someone else\'s answers a conflict: show it again. `reset` puts the page back to Kenso\'s default. Saving needs the `workspace_settings` permission, and the account page also needs the `accounts` plan. The same as the MCP\'s `account_views` operations `record-layouts-get`, `record-layouts-replace` and `record-layouts-reset`.\n\n## Pin a saved view\n\n```bash\nkenso views pin 118\nkenso views unpin 118\n```\n\nWith the `shared_views` flag on, `views pin` adds a saved view to your own sidebar, nested under its list (an account view under Accounts, a person view under People, a deal view under Deals). It is `kenso pins add --kind view --view-id <viewId>` under the name you would try: it prints the pin, and a view already pinned answers the pin it has. Pins are yours alone: pinning a shared view does not pin it for a teammate. `views unpin` finds your pin of the view and removes it, and prints `{"viewId": ..., "removed": true}`; a view you had not pinned prints `removed: false` and changes nothing. The view itself stays either way. `kenso pins list` shows every pin you have.\n\n## Tasks\n\nTasks are to-dos a member owes: a title, an optional due day or time, an assignee and at most one account, person or deal. They need the `tasks` flag. The app calls deals "Deals"; the CLI keeps `--deal` for an opportunity id.\n\n```bash\nkenso tasks add "Send the deck" --due tomorrow --account 812\nkenso tasks add "Call Ada back" --due friday --at 16:00 --person 501 --assignee ada@acme.com\nkenso tasks list --assignee me --due overdue,today\nkenso tasks queue --scope mine\nkenso tasks assign 7 me\nkenso tasks done 7 8 9\nkenso tasks done 7 --undo\n```\n\n- `tasks add` sends `POST /v1/tasks`. `--due` takes `today`, `tomorrow`, a weekday (the next one: `friday` or `fri`), a day (`2026-11-20`) or an ISO 8601 time with its offset (`2026-11-20T15:00:00Z`); `--at HH:MM` puts a time on that day (today without `--due`). Day words and `--at` read this computer\'s clock and time zone (`TZ`); a time\'s day is read in the assignee\'s app time zone. `--assignee` takes `me`, a member id or an email; without it the task is yours.\n- `tasks done` completes each task it names, in order (`PATCH /v1/tasks/{id}` with `status: done`); `--undo` reopens them. When one fails, its error names the tasks before it, which are already changed. `tasks assign` gives a task to `me`, a member id or a member\'s email; that member gets a `task_assigned` notification.\n- `tasks queue` is `task-queue list` under the name you would try: the Tasks screen\'s open work by due day, with `--scope mine|assigned_by_me|everyone`. It lists tasks, manual touches, call tasks, inbox threads with a reminder due (when you can view the Inbox) and Ken\'s follow-ups to you, each with the app path in `href` (null for a task, which opens in its panel).\n- `tasks list`, `get`, `update`, `delete`, `restore` and `task-queue list` are generated from the API: `kenso tasks --help` lists them.\n';
|
|
8780
|
+
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| `import accounts <file.csv>`, `import people <file.csv>`, `import deals <file.csv>` | Import a CSV export of another CRM, up to 50,000 rows: Kenso proposes the mapping, you approve once, it runs in the background and can be undone for 30 days |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts bulk-update`, `people bulk-update`, `opportunities bulk-update` | Set the same fields on many records at once, by ids or by a filter, with a preview first. Needs `bulk_edit` too |\n| `accounts bulk-delete`, `people bulk-delete`, `opportunities bulk-delete` | Delete many records at once, by ids or by a filter, with a preview first. Not undone. Needs `bulk_edit` too |\n| `changes list`, `get`, `rows`, `apply`, `cancel`, `undo` | Follow a bulk change, read what each record got, stop it, or put the old values back for 30 days |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities move <id> [--stage <key>] [--pipeline <pipelineId>] [--reason <key>]` | Move a deal to a stage or another pipeline, with its won or lost reason; a field the stage asks for never stops it |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `notes list`, `notes add`, `notes edit`, `notes delete` | Notes and comments on accounts, people and deals (needs `record_notes`) |\n| `deleted-accounts list`, `accounts restore <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `accounts duplicates`, `accounts merge <id> --into <id>`, `accounts merges list` | The pairs that look like one company, merging a pair, and the log of merges |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved view (`--view <id>`), or what the filters match |\n| `capture status` | Your captured mailbox, its backfill progress and what teammates see of a captured email. Needs the `crm_capture` flag |\n| `capture connect` | Turn capture on for your own mailbox. `--private` starts it hidden from teammates; `--provider google` prints a sign-in link when no account is connected yet |\n| `capture private on\\|off` | Hide your captured email from teammates, or show it again. Email only: meetings stay visible. `--thread <id>` sets the switch for one thread |\n| `capture thread <threadId>` | One captured email thread: subject, people, time, Ken\'s summary, the members whose mailboxes hold it, and each body you may open. The id is `capturedThread.id` on a timeline row |\n| `views pin <viewId>`, `views unpin <viewId>` | Pin a saved view to your own sidebar, or take it off. Needs the `shared_views` flag |\n| `capture sync` | Read your captured mailbox now, instead of waiting for the next two-minute poll. Prints what the pass read, logged and created |\n| `capture disconnect` | Turn capture off and delete your stored email bodies. Asks first; `--yes` skips the question |\n| `capture teammates-see summary\\|full_email` | Workspace admin: what teammates see of captured email |\n| `pipelines stage-rules` | List or set the fields a deal should have in each stage |\n| `opportunity-reasons get`, `opportunity-reasons replace` | List or edit why deals are lost and won |\n| `layouts show\\|set\\|reset <object>` | How every account, person or deal page in the workspace lays out its fields: header, rail sections and hidden fields (needs `record_layout`) |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n| `tasks add`, `tasks done`, `tasks assign`, `tasks queue` | Add a to-do for a member on an account, person or deal, complete it, hand it on, or read your open work (needs `tasks`) |\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\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "hqLocation", "operator": "contains", "values": ["Germany"]}]}}\' --all\n# my accounts with a meeting this quarter: me is whoever runs it, so a saved view with it lists each member\'s own\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "owner", "operator": "is", "values": ["me"]}, {"field": "lastMeeting", "operator": "in_period", "values": ["this_quarter"]}]}}\' --all\n# tier 1 accounts with no meeting in 30 days: none since then, or none ever\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}, {"match": "any", "conditions": [{"field": "lastMeeting", "operator": "older_than_days", "values": ["30"]}, {"field": "lastMeeting", "operator": "is_empty"}]}]}}\' --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\nTo set the same fields on many records, use `bulk-update` (below; it needs the `bulk_edit` flag). When every row gets its own values, or the workspace has no `bulk_edit`, 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## Change many accounts at once\n\n```bash\nkenso accounts bulk-update --filter \'{"filters":[{"field":"stage","operator":"is","values":["new"]}]}\' --set owner=42 --dry-run\nkenso changes apply --change-id 31\nkenso accounts bulk-update --ids 812,813 --set stage=engaged --set tier=2 --yes\nkenso changes get --change-id 31\n```\n\n`accounts bulk-update` sets the same fields on every account you name: `--ids` (1,000 at most), everything a `--filter` matches (the body `kenso accounts search --data` takes: `filters`, `where`, `q`; up to 50,000), or `--all`. A filter that holds only options and no condition (`--filter \'{"includeImportOnly":true}\'`) takes `--all` beside it. `--exclude-ids` leaves some of a filter\'s accounts out. `--set field=value` takes `ownerMemberId` (or `owner`), `stage`, `tierOverride` (or `tier`), `industry`, `fundingRound`, `employeeCount`, `hqLocation` and `cadenceDays`, and a custom field as `custom.<key>` (`--set custom.region=EMEA`; `kenso api GET \'/v1/fields?object=account\'` gives the keys); a value of `null` clears the field. `--add-tag 12,14` and `--remove-tag 13` put tags on every account or take them off (`kenso tags list` gives the ids); each tag is one row per account from `false` to `true` or back, so `kenso changes undo` takes off only the tags the change put on. People take them too; deals have no tags. A text field\'s value is sent as you type it (`--set hqLocation=10001` is the text "10001"); a custom field\'s type is not known to the CLI, so quote its text when it reads as a number or as true or false: `--set \'custom.code="10001"\'`. Use `accounts update --each` when every row gets its own values.\n\nIt makes a change set: the accounts it names and, for each, the field, its value before and its value after. Without `--yes` (or with `--dry-run`) it previews: it prints `count` and a `sample`, writes nothing, and `next` is the `kenso changes apply` command that writes exactly those accounts. With `--yes` it writes in the background and waits (`--timeout`, default 10m), then prints the change with its `counts`: `applied`, `unchanged` (already had the value), `conflict` (the account changed after the preview, so it was left alone) and `failed` (for example `pinned`: a person set the field by hand; `--overwrite-pinned` replaces it). Exit 5 when some accounts failed or conflicted. It needs the `bulk_edit` flag as well as `accounts`.\n\n`kenso accounts bulk-update` used to be the generated command for the route\'s older one-field body, which sets one `accountType` on up to 500 accounts and needs only `accounts`. The route still takes that body, but this command no longer sends it: use `kenso accounts update --each` with an `accountType` column, or `kenso api POST /v1/accounts/bulk-update --data \'{"accountIds":[812,813],"accountType":"lost"}\'`.\n\n`people bulk-update` and `opportunities bulk-update` work the same way. People take `--set` for `ownerMemberId` (or `owner`), `leadStatus`, `title`, `seniority`, `department` and `location`, and a `--filter` of `kenso people search --data` fields (`leadStatus`, `roles`, `tagIds`, `q` and the rest). Deals take `stage` (a live stage key), `ownerMemberId` (or `owner`), `closeDate` (or `close`), `amount`, `dealType` and `nextStep`, and a `--filter` of `kenso opportunities search --data` fields (`filters`, `accountId`, `q`):\n\n```bash\nkenso opportunities bulk-update --filter \'{"filters":[{"field":"stageCategory","operator":"is","values":["open"]}]}\' --set stage=proposal --dry-run\nkenso people bulk-update --ids 501,502 --set owner=42 --yes\n```\n\n### Delete many records at once\n\n```bash\nkenso people bulk-delete --filter \'{"onAccount":"none","leadStatus":["disqualified"]}\' --dry-run\nkenso changes apply --change-id 32\nkenso opportunities bulk-delete --ids 71,72,73 --yes\n```\n\n`accounts bulk-delete`, `people bulk-delete` and `opportunities bulk-delete` name their records the way `bulk-update` does (`--ids`, `--filter`, `--all`, `--exclude-ids`) and take no `--set`. Without `--yes` they preview: `count`, a `sample`, and `next` is the `kenso changes apply` command that deletes exactly those records. The API itself previews a delete whose body leaves `dryRun` out, so `--yes` sends `dryRun: false`. Each record is deleted as its own `delete` command deletes it, so one that cannot be deleted (a person still on an account) is counted as `failed` and the rest go on. A delete is not undone with `kenso changes undo`.\n\n### Follow, stop and undo a change\n\n```bash\nkenso changes list --object accounts\nkenso changes rows --change-id 31 --status conflict,failed\nkenso changes cancel --change-id 31\nkenso changes undo --change-id 31\n```\n\n`changes list` shows the workspace\'s bulk changes, newest first, whoever made them. `changes rows` lists a change\'s records with the value before (`from`) and after (`to`) and a `status`; `--status conflict,failed` reads what a change missed. `changes cancel` drops a preview or stops a change that is still writing; what it already wrote stays. `changes undo` puts the old value back on every record that still holds the value the change wrote, for 30 days after it was applied (`undoUntil`). A record someone changed again since keeps its newer value: `counts.undone` is how many went back, `counts.applied` how many still hold the change. Undo answers `409 invalid_state` with `undo_expired`, `still_running`, `nothing_applied` or `not_undoable` when there is nothing it can put back.\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` (member ids, or `me` for whoever runs it), `closeDate` (`past_due`, `next_30_days`, `later`, `none`, or a period such as `this_week` or `next_quarter`), `sourceCampaignId`, `closedAt` and `createdAt` (periods). `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## Pipelines\n\nA workspace with the `pipelines` flag on can run several deal pipelines, each with its own stages. These are generated commands (beta):\n\n```bash\nkenso pipelines list\nkenso pipelines list --query "[].{id: id, name: name, default: isDefault, stages: stages[].key}"\nkenso pipelines get --pipeline-id 5\n```\n\n`list` prints every pipeline in display order, archived ones included: `id`, `name`, `routingRule` (the one sentence Ken reads to decide whether a new deal belongs there), `isDefault`, `isArchived`, `position`, `opportunityCount`, `amountTotal` and `stages`, each stage as `kenso opportunity-stages list` prints it. A stage key is unique in the workspace, across pipelines, so a deal\'s `stage` names its pipeline and its `pipelineId` repeats it. The first read turns the workspace\'s stage list into its default pipeline, named Sales, with every deal in it. The same rows as the MCP\'s `pipelines(operation="list")`.\n\nShaping them needs the `workspace_settings` permission:\n\n```bash\nkenso pipelines create --name Renewals --routing-rule "The account is already a customer" --data \'{"stages": [{"label": "Up for renewal", "category": "open"}, {"label": "Won", "category": "won"}, {"label": "Lost", "category": "lost"}]}\'\nkenso pipelines update --pipeline-id 6 --name Expansion --position 0\nkenso pipelines update --pipeline-id 6 --data @stages.json\nkenso pipelines archive --pipeline-id 6\nkenso pipelines restore --pipeline-id 6\nkenso pipelines propose --description "upsells and renewals for customers"\n```\n\n- **`create`** takes a unique `name`, the pipeline\'s `stages` in display order (at least one `open`, one `won` and one `lost`) and an optional `routingRule`: one sentence that says which deals belong there, which Ken reads to route a new deal that names no pipeline. Each stage gets a key from its label; a key another pipeline already uses gets the pipeline\'s name in front (`renewals_won`). A workspace has at most 10 pipelines.\n- **`update`** changes what you send. `stages` is the pipeline\'s whole stage list: read it with `pipelines get`, keep each stage\'s `key`, and add a new stage without one. A stage with live deals in it cannot be left out; archive it with `"isArchived": true` instead.\n- **`propose`** asks Ken to draft a pipeline from one sentence: a `name`, a `routingRule` and `stages`, in the shape `create` takes. It saves nothing. Read it, change what you want, and send it to `create`.\n- **`archive`** stops new deals from entering a pipeline and keeps the deals in it. The default pipeline cannot be archived, and nothing is deleted: `restore` brings a pipeline back.\n\n## Deals in a pipeline\n\nA deal\'s stage names its pipeline, and the deal\'s `pipelineId` repeats it. To work one pipeline\'s deals, or move a deal between pipelines:\n\n```bash\nkenso opportunities list --pipeline-id 6\nkenso opportunities search --pipeline-id 6 --data \'{"countBy": ["stage"]}\'\nkenso opportunities create --account-id 501 --pipeline-id 6\nkenso opportunities move 77 --pipeline 6\nkenso opportunities move 77 --pipeline 6 --stage negotiating\n```\n\n- **`create --pipeline-id`** opens the deal in that pipeline\'s first live open stage. Without it, and without a `stage`, Ken reads each pipeline\'s `routingRule` and opens the deal in the pipeline whose rule clearly fits the account, else in the default pipeline. A pipeline you name always wins.\n- **`move --pipeline`** alone keeps the deal\'s category (`open`, `won` or `lost`): it lands in that pipeline\'s live stage of the category with the same label as its stage now, else in the category\'s first live stage. The printed deal says where it landed. With `--stage`, the stage must be that pipeline\'s; the error lists the pipeline\'s stage keys otherwise.\n- An archived pipeline takes no deal from another pipeline (`pipeline_archived`). The deals already in it still move between its stages.\n- A move is a stage change: it writes the same history, and a stage a person set is refused with `pinned_by_user` unless you pass `--overwrite-pinned`.\n\n## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore 812\n```\n\nA deleted account can be restored for 30 days. `deleted-accounts list` shows each one with who deleted it, `expiresAt` (restore works until then) and what comes back: `personCount`, `opportunityCount` and `touchCount`. `accounts restore <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. A domain another account took since stays with that account and is listed in `domainsTaken`. A merged account is not listed and cannot be restored: a merge has no undo. Both commands are behind the `crm_import_export` feature flag (`404` while it is off).\n\n## Import a CSV export of another CRM\n\n```bash\nkenso import accounts companies.csv\nkenso import accounts companies.csv --map "Company=name" --map "Notes=" --yes\nkenso import accounts --id 42 --yes\nkenso record-import-rows list --import-id 42 --outcome skipped\nkenso record-imports undo --import-id 42\n```\n\n`kenso import accounts <file.csv>` uploads the file (a header row, at most 50,000 rows) and prints Kenso\'s plan: which field each column fills, which columns it skips, how owner and stage values are read (`valueMaps`) and what it could not settle (`questions`). Headers of Kenso, Twenty, HubSpot, Attio and Salesforce exports are recognized. Nothing is written to your accounts yet. `--map "Header=field"` changes a column and `--map "Header="` skips it. A column fills a custom field with `--map "Header=custom.<key>"` (`kenso fields list --object account` has the keys; people are `person`, deals `opportunity`), and `--map "Header=new"` adds the custom field Kenso proposes for a column no field matches (`new:text` picks the type), and a column whose header is a custom field\'s label is mapped to it already; owner and stage values change with `kenso record-imports update --import-id <id>`.\n\nWith `--yes` the import starts and the command waits for it (`--timeout`, default 30m; the import keeps running on the server either way), then prints how many rows were created, updated, restored, left unchanged and skipped. Without `--yes` it stops at the plan and prints the command that starts that import (`--id <importId> --yes`), so the file is uploaded once. `--dry-run` sends nothing: with a file it prints the upload it would make, since the plan needs the upload, and with `--id` it reads the planned import and prints what `--map`, `--source` and `--research` would change on it. `--source twenty` names the system the file\'s record ids come from: pass the same one for every file of an export, so the people and deals files find the accounts by their old ids. `kenso record-imports delete --import-id <id>` discards an import that was planned and never started; one left planned for 30 days is discarded by itself.\n\nPer row: a domain no account has creates an account; a domain that is already an account fills only that account\'s empty fields, so nothing you entered is overwritten; an account deleted in the last 30 days is restored; a row with no usable domain is skipped, and `kenso record-import-rows list --import-id <id> --outcome skipped` says why. Research of new accounts is off unless you pass `--research`, which is charged per account. It needs the `accounts` and `crm_import_export` flags. This is a different command from `accounts import`, which creates accounts row by row from the machine running the CLI.\n\n`kenso record-imports undo --import-id <id>` takes a finished import back in the background (`kenso record-imports get --import-id <id>` reads `undoing`, then `undone`): an account the import created is deleted, and can be restored for 30 days, unless someone changed it since, it holds a deal, a person was added to it since, or it was merged; a field the import filled is emptied while it still holds the imported value. `kenso record-import-rows list --import-id <id>` shows each row\'s `undoOutcome`.\n\n`kenso import people <file.csv>` works the same way for people. Import the accounts file first: a people row\'s company id (Twenty\'s `Company Id`, HubSpot\'s associated company id) places the person on the account that kept that id, and without one the person goes on the account that holds their email\'s or company\'s domain. A people import never creates an account; a person whose company is no account comes in without one and the row says so. A row matches a person by email, then LinkedIn URL, then name on the company, as every other way into People does; a matched person gets only their empty fields filled (a phone only when they have none). A row with none of the three is skipped, and a row with only a name needs a company that is an account with a domain. `kenso record-imports undo --import-id <id>` takes a people import back too: a person it created leaves the accounts the row placed them on and is deleted, unless someone changed them since, they were contacted or have a touch planned, or they are on an open deal; a field it filled is emptied while it still holds the imported value. `kenso people import` stays the JSONL and enrichment path (`--find-emails`); `kenso import people` is the CRM file with a plan, a row report and one approval.\n\n`kenso import deals <file.csv>` works the same way for deals, after the accounts file and the people file. A row opens a deal on the account that kept its company id (Twenty\'s `Company Id`, HubSpot\'s associated company id), else on the account that holds its company domain; a row whose account Kenso does not know is skipped and says so. Its contact is the person a people import kept the row\'s contact id for (Twenty\'s `Point of Contact Id`). The plan maps each stage in the file to one of the workspace\'s deal stages (`valueMaps`, field `stage`): a stage\'s key or label matches by itself, Closed Won and Closed Lost go to the first won and lost stage, and a value with no match opens in the first open stage until you pick one with `kenso record-imports update`. Amounts stay in the workspace currency: an amount in another currency is left out with a warning, never converted. A row whose deal id an earlier import kept is that deal and only gets its empty fields filled; a file with no id column opens every deal again each time it is imported, and the plan says so (`no_source_id`). `kenso record-imports undo --import-id <id>` takes a deals import back: a deal it opened is deleted unless someone changed it since, and a field it filled is emptied while it still holds the imported value. Undo in the reverse order of the imports (deals, then people, then accounts): an account that holds a deal is kept.\n\n## Export accounts, people or deals\n\n```bash\nkenso export accounts --out accounts.csv\nkenso export accounts --view 12 --out tier-1.csv\nkenso export deals --view 40 --out pipeline.csv\nkenso export deals --filters \'[{"field":"stageCategory","operator":"is","values":["open"]}]\' > open-deals.csv\n```\n\nIt writes the CSV that `POST /v1/accounts/export`, `/v1/people/export` or `/v1/opportunities/export` returns, to stdout or to `--out` (then it prints the file and its row count). With no filter it exports every record. More than 50,000 rows is refused: narrow the filters. `--view <id>` exports a saved view of that object, your own or one shared with the workspace (`kenso views list --object account` shows the ids; people are `person`, deals `opportunity`): the file holds the rows the view lists, in its sort, so its row count is the view\'s count. `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields; given with `--view`, each replaces that key of the view. The accounts and deals files start with `id` and import back as they are. Each export writes an audit-log entry and needs the export permission. Accounts and deals also need the `crm_import_export` flag while it is in beta.\n\n## Duplicates and merges\n\n```bash\nkenso accounts duplicates --scan\nkenso accounts merge 812 --into 77 --dry-run\nkenso accounts merge 812 --into 77 --yes\nkenso accounts merges list --merged-by system\nkenso accounts merges 41\n```\n\nThese need the `crm_import_export` flag beside `accounts`. `accounts duplicates` lists the pairs of accounts that look like one company: both accounts, why they were paired (`reasons`: `domain`, `linkedin`, `name`) and `isCertain`, true when the two share the name and the domain apart from its ending (acme.com and acme.co). `--scan` compares every account first; a scan also runs after each accounts import. `--status dismissed` or `merged` shows the answered pairs. `kenso account-duplicates dismiss --duplicate-id <duplicateId>` answers that a pair is not a duplicate, for good.\n\n`accounts merge <accountId> --into <id>` merges the first account into the second, the one you keep. A merge cannot be undone, so look first: `--dry-run` prints `mergeSummary` (each field that changes with its value before and after, and how many people, deals, touches and domains move) and writes nothing. The merge itself needs `--yes` when no person is at the terminal. It answers the kept account with the same summary and a `mergeId`.\n\n`accounts merges list` is the log, newest first, and `accounts merges <mergeId>` opens one merge with `mergedValues`: the merged-away account as it was. `--merged-by system` shows the merges Ken made itself. Where automatic merging is on for the workspace, Ken merges only certain pairs, keeps the customer, then the owned, then the last touched account, and leaves a pair for you when both are customers, the two have different owners, or one is being worked and the other is set aside (`heldReason` on the pair says which). That job is off unless it was turned on for the workspace.\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\n## Notes on accounts, people and deals\n\nWith the `record_notes` feature on, everyone who can see a record reads its notes. Name the record with exactly one of `--account`, `--person` and `--deal`:\n\n```bash\nkenso notes list --account 5\nkenso notes add --account 5 --body \'Budget approved, @[Jane Doe](41) please send the DPA\'\nkenso notes add --parent 900 --body \'Sent it this morning\' # a comment under note 900\ncat call-notes.md | kenso notes add --deal 77 --body - # the body from stdin\nkenso notes edit 900 --body \'Budget approved for Q1\' # the author only\nkenso notes edit 900 --pin\nkenso notes delete 900 --yes # kenso notes restore 900 brings it back\n```\n\nThe body is markdown, up to 20,000 characters. Mention a teammate as `@[Name](memberId)`: they get a notification that opens the note. A note shows on the record\'s Notes tab and its Activity timeline, and Ken\'s account brief quotes the account\'s notes. The MCP\'s `notes` tool does the same. A note on an account needs the accounts plan feature; people and deals work on every plan.\n\n## Required fields per stage\n\n```bash\nkenso pipelines stage-rules\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier\nkenso pipelines stage-rules proposal --none\nkenso pipelines stage-rules lost --default\n```\n\nWith the `deal_stage_rules` flag on, each stage can name the fields a deal should have in it. Without a stage the command prints every stage\'s `key`, `label`, `category`, `isArchived`, `requiredFields` and `isDefault`, plus `requirableFields`: `amount`, `closeDate`, `ownerMemberId`, `primaryPersonId`, `nextStep`, `lostReasonKey`, `wonReasonKey` and `custom.<key>` for each custom deal field. `--require` sets the stage\'s whole list, in order, at most 10. `--none` requires nothing, and `--default` goes back to the default: a lost stage asks for `lostReasonKey`, any other stage nothing. Setting a rule needs the `workspace_settings` permission. The same as the MCP\'s `opportunities(operation="stages-set-required-fields")`.\n\nA missing field never stops a move. The deal moves, and it is flagged Missing on the board, the list and the deal page until the field is filled. A rule also applies to deals already in the stage.\n\n```bash\nkenso opportunities update --opportunity-id 4401 --stage proposal\nkenso opportunities list --missing-fields\n```\n\nEvery deal then carries `missingFields` (`[{field, label}]`). A create, or an update that sends a stage, answers `warnings` beside the deal for each field the stage asks for that the deal leaves empty: each prints on stderr as `warning: <message>`, stdout stays the deal and the exit code stays 0. `--missing-fields` keeps only the deals flagged Missing (also `missingFields: true` on `kenso opportunities search`).\n\n## Won and lost reasons\n\n```bash\nkenso opportunity-reasons get\nkenso opportunity-reasons replace --kind lost --data \'{"reasons":[{"key":"no_budget","label":"No budget"},{"label":"Built it in-house"}]}\'\nkenso opportunities move 4401 --stage lost --reason built_it_in_house\n```\n\n`kenso opportunities move <id> --stage <key> [--reason <key>]` sends the reason as `lostReasonKey` for a lost stage or `wonReasonKey` for a won stage; an open stage takes none. Each field the new stage asks for that the deal leaves empty prints a warning on stderr, and the move still goes through.\n\nWith the `deal_stage_rules` flag on, each workspace edits why its deals are lost and won. `get` prints `lost` and `won`, each `{isDefault, reasons: [{key, label, isArchived}]}`. `replace` takes a kind\'s whole list in order, as `get` prints it: keep a reason by its `key`, leave `key` out for a new one, and set `isArchived` to archive a reason or bring one back. A reason left out is archived too: deals keep it, and no write can pick it again. At least one reason stays live and at most 30, and labels stay unique, archived ones included. A deal takes a live key in `lostReasonKey` (a lost stage) or `wonReasonKey` (a won stage). A move to Lost without a reason still goes through, with a warning and "Missing: Lost reason" on the deal. Editing the lists needs the `workspace_settings` permission. The same as the MCP\'s `pipelines(operation="reasons-get")` and `reasons-replace`.\n\n## Record page layouts\n\n```bash\nkenso layouts show account\nkenso layouts set account --header tier,ownerMemberId,score,custom.arr\nkenso layouts show account > layout.json && kenso layouts set account --data @layout.json\nkenso layouts reset account\n```\n\nWith the `record_layout` flag on, a workspace lays out each record page once, for every member: `account`, `person` or `opportunity` (a deal). `show` prints `GET /v1/record-layouts/{object}`: `isDefault`, `version`, `headerFields` (up to 6, pinned under the record\'s name), `railSections` (`{name, fields}`), `hiddenFields` (under the rail\'s More), `sections` (`{key, label, placement, locked, hidden}`, in page order) and `availableFields`. Field keys are the field catalog\'s (`ownerMemberId`, `closeDate`, `primaryDomain`); a custom field is `custom.<field_key>`, and a new one joins the last rail section.\n\n`set --header` pins up to 6 fields and keeps the rest of the saved layout; the fields it unpins go to the top of the first rail section. `set --data` saves a whole layout, so group the rail into sections or hide a section that way, starting from `show`. A save made after someone else\'s answers a conflict: show it again. `reset` puts the page back to Kenso\'s default. Saving needs the `workspace_settings` permission, and the account page also needs the `accounts` plan. The same as the MCP\'s `account_views` operations `record-layouts-get`, `record-layouts-replace` and `record-layouts-reset`.\n\n## Pin a saved view\n\n```bash\nkenso views pin 118\nkenso views unpin 118\n```\n\nWith the `shared_views` flag on, `views pin` adds a saved view to your own sidebar, nested under its list (an account view under Accounts, a person view under People, a deal view under Deals). It is `kenso pins add --kind view --view-id <viewId>` under the name you would try: it prints the pin, and a view already pinned answers the pin it has. Pins are yours alone: pinning a shared view does not pin it for a teammate. `views unpin` finds your pin of the view and removes it, and prints `{"viewId": ..., "removed": true}`; a view you had not pinned prints `removed: false` and changes nothing. The view itself stays either way. `kenso pins list` shows every pin you have.\n\n## Tasks\n\nTasks are to-dos a member owes: a title, an optional due day or time, an assignee and at most one account, person or deal. They need the `tasks` flag. The app calls deals "Deals"; the CLI keeps `--deal` for an opportunity id.\n\n```bash\nkenso tasks add "Send the deck" --due tomorrow --account 812\nkenso tasks add "Call Ada back" --due friday --at 16:00 --person 501 --assignee ada@acme.com\nkenso tasks list --assignee me --due overdue,today\nkenso tasks queue --scope mine\nkenso tasks assign 7 me\nkenso tasks done 7 8 9\nkenso tasks done 7 --undo\n```\n\n- `tasks add` sends `POST /v1/tasks`. `--due` takes `today`, `tomorrow`, a weekday (the next one: `friday` or `fri`), a day (`2026-11-20`) or an ISO 8601 time with its offset (`2026-11-20T15:00:00Z`); `--at HH:MM` puts a time on that day (today without `--due`). Day words and `--at` read this computer\'s clock and time zone (`TZ`); a time\'s day is read in the assignee\'s app time zone. `--assignee` takes `me`, a member id or an email; without it the task is yours.\n- `tasks done` completes each task it names, in order (`PATCH /v1/tasks/{id}` with `status: done`); `--undo` reopens them. When one fails, its error names the tasks before it, which are already changed. `tasks assign` gives a task to `me`, a member id or a member\'s email; that member gets a `task_assigned` notification.\n- `tasks queue` is `task-queue list` under the name you would try: the Tasks screen\'s open work by due day, with `--scope mine|assigned_by_me|everyone`. It lists tasks, manual touches, call tasks, inbox threads with a reminder due (when you can view the Inbox) and Ken\'s follow-ups to you, each with the app path in `href` (null for a task, which opens in its panel).\n- `tasks list`, `get`, `update`, `delete`, `restore` and `task-queue list` are generated from the API: `kenso tasks --help` lists them.\n';
|
|
8781
8781
|
}
|
|
8782
8782
|
});
|
|
8783
8783
|
|
|
@@ -8793,7 +8793,7 @@ var init_leads = __esm({
|
|
|
8793
8793
|
var output_and_errors_default;
|
|
8794
8794
|
var init_output_and_errors = __esm({
|
|
8795
8795
|
"docs/output-and-errors.md"() {
|
|
8796
|
-
output_and_errors_default = '# Output and errors\n\nEvery command follows one contract, so a script or an agent can parse any of them the same way.\n\n## stdout and stderr\n\n- **stdout carries data only.** Progress, warnings, notices and errors go to stderr.\n- No colors, spinners or pagers. On a terminal you get readable tables; in a pipe you get JSON.\n- A batch command (an import, update, remove, tag or `--each` write) takes `--yes`; without it, the command plans or refuses.\n- A command that deletes, archives or removes, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive` or `kenso api DELETE /v1/tags/7`, needs `--yes` too. Without it, a person at a terminal is asked to confirm; anywhere else (a pipe, a script, CI, a coding agent) it sends nothing and fails with `confirmation_required`, whose `next` is the same command with `--yes`.\n- Any other single write, such as `kenso tags create` or a write through `kenso api` or `kenso mcp call`, sends at once: add `--dry-run` to print the request first (it sends nothing), then run the command without it.\n- A command with no dry run, such as `kenso contacts export`, `kenso auth logout` or `kenso workspace use`, refuses `--dry-run` with `usage_error` (exit 2) and does nothing. Its help ends with `No --dry-run`, and `kenso describe <resource> <action>` shows `"dryRun": false`.\n\n## Formats\n\n| What the command returns | stdout is a terminal | stdout is a pipe or file |\n|---|---|---|\n| One object | key-value lines | compact JSON on one line |\n| A list | a table (first 8 scalar fields, cells cut at 60 characters) | NDJSON: one JSON object per line |\n| A batch run | key-value lines | one JSON summary object |\n| No content (HTTP 204) | nothing | nothing |\n\n`-o` or `--output` picks the format: `json`, `ndjson`, `table` or `ids`. `--json` is the same as `-o json`.\n\n- `-o json` on a list prints one JSON array. On a terminal, `-o json` pretty-prints an object.\n- `-o ids` prints one id per line, ready for `--ids -`. Items without an `id` are skipped with one warning.\n\n```bash\nkenso campaigns list --limit 3\nkenso campaigns list --limit 3 -o json\nkenso contacts list --campaign-id 812 --all -o ids\n```\n\n## Shape the output\n\n- `--fields a,b.c` keeps only those fields (dots reach into nested objects).\n- `--query <JMESPath>` filters or reshapes in-process, so you need no `jq`. On a list it sees the whole list. There is no `--jq`: `--query` takes JMESPath, not jq syntax.\n- Neither applies to a batch summary, which always prints in full.\n- `threads list`, `contacts list` and `contacts search` print a short set of fields per row, in every format: a thread\'s id, channel, sender, subject, interest, read state, newest message time and preview, a contact\'s id, name, email, title, company and email validity, and a few more (the command\'s `--help` names them all). `--full` prints every field (`--full -o json` for a script that reads them all), `--fields` picks your own, and `--query` sees every field.\n\n```bash\nkenso campaigns list --fields id,name,status\nkenso campaigns list --all --query "[?status==\'active\'].id"\nkenso me get --query "length(features)"\nkenso threads list --folder inbox --full\n```\n\n## Lists and pages\n\nA list command prints one page. When there are more, it prints the command for the next page on stderr, for example `next: kenso tags list --limit 1 --cursor MQ`. `--all` follows every page and streams the items. `--limit` sets the page size and `--cursor` starts at a cursor.\n\n`accounts search`, `contacts search` and `people search` page the same way: one page with the `next:` command, or every page with `--all`. A search that asks for counts (`countBy` in `--data`) prints the whole answer instead: `data`, `pagination` and `counts`. Counts cover every match whatever the page, so ask for them on one page (`--limit 1`): `--all` with `countBy` is a usage error.\n\n```bash\nkenso tags list --limit 50\nkenso tags list --all\n```\n\n## Files: uploads and downloads\n\nA command whose API action takes a multipart upload takes `--file <path>`: the CLI reads the file and sends it in the form, with a content type from its extension (a `.png` goes as `image/png`), and the other flags as form fields. `--file <field>=<path>` names the form field, for a form with more than one file. An upload that also takes JSON, such as a logo from a URL instead of a file, sends JSON when you leave `--file` out.\n\nA command whose API action answers with a file (a CSV, an image, a ZIP) takes `--out <path>`: it saves the answer byte for byte (mode 0600) and prints `out`, `bytes` and `contentType`, so the file never passes through an agent\'s context. Without `--out`, a CSV prints as it came, and a binary file goes to stdout only when stdout is a pipe or a file: on a terminal it fails with `binary_output`, whose `next` adds `--out`.\n\n`kenso api` takes both, for any route: `--file` (repeat it for more files) sends multipart with the keys of a `--data` object as form fields, and `--out` saves any answer.\n\n```bash\nkenso saved-lists create-upload --saved-list-id 12 --file people.csv\nkenso workspaces replace-logo --workspace-id 42 --file ./logo.png\nkenso workspaces replace-logo --workspace-id 42 --source-url https://example.com/logo.png\nkenso attachments get-content --attachment-id att_123 --out ./invoice.pdf\nkenso api POST /v1/campaigns/812/email-sequence/images --file ./hero.png\nkenso api GET /v1/knowledge/exports/77/content --out knowledge.zip\n```\n\n## Live streams\n\n`kenso sync events` and `kenso onboarding-builds events` follow a live stream of server-sent events. They print one JSON line per event as it arrives, on a terminal too, with the event\'s name, its id when it has one, and its data:\n\n```json\n{"event":"hello","data":{"buildId":"obd_2x","status":"building","stage":"read","lastEventId":0}}\n{"event":"stage","id":"41","data":{"stage":"plan"}}\n{"event":"done","id":"42","data":{}}\n```\n\nA stream has no time limit while events arrive. The server ends each connection after 15 minutes with a `bye` event; the command then connects again at once, and after a dropped connection or 60 s without even a keepalive, after a second. A connection that brought nothing but `hello` and `bye` (a server that is restarting) backs off 1, 2, 4 ... 30 s. Once events carry an id (`onboarding-builds events`), it sends the last whole event\'s id as `Last-Event-ID`, so no event is lost or printed twice. A refusal (401, 403, 404) ends it at once; eight failed or empty connects in a row end it with the last error.\n\nIt runs until Ctrl-C (exit 130; every line printed is whole), or until one of these:\n\n| Flag | Ends the command |\n|---|---|\n| `--until <event>` | After the first event with that name; several names are comma-separated: `--until done,error` |\n| `--max-events <n>` | After n events, `hello` and `bye` included |\n| `--once` | When the server closes the connection, instead of connecting again |\n\n```bash\nkenso onboarding-builds events --build-id obd_2x --until done,error\nkenso sync events --max-events 2 # hello, then the first poke\n```\n\n`--output`, `--fields` and `--query` do not apply to a stream. `--last-event-id` starts an onboarding build stream after that id.\n\n## Errors\n\nWhen stderr is not a terminal, an error is one JSON line on stderr:\n\n```json\n{"error":{"code":"unknown_flag","message":"Unknown flag --fiel for kenso contacts import.","field":"fiel","hint":"did you mean --file?","next":"kenso contacts import --help"}}\n```\n\n| Key | Always there | Meaning |\n|---|---|---|\n| `code` | yes | A stable snake_case code to branch on |\n| `message` | yes | One sentence for a person |\n| `field` | no | The flag or input field at fault |\n| `hint` | no | What to change |\n| `next` | no | The exact command to run next, such as `kenso auth login`, `kenso workspace list --search <name>` or the same command with `--yes` |\n| `httpStatus` | no | The API\'s HTTP status, when the API answered |\n| `requestId` | no | The API\'s request id: quote it when you contact Kenso support |\n\nOn a terminal the same error prints as text: `Error: <message>`, then `field:`, `hint:`, `next:` and `requestId:` lines. The key never appears in an error.\n\n### How API errors map\n\nThe CLI looks at the HTTP status first, then at the API\'s own `error.code`, which wins when present.\n\n| HTTP status | Default code | Exit |\n|---|---|---|\n| 400, 422 | `validation_failed` | 2 |\n| 401 | `unauthorized` (`next`: `kenso auth login`) | 3 |\n| 403 | `forbidden`: the key\'s user or role cannot do this in this workspace | 3 |\n| 404 | `not_found` | 4 |\n| 409 | `conflict` | 7 |\n| 429 | `rate_limited`, after the CLI waited and retried | 6 |\n| 5xx | `server_error`, after retries where they are safe | 8 |\n| anything else | `http_error` | 1 |\n\nTwo API codes change the exit code: `workspace_required` exits 2 with `"next":"kenso workspace list --search <name>"`, and `limit_reached` (the plan\'s or the campaign\'s lead limit) exits 6.\n\n### Errors from the CLI itself\n\n| Code | Exit | When |\n|---|---|---|\n| `usage_error` | 2 | A required flag or argument is missing, two flags conflict (`--yes` with `--dry-run`), or `--dry-run` on a command that has no dry run |\n| `unknown_command` | 2 | No such command; `hint` suggests the closest one |\n| `unknown_flag`, `invalid_flag`, `invalid_flag_value`, `unexpected_argument` | 2 | A flag or argument the command does not take |\n| `invalid_query` | 2 | `--query` is not valid JMESPath |\n| `confirmation_required` | 2 | A delete, archive or remove ran without `--yes` where nobody can confirm: nothing was sent; `next` adds `--yes` |\n| `cancelled` | 2 | A person answered no to the confirmation: nothing was sent |\n| `file_unreadable` | 2 | An input file is missing, is a folder, cannot be opened, or cannot be parsed; the message names the line, such as `leads.csv line 3: a quote is not closed.` |\n| `config_invalid` | 2 | `~/.kenso/config.json` is not valid JSON: fix or delete it |\n| `feature_not_enabled` | 2 | Every action of the resource is a beta command your workspace has not enabled |\n| `invalid_key_format`, `key_required` | 2 | `auth login --with-key` read something that is not a Kenso key, or stdin is a terminal instead of a pipe |\n| `invalid_workspace_id` | 2 | `kenso workspace use` got an id that is not a positive whole number |\n| `unknown_topic` | 2 | `kenso docs` got a topic it does not have; `hint` lists the topics |\n| `file_unwritable` | 2 or 1 | An output file cannot be written: `--out` on `contacts export`, `kenso api` or a download command (2), `skill install` (1) |\n| `binary_output` | 2 | The answer is a binary file and stdout is a terminal: nothing was printed; `next` saves it with `--out` |\n| `no_api_key` | 3 | No key in `KENSO_API_KEY` or the profile (`next`: `kenso auth login`) |\n| `browser_login_unavailable`, `access_denied`, `login_expired` | 3 | Browser login is off, was denied, or timed out |\n| `run_not_found` | 4 | `kenso runs show` or `resume` got an unknown run id |\n| `docs_not_found` | 4 | `kenso docs reference` before the reference was generated (a source checkout without `pnpm build`) |\n| `run_in_progress`, `already_filled` | 7 | Another process is working on the run, or `studio fill` already ran with this file and these flags |\n| `skill_exists` | 7 | `kenso skill install` found a different `SKILL.md`; `next` adds `--force` to replace it |\n| `job_timeout`, `job_failed`, `job_canceled` | 1 | `kenso jobs wait` (or a command that waits on a job) ran out of time, or the job failed or was canceled |\n| `mcp_tool_error` | 1 | `kenso mcp call`: the MCP tool answered with an error |\n| `unsafe_path` | 1 | `studio pull` refused a file path that would land outside `--dir` |\n| `network_error` | 8 | The API could not be reached after retries |\n| `upload_failed`, `download_failed` | 8 or 1 | A signed upload or download of a Studio file failed: 8 when storage was unreachable or answered 5xx, 1 on a 4xx (often an expired link: run the command again) |\n| `pull_incomplete` | 8 | `studio pull`: a file came back with neither text nor a download link |\n| `unexpected_response` | 1 or 8 | The API answered something the CLI could not read |\n| `unexpected_error` | 1 | A bug: run again with `--verbose` and report it |\n| `interrupted` | 130 | Ctrl-C |\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | OK, including a batch where every row succeeded or was skipped |\n| 1 | Unexpected error |\n| 2 | Usage or input error: a bad flag, a bad file, a validation error |\n| 3 | Auth: no key, an invalid, revoked or expired key, or HTTP 401 or 403 |\n| 4 | Not found |\n| 5 | Partial: the batch finished and some rows failed, were not found or were invalid. See `results.csv` |\n| 6 | Rate limited after retries, or a plan or campaign lead limit stopped the run (`limit_reached`) |\n| 7 | Conflict or invalid state (HTTP 409), or a run another process holds |\n| 8 | Server error after retries (5xx), or the API is unreachable |\n| 9 | Answer refused: a Kenso sandbox run stopped because an answer held a credential or something shaped like one |\n| 130 | Interrupted. A batch run can be resumed: see its `next` |\n\nSkipped rows (duplicates, blocklisted, already contacted) are not failures: a batch with only created, updated and skipped rows exits 0.\n\n## Flags\n\n- Command flags go after the command: `kenso contacts import --campaign 812`. Global flags can go anywhere.\n- A boolean flag takes `--flag`, `--no-flag`, `--flag=true` and `--flag=false`.\n- A flag that carries a secret (`--password`, `--api-key`, `--api-secret`, any `--\u2026-token` or `--\u2026-secret`) also takes `-` (read stdin), `@file` (read the file) or `env:NAME` (read that environment variable), so the value stays out of shell history: `printf \'%s\' "$FATHOM_KEY" | kenso fathom-connection connect --api-key -`. A value typed on the command line still works and prints one warning. A typed secret that itself starts with `@` is written `@@` (`--password @@Spring2026` sends `@Spring2026`); one that is exactly `-` or starts with `env:` has to come through `@file` or `env:NAME`. `-` refuses a terminal, an empty value is refused, and only one flag can read stdin. `--dry-run` shows a secret as `***`. With `--each`, the plan, its `next` and the run record keep `@file` or `env:NAME` as typed and `kenso runs resume` reads it again; a secret from stdin is refused there.\n- `--help` on any command prints its flags, arguments and examples. `kenso describe <resource> <action>` prints the same as JSON, with the body schema.\n\n## Beta commands\n\nCommands that need a workspace feature flag (CRM, Studio and others) are beta. Help and `kenso describe` hide the ones your workspace has not enabled and say how many they hid; `--all-commands` shows them. Calling a hidden command still works: Kenso decides. `kenso <resource>` on a resource whose every action is hidden answers `feature_not_enabled` (exit 2) and names the flags it needs.\n\n```bash\nkenso --help --all-commands\nkenso describe --all-commands\n```\n\n## What the CLI sends\n\nEvery API call carries `Authorization: Bearer <key>`, `Ken-Version: 1.1`, `X-Ken-Workspace-Id` (when a workspace is picked), `User-Agent: kenso-cli/<version> (node <version>; <platform>)` and `X-Ken-Client: Kenso CLI`. When a coding agent runs the CLI, `X-Ken-Client` names it (`Kenso CLI via Claude Code`) and writes carry `X-Ken-Actor: agent`, so Kenso\'s activity log shows who made a change.\n';
|
|
8796
|
+
output_and_errors_default = '# Output and errors\n\nEvery command follows one contract, so a script or an agent can parse any of them the same way.\n\n## stdout and stderr\n\n- **stdout carries data only.** Progress, warnings, notices and errors go to stderr.\n- No colors, spinners or pagers. On a terminal you get readable tables; in a pipe you get JSON.\n- A batch command (an import, update, remove, tag or `--each` write) takes `--yes`; without it, the command plans or refuses.\n- A command that deletes, archives or removes, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive` or `kenso api DELETE /v1/tags/7`, needs `--yes` too. Without it, a person at a terminal is asked to confirm; anywhere else (a pipe, a script, CI, a coding agent) it sends nothing and fails with `confirmation_required`, whose `next` is the same command with `--yes`.\n- Any other single write, such as `kenso tags create` or a write through `kenso api` or `kenso mcp call`, sends at once: add `--dry-run` to print the request first (it sends nothing), then run the command without it.\n- A command with no dry run, such as `kenso contacts export`, `kenso auth logout` or `kenso workspace use`, refuses `--dry-run` with `usage_error` (exit 2) and does nothing. Its help ends with `No --dry-run`, and `kenso describe <resource> <action>` shows `"dryRun": false`.\n\n## Formats\n\n| What the command returns | stdout is a terminal | stdout is a pipe or file |\n|---|---|---|\n| One object | key-value lines | compact JSON on one line |\n| A list | a table (first 8 scalar fields, cells cut at 60 characters) | NDJSON: one JSON object per line |\n| A batch run | key-value lines | one JSON summary object |\n| No content (HTTP 204) | nothing | nothing |\n\n`-o` or `--output` picks the format: `json`, `ndjson`, `table` or `ids`. `--json` is the same as `-o json`.\n\n- `-o json` on a list prints one JSON array. On a terminal, `-o json` pretty-prints an object.\n- `-o ids` prints one id per line, ready for `--ids -`. Items without an `id` are skipped with one warning.\n\n```bash\nkenso campaigns list --limit 3\nkenso campaigns list --limit 3 -o json\nkenso contacts list --campaign-id 812 --all -o ids\n```\n\n## Shape the output\n\n- `--fields a,b.c` keeps only those fields (dots reach into nested objects).\n- `--query <JMESPath>` filters or reshapes in-process, so you need no `jq`. On a list it sees the whole list. There is no `--jq`: `--query` takes JMESPath, not jq syntax.\n- Neither applies to a batch summary, which always prints in full.\n- `threads list`, `contacts list` and `contacts search` print a short set of fields per row, in every format: a thread\'s id, channel, sender, subject, interest, read state, newest message time and preview, a contact\'s id, name, email, title, company and email validity, and a few more (the command\'s `--help` names them all). `--full` prints every field (`--full -o json` for a script that reads them all), `--fields` picks your own, and `--query` sees every field.\n\n```bash\nkenso campaigns list --fields id,name,status\nkenso campaigns list --all --query "[?status==\'active\'].id"\nkenso me get --query "length(features)"\nkenso threads list --folder inbox --full\n```\n\n## Lists and pages\n\nA list command prints one page. When there are more, it prints the command for the next page on stderr, for example `next: kenso tags list --limit 1 --cursor MQ`. `--all` follows every page and streams the items. `--limit` sets the page size and `--cursor` starts at a cursor.\n\n`accounts search`, `contacts search` and `people search` page the same way: one page with the `next:` command, or every page with `--all`. A search that asks for counts (`countBy` in `--data`) prints the whole answer instead: `data`, `pagination` and `counts`. Counts cover every match whatever the page, so ask for them on one page (`--limit 1`): `--all` with `countBy` is a usage error.\n\n```bash\nkenso tags list --limit 50\nkenso tags list --all\n```\n\n## Files: uploads and downloads\n\nA command whose API action takes a multipart upload takes `--file <path>`: the CLI reads the file and sends it in the form, with a content type from its extension (a `.png` goes as `image/png`), and the other flags as form fields. `--file <field>=<path>` names the form field, for a form with more than one file. An upload that also takes JSON, such as a logo from a URL instead of a file, sends JSON when you leave `--file` out.\n\nA command whose API action answers with a file (a CSV, an image, a ZIP) takes `--out <path>`: it saves the answer byte for byte (mode 0600) and prints `out`, `bytes` and `contentType`, so the file never passes through an agent\'s context. Without `--out`, a CSV prints as it came, and a binary file goes to stdout only when stdout is a pipe or a file: on a terminal it fails with `binary_output`, whose `next` adds `--out`.\n\n`kenso api` takes both, for any route: `--file` (repeat it for more files) sends multipart with the keys of a `--data` object as form fields, and `--out` saves any answer.\n\n```bash\nkenso saved-lists create-upload --saved-list-id 12 --file people.csv\nkenso workspaces replace-logo --workspace-id 42 --file ./logo.png\nkenso workspaces replace-logo --workspace-id 42 --source-url https://example.com/logo.png\nkenso attachments get-content --attachment-id att_123 --out ./invoice.pdf\nkenso api POST /v1/campaigns/812/email-sequence/images --file ./hero.png\nkenso api GET /v1/knowledge/exports/77/content --out knowledge.zip\n```\n\n## Live streams\n\n`kenso sync events` and `kenso onboarding-builds events` follow a live stream of server-sent events. They print one JSON line per event as it arrives, on a terminal too, with the event\'s name, its id when it has one, and its data:\n\n```json\n{"event":"hello","data":{"buildId":"obd_2x","status":"building","stage":"read","lastEventId":0}}\n{"event":"stage","id":"41","data":{"stage":"plan"}}\n{"event":"done","id":"42","data":{}}\n```\n\nA stream has no time limit while events arrive. The server ends each connection after 15 minutes with a `bye` event; the command then connects again at once, and after a dropped connection or 60 s without even a keepalive, after a second. A connection that brought nothing but `hello` and `bye` (a server that is restarting) backs off 1, 2, 4 ... 30 s. Once events carry an id (`onboarding-builds events`), it sends the last whole event\'s id as `Last-Event-ID`, so no event is lost or printed twice. A refusal (401, 403, 404) ends it at once; eight failed or empty connects in a row end it with the last error.\n\nIt runs until Ctrl-C (exit 130; every line printed is whole), or until one of these:\n\n| Flag | Ends the command |\n|---|---|\n| `--until <event>` | After the first event with that name; several names are comma-separated: `--until done,error` |\n| `--max-events <n>` | After n events, `hello` and `bye` included |\n| `--once` | When the server closes the connection, instead of connecting again |\n\n```bash\nkenso onboarding-builds events --build-id obd_2x --until done,error\nkenso sync events --max-events 2 # hello, then the first poke\n```\n\n`--output`, `--fields` and `--query` do not apply to a stream. `--last-event-id` starts an onboarding build stream after that id.\n\n## Errors\n\nWhen stderr is not a terminal, an error is one JSON line on stderr:\n\n```json\n{"error":{"code":"unknown_flag","message":"Unknown flag --fiel for kenso contacts import.","field":"fiel","hint":"did you mean --file?","next":"kenso contacts import --help"}}\n```\n\n| Key | Always there | Meaning |\n|---|---|---|\n| `code` | yes | A stable snake_case code to branch on |\n| `message` | yes | One sentence for a person |\n| `field` | no | The flag or input field at fault |\n| `hint` | no | What to change |\n| `next` | no | The exact command to run next, such as `kenso auth login`, `kenso workspace list --search <name>` or the same command with `--yes` |\n| `httpStatus` | no | The API\'s HTTP status, when the API answered |\n| `requestId` | no | The API\'s request id: quote it when you contact Kenso support |\n\nOn a terminal the same error prints as text: `Error: <message>`, then `field:`, `hint:`, `next:` and `requestId:` lines. The key never appears in an error.\n\n### How API errors map\n\nThe CLI looks at the HTTP status first, then at the API\'s own `error.code`, which wins when present.\n\n| HTTP status | Default code | Exit |\n|---|---|---|\n| 400, 422 | `validation_failed` | 2 |\n| 401 | `unauthorized` (`next`: `kenso auth login`) | 3 |\n| 403 | `forbidden`: the key\'s user or role cannot do this in this workspace | 3 |\n| 404 | `not_found` | 4 |\n| 409 | `conflict` | 7 |\n| 429 | `rate_limited`, after the CLI waited and retried | 6 |\n| 5xx | `server_error`, after retries where they are safe | 8 |\n| anything else | `http_error` | 1 |\n\nTwo API codes change the exit code: `workspace_required` exits 2 with `"next":"kenso workspace list --search <name>"`, and `limit_reached` (the plan\'s or the campaign\'s lead limit) exits 6.\n\n### Errors from the CLI itself\n\n| Code | Exit | When |\n|---|---|---|\n| `usage_error` | 2 | A required flag or argument is missing, two flags conflict (`--yes` with `--dry-run`), or `--dry-run` on a command that has no dry run |\n| `unknown_command` | 2 | No such command; `hint` suggests the closest one |\n| `unknown_flag`, `invalid_flag`, `invalid_flag_value`, `unexpected_argument` | 2 | A flag or argument the command does not take |\n| `invalid_query` | 2 | `--query` is not valid JMESPath |\n| `confirmation_required` | 2 | A delete, archive or remove ran without `--yes` where nobody can confirm: nothing was sent; `next` adds `--yes` |\n| `cancelled` | 2 | A person answered no to the confirmation: nothing was sent |\n| `file_unreadable` | 2 | An input file is missing, is a folder, cannot be opened, or cannot be parsed; the message names the line, such as `leads.csv line 3: a quote is not closed.` |\n| `config_invalid` | 2 | `~/.kenso/config.json` is not valid JSON: fix or delete it |\n| `feature_not_enabled` | 2 | Every action of the resource is a beta command your workspace has not enabled |\n| `invalid_key_format`, `key_required` | 2 | `auth login --with-key` read something that is not a Kenso key, or stdin is a terminal instead of a pipe |\n| `invalid_workspace_id` | 2 | `kenso workspace use` got an id that is not a positive whole number |\n| `unknown_topic` | 2 | `kenso docs` got a topic it does not have; `hint` lists the topics |\n| `file_unwritable` | 2 or 1 | An output file cannot be written: `--out` on `contacts export`, `kenso api` or a download command (2), `skill install` (1) |\n| `binary_output` | 2 | The answer is a binary file and stdout is a terminal: nothing was printed; `next` saves it with `--out` |\n| `no_api_key` | 3 | No key in `KENSO_API_KEY` or the profile (`next`: `kenso auth login`) |\n| `browser_login_unavailable`, `access_denied`, `login_expired` | 3 | Browser login is off, was denied, or timed out |\n| `run_not_found` | 4 | `kenso runs show` or `resume` got an unknown run id |\n| `docs_not_found` | 4 | `kenso docs reference` before the reference was generated (a source checkout without `pnpm build`) |\n| `run_in_progress`, `already_filled` | 7 | Another process is working on the run, or `studio fill` already ran with this file and these flags |\n| `skill_exists` | 7 | `kenso skill install` found a different `SKILL.md`; `next` adds `--force` to replace it |\n| `local_changes` | 7 | `studio pull` would replace files that no earlier pull wrote or push sent, or that changed since; nothing was written, and `next` adds `--force` to replace them |\n| `job_timeout`, `job_failed`, `job_canceled` | 1 | `kenso jobs wait` (or a command that waits on a job) ran out of time, or the job failed or was canceled |\n| `mcp_tool_error` | 1 | `kenso mcp call`: the MCP tool answered with an error |\n| `unsafe_path` | 1 | `studio pull` refused a file path that would land outside `--dir`, starts a file or folder name with a dot, or passes through a symbolic link |\n| `network_error` | 8 | The API could not be reached after retries |\n| `upload_failed`, `download_failed` | 8 or 1 | A signed upload or download of a Studio file failed: 8 when storage was unreachable or answered 5xx, 1 on a 4xx (often an expired link: run the command again) |\n| `pull_incomplete` | 8 | `studio pull`: a file came back with neither text nor a download link |\n| `unexpected_response` | 1 or 8 | The API answered something the CLI could not read |\n| `unexpected_error` | 1 | A bug: run again with `--verbose` and report it |\n| `interrupted` | 130 | Ctrl-C |\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | OK, including a batch where every row succeeded or was skipped |\n| 1 | Unexpected error |\n| 2 | Usage or input error: a bad flag, a bad file, a validation error |\n| 3 | Auth: no key, an invalid, revoked or expired key, or HTTP 401 or 403 |\n| 4 | Not found |\n| 5 | Partial: the batch finished and some rows failed, were not found or were invalid. See `results.csv` |\n| 6 | Rate limited after retries, or a plan or campaign lead limit stopped the run (`limit_reached`) |\n| 7 | Conflict or invalid state (HTTP 409), or a run another process holds |\n| 8 | Server error after retries (5xx), or the API is unreachable |\n| 9 | Answer refused: a Kenso sandbox run stopped because an answer held a credential or something shaped like one |\n| 130 | Interrupted. A batch run can be resumed: see its `next` |\n\nSkipped rows (duplicates, blocklisted, already contacted) are not failures: a batch with only created, updated and skipped rows exits 0.\n\n## Flags\n\n- Command flags go after the command: `kenso contacts import --campaign 812`. Global flags can go anywhere.\n- A boolean flag takes `--flag`, `--no-flag`, `--flag=true` and `--flag=false`.\n- A flag that carries a secret (`--password`, `--api-key`, `--api-secret`, any `--\u2026-token` or `--\u2026-secret`) also takes `-` (read stdin), `@file` (read the file) or `env:NAME` (read that environment variable), so the value stays out of shell history: `printf \'%s\' "$FATHOM_KEY" | kenso fathom-connection connect --api-key -`. A value typed on the command line still works and prints one warning. A typed secret that itself starts with `@` is written `@@` (`--password @@Spring2026` sends `@Spring2026`); one that is exactly `-` or starts with `env:` has to come through `@file` or `env:NAME`. `-` refuses a terminal, an empty value is refused, and only one flag can read stdin. `--dry-run` shows a secret as `***`. With `--each`, the plan, its `next` and the run record keep `@file` or `env:NAME` as typed and `kenso runs resume` reads it again; a secret from stdin is refused there.\n- `--help` on any command prints its flags, arguments and examples. `kenso describe <resource> <action>` prints the same as JSON, with the body schema.\n\n## Beta commands\n\nCommands that need a workspace feature flag (CRM, Studio and others) are beta. Help and `kenso describe` hide the ones your workspace has not enabled and say how many they hid; `--all-commands` shows them. Calling a hidden command still works: Kenso decides. `kenso <resource>` on a resource whose every action is hidden answers `feature_not_enabled` (exit 2) and names the flags it needs.\n\n```bash\nkenso --help --all-commands\nkenso describe --all-commands\n```\n\n## What the CLI sends\n\nEvery API call carries `Authorization: Bearer <key>`, `Ken-Version: 1.1`, `X-Ken-Workspace-Id` (when a workspace is picked), `User-Agent: kenso-cli/<version> (node <version>; <platform>)` and `X-Ken-Client: Kenso CLI`. When a coding agent runs the CLI, `X-Ken-Client` names it (`Kenso CLI via Claude Code`) and writes carry `X-Ken-Actor: agent`, so Kenso\'s activity log shows who made a change.\n';
|
|
8797
8797
|
}
|
|
8798
8798
|
});
|
|
8799
8799
|
|
|
@@ -8817,7 +8817,7 @@ var init_sandbox = __esm({
|
|
|
8817
8817
|
var studio_default;
|
|
8818
8818
|
var init_studio = __esm({
|
|
8819
8819
|
"docs/studio.md"() {
|
|
8820
|
-
studio_default = "# Studio (beta)\n\nStudio templates are the pages, docs and other assets Kenso builds for each account or lead. The `kenso studio` commands let you edit a template as a folder of files on your machine, check it, preview it, and fill it for many accounts or leads at once. They are beta: they need the `studio` feature flag on your workspace. Help and `kenso describe` hide them until your workspace has it; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `studio pull <templateId> --dir <dir>` | Write a template version's files to a folder |\n| `studio push <templateId> --dir <dir>` | Save the folder's files to the template's draft and print the validation |\n| `studio validate <templateId> --dir <dir>` | Validate the folder against the template without saving |\n| `studio preview <templateId>` | Render a version for up to 3 accounts and print the preview links |\n| `studio fill <templateId>` | Fill the template for many accounts or campaign leads, estimate first |\n\nFind template ids with the generated commands:\n\n```bash\nkenso asset-templates list\n```\n\n## Edit a template locally\n\n```bash\nkenso studio pull 12 --dir ./my-template\nkenso studio validate 12 --dir ./my-template\nkenso studio push 12 --dir ./my-template\nkenso studio preview 12 --dir ./my-template --account-ids 501,502\nkenso studio push 12 --dir ./my-template --publish\n```\n\n### pull\n\n`pull` writes every file of the version under `--dir`: text files from the answer, binaries downloaded from signed links and checked against their SHA-256. It
|
|
8820
|
+
studio_default = "# Studio (beta)\n\nStudio templates are the pages, docs and other assets Kenso builds for each account or lead. The `kenso studio` commands let you edit a template as a folder of files on your machine, check it, preview it, and fill it for many accounts or leads at once. They are beta: they need the `studio` feature flag on your workspace. Help and `kenso describe` hide them until your workspace has it; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `studio pull <templateId> --dir <dir>` | Write a template version's files to a folder |\n| `studio push <templateId> --dir <dir>` | Save the folder's files to the template's draft and print the validation |\n| `studio validate <templateId> --dir <dir>` | Validate the folder against the template without saving |\n| `studio preview <templateId>` | Render a version for up to 3 accounts and print the preview links |\n| `studio fill <templateId>` | Fill the template for many accounts or campaign leads, estimate first |\n\nFind template ids with the generated commands:\n\n```bash\nkenso asset-templates list\n```\n\n## Edit a template locally\n\n```bash\nkenso studio pull 12 --dir ./my-template\nkenso studio validate 12 --dir ./my-template\nkenso studio push 12 --dir ./my-template\nkenso studio preview 12 --dir ./my-template --account-ids 501,502\nkenso studio push 12 --dir ./my-template --publish\n```\n\n### pull\n\n`pull` writes every file of the version under `--dir`: text files from the answer, binaries downloaded from signed links and checked against their SHA-256. It leaves other files in the folder alone. It checks every path before it writes anything, and refuses (`unsafe_path`) one that would land outside `--dir`, one with a file or folder name that starts with a dot (such as `.claude/` or `.mcp.json`, which editors and coding agents read as their own settings), and one that passes through a symbolic link.\n\n`pull` replaces a file that is already there only when an earlier pull wrote it or a push sent it and nobody changed it since, or when it already holds the new content. `.kenso-pull.json` at the top of the folder records what pulls wrote and pushes sent; push skips it like any dotfile. So pull, edit, push and pull again works as before, and a teammate's change replaces the files you did not change since your last pull or push. A file you added or changed and did not push stops the pull before anything is written: `local_changes` (exit 7) lists them. Move them away or compare them with the template, or add `--force` to replace them with the template's version. The first pull into a folder that an older version of the CLI pulled into may ask for `--force` once, for files that changed in the template since.\n\n`--template-version` picks the version: `draft`, `latest` (the latest published) or a version id. The default is the draft, else the latest published version. (The flag is not `--version`: after a command, `--version` fails with `unknown_flag` and points at `--template-version`.)\n\n```bash\nkenso studio pull 12 --dir ./v3 --template-version 345\nkenso studio pull 12 --dir ./my-template --dry-run\n```\n\nIt prints `{templateId, versionId, files, dir}`, plus `replaced` when `--force` replaced files. `--dry-run` lists the paths, and as `conflicts` the files it would not replace without `--force`, and writes nothing.\n\n### push\n\n`push` reads `--dir`, skipping dotfiles, dot folders, `node_modules`, and Markdown files other than `README.md`, `brief.md` and `ideas.md` at the top of the folder (Studio stores no other `.md`, so a coding agent's `CLAUDE.md` or `AGENTS.md` in the folder stays local).\n\n- A text file (valid UTF-8, no NUL byte, under 1 MB) goes inline.\n- Any other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. A larger file is refused before any call.\n- One push then saves the files into the draft and prints `{templateId, versionId, versionNumber, validation, changed, deleted}`.\n\nFiles that are in the draft but not in the folder stay, unless you pass `--delete-missing`. `--message` describes the change (default \"Pushed with the Kenso CLI\"). With `--publish`, the new version is published when validation passes, and the output adds `published`.\n\n```bash\nkenso studio push 12 --dir ./my-template --message \"New hero copy\"\nkenso studio push 12 --dir ./my-template --delete-missing --publish\nkenso studio push 12 --dir ./my-template --dry-run\n```\n\nWhen validation finds errors, the draft is still saved: the result prints, then the error `validation_failed` (exit 2) with the first problem as its `hint`. When publishing fails after a good push, the push result still prints and the error says which version was saved. `--dry-run` lists what would be sent and calls nothing.\n\n### validate\n\n`validate` reads the folder the same way and checks the files laid over the draft, as a push would, without saving them. Binaries are uploaded so they can be checked. `--delete-missing` validates exactly the folder's files. It prints the validation and exits 2 when there are errors.\n\n### preview\n\n`preview` renders a saved version, not your local files: the draft, else the latest published version, or `--version-id`. It takes up to a minute per account.\n\n```bash\nkenso studio preview 12\nkenso studio preview 12 --account-ids 501,502,503 --mode render\nkenso studio preview 12 --sample samples/acme.json\nkenso studio preview 12 --mode interact --interact @steps.json\n```\n\n- `--account-ids` takes up to 3 ids. Without it, Kenso picks the 3 most recently touched accounts, else the template's samples.\n- `--mode` is `render` (default) or `interact`. `--interact` takes the click, type and wait steps as JSON, `@file` or `-` (up to 20).\n- With `--dir`, the CLI compares your folder to the version it renders and warns on stderr when they differ, naming the push command to run first.\n\nThe output lists each preview's link, screenshots, console errors and link issues.\n\n## Fill a template for many accounts or leads\n\n`fill` creates pages for a list of accounts, or for the leads of a campaign. A fill is charged per page, so it always prices the work first.\n\n```bash\nkenso studio fill 12 --accounts accounts.txt\nkenso studio fill 12 --accounts accounts.csv --column accountId --yes --wait\nkenso studio fill 12 --campaign 345 --contacts leads.csv --yes\n```\n\n- **Ids** come from `--accounts <file>`, or from `--contacts <file>` with `--campaign <id>`; `-` reads stdin. A file holds one id per line, or a CSV or JSONL with an id column (`--column`, else `id`, else `contactId`). Repeated ids are filled once.\n- **Without `--yes`** (or with `--estimate`) it prints the estimate and the apply command, and creates nothing. For a campaign, the estimate counts one page per lead; Kenso builds one page per company, so it is an upper bound.\n- **With `--yes`** it creates one fill run per 500 ids, one after another.\n- **With `--wait`** it follows each run every 5 seconds until it completes, fails or is cancelled. Without it, follow a run with `kenso asset-runs get --run-id <id>`.\n\nThe summary lists `runs: [{runId, state, rows}]`, and `results.csv` has one line per id with its page id and state.\n\n**The same fill never runs twice.** Rebuilding a page charges again, so when you rerun a fill with the same file (the same bytes) and the same flags:\n\n- an unfinished fill continues where it stopped;\n- a finished fill where every id succeeded answers from that run and changes nothing;\n- anything else is refused with `already_filled` (exit 7). To retry only the ids that failed, take them from the earlier run's `results.csv` into a new file and fill that file.\n\nThe guard compares the file and the flags, not the ids: the same ids in another file, or in another order, are filled and charged again. Keep one ids file per fill, and check `kenso runs list` before you fill ids from a new file.\n\n## Other Studio commands\n\nEverything else (create a template, list versions, restore a version, datasets, publish) is a generated command under `asset-templates`, `asset-runs` and `asset-template-datasets`:\n\n```bash\nkenso asset-templates --help --all-commands\nkenso describe asset-templates\n```\n";
|
|
8821
8821
|
}
|
|
8822
8822
|
});
|
|
8823
8823
|
|
|
@@ -13234,7 +13234,49 @@ function recordCount(csv) {
|
|
|
13234
13234
|
}
|
|
13235
13235
|
return hasText ? records + 1 : records;
|
|
13236
13236
|
}
|
|
13237
|
-
|
|
13237
|
+
async function ownAccountView(ctx, id) {
|
|
13238
|
+
try {
|
|
13239
|
+
const listed = await ctx.client.request({ method: "GET", path: "/v1/account-views", signal: ctx.signal });
|
|
13240
|
+
return (unwrap(listed.body) ?? []).find((v) => v.id === id);
|
|
13241
|
+
} catch (err) {
|
|
13242
|
+
if (err instanceof KensoError && err.httpStatus === 404) return void 0;
|
|
13243
|
+
throw err;
|
|
13244
|
+
}
|
|
13245
|
+
}
|
|
13246
|
+
async function viewBody(ctx, id, object) {
|
|
13247
|
+
let res;
|
|
13248
|
+
try {
|
|
13249
|
+
res = await ctx.client.request({ method: "GET", path: `/v1/views/${id}`, signal: ctx.signal });
|
|
13250
|
+
} catch (err) {
|
|
13251
|
+
if (!(err instanceof KensoError) || err.httpStatus !== 404) throw err;
|
|
13252
|
+
const own = object.resource === "accounts" ? await ownAccountView(ctx, id) : void 0;
|
|
13253
|
+
if (own) {
|
|
13254
|
+
if (own.filters && own.filters.length > 0) return { filters: own.filters };
|
|
13255
|
+
if (own.isDefault) return {};
|
|
13256
|
+
throw usageError(`View ${id} lists no conditions on this workspace, so the CLI cannot tell what it selects.`, {
|
|
13257
|
+
field: "view",
|
|
13258
|
+
hint: "Leave --view out to export every account, or pass the selection with --where or --filters."
|
|
13259
|
+
});
|
|
13260
|
+
}
|
|
13261
|
+
throw usageError(`No saved view has id ${id}.`, {
|
|
13262
|
+
field: "view",
|
|
13263
|
+
hint: `List them with kenso views list --object ${object.viewObject}. A private view shows only to its maker.`
|
|
13264
|
+
});
|
|
13265
|
+
}
|
|
13266
|
+
const view = unwrap(res.body);
|
|
13267
|
+
if (view?.object !== object.viewObject) {
|
|
13268
|
+
const other = VIEW_EXPORTS[view?.object ?? ""];
|
|
13269
|
+
throw usageError(`View ${id} is not a saved ${object.noun} view.`, {
|
|
13270
|
+
field: "view",
|
|
13271
|
+
...other ? { next: `kenso export ${other} --view ${id}` } : {}
|
|
13272
|
+
});
|
|
13273
|
+
}
|
|
13274
|
+
const filter = view.filter;
|
|
13275
|
+
const body2 = filter && typeof filter === "object" && !Array.isArray(filter) ? { ...filter } : {};
|
|
13276
|
+
if (typeof view.sort === "string" && view.sort.trim() !== "") body2.sort = view.sort;
|
|
13277
|
+
return body2;
|
|
13278
|
+
}
|
|
13279
|
+
var OBJECTS, VIEW_EXPORTS, command27, export_default2;
|
|
13238
13280
|
var init_export2 = __esm({
|
|
13239
13281
|
"src/commands/export/export.ts"() {
|
|
13240
13282
|
"use strict";
|
|
@@ -13244,19 +13286,20 @@ var init_export2 = __esm({
|
|
|
13244
13286
|
init_transfer();
|
|
13245
13287
|
init_columns();
|
|
13246
13288
|
OBJECTS = {
|
|
13247
|
-
accounts: { resource: "accounts", noun: "accounts" },
|
|
13248
|
-
people: { resource: "people", noun: "people" },
|
|
13249
|
-
deals: { resource: "opportunities", noun: "deals" },
|
|
13250
|
-
opportunities: { resource: "opportunities", noun: "deals" }
|
|
13289
|
+
accounts: { resource: "accounts", noun: "accounts", viewObject: "account" },
|
|
13290
|
+
people: { resource: "people", noun: "people", viewObject: "person" },
|
|
13291
|
+
deals: { resource: "opportunities", noun: "deals", viewObject: "opportunity" },
|
|
13292
|
+
opportunities: { resource: "opportunities", noun: "deals", viewObject: "opportunity" }
|
|
13251
13293
|
};
|
|
13294
|
+
VIEW_EXPORTS = { account: "accounts", person: "people", opportunity: "deals" };
|
|
13252
13295
|
command27 = {
|
|
13253
13296
|
resource: "export",
|
|
13254
13297
|
action: "",
|
|
13255
13298
|
summary: "Export accounts, people or deals as CSV: everything, a saved view, or what the filters match",
|
|
13256
13299
|
brief: "<accounts|people|deals> [--view <id>] [--out <file>]",
|
|
13257
|
-
description: "Writes the CSV that POST /v1/accounts/export, /v1/people/export or /v1/opportunities/export returns, to stdout or to --out. With no filter it exports every record; more than 50,000 rows is refused (narrow the filters). --view exports a saved
|
|
13300
|
+
description: "Writes the CSV that POST /v1/accounts/export, /v1/people/export or /v1/opportunities/export returns, to stdout or to --out. With no filter it exports every record; more than 50,000 rows is refused (narrow the filters). --view exports a saved view of that object, yours or a shared one: the whole filter and the sort GET /v1/views/{viewId} answers, so the file holds the rows the view lists. --filters, --where (accounts), --q and --sort are the search operation's own fields; given with --view, each replaces that key of the view's. The accounts and deals files start with id and import back as they are. Each export writes an audit-log entry. Needs the export permission.",
|
|
13258
13301
|
flags: {
|
|
13259
|
-
view: { type: "string", description: "A saved
|
|
13302
|
+
view: { type: "string", description: "A saved view's id (kenso views list): export what that view lists, in its sort" },
|
|
13260
13303
|
filters: { type: "string", description: `Filter conditions as JSON, e.g. '[{"field":"stage","operator":"is","values":["engaged"]}]'` },
|
|
13261
13304
|
where: { type: "string", description: "Accounts only: a condition group as JSON, as accounts search takes it" },
|
|
13262
13305
|
q: { type: "string", description: "Text to match, as the list's search box does" },
|
|
@@ -13267,31 +13310,23 @@ var init_export2 = __esm({
|
|
|
13267
13310
|
examples: [
|
|
13268
13311
|
"kenso export accounts --out accounts.csv",
|
|
13269
13312
|
"kenso export accounts --view 12 --out tier-1.csv",
|
|
13313
|
+
"kenso export deals --view 40 --out pipeline.csv",
|
|
13270
13314
|
`kenso export deals --filters '[{"field":"stageCategory","operator":"is","values":["open"]}]' > open-deals.csv`
|
|
13271
13315
|
],
|
|
13272
13316
|
beta: { featureGates: { all: ["accounts"] } },
|
|
13273
|
-
operationIds: ["accounts.export", "people.export", "opportunities.export", "account-views.list"],
|
|
13317
|
+
operationIds: ["accounts.export", "people.export", "opportunities.export", "views.get", "account-views.list"],
|
|
13274
13318
|
async run(ctx, { flags, positionals }) {
|
|
13275
13319
|
const typed = (positionals[0] ?? "").trim().toLowerCase();
|
|
13276
13320
|
const object = OBJECTS[typed];
|
|
13277
13321
|
if (!object) {
|
|
13278
13322
|
throw usageError(`Export takes accounts, people or deals (got "${typed}").`, { field: "object", next: "kenso export accounts" });
|
|
13279
13323
|
}
|
|
13280
|
-
|
|
13324
|
+
let body2 = {};
|
|
13281
13325
|
const view = stringFlag(flags.view);
|
|
13282
13326
|
if (view !== void 0) {
|
|
13283
|
-
if (object.resource !== "accounts") {
|
|
13284
|
-
throw usageError("--view exports a saved Accounts view. For people and deals, pass the view's --filters and --sort.", { field: "view" });
|
|
13285
|
-
}
|
|
13286
13327
|
const id = /^\d+$/.test(view.trim()) ? Number(view.trim()) : Number.NaN;
|
|
13287
13328
|
if (!Number.isSafeInteger(id) || id < 1) throw usageError(`--view must be a view id (got "${view}").`, { field: "view" });
|
|
13288
|
-
|
|
13289
|
-
const views = unwrap(listed.body);
|
|
13290
|
-
const found = (views ?? []).find((v) => v.id === id);
|
|
13291
|
-
if (!found) {
|
|
13292
|
-
throw usageError(`No saved Accounts view has id ${id}.`, { field: "view", hint: "List yours with kenso account-views list." });
|
|
13293
|
-
}
|
|
13294
|
-
if (found.filters && found.filters.length > 0) body2.filters = found.filters;
|
|
13329
|
+
body2 = await viewBody(ctx, id, object);
|
|
13295
13330
|
}
|
|
13296
13331
|
const filters = jsonFlag(flags, "filters", "array");
|
|
13297
13332
|
if (filters !== void 0) body2.filters = filters;
|
|
@@ -15528,7 +15563,8 @@ var init_common3 = __esm({
|
|
|
15528
15563
|
});
|
|
15529
15564
|
|
|
15530
15565
|
// src/commands/studio/folder.ts
|
|
15531
|
-
import {
|
|
15566
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
15567
|
+
import { lstat, readdir as readdir2, readFile as readFile11, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
|
|
15532
15568
|
import { extname as extname6, isAbsolute, join as join15, relative, resolve as resolve11, sep } from "node:path";
|
|
15533
15569
|
function textOf2(bytes) {
|
|
15534
15570
|
if (bytes.length >= TEXT_MAX_BYTES || bytes.includes(0)) return void 0;
|
|
@@ -15554,6 +15590,7 @@ async function readFolder(dir2) {
|
|
|
15554
15590
|
const abs = join15(folder, entry.name);
|
|
15555
15591
|
if (entry.isDirectory()) await walk(abs);
|
|
15556
15592
|
else if (entry.isFile()) {
|
|
15593
|
+
if (extname6(entry.name).toLowerCase() === ".md" && !(folder === root2 && TEMPLATE_MARKDOWN.has(entry.name))) continue;
|
|
15557
15594
|
const bytes = await readFile11(abs);
|
|
15558
15595
|
files.push({ path: relative(root2, abs).split(sep).join("/"), bytes, text: textOf2(bytes) });
|
|
15559
15596
|
}
|
|
@@ -15564,18 +15601,52 @@ async function readFolder(dir2) {
|
|
|
15564
15601
|
}
|
|
15565
15602
|
function safeJoin(root2, bundlePath) {
|
|
15566
15603
|
const segments = bundlePath.split("/");
|
|
15567
|
-
const bad = bundlePath === "" || isAbsolute(bundlePath) || /^[A-Za-z]:/.test(bundlePath) || bundlePath.includes("\\") || bundlePath.includes("\0") || segments.some((s) => s === "" || s
|
|
15604
|
+
const bad = bundlePath === "" || isAbsolute(bundlePath) || /^[A-Za-z]:/.test(bundlePath) || bundlePath.includes("\\") || bundlePath.includes("\0") || segments.some((s) => s === "" || s.startsWith("."));
|
|
15568
15605
|
const target2 = resolve11(root2, ...segments);
|
|
15569
15606
|
if (bad || !target2.startsWith(root2.endsWith(sep) ? root2 : root2 + sep)) {
|
|
15570
|
-
throw
|
|
15571
|
-
code: "unsafe_path",
|
|
15572
|
-
message: `Refusing to write "${bundlePath}": it is not a plain relative path inside ${root2}.`,
|
|
15573
|
-
exitCode: ExitCode.Error,
|
|
15574
|
-
hint: "The template holds a file path the CLI will not write. Nothing was written."
|
|
15575
|
-
});
|
|
15607
|
+
throw unsafePath(bundlePath, `it is not a plain relative path inside ${root2}`);
|
|
15576
15608
|
}
|
|
15577
15609
|
return target2;
|
|
15578
15610
|
}
|
|
15611
|
+
async function existingFileNoLinks(root2, target2, bundlePath) {
|
|
15612
|
+
const parts2 = relative(root2, target2).split(sep);
|
|
15613
|
+
let at = root2;
|
|
15614
|
+
for (const [i, part] of parts2.entries()) {
|
|
15615
|
+
at = join15(at, part);
|
|
15616
|
+
const info = await lstat(at).catch(() => void 0);
|
|
15617
|
+
if (!info) return false;
|
|
15618
|
+
if (info.isSymbolicLink()) throw unsafePath(bundlePath, `${at} is a symbolic link`);
|
|
15619
|
+
if (i === parts2.length - 1) {
|
|
15620
|
+
if (!info.isFile()) throw unsafePath(bundlePath, `${at} exists and is not a file`);
|
|
15621
|
+
return true;
|
|
15622
|
+
}
|
|
15623
|
+
}
|
|
15624
|
+
return false;
|
|
15625
|
+
}
|
|
15626
|
+
async function readPullState(root2) {
|
|
15627
|
+
try {
|
|
15628
|
+
const files = JSON.parse(await readFile11(join15(root2, PULL_STATE), "utf8"))?.files;
|
|
15629
|
+
if (typeof files !== "object" || files === null) return {};
|
|
15630
|
+
return Object.fromEntries(Object.entries(files).filter((entry) => typeof entry[1] === "string"));
|
|
15631
|
+
} catch {
|
|
15632
|
+
return {};
|
|
15633
|
+
}
|
|
15634
|
+
}
|
|
15635
|
+
async function recordPullState(root2, entries2) {
|
|
15636
|
+
const path = join15(root2, PULL_STATE);
|
|
15637
|
+
await existingFileNoLinks(root2, path, PULL_STATE);
|
|
15638
|
+
const files = { ...await readPullState(root2), ...Object.fromEntries(entries2) };
|
|
15639
|
+
await writeFile4(path, `${JSON.stringify({ files }, null, 2)}
|
|
15640
|
+
`);
|
|
15641
|
+
}
|
|
15642
|
+
function unsafePath(bundlePath, why) {
|
|
15643
|
+
return new KensoError({
|
|
15644
|
+
code: "unsafe_path",
|
|
15645
|
+
message: `Refusing to write "${bundlePath}": ${why}.`,
|
|
15646
|
+
exitCode: ExitCode.Error,
|
|
15647
|
+
hint: "The template holds a file path the CLI will not write, or the folder has a link or folder in its way. Nothing was written."
|
|
15648
|
+
});
|
|
15649
|
+
}
|
|
15579
15650
|
function contentTypeOf(path) {
|
|
15580
15651
|
return CONTENT_TYPES2[extname6(path).toLowerCase()] ?? "application/octet-stream";
|
|
15581
15652
|
}
|
|
@@ -15597,7 +15668,7 @@ async function mapLimit(items, limit, fn) {
|
|
|
15597
15668
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
15598
15669
|
return out;
|
|
15599
15670
|
}
|
|
15600
|
-
var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8, CONTENT_TYPES2;
|
|
15671
|
+
var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8, TEMPLATE_MARKDOWN, PULL_STATE, sha2562, CONTENT_TYPES2;
|
|
15601
15672
|
var init_folder = __esm({
|
|
15602
15673
|
"src/commands/studio/folder.ts"() {
|
|
15603
15674
|
"use strict";
|
|
@@ -15606,6 +15677,9 @@ var init_folder = __esm({
|
|
|
15606
15677
|
TEXT_MAX_BYTES = 1024 * 1024;
|
|
15607
15678
|
UPLOAD_MAX_BYTES = 5 * 1024 * 1024;
|
|
15608
15679
|
utf8 = new TextDecoder("utf-8", { fatal: true });
|
|
15680
|
+
TEMPLATE_MARKDOWN = /* @__PURE__ */ new Set(["README.md", "brief.md", "ideas.md"]);
|
|
15681
|
+
PULL_STATE = ".kenso-pull.json";
|
|
15682
|
+
sha2562 = (bytes) => createHash6("sha256").update(bytes).digest("hex");
|
|
15609
15683
|
CONTENT_TYPES2 = {
|
|
15610
15684
|
".png": "image/png",
|
|
15611
15685
|
".jpg": "image/jpeg",
|
|
@@ -15630,7 +15704,7 @@ var init_folder = __esm({
|
|
|
15630
15704
|
});
|
|
15631
15705
|
|
|
15632
15706
|
// src/commands/studio/transfer.ts
|
|
15633
|
-
import { createHash as
|
|
15707
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
15634
15708
|
function interrupted6() {
|
|
15635
15709
|
return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
15636
15710
|
}
|
|
@@ -15696,10 +15770,10 @@ async function bundleFiles(ctx, templateId, files) {
|
|
|
15696
15770
|
}
|
|
15697
15771
|
return out;
|
|
15698
15772
|
}
|
|
15699
|
-
async function download2(url, path,
|
|
15773
|
+
async function download2(url, path, sha2564, signal) {
|
|
15700
15774
|
const res = await presigned(url, { method: "GET" }, `Downloading ${path}`, "download_failed", signal);
|
|
15701
15775
|
const bytes = Buffer.from(await res.arrayBuffer());
|
|
15702
|
-
if (
|
|
15776
|
+
if (sha2564 && createHash7("sha256").update(bytes).digest("hex") !== sha2564.toLowerCase()) {
|
|
15703
15777
|
throw new KensoError({
|
|
15704
15778
|
code: "download_failed",
|
|
15705
15779
|
message: `${path} did not download intact (its SHA-256 does not match).`,
|
|
@@ -15726,8 +15800,8 @@ var pull_exports = {};
|
|
|
15726
15800
|
__export(pull_exports, {
|
|
15727
15801
|
default: () => pull_default
|
|
15728
15802
|
});
|
|
15729
|
-
import { mkdir, writeFile as
|
|
15730
|
-
import { dirname as dirname2, resolve as resolve12 } from "node:path";
|
|
15803
|
+
import { mkdir, readFile as readFile12, writeFile as writeFile5 } from "node:fs/promises";
|
|
15804
|
+
import { dirname as dirname2, join as join16, resolve as resolve12 } from "node:path";
|
|
15731
15805
|
var command50, pull_default;
|
|
15732
15806
|
var init_pull = __esm({
|
|
15733
15807
|
"src/commands/studio/pull.ts"() {
|
|
@@ -15735,6 +15809,7 @@ var init_pull = __esm({
|
|
|
15735
15809
|
init_errors();
|
|
15736
15810
|
init_exit_codes();
|
|
15737
15811
|
init_http();
|
|
15812
|
+
init_columns();
|
|
15738
15813
|
init_common3();
|
|
15739
15814
|
init_folder();
|
|
15740
15815
|
init_transfer2();
|
|
@@ -15742,17 +15817,19 @@ var init_pull = __esm({
|
|
|
15742
15817
|
resource: "studio",
|
|
15743
15818
|
action: "pull",
|
|
15744
15819
|
summary: "Write a template version's files to a folder",
|
|
15745
|
-
description:
|
|
15820
|
+
description: `Reads GET /v1/asset-templates/{templateId}/pull and writes every file under --dir: text files from the answer, binaries downloaded from their signed links. It replaces an existing file only when an earlier pull wrote it or a push sent it and it has not changed since (${PULL_STATE} in the folder records both), or with --force; other files in the folder are left alone. Every path is checked before anything is written: one that would land outside --dir, starts with a dot, or passes through a symbolic link is refused. --template-version picks the version: draft, latest (published) or a version id; the default is the draft, else the latest published version. --dry-run lists the paths, and the files it would not replace, without writing or downloading anything.`,
|
|
15746
15821
|
flags: {
|
|
15747
15822
|
dir: { type: "string", required: true, description: "The folder to write the files to (created when missing)" },
|
|
15748
|
-
"template-version": { type: "string", description: "draft, latest or a version id (default: the draft, else the latest published)" }
|
|
15823
|
+
"template-version": { type: "string", description: "draft, latest or a version id (default: the draft, else the latest published)" },
|
|
15824
|
+
force: { type: "boolean", description: "Replace files that no earlier pull wrote or push sent, or that changed since" }
|
|
15749
15825
|
},
|
|
15750
15826
|
positionals: [TEMPLATE_ID],
|
|
15751
15827
|
examples: ["kenso studio pull 12 --dir ./my-template", "kenso studio pull 12 --dir ./v3 --template-version 345"],
|
|
15752
15828
|
beta: { featureGates: STUDIO_GATES },
|
|
15753
15829
|
operationIds: ["asset-templates.pull"],
|
|
15754
15830
|
dryRun: true,
|
|
15755
|
-
async run(ctx,
|
|
15831
|
+
async run(ctx, args) {
|
|
15832
|
+
const { flags, positionals } = args;
|
|
15756
15833
|
const templateId = positiveId3(positionals[0], "templateId");
|
|
15757
15834
|
const version = typeof flags["template-version"] === "string" ? flags["template-version"].trim() : void 0;
|
|
15758
15835
|
if (version !== void 0 && !/^(draft|latest|\d+)$/.test(version)) {
|
|
@@ -15771,17 +15848,46 @@ var init_pull = __esm({
|
|
|
15771
15848
|
if (missing2) {
|
|
15772
15849
|
throw new KensoError({ code: "pull_incomplete", message: `${missing2.path} came back with neither text nor a download link.`, exitCode: ExitCode.Server });
|
|
15773
15850
|
}
|
|
15851
|
+
const statePath2 = join16(dir2, PULL_STATE);
|
|
15852
|
+
await existingFileNoLinks(dir2, statePath2, PULL_STATE);
|
|
15853
|
+
const state = await readPullState(dir2);
|
|
15854
|
+
const conflicts = [];
|
|
15855
|
+
for (const { path, file, target: target2 } of files) {
|
|
15856
|
+
if (!await existingFileNoLinks(dir2, target2, path)) continue;
|
|
15857
|
+
const current = sha2562(await readFile12(target2));
|
|
15858
|
+
const next = typeof file.text === "string" ? sha2562(Buffer.from(file.text, "utf8")) : file.sha256?.toLowerCase();
|
|
15859
|
+
if (current !== next && current !== state[path]) conflicts.push(path);
|
|
15860
|
+
}
|
|
15774
15861
|
if (ctx.flags.dryRun) {
|
|
15775
|
-
ctx.output.object({
|
|
15862
|
+
ctx.output.object({
|
|
15863
|
+
dryRun: true,
|
|
15864
|
+
templateId,
|
|
15865
|
+
versionId: pulled.versionId,
|
|
15866
|
+
dir: dir2,
|
|
15867
|
+
files: files.map(({ path }) => path),
|
|
15868
|
+
...conflicts.length > 0 ? { conflicts } : {}
|
|
15869
|
+
});
|
|
15776
15870
|
return ExitCode.Ok;
|
|
15777
15871
|
}
|
|
15872
|
+
if (conflicts.length > 0 && flags.force !== true) {
|
|
15873
|
+
throw new KensoError({
|
|
15874
|
+
code: "local_changes",
|
|
15875
|
+
message: `Pulling would replace ${conflicts.length} file${conflicts.length === 1 ? "" : "s"} in ${dir2} that no earlier pull wrote or push sent, or that changed since: ${conflicts.join(", ")}.`,
|
|
15876
|
+
exitCode: ExitCode.Conflict,
|
|
15877
|
+
field: "force",
|
|
15878
|
+
hint: "They are files you added or changed since the last pull or push. Move them away or compare them with the template first, or add --force to replace them with the template's version. Nothing was written.",
|
|
15879
|
+
next: commandLine2(ctx, "studio pull", { flags: { ...flags, force: true }, positionals })
|
|
15880
|
+
});
|
|
15881
|
+
}
|
|
15778
15882
|
await mkdir(dir2, { recursive: true });
|
|
15779
|
-
await mapLimit(files, PARALLEL_TRANSFERS, async ({ path, file, target: target2 }) => {
|
|
15780
|
-
const content = typeof file.text === "string" ? file.text : await download2(file.downloadUrl, path, file.sha256, ctx.signal);
|
|
15883
|
+
const written = await mapLimit(files, PARALLEL_TRANSFERS, async ({ path, file, target: target2 }) => {
|
|
15884
|
+
const content = typeof file.text === "string" ? Buffer.from(file.text, "utf8") : await download2(file.downloadUrl, path, file.sha256, ctx.signal);
|
|
15781
15885
|
await mkdir(dirname2(target2), { recursive: true });
|
|
15782
|
-
await
|
|
15886
|
+
await writeFile5(target2, content);
|
|
15887
|
+
return [path, sha2562(content)];
|
|
15783
15888
|
});
|
|
15784
|
-
|
|
15889
|
+
await recordPullState(dir2, written);
|
|
15890
|
+
ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir: dir2, ...conflicts.length > 0 ? { replaced: conflicts } : {} });
|
|
15785
15891
|
return ExitCode.Ok;
|
|
15786
15892
|
}
|
|
15787
15893
|
};
|
|
@@ -15793,7 +15899,7 @@ var init_pull = __esm({
|
|
|
15793
15899
|
async function readLocalTemplate(templateId, dir2) {
|
|
15794
15900
|
const files = await readFolder(dir2);
|
|
15795
15901
|
if (files.length === 0) {
|
|
15796
|
-
throw usageError(`${dir2} has no template files (dotfiles and
|
|
15902
|
+
throw usageError(`${dir2} has no template files (dotfiles, node_modules and Markdown files other than README.md, brief.md and ideas.md are skipped).`, {
|
|
15797
15903
|
field: "dir",
|
|
15798
15904
|
next: `kenso studio pull ${templateId} --dir ${dir2}`
|
|
15799
15905
|
});
|
|
@@ -15818,6 +15924,7 @@ var push_exports = {};
|
|
|
15818
15924
|
__export(push_exports, {
|
|
15819
15925
|
default: () => push_default
|
|
15820
15926
|
});
|
|
15927
|
+
import { resolve as resolve13 } from "node:path";
|
|
15821
15928
|
var BUILT_BY, DEFAULT_MESSAGE, command51, push_default;
|
|
15822
15929
|
var init_push = __esm({
|
|
15823
15930
|
"src/commands/studio/push.ts"() {
|
|
@@ -15827,14 +15934,16 @@ var init_push = __esm({
|
|
|
15827
15934
|
init_http();
|
|
15828
15935
|
init_columns();
|
|
15829
15936
|
init_common3();
|
|
15937
|
+
init_folder();
|
|
15830
15938
|
init_read();
|
|
15939
|
+
init_transfer2();
|
|
15831
15940
|
BUILT_BY = "customer_agent";
|
|
15832
15941
|
DEFAULT_MESSAGE = "Pushed with the Kenso CLI";
|
|
15833
15942
|
command51 = {
|
|
15834
15943
|
resource: "studio",
|
|
15835
15944
|
action: "push",
|
|
15836
15945
|
summary: "Save a folder's files to a template's draft and print the validation",
|
|
15837
|
-
description: "Reads --dir (skipping dotfiles and
|
|
15946
|
+
description: "Reads --dir (skipping dotfiles, node_modules, and Markdown files other than README.md, brief.md and ideas.md at the top, which Studio does not store). Text files (valid UTF-8, no NUL byte, under 1 MB) go inline; every other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. Then one push saves them into the draft and prints the validation result. Files not in the folder stay in the draft unless --delete-missing. With --publish, the new version is published when validation passes. Exit 2 when validation finds errors (the draft is still saved). --dry-run only lists the files a push would send; kenso studio validate checks them without saving.",
|
|
15838
15947
|
flags: {
|
|
15839
15948
|
dir: { type: "string", required: true, description: "The template folder" },
|
|
15840
15949
|
"delete-missing": { type: "boolean", description: "Make the draft hold exactly the folder's files" },
|
|
@@ -15851,11 +15960,11 @@ var init_push = __esm({
|
|
|
15851
15960
|
const templateId = positiveId3(positionals[0], "templateId");
|
|
15852
15961
|
const message = typeof flags.message === "string" && flags.message.trim() !== "" ? flags.message : DEFAULT_MESSAGE;
|
|
15853
15962
|
if (ctx.flags.dryRun) {
|
|
15854
|
-
const
|
|
15963
|
+
const local2 = await readLocalTemplate(templateId, String(flags.dir));
|
|
15855
15964
|
ctx.output.object({
|
|
15856
15965
|
dryRun: true,
|
|
15857
15966
|
templateId,
|
|
15858
|
-
files:
|
|
15967
|
+
files: local2.map((f) => ({ path: f.path, bytes: f.bytes.length, sentAs: f.text === void 0 && f.bytes.length > 0 ? "upload" : "text" })),
|
|
15859
15968
|
deleteMissing: flags["delete-missing"] === true,
|
|
15860
15969
|
message,
|
|
15861
15970
|
publish: flags.publish === true,
|
|
@@ -15863,7 +15972,8 @@ var init_push = __esm({
|
|
|
15863
15972
|
});
|
|
15864
15973
|
return ExitCode.Ok;
|
|
15865
15974
|
}
|
|
15866
|
-
const
|
|
15975
|
+
const local = await readLocalTemplate(templateId, String(flags.dir));
|
|
15976
|
+
const files = await bundleFiles(ctx, templateId, local);
|
|
15867
15977
|
const res = await ctx.client.request({
|
|
15868
15978
|
method: "POST",
|
|
15869
15979
|
path: `/v1/asset-templates/${templateId}/push`,
|
|
@@ -15871,6 +15981,7 @@ var init_push = __esm({
|
|
|
15871
15981
|
signal: ctx.signal
|
|
15872
15982
|
});
|
|
15873
15983
|
const pushed = unwrap(res.body) ?? {};
|
|
15984
|
+
await recordPullState(resolve13(String(flags.dir)), local.map((f) => [f.path, sha2562(f.bytes)]));
|
|
15874
15985
|
const versionId = pushed.version?.id;
|
|
15875
15986
|
const result = {
|
|
15876
15987
|
templateId,
|
|
@@ -15978,7 +16089,7 @@ var preview_exports = {};
|
|
|
15978
16089
|
__export(preview_exports, {
|
|
15979
16090
|
default: () => preview_default
|
|
15980
16091
|
});
|
|
15981
|
-
import { createHash as
|
|
16092
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
15982
16093
|
function list(paths) {
|
|
15983
16094
|
return paths.length > SHOWN ? `${paths.slice(0, SHOWN).join(", ")} and ${paths.length - SHOWN} more` : paths.join(", ");
|
|
15984
16095
|
}
|
|
@@ -15996,7 +16107,7 @@ async function warnIfFolderDiffers(ctx, templateId, dir2, versionId, push) {
|
|
|
15996
16107
|
for (const file of local) {
|
|
15997
16108
|
const remote = saved[file.path];
|
|
15998
16109
|
if (!remote) onlyLocal.push(file.path);
|
|
15999
|
-
else if (
|
|
16110
|
+
else if (createHash8("sha256").update(file.bytes).digest("hex") !== remote.sha256?.toLowerCase()) changed.push(file.path);
|
|
16000
16111
|
}
|
|
16001
16112
|
const localPaths = new Set(local.map((f) => f.path));
|
|
16002
16113
|
const onlySaved = Object.keys(saved).filter((path) => !localPaths.has(path)).sort();
|
|
@@ -16186,9 +16297,9 @@ var fill_exports = {};
|
|
|
16186
16297
|
__export(fill_exports, {
|
|
16187
16298
|
default: () => fill_default
|
|
16188
16299
|
});
|
|
16189
|
-
import { createHash as
|
|
16190
|
-
import { readFile as
|
|
16191
|
-
import { join as
|
|
16300
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
16301
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
16302
|
+
import { join as join17, resolve as resolve14 } from "node:path";
|
|
16192
16303
|
async function readTarget(ctx, flags) {
|
|
16193
16304
|
const accounts = stringFlag(flags.accounts);
|
|
16194
16305
|
const campaign = stringFlag(flags.campaign);
|
|
@@ -16221,7 +16332,7 @@ async function readTarget(ctx, flags) {
|
|
|
16221
16332
|
items: [...firstRow].map(([id, row]) => ({ id, row })),
|
|
16222
16333
|
duplicates: raw.length - firstRow.size,
|
|
16223
16334
|
...campaign !== void 0 ? { campaignId: positiveId3(campaign, "campaign") } : {},
|
|
16224
|
-
input: source === "-" ? { path: "-", sha256:
|
|
16335
|
+
input: source === "-" ? { path: "-", sha256: sha2563(raw.join("\n")) } : { path: resolve14(source), sha256: sha2563(await readFile13(resolve14(source))) }
|
|
16225
16336
|
};
|
|
16226
16337
|
}
|
|
16227
16338
|
async function refuseRefill(ctx, args, target2) {
|
|
@@ -16239,7 +16350,7 @@ async function refuseRefill(ctx, args, target2) {
|
|
|
16239
16350
|
code: "already_filled",
|
|
16240
16351
|
exitCode: ExitCode.Conflict,
|
|
16241
16352
|
message: unfinished ? `Run ${earlier.runId} is already filling these ${ids2} (${earlier.status}).` : `Run ${earlier.runId} already filled these ${ids2}.`,
|
|
16242
|
-
hint: unfinished ? "Continue that run instead: a new fill would create every fill run again." : succeeded ? "Every page was filled. Filling again rebuilds and charges every page that is not building or live; to do that anyway, use kenso asset-runs create." : `Filling again rebuilds and charges every page that is not building or live. To retry only the failed ones, put the ${target2.key} values of the failed rows in ${
|
|
16353
|
+
hint: unfinished ? "Continue that run instead: a new fill would create every fill run again." : succeeded ? "Every page was filled. Filling again rebuilds and charges every page that is not building or live; to do that anyway, use kenso asset-runs create." : `Filling again rebuilds and charges every page that is not building or live. To retry only the failed ones, put the ${target2.key} values of the failed rows in ${join17(earlier.dir, "results.csv")} in a file and fill that file.`,
|
|
16243
16354
|
next: unfinished ? `kenso runs resume ${earlier.runId}` : `kenso runs show ${earlier.runId}`
|
|
16244
16355
|
});
|
|
16245
16356
|
}
|
|
@@ -16280,7 +16391,7 @@ function estimateOutput(templateId, target2, estimate2) {
|
|
|
16280
16391
|
...target2.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
|
|
16281
16392
|
};
|
|
16282
16393
|
}
|
|
16283
|
-
var COMMAND6,
|
|
16394
|
+
var COMMAND6, sha2563, command54, fill_default;
|
|
16284
16395
|
var init_fill = __esm({
|
|
16285
16396
|
"src/commands/studio/fill.ts"() {
|
|
16286
16397
|
"use strict";
|
|
@@ -16295,7 +16406,7 @@ var init_fill = __esm({
|
|
|
16295
16406
|
init_common3();
|
|
16296
16407
|
init_fill_runs();
|
|
16297
16408
|
COMMAND6 = "studio fill";
|
|
16298
|
-
|
|
16409
|
+
sha2563 = (data) => createHash9("sha256").update(data).digest("hex");
|
|
16299
16410
|
command54 = {
|
|
16300
16411
|
resource: "studio",
|
|
16301
16412
|
action: "fill",
|
|
@@ -16755,14 +16866,14 @@ var init_views = __esm({
|
|
|
16755
16866
|
// src/commands/webhooks/local.ts
|
|
16756
16867
|
import { createHmac, randomBytes as randomBytes2 } from "node:crypto";
|
|
16757
16868
|
import { mkdirSync as mkdirSync4, readFileSync as readFileSync10, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
16758
|
-
import { join as
|
|
16869
|
+
import { join as join18 } from "node:path";
|
|
16759
16870
|
function webhooksDir(env) {
|
|
16760
|
-
const dir2 =
|
|
16871
|
+
const dir2 = join18(configDir(env), "webhooks");
|
|
16761
16872
|
mkdirSync4(dir2, { recursive: true, mode: 448 });
|
|
16762
16873
|
return dir2;
|
|
16763
16874
|
}
|
|
16764
16875
|
function signingSecretPath(env) {
|
|
16765
|
-
return
|
|
16876
|
+
return join18(webhooksDir(env), "signing-secret");
|
|
16766
16877
|
}
|
|
16767
16878
|
function signingSecret(env) {
|
|
16768
16879
|
const file = signingSecretPath(env);
|
|
@@ -16813,7 +16924,7 @@ async function forward(url, event, secret, signal) {
|
|
|
16813
16924
|
}
|
|
16814
16925
|
}
|
|
16815
16926
|
function statePath(env, workspaceId) {
|
|
16816
|
-
return
|
|
16927
|
+
return join18(webhooksDir(env), `listener-${(workspaceId ?? "default").replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
|
|
16817
16928
|
}
|
|
16818
16929
|
function writeListenerState(env, workspaceId, state) {
|
|
16819
16930
|
writeFileSync4(statePath(env, workspaceId), `${JSON.stringify(state)}
|
|
@@ -16869,7 +16980,7 @@ async function poll2(ctx, types, cursor2) {
|
|
|
16869
16980
|
return unwrap(res.body) ?? {};
|
|
16870
16981
|
}
|
|
16871
16982
|
function readBody(req) {
|
|
16872
|
-
return new Promise((
|
|
16983
|
+
return new Promise((resolve18, reject) => {
|
|
16873
16984
|
let size = 0;
|
|
16874
16985
|
const chunks = [];
|
|
16875
16986
|
req.on("data", (chunk) => {
|
|
@@ -16877,7 +16988,7 @@ function readBody(req) {
|
|
|
16877
16988
|
if (size > MAX_TRIGGER_BYTES) req.destroy(new Error("too large"));
|
|
16878
16989
|
else chunks.push(chunk);
|
|
16879
16990
|
});
|
|
16880
|
-
req.on("end", () =>
|
|
16991
|
+
req.on("end", () => resolve18(Buffer.concat(chunks).toString("utf8")));
|
|
16881
16992
|
req.on("error", reject);
|
|
16882
16993
|
});
|
|
16883
16994
|
}
|
|
@@ -16965,7 +17076,7 @@ var init_listen = __esm({
|
|
|
16965
17076
|
reply(res, 200, { forward: result ?? null });
|
|
16966
17077
|
}).catch(() => reply(res, 400, { error: "invalid_event" }));
|
|
16967
17078
|
});
|
|
16968
|
-
await new Promise((
|
|
17079
|
+
await new Promise((resolve18) => server.listen(0, "127.0.0.1", resolve18));
|
|
16969
17080
|
const url = `http://127.0.0.1:${server.address().port}/events`;
|
|
16970
17081
|
writeListenerState(ctx.env, workspaceId, { pid: process.pid, url, token, forwardTo: target2, startedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
16971
17082
|
try {
|
|
@@ -17154,7 +17265,7 @@ var init_status3 = __esm({
|
|
|
17154
17265
|
|
|
17155
17266
|
// src/work/files.ts
|
|
17156
17267
|
import { closeSync as closeSync2, constants, fchmodSync, fstatSync, lstatSync, openSync as openSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync5 } from "node:fs";
|
|
17157
|
-
import { join as
|
|
17268
|
+
import { join as join19 } from "node:path";
|
|
17158
17269
|
function agentName(value) {
|
|
17159
17270
|
if (typeof value !== "string") return void 0;
|
|
17160
17271
|
const name = value.trim().slice(0, MAX_AGENT_NAME);
|
|
@@ -17173,7 +17284,7 @@ function workFileName(claimId) {
|
|
|
17173
17284
|
function writeWorkFile(dir2, work, mode = 384) {
|
|
17174
17285
|
const name = workFileName(work.claimId);
|
|
17175
17286
|
if (!isPlainFileName(work.answersFile)) throw new Error("answersFile is not a plain file name");
|
|
17176
|
-
const path =
|
|
17287
|
+
const path = join19(dir2, name);
|
|
17177
17288
|
const fd = openSync2(path, "wx", mode);
|
|
17178
17289
|
try {
|
|
17179
17290
|
writeFileSync5(fd, JSON.stringify(work, null, 2) + "\n", "utf8");
|
|
@@ -17294,14 +17405,14 @@ function agentKensoEnv(opts) {
|
|
|
17294
17405
|
}
|
|
17295
17406
|
function sudoExec(user, command69, args, opts = {}) {
|
|
17296
17407
|
const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
|
|
17297
|
-
return new Promise((
|
|
17408
|
+
return new Promise((resolve18) => {
|
|
17298
17409
|
execFile(
|
|
17299
17410
|
sudo,
|
|
17300
17411
|
[...lead, ...sudoArgs(user.name, command69, args)],
|
|
17301
17412
|
{ env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
|
|
17302
17413
|
(err, stdout, stderr) => {
|
|
17303
17414
|
const code = err ? err.code : 0;
|
|
17304
|
-
|
|
17415
|
+
resolve18({ exitCode: typeof code === "number" ? code : null, stdout, stderr });
|
|
17305
17416
|
}
|
|
17306
17417
|
);
|
|
17307
17418
|
});
|
|
@@ -17397,7 +17508,7 @@ var init_agent_user = __esm({
|
|
|
17397
17508
|
// src/commands/work/folder.ts
|
|
17398
17509
|
import { existsSync as existsSync9 } from "node:fs";
|
|
17399
17510
|
import { appendFile as appendFile3, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
|
|
17400
|
-
import { dirname as dirname3, join as
|
|
17511
|
+
import { dirname as dirname3, join as join20, resolve as resolve15 } from "node:path";
|
|
17401
17512
|
var WorkRunFolder;
|
|
17402
17513
|
var init_folder2 = __esm({
|
|
17403
17514
|
"src/commands/work/folder.ts"() {
|
|
@@ -17439,12 +17550,12 @@ var init_folder2 = __esm({
|
|
|
17439
17550
|
const makeDir = (path) => this.shared ? ensureDir(path, SHARED_DIR_MODE) : ensurePrivateDir2(path);
|
|
17440
17551
|
let dir2;
|
|
17441
17552
|
if (this.outDir === void 0) {
|
|
17442
|
-
dir2 =
|
|
17553
|
+
dir2 = join20(root2, this.runId);
|
|
17443
17554
|
if (!this.shared) ensurePrivateDir2(root2);
|
|
17444
17555
|
makeDir(dir2);
|
|
17445
17556
|
} else {
|
|
17446
|
-
dir2 =
|
|
17447
|
-
const existing = existsSync9(
|
|
17557
|
+
dir2 = resolve15(this.outDir);
|
|
17558
|
+
const existing = existsSync9(join20(dir2, "run.json")) ? await readRunDir(dir2) : null;
|
|
17448
17559
|
if (existing && !existing.command.startsWith("work ")) {
|
|
17449
17560
|
throw usageError(`${dir2} already holds run ${existing.runId} (${existing.command}).`, {
|
|
17450
17561
|
field: "out",
|
|
@@ -17452,17 +17563,17 @@ var init_folder2 = __esm({
|
|
|
17452
17563
|
});
|
|
17453
17564
|
}
|
|
17454
17565
|
makeDir(dir2);
|
|
17455
|
-
for (const name of ["results.ndjson", "summary.json"]) await unlink3(
|
|
17566
|
+
for (const name of ["results.ndjson", "summary.json"]) await unlink3(join20(dir2, name)).catch(() => void 0);
|
|
17456
17567
|
try {
|
|
17457
17568
|
if (!this.shared) ensurePrivateDir2(root2);
|
|
17458
|
-
await symlink2(dir2,
|
|
17569
|
+
await symlink2(dir2, join20(root2, this.runId), "junction");
|
|
17459
17570
|
} catch (err) {
|
|
17460
17571
|
this.ctx.output.warn(`Could not link ${dir2} into ${root2} (${err.message}): kenso runs will not list this run.`);
|
|
17461
17572
|
}
|
|
17462
17573
|
}
|
|
17463
17574
|
this.dir = dir2;
|
|
17464
17575
|
if (this.shared) {
|
|
17465
|
-
this.tmpDir =
|
|
17576
|
+
this.tmpDir = join20(dir2, "tmp");
|
|
17466
17577
|
ensureDir(this.tmpDir, JOB_DIR_MODE);
|
|
17467
17578
|
}
|
|
17468
17579
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -17489,7 +17600,7 @@ var init_folder2 = __esm({
|
|
|
17489
17600
|
* writes (3770) under a jobs folder it can only pass through (2750).
|
|
17490
17601
|
*/
|
|
17491
17602
|
async jobDir(claimId) {
|
|
17492
|
-
const dir2 =
|
|
17603
|
+
const dir2 = join20(await this.ensure(), "jobs", claimId);
|
|
17493
17604
|
if (this.shared) {
|
|
17494
17605
|
ensureDir(dirname3(dir2), SHARED_DIR_MODE);
|
|
17495
17606
|
ensureDir(dir2, JOB_DIR_MODE);
|
|
@@ -17505,13 +17616,13 @@ var init_folder2 = __esm({
|
|
|
17505
17616
|
async append(line) {
|
|
17506
17617
|
if (!this.dir) return;
|
|
17507
17618
|
const json = JSON.stringify(line, (_key, value) => typeof value === "string" ? redact(value) : value);
|
|
17508
|
-
await appendFile3(
|
|
17619
|
+
await appendFile3(join20(this.dir, "results.ndjson"), `${json}
|
|
17509
17620
|
`, { mode: 384 });
|
|
17510
17621
|
}
|
|
17511
17622
|
/** summary.json, and run.json with the final status, the claims (chunkCount) and the items (rows). */
|
|
17512
17623
|
async finish(status, claims, items, summary) {
|
|
17513
17624
|
if (!this.dir || !this.record) return;
|
|
17514
|
-
await writeJsonAtomic(
|
|
17625
|
+
await writeJsonAtomic(join20(this.dir, "summary.json"), summary);
|
|
17515
17626
|
this.record = { ...this.record, status, chunkCount: claims, rows: items, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
17516
17627
|
await writeRunRecord(this.record);
|
|
17517
17628
|
}
|
|
@@ -17618,7 +17729,7 @@ var init_pull2 = __esm({
|
|
|
17618
17729
|
// src/commands/work/answers.ts
|
|
17619
17730
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
17620
17731
|
import { existsSync as existsSync10 } from "node:fs";
|
|
17621
|
-
import { basename as basename5, dirname as dirname4, join as
|
|
17732
|
+
import { basename as basename5, dirname as dirname4, join as join21 } from "node:path";
|
|
17622
17733
|
function zeroTotals() {
|
|
17623
17734
|
return { accepted: 0, rejected: 0, expired: 0, duplicate: 0, dropped: 0 };
|
|
17624
17735
|
}
|
|
@@ -17690,7 +17801,7 @@ function droppedResult(d) {
|
|
|
17690
17801
|
return { itemId: d.itemId ?? null, status: "dropped", reason: d.reason, message: `Answer ${d.index + 1} of the file was not sent: ${d.reason.replace(/_/g, " ")}.` };
|
|
17691
17802
|
}
|
|
17692
17803
|
async function writeResults(answersPath, claimId, results, totals) {
|
|
17693
|
-
const path =
|
|
17804
|
+
const path = join21(dirname4(answersPath), `${claimId}.results.json`);
|
|
17694
17805
|
await writeJsonAtomic(path, { version: 1, claimId, submittedAt: (/* @__PURE__ */ new Date()).toISOString(), ...totals, results });
|
|
17695
17806
|
return path;
|
|
17696
17807
|
}
|
|
@@ -17719,7 +17830,7 @@ function workFileNextTo(answersPath) {
|
|
|
17719
17830
|
hint: "Write the answers to <claimId>.answers.json next to its <claimId>.work.json, as the work file's rules say."
|
|
17720
17831
|
});
|
|
17721
17832
|
}
|
|
17722
|
-
const workPath =
|
|
17833
|
+
const workPath = join21(dirname4(answersPath), `${claimId}.work.json`);
|
|
17723
17834
|
if (!existsSync10(workPath)) {
|
|
17724
17835
|
throw usageError(`${workPath} is missing: kenso work submit reads it next to the answers file.`, { field: "answers-file" });
|
|
17725
17836
|
}
|
|
@@ -17752,7 +17863,7 @@ var submit_exports = {};
|
|
|
17752
17863
|
__export(submit_exports, {
|
|
17753
17864
|
default: () => submit_default
|
|
17754
17865
|
});
|
|
17755
|
-
import { resolve as
|
|
17866
|
+
import { resolve as resolve16 } from "node:path";
|
|
17756
17867
|
var command63, submit_default;
|
|
17757
17868
|
var init_submit = __esm({
|
|
17758
17869
|
"src/commands/work/submit.ts"() {
|
|
@@ -17774,7 +17885,7 @@ var init_submit = __esm({
|
|
|
17774
17885
|
beta: BETA,
|
|
17775
17886
|
operationIds: ["agent-work.submit-answers"],
|
|
17776
17887
|
async run(ctx, { positionals }) {
|
|
17777
|
-
const paths = [...new Set(positionals.map((p) =>
|
|
17888
|
+
const paths = [...new Set(positionals.map((p) => resolve16(p)))];
|
|
17778
17889
|
const jobs = paths.map((path) => {
|
|
17779
17890
|
const work = workFileNextTo(path);
|
|
17780
17891
|
const read2 = readAnswersFile(path, work);
|
|
@@ -17851,7 +17962,7 @@ var init_release = __esm({
|
|
|
17851
17962
|
import { spawn as nodeSpawn3 } from "node:child_process";
|
|
17852
17963
|
import { rmSync as rmSync3, statSync as statSync2 } from "node:fs";
|
|
17853
17964
|
import { access, constants as constants2 } from "node:fs/promises";
|
|
17854
|
-
import { delimiter as delimiter2, join as
|
|
17965
|
+
import { delimiter as delimiter2, join as join22 } from "node:path";
|
|
17855
17966
|
import { setTimeout as delay12 } from "node:timers/promises";
|
|
17856
17967
|
function childEnv(parent, adapter, extra) {
|
|
17857
17968
|
const scrub = new Set(adapter.scrubEnv.map((name) => name.toUpperCase()));
|
|
@@ -17888,7 +17999,7 @@ async function resolveBinary(adapter, env, override2) {
|
|
|
17888
17999
|
}
|
|
17889
18000
|
for (const dir2 of pathDirs(env)) {
|
|
17890
18001
|
for (const ext of extensions) {
|
|
17891
|
-
const candidate =
|
|
18002
|
+
const candidate = join22(dir2, name + ext);
|
|
17892
18003
|
if (await isExecutableFile(candidate)) return candidate;
|
|
17893
18004
|
}
|
|
17894
18005
|
}
|
|
@@ -17957,7 +18068,7 @@ async function groupGone(pid, runAs) {
|
|
|
17957
18068
|
}
|
|
17958
18069
|
}
|
|
17959
18070
|
function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
17960
|
-
return new Promise((
|
|
18071
|
+
return new Promise((resolve18) => {
|
|
17961
18072
|
const stdout = new Tail(OUTPUT_CAP_BYTES);
|
|
17962
18073
|
const stderr = new Tail(OUTPUT_CAP_BYTES);
|
|
17963
18074
|
let child;
|
|
@@ -17972,7 +18083,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
17972
18083
|
shell: false
|
|
17973
18084
|
});
|
|
17974
18085
|
} catch (err) {
|
|
17975
|
-
|
|
18086
|
+
resolve18({ exitCode: null, stdout: "", stderr: "", spawnError: err });
|
|
17976
18087
|
return;
|
|
17977
18088
|
}
|
|
17978
18089
|
let stopped;
|
|
@@ -17990,7 +18101,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
17990
18101
|
signal?.removeEventListener("abort", onAbort);
|
|
17991
18102
|
void groupGone(pid, runAs).then(() => {
|
|
17992
18103
|
if (pid !== void 0) liveGroups.delete(pid);
|
|
17993
|
-
|
|
18104
|
+
resolve18({ exitCode, stdout: stdout.text(), stderr: stderr.text(), stopped, spawnError });
|
|
17994
18105
|
});
|
|
17995
18106
|
};
|
|
17996
18107
|
const stop = (why) => {
|
|
@@ -18054,11 +18165,11 @@ async function runAgentJob(adapter, job, deps) {
|
|
|
18054
18165
|
}
|
|
18055
18166
|
let work;
|
|
18056
18167
|
try {
|
|
18057
|
-
work = readWorkFile(
|
|
18168
|
+
work = readWorkFile(join22(job.cwd, job.workFile));
|
|
18058
18169
|
} catch (err) {
|
|
18059
18170
|
return result("fatal", null, `the work file could not be read: ${err.message}`);
|
|
18060
18171
|
}
|
|
18061
|
-
const answersPath =
|
|
18172
|
+
const answersPath = join22(job.cwd, job.answersFile);
|
|
18062
18173
|
try {
|
|
18063
18174
|
rmSync3(answersPath, { force: true });
|
|
18064
18175
|
} catch (err) {
|
|
@@ -18185,22 +18296,22 @@ function runStatus(bin, args, env, adapter, runAs) {
|
|
|
18185
18296
|
const command69 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
|
|
18186
18297
|
const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
|
|
18187
18298
|
const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
|
|
18188
|
-
return new Promise((
|
|
18299
|
+
return new Promise((resolve18) => {
|
|
18189
18300
|
execFile2(
|
|
18190
18301
|
command69,
|
|
18191
18302
|
commandArgs2,
|
|
18192
18303
|
{ ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
|
|
18193
18304
|
(err, stdout, stderr) => {
|
|
18194
18305
|
if (err && typeof err.code === "string") {
|
|
18195
|
-
|
|
18306
|
+
resolve18(void 0);
|
|
18196
18307
|
return;
|
|
18197
18308
|
}
|
|
18198
18309
|
if (err && err.killed) {
|
|
18199
|
-
|
|
18310
|
+
resolve18(void 0);
|
|
18200
18311
|
return;
|
|
18201
18312
|
}
|
|
18202
18313
|
const exitCode = err ? err.code ?? null : 0;
|
|
18203
|
-
|
|
18314
|
+
resolve18({ exitCode: typeof exitCode === "number" ? exitCode : null, stdout: plain(String(stdout)), stderr: plain(String(stderr)) });
|
|
18204
18315
|
}
|
|
18205
18316
|
);
|
|
18206
18317
|
});
|
|
@@ -18468,7 +18579,7 @@ ${out.stderr}`;
|
|
|
18468
18579
|
});
|
|
18469
18580
|
|
|
18470
18581
|
// src/work/adapters/opencode.ts
|
|
18471
|
-
import { basename as basename6, join as
|
|
18582
|
+
import { basename as basename6, join as join23 } from "node:path";
|
|
18472
18583
|
var opencode;
|
|
18473
18584
|
var init_opencode = __esm({
|
|
18474
18585
|
"src/work/adapters/opencode.ts"() {
|
|
@@ -18512,7 +18623,7 @@ ${out.stderr}`);
|
|
|
18512
18623
|
if (job.model) args.push("--model", job.model);
|
|
18513
18624
|
args.push(job.instruction);
|
|
18514
18625
|
const env = { OPENCODE_CONFIG_CONTENT: JSON.stringify(config) };
|
|
18515
|
-
if (job.tmpDir !== void 0) env.OPENCODE_DB =
|
|
18626
|
+
if (job.tmpDir !== void 0) env.OPENCODE_DB = join23(job.tmpDir, `opencode-${basename6(job.cwd)}.db`);
|
|
18516
18627
|
return { args, env };
|
|
18517
18628
|
},
|
|
18518
18629
|
classify: classifyByExit
|
|
@@ -18716,8 +18827,8 @@ var init_scan = __esm({
|
|
|
18716
18827
|
});
|
|
18717
18828
|
|
|
18718
18829
|
// src/work/credentials.ts
|
|
18719
|
-
import { createHash as
|
|
18720
|
-
import { join as
|
|
18830
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
18831
|
+
import { join as join24 } from "node:path";
|
|
18721
18832
|
function unreadable(why) {
|
|
18722
18833
|
return new KensoError({
|
|
18723
18834
|
code: "credentials_unreadable",
|
|
@@ -18805,9 +18916,9 @@ var init_credentials = __esm({
|
|
|
18805
18916
|
}
|
|
18806
18917
|
}
|
|
18807
18918
|
async read(rel) {
|
|
18808
|
-
const r = await sudoExec(this.user, CAT, [
|
|
18919
|
+
const r = await sudoExec(this.user, CAT, [join24(this.user.home, rel)], { maxBuffer: MAX_CREDENTIAL_BYTES });
|
|
18809
18920
|
if (r.exitCode !== 0) return /No such file or directory/.test(r.stderr) ? "missing" : "unreadable";
|
|
18810
|
-
const digest =
|
|
18921
|
+
const digest = createHash10("sha256").update(r.stdout).digest("hex");
|
|
18811
18922
|
if (this.seen.get(rel) !== digest) {
|
|
18812
18923
|
this.index.add(r.stdout);
|
|
18813
18924
|
this.seen.set(rel, digest);
|
|
@@ -18820,7 +18931,7 @@ var init_credentials = __esm({
|
|
|
18820
18931
|
|
|
18821
18932
|
// src/work/guide.ts
|
|
18822
18933
|
import { closeSync as closeSync3, fchmodSync as fchmodSync2, openSync as openSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
18823
|
-
import { join as
|
|
18934
|
+
import { join as join25 } from "node:path";
|
|
18824
18935
|
function agentGuide(opts) {
|
|
18825
18936
|
const browser = opts.browser ?? findOperation("browser-runs", "create") !== void 0;
|
|
18826
18937
|
const parts2 = opts.kensoKey ? [JOB, KENSO, ...browser ? [BROWSER] : [], NEVER] : [JOB, NO_KENSO, NEVER];
|
|
@@ -18828,7 +18939,7 @@ function agentGuide(opts) {
|
|
|
18828
18939
|
}
|
|
18829
18940
|
function writeAgentGuide(dir2, text4, mode = WORK_FILE_MODE) {
|
|
18830
18941
|
for (const name of GUIDE_FILES) {
|
|
18831
|
-
const fd = openSync3(
|
|
18942
|
+
const fd = openSync3(join25(dir2, name), "wx", mode);
|
|
18832
18943
|
try {
|
|
18833
18944
|
writeFileSync6(fd, text4, "utf8");
|
|
18834
18945
|
fchmodSync2(fd, mode);
|
|
@@ -18982,7 +19093,7 @@ var init_instruction = __esm({
|
|
|
18982
19093
|
// src/work/pool.ts
|
|
18983
19094
|
function runPool(opts) {
|
|
18984
19095
|
const limit = Math.min(MAX_PARALLEL, Math.max(1, Math.floor(Number.isFinite(opts.parallel) ? opts.parallel : 1)));
|
|
18985
|
-
return new Promise((
|
|
19096
|
+
return new Promise((resolve18, reject) => {
|
|
18986
19097
|
let running = 0;
|
|
18987
19098
|
let filling = false;
|
|
18988
19099
|
let again = false;
|
|
@@ -19022,7 +19133,7 @@ function runPool(opts) {
|
|
|
19022
19133
|
const stopping = empty || failure !== void 0 || opts.signal?.aborted === true;
|
|
19023
19134
|
if (stopping && running === 0 && !again) {
|
|
19024
19135
|
if (failure) reject(failure.error);
|
|
19025
|
-
else
|
|
19136
|
+
else resolve18();
|
|
19026
19137
|
return;
|
|
19027
19138
|
}
|
|
19028
19139
|
} while (again);
|
|
@@ -19122,7 +19233,7 @@ var init_agent3 = __esm({
|
|
|
19122
19233
|
});
|
|
19123
19234
|
|
|
19124
19235
|
// src/commands/work/box.ts
|
|
19125
|
-
import { resolve as
|
|
19236
|
+
import { resolve as resolve17, sep as sep2 } from "node:path";
|
|
19126
19237
|
function invalidToken(message) {
|
|
19127
19238
|
return new KensoError({ code: "invalid_token_format", message, exitCode: ExitCode.Usage, field: "token-stdin" });
|
|
19128
19239
|
}
|
|
@@ -19149,7 +19260,7 @@ function requireSharedRunsDir(ctx, out) {
|
|
|
19149
19260
|
if (!root2) {
|
|
19150
19261
|
throw usageError("--agent-user needs KENSO_RUNS_DIR: the job folders go there, where the agent user's group can reach them.", { field: "agent-user" });
|
|
19151
19262
|
}
|
|
19152
|
-
if (out !== void 0 && !
|
|
19263
|
+
if (out !== void 0 && !resolve17(out).startsWith(resolve17(root2) + sep2)) {
|
|
19153
19264
|
throw usageError(`--out must be inside KENSO_RUNS_DIR (${root2}) with --agent-user.`, { field: "out" });
|
|
19154
19265
|
}
|
|
19155
19266
|
}
|
|
@@ -20346,13 +20457,13 @@ var init_invoked = __esm({
|
|
|
20346
20457
|
|
|
20347
20458
|
// src/core/update-notice.ts
|
|
20348
20459
|
import { mkdirSync as mkdirSync5, readFileSync as readFileSync13, realpathSync as realpathSync2, renameSync as renameSync4, writeFileSync as writeFileSync7 } from "node:fs";
|
|
20349
|
-
import { dirname as dirname5, join as
|
|
20460
|
+
import { dirname as dirname5, join as join26, sep as sep3 } from "node:path";
|
|
20350
20461
|
function installKind(script = process.argv[1], execPath = process.execPath, platform = process.platform) {
|
|
20351
20462
|
try {
|
|
20352
20463
|
if (!script) return "npm";
|
|
20353
20464
|
const bundle = realpathSync2(script);
|
|
20354
20465
|
const lib = dirname5(dirname5(dirname5(bundle)));
|
|
20355
|
-
if (execPath !==
|
|
20466
|
+
if (execPath !== join26(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
|
|
20356
20467
|
return bundle.includes(`${sep3}Cellar${sep3}kenso${sep3}`) ? "homebrew" : "standalone";
|
|
20357
20468
|
} catch {
|
|
20358
20469
|
return "npm";
|
|
@@ -20412,7 +20523,7 @@ function startUpdateNotice(argv, opts = {}) {
|
|
|
20412
20523
|
const stderr = opts.stderr ?? process.stderr;
|
|
20413
20524
|
const wanted = (opts.stderrIsTTY ?? process.stderr.isTTY === true) && detectAgent(env) === null && env.CI === void 0 && !env.KENSO_NO_UPDATE_NOTIFIER && RELEASE.test(version) && !argv.some((word) => QUIET_COMMANDS.has(word));
|
|
20414
20525
|
if (!wanted) return done;
|
|
20415
|
-
const file =
|
|
20526
|
+
const file = join26(configDir(env), UPDATE_CHECK_FILE);
|
|
20416
20527
|
const now = (opts.now ?? Date.now)();
|
|
20417
20528
|
const cached = readCheck(file);
|
|
20418
20529
|
const checkedAt = Date.parse(cached?.checkedAt ?? "");
|