kenso 0.1.94 → 0.1.95
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 +1 -0
- package/README.md +1 -1
- package/dist/kenso.js +736 -397
- package/dist/operations.json +1 -1
- package/docs/crm.md +47 -1
- package/docs/reference.md +78 -15
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -2477,7 +2477,7 @@ var VERSION;
|
|
|
2477
2477
|
var init_version = __esm({
|
|
2478
2478
|
"src/core/version.ts"() {
|
|
2479
2479
|
"use strict";
|
|
2480
|
-
VERSION = true ? "0.1.
|
|
2480
|
+
VERSION = true ? "0.1.95" : "0.0.0-dev";
|
|
2481
2481
|
}
|
|
2482
2482
|
});
|
|
2483
2483
|
|
|
@@ -7744,13 +7744,475 @@ var init_import = __esm({
|
|
|
7744
7744
|
}
|
|
7745
7745
|
});
|
|
7746
7746
|
|
|
7747
|
+
// src/commands/contacts/common.ts
|
|
7748
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
7749
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
7750
|
+
import { resolve as resolve5 } from "node:path";
|
|
7751
|
+
function stringFlag2(flags, name) {
|
|
7752
|
+
const value = flags[name];
|
|
7753
|
+
if (typeof value !== "string") return void 0;
|
|
7754
|
+
const text4 = value.trim();
|
|
7755
|
+
return text4 === "" ? void 0 : text4;
|
|
7756
|
+
}
|
|
7757
|
+
function requireFlag(flags, name, command65, hint) {
|
|
7758
|
+
const value = stringFlag2(flags, name);
|
|
7759
|
+
if (value === void 0) throw usageError(`--${name} is required for ${command65}.`, { field: name, next: `${command65} --help`, ...hint ? { hint } : {} });
|
|
7760
|
+
return value;
|
|
7761
|
+
}
|
|
7762
|
+
function positiveId(value) {
|
|
7763
|
+
const text4 = value.trim();
|
|
7764
|
+
if (!/^[0-9]+$/.test(text4)) return void 0;
|
|
7765
|
+
const id = Number(text4);
|
|
7766
|
+
return Number.isSafeInteger(id) && id > 0 ? id : void 0;
|
|
7767
|
+
}
|
|
7768
|
+
function idFlag(flags, name, command65) {
|
|
7769
|
+
const raw = requireFlag(flags, name, command65);
|
|
7770
|
+
const id = positiveId(raw);
|
|
7771
|
+
if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
|
|
7772
|
+
return id;
|
|
7773
|
+
}
|
|
7774
|
+
function concurrency(flags) {
|
|
7775
|
+
const raw = stringFlag2(flags, "concurrency");
|
|
7776
|
+
if (raw === void 0) return void 0;
|
|
7777
|
+
const value = Number(raw);
|
|
7778
|
+
if (!Number.isInteger(value) || value < 1 || value > 16) {
|
|
7779
|
+
throw usageError(`--concurrency must be a whole number from 1 to 16 (got "${raw}").`, { field: "concurrency" });
|
|
7780
|
+
}
|
|
7781
|
+
return value;
|
|
7782
|
+
}
|
|
7783
|
+
function isDryRun(ctx) {
|
|
7784
|
+
return ctx.flags.yes !== true;
|
|
7785
|
+
}
|
|
7786
|
+
function shellQuote4(value) {
|
|
7787
|
+
return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
7788
|
+
}
|
|
7789
|
+
function sameCommand2(command65, flags, ctx, extra = []) {
|
|
7790
|
+
const parts2 = [command65];
|
|
7791
|
+
for (const [name, value] of Object.entries(flags)) {
|
|
7792
|
+
if (value === void 0 || value === false) continue;
|
|
7793
|
+
if (value === true) parts2.push(`--${name}`);
|
|
7794
|
+
else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${name}`, shellQuote4(item));
|
|
7795
|
+
}
|
|
7796
|
+
for (const name of ["profile", "workspace"]) {
|
|
7797
|
+
const value = ctx.flags[name];
|
|
7798
|
+
if (value !== void 0) parts2.push(`--${name}`, shellQuote4(value));
|
|
7799
|
+
}
|
|
7800
|
+
parts2.push(...extra);
|
|
7801
|
+
return parts2.join(" ");
|
|
7802
|
+
}
|
|
7803
|
+
async function fileSha256(path) {
|
|
7804
|
+
return createHash3("sha256").update(await readFile6(resolve5(path))).digest("hex");
|
|
7805
|
+
}
|
|
7806
|
+
function rateLimitRemaining3(headers) {
|
|
7807
|
+
const raw = headers.get("ratelimit-remaining");
|
|
7808
|
+
if (raw === null || raw.trim() === "") return void 0;
|
|
7809
|
+
const value = Number(raw);
|
|
7810
|
+
return Number.isFinite(value) ? value : void 0;
|
|
7811
|
+
}
|
|
7812
|
+
function rethrowIfRunStopping(err) {
|
|
7813
|
+
if (!(err instanceof KensoError)) return;
|
|
7814
|
+
if (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.RateLimited || err.exitCode === ExitCode.Interrupted) throw err;
|
|
7815
|
+
}
|
|
7816
|
+
function failedRow(row, err, extra = {}) {
|
|
7817
|
+
const reason = err instanceof KensoError ? err.code : "failed";
|
|
7818
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
7819
|
+
return { row, status: "failed", reason, error, ...extra };
|
|
7820
|
+
}
|
|
7821
|
+
function invalidRow(row, reason, error, extra = {}) {
|
|
7822
|
+
return { row, status: "invalid", reason, ...error ? { error } : {}, ...extra };
|
|
7823
|
+
}
|
|
7824
|
+
function isRecord4(value) {
|
|
7825
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7826
|
+
}
|
|
7827
|
+
function warnDropped(ctx, mapping) {
|
|
7828
|
+
const dropped = Object.entries(mapping.dropped).filter(([, reason]) => reason !== "mapped_to_null");
|
|
7829
|
+
if (dropped.length === 0) return;
|
|
7830
|
+
const list2 = dropped.map(([header, reason]) => `"${header}" (${reason})`).join(", ");
|
|
7831
|
+
ctx.output.warn(`Not sent: ${list2}. Rename a column with --map '{"<column>": "customVariables.<name>"}'.`);
|
|
7832
|
+
}
|
|
7833
|
+
var OUT_FLAG2, CONCURRENCY_FLAG;
|
|
7834
|
+
var init_common = __esm({
|
|
7835
|
+
"src/commands/contacts/common.ts"() {
|
|
7836
|
+
"use strict";
|
|
7837
|
+
init_errors();
|
|
7838
|
+
init_exit_codes();
|
|
7839
|
+
OUT_FLAG2 = { type: "string", description: "Keep the run's files (results.csv, invalid.csv, plan.json) in this directory" };
|
|
7840
|
+
CONCURRENCY_FLAG = { type: "string", description: "Requests in flight at once (default 4, max 16)" };
|
|
7841
|
+
}
|
|
7842
|
+
});
|
|
7843
|
+
|
|
7844
|
+
// src/batch/jobs.ts
|
|
7845
|
+
import { setTimeout as delay2 } from "node:timers/promises";
|
|
7846
|
+
function interrupted2() {
|
|
7847
|
+
return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
7848
|
+
}
|
|
7849
|
+
async function defaultSleep(ms, signal) {
|
|
7850
|
+
try {
|
|
7851
|
+
await delay2(ms, void 0, signal ? { signal } : void 0);
|
|
7852
|
+
} catch (err) {
|
|
7853
|
+
if (signal?.aborted) throw interrupted2();
|
|
7854
|
+
throw err;
|
|
7855
|
+
}
|
|
7856
|
+
}
|
|
7857
|
+
function toJob(body2, jobId, type) {
|
|
7858
|
+
const data = unwrap(body2);
|
|
7859
|
+
const record = data !== null && typeof data === "object" && !Array.isArray(data) ? data : {};
|
|
7860
|
+
const rawId = record.id;
|
|
7861
|
+
return {
|
|
7862
|
+
...record,
|
|
7863
|
+
id: typeof rawId === "number" || typeof rawId === "string" && rawId !== "" ? String(rawId) : jobId,
|
|
7864
|
+
type: typeof record.type === "string" && record.type !== "" ? record.type : type,
|
|
7865
|
+
status: typeof record.status === "string" ? record.status : "queued"
|
|
7866
|
+
};
|
|
7867
|
+
}
|
|
7868
|
+
async function waitForJob(client, jobId, type, opts = {}) {
|
|
7869
|
+
const id = String(jobId).trim();
|
|
7870
|
+
if (id === "") throw usageError("Name the job id.", { field: "jobId" });
|
|
7871
|
+
const timeoutMs2 = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
7872
|
+
const intervalMs = opts.intervalMs ?? DEFAULT_INTERVAL_MS;
|
|
7873
|
+
const now = opts.now ?? Date.now;
|
|
7874
|
+
const sleep = opts.sleep ?? ((ms) => defaultSleep(ms, opts.signal));
|
|
7875
|
+
const started = now();
|
|
7876
|
+
for (; ; ) {
|
|
7877
|
+
if (opts.signal?.aborted) throw interrupted2();
|
|
7878
|
+
const res = await client.request({ method: "GET", path: `/v1/jobs/${encodeURIComponent(id)}`, query: { type }, signal: opts.signal });
|
|
7879
|
+
const job = toJob(res.body, id, type);
|
|
7880
|
+
if (TERMINAL_JOB_STATUSES.includes(job.status)) return job;
|
|
7881
|
+
opts.onProgress?.(job);
|
|
7882
|
+
const elapsed = now() - started;
|
|
7883
|
+
if (elapsed >= timeoutMs2) {
|
|
7884
|
+
throw new KensoError({
|
|
7885
|
+
code: "job_timeout",
|
|
7886
|
+
message: `Job ${id} is still ${job.status} after ${Math.round(timeoutMs2 / 1e3)} s.`,
|
|
7887
|
+
exitCode: ExitCode.Error,
|
|
7888
|
+
hint: "The job keeps running on the server. Wait for it again.",
|
|
7889
|
+
next: `kenso jobs wait ${id} --type ${type}`
|
|
7890
|
+
});
|
|
7891
|
+
}
|
|
7892
|
+
const interval = elapsed >= FAST_PHASE_MS ? Math.max(intervalMs, SLOW_INTERVAL_MS) : intervalMs;
|
|
7893
|
+
await sleep(Math.min(interval, Math.max(0, timeoutMs2 - elapsed)));
|
|
7894
|
+
}
|
|
7895
|
+
}
|
|
7896
|
+
var TERMINAL_JOB_STATUSES, DEFAULT_TIMEOUT_MS, DEFAULT_INTERVAL_MS, SLOW_INTERVAL_MS, FAST_PHASE_MS;
|
|
7897
|
+
var init_jobs = __esm({
|
|
7898
|
+
"src/batch/jobs.ts"() {
|
|
7899
|
+
"use strict";
|
|
7900
|
+
init_errors();
|
|
7901
|
+
init_exit_codes();
|
|
7902
|
+
init_http();
|
|
7903
|
+
TERMINAL_JOB_STATUSES = ["succeeded", "failed", "canceled"];
|
|
7904
|
+
DEFAULT_TIMEOUT_MS = 10 * 6e4;
|
|
7905
|
+
DEFAULT_INTERVAL_MS = 2e3;
|
|
7906
|
+
SLOW_INTERVAL_MS = 1e4;
|
|
7907
|
+
FAST_PHASE_MS = 6e4;
|
|
7908
|
+
}
|
|
7909
|
+
});
|
|
7910
|
+
|
|
7911
|
+
// src/commands/jobs/wait.ts
|
|
7912
|
+
var wait_exports = {};
|
|
7913
|
+
__export(wait_exports, {
|
|
7914
|
+
default: () => wait_default,
|
|
7915
|
+
parseDuration: () => parseDuration
|
|
7916
|
+
});
|
|
7917
|
+
function parseDuration(text4) {
|
|
7918
|
+
const match = /^(\d+(?:\.\d+)?)\s*([smh]?)$/i.exec(text4.trim());
|
|
7919
|
+
if (!match) return void 0;
|
|
7920
|
+
const ms = Number(match[1]) * (UNIT_MS[(match[2] || "s").toLowerCase()] ?? 1e3);
|
|
7921
|
+
return Number.isFinite(ms) ? Math.round(ms) : void 0;
|
|
7922
|
+
}
|
|
7923
|
+
var UNIT_MS, command2, wait_default;
|
|
7924
|
+
var init_wait = __esm({
|
|
7925
|
+
"src/commands/jobs/wait.ts"() {
|
|
7926
|
+
"use strict";
|
|
7927
|
+
init_jobs();
|
|
7928
|
+
init_errors();
|
|
7929
|
+
init_exit_codes();
|
|
7930
|
+
UNIT_MS = { s: 1e3, m: 6e4, h: 36e5 };
|
|
7931
|
+
command2 = {
|
|
7932
|
+
resource: "jobs",
|
|
7933
|
+
action: "wait",
|
|
7934
|
+
summary: "Wait for a background job and print it",
|
|
7935
|
+
description: "Polls GET /v1/jobs/{jobId}?type=<type> every 2 s (every 10 s after the first minute) until the job succeeds, fails or is canceled, then prints the job. Exit 0 when it succeeded, 1 when it failed, was canceled or is still running when --timeout passes.",
|
|
7936
|
+
flags: {
|
|
7937
|
+
type: { type: "string", required: true, description: "The job type, for example contact_import or contact_export" },
|
|
7938
|
+
timeout: { type: "string", default: "10m", description: "How long to wait: 90s, 10m, 1h or a number of seconds (default 10m)" }
|
|
7939
|
+
},
|
|
7940
|
+
positionals: [{ name: "jobId", required: true, description: "The job id" }],
|
|
7941
|
+
examples: ["kenso jobs wait 4821 --type contact_import", "kenso jobs wait 4821 --type contact_export --timeout 30m"],
|
|
7942
|
+
operationIds: ["jobs.get"],
|
|
7943
|
+
async run(ctx, { flags, positionals }) {
|
|
7944
|
+
const jobId = (positionals[0] ?? "").trim();
|
|
7945
|
+
if (jobId === "") throw usageError("Name the job id.", { field: "jobId", next: "kenso jobs wait <jobId> --type <type>" });
|
|
7946
|
+
const type = typeof flags.type === "string" ? flags.type.trim() : "";
|
|
7947
|
+
if (type === "") throw usageError("--type needs a value, for example contact_import.", { field: "type" });
|
|
7948
|
+
const timeoutText = typeof flags.timeout === "string" ? flags.timeout : "10m";
|
|
7949
|
+
const timeoutMs2 = parseDuration(timeoutText);
|
|
7950
|
+
if (timeoutMs2 === void 0) {
|
|
7951
|
+
throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
|
|
7952
|
+
}
|
|
7953
|
+
const job = await waitForJob(ctx.client, jobId, type, {
|
|
7954
|
+
timeoutMs: timeoutMs2,
|
|
7955
|
+
signal: ctx.signal,
|
|
7956
|
+
onProgress: (j) => {
|
|
7957
|
+
const done2 = j.progress ? `, ${j.progress.completed}/${j.progress.total ?? "?"}` : "";
|
|
7958
|
+
ctx.output.progress(`job ${j.id}: ${j.status}${done2}`);
|
|
7959
|
+
}
|
|
7960
|
+
});
|
|
7961
|
+
ctx.output.object(job);
|
|
7962
|
+
if (job.status === "succeeded") return ExitCode.Ok;
|
|
7963
|
+
throw new KensoError({
|
|
7964
|
+
code: job.error?.code || (job.status === "canceled" ? "job_canceled" : "job_failed"),
|
|
7965
|
+
message: job.error?.message || `Job ${job.id} ${job.status === "canceled" ? "was canceled" : "failed"}.`,
|
|
7966
|
+
exitCode: ExitCode.Error
|
|
7967
|
+
});
|
|
7968
|
+
}
|
|
7969
|
+
};
|
|
7970
|
+
wait_default = command2;
|
|
7971
|
+
}
|
|
7972
|
+
});
|
|
7973
|
+
|
|
7974
|
+
// src/commands/changes/bulk-update.ts
|
|
7975
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
7976
|
+
function idList(flags, name) {
|
|
7977
|
+
const raw = stringFlag2(flags, name);
|
|
7978
|
+
if (raw === void 0) return void 0;
|
|
7979
|
+
const ids2 = raw.split(/[\s,]+/).filter((part) => part !== "").map(positiveId);
|
|
7980
|
+
if (ids2.length === 0 || ids2.length > MAX_IDS || ids2.some((id) => id === void 0)) {
|
|
7981
|
+
throw usageError(`--${name} takes 1 to ${MAX_IDS} positive ids, comma-separated (got "${raw}").`, { field: name });
|
|
7982
|
+
}
|
|
7983
|
+
return [...new Set(ids2)];
|
|
7984
|
+
}
|
|
7985
|
+
function parseSet(pairs, aliases) {
|
|
7986
|
+
const set = {};
|
|
7987
|
+
for (const pair of pairs) {
|
|
7988
|
+
const at = pair.indexOf("=");
|
|
7989
|
+
const key = at > 0 ? pair.slice(0, at).trim() : "";
|
|
7990
|
+
if (key === "") throw usageError(`--set takes field=value (got "${pair}").`, { field: "set", hint: "For example --set stage=engaged." });
|
|
7991
|
+
const text4 = pair.slice(at + 1).trim();
|
|
7992
|
+
let value = text4;
|
|
7993
|
+
try {
|
|
7994
|
+
value = JSON.parse(text4);
|
|
7995
|
+
} catch {
|
|
7996
|
+
}
|
|
7997
|
+
const field = aliases[key] ?? key;
|
|
7998
|
+
if (field in set) throw usageError(`--set names ${field} twice.`, { field: "set" });
|
|
7999
|
+
set[field] = value;
|
|
8000
|
+
}
|
|
8001
|
+
return set;
|
|
8002
|
+
}
|
|
8003
|
+
function filterBody(flags) {
|
|
8004
|
+
const raw = stringFlag2(flags, "filter");
|
|
8005
|
+
if (raw === void 0) return void 0;
|
|
8006
|
+
let parsed2;
|
|
8007
|
+
try {
|
|
8008
|
+
parsed2 = JSON.parse(raw);
|
|
8009
|
+
} catch {
|
|
8010
|
+
parsed2 = void 0;
|
|
8011
|
+
}
|
|
8012
|
+
if (!isRecord4(parsed2)) {
|
|
8013
|
+
throw usageError("--filter takes the search body as a JSON object.", { field: "filter", hint: `For example --filter '{"q": "acme"}'.` });
|
|
8014
|
+
}
|
|
8015
|
+
return parsed2;
|
|
8016
|
+
}
|
|
8017
|
+
function targetBody(flags, target2, command65) {
|
|
8018
|
+
const ids2 = idList(flags, "ids");
|
|
8019
|
+
const filter = filterBody(flags);
|
|
8020
|
+
const everything = flags.all === true;
|
|
8021
|
+
if ([ids2 !== void 0, filter !== void 0, everything].filter(Boolean).length !== 1) {
|
|
8022
|
+
throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command65} --help` });
|
|
8023
|
+
}
|
|
8024
|
+
const exclude = idList(flags, "exclude-ids");
|
|
8025
|
+
if (exclude !== void 0 && ids2 !== void 0) throw usageError("--exclude-ids goes with --filter or --all.", { field: "exclude-ids" });
|
|
8026
|
+
const label = stringFlag2(flags, "label");
|
|
8027
|
+
return {
|
|
8028
|
+
...ids2 !== void 0 ? { ids: ids2 } : { filter: filter ?? {}, ...everything ? { all: true } : {}, ...exclude ? { excludeIds: exclude } : {} },
|
|
8029
|
+
...label !== void 0 ? { label } : {}
|
|
8030
|
+
};
|
|
8031
|
+
}
|
|
8032
|
+
function requestBody(flags, target2, dryRun2) {
|
|
8033
|
+
const command65 = `kenso ${target2.resource} bulk-update`;
|
|
8034
|
+
const pairs = Array.isArray(flags.set) ? flags.set : typeof flags.set === "string" ? [flags.set] : [];
|
|
8035
|
+
if (pairs.length === 0) throw usageError(`--set is required for ${command65}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command65} --help` });
|
|
8036
|
+
return {
|
|
8037
|
+
...targetBody(flags, target2, command65),
|
|
8038
|
+
set: parseSet(pairs, target2.aliases),
|
|
8039
|
+
...dryRun2 ? { dryRun: true } : {},
|
|
8040
|
+
...flags["overwrite-pinned"] === true ? { overwritePinned: true } : {}
|
|
8041
|
+
};
|
|
8042
|
+
}
|
|
8043
|
+
async function waitForChange(ctx, first, timeoutMs2) {
|
|
8044
|
+
const started = Date.now();
|
|
8045
|
+
let change = first;
|
|
8046
|
+
while (WORKING.has(change.status)) {
|
|
8047
|
+
const res = await ctx.client.request({ method: "GET", path: `/v1/changes/${change.id}`, signal: ctx.signal });
|
|
8048
|
+
change = unwrap(res.body);
|
|
8049
|
+
if (!WORKING.has(change.status)) break;
|
|
8050
|
+
if (Date.now() - started >= timeoutMs2) {
|
|
8051
|
+
throw new KensoError({
|
|
8052
|
+
code: "change_timeout",
|
|
8053
|
+
message: `Change ${change.id} is still ${change.status} after ${Math.round(timeoutMs2 / 1e3)} s.`,
|
|
8054
|
+
exitCode: ExitCode.Error,
|
|
8055
|
+
hint: "It keeps running on the server.",
|
|
8056
|
+
next: `kenso changes get --change-id ${change.id}`
|
|
8057
|
+
});
|
|
8058
|
+
}
|
|
8059
|
+
ctx.output.progress(`change ${change.id}: ${change.status}`);
|
|
8060
|
+
try {
|
|
8061
|
+
await delay3(POLL_MS, void 0, { signal: ctx.signal });
|
|
8062
|
+
} catch (err) {
|
|
8063
|
+
if (ctx.signal.aborted) throw new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
8064
|
+
throw err;
|
|
8065
|
+
}
|
|
8066
|
+
}
|
|
8067
|
+
return change;
|
|
8068
|
+
}
|
|
8069
|
+
function bulkUpdateCommand(target2) {
|
|
8070
|
+
return {
|
|
8071
|
+
resource: target2.resource,
|
|
8072
|
+
action: "bulk-update",
|
|
8073
|
+
summary: `Change fields on many ${target2.plural} at once: by --ids, or everything a --filter matches`,
|
|
8074
|
+
brief: "--filter --set",
|
|
8075
|
+
description: `Calls POST /v1/${target2.resource}/bulk-update, which makes a change set: the ${target2.plural} it names and, for each, the field, its value before and its value after. Without --yes (or with --dry-run) it only previews: it prints count and a sample, writes nothing, and names the command that applies exactly those ${target2.plural}. With --yes it writes them in the background and waits. Fields for --set: ${target2.fields.join(", ")}${Object.keys(target2.aliases).length > 0 ? ` (${Object.entries(target2.aliases).map(([short, field]) => `${short} = ${field}`).join(", ")})` : ""}. A value of null clears the field. A ${target2.noun} that changed after the preview is left alone and counted as a conflict. Exit 5 when some records failed or conflicted.`,
|
|
8076
|
+
flags: {
|
|
8077
|
+
ids: FLAGS.ids(target2),
|
|
8078
|
+
filter: FLAGS.filter(target2),
|
|
8079
|
+
all: FLAGS.all(target2),
|
|
8080
|
+
"exclude-ids": FLAGS.excludeIds,
|
|
8081
|
+
set: { type: "string", multiple: true, description: "field=value; repeat it for more fields (up to 10)" },
|
|
8082
|
+
label: FLAGS.label,
|
|
8083
|
+
"overwrite-pinned": { type: "boolean", description: "Also replace a value a person set by hand" },
|
|
8084
|
+
timeout: FLAGS.timeout
|
|
8085
|
+
},
|
|
8086
|
+
examples: target2.examples,
|
|
8087
|
+
beta: { featureGates: { all: target2.featureGates } },
|
|
8088
|
+
operationIds: [`${target2.resource}.bulk-update`, "changes.get"],
|
|
8089
|
+
dryRun: true,
|
|
8090
|
+
run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-update`, (dryRun2) => requestBody(flags, target2, dryRun2))
|
|
8091
|
+
};
|
|
8092
|
+
}
|
|
8093
|
+
function bulkDeleteCommand(target2) {
|
|
8094
|
+
const command65 = `kenso ${target2.resource} bulk-delete`;
|
|
8095
|
+
return {
|
|
8096
|
+
resource: target2.resource,
|
|
8097
|
+
action: "bulk-delete",
|
|
8098
|
+
summary: `Delete many ${target2.plural} at once: by --ids, or everything a --filter matches`,
|
|
8099
|
+
brief: "--filter --yes",
|
|
8100
|
+
description: `Calls POST /v1/${target2.resource}/bulk-delete, which makes a change set that lists every ${target2.noun} it would delete. Without --yes (or with --dry-run) it only previews: it prints count and a sample, deletes nothing, and names the command that deletes exactly those ${target2.plural}. With --yes it deletes them in the background and waits. Each ${target2.noun} is deleted as kenso ${target2.resource} delete deletes it, so one that cannot be deleted is counted as failed and the rest go on. A delete is not undone with kenso changes undo. Exit 5 when some records failed.`,
|
|
8101
|
+
flags: {
|
|
8102
|
+
ids: FLAGS.ids(target2),
|
|
8103
|
+
filter: FLAGS.filter(target2),
|
|
8104
|
+
all: FLAGS.all(target2),
|
|
8105
|
+
"exclude-ids": FLAGS.excludeIds,
|
|
8106
|
+
label: FLAGS.label,
|
|
8107
|
+
timeout: FLAGS.timeout
|
|
8108
|
+
},
|
|
8109
|
+
examples: target2.examples,
|
|
8110
|
+
beta: { featureGates: { all: target2.featureGates } },
|
|
8111
|
+
operationIds: [`${target2.resource}.bulk-delete`, "changes.get"],
|
|
8112
|
+
dryRun: true,
|
|
8113
|
+
run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command65), dryRun: dryRun2 }))
|
|
8114
|
+
};
|
|
8115
|
+
}
|
|
8116
|
+
async function runChange(ctx, flags, path, body2) {
|
|
8117
|
+
const dryRun2 = ctx.flags.yes !== true || ctx.flags.dryRun === true;
|
|
8118
|
+
const timeoutText = stringFlag2(flags, "timeout") ?? "10m";
|
|
8119
|
+
const timeoutMs2 = parseDuration(timeoutText);
|
|
8120
|
+
if (timeoutMs2 === void 0) throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
|
|
8121
|
+
const res = await ctx.client.request({ method: "POST", path, body: body2(dryRun2), signal: ctx.signal });
|
|
8122
|
+
const change = await waitForChange(ctx, unwrap(res.body), timeoutMs2);
|
|
8123
|
+
if (change.status === "previewed") {
|
|
8124
|
+
ctx.output.object({ ...change, next: sameCommand2("kenso changes apply", { "change-id": String(change.id) }, ctx) });
|
|
8125
|
+
return ExitCode.Ok;
|
|
8126
|
+
}
|
|
8127
|
+
ctx.output.object(change);
|
|
8128
|
+
if (change.status !== "done") {
|
|
8129
|
+
throw new KensoError({ code: `change_${change.status}`, message: change.error || `Change ${change.id} ended ${change.status}.`, exitCode: ExitCode.Error });
|
|
8130
|
+
}
|
|
8131
|
+
return (change.counts?.failed ?? 0) + (change.counts?.conflict ?? 0) > 0 ? ExitCode.Partial : ExitCode.Ok;
|
|
8132
|
+
}
|
|
8133
|
+
var POLL_MS, MAX_IDS, WORKING, FLAGS;
|
|
8134
|
+
var init_bulk_update = __esm({
|
|
8135
|
+
"src/commands/changes/bulk-update.ts"() {
|
|
8136
|
+
"use strict";
|
|
8137
|
+
init_errors();
|
|
8138
|
+
init_exit_codes();
|
|
8139
|
+
init_http();
|
|
8140
|
+
init_common();
|
|
8141
|
+
init_wait();
|
|
8142
|
+
POLL_MS = 2e3;
|
|
8143
|
+
MAX_IDS = 1e3;
|
|
8144
|
+
WORKING = /* @__PURE__ */ new Set(["resolving", "running"]);
|
|
8145
|
+
FLAGS = {
|
|
8146
|
+
ids: (target2) => ({ type: "string", description: `${target2.noun} ids, comma-separated (up to 1,000)` }),
|
|
8147
|
+
filter: (target2) => ({ type: "string", description: `The search body as JSON, as kenso ${target2.resource} search --data takes it (filters, where, q): everything it matches` }),
|
|
8148
|
+
all: (target2) => ({ type: "boolean", description: `Every ${target2.noun} in the workspace` }),
|
|
8149
|
+
excludeIds: { type: "string", description: "Ids to leave out of --filter or --all, comma-separated (up to 1,000)" },
|
|
8150
|
+
label: { type: "string", description: "A name for the change in kenso changes list" },
|
|
8151
|
+
timeout: { type: "string", default: "10m", description: "How long to wait for the change: 90s, 10m, 1h (default 10m)" }
|
|
8152
|
+
};
|
|
8153
|
+
}
|
|
8154
|
+
});
|
|
8155
|
+
|
|
8156
|
+
// src/commands/accounts/bulk-update.ts
|
|
8157
|
+
var bulk_update_exports = {};
|
|
8158
|
+
__export(bulk_update_exports, {
|
|
8159
|
+
default: () => bulk_update_default
|
|
8160
|
+
});
|
|
8161
|
+
var bulk_update_default;
|
|
8162
|
+
var init_bulk_update2 = __esm({
|
|
8163
|
+
"src/commands/accounts/bulk-update.ts"() {
|
|
8164
|
+
"use strict";
|
|
8165
|
+
init_bulk_update();
|
|
8166
|
+
bulk_update_default = bulkUpdateCommand({
|
|
8167
|
+
resource: "accounts",
|
|
8168
|
+
noun: "account",
|
|
8169
|
+
plural: "accounts",
|
|
8170
|
+
aliases: { owner: "ownerMemberId", tier: "tierOverride" },
|
|
8171
|
+
fields: ["ownerMemberId", "stage", "tierOverride", "industry", "fundingRound", "employeeCount", "hqLocation", "cadenceDays"],
|
|
8172
|
+
featureGates: ["accounts", "bulk_edit"],
|
|
8173
|
+
examples: [
|
|
8174
|
+
`kenso accounts bulk-update --filter '{"filters":[{"field":"stage","operator":"is","values":["new"]}]}' --set owner=42 --dry-run`,
|
|
8175
|
+
"kenso accounts bulk-update --ids 812,813 --set stage=engaged --set tier=2 --yes",
|
|
8176
|
+
"kenso changes apply --change-id 31"
|
|
8177
|
+
]
|
|
8178
|
+
});
|
|
8179
|
+
}
|
|
8180
|
+
});
|
|
8181
|
+
|
|
8182
|
+
// src/commands/accounts/bulk-delete.ts
|
|
8183
|
+
var bulk_delete_exports = {};
|
|
8184
|
+
__export(bulk_delete_exports, {
|
|
8185
|
+
default: () => bulk_delete_default
|
|
8186
|
+
});
|
|
8187
|
+
var bulk_delete_default;
|
|
8188
|
+
var init_bulk_delete = __esm({
|
|
8189
|
+
"src/commands/accounts/bulk-delete.ts"() {
|
|
8190
|
+
"use strict";
|
|
8191
|
+
init_bulk_update();
|
|
8192
|
+
bulk_delete_default = bulkDeleteCommand({
|
|
8193
|
+
resource: "accounts",
|
|
8194
|
+
noun: "account",
|
|
8195
|
+
plural: "accounts",
|
|
8196
|
+
featureGates: ["accounts", "bulk_edit"],
|
|
8197
|
+
examples: [
|
|
8198
|
+
`kenso accounts bulk-delete --filter '{"filters":[{"field":"stage","operator":"is","values":["not_a_fit"]}]}' --dry-run`,
|
|
8199
|
+
"kenso accounts bulk-delete --ids 812,813 --yes",
|
|
8200
|
+
"kenso changes apply --change-id 31"
|
|
8201
|
+
]
|
|
8202
|
+
});
|
|
8203
|
+
}
|
|
8204
|
+
});
|
|
8205
|
+
|
|
7747
8206
|
// src/commands/accounts/index.ts
|
|
7748
8207
|
var actions;
|
|
7749
8208
|
var init_accounts = __esm({
|
|
7750
8209
|
"src/commands/accounts/index.ts"() {
|
|
7751
8210
|
"use strict";
|
|
7752
8211
|
actions = {
|
|
7753
|
-
import: () => Promise.resolve().then(() => (init_import(), import_exports)).then((m) => m.default)
|
|
8212
|
+
import: () => Promise.resolve().then(() => (init_import(), import_exports)).then((m) => m.default),
|
|
8213
|
+
// Replaces the generated accounts bulk-update: its body's dryRun would collide with the global --dry-run (DEV-11162).
|
|
8214
|
+
"bulk-update": () => Promise.resolve().then(() => (init_bulk_update2(), bulk_update_exports)).then((m) => m.default),
|
|
8215
|
+
"bulk-delete": () => Promise.resolve().then(() => (init_bulk_delete(), bulk_delete_exports)).then((m) => m.default)
|
|
7754
8216
|
};
|
|
7755
8217
|
}
|
|
7756
8218
|
});
|
|
@@ -7791,7 +8253,7 @@ var init_connect = __esm({
|
|
|
7791
8253
|
var crm_default;
|
|
7792
8254
|
var init_crm = __esm({
|
|
7793
8255
|
"docs/crm.md"() {
|
|
7794
|
-
crm_default = '# CRM (beta)\n\nThe CRM commands work on Kenso\'s Accounts lane: accounts (companies), the people on them, and opportunities. They are beta: they need the `accounts` feature flag on your workspace (opportunities need `opportunities`, CRM sync needs `ingestion`). Help and `kenso describe` hide them until your workspace has the flag; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `accounts import` | Create accounts from a CSV or JSONL file. Research is charged per created account |\n| `people import` | Create or match people from a file, optionally onto accounts |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities move <id> --stage <key> [--reason <key>]` | Move a deal, with its won or lost reason; a field the stage asks for never stops it |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `notes list`, `notes add`, `notes edit`, `notes delete` | Notes and comments on accounts, people and deals (needs `record_notes`) |\n| `deleted-accounts list`, `accounts restore <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved Accounts view, or what the filters match |\n| `capture status` | Your captured mailbox, its backfill progress and what teammates see of a captured email. Needs the `crm_capture` flag |\n| `capture connect` | Turn capture on for your own mailbox. `--private` starts it hidden from teammates; `--provider google` prints a sign-in link when no account is connected yet |\n| `capture private on\\|off` | Hide your captured email from teammates, or show it again. Email only: meetings stay visible. `--thread <id>` sets the switch for one thread |\n| `capture thread <threadId>` | One captured email thread: subject, people, time, Ken\'s summary, and each body you may open. The id is `capturedThread.id` on a timeline row |\n| `capture sync` | Read your captured mailbox now, instead of waiting for the next two-minute poll. Prints what the pass read, logged and created |\n| `capture disconnect` | Turn capture off and delete your stored email bodies. Asks first; `--yes` skips the question |\n| `capture teammates-see summary\\|full_email` | Workspace admin: what teammates see of captured email |\n| `pipelines stage-rules` | List or set the fields a deal should have in each stage |\n| `opportunity-reasons get`, `opportunity-reasons replace` | List or edit why deals are lost and won |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n| `tasks add`, `tasks done`, `tasks assign`, `tasks queue` | Add a to-do for a member on an account, person or deal, complete it, hand it on, or read your open work (needs `tasks`) |\n\nImport accounts first, then people: `people import` never creates an account.\n\n## Import accounts\n\n```bash\nkenso accounts import --file accounts.csv\nkenso accounts import --file accounts.csv --yes\n```\n\n```csv\nname,domain,industry,employeeCount\nAcme,acme.io,Software,120\nGlobex,globex.com,Manufacturing,"1,200"\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `name` (or `company`, `companyName`, `accountName`), `domains` (several, split on `,` or `;`) or one `domain` (or `website`, `companyDomain`), `industry`, `employeeCount`, `hqLocation`, `linkedinUrl`, `stage`, `angle`, `whyNow`, `fitScore`, `fundingRound`, `cadenceDays`, `ownerMemberId`, `kenCompanyId`, `sendsFromInboxId`, `sendsFromLinkedInAccountId` and `source`.\n- **A domain is required.** A file with no domain column is a usage error, and a row without a domain is `invalid` (`domain_required`).\n- **The dry run prices the research.** It asks for a credit estimate per 1,000 accounts and puts the sum in the plan: `kind`, `accountCount`, `totalMillicredits`, `availableMillicredits` and `sufficient`.\n- **Rows go 100 per call** to `POST /v1/accounts/bulk-create`.\n\nEach row comes back `created` (`id` is the new account; its research is queued, `researchQueued`, or waits for credits, `researchWaitingCredits`), `skipped` with reason `domain_taken` (already an account; `id` is that account) or `failed` (`reason` is the API\'s code, `error` names the field; an item Kenso failed to save is sent once more first). Rerunning the same file is safe: accounts that exist come back `domain_taken`.\n\n## Import people\n\n```bash\nkenso people import --file people.csv\nkenso people import --file people.csv --find-emails --yes\nkenso people import --file people.jsonl --dry-run\n```\n\n```csv\nfullName,email,title,accountDomain,role\nAnn Lee,ann@acme.io,VP Sales,acme.io,champion\nBob Ray,,CTO,acme.io,\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `email`, `fullName` (or `name`), `firstName`, `lastName`, `title`, `linkedinUrl` (or `linkedin`, `profileUrl`), `accountDomain` (or `domain`, `website`, `companyDomain`), `accountId`, `role` and `priority`. Other columns are ignored with one warning.\n- **A person needs a name:** `fullName`, or `firstName`, `lastName` or both (the CLI joins them). A row with none of them is `invalid` (`name_required`).\n- **To put a person on an account,** give `accountDomain` or `accountId`. A row with both sends only `accountId`.\n- **`--find-emails`** queues an email find (charged in credits) for each person without an email.\n- **Rows go 200 per call** to `POST /v1/people/batch`.\n\nPeople already in the workspace are matched by email, then LinkedIn URL, so running the same file again creates nobody twice. A row comes back `created` (a new person), `updated` (an existing person added to the account), `skipped` with reason `already_on_account`, `matched` (no account asked) or `previously_removed`, or `failed`: `account_not_found` saves the person without an account (import the account, then rerun to place them), any other reason is the API\'s. The summary adds `matched`, `addedToAccounts` and `emailFindsQueued`.\n\n## List and search accounts\n\n`accounts list` and `accounts search` sort and page on the server, so they reach every account in the workspace, however many there are.\n\n```bash\nkenso accounts list --sort score:desc --limit 100 # one page; the output\'s next: line is the following one\nkenso accounts list --sort score:desc --limit 100 --all # every page, to the end\nkenso accounts search --search hiring --sort latestSignalAt:desc --data \'{"qFields": ["name", "latestSignal"]}\'\nkenso accounts search --limit 1 --data \'{"countBy": ["stage"]}\' # how many accounts sit in each stage\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}]}, "sort": "tier,-pipelineAmount"}\' --all\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "hqLocation", "operator": "contains", "values": ["Germany"]}]}}\' --all\n# tier 1 accounts with no meeting in 30 days: none since then, or none ever\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}, {"match": "any", "conditions": [{"field": "lastMeeting", "operator": "older_than_days", "values": ["30"]}, {"field": "lastMeeting", "operator": "is_empty"}]}]}}\' --all\n```\n\n- **`--sort`** takes up to 3 comma-separated keys, each `field` (ascending), `field:asc` or `field:desc`. The API\'s `-field` form needs the equals sign here, `--sort=-score`, because a value that starts with a dash reads as a flag. Fields: `createdAt`, `name`, `score`, `tier` (ascending is tier 1 first), `latestSignalAt`, `committee`, `pipelineAmount`, `nextTouchAt`, `lastTouchAt`. An account with no value for a key comes last in both directions. The default is `-createdAt`.\n- **`--limit`** is 1 to 1000 (default 50). `--cursor` takes the previous page\'s `nextCursor` with the same filters and sort; `--all` follows the cursors for you.\n- **`--search`** (also `--q`) matches the name or a domain.\n- **Lists and objects go in `--data`** on `search`, as the API takes them (`kenso describe accounts search`); a flag beside it sets or replaces one key:\n - `qFields` picks where the search text looks: `name`, `domain`, `latestSignal` (the latest signal\'s title).\n - `countBy` (`stage`, `stageGroup`) adds `counts` to the output: every value with the number of matching accounts that hold it, whatever the page. The output is then one object: `data`, `pagination` and `counts`.\n - `filters` and `where` narrow the accounts.\n\nAn account\'s timeline pages the same way. `kenso accounts activity 812` returns the newest 100 earlier rows and, when older ones exist, `data.nextCursor`. Pass it back as `--cursor` (with the same `--category`) for the rows before them, until a page comes without one.\n\n## Edit accounts, people and opportunities\n\nApart from `accounts bulk-update`, which sets one `accountType` on up to 500 accounts, there is no bulk edit route, so run the generated `update` command once per row with `--each`. Columns are the command\'s flags by API name or flag name, and the id column fills the route:\n\n```bash\nkenso accounts update --each accounts-edit.csv --dry-run # then the same with --yes\nkenso people update --each people-edit.csv --dry-run\nkenso opportunities update --each deals.csv --dry-run\n```\n\n```csv\naccountId,stage,ownerMemberId,overwritePinned\n501,engaged,42,true\n502,customer,42,true\n```\n\nA row that changes a field someone pinned in the app fails as a whole (`409 conflict`, `pinned_by_user`: nothing on that record changes, the other fields of the row included), unless the row sets `overwritePinned` to `true` (or you pass `--overwrite-pinned`, only with the person\'s OK). Every flag of an update command: `kenso accounts update --help`.\n\n## Search opportunities\n\n`kenso opportunities search` works as `accounts search` does: it takes `--search`, `--sort`, `--limit`, `--cursor`, `--all`, and its lists in `--data`.\n\n```bash\nkenso opportunities search --data \'{"filters": [{"field": "stageCategory", "operator": "is", "values": ["open"]}]}\' --all\nkenso opportunities search --data \'{"filters": [{"field": "ownerMemberId", "operator": "is", "values": ["none"]}, {"field": "closeDate", "operator": "is", "values": ["past_due", "next_30_days"]}]}\'\nkenso opportunities search --limit 1 --data \'{"countBy": ["stage", "ownerMemberId"]}\' # how many opportunities hold each value\n```\n\n- **`filters`** is a list of `{field, operator, values}`, all of which must hold. Fields: `stage` (a stage key), `stageCategory` (`open`, `won`, `lost`), `ownerMemberId`, `closeDate` (`past_due`, `next_30_days`, `later`, `none`) and `sourceCampaignId`. `operator` is `is` or `is_not`; the values of one condition are OR. `none` in `values` matches an opportunity with no owner, no source campaign or no close date.\n- **`countBy`** takes the same field names and adds `counts` to the output: per field, every value with the number of matching opportunities that hold it.\n- `--account-id` keeps the search to one account. `closeDate` counts days in the member\'s app time zone.\n\nOne person\'s deals, meetings and campaign contacts, as their person page lists them:\n\n```bash\nkenso opportunities list --person-id 9001 # the deals they are on, or are the primary person of\nkenso meetings list --person-id 9001 # the meetings they attend, among the ones you can see\nkenso contacts list --person-id 9001 # their contact in each campaign they are in\n```\n\n## Write research you gathered\n\n`accounts write-research` and `people write-research` store research you gathered outside Kenso as the record\'s latest research (`PUT /v1/accounts/{accountId}/research`, `PUT /v1/people/{personId}/research`). The Research tab shows it like a Ken run, with `trigger: agent` and `researchedAt` now. Nothing is charged, and no account or person field changes: set an account\'s own `fitScore`, `whyNow` or `angle` with `accounts update`. They need the `accounts_research` flag and accounts edit.\n\nThe body is the research block `accounts get --expand research` (or `people get-research`) returns, without its read-only fields: leave out `id`, `status`, `trigger`, `errorCode`, `researchedAt`, `isStale` and `appliedPrompt` (for a person also `mode`, `requestedAt`, `researchedMode`, `firecrawlCredits` and `webNote`), or the write fails with `unknown_field`. Pass it with `--data @file`:\n\n```bash\nkenso accounts write-research --account-id 501 --data @acme-dossier.json\nkenso people write-research --person-id 9001 --data @jane.json\n```\n\n```json\n{\n "tagline": { "text": "Payroll for EU contractors", "sourceUrls": ["https://acme.example"] },\n "description": { "text": "Acme runs payroll and compliance for companies hiring contractors in 30 EU countries.", "sourceUrls": ["https://acme.example"] },\n "links": { "website": "https://acme.example" },\n "whyNow": { "text": "Raised a $40M Series B in October", "sourceUrls": ["https://news.example/acme-b"], "date": "2026-10" },\n "fitScore": 82,\n "angle": "Lead with contractor onboarding time."\n}\n```\n\nMany records: one JSONL line per record, with the id next to the block\'s fields. Nested objects are sent as written. Use JSONL, not CSV: the block\'s fields are objects and lists, which a CSV cell cannot carry.\n\n```bash\nkenso accounts write-research --each dossiers.jsonl --dry-run # then the same with --yes\nkenso people write-research --each people-research.jsonl --yes --concurrency 8\n```\n\n```jsonl\n{"accountId": 501, "tagline": {"text": "Payroll for EU contractors"}, "links": {"website": "https://acme.example"}}\n{"accountId": 502, "description": {"text": "Cloud cost tooling for retailers."}, "links": {"website": "https://beta.example"}}\n```\n\nA row fails as a whole with the API\'s code: `validation_failed` (an unknown field is `unknown_field`, and `error.details` names every bad field), `research_in_progress` (`409`: Ken is researching that record now, write it again once the run ends; an account run waiting for credits counts too: it runs once the workspace has credits, and the write stays refused until that run ends) or `not_found`. Rerunning a file is safe: each write replaces the record\'s research shown.\n\n## CRM sync\n\nCRM sync has generated commands only: read connections, preview, start an import, and work through sync issues. Connect the CRM itself in the app.\n\n```bash\nkenso crm-connections list\nkenso crm-connections get --connection-id 7\nkenso crm-imports create --connection-id 7 --dry-run\nkenso crm-sync-issues list --connection-id 7 --all\n```\n\nRun `kenso crm-connections --help` (or add `--all-commands` when the actions are hidden) to see every action.\n\n## Pipelines\n\nA workspace with the `pipelines` flag on can run several deal pipelines, each with its own stages. These are generated commands (beta):\n\n```bash\nkenso pipelines list\nkenso pipelines list --query "[].{id: id, name: name, default: isDefault, stages: stages[].key}"\nkenso pipelines get --pipeline-id 5\n```\n\n`list` prints every pipeline in display order, archived ones included: `id`, `name`, `routingRule` (the one sentence Ken reads to decide whether a new deal belongs there), `isDefault`, `isArchived`, `position`, `opportunityCount`, `amountTotal` and `stages`, each stage as `kenso opportunity-stages list` prints it. A stage key is unique in the workspace, across pipelines, so a deal\'s `stage` names its pipeline and its `pipelineId` repeats it. The first read turns the workspace\'s stage list into its default pipeline, named Sales, with every deal in it. The same rows as the MCP\'s `pipelines(operation="list")`.\n\nShaping them needs the `workspace_settings` permission:\n\n```bash\nkenso pipelines create --name Renewals --routing-rule "The account is already a customer" --data \'{"stages": [{"label": "Up for renewal", "category": "open"}, {"label": "Won", "category": "won"}, {"label": "Lost", "category": "lost"}]}\'\nkenso pipelines update --pipeline-id 6 --name Expansion --position 0\nkenso pipelines update --pipeline-id 6 --data @stages.json\nkenso pipelines archive --pipeline-id 6\nkenso pipelines restore --pipeline-id 6\n```\n\n- **`create`** takes a unique `name`, the pipeline\'s `stages` in display order (at least one `open`, one `won` and one `lost`) and an optional `routingRule`: one sentence that says which deals belong there, which Ken reads to route a new deal that names no pipeline. Each stage gets a key from its label; a key another pipeline already uses gets the pipeline\'s name in front (`renewals_won`). A workspace has at most 10 pipelines.\n- **`update`** changes what you send. `stages` is the pipeline\'s whole stage list: read it with `pipelines get`, keep each stage\'s `key`, and add a new stage without one. A stage with live deals in it cannot be left out; archive it with `"isArchived": true` instead.\n- **`archive`** stops new deals from entering a pipeline and keeps the deals in it. The default pipeline cannot be archived, and nothing is deleted: `restore` brings a pipeline back.\n\n## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore 812\n```\n\nA deleted account can be restored for 30 days. `deleted-accounts list` shows each one with who deleted it, `expiresAt` (restore works until then) and what comes back: `personCount`, `opportunityCount` and `touchCount`. `accounts restore <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. A domain another account took since stays with that account and is listed in `domainsTaken`. A merged account is not listed and cannot be restored: a merge has no undo. Both commands are behind the `crm_import_export` feature flag (`404` while it is off).\n\n## Export accounts, people or deals\n\n```bash\nkenso export accounts --out accounts.csv\nkenso export accounts --view 12 --out tier-1.csv\nkenso export deals --filters \'[{"field":"stageCategory","operator":"is","values":["open"]}]\' > open-deals.csv\n```\n\nIt writes the CSV that `POST /v1/accounts/export`, `/v1/people/export` or `/v1/opportunities/export` returns, to stdout or to `--out` (then it prints the file and its row count). With no filter it exports every record. More than 50,000 rows is refused: narrow the filters. `--view <id>` exports a saved Accounts view (`kenso account-views list` shows the ids). `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields, so a deals or people view exports with its filters and sort. The accounts and deals files start with `id` and import back as they are. Each export writes an audit-log entry and needs the export permission. Accounts and deals also need the `crm_import_export` flag while it is in beta.\n\n## A deal\'s stage history\n\n```bash\nkenso opportunities stage-history 77\nkenso opportunities stage-history 77 --query "entries[].{to: stageLabel, at: enteredAt, by: changedBy}"\n```\n\nIt prints `GET /v1/opportunities/{id}/stage-history` as it is, the same rows as the deal page and the MCP\'s `opportunities(operation="get-stage-history")`: the stage now, `isComplete` and `entries`, oldest first, each with `fromStage`, `stage`, `stageLabel`, `enteredAt`, `leftAt`, `durationSeconds`, `actorKind`, `actorMemberId` and Ken\'s `reason` on a move its stage judge made. With the `deal_stage_rules` flag on, each entry also has `changedBy` (`member`, `agent`, `api_key`, `workflow`, `stage_judge`, `crm_sync` or `ken_automation`), `crmProvider` on a CRM sync, and on a move `fromStageLabel` and `fromStageDurationSeconds`, how long the deal sat in the stage it left. `isComplete` false means Kenso has no record of part of the history.\n\n## Notes on accounts, people and deals\n\nWith the `record_notes` feature on, everyone who can see a record reads its notes. Name the record with exactly one of `--account`, `--person` and `--deal`:\n\n```bash\nkenso notes list --account 5\nkenso notes add --account 5 --body \'Budget approved, @[Jane Doe](41) please send the DPA\'\nkenso notes add --parent 900 --body \'Sent it this morning\' # a comment under note 900\ncat call-notes.md | kenso notes add --deal 77 --body - # the body from stdin\nkenso notes edit 900 --body \'Budget approved for Q1\' # the author only\nkenso notes edit 900 --pin\nkenso notes delete 900 --yes # kenso notes restore 900 brings it back\n```\n\nThe body is markdown, up to 20,000 characters. Mention a teammate as `@[Name](memberId)`: they get a notification that opens the note. A note shows on the record\'s Notes tab and its Activity timeline, and Ken\'s account brief quotes the account\'s notes. The MCP\'s `notes` tool does the same. A note on an account needs the accounts plan feature; people and deals work on every plan.\n\n## Required fields per stage\n\n```bash\nkenso pipelines stage-rules\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier\nkenso pipelines stage-rules proposal --none\nkenso pipelines stage-rules lost --default\n```\n\nWith the `deal_stage_rules` flag on, each stage can name the fields a deal should have in it. Without a stage the command prints every stage\'s `key`, `label`, `category`, `isArchived`, `requiredFields` and `isDefault`, plus `requirableFields`: `amount`, `closeDate`, `ownerMemberId`, `primaryPersonId`, `nextStep`, `lostReasonKey`, `wonReasonKey` and `custom.<key>` for each custom deal field. `--require` sets the stage\'s whole list, in order, at most 10. `--none` requires nothing, and `--default` goes back to the default: a lost stage asks for `lostReasonKey`, any other stage nothing. Setting a rule needs the `workspace_settings` permission. The same as the MCP\'s `opportunities(operation="stages-set-required-fields")`.\n\nA missing field never stops a move. The deal moves, and it is flagged Missing on the board, the list and the deal page until the field is filled. A rule also applies to deals already in the stage.\n\n```bash\nkenso opportunities update --opportunity-id 4401 --stage proposal\nkenso opportunities list --missing-fields\n```\n\nEvery deal then carries `missingFields` (`[{field, label}]`). A create, or an update that sends a stage, answers `warnings` beside the deal for each field the stage asks for that the deal leaves empty: each prints on stderr as `warning: <message>`, stdout stays the deal and the exit code stays 0. `--missing-fields` keeps only the deals flagged Missing (also `missingFields: true` on `kenso opportunities search`).\n\n## Won and lost reasons\n\n```bash\nkenso opportunity-reasons get\nkenso opportunity-reasons replace --kind lost --data \'{"reasons":[{"key":"no_budget","label":"No budget"},{"label":"Built it in-house"}]}\'\nkenso opportunities move 4401 --stage lost --reason built_it_in_house\n```\n\n`kenso opportunities move <id> --stage <key> [--reason <key>]` sends the reason as `lostReasonKey` for a lost stage or `wonReasonKey` for a won stage; an open stage takes none. Each field the new stage asks for that the deal leaves empty prints a warning on stderr, and the move still goes through.\n\nWith the `deal_stage_rules` flag on, each workspace edits why its deals are lost and won. `get` prints `lost` and `won`, each `{isDefault, reasons: [{key, label, isArchived}]}`. `replace` takes a kind\'s whole list in order, as `get` prints it: keep a reason by its `key`, leave `key` out for a new one, and set `isArchived` to archive a reason or bring one back. A reason left out is archived too: deals keep it, and no write can pick it again. At least one reason stays live and at most 30, and labels stay unique, archived ones included. A deal takes a live key in `lostReasonKey` (a lost stage) or `wonReasonKey` (a won stage). A move to Lost without a reason still goes through, with a warning and "Missing: Lost reason" on the deal. Editing the lists needs the `workspace_settings` permission. The same as the MCP\'s `pipelines(operation="reasons-get")` and `reasons-replace`.\n\n## Tasks\n\nTasks are to-dos a member owes: a title, an optional due day or time, an assignee and at most one account, person or deal. They need the `tasks` flag. The app calls deals "Deals"; the CLI keeps `--deal` for an opportunity id.\n\n```bash\nkenso tasks add "Send the deck" --due tomorrow --account 812\nkenso tasks add "Call Ada back" --due friday --at 16:00 --person 501 --assignee ada@acme.com\nkenso tasks list --assignee me --due overdue,today\nkenso tasks queue --scope mine\nkenso tasks assign 7 me\nkenso tasks done 7 8 9\nkenso tasks done 7 --undo\n```\n\n- `tasks add` sends `POST /v1/tasks`. `--due` takes `today`, `tomorrow`, a weekday (the next one: `friday` or `fri`), a day (`2026-11-20`) or an ISO 8601 time; `--at HH:MM` puts a time on that day (today without `--due`). Day words and `--at` read this computer\'s clock and time zone (`TZ`); a time\'s day is read in the assignee\'s app time zone. `--assignee` takes `me`, a member id or an email; without it the task is yours.\n- `tasks done` completes each task it names, in order (`PATCH /v1/tasks/{id}` with `status: done`); `--undo` reopens them. `tasks assign` gives a task to `me`, a member id or a member\'s email; that member gets a `task_assigned` notification.\n- `tasks queue` is `task-queue list` under the name you would try: the Tasks screen\'s open work by due day, with `--scope mine|assigned_by_me|everyone`. It lists tasks, manual touches, call tasks, inbox threads with a reminder due (when you can view the Inbox) and Ken\'s follow-ups to you, each with the app path in `href` (null for a task, which opens in its panel).\n- `tasks list`, `get`, `update`, `delete`, `restore` and `task-queue list` are generated from the API: `kenso tasks --help` lists them.\n';
|
|
8256
|
+
crm_default = '# CRM (beta)\n\nThe CRM commands work on Kenso\'s Accounts lane: accounts (companies), the people on them, and opportunities. They are beta: they need the `accounts` feature flag on your workspace (opportunities need `opportunities`, CRM sync needs `ingestion`). Help and `kenso describe` hide them until your workspace has the flag; `--all-commands` shows them.\n\n| Command | What it does |\n|---|---|\n| `accounts import` | Create accounts from a CSV or JSONL file. Research is charged per created account |\n| `people import` | Create or match people from a file, optionally onto accounts |\n| `accounts update --each`, `people update --each`, `opportunities update --each` | Edit many records from a file, one call per row |\n| `accounts bulk-update`, `people bulk-update`, `opportunities bulk-update` | Set the same fields on many records at once, by ids or by a filter, with a preview first. Needs `bulk_edit` too |\n| `accounts bulk-delete`, `people bulk-delete`, `opportunities bulk-delete` | Delete many records at once, by ids or by a filter, with a preview first. Not undone. Needs `bulk_edit` too |\n| `changes list`, `get`, `rows`, `apply`, `cancel`, `undo` | Follow a bulk change, read what each record got, stop it, or put the old values back for 30 days |\n| `accounts write-research`, `people write-research` | Store research you gathered as a record\'s latest research, free. `--each` writes many |\n| `opportunities move <id> --stage <key> [--reason <key>]` | Move a deal, with its won or lost reason; a field the stage asks for never stops it |\n| `opportunities stage-history <id>` | A deal\'s stage history: each stage, when, who moved it and how long it sat there |\n| `notes list`, `notes add`, `notes edit`, `notes delete` | Notes and comments on accounts, people and deals (needs `record_notes`) |\n| `deleted-accounts list`, `accounts restore <id>` | The accounts deleted in the last 30 days, and bringing one back |\n| `export <accounts\\|people\\|deals>` | The list as CSV: everything, a saved Accounts view, or what the filters match |\n| `capture status` | Your captured mailbox, its backfill progress and what teammates see of a captured email. Needs the `crm_capture` flag |\n| `capture connect` | Turn capture on for your own mailbox. `--private` starts it hidden from teammates; `--provider google` prints a sign-in link when no account is connected yet |\n| `capture private on\\|off` | Hide your captured email from teammates, or show it again. Email only: meetings stay visible. `--thread <id>` sets the switch for one thread |\n| `capture thread <threadId>` | One captured email thread: subject, people, time, Ken\'s summary, and each body you may open. The id is `capturedThread.id` on a timeline row |\n| `capture sync` | Read your captured mailbox now, instead of waiting for the next two-minute poll. Prints what the pass read, logged and created |\n| `capture disconnect` | Turn capture off and delete your stored email bodies. Asks first; `--yes` skips the question |\n| `capture teammates-see summary\\|full_email` | Workspace admin: what teammates see of captured email |\n| `pipelines stage-rules` | List or set the fields a deal should have in each stage |\n| `opportunity-reasons get`, `opportunity-reasons replace` | List or edit why deals are lost and won |\n| `crm-connections`, `crm-imports`, `crm-sync-issues` | Read and run CRM sync. Connecting a CRM stays in the app |\n| `tasks add`, `tasks done`, `tasks assign`, `tasks queue` | Add a to-do for a member on an account, person or deal, complete it, hand it on, or read your open work (needs `tasks`) |\n\nImport accounts first, then people: `people import` never creates an account.\n\n## Import accounts\n\n```bash\nkenso accounts import --file accounts.csv\nkenso accounts import --file accounts.csv --yes\n```\n\n```csv\nname,domain,industry,employeeCount\nAcme,acme.io,Software,120\nGlobex,globex.com,Manufacturing,"1,200"\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `name` (or `company`, `companyName`, `accountName`), `domains` (several, split on `,` or `;`) or one `domain` (or `website`, `companyDomain`), `industry`, `employeeCount`, `hqLocation`, `linkedinUrl`, `stage`, `angle`, `whyNow`, `fitScore`, `fundingRound`, `cadenceDays`, `ownerMemberId`, `kenCompanyId`, `sendsFromInboxId`, `sendsFromLinkedInAccountId` and `source`.\n- **A domain is required.** A file with no domain column is a usage error, and a row without a domain is `invalid` (`domain_required`).\n- **The dry run prices the research.** It asks for a credit estimate per 1,000 accounts and puts the sum in the plan: `kind`, `accountCount`, `totalMillicredits`, `availableMillicredits` and `sufficient`.\n- **Rows go 100 per call** to `POST /v1/accounts/bulk-create`.\n\nEach row comes back `created` (`id` is the new account; its research is queued, `researchQueued`, or waits for credits, `researchWaitingCredits`), `skipped` with reason `domain_taken` (already an account; `id` is that account) or `failed` (`reason` is the API\'s code, `error` names the field; an item Kenso failed to save is sent once more first). Rerunning the same file is safe: accounts that exist come back `domain_taken`.\n\n## Import people\n\n```bash\nkenso people import --file people.csv\nkenso people import --file people.csv --find-emails --yes\nkenso people import --file people.jsonl --dry-run\n```\n\n```csv\nfullName,email,title,accountDomain,role\nAnn Lee,ann@acme.io,VP Sales,acme.io,champion\nBob Ray,,CTO,acme.io,\n```\n\n- **Columns** map by name, ignoring case, spaces and dashes: `email`, `fullName` (or `name`), `firstName`, `lastName`, `title`, `linkedinUrl` (or `linkedin`, `profileUrl`), `accountDomain` (or `domain`, `website`, `companyDomain`), `accountId`, `role` and `priority`. Other columns are ignored with one warning.\n- **A person needs a name:** `fullName`, or `firstName`, `lastName` or both (the CLI joins them). A row with none of them is `invalid` (`name_required`).\n- **To put a person on an account,** give `accountDomain` or `accountId`. A row with both sends only `accountId`.\n- **`--find-emails`** queues an email find (charged in credits) for each person without an email.\n- **Rows go 200 per call** to `POST /v1/people/batch`.\n\nPeople already in the workspace are matched by email, then LinkedIn URL, so running the same file again creates nobody twice. A row comes back `created` (a new person), `updated` (an existing person added to the account), `skipped` with reason `already_on_account`, `matched` (no account asked) or `previously_removed`, or `failed`: `account_not_found` saves the person without an account (import the account, then rerun to place them), any other reason is the API\'s. The summary adds `matched`, `addedToAccounts` and `emailFindsQueued`.\n\n## List and search accounts\n\n`accounts list` and `accounts search` sort and page on the server, so they reach every account in the workspace, however many there are.\n\n```bash\nkenso accounts list --sort score:desc --limit 100 # one page; the output\'s next: line is the following one\nkenso accounts list --sort score:desc --limit 100 --all # every page, to the end\nkenso accounts search --search hiring --sort latestSignalAt:desc --data \'{"qFields": ["name", "latestSignal"]}\'\nkenso accounts search --limit 1 --data \'{"countBy": ["stage"]}\' # how many accounts sit in each stage\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}]}, "sort": "tier,-pipelineAmount"}\' --all\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "hqLocation", "operator": "contains", "values": ["Germany"]}]}}\' --all\n# tier 1 accounts with no meeting in 30 days: none since then, or none ever\nkenso accounts search --data \'{"where": {"match": "all", "conditions": [{"field": "tier", "operator": "is", "values": ["1"]}, {"match": "any", "conditions": [{"field": "lastMeeting", "operator": "older_than_days", "values": ["30"]}, {"field": "lastMeeting", "operator": "is_empty"}]}]}}\' --all\n```\n\n- **`--sort`** takes up to 3 comma-separated keys, each `field` (ascending), `field:asc` or `field:desc`. The API\'s `-field` form needs the equals sign here, `--sort=-score`, because a value that starts with a dash reads as a flag. Fields: `createdAt`, `name`, `score`, `tier` (ascending is tier 1 first), `latestSignalAt`, `committee`, `pipelineAmount`, `nextTouchAt`, `lastTouchAt`. An account with no value for a key comes last in both directions. The default is `-createdAt`.\n- **`--limit`** is 1 to 1000 (default 50). `--cursor` takes the previous page\'s `nextCursor` with the same filters and sort; `--all` follows the cursors for you.\n- **`--search`** (also `--q`) matches the name or a domain.\n- **Lists and objects go in `--data`** on `search`, as the API takes them (`kenso describe accounts search`); a flag beside it sets or replaces one key:\n - `qFields` picks where the search text looks: `name`, `domain`, `latestSignal` (the latest signal\'s title).\n - `countBy` (`stage`, `stageGroup`) adds `counts` to the output: every value with the number of matching accounts that hold it, whatever the page. The output is then one object: `data`, `pagination` and `counts`.\n - `filters` and `where` narrow the accounts.\n\nAn account\'s timeline pages the same way. `kenso accounts activity 812` returns the newest 100 earlier rows and, when older ones exist, `data.nextCursor`. Pass it back as `--cursor` (with the same `--category`) for the rows before them, until a page comes without one.\n\n## Edit accounts, people and opportunities\n\nTo set the same fields on many records, use `bulk-update` (below; it needs the `bulk_edit` flag). When every row gets its own values, or the workspace has no `bulk_edit`, run the generated `update` command once per row with `--each`. Columns are the command\'s flags by API name or flag name, and the id column fills the route:\n\n```bash\nkenso accounts update --each accounts-edit.csv --dry-run # then the same with --yes\nkenso people update --each people-edit.csv --dry-run\nkenso opportunities update --each deals.csv --dry-run\n```\n\n```csv\naccountId,stage,ownerMemberId,overwritePinned\n501,engaged,42,true\n502,customer,42,true\n```\n\nA row that changes a field someone pinned in the app fails as a whole (`409 conflict`, `pinned_by_user`: nothing on that record changes, the other fields of the row included), unless the row sets `overwritePinned` to `true` (or you pass `--overwrite-pinned`, only with the person\'s OK). Every flag of an update command: `kenso accounts update --help`.\n\n## Change many accounts at once\n\n```bash\nkenso accounts bulk-update --filter \'{"filters":[{"field":"stage","operator":"is","values":["new"]}]}\' --set owner=42 --dry-run\nkenso changes apply --change-id 31\nkenso accounts bulk-update --ids 812,813 --set stage=engaged --set tier=2 --yes\nkenso changes get --change-id 31\n```\n\n`accounts bulk-update` sets the same fields on every account you name: `--ids` (up to 1,000), everything a `--filter` matches (the body `kenso accounts search --data` takes: `filters`, `where`, `q`; up to 50,000), or `--all`. `--exclude-ids` leaves some of a filter\'s accounts out. `--set field=value` takes `ownerMemberId` (or `owner`), `stage`, `tierOverride` (or `tier`), `industry`, `fundingRound`, `employeeCount`, `hqLocation` and `cadenceDays`; a value of `null` clears the field. Use `accounts update --each` when every row gets its own values.\n\nIt makes a change set: the accounts it names and, for each, the field, its value before and its value after. Without `--yes` (or with `--dry-run`) it previews: it prints `count` and a `sample`, writes nothing, and `next` is the `kenso changes apply` command that writes exactly those accounts. With `--yes` it writes in the background and waits (`--timeout`, default 10m), then prints the change with its `counts`: `applied`, `unchanged` (already had the value), `conflict` (the account changed after the preview, so it was left alone) and `failed` (for example `pinned`: a person set the field by hand; `--overwrite-pinned` replaces it). Exit 5 when some accounts failed or conflicted. It needs the `bulk_edit` flag as well as `accounts`.\n\n`kenso accounts bulk-update` used to be the generated command for the route\'s older one-field body, which sets one `accountType` on up to 500 accounts and needs only `accounts`. The route still takes that body, but this command no longer sends it: use `kenso accounts update --each` with an `accountType` column, or `kenso api POST /v1/accounts/bulk-update --data \'{"accountIds":[812,813],"accountType":"lost"}\'`.\n\n`people bulk-update` and `opportunities bulk-update` work the same way. People take `--set` for `ownerMemberId` (or `owner`), `leadStatus`, `title`, `seniority`, `department` and `location`, and a `--filter` of `kenso people search --data` fields (`leadStatus`, `roles`, `tagIds`, `q` and the rest). Deals take `stage` (a live stage key), `ownerMemberId` (or `owner`), `closeDate` (or `close`), `amount`, `dealType` and `nextStep`, and a `--filter` of `kenso opportunities search --data` fields (`filters`, `accountId`, `q`):\n\n```bash\nkenso opportunities bulk-update --filter \'{"filters":[{"field":"stageCategory","operator":"is","values":["open"]}]}\' --set stage=proposal --dry-run\nkenso people bulk-update --ids 501,502 --set owner=42 --yes\n```\n\n### Delete many records at once\n\n```bash\nkenso people bulk-delete --filter \'{"onAccount":"none","leadStatus":["disqualified"]}\' --dry-run\nkenso changes apply --change-id 32\nkenso opportunities bulk-delete --ids 71,72,73 --yes\n```\n\n`accounts bulk-delete`, `people bulk-delete` and `opportunities bulk-delete` name their records the way `bulk-update` does (`--ids`, `--filter`, `--all`, `--exclude-ids`) and take no `--set`. Without `--yes` they preview: `count`, a `sample`, and `next` is the `kenso changes apply` command that deletes exactly those records. The API itself previews a delete whose body leaves `dryRun` out, so `--yes` sends `dryRun: false`. Each record is deleted as its own `delete` command deletes it, so one that cannot be deleted (a person still on an account) is counted as `failed` and the rest go on. A delete is not undone with `kenso changes undo`.\n\n### Follow, stop and undo a change\n\n```bash\nkenso changes list --object accounts\nkenso changes rows --change-id 31 --status conflict,failed\nkenso changes cancel --change-id 31\nkenso changes undo --change-id 31\n```\n\n`changes list` shows the workspace\'s bulk changes, newest first, whoever made them. `changes rows` lists a change\'s records with the value before (`from`) and after (`to`) and a `status`; `--status conflict,failed` reads what a change missed. `changes cancel` drops a preview or stops a change that is still writing; what it already wrote stays. `changes undo` puts the old value back on every record that still holds the value the change wrote, for 30 days after it was applied (`undoUntil`). A record someone changed again since keeps its newer value: `counts.undone` is how many went back, `counts.applied` how many still hold the change. Undo answers `409 invalid_state` with `undo_expired`, `still_running`, `nothing_applied` or `not_undoable` when there is nothing it can put back.\n\n## Search opportunities\n\n`kenso opportunities search` works as `accounts search` does: it takes `--search`, `--sort`, `--limit`, `--cursor`, `--all`, and its lists in `--data`.\n\n```bash\nkenso opportunities search --data \'{"filters": [{"field": "stageCategory", "operator": "is", "values": ["open"]}]}\' --all\nkenso opportunities search --data \'{"filters": [{"field": "ownerMemberId", "operator": "is", "values": ["none"]}, {"field": "closeDate", "operator": "is", "values": ["past_due", "next_30_days"]}]}\'\nkenso opportunities search --limit 1 --data \'{"countBy": ["stage", "ownerMemberId"]}\' # how many opportunities hold each value\n```\n\n- **`filters`** is a list of `{field, operator, values}`, all of which must hold. Fields: `stage` (a stage key), `stageCategory` (`open`, `won`, `lost`), `ownerMemberId`, `closeDate` (`past_due`, `next_30_days`, `later`, `none`) and `sourceCampaignId`. `operator` is `is` or `is_not`; the values of one condition are OR. `none` in `values` matches an opportunity with no owner, no source campaign or no close date.\n- **`countBy`** takes the same field names and adds `counts` to the output: per field, every value with the number of matching opportunities that hold it.\n- `--account-id` keeps the search to one account. `closeDate` counts days in the member\'s app time zone.\n\nOne person\'s deals, meetings and campaign contacts, as their person page lists them:\n\n```bash\nkenso opportunities list --person-id 9001 # the deals they are on, or are the primary person of\nkenso meetings list --person-id 9001 # the meetings they attend, among the ones you can see\nkenso contacts list --person-id 9001 # their contact in each campaign they are in\n```\n\n## Write research you gathered\n\n`accounts write-research` and `people write-research` store research you gathered outside Kenso as the record\'s latest research (`PUT /v1/accounts/{accountId}/research`, `PUT /v1/people/{personId}/research`). The Research tab shows it like a Ken run, with `trigger: agent` and `researchedAt` now. Nothing is charged, and no account or person field changes: set an account\'s own `fitScore`, `whyNow` or `angle` with `accounts update`. They need the `accounts_research` flag and accounts edit.\n\nThe body is the research block `accounts get --expand research` (or `people get-research`) returns, without its read-only fields: leave out `id`, `status`, `trigger`, `errorCode`, `researchedAt`, `isStale` and `appliedPrompt` (for a person also `mode`, `requestedAt`, `researchedMode`, `firecrawlCredits` and `webNote`), or the write fails with `unknown_field`. Pass it with `--data @file`:\n\n```bash\nkenso accounts write-research --account-id 501 --data @acme-dossier.json\nkenso people write-research --person-id 9001 --data @jane.json\n```\n\n```json\n{\n "tagline": { "text": "Payroll for EU contractors", "sourceUrls": ["https://acme.example"] },\n "description": { "text": "Acme runs payroll and compliance for companies hiring contractors in 30 EU countries.", "sourceUrls": ["https://acme.example"] },\n "links": { "website": "https://acme.example" },\n "whyNow": { "text": "Raised a $40M Series B in October", "sourceUrls": ["https://news.example/acme-b"], "date": "2026-10" },\n "fitScore": 82,\n "angle": "Lead with contractor onboarding time."\n}\n```\n\nMany records: one JSONL line per record, with the id next to the block\'s fields. Nested objects are sent as written. Use JSONL, not CSV: the block\'s fields are objects and lists, which a CSV cell cannot carry.\n\n```bash\nkenso accounts write-research --each dossiers.jsonl --dry-run # then the same with --yes\nkenso people write-research --each people-research.jsonl --yes --concurrency 8\n```\n\n```jsonl\n{"accountId": 501, "tagline": {"text": "Payroll for EU contractors"}, "links": {"website": "https://acme.example"}}\n{"accountId": 502, "description": {"text": "Cloud cost tooling for retailers."}, "links": {"website": "https://beta.example"}}\n```\n\nA row fails as a whole with the API\'s code: `validation_failed` (an unknown field is `unknown_field`, and `error.details` names every bad field), `research_in_progress` (`409`: Ken is researching that record now, write it again once the run ends; an account run waiting for credits counts too: it runs once the workspace has credits, and the write stays refused until that run ends) or `not_found`. Rerunning a file is safe: each write replaces the record\'s research shown.\n\n## CRM sync\n\nCRM sync has generated commands only: read connections, preview, start an import, and work through sync issues. Connect the CRM itself in the app.\n\n```bash\nkenso crm-connections list\nkenso crm-connections get --connection-id 7\nkenso crm-imports create --connection-id 7 --dry-run\nkenso crm-sync-issues list --connection-id 7 --all\n```\n\nRun `kenso crm-connections --help` (or add `--all-commands` when the actions are hidden) to see every action.\n\n## Pipelines\n\nA workspace with the `pipelines` flag on can run several deal pipelines, each with its own stages. These are generated commands (beta):\n\n```bash\nkenso pipelines list\nkenso pipelines list --query "[].{id: id, name: name, default: isDefault, stages: stages[].key}"\nkenso pipelines get --pipeline-id 5\n```\n\n`list` prints every pipeline in display order, archived ones included: `id`, `name`, `routingRule` (the one sentence Ken reads to decide whether a new deal belongs there), `isDefault`, `isArchived`, `position`, `opportunityCount`, `amountTotal` and `stages`, each stage as `kenso opportunity-stages list` prints it. A stage key is unique in the workspace, across pipelines, so a deal\'s `stage` names its pipeline and its `pipelineId` repeats it. The first read turns the workspace\'s stage list into its default pipeline, named Sales, with every deal in it. The same rows as the MCP\'s `pipelines(operation="list")`.\n\nShaping them needs the `workspace_settings` permission:\n\n```bash\nkenso pipelines create --name Renewals --routing-rule "The account is already a customer" --data \'{"stages": [{"label": "Up for renewal", "category": "open"}, {"label": "Won", "category": "won"}, {"label": "Lost", "category": "lost"}]}\'\nkenso pipelines update --pipeline-id 6 --name Expansion --position 0\nkenso pipelines update --pipeline-id 6 --data @stages.json\nkenso pipelines archive --pipeline-id 6\nkenso pipelines restore --pipeline-id 6\n```\n\n- **`create`** takes a unique `name`, the pipeline\'s `stages` in display order (at least one `open`, one `won` and one `lost`) and an optional `routingRule`: one sentence that says which deals belong there, which Ken reads to route a new deal that names no pipeline. Each stage gets a key from its label; a key another pipeline already uses gets the pipeline\'s name in front (`renewals_won`). A workspace has at most 10 pipelines.\n- **`update`** changes what you send. `stages` is the pipeline\'s whole stage list: read it with `pipelines get`, keep each stage\'s `key`, and add a new stage without one. A stage with live deals in it cannot be left out; archive it with `"isArchived": true` instead.\n- **`archive`** stops new deals from entering a pipeline and keeps the deals in it. The default pipeline cannot be archived, and nothing is deleted: `restore` brings a pipeline back.\n\n## Restore a deleted account\n\n```bash\nkenso deleted-accounts list\nkenso accounts restore 812\n```\n\nA deleted account can be restored for 30 days. `deleted-accounts list` shows each one with who deleted it, `expiresAt` (restore works until then) and what comes back: `personCount`, `opportunityCount` and `touchCount`. `accounts restore <id>` brings the account back with its domains, its people, its deals and its planned touches, which wait for approval again. A domain another account took since stays with that account and is listed in `domainsTaken`. A merged account is not listed and cannot be restored: a merge has no undo. Both commands are behind the `crm_import_export` feature flag (`404` while it is off).\n\n## Export accounts, people or deals\n\n```bash\nkenso export accounts --out accounts.csv\nkenso export accounts --view 12 --out tier-1.csv\nkenso export deals --filters \'[{"field":"stageCategory","operator":"is","values":["open"]}]\' > open-deals.csv\n```\n\nIt writes the CSV that `POST /v1/accounts/export`, `/v1/people/export` or `/v1/opportunities/export` returns, to stdout or to `--out` (then it prints the file and its row count). With no filter it exports every record. More than 50,000 rows is refused: narrow the filters. `--view <id>` exports a saved Accounts view (`kenso account-views list` shows the ids). `--filters`, `--where` (accounts), `--q` and `--sort` are the search operation\'s own fields, so a deals or people view exports with its filters and sort. The accounts and deals files start with `id` and import back as they are. Each export writes an audit-log entry and needs the export permission. Accounts and deals also need the `crm_import_export` flag while it is in beta.\n\n## A deal\'s stage history\n\n```bash\nkenso opportunities stage-history 77\nkenso opportunities stage-history 77 --query "entries[].{to: stageLabel, at: enteredAt, by: changedBy}"\n```\n\nIt prints `GET /v1/opportunities/{id}/stage-history` as it is, the same rows as the deal page and the MCP\'s `opportunities(operation="get-stage-history")`: the stage now, `isComplete` and `entries`, oldest first, each with `fromStage`, `stage`, `stageLabel`, `enteredAt`, `leftAt`, `durationSeconds`, `actorKind`, `actorMemberId` and Ken\'s `reason` on a move its stage judge made. With the `deal_stage_rules` flag on, each entry also has `changedBy` (`member`, `agent`, `api_key`, `workflow`, `stage_judge`, `crm_sync` or `ken_automation`), `crmProvider` on a CRM sync, and on a move `fromStageLabel` and `fromStageDurationSeconds`, how long the deal sat in the stage it left. `isComplete` false means Kenso has no record of part of the history.\n\n## Notes on accounts, people and deals\n\nWith the `record_notes` feature on, everyone who can see a record reads its notes. Name the record with exactly one of `--account`, `--person` and `--deal`:\n\n```bash\nkenso notes list --account 5\nkenso notes add --account 5 --body \'Budget approved, @[Jane Doe](41) please send the DPA\'\nkenso notes add --parent 900 --body \'Sent it this morning\' # a comment under note 900\ncat call-notes.md | kenso notes add --deal 77 --body - # the body from stdin\nkenso notes edit 900 --body \'Budget approved for Q1\' # the author only\nkenso notes edit 900 --pin\nkenso notes delete 900 --yes # kenso notes restore 900 brings it back\n```\n\nThe body is markdown, up to 20,000 characters. Mention a teammate as `@[Name](memberId)`: they get a notification that opens the note. A note shows on the record\'s Notes tab and its Activity timeline, and Ken\'s account brief quotes the account\'s notes. The MCP\'s `notes` tool does the same. A note on an account needs the accounts plan feature; people and deals work on every plan.\n\n## Required fields per stage\n\n```bash\nkenso pipelines stage-rules\nkenso pipelines stage-rules proposal --require amount,closeDate,custom.tier\nkenso pipelines stage-rules proposal --none\nkenso pipelines stage-rules lost --default\n```\n\nWith the `deal_stage_rules` flag on, each stage can name the fields a deal should have in it. Without a stage the command prints every stage\'s `key`, `label`, `category`, `isArchived`, `requiredFields` and `isDefault`, plus `requirableFields`: `amount`, `closeDate`, `ownerMemberId`, `primaryPersonId`, `nextStep`, `lostReasonKey`, `wonReasonKey` and `custom.<key>` for each custom deal field. `--require` sets the stage\'s whole list, in order, at most 10. `--none` requires nothing, and `--default` goes back to the default: a lost stage asks for `lostReasonKey`, any other stage nothing. Setting a rule needs the `workspace_settings` permission. The same as the MCP\'s `opportunities(operation="stages-set-required-fields")`.\n\nA missing field never stops a move. The deal moves, and it is flagged Missing on the board, the list and the deal page until the field is filled. A rule also applies to deals already in the stage.\n\n```bash\nkenso opportunities update --opportunity-id 4401 --stage proposal\nkenso opportunities list --missing-fields\n```\n\nEvery deal then carries `missingFields` (`[{field, label}]`). A create, or an update that sends a stage, answers `warnings` beside the deal for each field the stage asks for that the deal leaves empty: each prints on stderr as `warning: <message>`, stdout stays the deal and the exit code stays 0. `--missing-fields` keeps only the deals flagged Missing (also `missingFields: true` on `kenso opportunities search`).\n\n## Won and lost reasons\n\n```bash\nkenso opportunity-reasons get\nkenso opportunity-reasons replace --kind lost --data \'{"reasons":[{"key":"no_budget","label":"No budget"},{"label":"Built it in-house"}]}\'\nkenso opportunities move 4401 --stage lost --reason built_it_in_house\n```\n\n`kenso opportunities move <id> --stage <key> [--reason <key>]` sends the reason as `lostReasonKey` for a lost stage or `wonReasonKey` for a won stage; an open stage takes none. Each field the new stage asks for that the deal leaves empty prints a warning on stderr, and the move still goes through.\n\nWith the `deal_stage_rules` flag on, each workspace edits why its deals are lost and won. `get` prints `lost` and `won`, each `{isDefault, reasons: [{key, label, isArchived}]}`. `replace` takes a kind\'s whole list in order, as `get` prints it: keep a reason by its `key`, leave `key` out for a new one, and set `isArchived` to archive a reason or bring one back. A reason left out is archived too: deals keep it, and no write can pick it again. At least one reason stays live and at most 30, and labels stay unique, archived ones included. A deal takes a live key in `lostReasonKey` (a lost stage) or `wonReasonKey` (a won stage). A move to Lost without a reason still goes through, with a warning and "Missing: Lost reason" on the deal. Editing the lists needs the `workspace_settings` permission. The same as the MCP\'s `pipelines(operation="reasons-get")` and `reasons-replace`.\n\n## Tasks\n\nTasks are to-dos a member owes: a title, an optional due day or time, an assignee and at most one account, person or deal. They need the `tasks` flag. The app calls deals "Deals"; the CLI keeps `--deal` for an opportunity id.\n\n```bash\nkenso tasks add "Send the deck" --due tomorrow --account 812\nkenso tasks add "Call Ada back" --due friday --at 16:00 --person 501 --assignee ada@acme.com\nkenso tasks list --assignee me --due overdue,today\nkenso tasks queue --scope mine\nkenso tasks assign 7 me\nkenso tasks done 7 8 9\nkenso tasks done 7 --undo\n```\n\n- `tasks add` sends `POST /v1/tasks`. `--due` takes `today`, `tomorrow`, a weekday (the next one: `friday` or `fri`), a day (`2026-11-20`) or an ISO 8601 time; `--at HH:MM` puts a time on that day (today without `--due`). Day words and `--at` read this computer\'s clock and time zone (`TZ`); a time\'s day is read in the assignee\'s app time zone. `--assignee` takes `me`, a member id or an email; without it the task is yours.\n- `tasks done` completes each task it names, in order (`PATCH /v1/tasks/{id}` with `status: done`); `--undo` reopens them. `tasks assign` gives a task to `me`, a member id or a member\'s email; that member gets a `task_assigned` notification.\n- `tasks queue` is `task-queue list` under the name you would try: the Tasks screen\'s open work by due day, with `--scope mine|assigned_by_me|everyone`. It lists tasks, manual touches, call tasks, inbox threads with a reminder due (when you can view the Inbox) and Ken\'s follow-ups to you, each with the app path in `href` (null for a task, which opens in its panel).\n- `tasks list`, `get`, `update`, `delete`, `restore` and `task-queue list` are generated from the API: `kenso tasks --help` lists them.\n';
|
|
7795
8257
|
}
|
|
7796
8258
|
});
|
|
7797
8259
|
|
|
@@ -7942,7 +8404,7 @@ var init_content = __esm({
|
|
|
7942
8404
|
});
|
|
7943
8405
|
|
|
7944
8406
|
// src/commands/mcp/client.ts
|
|
7945
|
-
function
|
|
8407
|
+
function isRecord5(value) {
|
|
7946
8408
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7947
8409
|
}
|
|
7948
8410
|
function parseJson(text4) {
|
|
@@ -7958,10 +8420,10 @@ function eventData(event) {
|
|
|
7958
8420
|
return lines.map((line) => line.slice(5).replace(/^ /, "")).join("\n");
|
|
7959
8421
|
}
|
|
7960
8422
|
function asMessages(value) {
|
|
7961
|
-
if (Array.isArray(value)) return value.filter(
|
|
7962
|
-
return
|
|
8423
|
+
if (Array.isArray(value)) return value.filter(isRecord5);
|
|
8424
|
+
return isRecord5(value) ? [value] : [];
|
|
7963
8425
|
}
|
|
7964
|
-
function
|
|
8426
|
+
function interrupted3() {
|
|
7965
8427
|
return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
7966
8428
|
}
|
|
7967
8429
|
var DEFAULT_MCP_URL, MCP_PROTOCOL_VERSION, REQUEST_TIMEOUT_MS2, McpClient;
|
|
@@ -7993,7 +8455,7 @@ var init_client = __esm({
|
|
|
7993
8455
|
capabilities: {},
|
|
7994
8456
|
clientInfo: { name: "kenso-cli", version: this.opts.version }
|
|
7995
8457
|
});
|
|
7996
|
-
const negotiated =
|
|
8458
|
+
const negotiated = isRecord5(result) && typeof result.protocolVersion === "string" ? result.protocolVersion : MCP_PROTOCOL_VERSION;
|
|
7997
8459
|
this.protocolVersion = negotiated;
|
|
7998
8460
|
await this.notify("notifications/initialized");
|
|
7999
8461
|
this.initialized = true;
|
|
@@ -8006,9 +8468,9 @@ var init_client = __esm({
|
|
|
8006
8468
|
let cursor2;
|
|
8007
8469
|
for (; ; ) {
|
|
8008
8470
|
const result = await this.rpc("tools/list", cursor2 === void 0 ? {} : { cursor: cursor2 });
|
|
8009
|
-
const page =
|
|
8010
|
-
for (const tool of page) if (
|
|
8011
|
-
const next =
|
|
8471
|
+
const page = isRecord5(result) && Array.isArray(result.tools) ? result.tools : [];
|
|
8472
|
+
for (const tool of page) if (isRecord5(tool) && typeof tool.name === "string") tools.push(tool);
|
|
8473
|
+
const next = isRecord5(result) ? result.nextCursor : void 0;
|
|
8012
8474
|
if (typeof next !== "string" || next === "" || seen.has(next)) return tools;
|
|
8013
8475
|
seen.add(next);
|
|
8014
8476
|
cursor2 = next;
|
|
@@ -8017,7 +8479,7 @@ var init_client = __esm({
|
|
|
8017
8479
|
async callTool(name, args) {
|
|
8018
8480
|
await this.initialize();
|
|
8019
8481
|
const result = await this.rpc("tools/call", { name, arguments: args });
|
|
8020
|
-
return
|
|
8482
|
+
return isRecord5(result) ? result : {};
|
|
8021
8483
|
}
|
|
8022
8484
|
headers() {
|
|
8023
8485
|
const { agent, apiKey, version, workspaceId } = this.opts;
|
|
@@ -8035,7 +8497,7 @@ var init_client = __esm({
|
|
|
8035
8497
|
}
|
|
8036
8498
|
async post(method, message) {
|
|
8037
8499
|
const callerSignal = this.opts.signal;
|
|
8038
|
-
if (callerSignal?.aborted) throw
|
|
8500
|
+
if (callerSignal?.aborted) throw interrupted3();
|
|
8039
8501
|
const timeout = AbortSignal.timeout(REQUEST_TIMEOUT_MS2);
|
|
8040
8502
|
const signal = callerSignal ? AbortSignal.any([callerSignal, timeout]) : timeout;
|
|
8041
8503
|
const started = Date.now();
|
|
@@ -8044,7 +8506,7 @@ var init_client = __esm({
|
|
|
8044
8506
|
this.opts.onResponse?.({ method, status: res.status, ms: Date.now() - started });
|
|
8045
8507
|
return res;
|
|
8046
8508
|
} catch (err) {
|
|
8047
|
-
if (callerSignal?.aborted) throw
|
|
8509
|
+
if (callerSignal?.aborted) throw interrupted3();
|
|
8048
8510
|
const reason = err instanceof Error ? err.name === "TimeoutError" ? `no answer within ${REQUEST_TIMEOUT_MS2 / 1e3} s` : err.message : String(err);
|
|
8049
8511
|
this.opts.onResponse?.({ method, ms: Date.now() - started, error: reason });
|
|
8050
8512
|
throw new KensoError({
|
|
@@ -8111,7 +8573,7 @@ var init_client = __esm({
|
|
|
8111
8573
|
if (done2) return buffer.trim() === "" ? void 0 : take(buffer);
|
|
8112
8574
|
}
|
|
8113
8575
|
} catch (err) {
|
|
8114
|
-
if (this.opts.signal?.aborted) throw
|
|
8576
|
+
if (this.opts.signal?.aborted) throw interrupted3();
|
|
8115
8577
|
throw err;
|
|
8116
8578
|
} finally {
|
|
8117
8579
|
reader.cancel().catch(() => {
|
|
@@ -8176,7 +8638,7 @@ __export(install_exports, {
|
|
|
8176
8638
|
write: () => write
|
|
8177
8639
|
});
|
|
8178
8640
|
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
8179
|
-
import { basename as basename2, dirname, join as join8, resolve as
|
|
8641
|
+
import { basename as basename2, dirname, join as join8, resolve as resolve6 } from "node:path";
|
|
8180
8642
|
function quote(value) {
|
|
8181
8643
|
return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
8182
8644
|
}
|
|
@@ -8201,7 +8663,7 @@ function write(path, text4) {
|
|
|
8201
8663
|
}
|
|
8202
8664
|
}
|
|
8203
8665
|
function folders(ctx, client, dir) {
|
|
8204
|
-
if (dir !== void 0) return [{ client, folder:
|
|
8666
|
+
if (dir !== void 0) return [{ client, folder: resolve6(dir) }];
|
|
8205
8667
|
const clients = client === "all" ? CLIENTS : [client];
|
|
8206
8668
|
return clients.map((c) => ({ client: c, folder: join8(skillsFolder(c, ctx.env), SKILL_NAME) }));
|
|
8207
8669
|
}
|
|
@@ -8212,7 +8674,7 @@ function installCommand(opts) {
|
|
|
8212
8674
|
if (opts.force) parts2.push("--force");
|
|
8213
8675
|
return parts2.join(" ");
|
|
8214
8676
|
}
|
|
8215
|
-
var SKILL_NAME, AGENT_CLIENTS2,
|
|
8677
|
+
var SKILL_NAME, AGENT_CLIENTS2, command3, install_default;
|
|
8216
8678
|
var init_install = __esm({
|
|
8217
8679
|
"src/commands/skill/install.ts"() {
|
|
8218
8680
|
"use strict";
|
|
@@ -8222,7 +8684,7 @@ var init_install = __esm({
|
|
|
8222
8684
|
init_clients();
|
|
8223
8685
|
SKILL_NAME = "kenso-cli";
|
|
8224
8686
|
AGENT_CLIENTS2 = { "Claude Code": "claude-code", Codex: "codex", Cursor: "cursor" };
|
|
8225
|
-
|
|
8687
|
+
command3 = {
|
|
8226
8688
|
resource: "skill",
|
|
8227
8689
|
action: "install",
|
|
8228
8690
|
summary: "Install the kenso-cli skill for Claude Code, Codex, Cursor, Gemini CLI or OpenCode",
|
|
@@ -8269,14 +8731,14 @@ var init_install = __esm({
|
|
|
8269
8731
|
for (const target2 of targets) {
|
|
8270
8732
|
if (target2.status !== "unchanged") write(target2.path, text4);
|
|
8271
8733
|
}
|
|
8272
|
-
if (dir !== void 0 && basename2(
|
|
8273
|
-
ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${
|
|
8734
|
+
if (dir !== void 0 && basename2(resolve6(dir)) !== SKILL_NAME) {
|
|
8735
|
+
ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve6(dir)} is not.`);
|
|
8274
8736
|
}
|
|
8275
8737
|
ctx.output.object({ installed: targets });
|
|
8276
8738
|
return ExitCode.Ok;
|
|
8277
8739
|
}
|
|
8278
8740
|
};
|
|
8279
|
-
install_default =
|
|
8741
|
+
install_default = command3;
|
|
8280
8742
|
}
|
|
8281
8743
|
});
|
|
8282
8744
|
|
|
@@ -8511,7 +8973,7 @@ function pickClients(ctx, clientFlag, status) {
|
|
|
8511
8973
|
next: "kenso agent setup --client claude-code"
|
|
8512
8974
|
});
|
|
8513
8975
|
}
|
|
8514
|
-
var
|
|
8976
|
+
var command4, setup_default;
|
|
8515
8977
|
var init_setup = __esm({
|
|
8516
8978
|
"src/commands/agent/setup.ts"() {
|
|
8517
8979
|
"use strict";
|
|
@@ -8522,7 +8984,7 @@ var init_setup = __esm({
|
|
|
8522
8984
|
init_clients();
|
|
8523
8985
|
init_install();
|
|
8524
8986
|
init_mcp_config();
|
|
8525
|
-
|
|
8987
|
+
command4 = {
|
|
8526
8988
|
resource: "agent",
|
|
8527
8989
|
action: "setup",
|
|
8528
8990
|
summary: "Set up a coding agent for Kenso: the kenso-cli skill and the Kenso MCP server",
|
|
@@ -8594,7 +9056,7 @@ var init_setup = __esm({
|
|
|
8594
9056
|
return ok ? ExitCode.Ok : ExitCode.Error;
|
|
8595
9057
|
}
|
|
8596
9058
|
};
|
|
8597
|
-
setup_default =
|
|
9059
|
+
setup_default = command4;
|
|
8598
9060
|
}
|
|
8599
9061
|
});
|
|
8600
9062
|
|
|
@@ -8650,7 +9112,7 @@ function multipartBody(files, data) {
|
|
|
8650
9112
|
}
|
|
8651
9113
|
return form;
|
|
8652
9114
|
}
|
|
8653
|
-
var METHODS, DEFAULT_FILE_FIELD,
|
|
9115
|
+
var METHODS, DEFAULT_FILE_FIELD, command5, actions3;
|
|
8654
9116
|
var init_api3 = __esm({
|
|
8655
9117
|
"src/commands/api/index.ts"() {
|
|
8656
9118
|
"use strict";
|
|
@@ -8661,7 +9123,7 @@ var init_api3 = __esm({
|
|
|
8661
9123
|
init_transfer();
|
|
8662
9124
|
METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
8663
9125
|
DEFAULT_FILE_FIELD = "file";
|
|
8664
|
-
|
|
9126
|
+
command5 = {
|
|
8665
9127
|
resource: "api",
|
|
8666
9128
|
action: "",
|
|
8667
9129
|
summary: "Call any API route, only when no command fits",
|
|
@@ -8734,7 +9196,7 @@ var init_api3 = __esm({
|
|
|
8734
9196
|
}
|
|
8735
9197
|
};
|
|
8736
9198
|
actions3 = {
|
|
8737
|
-
"": async () =>
|
|
9199
|
+
"": async () => command5
|
|
8738
9200
|
};
|
|
8739
9201
|
}
|
|
8740
9202
|
});
|
|
@@ -8786,8 +9248,8 @@ var init_browser = __esm({
|
|
|
8786
9248
|
// src/commands/auth/browser-login.ts
|
|
8787
9249
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
8788
9250
|
import { hostname as osHostname } from "node:os";
|
|
8789
|
-
import { setTimeout as
|
|
8790
|
-
function
|
|
9251
|
+
import { setTimeout as delay4 } from "node:timers/promises";
|
|
9252
|
+
function interrupted4() {
|
|
8791
9253
|
return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
8792
9254
|
}
|
|
8793
9255
|
function expired() {
|
|
@@ -8842,14 +9304,14 @@ function parsePickedUp(body2, status) {
|
|
|
8842
9304
|
};
|
|
8843
9305
|
}
|
|
8844
9306
|
async function wait(ms, ctx, deps) {
|
|
8845
|
-
if (ctx.signal.aborted) throw
|
|
9307
|
+
if (ctx.signal.aborted) throw interrupted4();
|
|
8846
9308
|
try {
|
|
8847
9309
|
await deps.sleep(ms, ctx.signal);
|
|
8848
9310
|
} catch (err) {
|
|
8849
|
-
if (ctx.signal.aborted) throw
|
|
9311
|
+
if (ctx.signal.aborted) throw interrupted4();
|
|
8850
9312
|
throw err;
|
|
8851
9313
|
}
|
|
8852
|
-
if (ctx.signal.aborted) throw
|
|
9314
|
+
if (ctx.signal.aborted) throw interrupted4();
|
|
8853
9315
|
}
|
|
8854
9316
|
async function browserLogin(ctx, opts, overrides) {
|
|
8855
9317
|
const deps = { ...defaultDeps, ...overrides };
|
|
@@ -8981,7 +9443,7 @@ var init_browser_login = __esm({
|
|
|
8981
9443
|
RETRY_LOGIN = "kenso auth login";
|
|
8982
9444
|
WITH_KEY = "kenso auth login --with-key";
|
|
8983
9445
|
defaultDeps = {
|
|
8984
|
-
sleep: (ms, signal) =>
|
|
9446
|
+
sleep: (ms, signal) => delay4(ms, void 0, signal ? { signal } : void 0),
|
|
8985
9447
|
now: () => Date.now(),
|
|
8986
9448
|
spawn: (command65, args) => {
|
|
8987
9449
|
const child = nodeSpawn(command65, args, { detached: true, stdio: "ignore" });
|
|
@@ -9033,7 +9495,7 @@ function invalidKey(message) {
|
|
|
9033
9495
|
next: PIPE_EXAMPLE
|
|
9034
9496
|
});
|
|
9035
9497
|
}
|
|
9036
|
-
var MAX_KEY_INPUT_BYTES, PIPE_EXAMPLE,
|
|
9498
|
+
var MAX_KEY_INPUT_BYTES, PIPE_EXAMPLE, command6, login_default;
|
|
9037
9499
|
var init_login = __esm({
|
|
9038
9500
|
"src/commands/auth/login.ts"() {
|
|
9039
9501
|
"use strict";
|
|
@@ -9046,7 +9508,7 @@ var init_login = __esm({
|
|
|
9046
9508
|
init_browser_login();
|
|
9047
9509
|
MAX_KEY_INPUT_BYTES = 4096;
|
|
9048
9510
|
PIPE_EXAMPLE = `printf '%s' "$KENSO_API_KEY" | kenso auth login --with-key`;
|
|
9049
|
-
|
|
9511
|
+
command6 = {
|
|
9050
9512
|
resource: "auth",
|
|
9051
9513
|
action: "login",
|
|
9052
9514
|
summary: "Log in through the browser, or save an API key from stdin with --with-key",
|
|
@@ -9148,7 +9610,7 @@ var init_login = __esm({
|
|
|
9148
9610
|
return ExitCode.Ok;
|
|
9149
9611
|
}
|
|
9150
9612
|
};
|
|
9151
|
-
login_default =
|
|
9613
|
+
login_default = command6;
|
|
9152
9614
|
}
|
|
9153
9615
|
});
|
|
9154
9616
|
|
|
@@ -9182,7 +9644,7 @@ async function revoke(ctx, apiKey, keyId, savedWorkspaceId) {
|
|
|
9182
9644
|
return false;
|
|
9183
9645
|
}
|
|
9184
9646
|
}
|
|
9185
|
-
var
|
|
9647
|
+
var command7, logout_default;
|
|
9186
9648
|
var init_logout = __esm({
|
|
9187
9649
|
"src/commands/auth/logout.ts"() {
|
|
9188
9650
|
"use strict";
|
|
@@ -9190,7 +9652,7 @@ var init_logout = __esm({
|
|
|
9190
9652
|
init_errors();
|
|
9191
9653
|
init_http();
|
|
9192
9654
|
init_exit_codes();
|
|
9193
|
-
|
|
9655
|
+
command7 = {
|
|
9194
9656
|
resource: "auth",
|
|
9195
9657
|
action: "logout",
|
|
9196
9658
|
summary: "Remove a saved profile, and revoke the key browser login made",
|
|
@@ -9212,7 +9674,7 @@ var init_logout = __esm({
|
|
|
9212
9674
|
return ExitCode.Ok;
|
|
9213
9675
|
}
|
|
9214
9676
|
};
|
|
9215
|
-
logout_default =
|
|
9677
|
+
logout_default = command7;
|
|
9216
9678
|
}
|
|
9217
9679
|
});
|
|
9218
9680
|
|
|
@@ -9221,7 +9683,7 @@ var status_exports = {};
|
|
|
9221
9683
|
__export(status_exports, {
|
|
9222
9684
|
default: () => status_default
|
|
9223
9685
|
});
|
|
9224
|
-
var EXPIRY_WARNING_DAYS, DAY_MS,
|
|
9686
|
+
var EXPIRY_WARNING_DAYS, DAY_MS, command8, status_default;
|
|
9225
9687
|
var init_status = __esm({
|
|
9226
9688
|
"src/commands/auth/status.ts"() {
|
|
9227
9689
|
"use strict";
|
|
@@ -9232,7 +9694,7 @@ var init_status = __esm({
|
|
|
9232
9694
|
init_http();
|
|
9233
9695
|
EXPIRY_WARNING_DAYS = 14;
|
|
9234
9696
|
DAY_MS = 24 * 60 * 60 * 1e3;
|
|
9235
|
-
|
|
9697
|
+
command8 = {
|
|
9236
9698
|
resource: "auth",
|
|
9237
9699
|
action: "status",
|
|
9238
9700
|
summary: "Show the key's user, workspace and expiry",
|
|
@@ -9309,7 +9771,7 @@ var init_status = __esm({
|
|
|
9309
9771
|
return ExitCode.Ok;
|
|
9310
9772
|
}
|
|
9311
9773
|
};
|
|
9312
|
-
status_default =
|
|
9774
|
+
status_default = command8;
|
|
9313
9775
|
}
|
|
9314
9776
|
});
|
|
9315
9777
|
|
|
@@ -9331,13 +9793,13 @@ var status_exports2 = {};
|
|
|
9331
9793
|
__export(status_exports2, {
|
|
9332
9794
|
default: () => status_default2
|
|
9333
9795
|
});
|
|
9334
|
-
var
|
|
9796
|
+
var command9, status_default2;
|
|
9335
9797
|
var init_status2 = __esm({
|
|
9336
9798
|
"src/commands/capture/status.ts"() {
|
|
9337
9799
|
"use strict";
|
|
9338
9800
|
init_exit_codes();
|
|
9339
9801
|
init_http();
|
|
9340
|
-
|
|
9802
|
+
command9 = {
|
|
9341
9803
|
resource: "capture",
|
|
9342
9804
|
action: "status",
|
|
9343
9805
|
summary: "Show your captured mailbox, its backfill progress and what teammates see of a captured email",
|
|
@@ -9352,7 +9814,7 @@ var init_status2 = __esm({
|
|
|
9352
9814
|
return ExitCode.Ok;
|
|
9353
9815
|
}
|
|
9354
9816
|
};
|
|
9355
|
-
status_default2 =
|
|
9817
|
+
status_default2 = command9;
|
|
9356
9818
|
}
|
|
9357
9819
|
});
|
|
9358
9820
|
|
|
@@ -9361,7 +9823,7 @@ var connect_exports = {};
|
|
|
9361
9823
|
__export(connect_exports, {
|
|
9362
9824
|
default: () => connect_default2
|
|
9363
9825
|
});
|
|
9364
|
-
var PROVIDERS,
|
|
9826
|
+
var PROVIDERS, command10, connect_default2;
|
|
9365
9827
|
var init_connect2 = __esm({
|
|
9366
9828
|
"src/commands/capture/connect.ts"() {
|
|
9367
9829
|
"use strict";
|
|
@@ -9369,7 +9831,7 @@ var init_connect2 = __esm({
|
|
|
9369
9831
|
init_exit_codes();
|
|
9370
9832
|
init_http();
|
|
9371
9833
|
PROVIDERS = ["google", "microsoft"];
|
|
9372
|
-
|
|
9834
|
+
command10 = {
|
|
9373
9835
|
resource: "capture",
|
|
9374
9836
|
action: "connect",
|
|
9375
9837
|
summary: "Turn capture on for your own mailbox",
|
|
@@ -9419,7 +9881,7 @@ var init_connect2 = __esm({
|
|
|
9419
9881
|
}
|
|
9420
9882
|
}
|
|
9421
9883
|
};
|
|
9422
|
-
connect_default2 =
|
|
9884
|
+
connect_default2 = command10;
|
|
9423
9885
|
}
|
|
9424
9886
|
});
|
|
9425
9887
|
|
|
@@ -9435,14 +9897,14 @@ function threadId(value, from = { field: "threadId", example: "kenso capture thr
|
|
|
9435
9897
|
}
|
|
9436
9898
|
return value;
|
|
9437
9899
|
}
|
|
9438
|
-
var
|
|
9900
|
+
var command11, thread_default;
|
|
9439
9901
|
var init_thread = __esm({
|
|
9440
9902
|
"src/commands/capture/thread.ts"() {
|
|
9441
9903
|
"use strict";
|
|
9442
9904
|
init_errors();
|
|
9443
9905
|
init_exit_codes();
|
|
9444
9906
|
init_http();
|
|
9445
|
-
|
|
9907
|
+
command11 = {
|
|
9446
9908
|
resource: "capture",
|
|
9447
9909
|
action: "thread",
|
|
9448
9910
|
summary: "Read one captured email thread",
|
|
@@ -9458,7 +9920,7 @@ var init_thread = __esm({
|
|
|
9458
9920
|
return ExitCode.Ok;
|
|
9459
9921
|
}
|
|
9460
9922
|
};
|
|
9461
|
-
thread_default =
|
|
9923
|
+
thread_default = command11;
|
|
9462
9924
|
}
|
|
9463
9925
|
});
|
|
9464
9926
|
|
|
@@ -9467,7 +9929,7 @@ var private_exports = {};
|
|
|
9467
9929
|
__export(private_exports, {
|
|
9468
9930
|
default: () => private_default
|
|
9469
9931
|
});
|
|
9470
|
-
var THREAD_FLAG,
|
|
9932
|
+
var THREAD_FLAG, command12, private_default;
|
|
9471
9933
|
var init_private = __esm({
|
|
9472
9934
|
"src/commands/capture/private.ts"() {
|
|
9473
9935
|
"use strict";
|
|
@@ -9476,7 +9938,7 @@ var init_private = __esm({
|
|
|
9476
9938
|
init_http();
|
|
9477
9939
|
init_thread();
|
|
9478
9940
|
THREAD_FLAG = { field: "thread", example: "kenso capture private on --thread 4821" };
|
|
9479
|
-
|
|
9941
|
+
command12 = {
|
|
9480
9942
|
resource: "capture",
|
|
9481
9943
|
action: "private",
|
|
9482
9944
|
summary: "Hide your captured email from teammates, or show it again",
|
|
@@ -9501,7 +9963,7 @@ var init_private = __esm({
|
|
|
9501
9963
|
return ExitCode.Ok;
|
|
9502
9964
|
}
|
|
9503
9965
|
};
|
|
9504
|
-
private_default =
|
|
9966
|
+
private_default = command12;
|
|
9505
9967
|
}
|
|
9506
9968
|
});
|
|
9507
9969
|
|
|
@@ -9510,13 +9972,13 @@ var sync_exports = {};
|
|
|
9510
9972
|
__export(sync_exports, {
|
|
9511
9973
|
default: () => sync_default
|
|
9512
9974
|
});
|
|
9513
|
-
var
|
|
9975
|
+
var command13, sync_default;
|
|
9514
9976
|
var init_sync3 = __esm({
|
|
9515
9977
|
"src/commands/capture/sync.ts"() {
|
|
9516
9978
|
"use strict";
|
|
9517
9979
|
init_exit_codes();
|
|
9518
9980
|
init_http();
|
|
9519
|
-
|
|
9981
|
+
command13 = {
|
|
9520
9982
|
resource: "capture",
|
|
9521
9983
|
action: "sync",
|
|
9522
9984
|
summary: "Read your captured mailbox now",
|
|
@@ -9531,7 +9993,7 @@ var init_sync3 = __esm({
|
|
|
9531
9993
|
return ExitCode.Ok;
|
|
9532
9994
|
}
|
|
9533
9995
|
};
|
|
9534
|
-
sync_default =
|
|
9996
|
+
sync_default = command13;
|
|
9535
9997
|
}
|
|
9536
9998
|
});
|
|
9537
9999
|
|
|
@@ -9540,13 +10002,13 @@ var disconnect_exports = {};
|
|
|
9540
10002
|
__export(disconnect_exports, {
|
|
9541
10003
|
default: () => disconnect_default
|
|
9542
10004
|
});
|
|
9543
|
-
var
|
|
10005
|
+
var command14, disconnect_default;
|
|
9544
10006
|
var init_disconnect = __esm({
|
|
9545
10007
|
"src/commands/capture/disconnect.ts"() {
|
|
9546
10008
|
"use strict";
|
|
9547
10009
|
init_confirm();
|
|
9548
10010
|
init_exit_codes();
|
|
9549
|
-
|
|
10011
|
+
command14 = {
|
|
9550
10012
|
resource: "capture",
|
|
9551
10013
|
action: "disconnect",
|
|
9552
10014
|
summary: "Turn capture off for your own mailbox and delete its stored email bodies",
|
|
@@ -9562,7 +10024,7 @@ var init_disconnect = __esm({
|
|
|
9562
10024
|
return ExitCode.Ok;
|
|
9563
10025
|
}
|
|
9564
10026
|
};
|
|
9565
|
-
disconnect_default =
|
|
10027
|
+
disconnect_default = command14;
|
|
9566
10028
|
}
|
|
9567
10029
|
});
|
|
9568
10030
|
|
|
@@ -9571,7 +10033,7 @@ var teammates_see_exports = {};
|
|
|
9571
10033
|
__export(teammates_see_exports, {
|
|
9572
10034
|
default: () => teammates_see_default
|
|
9573
10035
|
});
|
|
9574
|
-
var VALUES,
|
|
10036
|
+
var VALUES, command15, teammates_see_default;
|
|
9575
10037
|
var init_teammates_see = __esm({
|
|
9576
10038
|
"src/commands/capture/teammates-see.ts"() {
|
|
9577
10039
|
"use strict";
|
|
@@ -9579,7 +10041,7 @@ var init_teammates_see = __esm({
|
|
|
9579
10041
|
init_exit_codes();
|
|
9580
10042
|
init_http();
|
|
9581
10043
|
VALUES = ["summary", "full_email"];
|
|
9582
|
-
|
|
10044
|
+
command15 = {
|
|
9583
10045
|
resource: "capture",
|
|
9584
10046
|
action: "teammates-see",
|
|
9585
10047
|
summary: "Pick what teammates see of captured email: the summary, or the full email (workspace admin)",
|
|
@@ -9599,7 +10061,7 @@ var init_teammates_see = __esm({
|
|
|
9599
10061
|
return ExitCode.Ok;
|
|
9600
10062
|
}
|
|
9601
10063
|
};
|
|
9602
|
-
teammates_see_default =
|
|
10064
|
+
teammates_see_default = command15;
|
|
9603
10065
|
}
|
|
9604
10066
|
});
|
|
9605
10067
|
|
|
@@ -9626,7 +10088,7 @@ __export(completion_exports, {
|
|
|
9626
10088
|
SCRIPTS: () => SCRIPTS,
|
|
9627
10089
|
default: () => completion_default
|
|
9628
10090
|
});
|
|
9629
|
-
var ZSH, BASH, FISH, SCRIPTS,
|
|
10091
|
+
var ZSH, BASH, FISH, SCRIPTS, command16, completion_default;
|
|
9630
10092
|
var init_completion = __esm({
|
|
9631
10093
|
"src/commands/completion/completion.ts"() {
|
|
9632
10094
|
"use strict";
|
|
@@ -9690,7 +10152,7 @@ end
|
|
|
9690
10152
|
complete -c kenso -f -a '(__kenso_complete)'
|
|
9691
10153
|
`;
|
|
9692
10154
|
SCRIPTS = { bash: BASH, zsh: ZSH, fish: FISH };
|
|
9693
|
-
|
|
10155
|
+
command16 = {
|
|
9694
10156
|
resource: "completion",
|
|
9695
10157
|
action: "",
|
|
9696
10158
|
summary: "Print the tab-completion script for bash, zsh or fish",
|
|
@@ -9718,7 +10180,7 @@ complete -c kenso -f -a '(__kenso_complete)'
|
|
|
9718
10180
|
return ExitCode.Ok;
|
|
9719
10181
|
}
|
|
9720
10182
|
};
|
|
9721
|
-
completion_default =
|
|
10183
|
+
completion_default = command16;
|
|
9722
10184
|
}
|
|
9723
10185
|
});
|
|
9724
10186
|
|
|
@@ -10024,11 +10486,11 @@ __export(run_exports, {
|
|
|
10024
10486
|
runConnect: () => runConnect
|
|
10025
10487
|
});
|
|
10026
10488
|
import { spawn as nodeSpawn2 } from "node:child_process";
|
|
10027
|
-
import { setTimeout as
|
|
10028
|
-
function
|
|
10489
|
+
import { setTimeout as delay5 } from "node:timers/promises";
|
|
10490
|
+
function interrupted5() {
|
|
10029
10491
|
return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
10030
10492
|
}
|
|
10031
|
-
function
|
|
10493
|
+
function isRecord6(value) {
|
|
10032
10494
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10033
10495
|
}
|
|
10034
10496
|
function keyText(value) {
|
|
@@ -10065,12 +10527,12 @@ async function read(ctx, kind, flags, rowId) {
|
|
|
10065
10527
|
if (rowId !== void 0) {
|
|
10066
10528
|
const res = await ctx.client.request({ method: "GET", path: kind.watch.path.replace("{id}", encodeURIComponent(rowId)), signal: ctx.signal });
|
|
10067
10529
|
const row = unwrap(res.body);
|
|
10068
|
-
return
|
|
10530
|
+
return isRecord6(row) ? [row] : [];
|
|
10069
10531
|
}
|
|
10070
10532
|
const items = [];
|
|
10071
10533
|
const page = kind.watch.pageSize !== void 0 ? { pageSize: kind.watch.pageSize } : void 0;
|
|
10072
10534
|
for await (const item of ctx.client.paginate({ method: "GET", path: kind.watch.path, signal: ctx.signal }, page)) {
|
|
10073
|
-
if (
|
|
10535
|
+
if (isRecord6(item) && (!kind.watch.filter || kind.watch.filter(item, flags))) items.push(item);
|
|
10074
10536
|
}
|
|
10075
10537
|
return items;
|
|
10076
10538
|
}
|
|
@@ -10106,14 +10568,14 @@ function transient(err) {
|
|
|
10106
10568
|
return err.code === "network_error" || err.httpStatus !== void 0 && err.httpStatus >= 500;
|
|
10107
10569
|
}
|
|
10108
10570
|
async function wait2(ms, ctx, deps) {
|
|
10109
|
-
if (ctx.signal.aborted) throw
|
|
10571
|
+
if (ctx.signal.aborted) throw interrupted5();
|
|
10110
10572
|
try {
|
|
10111
10573
|
await deps.sleep(ms, ctx.signal);
|
|
10112
10574
|
} catch (err) {
|
|
10113
|
-
if (ctx.signal.aborted) throw
|
|
10575
|
+
if (ctx.signal.aborted) throw interrupted5();
|
|
10114
10576
|
throw err;
|
|
10115
10577
|
}
|
|
10116
|
-
if (ctx.signal.aborted) throw
|
|
10578
|
+
if (ctx.signal.aborted) throw interrupted5();
|
|
10117
10579
|
}
|
|
10118
10580
|
async function watch(ctx, kind, flags, rowId, baseline, limitMs, deps) {
|
|
10119
10581
|
const deadline = deps.now() + limitMs;
|
|
@@ -10135,7 +10597,7 @@ async function watch(ctx, kind, flags, rowId, baseline, limitMs, deps) {
|
|
|
10135
10597
|
});
|
|
10136
10598
|
}
|
|
10137
10599
|
} catch (err) {
|
|
10138
|
-
if (ctx.signal.aborted) throw
|
|
10600
|
+
if (ctx.signal.aborted) throw interrupted5();
|
|
10139
10601
|
if (!transient(err) || ++failures >= MAX_POLL_FAILURES) throw err;
|
|
10140
10602
|
ctx.output.warn(`Checking the connection failed (${err.message}); trying again.`);
|
|
10141
10603
|
}
|
|
@@ -10190,7 +10652,7 @@ async function runConnect(ctx, kind, flags, overrides) {
|
|
|
10190
10652
|
if (start) {
|
|
10191
10653
|
const res = await ctx.client.request({ ...start, signal: ctx.signal });
|
|
10192
10654
|
const data = unwrap(res.body);
|
|
10193
|
-
answer =
|
|
10655
|
+
answer = isRecord6(data) ? data : {};
|
|
10194
10656
|
link = linkOf(answer);
|
|
10195
10657
|
if (!link) {
|
|
10196
10658
|
if (keyText(answer[kind.watch.key]) !== void 0) {
|
|
@@ -10214,166 +10676,69 @@ async function runConnect(ctx, kind, flags, overrides) {
|
|
|
10214
10676
|
baseline = kind.reconnectId?.(flags) === void 0 ? /* @__PURE__ */ new Map([[rowId, { status: "connecting" }]]) : byKey(kind, await read(ctx, kind, flags, rowId), rowId);
|
|
10215
10677
|
if (baseline.size === 0) baseline.set(rowId, { status: "connecting" });
|
|
10216
10678
|
}
|
|
10217
|
-
const connection = await watch(ctx, kind, flags, rowId, baseline, limitMs, deps);
|
|
10218
|
-
ctx.output.object({ connected: true, kind: kind.name, connection });
|
|
10219
|
-
return ExitCode.Ok;
|
|
10220
|
-
}
|
|
10221
|
-
function connectCommand(kind) {
|
|
10222
|
-
return {
|
|
10223
|
-
resource: "connect",
|
|
10224
|
-
action: kind.name,
|
|
10225
|
-
summary: kind.summary,
|
|
10226
|
-
description: `${kind.description}
|
|
10227
|
-
|
|
10228
|
-
The connect finishes in a browser: Kenso refuses to complete a sign-in for an API key or an agent, so the person you work for opens the link. It prints the link on stderr (and opens it at a desktop when no coding agent runs it), checks every ${POLL_INTERVAL_MS / 1e3} s, and prints {connected, kind, connection} on stdout once the connection shows up. --no-wait prints the start answer, link included, and ends.`,
|
|
10229
|
-
flags: { ...kind.flags, ...COMMON_FLAGS },
|
|
10230
|
-
examples: [...kind.examples, `${kind.examples[0] ?? `kenso connect ${kind.name}`} --no-wait`],
|
|
10231
|
-
operationIds: kind.operationIds,
|
|
10232
|
-
dryRun: true,
|
|
10233
|
-
run: (ctx, args) => runConnect(ctx, kind, args.flags)
|
|
10234
|
-
};
|
|
10235
|
-
}
|
|
10236
|
-
var POLL_INTERVAL_MS, DEFAULT_TIMEOUT_SECONDS, MAX_POLL_FAILURES, LINK_FIELDS, defaultDeps2, COMMON_FLAGS;
|
|
10237
|
-
var init_run = __esm({
|
|
10238
|
-
"src/commands/connect/run.ts"() {
|
|
10239
|
-
"use strict";
|
|
10240
|
-
init_browser();
|
|
10241
|
-
init_errors();
|
|
10242
|
-
init_exit_codes();
|
|
10243
|
-
init_http();
|
|
10244
|
-
POLL_INTERVAL_MS = 5e3;
|
|
10245
|
-
DEFAULT_TIMEOUT_SECONDS = 600;
|
|
10246
|
-
MAX_POLL_FAILURES = 5;
|
|
10247
|
-
LINK_FIELDS = ["authorizationUrl", "authorizeUrl", "installUrl", "url"];
|
|
10248
|
-
defaultDeps2 = {
|
|
10249
|
-
sleep: (ms, signal) => delay3(ms, void 0, signal ? { signal } : void 0),
|
|
10250
|
-
now: () => Date.now(),
|
|
10251
|
-
spawn: (command65, args) => {
|
|
10252
|
-
const child = nodeSpawn2(command65, args, { detached: true, stdio: "ignore" });
|
|
10253
|
-
child.on("error", () => {
|
|
10254
|
-
});
|
|
10255
|
-
child.unref();
|
|
10256
|
-
},
|
|
10257
|
-
platform: process.platform
|
|
10258
|
-
};
|
|
10259
|
-
COMMON_FLAGS = {
|
|
10260
|
-
timeout: { type: "string", description: `Seconds to wait for the connection (default ${DEFAULT_TIMEOUT_SECONDS})` },
|
|
10261
|
-
"no-wait": { type: "boolean", description: "Print the link as JSON and end, without waiting for the connection" },
|
|
10262
|
-
"no-browser": { type: "boolean", description: "Print the link only; never open a browser" }
|
|
10263
|
-
};
|
|
10264
|
-
}
|
|
10265
|
-
});
|
|
10266
|
-
|
|
10267
|
-
// src/commands/connect/index.ts
|
|
10268
|
-
var KIND_NAMES, load, actions7;
|
|
10269
|
-
var init_connect3 = __esm({
|
|
10270
|
-
"src/commands/connect/index.ts"() {
|
|
10271
|
-
"use strict";
|
|
10272
|
-
KIND_NAMES = ["inbox", "calendar", "video", "crm", "hubspot-knowledge", "github", "migration", "linkedin", "whatsapp", "facebook", "instagram"];
|
|
10273
|
-
load = (name) => async () => {
|
|
10274
|
-
const [{ KINDS: KINDS2 }, { connectCommand: connectCommand2 }] = await Promise.all([Promise.resolve().then(() => (init_kinds(), kinds_exports)), Promise.resolve().then(() => (init_run(), run_exports))]);
|
|
10275
|
-
const kind = KINDS2.find((k) => k.name === name);
|
|
10276
|
-
if (!kind) throw new Error(`no connect kind ${name}`);
|
|
10277
|
-
return connectCommand2(kind);
|
|
10278
|
-
};
|
|
10279
|
-
actions7 = Object.fromEntries(KIND_NAMES.map((name) => [name, load(name)]));
|
|
10280
|
-
}
|
|
10281
|
-
});
|
|
10282
|
-
|
|
10283
|
-
// src/commands/contacts/common.ts
|
|
10284
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
10285
|
-
import { readFile as readFile6 } from "node:fs/promises";
|
|
10286
|
-
import { resolve as resolve6 } from "node:path";
|
|
10287
|
-
function stringFlag2(flags, name) {
|
|
10288
|
-
const value = flags[name];
|
|
10289
|
-
if (typeof value !== "string") return void 0;
|
|
10290
|
-
const text4 = value.trim();
|
|
10291
|
-
return text4 === "" ? void 0 : text4;
|
|
10292
|
-
}
|
|
10293
|
-
function requireFlag(flags, name, command65, hint) {
|
|
10294
|
-
const value = stringFlag2(flags, name);
|
|
10295
|
-
if (value === void 0) throw usageError(`--${name} is required for ${command65}.`, { field: name, next: `${command65} --help`, ...hint ? { hint } : {} });
|
|
10296
|
-
return value;
|
|
10297
|
-
}
|
|
10298
|
-
function positiveId(value) {
|
|
10299
|
-
const text4 = value.trim();
|
|
10300
|
-
if (!/^[0-9]+$/.test(text4)) return void 0;
|
|
10301
|
-
const id = Number(text4);
|
|
10302
|
-
return Number.isSafeInteger(id) && id > 0 ? id : void 0;
|
|
10303
|
-
}
|
|
10304
|
-
function idFlag(flags, name, command65) {
|
|
10305
|
-
const raw = requireFlag(flags, name, command65);
|
|
10306
|
-
const id = positiveId(raw);
|
|
10307
|
-
if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
|
|
10308
|
-
return id;
|
|
10309
|
-
}
|
|
10310
|
-
function concurrency(flags) {
|
|
10311
|
-
const raw = stringFlag2(flags, "concurrency");
|
|
10312
|
-
if (raw === void 0) return void 0;
|
|
10313
|
-
const value = Number(raw);
|
|
10314
|
-
if (!Number.isInteger(value) || value < 1 || value > 16) {
|
|
10315
|
-
throw usageError(`--concurrency must be a whole number from 1 to 16 (got "${raw}").`, { field: "concurrency" });
|
|
10316
|
-
}
|
|
10317
|
-
return value;
|
|
10318
|
-
}
|
|
10319
|
-
function isDryRun(ctx) {
|
|
10320
|
-
return ctx.flags.yes !== true;
|
|
10321
|
-
}
|
|
10322
|
-
function shellQuote4(value) {
|
|
10323
|
-
return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
10324
|
-
}
|
|
10325
|
-
function sameCommand2(command65, flags, ctx, extra = []) {
|
|
10326
|
-
const parts2 = [command65];
|
|
10327
|
-
for (const [name, value] of Object.entries(flags)) {
|
|
10328
|
-
if (value === void 0 || value === false) continue;
|
|
10329
|
-
if (value === true) parts2.push(`--${name}`);
|
|
10330
|
-
else for (const item of Array.isArray(value) ? value : [value]) parts2.push(`--${name}`, shellQuote4(item));
|
|
10331
|
-
}
|
|
10332
|
-
for (const name of ["profile", "workspace"]) {
|
|
10333
|
-
const value = ctx.flags[name];
|
|
10334
|
-
if (value !== void 0) parts2.push(`--${name}`, shellQuote4(value));
|
|
10335
|
-
}
|
|
10336
|
-
parts2.push(...extra);
|
|
10337
|
-
return parts2.join(" ");
|
|
10338
|
-
}
|
|
10339
|
-
async function fileSha256(path) {
|
|
10340
|
-
return createHash3("sha256").update(await readFile6(resolve6(path))).digest("hex");
|
|
10341
|
-
}
|
|
10342
|
-
function rateLimitRemaining3(headers) {
|
|
10343
|
-
const raw = headers.get("ratelimit-remaining");
|
|
10344
|
-
if (raw === null || raw.trim() === "") return void 0;
|
|
10345
|
-
const value = Number(raw);
|
|
10346
|
-
return Number.isFinite(value) ? value : void 0;
|
|
10347
|
-
}
|
|
10348
|
-
function rethrowIfRunStopping(err) {
|
|
10349
|
-
if (!(err instanceof KensoError)) return;
|
|
10350
|
-
if (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.RateLimited || err.exitCode === ExitCode.Interrupted) throw err;
|
|
10351
|
-
}
|
|
10352
|
-
function failedRow(row, err, extra = {}) {
|
|
10353
|
-
const reason = err instanceof KensoError ? err.code : "failed";
|
|
10354
|
-
const error = err instanceof Error ? err.message : String(err);
|
|
10355
|
-
return { row, status: "failed", reason, error, ...extra };
|
|
10356
|
-
}
|
|
10357
|
-
function invalidRow(row, reason, error, extra = {}) {
|
|
10358
|
-
return { row, status: "invalid", reason, ...error ? { error } : {}, ...extra };
|
|
10359
|
-
}
|
|
10360
|
-
function isRecord6(value) {
|
|
10361
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10679
|
+
const connection = await watch(ctx, kind, flags, rowId, baseline, limitMs, deps);
|
|
10680
|
+
ctx.output.object({ connected: true, kind: kind.name, connection });
|
|
10681
|
+
return ExitCode.Ok;
|
|
10362
10682
|
}
|
|
10363
|
-
function
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10683
|
+
function connectCommand(kind) {
|
|
10684
|
+
return {
|
|
10685
|
+
resource: "connect",
|
|
10686
|
+
action: kind.name,
|
|
10687
|
+
summary: kind.summary,
|
|
10688
|
+
description: `${kind.description}
|
|
10689
|
+
|
|
10690
|
+
The connect finishes in a browser: Kenso refuses to complete a sign-in for an API key or an agent, so the person you work for opens the link. It prints the link on stderr (and opens it at a desktop when no coding agent runs it), checks every ${POLL_INTERVAL_MS / 1e3} s, and prints {connected, kind, connection} on stdout once the connection shows up. --no-wait prints the start answer, link included, and ends.`,
|
|
10691
|
+
flags: { ...kind.flags, ...COMMON_FLAGS },
|
|
10692
|
+
examples: [...kind.examples, `${kind.examples[0] ?? `kenso connect ${kind.name}`} --no-wait`],
|
|
10693
|
+
operationIds: kind.operationIds,
|
|
10694
|
+
dryRun: true,
|
|
10695
|
+
run: (ctx, args) => runConnect(ctx, kind, args.flags)
|
|
10696
|
+
};
|
|
10368
10697
|
}
|
|
10369
|
-
var
|
|
10370
|
-
var
|
|
10371
|
-
"src/commands/
|
|
10698
|
+
var POLL_INTERVAL_MS, DEFAULT_TIMEOUT_SECONDS, MAX_POLL_FAILURES, LINK_FIELDS, defaultDeps2, COMMON_FLAGS;
|
|
10699
|
+
var init_run = __esm({
|
|
10700
|
+
"src/commands/connect/run.ts"() {
|
|
10372
10701
|
"use strict";
|
|
10702
|
+
init_browser();
|
|
10373
10703
|
init_errors();
|
|
10374
10704
|
init_exit_codes();
|
|
10375
|
-
|
|
10376
|
-
|
|
10705
|
+
init_http();
|
|
10706
|
+
POLL_INTERVAL_MS = 5e3;
|
|
10707
|
+
DEFAULT_TIMEOUT_SECONDS = 600;
|
|
10708
|
+
MAX_POLL_FAILURES = 5;
|
|
10709
|
+
LINK_FIELDS = ["authorizationUrl", "authorizeUrl", "installUrl", "url"];
|
|
10710
|
+
defaultDeps2 = {
|
|
10711
|
+
sleep: (ms, signal) => delay5(ms, void 0, signal ? { signal } : void 0),
|
|
10712
|
+
now: () => Date.now(),
|
|
10713
|
+
spawn: (command65, args) => {
|
|
10714
|
+
const child = nodeSpawn2(command65, args, { detached: true, stdio: "ignore" });
|
|
10715
|
+
child.on("error", () => {
|
|
10716
|
+
});
|
|
10717
|
+
child.unref();
|
|
10718
|
+
},
|
|
10719
|
+
platform: process.platform
|
|
10720
|
+
};
|
|
10721
|
+
COMMON_FLAGS = {
|
|
10722
|
+
timeout: { type: "string", description: `Seconds to wait for the connection (default ${DEFAULT_TIMEOUT_SECONDS})` },
|
|
10723
|
+
"no-wait": { type: "boolean", description: "Print the link as JSON and end, without waiting for the connection" },
|
|
10724
|
+
"no-browser": { type: "boolean", description: "Print the link only; never open a browser" }
|
|
10725
|
+
};
|
|
10726
|
+
}
|
|
10727
|
+
});
|
|
10728
|
+
|
|
10729
|
+
// src/commands/connect/index.ts
|
|
10730
|
+
var KIND_NAMES, load, actions7;
|
|
10731
|
+
var init_connect3 = __esm({
|
|
10732
|
+
"src/commands/connect/index.ts"() {
|
|
10733
|
+
"use strict";
|
|
10734
|
+
KIND_NAMES = ["inbox", "calendar", "video", "crm", "hubspot-knowledge", "github", "migration", "linkedin", "whatsapp", "facebook", "instagram"];
|
|
10735
|
+
load = (name) => async () => {
|
|
10736
|
+
const [{ KINDS: KINDS2 }, { connectCommand: connectCommand2 }] = await Promise.all([Promise.resolve().then(() => (init_kinds(), kinds_exports)), Promise.resolve().then(() => (init_run(), run_exports))]);
|
|
10737
|
+
const kind = KINDS2.find((k) => k.name === name);
|
|
10738
|
+
if (!kind) throw new Error(`no connect kind ${name}`);
|
|
10739
|
+
return connectCommand2(kind);
|
|
10740
|
+
};
|
|
10741
|
+
actions7 = Object.fromEntries(KIND_NAMES.map((name) => [name, load(name)]));
|
|
10377
10742
|
}
|
|
10378
10743
|
});
|
|
10379
10744
|
|
|
@@ -10742,10 +11107,10 @@ var init_import_rows = __esm({
|
|
|
10742
11107
|
});
|
|
10743
11108
|
|
|
10744
11109
|
// src/commands/contacts/import-send.ts
|
|
10745
|
-
import { setTimeout as
|
|
11110
|
+
import { setTimeout as delay6 } from "node:timers/promises";
|
|
10746
11111
|
async function abortableSleep(ms, signal) {
|
|
10747
11112
|
try {
|
|
10748
|
-
await
|
|
11113
|
+
await delay6(ms, void 0, { signal });
|
|
10749
11114
|
} catch (err) {
|
|
10750
11115
|
if (signal.aborted) throw new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
10751
11116
|
throw err;
|
|
@@ -10759,13 +11124,13 @@ function idText2(value) {
|
|
|
10759
11124
|
}
|
|
10760
11125
|
function mapCreateAnswer(chunk, body2) {
|
|
10761
11126
|
const data = unwrap(body2);
|
|
10762
|
-
const record =
|
|
11127
|
+
const record = isRecord4(data) ? data : {};
|
|
10763
11128
|
const results = [];
|
|
10764
11129
|
let limitMessage;
|
|
10765
11130
|
const email = (item) => item.contact.email ? { email: item.contact.email } : {};
|
|
10766
11131
|
if (Array.isArray(record.results)) {
|
|
10767
11132
|
for (const entry of record.results) {
|
|
10768
|
-
if (!
|
|
11133
|
+
if (!isRecord4(entry) || typeof entry.index !== "number") continue;
|
|
10769
11134
|
const item = chunk[entry.index];
|
|
10770
11135
|
if (!item) continue;
|
|
10771
11136
|
const reason = text2(entry.reason);
|
|
@@ -10790,8 +11155,8 @@ function mapCreateAnswer(chunk, body2) {
|
|
|
10790
11155
|
}
|
|
10791
11156
|
const failed = /* @__PURE__ */ new Map();
|
|
10792
11157
|
for (const entry of Array.isArray(record.failed) ? record.failed : []) {
|
|
10793
|
-
if (!
|
|
10794
|
-
const error =
|
|
11158
|
+
if (!isRecord4(entry) || typeof entry.index !== "number") continue;
|
|
11159
|
+
const error = isRecord4(entry.error) ? entry.error : entry;
|
|
10795
11160
|
failed.set(entry.index, { code: text2(error.code) ?? "failed", message: text2(error.message) });
|
|
10796
11161
|
}
|
|
10797
11162
|
chunk.forEach((item, index) => {
|
|
@@ -10844,136 +11209,6 @@ var init_import_send = __esm({
|
|
|
10844
11209
|
}
|
|
10845
11210
|
});
|
|
10846
11211
|
|
|
10847
|
-
// src/batch/jobs.ts
|
|
10848
|
-
import { setTimeout as delay5 } from "node:timers/promises";
|
|
10849
|
-
function interrupted5() {
|
|
10850
|
-
return new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
10851
|
-
}
|
|
10852
|
-
async function defaultSleep(ms, signal) {
|
|
10853
|
-
try {
|
|
10854
|
-
await delay5(ms, void 0, signal ? { signal } : void 0);
|
|
10855
|
-
} catch (err) {
|
|
10856
|
-
if (signal?.aborted) throw interrupted5();
|
|
10857
|
-
throw err;
|
|
10858
|
-
}
|
|
10859
|
-
}
|
|
10860
|
-
function toJob(body2, jobId, type) {
|
|
10861
|
-
const data = unwrap(body2);
|
|
10862
|
-
const record = data !== null && typeof data === "object" && !Array.isArray(data) ? data : {};
|
|
10863
|
-
const rawId = record.id;
|
|
10864
|
-
return {
|
|
10865
|
-
...record,
|
|
10866
|
-
id: typeof rawId === "number" || typeof rawId === "string" && rawId !== "" ? String(rawId) : jobId,
|
|
10867
|
-
type: typeof record.type === "string" && record.type !== "" ? record.type : type,
|
|
10868
|
-
status: typeof record.status === "string" ? record.status : "queued"
|
|
10869
|
-
};
|
|
10870
|
-
}
|
|
10871
|
-
async function waitForJob(client, jobId, type, opts = {}) {
|
|
10872
|
-
const id = String(jobId).trim();
|
|
10873
|
-
if (id === "") throw usageError("Name the job id.", { field: "jobId" });
|
|
10874
|
-
const timeoutMs2 = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
10875
|
-
const intervalMs = opts.intervalMs ?? DEFAULT_INTERVAL_MS;
|
|
10876
|
-
const now = opts.now ?? Date.now;
|
|
10877
|
-
const sleep = opts.sleep ?? ((ms) => defaultSleep(ms, opts.signal));
|
|
10878
|
-
const started = now();
|
|
10879
|
-
for (; ; ) {
|
|
10880
|
-
if (opts.signal?.aborted) throw interrupted5();
|
|
10881
|
-
const res = await client.request({ method: "GET", path: `/v1/jobs/${encodeURIComponent(id)}`, query: { type }, signal: opts.signal });
|
|
10882
|
-
const job = toJob(res.body, id, type);
|
|
10883
|
-
if (TERMINAL_JOB_STATUSES.includes(job.status)) return job;
|
|
10884
|
-
opts.onProgress?.(job);
|
|
10885
|
-
const elapsed = now() - started;
|
|
10886
|
-
if (elapsed >= timeoutMs2) {
|
|
10887
|
-
throw new KensoError({
|
|
10888
|
-
code: "job_timeout",
|
|
10889
|
-
message: `Job ${id} is still ${job.status} after ${Math.round(timeoutMs2 / 1e3)} s.`,
|
|
10890
|
-
exitCode: ExitCode.Error,
|
|
10891
|
-
hint: "The job keeps running on the server. Wait for it again.",
|
|
10892
|
-
next: `kenso jobs wait ${id} --type ${type}`
|
|
10893
|
-
});
|
|
10894
|
-
}
|
|
10895
|
-
const interval = elapsed >= FAST_PHASE_MS ? Math.max(intervalMs, SLOW_INTERVAL_MS) : intervalMs;
|
|
10896
|
-
await sleep(Math.min(interval, Math.max(0, timeoutMs2 - elapsed)));
|
|
10897
|
-
}
|
|
10898
|
-
}
|
|
10899
|
-
var TERMINAL_JOB_STATUSES, DEFAULT_TIMEOUT_MS, DEFAULT_INTERVAL_MS, SLOW_INTERVAL_MS, FAST_PHASE_MS;
|
|
10900
|
-
var init_jobs = __esm({
|
|
10901
|
-
"src/batch/jobs.ts"() {
|
|
10902
|
-
"use strict";
|
|
10903
|
-
init_errors();
|
|
10904
|
-
init_exit_codes();
|
|
10905
|
-
init_http();
|
|
10906
|
-
TERMINAL_JOB_STATUSES = ["succeeded", "failed", "canceled"];
|
|
10907
|
-
DEFAULT_TIMEOUT_MS = 10 * 6e4;
|
|
10908
|
-
DEFAULT_INTERVAL_MS = 2e3;
|
|
10909
|
-
SLOW_INTERVAL_MS = 1e4;
|
|
10910
|
-
FAST_PHASE_MS = 6e4;
|
|
10911
|
-
}
|
|
10912
|
-
});
|
|
10913
|
-
|
|
10914
|
-
// src/commands/jobs/wait.ts
|
|
10915
|
-
var wait_exports = {};
|
|
10916
|
-
__export(wait_exports, {
|
|
10917
|
-
default: () => wait_default,
|
|
10918
|
-
parseDuration: () => parseDuration
|
|
10919
|
-
});
|
|
10920
|
-
function parseDuration(text4) {
|
|
10921
|
-
const match = /^(\d+(?:\.\d+)?)\s*([smh]?)$/i.exec(text4.trim());
|
|
10922
|
-
if (!match) return void 0;
|
|
10923
|
-
const ms = Number(match[1]) * (UNIT_MS[(match[2] || "s").toLowerCase()] ?? 1e3);
|
|
10924
|
-
return Number.isFinite(ms) ? Math.round(ms) : void 0;
|
|
10925
|
-
}
|
|
10926
|
-
var UNIT_MS, command16, wait_default;
|
|
10927
|
-
var init_wait = __esm({
|
|
10928
|
-
"src/commands/jobs/wait.ts"() {
|
|
10929
|
-
"use strict";
|
|
10930
|
-
init_jobs();
|
|
10931
|
-
init_errors();
|
|
10932
|
-
init_exit_codes();
|
|
10933
|
-
UNIT_MS = { s: 1e3, m: 6e4, h: 36e5 };
|
|
10934
|
-
command16 = {
|
|
10935
|
-
resource: "jobs",
|
|
10936
|
-
action: "wait",
|
|
10937
|
-
summary: "Wait for a background job and print it",
|
|
10938
|
-
description: "Polls GET /v1/jobs/{jobId}?type=<type> every 2 s (every 10 s after the first minute) until the job succeeds, fails or is canceled, then prints the job. Exit 0 when it succeeded, 1 when it failed, was canceled or is still running when --timeout passes.",
|
|
10939
|
-
flags: {
|
|
10940
|
-
type: { type: "string", required: true, description: "The job type, for example contact_import or contact_export" },
|
|
10941
|
-
timeout: { type: "string", default: "10m", description: "How long to wait: 90s, 10m, 1h or a number of seconds (default 10m)" }
|
|
10942
|
-
},
|
|
10943
|
-
positionals: [{ name: "jobId", required: true, description: "The job id" }],
|
|
10944
|
-
examples: ["kenso jobs wait 4821 --type contact_import", "kenso jobs wait 4821 --type contact_export --timeout 30m"],
|
|
10945
|
-
operationIds: ["jobs.get"],
|
|
10946
|
-
async run(ctx, { flags, positionals }) {
|
|
10947
|
-
const jobId = (positionals[0] ?? "").trim();
|
|
10948
|
-
if (jobId === "") throw usageError("Name the job id.", { field: "jobId", next: "kenso jobs wait <jobId> --type <type>" });
|
|
10949
|
-
const type = typeof flags.type === "string" ? flags.type.trim() : "";
|
|
10950
|
-
if (type === "") throw usageError("--type needs a value, for example contact_import.", { field: "type" });
|
|
10951
|
-
const timeoutText = typeof flags.timeout === "string" ? flags.timeout : "10m";
|
|
10952
|
-
const timeoutMs2 = parseDuration(timeoutText);
|
|
10953
|
-
if (timeoutMs2 === void 0) {
|
|
10954
|
-
throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
|
|
10955
|
-
}
|
|
10956
|
-
const job = await waitForJob(ctx.client, jobId, type, {
|
|
10957
|
-
timeoutMs: timeoutMs2,
|
|
10958
|
-
signal: ctx.signal,
|
|
10959
|
-
onProgress: (j) => {
|
|
10960
|
-
const done2 = j.progress ? `, ${j.progress.completed}/${j.progress.total ?? "?"}` : "";
|
|
10961
|
-
ctx.output.progress(`job ${j.id}: ${j.status}${done2}`);
|
|
10962
|
-
}
|
|
10963
|
-
});
|
|
10964
|
-
ctx.output.object(job);
|
|
10965
|
-
if (job.status === "succeeded") return ExitCode.Ok;
|
|
10966
|
-
throw new KensoError({
|
|
10967
|
-
code: job.error?.code || (job.status === "canceled" ? "job_canceled" : "job_failed"),
|
|
10968
|
-
message: job.error?.message || `Job ${job.id} ${job.status === "canceled" ? "was canceled" : "failed"}.`,
|
|
10969
|
-
exitCode: ExitCode.Error
|
|
10970
|
-
});
|
|
10971
|
-
}
|
|
10972
|
-
};
|
|
10973
|
-
wait_default = command16;
|
|
10974
|
-
}
|
|
10975
|
-
});
|
|
10976
|
-
|
|
10977
11212
|
// src/commands/contacts/server-import.ts
|
|
10978
11213
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
10979
11214
|
import { basename as basename3, extname as extname3, resolve as resolve7 } from "node:path";
|
|
@@ -11051,7 +11286,7 @@ async function serverImport(ctx, opts) {
|
|
|
11051
11286
|
form.append("file", new Blob([upload2.bytes], { type: "text/csv" }), upload2.name);
|
|
11052
11287
|
const res = await ctx.client.request({ method: "POST", path: "/v1/contact-imports", form, signal: ctx.signal });
|
|
11053
11288
|
const created = unwrap(res.body);
|
|
11054
|
-
const jobId =
|
|
11289
|
+
const jobId = isRecord4(created) ? created.id : void 0;
|
|
11055
11290
|
if (typeof jobId !== "number" && (typeof jobId !== "string" || jobId === "")) {
|
|
11056
11291
|
throw new KensoError({ code: "unexpected_response", message: "The import was accepted, but the answer had no job id.", exitCode: ExitCode.Error });
|
|
11057
11292
|
}
|
|
@@ -11126,7 +11361,7 @@ async function readOverrides(ctx, flags, file) {
|
|
|
11126
11361
|
async function readCampaign(ctx, campaignId) {
|
|
11127
11362
|
const res = await ctx.client.request({ method: "GET", path: `/v1/campaigns/${campaignId}` });
|
|
11128
11363
|
const campaign = unwrap(res.body);
|
|
11129
|
-
const channel =
|
|
11364
|
+
const channel = isRecord4(campaign) && typeof campaign.channel === "string" ? campaign.channel.toLowerCase() : "";
|
|
11130
11365
|
return { linkedInOnly: LINKEDIN_ONLY_CHANNELS.has(channel) ? true : void 0 };
|
|
11131
11366
|
}
|
|
11132
11367
|
async function estimate(ctx, leadCount) {
|
|
@@ -11134,7 +11369,7 @@ async function estimate(ctx, leadCount) {
|
|
|
11134
11369
|
try {
|
|
11135
11370
|
const res = await ctx.client.request({ method: "POST", path: "/v1/credits/estimates", body: { kind: "leads", leadCount } });
|
|
11136
11371
|
const data = unwrap(res.body);
|
|
11137
|
-
if (!
|
|
11372
|
+
if (!isRecord4(data)) return { estimate: data ?? null };
|
|
11138
11373
|
const credits = (key) => typeof data[key] === "number" ? data[key] / 1e3 : void 0;
|
|
11139
11374
|
return {
|
|
11140
11375
|
estimate: data,
|
|
@@ -11277,7 +11512,7 @@ async function emailIndex(ctx, campaignId) {
|
|
|
11277
11512
|
for await (const contact of ctx.client.paginate({ method: "GET", path: "/v1/contacts", query: { campaignId } }, { pageSize: PAGE_SIZE })) {
|
|
11278
11513
|
read2++;
|
|
11279
11514
|
if (read2 % 2e3 === 0) ctx.output.progress(`read ${read2} contacts of campaign ${campaignId}`);
|
|
11280
|
-
if (!
|
|
11515
|
+
if (!isRecord4(contact)) continue;
|
|
11281
11516
|
const email = typeof contact.email === "string" ? contact.email.trim().toLowerCase() : "";
|
|
11282
11517
|
const id = typeof contact.id === "number" ? contact.id : typeof contact.id === "string" ? positiveId(contact.id) : void 0;
|
|
11283
11518
|
if (email !== "" && id !== void 0 && !index.has(email)) index.set(email, id);
|
|
@@ -11338,11 +11573,11 @@ function planUpdate(rows, mapping, match, emails) {
|
|
|
11338
11573
|
}
|
|
11339
11574
|
function mapUpdateAnswer(chunk, body2) {
|
|
11340
11575
|
const data = unwrap(body2);
|
|
11341
|
-
const entries2 =
|
|
11576
|
+
const entries2 = isRecord4(data) && Array.isArray(data.results) ? data.results : [];
|
|
11342
11577
|
const rowOf = new Map(chunk.map((u) => [u.item.contactId, u.row]));
|
|
11343
11578
|
const results = [];
|
|
11344
11579
|
for (const entry of entries2) {
|
|
11345
|
-
if (!
|
|
11580
|
+
if (!isRecord4(entry)) continue;
|
|
11346
11581
|
const contactId = typeof entry.contactId === "number" ? entry.contactId : Number(entry.contactId);
|
|
11347
11582
|
const row = rowOf.get(contactId);
|
|
11348
11583
|
if (row === void 0) continue;
|
|
@@ -11559,7 +11794,7 @@ async function idsFromFile(ctx, path) {
|
|
|
11559
11794
|
}
|
|
11560
11795
|
async function searchIds(ctx, where) {
|
|
11561
11796
|
const filters = await readDataArg(where, ctx.stdin);
|
|
11562
|
-
if (!
|
|
11797
|
+
if (!isRecord4(filters)) throw usageError("--where must be a JSON object of contacts search filters.", { field: "where" });
|
|
11563
11798
|
const body2 = { ...filters };
|
|
11564
11799
|
delete body2.cursor;
|
|
11565
11800
|
delete body2.limit;
|
|
@@ -11575,10 +11810,10 @@ async function searchIds(ctx, where) {
|
|
|
11575
11810
|
retrySafe: true
|
|
11576
11811
|
});
|
|
11577
11812
|
const page = unwrap(res.body);
|
|
11578
|
-
const data =
|
|
11579
|
-
for (const contact of data) if (
|
|
11813
|
+
const data = isRecord4(res.body) && Array.isArray(res.body.data) ? res.body.data : Array.isArray(page) ? page : [];
|
|
11814
|
+
for (const contact of data) if (isRecord4(contact) && (typeof contact.id === "number" || typeof contact.id === "string")) ids2.push(String(contact.id));
|
|
11580
11815
|
ctx.output.progress(`found ${ids2.length} contacts`);
|
|
11581
|
-
const pagination =
|
|
11816
|
+
const pagination = isRecord4(res.body) && isRecord4(res.body.pagination) ? res.body.pagination : void 0;
|
|
11582
11817
|
const next = pagination?.nextCursor;
|
|
11583
11818
|
if (pagination?.hasMore !== true || typeof next !== "string" || next === "" || seen.has(next)) break;
|
|
11584
11819
|
seen.add(next);
|
|
@@ -11626,12 +11861,12 @@ async function collectIds(ctx, flags, kind, dryRun2) {
|
|
|
11626
11861
|
}
|
|
11627
11862
|
function mapBulkAnswer(chunk, body2) {
|
|
11628
11863
|
const data = unwrap(body2);
|
|
11629
|
-
const record =
|
|
11864
|
+
const record = isRecord4(data) ? data : {};
|
|
11630
11865
|
const succeeded = new Set((Array.isArray(record.succeeded) ? record.succeeded : []).map((id) => String(id)));
|
|
11631
11866
|
const failed = /* @__PURE__ */ new Map();
|
|
11632
11867
|
for (const entry of Array.isArray(record.failed) ? record.failed : []) {
|
|
11633
|
-
if (!
|
|
11634
|
-
const error =
|
|
11868
|
+
if (!isRecord4(entry) || entry.id === void 0 || entry.id === null) continue;
|
|
11869
|
+
const error = isRecord4(entry.error) ? entry.error : entry;
|
|
11635
11870
|
const code = typeof error.code === "string" && error.code !== "" ? error.code : "failed";
|
|
11636
11871
|
failed.set(String(entry.id), { code, ...typeof error.message === "string" && error.message !== "" ? { message: error.message } : {} });
|
|
11637
11872
|
}
|
|
@@ -11877,7 +12112,7 @@ function idText3(value) {
|
|
|
11877
12112
|
return typeof value === "number" || typeof value === "string" && value !== "" ? String(value) : void 0;
|
|
11878
12113
|
}
|
|
11879
12114
|
function exportIdOf(job) {
|
|
11880
|
-
const resource =
|
|
12115
|
+
const resource = isRecord4(job.resource) ? idText3(job.resource.id) : void 0;
|
|
11881
12116
|
if (resource) return resource;
|
|
11882
12117
|
const url = typeof job.downloadUrl === "string" ? CONTENT_PATH.exec(job.downloadUrl)?.[1] : void 0;
|
|
11883
12118
|
return url ?? String(job.id);
|
|
@@ -11948,8 +12183,8 @@ var init_export = __esm({
|
|
|
11948
12183
|
if (timeoutMs2 === void 0) throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
|
|
11949
12184
|
const res = await ctx.client.request({ method: "POST", path: "/v1/contact-exports", body: { kind: "contacts", campaignId }, signal: ctx.signal });
|
|
11950
12185
|
const created = unwrap(res.body);
|
|
11951
|
-
const jobId =
|
|
11952
|
-
if (!
|
|
12186
|
+
const jobId = isRecord4(created) ? idText3(created.id) : void 0;
|
|
12187
|
+
if (!isRecord4(created) || jobId === void 0) {
|
|
11953
12188
|
throw new KensoError({ code: "unexpected_response", message: "The export was created, but the answer had no job id.", exitCode: ExitCode.Error });
|
|
11954
12189
|
}
|
|
11955
12190
|
if (out === void 0 && flags.wait !== true) {
|
|
@@ -12604,7 +12839,7 @@ var tail_exports = {};
|
|
|
12604
12839
|
__export(tail_exports, {
|
|
12605
12840
|
default: () => tail_default
|
|
12606
12841
|
});
|
|
12607
|
-
import { setTimeout as
|
|
12842
|
+
import { setTimeout as delay7 } from "node:timers/promises";
|
|
12608
12843
|
function duration(text4) {
|
|
12609
12844
|
const days = /^(\d+(?:\.\d+)?)\s*d$/i.exec(text4.trim());
|
|
12610
12845
|
return days ? Math.round(Number(days[1]) * 864e5) : parseDuration(text4);
|
|
@@ -12743,7 +12978,7 @@ var init_tail = __esm({
|
|
|
12743
12978
|
backoffMs2 = err instanceof KensoError && err.exitCode === ExitCode.RateLimited ? Math.max(intervalMs, RATE_LIMITED_WAIT_MS) : intervalMs;
|
|
12744
12979
|
ctx.output.warn(`Polling failed (${err.message}); trying again in ${backoffMs2 / 1e3} s.`);
|
|
12745
12980
|
}
|
|
12746
|
-
await
|
|
12981
|
+
await delay7(backoffMs2, void 0, { signal: ctx.signal }).catch(() => void 0);
|
|
12747
12982
|
}
|
|
12748
12983
|
return ExitCode.Ok;
|
|
12749
12984
|
}
|
|
@@ -13249,6 +13484,56 @@ var init_stage_history = __esm({
|
|
|
13249
13484
|
}
|
|
13250
13485
|
});
|
|
13251
13486
|
|
|
13487
|
+
// src/commands/opportunities/bulk-update.ts
|
|
13488
|
+
var bulk_update_exports2 = {};
|
|
13489
|
+
__export(bulk_update_exports2, {
|
|
13490
|
+
default: () => bulk_update_default2
|
|
13491
|
+
});
|
|
13492
|
+
var bulk_update_default2;
|
|
13493
|
+
var init_bulk_update3 = __esm({
|
|
13494
|
+
"src/commands/opportunities/bulk-update.ts"() {
|
|
13495
|
+
"use strict";
|
|
13496
|
+
init_bulk_update();
|
|
13497
|
+
bulk_update_default2 = bulkUpdateCommand({
|
|
13498
|
+
resource: "opportunities",
|
|
13499
|
+
noun: "deal",
|
|
13500
|
+
plural: "deals",
|
|
13501
|
+
aliases: { owner: "ownerMemberId", close: "closeDate" },
|
|
13502
|
+
fields: ["stage", "ownerMemberId", "closeDate", "amount", "dealType", "nextStep"],
|
|
13503
|
+
featureGates: ["opportunities", "bulk_edit"],
|
|
13504
|
+
examples: [
|
|
13505
|
+
`kenso opportunities bulk-update --filter '{"filters":[{"field":"stageCategory","operator":"is","values":["open"]}]}' --set stage=proposal --dry-run`,
|
|
13506
|
+
"kenso opportunities bulk-update --ids 71,72,73 --set close=2026-12-31 --yes",
|
|
13507
|
+
"kenso changes undo --change-id 31"
|
|
13508
|
+
]
|
|
13509
|
+
});
|
|
13510
|
+
}
|
|
13511
|
+
});
|
|
13512
|
+
|
|
13513
|
+
// src/commands/opportunities/bulk-delete.ts
|
|
13514
|
+
var bulk_delete_exports2 = {};
|
|
13515
|
+
__export(bulk_delete_exports2, {
|
|
13516
|
+
default: () => bulk_delete_default2
|
|
13517
|
+
});
|
|
13518
|
+
var bulk_delete_default2;
|
|
13519
|
+
var init_bulk_delete2 = __esm({
|
|
13520
|
+
"src/commands/opportunities/bulk-delete.ts"() {
|
|
13521
|
+
"use strict";
|
|
13522
|
+
init_bulk_update();
|
|
13523
|
+
bulk_delete_default2 = bulkDeleteCommand({
|
|
13524
|
+
resource: "opportunities",
|
|
13525
|
+
noun: "deal",
|
|
13526
|
+
plural: "deals",
|
|
13527
|
+
featureGates: ["opportunities", "bulk_edit"],
|
|
13528
|
+
examples: [
|
|
13529
|
+
`kenso opportunities bulk-delete --filter '{"accountId":812}' --dry-run`,
|
|
13530
|
+
"kenso opportunities bulk-delete --ids 71,72,73 --yes",
|
|
13531
|
+
"kenso changes apply --change-id 31"
|
|
13532
|
+
]
|
|
13533
|
+
});
|
|
13534
|
+
}
|
|
13535
|
+
});
|
|
13536
|
+
|
|
13252
13537
|
// src/commands/opportunities/index.ts
|
|
13253
13538
|
var actions18;
|
|
13254
13539
|
var init_opportunities = __esm({
|
|
@@ -13256,7 +13541,9 @@ var init_opportunities = __esm({
|
|
|
13256
13541
|
"use strict";
|
|
13257
13542
|
actions18 = {
|
|
13258
13543
|
move: () => Promise.resolve().then(() => (init_move(), move_exports)).then((m) => m.default),
|
|
13259
|
-
"stage-history": () => Promise.resolve().then(() => (init_stage_history(), stage_history_exports)).then((m) => m.default)
|
|
13544
|
+
"stage-history": () => Promise.resolve().then(() => (init_stage_history(), stage_history_exports)).then((m) => m.default),
|
|
13545
|
+
"bulk-update": () => Promise.resolve().then(() => (init_bulk_update3(), bulk_update_exports2)).then((m) => m.default),
|
|
13546
|
+
"bulk-delete": () => Promise.resolve().then(() => (init_bulk_delete2(), bulk_delete_exports2)).then((m) => m.default)
|
|
13260
13547
|
};
|
|
13261
13548
|
}
|
|
13262
13549
|
});
|
|
@@ -13433,13 +13720,65 @@ var init_import3 = __esm({
|
|
|
13433
13720
|
}
|
|
13434
13721
|
});
|
|
13435
13722
|
|
|
13723
|
+
// src/commands/people/bulk-update.ts
|
|
13724
|
+
var bulk_update_exports3 = {};
|
|
13725
|
+
__export(bulk_update_exports3, {
|
|
13726
|
+
default: () => bulk_update_default3
|
|
13727
|
+
});
|
|
13728
|
+
var bulk_update_default3;
|
|
13729
|
+
var init_bulk_update4 = __esm({
|
|
13730
|
+
"src/commands/people/bulk-update.ts"() {
|
|
13731
|
+
"use strict";
|
|
13732
|
+
init_bulk_update();
|
|
13733
|
+
bulk_update_default3 = bulkUpdateCommand({
|
|
13734
|
+
resource: "people",
|
|
13735
|
+
noun: "person",
|
|
13736
|
+
plural: "people",
|
|
13737
|
+
aliases: { owner: "ownerMemberId" },
|
|
13738
|
+
fields: ["ownerMemberId", "leadStatus", "title", "seniority", "department", "location"],
|
|
13739
|
+
featureGates: ["accounts", "bulk_edit"],
|
|
13740
|
+
examples: [
|
|
13741
|
+
`kenso people bulk-update --filter '{"leadStatus":["working"]}' --set owner=42 --dry-run`,
|
|
13742
|
+
"kenso people bulk-update --ids 501,502 --set seniority=VP --yes",
|
|
13743
|
+
"kenso changes undo --change-id 31"
|
|
13744
|
+
]
|
|
13745
|
+
});
|
|
13746
|
+
}
|
|
13747
|
+
});
|
|
13748
|
+
|
|
13749
|
+
// src/commands/people/bulk-delete.ts
|
|
13750
|
+
var bulk_delete_exports3 = {};
|
|
13751
|
+
__export(bulk_delete_exports3, {
|
|
13752
|
+
default: () => bulk_delete_default3
|
|
13753
|
+
});
|
|
13754
|
+
var bulk_delete_default3;
|
|
13755
|
+
var init_bulk_delete3 = __esm({
|
|
13756
|
+
"src/commands/people/bulk-delete.ts"() {
|
|
13757
|
+
"use strict";
|
|
13758
|
+
init_bulk_update();
|
|
13759
|
+
bulk_delete_default3 = bulkDeleteCommand({
|
|
13760
|
+
resource: "people",
|
|
13761
|
+
noun: "person",
|
|
13762
|
+
plural: "people",
|
|
13763
|
+
featureGates: ["accounts", "bulk_edit"],
|
|
13764
|
+
examples: [
|
|
13765
|
+
`kenso people bulk-delete --filter '{"onAccount":"none","leadStatus":["disqualified"]}' --dry-run`,
|
|
13766
|
+
"kenso people bulk-delete --ids 501,502 --yes",
|
|
13767
|
+
"kenso changes apply --change-id 31"
|
|
13768
|
+
]
|
|
13769
|
+
});
|
|
13770
|
+
}
|
|
13771
|
+
});
|
|
13772
|
+
|
|
13436
13773
|
// src/commands/people/index.ts
|
|
13437
13774
|
var actions19;
|
|
13438
13775
|
var init_people = __esm({
|
|
13439
13776
|
"src/commands/people/index.ts"() {
|
|
13440
13777
|
"use strict";
|
|
13441
13778
|
actions19 = {
|
|
13442
|
-
import: () => Promise.resolve().then(() => (init_import3(), import_exports3)).then((m) => m.default)
|
|
13779
|
+
import: () => Promise.resolve().then(() => (init_import3(), import_exports3)).then((m) => m.default),
|
|
13780
|
+
"bulk-update": () => Promise.resolve().then(() => (init_bulk_update4(), bulk_update_exports3)).then((m) => m.default),
|
|
13781
|
+
"bulk-delete": () => Promise.resolve().then(() => (init_bulk_delete3(), bulk_delete_exports3)).then((m) => m.default)
|
|
13443
13782
|
};
|
|
13444
13783
|
}
|
|
13445
13784
|
});
|
|
@@ -14822,7 +15161,7 @@ var init_preview = __esm({
|
|
|
14822
15161
|
});
|
|
14823
15162
|
|
|
14824
15163
|
// src/commands/studio/fill-runs.ts
|
|
14825
|
-
import { setTimeout as
|
|
15164
|
+
import { setTimeout as delay8 } from "node:timers/promises";
|
|
14826
15165
|
async function estimateFill(ctx, templateId, count) {
|
|
14827
15166
|
const parts2 = [];
|
|
14828
15167
|
for (let left = count; left > 0; left -= RUN_SIZE) {
|
|
@@ -14854,7 +15193,7 @@ async function estimateFill(ctx, templateId, count) {
|
|
|
14854
15193
|
async function waitForRun(client, runId, opts) {
|
|
14855
15194
|
const sleep = opts.sleep ?? (async (ms) => {
|
|
14856
15195
|
try {
|
|
14857
|
-
await
|
|
15196
|
+
await delay8(ms, void 0, { signal: opts.signal });
|
|
14858
15197
|
} catch (err) {
|
|
14859
15198
|
if (opts.signal.aborted) throw new KensoError({ code: "interrupted", message: "Interrupted.", exitCode: ExitCode.Interrupted });
|
|
14860
15199
|
throw err;
|
|
@@ -15478,7 +15817,7 @@ __export(listen_exports, {
|
|
|
15478
15817
|
liveBody: () => liveBody
|
|
15479
15818
|
});
|
|
15480
15819
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
15481
|
-
import { setTimeout as
|
|
15820
|
+
import { setTimeout as delay9 } from "node:timers/promises";
|
|
15482
15821
|
function eventTypes(value) {
|
|
15483
15822
|
const list2 = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
|
|
15484
15823
|
return list2.flatMap((item) => item.split(",")).map((item) => item.trim()).filter((item) => item !== "");
|
|
@@ -15618,7 +15957,7 @@ var init_listen = __esm({
|
|
|
15618
15957
|
ctx.output.warn(`Polling failed (${err.message}); trying again in ${MAX_POLL_MS / 1e3} s.`);
|
|
15619
15958
|
}
|
|
15620
15959
|
}
|
|
15621
|
-
await
|
|
15960
|
+
await delay9(waitMs, void 0, { signal: ctx.signal }).catch(() => void 0);
|
|
15622
15961
|
}
|
|
15623
15962
|
} catch (err) {
|
|
15624
15963
|
if (!ctx.signal.aborted) throw err;
|
|
@@ -15735,14 +16074,14 @@ var init_webhooks2 = __esm({
|
|
|
15735
16074
|
// src/commands/work/common.ts
|
|
15736
16075
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
15737
16076
|
import { join as join16 } from "node:path";
|
|
15738
|
-
import { setTimeout as
|
|
16077
|
+
import { setTimeout as delay10 } from "node:timers/promises";
|
|
15739
16078
|
function unavailable(err) {
|
|
15740
16079
|
return err instanceof KensoError && (err.code === "network_error" || err.httpStatus === 502 || err.httpStatus === 503 || err.httpStatus === 504);
|
|
15741
16080
|
}
|
|
15742
16081
|
async function pause3(ms, signal) {
|
|
15743
16082
|
if (signal.aborted) return false;
|
|
15744
16083
|
try {
|
|
15745
|
-
await
|
|
16084
|
+
await delay10(ms, void 0, { signal });
|
|
15746
16085
|
return true;
|
|
15747
16086
|
} catch {
|
|
15748
16087
|
return false;
|
|
@@ -16665,7 +17004,7 @@ import { spawn as nodeSpawn3 } from "node:child_process";
|
|
|
16665
17004
|
import { rmSync as rmSync3, statSync as statSync2 } from "node:fs";
|
|
16666
17005
|
import { access, constants as constants2 } from "node:fs/promises";
|
|
16667
17006
|
import { delimiter as delimiter2, join as join20 } from "node:path";
|
|
16668
|
-
import { setTimeout as
|
|
17007
|
+
import { setTimeout as delay11 } from "node:timers/promises";
|
|
16669
17008
|
function childEnv(parent, adapter, extra) {
|
|
16670
17009
|
const scrub = new Set(adapter.scrubEnv.map((name) => name.toUpperCase()));
|
|
16671
17010
|
const env = {};
|
|
@@ -16758,7 +17097,7 @@ async function groupGone(pid, runAs) {
|
|
|
16758
17097
|
while (Date.now() < deadline) {
|
|
16759
17098
|
if (runAs) {
|
|
16760
17099
|
if (!await sudoKill(runAs, "SIGKILL", pid)) return;
|
|
16761
|
-
await
|
|
17100
|
+
await delay11(100);
|
|
16762
17101
|
continue;
|
|
16763
17102
|
}
|
|
16764
17103
|
try {
|
|
@@ -16766,7 +17105,7 @@ async function groupGone(pid, runAs) {
|
|
|
16766
17105
|
} catch {
|
|
16767
17106
|
return;
|
|
16768
17107
|
}
|
|
16769
|
-
await
|
|
17108
|
+
await delay11(25);
|
|
16770
17109
|
}
|
|
16771
17110
|
}
|
|
16772
17111
|
function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|