kenso 0.1.205 → 0.1.207
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/discover.json +1 -1
- package/dist/kenso.js +115 -53
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/docs/reference.md +1 -1
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -247,6 +247,7 @@ var init_api_key = __esm({
|
|
|
247
247
|
});
|
|
248
248
|
|
|
249
249
|
// src/core/folder.ts
|
|
250
|
+
import { randomBytes } from "node:crypto";
|
|
250
251
|
import { existsSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
251
252
|
import { homedir } from "node:os";
|
|
252
253
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -361,10 +362,10 @@ function writeFolderFile(file) {
|
|
|
361
362
|
if (file.profile) out.profile = file.profile;
|
|
362
363
|
else delete out.profile;
|
|
363
364
|
out.workflows = file.workflows;
|
|
364
|
-
const temp = join(dirname(file.path), `.${FOLDER_FILE}.${process.pid}.${
|
|
365
|
+
const temp = join(dirname(file.path), `.${FOLDER_FILE}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`);
|
|
365
366
|
try {
|
|
366
367
|
writeFileSync(temp, `${JSON.stringify(out, null, 2)}
|
|
367
|
-
|
|
368
|
+
`, { flag: "wx" });
|
|
368
369
|
renameSync(temp, file.path);
|
|
369
370
|
} catch (err) {
|
|
370
371
|
try {
|
|
@@ -3539,7 +3540,7 @@ var VERSION;
|
|
|
3539
3540
|
var init_version = __esm({
|
|
3540
3541
|
"src/core/version.ts"() {
|
|
3541
3542
|
"use strict";
|
|
3542
|
-
VERSION = true ? "0.1.
|
|
3543
|
+
VERSION = true ? "0.1.207" : "0.0.0-dev";
|
|
3543
3544
|
}
|
|
3544
3545
|
});
|
|
3545
3546
|
|
|
@@ -4809,7 +4810,7 @@ var init_results = __esm({
|
|
|
4809
4810
|
});
|
|
4810
4811
|
|
|
4811
4812
|
// src/batch/runs.ts
|
|
4812
|
-
import { randomBytes } from "node:crypto";
|
|
4813
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
4813
4814
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync2, statSync as statSync2 } from "node:fs";
|
|
4814
4815
|
import { open, readdir, realpath, rename, stat, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
4815
4816
|
import { join as join7, resolve as resolve3 } from "node:path";
|
|
@@ -4818,7 +4819,7 @@ function runsRoot(env = process.env) {
|
|
|
4818
4819
|
return resolve3(override2 ? override2 : join7(configDir(env), "runs"));
|
|
4819
4820
|
}
|
|
4820
4821
|
function newRunId() {
|
|
4821
|
-
const bytes =
|
|
4822
|
+
const bytes = randomBytes2(5);
|
|
4822
4823
|
let bits = 0;
|
|
4823
4824
|
let value = 0;
|
|
4824
4825
|
let id = "";
|
|
@@ -4907,7 +4908,7 @@ function ensurePrivateDir2(dir3) {
|
|
|
4907
4908
|
ensureDir(dir3, 448);
|
|
4908
4909
|
}
|
|
4909
4910
|
async function writeFileAtomic(path, content) {
|
|
4910
|
-
const temp = `${path}.${process.pid}.${
|
|
4911
|
+
const temp = `${path}.${process.pid}.${randomBytes2(4).toString("hex")}.tmp`;
|
|
4911
4912
|
try {
|
|
4912
4913
|
await writeFile2(temp, content, { mode: 384 });
|
|
4913
4914
|
await rename(temp, path);
|
|
@@ -10428,7 +10429,8 @@ __export(install_exports, {
|
|
|
10428
10429
|
readExisting: () => readExisting,
|
|
10429
10430
|
write: () => write
|
|
10430
10431
|
});
|
|
10431
|
-
import {
|
|
10432
|
+
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
10433
|
+
import { closeSync as closeSync2, existsSync as existsSync5, fchmodSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync12, renameSync as renameSync6, rmSync as rmSync3, statSync as statSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
10432
10434
|
import { basename as basename2, dirname as dirname2, join as join14, resolve as resolve7 } from "node:path";
|
|
10433
10435
|
function quote(value) {
|
|
10434
10436
|
return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
@@ -10442,13 +10444,35 @@ function readExisting(path) {
|
|
|
10442
10444
|
throw new KensoError({ code: "file_unreadable", message: `Cannot read ${path}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Usage });
|
|
10443
10445
|
}
|
|
10444
10446
|
}
|
|
10445
|
-
function
|
|
10447
|
+
function currentMode(path) {
|
|
10448
|
+
if (process.platform === "win32") return void 0;
|
|
10449
|
+
try {
|
|
10450
|
+
return statSync3(path).mode & 511;
|
|
10451
|
+
} catch {
|
|
10452
|
+
return void 0;
|
|
10453
|
+
}
|
|
10454
|
+
}
|
|
10455
|
+
function write(path, text5, opts = {}) {
|
|
10456
|
+
let temp;
|
|
10446
10457
|
try {
|
|
10447
|
-
mkdirSync4(dirname2(path), { recursive: true });
|
|
10448
|
-
const
|
|
10449
|
-
|
|
10458
|
+
mkdirSync4(dirname2(path), opts.dirMode === void 0 ? { recursive: true } : { recursive: true, mode: opts.dirMode });
|
|
10459
|
+
const keep = currentMode(path);
|
|
10460
|
+
const name = `${path}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`;
|
|
10461
|
+
const fd = openSync2(name, "wx", keep ?? opts.mode ?? 438);
|
|
10462
|
+
temp = name;
|
|
10463
|
+
try {
|
|
10464
|
+
if (keep !== void 0) fchmodSync(fd, keep);
|
|
10465
|
+
writeFileSync6(fd, text5);
|
|
10466
|
+
} finally {
|
|
10467
|
+
closeSync2(fd);
|
|
10468
|
+
}
|
|
10450
10469
|
renameSync6(temp, path);
|
|
10470
|
+
temp = void 0;
|
|
10451
10471
|
} catch (err) {
|
|
10472
|
+
try {
|
|
10473
|
+
if (temp !== void 0) rmSync3(temp, { force: true });
|
|
10474
|
+
} catch {
|
|
10475
|
+
}
|
|
10452
10476
|
const code = err.code;
|
|
10453
10477
|
throw new KensoError({ code: "file_unwritable", message: `Cannot write ${path}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Error });
|
|
10454
10478
|
}
|
|
@@ -10531,7 +10555,7 @@ var init_install = __esm({
|
|
|
10531
10555
|
return ExitCode.Ok;
|
|
10532
10556
|
}
|
|
10533
10557
|
for (const target2 of targets) {
|
|
10534
|
-
if (WRITES.has(target2.status)) write(target2.path, texts.get(target2.name));
|
|
10558
|
+
if (WRITES.has(target2.status)) write(target2.path, texts.get(target2.name), dir3 === void 0 ? { dirMode: 448 } : {});
|
|
10535
10559
|
}
|
|
10536
10560
|
if (dir3 !== void 0 && basename2(resolve7(dir3)) !== names[0]) {
|
|
10537
10561
|
ctx.output.warn(`Agents expect the skill's folder to be named ${names[0]}, like the skill: ${resolve7(dir3)} is not.`);
|
|
@@ -10544,9 +10568,22 @@ var init_install = __esm({
|
|
|
10544
10568
|
}
|
|
10545
10569
|
});
|
|
10546
10570
|
|
|
10571
|
+
// src/core/windows.ts
|
|
10572
|
+
import { win32 } from "node:path";
|
|
10573
|
+
function system32(program, env = process.env) {
|
|
10574
|
+
const key = Object.keys(env).find((name) => name.toUpperCase() === "SYSTEMROOT");
|
|
10575
|
+
const root3 = key === void 0 ? void 0 : env[key];
|
|
10576
|
+
return win32.join(root3 !== void 0 && win32.isAbsolute(root3) ? root3 : "C:\\Windows", "System32", program);
|
|
10577
|
+
}
|
|
10578
|
+
var init_windows = __esm({
|
|
10579
|
+
"src/core/windows.ts"() {
|
|
10580
|
+
"use strict";
|
|
10581
|
+
}
|
|
10582
|
+
});
|
|
10583
|
+
|
|
10547
10584
|
// src/commands/agent/mcp-config.ts
|
|
10548
10585
|
import { spawnSync } from "node:child_process";
|
|
10549
|
-
import { existsSync as existsSync6, readFileSync as readFileSync13 } from "node:fs";
|
|
10586
|
+
import { accessSync, constants, existsSync as existsSync6, readFileSync as readFileSync13, statSync as statSync4 } from "node:fs";
|
|
10550
10587
|
import { delimiter, join as join15 } from "node:path";
|
|
10551
10588
|
function parse2(text5) {
|
|
10552
10589
|
try {
|
|
@@ -10616,9 +10653,23 @@ function canonical(url) {
|
|
|
10616
10653
|
return url.trim().replace(/[?#].*$/, "").replace(/\/+$/, "");
|
|
10617
10654
|
}
|
|
10618
10655
|
}
|
|
10656
|
+
function isRunnable(path) {
|
|
10657
|
+
try {
|
|
10658
|
+
if (process.platform !== "win32") accessSync(path, constants.X_OK);
|
|
10659
|
+
return statSync4(path).isFile();
|
|
10660
|
+
} catch {
|
|
10661
|
+
return false;
|
|
10662
|
+
}
|
|
10663
|
+
}
|
|
10664
|
+
function findOnPath(names, env) {
|
|
10665
|
+
for (const dir3 of (env.PATH ?? env.Path ?? "").split(delimiter)) {
|
|
10666
|
+
const found = dir3 === "" ? void 0 : names.map((n) => join15(dir3, n)).find(isRunnable);
|
|
10667
|
+
if (found !== void 0) return found;
|
|
10668
|
+
}
|
|
10669
|
+
return void 0;
|
|
10670
|
+
}
|
|
10619
10671
|
function onPath(bin, env) {
|
|
10620
|
-
|
|
10621
|
-
return (env.PATH ?? env.Path ?? "").split(delimiter).some((dir3) => dir3 !== "" && names.some((n) => existsSync6(join15(dir3, n))));
|
|
10672
|
+
return findOnPath(process.platform === "win32" ? [`${bin}.cmd`, `${bin}.exe`, bin] : [bin], env) !== void 0;
|
|
10622
10673
|
}
|
|
10623
10674
|
function isPresent(client, env) {
|
|
10624
10675
|
const t = TARGETS[client];
|
|
@@ -10659,10 +10710,17 @@ function addMcp(client, env, url) {
|
|
|
10659
10710
|
if (state2.status !== "missing") return state2;
|
|
10660
10711
|
if (t.command) {
|
|
10661
10712
|
const [bin, ...args] = t.command(url);
|
|
10662
|
-
if (!onPath(bin, env)) return { ...state2, status: "skipped", detail: `${bin} is not on PATH`, next };
|
|
10663
10713
|
const win = process.platform === "win32";
|
|
10664
|
-
const
|
|
10665
|
-
|
|
10714
|
+
const path = findOnPath(win ? [`${bin}.cmd`, `${bin}.exe`] : [bin], env);
|
|
10715
|
+
if (path === void 0) return { ...state2, status: "skipped", detail: `${bin} is not on PATH`, next };
|
|
10716
|
+
const quote4 = (a) => /^[A-Za-z0-9_\-.:/@=+]+$/.test(a) ? a : `"${a.replace(/"/g, '""')}"`;
|
|
10717
|
+
const childEnv2 = Object.fromEntries(Object.entries(env).filter(([name]) => !name.toUpperCase().startsWith("KENSO_")));
|
|
10718
|
+
const r = spawnSync(win ? quote4(path) : path, win ? args.map(quote4) : args, {
|
|
10719
|
+
env: childEnv2,
|
|
10720
|
+
encoding: "utf8",
|
|
10721
|
+
timeout: 6e4,
|
|
10722
|
+
shell: win ? system32("cmd.exe", env) : false
|
|
10723
|
+
});
|
|
10666
10724
|
if (r.status !== 0) {
|
|
10667
10725
|
const said = `${r.stderr ?? ""}${r.stdout ?? ""}`.trim().split("\n").pop()?.slice(0, 200);
|
|
10668
10726
|
return { ...state2, status: "failed", detail: `${bin} exited ${r.status ?? r.signal ?? r.error?.message}${said ? `: ${said}` : ""}`, next };
|
|
@@ -10676,7 +10734,7 @@ function addMcp(client, env, url) {
|
|
|
10676
10734
|
if (text5 === void 0 && client === "opencode") doc.$schema = "https://opencode.ai/config.json";
|
|
10677
10735
|
t.merge(doc, url);
|
|
10678
10736
|
write(state2.file, `${JSON.stringify(doc, null, 2)}
|
|
10679
|
-
|
|
10737
|
+
`, { mode: 384, dirMode: 448 });
|
|
10680
10738
|
return { status: "added", file: state2.file, name: SERVER_NAME };
|
|
10681
10739
|
}
|
|
10682
10740
|
function signInStep(client) {
|
|
@@ -10686,6 +10744,7 @@ var SERVER_NAME, isDoc, readJson, TARGETS;
|
|
|
10686
10744
|
var init_mcp_config = __esm({
|
|
10687
10745
|
"src/commands/agent/mcp-config.ts"() {
|
|
10688
10746
|
"use strict";
|
|
10747
|
+
init_windows();
|
|
10689
10748
|
init_clients();
|
|
10690
10749
|
init_install();
|
|
10691
10750
|
SERVER_NAME = "kenso";
|
|
@@ -10851,7 +10910,7 @@ var init_setup = __esm({
|
|
|
10851
10910
|
for (const row of rows) {
|
|
10852
10911
|
for (const skill of row.skills) {
|
|
10853
10912
|
const done2 = installStatus(skill.status, force);
|
|
10854
|
-
if (WRITES.has(done2)) write(skill.path, texts.get(skill.name));
|
|
10913
|
+
if (WRITES.has(done2)) write(skill.path, texts.get(skill.name), { dirMode: 448 });
|
|
10855
10914
|
if (done2 === "edited") edited.push(skill.path);
|
|
10856
10915
|
skill.status = done2;
|
|
10857
10916
|
}
|
|
@@ -11042,7 +11101,7 @@ function openBrowser(url, deps) {
|
|
|
11042
11101
|
deps.spawn("open", [url]);
|
|
11043
11102
|
} else if (deps.platform === "win32") {
|
|
11044
11103
|
if (/[&|^<>"%]/.test(url)) return;
|
|
11045
|
-
deps.spawn("cmd", ["/c", "start", "", url]);
|
|
11104
|
+
deps.spawn(system32("cmd.exe"), ["/c", "start", "", url]);
|
|
11046
11105
|
} else {
|
|
11047
11106
|
deps.spawn("xdg-open", [url]);
|
|
11048
11107
|
}
|
|
@@ -11052,11 +11111,12 @@ function openBrowser(url, deps) {
|
|
|
11052
11111
|
var init_browser = __esm({
|
|
11053
11112
|
"src/core/browser.ts"() {
|
|
11054
11113
|
"use strict";
|
|
11114
|
+
init_windows();
|
|
11055
11115
|
}
|
|
11056
11116
|
});
|
|
11057
11117
|
|
|
11058
11118
|
// src/core/pending-login.ts
|
|
11059
|
-
import { chmodSync as chmodSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync14, renameSync as renameSync7, rmSync as
|
|
11119
|
+
import { chmodSync as chmodSync4, mkdirSync as mkdirSync5, readFileSync as readFileSync14, renameSync as renameSync7, rmSync as rmSync4, unlinkSync as unlinkSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
11060
11120
|
import { join as join16 } from "node:path";
|
|
11061
11121
|
function pendingLoginPath(env = process.env) {
|
|
11062
11122
|
return join16(configDir(env), FILE2);
|
|
@@ -11107,7 +11167,7 @@ function writePendingLogin(login, env = process.env) {
|
|
|
11107
11167
|
}
|
|
11108
11168
|
}
|
|
11109
11169
|
function removePendingLogin(env = process.env) {
|
|
11110
|
-
|
|
11170
|
+
rmSync4(pendingLoginPath(env), { force: true });
|
|
11111
11171
|
}
|
|
11112
11172
|
var FILE2, TEXT_KEYS;
|
|
11113
11173
|
var init_pending_login = __esm({
|
|
@@ -15503,7 +15563,7 @@ var init_docs2 = __esm({
|
|
|
15503
15563
|
});
|
|
15504
15564
|
|
|
15505
15565
|
// src/commands/doctor/index.ts
|
|
15506
|
-
import { statSync as
|
|
15566
|
+
import { statSync as statSync5 } from "node:fs";
|
|
15507
15567
|
function withNext(check, next) {
|
|
15508
15568
|
return check.ok ? check : { ...check, next };
|
|
15509
15569
|
}
|
|
@@ -15548,7 +15608,7 @@ function configCheck(env) {
|
|
|
15548
15608
|
const file = configPath(env);
|
|
15549
15609
|
let mode;
|
|
15550
15610
|
try {
|
|
15551
|
-
mode =
|
|
15611
|
+
mode = statSync5(file).mode & 511;
|
|
15552
15612
|
} catch (err) {
|
|
15553
15613
|
if (err.code === "ENOENT") return { name: "config_permissions", ok: true, detail: `no config file at ${file}` };
|
|
15554
15614
|
return { name: "config_permissions", ok: false, detail: `cannot read ${file}: ${err.message}` };
|
|
@@ -20188,8 +20248,8 @@ var init_views = __esm({
|
|
|
20188
20248
|
});
|
|
20189
20249
|
|
|
20190
20250
|
// src/commands/webhooks/local.ts
|
|
20191
|
-
import { createHmac, randomBytes as
|
|
20192
|
-
import { mkdirSync as mkdirSync6, readFileSync as readFileSync17, rmSync as
|
|
20251
|
+
import { createHmac, randomBytes as randomBytes4 } from "node:crypto";
|
|
20252
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync17, rmSync as rmSync5, writeFileSync as writeFileSync8 } from "node:fs";
|
|
20193
20253
|
import { join as join22 } from "node:path";
|
|
20194
20254
|
function webhooksDir(env) {
|
|
20195
20255
|
const dir3 = join22(configDir(env), "webhooks");
|
|
@@ -20206,7 +20266,7 @@ function signingSecret(env) {
|
|
|
20206
20266
|
if (/^whsec_[A-Za-z0-9+/]{32,}={0,2}$/.test(saved)) return saved;
|
|
20207
20267
|
} catch {
|
|
20208
20268
|
}
|
|
20209
|
-
const secret = `whsec_${
|
|
20269
|
+
const secret = `whsec_${randomBytes4(24).toString("base64")}`;
|
|
20210
20270
|
writeFileSync8(file, `${secret}
|
|
20211
20271
|
`, { mode: 384 });
|
|
20212
20272
|
return secret;
|
|
@@ -20263,7 +20323,7 @@ function readListenerState(env, workspaceId) {
|
|
|
20263
20323
|
}
|
|
20264
20324
|
}
|
|
20265
20325
|
function removeListenerState(env, workspaceId, token) {
|
|
20266
|
-
if (readListenerState(env, workspaceId)?.token === token)
|
|
20326
|
+
if (readListenerState(env, workspaceId)?.token === token) rmSync5(statePath(env, workspaceId), { force: true });
|
|
20267
20327
|
}
|
|
20268
20328
|
var FORWARD_TIMEOUT_MS;
|
|
20269
20329
|
var init_local = __esm({
|
|
@@ -20282,7 +20342,7 @@ __export(listen_exports, {
|
|
|
20282
20342
|
default: () => listen_default,
|
|
20283
20343
|
liveBody: () => liveBody
|
|
20284
20344
|
});
|
|
20285
|
-
import { randomBytes as
|
|
20345
|
+
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
20286
20346
|
import { setTimeout as delay11 } from "node:timers/promises";
|
|
20287
20347
|
function eventTypes(value) {
|
|
20288
20348
|
const list2 = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
|
|
@@ -20390,7 +20450,7 @@ var init_listen = __esm({
|
|
|
20390
20450
|
throw err;
|
|
20391
20451
|
}
|
|
20392
20452
|
}
|
|
20393
|
-
const token =
|
|
20453
|
+
const token = randomBytes5(32).toString("base64url");
|
|
20394
20454
|
const { createServer } = await import("node:http");
|
|
20395
20455
|
const server = createServer((req, res) => {
|
|
20396
20456
|
if (req.method !== "POST" || req.url !== "/events") return reply(res, 404, { error: "not_found" });
|
|
@@ -20591,7 +20651,7 @@ var init_status3 = __esm({
|
|
|
20591
20651
|
});
|
|
20592
20652
|
|
|
20593
20653
|
// src/work/files.ts
|
|
20594
|
-
import { closeSync as
|
|
20654
|
+
import { closeSync as closeSync3, constants as constants2, fchmodSync as fchmodSync2, fstatSync, lstatSync, openSync as openSync3, readFileSync as readFileSync18, writeFileSync as writeFileSync9 } from "node:fs";
|
|
20595
20655
|
import { join as join23 } from "node:path";
|
|
20596
20656
|
function agentName(value) {
|
|
20597
20657
|
if (typeof value !== "string") return void 0;
|
|
@@ -20612,26 +20672,26 @@ function writeWorkFile(dir3, work, mode = 384) {
|
|
|
20612
20672
|
const name = workFileName(work.claimId);
|
|
20613
20673
|
if (!isPlainFileName(work.answersFile)) throw new Error("answersFile is not a plain file name");
|
|
20614
20674
|
const path = join23(dir3, name);
|
|
20615
|
-
const fd =
|
|
20675
|
+
const fd = openSync3(path, "wx", mode);
|
|
20616
20676
|
try {
|
|
20617
20677
|
writeFileSync9(fd, JSON.stringify(work, null, 2) + "\n", "utf8");
|
|
20618
|
-
|
|
20678
|
+
fchmodSync2(fd, mode);
|
|
20619
20679
|
} finally {
|
|
20620
|
-
|
|
20680
|
+
closeSync3(fd);
|
|
20621
20681
|
}
|
|
20622
20682
|
return path;
|
|
20623
20683
|
}
|
|
20624
20684
|
function readRegularFile(path, what) {
|
|
20625
20685
|
const notPlain = { ok: false, error: `the ${what} is not a plain file` };
|
|
20626
20686
|
if (!lstatSync(path).isFile()) return notPlain;
|
|
20627
|
-
const fd =
|
|
20687
|
+
const fd = openSync3(path, constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0) | (constants2.O_NONBLOCK ?? 0));
|
|
20628
20688
|
try {
|
|
20629
20689
|
const stat4 = fstatSync(fd);
|
|
20630
20690
|
if (!stat4.isFile()) return notPlain;
|
|
20631
20691
|
if (stat4.size > MAX_ANSWERS_FILE_BYTES) return { ok: false, error: `the ${what} is too large` };
|
|
20632
20692
|
return readFileSync18(fd, "utf8");
|
|
20633
20693
|
} finally {
|
|
20634
|
-
|
|
20694
|
+
closeSync3(fd);
|
|
20635
20695
|
}
|
|
20636
20696
|
}
|
|
20637
20697
|
function isObject2(value) {
|
|
@@ -21564,8 +21624,8 @@ var init_egress = __esm({
|
|
|
21564
21624
|
|
|
21565
21625
|
// src/work/job.ts
|
|
21566
21626
|
import { spawn as nodeSpawn3 } from "node:child_process";
|
|
21567
|
-
import { rmSync as
|
|
21568
|
-
import { access, constants as
|
|
21627
|
+
import { rmSync as rmSync6, statSync as statSync6 } from "node:fs";
|
|
21628
|
+
import { access, constants as constants3 } from "node:fs/promises";
|
|
21569
21629
|
import { delimiter as delimiter2, join as join26 } from "node:path";
|
|
21570
21630
|
import { setTimeout as delay12 } from "node:timers/promises";
|
|
21571
21631
|
function childEnv(parent, adapter, extra) {
|
|
@@ -21584,8 +21644,8 @@ function childEnv(parent, adapter, extra) {
|
|
|
21584
21644
|
}
|
|
21585
21645
|
async function isExecutableFile(path) {
|
|
21586
21646
|
try {
|
|
21587
|
-
await access(path,
|
|
21588
|
-
return
|
|
21647
|
+
await access(path, constants3.X_OK);
|
|
21648
|
+
return statSync6(path).isFile();
|
|
21589
21649
|
} catch {
|
|
21590
21650
|
return false;
|
|
21591
21651
|
}
|
|
@@ -21612,7 +21672,7 @@ async function resolveBinary(adapter, env, override2) {
|
|
|
21612
21672
|
}
|
|
21613
21673
|
return void 0;
|
|
21614
21674
|
}
|
|
21615
|
-
function signalTree(child, signal, runAs) {
|
|
21675
|
+
function signalTree(spawnFn, child, signal, runAs) {
|
|
21616
21676
|
const pid = child.pid;
|
|
21617
21677
|
if (pid === void 0) return;
|
|
21618
21678
|
if (runAs) {
|
|
@@ -21623,7 +21683,7 @@ function signalTree(child, signal, runAs) {
|
|
|
21623
21683
|
if (process.platform === "win32") {
|
|
21624
21684
|
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
21625
21685
|
const args = ["/pid", String(pid), "/T", ...signal === "SIGKILL" ? ["/F"] : []];
|
|
21626
|
-
|
|
21686
|
+
spawnFn(system32("taskkill.exe"), args, { stdio: "ignore", windowsHide: true }).on("error", () => {
|
|
21627
21687
|
});
|
|
21628
21688
|
return;
|
|
21629
21689
|
}
|
|
@@ -21713,8 +21773,8 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
21713
21773
|
const stop = (why2) => {
|
|
21714
21774
|
if (stopped || settled2 || exited) return;
|
|
21715
21775
|
stopped = why2;
|
|
21716
|
-
signalTree(child, "SIGTERM", runAs);
|
|
21717
|
-
timers.push(setTimeout(() => signalTree(child, "SIGKILL", runAs), KILL_GRACE_MS));
|
|
21776
|
+
signalTree(spawnFn, child, "SIGTERM", runAs);
|
|
21777
|
+
timers.push(setTimeout(() => signalTree(spawnFn, child, "SIGKILL", runAs), KILL_GRACE_MS));
|
|
21718
21778
|
};
|
|
21719
21779
|
const onAbort = () => stop("abort");
|
|
21720
21780
|
timers.push(setTimeout(() => stop("timeout"), Math.min(Math.max(job.timeoutMs, 1), MAX_TIMER_MS)));
|
|
@@ -21728,7 +21788,7 @@ function runChild(spawnFn, bin, built, job, env, signal, runAs) {
|
|
|
21728
21788
|
child.on("exit", (code) => {
|
|
21729
21789
|
exitCode = code;
|
|
21730
21790
|
exited = true;
|
|
21731
|
-
signalTree(child, "SIGKILL", runAs);
|
|
21791
|
+
signalTree(spawnFn, child, "SIGKILL", runAs);
|
|
21732
21792
|
timers.push(
|
|
21733
21793
|
setTimeout(() => {
|
|
21734
21794
|
child.stdout?.destroy();
|
|
@@ -21777,7 +21837,7 @@ async function runAgentJob(adapter, job, deps) {
|
|
|
21777
21837
|
}
|
|
21778
21838
|
const answersPath = join26(job.cwd, job.answersFile);
|
|
21779
21839
|
try {
|
|
21780
|
-
|
|
21840
|
+
rmSync6(answersPath, { force: true });
|
|
21781
21841
|
} catch (err) {
|
|
21782
21842
|
return result("fatal", null, `the answers path could not be cleared: ${err.message}`);
|
|
21783
21843
|
}
|
|
@@ -21821,6 +21881,7 @@ var OUTPUT_CAP_BYTES, KILL_GRACE_MS, KENSO_ENV_PREFIX, AGENT_ENV_NAMES, AGENT_EN
|
|
|
21821
21881
|
var init_job = __esm({
|
|
21822
21882
|
"src/work/job.ts"() {
|
|
21823
21883
|
"use strict";
|
|
21884
|
+
init_windows();
|
|
21824
21885
|
init_agent_user();
|
|
21825
21886
|
init_egress();
|
|
21826
21887
|
init_files();
|
|
@@ -22317,7 +22378,7 @@ var init_adapters = __esm({
|
|
|
22317
22378
|
});
|
|
22318
22379
|
|
|
22319
22380
|
// src/work/scan.ts
|
|
22320
|
-
import { createHmac as createHmac2, randomBytes as
|
|
22381
|
+
import { createHmac as createHmac2, randomBytes as randomBytes6 } from "node:crypto";
|
|
22321
22382
|
function fold(text5) {
|
|
22322
22383
|
return text5.normalize("NFKC").replace(/[^A-Za-z0-9]/g, "").toLowerCase();
|
|
22323
22384
|
}
|
|
@@ -22435,7 +22496,7 @@ var init_scan = __esm({
|
|
|
22435
22496
|
TOKEN_RUN = /[A-Za-z0-9+/=_.-]{16,}/g;
|
|
22436
22497
|
LINK = /^\W*(?:[a-z][a-z0-9+.-]*:\/\/|www\.)|^[^/]*\.[a-z]{2,}\//i;
|
|
22437
22498
|
CredentialIndex = class {
|
|
22438
|
-
key =
|
|
22499
|
+
key = randomBytes6(32);
|
|
22439
22500
|
exact = /* @__PURE__ */ new Set();
|
|
22440
22501
|
folded = /* @__PURE__ */ new Set();
|
|
22441
22502
|
/** Adds a credential file's text: its JSON string values (keys skipped), or the whole text when it is not JSON. */
|
|
@@ -22581,7 +22642,7 @@ var init_credentials = __esm({
|
|
|
22581
22642
|
});
|
|
22582
22643
|
|
|
22583
22644
|
// src/work/guide.ts
|
|
22584
|
-
import { closeSync as
|
|
22645
|
+
import { closeSync as closeSync4, fchmodSync as fchmodSync3, openSync as openSync4, writeFileSync as writeFileSync10 } from "node:fs";
|
|
22585
22646
|
import { join as join29 } from "node:path";
|
|
22586
22647
|
function agentGuide(opts) {
|
|
22587
22648
|
const browser = opts.browser ?? findOperation("browser-runs", "create") !== void 0;
|
|
@@ -22590,12 +22651,12 @@ function agentGuide(opts) {
|
|
|
22590
22651
|
}
|
|
22591
22652
|
function writeAgentGuide(dir3, text5, mode = WORK_FILE_MODE) {
|
|
22592
22653
|
for (const name of GUIDE_FILES) {
|
|
22593
|
-
const fd =
|
|
22654
|
+
const fd = openSync4(join29(dir3, name), "wx", mode);
|
|
22594
22655
|
try {
|
|
22595
22656
|
writeFileSync10(fd, text5, "utf8");
|
|
22596
|
-
|
|
22657
|
+
fchmodSync3(fd, mode);
|
|
22597
22658
|
} finally {
|
|
22598
|
-
|
|
22659
|
+
closeSync4(fd);
|
|
22599
22660
|
}
|
|
22600
22661
|
}
|
|
22601
22662
|
}
|
|
@@ -26782,6 +26843,7 @@ var init_main = __esm({
|
|
|
26782
26843
|
LINGERING_REQUEST_GRACE_MS = 50;
|
|
26783
26844
|
JQ_HINT = "kenso has no --jq: --query filters the output with a JMESPath expression, for example --query '[].id'.";
|
|
26784
26845
|
if (invokedDirectly(import.meta.url)) {
|
|
26846
|
+
if (process.platform === "win32") process.env.NoDefaultCurrentDirectoryInExePath = "1";
|
|
26785
26847
|
const updateNotice = startUpdateNotice(process.argv.slice(2));
|
|
26786
26848
|
void main(process.argv.slice(2)).then(async (code) => {
|
|
26787
26849
|
process.exitCode = code;
|