kenso 0.1.149 → 0.1.152
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 +6 -0
- package/dist/discover.json +1 -1
- package/dist/kenso.js +672 -110
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/docs/output-and-errors.md +1 -1
- package/docs/reference.md +11 -3
- package/docs/studio.md +2 -2
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -3389,7 +3389,7 @@ var VERSION;
|
|
|
3389
3389
|
var init_version = __esm({
|
|
3390
3390
|
"src/core/version.ts"() {
|
|
3391
3391
|
"use strict";
|
|
3392
|
-
VERSION = true ? "0.1.
|
|
3392
|
+
VERSION = true ? "0.1.152" : "0.0.0-dev";
|
|
3393
3393
|
}
|
|
3394
3394
|
});
|
|
3395
3395
|
|
|
@@ -3684,9 +3684,9 @@ async function readAnswer(ctx) {
|
|
|
3684
3684
|
const lines = createInterface({ input: ctx.stdin ?? process.stdin, terminal: false });
|
|
3685
3685
|
let onAbort;
|
|
3686
3686
|
try {
|
|
3687
|
-
return await new Promise((
|
|
3688
|
-
lines.once("line",
|
|
3689
|
-
lines.once("close", () =>
|
|
3687
|
+
return await new Promise((resolve22, reject) => {
|
|
3688
|
+
lines.once("line", resolve22);
|
|
3689
|
+
lines.once("close", () => resolve22(""));
|
|
3690
3690
|
onAbort = () => reject(interrupted());
|
|
3691
3691
|
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
3692
3692
|
});
|
|
@@ -4702,9 +4702,9 @@ async function readRun(dir3) {
|
|
|
4702
4702
|
return null;
|
|
4703
4703
|
}
|
|
4704
4704
|
if (!raw) return null;
|
|
4705
|
-
const { runId, command:
|
|
4705
|
+
const { runId, command: command89, createdAt, status } = raw;
|
|
4706
4706
|
if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
|
|
4707
|
-
if (typeof
|
|
4707
|
+
if (typeof command89 !== "string" || typeof createdAt !== "string") return null;
|
|
4708
4708
|
if (typeof status !== "string" || !STATUSES.includes(status)) return null;
|
|
4709
4709
|
let chunksDone = chunkList(raw.chunksDone) ?? [];
|
|
4710
4710
|
try {
|
|
@@ -4715,7 +4715,7 @@ async function readRun(dir3) {
|
|
|
4715
4715
|
const record3 = {
|
|
4716
4716
|
...raw,
|
|
4717
4717
|
runId,
|
|
4718
|
-
command:
|
|
4718
|
+
command: command89,
|
|
4719
4719
|
args: asRecord3(raw.args) ?? {},
|
|
4720
4720
|
createdAt,
|
|
4721
4721
|
status,
|
|
@@ -4775,11 +4775,11 @@ async function loadRun(runId, env = process.env) {
|
|
|
4775
4775
|
}
|
|
4776
4776
|
return run;
|
|
4777
4777
|
}
|
|
4778
|
-
async function findIdentical(
|
|
4778
|
+
async function findIdentical(command89, args, inputSha256, env, workspaceId, anyWorkspace = false) {
|
|
4779
4779
|
const identity = argsIdentity(args);
|
|
4780
4780
|
const runs = await listRuns(env);
|
|
4781
4781
|
return runs.filter(
|
|
4782
|
-
(run) => run.command ===
|
|
4782
|
+
(run) => run.command === command89 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
|
|
4783
4783
|
);
|
|
4784
4784
|
}
|
|
4785
4785
|
function isOtherLiveProcess(pid) {
|
|
@@ -8202,8 +8202,8 @@ async function ask(ctx, path, body2, read2) {
|
|
|
8202
8202
|
const res = await ctx.client.request({ method: "POST", path, body: body2 });
|
|
8203
8203
|
const data = unwrap(res.body);
|
|
8204
8204
|
if (!isRecord4(data)) return { estimate: data ?? null };
|
|
8205
|
-
const
|
|
8206
|
-
return { estimate, credits: await read2(data) };
|
|
8205
|
+
const estimate2 = Object.fromEntries(Object.entries(data).filter(([key]) => key !== "totalAmount" && !/usd/i.test(key)));
|
|
8206
|
+
return { estimate: estimate2, credits: await read2(data) };
|
|
8207
8207
|
} catch (err) {
|
|
8208
8208
|
if (mustRethrow(err)) throw err;
|
|
8209
8209
|
ctx.output.warn(`Could not estimate the credits: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -8212,10 +8212,10 @@ async function ask(ctx, path, body2, read2) {
|
|
|
8212
8212
|
}
|
|
8213
8213
|
async function creditEstimate(ctx, body2) {
|
|
8214
8214
|
return ask(ctx, "/v1/credits/estimates", body2, (data) => {
|
|
8215
|
-
const
|
|
8215
|
+
const credits3 = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
|
|
8216
8216
|
return {
|
|
8217
|
-
needed:
|
|
8218
|
-
available:
|
|
8217
|
+
needed: credits3("totalMillicredits"),
|
|
8218
|
+
available: credits3("availableMillicredits"),
|
|
8219
8219
|
sufficient: typeof data.sufficient === "boolean" ? data.sufficient : null
|
|
8220
8220
|
};
|
|
8221
8221
|
});
|
|
@@ -8305,8 +8305,8 @@ function idValue(value, field) {
|
|
|
8305
8305
|
function shellQuote3(arg) {
|
|
8306
8306
|
return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
8307
8307
|
}
|
|
8308
|
-
function commandLine2(ctx,
|
|
8309
|
-
const parts2 = ["kenso", ...
|
|
8308
|
+
function commandLine2(ctx, command89, args, extra = []) {
|
|
8309
|
+
const parts2 = ["kenso", ...command89.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
|
|
8310
8310
|
for (const [name, value] of Object.entries(args.flags)) {
|
|
8311
8311
|
if (value === void 0 || value === false) continue;
|
|
8312
8312
|
if (value === true) parts2.push(`--${name}`);
|
|
@@ -8581,8 +8581,8 @@ var init_import = __esm({
|
|
|
8581
8581
|
});
|
|
8582
8582
|
const dryRun2 = ctx.flags.dryRun === true || ctx.flags.yes !== true;
|
|
8583
8583
|
const mapping = Object.fromEntries(Object.entries(columns2.mapping).map(([header, field]) => [header, field === "domain" ? "domains" : field]));
|
|
8584
|
-
const
|
|
8585
|
-
const
|
|
8584
|
+
const estimate2 = dryRun2 ? await estimateAccounts(ctx, items.length) : null;
|
|
8585
|
+
const credits3 = estimate2 ? { ...creditsCheck(estimate2.totalMillicredits, estimate2.availableMillicredits), sufficient: estimate2.sufficient } : creditsCheck(0, void 0);
|
|
8586
8586
|
const outcome = await runBatch(
|
|
8587
8587
|
{
|
|
8588
8588
|
command: COMMAND,
|
|
@@ -8595,7 +8595,7 @@ var init_import = __esm({
|
|
|
8595
8595
|
execChunk: sendChunk,
|
|
8596
8596
|
invalid: invalid2,
|
|
8597
8597
|
dryRun: dryRun2,
|
|
8598
|
-
dryRunExtra: dryRun2 ? { mapping, ignoredColumns: columns2.ignored, estimate, credits:
|
|
8598
|
+
dryRunExtra: dryRun2 ? { mapping, ignoredColumns: columns2.ignored, estimate: estimate2, credits: credits3 } : void 0,
|
|
8599
8599
|
applyCommand: commandLine2(ctx, COMMAND, args, ["--yes"]),
|
|
8600
8600
|
outDir: stringFlag(flags.out),
|
|
8601
8601
|
summarize
|
|
@@ -8619,9 +8619,9 @@ function stringFlag2(flags, name) {
|
|
|
8619
8619
|
const text4 = value.trim();
|
|
8620
8620
|
return text4 === "" ? void 0 : text4;
|
|
8621
8621
|
}
|
|
8622
|
-
function requireFlag(flags, name,
|
|
8622
|
+
function requireFlag(flags, name, command89, hint) {
|
|
8623
8623
|
const value = stringFlag2(flags, name);
|
|
8624
|
-
if (value === void 0) throw usageError(`--${name} is required for ${
|
|
8624
|
+
if (value === void 0) throw usageError(`--${name} is required for ${command89}.`, { field: name, next: `${command89} --help`, ...hint ? { hint } : {} });
|
|
8625
8625
|
return value;
|
|
8626
8626
|
}
|
|
8627
8627
|
function positiveId(value) {
|
|
@@ -8630,8 +8630,8 @@ function positiveId(value) {
|
|
|
8630
8630
|
const id = Number(text4);
|
|
8631
8631
|
return Number.isSafeInteger(id) && id > 0 ? id : void 0;
|
|
8632
8632
|
}
|
|
8633
|
-
function idFlag(flags, name,
|
|
8634
|
-
const raw = requireFlag(flags, name,
|
|
8633
|
+
function idFlag(flags, name, command89) {
|
|
8634
|
+
const raw = requireFlag(flags, name, command89);
|
|
8635
8635
|
const id = positiveId(raw);
|
|
8636
8636
|
if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
|
|
8637
8637
|
return id;
|
|
@@ -8651,8 +8651,8 @@ function isDryRun(ctx) {
|
|
|
8651
8651
|
function shellQuote4(value) {
|
|
8652
8652
|
return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
8653
8653
|
}
|
|
8654
|
-
function sameCommand2(
|
|
8655
|
-
const parts2 = [
|
|
8654
|
+
function sameCommand2(command89, flags, ctx, extra = []) {
|
|
8655
|
+
const parts2 = [command89];
|
|
8656
8656
|
for (const [name, value] of Object.entries(flags)) {
|
|
8657
8657
|
if (value === void 0 || value === false) continue;
|
|
8658
8658
|
if (value === true) parts2.push(`--${name}`);
|
|
@@ -8884,12 +8884,12 @@ function filterBody(flags) {
|
|
|
8884
8884
|
}
|
|
8885
8885
|
return parsed2;
|
|
8886
8886
|
}
|
|
8887
|
-
function targetBody(flags, target2,
|
|
8887
|
+
function targetBody(flags, target2, command89) {
|
|
8888
8888
|
const ids2 = idList(flags, "ids");
|
|
8889
8889
|
const filter = filterBody(flags);
|
|
8890
8890
|
const everything = flags.all === true;
|
|
8891
8891
|
if (ids2 !== void 0 === (filter !== void 0 || everything)) {
|
|
8892
|
-
throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${
|
|
8892
|
+
throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command89} --help` });
|
|
8893
8893
|
}
|
|
8894
8894
|
const exclude = idList(flags, "exclude-ids");
|
|
8895
8895
|
if (exclude !== void 0 && ids2 !== void 0) throw usageError("--exclude-ids goes with --filter or --all.", { field: "exclude-ids" });
|
|
@@ -8910,14 +8910,14 @@ function tagSet(flags) {
|
|
|
8910
8910
|
return set2;
|
|
8911
8911
|
}
|
|
8912
8912
|
function requestBody(flags, target2, dryRun2) {
|
|
8913
|
-
const
|
|
8913
|
+
const command89 = `kenso ${target2.resource} bulk-update`;
|
|
8914
8914
|
const pairs = Array.isArray(flags.set) ? flags.set : typeof flags.set === "string" ? [flags.set] : [];
|
|
8915
8915
|
const tags = target2.tags ? tagSet(flags) : {};
|
|
8916
8916
|
if (pairs.length === 0 && Object.keys(tags).length === 0) {
|
|
8917
|
-
throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${
|
|
8917
|
+
throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${command89}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command89} --help` });
|
|
8918
8918
|
}
|
|
8919
8919
|
return {
|
|
8920
|
-
...targetBody(flags, target2,
|
|
8920
|
+
...targetBody(flags, target2, command89),
|
|
8921
8921
|
set: { ...parseSet(pairs, target2.aliases, target2.textFields), ...tags },
|
|
8922
8922
|
...dryRun2 ? { dryRun: true } : {},
|
|
8923
8923
|
...flags["overwrite-pinned"] === true ? { overwritePinned: true } : {}
|
|
@@ -8983,7 +8983,7 @@ function bulkUpdateCommand(target2) {
|
|
|
8983
8983
|
};
|
|
8984
8984
|
}
|
|
8985
8985
|
function bulkDeleteCommand(target2) {
|
|
8986
|
-
const
|
|
8986
|
+
const command89 = `kenso ${target2.resource} bulk-delete`;
|
|
8987
8987
|
return {
|
|
8988
8988
|
resource: target2.resource,
|
|
8989
8989
|
action: "bulk-delete",
|
|
@@ -9007,7 +9007,7 @@ function bulkDeleteCommand(target2) {
|
|
|
9007
9007
|
beta: { featureGates: { all: target2.featureGates } },
|
|
9008
9008
|
operationIds: [`${target2.resource}.bulk-delete`, "changes.get"],
|
|
9009
9009
|
dryRun: true,
|
|
9010
|
-
run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2,
|
|
9010
|
+
run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command89), dryRun: dryRun2 }))
|
|
9011
9011
|
};
|
|
9012
9012
|
}
|
|
9013
9013
|
async function runChange(ctx, flags, path, body2) {
|
|
@@ -9765,7 +9765,7 @@ var init_leads = __esm({
|
|
|
9765
9765
|
var output_and_errors_default;
|
|
9766
9766
|
var init_output_and_errors = __esm({
|
|
9767
9767
|
"docs/output-and-errors.md"() {
|
|
9768
|
-
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, removes or merges, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive`, `kenso people merge` 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`, `kenso notes add` 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. A command that reads before it writes (`kenso layouts set --header` reads the layout it edits) still reads with `--dry-run`, and prints the write it would send. A POST that changes nothing, such as `kenso accounts search` or `kenso reports query`, is a read like a GET.\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`, or with `Read-only.` when the command only reads, and `kenso describe <resource> <action>` shows `"dryRun": false`. Every command that only reads, generated ones included, says `Read-only.` there.\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, such as a delete) | key-value lines: `ok`, `status`, `request` | `{"ok":true,"status":204,"request":{"method":"DELETE","path":"/v1/tasks/7"}}` |\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- A thread list\'s `preview` is a one-line preview by default: the first 280 characters of the newest message\'s text (the API\'s `bodyFormat=snippet`), in every format. `--full`, or `--fields` that names `preview` or `htmlBody`, prints the whole message text, and `kenso threads list-messages --thread-id <id>` reads every message of a thread whole.\n- A contact list asks the API for only the fields it prints (the API\'s `fields`), so a page downloads what it shows. A thread list printed with `-o ids`, or with `--fields` that names neither `preview` nor `htmlBody`, asks for no message bodies (`bodyFormat=none`). `--full` and `--query` ask for every field, and `--param-fields` or `--body-format` sent by hand wins.\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 --fields id,subject,preview\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| `read_only` | 2 | `--read-only` or `KENSO_READ_ONLY` is on and the command is not a read: nothing was sent. `next` (with `--read-only` only, on a command with a dry run) is the same command with `--dry-run`, which prints the plan and changes nothing |\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| `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 is not a file of the Studio bundle layout (such as a dotfile, `opencode.json` or `CLAUDE.md`), would land outside `--dir`, 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## Effect, cost and read-only mode\n\nEvery command has an effect: `read` (changes nothing, charges nothing), `write` (changes workspace data, charges nothing the API contract declares, nothing leaves Kenso), `spend` (can charge credits), `send` (sends an email, a LinkedIn message, a call or an invitation, or starts or resumes sending) or `destructive` (deletes, archives, removes or merges). Command help prints `Effect: <effect>.` under the summary, and a command that charges adds a `Cost:` line in credits from your workspace\'s rate card.\n\n`kenso describe <resource> <action>` adds `effect` and `cost` to its JSON. `cost` is `null` for a command that does not charge, else `{"lines": [...], "rateCard": {"source": ..., "versions": [...]}}`: each line is the command\'s credit line with its `price` text, and `source` is `live`, `cache` or `bundled`. A command that charges something no rate-card row prices has `{"lines": [], "rateCard": null}`, with `text` saying what it charges when the command states it. `kenso describe` and `kenso describe <resource>` add `effect` to each row.\n\n`--read-only`, or `KENSO_READ_ONLY=1` in the environment, refuses every command whose effect is not `read` before it sends a request, with exit 2:\n\n```json\n{"error":{"code":"read_only","message":"kenso campaigns launch is a send command, and this session is read-only.","hint":"Read-only is on through --read-only: next prints the plan. Run the command again without --read-only to make the change.","next":"kenso --read-only campaigns launch --campaign-id 1 --dry-run"}}\n```\n\n`next` never makes the change: on a command with a dry run it is the same command with `--dry-run` and without `--yes`, which prints the plan. A command with no dry run gets no `next`, and its hint says to run it again without `--read-only`. A command with its own `--body-read-only` option (`kenso api-keys create`) gets no `next` either, and its hint names that option. When the variable turned read-only on, the hint reads `KENSO_READ_ONLY is set: unset it to run this command.` and there is no `next`, so an agent that runs `next` cannot loop. A POST that only reads, such as `kenso contacts search`, still runs; a GET that charges, such as `kenso search get-place`, is refused; a command with a dry run still prints its plan with `--dry-run`; `kenso api` has the effect of the route it calls, and on a route this CLI does not know only a `GET` runs.\n\n```bash\nKENSO_READ_ONLY=1 kenso contacts search --limit 1\nkenso --read-only describe email-finds create\n```\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';
|
|
9768
|
+
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, removes or merges, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive`, `kenso people merge` 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`, `kenso notes add` 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. A command that reads before it writes (`kenso layouts set --header` reads the layout it edits) still reads with `--dry-run`, and prints the write it would send. A POST that changes nothing, such as `kenso accounts search` or `kenso reports query`, is a read like a GET.\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`, or with `Read-only.` when the command only reads, and `kenso describe <resource> <action>` shows `"dryRun": false`. Every command that only reads, generated ones included, says `Read-only.` there.\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, such as a delete) | key-value lines: `ok`, `status`, `request` | `{"ok":true,"status":204,"request":{"method":"DELETE","path":"/v1/tasks/7"}}` |\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- A thread list\'s `preview` is a one-line preview by default: the first 280 characters of the newest message\'s text (the API\'s `bodyFormat=snippet`), in every format. `--full`, or `--fields` that names `preview` or `htmlBody`, prints the whole message text, and `kenso threads list-messages --thread-id <id>` reads every message of a thread whole.\n- A contact list asks the API for only the fields it prints (the API\'s `fields`), so a page downloads what it shows. A thread list printed with `-o ids`, or with `--fields` that names neither `preview` nor `htmlBody`, asks for no message bodies (`bodyFormat=none`). `--full` and `--query` ask for every field, and `--param-fields` or `--body-format` sent by hand wins.\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 --fields id,subject,preview\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| `read_only` | 2 | `--read-only` or `KENSO_READ_ONLY` is on and the command is not a read: nothing was sent. `next` (with `--read-only` only, on a command with a dry run) is the same command with `--dry-run`, which prints the plan and changes nothing |\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| `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 is not a file of the Studio bundle layout (such as a dotfile, `opencode.json` or `CLAUDE.md`), would land outside `--dir`, or passes through a symbolic link, or a `samples/*.json` that does not hold a sample |\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## Effect, cost and read-only mode\n\nEvery command has an effect: `read` (changes nothing, charges nothing), `write` (changes workspace data, charges nothing the API contract declares, nothing leaves Kenso), `spend` (can charge credits), `send` (sends an email, a LinkedIn message, a call or an invitation, or starts or resumes sending) or `destructive` (deletes, archives, removes or merges). Command help prints `Effect: <effect>.` under the summary, and a command that charges adds a `Cost:` line in credits from your workspace\'s rate card.\n\n`kenso describe <resource> <action>` adds `effect` and `cost` to its JSON. `cost` is `null` for a command that does not charge, else `{"lines": [...], "rateCard": {"source": ..., "versions": [...]}}`: each line is the command\'s credit line with its `price` text, and `source` is `live`, `cache` or `bundled`. A command that charges something no rate-card row prices has `{"lines": [], "rateCard": null}`, with `text` saying what it charges when the command states it. `kenso describe` and `kenso describe <resource>` add `effect` to each row.\n\n`--read-only`, or `KENSO_READ_ONLY=1` in the environment, refuses every command whose effect is not `read` before it sends a request, with exit 2:\n\n```json\n{"error":{"code":"read_only","message":"kenso campaigns launch is a send command, and this session is read-only.","hint":"Read-only is on through --read-only: next prints the plan. Run the command again without --read-only to make the change.","next":"kenso --read-only campaigns launch --campaign-id 1 --dry-run"}}\n```\n\n`next` never makes the change: on a command with a dry run it is the same command with `--dry-run` and without `--yes`, which prints the plan. A command with no dry run gets no `next`, and its hint says to run it again without `--read-only`. A command with its own `--body-read-only` option (`kenso api-keys create`) gets no `next` either, and its hint names that option. When the variable turned read-only on, the hint reads `KENSO_READ_ONLY is set: unset it to run this command.` and there is no `next`, so an agent that runs `next` cannot loop. A POST that only reads, such as `kenso contacts search`, still runs; a GET that charges, such as `kenso search get-place`, is refused; a command with a dry run still prints its plan with `--dry-run`; `kenso api` has the effect of the route it calls, and on a route this CLI does not know only a `GET` runs.\n\n```bash\nKENSO_READ_ONLY=1 kenso contacts search --limit 1\nkenso --read-only describe email-finds create\n```\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';
|
|
9769
9769
|
}
|
|
9770
9770
|
});
|
|
9771
9771
|
|
|
@@ -9789,7 +9789,7 @@ var init_sandbox = __esm({
|
|
|
9789
9789
|
var studio_default;
|
|
9790
9790
|
var init_studio = __esm({
|
|
9791
9791
|
"docs/studio.md"() {
|
|
9792
|
-
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 is not a file of the Studio bundle layout, one that would land outside `--dir`, and one that passes through a symbolic link. The layout is `studio.json`, `template.liquid`, `fallback.liquid`, `README.md`, `brief.md` and `ideas.md` at the top, images, fonts, pdf and csv files under `assets/`, and `.json` or `.csv` files directly in `samples/`, with names of letters, digits, `.`, `-` and `_` that neither start nor end with a dot and are not a Windows device name (`CON`, `NUL`, `COM1`). A sample is named in lowercase letters, digits, `-` and `_` (`samples/acme.json`), and never with a name a tool reads as its own config (`package.json`, `tsconfig.json`, `opencode.json`), so a tool started inside `samples/` finds none either. So pull never writes a hidden file (`.claude/`, `.mcp.json`), a tool's config file (`opencode.json`, `package.json`) or a coding agent's `CLAUDE.md` or `AGENTS.md`, which editors and coding agents read as their own settings, whatever the server sends. Studio stores nothing outside the layout; when a version stored before that rule holds such a file, the API leaves it out and pull prints a warning that names it.\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 the files of the bundle layout in `--dir` (see pull) and skips everything else, so a folder that also holds a coding agent's `CLAUDE.md`, a `package.json` or a `src/` folder still pushes. It prints a warning naming each skipped file or folder; dotfiles, dot folders and `node_modules` are skipped without one. `validate` reads the folder the same way.\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";
|
|
9792
|
+
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 is not a file of the Studio bundle layout, one that would land outside `--dir`, and one that passes through a symbolic link. The layout is `studio.json`, `template.liquid`, `fallback.liquid`, `README.md`, `brief.md` and `ideas.md` at the top, images, fonts, pdf and csv files under `assets/`, and `.json` or `.csv` files directly in `samples/`, with names of letters, digits, `.`, `-` and `_` that neither start nor end with a dot and are not a Windows device name (`CON`, `NUL`, `COM1`). A sample is named in lowercase letters, digits, `-` and `_` (`samples/acme.json`), and never with a name a tool reads as its own config (`package.json`, `tsconfig.json`, `opencode.json`), so a tool started inside `samples/` finds none either. A sample `.json` is also judged by what it holds: one JSON object with only the top-level keys `account`, `person`, `sender`, `brand`, `link`, `data`, `role` and `roles`. Pull refuses any other (`unsafe_path`) before it writes anything, so no tool's configuration arrives under a sample name. So pull never writes a hidden file (`.claude/`, `.mcp.json`), a tool's config file (`opencode.json`, `package.json`) or a coding agent's `CLAUDE.md` or `AGENTS.md`, which editors and coding agents read as their own settings, whatever the server sends. Studio stores nothing outside the layout; when a version stored before that rule holds such a file, the API leaves it out and pull prints a warning that names it.\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 the files of the bundle layout in `--dir` (see pull) and skips everything else, so a folder that also holds a coding agent's `CLAUDE.md`, a `package.json` or a `src/` folder still pushes. It prints a warning naming each skipped file or folder; dotfiles, dot folders and `node_modules` are skipped without one. A `samples/*.json` that is not one JSON object with only the keys `account`, `person`, `sender`, `brand`, `link`, `data`, `role` and `roles` is skipped with the same warning: the API refuses it (400 `content_mismatch`). `validate` reads the folder the same way.\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";
|
|
9793
9793
|
}
|
|
9794
9794
|
});
|
|
9795
9795
|
|
|
@@ -11043,8 +11043,8 @@ var init_browser_login = __esm({
|
|
|
11043
11043
|
defaultDeps = {
|
|
11044
11044
|
sleep: (ms, signal) => delay5(ms, void 0, signal ? { signal } : void 0),
|
|
11045
11045
|
now: () => Date.now(),
|
|
11046
|
-
spawn: (
|
|
11047
|
-
const child = nodeSpawn(
|
|
11046
|
+
spawn: (command89, args) => {
|
|
11047
|
+
const child = nodeSpawn(command89, args, { detached: true, stdio: "ignore" });
|
|
11048
11048
|
child.on("error", () => {
|
|
11049
11049
|
});
|
|
11050
11050
|
child.unref();
|
|
@@ -12435,8 +12435,8 @@ var init_run = __esm({
|
|
|
12435
12435
|
defaultDeps2 = {
|
|
12436
12436
|
sleep: (ms, signal) => delay6(ms, void 0, signal ? { signal } : void 0),
|
|
12437
12437
|
now: () => Date.now(),
|
|
12438
|
-
spawn: (
|
|
12439
|
-
const child = nodeSpawn2(
|
|
12438
|
+
spawn: (command89, args) => {
|
|
12439
|
+
const child = nodeSpawn2(command89, args, { detached: true, stdio: "ignore" });
|
|
12440
12440
|
child.on("error", () => {
|
|
12441
12441
|
});
|
|
12442
12442
|
child.unref();
|
|
@@ -13414,12 +13414,12 @@ import { join as join17 } from "node:path";
|
|
|
13414
13414
|
function whereDir(env) {
|
|
13415
13415
|
return join17(runsRoot(env), WHERE_DIR);
|
|
13416
13416
|
}
|
|
13417
|
-
async function unfinishedWhereIds(ctx,
|
|
13417
|
+
async function unfinishedWhereIds(ctx, command89, args) {
|
|
13418
13418
|
const dir3 = whereDir(ctx.env);
|
|
13419
13419
|
const identity = argsIdentity(args);
|
|
13420
13420
|
const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
|
|
13421
13421
|
for (const run of await listRuns(ctx.env)) {
|
|
13422
|
-
if (run.command !==
|
|
13422
|
+
if (run.command !== command89 || run.status === "done" || run.status === "planned") continue;
|
|
13423
13423
|
if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
|
|
13424
13424
|
if (run.inputPath?.startsWith(`${dir3}/`) && existsSync7(run.inputPath)) return run.inputPath;
|
|
13425
13425
|
}
|
|
@@ -13565,14 +13565,14 @@ async function idsFromRun(ctx, runId) {
|
|
|
13565
13565
|
return { ...idItems(ids2), source: "run" };
|
|
13566
13566
|
}
|
|
13567
13567
|
async function collectIds(ctx, flags, kind, dryRun2) {
|
|
13568
|
-
const
|
|
13568
|
+
const command89 = `kenso contacts ${kind}`;
|
|
13569
13569
|
const ids2 = stringFlag2(flags, "ids");
|
|
13570
13570
|
const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
|
|
13571
13571
|
const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
|
|
13572
13572
|
const given = [ids2, where, run].filter((v) => v !== void 0).length;
|
|
13573
13573
|
if (given !== 1) {
|
|
13574
13574
|
const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
|
|
13575
|
-
throw usageError(`${
|
|
13575
|
+
throw usageError(`${command89} needs exactly one of ${choices}.`, { field: "ids", next: `${command89} --help` });
|
|
13576
13576
|
}
|
|
13577
13577
|
if (ids2 !== void 0) return idsFromFile(ctx, ids2);
|
|
13578
13578
|
if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
|
|
@@ -14848,15 +14848,15 @@ function candidate(entry, costNote) {
|
|
|
14848
14848
|
function specEntry(spec) {
|
|
14849
14849
|
if (spec.brief?.startsWith("same as ")) return void 0;
|
|
14850
14850
|
const id = commandName(spec).slice("kenso ".length);
|
|
14851
|
-
const
|
|
14852
|
-
const actions39 =
|
|
14851
|
+
const credits3 = spec.cost ?? [];
|
|
14852
|
+
const actions39 = credits3.map((c) => c.action);
|
|
14853
14853
|
return {
|
|
14854
14854
|
kind: "command",
|
|
14855
14855
|
id,
|
|
14856
14856
|
summary: spec.summary,
|
|
14857
14857
|
terms: termsOf(id, spec.summary, spec.description, spec.doc?.when, Object.keys(spec.flags).join(" "), actions39.join(" ")),
|
|
14858
14858
|
effect: spec.effect,
|
|
14859
|
-
...
|
|
14859
|
+
...credits3.length > 0 ? { costActions: actions39, credits: credits3 } : {},
|
|
14860
14860
|
...spec.beta ? { beta: true } : {},
|
|
14861
14861
|
describe: `kenso describe ${id}`
|
|
14862
14862
|
};
|
|
@@ -16611,8 +16611,10 @@ var init_opportunities = __esm({
|
|
|
16611
16611
|
// src/commands/people/import.ts
|
|
16612
16612
|
var import_exports4 = {};
|
|
16613
16613
|
__export(import_exports4, {
|
|
16614
|
+
ALIASES: () => ALIASES3,
|
|
16614
16615
|
default: () => import_default4,
|
|
16615
|
-
personResult: () => personResult
|
|
16616
|
+
personResult: () => personResult,
|
|
16617
|
+
toBody: () => toBody2
|
|
16616
16618
|
});
|
|
16617
16619
|
function toBody2(row, columns2) {
|
|
16618
16620
|
const value = (field) => firstValue(row, columns2.sources.get(field));
|
|
@@ -16685,8 +16687,8 @@ async function emailFindCredits(ctx, items, findEmails) {
|
|
|
16685
16687
|
const price = unitMillicredits("email_found", await loadRateCards(ctx));
|
|
16686
16688
|
const { available, estimateError } = await readAvailable(ctx);
|
|
16687
16689
|
const check = creditsCheck(rows * (price ?? 0), available);
|
|
16688
|
-
const
|
|
16689
|
-
return { emailFindRows: rows, credits:
|
|
16690
|
+
const credits3 = price === void 0 && rows > 0 ? { ...check, needed: null, sufficient: null } : check;
|
|
16691
|
+
return { emailFindRows: rows, credits: credits3, ...estimateError ? { estimateError } : {} };
|
|
16690
16692
|
}
|
|
16691
16693
|
var COMMAND5, CHUNK_SIZE6, ALIASES3, PERSON_FIELDS, ACCOUNT_NOT_FOUND, command46, import_default4;
|
|
16692
16694
|
var init_import5 = __esm({
|
|
@@ -17338,8 +17340,8 @@ import { resolve as resolve11 } from "node:path";
|
|
|
17338
17340
|
function kebab(key) {
|
|
17339
17341
|
return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
17340
17342
|
}
|
|
17341
|
-
function commandWords(
|
|
17342
|
-
return
|
|
17343
|
+
function commandWords(command89) {
|
|
17344
|
+
return command89.trim().split(/\s+/).filter((t) => t !== "");
|
|
17343
17345
|
}
|
|
17344
17346
|
function flagValue(value) {
|
|
17345
17347
|
return typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
@@ -18097,6 +18099,16 @@ function inBundleLayout(bundlePath) {
|
|
|
18097
18099
|
const name = segments[1];
|
|
18098
18100
|
return segments[0] === "samples" && segments.length === 2 && SAMPLE_NAME.test(name) && !TOOL_CONFIG_NAMES.has(name.toLowerCase());
|
|
18099
18101
|
}
|
|
18102
|
+
function sampleContentOk(bundlePath, content) {
|
|
18103
|
+
if (!SAMPLE_JSON.test(bundlePath)) return true;
|
|
18104
|
+
if (content.length > UPLOAD_MAX_BYTES) return false;
|
|
18105
|
+
try {
|
|
18106
|
+
const value = JSON.parse(typeof content === "string" ? content : strictUtf8.decode(content));
|
|
18107
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).every((key) => SAMPLE_KEYS.has(key));
|
|
18108
|
+
} catch {
|
|
18109
|
+
return false;
|
|
18110
|
+
}
|
|
18111
|
+
}
|
|
18100
18112
|
async function readFolder(dir3, skipped = []) {
|
|
18101
18113
|
const root2 = await existingDir(dir3);
|
|
18102
18114
|
const files = [];
|
|
@@ -18115,7 +18127,12 @@ async function readFolder(dir3, skipped = []) {
|
|
|
18115
18127
|
continue;
|
|
18116
18128
|
}
|
|
18117
18129
|
const bytes = await readFile10(abs);
|
|
18118
|
-
|
|
18130
|
+
const text4 = textOf2(bytes);
|
|
18131
|
+
if (!sampleContentOk(path, text4 ?? bytes)) {
|
|
18132
|
+
skipped.push(path);
|
|
18133
|
+
continue;
|
|
18134
|
+
}
|
|
18135
|
+
files.push({ path, bytes, text: text4 });
|
|
18119
18136
|
}
|
|
18120
18137
|
}
|
|
18121
18138
|
};
|
|
@@ -18163,6 +18180,12 @@ async function recordPullState(root2, entries2) {
|
|
|
18163
18180
|
await writeFile4(path, `${JSON.stringify({ files }, null, 2)}
|
|
18164
18181
|
`);
|
|
18165
18182
|
}
|
|
18183
|
+
function checkPulledSample(bundlePath, text4) {
|
|
18184
|
+
if (!SAMPLE_JSON.test(bundlePath)) return;
|
|
18185
|
+
if (typeof text4 !== "string" || !sampleContentOk(bundlePath, Buffer.from(text4, "utf8"))) {
|
|
18186
|
+
throw unsafePath(bundlePath, "it does not hold a Studio sample (one JSON object with only the keys account, person, sender, brand, link, data, role and roles)");
|
|
18187
|
+
}
|
|
18188
|
+
}
|
|
18166
18189
|
function unsafePath(bundlePath, why) {
|
|
18167
18190
|
return new KensoError({
|
|
18168
18191
|
code: "unsafe_path",
|
|
@@ -18192,7 +18215,7 @@ async function mapLimit(items, limit, fn) {
|
|
|
18192
18215
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
18193
18216
|
return out;
|
|
18194
18217
|
}
|
|
18195
|
-
var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8, TOP_FILES, ASSET_TYPES, SAMPLE_NAME, TOOL_CONFIG_NAMES, NAME, WINDOWS_DEVICE, LAYOUT, PULL_STATE, sha2563, CONTENT_TYPES2;
|
|
18218
|
+
var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8, TOP_FILES, ASSET_TYPES, SAMPLE_NAME, TOOL_CONFIG_NAMES, SAMPLE_KEYS, SAMPLE_JSON, strictUtf8, NAME, WINDOWS_DEVICE, LAYOUT, PULL_STATE, sha2563, CONTENT_TYPES2;
|
|
18196
18219
|
var init_folder2 = __esm({
|
|
18197
18220
|
"src/commands/studio/folder.ts"() {
|
|
18198
18221
|
"use strict";
|
|
@@ -18241,9 +18264,12 @@ var init_folder2 = __esm({
|
|
|
18241
18264
|
"pyrightconfig.json",
|
|
18242
18265
|
"cypress.json"
|
|
18243
18266
|
]);
|
|
18267
|
+
SAMPLE_KEYS = /* @__PURE__ */ new Set(["account", "person", "sender", "brand", "link", "data", "role", "roles"]);
|
|
18268
|
+
SAMPLE_JSON = /^samples\/[^/]+\.json$/i;
|
|
18269
|
+
strictUtf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
18244
18270
|
NAME = /^[A-Za-z0-9_-](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?$/;
|
|
18245
18271
|
WINDOWS_DEVICE = /^(?:CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])(?:\.|$)/i;
|
|
18246
|
-
LAYOUT = "studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase like acme.json, never a tool's config name such as package.json)";
|
|
18272
|
+
LAYOUT = "studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase like acme.json, never a tool's config name such as package.json; a .json there is one object with only the keys account, person, sender, brand, link, data, role and roles)";
|
|
18247
18273
|
PULL_STATE = ".kenso-pull.json";
|
|
18248
18274
|
sha2563 = (bytes) => createHash7("sha256").update(bytes).digest("hex");
|
|
18249
18275
|
CONTENT_TYPES2 = {
|
|
@@ -18384,7 +18410,7 @@ var init_pull = __esm({
|
|
|
18384
18410
|
action: "pull",
|
|
18385
18411
|
summary: "Write a template version's files to a folder",
|
|
18386
18412
|
effect: "read",
|
|
18387
|
-
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 is not a file of the Studio bundle layout (studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/, samples/), would land outside --dir, 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.`,
|
|
18413
|
+
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 is not a file of the Studio bundle layout (studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/, samples/), would land outside --dir, or passes through a symbolic link is refused, and so is a samples/ .json that is not one object with only the keys account, person, sender, brand, link, data, role and roles. --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.`,
|
|
18388
18414
|
flags: {
|
|
18389
18415
|
dir: { type: "string", required: true, description: "The folder to write the files to (created when missing)" },
|
|
18390
18416
|
"template-version": { type: "string", description: "draft, latest or a version id (default: the draft, else the latest published)" },
|
|
@@ -18411,9 +18437,10 @@ var init_pull = __esm({
|
|
|
18411
18437
|
});
|
|
18412
18438
|
const pulled = unwrap(res.body) ?? {};
|
|
18413
18439
|
if (pulled.skipped?.length) {
|
|
18414
|
-
ctx.output.warn(`Kenso left out ${pulled.skipped.length} stored file${pulled.skipped.length === 1 ? "" : "s"} outside the bundle layout: ${pulled.skipped.join(", ")}.`);
|
|
18440
|
+
ctx.output.warn(`Kenso left out ${pulled.skipped.length} stored file${pulled.skipped.length === 1 ? "" : "s"} that a push would refuse now (outside the bundle layout, or a sample .json that does not hold a sample): ${pulled.skipped.join(", ")}.`);
|
|
18415
18441
|
}
|
|
18416
18442
|
const files = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(dir3, path) }));
|
|
18443
|
+
for (const { path, file } of files) checkPulledSample(path, file.text);
|
|
18417
18444
|
const missing2 = files.find(({ file }) => typeof file.text !== "string" && !file.downloadUrl);
|
|
18418
18445
|
if (missing2) {
|
|
18419
18446
|
throw new KensoError({ code: "pull_incomplete", message: `${missing2.path} came back with neither text nor a download link.`, exitCode: ExitCode.Server });
|
|
@@ -18521,7 +18548,7 @@ var init_push = __esm({
|
|
|
18521
18548
|
action: "push",
|
|
18522
18549
|
summary: "Save a folder's files to a template's draft and print the validation",
|
|
18523
18550
|
effect: "write",
|
|
18524
|
-
description: "Reads the files of the Studio bundle layout in --dir: studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase, never a tool's config name such as package.json). Anything else is skipped, with a note for each file or folder that is not a dotfile or node_modules. 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.",
|
|
18551
|
+
description: "Reads the files of the Studio bundle layout in --dir: studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase, never a tool's config name such as package.json; a .json there is one object with only the keys account, person, sender, brand, link, data, role and roles). Anything else is skipped, with a note for each file or folder that is not a dotfile or node_modules. 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.",
|
|
18525
18552
|
flags: {
|
|
18526
18553
|
dir: { type: "string", required: true, description: "The template folder" },
|
|
18527
18554
|
"delete-missing": { type: "boolean", description: "Make the draft hold exactly the folder's files" },
|
|
@@ -18960,14 +18987,14 @@ async function fillChunk(ctx, templateId, target2, wait3, chunk, chunkCtx) {
|
|
|
18960
18987
|
}
|
|
18961
18988
|
return { results: runResults(chunk, run, target2.key) };
|
|
18962
18989
|
}
|
|
18963
|
-
function estimateOutput(templateId, target2,
|
|
18990
|
+
function estimateOutput(templateId, target2, estimate2) {
|
|
18964
18991
|
return {
|
|
18965
18992
|
templateId,
|
|
18966
18993
|
...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
|
|
18967
18994
|
[target2.flag]: target2.items.length,
|
|
18968
18995
|
...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
|
|
18969
18996
|
runs: Math.ceil(target2.items.length / RUN_SIZE),
|
|
18970
|
-
estimate,
|
|
18997
|
+
estimate: estimate2,
|
|
18971
18998
|
...target2.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
|
|
18972
18999
|
};
|
|
18973
19000
|
}
|
|
@@ -19026,12 +19053,12 @@ var init_fill = __esm({
|
|
|
19026
19053
|
const target2 = await readTarget(ctx, flags);
|
|
19027
19054
|
const batchArgs = { ...flags, positionals };
|
|
19028
19055
|
if (ctx.flags.yes === true) await refuseRefill(ctx, batchArgs, target2);
|
|
19029
|
-
const
|
|
19056
|
+
const estimate2 = await estimateFill(ctx, templateId, target2.items.length);
|
|
19030
19057
|
if (ctx.flags.yes !== true) {
|
|
19031
19058
|
const next = commandLine2(ctx, COMMAND6, { flags: { ...flags, estimate: void 0 }, positionals }, ["--yes"]);
|
|
19032
19059
|
const { available, estimateError } = await readAvailable(ctx);
|
|
19033
|
-
const
|
|
19034
|
-
ctx.output.object({ ...estimateOutput(templateId, target2,
|
|
19060
|
+
const credits3 = creditsCheck(estimate2.millicredits, available);
|
|
19061
|
+
ctx.output.object({ ...estimateOutput(templateId, target2, estimate2), credits: credits3, ...estimateError ? { estimateError } : {}, next });
|
|
19035
19062
|
return ExitCode.Ok;
|
|
19036
19063
|
}
|
|
19037
19064
|
const wait3 = flags.wait === true;
|
|
@@ -19049,7 +19076,7 @@ var init_fill = __esm({
|
|
|
19049
19076
|
templateId,
|
|
19050
19077
|
...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
|
|
19051
19078
|
...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
|
|
19052
|
-
estimatedMillicredits:
|
|
19079
|
+
estimatedMillicredits: estimate2.millicredits,
|
|
19053
19080
|
runs: runsOf(results)
|
|
19054
19081
|
})
|
|
19055
19082
|
},
|
|
@@ -19600,7 +19627,7 @@ async function poll2(ctx, types, cursor2) {
|
|
|
19600
19627
|
return unwrap(res.body) ?? {};
|
|
19601
19628
|
}
|
|
19602
19629
|
function readBody(req) {
|
|
19603
|
-
return new Promise((
|
|
19630
|
+
return new Promise((resolve22, reject) => {
|
|
19604
19631
|
let size = 0;
|
|
19605
19632
|
const chunks = [];
|
|
19606
19633
|
req.on("data", (chunk) => {
|
|
@@ -19608,7 +19635,7 @@ function readBody(req) {
|
|
|
19608
19635
|
if (size > MAX_TRIGGER_BYTES) req.destroy(new Error("too large"));
|
|
19609
19636
|
else chunks.push(chunk);
|
|
19610
19637
|
});
|
|
19611
|
-
req.on("end", () =>
|
|
19638
|
+
req.on("end", () => resolve22(Buffer.concat(chunks).toString("utf8")));
|
|
19612
19639
|
req.on("error", reject);
|
|
19613
19640
|
});
|
|
19614
19641
|
}
|
|
@@ -19697,7 +19724,7 @@ var init_listen = __esm({
|
|
|
19697
19724
|
reply(res, 200, { forward: result ?? null });
|
|
19698
19725
|
}).catch(() => reply(res, 400, { error: "invalid_event" }));
|
|
19699
19726
|
});
|
|
19700
|
-
await new Promise((
|
|
19727
|
+
await new Promise((resolve22) => server.listen(0, "127.0.0.1", resolve22));
|
|
19701
19728
|
const url = `http://127.0.0.1:${server.address().port}/events`;
|
|
19702
19729
|
writeListenerState(ctx.env, workspaceId, { pid: process.pid, url, token, forwardTo: target2, startedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
19703
19730
|
try {
|
|
@@ -20014,9 +20041,9 @@ var init_files = __esm({
|
|
|
20014
20041
|
import { execFile, spawnSync as spawnSync2 } from "node:child_process";
|
|
20015
20042
|
import { readFileSync as readFileSync18 } from "node:fs";
|
|
20016
20043
|
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
20017
|
-
function sudoArgs(user,
|
|
20044
|
+
function sudoArgs(user, command89, args, keep = [], set2 = {}) {
|
|
20018
20045
|
const assignments = Object.entries(set2).map(([name, value]) => `${name}=${value}`);
|
|
20019
|
-
return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--",
|
|
20046
|
+
return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command89, ...args];
|
|
20020
20047
|
}
|
|
20021
20048
|
function agentKensoEnv(opts) {
|
|
20022
20049
|
return {
|
|
@@ -20026,16 +20053,16 @@ function agentKensoEnv(opts) {
|
|
|
20026
20053
|
AI_AGENT: opts.agentName
|
|
20027
20054
|
};
|
|
20028
20055
|
}
|
|
20029
|
-
function sudoExec(user,
|
|
20056
|
+
function sudoExec(user, command89, args, opts = {}) {
|
|
20030
20057
|
const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
|
|
20031
|
-
return new Promise((
|
|
20058
|
+
return new Promise((resolve22) => {
|
|
20032
20059
|
execFile(
|
|
20033
20060
|
sudo,
|
|
20034
|
-
[...lead, ...sudoArgs(user.name,
|
|
20061
|
+
[...lead, ...sudoArgs(user.name, command89, args)],
|
|
20035
20062
|
{ env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
|
|
20036
20063
|
(err, stdout, stderr) => {
|
|
20037
20064
|
const code = err ? err.code : 0;
|
|
20038
|
-
|
|
20065
|
+
resolve22({ exitCode: typeof code === "number" ? code : null, stdout, stderr });
|
|
20039
20066
|
}
|
|
20040
20067
|
);
|
|
20041
20068
|
});
|
|
@@ -20141,9 +20168,9 @@ var init_folder3 = __esm({
|
|
|
20141
20168
|
init_redact();
|
|
20142
20169
|
init_agent_user();
|
|
20143
20170
|
WorkRunFolder = class {
|
|
20144
|
-
constructor(ctx,
|
|
20171
|
+
constructor(ctx, command89, args, outDir, shared = false) {
|
|
20145
20172
|
this.ctx = ctx;
|
|
20146
|
-
this.command =
|
|
20173
|
+
this.command = command89;
|
|
20147
20174
|
this.args = args;
|
|
20148
20175
|
this.outDir = outDir;
|
|
20149
20176
|
this.shared = shared;
|
|
@@ -20694,7 +20721,7 @@ async function groupGone(pid, runAs) {
|
|
|
20694
20721
|
}
|
|
20695
20722
|
}
|
|
20696
20723
|
function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
20697
|
-
return new Promise((
|
|
20724
|
+
return new Promise((resolve22) => {
|
|
20698
20725
|
const stdout = new Tail(OUTPUT_CAP_BYTES);
|
|
20699
20726
|
const stderr = new Tail(OUTPUT_CAP_BYTES);
|
|
20700
20727
|
let child;
|
|
@@ -20709,7 +20736,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
20709
20736
|
shell: false
|
|
20710
20737
|
});
|
|
20711
20738
|
} catch (err) {
|
|
20712
|
-
|
|
20739
|
+
resolve22({ exitCode: null, stdout: "", stderr: "", spawnError: err });
|
|
20713
20740
|
return;
|
|
20714
20741
|
}
|
|
20715
20742
|
let stopped;
|
|
@@ -20727,7 +20754,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
20727
20754
|
signal?.removeEventListener("abort", onAbort);
|
|
20728
20755
|
void groupGone(pid, runAs).then(() => {
|
|
20729
20756
|
if (pid !== void 0) liveGroups.delete(pid);
|
|
20730
|
-
|
|
20757
|
+
resolve22({ exitCode, stdout: stdout.text(), stderr: stderr.text(), stopped, spawnError });
|
|
20731
20758
|
});
|
|
20732
20759
|
};
|
|
20733
20760
|
const stop = (why) => {
|
|
@@ -20919,25 +20946,25 @@ function plain(text4) {
|
|
|
20919
20946
|
return text4.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
|
|
20920
20947
|
}
|
|
20921
20948
|
function runStatus(bin, args, env, adapter, runAs) {
|
|
20922
|
-
const
|
|
20949
|
+
const command89 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
|
|
20923
20950
|
const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
|
|
20924
20951
|
const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
|
|
20925
|
-
return new Promise((
|
|
20952
|
+
return new Promise((resolve22) => {
|
|
20926
20953
|
execFile2(
|
|
20927
|
-
|
|
20954
|
+
command89,
|
|
20928
20955
|
commandArgs2,
|
|
20929
20956
|
{ ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
|
|
20930
20957
|
(err, stdout, stderr) => {
|
|
20931
20958
|
if (err && typeof err.code === "string") {
|
|
20932
|
-
|
|
20959
|
+
resolve22(void 0);
|
|
20933
20960
|
return;
|
|
20934
20961
|
}
|
|
20935
20962
|
if (err && err.killed) {
|
|
20936
|
-
|
|
20963
|
+
resolve22(void 0);
|
|
20937
20964
|
return;
|
|
20938
20965
|
}
|
|
20939
20966
|
const exitCode = err ? err.code ?? null : 0;
|
|
20940
|
-
|
|
20967
|
+
resolve22({ exitCode: typeof exitCode === "number" ? exitCode : null, stdout: plain(String(stdout)), stderr: plain(String(stderr)) });
|
|
20941
20968
|
}
|
|
20942
20969
|
);
|
|
20943
20970
|
});
|
|
@@ -21719,7 +21746,7 @@ var init_instruction = __esm({
|
|
|
21719
21746
|
// src/work/pool.ts
|
|
21720
21747
|
function runPool(opts) {
|
|
21721
21748
|
const limit = Math.min(MAX_PARALLEL, Math.max(1, Math.floor(Number.isFinite(opts.parallel) ? opts.parallel : 1)));
|
|
21722
|
-
return new Promise((
|
|
21749
|
+
return new Promise((resolve22, reject) => {
|
|
21723
21750
|
let running = 0;
|
|
21724
21751
|
let filling = false;
|
|
21725
21752
|
let again = false;
|
|
@@ -21759,7 +21786,7 @@ function runPool(opts) {
|
|
|
21759
21786
|
const stopping = empty || failure !== void 0 || opts.signal?.aborted === true;
|
|
21760
21787
|
if (stopping && running === 0 && !again) {
|
|
21761
21788
|
if (failure) reject(failure.error);
|
|
21762
|
-
else
|
|
21789
|
+
else resolve22();
|
|
21763
21790
|
return;
|
|
21764
21791
|
}
|
|
21765
21792
|
} while (again);
|
|
@@ -22477,6 +22504,11 @@ async function getVersion(ctx, workflowId, number) {
|
|
|
22477
22504
|
const res = await ctx.client.request({ method: "GET", path: `/v1/workflows/${workflowId}/versions/${number}`, signal: ctx.signal });
|
|
22478
22505
|
return unwrap(res.body) ?? {};
|
|
22479
22506
|
}
|
|
22507
|
+
async function publishedDefinition(ctx, workflow) {
|
|
22508
|
+
const number = workflow.published?.number;
|
|
22509
|
+
if (typeof number !== "number") return void 0;
|
|
22510
|
+
return (await getVersion(ctx, workflow.id, number)).definition ?? void 0;
|
|
22511
|
+
}
|
|
22480
22512
|
function sortKeys(value) {
|
|
22481
22513
|
if (Array.isArray(value)) return value.map(sortKeys);
|
|
22482
22514
|
if (value !== null && typeof value === "object") {
|
|
@@ -22685,9 +22717,9 @@ function boundFile(ctx, file, action) {
|
|
|
22685
22717
|
function currentHash(workflow) {
|
|
22686
22718
|
return (workflow.draft ?? workflow.published)?.definitionHash ?? void 0;
|
|
22687
22719
|
}
|
|
22688
|
-
function perRecord(
|
|
22689
|
-
if (
|
|
22690
|
-
const totals =
|
|
22720
|
+
function perRecord(estimate2) {
|
|
22721
|
+
if (estimate2 === null || typeof estimate2 !== "object") return null;
|
|
22722
|
+
const totals = estimate2;
|
|
22691
22723
|
const bulk = totals.bulkPriceApplies === true;
|
|
22692
22724
|
const expected = bulk ? totals.bulkExpectedMillicredits : totals.expectedMillicredits;
|
|
22693
22725
|
const max = bulk ? totals.bulkMaxMillicredits : totals.maxMillicredits;
|
|
@@ -22728,7 +22760,7 @@ var init_check = __esm({
|
|
|
22728
22760
|
signal: ctx.signal
|
|
22729
22761
|
});
|
|
22730
22762
|
const validation = unwrap(validated.body) ?? {};
|
|
22731
|
-
const
|
|
22763
|
+
const estimate2 = await workflowEstimate(ctx, { definition: target2.definition, records: 1 });
|
|
22732
22764
|
const workflow = await getWorkflow(ctx, target2.workflowId);
|
|
22733
22765
|
const valid = validation.valid === true;
|
|
22734
22766
|
const inSync = sameDefinition(target2.definition, workflow.definition ?? {});
|
|
@@ -22736,8 +22768,8 @@ var init_check = __esm({
|
|
|
22736
22768
|
ctx.output.object({
|
|
22737
22769
|
valid,
|
|
22738
22770
|
issues: (validation.issues ?? []).map((i) => ({ path: i.path, code: i.code, message: i.message, fix: i.fix ?? null, severity: i.severity })),
|
|
22739
|
-
perRecord: perRecord(
|
|
22740
|
-
...
|
|
22771
|
+
perRecord: perRecord(estimate2.estimate),
|
|
22772
|
+
...estimate2.estimateError ? { estimateError: estimate2.estimateError } : {},
|
|
22741
22773
|
draftHash: currentHash(workflow) ?? null,
|
|
22742
22774
|
inSync,
|
|
22743
22775
|
next: !valid ? nextLine(ctx, "check", file, again) : nextLine(ctx, inSync ? "test" : "push", file)
|
|
@@ -23237,12 +23269,542 @@ var init_file_actions = __esm({
|
|
|
23237
23269
|
}
|
|
23238
23270
|
});
|
|
23239
23271
|
|
|
23272
|
+
// src/commands/workflows/run-cap.ts
|
|
23273
|
+
function credits2(value) {
|
|
23274
|
+
return Math.round(value * 1e3) / 1e3;
|
|
23275
|
+
}
|
|
23276
|
+
function maxCreditsOf(value) {
|
|
23277
|
+
if (value === void 0) return void 0;
|
|
23278
|
+
const number = typeof value === "string" && value.trim() !== "" ? Number(value) : Number.NaN;
|
|
23279
|
+
if (!Number.isFinite(number) || number <= 0) {
|
|
23280
|
+
throw usageError(`--max-credits must be a number above 0 (got "${String(value)}").`, { field: "max-credits" });
|
|
23281
|
+
}
|
|
23282
|
+
return number;
|
|
23283
|
+
}
|
|
23284
|
+
function hardCeiling(definition) {
|
|
23285
|
+
const value = definition?.limits?.creditsPerRun;
|
|
23286
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
23287
|
+
}
|
|
23288
|
+
function planCap(maxCredits, records, kind, ceiling, retry) {
|
|
23289
|
+
const willStart = ceiling <= 0 ? records : Math.min(records, Math.floor(maxCredits / ceiling + 1e-9));
|
|
23290
|
+
if (willStart === 0 && records > 0) {
|
|
23291
|
+
const smallest = Math.ceil(ceiling * 1e3) / 1e3;
|
|
23292
|
+
throw new KensoError({
|
|
23293
|
+
code: "cap_too_low",
|
|
23294
|
+
message: `--max-credits ${maxCredits} is below one record's ceiling of ${smallest} credits, so nothing would start.`,
|
|
23295
|
+
exitCode: ExitCode.RateLimited,
|
|
23296
|
+
field: "max-credits",
|
|
23297
|
+
next: retry(smallest)
|
|
23298
|
+
});
|
|
23299
|
+
}
|
|
23300
|
+
return { maxCredits, kind, perRecord: credits2(ceiling), willStart, notStarted: records - willStart };
|
|
23301
|
+
}
|
|
23302
|
+
var init_run_cap = __esm({
|
|
23303
|
+
"src/commands/workflows/run-cap.ts"() {
|
|
23304
|
+
"use strict";
|
|
23305
|
+
init_errors();
|
|
23306
|
+
init_exit_codes();
|
|
23307
|
+
}
|
|
23308
|
+
});
|
|
23309
|
+
|
|
23310
|
+
// src/commands/workflows/run-input.ts
|
|
23311
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
23312
|
+
import { resolve as resolve21 } from "node:path";
|
|
23313
|
+
import { Readable as Readable2 } from "node:stream";
|
|
23314
|
+
function validId(id, type) {
|
|
23315
|
+
return type === "place" ? /^plc_[A-Za-z0-9_-]+$/.test(id) : /^[1-9]\d*$/.test(id);
|
|
23316
|
+
}
|
|
23317
|
+
function fromIds(ctx, raw, type) {
|
|
23318
|
+
const records = [];
|
|
23319
|
+
const invalid2 = [];
|
|
23320
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23321
|
+
let repeats = 0;
|
|
23322
|
+
raw.forEach((id, i) => {
|
|
23323
|
+
const row = i + 1;
|
|
23324
|
+
if (!validId(id, type)) {
|
|
23325
|
+
invalid2.push({ row, status: "invalid", reason: "invalid_id", error: `"${id}" is not ${type === "place" ? "a place id (plc_...)" : `a ${type} id`}.` });
|
|
23326
|
+
} else if (seen.has(id)) {
|
|
23327
|
+
repeats++;
|
|
23328
|
+
} else {
|
|
23329
|
+
seen.add(id);
|
|
23330
|
+
records.push({ row, id });
|
|
23331
|
+
}
|
|
23332
|
+
});
|
|
23333
|
+
if (repeats > 0) ctx.output.warn(`${repeats} repeated id${repeats === 1 ? "" : "s"} left out: each record runs once.`);
|
|
23334
|
+
return { people: false, records, invalid: invalid2 };
|
|
23335
|
+
}
|
|
23336
|
+
async function readRunInput(ctx, opts) {
|
|
23337
|
+
const type = opts.recordType;
|
|
23338
|
+
if (opts.ids === "-") {
|
|
23339
|
+
const text4 = await readStream(ctx.stdin ?? process.stdin);
|
|
23340
|
+
const ids2 = await readIds("-", { stdin: Readable2.from([text4]) });
|
|
23341
|
+
return { input: { path: "-", sha256: createHash12("sha256").update(text4).digest("hex") }, ...fromIds(ctx, ids2, type) };
|
|
23342
|
+
}
|
|
23343
|
+
if (opts.ids !== void 0) {
|
|
23344
|
+
return { input: { path: resolve21(opts.ids), sha256: await fileSha256(opts.ids) }, ...fromIds(ctx, await readIds(opts.ids), type) };
|
|
23345
|
+
}
|
|
23346
|
+
const name = opts.file ?? "";
|
|
23347
|
+
const file = await readInput(name, { stdin: ctx.stdin });
|
|
23348
|
+
const input = { path: file.path, sha256: file.sha256 };
|
|
23349
|
+
const idColumn = file.headers.find((header) => header.trim().toLowerCase() === "id");
|
|
23350
|
+
if (idColumn !== void 0) {
|
|
23351
|
+
return { input, ...fromIds(ctx, file.rows.map((row) => String(row[idColumn] ?? "").trim()), type) };
|
|
23352
|
+
}
|
|
23353
|
+
if (type !== "person") {
|
|
23354
|
+
const importer = IMPORT_COMMANDS[type];
|
|
23355
|
+
throw new KensoError({
|
|
23356
|
+
code: "ids_required",
|
|
23357
|
+
message: `${name} has no id column, and only people can be matched from a file: a run on ${type} records needs their ids.`,
|
|
23358
|
+
exitCode: ExitCode.Usage,
|
|
23359
|
+
field: "file",
|
|
23360
|
+
hint: importer ? `${importer} creates the records and prints their ids.` : "Pass the ids with --ids, one per line.",
|
|
23361
|
+
...importer ? { next: `${importer} --help` } : {}
|
|
23362
|
+
});
|
|
23363
|
+
}
|
|
23364
|
+
const columns2 = mapColumns(file.headers, ALIASES3);
|
|
23365
|
+
const records = [];
|
|
23366
|
+
const invalid2 = [];
|
|
23367
|
+
file.rows.forEach((row, i) => {
|
|
23368
|
+
try {
|
|
23369
|
+
records.push({ row: i + 1, person: toBody2(row, columns2) });
|
|
23370
|
+
} catch (err) {
|
|
23371
|
+
if (!(err instanceof RowInvalid)) throw err;
|
|
23372
|
+
invalid2.push({ row: i + 1, status: "invalid", reason: err.reason, error: err.message });
|
|
23373
|
+
}
|
|
23374
|
+
});
|
|
23375
|
+
return { input, people: true, records, invalid: invalid2 };
|
|
23376
|
+
}
|
|
23377
|
+
async function matchPeople(ctx, records) {
|
|
23378
|
+
const matched = [];
|
|
23379
|
+
const invalid2 = [];
|
|
23380
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23381
|
+
for (let at = 0; at < records.length; at += PEOPLE_CHUNK) {
|
|
23382
|
+
const chunk = records.slice(at, at + PEOPLE_CHUNK);
|
|
23383
|
+
const res = await ctx.client.request({
|
|
23384
|
+
method: "POST",
|
|
23385
|
+
path: "/v1/people/batch",
|
|
23386
|
+
body: { rows: chunk.map((record3) => record3.person) },
|
|
23387
|
+
retrySafe: true,
|
|
23388
|
+
signal: ctx.signal
|
|
23389
|
+
});
|
|
23390
|
+
const byIndex = new Map((unwrap(res.body)?.results ?? []).map((result) => [result.index, result]));
|
|
23391
|
+
chunk.forEach((record3, index2) => {
|
|
23392
|
+
const saved = byIndex.get(index2);
|
|
23393
|
+
const id = saved?.personId !== void 0 && saved.personId !== null ? String(saved.personId) : void 0;
|
|
23394
|
+
if (id === void 0) {
|
|
23395
|
+
invalid2.push({ row: record3.row, status: "invalid", reason: saved?.reason || "person_not_saved", error: saved?.error || "The API saved no person for this row." });
|
|
23396
|
+
} else if (!seen.has(id)) {
|
|
23397
|
+
seen.add(id);
|
|
23398
|
+
matched.push({ row: record3.row, id });
|
|
23399
|
+
}
|
|
23400
|
+
});
|
|
23401
|
+
}
|
|
23402
|
+
return { records: matched, invalid: invalid2 };
|
|
23403
|
+
}
|
|
23404
|
+
var RECORD_TYPES3, PEOPLE_CHUNK, IMPORT_COMMANDS;
|
|
23405
|
+
var init_run_input = __esm({
|
|
23406
|
+
"src/commands/workflows/run-input.ts"() {
|
|
23407
|
+
"use strict";
|
|
23408
|
+
init_input2();
|
|
23409
|
+
init_errors();
|
|
23410
|
+
init_exit_codes();
|
|
23411
|
+
init_http();
|
|
23412
|
+
init_input();
|
|
23413
|
+
init_common();
|
|
23414
|
+
init_columns();
|
|
23415
|
+
init_import5();
|
|
23416
|
+
RECORD_TYPES3 = ["account", "person", "lead", "place"];
|
|
23417
|
+
PEOPLE_CHUNK = 200;
|
|
23418
|
+
IMPORT_COMMANDS = { lead: "kenso contacts import", account: "kenso accounts import" };
|
|
23419
|
+
}
|
|
23420
|
+
});
|
|
23421
|
+
|
|
23422
|
+
// src/commands/workflows/run-start.ts
|
|
23423
|
+
import { readFileSync as readFileSync21 } from "node:fs";
|
|
23424
|
+
import { unlink as unlink4 } from "node:fs/promises";
|
|
23425
|
+
import { join as join32 } from "node:path";
|
|
23426
|
+
function readJournal(file) {
|
|
23427
|
+
try {
|
|
23428
|
+
return JSON.parse(readFileSync21(file, "utf8"));
|
|
23429
|
+
} catch {
|
|
23430
|
+
return void 0;
|
|
23431
|
+
}
|
|
23432
|
+
}
|
|
23433
|
+
function unknownOutcome(workflowId, journal) {
|
|
23434
|
+
return {
|
|
23435
|
+
exitCode: ExitCode.Partial,
|
|
23436
|
+
code: "chunk_outcome_unknown",
|
|
23437
|
+
message: `Rows ${journal.firstRow} to ${journal.lastRow} were sent at ${journal.sentAt} and no answer was recorded, so they are not sent again.`,
|
|
23438
|
+
next: `kenso workflow-runs list --workflow-id ${workflowId} --created-after ${journal.sentAt}`
|
|
23439
|
+
};
|
|
23440
|
+
}
|
|
23441
|
+
function answeredJournals(run, workflowId) {
|
|
23442
|
+
if (run.status === "running" && isOtherLiveProcess(run.pid)) {
|
|
23443
|
+
const { runId, pid } = run;
|
|
23444
|
+
throw new KensoError({ code: "run_in_progress", message: `Run ${runId} on this input is running in process ${pid}.`, exitCode: ExitCode.Conflict, next: `kenso runs show ${runId}` });
|
|
23445
|
+
}
|
|
23446
|
+
const journals = [];
|
|
23447
|
+
for (let index2 = 0; index2 < run.chunkCount; index2++) {
|
|
23448
|
+
const journal = readJournal(journalFile(run.dir, index2));
|
|
23449
|
+
if (journal && journal.response === void 0) throw new KensoError(unknownOutcome(workflowId, journal));
|
|
23450
|
+
if (journal) journals.push(journal);
|
|
23451
|
+
}
|
|
23452
|
+
return journals;
|
|
23453
|
+
}
|
|
23454
|
+
async function earlierRun(ctx, args, sha2565, workflowId) {
|
|
23455
|
+
const earlier = (await findIdentical(COMMAND7, args, sha2565, ctx.env, ctx.client.workspaceId ?? ctx.auth.workspaceId)).filter((run) => run.status !== "planned");
|
|
23456
|
+
const open2 = earlier.find((run) => run.status !== "done");
|
|
23457
|
+
if (open2) {
|
|
23458
|
+
answeredJournals(open2, workflowId);
|
|
23459
|
+
return void 0;
|
|
23460
|
+
}
|
|
23461
|
+
const done2 = earlier[0];
|
|
23462
|
+
if (!done2) return void 0;
|
|
23463
|
+
const summary = readSummary(filesOf(done2.dir).summaryJson) ?? { run: done2.runId };
|
|
23464
|
+
ctx.output.info(`Run ${done2.runId} already finished on this input, so nothing was started again. To run the same records again, pass a changed input file.`);
|
|
23465
|
+
ctx.output.summary({ ...summary, alreadyDone: true });
|
|
23466
|
+
return Number(summary.notStarted ?? 0) + Number(summary.failed ?? 0) > 0 ? ExitCode.Partial : ExitCode.Ok;
|
|
23467
|
+
}
|
|
23468
|
+
async function refuseRestart(ctx, run) {
|
|
23469
|
+
const loose = (args) => argsIdentity({ ...args, "max-credits": void 0 });
|
|
23470
|
+
const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
|
|
23471
|
+
const itemsSha256 = hashItems(run.items);
|
|
23472
|
+
for (const earlier of await listRuns(ctx.env)) {
|
|
23473
|
+
if (earlier.command !== COMMAND7 || earlier.status === "planned" || earlier.inputSha256 !== run.sha256 || loose(earlier.args) !== loose(run.args)) continue;
|
|
23474
|
+
if ((earlier.workspaceId || void 0) !== (workspaceId || void 0)) continue;
|
|
23475
|
+
if (earlier.status !== "done" && argsIdentity(earlier.args) === argsIdentity(run.args) && (earlier.itemsSha256 ?? itemsSha256) === itemsSha256) continue;
|
|
23476
|
+
const sent = /* @__PURE__ */ new Set();
|
|
23477
|
+
for (const journal of answeredJournals(earlier, run.workflowId)) for (const item of run.items) if (item.row >= journal.firstRow && item.row <= journal.lastRow) sent.add(item.row);
|
|
23478
|
+
for (const [row, { status }] of await readResults(filesOf(earlier.dir).resultsNdjson)) if (!["not_started", "invalid"].includes(status)) sent.add(row);
|
|
23479
|
+
if (sent.size === 0) continue;
|
|
23480
|
+
const rest = run.items.filter((item) => !sent.has(item.row));
|
|
23481
|
+
const file = join32(earlier.dir, "not-started.txt");
|
|
23482
|
+
if (rest.length > 0) await writeFileAtomic(file, rest.map((item) => `${item.id}
|
|
23483
|
+
`).join(""));
|
|
23484
|
+
throw new KensoError({
|
|
23485
|
+
code: "already_started",
|
|
23486
|
+
message: `Run ${earlier.runId} already sent starts for ${sent.size} records of this input, so this run would start them twice.`,
|
|
23487
|
+
exitCode: ExitCode.Conflict,
|
|
23488
|
+
hint: rest.length > 0 ? `${file} holds the ${rest.length} ids that run did not start; next runs only those.` : "That run sent every record of this input.",
|
|
23489
|
+
next: rest.length > 0 ? run.rerun(file) : `kenso workflow-runs list --workflow-id ${run.workflowId}`
|
|
23490
|
+
});
|
|
23491
|
+
}
|
|
23492
|
+
}
|
|
23493
|
+
async function startChunk(chunk, cc, run) {
|
|
23494
|
+
const held = notStarted(chunk.filter((item) => !run.start.has(item.row)), "over --max-credits");
|
|
23495
|
+
const starters = chunk.filter((item) => run.start.has(item.row));
|
|
23496
|
+
if (starters.length === 0) return { results: held };
|
|
23497
|
+
const file = journalFile(run.dirOf(cc.runId), cc.chunkIndex);
|
|
23498
|
+
const stopOn = (sent) => {
|
|
23499
|
+
const { next, ...stop } = unknownOutcome(run.workflowId, sent);
|
|
23500
|
+
return { results: held, stop: { ...stop, hint: `See what started: ${next}` } };
|
|
23501
|
+
};
|
|
23502
|
+
let journal = readJournal(file);
|
|
23503
|
+
let remaining;
|
|
23504
|
+
if (journal?.response === void 0) {
|
|
23505
|
+
if (journal) return stopOn(journal);
|
|
23506
|
+
const sent = { sentAt: (/* @__PURE__ */ new Date()).toISOString(), firstRow: starters[0].row, lastRow: starters[starters.length - 1].row };
|
|
23507
|
+
await writeJsonAtomic(file, sent);
|
|
23508
|
+
try {
|
|
23509
|
+
const res = await cc.client.request({
|
|
23510
|
+
method: "POST",
|
|
23511
|
+
path: `/v1/workflows/${run.workflowId}/runs`,
|
|
23512
|
+
body: { records: starters.map(({ type, id }) => ({ type, id })) },
|
|
23513
|
+
signal: cc.signal
|
|
23514
|
+
});
|
|
23515
|
+
journal = { ...sent, response: unwrap(res.body) ?? {} };
|
|
23516
|
+
await writeJsonAtomic(file, journal);
|
|
23517
|
+
remaining = rateLimitRemaining2(res.headers);
|
|
23518
|
+
} catch (err) {
|
|
23519
|
+
const error = err instanceof KensoError ? err : void 0;
|
|
23520
|
+
if (error?.httpStatus !== void 0 && error.httpStatus < 500) {
|
|
23521
|
+
await unlink4(file).catch(() => void 0);
|
|
23522
|
+
const exitCode = error.httpStatus === 402 ? ExitCode.RateLimited : error.exitCode;
|
|
23523
|
+
const stop = { exitCode, code: error.code, message: error.message, ...error.hint ? { hint: error.hint } : {} };
|
|
23524
|
+
return { results: [...notStarted(starters, error.code), ...held], stop };
|
|
23525
|
+
}
|
|
23526
|
+
if (cc.signal.aborted || error?.exitCode === ExitCode.Interrupted) throw err;
|
|
23527
|
+
return stopOn(sent);
|
|
23528
|
+
}
|
|
23529
|
+
}
|
|
23530
|
+
const answers = journal.response?.results ?? [];
|
|
23531
|
+
const results = starters.map((item, i) => {
|
|
23532
|
+
const answer = answers[i];
|
|
23533
|
+
return {
|
|
23534
|
+
row: item.row,
|
|
23535
|
+
id: item.id,
|
|
23536
|
+
// The API's own status: started, deduplicated, over_limit, not_live, not_found or failed.
|
|
23537
|
+
status: answer?.status ?? "failed",
|
|
23538
|
+
...answer?.runId !== void 0 && answer.runId !== null ? { runId: answer.runId } : {},
|
|
23539
|
+
...answer?.status ? {} : { reason: "no_result" }
|
|
23540
|
+
};
|
|
23541
|
+
});
|
|
23542
|
+
return { results: [...results, ...held], rateLimitRemaining: remaining };
|
|
23543
|
+
}
|
|
23544
|
+
var COMMAND7, journalFile, notStarted;
|
|
23545
|
+
var init_run_start = __esm({
|
|
23546
|
+
"src/commands/workflows/run-start.ts"() {
|
|
23547
|
+
"use strict";
|
|
23548
|
+
init_results();
|
|
23549
|
+
init_runs();
|
|
23550
|
+
init_errors();
|
|
23551
|
+
init_exit_codes();
|
|
23552
|
+
init_http();
|
|
23553
|
+
init_columns();
|
|
23554
|
+
COMMAND7 = "workflows run";
|
|
23555
|
+
journalFile = (dir3, index2) => join32(dir3, `chunk-${index2}.json`);
|
|
23556
|
+
notStarted = (items, reason) => items.map((item) => ({ row: item.row, ...item.id ? { id: item.id } : {}, status: "not_started", reason }));
|
|
23557
|
+
}
|
|
23558
|
+
});
|
|
23559
|
+
|
|
23560
|
+
// src/commands/workflows/run.ts
|
|
23561
|
+
var run_exports4 = {};
|
|
23562
|
+
__export(run_exports4, {
|
|
23563
|
+
default: () => run_default3
|
|
23564
|
+
});
|
|
23565
|
+
import { join as join33 } from "node:path";
|
|
23566
|
+
async function resolveTarget(ctx, target2) {
|
|
23567
|
+
const isId = /^[1-9]\d*$/.test(target2);
|
|
23568
|
+
const file = isId ? void 0 : readWorkflowFile(target2).definition;
|
|
23569
|
+
const workflowId = isId ? Number(target2) : findBinding(target2, ctx.auth).workflowId;
|
|
23570
|
+
if (workflowId === void 0) throw notBoundError(target2, `${target2} is not bound to a workflow: run needs a published one.`);
|
|
23571
|
+
const workflow = await getWorkflow(ctx, workflowId);
|
|
23572
|
+
const published = await publishedDefinition(ctx, workflow);
|
|
23573
|
+
if (file !== void 0 && (published === void 0 || !sameDefinition(file, published))) {
|
|
23574
|
+
const hash = workflow.draft?.definitionHash;
|
|
23575
|
+
const inDraft = typeof hash === "string" && sameDefinition(file, workflow.definition);
|
|
23576
|
+
const push = `kenso workflows push ${shellQuote3(target2)}`;
|
|
23577
|
+
throw new KensoError({
|
|
23578
|
+
code: "unpublished_changes",
|
|
23579
|
+
message: "This file differs from the published version.",
|
|
23580
|
+
exitCode: ExitCode.Conflict,
|
|
23581
|
+
hint: inDraft ? "The saved draft holds this file: publish it once kenso workflows test passed on it." : "Save the file, test it, then publish it.",
|
|
23582
|
+
next: inDraft ? `${push} --publish --expected-hash ${hash}` : push
|
|
23583
|
+
});
|
|
23584
|
+
}
|
|
23585
|
+
if (workflow.status !== "live" || published === void 0) {
|
|
23586
|
+
throw new KensoError({ code: "invalid_state", message: `Workflow ${workflowId} is not live.`, exitCode: ExitCode.Conflict, next: `kenso workflows publish --workflow-id ${workflowId}` });
|
|
23587
|
+
}
|
|
23588
|
+
return { workflowId, definition: published };
|
|
23589
|
+
}
|
|
23590
|
+
function recordTypeOf(definition, flag) {
|
|
23591
|
+
const known = (value) => RECORD_TYPES3.includes(value);
|
|
23592
|
+
if (flag !== void 0) {
|
|
23593
|
+
if (!known(flag)) throw usageError(`--record-type must be one of ${RECORD_TYPES3.join(", ")} (got "${flag}").`, { field: "record-type" });
|
|
23594
|
+
return flag;
|
|
23595
|
+
}
|
|
23596
|
+
const trigger = definition?.trigger;
|
|
23597
|
+
const declared = trigger?.type === "trigger.manual@1" ? trigger.with?.recordType : loadStepTypes().find((type) => type.type === trigger?.type)?.recordType;
|
|
23598
|
+
if (known(declared)) return declared;
|
|
23599
|
+
throw new KensoError({
|
|
23600
|
+
code: "not_runnable_on_records",
|
|
23601
|
+
message: `The trigger ${trigger?.type ?? "of this workflow"} names no record type, so it cannot run on records.`,
|
|
23602
|
+
exitCode: ExitCode.Usage,
|
|
23603
|
+
field: "record-type",
|
|
23604
|
+
hint: `Pass --record-type ${RECORD_TYPES3.join(", ")} when the workflow can run on picked records.`
|
|
23605
|
+
});
|
|
23606
|
+
}
|
|
23607
|
+
function totalsOf(estimate2) {
|
|
23608
|
+
const e = estimate2 ?? {};
|
|
23609
|
+
const n = (key) => typeof e[key] === "number" ? e[key] : 0;
|
|
23610
|
+
return e.bulkPriceApplies === true ? { max: n("bulkMaxMillicredits"), expected: n("bulkExpectedMillicredits") } : { max: n("maxMillicredits"), expected: n("expectedMillicredits") };
|
|
23611
|
+
}
|
|
23612
|
+
async function estimate(ctx, target2, type, records, peopleRows) {
|
|
23613
|
+
if (peopleRows !== void 0) {
|
|
23614
|
+
if (peopleRows === 0) return { max: 0, expected: 0 };
|
|
23615
|
+
const result = await workflowEstimate(ctx, { definition: target2.definition, records: peopleRows });
|
|
23616
|
+
const failed = result.estimateError;
|
|
23617
|
+
if (failed) throw new KensoError({ code: failed.code ?? "estimate_failed", message: failed.message, exitCode: ExitCode.Error });
|
|
23618
|
+
return totalsOf(result.estimate);
|
|
23619
|
+
}
|
|
23620
|
+
const total = { max: 0, expected: 0 };
|
|
23621
|
+
for (let at = 0; at < records.length; at += CHUNK_SIZE7) {
|
|
23622
|
+
const res = await ctx.client.request({
|
|
23623
|
+
method: "POST",
|
|
23624
|
+
path: `/v1/workflows/${target2.workflowId}/runs`,
|
|
23625
|
+
body: { records: records.slice(at, at + CHUNK_SIZE7).map((record3) => ({ type, id: record3.id })), estimateOnly: true },
|
|
23626
|
+
retrySafe: true,
|
|
23627
|
+
signal: ctx.signal
|
|
23628
|
+
});
|
|
23629
|
+
const part = totalsOf(unwrap(res.body)?.estimate);
|
|
23630
|
+
total.max += part.max;
|
|
23631
|
+
total.expected += part.expected;
|
|
23632
|
+
}
|
|
23633
|
+
return total;
|
|
23634
|
+
}
|
|
23635
|
+
function summarize4(workflowId, records, cap) {
|
|
23636
|
+
return (results) => {
|
|
23637
|
+
const count = (...statuses) => results.filter((result) => statuses.includes(result.status)).length;
|
|
23638
|
+
return {
|
|
23639
|
+
workflowId,
|
|
23640
|
+
records,
|
|
23641
|
+
started: count("started"),
|
|
23642
|
+
deduplicated: count("deduplicated"),
|
|
23643
|
+
notStarted: count("not_started", "over_limit", "not_live", "not_found"),
|
|
23644
|
+
succeeded: 0,
|
|
23645
|
+
failed: count("failed", "invalid"),
|
|
23646
|
+
waiting: 0,
|
|
23647
|
+
missed: {},
|
|
23648
|
+
creditsCharged: "pending",
|
|
23649
|
+
cap: cap(),
|
|
23650
|
+
resultsCsv: null,
|
|
23651
|
+
appUrl: `${APP_URL}/workflows/${workflowId}`,
|
|
23652
|
+
next: `kenso workflow-runs list --workflow-id ${workflowId}`
|
|
23653
|
+
};
|
|
23654
|
+
};
|
|
23655
|
+
}
|
|
23656
|
+
var NAME2, CHUNK_SIZE7, APP_URL, LIST_HINT, command85, run_default3;
|
|
23657
|
+
var init_run4 = __esm({
|
|
23658
|
+
"src/commands/workflows/run.ts"() {
|
|
23659
|
+
"use strict";
|
|
23660
|
+
init_engine();
|
|
23661
|
+
init_runs();
|
|
23662
|
+
init_confirm();
|
|
23663
|
+
init_errors();
|
|
23664
|
+
init_estimate();
|
|
23665
|
+
init_exit_codes();
|
|
23666
|
+
init_http();
|
|
23667
|
+
init_step_types();
|
|
23668
|
+
init_columns();
|
|
23669
|
+
init_files2();
|
|
23670
|
+
init_run_cap();
|
|
23671
|
+
init_run_input();
|
|
23672
|
+
init_run_start();
|
|
23673
|
+
NAME2 = `kenso ${COMMAND7}`;
|
|
23674
|
+
CHUNK_SIZE7 = 1e3;
|
|
23675
|
+
APP_URL = "https://app.ken.so";
|
|
23676
|
+
LIST_HINT = "A saved list runs through a workflow whose trigger is trigger.saved_list@1 or trigger.csv@1; kenso workflows run takes --ids or --file.";
|
|
23677
|
+
command85 = {
|
|
23678
|
+
resource: "workflows",
|
|
23679
|
+
action: "run",
|
|
23680
|
+
summary: "Run a published workflow on records from an ids file or a CSV",
|
|
23681
|
+
brief: "on ids or a CSV",
|
|
23682
|
+
description: "Starts one run per record on the workflow's published version. The target is a workflow id, or a workflow file bound in kenso.json that equals the published version. --ids is one id per line; --file is a CSV with an id column, or for a workflow that runs on people a CSV of people (the columns of kenso people import), matched or created first. Without --yes it prints the plan with the credit estimate and starts nothing. --max-credits starts only as many records as the cap covers and reports the rest as not_started. The same command on the same input never starts its records twice; another --max-credits on that input is refused with an ids file of the records not started yet. Exit 5 when some records failed, were not found or were not started, 6 when the cap starts nothing or the workspace is out of credits, 7 when the file differs from the published version or the workflow is not live.",
|
|
23683
|
+
effect: "send",
|
|
23684
|
+
doc: {
|
|
23685
|
+
when: "You have a published workflow and the records to run it on.",
|
|
23686
|
+
cost: "the workflow's steps; --dry-run prints the estimate",
|
|
23687
|
+
next: "kenso workflow-runs list --workflow-id <id>"
|
|
23688
|
+
},
|
|
23689
|
+
flags: {
|
|
23690
|
+
ids: { type: "string", description: "A file with one record id per line, or - for stdin" },
|
|
23691
|
+
file: { type: "string", description: "A CSV with an id column, or a CSV of people for a workflow that runs on people" },
|
|
23692
|
+
"record-type": { type: "string", description: "account, person, lead or place (default: the type the trigger runs on)" },
|
|
23693
|
+
"max-credits": { type: "string", description: "Start only as many records as this many credits cover" },
|
|
23694
|
+
// Declared only so the refusal can carry its hint: main refuses an undeclared flag before the command runs.
|
|
23695
|
+
list: { type: "string", helpHidden: true, description: "Not a flag: a saved list runs through its own trigger" }
|
|
23696
|
+
},
|
|
23697
|
+
positionals: [{ name: "target", required: true, description: "A workflow file bound in kenso.json, or a workflow id" }],
|
|
23698
|
+
examples: [
|
|
23699
|
+
"kenso workflows run qualify.workflow.json --ids ids.txt --dry-run",
|
|
23700
|
+
"kenso workflows run qualify.workflow.json --ids ids.txt --max-credits 50 --yes",
|
|
23701
|
+
"kenso workflows run 412 --file people.csv --record-type person --dry-run"
|
|
23702
|
+
],
|
|
23703
|
+
beta: { featureGates: WORKFLOWS_GATES },
|
|
23704
|
+
// workflow-runs.get is read by --wait.
|
|
23705
|
+
operationIds: ["workflows.get", "workflow-runs.run-on-records", "workflow-runs.get", "workflow-estimates.create", "credits.get", "people.batch", "workflow-versions.get"],
|
|
23706
|
+
dryRun: true,
|
|
23707
|
+
batch: true,
|
|
23708
|
+
async run(ctx, { flags, positionals }) {
|
|
23709
|
+
if (flags.list !== void 0) {
|
|
23710
|
+
throw new KensoError({ code: "unknown_flag", message: `Unknown flag --list for ${NAME2}.`, exitCode: ExitCode.Usage, field: "list", hint: LIST_HINT, next: `${NAME2} --help` });
|
|
23711
|
+
}
|
|
23712
|
+
const ids2 = stringFlag(flags.ids);
|
|
23713
|
+
const csv = stringFlag(flags.file);
|
|
23714
|
+
if (ids2 === void 0 === (csv === void 0)) throw usageError("Pass one of --ids and --file.", { field: "ids", next: `${NAME2} --help` });
|
|
23715
|
+
const maxCredits = maxCreditsOf(flags["max-credits"]);
|
|
23716
|
+
const apply = ctx.flags.yes === true;
|
|
23717
|
+
const target2 = await resolveTarget(ctx, positionals[0] ?? "");
|
|
23718
|
+
const { workflowId } = target2;
|
|
23719
|
+
const type = recordTypeOf(target2.definition, stringFlag(flags["record-type"]));
|
|
23720
|
+
const input = await readRunInput(ctx, { ids: ids2, file: csv, recordType: type });
|
|
23721
|
+
const rows = input.records.length + input.invalid.length;
|
|
23722
|
+
const basis = input.people ? rows : input.records.length;
|
|
23723
|
+
let totals;
|
|
23724
|
+
let check;
|
|
23725
|
+
let estimateError;
|
|
23726
|
+
try {
|
|
23727
|
+
totals = await estimate(ctx, target2, type, input.records, input.people ? rows : void 0);
|
|
23728
|
+
const balance = await ctx.client.request({ method: "GET", path: "/v1/credits", signal: ctx.signal });
|
|
23729
|
+
check = creditsCheck(totals.max, unwrap(balance.body)?.availableMillicredits);
|
|
23730
|
+
} catch (err) {
|
|
23731
|
+
if (apply || !(err instanceof KensoError) || err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.Interrupted) throw err;
|
|
23732
|
+
estimateError = { code: err.code, message: err.message };
|
|
23733
|
+
}
|
|
23734
|
+
const hard = hardCeiling(target2.definition);
|
|
23735
|
+
const ceiling = hard ?? (totals && basis > 0 ? totals.max / basis / 1e3 : void 0);
|
|
23736
|
+
const retry = (cap2) => commandLine2(ctx, COMMAND7, { flags: { ...flags, "max-credits": String(cap2) }, positionals });
|
|
23737
|
+
const capFor = (count) => maxCredits !== void 0 && ceiling !== void 0 ? planCap(maxCredits, count, hard !== void 0 ? "hard" : "estimate", ceiling, retry) : null;
|
|
23738
|
+
let cap = capFor(input.records.length);
|
|
23739
|
+
const args = { ...flags, positionals };
|
|
23740
|
+
const applyCommand = commandLine2(ctx, COMMAND7, { flags, positionals }, ["--yes"]);
|
|
23741
|
+
const plan2 = {
|
|
23742
|
+
workflowId,
|
|
23743
|
+
records: rows,
|
|
23744
|
+
recordType: type,
|
|
23745
|
+
...check ? { credits: check } : {},
|
|
23746
|
+
perRecord: totals && basis > 0 ? { expectedCredits: credits2(totals.expected / basis / 1e3), maxCredits: credits2(totals.max / basis / 1e3) } : null,
|
|
23747
|
+
expectedCredits: totals ? credits2(totals.expected / 1e3) : null,
|
|
23748
|
+
cap,
|
|
23749
|
+
...estimateError ? { estimateError } : {}
|
|
23750
|
+
};
|
|
23751
|
+
let start = /* @__PURE__ */ new Set();
|
|
23752
|
+
const spec = (dryRun2, records2, invalid3) => ({
|
|
23753
|
+
command: COMMAND7,
|
|
23754
|
+
args,
|
|
23755
|
+
input: input.input,
|
|
23756
|
+
items: records2.map((record3) => ({ row: record3.row, type, ...record3.id !== void 0 ? { id: record3.id } : {} })),
|
|
23757
|
+
rowOf: (item) => item.row,
|
|
23758
|
+
chunkSize: CHUNK_SIZE7,
|
|
23759
|
+
concurrency: 1,
|
|
23760
|
+
execChunk: (chunk, cc) => startChunk(chunk, cc, { dirOf: (runId) => join33(runsRoot(ctx.env), runId), workflowId, start }),
|
|
23761
|
+
invalid: invalid3,
|
|
23762
|
+
dryRun: dryRun2,
|
|
23763
|
+
dryRunExtra: plan2,
|
|
23764
|
+
applyCommand,
|
|
23765
|
+
summarize: summarize4(workflowId, records2.length + invalid3.length, () => cap)
|
|
23766
|
+
});
|
|
23767
|
+
if (!apply) {
|
|
23768
|
+
const planned = await runBatch(spec(true, input.records, input.invalid), ctx);
|
|
23769
|
+
if (ctx.flags.dryRun === true || !canAsk(ctx) || estimateError) return planned.exitCode;
|
|
23770
|
+
await confirmDestructive(ctx, `Start ${cap ? cap.willStart : input.records.length} of ${rows} records on workflow ${workflowId}`, applyCommand);
|
|
23771
|
+
}
|
|
23772
|
+
const answered = await earlierRun(ctx, args, input.input.sha256, workflowId);
|
|
23773
|
+
if (answered !== void 0) return answered;
|
|
23774
|
+
if (check?.available != null && check.available <= 0 && (check.needed ?? 0) > 0) {
|
|
23775
|
+
throw new KensoError({ code: "out_of_credits", message: "The workspace is out of credits, so nothing was started.", exitCode: ExitCode.RateLimited });
|
|
23776
|
+
}
|
|
23777
|
+
let records = input.records;
|
|
23778
|
+
let invalid2 = input.invalid;
|
|
23779
|
+
if (input.people) {
|
|
23780
|
+
const matched = await matchPeople(ctx, records);
|
|
23781
|
+
records = matched.records;
|
|
23782
|
+
invalid2 = [...invalid2, ...matched.invalid];
|
|
23783
|
+
cap = capFor(records.length);
|
|
23784
|
+
}
|
|
23785
|
+
start = new Set(records.slice(0, cap ? cap.willStart : records.length).map((record3) => record3.row));
|
|
23786
|
+
const applied = spec(false, records, invalid2);
|
|
23787
|
+
const rerun = (ids3) => commandLine2(ctx, COMMAND7, { flags: { ...flags, ids: ids3, file: void 0 }, positionals }, ["--yes"]);
|
|
23788
|
+
await refuseRestart(ctx, { args, sha256: input.input.sha256, workflowId, items: applied.items, rerun });
|
|
23789
|
+
const outcome = await runBatch(applied, ctx);
|
|
23790
|
+
const s = outcome.summary;
|
|
23791
|
+
ctx.output.info(`workflow ${workflowId}: ${s.started} started, ${s.deduplicated} deduplicated, ${s.notStarted} not started, ${s.failed} failed of ${s.records} records`);
|
|
23792
|
+
if (outcome.exitCode !== ExitCode.Ok) return outcome.exitCode;
|
|
23793
|
+
return Number(s.notStarted ?? 0) + Number(s.failed ?? 0) > 0 ? ExitCode.Partial : ExitCode.Ok;
|
|
23794
|
+
}
|
|
23795
|
+
};
|
|
23796
|
+
run_default3 = command85;
|
|
23797
|
+
}
|
|
23798
|
+
});
|
|
23799
|
+
|
|
23240
23800
|
// src/commands/workflows/run-actions.ts
|
|
23241
23801
|
var runActions;
|
|
23242
23802
|
var init_run_actions = __esm({
|
|
23243
23803
|
"src/commands/workflows/run-actions.ts"() {
|
|
23244
23804
|
"use strict";
|
|
23245
|
-
runActions = {
|
|
23805
|
+
runActions = {
|
|
23806
|
+
run: () => Promise.resolve().then(() => (init_run4(), run_exports4)).then((m) => m.default)
|
|
23807
|
+
};
|
|
23246
23808
|
}
|
|
23247
23809
|
});
|
|
23248
23810
|
|
|
@@ -23278,7 +23840,7 @@ function rewrap(err, overrides2) {
|
|
|
23278
23840
|
details: err.details
|
|
23279
23841
|
});
|
|
23280
23842
|
}
|
|
23281
|
-
var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE,
|
|
23843
|
+
var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command86, keys_default;
|
|
23282
23844
|
var init_keys = __esm({
|
|
23283
23845
|
"src/commands/workspace/keys.ts"() {
|
|
23284
23846
|
"use strict";
|
|
@@ -23288,7 +23850,7 @@ var init_keys = __esm({
|
|
|
23288
23850
|
TEMPLATES = ["admin", "editor", "viewer"];
|
|
23289
23851
|
APP_NEXT_STEP = "A workspace admin can create it in the app: Settings > API keys > Workspace keys";
|
|
23290
23852
|
NOT_AVAILABLE = "Workspace keys are not available for this workspace yet.";
|
|
23291
|
-
|
|
23853
|
+
command86 = {
|
|
23292
23854
|
resource: "workspace",
|
|
23293
23855
|
action: "keys",
|
|
23294
23856
|
summary: "Create an API key the workspace owns",
|
|
@@ -23350,7 +23912,7 @@ var init_keys = __esm({
|
|
|
23350
23912
|
return ExitCode.Ok;
|
|
23351
23913
|
}
|
|
23352
23914
|
};
|
|
23353
|
-
keys_default =
|
|
23915
|
+
keys_default = command86;
|
|
23354
23916
|
}
|
|
23355
23917
|
});
|
|
23356
23918
|
|
|
@@ -23368,14 +23930,14 @@ function parseLimit2(value) {
|
|
|
23368
23930
|
}
|
|
23369
23931
|
return limit;
|
|
23370
23932
|
}
|
|
23371
|
-
var MAX_LIMIT2,
|
|
23933
|
+
var MAX_LIMIT2, command87, list_default5;
|
|
23372
23934
|
var init_list5 = __esm({
|
|
23373
23935
|
"src/commands/workspace/list.ts"() {
|
|
23374
23936
|
"use strict";
|
|
23375
23937
|
init_errors();
|
|
23376
23938
|
init_exit_codes();
|
|
23377
23939
|
MAX_LIMIT2 = 200;
|
|
23378
|
-
|
|
23940
|
+
command87 = {
|
|
23379
23941
|
resource: "workspace",
|
|
23380
23942
|
action: "list",
|
|
23381
23943
|
summary: "List the workspaces your key can use",
|
|
@@ -23404,7 +23966,7 @@ var init_list5 = __esm({
|
|
|
23404
23966
|
return ExitCode.Ok;
|
|
23405
23967
|
}
|
|
23406
23968
|
};
|
|
23407
|
-
list_default5 =
|
|
23969
|
+
list_default5 = command87;
|
|
23408
23970
|
}
|
|
23409
23971
|
});
|
|
23410
23972
|
|
|
@@ -23413,7 +23975,7 @@ var use_exports = {};
|
|
|
23413
23975
|
__export(use_exports, {
|
|
23414
23976
|
default: () => use_default
|
|
23415
23977
|
});
|
|
23416
|
-
var
|
|
23978
|
+
var command88, use_default;
|
|
23417
23979
|
var init_use = __esm({
|
|
23418
23980
|
"src/commands/workspace/use.ts"() {
|
|
23419
23981
|
"use strict";
|
|
@@ -23421,7 +23983,7 @@ var init_use = __esm({
|
|
|
23421
23983
|
init_errors();
|
|
23422
23984
|
init_exit_codes();
|
|
23423
23985
|
init_http();
|
|
23424
|
-
|
|
23986
|
+
command88 = {
|
|
23425
23987
|
resource: "workspace",
|
|
23426
23988
|
action: "use",
|
|
23427
23989
|
summary: "Set the profile's default workspace",
|
|
@@ -23483,7 +24045,7 @@ var init_use = __esm({
|
|
|
23483
24045
|
return ExitCode.Ok;
|
|
23484
24046
|
}
|
|
23485
24047
|
};
|
|
23486
|
-
use_default =
|
|
24048
|
+
use_default = command88;
|
|
23487
24049
|
}
|
|
23488
24050
|
});
|
|
23489
24051
|
|
|
@@ -24101,14 +24663,14 @@ var init_pre_run = __esm({
|
|
|
24101
24663
|
});
|
|
24102
24664
|
|
|
24103
24665
|
// src/core/update-notice.ts
|
|
24104
|
-
import { mkdirSync as mkdirSync8, readFileSync as
|
|
24105
|
-
import { dirname as dirname7, join as
|
|
24666
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync22, realpathSync as realpathSync2, renameSync as renameSync8, writeFileSync as writeFileSync13 } from "node:fs";
|
|
24667
|
+
import { dirname as dirname7, join as join34, sep as sep4 } from "node:path";
|
|
24106
24668
|
function installKind(script = process.argv[1], execPath = process.execPath, platform = process.platform) {
|
|
24107
24669
|
try {
|
|
24108
24670
|
if (!script) return "npm";
|
|
24109
24671
|
const bundle = realpathSync2(script);
|
|
24110
24672
|
const lib = dirname7(dirname7(dirname7(bundle)));
|
|
24111
|
-
if (execPath !==
|
|
24673
|
+
if (execPath !== join34(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
|
|
24112
24674
|
return bundle.includes(`${sep4}Cellar${sep4}kenso${sep4}`) ? "homebrew" : "standalone";
|
|
24113
24675
|
} catch {
|
|
24114
24676
|
return "npm";
|
|
@@ -24121,7 +24683,7 @@ function updateCommand(install, platform) {
|
|
|
24121
24683
|
}
|
|
24122
24684
|
function readCheck(file) {
|
|
24123
24685
|
try {
|
|
24124
|
-
const parsed2 = JSON.parse(
|
|
24686
|
+
const parsed2 = JSON.parse(readFileSync22(file, "utf8"));
|
|
24125
24687
|
if (typeof parsed2?.checkedAt !== "string") return void 0;
|
|
24126
24688
|
return { checkedAt: parsed2.checkedAt, ...typeof parsed2.latest === "string" ? { latest: parsed2.latest } : {} };
|
|
24127
24689
|
} catch {
|
|
@@ -24162,13 +24724,13 @@ async function fetchLatest(fetchImpl, signal, install) {
|
|
|
24162
24724
|
return typeof body2?.version === "string" && RELEASE.test(body2.version) ? body2.version : void 0;
|
|
24163
24725
|
}
|
|
24164
24726
|
function agentNotice(env, agent, version, stderr, opts) {
|
|
24165
|
-
const latest = readCheck(
|
|
24727
|
+
const latest = readCheck(join34(configDir(env), UPDATE_CHECK_FILE))?.latest;
|
|
24166
24728
|
if (latest === void 0 || !isNewer(latest, version)) return done;
|
|
24167
24729
|
return async () => {
|
|
24168
24730
|
try {
|
|
24169
24731
|
if (!firstInSession(env, agent, "update")) return;
|
|
24170
|
-
const
|
|
24171
|
-
stderr.write(`kenso ${latest} is out (you have ${version}): ${
|
|
24732
|
+
const command89 = updateCommand(opts.install ?? installKind(), opts.platform ?? process.platform);
|
|
24733
|
+
stderr.write(`kenso ${latest} is out (you have ${version}): ${command89}
|
|
24172
24734
|
`);
|
|
24173
24735
|
} catch {
|
|
24174
24736
|
}
|
|
@@ -24184,7 +24746,7 @@ function startUpdateNotice(argv, opts = {}) {
|
|
|
24184
24746
|
const agent = detectAgent(env);
|
|
24185
24747
|
if (agent !== null) return agentNotice(env, agent, version, stderr, opts);
|
|
24186
24748
|
if (!(opts.stderrIsTTY ?? process.stderr.isTTY === true)) return done;
|
|
24187
|
-
const file =
|
|
24749
|
+
const file = join34(configDir(env), UPDATE_CHECK_FILE);
|
|
24188
24750
|
const now = (opts.now ?? Date.now)();
|
|
24189
24751
|
const cached = readCheck(file);
|
|
24190
24752
|
const checkedAt = Date.parse(cached?.checkedAt ?? "");
|
|
@@ -24203,8 +24765,8 @@ function startUpdateNotice(argv, opts = {}) {
|
|
|
24203
24765
|
if (!found) return;
|
|
24204
24766
|
writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
|
|
24205
24767
|
if (isNewer(found, version)) {
|
|
24206
|
-
const
|
|
24207
|
-
stderr.write(`kenso ${found} is out (you have ${version}): ${
|
|
24768
|
+
const command89 = updateCommand(install, opts.platform ?? process.platform);
|
|
24769
|
+
stderr.write(`kenso ${found} is out (you have ${version}): ${command89}
|
|
24208
24770
|
Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
|
|
24209
24771
|
`);
|
|
24210
24772
|
}
|