kenso 0.1.153 → 0.1.155
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 +3 -0
- package/dist/discover.json +1 -1
- package/dist/kenso.js +590 -201
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/docs/reference.md +33 -4
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -3389,7 +3389,7 @@ var VERSION;
|
|
|
3389
3389
|
var init_version = __esm({
|
|
3390
3390
|
"src/core/version.ts"() {
|
|
3391
3391
|
"use strict";
|
|
3392
|
-
VERSION = true ? "0.1.
|
|
3392
|
+
VERSION = true ? "0.1.155" : "0.0.0-dev";
|
|
3393
3393
|
}
|
|
3394
3394
|
});
|
|
3395
3395
|
|
|
@@ -3684,9 +3684,9 @@ async function readAnswer(ctx) {
|
|
|
3684
3684
|
const lines = createInterface({ input: ctx.stdin ?? process.stdin, terminal: false });
|
|
3685
3685
|
let onAbort;
|
|
3686
3686
|
try {
|
|
3687
|
-
return await new Promise((
|
|
3688
|
-
lines.once("line",
|
|
3689
|
-
lines.once("close", () =>
|
|
3687
|
+
return await new Promise((resolve23, reject) => {
|
|
3688
|
+
lines.once("line", resolve23);
|
|
3689
|
+
lines.once("close", () => resolve23(""));
|
|
3690
3690
|
onAbort = () => reject(interrupted());
|
|
3691
3691
|
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
3692
3692
|
});
|
|
@@ -3966,8 +3966,8 @@ async function saveFile(out, bytes) {
|
|
|
3966
3966
|
return path;
|
|
3967
3967
|
}
|
|
3968
3968
|
function suggestedFileName(res) {
|
|
3969
|
-
const
|
|
3970
|
-
const encoded = /filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/.exec(
|
|
3969
|
+
const header2 = res.headers.get("content-disposition") ?? "";
|
|
3970
|
+
const encoded = /filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/.exec(header2)?.[1];
|
|
3971
3971
|
let name;
|
|
3972
3972
|
if (encoded) {
|
|
3973
3973
|
try {
|
|
@@ -3976,7 +3976,7 @@ function suggestedFileName(res) {
|
|
|
3976
3976
|
name = void 0;
|
|
3977
3977
|
}
|
|
3978
3978
|
}
|
|
3979
|
-
name ??= /filename\s*=\s*"?([^";]+)"?/.exec(
|
|
3979
|
+
name ??= /filename\s*=\s*"?([^";]+)"?/.exec(header2)?.[1]?.trim();
|
|
3980
3980
|
const safe = basename(name ?? "").replace(/[^\w.-]+/g, "_").replace(/^\.+/, "");
|
|
3981
3981
|
return safe === "" ? "download" : safe;
|
|
3982
3982
|
}
|
|
@@ -4765,9 +4765,9 @@ async function readRun(dir3) {
|
|
|
4765
4765
|
return null;
|
|
4766
4766
|
}
|
|
4767
4767
|
if (!raw) return null;
|
|
4768
|
-
const { runId, command:
|
|
4768
|
+
const { runId, command: command90, createdAt, status } = raw;
|
|
4769
4769
|
if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
|
|
4770
|
-
if (typeof
|
|
4770
|
+
if (typeof command90 !== "string" || typeof createdAt !== "string") return null;
|
|
4771
4771
|
if (typeof status !== "string" || !STATUSES.includes(status)) return null;
|
|
4772
4772
|
let chunksDone = chunkList(raw.chunksDone) ?? [];
|
|
4773
4773
|
try {
|
|
@@ -4778,7 +4778,7 @@ async function readRun(dir3) {
|
|
|
4778
4778
|
const record3 = {
|
|
4779
4779
|
...raw,
|
|
4780
4780
|
runId,
|
|
4781
|
-
command:
|
|
4781
|
+
command: command90,
|
|
4782
4782
|
args: asRecord3(raw.args) ?? {},
|
|
4783
4783
|
createdAt,
|
|
4784
4784
|
status,
|
|
@@ -4838,11 +4838,11 @@ async function loadRun(runId, env = process.env) {
|
|
|
4838
4838
|
}
|
|
4839
4839
|
return run;
|
|
4840
4840
|
}
|
|
4841
|
-
async function findIdentical(
|
|
4841
|
+
async function findIdentical(command90, args, inputSha256, env, workspaceId, anyWorkspace = false) {
|
|
4842
4842
|
const identity = argsIdentity(args);
|
|
4843
4843
|
const runs = await listRuns(env);
|
|
4844
4844
|
return runs.filter(
|
|
4845
|
-
(run) => run.command ===
|
|
4845
|
+
(run) => run.command === command90 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
|
|
4846
4846
|
);
|
|
4847
4847
|
}
|
|
4848
4848
|
function isOtherLiveProcess(pid) {
|
|
@@ -7119,8 +7119,8 @@ function parseCsv(text4, source) {
|
|
|
7119
7119
|
let records;
|
|
7120
7120
|
try {
|
|
7121
7121
|
records = parse(text4, {
|
|
7122
|
-
columns: (
|
|
7123
|
-
headers =
|
|
7122
|
+
columns: (header2) => {
|
|
7123
|
+
headers = header2.map((h) => String(h));
|
|
7124
7124
|
return headers;
|
|
7125
7125
|
},
|
|
7126
7126
|
bom: true,
|
|
@@ -7136,7 +7136,7 @@ function parseCsv(text4, source) {
|
|
|
7136
7136
|
}
|
|
7137
7137
|
const rows = records.map((record3) => {
|
|
7138
7138
|
const row = {};
|
|
7139
|
-
for (const
|
|
7139
|
+
for (const header2 of headers) row[header2] = record3[header2] ?? "";
|
|
7140
7140
|
return row;
|
|
7141
7141
|
});
|
|
7142
7142
|
return { headers, rows };
|
|
@@ -7170,12 +7170,12 @@ function parseJsonl(text4, source) {
|
|
|
7170
7170
|
}
|
|
7171
7171
|
async function readInput(pathOrDash, opts) {
|
|
7172
7172
|
const { path, bytes } = await readRaw(pathOrDash, opts?.stdin);
|
|
7173
|
-
const
|
|
7173
|
+
const sha2566 = createHash2("sha256").update(bytes).digest("hex");
|
|
7174
7174
|
const text4 = bytes.toString("utf8");
|
|
7175
7175
|
const source = path === "-" ? "stdin" : pathOrDash;
|
|
7176
7176
|
const format = detectFormat(path, text4);
|
|
7177
7177
|
const parsed2 = format === "csv" ? parseCsv(text4, source) : parseJsonl(text4, source);
|
|
7178
|
-
return { path, format, sha256:
|
|
7178
|
+
return { path, format, sha256: sha2566, ...parsed2 };
|
|
7179
7179
|
}
|
|
7180
7180
|
function idText(value) {
|
|
7181
7181
|
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
@@ -8263,22 +8263,22 @@ var init_help_effect = __esm({
|
|
|
8263
8263
|
});
|
|
8264
8264
|
|
|
8265
8265
|
// src/commands/people/columns.ts
|
|
8266
|
-
function normalizeHeader(
|
|
8267
|
-
return
|
|
8266
|
+
function normalizeHeader(header2) {
|
|
8267
|
+
return header2.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
8268
8268
|
}
|
|
8269
8269
|
function mapColumns(headers, aliases) {
|
|
8270
8270
|
const sources = /* @__PURE__ */ new Map();
|
|
8271
8271
|
const mapping = {};
|
|
8272
8272
|
const ignored = [];
|
|
8273
|
-
for (const
|
|
8274
|
-
const field = aliases[normalizeHeader(
|
|
8273
|
+
for (const header2 of headers) {
|
|
8274
|
+
const field = aliases[normalizeHeader(header2)];
|
|
8275
8275
|
if (field === void 0) {
|
|
8276
|
-
ignored.push(
|
|
8276
|
+
ignored.push(header2);
|
|
8277
8277
|
continue;
|
|
8278
8278
|
}
|
|
8279
|
-
mapping[
|
|
8279
|
+
mapping[header2] = field;
|
|
8280
8280
|
const list2 = sources.get(field) ?? [];
|
|
8281
|
-
list2.push(
|
|
8281
|
+
list2.push(header2);
|
|
8282
8282
|
sources.set(field, list2);
|
|
8283
8283
|
}
|
|
8284
8284
|
return { sources, mapping, ignored };
|
|
@@ -8321,8 +8321,8 @@ function idValue(value, field) {
|
|
|
8321
8321
|
function shellQuote3(arg) {
|
|
8322
8322
|
return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
8323
8323
|
}
|
|
8324
|
-
function commandLine2(ctx,
|
|
8325
|
-
const parts2 = ["kenso", ...
|
|
8324
|
+
function commandLine2(ctx, command90, args, extra = []) {
|
|
8325
|
+
const parts2 = ["kenso", ...command90.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
|
|
8326
8326
|
for (const [name, value] of Object.entries(args.flags)) {
|
|
8327
8327
|
if (value === void 0 || value === false) continue;
|
|
8328
8328
|
if (value === true) parts2.push(`--${name}`);
|
|
@@ -8596,7 +8596,7 @@ var init_import = __esm({
|
|
|
8596
8596
|
}
|
|
8597
8597
|
});
|
|
8598
8598
|
const dryRun2 = ctx.flags.dryRun === true || ctx.flags.yes !== true;
|
|
8599
|
-
const mapping = Object.fromEntries(Object.entries(columns2.mapping).map(([
|
|
8599
|
+
const mapping = Object.fromEntries(Object.entries(columns2.mapping).map(([header2, field]) => [header2, field === "domain" ? "domains" : field]));
|
|
8600
8600
|
const estimate2 = dryRun2 ? await estimateAccounts(ctx, items.length) : null;
|
|
8601
8601
|
const credits3 = estimate2 ? { ...creditsCheck(estimate2.totalMillicredits, estimate2.availableMillicredits), sufficient: estimate2.sufficient } : creditsCheck(0, void 0);
|
|
8602
8602
|
const outcome = await runBatch(
|
|
@@ -8635,9 +8635,9 @@ function stringFlag2(flags, name) {
|
|
|
8635
8635
|
const text4 = value.trim();
|
|
8636
8636
|
return text4 === "" ? void 0 : text4;
|
|
8637
8637
|
}
|
|
8638
|
-
function requireFlag(flags, name,
|
|
8638
|
+
function requireFlag(flags, name, command90, hint) {
|
|
8639
8639
|
const value = stringFlag2(flags, name);
|
|
8640
|
-
if (value === void 0) throw usageError(`--${name} is required for ${
|
|
8640
|
+
if (value === void 0) throw usageError(`--${name} is required for ${command90}.`, { field: name, next: `${command90} --help`, ...hint ? { hint } : {} });
|
|
8641
8641
|
return value;
|
|
8642
8642
|
}
|
|
8643
8643
|
function positiveId(value) {
|
|
@@ -8646,8 +8646,8 @@ function positiveId(value) {
|
|
|
8646
8646
|
const id = Number(text4);
|
|
8647
8647
|
return Number.isSafeInteger(id) && id > 0 ? id : void 0;
|
|
8648
8648
|
}
|
|
8649
|
-
function idFlag(flags, name,
|
|
8650
|
-
const raw = requireFlag(flags, name,
|
|
8649
|
+
function idFlag(flags, name, command90) {
|
|
8650
|
+
const raw = requireFlag(flags, name, command90);
|
|
8651
8651
|
const id = positiveId(raw);
|
|
8652
8652
|
if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
|
|
8653
8653
|
return id;
|
|
@@ -8667,8 +8667,8 @@ function isDryRun(ctx) {
|
|
|
8667
8667
|
function shellQuote4(value) {
|
|
8668
8668
|
return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
8669
8669
|
}
|
|
8670
|
-
function sameCommand2(
|
|
8671
|
-
const parts2 = [
|
|
8670
|
+
function sameCommand2(command90, flags, ctx, extra = []) {
|
|
8671
|
+
const parts2 = [command90];
|
|
8672
8672
|
for (const [name, value] of Object.entries(flags)) {
|
|
8673
8673
|
if (value === void 0 || value === false) continue;
|
|
8674
8674
|
if (value === true) parts2.push(`--${name}`);
|
|
@@ -8708,7 +8708,7 @@ function isRecord5(value) {
|
|
|
8708
8708
|
function warnDropped(ctx, mapping) {
|
|
8709
8709
|
const dropped = Object.entries(mapping.dropped).filter(([, reason]) => reason !== "mapped_to_null");
|
|
8710
8710
|
if (dropped.length === 0) return;
|
|
8711
|
-
const list2 = dropped.map(([
|
|
8711
|
+
const list2 = dropped.map(([header2, reason]) => `"${header2}" (${reason})`).join(", ");
|
|
8712
8712
|
ctx.output.warn(`Not sent: ${list2}. Rename a column with --map '{"<column>": "customVariables.<name>"}'.`);
|
|
8713
8713
|
}
|
|
8714
8714
|
var OUT_FLAG2, CONCURRENCY_FLAG;
|
|
@@ -8900,12 +8900,12 @@ function filterBody(flags) {
|
|
|
8900
8900
|
}
|
|
8901
8901
|
return parsed2;
|
|
8902
8902
|
}
|
|
8903
|
-
function targetBody(flags, target2,
|
|
8903
|
+
function targetBody(flags, target2, command90) {
|
|
8904
8904
|
const ids2 = idList(flags, "ids");
|
|
8905
8905
|
const filter = filterBody(flags);
|
|
8906
8906
|
const everything = flags.all === true;
|
|
8907
8907
|
if (ids2 !== void 0 === (filter !== void 0 || everything)) {
|
|
8908
|
-
throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${
|
|
8908
|
+
throw usageError(`Name the ${target2.plural} one way: --ids, --filter, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command90} --help` });
|
|
8909
8909
|
}
|
|
8910
8910
|
const exclude = idList(flags, "exclude-ids");
|
|
8911
8911
|
if (exclude !== void 0 && ids2 !== void 0) throw usageError("--exclude-ids goes with --filter or --all.", { field: "exclude-ids" });
|
|
@@ -8926,14 +8926,14 @@ function tagSet(flags) {
|
|
|
8926
8926
|
return set2;
|
|
8927
8927
|
}
|
|
8928
8928
|
function requestBody(flags, target2, dryRun2) {
|
|
8929
|
-
const
|
|
8929
|
+
const command90 = `kenso ${target2.resource} bulk-update`;
|
|
8930
8930
|
const pairs = Array.isArray(flags.set) ? flags.set : typeof flags.set === "string" ? [flags.set] : [];
|
|
8931
8931
|
const tags = target2.tags ? tagSet(flags) : {};
|
|
8932
8932
|
if (pairs.length === 0 && Object.keys(tags).length === 0) {
|
|
8933
|
-
throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${
|
|
8933
|
+
throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${command90}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command90} --help` });
|
|
8934
8934
|
}
|
|
8935
8935
|
return {
|
|
8936
|
-
...targetBody(flags, target2,
|
|
8936
|
+
...targetBody(flags, target2, command90),
|
|
8937
8937
|
set: { ...parseSet(pairs, target2.aliases, target2.textFields), ...tags },
|
|
8938
8938
|
...dryRun2 ? { dryRun: true } : {},
|
|
8939
8939
|
...flags["overwrite-pinned"] === true ? { overwritePinned: true } : {}
|
|
@@ -8999,7 +8999,7 @@ function bulkUpdateCommand(target2) {
|
|
|
8999
8999
|
};
|
|
9000
9000
|
}
|
|
9001
9001
|
function bulkDeleteCommand(target2) {
|
|
9002
|
-
const
|
|
9002
|
+
const command90 = `kenso ${target2.resource} bulk-delete`;
|
|
9003
9003
|
return {
|
|
9004
9004
|
resource: target2.resource,
|
|
9005
9005
|
action: "bulk-delete",
|
|
@@ -9023,7 +9023,7 @@ function bulkDeleteCommand(target2) {
|
|
|
9023
9023
|
beta: { featureGates: { all: target2.featureGates } },
|
|
9024
9024
|
operationIds: [`${target2.resource}.bulk-delete`, "changes.get"],
|
|
9025
9025
|
dryRun: true,
|
|
9026
|
-
run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2,
|
|
9026
|
+
run: (ctx, { flags }) => runChange(ctx, flags, `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command90), dryRun: dryRun2 }))
|
|
9027
9027
|
};
|
|
9028
9028
|
}
|
|
9029
9029
|
async function runChange(ctx, flags, path, body2) {
|
|
@@ -10246,9 +10246,9 @@ function tomlServers(text4) {
|
|
|
10246
10246
|
const entries2 = [];
|
|
10247
10247
|
let name;
|
|
10248
10248
|
for (const line of text4.split(/\r?\n/)) {
|
|
10249
|
-
const
|
|
10250
|
-
if (
|
|
10251
|
-
const m = /^mcp_servers\.(?:"([^"]+)"|'([^']+)'|([A-Za-z0-9_-]+))$/.exec(
|
|
10249
|
+
const header2 = /^\s*\[([^\]]+)\]\s*(#.*)?$/.exec(line);
|
|
10250
|
+
if (header2) {
|
|
10251
|
+
const m = /^mcp_servers\.(?:"([^"]+)"|'([^']+)'|([A-Za-z0-9_-]+))$/.exec(header2[1].trim());
|
|
10252
10252
|
name = m ? m[1] ?? m[2] ?? m[3] : void 0;
|
|
10253
10253
|
continue;
|
|
10254
10254
|
}
|
|
@@ -11059,8 +11059,8 @@ var init_browser_login = __esm({
|
|
|
11059
11059
|
defaultDeps = {
|
|
11060
11060
|
sleep: (ms, signal) => delay5(ms, void 0, signal ? { signal } : void 0),
|
|
11061
11061
|
now: () => Date.now(),
|
|
11062
|
-
spawn: (
|
|
11063
|
-
const child = nodeSpawn(
|
|
11062
|
+
spawn: (command90, args) => {
|
|
11063
|
+
const child = nodeSpawn(command90, args, { detached: true, stdio: "ignore" });
|
|
11064
11064
|
child.on("error", () => {
|
|
11065
11065
|
});
|
|
11066
11066
|
child.unref();
|
|
@@ -12451,8 +12451,8 @@ var init_run = __esm({
|
|
|
12451
12451
|
defaultDeps2 = {
|
|
12452
12452
|
sleep: (ms, signal) => delay6(ms, void 0, signal ? { signal } : void 0),
|
|
12453
12453
|
now: () => Date.now(),
|
|
12454
|
-
spawn: (
|
|
12455
|
-
const child = nodeSpawn2(
|
|
12454
|
+
spawn: (command90, args) => {
|
|
12455
|
+
const child = nodeSpawn2(command90, args, { detached: true, stdio: "ignore" });
|
|
12456
12456
|
child.on("error", () => {
|
|
12457
12457
|
});
|
|
12458
12458
|
child.unref();
|
|
@@ -12579,37 +12579,37 @@ var init_normalize = __esm({
|
|
|
12579
12579
|
});
|
|
12580
12580
|
|
|
12581
12581
|
// src/commands/contacts/mapping.ts
|
|
12582
|
-
function headerKey(
|
|
12583
|
-
return
|
|
12582
|
+
function headerKey(header2) {
|
|
12583
|
+
return header2.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
12584
12584
|
}
|
|
12585
12585
|
function isObject(value) {
|
|
12586
12586
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12587
12587
|
}
|
|
12588
|
-
function isBagHeader(
|
|
12589
|
-
return
|
|
12588
|
+
function isBagHeader(header2) {
|
|
12589
|
+
return header2.trim().toLowerCase() === "customvariables";
|
|
12590
12590
|
}
|
|
12591
12591
|
function flattenCustomVariables(headers, rows) {
|
|
12592
12592
|
const out = [];
|
|
12593
|
-
for (const
|
|
12594
|
-
if (!isBagHeader(
|
|
12595
|
-
if (!out.includes(
|
|
12593
|
+
for (const header2 of headers) {
|
|
12594
|
+
if (!isBagHeader(header2) || !rows.some((row) => isObject(row[header2]))) {
|
|
12595
|
+
if (!out.includes(header2)) out.push(header2);
|
|
12596
12596
|
continue;
|
|
12597
12597
|
}
|
|
12598
12598
|
let keepColumn = false;
|
|
12599
12599
|
for (const row of rows) {
|
|
12600
|
-
const bag = row[
|
|
12600
|
+
const bag = row[header2];
|
|
12601
12601
|
if (!isObject(bag)) {
|
|
12602
12602
|
keepColumn ||= bag !== void 0 && bag !== null && String(bag).trim() !== "";
|
|
12603
12603
|
continue;
|
|
12604
12604
|
}
|
|
12605
|
-
delete row[
|
|
12605
|
+
delete row[header2];
|
|
12606
12606
|
for (const [key, value] of Object.entries(bag)) {
|
|
12607
|
-
const name = `${
|
|
12607
|
+
const name = `${header2}.${key}`;
|
|
12608
12608
|
if (!Object.hasOwn(row, name)) row[name] = value;
|
|
12609
12609
|
if (!out.includes(name) && !headers.includes(name)) out.push(name);
|
|
12610
12610
|
}
|
|
12611
12611
|
}
|
|
12612
|
-
if (keepColumn && !out.includes(
|
|
12612
|
+
if (keepColumn && !out.includes(header2)) out.push(header2);
|
|
12613
12613
|
}
|
|
12614
12614
|
return out;
|
|
12615
12615
|
}
|
|
@@ -12655,9 +12655,9 @@ function overrideTarget(column, value, mode) {
|
|
|
12655
12655
|
}
|
|
12656
12656
|
return { field };
|
|
12657
12657
|
}
|
|
12658
|
-
function overrideFor(
|
|
12659
|
-
if (Object.hasOwn(overrides2,
|
|
12660
|
-
const wanted =
|
|
12658
|
+
function overrideFor(header2, overrides2) {
|
|
12659
|
+
if (Object.hasOwn(overrides2, header2)) return { found: true, value: overrides2[header2] ?? null };
|
|
12660
|
+
const wanted = header2.trim().toLowerCase();
|
|
12661
12661
|
for (const [key, value] of Object.entries(overrides2)) if (key.trim().toLowerCase() === wanted) return { found: true, value };
|
|
12662
12662
|
return { found: false, value: null };
|
|
12663
12663
|
}
|
|
@@ -12670,49 +12670,49 @@ function buildMapping(headers, overrides2, mode) {
|
|
|
12670
12670
|
});
|
|
12671
12671
|
}
|
|
12672
12672
|
const result = { columns: [], mapping: {}, dropped: {}, customVariableKeys: [], fields: /* @__PURE__ */ new Set() };
|
|
12673
|
-
const drop = (
|
|
12674
|
-
result.mapping[
|
|
12675
|
-
result.dropped[
|
|
12673
|
+
const drop = (header2, reason) => {
|
|
12674
|
+
result.mapping[header2] = null;
|
|
12675
|
+
result.dropped[header2] = reason;
|
|
12676
12676
|
};
|
|
12677
|
-
for (const
|
|
12678
|
-
const override2 = overrideFor(
|
|
12677
|
+
for (const header2 of headers) {
|
|
12678
|
+
const override2 = overrideFor(header2, overrides2);
|
|
12679
12679
|
let target2;
|
|
12680
12680
|
if (override2.found) {
|
|
12681
12681
|
if (override2.value === null) {
|
|
12682
|
-
drop(
|
|
12682
|
+
drop(header2, "mapped_to_null");
|
|
12683
12683
|
continue;
|
|
12684
12684
|
}
|
|
12685
|
-
target2 = overrideTarget(
|
|
12685
|
+
target2 = overrideTarget(header2, override2.value, mode);
|
|
12686
12686
|
} else {
|
|
12687
|
-
const field = fieldOf(
|
|
12688
|
-
const custom = CUSTOM_HEADER.exec(
|
|
12687
|
+
const field = fieldOf(header2);
|
|
12688
|
+
const custom = CUSTOM_HEADER.exec(header2)?.[1];
|
|
12689
12689
|
if (custom !== void 0) {
|
|
12690
12690
|
const problem = customVariableKeyProblem(custom);
|
|
12691
12691
|
if (problem) {
|
|
12692
|
-
drop(
|
|
12692
|
+
drop(header2, problem);
|
|
12693
12693
|
continue;
|
|
12694
12694
|
}
|
|
12695
12695
|
target2 = { customKey: normalizeVariableName(custom) };
|
|
12696
|
-
} else if (isBagHeader(
|
|
12697
|
-
drop(
|
|
12696
|
+
} else if (isBagHeader(header2)) {
|
|
12697
|
+
drop(header2, "not_an_object");
|
|
12698
12698
|
continue;
|
|
12699
12699
|
} else if (field && !(field === "id" && mode === "import")) {
|
|
12700
12700
|
if (mode === "update" && NOT_UPDATABLE.has(field)) {
|
|
12701
|
-
drop(
|
|
12701
|
+
drop(header2, "not_updatable");
|
|
12702
12702
|
continue;
|
|
12703
12703
|
}
|
|
12704
12704
|
target2 = { field };
|
|
12705
12705
|
} else {
|
|
12706
|
-
const problem = customVariableKeyProblem(
|
|
12706
|
+
const problem = customVariableKeyProblem(header2);
|
|
12707
12707
|
if (problem) {
|
|
12708
|
-
drop(
|
|
12708
|
+
drop(header2, problem);
|
|
12709
12709
|
continue;
|
|
12710
12710
|
}
|
|
12711
|
-
target2 = { customKey: normalizeVariableName(
|
|
12711
|
+
target2 = { customKey: normalizeVariableName(header2) };
|
|
12712
12712
|
}
|
|
12713
12713
|
}
|
|
12714
|
-
result.columns.push({ header, target: target2 });
|
|
12715
|
-
result.mapping[
|
|
12714
|
+
result.columns.push({ header: header2, target: target2 });
|
|
12715
|
+
result.mapping[header2] = targetName(target2);
|
|
12716
12716
|
if ("field" in target2) result.fields.add(target2.field);
|
|
12717
12717
|
else if (!result.customVariableKeys.includes(target2.customKey)) result.customVariableKeys.push(target2.customKey);
|
|
12718
12718
|
}
|
|
@@ -12728,8 +12728,8 @@ function readCell(value) {
|
|
|
12728
12728
|
}
|
|
12729
12729
|
function rowValues(row, mapping, mode) {
|
|
12730
12730
|
const out = { fields: {}, customVariables: {} };
|
|
12731
|
-
for (const { header, target: target2 } of mapping.columns) {
|
|
12732
|
-
const cell2 = readCell(row[
|
|
12731
|
+
for (const { header: header2, target: target2 } of mapping.columns) {
|
|
12732
|
+
const cell2 = readCell(row[header2]);
|
|
12733
12733
|
if (cell2.kind === "blank") continue;
|
|
12734
12734
|
const value = cell2.kind === "null" ? null : cell2.text;
|
|
12735
12735
|
if ("field" in target2) {
|
|
@@ -12954,25 +12954,25 @@ var init_import_send = __esm({
|
|
|
12954
12954
|
// src/commands/contacts/server-import.ts
|
|
12955
12955
|
import { readFile as readFile6 } from "node:fs/promises";
|
|
12956
12956
|
import { basename as basename3, extname as extname3, resolve as resolve8 } from "node:path";
|
|
12957
|
-
function csvTargetOf(
|
|
12958
|
-
if (mapping.dropped[
|
|
12959
|
-
const key = normalizeVariableName(
|
|
12957
|
+
function csvTargetOf(header2, mapping) {
|
|
12958
|
+
if (mapping.dropped[header2] !== "reserved_name") return void 0;
|
|
12959
|
+
const key = normalizeVariableName(header2);
|
|
12960
12960
|
return CSV_IMPORT_TARGET_FIELDS.has(key) ? key : void 0;
|
|
12961
12961
|
}
|
|
12962
12962
|
function columnMappings(mapping) {
|
|
12963
12963
|
const sent = new Map(mapping.columns.map((column) => [column.header, column.target]));
|
|
12964
12964
|
const out = [];
|
|
12965
|
-
for (const
|
|
12966
|
-
const target2 = sent.get(
|
|
12967
|
-
const csvTarget = target2 ? void 0 : csvTargetOf(
|
|
12968
|
-
if (target2 && "field" in target2) out.push({ csvColumn:
|
|
12969
|
-
else if (target2) out.push({ csvColumn:
|
|
12970
|
-
else if (csvTarget) out.push({ csvColumn:
|
|
12965
|
+
for (const header2 of Object.keys(mapping.mapping)) {
|
|
12966
|
+
const target2 = sent.get(header2);
|
|
12967
|
+
const csvTarget = target2 ? void 0 : csvTargetOf(header2, mapping);
|
|
12968
|
+
if (target2 && "field" in target2) out.push({ csvColumn: header2, targetField: TARGET_FIELDS[target2.field] ?? target2.field });
|
|
12969
|
+
else if (target2) out.push({ csvColumn: header2, targetField: "custom_variable", customVariableName: target2.customKey });
|
|
12970
|
+
else if (csvTarget) out.push({ csvColumn: header2, targetField: csvTarget });
|
|
12971
12971
|
}
|
|
12972
12972
|
return out;
|
|
12973
12973
|
}
|
|
12974
12974
|
function notUploaded(mapping) {
|
|
12975
|
-
return Object.fromEntries(Object.entries(mapping.dropped).filter(([
|
|
12975
|
+
return Object.fromEntries(Object.entries(mapping.dropped).filter(([header2]) => csvTargetOf(header2, mapping) === void 0));
|
|
12976
12976
|
}
|
|
12977
12977
|
async function readUpload2(file) {
|
|
12978
12978
|
if (file === "-") throw usageError("--server-import uploads a file: name the CSV file instead of - (stdin).", { field: "file" });
|
|
@@ -13430,12 +13430,12 @@ import { join as join17 } from "node:path";
|
|
|
13430
13430
|
function whereDir(env) {
|
|
13431
13431
|
return join17(runsRoot(env), WHERE_DIR);
|
|
13432
13432
|
}
|
|
13433
|
-
async function unfinishedWhereIds(ctx,
|
|
13433
|
+
async function unfinishedWhereIds(ctx, command90, args) {
|
|
13434
13434
|
const dir3 = whereDir(ctx.env);
|
|
13435
13435
|
const identity = argsIdentity(args);
|
|
13436
13436
|
const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
|
|
13437
13437
|
for (const run of await listRuns(ctx.env)) {
|
|
13438
|
-
if (run.command !==
|
|
13438
|
+
if (run.command !== command90 || run.status === "done" || run.status === "planned") continue;
|
|
13439
13439
|
if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
|
|
13440
13440
|
if (run.inputPath?.startsWith(`${dir3}/`) && existsSync7(run.inputPath)) return run.inputPath;
|
|
13441
13441
|
}
|
|
@@ -13581,14 +13581,14 @@ async function idsFromRun(ctx, runId) {
|
|
|
13581
13581
|
return { ...idItems(ids2), source: "run" };
|
|
13582
13582
|
}
|
|
13583
13583
|
async function collectIds(ctx, flags, kind, dryRun2) {
|
|
13584
|
-
const
|
|
13584
|
+
const command90 = `kenso contacts ${kind}`;
|
|
13585
13585
|
const ids2 = stringFlag2(flags, "ids");
|
|
13586
13586
|
const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
|
|
13587
13587
|
const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
|
|
13588
13588
|
const given = [ids2, where, run].filter((v) => v !== void 0).length;
|
|
13589
13589
|
if (given !== 1) {
|
|
13590
13590
|
const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
|
|
13591
|
-
throw usageError(`${
|
|
13591
|
+
throw usageError(`${command90} needs exactly one of ${choices}.`, { field: "ids", next: `${command90} --help` });
|
|
13592
13592
|
}
|
|
13593
13593
|
if (ids2 !== void 0) return idsFromFile(ctx, ids2);
|
|
13594
13594
|
if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
|
|
@@ -14691,7 +14691,7 @@ var init_describe = __esm({
|
|
|
14691
14691
|
const [resourceArg, action] = positionals;
|
|
14692
14692
|
const resource = resourceArg === void 0 ? void 0 : resourceAliases[resourceArg] ?? resourceArg;
|
|
14693
14693
|
const all = await entries();
|
|
14694
|
-
const
|
|
14694
|
+
const header2 = { version: VERSION, contractsHash: loadManifest().contractsHash || null };
|
|
14695
14695
|
if (resource !== void 0 && action !== void 0) {
|
|
14696
14696
|
const entry = all.find((e) => e.resource === resource && e.action === action);
|
|
14697
14697
|
if (!entry) throw unknown([resourceArg, action]);
|
|
@@ -14705,7 +14705,7 @@ var init_describe = __esm({
|
|
|
14705
14705
|
const features = gated && !ctx.flags.allCommands ? await workspaceFeatures(ctx) : [];
|
|
14706
14706
|
const visible = ctx.flags.allCommands ? scoped : scoped.filter((e) => gateSatisfied(e.gates, features));
|
|
14707
14707
|
printJson(ctx, {
|
|
14708
|
-
...
|
|
14708
|
+
...header2,
|
|
14709
14709
|
commands: visible.map(
|
|
14710
14710
|
(e) => flags.full === true ? { ...detailOf(e), handWritten: e.spec !== void 0 } : summaryOf(e, resource !== void 0)
|
|
14711
14711
|
),
|
|
@@ -15464,11 +15464,11 @@ function columnChanges(maps, columns2) {
|
|
|
15464
15464
|
return maps.map((entry) => {
|
|
15465
15465
|
const at = entry.lastIndexOf("=");
|
|
15466
15466
|
if (at < 1) throw usageError(`--map takes "Header=field" (got "${entry}").`, { field: "map", hint: 'Skip a column with "Header=".' });
|
|
15467
|
-
const
|
|
15467
|
+
const header2 = entry.slice(0, at).trim();
|
|
15468
15468
|
const field = entry.slice(at + 1).trim();
|
|
15469
|
-
const column = byHeader.get(
|
|
15469
|
+
const column = byHeader.get(header2.toLowerCase());
|
|
15470
15470
|
if (!column) {
|
|
15471
|
-
throw usageError(`The file has no column "${
|
|
15471
|
+
throw usageError(`The file has no column "${header2}".`, { field: "map", hint: `Columns: ${columns2.map((c) => c.header).join(", ")}.` });
|
|
15472
15472
|
}
|
|
15473
15473
|
if (field === "new" || field.startsWith("new:")) {
|
|
15474
15474
|
const type = field.slice(4).trim();
|
|
@@ -15710,12 +15710,12 @@ function bodyOf(layout) {
|
|
|
15710
15710
|
sections: layout.sections?.map((s) => ({ key: s.key, hidden: s.hidden ?? false }))
|
|
15711
15711
|
};
|
|
15712
15712
|
}
|
|
15713
|
-
function withHeader(layout,
|
|
15714
|
-
const pinned = new Set(
|
|
15713
|
+
function withHeader(layout, header2) {
|
|
15714
|
+
const pinned = new Set(header2.map((key) => key.toLowerCase()));
|
|
15715
15715
|
const unpinned = (layout.headerFields ?? []).filter((f) => !pinned.has(f.toLowerCase()));
|
|
15716
15716
|
return bodyOf({
|
|
15717
15717
|
version: layout.version,
|
|
15718
|
-
headerFields:
|
|
15718
|
+
headerFields: header2,
|
|
15719
15719
|
railSections: (layout.railSections ?? []).map((s, index2) => ({
|
|
15720
15720
|
name: s.name,
|
|
15721
15721
|
fields: [...index2 === 0 ? unpinned : [], ...s.fields.filter((f) => !pinned.has(f.toLowerCase()))]
|
|
@@ -15774,14 +15774,14 @@ var init_layouts = __esm({
|
|
|
15774
15774
|
dryRun: true,
|
|
15775
15775
|
async run(ctx, { flags, positionals }) {
|
|
15776
15776
|
const object = objectOf(positionals, "set");
|
|
15777
|
-
const
|
|
15777
|
+
const header2 = typeof flags.header === "string" ? flags.header : void 0;
|
|
15778
15778
|
const data = typeof flags.data === "string" ? flags.data : void 0;
|
|
15779
|
-
if (
|
|
15779
|
+
if (header2 === void 0 === (data === void 0)) {
|
|
15780
15780
|
throw usageError("Pass one of --header or --data.", { next: `kenso layouts set ${object} --header tier,ownerMemberId` });
|
|
15781
15781
|
}
|
|
15782
15782
|
let body2;
|
|
15783
|
-
if (
|
|
15784
|
-
const keys =
|
|
15783
|
+
if (header2 !== void 0) {
|
|
15784
|
+
const keys = header2.split(",").map((k) => k.trim()).filter(Boolean);
|
|
15785
15785
|
body2 = withHeader(await call(ctx, "GET", object), keys);
|
|
15786
15786
|
} else {
|
|
15787
15787
|
const parsed2 = await readDataArg(data, ctx.stdin);
|
|
@@ -17356,8 +17356,8 @@ import { resolve as resolve11 } from "node:path";
|
|
|
17356
17356
|
function kebab(key) {
|
|
17357
17357
|
return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
17358
17358
|
}
|
|
17359
|
-
function commandWords(
|
|
17360
|
-
return
|
|
17359
|
+
function commandWords(command90) {
|
|
17360
|
+
return command90.trim().split(/\s+/).filter((t) => t !== "");
|
|
17361
17361
|
}
|
|
17362
17362
|
function flagValue(value) {
|
|
17363
17363
|
return typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
@@ -18378,10 +18378,10 @@ async function bundleFiles(ctx, templateId, files) {
|
|
|
18378
18378
|
}
|
|
18379
18379
|
return out;
|
|
18380
18380
|
}
|
|
18381
|
-
async function download2(url, path,
|
|
18381
|
+
async function download2(url, path, sha2566, signal) {
|
|
18382
18382
|
const res = await presigned(url, { method: "GET" }, `Downloading ${path}`, "download_failed", signal);
|
|
18383
18383
|
const bytes = Buffer.from(await res.arrayBuffer());
|
|
18384
|
-
if (
|
|
18384
|
+
if (sha2566 && createHash8("sha256").update(bytes).digest("hex") !== sha2566.toLowerCase()) {
|
|
18385
18385
|
throw new KensoError({
|
|
18386
18386
|
code: "download_failed",
|
|
18387
18387
|
message: `${path} did not download intact (its SHA-256 does not match).`,
|
|
@@ -19643,7 +19643,7 @@ async function poll2(ctx, types, cursor2) {
|
|
|
19643
19643
|
return unwrap(res.body) ?? {};
|
|
19644
19644
|
}
|
|
19645
19645
|
function readBody(req) {
|
|
19646
|
-
return new Promise((
|
|
19646
|
+
return new Promise((resolve23, reject) => {
|
|
19647
19647
|
let size = 0;
|
|
19648
19648
|
const chunks = [];
|
|
19649
19649
|
req.on("data", (chunk) => {
|
|
@@ -19651,7 +19651,7 @@ function readBody(req) {
|
|
|
19651
19651
|
if (size > MAX_TRIGGER_BYTES) req.destroy(new Error("too large"));
|
|
19652
19652
|
else chunks.push(chunk);
|
|
19653
19653
|
});
|
|
19654
|
-
req.on("end", () =>
|
|
19654
|
+
req.on("end", () => resolve23(Buffer.concat(chunks).toString("utf8")));
|
|
19655
19655
|
req.on("error", reject);
|
|
19656
19656
|
});
|
|
19657
19657
|
}
|
|
@@ -19740,7 +19740,7 @@ var init_listen = __esm({
|
|
|
19740
19740
|
reply(res, 200, { forward: result ?? null });
|
|
19741
19741
|
}).catch(() => reply(res, 400, { error: "invalid_event" }));
|
|
19742
19742
|
});
|
|
19743
|
-
await new Promise((
|
|
19743
|
+
await new Promise((resolve23) => server.listen(0, "127.0.0.1", resolve23));
|
|
19744
19744
|
const url = `http://127.0.0.1:${server.address().port}/events`;
|
|
19745
19745
|
writeListenerState(ctx.env, workspaceId, { pid: process.pid, url, token, forwardTo: target2, startedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
19746
19746
|
try {
|
|
@@ -20057,9 +20057,9 @@ var init_files = __esm({
|
|
|
20057
20057
|
import { execFile, spawnSync as spawnSync2 } from "node:child_process";
|
|
20058
20058
|
import { readFileSync as readFileSync18 } from "node:fs";
|
|
20059
20059
|
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
20060
|
-
function sudoArgs(user,
|
|
20060
|
+
function sudoArgs(user, command90, args, keep = [], set2 = {}) {
|
|
20061
20061
|
const assignments = Object.entries(set2).map(([name, value]) => `${name}=${value}`);
|
|
20062
|
-
return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--",
|
|
20062
|
+
return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command90, ...args];
|
|
20063
20063
|
}
|
|
20064
20064
|
function agentKensoEnv(opts) {
|
|
20065
20065
|
return {
|
|
@@ -20069,16 +20069,16 @@ function agentKensoEnv(opts) {
|
|
|
20069
20069
|
AI_AGENT: opts.agentName
|
|
20070
20070
|
};
|
|
20071
20071
|
}
|
|
20072
|
-
function sudoExec(user,
|
|
20072
|
+
function sudoExec(user, command90, args, opts = {}) {
|
|
20073
20073
|
const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
|
|
20074
|
-
return new Promise((
|
|
20074
|
+
return new Promise((resolve23) => {
|
|
20075
20075
|
execFile(
|
|
20076
20076
|
sudo,
|
|
20077
|
-
[...lead, ...sudoArgs(user.name,
|
|
20077
|
+
[...lead, ...sudoArgs(user.name, command90, args)],
|
|
20078
20078
|
{ env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
|
|
20079
20079
|
(err, stdout, stderr) => {
|
|
20080
20080
|
const code = err ? err.code : 0;
|
|
20081
|
-
|
|
20081
|
+
resolve23({ exitCode: typeof code === "number" ? code : null, stdout, stderr });
|
|
20082
20082
|
}
|
|
20083
20083
|
);
|
|
20084
20084
|
});
|
|
@@ -20184,9 +20184,9 @@ var init_folder3 = __esm({
|
|
|
20184
20184
|
init_redact();
|
|
20185
20185
|
init_agent_user();
|
|
20186
20186
|
WorkRunFolder = class {
|
|
20187
|
-
constructor(ctx,
|
|
20187
|
+
constructor(ctx, command90, args, outDir, shared = false) {
|
|
20188
20188
|
this.ctx = ctx;
|
|
20189
|
-
this.command =
|
|
20189
|
+
this.command = command90;
|
|
20190
20190
|
this.args = args;
|
|
20191
20191
|
this.outDir = outDir;
|
|
20192
20192
|
this.shared = shared;
|
|
@@ -20737,7 +20737,7 @@ async function groupGone(pid, runAs) {
|
|
|
20737
20737
|
}
|
|
20738
20738
|
}
|
|
20739
20739
|
function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
20740
|
-
return new Promise((
|
|
20740
|
+
return new Promise((resolve23) => {
|
|
20741
20741
|
const stdout = new Tail(OUTPUT_CAP_BYTES);
|
|
20742
20742
|
const stderr = new Tail(OUTPUT_CAP_BYTES);
|
|
20743
20743
|
let child;
|
|
@@ -20752,7 +20752,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
20752
20752
|
shell: false
|
|
20753
20753
|
});
|
|
20754
20754
|
} catch (err) {
|
|
20755
|
-
|
|
20755
|
+
resolve23({ exitCode: null, stdout: "", stderr: "", spawnError: err });
|
|
20756
20756
|
return;
|
|
20757
20757
|
}
|
|
20758
20758
|
let stopped;
|
|
@@ -20770,7 +20770,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
20770
20770
|
signal?.removeEventListener("abort", onAbort);
|
|
20771
20771
|
void groupGone(pid, runAs).then(() => {
|
|
20772
20772
|
if (pid !== void 0) liveGroups.delete(pid);
|
|
20773
|
-
|
|
20773
|
+
resolve23({ exitCode, stdout: stdout.text(), stderr: stderr.text(), stopped, spawnError });
|
|
20774
20774
|
});
|
|
20775
20775
|
};
|
|
20776
20776
|
const stop = (why) => {
|
|
@@ -20962,25 +20962,25 @@ function plain(text4) {
|
|
|
20962
20962
|
return text4.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
|
|
20963
20963
|
}
|
|
20964
20964
|
function runStatus(bin, args, env, adapter, runAs) {
|
|
20965
|
-
const
|
|
20965
|
+
const command90 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
|
|
20966
20966
|
const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
|
|
20967
20967
|
const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
|
|
20968
|
-
return new Promise((
|
|
20968
|
+
return new Promise((resolve23) => {
|
|
20969
20969
|
execFile2(
|
|
20970
|
-
|
|
20970
|
+
command90,
|
|
20971
20971
|
commandArgs2,
|
|
20972
20972
|
{ ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
|
|
20973
20973
|
(err, stdout, stderr) => {
|
|
20974
20974
|
if (err && typeof err.code === "string") {
|
|
20975
|
-
|
|
20975
|
+
resolve23(void 0);
|
|
20976
20976
|
return;
|
|
20977
20977
|
}
|
|
20978
20978
|
if (err && err.killed) {
|
|
20979
|
-
|
|
20979
|
+
resolve23(void 0);
|
|
20980
20980
|
return;
|
|
20981
20981
|
}
|
|
20982
20982
|
const exitCode = err ? err.code ?? null : 0;
|
|
20983
|
-
|
|
20983
|
+
resolve23({ exitCode: typeof exitCode === "number" ? exitCode : null, stdout: plain(String(stdout)), stderr: plain(String(stderr)) });
|
|
20984
20984
|
}
|
|
20985
20985
|
);
|
|
20986
20986
|
});
|
|
@@ -21762,7 +21762,7 @@ var init_instruction = __esm({
|
|
|
21762
21762
|
// src/work/pool.ts
|
|
21763
21763
|
function runPool(opts) {
|
|
21764
21764
|
const limit = Math.min(MAX_PARALLEL, Math.max(1, Math.floor(Number.isFinite(opts.parallel) ? opts.parallel : 1)));
|
|
21765
|
-
return new Promise((
|
|
21765
|
+
return new Promise((resolve23, reject) => {
|
|
21766
21766
|
let running = 0;
|
|
21767
21767
|
let filling = false;
|
|
21768
21768
|
let again = false;
|
|
@@ -21802,7 +21802,7 @@ function runPool(opts) {
|
|
|
21802
21802
|
const stopping = empty || failure !== void 0 || opts.signal?.aborted === true;
|
|
21803
21803
|
if (stopping && running === 0 && !again) {
|
|
21804
21804
|
if (failure) reject(failure.error);
|
|
21805
|
-
else
|
|
21805
|
+
else resolve23();
|
|
21806
21806
|
return;
|
|
21807
21807
|
}
|
|
21808
21808
|
} while (again);
|
|
@@ -22415,15 +22415,6 @@ var init_work2 = __esm({
|
|
|
22415
22415
|
}
|
|
22416
22416
|
});
|
|
22417
22417
|
|
|
22418
|
-
// src/commands/workflow-runs/index.ts
|
|
22419
|
-
var actions35;
|
|
22420
|
-
var init_workflow_runs = __esm({
|
|
22421
|
-
"src/commands/workflow-runs/index.ts"() {
|
|
22422
|
-
"use strict";
|
|
22423
|
-
actions35 = {};
|
|
22424
|
-
}
|
|
22425
|
-
});
|
|
22426
|
-
|
|
22427
22418
|
// src/commands/workflows/files.ts
|
|
22428
22419
|
import { mkdirSync as mkdirSync7, readFileSync as readFileSync19, writeFileSync as writeFileSync11 } from "node:fs";
|
|
22429
22420
|
import { basename as basename7, dirname as dirname6, join as join30, relative as relative2, resolve as resolve19, sep as sep3 } from "node:path";
|
|
@@ -22555,6 +22546,178 @@ var init_files2 = __esm({
|
|
|
22555
22546
|
}
|
|
22556
22547
|
});
|
|
22557
22548
|
|
|
22549
|
+
// src/commands/workflows/run-wait.ts
|
|
22550
|
+
import { setTimeout as delay13 } from "node:timers/promises";
|
|
22551
|
+
function roundCredits(value) {
|
|
22552
|
+
return Math.round(value * 1e3) / 1e3;
|
|
22553
|
+
}
|
|
22554
|
+
function runCredits(run) {
|
|
22555
|
+
if (typeof run.creditsCharged === "number") return roundCredits(run.creditsCharged);
|
|
22556
|
+
if (typeof run.creditsChargedMillicredits === "number") return roundCredits(run.creditsChargedMillicredits / 1e3);
|
|
22557
|
+
return void 0;
|
|
22558
|
+
}
|
|
22559
|
+
function stepErrorText(step) {
|
|
22560
|
+
const text4 = [step.errorClass, step.errorMessage].filter((part) => typeof part === "string" && part !== "").join(": ");
|
|
22561
|
+
return text4 === "" ? void 0 : text4;
|
|
22562
|
+
}
|
|
22563
|
+
async function readRun2(client, runId, signal) {
|
|
22564
|
+
const res = await client.request({ method: "GET", path: `/v1/workflow-runs/${runId}`, signal });
|
|
22565
|
+
const data = unwrap(res.body);
|
|
22566
|
+
return data !== null && typeof data === "object" ? { ...data, id: typeof data.id === "number" ? data.id : runId } : { id: runId };
|
|
22567
|
+
}
|
|
22568
|
+
async function waitForRuns(client, runIds, opts) {
|
|
22569
|
+
const now = opts.now ?? Date.now;
|
|
22570
|
+
const sleep = opts.sleep ?? ((ms) => delay13(ms, void 0, { signal: opts.signal }));
|
|
22571
|
+
const runs = /* @__PURE__ */ new Map();
|
|
22572
|
+
let open2 = [...new Set(runIds)];
|
|
22573
|
+
const total = open2.length;
|
|
22574
|
+
const started = now();
|
|
22575
|
+
try {
|
|
22576
|
+
for (; ; ) {
|
|
22577
|
+
let next = 0;
|
|
22578
|
+
const failures = [];
|
|
22579
|
+
const reader = async () => {
|
|
22580
|
+
while (next < open2.length && failures.length === 0) {
|
|
22581
|
+
const id = open2[next++];
|
|
22582
|
+
try {
|
|
22583
|
+
runs.set(id, await readRun2(client, id, opts.signal));
|
|
22584
|
+
} catch (err) {
|
|
22585
|
+
failures.push(err);
|
|
22586
|
+
}
|
|
22587
|
+
}
|
|
22588
|
+
};
|
|
22589
|
+
await Promise.all(Array.from({ length: Math.min(MAX_PARALLEL_READS, open2.length) }, reader));
|
|
22590
|
+
if (failures.length > 0) throw failures[0];
|
|
22591
|
+
open2 = open2.filter((id) => OPEN_RUN_STATUSES.has(runs.get(id)?.status ?? "queued"));
|
|
22592
|
+
opts.onProgress?.(open2.length, total);
|
|
22593
|
+
const elapsed = now() - started;
|
|
22594
|
+
if (open2.length === 0 || elapsed >= opts.timeoutMs) return { runs, interrupted: false };
|
|
22595
|
+
await sleep(Math.min(elapsed >= FAST_PHASE_MS2 ? SLOW_INTERVAL_MS2 : FAST_INTERVAL_MS, opts.timeoutMs - elapsed));
|
|
22596
|
+
}
|
|
22597
|
+
} catch (err) {
|
|
22598
|
+
if (opts.signal.aborted || err instanceof KensoError && err.exitCode === ExitCode.Interrupted) return { runs, interrupted: true };
|
|
22599
|
+
return { runs, interrupted: false, stopped: err instanceof Error ? err.message : String(err) };
|
|
22600
|
+
}
|
|
22601
|
+
}
|
|
22602
|
+
var OPEN_RUN_STATUSES, MAX_PARALLEL_READS, FAST_INTERVAL_MS, SLOW_INTERVAL_MS2, FAST_PHASE_MS2;
|
|
22603
|
+
var init_run_wait = __esm({
|
|
22604
|
+
"src/commands/workflows/run-wait.ts"() {
|
|
22605
|
+
"use strict";
|
|
22606
|
+
init_errors();
|
|
22607
|
+
init_exit_codes();
|
|
22608
|
+
init_http();
|
|
22609
|
+
OPEN_RUN_STATUSES = /* @__PURE__ */ new Set(["queued", "running", "waiting"]);
|
|
22610
|
+
MAX_PARALLEL_READS = 8;
|
|
22611
|
+
FAST_INTERVAL_MS = 2e3;
|
|
22612
|
+
SLOW_INTERVAL_MS2 = 1e4;
|
|
22613
|
+
FAST_PHASE_MS2 = 6e4;
|
|
22614
|
+
}
|
|
22615
|
+
});
|
|
22616
|
+
|
|
22617
|
+
// src/commands/workflow-runs/logs.ts
|
|
22618
|
+
var logs_exports = {};
|
|
22619
|
+
__export(logs_exports, {
|
|
22620
|
+
default: () => logs_default
|
|
22621
|
+
});
|
|
22622
|
+
function msBetween(start, end) {
|
|
22623
|
+
if (!start || !end) return null;
|
|
22624
|
+
const ms = Date.parse(end) - Date.parse(start);
|
|
22625
|
+
return Number.isFinite(ms) ? ms : null;
|
|
22626
|
+
}
|
|
22627
|
+
function inStartOrder(steps) {
|
|
22628
|
+
const at = (step) => {
|
|
22629
|
+
const time = step.startedAt ? Date.parse(step.startedAt) : Number.NaN;
|
|
22630
|
+
return Number.isFinite(time) ? time : Number.POSITIVE_INFINITY;
|
|
22631
|
+
};
|
|
22632
|
+
return steps.map((step, index2) => ({ step, index: index2, time: at(step) })).sort((a, b) => a.time === b.time ? a.index - b.index : a.time < b.time ? -1 : 1).map((entry) => entry.step);
|
|
22633
|
+
}
|
|
22634
|
+
function stepRow(step, full) {
|
|
22635
|
+
return {
|
|
22636
|
+
nodeId: step.nodeId ?? null,
|
|
22637
|
+
stepType: step.stepType ?? null,
|
|
22638
|
+
status: step.status ?? null,
|
|
22639
|
+
attempt: step.attempt ?? null,
|
|
22640
|
+
startedAt: step.startedAt ?? null,
|
|
22641
|
+
endedAt: step.endedAt ?? null,
|
|
22642
|
+
ms: msBetween(step.startedAt, step.endedAt),
|
|
22643
|
+
credits: typeof step.creditsMillicredits === "number" ? roundCredits(step.creditsMillicredits / 1e3) : null,
|
|
22644
|
+
error: stepErrorText(step) ?? null,
|
|
22645
|
+
...full ? { input: step.input ?? null, output: step.output ?? null, attempts: step.attempts ?? [] } : {}
|
|
22646
|
+
};
|
|
22647
|
+
}
|
|
22648
|
+
function header(run) {
|
|
22649
|
+
const record3 = run.recordType && run.recordType !== "none" ? `${run.recordType} ${run.recordId ?? "?"}` : "no record";
|
|
22650
|
+
return `run ${run.id}: ${run.status ?? "unknown"}, workflow ${run.workflowId ?? "?"}, ${record3}, charged ${runCredits(run) ?? 0} credits`;
|
|
22651
|
+
}
|
|
22652
|
+
var command78, logs_default;
|
|
22653
|
+
var init_logs2 = __esm({
|
|
22654
|
+
"src/commands/workflow-runs/logs.ts"() {
|
|
22655
|
+
"use strict";
|
|
22656
|
+
init_errors();
|
|
22657
|
+
init_exit_codes();
|
|
22658
|
+
init_files2();
|
|
22659
|
+
init_run_wait();
|
|
22660
|
+
command78 = {
|
|
22661
|
+
resource: "workflow-runs",
|
|
22662
|
+
action: "logs",
|
|
22663
|
+
summary: "Print a workflow run's steps: status, attempt, time, credits and error",
|
|
22664
|
+
brief: "a run's steps",
|
|
22665
|
+
description: "Reads GET /v1/workflow-runs/{runId} and prints one row per step run in start order: nodeId, stepType, status, attempt, startedAt, endedAt, ms, credits and error (errorClass: errorMessage). A header line on stderr names the run's status, workflow, record and the credits it charged, and its needs-attention reason when it has one. --step keeps one step; --full adds each step's input, output and attempts. A failed run ends with the retry command to try first. A succeeded run's step outputs are dropped 7 days after it ends unless the workflow keeps success details.",
|
|
22666
|
+
effect: "read",
|
|
22667
|
+
flags: {
|
|
22668
|
+
step: { type: "string", description: "Keep one step: its id in the workflow definition" },
|
|
22669
|
+
full: { type: "boolean", description: "Add each step's input, output and attempts" }
|
|
22670
|
+
},
|
|
22671
|
+
positionals: [{ name: "runId", required: true, description: "The run id (kenso workflow-runs list, or the runId column of a results file)" }],
|
|
22672
|
+
examples: ["kenso workflow-runs logs 9001", "kenso workflow-runs logs 9001 --step qualify --full -o json"],
|
|
22673
|
+
beta: { featureGates: WORKFLOWS_GATES },
|
|
22674
|
+
operationIds: ["workflow-runs.get"],
|
|
22675
|
+
async run(ctx, { flags, positionals }) {
|
|
22676
|
+
const text4 = (positionals[0] ?? "").trim();
|
|
22677
|
+
const runId = Number(text4);
|
|
22678
|
+
if (!/^\d+$/.test(text4) || !Number.isSafeInteger(runId) || runId < 1) {
|
|
22679
|
+
throw usageError(`"${text4}" is not a run id: a run id is a positive whole number.`, {
|
|
22680
|
+
field: "runId",
|
|
22681
|
+
next: "kenso workflow-runs list --workflow-id <workflowId>"
|
|
22682
|
+
});
|
|
22683
|
+
}
|
|
22684
|
+
const run = await readRun2(ctx.client, runId, ctx.signal);
|
|
22685
|
+
let steps = inStartOrder(run.steps ?? []);
|
|
22686
|
+
const step = typeof flags.step === "string" ? flags.step.trim() : void 0;
|
|
22687
|
+
if (step !== void 0) {
|
|
22688
|
+
steps = steps.filter((s) => s.nodeId === step);
|
|
22689
|
+
if (steps.length === 0) {
|
|
22690
|
+
throw new KensoError({
|
|
22691
|
+
code: "not_found",
|
|
22692
|
+
message: `Run ${runId} has no step ${step}.`,
|
|
22693
|
+
exitCode: ExitCode.NotFound,
|
|
22694
|
+
field: "step",
|
|
22695
|
+
next: `kenso workflow-runs logs ${runId}`
|
|
22696
|
+
});
|
|
22697
|
+
}
|
|
22698
|
+
}
|
|
22699
|
+
ctx.output.info(header(run));
|
|
22700
|
+
if (run.needsAttentionReason) ctx.output.info(`needs attention: ${run.needsAttentionReason}`);
|
|
22701
|
+
await ctx.output.list(steps.map((s) => stepRow(s, flags.full === true)));
|
|
22702
|
+
if (run.status === "failed") ctx.output.info(`next: kenso workflow-runs retry --run-id ${runId} --dry-run`);
|
|
22703
|
+
return ExitCode.Ok;
|
|
22704
|
+
}
|
|
22705
|
+
};
|
|
22706
|
+
logs_default = command78;
|
|
22707
|
+
}
|
|
22708
|
+
});
|
|
22709
|
+
|
|
22710
|
+
// src/commands/workflow-runs/index.ts
|
|
22711
|
+
var actions35;
|
|
22712
|
+
var init_workflow_runs = __esm({
|
|
22713
|
+
"src/commands/workflow-runs/index.ts"() {
|
|
22714
|
+
"use strict";
|
|
22715
|
+
actions35 = {
|
|
22716
|
+
logs: () => Promise.resolve().then(() => (init_logs2(), logs_exports)).then((m) => m.default)
|
|
22717
|
+
};
|
|
22718
|
+
}
|
|
22719
|
+
});
|
|
22720
|
+
|
|
22558
22721
|
// src/commands/workflows/init.ts
|
|
22559
22722
|
var init_exports = {};
|
|
22560
22723
|
__export(init_exports, {
|
|
@@ -22562,7 +22725,7 @@ __export(init_exports, {
|
|
|
22562
22725
|
});
|
|
22563
22726
|
import { existsSync as existsSync13 } from "node:fs";
|
|
22564
22727
|
import { join as join31, resolve as resolve20 } from "node:path";
|
|
22565
|
-
var STEM,
|
|
22728
|
+
var STEM, command79, init_default;
|
|
22566
22729
|
var init_init = __esm({
|
|
22567
22730
|
"src/commands/workflows/init.ts"() {
|
|
22568
22731
|
"use strict";
|
|
@@ -22572,7 +22735,7 @@ var init_init = __esm({
|
|
|
22572
22735
|
init_http();
|
|
22573
22736
|
init_files2();
|
|
22574
22737
|
STEM = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
22575
|
-
|
|
22738
|
+
command79 = {
|
|
22576
22739
|
resource: "workflows",
|
|
22577
22740
|
action: "init",
|
|
22578
22741
|
summary: "Start a workflow file in this folder",
|
|
@@ -22628,7 +22791,7 @@ var init_init = __esm({
|
|
|
22628
22791
|
return ExitCode.Ok;
|
|
22629
22792
|
}
|
|
22630
22793
|
};
|
|
22631
|
-
init_default =
|
|
22794
|
+
init_default = command79;
|
|
22632
22795
|
}
|
|
22633
22796
|
});
|
|
22634
22797
|
|
|
@@ -22641,7 +22804,7 @@ import { existsSync as existsSync14 } from "node:fs";
|
|
|
22641
22804
|
function slugOf(name) {
|
|
22642
22805
|
return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/, "");
|
|
22643
22806
|
}
|
|
22644
|
-
var
|
|
22807
|
+
var command80, pull_default3;
|
|
22645
22808
|
var init_pull3 = __esm({
|
|
22646
22809
|
"src/commands/workflows/pull.ts"() {
|
|
22647
22810
|
"use strict";
|
|
@@ -22649,7 +22812,7 @@ var init_pull3 = __esm({
|
|
|
22649
22812
|
init_exit_codes();
|
|
22650
22813
|
init_common4();
|
|
22651
22814
|
init_files2();
|
|
22652
|
-
|
|
22815
|
+
command80 = {
|
|
22653
22816
|
resource: "workflows",
|
|
22654
22817
|
action: "pull",
|
|
22655
22818
|
summary: "Write a workflow's definition to a file and bind it",
|
|
@@ -22708,7 +22871,7 @@ var init_pull3 = __esm({
|
|
|
22708
22871
|
return ExitCode.Ok;
|
|
22709
22872
|
}
|
|
22710
22873
|
};
|
|
22711
|
-
pull_default3 =
|
|
22874
|
+
pull_default3 = command80;
|
|
22712
22875
|
}
|
|
22713
22876
|
});
|
|
22714
22877
|
|
|
@@ -22741,7 +22904,7 @@ function perRecord(estimate2) {
|
|
|
22741
22904
|
const max = bulk ? totals.bulkMaxMillicredits : totals.maxMillicredits;
|
|
22742
22905
|
return typeof expected === "number" && typeof max === "number" ? { expectedCredits: expected / 1e3, maxCredits: max / 1e3 } : null;
|
|
22743
22906
|
}
|
|
22744
|
-
var FILE3,
|
|
22907
|
+
var FILE3, command81, check_default;
|
|
22745
22908
|
var init_check = __esm({
|
|
22746
22909
|
"src/commands/workflows/check.ts"() {
|
|
22747
22910
|
"use strict";
|
|
@@ -22752,7 +22915,7 @@ var init_check = __esm({
|
|
|
22752
22915
|
init_columns();
|
|
22753
22916
|
init_files2();
|
|
22754
22917
|
FILE3 = { name: "file", required: true, description: "The workflow file (<name>.workflow.json)" };
|
|
22755
|
-
|
|
22918
|
+
command81 = {
|
|
22756
22919
|
resource: "workflows",
|
|
22757
22920
|
action: "check",
|
|
22758
22921
|
summary: "Validate a workflow file on the server and print one record's credit estimate",
|
|
@@ -22793,7 +22956,7 @@ var init_check = __esm({
|
|
|
22793
22956
|
return valid ? ExitCode.Ok : ExitCode.Partial;
|
|
22794
22957
|
}
|
|
22795
22958
|
};
|
|
22796
|
-
check_default =
|
|
22959
|
+
check_default = command81;
|
|
22797
22960
|
}
|
|
22798
22961
|
});
|
|
22799
22962
|
|
|
@@ -22857,7 +23020,7 @@ function state(workflow, saved, published, extra = {}) {
|
|
|
22857
23020
|
...extra
|
|
22858
23021
|
};
|
|
22859
23022
|
}
|
|
22860
|
-
var
|
|
23023
|
+
var command82, push_default2;
|
|
22861
23024
|
var init_push2 = __esm({
|
|
22862
23025
|
"src/commands/workflows/push.ts"() {
|
|
22863
23026
|
"use strict";
|
|
@@ -22867,7 +23030,7 @@ var init_push2 = __esm({
|
|
|
22867
23030
|
init_columns();
|
|
22868
23031
|
init_check();
|
|
22869
23032
|
init_files2();
|
|
22870
|
-
|
|
23033
|
+
command82 = {
|
|
22871
23034
|
resource: "workflows",
|
|
22872
23035
|
action: "push",
|
|
22873
23036
|
summary: "Save a workflow file as the workflow's draft, and publish it with --publish",
|
|
@@ -22971,7 +23134,7 @@ var init_push2 = __esm({
|
|
|
22971
23134
|
return ExitCode.Ok;
|
|
22972
23135
|
}
|
|
22973
23136
|
};
|
|
22974
|
-
push_default2 =
|
|
23137
|
+
push_default2 = command82;
|
|
22975
23138
|
}
|
|
22976
23139
|
});
|
|
22977
23140
|
|
|
@@ -23004,7 +23167,7 @@ async function startTest(ctx, workflowId, body2) {
|
|
|
23004
23167
|
});
|
|
23005
23168
|
}
|
|
23006
23169
|
}
|
|
23007
|
-
var RECORD_TYPES2, MAX_WAIT_SECONDS,
|
|
23170
|
+
var RECORD_TYPES2, MAX_WAIT_SECONDS, command83, test_default;
|
|
23008
23171
|
var init_test = __esm({
|
|
23009
23172
|
"src/commands/workflows/test.ts"() {
|
|
23010
23173
|
"use strict";
|
|
@@ -23016,7 +23179,7 @@ var init_test = __esm({
|
|
|
23016
23179
|
init_files2();
|
|
23017
23180
|
RECORD_TYPES2 = ["account", "person", "lead", "place"];
|
|
23018
23181
|
MAX_WAIT_SECONDS = 50;
|
|
23019
|
-
|
|
23182
|
+
command83 = {
|
|
23020
23183
|
resource: "workflows",
|
|
23021
23184
|
action: "test",
|
|
23022
23185
|
summary: "Run the saved draft of a workflow file on one record and print the hash to publish with",
|
|
@@ -23072,7 +23235,7 @@ var init_test = __esm({
|
|
|
23072
23235
|
return passed ? ExitCode.Ok : ExitCode.Error;
|
|
23073
23236
|
}
|
|
23074
23237
|
};
|
|
23075
|
-
test_default =
|
|
23238
|
+
test_default = command83;
|
|
23076
23239
|
}
|
|
23077
23240
|
});
|
|
23078
23241
|
|
|
@@ -23106,7 +23269,7 @@ function diffDefinitions(from, to) {
|
|
|
23106
23269
|
stepsChanged: [...after.keys()].filter((id) => before.has(id) && differs(before.get(id), after.get(id)))
|
|
23107
23270
|
};
|
|
23108
23271
|
}
|
|
23109
|
-
var
|
|
23272
|
+
var command84, diff_default;
|
|
23110
23273
|
var init_diff = __esm({
|
|
23111
23274
|
"src/commands/workflows/diff.ts"() {
|
|
23112
23275
|
"use strict";
|
|
@@ -23115,7 +23278,7 @@ var init_diff = __esm({
|
|
|
23115
23278
|
init_columns();
|
|
23116
23279
|
init_check();
|
|
23117
23280
|
init_files2();
|
|
23118
|
-
|
|
23281
|
+
command84 = {
|
|
23119
23282
|
resource: "workflows",
|
|
23120
23283
|
action: "diff",
|
|
23121
23284
|
summary: "Compare a workflow file with the published version or the draft",
|
|
@@ -23143,7 +23306,7 @@ var init_diff = __esm({
|
|
|
23143
23306
|
return ExitCode.Ok;
|
|
23144
23307
|
}
|
|
23145
23308
|
};
|
|
23146
|
-
diff_default =
|
|
23309
|
+
diff_default = command84;
|
|
23147
23310
|
}
|
|
23148
23311
|
});
|
|
23149
23312
|
|
|
@@ -23227,7 +23390,7 @@ function workflowFileSchema(stepTypes) {
|
|
|
23227
23390
|
}
|
|
23228
23391
|
};
|
|
23229
23392
|
}
|
|
23230
|
-
var SCHEMA_ID, STEP_ID, MORE_THAN_ZERO,
|
|
23393
|
+
var SCHEMA_ID, STEP_ID, MORE_THAN_ZERO, command85, schema_default;
|
|
23231
23394
|
var init_schema = __esm({
|
|
23232
23395
|
"src/commands/workflows/schema.ts"() {
|
|
23233
23396
|
"use strict";
|
|
@@ -23238,7 +23401,7 @@ var init_schema = __esm({
|
|
|
23238
23401
|
SCHEMA_ID = "https://ken.so/schemas/workflow-file.json";
|
|
23239
23402
|
STEP_ID = "^[a-z][a-z0-9_]{0,39}$";
|
|
23240
23403
|
MORE_THAN_ZERO = { type: "number", exclusiveMinimum: 0 };
|
|
23241
|
-
|
|
23404
|
+
command85 = {
|
|
23242
23405
|
resource: "workflows",
|
|
23243
23406
|
action: "schema",
|
|
23244
23407
|
summary: "Print a JSON Schema for workflow files, for editors",
|
|
@@ -23264,7 +23427,7 @@ var init_schema = __esm({
|
|
|
23264
23427
|
return ExitCode.Ok;
|
|
23265
23428
|
}
|
|
23266
23429
|
};
|
|
23267
|
-
schema_default =
|
|
23430
|
+
schema_default = command85;
|
|
23268
23431
|
}
|
|
23269
23432
|
});
|
|
23270
23433
|
|
|
@@ -23362,7 +23525,7 @@ async function readRunInput(ctx, opts) {
|
|
|
23362
23525
|
const name = opts.file ?? "";
|
|
23363
23526
|
const file = await readInput(name, { stdin: ctx.stdin });
|
|
23364
23527
|
const input = { path: file.path, sha256: file.sha256 };
|
|
23365
|
-
const idColumn = file.headers.find((
|
|
23528
|
+
const idColumn = file.headers.find((header2) => header2.trim().toLowerCase() === "id");
|
|
23366
23529
|
if (idColumn !== void 0) {
|
|
23367
23530
|
return { input, ...fromIds(ctx, file.rows.map((row) => String(row[idColumn] ?? "").trim()), type) };
|
|
23368
23531
|
}
|
|
@@ -23467,8 +23630,8 @@ function answeredJournals(run, workflowId) {
|
|
|
23467
23630
|
}
|
|
23468
23631
|
return journals;
|
|
23469
23632
|
}
|
|
23470
|
-
async function earlierRun(ctx, args,
|
|
23471
|
-
const earlier = (await findIdentical(COMMAND7, args,
|
|
23633
|
+
async function earlierRun(ctx, args, sha2566, workflowId) {
|
|
23634
|
+
const earlier = (await findIdentical(COMMAND7, args, sha2566, ctx.env, ctx.client.workspaceId ?? ctx.auth.workspaceId)).filter((run) => run.status !== "planned");
|
|
23472
23635
|
const open2 = earlier.find((run) => run.status !== "done");
|
|
23473
23636
|
if (open2) {
|
|
23474
23637
|
answeredJournals(open2, workflowId);
|
|
@@ -23573,12 +23736,233 @@ var init_run_start = __esm({
|
|
|
23573
23736
|
}
|
|
23574
23737
|
});
|
|
23575
23738
|
|
|
23739
|
+
// src/commands/workflows/run-results.ts
|
|
23740
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
23741
|
+
import { existsSync as existsSync16, readFileSync as readFileSync22 } from "node:fs";
|
|
23742
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
23743
|
+
import { dirname as dirname7, join as join33, resolve as resolve22 } from "node:path";
|
|
23744
|
+
function sha2565(content) {
|
|
23745
|
+
return createHash13("sha256").update(content).digest("hex");
|
|
23746
|
+
}
|
|
23747
|
+
async function isOwnResultsFile(path, env) {
|
|
23748
|
+
let hash;
|
|
23749
|
+
try {
|
|
23750
|
+
hash = sha2565(readFileSync22(path));
|
|
23751
|
+
} catch {
|
|
23752
|
+
return false;
|
|
23753
|
+
}
|
|
23754
|
+
for (const record3 of await listRuns(env)) {
|
|
23755
|
+
if (record3.command !== COMMAND7) continue;
|
|
23756
|
+
try {
|
|
23757
|
+
const marker = JSON.parse(await readFile13(join33(record3.dir, OUT_MARKER), "utf8"));
|
|
23758
|
+
if (marker.path === path && marker.sha256 === hash) return true;
|
|
23759
|
+
} catch {
|
|
23760
|
+
}
|
|
23761
|
+
}
|
|
23762
|
+
return false;
|
|
23763
|
+
}
|
|
23764
|
+
async function readResultFlags(ctx, flags) {
|
|
23765
|
+
const wait3 = flags.wait === true;
|
|
23766
|
+
const timeoutText = typeof flags.timeout === "string" ? flags.timeout : void 0;
|
|
23767
|
+
const outText = typeof flags.out === "string" ? flags.out.trim() : void 0;
|
|
23768
|
+
if (timeoutText !== void 0 && !wait3) throw usageError("--timeout goes with --wait.", { field: "timeout" });
|
|
23769
|
+
if (outText !== void 0 && !wait3) {
|
|
23770
|
+
throw usageError("--out needs --wait: the results file is written when the runs end.", { field: "out" });
|
|
23771
|
+
}
|
|
23772
|
+
if (outText === "") throw usageError("--out needs a file path.", { field: "out" });
|
|
23773
|
+
const timeoutMs2 = parseDuration(timeoutText ?? DEFAULT_TIMEOUT4);
|
|
23774
|
+
if (timeoutMs2 === void 0) {
|
|
23775
|
+
throw usageError(`--timeout "${timeoutText}" is not a duration.`, { field: "timeout", hint: "Use 90s, 10m, 1h or a number of seconds." });
|
|
23776
|
+
}
|
|
23777
|
+
const out = outText === void 0 ? void 0 : resolve22(outText);
|
|
23778
|
+
if (out !== void 0 && !existsSync16(dirname7(out))) throw usageError(`--out: the folder ${dirname7(out)} does not exist.`, { field: "out" });
|
|
23779
|
+
if (out !== void 0 && existsSync16(out) && !await isOwnResultsFile(out, ctx.env)) {
|
|
23780
|
+
throw new KensoError({
|
|
23781
|
+
code: "file_exists",
|
|
23782
|
+
message: `${out} already exists and is not a results file of kenso workflows run.`,
|
|
23783
|
+
exitCode: ExitCode.Conflict,
|
|
23784
|
+
field: "out",
|
|
23785
|
+
hint: "Pick another --out path, or delete the file first."
|
|
23786
|
+
});
|
|
23787
|
+
}
|
|
23788
|
+
return { wait: wait3, timeoutMs: timeoutMs2, out };
|
|
23789
|
+
}
|
|
23790
|
+
function holdSummary(ctx) {
|
|
23791
|
+
let held = {};
|
|
23792
|
+
const output = Object.create(ctx.output);
|
|
23793
|
+
output.summary = (value) => {
|
|
23794
|
+
held = value;
|
|
23795
|
+
};
|
|
23796
|
+
return { ctx: { ...ctx, output }, held: () => held };
|
|
23797
|
+
}
|
|
23798
|
+
function lastByNode(steps = []) {
|
|
23799
|
+
const byNode = /* @__PURE__ */ new Map();
|
|
23800
|
+
for (const step of steps) if (step.nodeId) byNode.set(step.nodeId, step);
|
|
23801
|
+
return byNode;
|
|
23802
|
+
}
|
|
23803
|
+
function missReason(run, isDataStep) {
|
|
23804
|
+
for (const step of lastByNode(run.steps).values()) {
|
|
23805
|
+
if (!step.stepType || !isDataStep(step.stepType)) continue;
|
|
23806
|
+
const output = step.output;
|
|
23807
|
+
if (output === null || typeof output !== "object" || Array.isArray(output)) continue;
|
|
23808
|
+
for (const key of ["status", "reason"]) {
|
|
23809
|
+
const value = output[key];
|
|
23810
|
+
if (typeof value === "string" && value.trim() !== "" && !SUCCESS_VALUES.has(value.trim().toLowerCase())) return value.trim();
|
|
23811
|
+
}
|
|
23812
|
+
}
|
|
23813
|
+
return void 0;
|
|
23814
|
+
}
|
|
23815
|
+
function rowRunId(row) {
|
|
23816
|
+
if (row.runId === void 0 || row.runId === null || row.runId === "") return void 0;
|
|
23817
|
+
const id = Number(row.runId);
|
|
23818
|
+
return Number.isSafeInteger(id) ? id : void 0;
|
|
23819
|
+
}
|
|
23820
|
+
function outRows(rows, runs, isDataStep) {
|
|
23821
|
+
return rows.map((row) => {
|
|
23822
|
+
const runId = rowRunId(row);
|
|
23823
|
+
const run = runId === void 0 ? void 0 : runs.get(runId);
|
|
23824
|
+
const steps = {};
|
|
23825
|
+
if (run) for (const [nodeId, step] of lastByNode(run.steps)) steps[nodeId] = step.output;
|
|
23826
|
+
const charged = run ? runCredits(run) : void 0;
|
|
23827
|
+
const missed = run ? missReason(run, isDataStep) : void 0;
|
|
23828
|
+
const failed = run?.steps?.find((step) => step.status === "failed");
|
|
23829
|
+
const error = failed ? stepErrorText(failed) : void 0;
|
|
23830
|
+
return {
|
|
23831
|
+
row: row.row,
|
|
23832
|
+
id: String(row.id ?? ""),
|
|
23833
|
+
status: String(row.status),
|
|
23834
|
+
...runId !== void 0 ? { runId } : {},
|
|
23835
|
+
...run?.status ? { runStatus: run.status } : {},
|
|
23836
|
+
...charged !== void 0 ? { creditsCharged: charged } : {},
|
|
23837
|
+
...missed ? { missReason: missed } : {},
|
|
23838
|
+
...error ? { error } : {},
|
|
23839
|
+
steps
|
|
23840
|
+
};
|
|
23841
|
+
});
|
|
23842
|
+
}
|
|
23843
|
+
function outCsv(rows) {
|
|
23844
|
+
const stepIds = [];
|
|
23845
|
+
for (const row of rows) for (const id of Object.keys(row.steps)) if (!stepIds.includes(id)) stepIds.push(id);
|
|
23846
|
+
const json = (value) => value === void 0 || value === null ? "" : JSON.stringify(value);
|
|
23847
|
+
const lines = rows.map((row) => [...RESULT_COLUMNS2.map((column) => String(row[column] ?? "")), ...stepIds.map((id) => json(row.steps[id]))]);
|
|
23848
|
+
return stringify([[...RESULT_COLUMNS2, ...stepIds], ...lines]);
|
|
23849
|
+
}
|
|
23850
|
+
function isDataStepCheck() {
|
|
23851
|
+
let dataTypes = /* @__PURE__ */ new Set();
|
|
23852
|
+
try {
|
|
23853
|
+
dataTypes = new Set(loadStepTypes().filter((type) => type.kind === "data").map((type) => type.type));
|
|
23854
|
+
} catch {
|
|
23855
|
+
}
|
|
23856
|
+
return (stepType) => dataTypes.has(stepType) || stepType.startsWith("data.");
|
|
23857
|
+
}
|
|
23858
|
+
function waitedCounts(table) {
|
|
23859
|
+
let succeeded = 0;
|
|
23860
|
+
let runsFailed = 0;
|
|
23861
|
+
let waiting = 0;
|
|
23862
|
+
let charged = 0;
|
|
23863
|
+
const missed = {};
|
|
23864
|
+
for (const row of table) {
|
|
23865
|
+
if (row.missReason) missed[row.missReason] = (missed[row.missReason] ?? 0) + 1;
|
|
23866
|
+
if (!isOwnRun(row)) continue;
|
|
23867
|
+
if (row.runStatus === "succeeded") succeeded++;
|
|
23868
|
+
else if (row.runStatus !== void 0 && ENDED_UNSUCCESSFUL.has(row.runStatus)) runsFailed++;
|
|
23869
|
+
else waiting++;
|
|
23870
|
+
if (row.creditsCharged !== void 0) charged += row.creditsCharged;
|
|
23871
|
+
}
|
|
23872
|
+
return { succeeded, runsFailed, waiting, missed, creditsCharged: waiting > 0 ? "pending" : roundCredits(charged) };
|
|
23873
|
+
}
|
|
23874
|
+
async function finishRun(ctx, input) {
|
|
23875
|
+
const { outcome, engineSummary, workflowId, flags } = input;
|
|
23876
|
+
const summary = { ...engineSummary };
|
|
23877
|
+
const engineStopped = engineSummary.stopped !== void 0 || engineSummary.interrupted === true;
|
|
23878
|
+
let interrupted7 = false;
|
|
23879
|
+
let waitedLine = "";
|
|
23880
|
+
if (flags.wait) {
|
|
23881
|
+
const rows = [...(await readResults(outcome.resultsNdjson)).values()].sort((a, b) => a.row - b.row);
|
|
23882
|
+
const runIds = rows.flatMap((row) => rowRunId(row) ?? []);
|
|
23883
|
+
let runs = /* @__PURE__ */ new Map();
|
|
23884
|
+
if (!engineStopped && runIds.length > 0) {
|
|
23885
|
+
const waited = await waitForRuns(ctx.client, runIds, {
|
|
23886
|
+
timeoutMs: flags.timeoutMs,
|
|
23887
|
+
signal: ctx.signal,
|
|
23888
|
+
onProgress: (open2, total) => ctx.output.progress(`runs: ${total - open2}/${total} ended`)
|
|
23889
|
+
});
|
|
23890
|
+
runs = waited.runs;
|
|
23891
|
+
interrupted7 = waited.interrupted;
|
|
23892
|
+
if (waited.stopped) ctx.output.warn(`Stopped reading the runs (${waited.stopped}). They keep going: kenso workflow-runs list --workflow-id ${workflowId}`);
|
|
23893
|
+
}
|
|
23894
|
+
const table = outRows(rows, runs, isDataStepCheck());
|
|
23895
|
+
if (flags.out) {
|
|
23896
|
+
const text4 = outCsv(table);
|
|
23897
|
+
await writeFileAtomic(flags.out, text4);
|
|
23898
|
+
await writeJsonAtomic(join33(outcome.dir, OUT_MARKER), { path: flags.out, sha256: sha2565(text4) });
|
|
23899
|
+
summary.resultsCsv = flags.out;
|
|
23900
|
+
}
|
|
23901
|
+
const counts2 = waitedCounts(table);
|
|
23902
|
+
summary.succeeded = counts2.succeeded;
|
|
23903
|
+
summary.failed = Number(engineSummary.failed ?? 0) + counts2.runsFailed;
|
|
23904
|
+
summary.waiting = counts2.waiting;
|
|
23905
|
+
summary.missed = counts2.missed;
|
|
23906
|
+
summary.creditsCharged = counts2.creditsCharged;
|
|
23907
|
+
const firstFailed = table.find((row) => isOwnRun(row) && row.runStatus !== void 0 && ENDED_UNSUCCESSFUL.has(row.runStatus));
|
|
23908
|
+
if (!engineStopped && firstFailed?.runId !== void 0) summary.next = `kenso workflow-runs logs ${firstFailed.runId}`;
|
|
23909
|
+
waitedLine = `; ${counts2.succeeded} succeeded, ${counts2.waiting} waiting, ${String(counts2.creditsCharged)} credits charged`;
|
|
23910
|
+
}
|
|
23911
|
+
await writeJsonAtomic(join33(outcome.dir, "summary.json"), summary);
|
|
23912
|
+
ctx.output.summary(summary);
|
|
23913
|
+
const n = (key) => Number(summary[key] ?? 0);
|
|
23914
|
+
ctx.output.info(
|
|
23915
|
+
`workflow ${workflowId}: ${n("started")} started, ${n("deduplicated")} deduplicated, ${n("notStarted")} not started, ${n("failed")} failed of ${n("records")} records${waitedLine}`
|
|
23916
|
+
);
|
|
23917
|
+
if (interrupted7) return ExitCode.Interrupted;
|
|
23918
|
+
if (outcome.exitCode !== ExitCode.Ok) return outcome.exitCode;
|
|
23919
|
+
return n("notStarted") + n("failed") > 0 ? ExitCode.Partial : ExitCode.Ok;
|
|
23920
|
+
}
|
|
23921
|
+
var RESULT_COLUMNS2, OUT_MARKER, DEFAULT_TIMEOUT4, SUCCESS_VALUES, ENDED_UNSUCCESSFUL, isOwnRun;
|
|
23922
|
+
var init_run_results = __esm({
|
|
23923
|
+
"src/commands/workflows/run-results.ts"() {
|
|
23924
|
+
"use strict";
|
|
23925
|
+
init_sync();
|
|
23926
|
+
init_results();
|
|
23927
|
+
init_runs();
|
|
23928
|
+
init_errors();
|
|
23929
|
+
init_exit_codes();
|
|
23930
|
+
init_step_types();
|
|
23931
|
+
init_wait();
|
|
23932
|
+
init_run_start();
|
|
23933
|
+
init_run_wait();
|
|
23934
|
+
RESULT_COLUMNS2 = ["row", "id", "status", "runId", "runStatus", "creditsCharged", "missReason", "error"];
|
|
23935
|
+
OUT_MARKER = "results-out.json";
|
|
23936
|
+
DEFAULT_TIMEOUT4 = "30m";
|
|
23937
|
+
SUCCESS_VALUES = /* @__PURE__ */ new Set([
|
|
23938
|
+
"done",
|
|
23939
|
+
"fresh",
|
|
23940
|
+
"succeeded",
|
|
23941
|
+
"found",
|
|
23942
|
+
"verified",
|
|
23943
|
+
"valid",
|
|
23944
|
+
"catch_all",
|
|
23945
|
+
"unverified",
|
|
23946
|
+
"already_has_email",
|
|
23947
|
+
"already_has_phone",
|
|
23948
|
+
"already_queued",
|
|
23949
|
+
"already_accepted",
|
|
23950
|
+
"queued",
|
|
23951
|
+
"running",
|
|
23952
|
+
"cached",
|
|
23953
|
+
"checked"
|
|
23954
|
+
]);
|
|
23955
|
+
ENDED_UNSUCCESSFUL = /* @__PURE__ */ new Set(["failed", "cancelled", "needs_attention", "over_limit"]);
|
|
23956
|
+
isOwnRun = (row) => row.status === "started" && row.runId !== void 0;
|
|
23957
|
+
}
|
|
23958
|
+
});
|
|
23959
|
+
|
|
23576
23960
|
// src/commands/workflows/run.ts
|
|
23577
23961
|
var run_exports4 = {};
|
|
23578
23962
|
__export(run_exports4, {
|
|
23579
23963
|
default: () => run_default3
|
|
23580
23964
|
});
|
|
23581
|
-
import { join as
|
|
23965
|
+
import { join as join34 } from "node:path";
|
|
23582
23966
|
async function resolveTarget(ctx, target2) {
|
|
23583
23967
|
const isId = /^[1-9]\d*$/.test(target2);
|
|
23584
23968
|
const file = isId ? void 0 : readWorkflowFile(target2).definition;
|
|
@@ -23669,7 +24053,7 @@ function summarize4(workflowId, records, cap) {
|
|
|
23669
24053
|
};
|
|
23670
24054
|
};
|
|
23671
24055
|
}
|
|
23672
|
-
var NAME2, CHUNK_SIZE7, APP_URL, LIST_HINT,
|
|
24056
|
+
var NAME2, CHUNK_SIZE7, APP_URL, LIST_HINT, command86, run_default3;
|
|
23673
24057
|
var init_run4 = __esm({
|
|
23674
24058
|
"src/commands/workflows/run.ts"() {
|
|
23675
24059
|
"use strict";
|
|
@@ -23685,17 +24069,18 @@ var init_run4 = __esm({
|
|
|
23685
24069
|
init_files2();
|
|
23686
24070
|
init_run_cap();
|
|
23687
24071
|
init_run_input();
|
|
24072
|
+
init_run_results();
|
|
23688
24073
|
init_run_start();
|
|
23689
24074
|
NAME2 = `kenso ${COMMAND7}`;
|
|
23690
24075
|
CHUNK_SIZE7 = 1e3;
|
|
23691
24076
|
APP_URL = "https://app.ken.so";
|
|
23692
24077
|
LIST_HINT = "A saved list runs through a workflow whose trigger is trigger.saved_list@1 or trigger.csv@1; kenso workflows run takes --ids or --file.";
|
|
23693
|
-
|
|
24078
|
+
command86 = {
|
|
23694
24079
|
resource: "workflows",
|
|
23695
24080
|
action: "run",
|
|
23696
24081
|
summary: "Run a published workflow on records from an ids file or a CSV",
|
|
23697
24082
|
brief: "on ids or a CSV",
|
|
23698
|
-
description: "Starts one run per record on the workflow's published version. The target is a workflow id, or a workflow file bound in kenso.json that equals the published version. --ids is one id per line; --file is a CSV with an id column, or for a workflow that runs on people a CSV of people (the columns of kenso people import), matched or created first. Without --yes it prints the plan with the credit estimate and starts nothing. --max-credits starts only as many records as the cap covers and reports the rest as not_started. The same command on the same input never starts its records twice; another --max-credits on that input is refused with an ids file of the records not started yet. Exit 5 when some records failed, were not found or were not started, 6 when the cap starts nothing or the workspace is out of credits, 7 when the file differs from the published version or the workflow is not live.",
|
|
24083
|
+
description: "Starts one run per record on the workflow's published version. The target is a workflow id, or a workflow file bound in kenso.json that equals the published version. --ids is one id per line; --file is a CSV with an id column, or for a workflow that runs on people a CSV of people (the columns of kenso people import), matched or created first. Without --yes it prints the plan with the credit estimate and starts nothing. --max-credits starts only as many records as the cap covers and reports the rest as not_started. The same command on the same input never starts its records twice; another --max-credits on that input is refused with an ids file of the records not started yet. Exit 5 when some records failed, were not found or were not started, 6 when the cap starts nothing or the workspace is out of credits, 7 when the file differs from the published version or the workflow is not live. --wait reads each started run until it ends (--timeout, default 30m); --out writes one row per record with each step's output, because a succeeded run's step outputs are dropped 7 days after it ends unless the workflow keeps success details.",
|
|
23699
24084
|
effect: "send",
|
|
23700
24085
|
doc: {
|
|
23701
24086
|
when: "You have a published workflow and the records to run it on.",
|
|
@@ -23707,6 +24092,9 @@ var init_run4 = __esm({
|
|
|
23707
24092
|
file: { type: "string", description: "A CSV with an id column, or a CSV of people for a workflow that runs on people" },
|
|
23708
24093
|
"record-type": { type: "string", description: "account, person, lead or place (default: the type the trigger runs on)" },
|
|
23709
24094
|
"max-credits": { type: "string", description: "Start only as many records as this many credits cover" },
|
|
24095
|
+
wait: { type: "boolean", description: "Wait for every started run to end, reading up to 8 runs at a time" },
|
|
24096
|
+
timeout: { type: "string", description: "With --wait: how long to wait, 90s, 10m or 1h (default 30m)" },
|
|
24097
|
+
out: { type: "string", description: "With --wait: write one row per input record, with each step's output, to this CSV" },
|
|
23710
24098
|
// Declared only so the refusal can carry its hint: main refuses an undeclared flag before the command runs.
|
|
23711
24099
|
list: { type: "string", helpHidden: true, description: "Not a flag: a saved list runs through its own trigger" }
|
|
23712
24100
|
},
|
|
@@ -23714,7 +24102,8 @@ var init_run4 = __esm({
|
|
|
23714
24102
|
examples: [
|
|
23715
24103
|
"kenso workflows run qualify.workflow.json --ids ids.txt --dry-run",
|
|
23716
24104
|
"kenso workflows run qualify.workflow.json --ids ids.txt --max-credits 50 --yes",
|
|
23717
|
-
"kenso workflows run 412 --file people.csv --record-type person --dry-run"
|
|
24105
|
+
"kenso workflows run 412 --file people.csv --record-type person --dry-run",
|
|
24106
|
+
"kenso workflows run qualify.workflow.json --ids ids.txt --max-credits 10 --wait --out results.csv --yes"
|
|
23718
24107
|
],
|
|
23719
24108
|
beta: { featureGates: WORKFLOWS_GATES },
|
|
23720
24109
|
// workflow-runs.get is read by --wait.
|
|
@@ -23730,6 +24119,7 @@ var init_run4 = __esm({
|
|
|
23730
24119
|
if (ids2 === void 0 === (csv === void 0)) throw usageError("Pass one of --ids and --file.", { field: "ids", next: `${NAME2} --help` });
|
|
23731
24120
|
const maxCredits = maxCreditsOf(flags["max-credits"]);
|
|
23732
24121
|
const apply = ctx.flags.yes === true;
|
|
24122
|
+
const results = await readResultFlags(ctx, flags);
|
|
23733
24123
|
const target2 = await resolveTarget(ctx, positionals[0] ?? "");
|
|
23734
24124
|
const { workflowId } = target2;
|
|
23735
24125
|
const type = recordTypeOf(target2.definition, stringFlag(flags["record-type"]));
|
|
@@ -23752,7 +24142,8 @@ var init_run4 = __esm({
|
|
|
23752
24142
|
const retry = (cap2) => commandLine2(ctx, COMMAND7, { flags: { ...flags, "max-credits": String(cap2) }, positionals });
|
|
23753
24143
|
const capFor = (count) => maxCredits !== void 0 && ceiling !== void 0 ? planCap(maxCredits, count, hard !== void 0 ? "hard" : "estimate", ceiling, retry) : null;
|
|
23754
24144
|
let cap = capFor(input.records.length);
|
|
23755
|
-
const
|
|
24145
|
+
const { timeout: _timeout, out: _out, ...identity } = flags;
|
|
24146
|
+
const args = { ...identity, positionals };
|
|
23756
24147
|
const applyCommand = commandLine2(ctx, COMMAND7, { flags, positionals }, ["--yes"]);
|
|
23757
24148
|
const plan2 = {
|
|
23758
24149
|
workflowId,
|
|
@@ -23773,7 +24164,7 @@ var init_run4 = __esm({
|
|
|
23773
24164
|
rowOf: (item) => item.row,
|
|
23774
24165
|
chunkSize: CHUNK_SIZE7,
|
|
23775
24166
|
concurrency: 1,
|
|
23776
|
-
execChunk: (chunk, cc) => startChunk(chunk, cc, { dirOf: (runId) =>
|
|
24167
|
+
execChunk: (chunk, cc) => startChunk(chunk, cc, { dirOf: (runId) => join34(runsRoot(ctx.env), runId), workflowId, start }),
|
|
23777
24168
|
invalid: invalid3,
|
|
23778
24169
|
dryRun: dryRun2,
|
|
23779
24170
|
dryRunExtra: plan2,
|
|
@@ -23802,14 +24193,12 @@ var init_run4 = __esm({
|
|
|
23802
24193
|
const applied = spec(false, records, invalid2);
|
|
23803
24194
|
const rerun = (ids3) => commandLine2(ctx, COMMAND7, { flags: { ...flags, ids: ids3, file: void 0 }, positionals }, ["--yes"]);
|
|
23804
24195
|
await refuseRestart(ctx, { args, sha256: input.input.sha256, workflowId, items: applied.items, rerun });
|
|
23805
|
-
const
|
|
23806
|
-
const
|
|
23807
|
-
ctx
|
|
23808
|
-
if (outcome.exitCode !== ExitCode.Ok) return outcome.exitCode;
|
|
23809
|
-
return Number(s.notStarted ?? 0) + Number(s.failed ?? 0) > 0 ? ExitCode.Partial : ExitCode.Ok;
|
|
24196
|
+
const hold = holdSummary(ctx);
|
|
24197
|
+
const outcome = await runBatch(applied, hold.ctx);
|
|
24198
|
+
return finishRun(ctx, { outcome, engineSummary: hold.held(), workflowId, flags: results });
|
|
23810
24199
|
}
|
|
23811
24200
|
};
|
|
23812
|
-
run_default3 =
|
|
24201
|
+
run_default3 = command86;
|
|
23813
24202
|
}
|
|
23814
24203
|
});
|
|
23815
24204
|
|
|
@@ -23856,7 +24245,7 @@ function rewrap(err, overrides2) {
|
|
|
23856
24245
|
details: err.details
|
|
23857
24246
|
});
|
|
23858
24247
|
}
|
|
23859
|
-
var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE,
|
|
24248
|
+
var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command87, keys_default;
|
|
23860
24249
|
var init_keys = __esm({
|
|
23861
24250
|
"src/commands/workspace/keys.ts"() {
|
|
23862
24251
|
"use strict";
|
|
@@ -23866,7 +24255,7 @@ var init_keys = __esm({
|
|
|
23866
24255
|
TEMPLATES = ["admin", "editor", "viewer"];
|
|
23867
24256
|
APP_NEXT_STEP = "A workspace admin can create it in the app: Settings > API keys > Workspace keys";
|
|
23868
24257
|
NOT_AVAILABLE = "Workspace keys are not available for this workspace yet.";
|
|
23869
|
-
|
|
24258
|
+
command87 = {
|
|
23870
24259
|
resource: "workspace",
|
|
23871
24260
|
action: "keys",
|
|
23872
24261
|
summary: "Create an API key the workspace owns",
|
|
@@ -23928,7 +24317,7 @@ var init_keys = __esm({
|
|
|
23928
24317
|
return ExitCode.Ok;
|
|
23929
24318
|
}
|
|
23930
24319
|
};
|
|
23931
|
-
keys_default =
|
|
24320
|
+
keys_default = command87;
|
|
23932
24321
|
}
|
|
23933
24322
|
});
|
|
23934
24323
|
|
|
@@ -23946,14 +24335,14 @@ function parseLimit2(value) {
|
|
|
23946
24335
|
}
|
|
23947
24336
|
return limit;
|
|
23948
24337
|
}
|
|
23949
|
-
var MAX_LIMIT2,
|
|
24338
|
+
var MAX_LIMIT2, command88, list_default5;
|
|
23950
24339
|
var init_list5 = __esm({
|
|
23951
24340
|
"src/commands/workspace/list.ts"() {
|
|
23952
24341
|
"use strict";
|
|
23953
24342
|
init_errors();
|
|
23954
24343
|
init_exit_codes();
|
|
23955
24344
|
MAX_LIMIT2 = 200;
|
|
23956
|
-
|
|
24345
|
+
command88 = {
|
|
23957
24346
|
resource: "workspace",
|
|
23958
24347
|
action: "list",
|
|
23959
24348
|
summary: "List the workspaces your key can use",
|
|
@@ -23982,7 +24371,7 @@ var init_list5 = __esm({
|
|
|
23982
24371
|
return ExitCode.Ok;
|
|
23983
24372
|
}
|
|
23984
24373
|
};
|
|
23985
|
-
list_default5 =
|
|
24374
|
+
list_default5 = command88;
|
|
23986
24375
|
}
|
|
23987
24376
|
});
|
|
23988
24377
|
|
|
@@ -23991,7 +24380,7 @@ var use_exports = {};
|
|
|
23991
24380
|
__export(use_exports, {
|
|
23992
24381
|
default: () => use_default
|
|
23993
24382
|
});
|
|
23994
|
-
var
|
|
24383
|
+
var command89, use_default;
|
|
23995
24384
|
var init_use = __esm({
|
|
23996
24385
|
"src/commands/workspace/use.ts"() {
|
|
23997
24386
|
"use strict";
|
|
@@ -23999,7 +24388,7 @@ var init_use = __esm({
|
|
|
23999
24388
|
init_errors();
|
|
24000
24389
|
init_exit_codes();
|
|
24001
24390
|
init_http();
|
|
24002
|
-
|
|
24391
|
+
command89 = {
|
|
24003
24392
|
resource: "workspace",
|
|
24004
24393
|
action: "use",
|
|
24005
24394
|
summary: "Set the profile's default workspace",
|
|
@@ -24061,7 +24450,7 @@ var init_use = __esm({
|
|
|
24061
24450
|
return ExitCode.Ok;
|
|
24062
24451
|
}
|
|
24063
24452
|
};
|
|
24064
|
-
use_default =
|
|
24453
|
+
use_default = command89;
|
|
24065
24454
|
}
|
|
24066
24455
|
});
|
|
24067
24456
|
|
|
@@ -24679,14 +25068,14 @@ var init_pre_run = __esm({
|
|
|
24679
25068
|
});
|
|
24680
25069
|
|
|
24681
25070
|
// src/core/update-notice.ts
|
|
24682
|
-
import { mkdirSync as mkdirSync8, readFileSync as
|
|
24683
|
-
import { dirname as
|
|
25071
|
+
import { mkdirSync as mkdirSync8, readFileSync as readFileSync23, realpathSync as realpathSync2, renameSync as renameSync8, writeFileSync as writeFileSync13 } from "node:fs";
|
|
25072
|
+
import { dirname as dirname8, join as join35, sep as sep4 } from "node:path";
|
|
24684
25073
|
function installKind(script = process.argv[1], execPath = process.execPath, platform = process.platform) {
|
|
24685
25074
|
try {
|
|
24686
25075
|
if (!script) return "npm";
|
|
24687
25076
|
const bundle = realpathSync2(script);
|
|
24688
|
-
const lib =
|
|
24689
|
-
if (execPath !==
|
|
25077
|
+
const lib = dirname8(dirname8(dirname8(bundle)));
|
|
25078
|
+
if (execPath !== join35(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
|
|
24690
25079
|
return bundle.includes(`${sep4}Cellar${sep4}kenso${sep4}`) ? "homebrew" : "standalone";
|
|
24691
25080
|
} catch {
|
|
24692
25081
|
return "npm";
|
|
@@ -24699,7 +25088,7 @@ function updateCommand(install, platform) {
|
|
|
24699
25088
|
}
|
|
24700
25089
|
function readCheck(file) {
|
|
24701
25090
|
try {
|
|
24702
|
-
const parsed2 = JSON.parse(
|
|
25091
|
+
const parsed2 = JSON.parse(readFileSync23(file, "utf8"));
|
|
24703
25092
|
if (typeof parsed2?.checkedAt !== "string") return void 0;
|
|
24704
25093
|
return { checkedAt: parsed2.checkedAt, ...typeof parsed2.latest === "string" ? { latest: parsed2.latest } : {} };
|
|
24705
25094
|
} catch {
|
|
@@ -24708,7 +25097,7 @@ function readCheck(file) {
|
|
|
24708
25097
|
}
|
|
24709
25098
|
function writeCheck(file, check) {
|
|
24710
25099
|
try {
|
|
24711
|
-
mkdirSync8(
|
|
25100
|
+
mkdirSync8(dirname8(file), { recursive: true, mode: 448 });
|
|
24712
25101
|
const temp = `${file}.${process.pid}.tmp`;
|
|
24713
25102
|
writeFileSync13(temp, `${JSON.stringify(check)}
|
|
24714
25103
|
`, { mode: 384 });
|
|
@@ -24740,13 +25129,13 @@ async function fetchLatest(fetchImpl, signal, install) {
|
|
|
24740
25129
|
return typeof body2?.version === "string" && RELEASE.test(body2.version) ? body2.version : void 0;
|
|
24741
25130
|
}
|
|
24742
25131
|
function agentNotice(env, agent, version, stderr, opts) {
|
|
24743
|
-
const latest = readCheck(
|
|
25132
|
+
const latest = readCheck(join35(configDir(env), UPDATE_CHECK_FILE))?.latest;
|
|
24744
25133
|
if (latest === void 0 || !isNewer(latest, version)) return done;
|
|
24745
25134
|
return async () => {
|
|
24746
25135
|
try {
|
|
24747
25136
|
if (!firstInSession(env, agent, "update")) return;
|
|
24748
|
-
const
|
|
24749
|
-
stderr.write(`kenso ${latest} is out (you have ${version}): ${
|
|
25137
|
+
const command90 = updateCommand(opts.install ?? installKind(), opts.platform ?? process.platform);
|
|
25138
|
+
stderr.write(`kenso ${latest} is out (you have ${version}): ${command90}
|
|
24750
25139
|
`);
|
|
24751
25140
|
} catch {
|
|
24752
25141
|
}
|
|
@@ -24762,7 +25151,7 @@ function startUpdateNotice(argv, opts = {}) {
|
|
|
24762
25151
|
const agent = detectAgent(env);
|
|
24763
25152
|
if (agent !== null) return agentNotice(env, agent, version, stderr, opts);
|
|
24764
25153
|
if (!(opts.stderrIsTTY ?? process.stderr.isTTY === true)) return done;
|
|
24765
|
-
const file =
|
|
25154
|
+
const file = join35(configDir(env), UPDATE_CHECK_FILE);
|
|
24766
25155
|
const now = (opts.now ?? Date.now)();
|
|
24767
25156
|
const cached = readCheck(file);
|
|
24768
25157
|
const checkedAt = Date.parse(cached?.checkedAt ?? "");
|
|
@@ -24781,8 +25170,8 @@ function startUpdateNotice(argv, opts = {}) {
|
|
|
24781
25170
|
if (!found) return;
|
|
24782
25171
|
writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
|
|
24783
25172
|
if (isNewer(found, version)) {
|
|
24784
|
-
const
|
|
24785
|
-
stderr.write(`kenso ${found} is out (you have ${version}): ${
|
|
25173
|
+
const command90 = updateCommand(install, opts.platform ?? process.platform);
|
|
25174
|
+
stderr.write(`kenso ${found} is out (you have ${version}): ${command90}
|
|
24786
25175
|
Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
|
|
24787
25176
|
`);
|
|
24788
25177
|
}
|