kenso 0.1.192 → 0.1.193
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/dist/discover.json +1 -1
- package/dist/kenso.js +827 -608
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/docs/reference.md +35 -2
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -93,8 +93,8 @@ var init_exit_codes = __esm({
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
// src/core/redact.ts
|
|
96
|
-
function redact(
|
|
97
|
-
return
|
|
96
|
+
function redact(text5) {
|
|
97
|
+
return text5.replace(KEY_PATTERN, "ken_***").replace(KENSO_KEY_PATTERN, "$1***").replace(RUN_TOKEN_PATTERN, "krt_***").replace(BEARER_PATTERN, "$1***").replace(AUTH_HEADER_PATTERN, "$1***");
|
|
98
98
|
}
|
|
99
99
|
var KEY_PATTERN, KENSO_KEY_PATTERN, RUN_TOKEN_PATTERN, BEARER_PATTERN, AUTH_HEADER_PATTERN;
|
|
100
100
|
var init_redact = __esm({
|
|
@@ -160,8 +160,8 @@ function errorFromResponse(status, body2, requestId) {
|
|
|
160
160
|
message = nonEmptyString(envelope.message) ?? nonEmptyString(envelope.detail) ?? nonEmptyString(envelope.title);
|
|
161
161
|
requestId = requestId ?? nonEmptyString(envelope.requestId) ?? nonEmptyString(envelope.traceId);
|
|
162
162
|
} else if (typeof body2 === "string" && body2.trim() !== "") {
|
|
163
|
-
const
|
|
164
|
-
message =
|
|
163
|
+
const text5 = body2.trim();
|
|
164
|
+
message = text5.length > MAX_TEXT_MESSAGE ? `${text5.slice(0, MAX_TEXT_MESSAGE)}...` : text5;
|
|
165
165
|
}
|
|
166
166
|
if (code === "workspace_required") {
|
|
167
167
|
exitCode = ExitCode.Usage;
|
|
@@ -275,8 +275,8 @@ function readFolderFile(path) {
|
|
|
275
275
|
try {
|
|
276
276
|
parsed2 = JSON.parse(readFileSync(path, "utf8"));
|
|
277
277
|
} catch (err) {
|
|
278
|
-
const
|
|
279
|
-
throw invalid(path, `${path} ${
|
|
278
|
+
const why2 = err instanceof SyntaxError ? "is not valid JSON" : `cannot be read (${err.code ?? "error"})`;
|
|
279
|
+
throw invalid(path, `${path} ${why2}.`);
|
|
280
280
|
}
|
|
281
281
|
if (parsed2 === null || typeof parsed2 !== "object" || Array.isArray(parsed2)) throw invalid(path, `${path} must hold one JSON object.`);
|
|
282
282
|
const forbidden = forbiddenAt(parsed2, "", true);
|
|
@@ -485,16 +485,16 @@ function cleanProfile(value) {
|
|
|
485
485
|
}
|
|
486
486
|
function readConfig(env = process.env) {
|
|
487
487
|
const file = configPath(env);
|
|
488
|
-
let
|
|
488
|
+
let text5;
|
|
489
489
|
try {
|
|
490
|
-
|
|
490
|
+
text5 = readFileSync2(file, "utf8");
|
|
491
491
|
} catch (err) {
|
|
492
492
|
if (err.code === "ENOENT") return defaultConfig();
|
|
493
493
|
throw err;
|
|
494
494
|
}
|
|
495
495
|
let parsed2;
|
|
496
496
|
try {
|
|
497
|
-
parsed2 = JSON.parse(
|
|
497
|
+
parsed2 = JSON.parse(text5);
|
|
498
498
|
} catch {
|
|
499
499
|
throw new KensoError({
|
|
500
500
|
code: "config_invalid",
|
|
@@ -652,14 +652,14 @@ function isTextContentType(contentType) {
|
|
|
652
652
|
if (media === "" || media.startsWith("text/") || isJsonContentType(contentType)) return true;
|
|
653
653
|
return /[/+]xml$/.test(media) || ["application/csv", "application/x-www-form-urlencoded", "application/javascript"].includes(media);
|
|
654
654
|
}
|
|
655
|
-
function parseBody(
|
|
656
|
-
if (
|
|
657
|
-
const looksJson = contentType?.includes("json") || /^\s*[[{]/.test(
|
|
658
|
-
if (!looksJson) return
|
|
655
|
+
function parseBody(text5, contentType) {
|
|
656
|
+
if (text5 === "") return null;
|
|
657
|
+
const looksJson = contentType?.includes("json") || /^\s*[[{]/.test(text5);
|
|
658
|
+
if (!looksJson) return text5;
|
|
659
659
|
try {
|
|
660
|
-
return JSON.parse(
|
|
660
|
+
return JSON.parse(text5);
|
|
661
661
|
} catch {
|
|
662
|
-
return
|
|
662
|
+
return text5;
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
function retryAfterMs(headers) {
|
|
@@ -1127,8 +1127,8 @@ var init_CsvError = __esm({
|
|
|
1127
1127
|
var underscore;
|
|
1128
1128
|
var init_underscore = __esm({
|
|
1129
1129
|
"node_modules/.pnpm/csv-stringify@6.9.0/node_modules/csv-stringify/lib/utils/underscore.js"() {
|
|
1130
|
-
underscore = function(
|
|
1131
|
-
return
|
|
1130
|
+
underscore = function(str2) {
|
|
1131
|
+
return str2.replace(/([A-Z])/g, function(_, match) {
|
|
1132
1132
|
return "_" + match.toLowerCase();
|
|
1133
1133
|
});
|
|
1134
1134
|
};
|
|
@@ -1766,12 +1766,12 @@ var require_jmespath = __commonJS({
|
|
|
1766
1766
|
}
|
|
1767
1767
|
var trimLeft;
|
|
1768
1768
|
if (typeof String.prototype.trimLeft === "function") {
|
|
1769
|
-
trimLeft = function(
|
|
1770
|
-
return
|
|
1769
|
+
trimLeft = function(str2) {
|
|
1770
|
+
return str2.trimLeft();
|
|
1771
1771
|
};
|
|
1772
1772
|
} else {
|
|
1773
|
-
trimLeft = function(
|
|
1774
|
-
return
|
|
1773
|
+
trimLeft = function(str2) {
|
|
1774
|
+
return str2.match(/^\s*(.*)/)[1];
|
|
1775
1775
|
};
|
|
1776
1776
|
}
|
|
1777
1777
|
var TYPE_NUMBER = 0;
|
|
@@ -3213,17 +3213,17 @@ function pickFields(value, paths) {
|
|
|
3213
3213
|
}
|
|
3214
3214
|
return out;
|
|
3215
3215
|
}
|
|
3216
|
-
function terminalSafe(
|
|
3217
|
-
return
|
|
3216
|
+
function terminalSafe(text5) {
|
|
3217
|
+
return text5.replace(TERMINAL_CONTROLS, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
3218
3218
|
}
|
|
3219
3219
|
function cellText(value, max = TABLE_MAX_CELL) {
|
|
3220
|
-
let
|
|
3221
|
-
if (value === null || value === void 0)
|
|
3222
|
-
else if (typeof value === "string")
|
|
3223
|
-
else if (isScalar(value))
|
|
3224
|
-
else
|
|
3225
|
-
|
|
3226
|
-
return
|
|
3220
|
+
let text5;
|
|
3221
|
+
if (value === null || value === void 0) text5 = "";
|
|
3222
|
+
else if (typeof value === "string") text5 = value;
|
|
3223
|
+
else if (isScalar(value)) text5 = String(value);
|
|
3224
|
+
else text5 = JSON.stringify(value);
|
|
3225
|
+
text5 = terminalSafe(text5.replace(/\s*\n\s*/g, " "));
|
|
3226
|
+
return text5.length > max ? `${text5.slice(0, max - 3)}...` : text5;
|
|
3227
3227
|
}
|
|
3228
3228
|
function csvCell(value) {
|
|
3229
3229
|
if (value === null || value === void 0) return "";
|
|
@@ -3341,8 +3341,8 @@ var init_output = __esm({
|
|
|
3341
3341
|
* Text to stdout as given: no JSON wrapping, no newline added, --output/--fields/--query not applied. A terminal gets
|
|
3342
3342
|
* its control characters escaped (terminalSafe), a pipe or file every byte.
|
|
3343
3343
|
*/
|
|
3344
|
-
writeRaw(
|
|
3345
|
-
this.write(
|
|
3344
|
+
writeRaw(text5) {
|
|
3345
|
+
this.write(text5);
|
|
3346
3346
|
}
|
|
3347
3347
|
/** Bytes to stdout exactly as given (a downloaded file piped on). */
|
|
3348
3348
|
writeBytes(bytes) {
|
|
@@ -3523,12 +3523,12 @@ var init_output = __esm({
|
|
|
3523
3523
|
return keys.map((key) => `${key.padEnd(width)} ${cellText(value[key], Number.POSITIVE_INFINITY)}`.trimEnd()).join("\n");
|
|
3524
3524
|
}
|
|
3525
3525
|
/** On a terminal every stdout write goes through terminalSafe; a pipe or file gets the text as is. */
|
|
3526
|
-
write(
|
|
3527
|
-
this.stdout.write(this.stdoutIsTTY ? terminalSafe(
|
|
3526
|
+
write(text5) {
|
|
3527
|
+
this.stdout.write(this.stdoutIsTTY ? terminalSafe(text5) : text5);
|
|
3528
3528
|
}
|
|
3529
3529
|
/** On a terminal every stderr line (messages, errors, progress) goes through terminalSafe: they can quote Kenso's text. */
|
|
3530
|
-
writeErr(
|
|
3531
|
-
this.stderr.write(this.stderrIsTTY ? terminalSafe(
|
|
3530
|
+
writeErr(text5) {
|
|
3531
|
+
this.stderr.write(this.stderrIsTTY ? terminalSafe(text5) : text5);
|
|
3532
3532
|
}
|
|
3533
3533
|
};
|
|
3534
3534
|
}
|
|
@@ -3539,7 +3539,7 @@ var VERSION;
|
|
|
3539
3539
|
var init_version = __esm({
|
|
3540
3540
|
"src/core/version.ts"() {
|
|
3541
3541
|
"use strict";
|
|
3542
|
-
VERSION = true ? "0.1.
|
|
3542
|
+
VERSION = true ? "0.1.193" : "0.0.0-dev";
|
|
3543
3543
|
}
|
|
3544
3544
|
});
|
|
3545
3545
|
|
|
@@ -3712,16 +3712,16 @@ function readText(name) {
|
|
|
3712
3712
|
function loadManifest() {
|
|
3713
3713
|
if (override) return override;
|
|
3714
3714
|
if (!parsed) {
|
|
3715
|
-
const
|
|
3716
|
-
parsed =
|
|
3715
|
+
const text5 = readText(MANIFEST_FILE);
|
|
3716
|
+
parsed = text5 ? JSON.parse(text5) : EMPTY;
|
|
3717
3717
|
}
|
|
3718
3718
|
return parsed;
|
|
3719
3719
|
}
|
|
3720
3720
|
function loadIndex() {
|
|
3721
3721
|
if (index === void 0) {
|
|
3722
|
-
const
|
|
3722
|
+
const text5 = readText(INDEX_FILE);
|
|
3723
3723
|
try {
|
|
3724
|
-
const value =
|
|
3724
|
+
const value = text5 ? JSON.parse(text5) : null;
|
|
3725
3725
|
index = Array.isArray(value?.operations) ? value : null;
|
|
3726
3726
|
} catch {
|
|
3727
3727
|
index = null;
|
|
@@ -3954,27 +3954,27 @@ async function readStream(stream, maxBytes = DEFAULT_MAX_BYTES) {
|
|
|
3954
3954
|
return Buffer.concat(chunks).toString("utf8");
|
|
3955
3955
|
}
|
|
3956
3956
|
async function readDataArg(value, stdin) {
|
|
3957
|
-
let
|
|
3957
|
+
let text5;
|
|
3958
3958
|
let source;
|
|
3959
3959
|
if (value === "-") {
|
|
3960
3960
|
source = "stdin";
|
|
3961
|
-
|
|
3961
|
+
text5 = await readStream(stdin ?? process.stdin);
|
|
3962
3962
|
} else if (value.startsWith("@")) {
|
|
3963
3963
|
const path = value.slice(1);
|
|
3964
3964
|
source = path;
|
|
3965
3965
|
if (path === "") throw usageError("Name a file after @, for example @body.json.");
|
|
3966
3966
|
try {
|
|
3967
|
-
|
|
3967
|
+
text5 = await readFile(path, "utf8");
|
|
3968
3968
|
} catch (err) {
|
|
3969
3969
|
throw fileUnreadable(path, err);
|
|
3970
3970
|
}
|
|
3971
3971
|
} else {
|
|
3972
3972
|
source = "the inline value";
|
|
3973
|
-
|
|
3973
|
+
text5 = value;
|
|
3974
3974
|
}
|
|
3975
|
-
if (
|
|
3975
|
+
if (text5.trim() === "") throw usageError(`No JSON in ${source}: it is empty.`);
|
|
3976
3976
|
try {
|
|
3977
|
-
return JSON.parse(
|
|
3977
|
+
return JSON.parse(text5);
|
|
3978
3978
|
} catch (err) {
|
|
3979
3979
|
throw usageError(`Invalid JSON in ${source}: ${err instanceof Error ? err.message : String(err)}`, {
|
|
3980
3980
|
hint: `Pass JSON inline ('{"name":"x"}'), from a file (@body.json) or from stdin (-).`
|
|
@@ -3996,8 +3996,8 @@ import { readFile as readFile2 } from "node:fs/promises";
|
|
|
3996
3996
|
function isSecretFlag(name, type) {
|
|
3997
3997
|
return type === "string" && SECRET_NAME.test(name);
|
|
3998
3998
|
}
|
|
3999
|
-
function readValue(flag, source,
|
|
4000
|
-
const value =
|
|
3999
|
+
function readValue(flag, source, text5) {
|
|
4000
|
+
const value = text5.replace(/\r?\n$/, "");
|
|
4001
4001
|
if (value === "") throw usageError(`--${flag} read nothing from ${source}.`, { field: flag, hint: `Put the value in ${source}, or pass env:NAME.` });
|
|
4002
4002
|
return value;
|
|
4003
4003
|
}
|
|
@@ -4019,13 +4019,13 @@ async function readSecretFlag(ctx, flag, raw) {
|
|
|
4019
4019
|
}
|
|
4020
4020
|
if (raw.startsWith("@") && !raw.startsWith("@@") && raw.length > 1) {
|
|
4021
4021
|
const path = raw.slice(1);
|
|
4022
|
-
let
|
|
4022
|
+
let text5;
|
|
4023
4023
|
try {
|
|
4024
|
-
|
|
4024
|
+
text5 = await readFile2(path, "utf8");
|
|
4025
4025
|
} catch (err) {
|
|
4026
4026
|
throw fileUnreadable(path, err, flag, `--${flag} @path reads a file. A value that itself starts with @ is written @@, for example @@Spring2026.`);
|
|
4027
4027
|
}
|
|
4028
|
-
return readValue(flag, path,
|
|
4028
|
+
return readValue(flag, path, text5);
|
|
4029
4029
|
}
|
|
4030
4030
|
if (raw.startsWith("env:") && raw.length > 4) {
|
|
4031
4031
|
const name = raw.slice(4);
|
|
@@ -4380,22 +4380,22 @@ function toCredits(millicredits) {
|
|
|
4380
4380
|
function positiveFlag(flags, name) {
|
|
4381
4381
|
const raw = flags[name];
|
|
4382
4382
|
if (raw === void 0) return void 0;
|
|
4383
|
-
const
|
|
4384
|
-
if (!/^\d+$/.test(
|
|
4385
|
-
throw usageError(`--${name} must be a positive whole number, not "${
|
|
4383
|
+
const text5 = String(raw).trim();
|
|
4384
|
+
if (!/^\d+$/.test(text5) || Number(text5) < 1 || !Number.isSafeInteger(Number(text5))) {
|
|
4385
|
+
throw usageError(`--${name} must be a positive whole number, not "${text5}".`, { field: name });
|
|
4386
4386
|
}
|
|
4387
|
-
return Number(
|
|
4387
|
+
return Number(text5);
|
|
4388
4388
|
}
|
|
4389
4389
|
function instantFlag(flags, name) {
|
|
4390
4390
|
const raw = flags[name];
|
|
4391
4391
|
if (typeof raw !== "string") return void 0;
|
|
4392
|
-
const
|
|
4393
|
-
const back = /^(\d+)([dh])$/.exec(
|
|
4392
|
+
const text5 = raw.trim();
|
|
4393
|
+
const back = /^(\d+)([dh])$/.exec(text5);
|
|
4394
4394
|
if (back) return new Date(Date.now() - Number(back[1]) * (back[2] === "d" ? DAY_MS : DAY_MS / 24)).toISOString();
|
|
4395
|
-
const day = /^\d{4}-\d{2}-\d{2}$/.test(
|
|
4396
|
-
const ms = Date.parse(day ? `${
|
|
4395
|
+
const day = /^\d{4}-\d{2}-\d{2}$/.test(text5);
|
|
4396
|
+
const ms = Date.parse(day ? `${text5}T00:00:00Z` : text5);
|
|
4397
4397
|
if (Number.isNaN(ms)) {
|
|
4398
|
-
throw usageError(`--${name} "${
|
|
4398
|
+
throw usageError(`--${name} "${text5}" is not a date.`, { field: name, hint: "Use 7d, 12h, 2026-11-01 or 2026-11-01T09:00:00Z." });
|
|
4399
4399
|
}
|
|
4400
4400
|
return new Date(day && name === "until" ? ms + DAY_MS - 1 : ms).toISOString();
|
|
4401
4401
|
}
|
|
@@ -4451,8 +4451,8 @@ var init_sse = __esm({
|
|
|
4451
4451
|
this.idBuffer = lastEventId;
|
|
4452
4452
|
}
|
|
4453
4453
|
/** Feeds decoded text and returns the events it completed. A CR at the end waits for the next chunk (it may be CRLF). */
|
|
4454
|
-
push(
|
|
4455
|
-
this.buffer +=
|
|
4454
|
+
push(text5) {
|
|
4455
|
+
this.buffer += text5;
|
|
4456
4456
|
if (!this.started && this.buffer.length > 0) {
|
|
4457
4457
|
this.started = true;
|
|
4458
4458
|
if (this.buffer.startsWith("\uFEFF")) this.buffer = this.buffer.slice(1);
|
|
@@ -4557,8 +4557,8 @@ async function readConnection(ctx, res, parser, opts, printed) {
|
|
|
4557
4557
|
const reader = res.body.getReader();
|
|
4558
4558
|
const decoder = new TextDecoder();
|
|
4559
4559
|
let stopped;
|
|
4560
|
-
const stop = (
|
|
4561
|
-
stopped ??=
|
|
4560
|
+
const stop = (why2) => {
|
|
4561
|
+
stopped ??= why2;
|
|
4562
4562
|
reader.cancel().catch(() => void 0);
|
|
4563
4563
|
};
|
|
4564
4564
|
let idle = setTimeout(() => stop("idle"), STREAM_IDLE_MS);
|
|
@@ -4645,9 +4645,9 @@ async function followEventStream(ctx, req, opts) {
|
|
|
4645
4645
|
hint: "Try again later; --verbose shows each connect."
|
|
4646
4646
|
});
|
|
4647
4647
|
}
|
|
4648
|
-
const
|
|
4648
|
+
const why2 = ended.bye !== void 0 ? `the server said bye: ${ended.bye}` : ended.dropped ?? "the server closed it";
|
|
4649
4649
|
const waitMs = !progressed ? Math.max(backoffMs(failures), retryMs ?? 0) : ended.bye !== void 0 ? retryMs ?? 0 : Math.max(1e3, retryMs ?? 0);
|
|
4650
|
-
ctx.output.info(`Stream ended (${
|
|
4650
|
+
ctx.output.info(`Stream ended (${why2}); reconnecting${lastEventId !== "" ? ` after event ${lastEventId}` : ""}${waitMs >= 1e3 ? ` in ${Math.round(waitMs / 1e3)} s` : ""}.`);
|
|
4651
4651
|
if (waitMs > 0 && !await pause(ctx, waitMs)) return ExitCode.Ok;
|
|
4652
4652
|
}
|
|
4653
4653
|
}
|
|
@@ -4731,13 +4731,13 @@ function byRow(results) {
|
|
|
4731
4731
|
}
|
|
4732
4732
|
async function readResults(path) {
|
|
4733
4733
|
const results = /* @__PURE__ */ new Map();
|
|
4734
|
-
let
|
|
4734
|
+
let text5;
|
|
4735
4735
|
try {
|
|
4736
|
-
|
|
4736
|
+
text5 = await readFile3(path, "utf8");
|
|
4737
4737
|
} catch {
|
|
4738
4738
|
return results;
|
|
4739
4739
|
}
|
|
4740
|
-
for (const line of
|
|
4740
|
+
for (const line of text5.split("\n")) {
|
|
4741
4741
|
if (line.trim() === "") continue;
|
|
4742
4742
|
try {
|
|
4743
4743
|
const value = JSON.parse(line);
|
|
@@ -4968,9 +4968,9 @@ async function readRun(dir3) {
|
|
|
4968
4968
|
return null;
|
|
4969
4969
|
}
|
|
4970
4970
|
if (!raw) return null;
|
|
4971
|
-
const { runId, command:
|
|
4971
|
+
const { runId, command: command91, createdAt, status } = raw;
|
|
4972
4972
|
if (typeof runId !== "string" || !RUN_ID_PATTERN.test(runId)) return null;
|
|
4973
|
-
if (typeof
|
|
4973
|
+
if (typeof command91 !== "string" || typeof createdAt !== "string") return null;
|
|
4974
4974
|
if (typeof status !== "string" || !STATUSES.includes(status)) return null;
|
|
4975
4975
|
let chunksDone = chunkList(raw.chunksDone) ?? [];
|
|
4976
4976
|
try {
|
|
@@ -4981,7 +4981,7 @@ async function readRun(dir3) {
|
|
|
4981
4981
|
const record3 = {
|
|
4982
4982
|
...raw,
|
|
4983
4983
|
runId,
|
|
4984
|
-
command:
|
|
4984
|
+
command: command91,
|
|
4985
4985
|
args: asRecord3(raw.args) ?? {},
|
|
4986
4986
|
createdAt,
|
|
4987
4987
|
status,
|
|
@@ -5041,11 +5041,11 @@ async function loadRun(runId, env = process.env) {
|
|
|
5041
5041
|
}
|
|
5042
5042
|
return run;
|
|
5043
5043
|
}
|
|
5044
|
-
async function findIdentical(
|
|
5044
|
+
async function findIdentical(command91, args, inputSha256, env, workspaceId, anyWorkspace = false) {
|
|
5045
5045
|
const identity = argsIdentity(args);
|
|
5046
5046
|
const runs = await listRuns(env);
|
|
5047
5047
|
return runs.filter(
|
|
5048
|
-
(run) => run.command ===
|
|
5048
|
+
(run) => run.command === command91 && (run.inputSha256 || void 0) === (inputSha256 || void 0) && (anyWorkspace || (run.workspaceId || void 0) === (workspaceId || void 0)) && argsIdentity(run.args) === identity
|
|
5049
5049
|
);
|
|
5050
5050
|
}
|
|
5051
5051
|
function isOtherLiveProcess(pid) {
|
|
@@ -5764,8 +5764,8 @@ var init_init_state = __esm({
|
|
|
5764
5764
|
var underscore2;
|
|
5765
5765
|
var init_underscore2 = __esm({
|
|
5766
5766
|
"node_modules/.pnpm/csv-parse@7.0.3/node_modules/csv-parse/lib/utils/underscore.js"() {
|
|
5767
|
-
underscore2 = function(
|
|
5768
|
-
return
|
|
5767
|
+
underscore2 = function(str2) {
|
|
5768
|
+
return str2.replace(/([A-Z])/g, function(_, match) {
|
|
5769
5769
|
return "_" + match.toLowerCase();
|
|
5770
5770
|
});
|
|
5771
5771
|
};
|
|
@@ -7306,23 +7306,23 @@ async function readRaw(pathOrDash, stdin) {
|
|
|
7306
7306
|
throw fileUnreadable(pathOrDash, err);
|
|
7307
7307
|
}
|
|
7308
7308
|
}
|
|
7309
|
-
function stripBom(
|
|
7310
|
-
return
|
|
7309
|
+
function stripBom(text5) {
|
|
7310
|
+
return text5.charCodeAt(0) === 65279 ? text5.slice(1) : text5;
|
|
7311
7311
|
}
|
|
7312
|
-
function detectFormat(path,
|
|
7312
|
+
function detectFormat(path, text5) {
|
|
7313
7313
|
const ext = path === "-" ? "" : extname2(path).toLowerCase();
|
|
7314
7314
|
if (ext === ".csv") return "csv";
|
|
7315
7315
|
if (ext === ".jsonl" || ext === ".ndjson") return "jsonl";
|
|
7316
|
-
return stripBom(
|
|
7316
|
+
return stripBom(text5).trimStart().startsWith("{") ? "jsonl" : "csv";
|
|
7317
7317
|
}
|
|
7318
7318
|
function badFile(message, hint) {
|
|
7319
7319
|
return new KensoError({ code: "file_unreadable", message, exitCode: ExitCode.Usage, field: "file", hint });
|
|
7320
7320
|
}
|
|
7321
|
-
function parseCsv(
|
|
7321
|
+
function parseCsv(text5, source) {
|
|
7322
7322
|
let headers = [];
|
|
7323
7323
|
let records;
|
|
7324
7324
|
try {
|
|
7325
|
-
records = parse(
|
|
7325
|
+
records = parse(text5, {
|
|
7326
7326
|
columns: (header2) => {
|
|
7327
7327
|
headers = header2.map((h) => String(h));
|
|
7328
7328
|
return headers;
|
|
@@ -7345,11 +7345,11 @@ function parseCsv(text4, source) {
|
|
|
7345
7345
|
});
|
|
7346
7346
|
return { headers, rows };
|
|
7347
7347
|
}
|
|
7348
|
-
function parseJsonl(
|
|
7348
|
+
function parseJsonl(text5, source) {
|
|
7349
7349
|
const headers = [];
|
|
7350
7350
|
const seen = /* @__PURE__ */ new Set();
|
|
7351
7351
|
const rows = [];
|
|
7352
|
-
const lines = stripBom(
|
|
7352
|
+
const lines = stripBom(text5).split("\n");
|
|
7353
7353
|
lines.forEach((raw, i) => {
|
|
7354
7354
|
const line = raw.trim();
|
|
7355
7355
|
if (line === "") return;
|
|
@@ -7375,10 +7375,10 @@ function parseJsonl(text4, source) {
|
|
|
7375
7375
|
async function readInput(pathOrDash, opts) {
|
|
7376
7376
|
const { path, bytes } = await readRaw(pathOrDash, opts?.stdin);
|
|
7377
7377
|
const sha2566 = createHash2("sha256").update(bytes).digest("hex");
|
|
7378
|
-
const
|
|
7378
|
+
const text5 = bytes.toString("utf8");
|
|
7379
7379
|
const source = path === "-" ? "stdin" : pathOrDash;
|
|
7380
|
-
const format = detectFormat(path,
|
|
7381
|
-
const parsed2 = format === "csv" ? parseCsv(
|
|
7380
|
+
const format = detectFormat(path, text5);
|
|
7381
|
+
const parsed2 = format === "csv" ? parseCsv(text5, source) : parseJsonl(text5, source);
|
|
7382
7382
|
return { path, format, sha256: sha2566, ...parsed2 };
|
|
7383
7383
|
}
|
|
7384
7384
|
function idText(value) {
|
|
@@ -7386,8 +7386,8 @@ function idText(value) {
|
|
|
7386
7386
|
if (typeof value === "string" && value.trim() !== "") return value.trim();
|
|
7387
7387
|
return void 0;
|
|
7388
7388
|
}
|
|
7389
|
-
function looksLikeCsvHeader(
|
|
7390
|
-
const first = stripBom(
|
|
7389
|
+
function looksLikeCsvHeader(text5, column) {
|
|
7390
|
+
const first = stripBom(text5).split("\n").map((l) => l.trim()).find((l) => l !== "");
|
|
7391
7391
|
if (first === void 0) return false;
|
|
7392
7392
|
if (first.includes(",")) return true;
|
|
7393
7393
|
const name = first.replace(/^"(.*)"$/, "$1");
|
|
@@ -7395,18 +7395,18 @@ function looksLikeCsvHeader(text4, column) {
|
|
|
7395
7395
|
}
|
|
7396
7396
|
async function readIds(pathOrDash, opts) {
|
|
7397
7397
|
const { path, bytes } = await readRaw(pathOrDash, opts?.stdin);
|
|
7398
|
-
const
|
|
7398
|
+
const text5 = bytes.toString("utf8");
|
|
7399
7399
|
const source = path === "-" ? "stdin" : pathOrDash;
|
|
7400
7400
|
const column = opts?.column?.trim() || void 0;
|
|
7401
7401
|
const ext = path === "-" ? "" : extname2(path).toLowerCase();
|
|
7402
7402
|
let format;
|
|
7403
|
-
if (ext === ".csv" || ext === ".jsonl" || ext === ".ndjson") format = detectFormat(path,
|
|
7404
|
-
else if (stripBom(
|
|
7405
|
-
else format = column !== void 0 || looksLikeCsvHeader(
|
|
7403
|
+
if (ext === ".csv" || ext === ".jsonl" || ext === ".ndjson") format = detectFormat(path, text5);
|
|
7404
|
+
else if (stripBom(text5).trimStart().startsWith("{")) format = "jsonl";
|
|
7405
|
+
else format = column !== void 0 || looksLikeCsvHeader(text5, column) ? "csv" : "text";
|
|
7406
7406
|
if (format === "text") {
|
|
7407
|
-
return stripBom(
|
|
7407
|
+
return stripBom(text5).split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
7408
7408
|
}
|
|
7409
|
-
const { headers, rows } = format === "csv" ? parseCsv(
|
|
7409
|
+
const { headers, rows } = format === "csv" ? parseCsv(text5, source) : parseJsonl(text5, source);
|
|
7410
7410
|
const key = column ?? (headers.includes("id") ? "id" : headers.includes("contactId") ? "contactId" : void 0);
|
|
7411
7411
|
if (key === void 0 || !headers.includes(key)) {
|
|
7412
7412
|
throw usageError(
|
|
@@ -7462,32 +7462,32 @@ function paramIndex(op) {
|
|
|
7462
7462
|
for (const param of all) if (!index2.has(param.flag)) index2.set(param.flag, param);
|
|
7463
7463
|
return index2;
|
|
7464
7464
|
}
|
|
7465
|
-
function convert(
|
|
7466
|
-
if (!param) return
|
|
7465
|
+
function convert(text5, param, key) {
|
|
7466
|
+
if (!param) return text5;
|
|
7467
7467
|
switch (param.type) {
|
|
7468
7468
|
case "integer":
|
|
7469
7469
|
case "number": {
|
|
7470
|
-
const value = Number(
|
|
7470
|
+
const value = Number(text5);
|
|
7471
7471
|
if (!Number.isFinite(value) || param.type === "integer" && !Number.isSafeInteger(value)) {
|
|
7472
|
-
throw usageError(`${key} must be a ${param.type === "integer" ? "whole number" : "number"} (got "${
|
|
7472
|
+
throw usageError(`${key} must be a ${param.type === "integer" ? "whole number" : "number"} (got "${text5}").`, { field: key });
|
|
7473
7473
|
}
|
|
7474
7474
|
return value;
|
|
7475
7475
|
}
|
|
7476
7476
|
case "boolean": {
|
|
7477
|
-
const lower =
|
|
7477
|
+
const lower = text5.toLowerCase();
|
|
7478
7478
|
if (lower === "true" || lower === "false") return lower === "true";
|
|
7479
|
-
throw usageError(`${key} must be true or false (got "${
|
|
7479
|
+
throw usageError(`${key} must be true or false (got "${text5}").`, { field: key });
|
|
7480
7480
|
}
|
|
7481
7481
|
case "array":
|
|
7482
|
-
return
|
|
7482
|
+
return text5.split(",").map((item) => item.trim()).filter((item) => item !== "");
|
|
7483
7483
|
case "object":
|
|
7484
7484
|
try {
|
|
7485
|
-
return JSON.parse(
|
|
7485
|
+
return JSON.parse(text5);
|
|
7486
7486
|
} catch {
|
|
7487
|
-
throw usageError(`${key} must be JSON (got "${
|
|
7487
|
+
throw usageError(`${key} must be JSON (got "${text5}").`, { field: key });
|
|
7488
7488
|
}
|
|
7489
7489
|
default:
|
|
7490
|
-
return
|
|
7490
|
+
return text5;
|
|
7491
7491
|
}
|
|
7492
7492
|
}
|
|
7493
7493
|
function rowToValues(row, index2) {
|
|
@@ -7497,9 +7497,9 @@ function rowToValues(row, index2) {
|
|
|
7497
7497
|
const param = index2.get(key);
|
|
7498
7498
|
const name = param?.name ?? key;
|
|
7499
7499
|
if (typeof raw === "string") {
|
|
7500
|
-
const
|
|
7501
|
-
if (
|
|
7502
|
-
values[name] =
|
|
7500
|
+
const text5 = raw.trim();
|
|
7501
|
+
if (text5 === "") continue;
|
|
7502
|
+
values[name] = text5 === "null" ? null : convert(text5, param, key);
|
|
7503
7503
|
} else {
|
|
7504
7504
|
values[name] = raw;
|
|
7505
7505
|
}
|
|
@@ -7672,8 +7672,8 @@ function fileFlagText(op, files) {
|
|
|
7672
7672
|
function describeParam(param, location, list2) {
|
|
7673
7673
|
const fallback = list2 && location === "query" && LIST_PARAM_TEXT[param.name] || `${param.name} (${location === "route" ? "path" : location}, ${param.type})`;
|
|
7674
7674
|
const base = param.description?.replace(/\s*\n\s*/g, " ") ?? fallback;
|
|
7675
|
-
const
|
|
7676
|
-
return param.jsonOnly ? `${
|
|
7675
|
+
const text5 = param.enum ? `${base} One of: ${param.enum.join(", ")}.` : base;
|
|
7676
|
+
return param.jsonOnly ? `${text5} JSON body only: not with --file.` : text5;
|
|
7677
7677
|
}
|
|
7678
7678
|
function operationFlags(op) {
|
|
7679
7679
|
const flags = [];
|
|
@@ -7791,13 +7791,13 @@ function missing(op, flag) {
|
|
|
7791
7791
|
return usageError(`--${flag} is required for ${commandOf(op)}.`, { field: flag, hint: `Usage: ${usageLine(op)}`, next: `${commandOf(op)} --help` });
|
|
7792
7792
|
}
|
|
7793
7793
|
function parseNumber(raw, flag, integer) {
|
|
7794
|
-
const
|
|
7795
|
-
const value = Number(
|
|
7794
|
+
const text5 = raw.trim();
|
|
7795
|
+
const value = Number(text5);
|
|
7796
7796
|
if (integer) {
|
|
7797
|
-
if (!/^-?\d+$/.test(
|
|
7797
|
+
if (!/^-?\d+$/.test(text5) || !Number.isSafeInteger(value)) {
|
|
7798
7798
|
throw usageError(`--${flag} must be a whole number (got "${raw}").`, { field: flag });
|
|
7799
7799
|
}
|
|
7800
|
-
} else if (
|
|
7800
|
+
} else if (text5 === "" || !Number.isFinite(value)) {
|
|
7801
7801
|
throw usageError(`--${flag} must be a number (got "${raw}").`, { field: flag });
|
|
7802
7802
|
}
|
|
7803
7803
|
return value;
|
|
@@ -7816,11 +7816,11 @@ function buildRequest(op, values) {
|
|
|
7816
7816
|
const value = values[name];
|
|
7817
7817
|
const flag = op.routeParams.find((p) => p.name === name)?.flag ?? name;
|
|
7818
7818
|
if (isBlank(value)) throw missing(op, flag);
|
|
7819
|
-
const
|
|
7820
|
-
if (
|
|
7821
|
-
throw usageError(`--${flag} cannot be "${
|
|
7819
|
+
const text5 = String(value);
|
|
7820
|
+
if (text5 === "." || text5 === "..") {
|
|
7821
|
+
throw usageError(`--${flag} cannot be "${text5}": in the path it would send ${commandOf(op)} to another route.`, { field: flag });
|
|
7822
7822
|
}
|
|
7823
|
-
return encodeURIComponent(
|
|
7823
|
+
return encodeURIComponent(text5);
|
|
7824
7824
|
});
|
|
7825
7825
|
const query = {};
|
|
7826
7826
|
for (const name of queryNames) {
|
|
@@ -8167,9 +8167,9 @@ function normalizedNotes(op) {
|
|
|
8167
8167
|
return (op.description ?? "").trim().replace(/\n[ \t]+/g, "\n");
|
|
8168
8168
|
}
|
|
8169
8169
|
function helpNotes(op) {
|
|
8170
|
-
const
|
|
8171
|
-
if (
|
|
8172
|
-
const head =
|
|
8170
|
+
const text5 = normalizedNotes(op);
|
|
8171
|
+
if (text5.length <= HELP_NOTES_MAX) return text5;
|
|
8172
|
+
const head = text5.slice(0, HELP_NOTES_MAX);
|
|
8173
8173
|
const end = Math.max(head.lastIndexOf(". "), head.lastIndexOf(".\n"));
|
|
8174
8174
|
return end > HELP_NOTES_MAX / 3 ? head.slice(0, end + 1) : `${head.trimEnd()}...`;
|
|
8175
8175
|
}
|
|
@@ -8179,14 +8179,14 @@ function helpFlagText(f) {
|
|
|
8179
8179
|
if (enumText && base.endsWith(enumText)) base = base.slice(0, -enumText.length);
|
|
8180
8180
|
const placeholder = f.param ? /^\S+ \((?:path|query|body), ([\w-]+)\)$/.exec(base) : null;
|
|
8181
8181
|
if (placeholder) return { text: `${placeholder[1]}${enumText}`, cut: false };
|
|
8182
|
-
let
|
|
8183
|
-
const sentence = /\.(?=\s+[A-Z])/.exec(
|
|
8184
|
-
if (sentence)
|
|
8185
|
-
if (
|
|
8186
|
-
const head =
|
|
8187
|
-
|
|
8182
|
+
let text5 = base;
|
|
8183
|
+
const sentence = /\.(?=\s+[A-Z])/.exec(text5);
|
|
8184
|
+
if (sentence) text5 = text5.slice(0, sentence.index + 1);
|
|
8185
|
+
if (text5.length > HELP_FLAG_MAX) {
|
|
8186
|
+
const head = text5.slice(0, HELP_FLAG_MAX);
|
|
8187
|
+
text5 = `${head.slice(0, Math.max(head.lastIndexOf(" "), HELP_FLAG_MAX / 2)).replace(/[,;:]$/, "")}...`;
|
|
8188
8188
|
}
|
|
8189
|
-
return { text: `${
|
|
8189
|
+
return { text: `${text5}${enumText}`, cut: text5 !== base };
|
|
8190
8190
|
}
|
|
8191
8191
|
function withBareId(op, flags, positionals) {
|
|
8192
8192
|
const [param] = op.routeParams;
|
|
@@ -8200,15 +8200,15 @@ function withBareId(op, flags, positionals) {
|
|
|
8200
8200
|
}
|
|
8201
8201
|
function operationToCommand(op) {
|
|
8202
8202
|
const flags = {};
|
|
8203
|
-
let
|
|
8203
|
+
let cut2 = false;
|
|
8204
8204
|
for (const f of operationFlags(op)) {
|
|
8205
8205
|
const shown = helpFlagText(f);
|
|
8206
|
-
|
|
8207
|
-
const
|
|
8206
|
+
cut2 ||= shown.cut;
|
|
8207
|
+
const text5 = f.location === "body" && isSecretFlag(f.flag, f.type) ? `${shown.text} ${SECRET_HELP}` : shown.text;
|
|
8208
8208
|
const spec = {
|
|
8209
8209
|
type: f.type === "boolean" ? "boolean" : "string",
|
|
8210
8210
|
// The dispatcher would enforce `required` before --each rows can fill it, so the command checks it instead.
|
|
8211
|
-
description: f.required ? `${
|
|
8211
|
+
description: f.required ? `${text5} (required)` : text5
|
|
8212
8212
|
};
|
|
8213
8213
|
if (f.multiple) spec.multiple = true;
|
|
8214
8214
|
if (FOOTER_FLAGS.has(f.flag) && !f.param) spec.helpHidden = true;
|
|
@@ -8227,7 +8227,7 @@ ${STREAM_HELP}` : op.method === "GET" ? "" : op.read === true ? "\nA read: it se
|
|
|
8227
8227
|
const more = [
|
|
8228
8228
|
op.body ? "--data <json|@file|->: the body (flags win)." : "",
|
|
8229
8229
|
// The same text helpNotes measures, so the pointer shows only when something was left out.
|
|
8230
|
-
|
|
8230
|
+
cut2 || normalizedNotes(op).length > HELP_NOTES_MAX ? `Full notes: kenso describe ${op.resource} ${op.action}.` : ""
|
|
8231
8231
|
].filter(Boolean);
|
|
8232
8232
|
const compact = COMPACT_FIELDS[op.id];
|
|
8233
8233
|
const fields = compact ? `Each row holds ${compact.join(", ")}: --full prints every field, --fields <a,b> picks your own.` : "";
|
|
@@ -8457,12 +8457,12 @@ var init_session = __esm({
|
|
|
8457
8457
|
});
|
|
8458
8458
|
|
|
8459
8459
|
// src/commands/help-agent.ts
|
|
8460
|
-
function withAgentBlock(
|
|
8461
|
-
if (!opts.agent) return `${
|
|
8460
|
+
function withAgentBlock(text5, opts) {
|
|
8461
|
+
if (!opts.agent) return `${text5}
|
|
8462
8462
|
`;
|
|
8463
8463
|
const full = opts.verbose === true || !opts.env || firstInSession(opts.env, opts.agent, "help-block");
|
|
8464
8464
|
return `${AGENT_SKILL_POINTER}
|
|
8465
|
-
${
|
|
8465
|
+
${text5}
|
|
8466
8466
|
|
|
8467
8467
|
${full ? FOR_AGENTS : AGENT_RULES_LINE}
|
|
8468
8468
|
`;
|
|
@@ -8547,8 +8547,8 @@ function firstValue(row, columns2) {
|
|
|
8547
8547
|
const value = row[column];
|
|
8548
8548
|
if (value === void 0 || value === null) continue;
|
|
8549
8549
|
if (typeof value === "string") {
|
|
8550
|
-
const
|
|
8551
|
-
if (
|
|
8550
|
+
const text5 = value.trim();
|
|
8551
|
+
if (text5 !== "") return text5;
|
|
8552
8552
|
continue;
|
|
8553
8553
|
}
|
|
8554
8554
|
if (Array.isArray(value) && value.length === 0) continue;
|
|
@@ -8564,10 +8564,10 @@ function textValue(value, field) {
|
|
|
8564
8564
|
}
|
|
8565
8565
|
function integerValue(value, field, min) {
|
|
8566
8566
|
if (value === void 0) return void 0;
|
|
8567
|
-
let
|
|
8568
|
-
if (typeof value === "number")
|
|
8569
|
-
else if (typeof value === "string")
|
|
8570
|
-
const number =
|
|
8567
|
+
let text5;
|
|
8568
|
+
if (typeof value === "number") text5 = String(value);
|
|
8569
|
+
else if (typeof value === "string") text5 = /^\d{1,3}(,\d{3})+$/.test(value) ? value.replace(/,/g, "") : value;
|
|
8570
|
+
const number = text5 !== void 0 && /^-?\d+$/.test(text5) ? Number(text5) : Number.NaN;
|
|
8571
8571
|
if (!Number.isSafeInteger(number) || min !== void 0 && number < min) {
|
|
8572
8572
|
const kind = min === 1 ? "a positive whole number" : min === 0 ? "a whole number of 0 or more" : "a whole number";
|
|
8573
8573
|
throw new RowInvalid("invalid_value", `${field} must be ${kind} (got ${JSON.stringify(value)}).`);
|
|
@@ -8580,8 +8580,8 @@ function idValue(value, field) {
|
|
|
8580
8580
|
function shellQuote3(arg) {
|
|
8581
8581
|
return /^[A-Za-z0-9_./:=@%+,-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
8582
8582
|
}
|
|
8583
|
-
function commandLine2(ctx,
|
|
8584
|
-
const parts2 = ["kenso", ...
|
|
8583
|
+
function commandLine2(ctx, command91, args, extra = []) {
|
|
8584
|
+
const parts2 = ["kenso", ...command91.split(" "), ...(args.positionals ?? []).map(shellQuote3)];
|
|
8585
8585
|
for (const [name, value] of Object.entries(args.flags)) {
|
|
8586
8586
|
if (value === void 0 || value === false) continue;
|
|
8587
8587
|
if (value === true) parts2.push(`--${name}`);
|
|
@@ -8693,8 +8693,8 @@ function toBody(row, columns2) {
|
|
|
8693
8693
|
if (name !== void 0) body2.name = name;
|
|
8694
8694
|
body2.domains = domains;
|
|
8695
8695
|
for (const field of TEXT_FIELDS.slice(1)) {
|
|
8696
|
-
const
|
|
8697
|
-
if (
|
|
8696
|
+
const text5 = textValue(value(field), field);
|
|
8697
|
+
if (text5 !== void 0) body2[field] = text5;
|
|
8698
8698
|
}
|
|
8699
8699
|
const employeeCount = integerValue(value("employeeCount"), "employeeCount", 0);
|
|
8700
8700
|
if (employeeCount !== void 0) body2.employeeCount = employeeCount;
|
|
@@ -8891,22 +8891,22 @@ import { resolve as resolve6 } from "node:path";
|
|
|
8891
8891
|
function stringFlag2(flags, name) {
|
|
8892
8892
|
const value = flags[name];
|
|
8893
8893
|
if (typeof value !== "string") return void 0;
|
|
8894
|
-
const
|
|
8895
|
-
return
|
|
8894
|
+
const text5 = value.trim();
|
|
8895
|
+
return text5 === "" ? void 0 : text5;
|
|
8896
8896
|
}
|
|
8897
|
-
function requireFlag(flags, name,
|
|
8897
|
+
function requireFlag(flags, name, command91, hint) {
|
|
8898
8898
|
const value = stringFlag2(flags, name);
|
|
8899
|
-
if (value === void 0) throw usageError(`--${name} is required for ${
|
|
8899
|
+
if (value === void 0) throw usageError(`--${name} is required for ${command91}.`, { field: name, next: `${command91} --help`, ...hint ? { hint } : {} });
|
|
8900
8900
|
return value;
|
|
8901
8901
|
}
|
|
8902
8902
|
function positiveId(value) {
|
|
8903
|
-
const
|
|
8904
|
-
if (!/^[0-9]+$/.test(
|
|
8905
|
-
const id = Number(
|
|
8903
|
+
const text5 = value.trim();
|
|
8904
|
+
if (!/^[0-9]+$/.test(text5)) return void 0;
|
|
8905
|
+
const id = Number(text5);
|
|
8906
8906
|
return Number.isSafeInteger(id) && id > 0 ? id : void 0;
|
|
8907
8907
|
}
|
|
8908
|
-
function idFlag(flags, name,
|
|
8909
|
-
const raw = requireFlag(flags, name,
|
|
8908
|
+
function idFlag(flags, name, command91) {
|
|
8909
|
+
const raw = requireFlag(flags, name, command91);
|
|
8910
8910
|
const id = positiveId(raw);
|
|
8911
8911
|
if (id === void 0) throw usageError(`--${name} must be a positive whole number (got "${raw}").`, { field: name });
|
|
8912
8912
|
return id;
|
|
@@ -8926,8 +8926,8 @@ function isDryRun(ctx) {
|
|
|
8926
8926
|
function shellQuote4(value) {
|
|
8927
8927
|
return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
8928
8928
|
}
|
|
8929
|
-
function sameCommand2(
|
|
8930
|
-
const parts2 = [
|
|
8929
|
+
function sameCommand2(command91, flags, ctx, extra = []) {
|
|
8930
|
+
const parts2 = [command91];
|
|
8931
8931
|
for (const [name, value] of Object.entries(flags)) {
|
|
8932
8932
|
if (value === void 0 || value === false) continue;
|
|
8933
8933
|
if (value === true) parts2.push(`--${name}`);
|
|
@@ -9054,8 +9054,8 @@ __export(wait_exports, {
|
|
|
9054
9054
|
default: () => wait_default,
|
|
9055
9055
|
parseDuration: () => parseDuration
|
|
9056
9056
|
});
|
|
9057
|
-
function parseDuration(
|
|
9058
|
-
const match = /^(\d+(?:\.\d+)?)\s*([smh]?)$/i.exec(
|
|
9057
|
+
function parseDuration(text5) {
|
|
9058
|
+
const match = /^(\d+(?:\.\d+)?)\s*([smh]?)$/i.exec(text5.trim());
|
|
9059
9059
|
if (!match) return void 0;
|
|
9060
9060
|
const ms = Number(match[1]) * (UNIT_MS[(match[2] || "s").toLowerCase()] ?? 1e3);
|
|
9061
9061
|
return Number.isFinite(ms) ? Math.round(ms) : void 0;
|
|
@@ -9123,9 +9123,9 @@ function idList(flags, name) {
|
|
|
9123
9123
|
}
|
|
9124
9124
|
return [...new Set(ids2)];
|
|
9125
9125
|
}
|
|
9126
|
-
function jsonValue(
|
|
9126
|
+
function jsonValue(text5) {
|
|
9127
9127
|
try {
|
|
9128
|
-
return JSON.parse(
|
|
9128
|
+
return JSON.parse(text5);
|
|
9129
9129
|
} catch {
|
|
9130
9130
|
return void 0;
|
|
9131
9131
|
}
|
|
@@ -9136,12 +9136,12 @@ function parseSet(pairs, aliases, textFields = []) {
|
|
|
9136
9136
|
const at = pair.indexOf("=");
|
|
9137
9137
|
const key = at > 0 ? pair.slice(0, at).trim() : "";
|
|
9138
9138
|
if (key === "") throw usageError(`--set takes field=value (got "${pair}").`, { field: "set", hint: "For example --set stage=engaged." });
|
|
9139
|
-
const
|
|
9139
|
+
const text5 = pair.slice(at + 1).trim();
|
|
9140
9140
|
const field = aliases[key] ?? key;
|
|
9141
9141
|
if (field in set2) throw usageError(`--set names ${field} twice.`, { field: "set" });
|
|
9142
|
-
const json = jsonValue(
|
|
9142
|
+
const json = jsonValue(text5);
|
|
9143
9143
|
const asText = textFields.includes(field) && json !== null && typeof json !== "string";
|
|
9144
|
-
set2[field] = asText || json === void 0 ?
|
|
9144
|
+
set2[field] = asText || json === void 0 ? text5 : json;
|
|
9145
9145
|
}
|
|
9146
9146
|
return set2;
|
|
9147
9147
|
}
|
|
@@ -9166,14 +9166,14 @@ function viewId(flags) {
|
|
|
9166
9166
|
if (id === void 0) throw usageError(`--view takes a saved view's id (got "${raw}").`, { field: "view", next: "kenso views list" });
|
|
9167
9167
|
return id;
|
|
9168
9168
|
}
|
|
9169
|
-
function targetBody(flags, target2,
|
|
9169
|
+
function targetBody(flags, target2, command91) {
|
|
9170
9170
|
const ids2 = idList(flags, "ids");
|
|
9171
9171
|
const filter = filterBody(flags);
|
|
9172
9172
|
const view = viewId(flags);
|
|
9173
9173
|
const everything = flags.all === true;
|
|
9174
9174
|
const ways = [ids2, filter, view].filter((way) => way !== void 0).length;
|
|
9175
9175
|
if (ways > 1 || ways === 0 && !everything || ids2 !== void 0 && everything) {
|
|
9176
|
-
throw usageError(`Name the ${target2.plural} one way: --ids, --filter, --view, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${
|
|
9176
|
+
throw usageError(`Name the ${target2.plural} one way: --ids, --filter, --view, or --all for every ${target2.noun} in the workspace.`, { field: "ids", next: `${command91} --help` });
|
|
9177
9177
|
}
|
|
9178
9178
|
const exclude = idList(flags, "exclude-ids");
|
|
9179
9179
|
if (exclude !== void 0 && ids2 !== void 0) throw usageError("--exclude-ids goes with --filter, --view or --all.", { field: "exclude-ids" });
|
|
@@ -9195,14 +9195,14 @@ function tagSet(flags) {
|
|
|
9195
9195
|
return set2;
|
|
9196
9196
|
}
|
|
9197
9197
|
function requestBody(flags, target2, dryRun2) {
|
|
9198
|
-
const
|
|
9198
|
+
const command91 = `kenso ${target2.resource} bulk-update`;
|
|
9199
9199
|
const pairs = Array.isArray(flags.set) ? flags.set : typeof flags.set === "string" ? [flags.set] : [];
|
|
9200
9200
|
const tags = target2.tags ? tagSet(flags) : {};
|
|
9201
9201
|
if (pairs.length === 0 && Object.keys(tags).length === 0) {
|
|
9202
|
-
throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${
|
|
9202
|
+
throw usageError(`--set${target2.tags ? " or --add-tag" : ""} is required for ${command91}.`, { field: "set", hint: "For example --set stage=engaged.", next: `${command91} --help` });
|
|
9203
9203
|
}
|
|
9204
9204
|
return {
|
|
9205
|
-
...targetBody(flags, target2,
|
|
9205
|
+
...targetBody(flags, target2, command91),
|
|
9206
9206
|
set: { ...parseSet(pairs, target2.aliases, target2.textFields), ...tags },
|
|
9207
9207
|
...dryRun2 ? { dryRun: true } : {},
|
|
9208
9208
|
...flags["overwrite-pinned"] === true ? { overwritePinned: true } : {}
|
|
@@ -9270,7 +9270,7 @@ function bulkUpdateCommand(target2) {
|
|
|
9270
9270
|
};
|
|
9271
9271
|
}
|
|
9272
9272
|
function bulkDeleteCommand(target2) {
|
|
9273
|
-
const
|
|
9273
|
+
const command91 = `kenso ${target2.resource} bulk-delete`;
|
|
9274
9274
|
return {
|
|
9275
9275
|
resource: target2.resource,
|
|
9276
9276
|
action: "bulk-delete",
|
|
@@ -9296,11 +9296,11 @@ function bulkDeleteCommand(target2) {
|
|
|
9296
9296
|
beta: { featureGates: { all: target2.featureGates } },
|
|
9297
9297
|
operationIds: [`${target2.resource}.bulk-delete`, "changes.get"],
|
|
9298
9298
|
dryRun: true,
|
|
9299
|
-
run: (ctx, { flags }) => runChange(ctx, flags, target2, "delete", `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2,
|
|
9299
|
+
run: (ctx, { flags }) => runChange(ctx, flags, target2, "delete", `/v1/${target2.resource}/bulk-delete`, (dryRun2) => ({ ...targetBody(flags, target2, command91), dryRun: dryRun2 }))
|
|
9300
9300
|
};
|
|
9301
9301
|
}
|
|
9302
9302
|
async function applyPreview(ctx, flags, target2, action, raw) {
|
|
9303
|
-
const
|
|
9303
|
+
const command91 = `kenso ${target2.resource} bulk-${action}`;
|
|
9304
9304
|
const id = positiveId(raw);
|
|
9305
9305
|
if (id === void 0) throw usageError(`--change-id takes the id a dry run printed (got "${raw}").`, { field: "change-id" });
|
|
9306
9306
|
if (ctx.flags.yes !== true || ctx.flags.dryRun === true) {
|
|
@@ -9311,7 +9311,7 @@ async function applyPreview(ctx, flags, target2, action, raw) {
|
|
|
9311
9311
|
}
|
|
9312
9312
|
const extra = NEW_CHANGE_FLAGS.find((name) => flags[name] !== void 0 && flags[name] !== false && !(Array.isArray(flags[name]) && flags[name].length === 0));
|
|
9313
9313
|
if (extra !== void 0) {
|
|
9314
|
-
throw usageError(`--change-id applies the change as it was listed: leave out --${extra}.`, { field: extra, next: `${
|
|
9314
|
+
throw usageError(`--change-id applies the change as it was listed: leave out --${extra}.`, { field: extra, next: `${command91} --change-id ${id} --yes` });
|
|
9315
9315
|
}
|
|
9316
9316
|
const got = unwrap((await ctx.client.request({ method: "GET", path: `/v1/changes/${id}`, signal: ctx.signal })).body);
|
|
9317
9317
|
if (got.object !== void 0 && (got.object !== target2.resource || got.action !== action)) {
|
|
@@ -9866,11 +9866,11 @@ var init_starters = __esm({
|
|
|
9866
9866
|
function isRecord7(value) {
|
|
9867
9867
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
9868
9868
|
}
|
|
9869
|
-
function parseJson(
|
|
9869
|
+
function parseJson(text5) {
|
|
9870
9870
|
try {
|
|
9871
|
-
return JSON.parse(
|
|
9871
|
+
return JSON.parse(text5);
|
|
9872
9872
|
} catch {
|
|
9873
|
-
return
|
|
9873
|
+
return text5;
|
|
9874
9874
|
}
|
|
9875
9875
|
}
|
|
9876
9876
|
function eventData(event) {
|
|
@@ -9980,8 +9980,8 @@ var init_client = __esm({
|
|
|
9980
9980
|
}
|
|
9981
9981
|
async notify(method, params) {
|
|
9982
9982
|
const res = await this.post(method, { jsonrpc: "2.0", method, ...params ? { params } : {} });
|
|
9983
|
-
const
|
|
9984
|
-
if (!res.ok) throw errorFromResponse(res.status, parseJson(
|
|
9983
|
+
const text5 = await res.text();
|
|
9984
|
+
if (!res.ok) throw errorFromResponse(res.status, parseJson(text5));
|
|
9985
9985
|
}
|
|
9986
9986
|
async rpc(method, params) {
|
|
9987
9987
|
const id = this.nextId++;
|
|
@@ -10006,9 +10006,9 @@ var init_client = __esm({
|
|
|
10006
10006
|
}
|
|
10007
10007
|
return message.result;
|
|
10008
10008
|
}
|
|
10009
|
-
findInJson(
|
|
10010
|
-
if (
|
|
10011
|
-
return asMessages(parseJson(
|
|
10009
|
+
findInJson(text5, id) {
|
|
10010
|
+
if (text5.trim() === "") return void 0;
|
|
10011
|
+
return asMessages(parseJson(text5)).find((m) => m.id === id);
|
|
10012
10012
|
}
|
|
10013
10013
|
/** Reads SSE events until the message answering `id` arrives, then stops reading. */
|
|
10014
10014
|
async readSse(res, id) {
|
|
@@ -10326,8 +10326,8 @@ var init_shipped = __esm({
|
|
|
10326
10326
|
import { createHash as createHash4 } from "node:crypto";
|
|
10327
10327
|
import { readFileSync as readFileSync11 } from "node:fs";
|
|
10328
10328
|
import { join as join13 } from "node:path";
|
|
10329
|
-
function sha256(
|
|
10330
|
-
return createHash4("sha256").update(
|
|
10329
|
+
function sha256(text5) {
|
|
10330
|
+
return createHash4("sha256").update(text5, "utf8").digest("hex");
|
|
10331
10331
|
}
|
|
10332
10332
|
function skillPath(client, name, env) {
|
|
10333
10333
|
return join13(skillsFolder(client, env), name, "SKILL.md");
|
|
@@ -10408,11 +10408,11 @@ function readExisting(path) {
|
|
|
10408
10408
|
throw new KensoError({ code: "file_unreadable", message: `Cannot read ${path}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Usage });
|
|
10409
10409
|
}
|
|
10410
10410
|
}
|
|
10411
|
-
function write(path,
|
|
10411
|
+
function write(path, text5) {
|
|
10412
10412
|
try {
|
|
10413
10413
|
mkdirSync4(dirname2(path), { recursive: true });
|
|
10414
10414
|
const temp = `${path}.${process.pid}.tmp`;
|
|
10415
|
-
writeFileSync6(temp,
|
|
10415
|
+
writeFileSync6(temp, text5);
|
|
10416
10416
|
renameSync6(temp, path);
|
|
10417
10417
|
} catch (err) {
|
|
10418
10418
|
const code = err.code;
|
|
@@ -10514,28 +10514,28 @@ var init_install = __esm({
|
|
|
10514
10514
|
import { spawnSync } from "node:child_process";
|
|
10515
10515
|
import { existsSync as existsSync6, readFileSync as readFileSync13 } from "node:fs";
|
|
10516
10516
|
import { delimiter, join as join15 } from "node:path";
|
|
10517
|
-
function parse2(
|
|
10517
|
+
function parse2(text5) {
|
|
10518
10518
|
try {
|
|
10519
|
-
const doc = JSON.parse(
|
|
10519
|
+
const doc = JSON.parse(text5);
|
|
10520
10520
|
return isDoc(doc) ? doc : void 0;
|
|
10521
10521
|
} catch {
|
|
10522
10522
|
return void 0;
|
|
10523
10523
|
}
|
|
10524
10524
|
}
|
|
10525
|
-
function stripJsonc(
|
|
10525
|
+
function stripJsonc(text5) {
|
|
10526
10526
|
let out = "";
|
|
10527
|
-
for (let i = 0; i <
|
|
10528
|
-
const ch =
|
|
10527
|
+
for (let i = 0; i < text5.length; i++) {
|
|
10528
|
+
const ch = text5[i];
|
|
10529
10529
|
if (ch === '"') {
|
|
10530
|
-
const
|
|
10531
|
-
out +=
|
|
10532
|
-
i +=
|
|
10533
|
-
} else if (ch === "/" &&
|
|
10534
|
-
while (i <
|
|
10530
|
+
const str2 = /^"(?:[^"\\]|\\.)*"/.exec(text5.slice(i))?.[0] ?? text5.slice(i);
|
|
10531
|
+
out += str2;
|
|
10532
|
+
i += str2.length - 1;
|
|
10533
|
+
} else if (ch === "/" && text5[i + 1] === "/") {
|
|
10534
|
+
while (i < text5.length && text5[i] !== "\n") i++;
|
|
10535
10535
|
out += "\n";
|
|
10536
|
-
} else if (ch === "/" &&
|
|
10537
|
-
const close =
|
|
10538
|
-
i = close === -1 ?
|
|
10536
|
+
} else if (ch === "/" && text5[i + 1] === "*") {
|
|
10537
|
+
const close = text5.indexOf("*/", i + 2);
|
|
10538
|
+
i = close === -1 ? text5.length : close + 1;
|
|
10539
10539
|
} else {
|
|
10540
10540
|
out += ch;
|
|
10541
10541
|
}
|
|
@@ -10550,14 +10550,14 @@ function servers(record3, keys = ["url"]) {
|
|
|
10550
10550
|
return typeof url === "string" ? [{ name, url }] : [];
|
|
10551
10551
|
});
|
|
10552
10552
|
}
|
|
10553
|
-
function mcpServersOf(
|
|
10554
|
-
const doc = readJson(
|
|
10553
|
+
function mcpServersOf(text5, keys) {
|
|
10554
|
+
const doc = readJson(text5);
|
|
10555
10555
|
return doc === void 0 ? void 0 : servers(doc.mcpServers, keys);
|
|
10556
10556
|
}
|
|
10557
|
-
function tomlServers(
|
|
10557
|
+
function tomlServers(text5) {
|
|
10558
10558
|
const entries2 = [];
|
|
10559
10559
|
let name;
|
|
10560
|
-
for (const line of
|
|
10560
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
10561
10561
|
const header2 = /^\s*\[([^\]]+)\]\s*(#.*)?$/.exec(line);
|
|
10562
10562
|
if (header2) {
|
|
10563
10563
|
const m = /^mcp_servers\.(?:"([^"]+)"|'([^']+)'|([A-Za-z0-9_-]+))$/.exec(header2[1].trim());
|
|
@@ -10607,9 +10607,9 @@ function manualStep(client, env, url) {
|
|
|
10607
10607
|
function mcpState(client, env, url) {
|
|
10608
10608
|
const t = TARGETS[client];
|
|
10609
10609
|
const file = t.file(env);
|
|
10610
|
-
const
|
|
10611
|
-
if (
|
|
10612
|
-
const entries2 = t.entries(
|
|
10610
|
+
const text5 = readText2(file);
|
|
10611
|
+
if (text5 === void 0) return { status: "missing", file };
|
|
10612
|
+
const entries2 = t.entries(text5);
|
|
10613
10613
|
if (entries2 === void 0) return { status: "unknown", file, detail: `${file} could not be read as JSON` };
|
|
10614
10614
|
const match = entries2.find((e) => canonical(e.url) === canonical(url));
|
|
10615
10615
|
if (match) return { status: "registered", file, name: match.name };
|
|
@@ -10636,10 +10636,10 @@ function addMcp(client, env, url) {
|
|
|
10636
10636
|
const after = mcpState(client, env, url);
|
|
10637
10637
|
return after.status === "registered" ? { ...after, status: "added" } : { ...state2, status: "failed", detail: `${bin} answered OK but ${t.file(env)} does not list kenso`, next };
|
|
10638
10638
|
}
|
|
10639
|
-
const
|
|
10640
|
-
const doc =
|
|
10639
|
+
const text5 = readText2(state2.file);
|
|
10640
|
+
const doc = text5 === void 0 || text5.trim() === "" ? {} : parse2(text5);
|
|
10641
10641
|
if (doc === void 0) return { ...state2, status: "skipped", detail: `${state2.file} is not plain JSON, so it was left as it is`, next };
|
|
10642
|
-
if (
|
|
10642
|
+
if (text5 === void 0 && client === "opencode") doc.$schema = "https://opencode.ai/config.json";
|
|
10643
10643
|
t.merge(doc, url);
|
|
10644
10644
|
write(state2.file, `${JSON.stringify(doc, null, 2)}
|
|
10645
10645
|
`);
|
|
@@ -10656,14 +10656,14 @@ var init_mcp_config = __esm({
|
|
|
10656
10656
|
init_install();
|
|
10657
10657
|
SERVER_NAME = "kenso";
|
|
10658
10658
|
isDoc = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
10659
|
-
readJson = (
|
|
10659
|
+
readJson = (text5) => parse2(text5) ?? parse2(stripJsonc(text5));
|
|
10660
10660
|
TARGETS = {
|
|
10661
10661
|
"claude-code": {
|
|
10662
10662
|
bins: ["claude"],
|
|
10663
10663
|
folder: claudeDir,
|
|
10664
10664
|
file: (env) => env.CLAUDE_CONFIG_DIR?.trim() ? join15(env.CLAUDE_CONFIG_DIR.trim(), ".claude.json") : join15(home(env), ".claude.json"),
|
|
10665
10665
|
// User scope only: that is where setup adds it, and it reaches every project.
|
|
10666
|
-
entries: (
|
|
10666
|
+
entries: (text5) => mcpServersOf(text5),
|
|
10667
10667
|
command: (url) => ["claude", "mcp", "add", "--scope", "user", "--transport", "http", SERVER_NAME, url],
|
|
10668
10668
|
signIn: "In Claude Code, run /mcp, select kenso and sign in."
|
|
10669
10669
|
},
|
|
@@ -10679,7 +10679,7 @@ var init_mcp_config = __esm({
|
|
|
10679
10679
|
bins: ["cursor", "cursor-agent"],
|
|
10680
10680
|
folder: (env) => join15(home(env), ".cursor"),
|
|
10681
10681
|
file: (env) => join15(home(env), ".cursor", "mcp.json"),
|
|
10682
|
-
entries: (
|
|
10682
|
+
entries: (text5) => mcpServersOf(text5),
|
|
10683
10683
|
merge: (doc, url) => {
|
|
10684
10684
|
const all = isDoc(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
|
|
10685
10685
|
all[SERVER_NAME] = { url };
|
|
@@ -10691,7 +10691,7 @@ var init_mcp_config = __esm({
|
|
|
10691
10691
|
folder: (env) => join15(home(env), ".gemini"),
|
|
10692
10692
|
file: (env) => join15(home(env), ".gemini", "settings.json"),
|
|
10693
10693
|
// httpUrl is Gemini CLI's Streamable HTTP key; url is SSE.
|
|
10694
|
-
entries: (
|
|
10694
|
+
entries: (text5) => mcpServersOf(text5, ["httpUrl", "url"]),
|
|
10695
10695
|
command: (url) => ["gemini", "mcp", "add", "--scope", "user", "--transport", "http", SERVER_NAME, url],
|
|
10696
10696
|
signIn: "In Gemini CLI, run /mcp auth kenso."
|
|
10697
10697
|
},
|
|
@@ -10700,8 +10700,8 @@ var init_mcp_config = __esm({
|
|
|
10700
10700
|
folder: (env) => join15(xdgConfigDir(env), "opencode"),
|
|
10701
10701
|
file: opencodeFile,
|
|
10702
10702
|
// OpenCode 1.x lists servers under mcp; newer configs nest them under mcp.servers.
|
|
10703
|
-
entries: (
|
|
10704
|
-
const doc = readJson(
|
|
10703
|
+
entries: (text5) => {
|
|
10704
|
+
const doc = readJson(text5);
|
|
10705
10705
|
if (doc === void 0) return void 0;
|
|
10706
10706
|
return [...servers(doc.mcp), ...isDoc(doc.mcp) ? servers(doc.mcp.servers) : []];
|
|
10707
10707
|
},
|
|
@@ -11039,15 +11039,15 @@ function readPendingLogin(env = process.env) {
|
|
|
11039
11039
|
if (TEXT_KEYS.some((key) => typeof record3[key] !== "string" || record3[key] === "")) return void 0;
|
|
11040
11040
|
const interval = record3.interval;
|
|
11041
11041
|
if (typeof interval !== "number" || !(interval > 0)) return void 0;
|
|
11042
|
-
const
|
|
11042
|
+
const text5 = (key) => record3[key];
|
|
11043
11043
|
return {
|
|
11044
|
-
loginId:
|
|
11045
|
-
userCode:
|
|
11046
|
-
verificationUrl:
|
|
11047
|
-
expiresAt:
|
|
11044
|
+
loginId: text5("loginId"),
|
|
11045
|
+
userCode: text5("userCode"),
|
|
11046
|
+
verificationUrl: text5("verificationUrl"),
|
|
11047
|
+
expiresAt: text5("expiresAt"),
|
|
11048
11048
|
interval,
|
|
11049
|
-
profile:
|
|
11050
|
-
apiUrl:
|
|
11049
|
+
profile: text5("profile"),
|
|
11050
|
+
apiUrl: text5("apiUrl")
|
|
11051
11051
|
};
|
|
11052
11052
|
}
|
|
11053
11053
|
function writePendingLogin(login, env = process.env) {
|
|
@@ -11381,8 +11381,8 @@ var init_browser_login = __esm({
|
|
|
11381
11381
|
defaultDeps = {
|
|
11382
11382
|
sleep: (ms, signal) => delay5(ms, void 0, signal ? { signal } : void 0),
|
|
11383
11383
|
now: () => Date.now(),
|
|
11384
|
-
spawn: (
|
|
11385
|
-
const child = nodeSpawn(
|
|
11384
|
+
spawn: (command91, args) => {
|
|
11385
|
+
const child = nodeSpawn(command91, args, { detached: true, stdio: "ignore" });
|
|
11386
11386
|
child.on("error", () => {
|
|
11387
11387
|
});
|
|
11388
11388
|
child.unref();
|
|
@@ -11490,13 +11490,13 @@ var init_login = __esm({
|
|
|
11490
11490
|
next: PIPE_EXAMPLE
|
|
11491
11491
|
});
|
|
11492
11492
|
}
|
|
11493
|
-
let
|
|
11493
|
+
let text5;
|
|
11494
11494
|
try {
|
|
11495
|
-
|
|
11495
|
+
text5 = await readStream(stdin, MAX_KEY_INPUT_BYTES);
|
|
11496
11496
|
} catch {
|
|
11497
11497
|
throw invalidKey("stdin holds more than one API key's worth of text.");
|
|
11498
11498
|
}
|
|
11499
|
-
const key = (
|
|
11499
|
+
const key = (text5.trim().split(/\r?\n/)[0] ?? "").trim();
|
|
11500
11500
|
if (key === "") throw invalidKey("stdin was empty: pipe the API key in.");
|
|
11501
11501
|
if (!API_KEY_PATTERN.test(key)) throw invalidKey("stdin does not hold a Kenso API key.");
|
|
11502
11502
|
let body2;
|
|
@@ -11601,8 +11601,8 @@ async function revoke(ctx, profile) {
|
|
|
11601
11601
|
hint: `Set KENSO_API_URL to ${keyOrigin} (or unset it if that is the default) and log out again, or pass --keep-key to remove the profile without revoking the key.`
|
|
11602
11602
|
});
|
|
11603
11603
|
}
|
|
11604
|
-
const
|
|
11605
|
-
ctx.output.warn(`Could not revoke the key (${
|
|
11604
|
+
const why2 = err instanceof Error ? err.message : String(err);
|
|
11605
|
+
ctx.output.warn(`Could not revoke the key (${why2}). The profile is removed anyway; revoke the key at Settings > API keys.`);
|
|
11606
11606
|
return false;
|
|
11607
11607
|
}
|
|
11608
11608
|
}
|
|
@@ -11778,10 +11778,10 @@ var init_wait2 = __esm({
|
|
|
11778
11778
|
examples: ["kenso auth wait", "kenso auth wait --timeout 2m"],
|
|
11779
11779
|
operationIds: ["cli-logins.token"],
|
|
11780
11780
|
async run(ctx, { flags }) {
|
|
11781
|
-
const
|
|
11782
|
-
const timeoutMs2 =
|
|
11783
|
-
if (
|
|
11784
|
-
throw usageError(`--timeout takes 90s, 10m, 1h or a number of seconds (got "${
|
|
11781
|
+
const text5 = typeof flags.timeout === "string" ? flags.timeout : void 0;
|
|
11782
|
+
const timeoutMs2 = text5 === void 0 ? void 0 : parseDuration(text5);
|
|
11783
|
+
if (text5 !== void 0 && timeoutMs2 === void 0) {
|
|
11784
|
+
throw usageError(`--timeout takes 90s, 10m, 1h or a number of seconds (got "${text5}").`, { field: "timeout", next: "kenso auth wait --help" });
|
|
11785
11785
|
}
|
|
11786
11786
|
return waitForPendingLogin(ctx, { timeoutMs: timeoutMs2, workspace: ctx.flags.workspace, saveApiUrl: flags["save-api-url"] === true });
|
|
11787
11787
|
}
|
|
@@ -12794,8 +12794,8 @@ var init_run = __esm({
|
|
|
12794
12794
|
defaultDeps2 = {
|
|
12795
12795
|
sleep: (ms, signal) => delay6(ms, void 0, signal ? { signal } : void 0),
|
|
12796
12796
|
now: () => Date.now(),
|
|
12797
|
-
spawn: (
|
|
12798
|
-
const child = nodeSpawn2(
|
|
12797
|
+
spawn: (command91, args) => {
|
|
12798
|
+
const child = nodeSpawn2(command91, args, { detached: true, stdio: "ignore" });
|
|
12799
12799
|
child.on("error", () => {
|
|
12800
12800
|
});
|
|
12801
12801
|
child.unref();
|
|
@@ -12818,8 +12818,8 @@ var init_connect3 = __esm({
|
|
|
12818
12818
|
"use strict";
|
|
12819
12819
|
KIND_NAMES = ["inbox", "calendar", "video", "crm", "hubspot-knowledge", "github", "migration", "linkedin", "whatsapp", "facebook", "instagram"];
|
|
12820
12820
|
load = (name) => async () => {
|
|
12821
|
-
const [{ KINDS:
|
|
12822
|
-
const kind =
|
|
12821
|
+
const [{ KINDS: KINDS5 }, { connectCommand: connectCommand2 }] = await Promise.all([Promise.resolve().then(() => (init_kinds(), kinds_exports)), Promise.resolve().then(() => (init_run(), run_exports))]);
|
|
12822
|
+
const kind = KINDS5.find((k) => k.name === name);
|
|
12823
12823
|
if (!kind) throw new Error(`no connect kind ${name}`);
|
|
12824
12824
|
return connectCommand2(kind);
|
|
12825
12825
|
};
|
|
@@ -12978,17 +12978,17 @@ function targetName(target2) {
|
|
|
12978
12978
|
return "field" in target2 ? target2.field : `${CUSTOM_PREFIX}${target2.customKey}`;
|
|
12979
12979
|
}
|
|
12980
12980
|
function overrideTarget(column, value, mode) {
|
|
12981
|
-
const
|
|
12982
|
-
if (
|
|
12983
|
-
const raw =
|
|
12981
|
+
const text5 = value.trim();
|
|
12982
|
+
if (text5.startsWith(CUSTOM_PREFIX)) {
|
|
12983
|
+
const raw = text5.slice(CUSTOM_PREFIX.length);
|
|
12984
12984
|
const problem = customVariableKeyProblem(raw);
|
|
12985
12985
|
if (problem) {
|
|
12986
|
-
const
|
|
12987
|
-
throw usageError(`--map "${column}": customVariables.${raw} ${
|
|
12986
|
+
const why2 = problem === "reserved_name" ? "is a name Kenso keeps for its own fields" : "is not a usable variable key (a letter, then letters, digits and _)";
|
|
12987
|
+
throw usageError(`--map "${column}": customVariables.${raw} ${why2}.`, { field: "map", hint: "Pick another custom variable name." });
|
|
12988
12988
|
}
|
|
12989
12989
|
return { customKey: normalizeVariableName(raw) };
|
|
12990
12990
|
}
|
|
12991
|
-
const field = fieldOf(
|
|
12991
|
+
const field = fieldOf(text5);
|
|
12992
12992
|
if (!field) {
|
|
12993
12993
|
throw usageError(`--map "${column}": "${value}" is not a field. Use one of ${FIELD_LIST}, customVariables.<key>, or null.`, { field: "map" });
|
|
12994
12994
|
}
|
|
@@ -13064,10 +13064,10 @@ function buildMapping(headers, overrides2, mode) {
|
|
|
13064
13064
|
function readCell(value) {
|
|
13065
13065
|
if (value === void 0) return { kind: "blank" };
|
|
13066
13066
|
if (value === null) return { kind: "null" };
|
|
13067
|
-
const
|
|
13068
|
-
if (
|
|
13069
|
-
if (
|
|
13070
|
-
return { kind: "value", text:
|
|
13067
|
+
const text5 = (typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value)).trim();
|
|
13068
|
+
if (text5 === "") return { kind: "blank" };
|
|
13069
|
+
if (text5 === "null") return { kind: "null" };
|
|
13070
|
+
return { kind: "value", text: text5 };
|
|
13071
13071
|
}
|
|
13072
13072
|
function rowValues(row, mapping, mode) {
|
|
13073
13073
|
const out = { fields: {}, customVariables: {} };
|
|
@@ -13774,12 +13774,12 @@ import { join as join17 } from "node:path";
|
|
|
13774
13774
|
function whereDir(env) {
|
|
13775
13775
|
return join17(runsRoot(env), WHERE_DIR);
|
|
13776
13776
|
}
|
|
13777
|
-
async function unfinishedWhereIds(ctx,
|
|
13777
|
+
async function unfinishedWhereIds(ctx, command91, args) {
|
|
13778
13778
|
const dir3 = whereDir(ctx.env);
|
|
13779
13779
|
const identity = argsIdentity(args);
|
|
13780
13780
|
const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
|
|
13781
13781
|
for (const run of await listRuns(ctx.env)) {
|
|
13782
|
-
if (run.command !==
|
|
13782
|
+
if (run.command !== command91 || run.status === "done" || run.status === "planned") continue;
|
|
13783
13783
|
if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
|
|
13784
13784
|
if (run.inputPath?.startsWith(`${dir3}/`) && existsSync7(run.inputPath)) return run.inputPath;
|
|
13785
13785
|
}
|
|
@@ -13798,9 +13798,9 @@ function chunkAttempts(env) {
|
|
|
13798
13798
|
return async (runId, chunkIndex) => {
|
|
13799
13799
|
earlier ??= (async () => {
|
|
13800
13800
|
const path2 = join17(runsRoot(env), runId, ATTEMPTS_FILE);
|
|
13801
|
-
const
|
|
13801
|
+
const text5 = await readFile7(path2, "utf8").catch(() => "");
|
|
13802
13802
|
const indexes3 = new Set(
|
|
13803
|
-
|
|
13803
|
+
text5.split("\n").filter((line) => line.trim() !== "").map(Number)
|
|
13804
13804
|
);
|
|
13805
13805
|
return { path: path2, indexes: indexes3 };
|
|
13806
13806
|
})();
|
|
@@ -13841,11 +13841,11 @@ function idItems(raw) {
|
|
|
13841
13841
|
const items = [];
|
|
13842
13842
|
const invalid2 = [];
|
|
13843
13843
|
const firstRowOf = /* @__PURE__ */ new Map();
|
|
13844
|
-
raw.forEach((
|
|
13844
|
+
raw.forEach((text5, i) => {
|
|
13845
13845
|
const row = i + 1;
|
|
13846
|
-
const id = positiveId(
|
|
13846
|
+
const id = positiveId(text5);
|
|
13847
13847
|
if (id === void 0) {
|
|
13848
|
-
invalid2.push(invalidRow(row, "invalid_id", `"${
|
|
13848
|
+
invalid2.push(invalidRow(row, "invalid_id", `"${text5}" is not a contact id.`));
|
|
13849
13849
|
return;
|
|
13850
13850
|
}
|
|
13851
13851
|
const first = firstRowOf.get(id);
|
|
@@ -13862,9 +13862,9 @@ async function idsFromFile(ctx, path) {
|
|
|
13862
13862
|
let ids2;
|
|
13863
13863
|
let input;
|
|
13864
13864
|
if (path === "-") {
|
|
13865
|
-
const
|
|
13866
|
-
ids2 = await readIds("-", { stdin: Readable.from([
|
|
13867
|
-
input = { path: "-", sha256: createHash5("sha256").update(
|
|
13865
|
+
const text5 = await readStream(ctx.stdin ?? process.stdin);
|
|
13866
|
+
ids2 = await readIds("-", { stdin: Readable.from([text5]) });
|
|
13867
|
+
input = { path: "-", sha256: createHash5("sha256").update(text5).digest("hex") };
|
|
13868
13868
|
} else {
|
|
13869
13869
|
ids2 = await readIds(path);
|
|
13870
13870
|
input = { path: resolve9(path), sha256: await fileSha256(path) };
|
|
@@ -13925,14 +13925,14 @@ async function idsFromRun(ctx, runId) {
|
|
|
13925
13925
|
return { ...idItems(ids2), source: "run" };
|
|
13926
13926
|
}
|
|
13927
13927
|
async function collectIds(ctx, flags, kind, dryRun2) {
|
|
13928
|
-
const
|
|
13928
|
+
const command91 = `kenso contacts ${kind}`;
|
|
13929
13929
|
const ids2 = stringFlag2(flags, "ids");
|
|
13930
13930
|
const where = kind === "restore" ? void 0 : stringFlag2(flags, "where");
|
|
13931
13931
|
const run = kind === "restore" ? stringFlag2(flags, "run") : void 0;
|
|
13932
13932
|
const given = [ids2, where, run].filter((v) => v !== void 0).length;
|
|
13933
13933
|
if (given !== 1) {
|
|
13934
13934
|
const choices = kind === "restore" ? "--ids <file|-> or --run <runId>" : "--ids <file|-> or --where '<json>'";
|
|
13935
|
-
throw usageError(`${
|
|
13935
|
+
throw usageError(`${command91} needs exactly one of ${choices}.`, { field: "ids", next: `${command91} --help` });
|
|
13936
13936
|
}
|
|
13937
13937
|
if (ids2 !== void 0) return idsFromFile(ctx, ids2);
|
|
13938
13938
|
if (where !== void 0) return idsFromWhere(ctx, kind, flags, where, dryRun2);
|
|
@@ -14959,12 +14959,12 @@ function detailOf(entry, cards) {
|
|
|
14959
14959
|
if (entry.op?.download) out.download = entry.op.download;
|
|
14960
14960
|
if (cards) {
|
|
14961
14961
|
const lines = creditLines(entry);
|
|
14962
|
-
const
|
|
14962
|
+
const text5 = entry.spec?.doc?.cost;
|
|
14963
14963
|
out.cost = lines.length > 0 ? {
|
|
14964
14964
|
lines: lines.map((line) => ({ ...line, price: priceLine(line, cards) })),
|
|
14965
|
-
...
|
|
14965
|
+
...text5 ? { text: text5 } : {},
|
|
14966
14966
|
rateCard: { source: cards[0]?.source ?? "bundled", versions: cards.map((card) => card.version) }
|
|
14967
|
-
} :
|
|
14967
|
+
} : text5 || effectOf(entry) === "spend" ? { lines: [], ...text5 ? { text: text5 } : {}, rateCard: null } : null;
|
|
14968
14968
|
}
|
|
14969
14969
|
return out;
|
|
14970
14970
|
}
|
|
@@ -15060,13 +15060,13 @@ function stem(word) {
|
|
|
15060
15060
|
if (word.length > 3 && word.endsWith("s") && !word.endsWith("ss")) return word.slice(0, -1);
|
|
15061
15061
|
return word;
|
|
15062
15062
|
}
|
|
15063
|
-
function words(
|
|
15064
|
-
return
|
|
15063
|
+
function words(text5) {
|
|
15064
|
+
return text5.replace(/linkedin/gi, "linkedin").replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter((word) => word.length > 1 && !STOP_WORDS.has(word)).map(stem);
|
|
15065
15065
|
}
|
|
15066
15066
|
function termsOf(...texts) {
|
|
15067
15067
|
const out = /* @__PURE__ */ new Set();
|
|
15068
|
-
for (const
|
|
15069
|
-
for (const word of words(
|
|
15068
|
+
for (const text5 of texts) {
|
|
15069
|
+
for (const word of words(text5 ?? "")) {
|
|
15070
15070
|
out.add(word);
|
|
15071
15071
|
for (const other of FOLDED.get(word) ?? []) out.add(other);
|
|
15072
15072
|
}
|
|
@@ -15228,14 +15228,14 @@ function specEntry(spec) {
|
|
|
15228
15228
|
if (spec.brief?.startsWith("same as ")) return void 0;
|
|
15229
15229
|
const id = commandName(spec).slice("kenso ".length);
|
|
15230
15230
|
const credits3 = spec.cost ?? [];
|
|
15231
|
-
const
|
|
15231
|
+
const actions40 = credits3.map((c) => c.action);
|
|
15232
15232
|
return {
|
|
15233
15233
|
kind: "command",
|
|
15234
15234
|
id,
|
|
15235
15235
|
summary: spec.summary,
|
|
15236
|
-
terms: termsOf(id, spec.summary, spec.description, spec.doc?.when, Object.keys(spec.flags).join(" "),
|
|
15236
|
+
terms: termsOf(id, spec.summary, spec.description, spec.doc?.when, Object.keys(spec.flags).join(" "), actions40.join(" ")),
|
|
15237
15237
|
effect: spec.effect,
|
|
15238
|
-
...credits3.length > 0 ? { costActions:
|
|
15238
|
+
...credits3.length > 0 ? { costActions: actions40, credits: credits3 } : {},
|
|
15239
15239
|
...spec.beta ? { beta: true } : {},
|
|
15240
15240
|
describe: `kenso describe ${id}`
|
|
15241
15241
|
};
|
|
@@ -15438,8 +15438,8 @@ var init_docs = __esm({
|
|
|
15438
15438
|
next: "kenso docs"
|
|
15439
15439
|
});
|
|
15440
15440
|
}
|
|
15441
|
-
const
|
|
15442
|
-
if (
|
|
15441
|
+
const text5 = await topicText(topic);
|
|
15442
|
+
if (text5 === void 0) {
|
|
15443
15443
|
throw new KensoError({
|
|
15444
15444
|
code: "docs_not_found",
|
|
15445
15445
|
message: `docs/${topic.file} is not in this install of the CLI.`,
|
|
@@ -15448,7 +15448,7 @@ var init_docs = __esm({
|
|
|
15448
15448
|
next: "kenso describe --all-commands"
|
|
15449
15449
|
});
|
|
15450
15450
|
}
|
|
15451
|
-
ctx.output.writeRaw(
|
|
15451
|
+
ctx.output.writeRaw(text5.endsWith("\n") ? text5 : `${text5}
|
|
15452
15452
|
`);
|
|
15453
15453
|
return ExitCode.Ok;
|
|
15454
15454
|
}
|
|
@@ -15486,10 +15486,10 @@ async function agentChecks(ctx) {
|
|
|
15486
15486
|
const names = clients.map((c) => CLIENT_NAMES[c]).join(", ");
|
|
15487
15487
|
const files = [];
|
|
15488
15488
|
for (const name of BUNDLED_SKILLS) {
|
|
15489
|
-
const
|
|
15489
|
+
const text5 = await bundledSkillText(name);
|
|
15490
15490
|
for (const client of clients) {
|
|
15491
15491
|
const path = skillPath(client, name, ctx.env);
|
|
15492
|
-
files.push({ path, state: skillState(name, readSkill(path),
|
|
15492
|
+
files.push({ path, state: skillState(name, readSkill(path), text5) });
|
|
15493
15493
|
}
|
|
15494
15494
|
}
|
|
15495
15495
|
const pathsIn = (state2) => files.filter((f) => f.state === state2).map((f) => f.path).join(", ");
|
|
@@ -15629,13 +15629,13 @@ __export(export_exports2, {
|
|
|
15629
15629
|
recordCount: () => recordCount
|
|
15630
15630
|
});
|
|
15631
15631
|
function jsonFlag(flags, name, shape) {
|
|
15632
|
-
const
|
|
15633
|
-
if (
|
|
15632
|
+
const text5 = stringFlag(flags[name]);
|
|
15633
|
+
if (text5 === void 0) return void 0;
|
|
15634
15634
|
let value;
|
|
15635
15635
|
try {
|
|
15636
|
-
value = JSON.parse(
|
|
15636
|
+
value = JSON.parse(text5);
|
|
15637
15637
|
} catch {
|
|
15638
|
-
throw usageError(`--${name} must be JSON (got "${
|
|
15638
|
+
throw usageError(`--${name} must be JSON (got "${text5}").`, { field: name });
|
|
15639
15639
|
}
|
|
15640
15640
|
const ok = shape === "array" ? Array.isArray(value) : typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15641
15641
|
if (!ok) throw usageError(`--${name} must be a JSON ${shape}.`, { field: name });
|
|
@@ -16056,14 +16056,14 @@ __export(layouts_exports, {
|
|
|
16056
16056
|
withHeader: () => withHeader
|
|
16057
16057
|
});
|
|
16058
16058
|
function objectOf(positionals, action) {
|
|
16059
|
-
const
|
|
16060
|
-
if (!OBJECTS3.includes(
|
|
16059
|
+
const text5 = (positionals[0] ?? "").trim().toLowerCase();
|
|
16060
|
+
if (!OBJECTS3.includes(text5)) {
|
|
16061
16061
|
throw usageError(`object must be account, person or opportunity (got "${positionals[0] ?? ""}").`, {
|
|
16062
16062
|
field: "object",
|
|
16063
16063
|
next: `kenso layouts ${action} account`
|
|
16064
16064
|
});
|
|
16065
16065
|
}
|
|
16066
|
-
return
|
|
16066
|
+
return text5;
|
|
16067
16067
|
}
|
|
16068
16068
|
async function call(ctx, method, object, body2) {
|
|
16069
16069
|
const res = await ctx.client.request({ method, path: `/v1/record-layouts/${object}`, body: body2, signal: ctx.signal });
|
|
@@ -16213,9 +16213,9 @@ __export(tail_exports, {
|
|
|
16213
16213
|
default: () => tail_default
|
|
16214
16214
|
});
|
|
16215
16215
|
import { setTimeout as delay9 } from "node:timers/promises";
|
|
16216
|
-
function duration(
|
|
16217
|
-
const days = /^(\d+(?:\.\d+)?)\s*d$/i.exec(
|
|
16218
|
-
return days ? Math.round(Number(days[1]) * 864e5) : parseDuration(
|
|
16216
|
+
function duration(text5) {
|
|
16217
|
+
const days = /^(\d+(?:\.\d+)?)\s*d$/i.exec(text5.trim());
|
|
16218
|
+
return days ? Math.round(Number(days[1]) * 864e5) : parseDuration(text5);
|
|
16219
16219
|
}
|
|
16220
16220
|
function nonEmpty2(flags, name) {
|
|
16221
16221
|
const value = flags[name];
|
|
@@ -16405,8 +16405,8 @@ function mcpClient(ctx) {
|
|
|
16405
16405
|
onResponse: ctx.flags.verbose ? ({ method, status, ms, error }) => ctx.output.info(`POST ${url} ${method} -> ${status ?? error ?? "error"} (${ms} ms)`) : void 0
|
|
16406
16406
|
});
|
|
16407
16407
|
}
|
|
16408
|
-
function writeRaw(ctx,
|
|
16409
|
-
ctx.output.writeRaw(
|
|
16408
|
+
function writeRaw(ctx, text5) {
|
|
16409
|
+
ctx.output.writeRaw(text5.endsWith("\n") ? text5 : `${text5}
|
|
16410
16410
|
`);
|
|
16411
16411
|
}
|
|
16412
16412
|
var init_connect4 = __esm({
|
|
@@ -16473,11 +16473,11 @@ var init_call = __esm({
|
|
|
16473
16473
|
return ExitCode.Ok;
|
|
16474
16474
|
}
|
|
16475
16475
|
const result = await mcpClient(ctx).callTool(tool, args);
|
|
16476
|
-
const
|
|
16476
|
+
const text5 = textOf(result);
|
|
16477
16477
|
if (result.isError === true) {
|
|
16478
16478
|
throw new KensoError({
|
|
16479
16479
|
code: "mcp_tool_error",
|
|
16480
|
-
message:
|
|
16480
|
+
message: text5 || `The MCP tool ${tool} returned an error.`,
|
|
16481
16481
|
exitCode: ExitCode.Error,
|
|
16482
16482
|
details: result
|
|
16483
16483
|
});
|
|
@@ -16486,12 +16486,12 @@ var init_call = __esm({
|
|
|
16486
16486
|
ctx.output.object(result.structuredContent);
|
|
16487
16487
|
return ExitCode.Ok;
|
|
16488
16488
|
}
|
|
16489
|
-
if (
|
|
16489
|
+
if (text5 === "") return ExitCode.Ok;
|
|
16490
16490
|
let parsed2;
|
|
16491
16491
|
try {
|
|
16492
|
-
parsed2 = JSON.parse(
|
|
16492
|
+
parsed2 = JSON.parse(text5);
|
|
16493
16493
|
} catch {
|
|
16494
|
-
writeRaw(ctx,
|
|
16494
|
+
writeRaw(ctx, text5);
|
|
16495
16495
|
return ExitCode.Ok;
|
|
16496
16496
|
}
|
|
16497
16497
|
ctx.output.object(parsed2);
|
|
@@ -16547,10 +16547,10 @@ var init_mcp = __esm({
|
|
|
16547
16547
|
|
|
16548
16548
|
// src/commands/notes/target.ts
|
|
16549
16549
|
function positiveId2(value, field, next) {
|
|
16550
|
-
const
|
|
16551
|
-
const id = /^\d+$/.test(
|
|
16550
|
+
const text5 = String(value ?? "").trim();
|
|
16551
|
+
const id = /^\d+$/.test(text5) ? Number(text5) : Number.NaN;
|
|
16552
16552
|
if (!Number.isSafeInteger(id) || id < 1) {
|
|
16553
|
-
throw usageError(`${field} must be a positive whole number (got "${
|
|
16553
|
+
throw usageError(`${field} must be a positive whole number (got "${text5}").`, { field, next });
|
|
16554
16554
|
}
|
|
16555
16555
|
return id;
|
|
16556
16556
|
}
|
|
@@ -16634,9 +16634,9 @@ __export(add_exports, {
|
|
|
16634
16634
|
default: () => add_default
|
|
16635
16635
|
});
|
|
16636
16636
|
async function bodyText(ctx, value, next) {
|
|
16637
|
-
const
|
|
16638
|
-
if (
|
|
16639
|
-
return
|
|
16637
|
+
const text5 = value === "-" ? await readStream(ctx.stdin ?? process.stdin) : String(value ?? "");
|
|
16638
|
+
if (text5.trim() === "") throw usageError("--body cannot be empty: the note's text, in markdown (--body - reads stdin).", { field: "body", next });
|
|
16639
|
+
return text5;
|
|
16640
16640
|
}
|
|
16641
16641
|
var command41, add_default;
|
|
16642
16642
|
var init_add = __esm({
|
|
@@ -16918,10 +16918,10 @@ var init_stage_history = __esm({
|
|
|
16918
16918
|
beta: { featureGates: { all: ["opportunities"] } },
|
|
16919
16919
|
operationIds: ["opportunities.get-stage-history"],
|
|
16920
16920
|
async run(ctx, { positionals }) {
|
|
16921
|
-
const
|
|
16922
|
-
const id = /^\d+$/.test(
|
|
16921
|
+
const text5 = (positionals[0] ?? "").trim();
|
|
16922
|
+
const id = /^\d+$/.test(text5) ? Number(text5) : Number.NaN;
|
|
16923
16923
|
if (!Number.isSafeInteger(id) || id < 1) {
|
|
16924
|
-
throw usageError(`opportunityId must be a positive whole number (got "${
|
|
16924
|
+
throw usageError(`opportunityId must be a positive whole number (got "${text5}").`, {
|
|
16925
16925
|
field: "opportunityId",
|
|
16926
16926
|
next: "kenso opportunities stage-history <opportunityId>"
|
|
16927
16927
|
});
|
|
@@ -17012,8 +17012,8 @@ function toBody2(row, columns2) {
|
|
|
17012
17012
|
const value = (field) => firstValue(row, columns2.sources.get(field));
|
|
17013
17013
|
const person = {};
|
|
17014
17014
|
for (const field of PERSON_FIELDS) {
|
|
17015
|
-
const
|
|
17016
|
-
if (
|
|
17015
|
+
const text5 = textValue(value(field), field);
|
|
17016
|
+
if (text5 !== void 0) person[field] = text5;
|
|
17017
17017
|
}
|
|
17018
17018
|
const fullName = person.fullName ?? ([person.firstName, person.lastName].filter(Boolean).join(" ") || void 0);
|
|
17019
17019
|
if (fullName === void 0) {
|
|
@@ -17651,9 +17651,9 @@ var init_list2 = __esm({
|
|
|
17651
17651
|
},
|
|
17652
17652
|
examples: ["kenso runs list", "kenso runs list --limit 5 -o json"],
|
|
17653
17653
|
async run(ctx, { flags }) {
|
|
17654
|
-
const
|
|
17655
|
-
const limit = /^\d+$/.test(
|
|
17656
|
-
if (!(limit >= 1 && limit <= 1e3)) throw usageError(`--limit must be a whole number from 1 to 1000 (got "${
|
|
17654
|
+
const text5 = typeof flags.limit === "string" ? flags.limit.trim() : "20";
|
|
17655
|
+
const limit = /^\d+$/.test(text5) ? Number(text5) : Number.NaN;
|
|
17656
|
+
if (!(limit >= 1 && limit <= 1e3)) throw usageError(`--limit must be a whole number from 1 to 1000 (got "${text5}").`, { field: "limit" });
|
|
17657
17657
|
const runs = await listRuns(ctx.env);
|
|
17658
17658
|
await ctx.output.list(
|
|
17659
17659
|
runs.slice(0, limit).map((run) => ({ runId: run.runId, command: run.command, status: run.status, rows: run.rows ?? null, createdAt: run.createdAt }))
|
|
@@ -17732,8 +17732,8 @@ import { resolve as resolve11 } from "node:path";
|
|
|
17732
17732
|
function kebab(key) {
|
|
17733
17733
|
return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
17734
17734
|
}
|
|
17735
|
-
function commandWords(
|
|
17736
|
-
return
|
|
17735
|
+
function commandWords(command91) {
|
|
17736
|
+
return command91.trim().split(/\s+/).filter((t) => t !== "");
|
|
17737
17737
|
}
|
|
17738
17738
|
function flagValue(value) {
|
|
17739
17739
|
return typeof value === "string" ? value : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
@@ -18239,9 +18239,9 @@ function scopeOf(inputSchema) {
|
|
|
18239
18239
|
}
|
|
18240
18240
|
function costOf(step, cards) {
|
|
18241
18241
|
if (step.cost?.free === true) return "free";
|
|
18242
|
-
const
|
|
18243
|
-
if (
|
|
18244
|
-
return
|
|
18242
|
+
const actions40 = step.cost?.action ? [step.cost.action] : [...new Set(Object.values(step.cost?.actionByTier ?? {}))];
|
|
18243
|
+
if (actions40.length === 0) return priceLine({ action: step.key, pricing: "unlisted" }, cards);
|
|
18244
|
+
return actions40.map((action) => priceLine({ action: rateCardAction(action), pricing: "fixed" }, cards)).join("; ");
|
|
18245
18245
|
}
|
|
18246
18246
|
function toRow(step, cards) {
|
|
18247
18247
|
return {
|
|
@@ -18310,6 +18310,223 @@ var init_signals = __esm({
|
|
|
18310
18310
|
}
|
|
18311
18311
|
});
|
|
18312
18312
|
|
|
18313
|
+
// src/commands/simulations/run.ts
|
|
18314
|
+
var run_exports3 = {};
|
|
18315
|
+
__export(run_exports3, {
|
|
18316
|
+
default: () => run_default2
|
|
18317
|
+
});
|
|
18318
|
+
function whole(flags, name) {
|
|
18319
|
+
const raw = str(flags[name]);
|
|
18320
|
+
if (raw === void 0) return void 0;
|
|
18321
|
+
if (!/^\d+$/.test(raw) || !Number.isSafeInteger(Number(raw))) throw usageError(`--${name} needs a whole number.`, { field: name });
|
|
18322
|
+
return Number(raw);
|
|
18323
|
+
}
|
|
18324
|
+
function text4(flags, subjectFlag, bodyFlag) {
|
|
18325
|
+
const subject = str(flags[subjectFlag]);
|
|
18326
|
+
const raw = flags[bodyFlag];
|
|
18327
|
+
const body2 = typeof raw === "string" && raw.trim() !== "" ? raw : void 0;
|
|
18328
|
+
if (body2 === void 0) {
|
|
18329
|
+
if (subject !== void 0) throw usageError(`--${subjectFlag} needs --${bodyFlag}.`, { field: bodyFlag });
|
|
18330
|
+
return void 0;
|
|
18331
|
+
}
|
|
18332
|
+
return subject === void 0 ? { body: body2 } : { subject, body: body2 };
|
|
18333
|
+
}
|
|
18334
|
+
function createBody(flags) {
|
|
18335
|
+
const kind = str(flags.kind);
|
|
18336
|
+
if (kind === void 0 || !KINDS4.includes(kind)) throw usageError(`--kind needs one of ${KINDS4.join(", ")}.`, { field: "kind" });
|
|
18337
|
+
const channel = str(flags.channel) ?? "email";
|
|
18338
|
+
if (!CHANNELS.includes(channel)) throw usageError("--channel needs email or linkedin.", { field: "channel" });
|
|
18339
|
+
const source = {};
|
|
18340
|
+
for (const [flag, key] of SOURCE_FLAGS) {
|
|
18341
|
+
const id = whole(flags, flag);
|
|
18342
|
+
if (id !== void 0) source[key] = id;
|
|
18343
|
+
}
|
|
18344
|
+
const body2 = { kind, channel, source };
|
|
18345
|
+
const message = text4(flags, "subject", "body");
|
|
18346
|
+
if (message) body2.message = message;
|
|
18347
|
+
const compareWith = text4(flags, "compare-subject", "compare-body");
|
|
18348
|
+
if (compareWith) body2.compareWith = compareWith;
|
|
18349
|
+
const readerCount = whole(flags, "reader-count");
|
|
18350
|
+
if (readerCount !== void 0) body2.readerCount = readerCount;
|
|
18351
|
+
const rounds = whole(flags, "rounds");
|
|
18352
|
+
if (rounds !== void 0) body2.rounds = rounds;
|
|
18353
|
+
if (flags.rewrite === true) body2.rewrite = true;
|
|
18354
|
+
return body2;
|
|
18355
|
+
}
|
|
18356
|
+
function cut(value, max = WHY_MAX) {
|
|
18357
|
+
const flat = (value ?? "").replace(/\s+/g, " ").trim();
|
|
18358
|
+
return flat.length <= max ? flat : `${flat.slice(0, max - 3)}...`;
|
|
18359
|
+
}
|
|
18360
|
+
function table(header2, rows) {
|
|
18361
|
+
const widths = header2.map((h, i) => Math.max(h.length, ...rows.map((row) => (row[i] ?? "").length)));
|
|
18362
|
+
return [header2, ...rows].map((row) => row.map((cell2, i) => cell2.padEnd(widths[i] ?? 0)).join(" ").trimEnd()).join("\n");
|
|
18363
|
+
}
|
|
18364
|
+
function render(simulation) {
|
|
18365
|
+
const out = [`Simulation ${simulation.id} (${simulation.kind}, ${simulation.channel}): ${simulation.status}`];
|
|
18366
|
+
const result = simulation.result;
|
|
18367
|
+
if (!result) return `${out.join("\n")}
|
|
18368
|
+
`;
|
|
18369
|
+
out.push(LABEL_NOTES[result.label ?? ""] ?? NOTE, "");
|
|
18370
|
+
out.push(
|
|
18371
|
+
table(
|
|
18372
|
+
["READER", "VERSION", "STEP", "ROUND", "DECISION", "SCORE", "WHY"],
|
|
18373
|
+
result.reads.map((r) => [r.reader.alias, r.version, String(r.stepOrder), String(r.round), r.decision, score2(r.replyLikelihood), why(r)])
|
|
18374
|
+
)
|
|
18375
|
+
);
|
|
18376
|
+
const aggregate = result.aggregate;
|
|
18377
|
+
if (aggregate) {
|
|
18378
|
+
const c = aggregate.decisionCounts;
|
|
18379
|
+
out.push("", `Decisions: ignore ${c.ignore}, reply ${c.reply}, forward ${c.forward}, unsubscribe ${c.unsubscribe}. Mean score ${score2(aggregate.meanReplyLikelihood)} of 100.`);
|
|
18380
|
+
if (aggregate.topIgnoreReasons.length > 0) {
|
|
18381
|
+
out.push("", table(["READERS", "REASON TO IGNORE"], aggregate.topIgnoreReasons.slice(0, 5).map((t) => [String(t.readerCount), cut(t.reason)])));
|
|
18382
|
+
}
|
|
18383
|
+
}
|
|
18384
|
+
const compare = result.compare;
|
|
18385
|
+
if (compare) {
|
|
18386
|
+
out.push(
|
|
18387
|
+
"",
|
|
18388
|
+
compare.verdict === "no_clear_difference" ? "Compare: no clear difference." : `Compare: version ${compare.verdict} reads better.`,
|
|
18389
|
+
`Mean score A ${score2(compare.meanReplyLikelihoodA)}, B ${score2(compare.meanReplyLikelihoodB)}; readers prefer A ${compare.readersPreferA}, B ${compare.readersPreferB}, same ${compare.readersSame}.`
|
|
18390
|
+
);
|
|
18391
|
+
}
|
|
18392
|
+
if (simulation.kind === "read_through") {
|
|
18393
|
+
out.push("", result.gaveUpAtStep === void 0 ? "They read every step." : `They gave up at step ${result.gaveUpAtStep}.`);
|
|
18394
|
+
}
|
|
18395
|
+
if (result.forwards?.length) {
|
|
18396
|
+
const alias = new Map(result.reads.map((r) => [r.readerKey, r.reader.alias]));
|
|
18397
|
+
const who = (key) => key === void 0 ? void 0 : alias.get(key) ?? key;
|
|
18398
|
+
const rows = result.forwards.map((f) => [who(f.fromReaderKey) ?? "-", f.action, who(f.toReaderKey) ?? f.toRole ?? "-", cut(f.note)]);
|
|
18399
|
+
out.push("", table(["FROM", "ACTION", "TO", "NOTE"], rows));
|
|
18400
|
+
}
|
|
18401
|
+
if (result.rounds?.length || result.outcome) out.push("");
|
|
18402
|
+
if (result.rounds?.length) {
|
|
18403
|
+
const rows = result.rounds.map((r) => [
|
|
18404
|
+
String(r.round),
|
|
18405
|
+
score2(r.beforeMean),
|
|
18406
|
+
score2(r.afterMean),
|
|
18407
|
+
String(r.readersUp),
|
|
18408
|
+
String(r.readersDown),
|
|
18409
|
+
String(r.readersSame),
|
|
18410
|
+
r.accepted ? "yes" : "no",
|
|
18411
|
+
r.rejectedReasons.length > 0 ? r.rejectedReasons.join(", ") : "-"
|
|
18412
|
+
]);
|
|
18413
|
+
out.push(table(["ROUND", "BEFORE", "AFTER", "UP", "DOWN", "SAME", "ACCEPTED", "REJECTED"], rows));
|
|
18414
|
+
}
|
|
18415
|
+
if (result.outcome) out.push(`Outcome: ${result.outcome === "improved" ? "improved" : "no improvement"}`);
|
|
18416
|
+
const rewritten = result.best ?? result.rewrite;
|
|
18417
|
+
if (rewritten) {
|
|
18418
|
+
const step = result.rewrite?.stepOrder ?? 0;
|
|
18419
|
+
const title = result.best ? "Best version:" : step > 0 ? `Rewrite of step ${step}:` : "Rewrite:";
|
|
18420
|
+
out.push("", title, ...rewritten.subject ? [`Subject: ${rewritten.subject}`] : [], rewritten.body);
|
|
18421
|
+
}
|
|
18422
|
+
return `${out.join("\n")}
|
|
18423
|
+
`;
|
|
18424
|
+
}
|
|
18425
|
+
var POLL_MS3, MAX_WAIT_MS, KINDS4, CHANNELS, TERMINAL, SOURCE_FLAGS, str, WHY_MAX, NOTE, LABEL_NOTES, score2, why, command60, run_default2;
|
|
18426
|
+
var init_run3 = __esm({
|
|
18427
|
+
"src/commands/simulations/run.ts"() {
|
|
18428
|
+
"use strict";
|
|
18429
|
+
init_errors();
|
|
18430
|
+
init_exit_codes();
|
|
18431
|
+
POLL_MS3 = 2e3;
|
|
18432
|
+
MAX_WAIT_MS = 9e5;
|
|
18433
|
+
KINDS4 = ["person", "panel", "read_through", "committee", "improve"];
|
|
18434
|
+
CHANNELS = ["email", "linkedin"];
|
|
18435
|
+
TERMINAL = /* @__PURE__ */ new Set(["succeeded", "failed", "canceled"]);
|
|
18436
|
+
SOURCE_FLAGS = [
|
|
18437
|
+
["campaign-id", "campaignId"],
|
|
18438
|
+
["segment-id", "segmentId"],
|
|
18439
|
+
["step-order", "stepOrder"],
|
|
18440
|
+
["touch-id", "touchId"],
|
|
18441
|
+
["account-id", "accountId"],
|
|
18442
|
+
["contact-id", "contactId"],
|
|
18443
|
+
["person-id", "personId"]
|
|
18444
|
+
];
|
|
18445
|
+
str = (value) => typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
18446
|
+
WHY_MAX = 60;
|
|
18447
|
+
NOTE = "A simulation of how readers react, not a forecast. Scores are 0 to 100.";
|
|
18448
|
+
LABEL_NOTES = {
|
|
18449
|
+
exploration: "Exploration: a committee read is a simulation to explore with, not a forecast. Scores are 0 to 100.",
|
|
18450
|
+
less_evidence: "Less evidence: a LinkedIn read is a simulation with less evidence behind it, not a forecast. Scores are 0 to 100."
|
|
18451
|
+
};
|
|
18452
|
+
score2 = (likelihood) => String(Math.round(likelihood * 100));
|
|
18453
|
+
why = (read2) => cut(read2.ignoreReasons[0]?.reason || read2.wouldReplyIf || read2.reaction);
|
|
18454
|
+
command60 = {
|
|
18455
|
+
resource: "simulations",
|
|
18456
|
+
action: "run",
|
|
18457
|
+
summary: "Run a response simulation and print how the readers reacted",
|
|
18458
|
+
effect: "write",
|
|
18459
|
+
description: "Creates a simulation (POST /v1/simulations), reads it every 2 s until it succeeds, fails or is canceled, and prints its reads as a table, then the table of its kind (a panel's decisions and reasons, a compare, a read-through's stop, a committee's forwards, improve's rounds and best version). Exit 0 when it succeeded, 1 when it failed, was canceled or is still running after 15 minutes. Ctrl-C stops the wait, not the run.",
|
|
18460
|
+
doc: { when: "Read a message the way the people it goes to might, before it is sent.", next: "kenso simulations get <id>" },
|
|
18461
|
+
flags: {
|
|
18462
|
+
kind: { type: "string", required: true, description: "person, panel, read_through, committee or improve" },
|
|
18463
|
+
channel: { type: "string", default: "email", description: "email or linkedin (default email)" },
|
|
18464
|
+
"campaign-id": { type: "string", description: "The campaign (panel, read_through, improve, a person read of a step, or beside --body for any kind: the run's campaign and sender)" },
|
|
18465
|
+
"segment-id": { type: "string", description: "The campaign's segment, for any kind with --campaign-id: whose sequence is read, and whose contacts a panel or improve samples" },
|
|
18466
|
+
"step-order": { type: "string", description: "The campaign step to read" },
|
|
18467
|
+
"touch-id": { type: "string", description: "An account touch: its recipient reads it, and its message unless --body gives the unsaved text (person, committee, improve)" },
|
|
18468
|
+
"account-id": { type: "string", description: "A committee's account" },
|
|
18469
|
+
"contact-id": { type: "string", description: "The contact who reads it (a person read with no --contact-id, --person-id or --touch-id is read by a generic reader)" },
|
|
18470
|
+
"person-id": { type: "string", description: "The account person who reads it" },
|
|
18471
|
+
subject: { type: "string", description: "The subject to read (email)" },
|
|
18472
|
+
body: { type: "string", description: "The message to read: instead of a saved step, or the unsaved text of --step-order or --touch-id" },
|
|
18473
|
+
"compare-subject": { type: "string", description: "A second version's subject" },
|
|
18474
|
+
"compare-body": { type: "string", description: "A second version: every reader reads both (person and panel)" },
|
|
18475
|
+
"reader-count": { type: "string", description: "Readers for a panel or improve, 5 to 25 (default 10; improve 6)" },
|
|
18476
|
+
rounds: { type: "string", description: "Improve rounds, 1 to 3 (default 3)" },
|
|
18477
|
+
rewrite: { type: "boolean", description: "A person read also suggests a rewrite" }
|
|
18478
|
+
},
|
|
18479
|
+
examples: [
|
|
18480
|
+
'kenso simulations run --kind person --contact-id 8123 --subject "Quick question" --body "Hi {first_name}, worth a call?"',
|
|
18481
|
+
"kenso simulations run --kind panel --campaign-id 431 --step-order 1 --reader-count 10",
|
|
18482
|
+
"kenso simulations run --kind improve --campaign-id 431 --step-order 1 --rounds 2 --json"
|
|
18483
|
+
],
|
|
18484
|
+
helpFooter: ["--json prints the simulation as the API returns it.", "A score is the reply likelihood as 0 to 100: an index, not a percentage."],
|
|
18485
|
+
beta: { featureGates: { all: ["response_simulation"] } },
|
|
18486
|
+
operationIds: ["simulations.create", "simulations.get"],
|
|
18487
|
+
async run(ctx, { flags }) {
|
|
18488
|
+
const body2 = createBody(flags);
|
|
18489
|
+
let simulation = (await ctx.client.request({ method: "POST", path: "/v1/simulations", body: body2 })).body.data;
|
|
18490
|
+
const started = Date.now();
|
|
18491
|
+
for (let paused = 0; !TERMINAL.has(simulation.status); paused += POLL_MS3) {
|
|
18492
|
+
if (paused >= MAX_WAIT_MS || Date.now() - started >= MAX_WAIT_MS) {
|
|
18493
|
+
throw new KensoError({
|
|
18494
|
+
code: "simulation_timeout",
|
|
18495
|
+
message: `Simulation ${simulation.id} is still ${simulation.status} after 15 minutes.`,
|
|
18496
|
+
exitCode: ExitCode.Error,
|
|
18497
|
+
next: `kenso simulations get ${simulation.id}`
|
|
18498
|
+
});
|
|
18499
|
+
}
|
|
18500
|
+
const p = simulation.progress;
|
|
18501
|
+
ctx.output.progress(`simulation ${simulation.id}: ${simulation.status}, ${p?.readsDone ?? 0}/${p?.readsTotal ?? 0} reads`);
|
|
18502
|
+
await ctx.client.pause(POLL_MS3);
|
|
18503
|
+
simulation = (await ctx.client.request({ method: "GET", path: `/v1/simulations/${simulation.id}` })).body.data;
|
|
18504
|
+
}
|
|
18505
|
+
if (ctx.flags.output === "json") ctx.output.object(simulation);
|
|
18506
|
+
else ctx.output.writeRaw(render(simulation));
|
|
18507
|
+
if (simulation.status === "succeeded") return ExitCode.Ok;
|
|
18508
|
+
throw new KensoError({
|
|
18509
|
+
code: simulation.error?.code || `simulation_${simulation.status}`,
|
|
18510
|
+
message: simulation.error?.message || `Simulation ${simulation.id} ${simulation.status === "canceled" ? "was canceled" : "failed"}.`,
|
|
18511
|
+
exitCode: ExitCode.Error
|
|
18512
|
+
});
|
|
18513
|
+
}
|
|
18514
|
+
};
|
|
18515
|
+
run_default2 = command60;
|
|
18516
|
+
}
|
|
18517
|
+
});
|
|
18518
|
+
|
|
18519
|
+
// src/commands/simulations/index.ts
|
|
18520
|
+
var actions29;
|
|
18521
|
+
var init_simulations = __esm({
|
|
18522
|
+
"src/commands/simulations/index.ts"() {
|
|
18523
|
+
"use strict";
|
|
18524
|
+
actions29 = {
|
|
18525
|
+
run: () => Promise.resolve().then(() => (init_run3(), run_exports3)).then((m) => m.default)
|
|
18526
|
+
};
|
|
18527
|
+
}
|
|
18528
|
+
});
|
|
18529
|
+
|
|
18313
18530
|
// src/commands/skill/list.ts
|
|
18314
18531
|
var list_exports4 = {};
|
|
18315
18532
|
__export(list_exports4, {
|
|
@@ -18322,19 +18539,19 @@ function isRecord10(value) {
|
|
|
18322
18539
|
}
|
|
18323
18540
|
async function callSkillTool(ctx, tool, args) {
|
|
18324
18541
|
const result = await mcpClient(ctx).callTool(tool, args);
|
|
18325
|
-
const
|
|
18542
|
+
const text5 = (result.content ?? []).flatMap((part) => part.type === "text" && typeof part.text === "string" ? [part.text] : []).join("\n");
|
|
18326
18543
|
let data = result.structuredContent;
|
|
18327
18544
|
if (isRecord10(data) && Object.keys(data).length === 1 && "result" in data) data = data.result;
|
|
18328
18545
|
if (data === void 0) {
|
|
18329
18546
|
try {
|
|
18330
|
-
data = JSON.parse(
|
|
18547
|
+
data = JSON.parse(text5);
|
|
18331
18548
|
} catch {
|
|
18332
|
-
data =
|
|
18549
|
+
data = text5;
|
|
18333
18550
|
}
|
|
18334
18551
|
}
|
|
18335
18552
|
const error = isRecord10(data) && data.success === false && isRecord10(data.error) ? data.error : void 0;
|
|
18336
18553
|
if (result.isError !== true && error === void 0) return data;
|
|
18337
|
-
const message = typeof error?.message === "string" ? error.message :
|
|
18554
|
+
const message = typeof error?.message === "string" ? error.message : text5 || `The Kenso MCP tool ${tool} returned an error.`;
|
|
18338
18555
|
if (error?.type === "KenNotFoundError") {
|
|
18339
18556
|
throw new KensoError({ code: "skill_not_found", message, exitCode: ExitCode.NotFound, next: "kenso skill list" });
|
|
18340
18557
|
}
|
|
@@ -18347,14 +18564,14 @@ function unexpectedAnswer(tool) {
|
|
|
18347
18564
|
exitCode: ExitCode.Server
|
|
18348
18565
|
});
|
|
18349
18566
|
}
|
|
18350
|
-
var
|
|
18567
|
+
var command61, list_default4;
|
|
18351
18568
|
var init_list4 = __esm({
|
|
18352
18569
|
"src/commands/skill/list.ts"() {
|
|
18353
18570
|
"use strict";
|
|
18354
18571
|
init_errors();
|
|
18355
18572
|
init_exit_codes();
|
|
18356
18573
|
init_connect4();
|
|
18357
|
-
|
|
18574
|
+
command61 = {
|
|
18358
18575
|
resource: "skill",
|
|
18359
18576
|
action: "list",
|
|
18360
18577
|
effect: "read",
|
|
@@ -18378,7 +18595,7 @@ var init_list4 = __esm({
|
|
|
18378
18595
|
return ExitCode.Ok;
|
|
18379
18596
|
}
|
|
18380
18597
|
};
|
|
18381
|
-
list_default4 =
|
|
18598
|
+
list_default4 = command61;
|
|
18382
18599
|
}
|
|
18383
18600
|
});
|
|
18384
18601
|
|
|
@@ -18387,7 +18604,7 @@ var show_exports3 = {};
|
|
|
18387
18604
|
__export(show_exports3, {
|
|
18388
18605
|
default: () => show_default3
|
|
18389
18606
|
});
|
|
18390
|
-
var
|
|
18607
|
+
var command62, show_default3;
|
|
18391
18608
|
var init_show3 = __esm({
|
|
18392
18609
|
"src/commands/skill/show.ts"() {
|
|
18393
18610
|
"use strict";
|
|
@@ -18395,7 +18612,7 @@ var init_show3 = __esm({
|
|
|
18395
18612
|
init_connect4();
|
|
18396
18613
|
init_bundled();
|
|
18397
18614
|
init_list4();
|
|
18398
|
-
|
|
18615
|
+
command62 = {
|
|
18399
18616
|
resource: "skill",
|
|
18400
18617
|
action: "show",
|
|
18401
18618
|
effect: "read",
|
|
@@ -18422,16 +18639,16 @@ var init_show3 = __esm({
|
|
|
18422
18639
|
return ExitCode.Ok;
|
|
18423
18640
|
}
|
|
18424
18641
|
};
|
|
18425
|
-
show_default3 =
|
|
18642
|
+
show_default3 = command62;
|
|
18426
18643
|
}
|
|
18427
18644
|
});
|
|
18428
18645
|
|
|
18429
18646
|
// src/commands/skill/index.ts
|
|
18430
|
-
var
|
|
18647
|
+
var actions30;
|
|
18431
18648
|
var init_skill = __esm({
|
|
18432
18649
|
"src/commands/skill/index.ts"() {
|
|
18433
18650
|
"use strict";
|
|
18434
|
-
|
|
18651
|
+
actions30 = {
|
|
18435
18652
|
install: () => Promise.resolve().then(() => (init_install(), install_exports)).then((m) => m.default),
|
|
18436
18653
|
list: () => Promise.resolve().then(() => (init_list4(), list_exports4)).then((m) => m.default),
|
|
18437
18654
|
show: () => Promise.resolve().then(() => (init_show3(), show_exports3)).then((m) => m.default)
|
|
@@ -18441,9 +18658,9 @@ var init_skill = __esm({
|
|
|
18441
18658
|
|
|
18442
18659
|
// src/commands/studio/common.ts
|
|
18443
18660
|
function positiveId3(value, field) {
|
|
18444
|
-
const
|
|
18445
|
-
const id = /^\d+$/.test(
|
|
18446
|
-
if (!Number.isSafeInteger(id) || id < 1) throw usageError(`${field} must be a positive whole number (got "${
|
|
18661
|
+
const text5 = (value ?? "").trim();
|
|
18662
|
+
const id = /^\d+$/.test(text5) ? Number(text5) : Number.NaN;
|
|
18663
|
+
if (!Number.isSafeInteger(id) || id < 1) throw usageError(`${field} must be a positive whole number (got "${text5}").`, { field });
|
|
18447
18664
|
return id;
|
|
18448
18665
|
}
|
|
18449
18666
|
function validationFailed(validation, message, next) {
|
|
@@ -18525,12 +18742,12 @@ async function readFolder(dir3, skipped = []) {
|
|
|
18525
18742
|
continue;
|
|
18526
18743
|
}
|
|
18527
18744
|
const bytes = await readFile10(abs);
|
|
18528
|
-
const
|
|
18529
|
-
if (!contentOk(path,
|
|
18745
|
+
const text5 = textOf2(bytes);
|
|
18746
|
+
if (!contentOk(path, text5 ?? bytes)) {
|
|
18530
18747
|
skipped.push(path);
|
|
18531
18748
|
continue;
|
|
18532
18749
|
}
|
|
18533
|
-
files.push({ path, bytes, text:
|
|
18750
|
+
files.push({ path, bytes, text: text5 });
|
|
18534
18751
|
}
|
|
18535
18752
|
}
|
|
18536
18753
|
};
|
|
@@ -18578,19 +18795,19 @@ async function recordPullState(root3, entries2) {
|
|
|
18578
18795
|
await writeFile4(path, `${JSON.stringify({ files }, null, 2)}
|
|
18579
18796
|
`);
|
|
18580
18797
|
}
|
|
18581
|
-
function checkPulledContent(bundlePath,
|
|
18798
|
+
function checkPulledContent(bundlePath, text5) {
|
|
18582
18799
|
const markdown = MARKDOWN.test(bundlePath);
|
|
18583
18800
|
if (!markdown && !SAMPLE_JSON.test(bundlePath)) return;
|
|
18584
|
-
if (typeof
|
|
18801
|
+
if (typeof text5 === "string" && contentOk(bundlePath, Buffer.from(text5, "utf8"))) return;
|
|
18585
18802
|
throw unsafePath(
|
|
18586
18803
|
bundlePath,
|
|
18587
|
-
!markdown ? "it does not hold a Studio sample (one JSON object with only the keys account, person, sender, brand, link, data, role and roles)" : typeof
|
|
18804
|
+
!markdown ? "it does not hold a Studio sample (one JSON object with only the keys account, person, sender, brand, link, data, role and roles)" : typeof text5 !== "string" ? "it came as a download link, and Kenso serves a .md file as text" : `it holds the line "${TOOL_CONFIG_MARKER}", which makes a code generator read it as its configuration and run the packages it names`
|
|
18588
18805
|
);
|
|
18589
18806
|
}
|
|
18590
|
-
function unsafePath(bundlePath,
|
|
18807
|
+
function unsafePath(bundlePath, why2) {
|
|
18591
18808
|
return new KensoError({
|
|
18592
18809
|
code: "unsafe_path",
|
|
18593
|
-
message: `Refusing to write "${bundlePath}": ${
|
|
18810
|
+
message: `Refusing to write "${bundlePath}": ${why2}.`,
|
|
18594
18811
|
exitCode: ExitCode.Error,
|
|
18595
18812
|
hint: "The template holds a file path the CLI will not write, or the folder has a link or folder in its way. Nothing was written."
|
|
18596
18813
|
});
|
|
@@ -18812,7 +19029,7 @@ function caseTwins(paths) {
|
|
|
18812
19029
|
}
|
|
18813
19030
|
return twins;
|
|
18814
19031
|
}
|
|
18815
|
-
var
|
|
19032
|
+
var command63, pull_default;
|
|
18816
19033
|
var init_pull = __esm({
|
|
18817
19034
|
"src/commands/studio/pull.ts"() {
|
|
18818
19035
|
"use strict";
|
|
@@ -18823,7 +19040,7 @@ var init_pull = __esm({
|
|
|
18823
19040
|
init_common4();
|
|
18824
19041
|
init_folder2();
|
|
18825
19042
|
init_transfer2();
|
|
18826
|
-
|
|
19043
|
+
command63 = {
|
|
18827
19044
|
resource: "studio",
|
|
18828
19045
|
action: "pull",
|
|
18829
19046
|
summary: "Write a template version's files to a folder",
|
|
@@ -18914,7 +19131,7 @@ var init_pull = __esm({
|
|
|
18914
19131
|
return ExitCode.Ok;
|
|
18915
19132
|
}
|
|
18916
19133
|
};
|
|
18917
|
-
pull_default =
|
|
19134
|
+
pull_default = command63;
|
|
18918
19135
|
}
|
|
18919
19136
|
});
|
|
18920
19137
|
|
|
@@ -18955,7 +19172,7 @@ __export(push_exports, {
|
|
|
18955
19172
|
default: () => push_default
|
|
18956
19173
|
});
|
|
18957
19174
|
import { resolve as resolve14 } from "node:path";
|
|
18958
|
-
var BUILT_BY, DEFAULT_MESSAGE,
|
|
19175
|
+
var BUILT_BY, DEFAULT_MESSAGE, command64, push_default;
|
|
18959
19176
|
var init_push = __esm({
|
|
18960
19177
|
"src/commands/studio/push.ts"() {
|
|
18961
19178
|
"use strict";
|
|
@@ -18969,7 +19186,7 @@ var init_push = __esm({
|
|
|
18969
19186
|
init_transfer2();
|
|
18970
19187
|
BUILT_BY = "customer_agent";
|
|
18971
19188
|
DEFAULT_MESSAGE = "Pushed with the Kenso CLI";
|
|
18972
|
-
|
|
19189
|
+
command64 = {
|
|
18973
19190
|
resource: "studio",
|
|
18974
19191
|
action: "push",
|
|
18975
19192
|
summary: "Save a folder's files to a template's draft and print the validation",
|
|
@@ -19064,7 +19281,7 @@ var init_push = __esm({
|
|
|
19064
19281
|
);
|
|
19065
19282
|
}
|
|
19066
19283
|
};
|
|
19067
|
-
push_default =
|
|
19284
|
+
push_default = command64;
|
|
19068
19285
|
}
|
|
19069
19286
|
});
|
|
19070
19287
|
|
|
@@ -19073,7 +19290,7 @@ var validate_exports = {};
|
|
|
19073
19290
|
__export(validate_exports, {
|
|
19074
19291
|
default: () => validate_default
|
|
19075
19292
|
});
|
|
19076
|
-
var
|
|
19293
|
+
var command65, validate_default;
|
|
19077
19294
|
var init_validate = __esm({
|
|
19078
19295
|
"src/commands/studio/validate.ts"() {
|
|
19079
19296
|
"use strict";
|
|
@@ -19082,7 +19299,7 @@ var init_validate = __esm({
|
|
|
19082
19299
|
init_columns();
|
|
19083
19300
|
init_common4();
|
|
19084
19301
|
init_read();
|
|
19085
|
-
|
|
19302
|
+
command65 = {
|
|
19086
19303
|
resource: "studio",
|
|
19087
19304
|
action: "validate",
|
|
19088
19305
|
summary: "Validate a folder's files against a template without saving them",
|
|
@@ -19112,7 +19329,7 @@ var init_validate = __esm({
|
|
|
19112
19329
|
throw validationFailed(validation, "The files have validation errors", commandLine2(ctx, "studio validate", args));
|
|
19113
19330
|
}
|
|
19114
19331
|
};
|
|
19115
|
-
validate_default =
|
|
19332
|
+
validate_default = command65;
|
|
19116
19333
|
}
|
|
19117
19334
|
});
|
|
19118
19335
|
|
|
@@ -19161,7 +19378,7 @@ function accountIds(value) {
|
|
|
19161
19378
|
}
|
|
19162
19379
|
return ids2.map(Number);
|
|
19163
19380
|
}
|
|
19164
|
-
var SHOWN2,
|
|
19381
|
+
var SHOWN2, command66, preview_default;
|
|
19165
19382
|
var init_preview = __esm({
|
|
19166
19383
|
"src/commands/studio/preview.ts"() {
|
|
19167
19384
|
"use strict";
|
|
@@ -19173,7 +19390,7 @@ var init_preview = __esm({
|
|
|
19173
19390
|
init_common4();
|
|
19174
19391
|
init_folder2();
|
|
19175
19392
|
SHOWN2 = 5;
|
|
19176
|
-
|
|
19393
|
+
command66 = {
|
|
19177
19394
|
resource: "studio",
|
|
19178
19395
|
action: "preview",
|
|
19179
19396
|
summary: "Render a saved version for up to 3 accounts; for local edits, studio push them to the draft first",
|
|
@@ -19223,7 +19440,7 @@ var init_preview = __esm({
|
|
|
19223
19440
|
return ExitCode.Ok;
|
|
19224
19441
|
}
|
|
19225
19442
|
};
|
|
19226
|
-
preview_default =
|
|
19443
|
+
preview_default = command66;
|
|
19227
19444
|
}
|
|
19228
19445
|
});
|
|
19229
19446
|
|
|
@@ -19406,8 +19623,8 @@ async function fillChunk(ctx, templateId, target2, wait3, chunk, chunkCtx) {
|
|
|
19406
19623
|
run = { ...run, skipped: created.skipped };
|
|
19407
19624
|
} catch (err) {
|
|
19408
19625
|
if (!chunkCtx.signal.aborted) {
|
|
19409
|
-
const
|
|
19410
|
-
ctx.output.warn(`Stopped following run ${created.id} (${
|
|
19626
|
+
const why2 = err instanceof Error ? err.message : String(err);
|
|
19627
|
+
ctx.output.warn(`Stopped following run ${created.id} (${why2}). It keeps going: kenso asset-runs get ${created.id}`);
|
|
19411
19628
|
}
|
|
19412
19629
|
}
|
|
19413
19630
|
}
|
|
@@ -19424,7 +19641,7 @@ function estimateOutput(templateId, target2, estimate2) {
|
|
|
19424
19641
|
...target2.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
|
|
19425
19642
|
};
|
|
19426
19643
|
}
|
|
19427
|
-
var COMMAND6, sha2564,
|
|
19644
|
+
var COMMAND6, sha2564, command67, fill_default;
|
|
19428
19645
|
var init_fill = __esm({
|
|
19429
19646
|
"src/commands/studio/fill.ts"() {
|
|
19430
19647
|
"use strict";
|
|
@@ -19442,7 +19659,7 @@ var init_fill = __esm({
|
|
|
19442
19659
|
init_fill_runs();
|
|
19443
19660
|
COMMAND6 = "studio fill";
|
|
19444
19661
|
sha2564 = (data) => createHash10("sha256").update(data).digest("hex");
|
|
19445
|
-
|
|
19662
|
+
command67 = {
|
|
19446
19663
|
resource: "studio",
|
|
19447
19664
|
action: "fill",
|
|
19448
19665
|
summary: "Fill a template on many accounts or campaign leads (estimate first)",
|
|
@@ -19511,16 +19728,16 @@ var init_fill = __esm({
|
|
|
19511
19728
|
return outcome.exitCode;
|
|
19512
19729
|
}
|
|
19513
19730
|
};
|
|
19514
|
-
fill_default =
|
|
19731
|
+
fill_default = command67;
|
|
19515
19732
|
}
|
|
19516
19733
|
});
|
|
19517
19734
|
|
|
19518
19735
|
// src/commands/studio/index.ts
|
|
19519
|
-
var
|
|
19736
|
+
var actions31;
|
|
19520
19737
|
var init_studio2 = __esm({
|
|
19521
19738
|
"src/commands/studio/index.ts"() {
|
|
19522
19739
|
"use strict";
|
|
19523
|
-
|
|
19740
|
+
actions31 = {
|
|
19524
19741
|
pull: () => Promise.resolve().then(() => (init_pull(), pull_exports)).then((m) => m.default),
|
|
19525
19742
|
push: () => Promise.resolve().then(() => (init_push(), push_exports)).then((m) => m.default),
|
|
19526
19743
|
validate: () => Promise.resolve().then(() => (init_validate(), validate_exports)).then((m) => m.default),
|
|
@@ -19531,52 +19748,52 @@ var init_studio2 = __esm({
|
|
|
19531
19748
|
});
|
|
19532
19749
|
|
|
19533
19750
|
// src/commands/tasks/shared.ts
|
|
19534
|
-
function positiveId4(
|
|
19535
|
-
const value = (
|
|
19751
|
+
function positiveId4(text5, field, next) {
|
|
19752
|
+
const value = (text5 ?? "").trim();
|
|
19536
19753
|
const id = /^\d+$/.test(value) ? Number(value) : Number.NaN;
|
|
19537
19754
|
if (!Number.isSafeInteger(id) || id < 1) throw usageError(`${field} must be a positive whole number (got "${value}").`, { field, next });
|
|
19538
19755
|
return id;
|
|
19539
19756
|
}
|
|
19540
19757
|
function due(dueText, atText, now = /* @__PURE__ */ new Date()) {
|
|
19541
|
-
const
|
|
19542
|
-
if (/^\d{4}-\d{2}-\d{2}T/.test(
|
|
19758
|
+
const text5 = (dueText ?? "").trim();
|
|
19759
|
+
if (/^\d{4}-\d{2}-\d{2}T/.test(text5)) {
|
|
19543
19760
|
if (atText !== void 0) throw usageError("--at puts a time on a day: give --due a day, not a time.", { field: "at", next: DUE_NEXT });
|
|
19544
|
-
if (!/(Z|[+-]\d{2}:?\d{2})$/i.test(
|
|
19545
|
-
throw usageError(`--due as a time needs its offset, such as ${
|
|
19761
|
+
if (!/(Z|[+-]\d{2}:?\d{2})$/i.test(text5))
|
|
19762
|
+
throw usageError(`--due as a time needs its offset, such as ${text5}Z or ${text5}+02:00 (got "${text5}"); or use --at for local time.`, {
|
|
19546
19763
|
field: "due",
|
|
19547
19764
|
next: DUE_NEXT
|
|
19548
19765
|
});
|
|
19549
|
-
if (Number.isNaN(Date.parse(
|
|
19550
|
-
return { dueAt:
|
|
19766
|
+
if (Number.isNaN(Date.parse(text5))) throw badDue(text5);
|
|
19767
|
+
return { dueAt: text5 };
|
|
19551
19768
|
}
|
|
19552
19769
|
if (dueText === void 0 && atText === void 0) return {};
|
|
19553
|
-
const day = dueText === void 0 ? startOfDay(now) : dayOf(
|
|
19770
|
+
const day = dueText === void 0 ? startOfDay(now) : dayOf(text5.toLowerCase(), now);
|
|
19554
19771
|
if (atText === void 0) return { dueDate: ymd(day) };
|
|
19555
19772
|
const at = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(atText.trim());
|
|
19556
19773
|
if (!at) throw usageError(`--at must be a time of day as HH:MM (got "${atText}").`, { field: "at", next: DUE_NEXT });
|
|
19557
19774
|
return { dueAt: new Date(day.getFullYear(), day.getMonth(), day.getDate(), Number(at[1]), Number(at[2])).toISOString() };
|
|
19558
19775
|
}
|
|
19559
|
-
function dayOf(
|
|
19776
|
+
function dayOf(text5, now) {
|
|
19560
19777
|
const today = startOfDay(now);
|
|
19561
|
-
if (
|
|
19562
|
-
if (
|
|
19563
|
-
const weekday = WEEKDAYS.findIndex((name) => name ===
|
|
19778
|
+
if (text5 === "today") return today;
|
|
19779
|
+
if (text5 === "tomorrow") return addDays(today, 1);
|
|
19780
|
+
const weekday = WEEKDAYS.findIndex((name) => name === text5 || name.slice(0, 3) === text5);
|
|
19564
19781
|
if (weekday >= 0) return addDays(today, (weekday - today.getDay() + 6) % 7 + 1);
|
|
19565
|
-
const parts2 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(
|
|
19782
|
+
const parts2 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text5);
|
|
19566
19783
|
if (parts2) {
|
|
19567
19784
|
const day = new Date(Number(parts2[1]), Number(parts2[2]) - 1, Number(parts2[3]));
|
|
19568
|
-
if (ymd(day) ===
|
|
19785
|
+
if (ymd(day) === text5) return day;
|
|
19569
19786
|
}
|
|
19570
|
-
throw badDue(
|
|
19787
|
+
throw badDue(text5);
|
|
19571
19788
|
}
|
|
19572
|
-
function badDue(
|
|
19573
|
-
return usageError(`--due must be today, tomorrow, a weekday, a day (2026-11-20) or an ISO 8601 time (got "${
|
|
19789
|
+
function badDue(text5) {
|
|
19790
|
+
return usageError(`--due must be today, tomorrow, a weekday, a day (2026-11-20) or an ISO 8601 time (got "${text5}").`, {
|
|
19574
19791
|
field: "due",
|
|
19575
19792
|
next: DUE_NEXT
|
|
19576
19793
|
});
|
|
19577
19794
|
}
|
|
19578
|
-
async function memberId(ctx,
|
|
19579
|
-
const value =
|
|
19795
|
+
async function memberId(ctx, text5, field, next) {
|
|
19796
|
+
const value = text5.trim();
|
|
19580
19797
|
if (value.toLowerCase() === "me") {
|
|
19581
19798
|
let me = unwrap((await ctx.client.request({ method: "GET", path: "/v1/me", signal: ctx.signal })).body);
|
|
19582
19799
|
if (me && typeof me.id !== "number" && typeof me.data?.id === "number") me = me.data;
|
|
@@ -19618,7 +19835,7 @@ var add_exports2 = {};
|
|
|
19618
19835
|
__export(add_exports2, {
|
|
19619
19836
|
default: () => add_default2
|
|
19620
19837
|
});
|
|
19621
|
-
var NEXT,
|
|
19838
|
+
var NEXT, command68, add_default2;
|
|
19622
19839
|
var init_add2 = __esm({
|
|
19623
19840
|
"src/commands/tasks/add.ts"() {
|
|
19624
19841
|
"use strict";
|
|
@@ -19628,7 +19845,7 @@ var init_add2 = __esm({
|
|
|
19628
19845
|
init_http();
|
|
19629
19846
|
init_shared2();
|
|
19630
19847
|
NEXT = 'kenso tasks add "Send the deck" --due tomorrow --account 812';
|
|
19631
|
-
|
|
19848
|
+
command68 = {
|
|
19632
19849
|
resource: "tasks",
|
|
19633
19850
|
action: "add",
|
|
19634
19851
|
summary: "Add a task: a title, an optional due day and time, assignee and the account, person or deal it is about",
|
|
@@ -19666,7 +19883,7 @@ var init_add2 = __esm({
|
|
|
19666
19883
|
return ExitCode.Ok;
|
|
19667
19884
|
}
|
|
19668
19885
|
};
|
|
19669
|
-
add_default2 =
|
|
19886
|
+
add_default2 = command68;
|
|
19670
19887
|
}
|
|
19671
19888
|
});
|
|
19672
19889
|
|
|
@@ -19703,7 +19920,7 @@ function stoppedAt(error, id, finished, status) {
|
|
|
19703
19920
|
details: error.details
|
|
19704
19921
|
});
|
|
19705
19922
|
}
|
|
19706
|
-
var
|
|
19923
|
+
var command69, done_default;
|
|
19707
19924
|
var init_done = __esm({
|
|
19708
19925
|
"src/commands/tasks/done.ts"() {
|
|
19709
19926
|
"use strict";
|
|
@@ -19712,7 +19929,7 @@ var init_done = __esm({
|
|
|
19712
19929
|
init_exit_codes();
|
|
19713
19930
|
init_http();
|
|
19714
19931
|
init_shared2();
|
|
19715
|
-
|
|
19932
|
+
command69 = {
|
|
19716
19933
|
resource: "tasks",
|
|
19717
19934
|
action: "done",
|
|
19718
19935
|
summary: "Complete one or more tasks (--undo reopens them)",
|
|
@@ -19725,7 +19942,7 @@ var init_done = __esm({
|
|
|
19725
19942
|
operationIds: ["tasks.update"],
|
|
19726
19943
|
dryRun: true,
|
|
19727
19944
|
async run(ctx, { flags, positionals }) {
|
|
19728
|
-
const ids2 = [...new Set(positionals.map((
|
|
19945
|
+
const ids2 = [...new Set(positionals.map((text5) => positiveId4(text5, "taskId", "kenso tasks done <taskId>...")))];
|
|
19729
19946
|
const change = { status: flags.undo === true ? "open" : "done" };
|
|
19730
19947
|
if (printDryRun(ctx, ...ids2.map((id) => ({ method: "PATCH", path: `/v1/tasks/${id}`, body: change })))) return ExitCode.Ok;
|
|
19731
19948
|
if (ids2.length === 1) ctx.output.object(await patchTask(ctx, ids2[0], change));
|
|
@@ -19746,7 +19963,7 @@ var init_done = __esm({
|
|
|
19746
19963
|
return ExitCode.Ok;
|
|
19747
19964
|
}
|
|
19748
19965
|
};
|
|
19749
|
-
done_default =
|
|
19966
|
+
done_default = command69;
|
|
19750
19967
|
}
|
|
19751
19968
|
});
|
|
19752
19969
|
|
|
@@ -19755,7 +19972,7 @@ var assign_exports = {};
|
|
|
19755
19972
|
__export(assign_exports, {
|
|
19756
19973
|
default: () => assign_default
|
|
19757
19974
|
});
|
|
19758
|
-
var NEXT2,
|
|
19975
|
+
var NEXT2, command70, assign_default;
|
|
19759
19976
|
var init_assign = __esm({
|
|
19760
19977
|
"src/commands/tasks/assign.ts"() {
|
|
19761
19978
|
"use strict";
|
|
@@ -19764,7 +19981,7 @@ var init_assign = __esm({
|
|
|
19764
19981
|
init_done();
|
|
19765
19982
|
init_shared2();
|
|
19766
19983
|
NEXT2 = "kenso tasks assign <taskId> <me|memberId|email>";
|
|
19767
|
-
|
|
19984
|
+
command70 = {
|
|
19768
19985
|
resource: "tasks",
|
|
19769
19986
|
action: "assign",
|
|
19770
19987
|
summary: "Give a task to a member",
|
|
@@ -19788,7 +20005,7 @@ var init_assign = __esm({
|
|
|
19788
20005
|
return ExitCode.Ok;
|
|
19789
20006
|
}
|
|
19790
20007
|
};
|
|
19791
|
-
assign_default =
|
|
20008
|
+
assign_default = command70;
|
|
19792
20009
|
}
|
|
19793
20010
|
});
|
|
19794
20011
|
|
|
@@ -19797,14 +20014,14 @@ var queue_exports = {};
|
|
|
19797
20014
|
__export(queue_exports, {
|
|
19798
20015
|
default: () => queue_default
|
|
19799
20016
|
});
|
|
19800
|
-
var SCOPES,
|
|
20017
|
+
var SCOPES, command71, queue_default;
|
|
19801
20018
|
var init_queue = __esm({
|
|
19802
20019
|
"src/commands/tasks/queue.ts"() {
|
|
19803
20020
|
"use strict";
|
|
19804
20021
|
init_errors();
|
|
19805
20022
|
init_exit_codes();
|
|
19806
20023
|
SCOPES = ["mine", "assigned_by_me", "everyone"];
|
|
19807
|
-
|
|
20024
|
+
command71 = {
|
|
19808
20025
|
resource: "tasks",
|
|
19809
20026
|
action: "queue",
|
|
19810
20027
|
summary: "Your open work by due day: tasks, touches, call tasks, reply reminders and Ken follow-ups",
|
|
@@ -19826,16 +20043,16 @@ var init_queue = __esm({
|
|
|
19826
20043
|
return ExitCode.Ok;
|
|
19827
20044
|
}
|
|
19828
20045
|
};
|
|
19829
|
-
queue_default =
|
|
20046
|
+
queue_default = command71;
|
|
19830
20047
|
}
|
|
19831
20048
|
});
|
|
19832
20049
|
|
|
19833
20050
|
// src/commands/tasks/index.ts
|
|
19834
|
-
var
|
|
20051
|
+
var actions32;
|
|
19835
20052
|
var init_tasks = __esm({
|
|
19836
20053
|
"src/commands/tasks/index.ts"() {
|
|
19837
20054
|
"use strict";
|
|
19838
|
-
|
|
20055
|
+
actions32 = {
|
|
19839
20056
|
add: () => Promise.resolve().then(() => (init_add2(), add_exports2)).then((m) => m.default),
|
|
19840
20057
|
done: () => Promise.resolve().then(() => (init_done(), done_exports)).then((m) => m.default),
|
|
19841
20058
|
assign: () => Promise.resolve().then(() => (init_assign(), assign_exports)).then((m) => m.default),
|
|
@@ -19850,8 +20067,8 @@ __export(pin_exports, {
|
|
|
19850
20067
|
pin: () => pin,
|
|
19851
20068
|
unpin: () => unpin
|
|
19852
20069
|
});
|
|
19853
|
-
function viewId2(
|
|
19854
|
-
const value = (
|
|
20070
|
+
function viewId2(text5, next) {
|
|
20071
|
+
const value = (text5 ?? "").trim();
|
|
19855
20072
|
const id = /^\d+$/.test(value) ? Number(value) : Number.NaN;
|
|
19856
20073
|
if (!Number.isSafeInteger(id) || id < 1) throw usageError(`Pass the view's id (got "${value}"): ${next}`, { field: "viewId", next });
|
|
19857
20074
|
return id;
|
|
@@ -19925,11 +20142,11 @@ var init_pin = __esm({
|
|
|
19925
20142
|
});
|
|
19926
20143
|
|
|
19927
20144
|
// src/commands/views/index.ts
|
|
19928
|
-
var
|
|
20145
|
+
var actions33;
|
|
19929
20146
|
var init_views = __esm({
|
|
19930
20147
|
"src/commands/views/index.ts"() {
|
|
19931
20148
|
"use strict";
|
|
19932
|
-
|
|
20149
|
+
actions33 = {
|
|
19933
20150
|
pin: () => Promise.resolve().then(() => (init_pin(), pin_exports)).then((m) => m.pin),
|
|
19934
20151
|
unpin: () => Promise.resolve().then(() => (init_pin(), pin_exports)).then((m) => m.unpin)
|
|
19935
20152
|
};
|
|
@@ -19966,14 +20183,14 @@ function signatureHeaders(secret, id, body2, nowMs = Date.now()) {
|
|
|
19966
20183
|
const signature = createHmac("sha256", key).update(`${id}.${timestamp}.${body2}`).digest("base64");
|
|
19967
20184
|
return { "svix-id": id, "svix-timestamp": timestamp, "svix-signature": `v1,${signature}` };
|
|
19968
20185
|
}
|
|
19969
|
-
function forwardUrl(
|
|
19970
|
-
const trimmed =
|
|
20186
|
+
function forwardUrl(text5) {
|
|
20187
|
+
const trimmed = text5.trim();
|
|
19971
20188
|
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? trimmed : `http://${trimmed}`;
|
|
19972
20189
|
let url;
|
|
19973
20190
|
try {
|
|
19974
20191
|
url = new URL(withScheme);
|
|
19975
20192
|
} catch {
|
|
19976
|
-
throw usageError(`--forward-to "${
|
|
20193
|
+
throw usageError(`--forward-to "${text5}" is not a URL.`, { field: "forward-to", hint: "Use the URL of your handler, for example http://localhost:3000/hook." });
|
|
19977
20194
|
}
|
|
19978
20195
|
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
19979
20196
|
throw usageError(`--forward-to must be an http or https URL, not ${url.protocol}`, { field: "forward-to" });
|
|
@@ -20068,7 +20285,7 @@ function readBody(req) {
|
|
|
20068
20285
|
function reply(res, status, body2) {
|
|
20069
20286
|
res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(body2));
|
|
20070
20287
|
}
|
|
20071
|
-
var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES,
|
|
20288
|
+
var MIN_POLL_MS, MAX_POLL_MS, MAX_TRIGGER_BYTES, command72, listen_default;
|
|
20072
20289
|
var init_listen = __esm({
|
|
20073
20290
|
"src/commands/webhooks/listen.ts"() {
|
|
20074
20291
|
"use strict";
|
|
@@ -20079,7 +20296,7 @@ var init_listen = __esm({
|
|
|
20079
20296
|
MIN_POLL_MS = 1e3;
|
|
20080
20297
|
MAX_POLL_MS = 6e4;
|
|
20081
20298
|
MAX_TRIGGER_BYTES = 1e6;
|
|
20082
|
-
|
|
20299
|
+
command72 = {
|
|
20083
20300
|
resource: "webhooks",
|
|
20084
20301
|
action: "listen",
|
|
20085
20302
|
summary: "Stream the workspace's events and forward them, signed, to a local handler",
|
|
@@ -20144,8 +20361,8 @@ var init_listen = __esm({
|
|
|
20144
20361
|
const server = createServer((req, res) => {
|
|
20145
20362
|
if (req.method !== "POST" || req.url !== "/events") return reply(res, 404, { error: "not_found" });
|
|
20146
20363
|
if (req.headers.authorization !== `Bearer ${token}`) return reply(res, 401, { error: "unauthorized" });
|
|
20147
|
-
readBody(req).then(async (
|
|
20148
|
-
const sent = JSON.parse(
|
|
20364
|
+
readBody(req).then(async (text5) => {
|
|
20365
|
+
const sent = JSON.parse(text5);
|
|
20149
20366
|
const result = await deliver({ eventId: sent.eventId, type: sent.type, timestamp: sent.timestamp, source: "trigger", body: JSON.stringify(sent.data) });
|
|
20150
20367
|
reply(res, 200, { forward: result ?? null });
|
|
20151
20368
|
}).catch(() => reply(res, 400, { error: "invalid_event" }));
|
|
@@ -20186,7 +20403,7 @@ var init_listen = __esm({
|
|
|
20186
20403
|
return ExitCode.Ok;
|
|
20187
20404
|
}
|
|
20188
20405
|
};
|
|
20189
|
-
listen_default =
|
|
20406
|
+
listen_default = command72;
|
|
20190
20407
|
}
|
|
20191
20408
|
});
|
|
20192
20409
|
|
|
@@ -20205,7 +20422,7 @@ function notRunning() {
|
|
|
20205
20422
|
next: LISTEN_NEXT
|
|
20206
20423
|
});
|
|
20207
20424
|
}
|
|
20208
|
-
var LISTEN_NEXT,
|
|
20425
|
+
var LISTEN_NEXT, command73, trigger_default;
|
|
20209
20426
|
var init_trigger = __esm({
|
|
20210
20427
|
"src/commands/webhooks/trigger.ts"() {
|
|
20211
20428
|
"use strict";
|
|
@@ -20214,7 +20431,7 @@ var init_trigger = __esm({
|
|
|
20214
20431
|
init_http();
|
|
20215
20432
|
init_local();
|
|
20216
20433
|
LISTEN_NEXT = "kenso webhooks listen --forward-to http://localhost:3000/hook";
|
|
20217
|
-
|
|
20434
|
+
command73 = {
|
|
20218
20435
|
resource: "webhooks",
|
|
20219
20436
|
action: "trigger",
|
|
20220
20437
|
summary: "Send a sample event of one type through the running kenso webhooks listen",
|
|
@@ -20272,16 +20489,16 @@ var init_trigger = __esm({
|
|
|
20272
20489
|
return ExitCode.Ok;
|
|
20273
20490
|
}
|
|
20274
20491
|
};
|
|
20275
|
-
trigger_default =
|
|
20492
|
+
trigger_default = command73;
|
|
20276
20493
|
}
|
|
20277
20494
|
});
|
|
20278
20495
|
|
|
20279
20496
|
// src/commands/webhooks/index.ts
|
|
20280
|
-
var
|
|
20497
|
+
var actions34;
|
|
20281
20498
|
var init_webhooks2 = __esm({
|
|
20282
20499
|
"src/commands/webhooks/index.ts"() {
|
|
20283
20500
|
"use strict";
|
|
20284
|
-
|
|
20501
|
+
actions34 = {
|
|
20285
20502
|
listen: () => Promise.resolve().then(() => (init_listen(), listen_exports)).then((m) => m.default),
|
|
20286
20503
|
trigger: () => Promise.resolve().then(() => (init_trigger(), trigger_exports)).then((m) => m.default)
|
|
20287
20504
|
};
|
|
@@ -20293,14 +20510,14 @@ var status_exports3 = {};
|
|
|
20293
20510
|
__export(status_exports3, {
|
|
20294
20511
|
default: () => status_default3
|
|
20295
20512
|
});
|
|
20296
|
-
var
|
|
20513
|
+
var command74, status_default3;
|
|
20297
20514
|
var init_status3 = __esm({
|
|
20298
20515
|
"src/commands/work/status.ts"() {
|
|
20299
20516
|
"use strict";
|
|
20300
20517
|
init_exit_codes();
|
|
20301
20518
|
init_http();
|
|
20302
20519
|
init_common3();
|
|
20303
|
-
|
|
20520
|
+
command74 = {
|
|
20304
20521
|
resource: "work",
|
|
20305
20522
|
action: "status",
|
|
20306
20523
|
summary: "Show the Kenso AI work waiting for your own agent, per kind",
|
|
@@ -20335,7 +20552,7 @@ var init_status3 = __esm({
|
|
|
20335
20552
|
return ExitCode.Ok;
|
|
20336
20553
|
}
|
|
20337
20554
|
};
|
|
20338
|
-
status_default3 =
|
|
20555
|
+
status_default3 = command74;
|
|
20339
20556
|
}
|
|
20340
20557
|
});
|
|
20341
20558
|
|
|
@@ -20387,18 +20604,18 @@ function isObject2(value) {
|
|
|
20387
20604
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
20388
20605
|
}
|
|
20389
20606
|
function readAnswersFile(path, work) {
|
|
20390
|
-
let
|
|
20607
|
+
let text5;
|
|
20391
20608
|
try {
|
|
20392
20609
|
const read2 = readRegularFile(path, "answers file");
|
|
20393
20610
|
if (typeof read2 !== "string") return read2;
|
|
20394
|
-
|
|
20611
|
+
text5 = read2;
|
|
20395
20612
|
} catch (err) {
|
|
20396
20613
|
const code = err.code;
|
|
20397
20614
|
return { ok: false, error: code === "ENOENT" ? "the answers file was not written" : "the answers file could not be read" };
|
|
20398
20615
|
}
|
|
20399
20616
|
let doc;
|
|
20400
20617
|
try {
|
|
20401
|
-
doc = JSON.parse(
|
|
20618
|
+
doc = JSON.parse(text5.charCodeAt(0) === 65279 ? text5.slice(1) : text5);
|
|
20402
20619
|
} catch {
|
|
20403
20620
|
return { ok: false, error: "the answers file is not valid JSON" };
|
|
20404
20621
|
}
|
|
@@ -20441,9 +20658,9 @@ function readAnswersFile(path, work) {
|
|
|
20441
20658
|
return { ok: true, answers, dropped, agent: { ...cli ? { cli } : {}, ...model ? { model } : {} } };
|
|
20442
20659
|
}
|
|
20443
20660
|
function readWorkFile(path) {
|
|
20444
|
-
const
|
|
20445
|
-
if (typeof
|
|
20446
|
-
const doc = JSON.parse(
|
|
20661
|
+
const text5 = readRegularFile(path, "work file");
|
|
20662
|
+
if (typeof text5 !== "string") throw new Error(text5.error);
|
|
20663
|
+
const doc = JSON.parse(text5);
|
|
20447
20664
|
if (!isObject2(doc) || typeof doc.claimId !== "string" || !Array.isArray(doc.items)) {
|
|
20448
20665
|
throw new Error("the work file is not a work file");
|
|
20449
20666
|
}
|
|
@@ -20467,9 +20684,9 @@ var init_files = __esm({
|
|
|
20467
20684
|
import { execFile, spawnSync as spawnSync2 } from "node:child_process";
|
|
20468
20685
|
import { readFileSync as readFileSync19 } from "node:fs";
|
|
20469
20686
|
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
20470
|
-
function sudoArgs(user,
|
|
20687
|
+
function sudoArgs(user, command91, args, keep = [], set2 = {}) {
|
|
20471
20688
|
const assignments = Object.entries(set2).map(([name, value]) => `${name}=${value}`);
|
|
20472
|
-
return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--",
|
|
20689
|
+
return ["-n", "-u", user, "-H", ...keep.length > 0 ? [`--preserve-env=${keep.join(",")}`] : [], ...assignments, "--", command91, ...args];
|
|
20473
20690
|
}
|
|
20474
20691
|
function agentKensoEnv(opts) {
|
|
20475
20692
|
return {
|
|
@@ -20479,12 +20696,12 @@ function agentKensoEnv(opts) {
|
|
|
20479
20696
|
AI_AGENT: opts.agentName
|
|
20480
20697
|
};
|
|
20481
20698
|
}
|
|
20482
|
-
function sudoExec(user,
|
|
20699
|
+
function sudoExec(user, command91, args, opts = {}) {
|
|
20483
20700
|
const [sudo = "/usr/bin/sudo", ...lead] = user.sudo;
|
|
20484
20701
|
return new Promise((resolve24) => {
|
|
20485
20702
|
execFile(
|
|
20486
20703
|
sudo,
|
|
20487
|
-
[...lead, ...sudoArgs(user.name,
|
|
20704
|
+
[...lead, ...sudoArgs(user.name, command91, args)],
|
|
20488
20705
|
{ env: { PATH: SUDO_PATH }, cwd: "/", timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS, maxBuffer: opts.maxBuffer ?? 1024 * 1024, encoding: "utf8", windowsHide: true, shell: false },
|
|
20489
20706
|
(err, stdout, stderr) => {
|
|
20490
20707
|
const code = err ? err.code : 0;
|
|
@@ -20507,10 +20724,10 @@ function sudoKillSync(user, group) {
|
|
|
20507
20724
|
windowsHide: true
|
|
20508
20725
|
});
|
|
20509
20726
|
}
|
|
20510
|
-
function refusal(name,
|
|
20727
|
+
function refusal(name, why2) {
|
|
20511
20728
|
return new KensoError({
|
|
20512
20729
|
code: "agent_user_invalid",
|
|
20513
|
-
message: `--agent-user ${name} ${
|
|
20730
|
+
message: `--agent-user ${name} ${why2}.`,
|
|
20514
20731
|
exitCode: ExitCode.Usage,
|
|
20515
20732
|
field: "agent-user",
|
|
20516
20733
|
hint: "Name a separate user with no sudo and a home folder of its own, as which this user may run the agent CLIs, kill and cat through sudo -n."
|
|
@@ -20594,9 +20811,9 @@ var init_folder3 = __esm({
|
|
|
20594
20811
|
init_redact();
|
|
20595
20812
|
init_agent_user();
|
|
20596
20813
|
WorkRunFolder = class {
|
|
20597
|
-
constructor(ctx,
|
|
20814
|
+
constructor(ctx, command91, args, outDir, shared = false) {
|
|
20598
20815
|
this.ctx = ctx;
|
|
20599
|
-
this.command =
|
|
20816
|
+
this.command = command91;
|
|
20600
20817
|
this.args = args;
|
|
20601
20818
|
this.outDir = outDir;
|
|
20602
20819
|
this.shared = shared;
|
|
@@ -20711,7 +20928,7 @@ var pull_exports2 = {};
|
|
|
20711
20928
|
__export(pull_exports2, {
|
|
20712
20929
|
default: () => pull_default2
|
|
20713
20930
|
});
|
|
20714
|
-
var MAX_FILES,
|
|
20931
|
+
var MAX_FILES, command75, pull_default2;
|
|
20715
20932
|
var init_pull2 = __esm({
|
|
20716
20933
|
"src/commands/work/pull.ts"() {
|
|
20717
20934
|
"use strict";
|
|
@@ -20720,7 +20937,7 @@ var init_pull2 = __esm({
|
|
|
20720
20937
|
init_common3();
|
|
20721
20938
|
init_folder3();
|
|
20722
20939
|
MAX_FILES = 100;
|
|
20723
|
-
|
|
20940
|
+
command75 = {
|
|
20724
20941
|
resource: "work",
|
|
20725
20942
|
action: "pull",
|
|
20726
20943
|
summary: "Claim waiting work into local work files, to answer by hand",
|
|
@@ -20799,7 +21016,7 @@ var init_pull2 = __esm({
|
|
|
20799
21016
|
return interrupted7 ? ExitCode.Interrupted : ExitCode.Ok;
|
|
20800
21017
|
}
|
|
20801
21018
|
};
|
|
20802
|
-
pull_default2 =
|
|
21019
|
+
pull_default2 = command75;
|
|
20803
21020
|
}
|
|
20804
21021
|
});
|
|
20805
21022
|
|
|
@@ -20941,7 +21158,7 @@ __export(submit_exports, {
|
|
|
20941
21158
|
default: () => submit_default
|
|
20942
21159
|
});
|
|
20943
21160
|
import { resolve as resolve17 } from "node:path";
|
|
20944
|
-
var
|
|
21161
|
+
var command76, submit_default;
|
|
20945
21162
|
var init_submit = __esm({
|
|
20946
21163
|
"src/commands/work/submit.ts"() {
|
|
20947
21164
|
"use strict";
|
|
@@ -20950,7 +21167,7 @@ var init_submit = __esm({
|
|
|
20950
21167
|
init_files();
|
|
20951
21168
|
init_answers();
|
|
20952
21169
|
init_common3();
|
|
20953
|
-
|
|
21170
|
+
command76 = {
|
|
20954
21171
|
resource: "work",
|
|
20955
21172
|
action: "submit",
|
|
20956
21173
|
summary: "Send answers files to Kenso and write each one's results",
|
|
@@ -20983,7 +21200,7 @@ var init_submit = __esm({
|
|
|
20983
21200
|
return totals.rejected > 0 ? ExitCode.Partial : ExitCode.Ok;
|
|
20984
21201
|
}
|
|
20985
21202
|
};
|
|
20986
|
-
submit_default =
|
|
21203
|
+
submit_default = command76;
|
|
20987
21204
|
}
|
|
20988
21205
|
});
|
|
20989
21206
|
|
|
@@ -21004,7 +21221,7 @@ function claimIdOf(arg) {
|
|
|
21004
21221
|
if (!CLAIM_ID.test(arg)) throw usageError(`"${arg}" is neither a claim id nor a work file.`, { field: "claim", hint: "Claim ids look like awc_8fK2..." });
|
|
21005
21222
|
return arg;
|
|
21006
21223
|
}
|
|
21007
|
-
var CLAIM_ID,
|
|
21224
|
+
var CLAIM_ID, command77, release_default;
|
|
21008
21225
|
var init_release = __esm({
|
|
21009
21226
|
"src/commands/work/release.ts"() {
|
|
21010
21227
|
"use strict";
|
|
@@ -21013,7 +21230,7 @@ var init_release = __esm({
|
|
|
21013
21230
|
init_files();
|
|
21014
21231
|
init_common3();
|
|
21015
21232
|
CLAIM_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
21016
|
-
|
|
21233
|
+
command77 = {
|
|
21017
21234
|
resource: "work",
|
|
21018
21235
|
action: "release",
|
|
21019
21236
|
summary: "Give claimed work back to the queue now",
|
|
@@ -21033,22 +21250,22 @@ var init_release = __esm({
|
|
|
21033
21250
|
return ExitCode.Ok;
|
|
21034
21251
|
}
|
|
21035
21252
|
};
|
|
21036
|
-
release_default =
|
|
21253
|
+
release_default = command77;
|
|
21037
21254
|
}
|
|
21038
21255
|
});
|
|
21039
21256
|
|
|
21040
21257
|
// src/work/egress.ts
|
|
21041
21258
|
function v6Groups(address) {
|
|
21042
|
-
let
|
|
21043
|
-
const v4 = /(\d+\.\d+\.\d+\.\d+)$/.exec(
|
|
21259
|
+
let text5 = address.toLowerCase();
|
|
21260
|
+
const v4 = /(\d+\.\d+\.\d+\.\d+)$/.exec(text5);
|
|
21044
21261
|
if (v4) {
|
|
21045
21262
|
const bytes = v4[1].split(".").map(Number);
|
|
21046
|
-
|
|
21263
|
+
text5 = text5.slice(0, v4.index) + `${(bytes[0] << 8 | bytes[1]).toString(16)}:${(bytes[2] << 8 | bytes[3]).toString(16)}`;
|
|
21047
21264
|
}
|
|
21048
|
-
const [head, tail2] =
|
|
21265
|
+
const [head, tail2] = text5.split("::");
|
|
21049
21266
|
const left = head ? head.split(":") : [];
|
|
21050
21267
|
const right = tail2 ? tail2.split(":") : [];
|
|
21051
|
-
const fill =
|
|
21268
|
+
const fill = text5.includes("::") ? 8 - left.length - right.length : 0;
|
|
21052
21269
|
const groups = [...left, ...Array(Math.max(fill, 0)).fill("0"), ...right].map((g) => parseInt(g, 16));
|
|
21053
21270
|
return groups.length === 8 && groups.every((g) => g >= 0 && g <= 65535) ? groups : void 0;
|
|
21054
21271
|
}
|
|
@@ -21183,8 +21400,8 @@ async function startWebGuard(opts = {}) {
|
|
|
21183
21400
|
delete headers["proxy-authorization"];
|
|
21184
21401
|
const fail = (err) => {
|
|
21185
21402
|
if (res.headersSent) return void res.destroy();
|
|
21186
|
-
const { status, text:
|
|
21187
|
-
res.writeHead(status, { "Content-Type": "text/plain" }).end(
|
|
21403
|
+
const { status, text: text5 } = failure(err);
|
|
21404
|
+
res.writeHead(status, { "Content-Type": "text/plain" }).end(text5);
|
|
21188
21405
|
};
|
|
21189
21406
|
const reply2 = (answer) => {
|
|
21190
21407
|
if (upstream && answer.statusCode === 407) opts.onUpstreamTrouble?.("answered 407");
|
|
@@ -21224,8 +21441,8 @@ ${body2}`);
|
|
|
21224
21441
|
},
|
|
21225
21442
|
(err) => {
|
|
21226
21443
|
if (client.destroyed || client.writableEnded) return;
|
|
21227
|
-
const { status, text:
|
|
21228
|
-
answer(status === 403 ? "403 Forbidden" : "502 Bad Gateway",
|
|
21444
|
+
const { status, text: text5 } = failure(err);
|
|
21445
|
+
answer(status === 403 ? "403 Forbidden" : "502 Bad Gateway", text5);
|
|
21229
21446
|
}
|
|
21230
21447
|
);
|
|
21231
21448
|
});
|
|
@@ -21453,9 +21670,9 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
21453
21670
|
resolve24({ exitCode, stdout: stdout.text(), stderr: stderr.text(), stopped, spawnError });
|
|
21454
21671
|
});
|
|
21455
21672
|
};
|
|
21456
|
-
const stop = (
|
|
21673
|
+
const stop = (why2) => {
|
|
21457
21674
|
if (stopped || settled2 || exited) return;
|
|
21458
|
-
stopped =
|
|
21675
|
+
stopped = why2;
|
|
21459
21676
|
signalTree(child, "SIGTERM", runAs);
|
|
21460
21677
|
timers.push(setTimeout(() => signalTree(child, "SIGKILL", runAs), KILL_GRACE_MS));
|
|
21461
21678
|
};
|
|
@@ -21489,8 +21706,8 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
21489
21706
|
if (signal?.aborted) stop("abort");
|
|
21490
21707
|
});
|
|
21491
21708
|
}
|
|
21492
|
-
function tail(
|
|
21493
|
-
const flat =
|
|
21709
|
+
function tail(text5) {
|
|
21710
|
+
const flat = text5.replace(/\s+/g, " ").trim();
|
|
21494
21711
|
return flat.length > DETAIL_TAIL ? "..." + flat.slice(flat.length - DETAIL_TAIL) : flat;
|
|
21495
21712
|
}
|
|
21496
21713
|
async function confirmToolsVerdict(adapter, verdict, loginCheck) {
|
|
@@ -21639,10 +21856,10 @@ var init_job = __esm({
|
|
|
21639
21856
|
|
|
21640
21857
|
// src/work/adapters/common.ts
|
|
21641
21858
|
import { execFile as execFile2 } from "node:child_process";
|
|
21642
|
-
function verdictForError(
|
|
21643
|
-
if (USAGE_LIMIT.test(
|
|
21644
|
-
if (AUTH.test(
|
|
21645
|
-
if (TRANSIENT.test(
|
|
21859
|
+
function verdictForError(text5) {
|
|
21860
|
+
if (USAGE_LIMIT.test(text5)) return "usage_limit";
|
|
21861
|
+
if (AUTH.test(text5)) return "auth";
|
|
21862
|
+
if (TRANSIENT.test(text5)) return "transient";
|
|
21646
21863
|
return "fatal";
|
|
21647
21864
|
}
|
|
21648
21865
|
function classifyByExit(r) {
|
|
@@ -21651,16 +21868,16 @@ function classifyByExit(r) {
|
|
|
21651
21868
|
${errorTail(r.stdout)}`);
|
|
21652
21869
|
}
|
|
21653
21870
|
function lastJsonObject(stdout) {
|
|
21654
|
-
const parse3 = (
|
|
21871
|
+
const parse3 = (text5) => {
|
|
21655
21872
|
try {
|
|
21656
|
-
const value = JSON.parse(
|
|
21873
|
+
const value = JSON.parse(text5);
|
|
21657
21874
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
21658
21875
|
} catch {
|
|
21659
21876
|
return void 0;
|
|
21660
21877
|
}
|
|
21661
21878
|
};
|
|
21662
|
-
const
|
|
21663
|
-
if (
|
|
21879
|
+
const whole2 = parse3(stdout.trim());
|
|
21880
|
+
if (whole2) return whole2;
|
|
21664
21881
|
const lines = stdout.split("\n");
|
|
21665
21882
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
21666
21883
|
const line = lines[i].trim();
|
|
@@ -21679,16 +21896,16 @@ function classifyResultJson(r) {
|
|
|
21679
21896
|
return verdictForError(`${errorTail(said)}
|
|
21680
21897
|
${errorTail(r.stderr)}`);
|
|
21681
21898
|
}
|
|
21682
|
-
function plain(
|
|
21683
|
-
return
|
|
21899
|
+
function plain(text5) {
|
|
21900
|
+
return text5.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
|
|
21684
21901
|
}
|
|
21685
21902
|
function runStatus(bin, args, env, adapter, runAs) {
|
|
21686
|
-
const
|
|
21903
|
+
const command91 = runAs ? runAs.sudo[0] ?? "/usr/bin/sudo" : bin;
|
|
21687
21904
|
const commandArgs2 = runAs ? [...runAs.sudo.slice(1), ...sudoArgs(runAs.name, bin, args)] : args;
|
|
21688
21905
|
const options = runAs ? { env: { PATH: SUDO_PATH }, cwd: "/" } : { env: childEnv(env, adapter) };
|
|
21689
21906
|
return new Promise((resolve24) => {
|
|
21690
21907
|
execFile2(
|
|
21691
|
-
|
|
21908
|
+
command91,
|
|
21692
21909
|
commandArgs2,
|
|
21693
21910
|
{ ...options, timeout: STATUS_TIMEOUT_MS, maxBuffer: 1024 * 1024, windowsHide: true, shell: false },
|
|
21694
21911
|
(err, stdout, stderr) => {
|
|
@@ -21716,7 +21933,7 @@ var init_common5 = __esm({
|
|
|
21716
21933
|
AUTH = /not logged in|not authenticated|authentication (required|failed|error)|401 unauthori[sz]ed|invalid[ _-]api[ _-]key|please run \/?login|log ?in (again|required)|login required|(oauth |access )?token (has )?expired|could not be refreshed|invalid (credentials|token)|(status|http|api error)[: ]*(401|403)\b/i;
|
|
21717
21934
|
TRANSIENT = /overloaded|internal server error|service unavailable|bad gateway|gateway timeout|temporarily unavailable|(status|http|api error)[: ]*5\d\d\b|timed? ?out|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EAI_AGAIN|ENOTFOUND|socket hang up|network error|fetch failed|connection (reset|refused|closed|error)|stream (error|disconnected)/i;
|
|
21718
21935
|
ERROR_TAIL_CHARS = 1500;
|
|
21719
|
-
errorTail = (
|
|
21936
|
+
errorTail = (text5) => text5.slice(-ERROR_TAIL_CHARS);
|
|
21720
21937
|
STATUS_TIMEOUT_MS = 2e4;
|
|
21721
21938
|
}
|
|
21722
21939
|
});
|
|
@@ -21846,10 +22063,10 @@ var init_codex = __esm({
|
|
|
21846
22063
|
async check(bin, env, runAs) {
|
|
21847
22064
|
const out = await runStatus(bin, ["login", "status"], env, codex, runAs);
|
|
21848
22065
|
if (!out) return "unknown";
|
|
21849
|
-
const
|
|
22066
|
+
const text5 = `${out.stdout}
|
|
21850
22067
|
${out.stderr}`;
|
|
21851
|
-
if (/logged in using chatgpt/i.test(
|
|
21852
|
-
if (/not logged in|logged in using an api key/i.test(
|
|
22068
|
+
if (/logged in using chatgpt/i.test(text5)) return "ok";
|
|
22069
|
+
if (/not logged in|logged in using an api key/i.test(text5)) return "logged_out";
|
|
21853
22070
|
return "unknown";
|
|
21854
22071
|
},
|
|
21855
22072
|
loginCommand: "codex login"
|
|
@@ -21938,10 +22155,10 @@ var init_grok = __esm({
|
|
|
21938
22155
|
async check(bin, env, runAs) {
|
|
21939
22156
|
const out = await runStatus(bin, ["models"], env, grok, runAs);
|
|
21940
22157
|
if (!out) return "unknown";
|
|
21941
|
-
const
|
|
22158
|
+
const text5 = `${out.stdout}
|
|
21942
22159
|
${out.stderr}`;
|
|
21943
|
-
if (/logged in with grok\.com/i.test(
|
|
21944
|
-
if (/not authenticated|not logged in/i.test(
|
|
22160
|
+
if (/logged in with grok\.com/i.test(text5)) return "ok";
|
|
22161
|
+
if (/not authenticated|not logged in/i.test(text5)) return "logged_out";
|
|
21945
22162
|
return "unknown";
|
|
21946
22163
|
},
|
|
21947
22164
|
loginCommand: "grok login"
|
|
@@ -22061,18 +22278,18 @@ var init_adapters = __esm({
|
|
|
22061
22278
|
|
|
22062
22279
|
// src/work/scan.ts
|
|
22063
22280
|
import { createHmac as createHmac2, randomBytes as randomBytes4 } from "node:crypto";
|
|
22064
|
-
function fold(
|
|
22065
|
-
return
|
|
22281
|
+
function fold(text5) {
|
|
22282
|
+
return text5.normalize("NFKC").replace(/[^A-Za-z0-9]/g, "").toLowerCase();
|
|
22066
22283
|
}
|
|
22067
|
-
function entropy(
|
|
22284
|
+
function entropy(text5) {
|
|
22068
22285
|
const counts2 = /* @__PURE__ */ new Map();
|
|
22069
|
-
for (const c of
|
|
22286
|
+
for (const c of text5) counts2.set(c, (counts2.get(c) ?? 0) + 1);
|
|
22070
22287
|
let bits = 0;
|
|
22071
|
-
for (const n of counts2.values()) bits -= n /
|
|
22288
|
+
for (const n of counts2.values()) bits -= n / text5.length * Math.log2(n / text5.length);
|
|
22072
22289
|
return bits;
|
|
22073
22290
|
}
|
|
22074
|
-
function hasHighEntropyRun(
|
|
22075
|
-
for (const word of
|
|
22291
|
+
function hasHighEntropyRun(text5) {
|
|
22292
|
+
for (const word of text5.split(/\s+/)) {
|
|
22076
22293
|
if (LINK.test(word)) continue;
|
|
22077
22294
|
for (const m of word.matchAll(/[A-Za-z0-9+/=_-]{32,}/g)) {
|
|
22078
22295
|
const run = m[0];
|
|
@@ -22087,18 +22304,18 @@ function stringValues(value, out = []) {
|
|
|
22087
22304
|
else if (value !== null && typeof value === "object") for (const v of Object.values(value)) stringValues(v, out);
|
|
22088
22305
|
return out;
|
|
22089
22306
|
}
|
|
22090
|
-
function decodings(
|
|
22307
|
+
function decodings(text5) {
|
|
22091
22308
|
const out = [];
|
|
22092
|
-
for (const m of
|
|
22309
|
+
for (const m of text5.matchAll(/[A-Za-z0-9+/_-]{20,}={0,2}/g)) {
|
|
22093
22310
|
for (const encoding of ["base64", "base64url"]) {
|
|
22094
22311
|
const decoded = Buffer.from(m[0], encoding).toString("utf8");
|
|
22095
22312
|
if (decoded.length >= WINDOW && /^[\x20-\x7e\s]+$/.test(decoded)) out.push(decoded);
|
|
22096
22313
|
}
|
|
22097
22314
|
}
|
|
22098
|
-
for (const m of
|
|
22099
|
-
if (/%[0-9a-fA-F]{2}/.test(
|
|
22315
|
+
for (const m of text5.matchAll(/(?:[0-9a-fA-F]{2}){16,}/g)) out.push(Buffer.from(m[0], "hex").toString("utf8"));
|
|
22316
|
+
if (/%[0-9a-fA-F]{2}/.test(text5)) {
|
|
22100
22317
|
try {
|
|
22101
|
-
out.push(decodeURIComponent(
|
|
22318
|
+
out.push(decodeURIComponent(text5));
|
|
22102
22319
|
} catch {
|
|
22103
22320
|
}
|
|
22104
22321
|
}
|
|
@@ -22182,12 +22399,12 @@ var init_scan = __esm({
|
|
|
22182
22399
|
exact = /* @__PURE__ */ new Set();
|
|
22183
22400
|
folded = /* @__PURE__ */ new Set();
|
|
22184
22401
|
/** Adds a credential file's text: its JSON string values (keys skipped), or the whole text when it is not JSON. */
|
|
22185
|
-
add(
|
|
22402
|
+
add(text5) {
|
|
22186
22403
|
let values;
|
|
22187
22404
|
try {
|
|
22188
|
-
values = stringValues(JSON.parse(
|
|
22405
|
+
values = stringValues(JSON.parse(text5));
|
|
22189
22406
|
} catch {
|
|
22190
|
-
values = [
|
|
22407
|
+
values = [text5];
|
|
22191
22408
|
}
|
|
22192
22409
|
for (const value of values) {
|
|
22193
22410
|
for (const run of value.match(TOKEN_RUN) ?? []) {
|
|
@@ -22209,11 +22426,11 @@ var init_scan = __esm({
|
|
|
22209
22426
|
hash(window) {
|
|
22210
22427
|
return createHmac2("sha256", this.key).update(window).digest("base64url");
|
|
22211
22428
|
}
|
|
22212
|
-
addWindows(
|
|
22213
|
-
for (let i = 0; i + WINDOW <=
|
|
22429
|
+
addWindows(text5, into) {
|
|
22430
|
+
for (let i = 0; i + WINDOW <= text5.length; i++) into.add(this.hash(text5.slice(i, i + WINDOW)));
|
|
22214
22431
|
}
|
|
22215
|
-
anyWindow(
|
|
22216
|
-
for (let i = 0; i + WINDOW <=
|
|
22432
|
+
anyWindow(text5, set2) {
|
|
22433
|
+
for (let i = 0; i + WINDOW <= text5.length; i++) if (set2.has(this.hash(text5.slice(i, i + WINDOW)))) return true;
|
|
22217
22434
|
return false;
|
|
22218
22435
|
}
|
|
22219
22436
|
};
|
|
@@ -22223,10 +22440,10 @@ var init_scan = __esm({
|
|
|
22223
22440
|
// src/work/credentials.ts
|
|
22224
22441
|
import { createHash as createHash11 } from "node:crypto";
|
|
22225
22442
|
import { join as join28 } from "node:path";
|
|
22226
|
-
function unreadable(
|
|
22443
|
+
function unreadable(why2) {
|
|
22227
22444
|
return new KensoError({
|
|
22228
22445
|
code: "credentials_unreadable",
|
|
22229
|
-
message: `Kenso cannot scan this run's answers: ${
|
|
22446
|
+
message: `Kenso cannot scan this run's answers: ${why2}.`,
|
|
22230
22447
|
exitCode: ExitCode.Error,
|
|
22231
22448
|
field: "agent-user",
|
|
22232
22449
|
hint: "A Kenso sandbox run scans every answer against the agent's login files, so it does not start without them. Connect the agent again."
|
|
@@ -22331,11 +22548,11 @@ function agentGuide(opts) {
|
|
|
22331
22548
|
const parts2 = opts.kensoKey ? [JOB, KENSO, ...browser ? [BROWSER] : [], NEVER] : [JOB, NO_KENSO, NEVER];
|
|
22332
22549
|
return parts2.join("\n");
|
|
22333
22550
|
}
|
|
22334
|
-
function writeAgentGuide(dir3,
|
|
22551
|
+
function writeAgentGuide(dir3, text5, mode = WORK_FILE_MODE) {
|
|
22335
22552
|
for (const name of GUIDE_FILES) {
|
|
22336
22553
|
const fd = openSync3(join29(dir3, name), "wx", mode);
|
|
22337
22554
|
try {
|
|
22338
|
-
writeFileSync10(fd,
|
|
22555
|
+
writeFileSync10(fd, text5, "utf8");
|
|
22339
22556
|
fchmodSync2(fd, mode);
|
|
22340
22557
|
} finally {
|
|
22341
22558
|
closeSync3(fd);
|
|
@@ -22645,13 +22862,13 @@ async function readRunToken(ctx) {
|
|
|
22645
22862
|
if (stdin.isTTY === true) {
|
|
22646
22863
|
throw new KensoError({ code: "token_required", message: "--token-stdin reads the run token from a pipe, not a terminal.", exitCode: ExitCode.Usage, field: "token-stdin" });
|
|
22647
22864
|
}
|
|
22648
|
-
let
|
|
22865
|
+
let text5;
|
|
22649
22866
|
try {
|
|
22650
|
-
|
|
22867
|
+
text5 = await readStream(stdin, MAX_TOKEN_INPUT_BYTES);
|
|
22651
22868
|
} catch {
|
|
22652
22869
|
throw invalidToken("stdin holds more than one Kenso run token's worth of text.");
|
|
22653
22870
|
}
|
|
22654
|
-
const token = (
|
|
22871
|
+
const token = (text5.split(/\r?\n/)[0] ?? "").trim();
|
|
22655
22872
|
if (!RUN_TOKEN.test(token)) throw invalidToken("The first line of stdin is not a Kenso run token (krt_ and 43 characters).");
|
|
22656
22873
|
return token;
|
|
22657
22874
|
}
|
|
@@ -22843,12 +23060,12 @@ var init_stop = __esm({
|
|
|
22843
23060
|
});
|
|
22844
23061
|
|
|
22845
23062
|
// src/commands/work/run.ts
|
|
22846
|
-
var
|
|
22847
|
-
__export(
|
|
22848
|
-
default: () =>
|
|
23063
|
+
var run_exports4 = {};
|
|
23064
|
+
__export(run_exports4, {
|
|
23065
|
+
default: () => run_default3
|
|
22849
23066
|
});
|
|
22850
|
-
var FAILURES_IN_A_ROW,
|
|
22851
|
-
var
|
|
23067
|
+
var FAILURES_IN_A_ROW, command78, run_default3;
|
|
23068
|
+
var init_run4 = __esm({
|
|
22852
23069
|
"src/commands/work/run.ts"() {
|
|
22853
23070
|
"use strict";
|
|
22854
23071
|
init_errors();
|
|
@@ -22870,7 +23087,7 @@ var init_run3 = __esm({
|
|
|
22870
23087
|
init_run_flags();
|
|
22871
23088
|
init_stop();
|
|
22872
23089
|
FAILURES_IN_A_ROW = 3;
|
|
22873
|
-
|
|
23090
|
+
command78 = {
|
|
22874
23091
|
resource: "work",
|
|
22875
23092
|
action: "run",
|
|
22876
23093
|
summary: "Run your own coding agent on the waiting work until the queue is empty",
|
|
@@ -22930,10 +23147,10 @@ var init_run3 = __esm({
|
|
|
22930
23147
|
let message;
|
|
22931
23148
|
let next;
|
|
22932
23149
|
let error;
|
|
22933
|
-
const halt = (reason2,
|
|
23150
|
+
const halt = (reason2, why2) => {
|
|
22934
23151
|
if (stopped === void 0 || replaces(reason2, stopped)) {
|
|
22935
23152
|
stopped = reason2;
|
|
22936
|
-
message =
|
|
23153
|
+
message = why2;
|
|
22937
23154
|
}
|
|
22938
23155
|
quit.abort();
|
|
22939
23156
|
};
|
|
@@ -22961,8 +23178,8 @@ var init_run3 = __esm({
|
|
|
22961
23178
|
}
|
|
22962
23179
|
return pending;
|
|
22963
23180
|
};
|
|
22964
|
-
const abortRun = (reason2,
|
|
22965
|
-
halt(reason2,
|
|
23181
|
+
const abortRun = (reason2, why2) => {
|
|
23182
|
+
halt(reason2, why2);
|
|
22966
23183
|
stop.abort();
|
|
22967
23184
|
for (const [claimId, phase] of [...open2]) if (phase === "agent") void releaseOnce(claimId);
|
|
22968
23185
|
};
|
|
@@ -23185,21 +23402,21 @@ var init_run3 = __esm({
|
|
|
23185
23402
|
return exitCodeFor(reason, totals.rejected > 0 || jobsFailed > 0);
|
|
23186
23403
|
}
|
|
23187
23404
|
};
|
|
23188
|
-
|
|
23405
|
+
run_default3 = command78;
|
|
23189
23406
|
}
|
|
23190
23407
|
});
|
|
23191
23408
|
|
|
23192
23409
|
// src/commands/work/index.ts
|
|
23193
|
-
var
|
|
23410
|
+
var actions35;
|
|
23194
23411
|
var init_work2 = __esm({
|
|
23195
23412
|
"src/commands/work/index.ts"() {
|
|
23196
23413
|
"use strict";
|
|
23197
|
-
|
|
23414
|
+
actions35 = {
|
|
23198
23415
|
status: () => Promise.resolve().then(() => (init_status3(), status_exports3)).then((m) => m.default),
|
|
23199
23416
|
pull: () => Promise.resolve().then(() => (init_pull2(), pull_exports2)).then((m) => m.default),
|
|
23200
23417
|
submit: () => Promise.resolve().then(() => (init_submit(), submit_exports)).then((m) => m.default),
|
|
23201
23418
|
release: () => Promise.resolve().then(() => (init_release(), release_exports)).then((m) => m.default),
|
|
23202
|
-
run: () => Promise.resolve().then(() => (
|
|
23419
|
+
run: () => Promise.resolve().then(() => (init_run4(), run_exports4)).then((m) => m.default)
|
|
23203
23420
|
};
|
|
23204
23421
|
}
|
|
23205
23422
|
});
|
|
@@ -23212,16 +23429,16 @@ function shownPath(path) {
|
|
|
23212
23429
|
}
|
|
23213
23430
|
function readWorkflowFile(file) {
|
|
23214
23431
|
const path = resolve19(file);
|
|
23215
|
-
let
|
|
23432
|
+
let text5;
|
|
23216
23433
|
try {
|
|
23217
|
-
|
|
23434
|
+
text5 = readFileSync20(path, "utf8");
|
|
23218
23435
|
} catch (err) {
|
|
23219
23436
|
if (err.code !== "ENOENT") throw err;
|
|
23220
23437
|
throw new KensoError({ code: "file_not_found", message: `${file} does not exist.`, exitCode: ExitCode.Usage, field: "file" });
|
|
23221
23438
|
}
|
|
23222
23439
|
let parsed2;
|
|
23223
23440
|
try {
|
|
23224
|
-
parsed2 = JSON.parse(
|
|
23441
|
+
parsed2 = JSON.parse(text5);
|
|
23225
23442
|
} catch (err) {
|
|
23226
23443
|
throw new KensoError({ code: "invalid_workflow_file", message: `${file} is not valid JSON: ${err.message}.`, exitCode: ExitCode.Usage, field: "file" });
|
|
23227
23444
|
}
|
|
@@ -23357,8 +23574,8 @@ function runCredits(run) {
|
|
|
23357
23574
|
return void 0;
|
|
23358
23575
|
}
|
|
23359
23576
|
function stepErrorText(step) {
|
|
23360
|
-
const
|
|
23361
|
-
return
|
|
23577
|
+
const text5 = [step.errorClass, step.errorMessage].filter((part) => typeof part === "string" && part !== "").join(": ");
|
|
23578
|
+
return text5 === "" ? void 0 : text5;
|
|
23362
23579
|
}
|
|
23363
23580
|
async function readRun2(client, runId, signal) {
|
|
23364
23581
|
const res = await client.request({ method: "GET", path: `/v1/workflow-runs/${runId}`, signal });
|
|
@@ -23462,7 +23679,7 @@ function header(run) {
|
|
|
23462
23679
|
const record3 = run.recordType && run.recordType !== "none" ? `${run.recordType} ${run.recordId ?? "?"}` : "no record";
|
|
23463
23680
|
return `run ${run.id}: ${run.status ?? "unknown"}, workflow ${run.workflowId ?? "?"}, ${record3}, charged ${runCredits(run) ?? 0} credits`;
|
|
23464
23681
|
}
|
|
23465
|
-
var
|
|
23682
|
+
var command79, logs_default;
|
|
23466
23683
|
var init_logs2 = __esm({
|
|
23467
23684
|
"src/commands/workflow-runs/logs.ts"() {
|
|
23468
23685
|
"use strict";
|
|
@@ -23470,7 +23687,7 @@ var init_logs2 = __esm({
|
|
|
23470
23687
|
init_exit_codes();
|
|
23471
23688
|
init_files2();
|
|
23472
23689
|
init_run_wait();
|
|
23473
|
-
|
|
23690
|
+
command79 = {
|
|
23474
23691
|
resource: "workflow-runs",
|
|
23475
23692
|
action: "logs",
|
|
23476
23693
|
summary: "Print a workflow run's steps: status, attempt, time, credits and error",
|
|
@@ -23486,10 +23703,10 @@ var init_logs2 = __esm({
|
|
|
23486
23703
|
beta: { featureGates: WORKFLOWS_GATES },
|
|
23487
23704
|
operationIds: ["workflow-runs.get"],
|
|
23488
23705
|
async run(ctx, { flags, positionals }) {
|
|
23489
|
-
const
|
|
23490
|
-
const runId = Number(
|
|
23491
|
-
if (!/^\d+$/.test(
|
|
23492
|
-
throw usageError(`"${
|
|
23706
|
+
const text5 = (positionals[0] ?? "").trim();
|
|
23707
|
+
const runId = Number(text5);
|
|
23708
|
+
if (!/^\d+$/.test(text5) || !Number.isSafeInteger(runId) || runId < 1) {
|
|
23709
|
+
throw usageError(`"${text5}" is not a run id: a run id is a positive whole number.`, {
|
|
23493
23710
|
field: "runId",
|
|
23494
23711
|
next: "kenso workflow-runs list --workflow-id <workflowId>"
|
|
23495
23712
|
});
|
|
@@ -23516,16 +23733,16 @@ var init_logs2 = __esm({
|
|
|
23516
23733
|
return ExitCode.Ok;
|
|
23517
23734
|
}
|
|
23518
23735
|
};
|
|
23519
|
-
logs_default =
|
|
23736
|
+
logs_default = command79;
|
|
23520
23737
|
}
|
|
23521
23738
|
});
|
|
23522
23739
|
|
|
23523
23740
|
// src/commands/workflow-runs/index.ts
|
|
23524
|
-
var
|
|
23741
|
+
var actions36;
|
|
23525
23742
|
var init_workflow_runs = __esm({
|
|
23526
23743
|
"src/commands/workflow-runs/index.ts"() {
|
|
23527
23744
|
"use strict";
|
|
23528
|
-
|
|
23745
|
+
actions36 = {
|
|
23529
23746
|
logs: () => Promise.resolve().then(() => (init_logs2(), logs_exports)).then((m) => m.default)
|
|
23530
23747
|
};
|
|
23531
23748
|
}
|
|
@@ -23538,7 +23755,7 @@ __export(init_exports, {
|
|
|
23538
23755
|
});
|
|
23539
23756
|
import { existsSync as existsSync13 } from "node:fs";
|
|
23540
23757
|
import { join as join31, resolve as resolve20 } from "node:path";
|
|
23541
|
-
var STEM,
|
|
23758
|
+
var STEM, command80, init_default;
|
|
23542
23759
|
var init_init = __esm({
|
|
23543
23760
|
"src/commands/workflows/init.ts"() {
|
|
23544
23761
|
"use strict";
|
|
@@ -23548,7 +23765,7 @@ var init_init = __esm({
|
|
|
23548
23765
|
init_http();
|
|
23549
23766
|
init_files2();
|
|
23550
23767
|
STEM = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
23551
|
-
|
|
23768
|
+
command80 = {
|
|
23552
23769
|
resource: "workflows",
|
|
23553
23770
|
action: "init",
|
|
23554
23771
|
summary: "Start a workflow file in this folder",
|
|
@@ -23605,7 +23822,7 @@ var init_init = __esm({
|
|
|
23605
23822
|
return ExitCode.Ok;
|
|
23606
23823
|
}
|
|
23607
23824
|
};
|
|
23608
|
-
init_default =
|
|
23825
|
+
init_default = command80;
|
|
23609
23826
|
}
|
|
23610
23827
|
});
|
|
23611
23828
|
|
|
@@ -23618,7 +23835,7 @@ import { existsSync as existsSync14 } from "node:fs";
|
|
|
23618
23835
|
function slugOf(name) {
|
|
23619
23836
|
return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/, "");
|
|
23620
23837
|
}
|
|
23621
|
-
var
|
|
23838
|
+
var command81, pull_default3;
|
|
23622
23839
|
var init_pull3 = __esm({
|
|
23623
23840
|
"src/commands/workflows/pull.ts"() {
|
|
23624
23841
|
"use strict";
|
|
@@ -23626,7 +23843,7 @@ var init_pull3 = __esm({
|
|
|
23626
23843
|
init_exit_codes();
|
|
23627
23844
|
init_common4();
|
|
23628
23845
|
init_files2();
|
|
23629
|
-
|
|
23846
|
+
command81 = {
|
|
23630
23847
|
resource: "workflows",
|
|
23631
23848
|
action: "pull",
|
|
23632
23849
|
summary: "Write a workflow's definition to a file and bind it",
|
|
@@ -23685,7 +23902,7 @@ var init_pull3 = __esm({
|
|
|
23685
23902
|
return ExitCode.Ok;
|
|
23686
23903
|
}
|
|
23687
23904
|
};
|
|
23688
|
-
pull_default3 =
|
|
23905
|
+
pull_default3 = command81;
|
|
23689
23906
|
}
|
|
23690
23907
|
});
|
|
23691
23908
|
|
|
@@ -23718,7 +23935,7 @@ function perRecord(estimate2) {
|
|
|
23718
23935
|
const max = bulk ? totals.bulkMaxMillicredits : totals.maxMillicredits;
|
|
23719
23936
|
return typeof expected === "number" && typeof max === "number" ? { expectedCredits: expected / 1e3, maxCredits: max / 1e3 } : null;
|
|
23720
23937
|
}
|
|
23721
|
-
var FILE3,
|
|
23938
|
+
var FILE3, command82, check_default;
|
|
23722
23939
|
var init_check = __esm({
|
|
23723
23940
|
"src/commands/workflows/check.ts"() {
|
|
23724
23941
|
"use strict";
|
|
@@ -23729,7 +23946,7 @@ var init_check = __esm({
|
|
|
23729
23946
|
init_columns();
|
|
23730
23947
|
init_files2();
|
|
23731
23948
|
FILE3 = { name: "file", required: true, description: "The workflow file (<name>.workflow.json)" };
|
|
23732
|
-
|
|
23949
|
+
command82 = {
|
|
23733
23950
|
resource: "workflows",
|
|
23734
23951
|
action: "check",
|
|
23735
23952
|
summary: "Validate a workflow file on the server and print one record's credit estimate",
|
|
@@ -23770,7 +23987,7 @@ var init_check = __esm({
|
|
|
23770
23987
|
return valid ? ExitCode.Ok : ExitCode.Partial;
|
|
23771
23988
|
}
|
|
23772
23989
|
};
|
|
23773
|
-
check_default =
|
|
23990
|
+
check_default = command82;
|
|
23774
23991
|
}
|
|
23775
23992
|
});
|
|
23776
23993
|
|
|
@@ -23834,7 +24051,7 @@ function state(workflow, saved, published, extra = {}) {
|
|
|
23834
24051
|
...extra
|
|
23835
24052
|
};
|
|
23836
24053
|
}
|
|
23837
|
-
var
|
|
24054
|
+
var command83, push_default2;
|
|
23838
24055
|
var init_push2 = __esm({
|
|
23839
24056
|
"src/commands/workflows/push.ts"() {
|
|
23840
24057
|
"use strict";
|
|
@@ -23844,7 +24061,7 @@ var init_push2 = __esm({
|
|
|
23844
24061
|
init_columns();
|
|
23845
24062
|
init_check();
|
|
23846
24063
|
init_files2();
|
|
23847
|
-
|
|
24064
|
+
command83 = {
|
|
23848
24065
|
resource: "workflows",
|
|
23849
24066
|
action: "push",
|
|
23850
24067
|
summary: "Save a workflow file as the workflow's draft, and publish it with --publish",
|
|
@@ -23948,7 +24165,7 @@ var init_push2 = __esm({
|
|
|
23948
24165
|
return ExitCode.Ok;
|
|
23949
24166
|
}
|
|
23950
24167
|
};
|
|
23951
|
-
push_default2 =
|
|
24168
|
+
push_default2 = command83;
|
|
23952
24169
|
}
|
|
23953
24170
|
});
|
|
23954
24171
|
|
|
@@ -23981,7 +24198,7 @@ async function startTest(ctx, workflowId, body2) {
|
|
|
23981
24198
|
});
|
|
23982
24199
|
}
|
|
23983
24200
|
}
|
|
23984
|
-
var RECORD_TYPES2, MAX_WAIT_SECONDS,
|
|
24201
|
+
var RECORD_TYPES2, MAX_WAIT_SECONDS, command84, test_default;
|
|
23985
24202
|
var init_test = __esm({
|
|
23986
24203
|
"src/commands/workflows/test.ts"() {
|
|
23987
24204
|
"use strict";
|
|
@@ -23993,7 +24210,7 @@ var init_test = __esm({
|
|
|
23993
24210
|
init_files2();
|
|
23994
24211
|
RECORD_TYPES2 = ["account", "person", "lead", "place"];
|
|
23995
24212
|
MAX_WAIT_SECONDS = 50;
|
|
23996
|
-
|
|
24213
|
+
command84 = {
|
|
23997
24214
|
resource: "workflows",
|
|
23998
24215
|
action: "test",
|
|
23999
24216
|
summary: "Run the saved draft of a workflow file on one record and print the hash to publish with",
|
|
@@ -24049,7 +24266,7 @@ var init_test = __esm({
|
|
|
24049
24266
|
return passed ? ExitCode.Ok : ExitCode.Error;
|
|
24050
24267
|
}
|
|
24051
24268
|
};
|
|
24052
|
-
test_default =
|
|
24269
|
+
test_default = command84;
|
|
24053
24270
|
}
|
|
24054
24271
|
});
|
|
24055
24272
|
|
|
@@ -24083,7 +24300,7 @@ function diffDefinitions(from, to) {
|
|
|
24083
24300
|
stepsChanged: [...after.keys()].filter((id) => before.has(id) && differs(before.get(id), after.get(id)))
|
|
24084
24301
|
};
|
|
24085
24302
|
}
|
|
24086
|
-
var
|
|
24303
|
+
var command85, diff_default;
|
|
24087
24304
|
var init_diff = __esm({
|
|
24088
24305
|
"src/commands/workflows/diff.ts"() {
|
|
24089
24306
|
"use strict";
|
|
@@ -24092,7 +24309,7 @@ var init_diff = __esm({
|
|
|
24092
24309
|
init_columns();
|
|
24093
24310
|
init_check();
|
|
24094
24311
|
init_files2();
|
|
24095
|
-
|
|
24312
|
+
command85 = {
|
|
24096
24313
|
resource: "workflows",
|
|
24097
24314
|
action: "diff",
|
|
24098
24315
|
summary: "Compare a workflow file with the published version or the draft",
|
|
@@ -24120,7 +24337,7 @@ var init_diff = __esm({
|
|
|
24120
24337
|
return ExitCode.Ok;
|
|
24121
24338
|
}
|
|
24122
24339
|
};
|
|
24123
|
-
diff_default =
|
|
24340
|
+
diff_default = command85;
|
|
24124
24341
|
}
|
|
24125
24342
|
});
|
|
24126
24343
|
|
|
@@ -24204,7 +24421,7 @@ function workflowFileSchema(stepTypes) {
|
|
|
24204
24421
|
}
|
|
24205
24422
|
};
|
|
24206
24423
|
}
|
|
24207
|
-
var SCHEMA_ID, STEP_ID, MORE_THAN_ZERO,
|
|
24424
|
+
var SCHEMA_ID, STEP_ID, MORE_THAN_ZERO, command86, schema_default;
|
|
24208
24425
|
var init_schema = __esm({
|
|
24209
24426
|
"src/commands/workflows/schema.ts"() {
|
|
24210
24427
|
"use strict";
|
|
@@ -24215,7 +24432,7 @@ var init_schema = __esm({
|
|
|
24215
24432
|
SCHEMA_ID = "https://ken.so/schemas/workflow-file.json";
|
|
24216
24433
|
STEP_ID = "^[a-z][a-z0-9_]{0,39}$";
|
|
24217
24434
|
MORE_THAN_ZERO = { type: "number", exclusiveMinimum: 0 };
|
|
24218
|
-
|
|
24435
|
+
command86 = {
|
|
24219
24436
|
resource: "workflows",
|
|
24220
24437
|
action: "schema",
|
|
24221
24438
|
summary: "Print a JSON Schema for workflow files, for editors",
|
|
@@ -24226,22 +24443,22 @@ var init_schema = __esm({
|
|
|
24226
24443
|
beta: { featureGates: WORKFLOWS_GATES },
|
|
24227
24444
|
async run(ctx, args) {
|
|
24228
24445
|
const stepTypes = loadStepTypes();
|
|
24229
|
-
const
|
|
24446
|
+
const text5 = `${JSON.stringify(workflowFileSchema(stepTypes), null, 2)}
|
|
24230
24447
|
`;
|
|
24231
24448
|
const out = stringFlag(args.flags.out);
|
|
24232
24449
|
if (out === void 0) {
|
|
24233
|
-
ctx.output.writeRaw(
|
|
24450
|
+
ctx.output.writeRaw(text5);
|
|
24234
24451
|
return ExitCode.Ok;
|
|
24235
24452
|
}
|
|
24236
24453
|
if (existsSync15(out) && !isOwnSchema(out)) {
|
|
24237
24454
|
throw fileExists(out, "It is not a schema this command wrote: pick another --out path, or remove the file.");
|
|
24238
24455
|
}
|
|
24239
|
-
writeFileSync12(out,
|
|
24456
|
+
writeFileSync12(out, text5);
|
|
24240
24457
|
ctx.output.object({ file: out, stepTypes: stepTypes.filter((t) => t.systemOnly !== true).length });
|
|
24241
24458
|
return ExitCode.Ok;
|
|
24242
24459
|
}
|
|
24243
24460
|
};
|
|
24244
|
-
schema_default =
|
|
24461
|
+
schema_default = command86;
|
|
24245
24462
|
}
|
|
24246
24463
|
});
|
|
24247
24464
|
|
|
@@ -24329,9 +24546,9 @@ function fromIds(ctx, raw, type) {
|
|
|
24329
24546
|
async function readRunInput(ctx, opts) {
|
|
24330
24547
|
const type = opts.recordType;
|
|
24331
24548
|
if (opts.ids === "-") {
|
|
24332
|
-
const
|
|
24333
|
-
const ids2 = await readIds("-", { stdin: Readable2.from([
|
|
24334
|
-
return { input: { path: "-", sha256: createHash12("sha256").update(
|
|
24549
|
+
const text5 = await readStream(ctx.stdin ?? process.stdin);
|
|
24550
|
+
const ids2 = await readIds("-", { stdin: Readable2.from([text5]) });
|
|
24551
|
+
return { input: { path: "-", sha256: createHash12("sha256").update(text5).digest("hex") }, ...fromIds(ctx, ids2, type) };
|
|
24335
24552
|
}
|
|
24336
24553
|
if (opts.ids !== void 0) {
|
|
24337
24554
|
return { input: { path: resolve21(opts.ids), sha256: await fileSha256(opts.ids) }, ...fromIds(ctx, await readIds(opts.ids), type) };
|
|
@@ -24700,13 +24917,13 @@ function isDataStepCheck() {
|
|
|
24700
24917
|
}
|
|
24701
24918
|
return (stepType) => dataTypes.has(stepType) || stepType.startsWith("data.");
|
|
24702
24919
|
}
|
|
24703
|
-
function waitedCounts(
|
|
24920
|
+
function waitedCounts(table2) {
|
|
24704
24921
|
let succeeded = 0;
|
|
24705
24922
|
let runsFailed = 0;
|
|
24706
24923
|
let waiting = 0;
|
|
24707
24924
|
let charged = 0;
|
|
24708
24925
|
const missed = {};
|
|
24709
|
-
for (const row of
|
|
24926
|
+
for (const row of table2) {
|
|
24710
24927
|
if (row.missReason) missed[row.missReason] = (missed[row.missReason] ?? 0) + 1;
|
|
24711
24928
|
if (!isOwnRun(row)) continue;
|
|
24712
24929
|
if (row.runStatus === "succeeded") succeeded++;
|
|
@@ -24738,20 +24955,20 @@ async function finishRun(ctx, input) {
|
|
|
24738
24955
|
interrupted7 = waited.interrupted;
|
|
24739
24956
|
if (waited.stopped) ctx.output.warn(`Stopped reading the runs (${waited.stopped}). They keep going: kenso workflow-runs list --workflow-id ${workflowId}`);
|
|
24740
24957
|
}
|
|
24741
|
-
const
|
|
24958
|
+
const table2 = outRows(rows, runs, isDataStepCheck());
|
|
24742
24959
|
if (flags.out) {
|
|
24743
|
-
const
|
|
24744
|
-
await writeFileAtomic(flags.out,
|
|
24745
|
-
await writeJsonAtomic(join33(outcome.dir, OUT_MARKER), { path: flags.out, sha256: sha2565(
|
|
24960
|
+
const text5 = outCsv(table2);
|
|
24961
|
+
await writeFileAtomic(flags.out, text5);
|
|
24962
|
+
await writeJsonAtomic(join33(outcome.dir, OUT_MARKER), { path: flags.out, sha256: sha2565(text5) });
|
|
24746
24963
|
summary.resultsCsv = flags.out;
|
|
24747
24964
|
}
|
|
24748
|
-
const counts2 = waitedCounts(
|
|
24965
|
+
const counts2 = waitedCounts(table2);
|
|
24749
24966
|
summary.succeeded = counts2.succeeded;
|
|
24750
24967
|
summary.failed = Number(engineSummary.failed ?? 0) + counts2.runsFailed;
|
|
24751
24968
|
summary.waiting = counts2.waiting;
|
|
24752
24969
|
summary.missed = counts2.missed;
|
|
24753
24970
|
summary.creditsCharged = counts2.creditsCharged;
|
|
24754
|
-
const firstFailed =
|
|
24971
|
+
const firstFailed = table2.find((row) => isOwnRun(row) && row.runStatus !== void 0 && ENDED_UNSUCCESSFUL.has(row.runStatus));
|
|
24755
24972
|
if (!engineStopped && firstFailed?.runId !== void 0) summary.next = `kenso workflow-runs logs ${firstFailed.runId}`;
|
|
24756
24973
|
waitedLine = `; ${counts2.succeeded} succeeded, ${counts2.waiting} waiting, ${String(counts2.creditsCharged)} credits charged`;
|
|
24757
24974
|
}
|
|
@@ -24817,9 +25034,9 @@ var init_run_results = __esm({
|
|
|
24817
25034
|
});
|
|
24818
25035
|
|
|
24819
25036
|
// src/commands/workflows/run.ts
|
|
24820
|
-
var
|
|
24821
|
-
__export(
|
|
24822
|
-
default: () =>
|
|
25037
|
+
var run_exports5 = {};
|
|
25038
|
+
__export(run_exports5, {
|
|
25039
|
+
default: () => run_default4
|
|
24823
25040
|
});
|
|
24824
25041
|
import { join as join34 } from "node:path";
|
|
24825
25042
|
async function resolveTarget(ctx, target2) {
|
|
@@ -24897,8 +25114,8 @@ function appUrl(workflowId, workspaceId) {
|
|
|
24897
25114
|
function summarize4(workflowId, records, cap, url) {
|
|
24898
25115
|
return (results) => ({ workflowId, records, ...startKeys(results, workflowId), cap: cap(), appUrl: url });
|
|
24899
25116
|
}
|
|
24900
|
-
var NAME2, CHUNK_SIZE7, APP_URL, LIST_HINT,
|
|
24901
|
-
var
|
|
25117
|
+
var NAME2, CHUNK_SIZE7, APP_URL, LIST_HINT, command87, run_default4;
|
|
25118
|
+
var init_run5 = __esm({
|
|
24902
25119
|
"src/commands/workflows/run.ts"() {
|
|
24903
25120
|
"use strict";
|
|
24904
25121
|
init_engine();
|
|
@@ -24919,7 +25136,7 @@ var init_run4 = __esm({
|
|
|
24919
25136
|
CHUNK_SIZE7 = 1e3;
|
|
24920
25137
|
APP_URL = "https://app.ken.so";
|
|
24921
25138
|
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.";
|
|
24922
|
-
|
|
25139
|
+
command87 = {
|
|
24923
25140
|
resource: "workflows",
|
|
24924
25141
|
action: "run",
|
|
24925
25142
|
summary: "Run a published workflow on records from an ids file or a CSV",
|
|
@@ -25053,7 +25270,7 @@ var init_run4 = __esm({
|
|
|
25053
25270
|
return finishRun(ctx, { outcome, engineSummary: hold.held(), workflowId, flags: results });
|
|
25054
25271
|
}
|
|
25055
25272
|
};
|
|
25056
|
-
|
|
25273
|
+
run_default4 = command87;
|
|
25057
25274
|
}
|
|
25058
25275
|
});
|
|
25059
25276
|
|
|
@@ -25063,19 +25280,19 @@ var init_run_actions = __esm({
|
|
|
25063
25280
|
"src/commands/workflows/run-actions.ts"() {
|
|
25064
25281
|
"use strict";
|
|
25065
25282
|
runActions = {
|
|
25066
|
-
run: () => Promise.resolve().then(() => (
|
|
25283
|
+
run: () => Promise.resolve().then(() => (init_run5(), run_exports5)).then((m) => m.default)
|
|
25067
25284
|
};
|
|
25068
25285
|
}
|
|
25069
25286
|
});
|
|
25070
25287
|
|
|
25071
25288
|
// src/commands/workflows/index.ts
|
|
25072
|
-
var
|
|
25289
|
+
var actions37;
|
|
25073
25290
|
var init_workflows2 = __esm({
|
|
25074
25291
|
"src/commands/workflows/index.ts"() {
|
|
25075
25292
|
"use strict";
|
|
25076
25293
|
init_file_actions();
|
|
25077
25294
|
init_run_actions();
|
|
25078
|
-
|
|
25295
|
+
actions37 = { ...fileActions, ...runActions };
|
|
25079
25296
|
}
|
|
25080
25297
|
});
|
|
25081
25298
|
|
|
@@ -25100,7 +25317,7 @@ function rewrap(err, overrides2) {
|
|
|
25100
25317
|
details: err.details
|
|
25101
25318
|
});
|
|
25102
25319
|
}
|
|
25103
|
-
var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE,
|
|
25320
|
+
var TEMPLATES, APP_NEXT_STEP, NOT_AVAILABLE, command88, keys_default;
|
|
25104
25321
|
var init_keys = __esm({
|
|
25105
25322
|
"src/commands/workspace/keys.ts"() {
|
|
25106
25323
|
"use strict";
|
|
@@ -25110,7 +25327,7 @@ var init_keys = __esm({
|
|
|
25110
25327
|
TEMPLATES = ["admin", "editor", "viewer"];
|
|
25111
25328
|
APP_NEXT_STEP = "A workspace admin can create it in the app: Settings > API keys > Workspace keys";
|
|
25112
25329
|
NOT_AVAILABLE = "Workspace keys are not available for this workspace yet.";
|
|
25113
|
-
|
|
25330
|
+
command88 = {
|
|
25114
25331
|
resource: "workspace",
|
|
25115
25332
|
action: "keys",
|
|
25116
25333
|
summary: "Create an API key the workspace owns",
|
|
@@ -25137,11 +25354,11 @@ var init_keys = __esm({
|
|
|
25137
25354
|
const rawDays = flags["expires-in-days"];
|
|
25138
25355
|
let expiresInDays;
|
|
25139
25356
|
if (rawDays !== void 0) {
|
|
25140
|
-
const
|
|
25141
|
-
if (!/^[1-9]\d*$/.test(
|
|
25142
|
-
throw usage(`--expires-in-days must be a positive whole number, not "${
|
|
25357
|
+
const text5 = String(rawDays).trim();
|
|
25358
|
+
if (!/^[1-9]\d*$/.test(text5)) {
|
|
25359
|
+
throw usage(`--expires-in-days must be a positive whole number, not "${text5}".`, "expires-in-days");
|
|
25143
25360
|
}
|
|
25144
|
-
expiresInDays = Number(
|
|
25361
|
+
expiresInDays = Number(text5);
|
|
25145
25362
|
}
|
|
25146
25363
|
const request = { name: String(flags.name ?? "").trim(), template: template2, ...expiresInDays === void 0 ? {} : { expiresInDays } };
|
|
25147
25364
|
let body2;
|
|
@@ -25172,7 +25389,7 @@ var init_keys = __esm({
|
|
|
25172
25389
|
return ExitCode.Ok;
|
|
25173
25390
|
}
|
|
25174
25391
|
};
|
|
25175
|
-
keys_default =
|
|
25392
|
+
keys_default = command88;
|
|
25176
25393
|
}
|
|
25177
25394
|
});
|
|
25178
25395
|
|
|
@@ -25183,21 +25400,21 @@ __export(list_exports5, {
|
|
|
25183
25400
|
});
|
|
25184
25401
|
function parseLimit2(value) {
|
|
25185
25402
|
if (value === void 0) return void 0;
|
|
25186
|
-
const
|
|
25187
|
-
const limit = Number(
|
|
25188
|
-
if (!/^\d+$/.test(
|
|
25403
|
+
const text5 = String(value).trim();
|
|
25404
|
+
const limit = Number(text5);
|
|
25405
|
+
if (!/^\d+$/.test(text5) || limit < 1 || limit > MAX_LIMIT2) {
|
|
25189
25406
|
throw usageError(`--limit must be a whole number from 1 to ${MAX_LIMIT2}.`, { field: "limit" });
|
|
25190
25407
|
}
|
|
25191
25408
|
return limit;
|
|
25192
25409
|
}
|
|
25193
|
-
var MAX_LIMIT2,
|
|
25410
|
+
var MAX_LIMIT2, command89, list_default5;
|
|
25194
25411
|
var init_list5 = __esm({
|
|
25195
25412
|
"src/commands/workspace/list.ts"() {
|
|
25196
25413
|
"use strict";
|
|
25197
25414
|
init_errors();
|
|
25198
25415
|
init_exit_codes();
|
|
25199
25416
|
MAX_LIMIT2 = 200;
|
|
25200
|
-
|
|
25417
|
+
command89 = {
|
|
25201
25418
|
resource: "workspace",
|
|
25202
25419
|
action: "list",
|
|
25203
25420
|
summary: "List the workspaces your key can use",
|
|
@@ -25226,7 +25443,7 @@ var init_list5 = __esm({
|
|
|
25226
25443
|
return ExitCode.Ok;
|
|
25227
25444
|
}
|
|
25228
25445
|
};
|
|
25229
|
-
list_default5 =
|
|
25446
|
+
list_default5 = command89;
|
|
25230
25447
|
}
|
|
25231
25448
|
});
|
|
25232
25449
|
|
|
@@ -25235,7 +25452,7 @@ var use_exports = {};
|
|
|
25235
25452
|
__export(use_exports, {
|
|
25236
25453
|
default: () => use_default
|
|
25237
25454
|
});
|
|
25238
|
-
var
|
|
25455
|
+
var command90, use_default;
|
|
25239
25456
|
var init_use = __esm({
|
|
25240
25457
|
"src/commands/workspace/use.ts"() {
|
|
25241
25458
|
"use strict";
|
|
@@ -25243,7 +25460,7 @@ var init_use = __esm({
|
|
|
25243
25460
|
init_errors();
|
|
25244
25461
|
init_exit_codes();
|
|
25245
25462
|
init_http();
|
|
25246
|
-
|
|
25463
|
+
command90 = {
|
|
25247
25464
|
resource: "workspace",
|
|
25248
25465
|
action: "use",
|
|
25249
25466
|
summary: "Set the profile's default workspace",
|
|
@@ -25305,16 +25522,16 @@ var init_use = __esm({
|
|
|
25305
25522
|
return ExitCode.Ok;
|
|
25306
25523
|
}
|
|
25307
25524
|
};
|
|
25308
|
-
use_default =
|
|
25525
|
+
use_default = command90;
|
|
25309
25526
|
}
|
|
25310
25527
|
});
|
|
25311
25528
|
|
|
25312
25529
|
// src/commands/workspace/index.ts
|
|
25313
|
-
var
|
|
25530
|
+
var actions38;
|
|
25314
25531
|
var init_workspace = __esm({
|
|
25315
25532
|
"src/commands/workspace/index.ts"() {
|
|
25316
25533
|
"use strict";
|
|
25317
|
-
|
|
25534
|
+
actions38 = {
|
|
25318
25535
|
keys: () => Promise.resolve().then(() => (init_keys(), keys_exports)).then((m) => m.default),
|
|
25319
25536
|
list: () => Promise.resolve().then(() => (init_list5(), list_exports5)).then((m) => m.default),
|
|
25320
25537
|
use: () => Promise.resolve().then(() => (init_use(), use_exports)).then((m) => m.default)
|
|
@@ -25378,6 +25595,7 @@ var init_registry = __esm({
|
|
|
25378
25595
|
init_runs2();
|
|
25379
25596
|
init_sandbox2();
|
|
25380
25597
|
init_signals();
|
|
25598
|
+
init_simulations();
|
|
25381
25599
|
init_skill();
|
|
25382
25600
|
init_studio2();
|
|
25383
25601
|
init_tasks();
|
|
@@ -25418,16 +25636,17 @@ var init_registry = __esm({
|
|
|
25418
25636
|
runs: actions26,
|
|
25419
25637
|
sandbox: actions27,
|
|
25420
25638
|
signals: actions28,
|
|
25421
|
-
|
|
25422
|
-
|
|
25423
|
-
|
|
25424
|
-
|
|
25425
|
-
|
|
25639
|
+
simulations: actions29,
|
|
25640
|
+
skill: actions30,
|
|
25641
|
+
studio: actions31,
|
|
25642
|
+
tasks: actions32,
|
|
25643
|
+
views: actions33,
|
|
25644
|
+
webhooks: actions34,
|
|
25426
25645
|
whoami: topLevel("whoami", actions4.status, "kenso auth status"),
|
|
25427
|
-
work:
|
|
25428
|
-
"workflow-runs":
|
|
25429
|
-
workflows:
|
|
25430
|
-
workspace:
|
|
25646
|
+
work: actions35,
|
|
25647
|
+
"workflow-runs": actions36,
|
|
25648
|
+
workflows: actions37,
|
|
25649
|
+
workspace: actions38
|
|
25431
25650
|
};
|
|
25432
25651
|
resourceAliases = { leads: "contacts" };
|
|
25433
25652
|
}
|
|
@@ -25468,10 +25687,10 @@ async function visibleSpecs(specs, opts, getFeatures, hidden) {
|
|
|
25468
25687
|
}
|
|
25469
25688
|
return visible;
|
|
25470
25689
|
}
|
|
25471
|
-
function wrap(
|
|
25690
|
+
function wrap(text5, indent) {
|
|
25472
25691
|
const out = [];
|
|
25473
25692
|
let line = "";
|
|
25474
|
-
for (const word of
|
|
25693
|
+
for (const word of text5.split(" ")) {
|
|
25475
25694
|
if (line && indent.length + line.length + 1 + word.length > 110) {
|
|
25476
25695
|
out.push(indent + line);
|
|
25477
25696
|
line = word;
|
|
@@ -25557,8 +25776,8 @@ async function renderTopHelp(opts) {
|
|
|
25557
25776
|
names.push(withPositionals(spec, spec.action));
|
|
25558
25777
|
groups.set(hint, names);
|
|
25559
25778
|
}
|
|
25560
|
-
const
|
|
25561
|
-
if (
|
|
25779
|
+
const actions40 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
|
|
25780
|
+
if (actions40.length > 0) rows.push([resource, actions40.join(", ")]);
|
|
25562
25781
|
}
|
|
25563
25782
|
const at = 4 + Math.min(22, Math.max(0, ...rows.map(([left]) => left.length)));
|
|
25564
25783
|
lines.push(
|
|
@@ -25571,7 +25790,7 @@ async function renderTopHelp(opts) {
|
|
|
25571
25790
|
const [area = "", action = ""] = name.split(" ");
|
|
25572
25791
|
byArea.set(area, [...byArea.get(area) ?? [], action]);
|
|
25573
25792
|
}
|
|
25574
|
-
const named = [...byArea.entries()].map(([area,
|
|
25793
|
+
const named = [...byArea.entries()].map(([area, actions40]) => `${area} ${actions40.join("|")}`);
|
|
25575
25794
|
lines.push(wrap(`Beta, hidden here but they run (the server decides): ${named.join(", ")}.`, " "));
|
|
25576
25795
|
}
|
|
25577
25796
|
const generated = await listGenerated({ features: opts.allCommands ? [] : getFeatures, env: opts.env });
|
|
@@ -25579,13 +25798,13 @@ async function renderTopHelp(opts) {
|
|
|
25579
25798
|
if (visible.length > 0) {
|
|
25580
25799
|
const byResource = /* @__PURE__ */ new Map();
|
|
25581
25800
|
for (const g of visible) {
|
|
25582
|
-
const
|
|
25583
|
-
|
|
25584
|
-
byResource.set(g.resource,
|
|
25801
|
+
const actions40 = byResource.get(g.resource) ?? [];
|
|
25802
|
+
actions40.push(`${g.action}${g.beta ? " (beta)" : ""}`);
|
|
25803
|
+
byResource.set(g.resource, actions40);
|
|
25585
25804
|
}
|
|
25586
25805
|
const sorted2 = [...byResource.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
25587
25806
|
if (opts.allCommands) {
|
|
25588
|
-
const generatedRows = sorted2.map(([resource,
|
|
25807
|
+
const generatedRows = sorted2.map(([resource, actions40]) => [resource, actions40.sort().join(", ")]);
|
|
25589
25808
|
lines.push("", "API resources (kenso <resource> <action>):", columns(generatedRows));
|
|
25590
25809
|
} else {
|
|
25591
25810
|
const names = new Set(sorted2.map(([resource]) => resource));
|
|
@@ -25990,8 +26209,8 @@ function agentNotice(env, agent, version, stderr, opts) {
|
|
|
25990
26209
|
return async () => {
|
|
25991
26210
|
try {
|
|
25992
26211
|
if (!firstInSession(env, agent, "update")) return;
|
|
25993
|
-
const
|
|
25994
|
-
stderr.write(`kenso ${latest} is out (you have ${version}): ${
|
|
26212
|
+
const command91 = updateCommand(opts.install ?? installKind(), opts.platform ?? process.platform);
|
|
26213
|
+
stderr.write(`kenso ${latest} is out (you have ${version}): ${command91}
|
|
25995
26214
|
`);
|
|
25996
26215
|
} catch {
|
|
25997
26216
|
}
|
|
@@ -26026,8 +26245,8 @@ function startUpdateNotice(argv, opts = {}) {
|
|
|
26026
26245
|
if (!found) return;
|
|
26027
26246
|
writeCheck(file, { checkedAt: new Date(now).toISOString(), latest: found });
|
|
26028
26247
|
if (isNewer(found, version)) {
|
|
26029
|
-
const
|
|
26030
|
-
stderr.write(`kenso ${found} is out (you have ${version}): ${
|
|
26248
|
+
const command91 = updateCommand(install, opts.platform ?? process.platform);
|
|
26249
|
+
stderr.write(`kenso ${found} is out (you have ${version}): ${command91}
|
|
26031
26250
|
Turn this off with KENSO_NO_UPDATE_NOTIFIER=1.
|
|
26032
26251
|
`);
|
|
26033
26252
|
}
|
|
@@ -26070,7 +26289,7 @@ function resources() {
|
|
|
26070
26289
|
const names = Object.entries(handWritten).filter(([, area]) => Object.keys(area).length > 0).map(([resource]) => resource);
|
|
26071
26290
|
return sorted([...names, ...Object.keys(resourceAliases), ...listOperations().map((op) => op.resource)]);
|
|
26072
26291
|
}
|
|
26073
|
-
function
|
|
26292
|
+
function actions39(resource) {
|
|
26074
26293
|
const own = Object.keys(handWritten[resource] ?? {}).filter((action) => action !== "");
|
|
26075
26294
|
return sorted([...own, ...listOperations().filter((op) => op.resource === resource).map((op) => op.action)]);
|
|
26076
26295
|
}
|
|
@@ -26135,7 +26354,7 @@ async function completions(words2, globals) {
|
|
|
26135
26354
|
return flagsOf2(spec, globals, positionals.length === 0);
|
|
26136
26355
|
}
|
|
26137
26356
|
if (positionals.length === 0) return resources();
|
|
26138
|
-
if (!spec) return positionals.length === 1 ?
|
|
26357
|
+
if (!spec) return positionals.length === 1 ? actions39(resourceAliases[positionals[0]] ?? positionals[0]) : [];
|
|
26139
26358
|
const given = positionals.length - commandWords2;
|
|
26140
26359
|
const declared = spec.positionals ?? [];
|
|
26141
26360
|
if (given < declared.length || declared.at(-1)?.variadic === true) {
|
|
@@ -26201,9 +26420,9 @@ function leaveRun(active) {
|
|
|
26201
26420
|
async function knownCommands() {
|
|
26202
26421
|
const commands = /* @__PURE__ */ new Set();
|
|
26203
26422
|
for (const [resource, area] of Object.entries(handWritten)) {
|
|
26204
|
-
const
|
|
26205
|
-
if (
|
|
26206
|
-
for (const action of
|
|
26423
|
+
const actions40 = Object.keys(area);
|
|
26424
|
+
if (actions40.length > 0) commands.add(resource);
|
|
26425
|
+
for (const action of actions40) commands.add(action ? `${resource} ${action}` : resource);
|
|
26207
26426
|
}
|
|
26208
26427
|
for (const g of await listGenerated({ features: [] })) {
|
|
26209
26428
|
commands.add(g.resource);
|
|
@@ -26371,8 +26590,8 @@ async function main(argv, env = process.env, overrides2 = {}) {
|
|
|
26371
26590
|
return ExitCode.Ok;
|
|
26372
26591
|
}
|
|
26373
26592
|
verbose = loose.values.verbose === true;
|
|
26374
|
-
const
|
|
26375
|
-
const lookupFlags = { profile:
|
|
26593
|
+
const text5 = (value) => typeof value === "string" ? value : void 0;
|
|
26594
|
+
const lookupFlags = { profile: text5(loose.values.profile), workspace: text5(loose.values.workspace) };
|
|
26376
26595
|
const lookupOverrides = { fetchImpl: overrides2.fetchImpl, sleep: overrides2.sleep, signal: controller.signal };
|
|
26377
26596
|
const helpOptions = {
|
|
26378
26597
|
agent,
|