kenso 0.1.73 → 0.1.74
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 +2 -0
- package/README.md +2 -2
- package/dist/kenso.js +416 -166
- package/dist/operations.json +1 -1
- package/docs/README.md +1 -1
- package/docs/leads.md +1 -1
- package/docs/output-and-errors.md +19 -1
- package/docs/reference.md +40 -25
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -375,6 +375,17 @@ function unwrap(body2) {
|
|
|
375
375
|
function interruptedError() {
|
|
376
376
|
return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
377
377
|
}
|
|
378
|
+
function mediaType(contentType) {
|
|
379
|
+
return (contentType ?? "").split(";")[0].trim().toLowerCase();
|
|
380
|
+
}
|
|
381
|
+
function isJsonContentType(contentType) {
|
|
382
|
+
return /^(application|text)\/([\w.-]+\+)?json$/.test(mediaType(contentType));
|
|
383
|
+
}
|
|
384
|
+
function isTextContentType(contentType) {
|
|
385
|
+
const media = mediaType(contentType);
|
|
386
|
+
if (media === "" || media.startsWith("text/") || isJsonContentType(contentType)) return true;
|
|
387
|
+
return /[/+]xml$/.test(media) || ["application/csv", "application/x-www-form-urlencoded", "application/javascript"].includes(media);
|
|
388
|
+
}
|
|
378
389
|
function parseBody(text4, contentType) {
|
|
379
390
|
if (text4 === "") return null;
|
|
380
391
|
const looksJson = contentType?.includes("json") || /^\s*[[{]/.test(text4);
|
|
@@ -482,10 +493,10 @@ var init_http = __esm({
|
|
|
482
493
|
const signal = callerSignal ? AbortSignal.any([callerSignal, timeout]) : timeout;
|
|
483
494
|
const started = Date.now();
|
|
484
495
|
let res;
|
|
485
|
-
let
|
|
496
|
+
let bytes;
|
|
486
497
|
try {
|
|
487
498
|
res = await this.fetchImpl(url, { method: req.method, headers, body: body2, signal });
|
|
488
|
-
|
|
499
|
+
bytes = Buffer.from(await res.arrayBuffer());
|
|
489
500
|
} catch (err) {
|
|
490
501
|
if (callerSignal?.aborted) throw interruptedError();
|
|
491
502
|
if (!isNetworkFailure(err)) {
|
|
@@ -512,7 +523,9 @@ var init_http = __esm({
|
|
|
512
523
|
}
|
|
513
524
|
const requestId = res.headers.get("x-request-id") ?? void 0;
|
|
514
525
|
this.opts.onResponse?.({ method: req.method, url, status: res.status, ms: Date.now() - started, requestId });
|
|
515
|
-
const
|
|
526
|
+
const contentType = res.headers.get("content-type");
|
|
527
|
+
const binary = res.ok && !isTextContentType(contentType);
|
|
528
|
+
const parsed2 = binary ? bytes.length > 0 ? bytes : null : parseBody(new TextDecoder().decode(bytes), contentType);
|
|
516
529
|
if (res.status === 429) {
|
|
517
530
|
const remaining = this.rateLimitBudgetMs - this.rateLimitWaitedMs;
|
|
518
531
|
if (remaining <= 0) throw errorFromResponse(res.status, parsed2, requestId);
|
|
@@ -531,7 +544,9 @@ var init_http = __esm({
|
|
|
531
544
|
continue;
|
|
532
545
|
}
|
|
533
546
|
if (!res.ok) throw errorFromResponse(res.status, parsed2, requestId);
|
|
534
|
-
|
|
547
|
+
const response = { status: res.status, body: parsed2, headers: res.headers, requestId };
|
|
548
|
+
if (contentType !== null && !isJsonContentType(contentType)) response.raw = bytes;
|
|
549
|
+
return response;
|
|
535
550
|
}
|
|
536
551
|
}
|
|
537
552
|
/**
|
|
@@ -2315,6 +2330,10 @@ var init_output = __esm({
|
|
|
2315
2330
|
writeRaw(text4) {
|
|
2316
2331
|
this.write(text4);
|
|
2317
2332
|
}
|
|
2333
|
+
/** Bytes to stdout exactly as given (a downloaded file piped on). */
|
|
2334
|
+
writeBytes(bytes) {
|
|
2335
|
+
this.stdout.write(bytes);
|
|
2336
|
+
}
|
|
2318
2337
|
info(message) {
|
|
2319
2338
|
this.writeErr(`${redact(message)}
|
|
2320
2339
|
`);
|
|
@@ -2458,7 +2477,7 @@ var VERSION;
|
|
|
2458
2477
|
var init_version = __esm({
|
|
2459
2478
|
"src/core/version.ts"() {
|
|
2460
2479
|
"use strict";
|
|
2461
|
-
VERSION = true ? "0.1.
|
|
2480
|
+
VERSION = true ? "0.1.74" : "0.0.0-dev";
|
|
2462
2481
|
}
|
|
2463
2482
|
});
|
|
2464
2483
|
|
|
@@ -2835,6 +2854,154 @@ var init_secret_flags = __esm({
|
|
|
2835
2854
|
}
|
|
2836
2855
|
});
|
|
2837
2856
|
|
|
2857
|
+
// src/core/transfer.ts
|
|
2858
|
+
import { existsSync as existsSync2, readFileSync as readFileSync4 } from "node:fs";
|
|
2859
|
+
import { writeFile } from "node:fs/promises";
|
|
2860
|
+
import { basename, extname, resolve } from "node:path";
|
|
2861
|
+
function contentTypeFor(name) {
|
|
2862
|
+
return CONTENT_TYPES[extname(name).toLowerCase()];
|
|
2863
|
+
}
|
|
2864
|
+
function readUpload(path, field) {
|
|
2865
|
+
if (path instanceof Blob) return { blob: path, name: field };
|
|
2866
|
+
const file = String(path);
|
|
2867
|
+
let bytes;
|
|
2868
|
+
try {
|
|
2869
|
+
bytes = readFileSync4(file);
|
|
2870
|
+
} catch (err) {
|
|
2871
|
+
throw fileUnreadable(file, err);
|
|
2872
|
+
}
|
|
2873
|
+
const type = contentTypeFor(file);
|
|
2874
|
+
return { blob: new Blob([bytes], type ? { type } : {}), name: basename(file) };
|
|
2875
|
+
}
|
|
2876
|
+
function formValue(value) {
|
|
2877
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
2878
|
+
}
|
|
2879
|
+
function describeForm(form, secrets = /* @__PURE__ */ new Set()) {
|
|
2880
|
+
const out = {};
|
|
2881
|
+
for (const [key, value] of form.entries()) {
|
|
2882
|
+
const shown = typeof value === "string" ? secrets.has(key) ? "***" : value : { file: value.name, bytes: value.size };
|
|
2883
|
+
const previous = out[key];
|
|
2884
|
+
out[key] = previous === void 0 ? shown : Array.isArray(previous) ? [...previous, shown] : [previous, shown];
|
|
2885
|
+
}
|
|
2886
|
+
return out;
|
|
2887
|
+
}
|
|
2888
|
+
function splitFileArg(value) {
|
|
2889
|
+
const eq = value.indexOf("=");
|
|
2890
|
+
if (eq > 0) {
|
|
2891
|
+
const field = value.slice(0, eq);
|
|
2892
|
+
if (FIELD_NAME.test(field) && !existsSync2(value)) return { field, path: value.slice(eq + 1) };
|
|
2893
|
+
}
|
|
2894
|
+
return { path: value };
|
|
2895
|
+
}
|
|
2896
|
+
function fileUnwritable(path, err, field = "out") {
|
|
2897
|
+
const code = err?.code;
|
|
2898
|
+
return new KensoError({
|
|
2899
|
+
code: "file_unwritable",
|
|
2900
|
+
message: `Cannot write ${path}${code ? ` (${code})` : ""}.`,
|
|
2901
|
+
exitCode: ExitCode.Usage,
|
|
2902
|
+
field,
|
|
2903
|
+
hint: "Check that the folder exists and that you can write to it."
|
|
2904
|
+
});
|
|
2905
|
+
}
|
|
2906
|
+
async function saveFile(out, bytes) {
|
|
2907
|
+
const path = resolve(out);
|
|
2908
|
+
try {
|
|
2909
|
+
await writeFile(path, bytes, { mode: 384 });
|
|
2910
|
+
} catch (err) {
|
|
2911
|
+
throw fileUnwritable(out, err);
|
|
2912
|
+
}
|
|
2913
|
+
return path;
|
|
2914
|
+
}
|
|
2915
|
+
function suggestedFileName(res) {
|
|
2916
|
+
const header = res.headers.get("content-disposition") ?? "";
|
|
2917
|
+
const encoded = /filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/.exec(header)?.[1];
|
|
2918
|
+
let name;
|
|
2919
|
+
if (encoded) {
|
|
2920
|
+
try {
|
|
2921
|
+
name = decodeURIComponent(encoded.trim());
|
|
2922
|
+
} catch {
|
|
2923
|
+
name = void 0;
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
name ??= /filename\s*=\s*"?([^";]+)"?/.exec(header)?.[1]?.trim();
|
|
2927
|
+
const safe = basename(name ?? "").replace(/[^\w.-]+/g, "_").replace(/^\.+/, "");
|
|
2928
|
+
return safe === "" ? "download" : safe;
|
|
2929
|
+
}
|
|
2930
|
+
function isBinaryResponse(res) {
|
|
2931
|
+
return Buffer.isBuffer(res.body) || res.raw !== void 0 && !isTextContentType(res.headers.get("content-type"));
|
|
2932
|
+
}
|
|
2933
|
+
function responseBytes(res) {
|
|
2934
|
+
if (res.raw !== void 0) return res.raw;
|
|
2935
|
+
if (res.body === null || res.body === void 0) return Buffer.alloc(0);
|
|
2936
|
+
return Buffer.from(typeof res.body === "string" ? res.body : `${JSON.stringify(res.body)}
|
|
2937
|
+
`, "utf8");
|
|
2938
|
+
}
|
|
2939
|
+
async function writeFileResponse(ctx, res, opts = {}) {
|
|
2940
|
+
const bytes = responseBytes(res);
|
|
2941
|
+
const contentType = res.headers.get("content-type") ?? void 0;
|
|
2942
|
+
if (opts.out !== void 0) {
|
|
2943
|
+
const path = await saveFile(opts.out, bytes);
|
|
2944
|
+
ctx.output.object({ out: path, bytes: bytes.length, ...contentType ? { contentType } : {} });
|
|
2945
|
+
return;
|
|
2946
|
+
}
|
|
2947
|
+
if (bytes.length === 0) return;
|
|
2948
|
+
if (!isBinaryResponse(res)) {
|
|
2949
|
+
ctx.output.writeRaw(bytes.toString("utf8"));
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2952
|
+
if (ctx.output.stdoutIsTTY) {
|
|
2953
|
+
throw new KensoError({
|
|
2954
|
+
code: "binary_output",
|
|
2955
|
+
message: `The answer is a ${contentType ?? "binary"} file of ${bytes.length} bytes, which is not printed to a terminal.`,
|
|
2956
|
+
exitCode: ExitCode.Usage,
|
|
2957
|
+
field: "out",
|
|
2958
|
+
hint: "Save it with --out <path>, or redirect stdout to a file.",
|
|
2959
|
+
...opts.next ? { next: opts.next } : {}
|
|
2960
|
+
});
|
|
2961
|
+
}
|
|
2962
|
+
ctx.output.writeBytes(bytes);
|
|
2963
|
+
}
|
|
2964
|
+
var CONTENT_TYPES, FIELD_NAME;
|
|
2965
|
+
var init_transfer = __esm({
|
|
2966
|
+
"src/core/transfer.ts"() {
|
|
2967
|
+
"use strict";
|
|
2968
|
+
init_errors();
|
|
2969
|
+
init_exit_codes();
|
|
2970
|
+
init_http();
|
|
2971
|
+
init_input();
|
|
2972
|
+
CONTENT_TYPES = {
|
|
2973
|
+
".png": "image/png",
|
|
2974
|
+
".jpg": "image/jpeg",
|
|
2975
|
+
".jpeg": "image/jpeg",
|
|
2976
|
+
".webp": "image/webp",
|
|
2977
|
+
".gif": "image/gif",
|
|
2978
|
+
".svg": "image/svg+xml",
|
|
2979
|
+
".ico": "image/x-icon",
|
|
2980
|
+
".csv": "text/csv",
|
|
2981
|
+
".txt": "text/plain",
|
|
2982
|
+
".md": "text/markdown",
|
|
2983
|
+
".vtt": "text/vtt",
|
|
2984
|
+
".srt": "application/x-subrip",
|
|
2985
|
+
".html": "text/html",
|
|
2986
|
+
".json": "application/json",
|
|
2987
|
+
".pdf": "application/pdf",
|
|
2988
|
+
".zip": "application/zip",
|
|
2989
|
+
".skill": "application/zip",
|
|
2990
|
+
".doc": "application/msword",
|
|
2991
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
2992
|
+
".xls": "application/vnd.ms-excel",
|
|
2993
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
2994
|
+
".ppt": "application/vnd.ms-powerpoint",
|
|
2995
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
2996
|
+
".mp3": "audio/mpeg",
|
|
2997
|
+
".wav": "audio/wav",
|
|
2998
|
+
".m4a": "audio/mp4",
|
|
2999
|
+
".mp4": "video/mp4"
|
|
3000
|
+
};
|
|
3001
|
+
FIELD_NAME = /^[A-Za-z_][\w.[\]-]*$/;
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
|
|
2838
3005
|
// src/core/sse.ts
|
|
2839
3006
|
var SseParser;
|
|
2840
3007
|
var init_sse = __esm({
|
|
@@ -3126,9 +3293,9 @@ var init_get = __esm({
|
|
|
3126
3293
|
if (string.charCodeAt(0) === charCodeOfDot) {
|
|
3127
3294
|
result.push("");
|
|
3128
3295
|
}
|
|
3129
|
-
string.replace(rePropName, function(match, expression,
|
|
3296
|
+
string.replace(rePropName, function(match, expression, quote4, subString) {
|
|
3130
3297
|
let key = match;
|
|
3131
|
-
if (
|
|
3298
|
+
if (quote4) {
|
|
3132
3299
|
key = subString.replace(reEscapeChar, "$1");
|
|
3133
3300
|
} else if (expression) {
|
|
3134
3301
|
key = expression.trim();
|
|
@@ -3621,7 +3788,7 @@ var init_api = __esm({
|
|
|
3621
3788
|
const {
|
|
3622
3789
|
delimiter: delimiter3,
|
|
3623
3790
|
escape,
|
|
3624
|
-
quote:
|
|
3791
|
+
quote: quote4,
|
|
3625
3792
|
quoted,
|
|
3626
3793
|
quoted_empty,
|
|
3627
3794
|
quoted_string,
|
|
@@ -3634,7 +3801,7 @@ var init_api = __esm({
|
|
|
3634
3801
|
const quotedMatch = matches_quoted_match(value, quoted_match);
|
|
3635
3802
|
const shouldQuote = quotedMatch || true === quoted_empty || true === quoted_string && false !== quoted_empty;
|
|
3636
3803
|
if (shouldQuote === true) {
|
|
3637
|
-
value =
|
|
3804
|
+
value = quote4 + value + quote4;
|
|
3638
3805
|
}
|
|
3639
3806
|
csvrecord += value;
|
|
3640
3807
|
} else if (value) {
|
|
@@ -3646,8 +3813,8 @@ var init_api = __esm({
|
|
|
3646
3813
|
];
|
|
3647
3814
|
}
|
|
3648
3815
|
const containsdelimiter = emits_separator(value, [delimiter3]);
|
|
3649
|
-
const containsQuote =
|
|
3650
|
-
const containsEscape = value.indexOf(escape) >= 0 && escape !==
|
|
3816
|
+
const containsQuote = quote4 !== "" && value.indexOf(quote4) >= 0;
|
|
3817
|
+
const containsEscape = value.indexOf(escape) >= 0 && escape !== quote4;
|
|
3651
3818
|
const containsRecordDelimiter = emits_separator(value, [
|
|
3652
3819
|
record_delimiter,
|
|
3653
3820
|
...quote_record_delimiter === false ? [] : ["\n", "\r"]
|
|
@@ -3683,14 +3850,14 @@ var init_api = __esm({
|
|
|
3683
3850
|
value = value.replaceAll(escape, () => escape + escape);
|
|
3684
3851
|
}
|
|
3685
3852
|
if (containsQuote === true) {
|
|
3686
|
-
value = value.replaceAll(
|
|
3853
|
+
value = value.replaceAll(quote4, () => escape + quote4);
|
|
3687
3854
|
}
|
|
3688
3855
|
if (shouldQuote === true) {
|
|
3689
|
-
value =
|
|
3856
|
+
value = quote4 + value + quote4;
|
|
3690
3857
|
}
|
|
3691
3858
|
csvrecord += value;
|
|
3692
3859
|
} else if (quoted_empty === true || field === "" && quoted_string === true && quoted_empty !== false) {
|
|
3693
|
-
csvrecord +=
|
|
3860
|
+
csvrecord += quote4 + quote4;
|
|
3694
3861
|
}
|
|
3695
3862
|
if (i !== record.length - 1) {
|
|
3696
3863
|
csvrecord += delimiter3;
|
|
@@ -3795,7 +3962,7 @@ var init_sync = __esm({
|
|
|
3795
3962
|
|
|
3796
3963
|
// src/batch/results.ts
|
|
3797
3964
|
import { createHash } from "node:crypto";
|
|
3798
|
-
import { readFileSync as
|
|
3965
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
3799
3966
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
3800
3967
|
import { join as join3 } from "node:path";
|
|
3801
3968
|
function filesOf(dir) {
|
|
@@ -3862,7 +4029,7 @@ async function readResults(path) {
|
|
|
3862
4029
|
}
|
|
3863
4030
|
function readSummary(path) {
|
|
3864
4031
|
try {
|
|
3865
|
-
const value = JSON.parse(
|
|
4032
|
+
const value = JSON.parse(readFileSync5(path, "utf8"));
|
|
3866
4033
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
3867
4034
|
} catch {
|
|
3868
4035
|
return void 0;
|
|
@@ -3924,11 +4091,11 @@ var init_results = __esm({
|
|
|
3924
4091
|
// src/batch/runs.ts
|
|
3925
4092
|
import { randomBytes } from "node:crypto";
|
|
3926
4093
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
3927
|
-
import { readdir, readFile as readFile4, realpath, rename, unlink, writeFile } from "node:fs/promises";
|
|
3928
|
-
import { join as join4, resolve } from "node:path";
|
|
4094
|
+
import { readdir, readFile as readFile4, realpath, rename, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
4095
|
+
import { join as join4, resolve as resolve2 } from "node:path";
|
|
3929
4096
|
function runsRoot(env = process.env) {
|
|
3930
4097
|
const override2 = env.KENSO_RUNS_DIR?.trim();
|
|
3931
|
-
return
|
|
4098
|
+
return resolve2(override2 ? override2 : join4(configDir(env), "runs"));
|
|
3932
4099
|
}
|
|
3933
4100
|
function newRunId() {
|
|
3934
4101
|
const bytes = randomBytes(5);
|
|
@@ -3974,7 +4141,7 @@ function ensurePrivateDir2(dir) {
|
|
|
3974
4141
|
async function writeFileAtomic(path, content) {
|
|
3975
4142
|
const temp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
3976
4143
|
try {
|
|
3977
|
-
await
|
|
4144
|
+
await writeFile2(temp, content, { mode: 384 });
|
|
3978
4145
|
await rename(temp, path);
|
|
3979
4146
|
} catch (err) {
|
|
3980
4147
|
await unlink(temp).catch(() => void 0);
|
|
@@ -4106,9 +4273,9 @@ var init_runs = __esm({
|
|
|
4106
4273
|
});
|
|
4107
4274
|
|
|
4108
4275
|
// src/batch/run-dir.ts
|
|
4109
|
-
import { existsSync as
|
|
4276
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
4110
4277
|
import { symlink, unlink as unlink2 } from "node:fs/promises";
|
|
4111
|
-
import { join as join5, resolve as
|
|
4278
|
+
import { join as join5, resolve as resolve3 } from "node:path";
|
|
4112
4279
|
async function prepareRunDir(outDir, runId, identical, ctx) {
|
|
4113
4280
|
const root2 = runsRoot(ctx.env);
|
|
4114
4281
|
if (outDir === void 0) {
|
|
@@ -4117,8 +4284,8 @@ async function prepareRunDir(outDir, runId, identical, ctx) {
|
|
|
4117
4284
|
ensurePrivateDir2(dir2);
|
|
4118
4285
|
return dir2;
|
|
4119
4286
|
}
|
|
4120
|
-
const dir =
|
|
4121
|
-
const existing =
|
|
4287
|
+
const dir = resolve3(outDir);
|
|
4288
|
+
const existing = existsSync3(join5(dir, "run.json")) ? await readRunDir(dir) : null;
|
|
4122
4289
|
if (existing && !identical.some((run) => run.runId === existing.runId)) {
|
|
4123
4290
|
throw usageError(`${dir} already holds run ${existing.runId} (${existing.command}).`, {
|
|
4124
4291
|
field: "out",
|
|
@@ -5502,7 +5669,7 @@ var init_api2 = __esm({
|
|
|
5502
5669
|
state: init_state(options),
|
|
5503
5670
|
__needMoreData: function(i, bufLen, end) {
|
|
5504
5671
|
if (end) return false;
|
|
5505
|
-
const { encoding, escape, quote:
|
|
5672
|
+
const { encoding, escape, quote: quote4 } = this.options;
|
|
5506
5673
|
const { quoting, needMoreDataSize, recordDelimiterMaxLength } = this.state;
|
|
5507
5674
|
const numOfCharLeft = bufLen - i - 1;
|
|
5508
5675
|
const requiredLength = Math.max(
|
|
@@ -5515,9 +5682,9 @@ var init_api2 = __esm({
|
|
|
5515
5682
|
// recordDelimiterMaxLength,
|
|
5516
5683
|
recordDelimiterMaxLength === 0 ? Buffer.from("\r\n", encoding).length : recordDelimiterMaxLength,
|
|
5517
5684
|
// Skip if remaining buffer can be an escaped quote
|
|
5518
|
-
quoting ? (escape === null ? 0 : escape.length) +
|
|
5685
|
+
quoting ? (escape === null ? 0 : escape.length) + quote4.length : 0,
|
|
5519
5686
|
// Skip if remaining buffer can be record delimiter following the closing quote
|
|
5520
|
-
quoting ?
|
|
5687
|
+
quoting ? quote4.length + recordDelimiterMaxLength : 0
|
|
5521
5688
|
);
|
|
5522
5689
|
return numOfCharLeft < requiredLength;
|
|
5523
5690
|
},
|
|
@@ -5538,7 +5705,7 @@ var init_api2 = __esm({
|
|
|
5538
5705
|
to,
|
|
5539
5706
|
to_line
|
|
5540
5707
|
} = this.options;
|
|
5541
|
-
let { comment, escape, quote:
|
|
5708
|
+
let { comment, escape, quote: quote4, record_delimiter } = this.options;
|
|
5542
5709
|
const {
|
|
5543
5710
|
bomSkipped,
|
|
5544
5711
|
delimiterDiscovered,
|
|
@@ -5605,7 +5772,7 @@ var init_api2 = __esm({
|
|
|
5605
5772
|
for (const key in options2) {
|
|
5606
5773
|
this.options[key] = options2[key];
|
|
5607
5774
|
}
|
|
5608
|
-
({ comment, escape, quote:
|
|
5775
|
+
({ comment, escape, quote: quote4 } = this.options);
|
|
5609
5776
|
break;
|
|
5610
5777
|
}
|
|
5611
5778
|
}
|
|
@@ -5661,21 +5828,21 @@ var init_api2 = __esm({
|
|
|
5661
5828
|
}
|
|
5662
5829
|
if (this.state.commenting === false && this.__isQuote(buf, pos)) {
|
|
5663
5830
|
if (this.state.quoting === true) {
|
|
5664
|
-
const nextChr = buf[pos +
|
|
5665
|
-
const isNextChrTrimable = rtrim && this.__isCharTrimable(buf, pos +
|
|
5666
|
-
const isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos +
|
|
5831
|
+
const nextChr = buf[pos + quote4.length];
|
|
5832
|
+
const isNextChrTrimable = rtrim && this.__isCharTrimable(buf, pos + quote4.length);
|
|
5833
|
+
const isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos + quote4.length, nextChr);
|
|
5667
5834
|
const isNextChrDelimiter = this.__isDelimiter(
|
|
5668
5835
|
buf,
|
|
5669
|
-
pos +
|
|
5836
|
+
pos + quote4.length,
|
|
5670
5837
|
nextChr
|
|
5671
5838
|
);
|
|
5672
|
-
const isNextChrRecordDelimiter = record_delimiter.length === 0 ? this.__autoDiscoverRecordDelimiter(buf, pos +
|
|
5839
|
+
const isNextChrRecordDelimiter = record_delimiter.length === 0 ? this.__autoDiscoverRecordDelimiter(buf, pos + quote4.length) : this.__isRecordDelimiter(nextChr, buf, pos + quote4.length);
|
|
5673
5840
|
if (escape !== null && this.__isEscape(buf, pos, chr) && this.__isQuote(buf, pos + escape.length)) {
|
|
5674
5841
|
pos += escape.length - 1;
|
|
5675
5842
|
} else if (!nextChr || isNextChrDelimiter || isNextChrRecordDelimiter || isNextChrComment || isNextChrTrimable) {
|
|
5676
5843
|
this.state.quoting = false;
|
|
5677
5844
|
this.state.wasQuoting = true;
|
|
5678
|
-
pos +=
|
|
5845
|
+
pos += quote4.length - 1;
|
|
5679
5846
|
continue;
|
|
5680
5847
|
} else if (relax_quotes === false) {
|
|
5681
5848
|
const err = this.__error(
|
|
@@ -5696,8 +5863,8 @@ var init_api2 = __esm({
|
|
|
5696
5863
|
} else {
|
|
5697
5864
|
this.state.quoting = false;
|
|
5698
5865
|
this.state.wasQuoting = true;
|
|
5699
|
-
this.state.field.prepend(
|
|
5700
|
-
pos +=
|
|
5866
|
+
this.state.field.prepend(quote4);
|
|
5867
|
+
pos += quote4.length - 1;
|
|
5701
5868
|
}
|
|
5702
5869
|
} else {
|
|
5703
5870
|
if (this.state.field.length !== 0) {
|
|
@@ -5725,7 +5892,7 @@ var init_api2 = __esm({
|
|
|
5725
5892
|
}
|
|
5726
5893
|
} else {
|
|
5727
5894
|
this.state.quoting = true;
|
|
5728
|
-
pos +=
|
|
5895
|
+
pos += quote4.length - 1;
|
|
5729
5896
|
continue;
|
|
5730
5897
|
}
|
|
5731
5898
|
}
|
|
@@ -6175,11 +6342,11 @@ var init_api2 = __esm({
|
|
|
6175
6342
|
// return /^(\-|\+)?[1-9][0-9]*$/.test(value)
|
|
6176
6343
|
// }
|
|
6177
6344
|
__isQuote: function(buf, pos) {
|
|
6178
|
-
const { quote:
|
|
6179
|
-
if (
|
|
6180
|
-
const l =
|
|
6345
|
+
const { quote: quote4 } = this.options;
|
|
6346
|
+
if (quote4 === null) return false;
|
|
6347
|
+
const l = quote4.length;
|
|
6181
6348
|
for (let i = 0; i < l; i++) {
|
|
6182
|
-
if (
|
|
6349
|
+
if (quote4[i] !== buf[pos + i]) {
|
|
6183
6350
|
return false;
|
|
6184
6351
|
}
|
|
6185
6352
|
}
|
|
@@ -6307,7 +6474,7 @@ var init_sync2 = __esm({
|
|
|
6307
6474
|
// src/batch/input.ts
|
|
6308
6475
|
import { createHash as createHash2 } from "node:crypto";
|
|
6309
6476
|
import { readFile as readFile5, stat } from "node:fs/promises";
|
|
6310
|
-
import { extname, resolve as
|
|
6477
|
+
import { extname as extname2, resolve as resolve4 } from "node:path";
|
|
6311
6478
|
function tooLarge(source) {
|
|
6312
6479
|
return usageError(`${source} is larger than 200 MB, the most the CLI reads in one run.`, {
|
|
6313
6480
|
field: "file",
|
|
@@ -6328,7 +6495,7 @@ async function readStdinBytes(stdin) {
|
|
|
6328
6495
|
async function readRaw(pathOrDash, stdin) {
|
|
6329
6496
|
if (pathOrDash === "-") return { path: "-", bytes: await readStdinBytes(stdin ?? process.stdin) };
|
|
6330
6497
|
if (pathOrDash.trim() === "") throw usageError("Name an input file, or - for stdin.", { field: "file" });
|
|
6331
|
-
const path =
|
|
6498
|
+
const path = resolve4(pathOrDash);
|
|
6332
6499
|
try {
|
|
6333
6500
|
const info = await stat(path);
|
|
6334
6501
|
if (info.isDirectory()) throw fileUnreadable(pathOrDash, { code: "EISDIR" });
|
|
@@ -6343,7 +6510,7 @@ function stripBom(text4) {
|
|
|
6343
6510
|
return text4.charCodeAt(0) === 65279 ? text4.slice(1) : text4;
|
|
6344
6511
|
}
|
|
6345
6512
|
function detectFormat(path, text4) {
|
|
6346
|
-
const ext = path === "-" ? "" :
|
|
6513
|
+
const ext = path === "-" ? "" : extname2(path).toLowerCase();
|
|
6347
6514
|
if (ext === ".csv") return "csv";
|
|
6348
6515
|
if (ext === ".jsonl" || ext === ".ndjson") return "jsonl";
|
|
6349
6516
|
return stripBom(text4).trimStart().startsWith("{") ? "jsonl" : "csv";
|
|
@@ -6431,7 +6598,7 @@ async function readIds(pathOrDash, opts) {
|
|
|
6431
6598
|
const text4 = bytes.toString("utf8");
|
|
6432
6599
|
const source = path === "-" ? "stdin" : pathOrDash;
|
|
6433
6600
|
const column = opts?.column?.trim() || void 0;
|
|
6434
|
-
const ext = path === "-" ? "" :
|
|
6601
|
+
const ext = path === "-" ? "" : extname2(path).toLowerCase();
|
|
6435
6602
|
let format;
|
|
6436
6603
|
if (ext === ".csv" || ext === ".jsonl" || ext === ".ndjson") format = detectFormat(path, text4);
|
|
6437
6604
|
else if (stripBom(text4).trimStart().startsWith("{")) format = "jsonl";
|
|
@@ -6672,8 +6839,6 @@ __export(execute_exports, {
|
|
|
6672
6839
|
operationToCommand: () => operationToCommand,
|
|
6673
6840
|
secretParams: () => secretParams
|
|
6674
6841
|
});
|
|
6675
|
-
import { readFileSync as readFileSync5 } from "node:fs";
|
|
6676
|
-
import { basename } from "node:path";
|
|
6677
6842
|
function isRecord3(value) {
|
|
6678
6843
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6679
6844
|
}
|
|
@@ -6683,13 +6848,21 @@ function commandOf(op) {
|
|
|
6683
6848
|
function isDestructive(op) {
|
|
6684
6849
|
return op.method === "DELETE" || /(^|-)(delete|archive|remove)(-|$)/.test(op.action);
|
|
6685
6850
|
}
|
|
6686
|
-
function
|
|
6687
|
-
return op.body?.format === "multipart" ? op.body.props.
|
|
6851
|
+
function fileProps(op) {
|
|
6852
|
+
return op.body?.format === "multipart" ? op.body.props.filter((p) => p.flag === "file") : [];
|
|
6853
|
+
}
|
|
6854
|
+
function fileFlagText(op, files) {
|
|
6855
|
+
const first = files[0];
|
|
6856
|
+
const many = first.type === "array" ? "; repeat for more files" : "";
|
|
6857
|
+
const named = files.length > 1 ? ` Name another file field with <field>=<path> (${files.map((f) => f.name).join(", ")}).` : "";
|
|
6858
|
+
const json = op.body?.json ? " Without --file the body is JSON." : "";
|
|
6859
|
+
return `Path of the file to upload, sent as form field ${first.name}${many}.${named}${json}`;
|
|
6688
6860
|
}
|
|
6689
6861
|
function describeParam(param, location, list2) {
|
|
6690
6862
|
const fallback = list2 && location === "query" && LIST_PARAM_TEXT[param.name] || `${param.name} (${location === "route" ? "path" : location}, ${param.type})`;
|
|
6691
6863
|
const base = param.description?.replace(/\s*\n\s*/g, " ") ?? fallback;
|
|
6692
|
-
|
|
6864
|
+
const text4 = param.enum ? `${base} One of: ${param.enum.join(", ")}.` : base;
|
|
6865
|
+
return param.jsonOnly ? `${text4} JSON body only: not with --file.` : text4;
|
|
6693
6866
|
}
|
|
6694
6867
|
function operationFlags(op) {
|
|
6695
6868
|
const flags = [];
|
|
@@ -6707,15 +6880,16 @@ function operationFlags(op) {
|
|
|
6707
6880
|
};
|
|
6708
6881
|
for (const param of op.routeParams) add(param, "route", true);
|
|
6709
6882
|
for (const param of op.queryParams) add(param, "query", param.required);
|
|
6710
|
-
const
|
|
6883
|
+
const files = fileProps(op);
|
|
6711
6884
|
for (const prop of op.body?.props ?? []) {
|
|
6712
|
-
if (prop === file) {
|
|
6885
|
+
if (prop.flag === "file" && files.length > 0) {
|
|
6886
|
+
if (prop !== files[0]) continue;
|
|
6713
6887
|
flags.push({
|
|
6714
6888
|
flag: "file",
|
|
6715
6889
|
type: "file",
|
|
6716
6890
|
required: prop.required,
|
|
6717
|
-
description:
|
|
6718
|
-
...prop.type === "array" ? { multiple: true } : {},
|
|
6891
|
+
description: fileFlagText(op, files),
|
|
6892
|
+
...prop.type === "array" || files.length > 1 ? { multiple: true } : {},
|
|
6719
6893
|
param: prop,
|
|
6720
6894
|
location: "body"
|
|
6721
6895
|
});
|
|
@@ -6737,6 +6911,14 @@ function operationFlags(op) {
|
|
|
6737
6911
|
description: op.idempotencyKey.required ? "Idempotency-Key, required: a unique value. Run the command again with the same key to retry it safely." : "Idempotency-Key: a unique value. Run the command again with the same key to retry it safely. Without it no key is sent."
|
|
6738
6912
|
});
|
|
6739
6913
|
}
|
|
6914
|
+
if (op.download) {
|
|
6915
|
+
flags.push({
|
|
6916
|
+
flag: OUT_FLAG,
|
|
6917
|
+
type: "string",
|
|
6918
|
+
required: false,
|
|
6919
|
+
description: `Save the answer (${op.download.contentTypes.join(" or ")}) to this file, byte for byte, and print a summary.`
|
|
6920
|
+
});
|
|
6921
|
+
}
|
|
6740
6922
|
if (op.body) {
|
|
6741
6923
|
flags.push({
|
|
6742
6924
|
flag: "data",
|
|
@@ -6776,7 +6958,8 @@ function usageLine(op) {
|
|
|
6776
6958
|
function operationExamples(op) {
|
|
6777
6959
|
const required = operationFlags(op).filter((f) => f.required && f.flag !== "file").map(flagUsage);
|
|
6778
6960
|
const base = [commandOf(op), ...required].join(" ");
|
|
6779
|
-
const
|
|
6961
|
+
const upload2 = op.body?.format === "multipart" ? `${base} --file ./file.csv` : base;
|
|
6962
|
+
const first = op.download ? `${upload2} --out ./${op.download.contentTypes.some((t) => t.includes("csv")) ? "export.csv" : "download"}` : upload2;
|
|
6780
6963
|
const examples = op.method === "GET" ? [first] : [`${first} --dry-run`, isDestructive(op) ? `${first} --yes` : first];
|
|
6781
6964
|
if (op.body && op.body.format !== "multipart") examples.push(`${base} --data @body.json`);
|
|
6782
6965
|
if (op.list) examples.push(`${base} --all`);
|
|
@@ -6801,18 +6984,6 @@ function parseNumber(raw, flag, integer) {
|
|
|
6801
6984
|
function isBlank(value) {
|
|
6802
6985
|
return value === void 0 || value === null || value === "";
|
|
6803
6986
|
}
|
|
6804
|
-
function readUpload(path, field) {
|
|
6805
|
-
if (path instanceof Blob) return { blob: path, name: field };
|
|
6806
|
-
const file = String(path);
|
|
6807
|
-
try {
|
|
6808
|
-
return { blob: new Blob([readFileSync5(file)]), name: basename(file) };
|
|
6809
|
-
} catch (err) {
|
|
6810
|
-
throw fileUnreadable(file, err);
|
|
6811
|
-
}
|
|
6812
|
-
}
|
|
6813
|
-
function formValue(value) {
|
|
6814
|
-
return typeof value === "string" ? value : JSON.stringify(value);
|
|
6815
|
-
}
|
|
6816
6987
|
function buildRequest(op, values) {
|
|
6817
6988
|
const routeNames = new Set(op.routeParams.map((p) => p.name));
|
|
6818
6989
|
const queryNames = new Set(op.queryParams.map((p) => p.name));
|
|
@@ -6852,18 +7023,28 @@ function buildRequest(op, values) {
|
|
|
6852
7023
|
if (key === DATA_KEY || key === IDEMPOTENCY_KEY || routeNames.has(key) || queryNames.has(key) || value === void 0) continue;
|
|
6853
7024
|
body2[key] = value;
|
|
6854
7025
|
}
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
7026
|
+
const files = fileProps(op);
|
|
7027
|
+
const fileNames = new Set(files.map((p) => p.name));
|
|
7028
|
+
const sendForm = op.body.format === "multipart" && !(op.body.json === true && files.every((p) => isBlank(body2[p.name])));
|
|
7029
|
+
if (sendForm) {
|
|
7030
|
+
if (files[0]?.required && isBlank(body2[files[0].name])) throw missing(op, "file");
|
|
7031
|
+
const jsonOnly = op.body.props.find((p) => p.jsonOnly === true && !isBlank(body2[p.name]));
|
|
7032
|
+
if (jsonOnly) {
|
|
7033
|
+
throw usageError(`--${jsonOnly.flag} goes in the JSON body, which ${commandOf(op)} sends only without --file.`, {
|
|
7034
|
+
field: jsonOnly.flag,
|
|
7035
|
+
hint: `Send either --file or --${jsonOnly.flag}, not both.`
|
|
7036
|
+
});
|
|
7037
|
+
}
|
|
6858
7038
|
const form = new FormData();
|
|
7039
|
+
const formTypes = new Map(op.body.props.map((p) => [p.name, p.type]));
|
|
6859
7040
|
for (const [key, value] of Object.entries(body2)) {
|
|
6860
7041
|
if (value === void 0 || value === null) continue;
|
|
6861
|
-
if (
|
|
7042
|
+
if (fileNames.has(key)) {
|
|
6862
7043
|
for (const path2 of Array.isArray(value) ? value : [value]) {
|
|
6863
7044
|
const upload2 = readUpload(path2, key);
|
|
6864
7045
|
form.append(key, upload2.blob, upload2.name);
|
|
6865
7046
|
}
|
|
6866
|
-
} else if (Array.isArray(value)) {
|
|
7047
|
+
} else if (Array.isArray(value) && (formTypes.get(key) ?? "array") === "array") {
|
|
6867
7048
|
for (const item of value) form.append(key, formValue(item));
|
|
6868
7049
|
} else {
|
|
6869
7050
|
form.append(key, formValue(value));
|
|
@@ -6882,6 +7063,28 @@ function buildRequest(op, values) {
|
|
|
6882
7063
|
request.body = body2;
|
|
6883
7064
|
return request;
|
|
6884
7065
|
}
|
|
7066
|
+
function fileValues(op, raw) {
|
|
7067
|
+
const files = fileProps(op);
|
|
7068
|
+
const byField = /* @__PURE__ */ new Map();
|
|
7069
|
+
for (const item of Array.isArray(raw) ? raw : [String(raw)]) {
|
|
7070
|
+
const { field, path } = splitFileArg(item);
|
|
7071
|
+
const prop = field === void 0 ? files[0] : files.find((p) => p.name.toLowerCase() === field.toLowerCase());
|
|
7072
|
+
if (!prop) {
|
|
7073
|
+
throw usageError(`${commandOf(op)} has no file field "${field}".`, {
|
|
7074
|
+
field: "file",
|
|
7075
|
+
hint: `Its file field${files.length > 1 ? "s are" : " is"} ${files.map((p) => p.name).join(", ")}. A path with = in it reads as a path when it starts with ./ (./${item}).`
|
|
7076
|
+
});
|
|
7077
|
+
}
|
|
7078
|
+
if (path === "") throw usageError(`--file ${item} names no file.`, { field: "file" });
|
|
7079
|
+
byField.set(prop, [...byField.get(prop) ?? [], path]);
|
|
7080
|
+
}
|
|
7081
|
+
const values = {};
|
|
7082
|
+
for (const [prop, paths] of byField) {
|
|
7083
|
+
if (prop.type !== "array" && paths.length > 1) throw usageError(`--file takes one file for ${prop.name} (got ${paths.length}).`, { field: "file" });
|
|
7084
|
+
values[prop.name] = prop.type === "array" ? paths : paths[0];
|
|
7085
|
+
}
|
|
7086
|
+
return values;
|
|
7087
|
+
}
|
|
6885
7088
|
async function collectValues(ctx, op, flags) {
|
|
6886
7089
|
const values = {};
|
|
6887
7090
|
const bodyOnly = {};
|
|
@@ -6897,7 +7100,8 @@ async function collectValues(ctx, op, flags) {
|
|
|
6897
7100
|
} else if (raw === void 0) {
|
|
6898
7101
|
continue;
|
|
6899
7102
|
} else if (f.type === "file") {
|
|
6900
|
-
|
|
7103
|
+
Object.assign(values, fileValues(op, raw));
|
|
7104
|
+
continue;
|
|
6901
7105
|
} else if (f.type === "array") {
|
|
6902
7106
|
value = (Array.isArray(raw) ? raw : [String(raw)]).flatMap((item) => item.split(",")).map((item) => item.trim()).filter((item) => item !== "");
|
|
6903
7107
|
} else if (f.type === "integer" || f.type === "number") {
|
|
@@ -6959,15 +7163,7 @@ function describeRequest(req, op) {
|
|
|
6959
7163
|
const out = { method: req.method, path: req.path };
|
|
6960
7164
|
if (req.query) out.query = req.query;
|
|
6961
7165
|
if (req.body !== void 0) out.body = maskSecrets(req.body, secrets);
|
|
6962
|
-
if (req.form)
|
|
6963
|
-
const form = {};
|
|
6964
|
-
for (const [key, value] of req.form.entries()) {
|
|
6965
|
-
const shown = typeof value === "string" ? secrets.has(key) ? "***" : value : { file: value.name, bytes: value.size };
|
|
6966
|
-
const previous = form[key];
|
|
6967
|
-
form[key] = previous === void 0 ? shown : Array.isArray(previous) ? [...previous, shown] : [previous, shown];
|
|
6968
|
-
}
|
|
6969
|
-
out.form = form;
|
|
6970
|
-
}
|
|
7166
|
+
if (req.form) out.form = describeForm(req.form, secrets);
|
|
6971
7167
|
return out;
|
|
6972
7168
|
}
|
|
6973
7169
|
function eachConcurrency(raw) {
|
|
@@ -6985,6 +7181,10 @@ async function runOperation(ctx, op, flags) {
|
|
|
6985
7181
|
const secrets = secretParams(op);
|
|
6986
7182
|
checkSecretSources(flags, secrets.map((s) => s.flag));
|
|
6987
7183
|
const values = await collectValues(ctx, op, flags);
|
|
7184
|
+
const out = typeof flags[OUT_FLAG] === "string" ? flags[OUT_FLAG] : void 0;
|
|
7185
|
+
if (out !== void 0 && typeof flags.each === "string") {
|
|
7186
|
+
throw usageError("--out names one file, so it cannot take an answer per --each row.", { field: OUT_FLAG });
|
|
7187
|
+
}
|
|
6988
7188
|
const stream = op.stream === "sse" ? streamOptions(flags) : void 0;
|
|
6989
7189
|
if (typeof flags.each === "string") {
|
|
6990
7190
|
const { runEach: runEach2 } = await Promise.resolve().then(() => (init_each(), each_exports));
|
|
@@ -7007,6 +7207,11 @@ async function runOperation(ctx, op, flags) {
|
|
|
7007
7207
|
return ExitCode.Ok;
|
|
7008
7208
|
}
|
|
7009
7209
|
const res = await ctx.client.request(req);
|
|
7210
|
+
if (out !== void 0 || res.raw !== void 0 && (op.download !== void 0 || isBinaryResponse(res))) {
|
|
7211
|
+
const next = op.download ? `${sameCommand(ctx, op, flags)} --out ${shellQuote2(suggestedFileName(res))}` : void 0;
|
|
7212
|
+
await writeFileResponse(ctx, res, { out, ...next ? { next } : {} });
|
|
7213
|
+
return ExitCode.Ok;
|
|
7214
|
+
}
|
|
7010
7215
|
if (res.status === 204 || res.body === null || res.body === "") return ExitCode.Ok;
|
|
7011
7216
|
if (op.list && isRecord3(res.body) && Array.isArray(res.body.data)) {
|
|
7012
7217
|
if (res.body.counts !== void 0) {
|
|
@@ -7102,7 +7307,7 @@ ${api}` : api,
|
|
|
7102
7307
|
run: (ctx, args) => runOperation(ctx, op, args.flags)
|
|
7103
7308
|
};
|
|
7104
7309
|
}
|
|
7105
|
-
var STREAM_HELP, DATA_KEY, IDEMPOTENCY_KEY, IDEMPOTENCY_KEY_FLAG, SCALAR_TYPES, FLAG_ALIASES, LIST_PARAM_TEXT, HELP_NOTES_MAX, HELP_FLAG_MAX, FOOTER_FLAGS;
|
|
7310
|
+
var STREAM_HELP, DATA_KEY, IDEMPOTENCY_KEY, IDEMPOTENCY_KEY_FLAG, SCALAR_TYPES, FLAG_ALIASES, OUT_FLAG, LIST_PARAM_TEXT, HELP_NOTES_MAX, HELP_FLAG_MAX, FOOTER_FLAGS;
|
|
7106
7311
|
var init_execute = __esm({
|
|
7107
7312
|
"src/generated/execute.ts"() {
|
|
7108
7313
|
"use strict";
|
|
@@ -7112,6 +7317,7 @@ var init_execute = __esm({
|
|
|
7112
7317
|
init_http();
|
|
7113
7318
|
init_input();
|
|
7114
7319
|
init_secret_flags();
|
|
7320
|
+
init_transfer();
|
|
7115
7321
|
init_stream();
|
|
7116
7322
|
STREAM_HELP = "A live stream: it prints one JSON line per event ({event, id, data}) as it arrives and runs until Ctrl-C, reconnecting when the server closes it (with Last-Event-ID once events carry an id). --until <event> ends after that event, --max-events <n> after n events, --once when the server closes it.";
|
|
7117
7323
|
DATA_KEY = "$data";
|
|
@@ -7126,6 +7332,7 @@ var init_execute = __esm({
|
|
|
7126
7332
|
["opportunity", "opportunity-id"],
|
|
7127
7333
|
["q", "search"]
|
|
7128
7334
|
];
|
|
7335
|
+
OUT_FLAG = "out";
|
|
7129
7336
|
LIST_PARAM_TEXT = {
|
|
7130
7337
|
limit: "Page size.",
|
|
7131
7338
|
cursor: "Start at this cursor (the next: hint of a previous page)."
|
|
@@ -7585,7 +7792,7 @@ var init_crm = __esm({
|
|
|
7585
7792
|
var leads_default;
|
|
7586
7793
|
var init_leads = __esm({
|
|
7587
7794
|
"docs/leads.md"() {
|
|
7588
|
-
leads_default = '# Leads\n\nLeads are contacts in a campaign. The lead commands live under `kenso contacts`, and `kenso leads` is the same thing: `kenso leads import` runs `kenso contacts import`.\n\n| Command | What it does |\n|---|---|\n| `contacts import` | Add leads from a CSV or JSONL file to a campaign, with one result per row |\n| `contacts update` | Edit leads in bulk from a file, matched by id or by email |\n| `contacts remove` / `restore` | Remove (soft-delete) leads by id, and undo it |\n| `contacts pause` / `resume` | Pause and resume the campaign sequence of leads (pause is beta, `pause_leads` flag) |\n| `contacts tag` / `untag` | Add or remove a tag on leads by id |\n| `contacts export` | Download a campaign\'s leads as one CSV file |\n\nAll of them except `export` are batch commands: without `--yes` they print a plan and change nothing. [Batch runs](batch.md) explains plans, run folders, results files and resume.\n\n## Import a CSV into a campaign\n\n```bash\nkenso contacts import --template\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\n`--template` prints the accepted columns. A minimal file:\n\n```csv\nemail,firstName,lastName,companyName,Pain Point\nann@acme.io,Ann,Lee,Acme,Slow onboarding\ncid@globex.com,Cid,Moe,Globex,Churn\n```\n\n### Columns\n\nHeaders are matched without regard to case, spaces or punctuation. The known fields and the other headers each one reads:\n\n| Field | Also read from | Rule |\n|---|---|---|\n| `email` | email address, e-mail, work email | Required, unless the campaign is LinkedIn-only and the row has a linkedin.com/in/ URL |\n| `firstName` | first name, first, given name | Required |\n| `lastName` | last name, last, surname, family name | Required |\n| `title` | job title, position, role | Optional |\n| `linkedInUrl` | linkedin, linkedin url, linkedin profile, profile url | Optional |\n| `companyName` | company, organization, account, account name | `companyName` or `companyDomain` is required |\n| `companyDomain` | website, domain, company website, url | `companyName` or `companyDomain` is required |\n\nEvery other column becomes a custom variable, named like its header in snake_case: a `Pain Point` column fills `{{pain_point}}` in your sequence. Names Kenso keeps for its own fields (`city`, `country`, `phone_number` and others) are not sent: the CLI warns and the plan lists them under `droppedColumns`. Rename them with `--map`.\n\n### Cells\n\n- A blank cell is never sent, so importing a file never erases data on a lead that is already in the campaign.\n- The literal value `null` clears a custom variable.\n\n### Rename or drop columns with --map\n\n`--map` takes a JSON object, `@file` or `-` for stdin. A value names the target field, and `null` drops the column:\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --map \'{"Pain": "customVariables.pain_point", "Notes": null}\' --yes\n```\n\n### JSONL\n\nEach line is one lead. Keys work like CSV headers, and a `customVariables` object is spread into custom variables:\n\n```json\n{"email":"ann@acme.io","firstName":"Ann","lastName":"Lee","companyName":"Acme","customVariables":{"pain_point":"Slow onboarding"}}\n```\n\n```bash\nkenso contacts import --campaign 812 --file leads.jsonl --yes\ncat leads.jsonl | kenso contacts import --campaign 812 --file - --yes\n```\n\nA run read from stdin cannot be resumed with `kenso runs resume`, so prefer a file for large imports.\n\n### What the CLI checks before sending\n\nEvery row is checked locally first. A row that fails goes to `invalid.csv` with one of these reasons and is not sent:\n\n| Reason | Meaning |\n|---|---|\n| `missing_email` | The row has no email (and is not a LinkedIn-only lead) |\n| `invalid_email` | The email is not a valid address |\n| `missing_first_name` | The row has no first name |\n| `missing_last_name` | The row has no last name |\n| `missing_company` | The row has neither a company name nor a company domain |\n| `sales_navigator_url` | An email-less row whose LinkedIn URL is a Sales Navigator link: add the email or a linkedin.com/in/ URL |\n| `duplicate_in_file` | An earlier row of the file has the same email |\n\nKenso stays the authority and checks every row again.\n\n### What the dry run shows\n\nThe dry run maps the columns, checks the rows, reads the campaign, and asks for a credit estimate (`credit-estimates create`, kind `leads`). Its plan holds `rows`, `valid`, `invalid`, `mapping`, `customVariableKeys`, `estimate`, `credits` (`needed`, `available`, `sufficient`) and `next`, the exact apply command. If the estimate call fails, the plan still prints with `"estimate":null` and an `estimateError`.\n\n### How rows are sent\n\nThe CLI sends 1,000 rows per call to `POST /v1/campaigns/{campaignId}/contacts`, one call at a time per campaign, because two overlapping upserts of the same email could create duplicates. After a 5xx answer or a dropped connection it does not retry right away: it waits 130 seconds, so the first request has finished on the server, then resends the chunk once. Rows the first request saved come back `updated`.\n\n### Reading the result\n\nEach row in `results.csv` gets one status:\n\n| Status | Meaning |\n|---|---|\n| `created` | A new lead in the campaign |\n| `updated` | The lead was already there and was updated |\n| `skipped` | Kenso kept the lead out on purpose. `reason` is `duplicate`, `blocklisted`, `already_contacted`, `excluded` or another code |\n| `failed` | Kenso refused the row (`reason` such as `invalid_email` or `validation`, and an `error` message), or the call failed |\n| `invalid` | The CLI refused the row before sending it (see the table above) |\n\nA saved lead that cannot be emailed yet has `sendable` false, and the summary counts those leads in `notSendable` with a warning on stderr.\n\nExit codes: 0 when no row failed (skipped rows are not failures), 5 when some rows failed or were invalid, 6 when the plan\'s or campaign\'s lead limit stopped the run (`limit_reached`; raise the limit, then rerun the same command to send the rest).\n\n## Import a very large file on the server\n\nFor up to 100,000 rows, `--server-import` uploads the CSV as one server import job and waits for it (default 30 minutes, `--timeout`). It reports the job\'s counts but no per-row results.\n\n```bash\nkenso contacts import --campaign 812 --file big.csv --server-import --yes\nkenso contacts import --campaign 812 --file big.csv --server-import --timeout 1h --yes\n```\n\n## Update leads in bulk\n\n```bash\nkenso contacts update --file edits.csv --match id\nkenso contacts update --file edits.csv --match id --yes\nkenso contacts update --file edits.csv --match email --campaign 812 --yes\n```\n\n- `--match id` reads the contact id from an `id` or `contactId` column.\n- `--match email` finds each email among the leads of `--campaign`. An email it cannot find is `not_found`. The email column only finds the lead; it is never sent as an edit.\n- A column that is absent, or a blank cell, leaves that field unchanged. The literal `null` clears it.\n- The lead fields you can edit are `firstName`, `lastName`, `title`, `linkedInUrl`, and `email` with `--match id`. `companyName` and `companyDomain` cannot change here and are not sent. Every other column is a custom variable, mapped the same way as in an import, and `--map` works here too.\n- A row with nothing to change is `skipped` with reason `no_changes` and is not sent. Rows go 1,000 per call to `POST /v1/contacts/bulk-update`.\n\nTo edit one lead, use a one-row file from stdin:\n\n```bash\nprintf \'id,title\\n9001,VP Sales\\n\' | kenso contacts update --file - --match id --yes\n```\n\n## Remove, restore, pause and resume\n\nThese four take contact ids from `--ids` (one id per line, or a CSV or JSONL file with an `id` or `contactId` column, or `-` for stdin), or from a search with `--where` (remove, pause and resume). `--where` takes the body of `POST /v1/contacts/search` as JSON, `@file` or `-`, and does the search itself: its plan shows how many contacts match and the first ids, so run no separate search or list first. `q` matches names and email addresses only; a company is a `filters` condition on `ContactCompany.Name` (`operator` 2 is contains; `kenso describe contacts search` lists the fields and operators).\n\n```bash\nkenso contacts remove --ids ids.txt --dry-run\nkenso contacts remove --ids ids.txt --yes\nkenso contacts remove --where \'{"campaignIds": [812], "filters": [{"conditions": {"field": "ContactCompany.Name", "operator": 2, "value": "acme"}}]}\' --dry-run\nkenso contacts remove --where \'{"campaignIds": [812], "filters": [{"conditions": {"field": "ContactCompany.Name", "operator": 2, "value": "acme"}}]}\' --yes\nkenso contacts remove --ids big.csv --confirm 2500 --yes\n```\n\n- Without `--yes`, the plan prints the count and the first ids.\n- Removing more than 1,000 contacts also needs `--confirm <count>`, and the count must match. The plan\'s `next` already carries the right `--confirm`.\n- Each id comes back `ok`, `skipped` when there was nothing to do (for example `not_deleted` when you restore a contact that is not removed), `not_found` or `failed`.\n- The remove summary carries the undo command, `"undo":"kenso contacts restore --run r_ubqu7wtx"`.\n\n```bash\nkenso contacts restore --run r_ubqu7wtx --yes\nkenso contacts restore --ids ids.txt --yes\nkenso contacts pause --where \'{"campaignIds": [812]}\' --yes\nkenso contacts resume --ids ids.txt --yes\n```\n\n`restore` takes `--ids` or `--run <runId>` of an earlier remove, not `--where`: a search cannot find removed contacts. `pause` is a beta command for workspaces with the `pause_leads` flag.\n\n## Tag and untag\n\n```bash\nkenso tags list\nkenso contacts tag --tag 31 --ids ids.txt --yes\nkenso contacts untag --tag 31 --ids ids.txt --yes\n```\n\n`tag` calls `POST /v1/tags/{tagId}/assignments` once per contact. A contact that already has the tag is `skipped` with reason `already_tagged`.\n\n## Export a campaign\'s leads\n\n```bash\nkenso contacts export --campaign 812 --out contacts.csv\nkenso contacts export --campaign 812 --wait\n```\n\nWith `--out`, the CLI creates the export, waits for the job (default 30 minutes, `--timeout`) and writes one CSV file (mode 0600). Without `--out` it prints the export job; `--wait` waits for it, or run the `next` it prints, `kenso jobs wait <jobId> --type contact_export`.\n\n## Recipes\n\n**Tag every lead of a campaign.** List the ids, then tag them:\n\n```bash\nkenso contacts list --campaign-id 812 --all -o ids > ids.txt\nkenso contacts tag --tag 31 --ids ids.txt --yes\n```\n\n**Fix the invalid rows and send them.** `invalid.csv` keeps each refused row\'s number and reason. Fix those rows in a new file and import it. Rerunning the original file also works: rows Kenso already saved come back `updated` or `skipped`.\n\n**Retry only what failed.** Filter `results.csv` to the `failed` rows, take those rows from the input by `row` number, and import that file.\n\n**Pause leads who replied elsewhere.** Plan with the filter (the plan shows the count), then apply:\n\n```bash\nkenso contacts pause --where @replied.json\nkenso contacts pause --where @replied.json --yes\n```\n\n**Edit one field on many leads by email.**\n\n```bash\nkenso contacts update --file titles.csv --match email --campaign 812 --dry-run\nkenso contacts update --file titles.csv --match email --campaign 812 --yes\n```\n';
|
|
7795
|
+
leads_default = '# Leads\n\nLeads are contacts in a campaign. The lead commands live under `kenso contacts`, and `kenso leads` is the same thing: `kenso leads import` runs `kenso contacts import`.\n\n| Command | What it does |\n|---|---|\n| `contacts import` | Add leads from a CSV or JSONL file to a campaign, with one result per row |\n| `contacts update` | Edit leads in bulk from a file, matched by id or by email |\n| `contacts remove` / `restore` | Remove (soft-delete) leads by id, and undo it |\n| `contacts pause` / `resume` | Pause and resume the campaign sequence of leads (pause is beta, `pause_leads` flag) |\n| `contacts tag` / `untag` | Add or remove a tag on leads by id |\n| `contacts export` | Download a campaign\'s leads as one CSV file |\n\nAll of them except `export` are batch commands: without `--yes` they print a plan and change nothing. [Batch runs](batch.md) explains plans, run folders, results files and resume.\n\n## Import a CSV into a campaign\n\n```bash\nkenso contacts import --template\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\n`--template` prints the accepted columns. A minimal file:\n\n```csv\nemail,firstName,lastName,companyName,Pain Point\nann@acme.io,Ann,Lee,Acme,Slow onboarding\ncid@globex.com,Cid,Moe,Globex,Churn\n```\n\n### Columns\n\nHeaders are matched without regard to case, spaces or punctuation. The known fields and the other headers each one reads:\n\n| Field | Also read from | Rule |\n|---|---|---|\n| `email` | email address, e-mail, work email | Required, unless the campaign is LinkedIn-only and the row has a linkedin.com/in/ URL |\n| `firstName` | first name, first, given name | Required |\n| `lastName` | last name, last, surname, family name | Required |\n| `title` | job title, position, role | Optional |\n| `linkedInUrl` | linkedin, linkedin url, linkedin profile, profile url | Optional |\n| `companyName` | company, organization, account, account name | `companyName` or `companyDomain` is required |\n| `companyDomain` | website, domain, company website, url | `companyName` or `companyDomain` is required |\n\nEvery other column becomes a custom variable, named like its header in snake_case: a `Pain Point` column fills `{{pain_point}}` in your sequence. Names Kenso keeps for its own fields (`city`, `country`, `phone_number` and others) are not sent: the CLI warns and the plan lists them under `droppedColumns`. Rename them with `--map`.\n\n### Cells\n\n- A blank cell is never sent, so importing a file never erases data on a lead that is already in the campaign.\n- The literal value `null` clears a custom variable.\n\n### Rename or drop columns with --map\n\n`--map` takes a JSON object, `@file` or `-` for stdin. A value names the target field, and `null` drops the column:\n\n```bash\nkenso contacts import --campaign 812 --file leads.csv --map \'{"Pain": "customVariables.pain_point", "Notes": null}\' --yes\n```\n\n### JSONL\n\nEach line is one lead. Keys work like CSV headers, and a `customVariables` object is spread into custom variables:\n\n```json\n{"email":"ann@acme.io","firstName":"Ann","lastName":"Lee","companyName":"Acme","customVariables":{"pain_point":"Slow onboarding"}}\n```\n\n```bash\nkenso contacts import --campaign 812 --file leads.jsonl --yes\ncat leads.jsonl | kenso contacts import --campaign 812 --file - --yes\n```\n\nA run read from stdin cannot be resumed with `kenso runs resume`, so prefer a file for large imports.\n\n### What the CLI checks before sending\n\nEvery row is checked locally first. A row that fails goes to `invalid.csv` with one of these reasons and is not sent:\n\n| Reason | Meaning |\n|---|---|\n| `missing_email` | The row has no email (and is not a LinkedIn-only lead) |\n| `invalid_email` | The email is not a valid address |\n| `missing_first_name` | The row has no first name |\n| `missing_last_name` | The row has no last name |\n| `missing_company` | The row has neither a company name nor a company domain |\n| `sales_navigator_url` | An email-less row whose LinkedIn URL is a Sales Navigator link: add the email or a linkedin.com/in/ URL |\n| `duplicate_in_file` | An earlier row of the file has the same email |\n\nKenso stays the authority and checks every row again.\n\n### What the dry run shows\n\nThe dry run maps the columns, checks the rows, reads the campaign, and asks for a credit estimate (`credit-estimates create`, kind `leads`). Its plan holds `rows`, `valid`, `invalid`, `mapping`, `customVariableKeys`, `estimate`, `credits` (`needed`, `available`, `sufficient`) and `next`, the exact apply command. If the estimate call fails, the plan still prints with `"estimate":null` and an `estimateError`.\n\n### How rows are sent\n\nThe CLI sends 1,000 rows per call to `POST /v1/campaigns/{campaignId}/contacts`, one call at a time per campaign, because two overlapping upserts of the same email could create duplicates. After a 5xx answer or a dropped connection it does not retry right away: it waits 130 seconds, so the first request has finished on the server, then resends the chunk once. Rows the first request saved come back `updated`.\n\n### Reading the result\n\nEach row in `results.csv` gets one status:\n\n| Status | Meaning |\n|---|---|\n| `created` | A new lead in the campaign |\n| `updated` | The lead was already there and was updated |\n| `skipped` | Kenso kept the lead out on purpose. `reason` is `duplicate`, `blocklisted`, `already_contacted`, `excluded` or another code |\n| `failed` | Kenso refused the row (`reason` such as `invalid_email` or `validation`, and an `error` message), or the call failed |\n| `invalid` | The CLI refused the row before sending it (see the table above) |\n\nA saved lead that cannot be emailed yet has `sendable` false, and the summary counts those leads in `notSendable` with a warning on stderr.\n\nExit codes: 0 when no row failed (skipped rows are not failures), 5 when some rows failed or were invalid, 6 when the plan\'s or campaign\'s lead limit stopped the run (`limit_reached`; raise the limit, then rerun the same command to send the rest).\n\n## Import a very large file on the server\n\nFor up to 100,000 rows, `--server-import` uploads the CSV as one server import job and waits for it (default 30 minutes, `--timeout`). It reports the job\'s counts but no per-row results.\n\n```bash\nkenso contacts import --campaign 812 --file big.csv --server-import --yes\nkenso contacts import --campaign 812 --file big.csv --server-import --timeout 1h --yes\n```\n\n## Update leads in bulk\n\n```bash\nkenso contacts update --file edits.csv --match id\nkenso contacts update --file edits.csv --match id --yes\nkenso contacts update --file edits.csv --match email --campaign 812 --yes\n```\n\n- `--match id` reads the contact id from an `id` or `contactId` column.\n- `--match email` finds each email among the leads of `--campaign`. An email it cannot find is `not_found`. The email column only finds the lead; it is never sent as an edit.\n- A column that is absent, or a blank cell, leaves that field unchanged. The literal `null` clears it.\n- The lead fields you can edit are `firstName`, `lastName`, `title`, `linkedInUrl`, and `email` with `--match id`. `companyName` and `companyDomain` cannot change here and are not sent. Every other column is a custom variable, mapped the same way as in an import, and `--map` works here too.\n- A row with nothing to change is `skipped` with reason `no_changes` and is not sent. Rows go 1,000 per call to `POST /v1/contacts/bulk-update`.\n\nTo edit one lead, use a one-row file from stdin:\n\n```bash\nprintf \'id,title\\n9001,VP Sales\\n\' | kenso contacts update --file - --match id --yes\n```\n\n## Remove, restore, pause and resume\n\nThese four take contact ids from `--ids` (one id per line, or a CSV or JSONL file with an `id` or `contactId` column, or `-` for stdin), or from a search with `--where` (remove, pause and resume). `--where` takes the body of `POST /v1/contacts/search` as JSON, `@file` or `-`, and does the search itself: its plan shows how many contacts match and the first ids, so run no separate search or list first. `q` matches names and email addresses only; a company is a `filters` condition on `ContactCompany.Name` (`operator` 2 is contains; `kenso describe contacts search` lists the fields and operators).\n\n```bash\nkenso contacts remove --ids ids.txt --dry-run\nkenso contacts remove --ids ids.txt --yes\nkenso contacts remove --where \'{"campaignIds": [812], "filters": [{"conditions": {"field": "ContactCompany.Name", "operator": 2, "value": "acme"}}]}\' --dry-run\nkenso contacts remove --where \'{"campaignIds": [812], "filters": [{"conditions": {"field": "ContactCompany.Name", "operator": 2, "value": "acme"}}]}\' --yes\nkenso contacts remove --ids big.csv --confirm 2500 --yes\n```\n\n- Without `--yes`, the plan prints the count and the first ids.\n- Removing more than 1,000 contacts also needs `--confirm <count>`, and the count must match. The plan\'s `next` already carries the right `--confirm`.\n- Each id comes back `ok`, `skipped` when there was nothing to do (for example `not_deleted` when you restore a contact that is not removed), `not_found` or `failed`.\n- The remove summary carries the undo command, `"undo":"kenso contacts restore --run r_ubqu7wtx"`.\n\n```bash\nkenso contacts restore --run r_ubqu7wtx --yes\nkenso contacts restore --ids ids.txt --yes\nkenso contacts pause --where \'{"campaignIds": [812]}\' --yes\nkenso contacts resume --ids ids.txt --yes\n```\n\n`restore` takes `--ids` or `--run <runId>` of an earlier remove, not `--where`: a search cannot find removed contacts. `pause` is a beta command for workspaces with the `pause_leads` flag.\n\n## Tag and untag\n\n```bash\nkenso tags list\nkenso contacts tag --tag 31 --ids ids.txt --yes\nkenso contacts untag --tag 31 --ids ids.txt --yes\n```\n\n`tag` calls `POST /v1/tags/{tagId}/assignments` once per contact. A contact that already has the tag is `skipped` with reason `already_tagged`.\n\n## Export a campaign\'s leads\n\n```bash\nkenso contacts export --campaign 812 --out contacts.csv\nkenso contacts export --campaign 812 --wait\n```\n\nWith `--out`, the CLI creates the export, waits for the job (default 30 minutes, `--timeout`) and writes one CSV file (mode 0600). An audience-based campaign exports one CSV per segment in a ZIP: the CLI saves the ZIP as it came, prints `"format": "zip"` and its size instead of a row count, and warns when `--out` does not end in `.zip`. Without `--out` it prints the export job; `--wait` waits for it, or run the `next` it prints, `kenso jobs wait <jobId> --type contact_export`.\n\n## Recipes\n\n**Tag every lead of a campaign.** List the ids, then tag them:\n\n```bash\nkenso contacts list --campaign-id 812 --all -o ids > ids.txt\nkenso contacts tag --tag 31 --ids ids.txt --yes\n```\n\n**Fix the invalid rows and send them.** `invalid.csv` keeps each refused row\'s number and reason. Fix those rows in a new file and import it. Rerunning the original file also works: rows Kenso already saved come back `updated` or `skipped`.\n\n**Retry only what failed.** Filter `results.csv` to the `failed` rows, take those rows from the input by `row` number, and import that file.\n\n**Pause leads who replied elsewhere.** Plan with the filter (the plan shows the count), then apply:\n\n```bash\nkenso contacts pause --where @replied.json\nkenso contacts pause --where @replied.json --yes\n```\n\n**Edit one field on many leads by email.**\n\n```bash\nkenso contacts update --file titles.csv --match email --campaign 812 --dry-run\nkenso contacts update --file titles.csv --match email --campaign 812 --yes\n```\n';
|
|
7589
7796
|
}
|
|
7590
7797
|
});
|
|
7591
7798
|
|
|
@@ -7593,7 +7800,7 @@ var init_leads = __esm({
|
|
|
7593
7800
|
var output_and_errors_default;
|
|
7594
7801
|
var init_output_and_errors = __esm({
|
|
7595
7802
|
"docs/output-and-errors.md"() {
|
|
7596
|
-
output_and_errors_default = '# Output and errors\n\nEvery command follows one contract, so a script or an agent can parse any of them the same way.\n\n## stdout and stderr\n\n- **stdout carries data only.** Progress, warnings, notices and errors go to stderr.\n- No colors, spinners or pagers. On a terminal you get readable tables; in a pipe you get JSON.\n- A batch command (an import, update, remove, tag or `--each` write) takes `--yes`; without it, the command plans or refuses.\n- A command that deletes, archives or removes, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive` or `kenso api DELETE /v1/tags/7`, needs `--yes` too. Without it, a person at a terminal is asked to confirm; anywhere else (a pipe, a script, CI, a coding agent) it sends nothing and fails with `confirmation_required`, whose `next` is the same command with `--yes`.\n- Any other single write, such as `kenso tags create` or a write through `kenso api` or `kenso mcp call`, sends at once: add `--dry-run` to print the request first (it sends nothing), then run the command without it.\n- A command with no dry run, such as `kenso contacts export`, `kenso auth logout` or `kenso workspace use`, refuses `--dry-run` with `usage_error` (exit 2) and does nothing. Its help ends with `No --dry-run`, and `kenso describe <resource> <action>` shows `"dryRun": false`.\n\n## Formats\n\n| What the command returns | stdout is a terminal | stdout is a pipe or file |\n|---|---|---|\n| One object | key-value lines | compact JSON on one line |\n| A list | a table (first 8 scalar fields, cells cut at 60 characters) | NDJSON: one JSON object per line |\n| A batch run | key-value lines | one JSON summary object |\n| No content (HTTP 204) | nothing | nothing |\n\n`-o` or `--output` picks the format: `json`, `ndjson`, `table` or `ids`. `--json` is the same as `-o json`.\n\n- `-o json` on a list prints one JSON array. On a terminal, `-o json` pretty-prints an object.\n- `-o ids` prints one id per line, ready for `--ids -`. Items without an `id` are skipped with one warning.\n\n```bash\nkenso campaigns list --limit 3\nkenso campaigns list --limit 3 -o json\nkenso contacts list --campaign-id 812 --all -o ids\n```\n\n## Shape the output\n\n- `--fields a,b.c` keeps only those fields (dots reach into nested objects).\n- `--query <JMESPath>` filters or reshapes in-process, so you need no `jq`. On a list it sees the whole list. There is no `--jq`: `--query` takes JMESPath, not jq syntax.\n- Neither applies to a batch summary, which always prints in full.\n\n```bash\nkenso campaigns list --fields id,name,status\nkenso campaigns list --all --query "[?status==\'active\'].id"\nkenso me get --query "length(features)"\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## Live streams\n\n`kenso sync events` and `kenso onboarding-builds events` follow a live stream of server-sent events. They print one JSON line per event as it arrives, on a terminal too, with the event\'s name, its id when it has one, and its data:\n\n```json\n{"event":"hello","data":{"buildId":"obd_2x","status":"building","stage":"read","lastEventId":0}}\n{"event":"stage","id":"41","data":{"stage":"plan"}}\n{"event":"done","id":"42","data":{}}\n```\n\nA stream has no time limit while events arrive. The server ends each connection after 15 minutes with a `bye` event; the command then connects again at once, and after a dropped connection or 60 s without even a keepalive, after a second. A connection that brought nothing but `hello` and `bye` (a server that is restarting) backs off 1, 2, 4 ... 30 s. Once events carry an id (`onboarding-builds events`), it sends the last whole event\'s id as `Last-Event-ID`, so no event is lost or printed twice. A refusal (401, 403, 404) ends it at once; eight failed or empty connects in a row end it with the last error.\n\nIt runs until Ctrl-C (exit 130; every line printed is whole), or until one of these:\n\n| Flag | Ends the command |\n|---|---|\n| `--until <event>` | After the first event with that name; several names are comma-separated: `--until done,error` |\n| `--max-events <n>` | After n events, `hello` and `bye` included |\n| `--once` | When the server closes the connection, instead of connecting again |\n\n```bash\nkenso onboarding-builds events --build-id obd_2x --until done,error\nkenso sync events --max-events 2 # hello, then the first poke\n```\n\n`--output`, `--fields` and `--query` do not apply to a stream. `--last-event-id` starts an onboarding build stream after that id.\n\n## Errors\n\nWhen stderr is not a terminal, an error is one JSON line on stderr:\n\n```json\n{"error":{"code":"unknown_flag","message":"Unknown flag --fiel for kenso contacts import.","field":"fiel","hint":"did you mean --file?","next":"kenso contacts import --help"}}\n```\n\n| Key | Always there | Meaning |\n|---|---|---|\n| `code` | yes | A stable snake_case code to branch on |\n| `message` | yes | One sentence for a person |\n| `field` | no | The flag or input field at fault |\n| `hint` | no | What to change |\n| `next` | no | The exact command to run next, such as `kenso auth login`, `kenso workspace list --search <name>` or the same command with `--yes` |\n| `httpStatus` | no | The API\'s HTTP status, when the API answered |\n| `requestId` | no | The API\'s request id: quote it when you contact Kenso support |\n\nOn a terminal the same error prints as text: `Error: <message>`, then `field:`, `hint:`, `next:` and `requestId:` lines. The key never appears in an error.\n\n### How API errors map\n\nThe CLI looks at the HTTP status first, then at the API\'s own `error.code`, which wins when present.\n\n| HTTP status | Default code | Exit |\n|---|---|---|\n| 400, 422 | `validation_failed` | 2 |\n| 401 | `unauthorized` (`next`: `kenso auth login`) | 3 |\n| 403 | `forbidden`: the key\'s user or role cannot do this in this workspace | 3 |\n| 404 | `not_found` | 4 |\n| 409 | `conflict` | 7 |\n| 429 | `rate_limited`, after the CLI waited and retried | 6 |\n| 5xx | `server_error`, after retries where they are safe | 8 |\n| anything else | `http_error` | 1 |\n\nTwo API codes change the exit code: `workspace_required` exits 2 with `"next":"kenso workspace list --search <name>"`, and `limit_reached` (the plan\'s or the campaign\'s lead limit) exits 6.\n\n### Errors from the CLI itself\n\n| Code | Exit | When |\n|---|---|---|\n| `usage_error` | 2 | A required flag or argument is missing, two flags conflict (`--yes` with `--dry-run`), or `--dry-run` on a command that has no dry run |\n| `unknown_command` | 2 | No such command; `hint` suggests the closest one |\n| `unknown_flag`, `invalid_flag`, `invalid_flag_value`, `unexpected_argument` | 2 | A flag or argument the command does not take |\n| `invalid_query` | 2 | `--query` is not valid JMESPath |\n| `confirmation_required` | 2 | A delete, archive or remove ran without `--yes` where nobody can confirm: nothing was sent; `next` adds `--yes` |\n| `cancelled` | 2 | A person answered no to the confirmation: nothing was sent |\n| `file_unreadable` | 2 | An input file is missing, is a folder, cannot be opened, or cannot be parsed; the message names the line, such as `leads.csv line 3: a quote is not closed.` |\n| `config_invalid` | 2 | `~/.kenso/config.json` is not valid JSON: fix or delete it |\n| `feature_not_enabled` | 2 | Every action of the resource is a beta command your workspace has not enabled |\n| `invalid_key_format`, `key_required` | 2 | `auth login --with-key` read something that is not a Kenso key, or stdin is a terminal instead of a pipe |\n| `invalid_workspace_id` | 2 | `kenso workspace use` got an id that is not a positive whole number |\n| `unknown_topic` | 2 | `kenso docs` got a topic it does not have; `hint` lists the topics |\n| `file_unwritable` | 2 or 1 | An output file cannot be written: `contacts export --out` (2), `skill install` (1) |\n| `no_api_key` | 3 | No key in `KENSO_API_KEY` or the profile (`next`: `kenso auth login`) |\n| `browser_login_unavailable`, `access_denied`, `login_expired` | 3 | Browser login is off, was denied, or timed out |\n| `run_not_found` | 4 | `kenso runs show` or `resume` got an unknown run id |\n| `docs_not_found` | 4 | `kenso docs reference` before the reference was generated (a source checkout without `pnpm build`) |\n| `run_in_progress`, `already_filled` | 7 | Another process is working on the run, or `studio fill` already ran with this file and these flags |\n| `skill_exists` | 7 | `kenso skill install` found a different `SKILL.md`; `next` adds `--force` to replace it |\n| `job_timeout`, `job_failed`, `job_canceled` | 1 | `kenso jobs wait` (or a command that waits on a job) ran out of time, or the job failed or was canceled |\n| `mcp_tool_error` | 1 | `kenso mcp call`: the MCP tool answered with an error |\n| `unsafe_path` | 1 | `studio pull` refused a file path that would land outside `--dir` |\n| `network_error` | 8 | The API could not be reached after retries |\n| `upload_failed`, `download_failed` | 8 or 1 | A signed upload or download of a Studio file failed: 8 when storage was unreachable or answered 5xx, 1 on a 4xx (often an expired link: run the command again) |\n| `pull_incomplete` | 8 | `studio pull`: a file came back with neither text nor a download link |\n| `unexpected_response` | 1 or 8 | The API answered something the CLI could not read |\n| `unexpected_error` | 1 | A bug: run again with `--verbose` and report it |\n| `interrupted` | 130 | Ctrl-C |\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | OK, including a batch where every row succeeded or was skipped |\n| 1 | Unexpected error |\n| 2 | Usage or input error: a bad flag, a bad file, a validation error |\n| 3 | Auth: no key, an invalid, revoked or expired key, or HTTP 401 or 403 |\n| 4 | Not found |\n| 5 | Partial: the batch finished and some rows failed, were not found or were invalid. See `results.csv` |\n| 6 | Rate limited after retries, or a plan or campaign lead limit stopped the run (`limit_reached`) |\n| 7 | Conflict or invalid state (HTTP 409), or a run another process holds |\n| 8 | Server error after retries (5xx), or the API is unreachable |\n| 9 | Answer refused: a Kenso sandbox run stopped because an answer held a credential or something shaped like one |\n| 130 | Interrupted. A batch run can be resumed: see its `next` |\n\nSkipped rows (duplicates, blocklisted, already contacted) are not failures: a batch with only created, updated and skipped rows exits 0.\n\n## Flags\n\n- Command flags go after the command: `kenso contacts import --campaign 812`. Global flags can go anywhere.\n- A boolean flag takes `--flag`, `--no-flag`, `--flag=true` and `--flag=false`.\n- A flag that carries a secret (`--password`, `--api-key`, `--api-secret`, any `--\u2026-token` or `--\u2026-secret`) also takes `-` (read stdin), `@file` (read the file) or `env:NAME` (read that environment variable), so the value stays out of shell history: `printf \'%s\' "$FATHOM_KEY" | kenso fathom-connection connect --api-key -`. A value typed on the command line still works and prints one warning. A typed secret that itself starts with `@` is written `@@` (`--password @@Spring2026` sends `@Spring2026`); one that is exactly `-` or starts with `env:` has to come through `@file` or `env:NAME`. `-` refuses a terminal, an empty value is refused, and only one flag can read stdin. `--dry-run` shows a secret as `***`. With `--each`, the plan, its `next` and the run record keep `@file` or `env:NAME` as typed and `kenso runs resume` reads it again; a secret from stdin is refused there.\n- `--help` on any command prints its flags, arguments and examples. `kenso describe <resource> <action>` prints the same as JSON, with the body schema.\n\n## Beta commands\n\nCommands that need a workspace feature flag (CRM, Studio and others) are beta. Help and `kenso describe` hide the ones your workspace has not enabled and say how many they hid; `--all-commands` shows them. Calling a hidden command still works: Kenso decides. `kenso <resource>` on a resource whose every action is hidden answers `feature_not_enabled` (exit 2) and names the flags it needs.\n\n```bash\nkenso --help --all-commands\nkenso describe --all-commands\n```\n\n## What the CLI sends\n\nEvery API call carries `Authorization: Bearer <key>`, `Ken-Version: 1.1`, `X-Ken-Workspace-Id` (when a workspace is picked), `User-Agent: kenso-cli/<version> (node <version>; <platform>)` and `X-Ken-Client: Kenso CLI`. When a coding agent runs the CLI, `X-Ken-Client` names it (`Kenso CLI via Claude Code`) and writes carry `X-Ken-Actor: agent`, so Kenso\'s activity log shows who made a change.\n';
|
|
7803
|
+
output_and_errors_default = '# Output and errors\n\nEvery command follows one contract, so a script or an agent can parse any of them the same way.\n\n## stdout and stderr\n\n- **stdout carries data only.** Progress, warnings, notices and errors go to stderr.\n- No colors, spinners or pagers. On a terminal you get readable tables; in a pipe you get JSON.\n- A batch command (an import, update, remove, tag or `--each` write) takes `--yes`; without it, the command plans or refuses.\n- A command that deletes, archives or removes, such as `kenso tags delete --tag-id 7`, `kenso campaigns archive` or `kenso api DELETE /v1/tags/7`, needs `--yes` too. Without it, a person at a terminal is asked to confirm; anywhere else (a pipe, a script, CI, a coding agent) it sends nothing and fails with `confirmation_required`, whose `next` is the same command with `--yes`.\n- Any other single write, such as `kenso tags create` or a write through `kenso api` or `kenso mcp call`, sends at once: add `--dry-run` to print the request first (it sends nothing), then run the command without it.\n- A command with no dry run, such as `kenso contacts export`, `kenso auth logout` or `kenso workspace use`, refuses `--dry-run` with `usage_error` (exit 2) and does nothing. Its help ends with `No --dry-run`, and `kenso describe <resource> <action>` shows `"dryRun": false`.\n\n## Formats\n\n| What the command returns | stdout is a terminal | stdout is a pipe or file |\n|---|---|---|\n| One object | key-value lines | compact JSON on one line |\n| A list | a table (first 8 scalar fields, cells cut at 60 characters) | NDJSON: one JSON object per line |\n| A batch run | key-value lines | one JSON summary object |\n| No content (HTTP 204) | nothing | nothing |\n\n`-o` or `--output` picks the format: `json`, `ndjson`, `table` or `ids`. `--json` is the same as `-o json`.\n\n- `-o json` on a list prints one JSON array. On a terminal, `-o json` pretty-prints an object.\n- `-o ids` prints one id per line, ready for `--ids -`. Items without an `id` are skipped with one warning.\n\n```bash\nkenso campaigns list --limit 3\nkenso campaigns list --limit 3 -o json\nkenso contacts list --campaign-id 812 --all -o ids\n```\n\n## Shape the output\n\n- `--fields a,b.c` keeps only those fields (dots reach into nested objects).\n- `--query <JMESPath>` filters or reshapes in-process, so you need no `jq`. On a list it sees the whole list. There is no `--jq`: `--query` takes JMESPath, not jq syntax.\n- Neither applies to a batch summary, which always prints in full.\n\n```bash\nkenso campaigns list --fields id,name,status\nkenso campaigns list --all --query "[?status==\'active\'].id"\nkenso me get --query "length(features)"\n```\n\n## Lists and pages\n\nA list command prints one page. When there are more, it prints the command for the next page on stderr, for example `next: kenso tags list --limit 1 --cursor MQ`. `--all` follows every page and streams the items. `--limit` sets the page size and `--cursor` starts at a cursor.\n\n`accounts search`, `contacts search` and `people search` page the same way: one page with the `next:` command, or every page with `--all`. A search that asks for counts (`countBy` in `--data`) prints the whole answer instead: `data`, `pagination` and `counts`. Counts cover every match whatever the page, so ask for them on one page (`--limit 1`): `--all` with `countBy` is a usage error.\n\n```bash\nkenso tags list --limit 50\nkenso tags list --all\n```\n\n## Files: uploads and downloads\n\nA command whose API action takes a multipart upload takes `--file <path>`: the CLI reads the file and sends it in the form, with a content type from its extension (a `.png` goes as `image/png`), and the other flags as form fields. `--file <field>=<path>` names the form field, for a form with more than one file. An upload that also takes JSON, such as a logo from a URL instead of a file, sends JSON when you leave `--file` out.\n\nA command whose API action answers with a file (a CSV, an image, a ZIP) takes `--out <path>`: it saves the answer byte for byte (mode 0600) and prints `out`, `bytes` and `contentType`, so the file never passes through an agent\'s context. Without `--out`, a CSV prints as it came, and a binary file goes to stdout only when stdout is a pipe or a file: on a terminal it fails with `binary_output`, whose `next` adds `--out`.\n\n`kenso api` takes both, for any route: `--file` (repeat it for more files) sends multipart with the keys of a `--data` object as form fields, and `--out` saves any answer.\n\n```bash\nkenso saved-lists create-upload --saved-list-id 12 --file people.csv\nkenso workspaces replace-logo --workspace-id 42 --file ./logo.png\nkenso workspaces replace-logo --workspace-id 42 --source-url https://example.com/logo.png\nkenso attachments get-content --attachment-id att_123 --out ./invoice.pdf\nkenso api POST /v1/campaigns/812/email-sequence/images --file ./hero.png\nkenso api GET /v1/knowledge/exports/77/content --out knowledge.zip\n```\n\n## Live streams\n\n`kenso sync events` and `kenso onboarding-builds events` follow a live stream of server-sent events. They print one JSON line per event as it arrives, on a terminal too, with the event\'s name, its id when it has one, and its data:\n\n```json\n{"event":"hello","data":{"buildId":"obd_2x","status":"building","stage":"read","lastEventId":0}}\n{"event":"stage","id":"41","data":{"stage":"plan"}}\n{"event":"done","id":"42","data":{}}\n```\n\nA stream has no time limit while events arrive. The server ends each connection after 15 minutes with a `bye` event; the command then connects again at once, and after a dropped connection or 60 s without even a keepalive, after a second. A connection that brought nothing but `hello` and `bye` (a server that is restarting) backs off 1, 2, 4 ... 30 s. Once events carry an id (`onboarding-builds events`), it sends the last whole event\'s id as `Last-Event-ID`, so no event is lost or printed twice. A refusal (401, 403, 404) ends it at once; eight failed or empty connects in a row end it with the last error.\n\nIt runs until Ctrl-C (exit 130; every line printed is whole), or until one of these:\n\n| Flag | Ends the command |\n|---|---|\n| `--until <event>` | After the first event with that name; several names are comma-separated: `--until done,error` |\n| `--max-events <n>` | After n events, `hello` and `bye` included |\n| `--once` | When the server closes the connection, instead of connecting again |\n\n```bash\nkenso onboarding-builds events --build-id obd_2x --until done,error\nkenso sync events --max-events 2 # hello, then the first poke\n```\n\n`--output`, `--fields` and `--query` do not apply to a stream. `--last-event-id` starts an onboarding build stream after that id.\n\n## Errors\n\nWhen stderr is not a terminal, an error is one JSON line on stderr:\n\n```json\n{"error":{"code":"unknown_flag","message":"Unknown flag --fiel for kenso contacts import.","field":"fiel","hint":"did you mean --file?","next":"kenso contacts import --help"}}\n```\n\n| Key | Always there | Meaning |\n|---|---|---|\n| `code` | yes | A stable snake_case code to branch on |\n| `message` | yes | One sentence for a person |\n| `field` | no | The flag or input field at fault |\n| `hint` | no | What to change |\n| `next` | no | The exact command to run next, such as `kenso auth login`, `kenso workspace list --search <name>` or the same command with `--yes` |\n| `httpStatus` | no | The API\'s HTTP status, when the API answered |\n| `requestId` | no | The API\'s request id: quote it when you contact Kenso support |\n\nOn a terminal the same error prints as text: `Error: <message>`, then `field:`, `hint:`, `next:` and `requestId:` lines. The key never appears in an error.\n\n### How API errors map\n\nThe CLI looks at the HTTP status first, then at the API\'s own `error.code`, which wins when present.\n\n| HTTP status | Default code | Exit |\n|---|---|---|\n| 400, 422 | `validation_failed` | 2 |\n| 401 | `unauthorized` (`next`: `kenso auth login`) | 3 |\n| 403 | `forbidden`: the key\'s user or role cannot do this in this workspace | 3 |\n| 404 | `not_found` | 4 |\n| 409 | `conflict` | 7 |\n| 429 | `rate_limited`, after the CLI waited and retried | 6 |\n| 5xx | `server_error`, after retries where they are safe | 8 |\n| anything else | `http_error` | 1 |\n\nTwo API codes change the exit code: `workspace_required` exits 2 with `"next":"kenso workspace list --search <name>"`, and `limit_reached` (the plan\'s or the campaign\'s lead limit) exits 6.\n\n### Errors from the CLI itself\n\n| Code | Exit | When |\n|---|---|---|\n| `usage_error` | 2 | A required flag or argument is missing, two flags conflict (`--yes` with `--dry-run`), or `--dry-run` on a command that has no dry run |\n| `unknown_command` | 2 | No such command; `hint` suggests the closest one |\n| `unknown_flag`, `invalid_flag`, `invalid_flag_value`, `unexpected_argument` | 2 | A flag or argument the command does not take |\n| `invalid_query` | 2 | `--query` is not valid JMESPath |\n| `confirmation_required` | 2 | A delete, archive or remove ran without `--yes` where nobody can confirm: nothing was sent; `next` adds `--yes` |\n| `cancelled` | 2 | A person answered no to the confirmation: nothing was sent |\n| `file_unreadable` | 2 | An input file is missing, is a folder, cannot be opened, or cannot be parsed; the message names the line, such as `leads.csv line 3: a quote is not closed.` |\n| `config_invalid` | 2 | `~/.kenso/config.json` is not valid JSON: fix or delete it |\n| `feature_not_enabled` | 2 | Every action of the resource is a beta command your workspace has not enabled |\n| `invalid_key_format`, `key_required` | 2 | `auth login --with-key` read something that is not a Kenso key, or stdin is a terminal instead of a pipe |\n| `invalid_workspace_id` | 2 | `kenso workspace use` got an id that is not a positive whole number |\n| `unknown_topic` | 2 | `kenso docs` got a topic it does not have; `hint` lists the topics |\n| `file_unwritable` | 2 or 1 | An output file cannot be written: `--out` on `contacts export`, `kenso api` or a download command (2), `skill install` (1) |\n| `binary_output` | 2 | The answer is a binary file and stdout is a terminal: nothing was printed; `next` saves it with `--out` |\n| `no_api_key` | 3 | No key in `KENSO_API_KEY` or the profile (`next`: `kenso auth login`) |\n| `browser_login_unavailable`, `access_denied`, `login_expired` | 3 | Browser login is off, was denied, or timed out |\n| `run_not_found` | 4 | `kenso runs show` or `resume` got an unknown run id |\n| `docs_not_found` | 4 | `kenso docs reference` before the reference was generated (a source checkout without `pnpm build`) |\n| `run_in_progress`, `already_filled` | 7 | Another process is working on the run, or `studio fill` already ran with this file and these flags |\n| `skill_exists` | 7 | `kenso skill install` found a different `SKILL.md`; `next` adds `--force` to replace it |\n| `job_timeout`, `job_failed`, `job_canceled` | 1 | `kenso jobs wait` (or a command that waits on a job) ran out of time, or the job failed or was canceled |\n| `mcp_tool_error` | 1 | `kenso mcp call`: the MCP tool answered with an error |\n| `unsafe_path` | 1 | `studio pull` refused a file path that would land outside `--dir` |\n| `network_error` | 8 | The API could not be reached after retries |\n| `upload_failed`, `download_failed` | 8 or 1 | A signed upload or download of a Studio file failed: 8 when storage was unreachable or answered 5xx, 1 on a 4xx (often an expired link: run the command again) |\n| `pull_incomplete` | 8 | `studio pull`: a file came back with neither text nor a download link |\n| `unexpected_response` | 1 or 8 | The API answered something the CLI could not read |\n| `unexpected_error` | 1 | A bug: run again with `--verbose` and report it |\n| `interrupted` | 130 | Ctrl-C |\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | OK, including a batch where every row succeeded or was skipped |\n| 1 | Unexpected error |\n| 2 | Usage or input error: a bad flag, a bad file, a validation error |\n| 3 | Auth: no key, an invalid, revoked or expired key, or HTTP 401 or 403 |\n| 4 | Not found |\n| 5 | Partial: the batch finished and some rows failed, were not found or were invalid. See `results.csv` |\n| 6 | Rate limited after retries, or a plan or campaign lead limit stopped the run (`limit_reached`) |\n| 7 | Conflict or invalid state (HTTP 409), or a run another process holds |\n| 8 | Server error after retries (5xx), or the API is unreachable |\n| 9 | Answer refused: a Kenso sandbox run stopped because an answer held a credential or something shaped like one |\n| 130 | Interrupted. A batch run can be resumed: see its `next` |\n\nSkipped rows (duplicates, blocklisted, already contacted) are not failures: a batch with only created, updated and skipped rows exits 0.\n\n## Flags\n\n- Command flags go after the command: `kenso contacts import --campaign 812`. Global flags can go anywhere.\n- A boolean flag takes `--flag`, `--no-flag`, `--flag=true` and `--flag=false`.\n- A flag that carries a secret (`--password`, `--api-key`, `--api-secret`, any `--\u2026-token` or `--\u2026-secret`) also takes `-` (read stdin), `@file` (read the file) or `env:NAME` (read that environment variable), so the value stays out of shell history: `printf \'%s\' "$FATHOM_KEY" | kenso fathom-connection connect --api-key -`. A value typed on the command line still works and prints one warning. A typed secret that itself starts with `@` is written `@@` (`--password @@Spring2026` sends `@Spring2026`); one that is exactly `-` or starts with `env:` has to come through `@file` or `env:NAME`. `-` refuses a terminal, an empty value is refused, and only one flag can read stdin. `--dry-run` shows a secret as `***`. With `--each`, the plan, its `next` and the run record keep `@file` or `env:NAME` as typed and `kenso runs resume` reads it again; a secret from stdin is refused there.\n- `--help` on any command prints its flags, arguments and examples. `kenso describe <resource> <action>` prints the same as JSON, with the body schema.\n\n## Beta commands\n\nCommands that need a workspace feature flag (CRM, Studio and others) are beta. Help and `kenso describe` hide the ones your workspace has not enabled and say how many they hid; `--all-commands` shows them. Calling a hidden command still works: Kenso decides. `kenso <resource>` on a resource whose every action is hidden answers `feature_not_enabled` (exit 2) and names the flags it needs.\n\n```bash\nkenso --help --all-commands\nkenso describe --all-commands\n```\n\n## What the CLI sends\n\nEvery API call carries `Authorization: Bearer <key>`, `Ken-Version: 1.1`, `X-Ken-Workspace-Id` (when a workspace is picked), `User-Agent: kenso-cli/<version> (node <version>; <platform>)` and `X-Ken-Client: Kenso CLI`. When a coding agent runs the CLI, `X-Ken-Client` names it (`Kenso CLI via Claude Code`) and writes carry `X-Ken-Actor: agent`, so Kenso\'s activity log shows who made a change.\n';
|
|
7597
7804
|
}
|
|
7598
7805
|
});
|
|
7599
7806
|
|
|
@@ -7601,7 +7808,7 @@ var init_output_and_errors = __esm({
|
|
|
7601
7808
|
var README_default;
|
|
7602
7809
|
var init_README = __esm({
|
|
7603
7810
|
"docs/README.md"() {
|
|
7604
|
-
README_default = '# Kenso CLI\n\nThe Kenso CLI (`kenso`) is the command line for Kenso. It does bulk work in your Kenso workspace from files: add thousands of leads to a campaign, update or clean them up, import accounts and people, and build Studio templates. It is made for coding agents (Claude Code, Codex, Cursor) and the people who drive them: JSON on stdout, fixed exit codes, a dry run before every bulk write, and runs you can resume.\n\nEvery API operation a workspace member can call is also a command, such as `kenso campaigns list` or `kenso tags create`. So the CLI reaches what the Kenso MCP reaches, straight against `https://api.ken.so
|
|
7811
|
+
README_default = '# Kenso CLI\n\nThe Kenso CLI (`kenso`) is the command line for Kenso. It does bulk work in your Kenso workspace from files: add thousands of leads to a campaign, update or clean them up, import accounts and people, and build Studio templates. It is made for coding agents (Claude Code, Codex, Cursor) and the people who drive them: JSON on stdout, fixed exit codes, a dry run before every bulk write, and runs you can resume.\n\nEvery canonical API operation a workspace member can call is also a command, such as `kenso campaigns list` or `kenso tags create`. So the CLI reaches what the Kenso MCP reaches, straight against `https://api.ken.so`. The legacy routes with no canonical successor, such as sequence images, AI variables or thread opens, have no command: reach them with `kenso api <METHOD> <path>`.\n\n## Install\n\nOn macOS or Linux, with or without Node, run the [install script](https://ken.so/install.sh): fetch it with `curl -fsSL` and pipe it to `sh`. It installs a standalone build that brings its own Node.js, checks the download against the release\'s `SHA256SUMS`, puts the CLI in `~/.local/share/kenso` and links `~/.local/bin/kenso`. Run it again to update.\n\nWith Homebrew, on macOS or Linux, the same standalone build:\n\n```bash\nbrew install ken-technology/tap/kenso\n```\n\n`brew upgrade kenso` updates it.\n\nWith Node 22 or newer, on any system, Windows included:\n\n```bash\nnpm i -g kenso\nkenso --version\n```\n\nTo run it once without installing, use `npx kenso --version`. On an older Node, kenso stops with one line that says so.\n\nEvery way to install:\n\n| Way | Systems | Needs |\n|---|---|---|\n| Install script, above | macOS, Linux (glibc) | Nothing |\n| Homebrew, above | macOS, Linux | Homebrew |\n| npm, above | Any | Node 22 or newer |\n| Standalone build: unpack it and put its `bin` folder on your PATH | macOS, Linux, Windows | Nothing |\n\nThe standalone builds are at `https://downloads.ken.so/desktop/cli/<version>/`, one per system: `kenso-<version>-darwin-arm64.tar.gz`, `darwin-x64`, `linux-arm64`, `linux-x64` and `kenso-<version>-windows-x64.zip`, with their `SHA256SUMS`. `https://downloads.ken.so/desktop/cli/latest.yml` names the newest version. The builds come out nightly and Homebrew follows them, so a command added that day reaches npm first.\n\n### Tab completion\n\nTab completes resources, actions and flags once you install the script for your shell. The script asks `kenso` for the candidates on each Tab, so it stays right as the CLI updates: install it once.\n\n```bash\n# zsh: add this line to ~/.zshrc\nsource <(kenso completion zsh)\n# bash: add this line to ~/.bashrc (on bash 3.2, the macOS default, use: eval "$(kenso completion bash)")\nsource <(kenso completion bash)\n# fish: save the script once\nkenso completion fish > ~/.config/fish/completions/kenso.fish\n```\n\n### Update notice\n\nWhen a newer version is out, `kenso` says so on stderr after the command\'s own output, at most once a week: `kenso 0.1.40 is out (you have 0.1.35): npm i -g kenso@latest`. It checks `registry.npmjs.org` at most once every 7 days and never delays a command by more than about a second. A standalone build checks `latest.yml` on `downloads.ken.so` instead and names its own update: the install script, or `brew upgrade kenso` when Homebrew installed it. It stays quiet when stderr is not a terminal, in CI (`CI` set) and under a coding agent. Set `KENSO_NO_UPDATE_NOTIFIER=1` to turn it off.\n\n## 60-second quickstart\n\n1. Create an API key in app.ken.so at Settings > Integrations > API keys.\n2. Save the key, pick a workspace, then plan and apply a CSV import:\n\n```bash\necho $KEY | kenso auth login --with-key\nkenso workspace list --search acme\nkenso workspace use 1234\nkenso campaigns list --limit 5\nkenso contacts import --campaign 812 --file leads.csv --dry-run\nkenso contacts import --campaign 812 --file leads.csv --yes\n```\n\n`workspace list` and `workspace use` are only needed when your key reaches more than one workspace.\n\nThe dry run reads the file, maps the columns, checks every row, asks Kenso for a credit estimate, and writes nothing. It prints the plan, with the exact apply command in `next`:\n\n```json\n{"run":"r_tdi5cdnx","dryRun":true,"command":"contacts import","rows":4,"valid":2,"invalid":2,"chunks":1,"chunkSize":1000,"campaignId":812,"mapping":{"Email":"email","First Name":"firstName","Last Name":"lastName","Company":"companyName","Pain Point":"customVariables.pain_point"},"customVariableKeys":["pain_point"],"estimate":{"kind":"leads","totalMillicredits":2000,"availableMillicredits":500000,"sufficient":true},"credits":{"needed":2,"available":500,"sufficient":true},"next":"kenso contacts import --campaign 812 --file leads.csv --yes","plan":"/home/you/.kenso/runs/r_tdi5cdnx/plan.json","invalidRows":"/home/you/.kenso/runs/r_tdi5cdnx/invalid.csv"}\n```\n\nThe apply sends the rows and prints one summary. Every input row has one line in `results.csv`:\n\n```json\n{"run":"r_tdi5cdnx","rows":4,"ok":0,"created":1,"updated":0,"skipped":{"duplicate":1},"failed":0,"notFound":0,"invalid":2,"changed":1,"results":"/home/you/.kenso/runs/r_tdi5cdnx/results.csv","resultsNdjson":"/home/you/.kenso/runs/r_tdi5cdnx/results.ndjson","invalidRows":"/home/you/.kenso/runs/r_tdi5cdnx/invalid.csv","resumed":false,"durationMs":1840,"campaignId":812,"notSendable":0}\n```\n\nThis run exits 5 because two rows were invalid: open `invalid.csv` to see why, fix those rows, and import them again. Running the same command again is safe: an email that is already in the campaign comes back `updated` or `skipped`, never as a second lead.\n\n## CLI or MCP\n\n- **Use the CLI for volume:** anything that starts from a file, anything over about 50 records, anything you may need to rerun or resume. Records never pass through the model\'s context: the agent passes a file path and reads a short summary.\n- **Use the MCP for conversation and single records:** look up a campaign, draft a reply, read a report. The MCP is at `https://mcp.ken.so/mcp`, signs in with OAuth and needs no install ([connection guide](https://ken.so/mcp)).\n- **Both use the same API and the same permissions.** `kenso mcp call` reaches MCP-only tools, such as skills, from the shell.\n\n## Docs\n\nEvery page is in the package and prints offline with `kenso docs <topic>`.\n\n| Page | Topic | What it covers |\n|---|---|---|\n| [Authentication](auth.md) | `auth` | API keys, browser login, profiles, workspaces, `doctor` |\n| [Leads](leads.md) | `leads` | Import, update, remove, pause, tag and export leads, with recipes |\n| [Batch runs](batch.md) | `batch` | Dry run and apply, run folders, results files, resume, rate limits, `--each` |\n| [Output and errors](output-and-errors.md) | `output-and-errors` | The output contract, error JSON, error codes, exit codes, live streams |\n| [CRM (beta)](crm.md) | `crm` | Accounts, people, opportunities and CRM sync |\n| [Studio (beta)](studio.md) | `studio` | Pull, push, validate, preview and fill templates |\n| [Agent work (beta)](work.md) | `work` | My agent: your own coding agent writes Kenso\'s AI work with `kenso work run`, or pull and submit |\n| [Webhooks](webhooks.md) | `webhooks` | Build a webhook handler locally: `kenso webhooks listen --forward-to`, `trigger`, the signature |\n| [Developer sandbox](sandbox.md) | `sandbox` | `kenso sandbox`: a workspace of your own where sends are simulated, its test key, the reserved test leads |\n| [Connect accounts](connect.md) | `connect` | `kenso connect`: an inbox, calendar, CRM, GitHub or other OAuth account, signed in by the person in a browser |\n| [Coding agents](agents.md) | `agents` | Claude Code, Codex, Cursor, the Agent Skill, environment variables, sandboxes |\n| Command reference | `reference` | Every command with its flags, generated from the CLI at build time: `kenso docs reference`, or `docs/reference.md` in the installed package |\n\n```bash\nkenso docs\nkenso docs leads\n```\n\nFor machine-readable help, run `kenso describe`: it prints every command, its flags and its body schema as JSON.\n';
|
|
7605
7812
|
}
|
|
7606
7813
|
});
|
|
7607
7814
|
|
|
@@ -7961,13 +8168,13 @@ __export(install_exports, {
|
|
|
7961
8168
|
readExisting: () => readExisting,
|
|
7962
8169
|
write: () => write
|
|
7963
8170
|
});
|
|
7964
|
-
import { existsSync as
|
|
7965
|
-
import { basename as basename2, dirname, join as join8, resolve as
|
|
8171
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
8172
|
+
import { basename as basename2, dirname, join as join8, resolve as resolve5 } from "node:path";
|
|
7966
8173
|
function quote(value) {
|
|
7967
8174
|
return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
7968
8175
|
}
|
|
7969
8176
|
function readExisting(path) {
|
|
7970
|
-
if (!
|
|
8177
|
+
if (!existsSync4(path)) return void 0;
|
|
7971
8178
|
try {
|
|
7972
8179
|
return readFileSync7(path, "utf8");
|
|
7973
8180
|
} catch (err) {
|
|
@@ -7987,7 +8194,7 @@ function write(path, text4) {
|
|
|
7987
8194
|
}
|
|
7988
8195
|
}
|
|
7989
8196
|
function folders(ctx, client, dir) {
|
|
7990
|
-
if (dir !== void 0) return [{ client, folder:
|
|
8197
|
+
if (dir !== void 0) return [{ client, folder: resolve5(dir) }];
|
|
7991
8198
|
const clients = client === "all" ? CLIENTS : [client];
|
|
7992
8199
|
return clients.map((c) => ({ client: c, folder: join8(skillsFolder(c, ctx.env), SKILL_NAME) }));
|
|
7993
8200
|
}
|
|
@@ -8055,8 +8262,8 @@ var init_install = __esm({
|
|
|
8055
8262
|
for (const target of targets) {
|
|
8056
8263
|
if (target.status !== "unchanged") write(target.path, text4);
|
|
8057
8264
|
}
|
|
8058
|
-
if (dir !== void 0 && basename2(
|
|
8059
|
-
ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${
|
|
8265
|
+
if (dir !== void 0 && basename2(resolve5(dir)) !== SKILL_NAME) {
|
|
8266
|
+
ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve5(dir)} is not.`);
|
|
8060
8267
|
}
|
|
8061
8268
|
ctx.output.object({ installed: targets });
|
|
8062
8269
|
return ExitCode.Ok;
|
|
@@ -8068,7 +8275,7 @@ var init_install = __esm({
|
|
|
8068
8275
|
|
|
8069
8276
|
// src/commands/agent/mcp-config.ts
|
|
8070
8277
|
import { spawnSync } from "node:child_process";
|
|
8071
|
-
import { existsSync as
|
|
8278
|
+
import { existsSync as existsSync5, readFileSync as readFileSync8 } from "node:fs";
|
|
8072
8279
|
import { delimiter, join as join9 } from "node:path";
|
|
8073
8280
|
function parse2(text4) {
|
|
8074
8281
|
try {
|
|
@@ -8127,7 +8334,7 @@ function tomlServers(text4) {
|
|
|
8127
8334
|
}
|
|
8128
8335
|
function opencodeFile(env) {
|
|
8129
8336
|
const dir = join9(xdgConfigDir(env), "opencode");
|
|
8130
|
-
const existing = ["opencode.jsonc", "opencode.json", "config.json"].map((f) => join9(dir, f)).find((f) =>
|
|
8337
|
+
const existing = ["opencode.jsonc", "opencode.json", "config.json"].map((f) => join9(dir, f)).find((f) => existsSync5(f));
|
|
8131
8338
|
return existing ?? join9(dir, "opencode.json");
|
|
8132
8339
|
}
|
|
8133
8340
|
function canonical(url) {
|
|
@@ -8140,11 +8347,11 @@ function canonical(url) {
|
|
|
8140
8347
|
}
|
|
8141
8348
|
function onPath(bin, env) {
|
|
8142
8349
|
const names = process.platform === "win32" ? [`${bin}.cmd`, `${bin}.exe`, bin] : [bin];
|
|
8143
|
-
return (env.PATH ?? env.Path ?? "").split(delimiter).some((dir) => dir !== "" && names.some((n) =>
|
|
8350
|
+
return (env.PATH ?? env.Path ?? "").split(delimiter).some((dir) => dir !== "" && names.some((n) => existsSync5(join9(dir, n))));
|
|
8144
8351
|
}
|
|
8145
8352
|
function isPresent(client, env) {
|
|
8146
8353
|
const t = TARGETS[client];
|
|
8147
|
-
return t.bins.some((b) => onPath(b, env)) ||
|
|
8354
|
+
return t.bins.some((b) => onPath(b, env)) || existsSync5(t.folder(env));
|
|
8148
8355
|
}
|
|
8149
8356
|
function readText(path) {
|
|
8150
8357
|
try {
|
|
@@ -8413,7 +8620,30 @@ function normalizePath(raw, apiUrl) {
|
|
|
8413
8620
|
}
|
|
8414
8621
|
return raw;
|
|
8415
8622
|
}
|
|
8416
|
-
|
|
8623
|
+
function quote3(value) {
|
|
8624
|
+
return /^[\w\-./]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
8625
|
+
}
|
|
8626
|
+
function multipartBody(files, data) {
|
|
8627
|
+
const form = new FormData();
|
|
8628
|
+
if (data !== void 0) {
|
|
8629
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) {
|
|
8630
|
+
throw usageError("With --file, --data must be a JSON object: its keys become form fields.", { field: "data" });
|
|
8631
|
+
}
|
|
8632
|
+
for (const [key, value] of Object.entries(data)) {
|
|
8633
|
+
if (value === void 0 || value === null) continue;
|
|
8634
|
+
for (const item of Array.isArray(value) ? value : [value]) form.append(key, formValue(item));
|
|
8635
|
+
}
|
|
8636
|
+
}
|
|
8637
|
+
for (const item of files) {
|
|
8638
|
+
const { field, path } = splitFileArg(item);
|
|
8639
|
+
if (path === "") throw usageError(`--file ${item} names no file.`, { field: "file" });
|
|
8640
|
+
const name = field ?? DEFAULT_FILE_FIELD;
|
|
8641
|
+
const upload2 = readUpload(path, name);
|
|
8642
|
+
form.append(name, upload2.blob, upload2.name);
|
|
8643
|
+
}
|
|
8644
|
+
return form;
|
|
8645
|
+
}
|
|
8646
|
+
var METHODS, DEFAULT_FILE_FIELD, command4, actions3;
|
|
8417
8647
|
var init_api3 = __esm({
|
|
8418
8648
|
"src/commands/api/index.ts"() {
|
|
8419
8649
|
"use strict";
|
|
@@ -8421,15 +8651,23 @@ var init_api3 = __esm({
|
|
|
8421
8651
|
init_errors();
|
|
8422
8652
|
init_exit_codes();
|
|
8423
8653
|
init_input();
|
|
8654
|
+
init_transfer();
|
|
8424
8655
|
METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
8656
|
+
DEFAULT_FILE_FIELD = "file";
|
|
8425
8657
|
command4 = {
|
|
8426
8658
|
resource: "api",
|
|
8427
8659
|
action: "",
|
|
8428
8660
|
summary: "Call any API route, only when no command fits",
|
|
8429
8661
|
brief: "only when no command fits",
|
|
8430
|
-
description: "The raw escape hatch: sends Authorization, Ken-Version: 1.1 and X-Ken-Workspace-Id, prints the full JSON body. The path may carry a query string. --all (GET only) follows pagination.nextCursor and prints the data[] items as a list. POST, PUT and PATCH send at once; DELETE needs --yes (on a terminal it asks). --dry-run prints the request (method, path, body) and sends nothing.",
|
|
8662
|
+
description: "The raw escape hatch: sends Authorization, Ken-Version: 1.1 and X-Ken-Workspace-Id, prints the full JSON body. It reaches the legacy routes that have no command. The path may carry a query string. --all (GET only) follows pagination.nextCursor and prints the data[] items as a list. --file sends a multipart upload. An answer that is not JSON (a CSV, an image, a ZIP) prints as it came; --out saves it byte for byte, and a binary one is never printed to a terminal. POST, PUT and PATCH send at once; DELETE needs --yes (on a terminal it asks). --dry-run prints the request (method, path, body) and sends nothing.",
|
|
8431
8663
|
flags: {
|
|
8432
|
-
data: { type: "string", description: "Request body: inline JSON, @file or - for stdin" },
|
|
8664
|
+
data: { type: "string", description: "Request body: inline JSON, @file or - for stdin. With --file, its keys are form fields" },
|
|
8665
|
+
file: {
|
|
8666
|
+
type: "string",
|
|
8667
|
+
multiple: true,
|
|
8668
|
+
description: "Upload as multipart/form-data: <field>=<path>, or <path> for field file. Repeat for more files"
|
|
8669
|
+
},
|
|
8670
|
+
out: { type: "string", description: "Save the answer to this file, byte for byte, and print a summary" },
|
|
8433
8671
|
all: { type: "boolean", description: "GET only: follow every page and print the data[] items" },
|
|
8434
8672
|
"no-workspace": { type: "boolean", description: "Do not send X-Ken-Workspace-Id" }
|
|
8435
8673
|
},
|
|
@@ -8442,6 +8680,8 @@ var init_api3 = __esm({
|
|
|
8442
8680
|
"kenso api GET '/v1/campaigns?limit=200' --all --output ids",
|
|
8443
8681
|
`kenso api PATCH /v1/campaigns/123 --data '{"name":"Q4 outbound"}'`,
|
|
8444
8682
|
"kenso api POST /v1/tags --data @tag.json",
|
|
8683
|
+
"kenso api POST /v1/campaigns/123/email-sequence/images --file ./hero.png",
|
|
8684
|
+
"kenso api GET /v1/attachments/att_123/content --out ./attachment.pdf",
|
|
8445
8685
|
"kenso api DELETE /v1/tags/7 --dry-run"
|
|
8446
8686
|
],
|
|
8447
8687
|
dryRun: true,
|
|
@@ -8452,14 +8692,21 @@ var init_api3 = __esm({
|
|
|
8452
8692
|
}
|
|
8453
8693
|
const path = normalizePath(positionals[1] ?? "", ctx.auth.apiUrl);
|
|
8454
8694
|
const all = flags.all === true;
|
|
8695
|
+
const files = Array.isArray(flags.file) ? flags.file : typeof flags.file === "string" ? [flags.file] : [];
|
|
8696
|
+
const out = typeof flags.out === "string" ? flags.out : void 0;
|
|
8455
8697
|
if (all && method !== "GET") throw usageError("--all works with GET only.", { field: "all" });
|
|
8698
|
+
if (all && out !== void 0) throw usageError("--all prints the items of every page; --out saves one answer.", { field: "out" });
|
|
8456
8699
|
if (method === "GET" && typeof flags.data === "string") {
|
|
8457
8700
|
throw usageError("--data cannot be used with GET.", { field: "data", hint: "Put the values in the query string, or use POST, PUT or PATCH." });
|
|
8458
8701
|
}
|
|
8459
|
-
|
|
8702
|
+
if (method === "GET" && files.length > 0) throw usageError("--file cannot be used with GET.", { field: "file", hint: "Upload with POST, PUT or PATCH." });
|
|
8703
|
+
const data = typeof flags.data === "string" ? await readDataArg(flags.data, ctx.stdin) : void 0;
|
|
8704
|
+
const form = files.length > 0 ? multipartBody(files, data) : void 0;
|
|
8705
|
+
const body2 = form ? void 0 : data;
|
|
8460
8706
|
const noWorkspace = flags["no-workspace"] === true;
|
|
8461
8707
|
if (ctx.flags.dryRun) {
|
|
8462
|
-
|
|
8708
|
+
const request = { method, path, ...form ? { form: describeForm(form) } : body2 !== void 0 ? { body: body2 } : {} };
|
|
8709
|
+
ctx.output.object({ dryRun: true, request });
|
|
8463
8710
|
return ExitCode.Ok;
|
|
8464
8711
|
}
|
|
8465
8712
|
if (all) {
|
|
@@ -8467,10 +8714,14 @@ var init_api3 = __esm({
|
|
|
8467
8714
|
return ExitCode.Ok;
|
|
8468
8715
|
}
|
|
8469
8716
|
if (method === "DELETE") {
|
|
8470
|
-
|
|
8471
|
-
|
|
8717
|
+
await confirmDestructive(ctx, `kenso api sends DELETE ${path}`, `kenso api DELETE ${quote3(path)} --yes`);
|
|
8718
|
+
}
|
|
8719
|
+
const res = await ctx.client.request({ method, path, body: body2, ...form ? { form } : {}, noWorkspace, signal: ctx.signal });
|
|
8720
|
+
if (out !== void 0 || res.raw !== void 0) {
|
|
8721
|
+
const next = `kenso api ${method} ${quote3(path)}${noWorkspace ? " --no-workspace" : ""} --out ${quote3(suggestedFileName(res))}`;
|
|
8722
|
+
await writeFileResponse(ctx, res, { out, next });
|
|
8723
|
+
return ExitCode.Ok;
|
|
8472
8724
|
}
|
|
8473
|
-
const res = await ctx.client.request({ method, path, body: body2, noWorkspace, signal: ctx.signal });
|
|
8474
8725
|
if (res.body !== null && res.body !== "") ctx.output.object(res.body);
|
|
8475
8726
|
return ExitCode.Ok;
|
|
8476
8727
|
}
|
|
@@ -9950,7 +10201,7 @@ var init_connect3 = __esm({
|
|
|
9950
10201
|
// src/commands/contacts/common.ts
|
|
9951
10202
|
import { createHash as createHash3 } from "node:crypto";
|
|
9952
10203
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
9953
|
-
import { resolve as
|
|
10204
|
+
import { resolve as resolve6 } from "node:path";
|
|
9954
10205
|
function stringFlag2(flags, name) {
|
|
9955
10206
|
const value = flags[name];
|
|
9956
10207
|
if (typeof value !== "string") return void 0;
|
|
@@ -10004,7 +10255,7 @@ function sameCommand2(command48, flags, ctx, extra = []) {
|
|
|
10004
10255
|
return parts2.join(" ");
|
|
10005
10256
|
}
|
|
10006
10257
|
async function fileSha256(path) {
|
|
10007
|
-
return createHash3("sha256").update(await readFile6(
|
|
10258
|
+
return createHash3("sha256").update(await readFile6(resolve6(path))).digest("hex");
|
|
10008
10259
|
}
|
|
10009
10260
|
function rateLimitRemaining3(headers) {
|
|
10010
10261
|
const raw = headers.get("ratelimit-remaining");
|
|
@@ -10033,13 +10284,13 @@ function warnDropped(ctx, mapping) {
|
|
|
10033
10284
|
const list2 = dropped.map(([header, reason]) => `"${header}" (${reason})`).join(", ");
|
|
10034
10285
|
ctx.output.warn(`Not sent: ${list2}. Rename a column with --map '{"<column>": "customVariables.<name>"}'.`);
|
|
10035
10286
|
}
|
|
10036
|
-
var
|
|
10287
|
+
var OUT_FLAG2, CONCURRENCY_FLAG;
|
|
10037
10288
|
var init_common = __esm({
|
|
10038
10289
|
"src/commands/contacts/common.ts"() {
|
|
10039
10290
|
"use strict";
|
|
10040
10291
|
init_errors();
|
|
10041
10292
|
init_exit_codes();
|
|
10042
|
-
|
|
10293
|
+
OUT_FLAG2 = { type: "string", description: "Keep the run's files (results.csv, invalid.csv, plan.json) in this directory" };
|
|
10043
10294
|
CONCURRENCY_FLAG = { type: "string", description: "Requests in flight at once (default 4, max 16)" };
|
|
10044
10295
|
}
|
|
10045
10296
|
});
|
|
@@ -10643,7 +10894,7 @@ var init_wait = __esm({
|
|
|
10643
10894
|
|
|
10644
10895
|
// src/commands/contacts/server-import.ts
|
|
10645
10896
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
10646
|
-
import { basename as basename3, extname as
|
|
10897
|
+
import { basename as basename3, extname as extname3, resolve as resolve7 } from "node:path";
|
|
10647
10898
|
function csvTargetOf(header, mapping) {
|
|
10648
10899
|
if (mapping.dropped[header] !== "reserved_name") return void 0;
|
|
10649
10900
|
const key = normalizeVariableName(header);
|
|
@@ -10666,14 +10917,14 @@ function notUploaded(mapping) {
|
|
|
10666
10917
|
}
|
|
10667
10918
|
async function readUpload2(file) {
|
|
10668
10919
|
if (file === "-") throw usageError("--server-import uploads a file: name the CSV file instead of - (stdin).", { field: "file" });
|
|
10669
|
-
const ext =
|
|
10920
|
+
const ext = extname3(file).toLowerCase();
|
|
10670
10921
|
if (ext === ".jsonl" || ext === ".ndjson" || ext === ".json") {
|
|
10671
10922
|
throw usageError("--server-import uploads a CSV file. Convert the file to CSV, or leave --server-import off.", { field: "file" });
|
|
10672
10923
|
}
|
|
10673
|
-
const path =
|
|
10924
|
+
const path = resolve7(file);
|
|
10674
10925
|
try {
|
|
10675
10926
|
const bytes = await readFile7(path);
|
|
10676
|
-
const name = ext === ".csv" ? basename3(path) : `${basename3(path,
|
|
10927
|
+
const name = ext === ".csv" ? basename3(path) : `${basename3(path, extname3(path))}.csv`;
|
|
10677
10928
|
return { bytes, name, path };
|
|
10678
10929
|
} catch (err) {
|
|
10679
10930
|
const code = err.code;
|
|
@@ -10851,7 +11102,7 @@ var init_import2 = __esm({
|
|
|
10851
11102
|
"server-import": { type: "boolean", description: "Upload the CSV as a server import job (up to 100,000 rows; no per-row results)" },
|
|
10852
11103
|
template: { type: "boolean", description: "Print a sample header and the accepted fields, then exit" },
|
|
10853
11104
|
timeout: { type: "string", description: "With --server-import: how long to wait for the job (default 30m)" },
|
|
10854
|
-
out:
|
|
11105
|
+
out: OUT_FLAG2
|
|
10855
11106
|
},
|
|
10856
11107
|
examples: [
|
|
10857
11108
|
"kenso contacts import --campaign 812 --file leads.csv --dry-run",
|
|
@@ -11056,7 +11307,7 @@ var init_update = __esm({
|
|
|
11056
11307
|
match: { type: "string", description: "id (an id or contactId column) or email (needs --campaign)" },
|
|
11057
11308
|
campaign: { type: "string", description: "With --match email: the campaign whose contacts the emails are matched in", aliases: ["campaign-id"] },
|
|
11058
11309
|
map: { type: "string", description: 'Column overrides as JSON, @file or -: {"Pain": "customVariables.pain_point", "Notes": null}' },
|
|
11059
|
-
out:
|
|
11310
|
+
out: OUT_FLAG2,
|
|
11060
11311
|
concurrency: CONCURRENCY_FLAG
|
|
11061
11312
|
},
|
|
11062
11313
|
examples: [
|
|
@@ -11121,8 +11372,8 @@ var init_update = __esm({
|
|
|
11121
11372
|
});
|
|
11122
11373
|
|
|
11123
11374
|
// src/commands/contacts/bulk-store.ts
|
|
11124
|
-
import { existsSync as
|
|
11125
|
-
import { appendFile as appendFile2, readFile as readFile8, writeFile as
|
|
11375
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
11376
|
+
import { appendFile as appendFile2, readFile as readFile8, writeFile as writeFile3 } from "node:fs/promises";
|
|
11126
11377
|
import { join as join11 } from "node:path";
|
|
11127
11378
|
function whereDir(env) {
|
|
11128
11379
|
return join11(runsRoot(env), WHERE_DIR);
|
|
@@ -11134,7 +11385,7 @@ async function unfinishedWhereIds(ctx, command48, args) {
|
|
|
11134
11385
|
for (const run of await listRuns(ctx.env)) {
|
|
11135
11386
|
if (run.command !== command48 || run.status === "done" || run.status === "planned") continue;
|
|
11136
11387
|
if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
|
|
11137
|
-
if (run.inputPath?.startsWith(`${dir}/`) &&
|
|
11388
|
+
if (run.inputPath?.startsWith(`${dir}/`) && existsSync6(run.inputPath)) return run.inputPath;
|
|
11138
11389
|
}
|
|
11139
11390
|
return void 0;
|
|
11140
11391
|
}
|
|
@@ -11142,7 +11393,7 @@ async function saveWhereIds(ctx, kind, ids2) {
|
|
|
11142
11393
|
const dir = whereDir(ctx.env);
|
|
11143
11394
|
ensurePrivateDir2(dir);
|
|
11144
11395
|
const path = join11(dir, `${kind}-${Date.now()}-${newRunId().slice(2)}.txt`);
|
|
11145
|
-
await
|
|
11396
|
+
await writeFile3(path, ids2.map((id) => `${id}
|
|
11146
11397
|
`).join(""), { mode: 384 });
|
|
11147
11398
|
return path;
|
|
11148
11399
|
}
|
|
@@ -11188,7 +11439,7 @@ __export(bulk_ids_exports, {
|
|
|
11188
11439
|
resume: () => resume
|
|
11189
11440
|
});
|
|
11190
11441
|
import { createHash as createHash4 } from "node:crypto";
|
|
11191
|
-
import { resolve as
|
|
11442
|
+
import { resolve as resolve8 } from "node:path";
|
|
11192
11443
|
import { Readable } from "node:stream";
|
|
11193
11444
|
function idItems(raw) {
|
|
11194
11445
|
const items = [];
|
|
@@ -11220,7 +11471,7 @@ async function idsFromFile(ctx, path) {
|
|
|
11220
11471
|
input = { path: "-", sha256: createHash4("sha256").update(text4).digest("hex") };
|
|
11221
11472
|
} else {
|
|
11222
11473
|
ids2 = await readIds(path);
|
|
11223
|
-
input = { path:
|
|
11474
|
+
input = { path: resolve8(path), sha256: await fileSha256(path) };
|
|
11224
11475
|
}
|
|
11225
11476
|
return { ...idItems(ids2), source: "ids", input };
|
|
11226
11477
|
}
|
|
@@ -11326,7 +11577,7 @@ function bulkCommand(kind) {
|
|
|
11326
11577
|
if (kind === "restore") flags.run = { type: "string", description: "Restore what an earlier contacts remove run removed" };
|
|
11327
11578
|
else flags.where = { type: "string", description: "contacts search filters as JSON, @file or - (the body of POST /v1/contacts/search: campaignIds, q matches names and emails, filters match fields such as ContactCompany.Name). Its dry-run plan shows the count and first ids: check the match there, never with a search or list first" };
|
|
11328
11579
|
if (kind === "remove") flags.confirm = { type: "string", description: "Required to remove more than 1,000 contacts: the exact count" };
|
|
11329
|
-
flags.out =
|
|
11580
|
+
flags.out = OUT_FLAG2;
|
|
11330
11581
|
flags.concurrency = CONCURRENCY_FLAG;
|
|
11331
11582
|
return {
|
|
11332
11583
|
resource: "contacts",
|
|
@@ -11486,7 +11737,7 @@ function tagCommand(kind) {
|
|
|
11486
11737
|
flags: {
|
|
11487
11738
|
tag: { type: "string", description: "The tag id (see kenso tags list)", aliases: ["tag-id"] },
|
|
11488
11739
|
ids: { type: "string", description: "Contact ids: one per line, or a CSV/JSONL with an id column; - for stdin" },
|
|
11489
|
-
out:
|
|
11740
|
+
out: OUT_FLAG2,
|
|
11490
11741
|
concurrency: CONCURRENCY_FLAG
|
|
11491
11742
|
},
|
|
11492
11743
|
examples: [`kenso contacts ${kind} --tag 31 --ids ids.txt --dry-run`, `kenso contacts ${kind} --tag 31 --ids ids.txt --yes`],
|
|
@@ -11539,8 +11790,7 @@ __export(export_exports, {
|
|
|
11539
11790
|
default: () => export_default,
|
|
11540
11791
|
exportIdOf: () => exportIdOf
|
|
11541
11792
|
});
|
|
11542
|
-
import {
|
|
11543
|
-
import { resolve as resolve8 } from "node:path";
|
|
11793
|
+
import { extname as extname4 } from "node:path";
|
|
11544
11794
|
function idText3(value) {
|
|
11545
11795
|
return typeof value === "number" || typeof value === "string" && value !== "" ? String(value) : void 0;
|
|
11546
11796
|
}
|
|
@@ -11567,25 +11817,16 @@ function countRows(csv) {
|
|
|
11567
11817
|
return Math.max(0, records.length - 1);
|
|
11568
11818
|
}
|
|
11569
11819
|
async function download(ctx, job, exportId, out) {
|
|
11570
|
-
const res = await ctx.client.request({ method: "GET", path: contentPath(ctx, job, exportId), headers: { Accept: "text/csv, */*" }, signal: ctx.signal });
|
|
11820
|
+
const res = await ctx.client.request({ method: "GET", path: contentPath(ctx, job, exportId), headers: { Accept: "text/csv, application/zip, */*" }, signal: ctx.signal });
|
|
11571
11821
|
const type = res.headers.get("content-type") ?? "";
|
|
11572
11822
|
if (type.includes("zip")) {
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
hint: `Download it with: kenso contact-exports content --export-id ${exportId}`
|
|
11578
|
-
});
|
|
11823
|
+
const bytes = res.raw ?? (Buffer.isBuffer(res.body) ? res.body : Buffer.alloc(0));
|
|
11824
|
+
const path = await saveFile(out, bytes);
|
|
11825
|
+
if (extname4(out).toLowerCase() !== ".zip") ctx.output.warn(`the export is a ZIP of CSV files (one per segment); ${out} holds the ZIP as it came.`);
|
|
11826
|
+
return { format: "zip", bytes: bytes.length, path };
|
|
11579
11827
|
}
|
|
11580
11828
|
const body2 = typeof res.body === "string" ? res.body : res.body === null ? "" : JSON.stringify(res.body);
|
|
11581
|
-
|
|
11582
|
-
try {
|
|
11583
|
-
await writeFile3(path, body2, { mode: 384 });
|
|
11584
|
-
} catch (err) {
|
|
11585
|
-
const code = err.code;
|
|
11586
|
-
throw new KensoError({ code: "file_unwritable", message: `Cannot write ${out}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Usage, field: "out" });
|
|
11587
|
-
}
|
|
11588
|
-
return { rows: countRows(body2), path };
|
|
11829
|
+
return { format: "csv", rows: countRows(body2), path: await saveFile(out, res.raw ?? Buffer.from(body2, "utf8")) };
|
|
11589
11830
|
}
|
|
11590
11831
|
var COMMAND4, JOB_TYPE, DEFAULT_TIMEOUT2, CONTENT_PATH, command17, export_default;
|
|
11591
11832
|
var init_export = __esm({
|
|
@@ -11596,6 +11837,7 @@ var init_export = __esm({
|
|
|
11596
11837
|
init_errors();
|
|
11597
11838
|
init_exit_codes();
|
|
11598
11839
|
init_http();
|
|
11840
|
+
init_transfer();
|
|
11599
11841
|
init_wait();
|
|
11600
11842
|
init_common();
|
|
11601
11843
|
COMMAND4 = "kenso contacts export";
|
|
@@ -11610,7 +11852,7 @@ var init_export = __esm({
|
|
|
11610
11852
|
description: "Creates a contact export of the campaign (POST /v1/contact-exports, kind contacts), waits for the contact_export job, then downloads GET /v1/contact-exports/{exportId}/content to --out. Without --out it prints the job (add --wait to wait for it).",
|
|
11611
11853
|
flags: {
|
|
11612
11854
|
campaign: { type: "string", description: "The campaign id", aliases: ["campaign-id"] },
|
|
11613
|
-
out: { type: "string", description: "Write the CSV to this file
|
|
11855
|
+
out: { type: "string", description: "Write the CSV (a ZIP of one CSV per segment for an audience-based campaign) to this file; waits for the job" },
|
|
11614
11856
|
wait: { type: "boolean", description: "Wait for the export job to finish (on when --out is set)" },
|
|
11615
11857
|
timeout: { type: "string", description: "How long to wait for the job (default 30m)" }
|
|
11616
11858
|
},
|
|
@@ -11655,8 +11897,9 @@ var init_export = __esm({
|
|
|
11655
11897
|
ctx.output.object({ exportId, jobId, status: job.status, downloadUrl: job.downloadUrl ?? `/v1/contact-exports/${exportId}/content` });
|
|
11656
11898
|
return ExitCode.Ok;
|
|
11657
11899
|
}
|
|
11658
|
-
const
|
|
11659
|
-
|
|
11900
|
+
const saved = await download(ctx, job, exportId, out);
|
|
11901
|
+
const counts2 = saved.format === "zip" ? { format: "zip", bytes: saved.bytes } : { rows: saved.rows };
|
|
11902
|
+
ctx.output.object({ exportId, jobId, status: job.status, ...counts2, out: saved.path });
|
|
11660
11903
|
return ExitCode.Ok;
|
|
11661
11904
|
}
|
|
11662
11905
|
};
|
|
@@ -11765,7 +12008,13 @@ function detailOf(entry) {
|
|
|
11765
12008
|
operationIds: ids2,
|
|
11766
12009
|
flags: flagsOf(entry),
|
|
11767
12010
|
positionals: (spec?.positionals ?? []).map((p) => ({ name: p.name, required: p.required === true, description: p.description })),
|
|
11768
|
-
body: body2 ? {
|
|
12011
|
+
body: body2 ? {
|
|
12012
|
+
format: body2.format,
|
|
12013
|
+
// An upload that also takes JSON: without --file the command sends JSON (DEV-11921).
|
|
12014
|
+
...body2.json ? { json: true } : {},
|
|
12015
|
+
...body2.schema !== void 0 ? { schema: body2.schema } : {},
|
|
12016
|
+
...body2.schemaTruncated ? { schemaTruncated: true } : {}
|
|
12017
|
+
} : null,
|
|
11769
12018
|
list: op?.list ?? false,
|
|
11770
12019
|
examples: entry.op ? operationExamples(entry.op) : spec?.examples ?? [],
|
|
11771
12020
|
beta: entry.gates !== void 0,
|
|
@@ -11773,6 +12022,7 @@ function detailOf(entry) {
|
|
|
11773
12022
|
dryRun: entry.op !== void 0 || spec?.dryRun === true
|
|
11774
12023
|
};
|
|
11775
12024
|
if (entry.gates) out.featureGates = entry.gates;
|
|
12025
|
+
if (entry.op?.download) out.download = entry.op.download;
|
|
11776
12026
|
return out;
|
|
11777
12027
|
}
|
|
11778
12028
|
function unknown(words) {
|
|
@@ -12636,7 +12886,7 @@ var show_exports = {};
|
|
|
12636
12886
|
__export(show_exports, {
|
|
12637
12887
|
default: () => show_default
|
|
12638
12888
|
});
|
|
12639
|
-
import { existsSync as
|
|
12889
|
+
import { existsSync as existsSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
12640
12890
|
import { join as join12 } from "node:path";
|
|
12641
12891
|
var FILES, command27, show_default;
|
|
12642
12892
|
var init_show = __esm({
|
|
@@ -12666,7 +12916,7 @@ var init_show = __esm({
|
|
|
12666
12916
|
const files = { dir };
|
|
12667
12917
|
for (const [key, name] of FILES) {
|
|
12668
12918
|
const path = join12(dir, name);
|
|
12669
|
-
if (
|
|
12919
|
+
if (existsSync7(path)) files[key] = path;
|
|
12670
12920
|
}
|
|
12671
12921
|
let summary;
|
|
12672
12922
|
if (files.summary) {
|
|
@@ -12691,7 +12941,7 @@ __export(resume_exports, {
|
|
|
12691
12941
|
resumeArgv: () => resumeArgv
|
|
12692
12942
|
});
|
|
12693
12943
|
import { createHash as createHash5 } from "node:crypto";
|
|
12694
|
-
import { existsSync as
|
|
12944
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
12695
12945
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
12696
12946
|
import { resolve as resolve9 } from "node:path";
|
|
12697
12947
|
function kebab(key) {
|
|
@@ -12771,7 +13021,7 @@ var init_resume = __esm({
|
|
|
12771
13021
|
});
|
|
12772
13022
|
}
|
|
12773
13023
|
if (run.inputPath !== void 0) {
|
|
12774
|
-
if (!
|
|
13024
|
+
if (!existsSync8(run.inputPath)) {
|
|
12775
13025
|
throw usageError(`The input file of run ${run.runId} is gone: ${run.inputPath}.`, { field: "file", next });
|
|
12776
13026
|
}
|
|
12777
13027
|
if (await sha256(run.inputPath) !== run.inputSha256) {
|
|
@@ -12786,7 +13036,7 @@ var init_resume = __esm({
|
|
|
12786
13036
|
if (ctx.env.KENSO_CONFIG_DIR?.trim()) env.KENSO_CONFIG_DIR = resolve9(ctx.env.KENSO_CONFIG_DIR.trim());
|
|
12787
13037
|
const previousCwd = process.cwd();
|
|
12788
13038
|
if (run.cwd && run.cwd !== previousCwd) {
|
|
12789
|
-
if (!
|
|
13039
|
+
if (!existsSync8(run.cwd)) throw usageError(`Run ${run.runId} started in ${run.cwd}, which no longer exists.`, { next });
|
|
12790
13040
|
process.chdir(run.cwd);
|
|
12791
13041
|
}
|
|
12792
13042
|
try {
|
|
@@ -13165,7 +13415,7 @@ var init_common2 = __esm({
|
|
|
13165
13415
|
|
|
13166
13416
|
// src/commands/studio/folder.ts
|
|
13167
13417
|
import { readdir as readdir2, readFile as readFile10, stat as stat2 } from "node:fs/promises";
|
|
13168
|
-
import { extname as
|
|
13418
|
+
import { extname as extname5, isAbsolute, join as join13, relative, resolve as resolve10, sep } from "node:path";
|
|
13169
13419
|
function textOf2(bytes) {
|
|
13170
13420
|
if (bytes.length >= TEXT_MAX_BYTES || bytes.includes(0)) return void 0;
|
|
13171
13421
|
try {
|
|
@@ -13213,7 +13463,7 @@ function safeJoin(root2, bundlePath) {
|
|
|
13213
13463
|
return target;
|
|
13214
13464
|
}
|
|
13215
13465
|
function contentTypeOf(path) {
|
|
13216
|
-
return
|
|
13466
|
+
return CONTENT_TYPES2[extname5(path).toLowerCase()] ?? "application/octet-stream";
|
|
13217
13467
|
}
|
|
13218
13468
|
async function mapLimit(items, limit, fn) {
|
|
13219
13469
|
const out = new Array(items.length);
|
|
@@ -13233,7 +13483,7 @@ async function mapLimit(items, limit, fn) {
|
|
|
13233
13483
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
13234
13484
|
return out;
|
|
13235
13485
|
}
|
|
13236
|
-
var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8,
|
|
13486
|
+
var TEXT_MAX_BYTES, UPLOAD_MAX_BYTES, utf8, CONTENT_TYPES2;
|
|
13237
13487
|
var init_folder = __esm({
|
|
13238
13488
|
"src/commands/studio/folder.ts"() {
|
|
13239
13489
|
"use strict";
|
|
@@ -13242,7 +13492,7 @@ var init_folder = __esm({
|
|
|
13242
13492
|
TEXT_MAX_BYTES = 1024 * 1024;
|
|
13243
13493
|
UPLOAD_MAX_BYTES = 5 * 1024 * 1024;
|
|
13244
13494
|
utf8 = new TextDecoder("utf-8", { fatal: true });
|
|
13245
|
-
|
|
13495
|
+
CONTENT_TYPES2 = {
|
|
13246
13496
|
".png": "image/png",
|
|
13247
13497
|
".jpg": "image/jpeg",
|
|
13248
13498
|
".jpeg": "image/jpeg",
|
|
@@ -13346,7 +13596,7 @@ async function download2(url, path, sha2563, signal) {
|
|
|
13346
13596
|
return bytes;
|
|
13347
13597
|
}
|
|
13348
13598
|
var PARALLEL_TRANSFERS;
|
|
13349
|
-
var
|
|
13599
|
+
var init_transfer2 = __esm({
|
|
13350
13600
|
"src/commands/studio/transfer.ts"() {
|
|
13351
13601
|
"use strict";
|
|
13352
13602
|
init_errors();
|
|
@@ -13373,7 +13623,7 @@ var init_pull = __esm({
|
|
|
13373
13623
|
init_http();
|
|
13374
13624
|
init_common2();
|
|
13375
13625
|
init_folder();
|
|
13376
|
-
|
|
13626
|
+
init_transfer2();
|
|
13377
13627
|
command34 = {
|
|
13378
13628
|
resource: "studio",
|
|
13379
13629
|
action: "pull",
|
|
@@ -13445,7 +13695,7 @@ var init_read = __esm({
|
|
|
13445
13695
|
"use strict";
|
|
13446
13696
|
init_errors();
|
|
13447
13697
|
init_folder();
|
|
13448
|
-
|
|
13698
|
+
init_transfer2();
|
|
13449
13699
|
}
|
|
13450
13700
|
});
|
|
13451
13701
|
|
|
@@ -14517,7 +14767,7 @@ async function releaseClaim(ctx, claimId, headers = {}) {
|
|
|
14517
14767
|
const data = unwrap(res.body);
|
|
14518
14768
|
return isRecord8(data) && typeof data.released === "number" ? data.released : 0;
|
|
14519
14769
|
}
|
|
14520
|
-
var BETA, KINDS_TEXT, MAX_PER_FILE, MIN_LEASE_MINUTES, MAX_LEASE_MINUTES, KIND_FLAG, CAMPAIGN_FLAG, LIVE_ONLY_FLAG, PER_FILE_FLAG, LEASE_FLAG,
|
|
14770
|
+
var BETA, KINDS_TEXT, MAX_PER_FILE, MIN_LEASE_MINUTES, MAX_LEASE_MINUTES, KIND_FLAG, CAMPAIGN_FLAG, LIVE_ONLY_FLAG, PER_FILE_FLAG, LEASE_FLAG, OUT_FLAG3, UNTIL_DONE, WORK_TIMING, MAX_UNAVAILABLE_WAITS;
|
|
14521
14771
|
var init_common3 = __esm({
|
|
14522
14772
|
"src/commands/work/common.ts"() {
|
|
14523
14773
|
"use strict";
|
|
@@ -14537,7 +14787,7 @@ var init_common3 = __esm({
|
|
|
14537
14787
|
};
|
|
14538
14788
|
PER_FILE_FLAG = { type: "string", default: "10", description: "Items per work file (one claim), 1-50" };
|
|
14539
14789
|
LEASE_FLAG = { type: "string", default: "30m", description: "How long a claim holds its items, 5m to 4h; unanswered items go back after it" };
|
|
14540
|
-
|
|
14790
|
+
OUT_FLAG3 = { type: "string", description: "Keep the files in this directory instead of a new folder under the runs directory" };
|
|
14541
14791
|
UNTIL_DONE = new AbortController().signal;
|
|
14542
14792
|
WORK_TIMING = { watchMs: 6e4, unavailableMs: 3e4, retryMs: 2e3 };
|
|
14543
14793
|
MAX_UNAVAILABLE_WAITS = 10;
|
|
@@ -14837,7 +15087,7 @@ var init_agent_user = __esm({
|
|
|
14837
15087
|
});
|
|
14838
15088
|
|
|
14839
15089
|
// src/commands/work/folder.ts
|
|
14840
|
-
import { existsSync as
|
|
15090
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
14841
15091
|
import { appendFile as appendFile3, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
|
|
14842
15092
|
import { dirname as dirname3, join as join18, resolve as resolve13 } from "node:path";
|
|
14843
15093
|
var WorkRunFolder;
|
|
@@ -14886,7 +15136,7 @@ var init_folder2 = __esm({
|
|
|
14886
15136
|
makeDir(dir);
|
|
14887
15137
|
} else {
|
|
14888
15138
|
dir = resolve13(this.outDir);
|
|
14889
|
-
const existing =
|
|
15139
|
+
const existing = existsSync9(join18(dir, "run.json")) ? await readRunDir(dir) : null;
|
|
14890
15140
|
if (existing && !existing.command.startsWith("work ")) {
|
|
14891
15141
|
throw usageError(`${dir} already holds run ${existing.runId} (${existing.command}).`, {
|
|
14892
15142
|
field: "out",
|
|
@@ -14987,7 +15237,7 @@ var init_pull2 = __esm({
|
|
|
14987
15237
|
"live-only": LIVE_ONLY_FLAG,
|
|
14988
15238
|
files: { type: "string", default: "16", description: `Work files (claims) to take, 1-${MAX_FILES}` },
|
|
14989
15239
|
"per-file": PER_FILE_FLAG,
|
|
14990
|
-
out:
|
|
15240
|
+
out: OUT_FLAG3,
|
|
14991
15241
|
lease: LEASE_FLAG
|
|
14992
15242
|
},
|
|
14993
15243
|
examples: [
|
|
@@ -15059,7 +15309,7 @@ var init_pull2 = __esm({
|
|
|
15059
15309
|
|
|
15060
15310
|
// src/commands/work/answers.ts
|
|
15061
15311
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
15062
|
-
import { existsSync as
|
|
15312
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
15063
15313
|
import { basename as basename4, dirname as dirname4, join as join19 } from "node:path";
|
|
15064
15314
|
function zeroTotals() {
|
|
15065
15315
|
return { accepted: 0, rejected: 0, expired: 0, duplicate: 0, dropped: 0 };
|
|
@@ -15162,7 +15412,7 @@ function workFileNextTo(answersPath) {
|
|
|
15162
15412
|
});
|
|
15163
15413
|
}
|
|
15164
15414
|
const workPath = join19(dirname4(answersPath), `${claimId}.work.json`);
|
|
15165
|
-
if (!
|
|
15415
|
+
if (!existsSync10(workPath)) {
|
|
15166
15416
|
throw usageError(`${workPath} is missing: kenso work submit reads it next to the answers file.`, { field: "answers-file" });
|
|
15167
15417
|
}
|
|
15168
15418
|
let work;
|
|
@@ -15245,9 +15495,9 @@ var release_exports = {};
|
|
|
15245
15495
|
__export(release_exports, {
|
|
15246
15496
|
default: () => release_default
|
|
15247
15497
|
});
|
|
15248
|
-
import { existsSync as
|
|
15498
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
15249
15499
|
function claimIdOf(arg) {
|
|
15250
|
-
if (arg.endsWith(".json") ||
|
|
15500
|
+
if (arg.endsWith(".json") || existsSync11(arg)) {
|
|
15251
15501
|
try {
|
|
15252
15502
|
return readWorkFile(arg).claimId;
|
|
15253
15503
|
} catch (err) {
|
|
@@ -16753,7 +17003,7 @@ var init_run2 = __esm({
|
|
|
16753
17003
|
"agent-bin": { type: "string", description: "The agent's binary, when it is not on PATH under its usual name" },
|
|
16754
17004
|
"allow-unconfined": { type: "boolean", description: "Run an agent Kenso cannot hold to the job folder (every agent but claude)" },
|
|
16755
17005
|
lease: LEASE_FLAG,
|
|
16756
|
-
out:
|
|
17006
|
+
out: OUT_FLAG3,
|
|
16757
17007
|
// --token-stdin, --agent-user and --agent-tools: how a Kenso sandbox runs it (src/commands/work/box.ts).
|
|
16758
17008
|
...BOX_FLAGS
|
|
16759
17009
|
},
|