kenso 0.1.137 → 0.1.140
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 +7 -0
- package/dist/kenso.js +917 -430
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/dist/pricing.json +1 -0
- package/dist/step-types.json +1 -0
- package/docs/reference.md +14 -4
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -282,18 +282,18 @@ function readConfig(env = process.env) {
|
|
|
282
282
|
}
|
|
283
283
|
return config;
|
|
284
284
|
}
|
|
285
|
-
function ensurePrivateDir(
|
|
286
|
-
mkdirSync(
|
|
285
|
+
function ensurePrivateDir(dir3) {
|
|
286
|
+
mkdirSync(dir3, { recursive: true, mode: 448 });
|
|
287
287
|
try {
|
|
288
|
-
chmodSync(
|
|
288
|
+
chmodSync(dir3, 448);
|
|
289
289
|
} catch {
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
function writeConfig(config, env) {
|
|
293
|
-
const
|
|
294
|
-
ensurePrivateDir(
|
|
295
|
-
const file = join(
|
|
296
|
-
const temp = join(
|
|
293
|
+
const dir3 = configDir(env);
|
|
294
|
+
ensurePrivateDir(dir3);
|
|
295
|
+
const file = join(dir3, CONFIG_FILE);
|
|
296
|
+
const temp = join(dir3, `.${CONFIG_FILE}.${process.pid}.${Date.now()}.tmp`);
|
|
297
297
|
try {
|
|
298
298
|
writeFileSync(temp, `${JSON.stringify(config, null, 2)}
|
|
299
299
|
`, { mode: 384 });
|
|
@@ -321,13 +321,13 @@ function removeProfile(name, env = process.env) {
|
|
|
321
321
|
writeConfig(config, env);
|
|
322
322
|
}
|
|
323
323
|
function cacheDir(env = process.env) {
|
|
324
|
-
const
|
|
325
|
-
ensurePrivateDir(
|
|
326
|
-
return
|
|
324
|
+
const dir3 = join(configDir(env), "cache");
|
|
325
|
+
ensurePrivateDir(dir3);
|
|
326
|
+
return dir3;
|
|
327
327
|
}
|
|
328
328
|
function clearCache(env = process.env) {
|
|
329
|
-
const
|
|
330
|
-
if (existsSync(
|
|
329
|
+
const dir3 = join(configDir(env), "cache");
|
|
330
|
+
if (existsSync(dir3)) rmSync(dir3, { recursive: true, force: true });
|
|
331
331
|
}
|
|
332
332
|
function nonEmpty(value) {
|
|
333
333
|
const trimmed = value?.trim();
|
|
@@ -340,14 +340,18 @@ function resolveAuth(flags, env = process.env) {
|
|
|
340
340
|
const envKey = nonEmpty(env.KENSO_API_KEY);
|
|
341
341
|
const apiKey = envKey ?? profile.apiKey;
|
|
342
342
|
const source = envKey ? "env" : profile.apiKey ? "profile" : "none";
|
|
343
|
-
const
|
|
343
|
+
const flagWorkspace = nonEmpty(flags.workspace);
|
|
344
|
+
const envWorkspace = nonEmpty(env.KENSO_WORKSPACE_ID);
|
|
345
|
+
const workspaceId = flagWorkspace ?? envWorkspace ?? profile.workspaceId;
|
|
346
|
+
const workspaceSource = flagWorkspace ? "flag" : envWorkspace ? "env" : profile.workspaceId ? "profile" : "none";
|
|
344
347
|
const apiUrl = (nonEmpty(env.KENSO_API_URL) ?? profile.apiUrl ?? DEFAULT_API_URL).replace(/\/+$/, "");
|
|
345
|
-
return { apiKey, workspaceId, apiUrl, profileName, source };
|
|
348
|
+
return { apiKey, workspaceId, workspaceSource, apiUrl, profileName, source };
|
|
346
349
|
}
|
|
347
350
|
function authWithoutConfig(flags, env = process.env) {
|
|
348
|
-
const
|
|
351
|
+
const flagWorkspace = nonEmpty(flags.workspace);
|
|
352
|
+
const envWorkspace = nonEmpty(env.KENSO_WORKSPACE_ID);
|
|
349
353
|
const apiUrl = (nonEmpty(env.KENSO_API_URL) ?? DEFAULT_API_URL).replace(/\/+$/, "");
|
|
350
|
-
return { workspaceId, apiUrl, profileName: "none", source: "none" };
|
|
354
|
+
return { workspaceId: flagWorkspace ?? envWorkspace, workspaceSource: flagWorkspace ? "flag" : envWorkspace ? "env" : "none", apiUrl, profileName: "none", source: "none" };
|
|
351
355
|
}
|
|
352
356
|
var DEFAULT_API_URL, DEFAULT_PROFILE, CONFIG_FILE, PROFILE_KEYS;
|
|
353
357
|
var init_config = __esm({
|
|
@@ -2481,23 +2485,23 @@ var VERSION;
|
|
|
2481
2485
|
var init_version = __esm({
|
|
2482
2486
|
"src/core/version.ts"() {
|
|
2483
2487
|
"use strict";
|
|
2484
|
-
VERSION = true ? "0.1.
|
|
2488
|
+
VERSION = true ? "0.1.140" : "0.0.0-dev";
|
|
2485
2489
|
}
|
|
2486
2490
|
});
|
|
2487
2491
|
|
|
2488
2492
|
// src/core/context.ts
|
|
2489
|
-
function createContext(flags, env = process.env,
|
|
2493
|
+
function createContext(flags, env = process.env, overrides2) {
|
|
2490
2494
|
const agent = detectAgent(env);
|
|
2491
|
-
const signal =
|
|
2492
|
-
const auth =
|
|
2495
|
+
const signal = overrides2?.signal ?? new AbortController().signal;
|
|
2496
|
+
const auth = overrides2?.noConfig ? authWithoutConfig({ workspace: flags.workspace }, env) : resolveAuth({ profile: flags.profile, workspace: flags.workspace }, env);
|
|
2493
2497
|
const output = new Output({
|
|
2494
2498
|
format: flags.output,
|
|
2495
2499
|
fields: flags.fields?.split(","),
|
|
2496
2500
|
query: flags.query,
|
|
2497
|
-
stdout:
|
|
2498
|
-
stderr:
|
|
2499
|
-
stdoutIsTTY:
|
|
2500
|
-
stderrIsTTY:
|
|
2501
|
+
stdout: overrides2?.stdout,
|
|
2502
|
+
stderr: overrides2?.stderr,
|
|
2503
|
+
stdoutIsTTY: overrides2?.stdoutIsTTY,
|
|
2504
|
+
stderrIsTTY: overrides2?.stderrIsTTY,
|
|
2501
2505
|
progress: flags.progress
|
|
2502
2506
|
});
|
|
2503
2507
|
const client = new KensoClient({
|
|
@@ -2506,8 +2510,8 @@ function createContext(flags, env = process.env, overrides) {
|
|
|
2506
2510
|
workspaceId: auth.workspaceId,
|
|
2507
2511
|
agent,
|
|
2508
2512
|
version: VERSION,
|
|
2509
|
-
fetchImpl:
|
|
2510
|
-
sleep:
|
|
2513
|
+
fetchImpl: overrides2?.fetchImpl,
|
|
2514
|
+
sleep: overrides2?.sleep,
|
|
2511
2515
|
signal,
|
|
2512
2516
|
onRetry: ({ status, waitMs }) => {
|
|
2513
2517
|
const seconds = Math.max(1, Math.round(waitMs / 1e3));
|
|
@@ -2528,7 +2532,7 @@ function createContext(flags, env = process.env, overrides) {
|
|
|
2528
2532
|
agent,
|
|
2529
2533
|
version: VERSION,
|
|
2530
2534
|
signal,
|
|
2531
|
-
stdin:
|
|
2535
|
+
stdin: overrides2?.stdin
|
|
2532
2536
|
};
|
|
2533
2537
|
}
|
|
2534
2538
|
var init_context = __esm({
|
|
@@ -2570,14 +2574,14 @@ async function loadWorkspaceFeatures(ctx, opts = {}) {
|
|
|
2570
2574
|
if (!key) return { features: [] };
|
|
2571
2575
|
const now = Date.now();
|
|
2572
2576
|
let file;
|
|
2573
|
-
let
|
|
2577
|
+
let cache2 = {};
|
|
2574
2578
|
try {
|
|
2575
2579
|
file = join2(cacheDir(ctx.env), CACHE_FILE);
|
|
2576
|
-
|
|
2580
|
+
cache2 = readCache(file);
|
|
2577
2581
|
} catch {
|
|
2578
2582
|
file = void 0;
|
|
2579
2583
|
}
|
|
2580
|
-
const hit =
|
|
2584
|
+
const hit = cache2[key];
|
|
2581
2585
|
if (isFresh(hit, now)) return { features: hit.features.filter((f) => typeof f === "string") };
|
|
2582
2586
|
const timeoutMs2 = opts.timeoutMs ?? FETCH_TIMEOUT_MS;
|
|
2583
2587
|
const timeout = AbortSignal.timeout(timeoutMs2);
|
|
@@ -2594,7 +2598,7 @@ async function loadWorkspaceFeatures(ctx, opts = {}) {
|
|
|
2594
2598
|
if (file) {
|
|
2595
2599
|
try {
|
|
2596
2600
|
const kept = {};
|
|
2597
|
-
for (const [k, entry] of Object.entries(
|
|
2601
|
+
for (const [k, entry] of Object.entries(cache2)) if (isFresh(entry, now)) kept[k] = entry;
|
|
2598
2602
|
kept[key] = { features, fetchedAt: new Date(now).toISOString() };
|
|
2599
2603
|
const temp = `${file}.${process.pid}.tmp`;
|
|
2600
2604
|
writeFileSync2(temp, `${JSON.stringify(kept)}
|
|
@@ -2635,6 +2639,7 @@ __export(manifest_exports, {
|
|
|
2635
2639
|
findOperationById: () => findOperationById,
|
|
2636
2640
|
listOperations: () => listOperations,
|
|
2637
2641
|
loadManifest: () => loadManifest,
|
|
2642
|
+
routeEffect: () => routeEffect,
|
|
2638
2643
|
useManifestDirForTest: () => useManifestDirForTest,
|
|
2639
2644
|
useManifestForTest: () => useManifestForTest
|
|
2640
2645
|
});
|
|
@@ -2672,6 +2677,25 @@ function listOperations() {
|
|
|
2672
2677
|
if (override) return override.operations;
|
|
2673
2678
|
return loadIndex()?.operations ?? loadManifest().operations;
|
|
2674
2679
|
}
|
|
2680
|
+
function routeEffect(method, path) {
|
|
2681
|
+
const fold2 = (segment) => {
|
|
2682
|
+
try {
|
|
2683
|
+
return decodeURIComponent(segment).toLowerCase();
|
|
2684
|
+
} catch {
|
|
2685
|
+
return segment.toLowerCase();
|
|
2686
|
+
}
|
|
2687
|
+
};
|
|
2688
|
+
const segments = path.split(/[?#]/, 1)[0].replace(/\/+$/, "").split("/").map(fold2);
|
|
2689
|
+
let best;
|
|
2690
|
+
for (const op of listOperations()) {
|
|
2691
|
+
const template2 = op.path.split("/");
|
|
2692
|
+
if (op.method !== method || template2.length !== segments.length) continue;
|
|
2693
|
+
const literals = template2.filter((part) => !part.startsWith("{")).length;
|
|
2694
|
+
const fits = template2.every((part, i) => part.startsWith("{") ? segments[i] !== "" : part.toLowerCase() === segments[i]);
|
|
2695
|
+
if (fits && (!best || literals > best.literals)) best = { effect: op.effect ?? "write", literals };
|
|
2696
|
+
}
|
|
2697
|
+
return best?.effect;
|
|
2698
|
+
}
|
|
2675
2699
|
function indexes() {
|
|
2676
2700
|
if (!byCommand || !byId) {
|
|
2677
2701
|
const operations = listOperations();
|
|
@@ -4027,15 +4051,15 @@ import { createHash } from "node:crypto";
|
|
|
4027
4051
|
import { readFileSync as readFileSync5 } from "node:fs";
|
|
4028
4052
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
4029
4053
|
import { join as join4 } from "node:path";
|
|
4030
|
-
function filesOf(
|
|
4054
|
+
function filesOf(dir3) {
|
|
4031
4055
|
return {
|
|
4032
|
-
runJson: join4(
|
|
4033
|
-
stateJson: join4(
|
|
4034
|
-
resultsCsv: join4(
|
|
4035
|
-
resultsNdjson: join4(
|
|
4036
|
-
invalidCsv: join4(
|
|
4037
|
-
planJson: join4(
|
|
4038
|
-
summaryJson: join4(
|
|
4056
|
+
runJson: join4(dir3, "run.json"),
|
|
4057
|
+
stateJson: join4(dir3, "state.json"),
|
|
4058
|
+
resultsCsv: join4(dir3, "results.csv"),
|
|
4059
|
+
resultsNdjson: join4(dir3, "results.ndjson"),
|
|
4060
|
+
invalidCsv: join4(dir3, "invalid.csv"),
|
|
4061
|
+
planJson: join4(dir3, "plan.json"),
|
|
4062
|
+
summaryJson: join4(dir3, "summary.json")
|
|
4039
4063
|
};
|
|
4040
4064
|
}
|
|
4041
4065
|
function hashItems(items) {
|
|
@@ -4211,24 +4235,24 @@ function rootRefusal(stats) {
|
|
|
4211
4235
|
if ((stats.mode & 18) !== 0 && !sticky) return `other users can write it (mode ${modeText(stats)})`;
|
|
4212
4236
|
return void 0;
|
|
4213
4237
|
}
|
|
4214
|
-
function notPrivateError(
|
|
4215
|
-
return usageError(`kenso will not keep runs in ${
|
|
4238
|
+
function notPrivateError(dir3, reason) {
|
|
4239
|
+
return usageError(`kenso will not keep runs in ${dir3}: ${reason}.`, {
|
|
4216
4240
|
hint: "Use a folder only you own and can write (chmod 700 it), or leave KENSO_RUNS_DIR and --out unset to use ~/.kenso/runs."
|
|
4217
4241
|
});
|
|
4218
4242
|
}
|
|
4219
|
-
function ensureDir(
|
|
4220
|
-
mkdirSync2(
|
|
4243
|
+
function ensureDir(dir3, mode) {
|
|
4244
|
+
mkdirSync2(dir3, { recursive: true, mode: mode & 511 });
|
|
4221
4245
|
const uid = currentUid();
|
|
4222
4246
|
try {
|
|
4223
|
-
chmodSync2(
|
|
4247
|
+
chmodSync2(dir3, mode);
|
|
4224
4248
|
} catch (err) {
|
|
4225
4249
|
if (uid === void 0) return;
|
|
4226
|
-
throw notPrivateError(
|
|
4250
|
+
throw notPrivateError(dir3, `kenso cannot set its mode (${err.code ?? String(err)})`);
|
|
4227
4251
|
}
|
|
4228
4252
|
if (uid === void 0) return;
|
|
4229
|
-
const stats = statSync(
|
|
4230
|
-
if (stats.uid !== uid) throw notPrivateError(
|
|
4231
|
-
if ((stats.mode & 18 & ~mode) !== 0) throw notPrivateError(
|
|
4253
|
+
const stats = statSync(dir3);
|
|
4254
|
+
if (stats.uid !== uid) throw notPrivateError(dir3, `another user (uid ${stats.uid}) owns it`);
|
|
4255
|
+
if ((stats.mode & 18 & ~mode) !== 0) throw notPrivateError(dir3, `its mode stayed ${modeText(stats)} after kenso set it`);
|
|
4232
4256
|
}
|
|
4233
4257
|
async function checkRoot(root2) {
|
|
4234
4258
|
let stats;
|
|
@@ -4245,8 +4269,8 @@ async function checkRoot(root2) {
|
|
|
4245
4269
|
if (refusal2) throw notPrivateError(root2, refusal2);
|
|
4246
4270
|
return true;
|
|
4247
4271
|
}
|
|
4248
|
-
function ensurePrivateDir2(
|
|
4249
|
-
ensureDir(
|
|
4272
|
+
function ensurePrivateDir2(dir3) {
|
|
4273
|
+
ensureDir(dir3, 448);
|
|
4250
4274
|
}
|
|
4251
4275
|
async function writeFileAtomic(path, content) {
|
|
4252
4276
|
const temp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
@@ -4263,8 +4287,8 @@ async function writeJsonAtomic(path, value) {
|
|
|
4263
4287
|
`);
|
|
4264
4288
|
}
|
|
4265
4289
|
async function writeRunRecord(record3) {
|
|
4266
|
-
const { dir:
|
|
4267
|
-
await writeJsonAtomic(join5(
|
|
4290
|
+
const { dir: dir3, ...rest } = record3;
|
|
4291
|
+
await writeJsonAtomic(join5(dir3, "run.json"), rest);
|
|
4268
4292
|
}
|
|
4269
4293
|
function notYoursError(path, reason) {
|
|
4270
4294
|
return new KensoError({
|
|
@@ -4293,18 +4317,18 @@ function chunkList(value) {
|
|
|
4293
4317
|
if (!Array.isArray(value)) return void 0;
|
|
4294
4318
|
return value.filter((n) => Number.isInteger(n) && n >= 0);
|
|
4295
4319
|
}
|
|
4296
|
-
async function readRun(
|
|
4320
|
+
async function readRun(dir3) {
|
|
4297
4321
|
let dirStats;
|
|
4298
4322
|
try {
|
|
4299
|
-
dirStats = await stat(
|
|
4323
|
+
dirStats = await stat(dir3);
|
|
4300
4324
|
} catch {
|
|
4301
4325
|
return null;
|
|
4302
4326
|
}
|
|
4303
4327
|
const refusal2 = notOurs(dirStats);
|
|
4304
|
-
if (refusal2) throw notYoursError(
|
|
4328
|
+
if (refusal2) throw notYoursError(dir3, refusal2);
|
|
4305
4329
|
let raw;
|
|
4306
4330
|
try {
|
|
4307
|
-
raw = asRecord3(await readOwnJson(join5(
|
|
4331
|
+
raw = asRecord3(await readOwnJson(join5(dir3, "run.json")));
|
|
4308
4332
|
} catch (err) {
|
|
4309
4333
|
if (err instanceof KensoError) throw err;
|
|
4310
4334
|
return null;
|
|
@@ -4316,7 +4340,7 @@ async function readRun(dir2) {
|
|
|
4316
4340
|
if (typeof status !== "string" || !STATUSES.includes(status)) return null;
|
|
4317
4341
|
let chunksDone = chunkList(raw.chunksDone) ?? [];
|
|
4318
4342
|
try {
|
|
4319
|
-
const state = asRecord3(await readOwnJson(join5(
|
|
4343
|
+
const state = asRecord3(await readOwnJson(join5(dir3, "state.json")));
|
|
4320
4344
|
chunksDone = chunkList(state?.chunksDone) ?? chunksDone;
|
|
4321
4345
|
} catch {
|
|
4322
4346
|
}
|
|
@@ -4329,12 +4353,12 @@ async function readRun(dir2) {
|
|
|
4329
4353
|
status,
|
|
4330
4354
|
chunkCount: typeof raw.chunkCount === "number" ? raw.chunkCount : 0,
|
|
4331
4355
|
chunksDone: [...new Set(chunksDone)].sort((a, b) => a - b),
|
|
4332
|
-
dir:
|
|
4356
|
+
dir: dir3
|
|
4333
4357
|
};
|
|
4334
4358
|
return record3;
|
|
4335
4359
|
}
|
|
4336
|
-
async function readRunDir(
|
|
4337
|
-
return readRun(
|
|
4360
|
+
async function readRunDir(dir3) {
|
|
4361
|
+
return readRun(dir3).catch(() => null);
|
|
4338
4362
|
}
|
|
4339
4363
|
async function listRuns(env = process.env) {
|
|
4340
4364
|
const root2 = runsRoot(env);
|
|
@@ -4348,13 +4372,13 @@ async function listRuns(env = process.env) {
|
|
|
4348
4372
|
const runs = [];
|
|
4349
4373
|
for (const name of names) {
|
|
4350
4374
|
if (!RUN_ID_PATTERN.test(name)) continue;
|
|
4351
|
-
let
|
|
4375
|
+
let dir3;
|
|
4352
4376
|
try {
|
|
4353
|
-
|
|
4377
|
+
dir3 = await realpath(join5(root2, name));
|
|
4354
4378
|
} catch {
|
|
4355
4379
|
continue;
|
|
4356
4380
|
}
|
|
4357
|
-
const run = await readRunDir(
|
|
4381
|
+
const run = await readRunDir(dir3);
|
|
4358
4382
|
if (run && run.runId === name) runs.push(run);
|
|
4359
4383
|
}
|
|
4360
4384
|
return runs.sort((a, b) => a.createdAt === b.createdAt ? b.runId.localeCompare(a.runId) : b.createdAt.localeCompare(a.createdAt));
|
|
@@ -4364,14 +4388,14 @@ async function loadRun(runId, env = process.env) {
|
|
|
4364
4388
|
if (!RUN_ID_PATTERN.test(id)) {
|
|
4365
4389
|
throw usageError(`"${runId}" is not a run id: run ids look like r_ab3dxk2q.`, { field: "runId", next: "kenso runs list" });
|
|
4366
4390
|
}
|
|
4367
|
-
let
|
|
4391
|
+
let dir3;
|
|
4368
4392
|
try {
|
|
4369
|
-
if (await checkRoot(runsRoot(env)))
|
|
4393
|
+
if (await checkRoot(runsRoot(env))) dir3 = await realpath(join5(runsRoot(env), id));
|
|
4370
4394
|
} catch (err) {
|
|
4371
4395
|
if (err instanceof KensoError) throw err;
|
|
4372
|
-
|
|
4396
|
+
dir3 = void 0;
|
|
4373
4397
|
}
|
|
4374
|
-
const run =
|
|
4398
|
+
const run = dir3 ? await readRun(dir3) : null;
|
|
4375
4399
|
if (!run || run.runId !== id) {
|
|
4376
4400
|
throw new KensoError({
|
|
4377
4401
|
code: "run_not_found",
|
|
@@ -4420,30 +4444,30 @@ import { join as join6, resolve as resolve3 } from "node:path";
|
|
|
4420
4444
|
async function prepareRunDir(outDir, runId, identical, ctx) {
|
|
4421
4445
|
const root2 = runsRoot(ctx.env);
|
|
4422
4446
|
if (outDir === void 0) {
|
|
4423
|
-
const
|
|
4447
|
+
const dir4 = join6(root2, runId);
|
|
4424
4448
|
ensurePrivateDir2(root2);
|
|
4425
|
-
ensurePrivateDir2(
|
|
4426
|
-
return
|
|
4449
|
+
ensurePrivateDir2(dir4);
|
|
4450
|
+
return dir4;
|
|
4427
4451
|
}
|
|
4428
|
-
const
|
|
4429
|
-
const existing = existsSync3(join6(
|
|
4452
|
+
const dir3 = resolve3(outDir);
|
|
4453
|
+
const existing = existsSync3(join6(dir3, "run.json")) ? await readRunDir(dir3) : null;
|
|
4430
4454
|
if (existing && !identical.some((run) => run.runId === existing.runId)) {
|
|
4431
|
-
throw usageError(`${
|
|
4455
|
+
throw usageError(`${dir3} already holds run ${existing.runId} (${existing.command}).`, {
|
|
4432
4456
|
field: "out",
|
|
4433
4457
|
hint: "Pick an empty --out directory, or leave --out off to keep the run under the runs directory."
|
|
4434
4458
|
});
|
|
4435
4459
|
}
|
|
4436
|
-
ensurePrivateDir2(
|
|
4460
|
+
ensurePrivateDir2(dir3);
|
|
4437
4461
|
for (const name of ["results.csv", "invalid.csv", "plan.json", "summary.json", "state.json"]) {
|
|
4438
|
-
await unlink2(join6(
|
|
4462
|
+
await unlink2(join6(dir3, name)).catch(() => void 0);
|
|
4439
4463
|
}
|
|
4440
4464
|
try {
|
|
4441
4465
|
ensurePrivateDir2(root2);
|
|
4442
|
-
await symlink(
|
|
4466
|
+
await symlink(dir3, join6(root2, runId), "junction");
|
|
4443
4467
|
} catch (err) {
|
|
4444
|
-
ctx.output.warn(`Could not link ${
|
|
4468
|
+
ctx.output.warn(`Could not link ${dir3} into ${root2} (${errorText(err)}): kenso runs will not list this run.`);
|
|
4445
4469
|
}
|
|
4446
|
-
return
|
|
4470
|
+
return dir3;
|
|
4447
4471
|
}
|
|
4448
4472
|
async function allSucceeded(run, totalRows) {
|
|
4449
4473
|
const previous = await readResults(filesOf(run.dir).resultsNdjson);
|
|
@@ -4480,14 +4504,14 @@ async function alreadyDone(run, totalRows, started, ctx) {
|
|
|
4480
4504
|
}
|
|
4481
4505
|
async function dryRun(spec, ctx, plan) {
|
|
4482
4506
|
let runId;
|
|
4483
|
-
let
|
|
4507
|
+
let dir3;
|
|
4484
4508
|
const target2 = plan.finished ?? plan.resumable;
|
|
4485
4509
|
if (target2) {
|
|
4486
4510
|
runId = target2.runId;
|
|
4487
|
-
|
|
4511
|
+
dir3 = target2.dir;
|
|
4488
4512
|
} else {
|
|
4489
4513
|
runId = newRunId();
|
|
4490
|
-
|
|
4514
|
+
dir3 = await prepareRunDir(spec.outDir, runId, plan.identical, ctx);
|
|
4491
4515
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4492
4516
|
await writeRunRecord({
|
|
4493
4517
|
runId,
|
|
@@ -4500,7 +4524,7 @@ async function dryRun(spec, ctx, plan) {
|
|
|
4500
4524
|
status: "planned",
|
|
4501
4525
|
chunkCount: plan.chunkCount,
|
|
4502
4526
|
chunksDone: [],
|
|
4503
|
-
dir:
|
|
4527
|
+
dir: dir3,
|
|
4504
4528
|
rows: plan.totalRows,
|
|
4505
4529
|
chunkSize: spec.chunkSize,
|
|
4506
4530
|
itemsSha256: plan.itemsSha256,
|
|
@@ -4508,7 +4532,7 @@ async function dryRun(spec, ctx, plan) {
|
|
|
4508
4532
|
updatedAt: now
|
|
4509
4533
|
});
|
|
4510
4534
|
}
|
|
4511
|
-
const files = filesOf(
|
|
4535
|
+
const files = filesOf(dir3);
|
|
4512
4536
|
const planBody = {
|
|
4513
4537
|
dryRun: true,
|
|
4514
4538
|
command: spec.command,
|
|
@@ -4535,7 +4559,7 @@ async function dryRun(spec, ctx, plan) {
|
|
|
4535
4559
|
ctx.output.summary(summary);
|
|
4536
4560
|
return {
|
|
4537
4561
|
runId,
|
|
4538
|
-
dir:
|
|
4562
|
+
dir: dir3,
|
|
4539
4563
|
resultsCsv: files.resultsCsv,
|
|
4540
4564
|
resultsNdjson: files.resultsNdjson,
|
|
4541
4565
|
invalidCsv: plan.invalid.length > 0 ? files.invalidCsv : void 0,
|
|
@@ -4614,7 +4638,7 @@ async function runBatch(spec, ctx) {
|
|
|
4614
4638
|
};
|
|
4615
4639
|
} else {
|
|
4616
4640
|
const runId = newRunId();
|
|
4617
|
-
const
|
|
4641
|
+
const dir3 = await prepareRunDir(spec.outDir, runId, identical, ctx);
|
|
4618
4642
|
record3 = {
|
|
4619
4643
|
runId,
|
|
4620
4644
|
command: spec.command,
|
|
@@ -4626,7 +4650,7 @@ async function runBatch(spec, ctx) {
|
|
|
4626
4650
|
status: "running",
|
|
4627
4651
|
chunkCount,
|
|
4628
4652
|
chunksDone: [],
|
|
4629
|
-
dir:
|
|
4653
|
+
dir: dir3,
|
|
4630
4654
|
rows: totalRows,
|
|
4631
4655
|
chunkSize: spec.chunkSize,
|
|
4632
4656
|
itemsSha256,
|
|
@@ -7512,6 +7536,9 @@ ${STREAM_HELP}` : op.method === "GET" ? "" : op.read === true ? "\nA read: it se
|
|
|
7512
7536
|
resource: op.resource,
|
|
7513
7537
|
action: op.action,
|
|
7514
7538
|
summary: op.summary ?? `${op.method} ${op.path}`,
|
|
7539
|
+
// A manifest written before effects existed has none: a write, so read-only mode refuses it.
|
|
7540
|
+
effect: op.effect ?? "write",
|
|
7541
|
+
...op.credits ? { cost: op.credits } : {},
|
|
7515
7542
|
description: op.description ? `${helpNotes(op)}
|
|
7516
7543
|
|
|
7517
7544
|
${api}` : api,
|
|
@@ -7608,9 +7635,9 @@ async function resolveGenerated(resource, action) {
|
|
|
7608
7635
|
const { operationToCommand: operationToCommand2 } = await Promise.resolve().then(() => (init_execute(), execute_exports));
|
|
7609
7636
|
return operationToCommand2(op);
|
|
7610
7637
|
}
|
|
7611
|
-
async function featuresFromEnv(env, flags = {},
|
|
7638
|
+
async function featuresFromEnv(env, flags = {}, overrides2 = {}) {
|
|
7612
7639
|
try {
|
|
7613
|
-
const ctx = createContext(flags, env, { ...
|
|
7640
|
+
const ctx = createContext(flags, env, { ...overrides2, stdout: DISCARD, stderr: DISCARD });
|
|
7614
7641
|
return await loadWorkspaceFeatures(ctx, { timeoutMs: HELP_FEATURES_TIMEOUT_MS });
|
|
7615
7642
|
} catch {
|
|
7616
7643
|
return { features: [] };
|
|
@@ -7630,6 +7657,7 @@ async function listGenerated(opts = {}) {
|
|
|
7630
7657
|
resource: op.resource,
|
|
7631
7658
|
action: op.action,
|
|
7632
7659
|
summary: op.summary ?? `${op.method} ${op.path}`,
|
|
7660
|
+
effect: op.effect ?? "write",
|
|
7633
7661
|
beta: !gateSatisfied(op.featureGates, features),
|
|
7634
7662
|
...op.featureGates ? { featureGates: op.featureGates } : {}
|
|
7635
7663
|
}));
|
|
@@ -7648,6 +7676,187 @@ var init_generated_hook = __esm({
|
|
|
7648
7676
|
}
|
|
7649
7677
|
});
|
|
7650
7678
|
|
|
7679
|
+
// src/manifest/data.ts
|
|
7680
|
+
import { readFileSync as readFileSync6 } from "node:fs";
|
|
7681
|
+
function readDataFile(name) {
|
|
7682
|
+
if (overrides.has(name)) return overrides.get(name);
|
|
7683
|
+
if (!cache.has(name)) {
|
|
7684
|
+
let value;
|
|
7685
|
+
try {
|
|
7686
|
+
value = JSON.parse(readFileSync6(new URL(name, dir2), "utf8"));
|
|
7687
|
+
} catch {
|
|
7688
|
+
value = void 0;
|
|
7689
|
+
}
|
|
7690
|
+
cache.set(name, value);
|
|
7691
|
+
}
|
|
7692
|
+
return cache.get(name);
|
|
7693
|
+
}
|
|
7694
|
+
var dir2, cache, overrides;
|
|
7695
|
+
var init_data = __esm({
|
|
7696
|
+
"src/manifest/data.ts"() {
|
|
7697
|
+
"use strict";
|
|
7698
|
+
dir2 = new URL("./", import.meta.url);
|
|
7699
|
+
cache = /* @__PURE__ */ new Map();
|
|
7700
|
+
overrides = /* @__PURE__ */ new Map();
|
|
7701
|
+
}
|
|
7702
|
+
});
|
|
7703
|
+
|
|
7704
|
+
// src/core/rate-card.ts
|
|
7705
|
+
import { readFileSync as readFileSync7, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
7706
|
+
import { join as join8 } from "node:path";
|
|
7707
|
+
import { Writable as Writable2 } from "node:stream";
|
|
7708
|
+
function cleanItems(value) {
|
|
7709
|
+
if (!Array.isArray(value)) return [];
|
|
7710
|
+
const out = [];
|
|
7711
|
+
for (const raw of value) {
|
|
7712
|
+
if (raw === null || typeof raw !== "object" || typeof raw.action !== "string") continue;
|
|
7713
|
+
const item = {};
|
|
7714
|
+
for (const key of ITEM_KEYS) {
|
|
7715
|
+
const field = raw[key];
|
|
7716
|
+
if (typeof field === "string" || typeof field === "number") item[key] = field;
|
|
7717
|
+
}
|
|
7718
|
+
out.push(item);
|
|
7719
|
+
}
|
|
7720
|
+
return out;
|
|
7721
|
+
}
|
|
7722
|
+
function bundledCards() {
|
|
7723
|
+
const data = readDataFile(DATA_FILE);
|
|
7724
|
+
const cards = [];
|
|
7725
|
+
for (const card of Array.isArray(data?.cards) ? data.cards : []) {
|
|
7726
|
+
if (typeof card.version === "number") cards.push({ version: card.version, source: "bundled", items: cleanItems(card.items) });
|
|
7727
|
+
}
|
|
7728
|
+
return cards;
|
|
7729
|
+
}
|
|
7730
|
+
function readCache2(file) {
|
|
7731
|
+
try {
|
|
7732
|
+
const parsed2 = JSON.parse(readFileSync7(file, "utf8"));
|
|
7733
|
+
return parsed2 !== null && typeof parsed2 === "object" && !Array.isArray(parsed2) ? parsed2 : {};
|
|
7734
|
+
} catch {
|
|
7735
|
+
return {};
|
|
7736
|
+
}
|
|
7737
|
+
}
|
|
7738
|
+
function isFresh2(entry, now) {
|
|
7739
|
+
if (!entry || typeof entry.version !== "number" || !Array.isArray(entry.items)) return false;
|
|
7740
|
+
const at = Date.parse(entry.fetchedAt);
|
|
7741
|
+
return Number.isFinite(at) && now - at >= 0 && now - at < TTL_MS2;
|
|
7742
|
+
}
|
|
7743
|
+
function writeCache(file, cache2, key, entry, now) {
|
|
7744
|
+
try {
|
|
7745
|
+
const kept = {};
|
|
7746
|
+
for (const [k, old] of Object.entries(cache2)) if (isFresh2(old, now)) kept[k] = old;
|
|
7747
|
+
kept[key] = entry;
|
|
7748
|
+
const temp = `${file}.${process.pid}.tmp`;
|
|
7749
|
+
writeFileSync3(temp, `${JSON.stringify(kept)}
|
|
7750
|
+
`, { mode: 384 });
|
|
7751
|
+
renameSync3(temp, file);
|
|
7752
|
+
} catch {
|
|
7753
|
+
}
|
|
7754
|
+
}
|
|
7755
|
+
async function loadRateCards(ctx, opts = {}) {
|
|
7756
|
+
const key = featureCacheKey(ctx.auth);
|
|
7757
|
+
if (!key) return bundledCards();
|
|
7758
|
+
const now = Date.now();
|
|
7759
|
+
let file;
|
|
7760
|
+
let cache2 = {};
|
|
7761
|
+
try {
|
|
7762
|
+
file = join8(cacheDir(ctx.env), CACHE_FILE2);
|
|
7763
|
+
cache2 = readCache2(file);
|
|
7764
|
+
} catch {
|
|
7765
|
+
file = void 0;
|
|
7766
|
+
}
|
|
7767
|
+
const entry = cache2[key];
|
|
7768
|
+
const hit = isFresh2(entry, now) ? entry : void 0;
|
|
7769
|
+
const offline = () => hit ? [{ version: hit.version, source: "cache", items: cleanItems(hit.items) }] : bundledCards();
|
|
7770
|
+
if (opts.live === false || opts.live === void 0 && hit) return offline();
|
|
7771
|
+
try {
|
|
7772
|
+
const signal = AbortSignal.any([ctx.signal, AbortSignal.timeout(opts.timeoutMs ?? FETCH_TIMEOUT_MS2)]);
|
|
7773
|
+
const res = await ctx.client.request({ method: "GET", path: "/v1/credits/rate-card", signal });
|
|
7774
|
+
const card = unwrap(res.body);
|
|
7775
|
+
if (!card || typeof card.version !== "number") return offline();
|
|
7776
|
+
const items = cleanItems(card.items);
|
|
7777
|
+
if (file) writeCache(file, cache2, key, { version: card.version, items, fetchedAt: new Date(now).toISOString() }, now);
|
|
7778
|
+
return [{ version: card.version, source: "live", items }];
|
|
7779
|
+
} catch {
|
|
7780
|
+
return offline();
|
|
7781
|
+
}
|
|
7782
|
+
}
|
|
7783
|
+
async function rateCardsForHelp(env, flags = {}, overrides2 = {}) {
|
|
7784
|
+
try {
|
|
7785
|
+
const ctx = createContext(flags, env, { ...overrides2, stdout: DISCARD2, stderr: DISCARD2 });
|
|
7786
|
+
return await loadRateCards(ctx, { timeoutMs: HELP_RATE_CARD_TIMEOUT_MS });
|
|
7787
|
+
} catch {
|
|
7788
|
+
return bundledCards();
|
|
7789
|
+
}
|
|
7790
|
+
}
|
|
7791
|
+
function credits(millicredits) {
|
|
7792
|
+
return String(Number((millicredits / 1e3).toFixed(3)));
|
|
7793
|
+
}
|
|
7794
|
+
function unitPrice(item, line) {
|
|
7795
|
+
if ((item.millicreditsPerUnit ?? 0) === 0) {
|
|
7796
|
+
const note = (item.note ?? "").replace(/^not charged in credits\.?\s*/i, "").replace(/\.$/, "");
|
|
7797
|
+
return `not charged in credits${note ? ` (${note})` : ""}`;
|
|
7798
|
+
}
|
|
7799
|
+
const amount = credits(item.millicreditsPerUnit ?? 0);
|
|
7800
|
+
const billing = item.billing ?? line.billing;
|
|
7801
|
+
const period = billing === "monthly" ? " per month" : billing === "yearly" ? " per year" : "";
|
|
7802
|
+
return `${amount} ${amount === "1" ? "credit" : "credits"} per ${item.unit ?? line.unit ?? "unit"}${period}`;
|
|
7803
|
+
}
|
|
7804
|
+
function priceLine(line, cards) {
|
|
7805
|
+
if (line.pricing === "varies") return `${line.action}: price depends on the work; --dry-run prints the estimate where the command has one`;
|
|
7806
|
+
const priced = [];
|
|
7807
|
+
for (const card of cards) {
|
|
7808
|
+
const item = card.items.find((candidate) => candidate.action === line.action && (candidate.pricing ?? "fixed") === "fixed");
|
|
7809
|
+
if (item) priced.push({ card, item });
|
|
7810
|
+
}
|
|
7811
|
+
if (priced.length === 0) return `${line.action}: charged, not on the rate card (${RATE_CARD_COMMAND})`;
|
|
7812
|
+
const named = cards.length > 1;
|
|
7813
|
+
return `${line.action}: ${priced.map(({ card, item }) => `${unitPrice(item, line)}${named ? ` (rate card v${card.version})` : ""}`).join(", ")}`;
|
|
7814
|
+
}
|
|
7815
|
+
var CACHE_FILE2, DATA_FILE, TTL_MS2, FETCH_TIMEOUT_MS2, ITEM_KEYS, HELP_RATE_CARD_TIMEOUT_MS, RATE_CARD_COMMAND, DISCARD2;
|
|
7816
|
+
var init_rate_card = __esm({
|
|
7817
|
+
"src/core/rate-card.ts"() {
|
|
7818
|
+
"use strict";
|
|
7819
|
+
init_data();
|
|
7820
|
+
init_config();
|
|
7821
|
+
init_context();
|
|
7822
|
+
init_features();
|
|
7823
|
+
init_http();
|
|
7824
|
+
CACHE_FILE2 = "rate-card.json";
|
|
7825
|
+
DATA_FILE = "pricing.json";
|
|
7826
|
+
TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
7827
|
+
FETCH_TIMEOUT_MS2 = 5e3;
|
|
7828
|
+
ITEM_KEYS = ["action", "unit", "unitSize", "millicreditsPerUnit", "billing", "pricing", "note"];
|
|
7829
|
+
HELP_RATE_CARD_TIMEOUT_MS = 1500;
|
|
7830
|
+
RATE_CARD_COMMAND = "kenso credit-rate-card get";
|
|
7831
|
+
DISCARD2 = new Writable2({
|
|
7832
|
+
write(_chunk, _encoding, callback) {
|
|
7833
|
+
callback();
|
|
7834
|
+
}
|
|
7835
|
+
});
|
|
7836
|
+
}
|
|
7837
|
+
});
|
|
7838
|
+
|
|
7839
|
+
// src/commands/help-effect.ts
|
|
7840
|
+
function effectAndCost(spec, rateCards) {
|
|
7841
|
+
const lines = [`Effect: ${spec.effect ?? "write"}.`];
|
|
7842
|
+
if (spec.cost && spec.cost.length > 0) {
|
|
7843
|
+
const cards = rateCards ?? bundledCards();
|
|
7844
|
+
lines.push(`Cost: ${spec.cost.map((line) => priceLine(line, cards)).join("; ")}.`);
|
|
7845
|
+
} else if (spec.doc?.cost) {
|
|
7846
|
+
lines.push(`Cost: ${spec.doc.cost}`);
|
|
7847
|
+
}
|
|
7848
|
+
return lines;
|
|
7849
|
+
}
|
|
7850
|
+
function effectMark(effect) {
|
|
7851
|
+
return (effect ?? "write") === "read" ? "" : ` (${effect ?? "write"})`;
|
|
7852
|
+
}
|
|
7853
|
+
var init_help_effect = __esm({
|
|
7854
|
+
"src/commands/help-effect.ts"() {
|
|
7855
|
+
"use strict";
|
|
7856
|
+
init_rate_card();
|
|
7857
|
+
}
|
|
7858
|
+
});
|
|
7859
|
+
|
|
7651
7860
|
// src/commands/people/columns.ts
|
|
7652
7861
|
function normalizeHeader(header) {
|
|
7653
7862
|
return header.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
@@ -7933,6 +8142,7 @@ var init_import = __esm({
|
|
|
7933
8142
|
action: "import",
|
|
7934
8143
|
summary: "Create accounts (companies) from a CSV or JSONL file, charged per created account; a file of people: people import",
|
|
7935
8144
|
brief: "companies, charged per new account",
|
|
8145
|
+
effect: "spend",
|
|
7936
8146
|
description: "Sends the rows to accounts.bulk-create, 100 per call. Columns map by name (case, spaces and dashes ignored) to the account fields: name (or company), domains (split on , or ;) or one domain (domain, website, companyDomain), industry, employeeCount, hqLocation, linkedinUrl, stage, angle, whyNow, fitScore, fundingRound, cadenceDays, ownerMemberId, kenCompanyId, sendsFromInboxId, sendsFromLinkedInAccountId and source. A company that is already an account is skipped (domain_taken) with that account's id. Without --yes it prints the plan with a credit estimate; research runs for each created account.",
|
|
7937
8147
|
flags: {
|
|
7938
8148
|
file: { type: "string", required: true, description: "The CSV or JSONL file, or - for stdin" },
|
|
@@ -8182,6 +8392,7 @@ var init_wait = __esm({
|
|
|
8182
8392
|
resource: "jobs",
|
|
8183
8393
|
action: "wait",
|
|
8184
8394
|
summary: "Wait for a background job and print it",
|
|
8395
|
+
effect: "read",
|
|
8185
8396
|
description: "Polls GET /v1/jobs/{jobId}?type=<type> every 2 s (every 10 s after the first minute) until the job succeeds, fails or is canceled, then prints the job. Exit 0 when it succeeded, 1 when it failed, was canceled or is still running when --timeout passes.",
|
|
8186
8397
|
flags: {
|
|
8187
8398
|
type: { type: "string", required: true, description: "The job type, for example contact_import or contact_export" },
|
|
@@ -8339,6 +8550,7 @@ function bulkUpdateCommand(target2) {
|
|
|
8339
8550
|
action: "bulk-update",
|
|
8340
8551
|
summary: `Change fields on many ${target2.plural} at once: by --ids, or everything a --filter matches`,
|
|
8341
8552
|
brief: "--filter --set",
|
|
8553
|
+
effect: "write",
|
|
8342
8554
|
description: `Calls POST /v1/${target2.resource}/bulk-update, which makes a change set: the ${target2.plural} it names and, for each, the field, its value before and its value after. Without --yes (or with --dry-run) it only previews: it prints count and a sample, writes nothing, and names the command that applies exactly those ${target2.plural}. With --yes it writes them in the background and waits. Fields for --set: ${target2.fields.join(", ")}${Object.keys(target2.aliases).length > 0 ? ` (${Object.entries(target2.aliases).map(([short, field]) => `${short} = ${field}`).join(", ")})` : ""}. A custom field is custom.<key> with a value of its type (GET /v1/fields gives the keys). ` + (target2.tags ? "--add-tag and --remove-tag put tags on or take them off (kenso tags list gives the ids); undo takes off only what the change put on. " : "") + `A value of null clears the field. A ${target2.noun} that changed after the preview is left alone and counted as a conflict. Exit 5 when some records failed or conflicted.`,
|
|
8343
8555
|
flags: {
|
|
8344
8556
|
ids: FLAGS.ids(target2),
|
|
@@ -8372,6 +8584,7 @@ function bulkDeleteCommand(target2) {
|
|
|
8372
8584
|
action: "bulk-delete",
|
|
8373
8585
|
summary: `Delete many ${target2.plural} at once: by --ids, or everything a --filter matches`,
|
|
8374
8586
|
brief: "--filter --yes",
|
|
8587
|
+
effect: "destructive",
|
|
8375
8588
|
description: `Calls POST /v1/${target2.resource}/bulk-delete, which makes a change set that lists every ${target2.noun} it would delete. Without --yes (or with --dry-run) it only previews: it prints count and a sample, deletes nothing, and names the command that deletes exactly those ${target2.plural}. With --yes it deletes them in the background and waits. Each ${target2.noun} is deleted as kenso ${target2.resource} delete deletes it, so one that cannot be deleted is counted as failed and the rest go on. ` + (target2.resource === "accounts" ? "kenso changes undo restores the accounts for 30 days. " : "A delete is not undone with kenso changes undo. ") + "Exit 5 when some records failed.",
|
|
8376
8589
|
flags: {
|
|
8377
8590
|
ids: FLAGS.ids(target2),
|
|
@@ -8498,6 +8711,7 @@ var init_merge = __esm({
|
|
|
8498
8711
|
resource: "accounts",
|
|
8499
8712
|
action: "merge",
|
|
8500
8713
|
summary: "Merge an account into the one you keep. --dry-run shows what would change and writes nothing",
|
|
8714
|
+
effect: "destructive",
|
|
8501
8715
|
description: "Sends POST /v1/accounts/{accountId}/merge with intoAccountId, the account to keep. The kept account keeps every field a person set and takes the merged account's value where its own is blank; domains, people, deals, touches, research and tags move to it. A merge cannot be undone. With --dry-run the API runs the merge, answers mergeSummary (fieldChanges with the value before and after, and the counts moved) and rolls it back: nothing is written. A real merge answers the kept account with the same mergeSummary and its mergeId, which `kenso accounts merges <mergeId>` opens later with the merged account's values as they were.",
|
|
8502
8716
|
flags: {
|
|
8503
8717
|
into: { type: "string", description: "The id of the account to keep" },
|
|
@@ -8546,7 +8760,7 @@ var init_merge = __esm({
|
|
|
8546
8760
|
|
|
8547
8761
|
// src/commands/work/common.ts
|
|
8548
8762
|
import { randomUUID } from "node:crypto";
|
|
8549
|
-
import { join as
|
|
8763
|
+
import { join as join9 } from "node:path";
|
|
8550
8764
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
8551
8765
|
function unavailable(err) {
|
|
8552
8766
|
return err instanceof KensoError && (err.code === "network_error" || err.httpStatus === 502 || err.httpStatus === 503 || err.httpStatus === 504);
|
|
@@ -8620,8 +8834,8 @@ function leaseMinutes(flags) {
|
|
|
8620
8834
|
function shellQuote5(value) {
|
|
8621
8835
|
return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
8622
8836
|
}
|
|
8623
|
-
function submitCommand(
|
|
8624
|
-
return `kenso work submit ${shellQuote5(
|
|
8837
|
+
function submitCommand(dir3) {
|
|
8838
|
+
return `kenso work submit ${shellQuote5(join9(dir3, "/"))}*.answers.json`;
|
|
8625
8839
|
}
|
|
8626
8840
|
function explainNotFound(err) {
|
|
8627
8841
|
if (!(err instanceof KensoError) || err.httpStatus !== 404 || err.hint !== void 0) return err;
|
|
@@ -8748,6 +8962,8 @@ var init_duplicates = __esm({
|
|
|
8748
8962
|
resource: "accounts",
|
|
8749
8963
|
action: "duplicates",
|
|
8750
8964
|
summary: "List the account pairs that look like duplicates. --scan looks for new pairs first",
|
|
8965
|
+
effect: "write",
|
|
8966
|
+
effectFor: ({ flags }) => flags.scan === true ? "write" : "read",
|
|
8751
8967
|
description: "Reads GET /v1/account-duplicates: each pair with both accounts (account and otherAccount: name, domain, stage, owner, last touch), why they were paired (reasons: domain, linkedin, name) and isCertain (same domain and same name, the pairs Ken merges itself where that is on; heldReason says why Ken left one). --status picks open (the default), dismissed or merged. --scan sends POST /v1/account-duplicates/scan first, which compares every account of the workspace and needs a plan with accounts. Merge a pair with `kenso accounts merge <accountId> --into <id>`, or answer that it is not a duplicate with `kenso account-duplicates dismiss --duplicate-id <duplicateId>`.",
|
|
8752
8968
|
flags: {
|
|
8753
8969
|
status: { type: "string", description: "open (default), dismissed or merged" },
|
|
@@ -8821,6 +9037,7 @@ var init_merges = __esm({
|
|
|
8821
9037
|
resource: "accounts",
|
|
8822
9038
|
action: "merges",
|
|
8823
9039
|
summary: "List the account merges, newest first, or open one with the merged account's values as they were",
|
|
9040
|
+
effect: "read",
|
|
8824
9041
|
description: "`kenso accounts merges list` reads GET /v1/account-merges: each merge with the kept and the merged-away account, who merged, when and what moved. --merged-by system shows the merges Ken made itself of certain duplicates (same domain and same name). `kenso accounts merges <mergeId>` reads GET /v1/account-merges/{mergeId}, which adds mergedValues: the merged-away account before the merge (name, domains, stage, owner, tier, firmographics, custom fields), the values to copy back by hand when a merge was wrong.",
|
|
8825
9042
|
flags: {
|
|
8826
9043
|
"merged-by": { type: "string", description: "user, agent, api_key, workflow or system (Ken's own merges)" },
|
|
@@ -9031,10 +9248,10 @@ var init_embedded = __esm({
|
|
|
9031
9248
|
});
|
|
9032
9249
|
|
|
9033
9250
|
// src/commands/docs/content.ts
|
|
9034
|
-
import { readFileSync as
|
|
9251
|
+
import { readFileSync as readFileSync8 } from "node:fs";
|
|
9035
9252
|
function readOptional(url) {
|
|
9036
9253
|
try {
|
|
9037
|
-
return
|
|
9254
|
+
return readFileSync8(url, "utf8");
|
|
9038
9255
|
} catch {
|
|
9039
9256
|
return void 0;
|
|
9040
9257
|
}
|
|
@@ -9045,7 +9262,7 @@ async function topicText(topic) {
|
|
|
9045
9262
|
}
|
|
9046
9263
|
async function skillText() {
|
|
9047
9264
|
if (!fromSource) return (await Promise.resolve().then(() => (init_embedded(), embedded_exports))).SKILL;
|
|
9048
|
-
return
|
|
9265
|
+
return readFileSync8(new URL("skill/kenso-cli/SKILL.md", root), "utf8");
|
|
9049
9266
|
}
|
|
9050
9267
|
var TOPICS, fromSource, root;
|
|
9051
9268
|
var init_content = __esm({
|
|
@@ -9254,28 +9471,28 @@ var init_client = __esm({
|
|
|
9254
9471
|
|
|
9255
9472
|
// src/commands/skill/clients.ts
|
|
9256
9473
|
import { homedir as homedir2 } from "node:os";
|
|
9257
|
-
import { join as
|
|
9474
|
+
import { join as join10 } from "node:path";
|
|
9258
9475
|
function home(env) {
|
|
9259
9476
|
return env.HOME?.trim() || env.USERPROFILE?.trim() || homedir2();
|
|
9260
9477
|
}
|
|
9261
9478
|
function claudeDir(env) {
|
|
9262
|
-
return env.CLAUDE_CONFIG_DIR?.trim() ||
|
|
9479
|
+
return env.CLAUDE_CONFIG_DIR?.trim() || join10(home(env), ".claude");
|
|
9263
9480
|
}
|
|
9264
9481
|
function xdgConfigDir(env) {
|
|
9265
|
-
return env.XDG_CONFIG_HOME?.trim() ||
|
|
9482
|
+
return env.XDG_CONFIG_HOME?.trim() || join10(home(env), ".config");
|
|
9266
9483
|
}
|
|
9267
9484
|
function skillsFolder(client, env) {
|
|
9268
9485
|
switch (client) {
|
|
9269
9486
|
case "claude-code":
|
|
9270
|
-
return
|
|
9487
|
+
return join10(claudeDir(env), "skills");
|
|
9271
9488
|
case "codex":
|
|
9272
|
-
return
|
|
9489
|
+
return join10(home(env), ".agents", "skills");
|
|
9273
9490
|
case "cursor":
|
|
9274
|
-
return
|
|
9491
|
+
return join10(home(env), ".cursor", "skills");
|
|
9275
9492
|
case "gemini":
|
|
9276
|
-
return
|
|
9493
|
+
return join10(home(env), ".gemini", "skills");
|
|
9277
9494
|
case "opencode":
|
|
9278
|
-
return
|
|
9495
|
+
return join10(xdgConfigDir(env), "opencode", "skills");
|
|
9279
9496
|
}
|
|
9280
9497
|
}
|
|
9281
9498
|
var CLIENTS, CLIENT_CHOICES, CLIENT_NAMES, AGENT_CLIENTS;
|
|
@@ -9305,15 +9522,15 @@ __export(install_exports, {
|
|
|
9305
9522
|
readExisting: () => readExisting,
|
|
9306
9523
|
write: () => write
|
|
9307
9524
|
});
|
|
9308
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as
|
|
9309
|
-
import { basename as basename2, dirname, join as
|
|
9525
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync9, renameSync as renameSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
9526
|
+
import { basename as basename2, dirname, join as join11, resolve as resolve6 } from "node:path";
|
|
9310
9527
|
function quote(value) {
|
|
9311
9528
|
return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
9312
9529
|
}
|
|
9313
9530
|
function readExisting(path) {
|
|
9314
9531
|
if (!existsSync4(path)) return void 0;
|
|
9315
9532
|
try {
|
|
9316
|
-
return
|
|
9533
|
+
return readFileSync9(path, "utf8");
|
|
9317
9534
|
} catch (err) {
|
|
9318
9535
|
const code = err.code;
|
|
9319
9536
|
throw new KensoError({ code: "file_unreadable", message: `Cannot read ${path}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Usage });
|
|
@@ -9323,17 +9540,17 @@ function write(path, text4) {
|
|
|
9323
9540
|
try {
|
|
9324
9541
|
mkdirSync3(dirname(path), { recursive: true });
|
|
9325
9542
|
const temp = `${path}.${process.pid}.tmp`;
|
|
9326
|
-
|
|
9327
|
-
|
|
9543
|
+
writeFileSync4(temp, text4);
|
|
9544
|
+
renameSync4(temp, path);
|
|
9328
9545
|
} catch (err) {
|
|
9329
9546
|
const code = err.code;
|
|
9330
9547
|
throw new KensoError({ code: "file_unwritable", message: `Cannot write ${path}${code ? ` (${code})` : ""}.`, exitCode: ExitCode.Error });
|
|
9331
9548
|
}
|
|
9332
9549
|
}
|
|
9333
|
-
function folders(ctx, client,
|
|
9334
|
-
if (
|
|
9550
|
+
function folders(ctx, client, dir3) {
|
|
9551
|
+
if (dir3 !== void 0) return [{ client, folder: resolve6(dir3) }];
|
|
9335
9552
|
const clients = client === "all" ? CLIENTS : [client];
|
|
9336
|
-
return clients.map((c) => ({ client: c, folder:
|
|
9553
|
+
return clients.map((c) => ({ client: c, folder: join11(skillsFolder(c, ctx.env), SKILL_NAME) }));
|
|
9337
9554
|
}
|
|
9338
9555
|
function installCommand(opts) {
|
|
9339
9556
|
const parts2 = ["kenso skill install"];
|
|
@@ -9357,6 +9574,7 @@ var init_install = __esm({
|
|
|
9357
9574
|
action: "install",
|
|
9358
9575
|
summary: "Install the kenso-cli skill for Claude Code, Codex, Cursor, Gemini CLI or OpenCode",
|
|
9359
9576
|
brief: "",
|
|
9577
|
+
effect: "read",
|
|
9360
9578
|
description: "Writes the Agent Skill bundled with this CLI to SKILL.md in each agent's skills folder: ~/.claude/skills/kenso-cli (Claude Code; $CLAUDE_CONFIG_DIR/skills when that is set), ~/.agents/skills/kenso-cli (Codex), ~/.cursor/skills/kenso-cli (Cursor), ~/.gemini/skills/kenso-cli (Gemini CLI) and ~/.config/opencode/skills/kenso-cli (OpenCode). The default client is the coding agent running the command when it is Claude Code, Codex or Cursor, else all of them. --dir writes into that folder instead. A different SKILL.md already there is replaced only with --force (exit 7 without it). --dry-run prints the plan and writes nothing. To also connect the Kenso MCP server: kenso agent setup.",
|
|
9361
9579
|
flags: {
|
|
9362
9580
|
client: { type: "string", description: "claude-code, codex, cursor, gemini, opencode or all (default: the detected agent, else all)" },
|
|
@@ -9367,21 +9585,21 @@ var init_install = __esm({
|
|
|
9367
9585
|
dryRun: true,
|
|
9368
9586
|
async run(ctx, { flags }) {
|
|
9369
9587
|
const clientFlag = typeof flags.client === "string" ? flags.client.trim() : void 0;
|
|
9370
|
-
const
|
|
9588
|
+
const dir3 = typeof flags.dir === "string" && flags.dir.trim() !== "" ? flags.dir : void 0;
|
|
9371
9589
|
if (clientFlag !== void 0 && !CLIENT_CHOICES.includes(clientFlag)) {
|
|
9372
9590
|
throw usageError(`--client must be one of ${CLIENT_CHOICES.join(", ")} (got "${clientFlag}").`, { field: "client", next: "kenso skill install --help" });
|
|
9373
9591
|
}
|
|
9374
9592
|
const client = clientFlag ?? (ctx.agent ? AGENT_CLIENTS2[ctx.agent.name] : void 0) ?? "all";
|
|
9375
9593
|
const text4 = await skillText();
|
|
9376
|
-
const targets = folders(ctx, client,
|
|
9377
|
-
const path =
|
|
9594
|
+
const targets = folders(ctx, client, dir3).map(({ client: c, folder }) => {
|
|
9595
|
+
const path = join11(folder, "SKILL.md");
|
|
9378
9596
|
const existing = readExisting(path);
|
|
9379
9597
|
const status = existing === void 0 ? "created" : existing === text4 ? "unchanged" : "replaced";
|
|
9380
9598
|
return { client: c, path, status };
|
|
9381
9599
|
});
|
|
9382
9600
|
const conflicts = targets.filter((t) => t.status === "replaced");
|
|
9383
9601
|
const needsForce = conflicts.length > 0 || flags.force === true;
|
|
9384
|
-
const next = installCommand({ client:
|
|
9602
|
+
const next = installCommand({ client: dir3 === void 0 ? client : clientFlag, dir: dir3, force: needsForce });
|
|
9385
9603
|
if (ctx.flags.dryRun) {
|
|
9386
9604
|
ctx.output.object({ dryRun: true, installed: targets, next });
|
|
9387
9605
|
return ExitCode.Ok;
|
|
@@ -9399,8 +9617,8 @@ var init_install = __esm({
|
|
|
9399
9617
|
for (const target2 of targets) {
|
|
9400
9618
|
if (target2.status !== "unchanged") write(target2.path, text4);
|
|
9401
9619
|
}
|
|
9402
|
-
if (
|
|
9403
|
-
ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve6(
|
|
9620
|
+
if (dir3 !== void 0 && basename2(resolve6(dir3)) !== SKILL_NAME) {
|
|
9621
|
+
ctx.output.warn(`Agents expect the skill's folder to be named ${SKILL_NAME}, like the skill: ${resolve6(dir3)} is not.`);
|
|
9404
9622
|
}
|
|
9405
9623
|
ctx.output.object({ installed: targets });
|
|
9406
9624
|
return ExitCode.Ok;
|
|
@@ -9412,8 +9630,8 @@ var init_install = __esm({
|
|
|
9412
9630
|
|
|
9413
9631
|
// src/commands/agent/mcp-config.ts
|
|
9414
9632
|
import { spawnSync } from "node:child_process";
|
|
9415
|
-
import { existsSync as existsSync5, readFileSync as
|
|
9416
|
-
import { delimiter, join as
|
|
9633
|
+
import { existsSync as existsSync5, readFileSync as readFileSync10 } from "node:fs";
|
|
9634
|
+
import { delimiter, join as join12 } from "node:path";
|
|
9417
9635
|
function parse2(text4) {
|
|
9418
9636
|
try {
|
|
9419
9637
|
const doc = JSON.parse(text4);
|
|
@@ -9470,9 +9688,9 @@ function tomlServers(text4) {
|
|
|
9470
9688
|
return entries2;
|
|
9471
9689
|
}
|
|
9472
9690
|
function opencodeFile(env) {
|
|
9473
|
-
const
|
|
9474
|
-
const existing = ["opencode.jsonc", "opencode.json", "config.json"].map((f) =>
|
|
9475
|
-
return existing ??
|
|
9691
|
+
const dir3 = join12(xdgConfigDir(env), "opencode");
|
|
9692
|
+
const existing = ["opencode.jsonc", "opencode.json", "config.json"].map((f) => join12(dir3, f)).find((f) => existsSync5(f));
|
|
9693
|
+
return existing ?? join12(dir3, "opencode.json");
|
|
9476
9694
|
}
|
|
9477
9695
|
function canonical(url) {
|
|
9478
9696
|
try {
|
|
@@ -9484,7 +9702,7 @@ function canonical(url) {
|
|
|
9484
9702
|
}
|
|
9485
9703
|
function onPath(bin, env) {
|
|
9486
9704
|
const names = process.platform === "win32" ? [`${bin}.cmd`, `${bin}.exe`, bin] : [bin];
|
|
9487
|
-
return (env.PATH ?? env.Path ?? "").split(delimiter).some((
|
|
9705
|
+
return (env.PATH ?? env.Path ?? "").split(delimiter).some((dir3) => dir3 !== "" && names.some((n) => existsSync5(join12(dir3, n))));
|
|
9488
9706
|
}
|
|
9489
9707
|
function isPresent(client, env) {
|
|
9490
9708
|
const t = TARGETS[client];
|
|
@@ -9492,7 +9710,7 @@ function isPresent(client, env) {
|
|
|
9492
9710
|
}
|
|
9493
9711
|
function readText2(path) {
|
|
9494
9712
|
try {
|
|
9495
|
-
return
|
|
9713
|
+
return readFileSync10(path, "utf8");
|
|
9496
9714
|
} catch {
|
|
9497
9715
|
return void 0;
|
|
9498
9716
|
}
|
|
@@ -9561,7 +9779,7 @@ var init_mcp_config = __esm({
|
|
|
9561
9779
|
"claude-code": {
|
|
9562
9780
|
bins: ["claude"],
|
|
9563
9781
|
folder: claudeDir,
|
|
9564
|
-
file: (env) => env.CLAUDE_CONFIG_DIR?.trim() ?
|
|
9782
|
+
file: (env) => env.CLAUDE_CONFIG_DIR?.trim() ? join12(env.CLAUDE_CONFIG_DIR.trim(), ".claude.json") : join12(home(env), ".claude.json"),
|
|
9565
9783
|
// User scope only: that is where setup adds it, and it reaches every project.
|
|
9566
9784
|
entries: (text4) => mcpServersOf(text4),
|
|
9567
9785
|
command: (url) => ["claude", "mcp", "add", "--scope", "user", "--transport", "http", SERVER_NAME, url],
|
|
@@ -9569,16 +9787,16 @@ var init_mcp_config = __esm({
|
|
|
9569
9787
|
},
|
|
9570
9788
|
codex: {
|
|
9571
9789
|
bins: ["codex"],
|
|
9572
|
-
folder: (env) => env.CODEX_HOME?.trim() ||
|
|
9573
|
-
file: (env) =>
|
|
9790
|
+
folder: (env) => env.CODEX_HOME?.trim() || join12(home(env), ".codex"),
|
|
9791
|
+
file: (env) => join12(env.CODEX_HOME?.trim() || join12(home(env), ".codex"), "config.toml"),
|
|
9574
9792
|
entries: tomlServers,
|
|
9575
9793
|
command: (url) => ["codex", "mcp", "add", SERVER_NAME, "--url", url],
|
|
9576
9794
|
signIn: "Run codex mcp login kenso."
|
|
9577
9795
|
},
|
|
9578
9796
|
cursor: {
|
|
9579
9797
|
bins: ["cursor", "cursor-agent"],
|
|
9580
|
-
folder: (env) =>
|
|
9581
|
-
file: (env) =>
|
|
9798
|
+
folder: (env) => join12(home(env), ".cursor"),
|
|
9799
|
+
file: (env) => join12(home(env), ".cursor", "mcp.json"),
|
|
9582
9800
|
entries: (text4) => mcpServersOf(text4),
|
|
9583
9801
|
merge: (doc, url) => {
|
|
9584
9802
|
const all = isDoc(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
|
|
@@ -9588,8 +9806,8 @@ var init_mcp_config = __esm({
|
|
|
9588
9806
|
},
|
|
9589
9807
|
gemini: {
|
|
9590
9808
|
bins: ["gemini"],
|
|
9591
|
-
folder: (env) =>
|
|
9592
|
-
file: (env) =>
|
|
9809
|
+
folder: (env) => join12(home(env), ".gemini"),
|
|
9810
|
+
file: (env) => join12(home(env), ".gemini", "settings.json"),
|
|
9593
9811
|
// httpUrl is Gemini CLI's Streamable HTTP key; url is SSE.
|
|
9594
9812
|
entries: (text4) => mcpServersOf(text4, ["httpUrl", "url"]),
|
|
9595
9813
|
command: (url) => ["gemini", "mcp", "add", "--scope", "user", "--transport", "http", SERVER_NAME, url],
|
|
@@ -9597,7 +9815,7 @@ var init_mcp_config = __esm({
|
|
|
9597
9815
|
},
|
|
9598
9816
|
opencode: {
|
|
9599
9817
|
bins: ["opencode"],
|
|
9600
|
-
folder: (env) =>
|
|
9818
|
+
folder: (env) => join12(xdgConfigDir(env), "opencode"),
|
|
9601
9819
|
file: opencodeFile,
|
|
9602
9820
|
// OpenCode 1.x lists servers under mcp; newer configs nest them under mcp.servers.
|
|
9603
9821
|
entries: (text4) => {
|
|
@@ -9621,7 +9839,7 @@ var setup_exports = {};
|
|
|
9621
9839
|
__export(setup_exports, {
|
|
9622
9840
|
default: () => setup_default
|
|
9623
9841
|
});
|
|
9624
|
-
import { join as
|
|
9842
|
+
import { join as join13 } from "node:path";
|
|
9625
9843
|
function quote2(value) {
|
|
9626
9844
|
return /^[A-Za-z0-9_\-.,:/@=+%~]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
9627
9845
|
}
|
|
@@ -9657,6 +9875,7 @@ var init_setup = __esm({
|
|
|
9657
9875
|
action: "setup",
|
|
9658
9876
|
summary: "Set up a coding agent for Kenso: the kenso-cli skill and the Kenso MCP server",
|
|
9659
9877
|
brief: "",
|
|
9878
|
+
effect: "read",
|
|
9660
9879
|
description: "Installs the kenso-cli Agent Skill (as kenso skill install does) and registers the Kenso MCP server (https://mcp.ken.so/mcp, or KENSO_MCP_URL) with Claude Code, Codex, Cursor, Gemini CLI or OpenCode. Claude Code, Codex and Gemini CLI register it with their own mcp add command at user scope; Cursor's ~/.cursor/mcp.json and OpenCode's opencode.json get the entry written. An MCP entry with the same URL under another name counts as registered; a kenso entry with another URL is left alone (status conflict). The default client is the coding agent running the command, else every one found on this machine. Without --yes it prints the plan and changes nothing. --status reports what is set up for every client and changes nothing. The person signs in to the MCP server once in the agent (OAuth in the browser): each client's next says how. Exits 1 when a client could not be set up, and 7 when a different SKILL.md is in the way without --force.",
|
|
9661
9880
|
flags: {
|
|
9662
9881
|
client: { type: "string", description: "claude-code, codex, cursor, gemini, opencode or all (default: the detected agent, else every one found)" },
|
|
@@ -9681,7 +9900,7 @@ var init_setup = __esm({
|
|
|
9681
9900
|
const clients = pickClients(ctx, clientFlag, status);
|
|
9682
9901
|
const text4 = await skillText();
|
|
9683
9902
|
const rows = clients.map((client) => {
|
|
9684
|
-
const path =
|
|
9903
|
+
const path = join13(skillsFolder(client, ctx.env), SKILL_NAME, "SKILL.md");
|
|
9685
9904
|
const existing = readExisting(path);
|
|
9686
9905
|
const skill = existing === void 0 ? "missing" : existing === text4 ? "installed" : "different";
|
|
9687
9906
|
return { client, present: isPresent(client, ctx.env), skill: { path, status: skill }, mcp: mcpState(client, ctx.env, url) };
|
|
@@ -9789,6 +10008,7 @@ var init_api3 = __esm({
|
|
|
9789
10008
|
init_exit_codes();
|
|
9790
10009
|
init_input();
|
|
9791
10010
|
init_transfer();
|
|
10011
|
+
init_manifest();
|
|
9792
10012
|
METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
9793
10013
|
DEFAULT_FILE_FIELD = "file";
|
|
9794
10014
|
command8 = {
|
|
@@ -9796,6 +10016,15 @@ var init_api3 = __esm({
|
|
|
9796
10016
|
action: "",
|
|
9797
10017
|
summary: "Call any API route, only when no command fits",
|
|
9798
10018
|
brief: "only when no command fits",
|
|
10019
|
+
effect: "destructive",
|
|
10020
|
+
// The effect of the route the call reaches (a GET that charges is a spend); a route the manifest does not know
|
|
10021
|
+
// goes by its method.
|
|
10022
|
+
effectFor({ positionals }) {
|
|
10023
|
+
const method = (positionals[0] ?? "").toUpperCase();
|
|
10024
|
+
const raw = positionals[1] ?? "";
|
|
10025
|
+
const path = URL.canParse(raw, "http://kenso.invalid") ? new URL(raw, "http://kenso.invalid").pathname : raw;
|
|
10026
|
+
return routeEffect(method, path) ?? (method === "GET" ? "read" : method === "DELETE" ? "destructive" : "write");
|
|
10027
|
+
},
|
|
9799
10028
|
description: "The raw escape hatch: sends Authorization, Ken-Version: 1.1 and X-Ken-Workspace-Id, prints the full JSON body. It reaches the legacy routes that have no command. The path may carry a query string. --all (GET only) follows pagination.nextCursor and prints the data[] items as a list. --file sends a multipart upload. An answer that is not JSON (a CSV, an image, a ZIP) prints as it came; --out saves it byte for byte, and a binary one is never printed to a terminal. POST, PUT and PATCH send at once; DELETE needs --yes (on a terminal it asks). --dry-run prints the request (method, path, body) and sends nothing.",
|
|
9800
10029
|
flags: {
|
|
9801
10030
|
data: { type: "string", description: "Request body: inline JSON, @file or - for stdin. With --file, its keys are form fields" },
|
|
@@ -9981,8 +10210,8 @@ async function wait(ms, ctx, deps) {
|
|
|
9981
10210
|
}
|
|
9982
10211
|
if (ctx.signal.aborted) throw interrupted4();
|
|
9983
10212
|
}
|
|
9984
|
-
async function browserLogin(ctx, opts,
|
|
9985
|
-
const deps = { ...defaultDeps, ...
|
|
10213
|
+
async function browserLogin(ctx, opts, overrides2) {
|
|
10214
|
+
const deps = { ...defaultDeps, ...overrides2 };
|
|
9986
10215
|
let started;
|
|
9987
10216
|
try {
|
|
9988
10217
|
const res = await ctx.client.request({
|
|
@@ -10181,6 +10410,7 @@ var init_login = __esm({
|
|
|
10181
10410
|
action: "login",
|
|
10182
10411
|
summary: "Log in through the browser, or save an API key from stdin with --with-key",
|
|
10183
10412
|
brief: "--with-key reads the key from stdin",
|
|
10413
|
+
effect: "read",
|
|
10184
10414
|
description: "With --with-key, reads one API key from stdin, checks it with GET /v1/me and saves it to the profile (--profile, KENSO_PROFILE or the active one) in ~/.kenso/config.json with mode 0600. The workspace is --workspace when the key can reach it, else the key's only workspace (a developer sandbox counts only when every workspace is one). The key is never a flag value: to use a key from an environment variable, pipe the variable in as the first example shows (an empty or malformed key is refused, exit 2, without printing it).",
|
|
10185
10415
|
flags: {
|
|
10186
10416
|
"with-key": { type: "boolean", description: "Read the API key from stdin" },
|
|
@@ -10324,6 +10554,7 @@ var init_logout = __esm({
|
|
|
10324
10554
|
resource: "auth",
|
|
10325
10555
|
action: "logout",
|
|
10326
10556
|
summary: "Remove a saved profile, and revoke the key browser login made",
|
|
10557
|
+
effect: "destructive",
|
|
10327
10558
|
description: "Removes the profile (--profile, KENSO_PROFILE or the active one) from ~/.kenso/config.json. When browser login made its key, it revokes that key first (--keep-key keeps it valid); if the revoke fails it warns and still removes the profile. A key saved with --with-key stays valid: revoke it at Settings > Integrations > API keys.",
|
|
10328
10559
|
flags: {
|
|
10329
10560
|
"keep-key": { type: "boolean", description: "Remove the profile but leave its key valid" }
|
|
@@ -10366,6 +10597,7 @@ var init_status = __esm({
|
|
|
10366
10597
|
resource: "auth",
|
|
10367
10598
|
action: "status",
|
|
10368
10599
|
summary: "Show the key's user, workspace and expiry",
|
|
10600
|
+
effect: "read",
|
|
10369
10601
|
description: `Reads GET /v1/me for the email and workspaces, and GET /v1/api-keys for the key's expiry. Warns on stderr when the key expires within ${EXPIRY_WARNING_DAYS} days. A sandbox test key (kenso_test_) adds keyKind "test" and the sandbox it works in.`,
|
|
10370
10602
|
flags: {},
|
|
10371
10603
|
examples: ["kenso auth status", "kenso auth status --profile client-a"],
|
|
@@ -10473,6 +10705,7 @@ var init_status2 = __esm({
|
|
|
10473
10705
|
resource: "capture",
|
|
10474
10706
|
action: "status",
|
|
10475
10707
|
summary: "Show your captured mailbox, its backfill progress and what teammates see of a captured email",
|
|
10708
|
+
effect: "read",
|
|
10476
10709
|
description: "Reads GET /v1/capture and prints it. mailbox is your own captured mailbox, or null when capture is not on for you: provider (google, microsoft), email, status (catching_up while the 90-day backfill runs, active, reconnect_needed, failed), failureReason, isPrivate (teammates see none of its email; meetings stay visible), connectedAt, lastSyncedAt and backfill (from, coveredFrom, isDone, messagesRead, messagesLogged). connection is the Google or Microsoft account you connected in Kenso with email access, or null: connect one in the app first. teammatesSee is summary (teammates read subject, people, time and Ken's summary; only the mailbox owner opens the body) or full_email. A workspace admin also gets members: every member's mailbox status, never mail. Needs an API key bound to a member (kenso auth login creates one).",
|
|
10477
10710
|
flags: {},
|
|
10478
10711
|
examples: ["kenso capture status", "kenso capture status --query 'mailbox.{status: status, read: backfill.messagesRead, logged: backfill.messagesLogged}'"],
|
|
@@ -10524,6 +10757,7 @@ var init_connect2 = __esm({
|
|
|
10524
10757
|
resource: "capture",
|
|
10525
10758
|
action: "connect",
|
|
10526
10759
|
summary: "Turn capture on for your own mailbox",
|
|
10760
|
+
effect: "write",
|
|
10527
10761
|
description: "Sends PUT /v1/capture/mailbox. Kenso then logs your email with people in Kenso on the person, the account and its open deals, starting with the newest mail and going back 90 days; kenso capture status shows the progress. Running it again changes nothing. It uses the Google or Microsoft account you connected in Kenso with email access. With none, the answer is mailbox_not_connected: run it with --provider to get a sign-in link (POST /v1/calendar-accounts/connect-sessions), open the link, sign in, then run kenso capture connect again. other_mailbox_connected means your captured mailbox needs its sign-in again and the account connected now is another one: sign in to the captured mailbox again, or run kenso capture disconnect and then connect. --dry-run prints the PUT and turns nothing on.",
|
|
10528
10762
|
flags: {
|
|
10529
10763
|
private: { type: "boolean", description: "Start with the Private switch on: teammates see none of this mailbox's email" },
|
|
@@ -10601,6 +10835,7 @@ var init_thread = __esm({
|
|
|
10601
10835
|
resource: "capture",
|
|
10602
10836
|
action: "thread",
|
|
10603
10837
|
summary: "Read one captured email thread",
|
|
10838
|
+
effect: "read",
|
|
10604
10839
|
description: "Reads GET /v1/capture/threads/{threadId} and prints it. threadId is capturedThread.id of an email_captured row on an account or person timeline (GET /v1/accounts/{accountId}/activity). Prints subject, Ken's summary, messageCount, lastMessageAt, access, isPrivate (your own Private switch for this thread, null when your mailbox does not hold it), holders (the members whose mailbox holds a message shown, most first, you included; a private mailbox is never named) and messages, oldest first: people, time, direction, access and body. body is filled only when access is full: your own mailbox holds the message, or the workspace lets teammates open the full email and a mailbox that is not private holds it. Kenso decides that on the server. Hide a thread with kenso capture private on --thread.",
|
|
10605
10840
|
flags: {},
|
|
10606
10841
|
positionals: [{ name: "threadId", required: true, description: "The captured thread id (capturedThread.id on a timeline row)" }],
|
|
@@ -10636,6 +10871,7 @@ var init_private = __esm({
|
|
|
10636
10871
|
resource: "capture",
|
|
10637
10872
|
action: "private",
|
|
10638
10873
|
summary: "Hide your captured email from teammates, or show it again",
|
|
10874
|
+
effect: "write",
|
|
10639
10875
|
description: "Sends PATCH /v1/capture/mailbox with isPrivate. on hides your captured email from teammates, mail already captured included: a teammate sees no trace of a thread only your mailbox holds, and a private mailbox creates no people or accounts. A message a teammate's own mailbox also holds stays visible through theirs. off shows your email again as the workspace setting allows. Email only: meetings stay visible, and Ken still reads the mailbox for you. With --thread it sends PATCH /v1/capture/threads/{threadId} instead: the switch for that one thread, as far as your own mailbox holds it. --dry-run prints the PATCH and changes nothing.",
|
|
10640
10876
|
flags: {
|
|
10641
10877
|
thread: { type: "string", description: "Set the switch for this one captured thread (its id), not the whole mailbox" }
|
|
@@ -10679,6 +10915,7 @@ var init_sync3 = __esm({
|
|
|
10679
10915
|
resource: "capture",
|
|
10680
10916
|
action: "sync",
|
|
10681
10917
|
summary: "Read your captured mailbox now",
|
|
10918
|
+
effect: "write",
|
|
10682
10919
|
description: "Sends POST /v1/capture/mailbox/sync: one sync pass over your own mailbox. Kenso lists up to 25 messages and logs the ones with people and accounts in Kenso on their timelines; a reply from someone new to mail you sent creates the person and their account. Prints outcome (completed, busy while another pass reads the mailbox or it waits on a retry, timed_out when the pass ran out of its 70 seconds before the page was done: what it logged is kept, so run it again, or why the pass stopped: connection_unavailable, missing_scope, login_refused, token_unavailable, provider_unavailable, store_unavailable), messagesRead, messagesLogged, peopleCreated, threadsSummarized (threads Ken summarized after the pass, up to 3 a call), meetingsLogged (meetings you held that went on a guest's timeline), hasMore (true while the mailbox has more to read: run it again, or leave the rest to the poll) and the mailbox after the pass. --dry-run prints the POST and reads nothing.",
|
|
10683
10920
|
flags: {},
|
|
10684
10921
|
examples: ["kenso capture sync", "kenso capture sync --query '{outcome: outcome, logged: messagesLogged, more: hasMore}'"],
|
|
@@ -10712,6 +10949,7 @@ var init_disconnect = __esm({
|
|
|
10712
10949
|
resource: "capture",
|
|
10713
10950
|
action: "disconnect",
|
|
10714
10951
|
summary: "Turn capture off for your own mailbox and delete its stored email bodies",
|
|
10952
|
+
effect: "destructive",
|
|
10715
10953
|
description: "Sends DELETE /v1/capture/mailbox. Sync stops and Kenso deletes the stored body of every email only your mailbox holds. Subject, people, time and Ken's summary stay on the records. Your Google or Microsoft account stays connected for calendar and scheduling. Deleted bodies do not come back, so it asks first: add --yes to run it without the question. --dry-run prints the DELETE and deletes nothing.",
|
|
10716
10954
|
flags: {},
|
|
10717
10955
|
examples: ["kenso capture disconnect --dry-run", "kenso capture disconnect --yes"],
|
|
@@ -10748,6 +10986,7 @@ var init_teammates_see = __esm({
|
|
|
10748
10986
|
resource: "capture",
|
|
10749
10987
|
action: "teammates-see",
|
|
10750
10988
|
summary: "Pick what teammates see of captured email: the summary, or the full email (workspace admin)",
|
|
10989
|
+
effect: "write",
|
|
10751
10990
|
description: "Sends PATCH /v1/capture with teammatesSee. summary (the default): teammates read subject, people, time and Ken's summary, and only the mailbox owner opens the body. full_email: every member can open a captured body. It applies to every read from then on, mail already captured included. A member's Private switch still hides their email either way. Only a workspace admin can change it. --dry-run prints the PATCH and changes nothing.",
|
|
10752
10991
|
flags: {},
|
|
10753
10992
|
positionals: [{ name: "value", required: true, description: "summary or full_email" }],
|
|
@@ -10862,6 +11101,7 @@ complete -c kenso -f -a '(__kenso_complete)'
|
|
|
10862
11101
|
action: "",
|
|
10863
11102
|
summary: "Print the tab-completion script for bash, zsh or fish",
|
|
10864
11103
|
brief: "",
|
|
11104
|
+
effect: "read",
|
|
10865
11105
|
description: "Prints a script that makes Tab complete kenso's resources, actions and flags. The script asks kenso for the candidates on each Tab, so it stays right as kenso updates: install it once.",
|
|
10866
11106
|
flags: {},
|
|
10867
11107
|
positionals: [{ name: "shell", required: true, description: "bash, zsh or fish" }],
|
|
@@ -11332,8 +11572,8 @@ function announce(ctx, kind, flags, link, answer, waiting, limitMs, deps) {
|
|
|
11332
11572
|
}
|
|
11333
11573
|
if (link && !ctx.agent && flags["no-browser"] !== true && hasDisplay(ctx.env, deps.platform)) openBrowser(link, deps);
|
|
11334
11574
|
}
|
|
11335
|
-
async function runConnect(ctx, kind, flags,
|
|
11336
|
-
const deps = { ...defaultDeps2, ...
|
|
11575
|
+
async function runConnect(ctx, kind, flags, overrides2) {
|
|
11576
|
+
const deps = { ...defaultDeps2, ...overrides2 };
|
|
11337
11577
|
const limitMs = timeoutMs(flags);
|
|
11338
11578
|
kind.manual?.check(flags);
|
|
11339
11579
|
const start = kind.start?.(flags);
|
|
@@ -11390,6 +11630,7 @@ function connectCommand(kind) {
|
|
|
11390
11630
|
resource: "connect",
|
|
11391
11631
|
action: kind.name,
|
|
11392
11632
|
summary: kind.summary,
|
|
11633
|
+
effect: KIND_EFFECTS[kind.name] ?? "write",
|
|
11393
11634
|
description: `${kind.description}
|
|
11394
11635
|
|
|
11395
11636
|
The connect finishes in a browser: Kenso refuses to complete a sign-in for an API key or an agent, so the person you work for opens the link. It prints the link on stderr (and opens it at a desktop when no coding agent runs it), checks every ${POLL_INTERVAL_MS / 1e3} s, and prints {connected, kind, connection} on stdout once the connection shows up. --no-wait prints the start answer, link included, and ends.`,
|
|
@@ -11400,7 +11641,7 @@ The connect finishes in a browser: Kenso refuses to complete a sign-in for an AP
|
|
|
11400
11641
|
run: (ctx, args) => runConnect(ctx, kind, args.flags)
|
|
11401
11642
|
};
|
|
11402
11643
|
}
|
|
11403
|
-
var POLL_INTERVAL_MS, DEFAULT_TIMEOUT_SECONDS, MAX_POLL_FAILURES, LINK_FIELDS, defaultDeps2, COMMON_FLAGS;
|
|
11644
|
+
var POLL_INTERVAL_MS, DEFAULT_TIMEOUT_SECONDS, MAX_POLL_FAILURES, LINK_FIELDS, defaultDeps2, COMMON_FLAGS, KIND_EFFECTS;
|
|
11404
11645
|
var init_run = __esm({
|
|
11405
11646
|
"src/commands/connect/run.ts"() {
|
|
11406
11647
|
"use strict";
|
|
@@ -11428,6 +11669,7 @@ var init_run = __esm({
|
|
|
11428
11669
|
"no-wait": { type: "boolean", description: "Print the link as JSON and end, without waiting for the connection" },
|
|
11429
11670
|
"no-browser": { type: "boolean", description: "Print the link only; never open a browser" }
|
|
11430
11671
|
};
|
|
11672
|
+
KIND_EFFECTS = { linkedin: "spend", whatsapp: "spend", facebook: "spend", video: "read", github: "read" };
|
|
11431
11673
|
}
|
|
11432
11674
|
});
|
|
11433
11675
|
|
|
@@ -11447,6 +11689,45 @@ var init_connect3 = __esm({
|
|
|
11447
11689
|
}
|
|
11448
11690
|
});
|
|
11449
11691
|
|
|
11692
|
+
// src/core/estimate.ts
|
|
11693
|
+
function isRecord8(value) {
|
|
11694
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
11695
|
+
}
|
|
11696
|
+
function mustRethrow(err) {
|
|
11697
|
+
return err instanceof KensoError && (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.Interrupted);
|
|
11698
|
+
}
|
|
11699
|
+
async function ask(ctx, path, body2, read2) {
|
|
11700
|
+
try {
|
|
11701
|
+
const res = await ctx.client.request({ method: "POST", path, body: body2 });
|
|
11702
|
+
const data = unwrap(res.body);
|
|
11703
|
+
if (!isRecord8(data)) return { estimate: data ?? null };
|
|
11704
|
+
const estimate = Object.fromEntries(Object.entries(data).filter(([key]) => key !== "totalAmount" && !/usd/i.test(key)));
|
|
11705
|
+
return { estimate, credits: await read2(data) };
|
|
11706
|
+
} catch (err) {
|
|
11707
|
+
if (mustRethrow(err)) throw err;
|
|
11708
|
+
ctx.output.warn(`Could not estimate the credits: ${err instanceof Error ? err.message : String(err)}`);
|
|
11709
|
+
return { estimate: null, estimateError: err instanceof KensoError ? { code: err.code, message: err.message } : { message: String(err) } };
|
|
11710
|
+
}
|
|
11711
|
+
}
|
|
11712
|
+
async function creditEstimate(ctx, body2) {
|
|
11713
|
+
return ask(ctx, "/v1/credits/estimates", body2, (data) => {
|
|
11714
|
+
const credits2 = (key) => typeof data[key] === "number" ? data[key] / 1e3 : null;
|
|
11715
|
+
return {
|
|
11716
|
+
needed: credits2("totalMillicredits"),
|
|
11717
|
+
available: credits2("availableMillicredits"),
|
|
11718
|
+
sufficient: typeof data.sufficient === "boolean" ? data.sufficient : null
|
|
11719
|
+
};
|
|
11720
|
+
});
|
|
11721
|
+
}
|
|
11722
|
+
var init_estimate2 = __esm({
|
|
11723
|
+
"src/core/estimate.ts"() {
|
|
11724
|
+
"use strict";
|
|
11725
|
+
init_errors();
|
|
11726
|
+
init_exit_codes();
|
|
11727
|
+
init_http();
|
|
11728
|
+
}
|
|
11729
|
+
});
|
|
11730
|
+
|
|
11450
11731
|
// src/commands/contacts/normalize.ts
|
|
11451
11732
|
function normalizeVariableName(name) {
|
|
11452
11733
|
if (name === null || name === void 0 || name.trim() === "") return "";
|
|
@@ -11618,14 +11899,14 @@ function overrideTarget(column, value, mode) {
|
|
|
11618
11899
|
}
|
|
11619
11900
|
return { field };
|
|
11620
11901
|
}
|
|
11621
|
-
function overrideFor(header,
|
|
11622
|
-
if (Object.hasOwn(
|
|
11902
|
+
function overrideFor(header, overrides2) {
|
|
11903
|
+
if (Object.hasOwn(overrides2, header)) return { found: true, value: overrides2[header] ?? null };
|
|
11623
11904
|
const wanted = header.trim().toLowerCase();
|
|
11624
|
-
for (const [key, value] of Object.entries(
|
|
11905
|
+
for (const [key, value] of Object.entries(overrides2)) if (key.trim().toLowerCase() === wanted) return { found: true, value };
|
|
11625
11906
|
return { found: false, value: null };
|
|
11626
11907
|
}
|
|
11627
|
-
function buildMapping(headers,
|
|
11628
|
-
const unknown2 = Object.keys(
|
|
11908
|
+
function buildMapping(headers, overrides2, mode) {
|
|
11909
|
+
const unknown2 = Object.keys(overrides2).filter((key) => !headers.some((h) => h === key || h.trim().toLowerCase() === key.trim().toLowerCase()));
|
|
11629
11910
|
if (unknown2.length > 0) {
|
|
11630
11911
|
throw usageError(`--map names column${unknown2.length === 1 ? "" : "s"} ${unknown2.map((k) => `"${k}"`).join(", ")} that the file does not have.`, {
|
|
11631
11912
|
field: "map",
|
|
@@ -11638,7 +11919,7 @@ function buildMapping(headers, overrides, mode) {
|
|
|
11638
11919
|
result.dropped[header] = reason;
|
|
11639
11920
|
};
|
|
11640
11921
|
for (const header of headers) {
|
|
11641
|
-
const override2 = overrideFor(header,
|
|
11922
|
+
const override2 = overrideFor(header, overrides2);
|
|
11642
11923
|
let target2;
|
|
11643
11924
|
if (override2.found) {
|
|
11644
11925
|
if (override2.value === null) {
|
|
@@ -12069,23 +12350,6 @@ async function readCampaign(ctx, campaignId) {
|
|
|
12069
12350
|
const channel = isRecord4(campaign) && typeof campaign.channel === "string" ? campaign.channel.toLowerCase() : "";
|
|
12070
12351
|
return { linkedInOnly: LINKEDIN_ONLY_CHANNELS.has(channel) ? true : void 0 };
|
|
12071
12352
|
}
|
|
12072
|
-
async function estimate(ctx, leadCount) {
|
|
12073
|
-
if (leadCount === 0) return { estimate: null };
|
|
12074
|
-
try {
|
|
12075
|
-
const res = await ctx.client.request({ method: "POST", path: "/v1/credits/estimates", body: { kind: "leads", leadCount } });
|
|
12076
|
-
const data = unwrap(res.body);
|
|
12077
|
-
if (!isRecord4(data)) return { estimate: data ?? null };
|
|
12078
|
-
const credits = (key) => typeof data[key] === "number" ? data[key] / 1e3 : void 0;
|
|
12079
|
-
return {
|
|
12080
|
-
estimate: data,
|
|
12081
|
-
credits: { needed: credits("totalMillicredits"), available: credits("availableMillicredits"), sufficient: data.sufficient }
|
|
12082
|
-
};
|
|
12083
|
-
} catch (err) {
|
|
12084
|
-
if (err instanceof KensoError && (err.exitCode === ExitCode.Auth || err.exitCode === ExitCode.Interrupted)) throw err;
|
|
12085
|
-
ctx.output.warn(`Could not estimate the credits: ${err instanceof Error ? err.message : String(err)}`);
|
|
12086
|
-
return { estimate: null, estimateError: err instanceof KensoError ? { code: err.code, message: err.message } : { message: String(err) } };
|
|
12087
|
-
}
|
|
12088
|
-
}
|
|
12089
12353
|
function summarize2(campaignId) {
|
|
12090
12354
|
return (results) => ({
|
|
12091
12355
|
campaignId,
|
|
@@ -12099,6 +12363,7 @@ var init_import2 = __esm({
|
|
|
12099
12363
|
init_engine();
|
|
12100
12364
|
init_input2();
|
|
12101
12365
|
init_errors();
|
|
12366
|
+
init_estimate2();
|
|
12102
12367
|
init_exit_codes();
|
|
12103
12368
|
init_http();
|
|
12104
12369
|
init_input();
|
|
@@ -12116,6 +12381,7 @@ var init_import2 = __esm({
|
|
|
12116
12381
|
action: "import",
|
|
12117
12382
|
summary: "Add leads from a CSV or JSONL file to a campaign",
|
|
12118
12383
|
brief: "a file into a campaign",
|
|
12384
|
+
effect: "spend",
|
|
12119
12385
|
description: "Maps columns by header (email, firstName, lastName, title, linkedInUrl, companyName, companyDomain; every other column becomes a custom variable), checks every row locally, then sends 1,000 rows per call to POST /v1/campaigns/{campaignId}/contacts. Without --yes it prints the plan and the credit estimate. Rerunning the same command on the same file resumes the run. Exit 5 when some rows failed or were invalid, 6 when the contact limit stopped the run.",
|
|
12120
12386
|
flags: {
|
|
12121
12387
|
campaign: { type: "string", description: "The campaign id (required unless --template)", aliases: ["campaign-id"] },
|
|
@@ -12141,20 +12407,20 @@ var init_import2 = __esm({
|
|
|
12141
12407
|
}
|
|
12142
12408
|
const campaignId = idFlag(flags, "campaign", COMMAND2);
|
|
12143
12409
|
const file = requireFlag(flags, "file", COMMAND2, "Pass a CSV or JSONL file, or - for stdin. kenso contacts import --template shows the columns.");
|
|
12144
|
-
const
|
|
12410
|
+
const overrides2 = await readOverrides(ctx, flags, file);
|
|
12145
12411
|
const dryRun2 = isDryRun(ctx);
|
|
12146
12412
|
const applyCommand = sameCommand2(COMMAND2, flags, ctx, ["--yes"]);
|
|
12147
12413
|
if (flags["server-import"] === true) {
|
|
12148
12414
|
let mapping2;
|
|
12149
|
-
if (
|
|
12415
|
+
if (overrides2) {
|
|
12150
12416
|
const head = await readInput(file, { stdin: ctx.stdin });
|
|
12151
|
-
mapping2 = buildMapping(head.headers,
|
|
12417
|
+
mapping2 = buildMapping(head.headers, overrides2, "import");
|
|
12152
12418
|
warnDropped(ctx, { ...mapping2, dropped: notUploaded(mapping2) });
|
|
12153
12419
|
}
|
|
12154
12420
|
return serverImport(ctx, { campaignId, file, mapping: mapping2, timeout: stringFlag2(flags, "timeout"), dryRun: dryRun2, applyCommand });
|
|
12155
12421
|
}
|
|
12156
12422
|
const input = await readInput(file, { stdin: ctx.stdin });
|
|
12157
|
-
const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows),
|
|
12423
|
+
const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows), overrides2 ?? {}, "import");
|
|
12158
12424
|
warnDropped(ctx, mapping);
|
|
12159
12425
|
const { linkedInOnly } = await readCampaign(ctx, campaignId);
|
|
12160
12426
|
if (input.rows.length > 0 && !mapping.fields.has("email") && !(linkedInOnly !== false && mapping.fields.has("linkedInUrl"))) {
|
|
@@ -12177,7 +12443,7 @@ var init_import2 = __esm({
|
|
|
12177
12443
|
...Object.keys(mapping.dropped).length > 0 ? { droppedColumns: mapping.dropped } : {},
|
|
12178
12444
|
...emailLess > 0 ? { emailLessRows: emailLess } : {}
|
|
12179
12445
|
};
|
|
12180
|
-
if (dryRun2) Object.assign(dryRunExtra, await
|
|
12446
|
+
if (dryRun2) Object.assign(dryRunExtra, items.length === 0 ? { estimate: null } : await creditEstimate(ctx, { kind: "leads", leadCount: items.length }));
|
|
12181
12447
|
const outcome = await runBatch(
|
|
12182
12448
|
{
|
|
12183
12449
|
command: "contacts import",
|
|
@@ -12324,6 +12590,7 @@ var init_update = __esm({
|
|
|
12324
12590
|
action: "update",
|
|
12325
12591
|
summary: "Edit leads from a CSV or JSONL file, by id or email (also one lead)",
|
|
12326
12592
|
brief: "a file, by id or email; also one lead",
|
|
12593
|
+
effect: "write",
|
|
12327
12594
|
description: "Matches each row to a contact by its id (--match id, an id or contactId column) or by email within a campaign (--match email --campaign <id>), then sends 1,000 items per call to POST /v1/contacts/bulk-update. A column that is absent or a blank cell leaves the field unchanged; the literal null clears it. Other columns are custom variables. Without --yes it prints the plan. Exit 5 when some rows failed or were not found.",
|
|
12328
12595
|
flags: {
|
|
12329
12596
|
file: { type: "string", description: "CSV (with a header row) or JSONL file, or - for stdin" },
|
|
@@ -12349,9 +12616,9 @@ var init_update = __esm({
|
|
|
12349
12616
|
const campaignId = match === "email" ? idFlag(flags, "campaign", `${COMMAND3} --match email`) : void 0;
|
|
12350
12617
|
const map = stringFlag2(flags, "map");
|
|
12351
12618
|
if (map === "-" && file === "-") throw usageError("--map and --file cannot both read stdin.", { field: "map" });
|
|
12352
|
-
const
|
|
12619
|
+
const overrides2 = map === void 0 ? {} : parseMapOverrides(await readDataArg(map, ctx.stdin));
|
|
12353
12620
|
const input = await readInput(file, { stdin: ctx.stdin });
|
|
12354
|
-
const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows),
|
|
12621
|
+
const mapping = buildMapping(flattenCustomVariables(input.headers, input.rows), overrides2, "update");
|
|
12355
12622
|
warnDropped(ctx, mapping);
|
|
12356
12623
|
const key = match === "id" ? "id" : "email";
|
|
12357
12624
|
if (input.rows.length > 0 && !mapping.fields.has(key)) {
|
|
@@ -12398,25 +12665,25 @@ var init_update = __esm({
|
|
|
12398
12665
|
// src/commands/contacts/bulk-store.ts
|
|
12399
12666
|
import { existsSync as existsSync6 } from "node:fs";
|
|
12400
12667
|
import { appendFile as appendFile2, readFile as readFile7, writeFile as writeFile3 } from "node:fs/promises";
|
|
12401
|
-
import { join as
|
|
12668
|
+
import { join as join14 } from "node:path";
|
|
12402
12669
|
function whereDir(env) {
|
|
12403
|
-
return
|
|
12670
|
+
return join14(runsRoot(env), WHERE_DIR);
|
|
12404
12671
|
}
|
|
12405
12672
|
async function unfinishedWhereIds(ctx, command70, args) {
|
|
12406
|
-
const
|
|
12673
|
+
const dir3 = whereDir(ctx.env);
|
|
12407
12674
|
const identity = argsIdentity(args);
|
|
12408
12675
|
const workspaceId = ctx.client.workspaceId ?? ctx.auth.workspaceId;
|
|
12409
12676
|
for (const run of await listRuns(ctx.env)) {
|
|
12410
12677
|
if (run.command !== command70 || run.status === "done" || run.status === "planned") continue;
|
|
12411
12678
|
if ((run.workspaceId || void 0) !== (workspaceId || void 0) || argsIdentity(run.args) !== identity) continue;
|
|
12412
|
-
if (run.inputPath?.startsWith(`${
|
|
12679
|
+
if (run.inputPath?.startsWith(`${dir3}/`) && existsSync6(run.inputPath)) return run.inputPath;
|
|
12413
12680
|
}
|
|
12414
12681
|
return void 0;
|
|
12415
12682
|
}
|
|
12416
12683
|
async function saveWhereIds(ctx, kind, ids2) {
|
|
12417
|
-
const
|
|
12418
|
-
ensurePrivateDir2(
|
|
12419
|
-
const path =
|
|
12684
|
+
const dir3 = whereDir(ctx.env);
|
|
12685
|
+
ensurePrivateDir2(dir3);
|
|
12686
|
+
const path = join14(dir3, `${kind}-${Date.now()}-${newRunId().slice(2)}.txt`);
|
|
12420
12687
|
await writeFile3(path, ids2.map((id) => `${id}
|
|
12421
12688
|
`).join(""), { mode: 384 });
|
|
12422
12689
|
return path;
|
|
@@ -12425,7 +12692,7 @@ function chunkAttempts(env) {
|
|
|
12425
12692
|
let earlier;
|
|
12426
12693
|
return async (runId, chunkIndex) => {
|
|
12427
12694
|
earlier ??= (async () => {
|
|
12428
|
-
const path2 =
|
|
12695
|
+
const path2 = join14(runsRoot(env), runId, ATTEMPTS_FILE);
|
|
12429
12696
|
const text4 = await readFile7(path2, "utf8").catch(() => "");
|
|
12430
12697
|
const indexes3 = new Set(
|
|
12431
12698
|
text4.split("\n").filter((line) => line.trim() !== "").map(Number)
|
|
@@ -12608,6 +12875,7 @@ function bulkCommand(kind) {
|
|
|
12608
12875
|
action: kind,
|
|
12609
12876
|
summary: kind === "restore" ? `${route.verb} contacts by --ids or by a remove run (--run)` : `${route.verb} contacts by --ids file or --where filters`,
|
|
12610
12877
|
brief: kind === "restore" ? "--ids or --run" : "--ids file or --where, no search first",
|
|
12878
|
+
effect: kind === "remove" ? "destructive" : kind === "resume" ? "send" : "write",
|
|
12611
12879
|
description: `Sends the ids to POST ${route.path} in chunks of 1,000 and reports each id: ok, skipped (nothing to do), not_found or failed. Ids come from --ids` + (kind === "restore" ? " or from an earlier remove run (--run <runId>)" : " or from a contacts search (--where); a rerun of an unfinished --where run keeps its ids") + ". Without --yes it prints the count and the first ids." + (kind === "remove" ? " More than 1,000 ids also needs --confirm <count>. The summary prints the undo command." : ""),
|
|
12612
12880
|
flags,
|
|
12613
12881
|
examples: [
|
|
@@ -12773,6 +13041,7 @@ function tagCommand(kind) {
|
|
|
12773
13041
|
action: kind,
|
|
12774
13042
|
summary: `${kind === "tag" ? "Add a tag to" : "Remove a tag from"} contacts by --ids only (a campaign: list its ids first)`,
|
|
12775
13043
|
brief: "--ids only",
|
|
13044
|
+
effect: kind === "tag" ? "write" : "destructive",
|
|
12776
13045
|
description: `Sends the ids to POST /v1/tags/{tagId}/assignments/${kind === "tag" ? "bulk-create" : "bulk-delete"}, 250 per call. Ids come one per line, or from a CSV/JSONL with an id column. Without --yes it prints the count. Exit 5 when some ids failed or were not found.`,
|
|
12777
13046
|
flags: {
|
|
12778
13047
|
tag: { type: "string", description: "The tag id (see kenso tags list)", aliases: ["tag-id"] },
|
|
@@ -12891,6 +13160,7 @@ var init_export = __esm({
|
|
|
12891
13160
|
action: "export",
|
|
12892
13161
|
summary: "Export a campaign's contacts to CSV (a segment: contact-exports create)",
|
|
12893
13162
|
brief: "a campaign to CSV; a segment: contact-exports create",
|
|
13163
|
+
effect: "write",
|
|
12894
13164
|
description: "Creates a contact export of the campaign (POST /v1/contact-exports, kind contacts), waits for the contact_export job, then downloads GET /v1/contact-exports/{exportId}/content to --out. Without --out it prints the job (add --wait to wait for it).",
|
|
12895
13165
|
flags: {
|
|
12896
13166
|
campaign: { type: "string", description: "The campaign id", aliases: ["campaign-id"] },
|
|
@@ -12968,6 +13238,15 @@ var init_contacts = __esm({
|
|
|
12968
13238
|
}
|
|
12969
13239
|
});
|
|
12970
13240
|
|
|
13241
|
+
// src/commands/credits/index.ts
|
|
13242
|
+
var actions9;
|
|
13243
|
+
var init_credits = __esm({
|
|
13244
|
+
"src/commands/credits/index.ts"() {
|
|
13245
|
+
"use strict";
|
|
13246
|
+
actions9 = {};
|
|
13247
|
+
}
|
|
13248
|
+
});
|
|
13249
|
+
|
|
12971
13250
|
// src/commands/dashboards/show.ts
|
|
12972
13251
|
var show_exports = {};
|
|
12973
13252
|
__export(show_exports, {
|
|
@@ -12984,6 +13263,7 @@ var init_show = __esm({
|
|
|
12984
13263
|
resource: "dashboards",
|
|
12985
13264
|
action: "show",
|
|
12986
13265
|
summary: "Run a dashboard's charts and print their numbers",
|
|
13266
|
+
effect: "read",
|
|
12987
13267
|
description: "Reads GET /v1/dashboards/{dashboardId}?include=results and prints one row per chart bucket: the chart's id and title, the bucket's label, the measure the chart draws (valueKey) and its value. Amounts are in the workspace currency. The dashboard's name, each chart's total and any chart that could not run are printed to stderr. The numbers cover the deals you may read. --full prints the whole answer as one object, each chart with its stored report or query and its full result. List dashboards with kenso dashboards list.",
|
|
12988
13268
|
flags: {
|
|
12989
13269
|
"time-zone": { type: "string", description: "IANA zone days start in when you have no app time zone (default UTC)" },
|
|
@@ -13039,11 +13319,11 @@ var init_show = __esm({
|
|
|
13039
13319
|
});
|
|
13040
13320
|
|
|
13041
13321
|
// src/commands/dashboards/index.ts
|
|
13042
|
-
var
|
|
13322
|
+
var actions10;
|
|
13043
13323
|
var init_dashboards = __esm({
|
|
13044
13324
|
"src/commands/dashboards/index.ts"() {
|
|
13045
13325
|
"use strict";
|
|
13046
|
-
|
|
13326
|
+
actions10 = {
|
|
13047
13327
|
show: () => Promise.resolve().then(() => (init_show(), show_exports)).then((m) => m.default)
|
|
13048
13328
|
};
|
|
13049
13329
|
}
|
|
@@ -13054,10 +13334,10 @@ var describe_exports = {};
|
|
|
13054
13334
|
__export(describe_exports, {
|
|
13055
13335
|
default: () => describe_default
|
|
13056
13336
|
});
|
|
13057
|
-
import { Writable as
|
|
13337
|
+
import { Writable as Writable3 } from "node:stream";
|
|
13058
13338
|
function printJson(ctx, value) {
|
|
13059
13339
|
const chunks = [];
|
|
13060
|
-
const collect = new
|
|
13340
|
+
const collect = new Writable3({
|
|
13061
13341
|
write(chunk, _encoding, callback) {
|
|
13062
13342
|
chunks.push(chunk.toString());
|
|
13063
13343
|
callback();
|
|
@@ -13112,12 +13392,18 @@ function flagsOf(entry) {
|
|
|
13112
13392
|
...flag.multiple ? { multiple: true } : {}
|
|
13113
13393
|
}));
|
|
13114
13394
|
}
|
|
13395
|
+
function effectOf(entry) {
|
|
13396
|
+
return (entry.op ? entry.op.effect : entry.spec?.effect) ?? "write";
|
|
13397
|
+
}
|
|
13398
|
+
function creditLines(entry) {
|
|
13399
|
+
return entry.op?.credits ?? entry.spec?.cost ?? [];
|
|
13400
|
+
}
|
|
13115
13401
|
function summaryOf(entry, withFlags) {
|
|
13116
|
-
const out = { command: entry.command, summary: entry.summary, beta: entry.gates !== void 0, handWritten: entry.spec !== void 0 };
|
|
13402
|
+
const out = { command: entry.command, summary: entry.summary, effect: effectOf(entry), beta: entry.gates !== void 0, handWritten: entry.spec !== void 0 };
|
|
13117
13403
|
if (withFlags) out.flags = flagsOf(entry);
|
|
13118
13404
|
return out;
|
|
13119
13405
|
}
|
|
13120
|
-
function detailOf(entry) {
|
|
13406
|
+
function detailOf(entry, cards) {
|
|
13121
13407
|
const spec = entry.spec;
|
|
13122
13408
|
const ids2 = entry.op ? [entry.op.id] : spec?.operationIds ?? [];
|
|
13123
13409
|
const op = entry.op ?? (ids2.length === 1 ? findOperationById(ids2[0]) : void 0);
|
|
@@ -13125,6 +13411,7 @@ function detailOf(entry) {
|
|
|
13125
13411
|
const out = {
|
|
13126
13412
|
command: entry.command,
|
|
13127
13413
|
summary: entry.summary,
|
|
13414
|
+
effect: effectOf(entry),
|
|
13128
13415
|
description: entry.op ? entry.op.description ?? null : spec?.description ?? null,
|
|
13129
13416
|
method: op?.method ?? null,
|
|
13130
13417
|
path: op?.path ?? null,
|
|
@@ -13146,6 +13433,10 @@ function detailOf(entry) {
|
|
|
13146
13433
|
};
|
|
13147
13434
|
if (entry.gates) out.featureGates = entry.gates;
|
|
13148
13435
|
if (entry.op?.download) out.download = entry.op.download;
|
|
13436
|
+
if (cards) {
|
|
13437
|
+
const lines = creditLines(entry);
|
|
13438
|
+
out.cost = lines.length > 0 ? { lines: lines.map((line) => ({ ...line, price: priceLine(line, cards) })), rateCard: { source: cards[0]?.source ?? "bundled", versions: cards.map((card) => card.version) } } : effectOf(entry) === "spend" ? { lines: [], rateCard: null } : null;
|
|
13439
|
+
}
|
|
13149
13440
|
return out;
|
|
13150
13441
|
}
|
|
13151
13442
|
function unknown(words) {
|
|
@@ -13165,6 +13456,7 @@ var init_describe = __esm({
|
|
|
13165
13456
|
init_exit_codes();
|
|
13166
13457
|
init_features();
|
|
13167
13458
|
init_output();
|
|
13459
|
+
init_rate_card();
|
|
13168
13460
|
init_version();
|
|
13169
13461
|
init_execute();
|
|
13170
13462
|
init_manifest();
|
|
@@ -13175,7 +13467,8 @@ var init_describe = __esm({
|
|
|
13175
13467
|
action: "",
|
|
13176
13468
|
summary: "The command map as JSON: commands, flags, body schemas",
|
|
13177
13469
|
brief: "",
|
|
13178
|
-
|
|
13470
|
+
effect: "read",
|
|
13471
|
+
description: "Always JSON. No arguments: every command with its summary. A resource: its commands with their flags. A resource and an action: one command in full (method, path, flags, body schema, examples). Beta commands your workspace has not enabled are left out unless --all-commands; calling one still works. Every command has an effect (read, write, spend, send or destructive), and one command in full has its cost in credits on your rate card.",
|
|
13179
13472
|
flags: {
|
|
13180
13473
|
// Used by scripts/build-reference.ts to write docs/reference.md in one call.
|
|
13181
13474
|
full: { type: "boolean", description: "Every listed command in full (method, path, flags, body schema, examples), for the docs build" }
|
|
@@ -13185,6 +13478,7 @@ var init_describe = __esm({
|
|
|
13185
13478
|
{ name: "action", description: "One command in full" }
|
|
13186
13479
|
],
|
|
13187
13480
|
examples: ["kenso describe", "kenso describe contacts", "kenso describe contacts bulk-update", "kenso describe --all-commands"],
|
|
13481
|
+
operationIds: ["me.get", "credit-rate-card.get"],
|
|
13188
13482
|
async run(ctx, { flags, positionals }) {
|
|
13189
13483
|
const [resourceArg, action] = positionals;
|
|
13190
13484
|
const resource = resourceArg === void 0 ? void 0 : resourceAliases[resourceArg] ?? resourceArg;
|
|
@@ -13193,7 +13487,8 @@ var init_describe = __esm({
|
|
|
13193
13487
|
if (resource !== void 0 && action !== void 0) {
|
|
13194
13488
|
const entry = all.find((e) => e.resource === resource && e.action === action);
|
|
13195
13489
|
if (!entry) throw unknown([resourceArg, action]);
|
|
13196
|
-
|
|
13490
|
+
const cards = creditLines(entry).length > 0 ? await loadRateCards(ctx, { timeoutMs: HELP_RATE_CARD_TIMEOUT_MS }) : [];
|
|
13491
|
+
printJson(ctx, detailOf(entry, cards));
|
|
13197
13492
|
return ExitCode.Ok;
|
|
13198
13493
|
}
|
|
13199
13494
|
const scoped = resource === void 0 ? all : all.filter((e) => e.resource === resource);
|
|
@@ -13216,16 +13511,25 @@ var init_describe = __esm({
|
|
|
13216
13511
|
});
|
|
13217
13512
|
|
|
13218
13513
|
// src/commands/describe/index.ts
|
|
13219
|
-
var
|
|
13514
|
+
var actions11;
|
|
13220
13515
|
var init_describe2 = __esm({
|
|
13221
13516
|
"src/commands/describe/index.ts"() {
|
|
13222
13517
|
"use strict";
|
|
13223
|
-
|
|
13518
|
+
actions11 = {
|
|
13224
13519
|
"": () => Promise.resolve().then(() => (init_describe(), describe_exports)).then((m) => m.default)
|
|
13225
13520
|
};
|
|
13226
13521
|
}
|
|
13227
13522
|
});
|
|
13228
13523
|
|
|
13524
|
+
// src/commands/discover/index.ts
|
|
13525
|
+
var actions12;
|
|
13526
|
+
var init_discover = __esm({
|
|
13527
|
+
"src/commands/discover/index.ts"() {
|
|
13528
|
+
"use strict";
|
|
13529
|
+
actions12 = {};
|
|
13530
|
+
}
|
|
13531
|
+
});
|
|
13532
|
+
|
|
13229
13533
|
// src/commands/docs/docs.ts
|
|
13230
13534
|
var docs_exports = {};
|
|
13231
13535
|
__export(docs_exports, {
|
|
@@ -13248,6 +13552,7 @@ var init_docs = __esm({
|
|
|
13248
13552
|
action: "",
|
|
13249
13553
|
summary: "Offline docs: the topic list, or one topic",
|
|
13250
13554
|
brief: "",
|
|
13555
|
+
effect: "read",
|
|
13251
13556
|
description: "Without a topic, lists the topics with one line each (NDJSON when piped). With a topic, prints that page's Markdown to stdout. The same pages are in the package's docs/ folder.",
|
|
13252
13557
|
flags: {},
|
|
13253
13558
|
positionals: [{ name: "topic", description: `One of ${NAMES}` }],
|
|
@@ -13289,11 +13594,11 @@ var init_docs = __esm({
|
|
|
13289
13594
|
});
|
|
13290
13595
|
|
|
13291
13596
|
// src/commands/docs/index.ts
|
|
13292
|
-
var
|
|
13597
|
+
var actions13;
|
|
13293
13598
|
var init_docs2 = __esm({
|
|
13294
13599
|
"src/commands/docs/index.ts"() {
|
|
13295
13600
|
"use strict";
|
|
13296
|
-
|
|
13601
|
+
actions13 = {
|
|
13297
13602
|
"": () => Promise.resolve().then(() => (init_docs(), docs_exports)).then((m) => m.default)
|
|
13298
13603
|
};
|
|
13299
13604
|
}
|
|
@@ -13322,7 +13627,7 @@ function configCheck(env) {
|
|
|
13322
13627
|
const octal = mode.toString(8).padStart(4, "0");
|
|
13323
13628
|
return mode === 384 ? { name: "config_permissions", ok: true, detail: `${file} is ${octal}` } : { name: "config_permissions", ok: false, detail: `${file} is ${octal}: run chmod 600 ${file}` };
|
|
13324
13629
|
}
|
|
13325
|
-
var MIN_NODE_MAJOR, command26,
|
|
13630
|
+
var MIN_NODE_MAJOR, command26, actions14;
|
|
13326
13631
|
var init_doctor = __esm({
|
|
13327
13632
|
"src/commands/doctor/index.ts"() {
|
|
13328
13633
|
"use strict";
|
|
@@ -13336,6 +13641,7 @@ var init_doctor = __esm({
|
|
|
13336
13641
|
action: "",
|
|
13337
13642
|
summary: "Check Node, the config, the API and the key",
|
|
13338
13643
|
brief: "",
|
|
13644
|
+
effect: "read",
|
|
13339
13645
|
description: "Prints the version, Node, platform, config location, profile, key source, API URL, workspace and detected agent, plus checks node_version, config_permissions, api_reachable and key_valid. Exits 0 when every check passes, 3 when the key check fails, else 1.",
|
|
13340
13646
|
flags: {},
|
|
13341
13647
|
examples: ["kenso doctor", "kenso doctor --profile client-a --output json"],
|
|
@@ -13395,7 +13701,7 @@ var init_doctor = __esm({
|
|
|
13395
13701
|
return keyFailed ? ExitCode.Auth : ExitCode.Error;
|
|
13396
13702
|
}
|
|
13397
13703
|
};
|
|
13398
|
-
|
|
13704
|
+
actions14 = {
|
|
13399
13705
|
"": async () => command26
|
|
13400
13706
|
};
|
|
13401
13707
|
}
|
|
@@ -13498,6 +13804,7 @@ var init_export2 = __esm({
|
|
|
13498
13804
|
action: "",
|
|
13499
13805
|
summary: "Export accounts, people or deals as CSV: everything, a saved view, or what the filters match",
|
|
13500
13806
|
brief: "<accounts|people|deals> [--view <id>] [--out <file>]",
|
|
13807
|
+
effect: "write",
|
|
13501
13808
|
description: "Writes the CSV that POST /v1/accounts/export, /v1/people/export or /v1/opportunities/export returns, to stdout or to --out. With no filter it exports every record; more than 50,000 rows is refused (narrow the filters). --view exports a saved view of that object, yours or a shared one: the whole filter and the sort GET /v1/views/{viewId} answers, so the file holds the rows the view lists. --filters, --where (accounts), --q and --sort are the search operation's own fields; given with --view, each replaces that key of the view's. The accounts and deals files start with id and import back as they are. Each export writes an audit-log entry. Needs the export permission.",
|
|
13502
13809
|
flags: {
|
|
13503
13810
|
view: { type: "string", description: "A saved view's id (kenso views list): export what that view lists, in its sort" },
|
|
@@ -13573,11 +13880,11 @@ var init_export2 = __esm({
|
|
|
13573
13880
|
});
|
|
13574
13881
|
|
|
13575
13882
|
// src/commands/export/index.ts
|
|
13576
|
-
var
|
|
13883
|
+
var actions15;
|
|
13577
13884
|
var init_export3 = __esm({
|
|
13578
13885
|
"src/commands/export/index.ts"() {
|
|
13579
13886
|
"use strict";
|
|
13580
|
-
|
|
13887
|
+
actions15 = {
|
|
13581
13888
|
"": async () => (await Promise.resolve().then(() => (init_export2(), export_exports2))).default
|
|
13582
13889
|
};
|
|
13583
13890
|
}
|
|
@@ -13690,6 +13997,7 @@ var init_import3 = __esm({
|
|
|
13690
13997
|
action: "",
|
|
13691
13998
|
summary: "Import accounts, people or deals from a CSV file: Kenso proposes the mapping, you approve, it runs in the background",
|
|
13692
13999
|
brief: "<accounts|people|deals> <file.csv> [--map Header=field] [--yes]",
|
|
14000
|
+
effect: "spend",
|
|
13693
14001
|
description: `Uploads the file to POST /v1/record-imports and prints Kenso's plan: what each column becomes, how owner and stage values are read, and what it could not settle. Nothing is written to your accounts until the import starts. Without --yes it stops there and names the command that starts it: the file is uploaded and planned, and no record is written. With --yes it starts the import and waits for it. --dry-run sends nothing: with a file it prints the upload it would make (the plan needs the upload), and with --id it reads the planned import and prints what --map, --source and --research would change on it. A row whose domain is already an account only fills that account's empty fields; a new domain creates an account; an account deleted in the last 30 days is restored. Research of new accounts is off unless --research (charged per account). --source names the system the file's record ids come from (twenty, hubspot): ids are kept and matched under that name, so pass the same one for every file of an export. --map changes the plan's columns ("Header=new" adds the custom field Kenso proposes for a column no field matches); owner and stage values change with kenso record-imports update. What happened to each row: kenso record-import-rows list --import-id <id>. Take a finished import back: kenso record-imports undo --import-id <id>. kenso import people matches a row by email, then LinkedIn URL, then name on its company, fills only the empty fields of a person it finds, and places a person on the account that holds their company id (from an accounts file imported before) or their company domain. It never creates an account: import accounts first. kenso import deals opens a deal on the account that holds the row's company id or company domain (a row whose account Kenso does not know is skipped), links the contact a people file imported before, maps the file's stages to the workspace's deal stages, and keeps amounts in the workspace currency. A row whose deal id an earlier import kept only fills that deal's empty fields. So does a row no id names a deal for, when one deal on its account has its name and contact and is open, won or lost as the row is; a row that matches two such deals is skipped.`,
|
|
13694
14002
|
flags: {
|
|
13695
14003
|
map: { type: "string", multiple: true, description: 'Map a column: "Header=field". "Header=" skips it. Repeatable' },
|
|
@@ -13796,22 +14104,22 @@ var init_import3 = __esm({
|
|
|
13796
14104
|
});
|
|
13797
14105
|
|
|
13798
14106
|
// src/commands/import/index.ts
|
|
13799
|
-
var
|
|
14107
|
+
var actions16;
|
|
13800
14108
|
var init_import4 = __esm({
|
|
13801
14109
|
"src/commands/import/index.ts"() {
|
|
13802
14110
|
"use strict";
|
|
13803
|
-
|
|
14111
|
+
actions16 = {
|
|
13804
14112
|
"": async () => (await Promise.resolve().then(() => (init_import3(), import_exports3))).default
|
|
13805
14113
|
};
|
|
13806
14114
|
}
|
|
13807
14115
|
});
|
|
13808
14116
|
|
|
13809
14117
|
// src/commands/jobs/index.ts
|
|
13810
|
-
var
|
|
14118
|
+
var actions17;
|
|
13811
14119
|
var init_jobs2 = __esm({
|
|
13812
14120
|
"src/commands/jobs/index.ts"() {
|
|
13813
14121
|
"use strict";
|
|
13814
|
-
|
|
14122
|
+
actions17 = {
|
|
13815
14123
|
wait: () => Promise.resolve().then(() => (init_wait(), wait_exports)).then((m) => m.default)
|
|
13816
14124
|
};
|
|
13817
14125
|
}
|
|
@@ -13879,6 +14187,7 @@ var init_layouts = __esm({
|
|
|
13879
14187
|
resource: "layouts",
|
|
13880
14188
|
action: "show",
|
|
13881
14189
|
summary: "Show how the workspace's account, person or deal pages lay out their fields",
|
|
14190
|
+
effect: "read",
|
|
13882
14191
|
description: "Reads GET /v1/record-layouts/{object} and prints it: isDefault, version, headerFields (up to 6, pinned under the record's name), railSections ({name, fields}), hiddenFields (under the rail's More), sections ({key, label, placement, locked, hidden}, in page order) and availableFields ({key, label, custom}). A custom field's key is custom.<field_key>. The default answers while nobody saved a layout.",
|
|
13883
14192
|
flags: {},
|
|
13884
14193
|
positionals: [OBJECT_ARG],
|
|
@@ -13894,6 +14203,7 @@ var init_layouts = __esm({
|
|
|
13894
14203
|
resource: "layouts",
|
|
13895
14204
|
action: "set",
|
|
13896
14205
|
summary: "Save the layout every account, person or deal page in the workspace draws",
|
|
14206
|
+
effect: "write",
|
|
13897
14207
|
description: "PUT /v1/record-layouts/{object}. --header pins up to 6 fields to the header: it reads the layout, takes those fields out of the rail and the hidden list, puts the fields it unpins at the top of the first rail section, and saves the rest as it was. --data sends a whole layout (headerFields, railSections, hiddenFields, sections, version) inline, from @file or from - (stdin); start from `kenso layouts show <object>`. A save after someone else's answers conflict: show it again. Needs the workspace_settings permission; it changes the page for every member. --dry-run prints the PUT and saves nothing.",
|
|
13898
14208
|
flags: {
|
|
13899
14209
|
header: { type: "string", description: "Field keys to pin to the header, comma separated (tier,custom.arr)" },
|
|
@@ -13935,6 +14245,7 @@ var init_layouts = __esm({
|
|
|
13935
14245
|
resource: "layouts",
|
|
13936
14246
|
action: "reset",
|
|
13937
14247
|
summary: "Put the account, person or deal page back to Kenso's default layout",
|
|
14248
|
+
effect: "destructive",
|
|
13938
14249
|
description: "DELETE /v1/record-layouts/{object}: drops the saved layout for the whole workspace, so every member's page goes back to the default (the version keeps counting), and prints the default. Needs --yes, or a yes at the prompt; --dry-run prints the DELETE and drops nothing. Save the layout first with `kenso layouts show <object> > layout.json`.",
|
|
13939
14250
|
flags: {},
|
|
13940
14251
|
positionals: [OBJECT_ARG],
|
|
@@ -13958,11 +14269,11 @@ var init_layouts = __esm({
|
|
|
13958
14269
|
});
|
|
13959
14270
|
|
|
13960
14271
|
// src/commands/layouts/index.ts
|
|
13961
|
-
var
|
|
14272
|
+
var actions18;
|
|
13962
14273
|
var init_layouts2 = __esm({
|
|
13963
14274
|
"src/commands/layouts/index.ts"() {
|
|
13964
14275
|
"use strict";
|
|
13965
|
-
|
|
14276
|
+
actions18 = {
|
|
13966
14277
|
show: () => Promise.resolve().then(() => (init_layouts(), layouts_exports)).then((m) => m.show),
|
|
13967
14278
|
set: () => Promise.resolve().then(() => (init_layouts(), layouts_exports)).then((m) => m.set),
|
|
13968
14279
|
reset: () => Promise.resolve().then(() => (init_layouts(), layouts_exports)).then((m) => m.reset)
|
|
@@ -14018,6 +14329,7 @@ var init_tail = __esm({
|
|
|
14018
14329
|
action: "tail",
|
|
14019
14330
|
summary: "Stream your workspace's new API request log rows",
|
|
14020
14331
|
brief: "--status, --key",
|
|
14332
|
+
effect: "read",
|
|
14021
14333
|
description: "Polls GET /v1/api-requests and prints each new row as it is logged, oldest first within a poll: one line per request on a terminal (time, [status], method, path template, error code, duration, API key id, request id), one JSON object per line when piped or with -o json or -o ndjson. It starts from now; --since 10m starts earlier. A row is logged after its request finishes, so each poll looks 60 s back and a slow request can print up to a minute out of order.",
|
|
14022
14334
|
flags: {
|
|
14023
14335
|
status: { type: "string", description: "Only these statuses: codes or classes, comma-separated (429,5xx)" },
|
|
@@ -14124,11 +14436,11 @@ var init_tail = __esm({
|
|
|
14124
14436
|
});
|
|
14125
14437
|
|
|
14126
14438
|
// src/commands/logs/index.ts
|
|
14127
|
-
var
|
|
14439
|
+
var actions19;
|
|
14128
14440
|
var init_logs = __esm({
|
|
14129
14441
|
"src/commands/logs/index.ts"() {
|
|
14130
14442
|
"use strict";
|
|
14131
|
-
|
|
14443
|
+
actions19 = {
|
|
14132
14444
|
tail: () => Promise.resolve().then(() => (init_tail(), tail_exports)).then((m) => m.default)
|
|
14133
14445
|
};
|
|
14134
14446
|
}
|
|
@@ -14178,7 +14490,7 @@ var call_exports = {};
|
|
|
14178
14490
|
__export(call_exports, {
|
|
14179
14491
|
default: () => call_default
|
|
14180
14492
|
});
|
|
14181
|
-
function
|
|
14493
|
+
function isRecord9(value) {
|
|
14182
14494
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14183
14495
|
}
|
|
14184
14496
|
function textOf(result) {
|
|
@@ -14197,6 +14509,9 @@ var init_call = __esm({
|
|
|
14197
14509
|
action: "call",
|
|
14198
14510
|
summary: "Call a hosted Kenso MCP tool, such as list_skills",
|
|
14199
14511
|
brief: "list_skills runs directly",
|
|
14512
|
+
effect: "destructive",
|
|
14513
|
+
// The two skill tools only read; any other tool can do whatever the API can.
|
|
14514
|
+
effectFor: ({ positionals }) => positionals[0] === "list_skills" || positionals[0] === "load_skill" ? "read" : "destructive",
|
|
14200
14515
|
description: "Calls one Kenso MCP tool with the same API key and prints its result: structuredContent when the tool returns it, else its text parsed as JSON, else the text. Covers MCP-only tools, such as the skills: list_skills and load_skill take no kenso mcp tools first. A tool error exits 1 with the tool's message. A facade tool takes its operation with --operation. --dry-run prints the tools/call request (tool and arguments) and sends nothing.",
|
|
14201
14516
|
flags: {
|
|
14202
14517
|
operation: { type: "string", description: "The facade operation, for example list" },
|
|
@@ -14211,7 +14526,7 @@ var init_call = __esm({
|
|
|
14211
14526
|
let args = {};
|
|
14212
14527
|
if (typeof flags.args === "string") {
|
|
14213
14528
|
const parsed3 = await readDataArg(flags.args, ctx.stdin);
|
|
14214
|
-
if (!
|
|
14529
|
+
if (!isRecord9(parsed3)) throw usageError("--args must be a JSON object.", { field: "args", hint: `For example --args '{"limit":5}'.` });
|
|
14215
14530
|
args = parsed3;
|
|
14216
14531
|
}
|
|
14217
14532
|
if (typeof flags.operation === "string") args = { ...args, operation: flags.operation };
|
|
@@ -14265,6 +14580,7 @@ var init_tools = __esm({
|
|
|
14265
14580
|
action: "tools",
|
|
14266
14581
|
summary: "List the hosted Kenso MCP's tools",
|
|
14267
14582
|
brief: "only to find a tool name",
|
|
14583
|
+
effect: "read",
|
|
14268
14584
|
description: "Lists every tool of the Kenso MCP (KENSO_MCP_URL, default https://mcp.ken.so/mcp) as { name, description }, with the same API key. Call one with kenso mcp call <tool>.",
|
|
14269
14585
|
flags: {},
|
|
14270
14586
|
examples: ["kenso mcp tools", "kenso mcp tools --fields name"],
|
|
@@ -14280,11 +14596,11 @@ var init_tools = __esm({
|
|
|
14280
14596
|
});
|
|
14281
14597
|
|
|
14282
14598
|
// src/commands/mcp/index.ts
|
|
14283
|
-
var
|
|
14599
|
+
var actions20;
|
|
14284
14600
|
var init_mcp = __esm({
|
|
14285
14601
|
"src/commands/mcp/index.ts"() {
|
|
14286
14602
|
"use strict";
|
|
14287
|
-
|
|
14603
|
+
actions20 = {
|
|
14288
14604
|
call: () => Promise.resolve().then(() => (init_call(), call_exports)).then((m) => m.default),
|
|
14289
14605
|
tools: () => Promise.resolve().then(() => (init_tools(), tools_exports)).then((m) => m.default)
|
|
14290
14606
|
};
|
|
@@ -14339,6 +14655,7 @@ var init_list = __esm({
|
|
|
14339
14655
|
resource: "notes",
|
|
14340
14656
|
action: "list",
|
|
14341
14657
|
summary: "List the notes on an account, a person or a deal, or every comment under one note",
|
|
14658
|
+
effect: "read",
|
|
14342
14659
|
description: "Reads GET /v1/notes for the one record you name and follows every page. Each note has id, body (markdown, mentions as @[Name](memberId)), mentions, isPinned, createdBy, createdAt, editedAt, commentCount and its first 50 comments, oldest first. When commentCount is above 50, --parent <noteId> (alone, no record flag) lists every comment under that note, oldest first. --account with --related adds the notes on the account's deals and on the people with a role on it, each naming its own record. A record or note outside your workspace or account scope is not_found.",
|
|
14343
14660
|
flags: {
|
|
14344
14661
|
...targetFlags,
|
|
@@ -14397,6 +14714,7 @@ var init_add = __esm({
|
|
|
14397
14714
|
resource: "notes",
|
|
14398
14715
|
action: "add",
|
|
14399
14716
|
summary: "Write a note on an account, a person or a deal, or a comment under a note",
|
|
14717
|
+
effect: "write",
|
|
14400
14718
|
description: "Sends POST /v1/notes and prints the note. Name the record with one of --account, --person and --deal, or answer a note with --parent. The body is markdown, up to 20,000 characters; mention a teammate as @[Name](memberId) and they are notified. The note shows on the record's Notes tab and its Activity timeline. A note on an account needs the accounts plan feature. --dry-run prints the POST and writes nothing.",
|
|
14401
14719
|
flags: {
|
|
14402
14720
|
...targetFlags,
|
|
@@ -14449,6 +14767,7 @@ var init_edit = __esm({
|
|
|
14449
14767
|
resource: "notes",
|
|
14450
14768
|
action: "edit",
|
|
14451
14769
|
summary: "Change a note's text, or pin or unpin it",
|
|
14770
|
+
effect: "write",
|
|
14452
14771
|
description: "Sends PATCH /v1/notes/{noteId} and prints the note. Only the note's author changes its text; anyone who can edit accounts pins or unpins a note (not a comment). Teammates a new text mentions for the first time are notified. --dry-run prints the PATCH and changes nothing.",
|
|
14453
14772
|
flags: {
|
|
14454
14773
|
body: { type: "string", description: "The new text, in markdown. - reads it from stdin" },
|
|
@@ -14496,6 +14815,7 @@ var init_delete = __esm({
|
|
|
14496
14815
|
resource: "notes",
|
|
14497
14816
|
action: "delete",
|
|
14498
14817
|
summary: "Delete a note or a comment (its author or a workspace admin)",
|
|
14818
|
+
effect: "destructive",
|
|
14499
14819
|
description: "Sends DELETE /v1/notes/{noteId}. The note leaves the record's Notes tab and Activity timeline; `kenso notes restore --note-id <noteId>` brings it back. Needs --yes, or a yes at the prompt; --dry-run prints the DELETE and deletes nothing.",
|
|
14500
14820
|
flags: {},
|
|
14501
14821
|
positionals: [{ name: "noteId", required: true, description: "The note or comment id" }],
|
|
@@ -14518,11 +14838,11 @@ var init_delete = __esm({
|
|
|
14518
14838
|
});
|
|
14519
14839
|
|
|
14520
14840
|
// src/commands/notes/index.ts
|
|
14521
|
-
var
|
|
14841
|
+
var actions21;
|
|
14522
14842
|
var init_notes = __esm({
|
|
14523
14843
|
"src/commands/notes/index.ts"() {
|
|
14524
14844
|
"use strict";
|
|
14525
|
-
|
|
14845
|
+
actions21 = {
|
|
14526
14846
|
list: () => Promise.resolve().then(() => (init_list(), list_exports)).then((m) => m.default),
|
|
14527
14847
|
add: () => Promise.resolve().then(() => (init_add(), add_exports)).then((m) => m.default),
|
|
14528
14848
|
edit: () => Promise.resolve().then(() => (init_edit(), edit_exports)).then((m) => m.default),
|
|
@@ -14563,6 +14883,7 @@ var init_move = __esm({
|
|
|
14563
14883
|
resource: "opportunities",
|
|
14564
14884
|
action: "move",
|
|
14565
14885
|
summary: "Move a deal to a stage or another pipeline, with its won or lost reason",
|
|
14886
|
+
effect: "write",
|
|
14566
14887
|
description: "Sends PATCH /v1/opportunities/{opportunityId} with stage, pipelineId or both, and prints the deal. With --pipeline alone the deal keeps its category (open, won or lost): it lands in that pipeline's live stage of the category with the same label as its stage now, else in the category's first live stage. Read where it landed from the printed stage. With --stage too, the stage must be that pipeline's. --stage alone moves the deal to that stage, in whichever pipeline holds it. An archived pipeline takes no deal from another one. A stage a person set is refused with pinned_by_user unless --overwrite-pinned. Pipeline ids and stage keys: kenso pipelines list. With --reason (it needs --stage) the reason key goes as wonReasonKey for a won stage or lostReasonKey for a lost stage (it reads GET /v1/opportunity-stages, and GET /v1/pipelines for a stage of another pipeline, to tell which; an open stage takes no reason). Reason keys come from kenso opportunity-reasons get. A move never waits for a field the stage asks for: the deal moves, each missing field prints a warning on stderr, and the deal is flagged Missing until the field is filled (kenso opportunities list --missing-fields). --dry-run prints the PATCH and moves nothing.",
|
|
14567
14888
|
flags: {
|
|
14568
14889
|
stage: { type: "string", description: "The stage key to move to (kenso pipelines list lists every pipeline's). Without it, --pipeline maps the stage" },
|
|
@@ -14647,6 +14968,7 @@ var init_stage_history = __esm({
|
|
|
14647
14968
|
resource: "opportunities",
|
|
14648
14969
|
action: "stage-history",
|
|
14649
14970
|
summary: "Show a deal's stage history: each stage, when, who moved it and how long it sat there",
|
|
14971
|
+
effect: "read",
|
|
14650
14972
|
description: "Reads GET /v1/opportunities/{opportunityId}/stage-history and prints it: the stage now, isComplete and entries, oldest first. Each entry has kind (created, stage_changed, won, lost), fromStage, stage, stageLabel, enteredAt, leftAt, durationSeconds, actorKind, actorMemberId and, on a move Ken's stage judge made, reason. The created entry of a deal a CSV import brought in has imported: true, entered on the file's close date when it came in closed. With the deal_stage_rules flag on, each entry also says who changed it (changedBy: member, agent, api_key, workflow, stage_judge, crm_sync or ken_automation, with crmProvider on a CRM sync) and, on a move, fromStageLabel and fromStageDurationSeconds (how long the deal sat in the stage it left). With the pipelines flag on, a move between pipelines also has pipeline and fromPipeline ({id, name}). isComplete false means Kenso has no record of part of the history.",
|
|
14651
14973
|
flags: {},
|
|
14652
14974
|
positionals: [{ name: "opportunityId", required: true, description: "The deal (opportunity) id" }],
|
|
@@ -14723,11 +15045,11 @@ var init_bulk_delete2 = __esm({
|
|
|
14723
15045
|
});
|
|
14724
15046
|
|
|
14725
15047
|
// src/commands/opportunities/index.ts
|
|
14726
|
-
var
|
|
15048
|
+
var actions22;
|
|
14727
15049
|
var init_opportunities = __esm({
|
|
14728
15050
|
"src/commands/opportunities/index.ts"() {
|
|
14729
15051
|
"use strict";
|
|
14730
|
-
|
|
15052
|
+
actions22 = {
|
|
14731
15053
|
move: () => Promise.resolve().then(() => (init_move(), move_exports)).then((m) => m.default),
|
|
14732
15054
|
"stage-history": () => Promise.resolve().then(() => (init_stage_history(), stage_history_exports)).then((m) => m.default),
|
|
14733
15055
|
"bulk-update": () => Promise.resolve().then(() => (init_bulk_update3(), bulk_update_exports2)).then((m) => m.default),
|
|
@@ -14844,6 +15166,7 @@ var init_import5 = __esm({
|
|
|
14844
15166
|
action: "import",
|
|
14845
15167
|
summary: "Create or match people from a CSV or JSONL file, optionally onto accounts",
|
|
14846
15168
|
brief: "a file of people",
|
|
15169
|
+
effect: "spend",
|
|
14847
15170
|
description: "Sends the rows to people.batch, 200 per call. Columns map by name (case, spaces and dashes ignored): email, fullName (or name), firstName, lastName, linkedinUrl (or linkedin, profileUrl), title, accountDomain (or domain, website, companyDomain), accountId, role and priority. A person needs a name: fullName, or firstName and lastName. Other columns are ignored with a warning. People already in the workspace are matched by email, then LinkedIn URL, so running the same file again creates nothing. It never creates accounts: a row whose accountDomain matches no account fails with account_not_found. Without --yes it only prints the plan.",
|
|
14848
15171
|
flags: {
|
|
14849
15172
|
file: { type: "string", required: true, description: "The CSV or JSONL file, or - for stdin" },
|
|
@@ -14979,6 +15302,7 @@ var init_merge2 = __esm({
|
|
|
14979
15302
|
resource: "people",
|
|
14980
15303
|
action: "merge",
|
|
14981
15304
|
summary: "Merge a person into the one you keep. --dry-run shows what would move and writes nothing",
|
|
15305
|
+
effect: "destructive",
|
|
14982
15306
|
description: "Sends POST /v1/people/{personId}/merge with intoPersonId, the person to keep. The kept person keeps every value they have and takes the merged person's values for their blank fields, custom fields included; account places, deals, meetings, tasks, notes and captured email and meetings move to them. A merge cannot be undone. With --dry-run the API runs the merge, answers the kept person with mergeSummary (fieldChanges the merge would fill, and moved: accountCount, combinedAccountCount, opportunityCount, meetingCount, taskCount, noteCount, timelineEventCount) and rolls it back: nothing is written. The dry run needs the crm_import_export flag.",
|
|
14983
15307
|
flags: {
|
|
14984
15308
|
into: { type: "string", description: "The id of the person to keep" },
|
|
@@ -15026,11 +15350,11 @@ var init_merge2 = __esm({
|
|
|
15026
15350
|
});
|
|
15027
15351
|
|
|
15028
15352
|
// src/commands/people/index.ts
|
|
15029
|
-
var
|
|
15353
|
+
var actions23;
|
|
15030
15354
|
var init_people = __esm({
|
|
15031
15355
|
"src/commands/people/index.ts"() {
|
|
15032
15356
|
"use strict";
|
|
15033
|
-
|
|
15357
|
+
actions23 = {
|
|
15034
15358
|
import: () => Promise.resolve().then(() => (init_import5(), import_exports4)).then((m) => m.default),
|
|
15035
15359
|
"bulk-update": () => Promise.resolve().then(() => (init_bulk_update4(), bulk_update_exports3)).then((m) => m.default),
|
|
15036
15360
|
"bulk-delete": () => Promise.resolve().then(() => (init_bulk_delete3(), bulk_delete_exports3)).then((m) => m.default),
|
|
@@ -15072,6 +15396,8 @@ var init_stage_rules = __esm({
|
|
|
15072
15396
|
resource: "pipelines",
|
|
15073
15397
|
action: "stage-rules",
|
|
15074
15398
|
summary: "List or set the fields a deal should have in each stage",
|
|
15399
|
+
effect: "write",
|
|
15400
|
+
effectFor: ({ positionals }) => positionals.length === 0 ? "read" : "write",
|
|
15075
15401
|
description: "Without a stage, reads GET /v1/opportunity-stages (the default pipeline's stages; --pipeline <id> reads that pipeline's from GET /v1/pipelines/{pipelineId}) and prints each stage's key, label, category, isArchived, requiredFields and isDefault, plus requirableFields: every field a stage can require (amount, closeDate, ownerMemberId, primaryPersonId, nextStep, lostReasonKey, wonReasonKey, and custom.<key> for each custom deal field). With a stage and --require, --default or --none, sends PUT /v1/opportunity-stages/{stageKey}/required-fields and prints that stage's rule. --require is the stage's whole list, in order, at most 10. --default puts it back on the default: a lost stage asks for lostReasonKey, any other stage nothing. A missing field never stops a move: the deal moves, the move prints a warning, and the deal is flagged Missing until the field is filled. Setting a rule needs the workspace_settings permission. A stage key is unique across pipelines, so it sets a stage of any pipeline; with --pipeline it first checks the stage is that pipeline's. --dry-run prints the PUT and changes nothing.",
|
|
15076
15402
|
flags: {
|
|
15077
15403
|
require: { type: "string", description: "Comma-separated field ids the stage requires, in order (amount,closeDate,custom.tier)" },
|
|
@@ -15145,11 +15471,11 @@ var init_stage_rules = __esm({
|
|
|
15145
15471
|
});
|
|
15146
15472
|
|
|
15147
15473
|
// src/commands/pipelines/index.ts
|
|
15148
|
-
var
|
|
15474
|
+
var actions24;
|
|
15149
15475
|
var init_pipelines = __esm({
|
|
15150
15476
|
"src/commands/pipelines/index.ts"() {
|
|
15151
15477
|
"use strict";
|
|
15152
|
-
|
|
15478
|
+
actions24 = {
|
|
15153
15479
|
"stage-rules": () => Promise.resolve().then(() => (init_stage_rules(), stage_rules_exports)).then((m) => m.default)
|
|
15154
15480
|
};
|
|
15155
15481
|
}
|
|
@@ -15172,6 +15498,7 @@ var init_run2 = __esm({
|
|
|
15172
15498
|
resource: "reports",
|
|
15173
15499
|
action: "run",
|
|
15174
15500
|
summary: "Run a stock pipeline report and print its table",
|
|
15501
|
+
effect: "read",
|
|
15175
15502
|
description: `Reads GET /v1/reports/{reportKey} and prints one row per bucket: the bucket's label under the dimension's name (stage, closedAt, sourceCampaignId) and each measure under its key (count, sumAmount, weightedAmount, avgAmount). Amounts are in the workspace currency. The report's title, its finding, the days it covers and the totals are printed to stderr. stage_conversion reads one pipeline: with no --pipeline in a workspace with several, the default one, named after the title. --full prints the whole answer as one object: headline, finding, stats, chart, the stored query, and result with each bucket's filter for opportunities search. Reports: ${REPORTS.join(", ")}; kenso reports list prints the ones your workspace has now.`,
|
|
15176
15503
|
flags: {
|
|
15177
15504
|
period: {
|
|
@@ -15259,6 +15586,7 @@ var init_summary = __esm({
|
|
|
15259
15586
|
resource: "reports",
|
|
15260
15587
|
action: "summary",
|
|
15261
15588
|
summary: "Read where the period stands and what needs you",
|
|
15589
|
+
effect: "read",
|
|
15262
15590
|
description: "Reads GET /v1/reports/summary. Prints the summary in words, the four numbers (closed won, open pipeline, weighted, win rate; a fraction from 0 to 1) and each thing that needs you with the report that shows it to stderr, then one row per stock report: its key, the question it answers and its headline value, format and label. Run a report with kenso reports run <report>. --full prints the whole answer as one object.",
|
|
15263
15591
|
flags: {
|
|
15264
15592
|
period: {
|
|
@@ -15321,11 +15649,11 @@ var init_summary = __esm({
|
|
|
15321
15649
|
});
|
|
15322
15650
|
|
|
15323
15651
|
// src/commands/reports/index.ts
|
|
15324
|
-
var
|
|
15652
|
+
var actions25;
|
|
15325
15653
|
var init_reports = __esm({
|
|
15326
15654
|
"src/commands/reports/index.ts"() {
|
|
15327
15655
|
"use strict";
|
|
15328
|
-
|
|
15656
|
+
actions25 = {
|
|
15329
15657
|
run: () => Promise.resolve().then(() => (init_run2(), run_exports2)).then((m) => m.default),
|
|
15330
15658
|
summary: () => Promise.resolve().then(() => (init_summary(), summary_exports)).then((m) => m.default)
|
|
15331
15659
|
};
|
|
@@ -15349,6 +15677,7 @@ var init_list2 = __esm({
|
|
|
15349
15677
|
action: "list",
|
|
15350
15678
|
summary: "List batch runs, newest first (finds an interrupted run)",
|
|
15351
15679
|
brief: "finds an interrupted run",
|
|
15680
|
+
effect: "read",
|
|
15352
15681
|
description: "Lists the runs under the runs directory (KENSO_RUNS_DIR, else ~/.kenso/runs). Needs no API key.",
|
|
15353
15682
|
flags: {
|
|
15354
15683
|
limit: { type: "string", default: "20", description: "How many runs to list, 1-1000 (default 20)" }
|
|
@@ -15374,8 +15703,8 @@ var show_exports2 = {};
|
|
|
15374
15703
|
__export(show_exports2, {
|
|
15375
15704
|
default: () => show_default2
|
|
15376
15705
|
});
|
|
15377
|
-
import { existsSync as existsSync7, readFileSync as
|
|
15378
|
-
import { join as
|
|
15706
|
+
import { existsSync as existsSync7, readFileSync as readFileSync11 } from "node:fs";
|
|
15707
|
+
import { join as join15 } from "node:path";
|
|
15379
15708
|
var FILES, command44, show_default2;
|
|
15380
15709
|
var init_show2 = __esm({
|
|
15381
15710
|
"src/commands/runs/show.ts"() {
|
|
@@ -15395,21 +15724,22 @@ var init_show2 = __esm({
|
|
|
15395
15724
|
resource: "runs",
|
|
15396
15725
|
action: "show",
|
|
15397
15726
|
summary: "Show one batch run and its files",
|
|
15727
|
+
effect: "read",
|
|
15398
15728
|
flags: {},
|
|
15399
15729
|
positionals: [{ name: "runId", required: true, description: "The run id (see kenso runs list)" }],
|
|
15400
15730
|
examples: ["kenso runs show r_ab3dxk2q"],
|
|
15401
15731
|
async run(ctx, { positionals }) {
|
|
15402
15732
|
const run = await loadRun(positionals[0] ?? "", ctx.env);
|
|
15403
|
-
const { dir:
|
|
15404
|
-
const files = { dir:
|
|
15733
|
+
const { dir: dir3, ...record3 } = run;
|
|
15734
|
+
const files = { dir: dir3 };
|
|
15405
15735
|
for (const [key, name] of FILES) {
|
|
15406
|
-
const path =
|
|
15736
|
+
const path = join15(dir3, name);
|
|
15407
15737
|
if (existsSync7(path)) files[key] = path;
|
|
15408
15738
|
}
|
|
15409
15739
|
let summary;
|
|
15410
15740
|
if (files.summary) {
|
|
15411
15741
|
try {
|
|
15412
|
-
summary = JSON.parse(
|
|
15742
|
+
summary = JSON.parse(readFileSync11(files.summary, "utf8"));
|
|
15413
15743
|
} catch {
|
|
15414
15744
|
summary = void 0;
|
|
15415
15745
|
}
|
|
@@ -15523,6 +15853,7 @@ var init_resume = __esm({
|
|
|
15523
15853
|
action: "resume",
|
|
15524
15854
|
summary: "Continue an interrupted batch run (its command with --yes, no dry run)",
|
|
15525
15855
|
brief: "with --yes, no dry run",
|
|
15856
|
+
effect: "destructive",
|
|
15526
15857
|
description: "Rebuilds the run's command from run.json and runs it with --yes from the directory it started in. The engine finds the run by its identity and skips the chunks already done. Refused when the input file is gone or changed, when the run is not a batch run or names a flag its command does not take, and when its folder or run.json is not yours alone.",
|
|
15527
15858
|
flags: {},
|
|
15528
15859
|
positionals: [{ name: "runId", required: true, description: "The run id (see kenso runs list)" }],
|
|
@@ -15573,11 +15904,11 @@ var init_resume = __esm({
|
|
|
15573
15904
|
});
|
|
15574
15905
|
|
|
15575
15906
|
// src/commands/runs/index.ts
|
|
15576
|
-
var
|
|
15907
|
+
var actions26;
|
|
15577
15908
|
var init_runs2 = __esm({
|
|
15578
15909
|
"src/commands/runs/index.ts"() {
|
|
15579
15910
|
"use strict";
|
|
15580
|
-
|
|
15911
|
+
actions26 = {
|
|
15581
15912
|
list: () => Promise.resolve().then(() => (init_list2(), list_exports2)).then((m) => m.default),
|
|
15582
15913
|
show: () => Promise.resolve().then(() => (init_show2(), show_exports2)).then((m) => m.default),
|
|
15583
15914
|
resume: () => Promise.resolve().then(() => (init_resume(), resume_exports)).then((m) => m.default)
|
|
@@ -15688,6 +16019,7 @@ var init_create = __esm({
|
|
|
15688
16019
|
resource: "sandbox",
|
|
15689
16020
|
action: "create",
|
|
15690
16021
|
summary: "Create your developer sandbox and save its test key as the sandbox profile",
|
|
16022
|
+
effect: "write",
|
|
15691
16023
|
description: `Calls POST /v1/sandboxes with your live key. Kenso creates a sandbox workspace of your own, seeds it with campaigns, contacts, inboxes and threads, and returns a test key (kenso_test_...) that works only there. The key is saved as the profile "${SANDBOX_PROFILE}" and the active profile stays as it is: add --profile ${SANDBOX_PROFILE} to run a command in the sandbox. In a sandbox, sends are simulated: nothing leaves Kenso.`,
|
|
15692
16024
|
flags: {},
|
|
15693
16025
|
examples: ["kenso sandbox create", "kenso campaigns list --profile sandbox"],
|
|
@@ -15747,6 +16079,7 @@ var init_delete2 = __esm({
|
|
|
15747
16079
|
resource: "sandbox",
|
|
15748
16080
|
action: "delete",
|
|
15749
16081
|
summary: "Delete your sandbox and its test keys",
|
|
16082
|
+
effect: "destructive",
|
|
15750
16083
|
description: `Calls DELETE /v1/sandboxes/{sandboxId} with your live key: the sandbox's data, its webhook endpoints and their delivery history are gone for good and its test keys are revoked. Then removes the profile "${SANDBOX_PROFILE}" when it holds this sandbox. Without an id it deletes your one sandbox. It asks first on a terminal; anywhere else it needs --yes.`,
|
|
15751
16084
|
flags: {},
|
|
15752
16085
|
positionals: [SANDBOX_ID_POSITIONAL],
|
|
@@ -15790,6 +16123,7 @@ var init_key = __esm({
|
|
|
15790
16123
|
resource: "sandbox",
|
|
15791
16124
|
action: "key",
|
|
15792
16125
|
summary: "Create a new test key for your sandbox and save it as the sandbox profile",
|
|
16126
|
+
effect: "write",
|
|
15793
16127
|
description: `Calls POST /v1/sandboxes/{sandboxId}/test-keys with your live key and saves the new key as the profile "${SANDBOX_PROFILE}" (the active profile stays as it is). A sandbox has 5 active test keys at most. Without an id it uses your one sandbox.`,
|
|
15794
16128
|
flags: {},
|
|
15795
16129
|
positionals: [SANDBOX_ID_POSITIONAL],
|
|
@@ -15825,6 +16159,7 @@ var init_list3 = __esm({
|
|
|
15825
16159
|
resource: "sandbox",
|
|
15826
16160
|
action: "list",
|
|
15827
16161
|
summary: "List your developer sandbox",
|
|
16162
|
+
effect: "read",
|
|
15828
16163
|
description: "Calls GET /v1/sandboxes with your live key. You have one sandbox at most, so this prints one row or none.",
|
|
15829
16164
|
flags: {},
|
|
15830
16165
|
examples: ["kenso sandbox list"],
|
|
@@ -15857,6 +16192,7 @@ var init_reset = __esm({
|
|
|
15857
16192
|
resource: "sandbox",
|
|
15858
16193
|
action: "reset",
|
|
15859
16194
|
summary: "Reset your sandbox to its seed data",
|
|
16195
|
+
effect: "destructive",
|
|
15860
16196
|
description: "Calls POST /v1/sandboxes/{sandboxId}/reset with your live key: everything in the sandbox is deleted and seeded again. Its test keys and webhook endpoints stay. Without an id it resets your one sandbox.",
|
|
15861
16197
|
flags: {},
|
|
15862
16198
|
positionals: [SANDBOX_ID_POSITIONAL],
|
|
@@ -15876,11 +16212,11 @@ var init_reset = __esm({
|
|
|
15876
16212
|
});
|
|
15877
16213
|
|
|
15878
16214
|
// src/commands/sandbox/index.ts
|
|
15879
|
-
var
|
|
16215
|
+
var actions27;
|
|
15880
16216
|
var init_sandbox2 = __esm({
|
|
15881
16217
|
"src/commands/sandbox/index.ts"() {
|
|
15882
16218
|
"use strict";
|
|
15883
|
-
|
|
16219
|
+
actions27 = {
|
|
15884
16220
|
create: () => Promise.resolve().then(() => (init_create(), create_exports)).then((m) => m.default),
|
|
15885
16221
|
delete: () => Promise.resolve().then(() => (init_delete2(), delete_exports2)).then((m) => m.default),
|
|
15886
16222
|
key: () => Promise.resolve().then(() => (init_key(), key_exports)).then((m) => m.default),
|
|
@@ -15890,12 +16226,21 @@ var init_sandbox2 = __esm({
|
|
|
15890
16226
|
}
|
|
15891
16227
|
});
|
|
15892
16228
|
|
|
16229
|
+
// src/commands/signals/index.ts
|
|
16230
|
+
var actions28;
|
|
16231
|
+
var init_signals = __esm({
|
|
16232
|
+
"src/commands/signals/index.ts"() {
|
|
16233
|
+
"use strict";
|
|
16234
|
+
actions28 = {};
|
|
16235
|
+
}
|
|
16236
|
+
});
|
|
16237
|
+
|
|
15893
16238
|
// src/commands/skill/index.ts
|
|
15894
|
-
var
|
|
16239
|
+
var actions29;
|
|
15895
16240
|
var init_skill = __esm({
|
|
15896
16241
|
"src/commands/skill/index.ts"() {
|
|
15897
16242
|
"use strict";
|
|
15898
|
-
|
|
16243
|
+
actions29 = {
|
|
15899
16244
|
install: () => Promise.resolve().then(() => (init_install(), install_exports)).then((m) => m.default)
|
|
15900
16245
|
};
|
|
15901
16246
|
}
|
|
@@ -15933,7 +16278,7 @@ var init_common3 = __esm({
|
|
|
15933
16278
|
// src/commands/studio/folder.ts
|
|
15934
16279
|
import { createHash as createHash6 } from "node:crypto";
|
|
15935
16280
|
import { lstat, readdir as readdir2, readFile as readFile10, stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
|
|
15936
|
-
import { extname as extname6, isAbsolute, join as
|
|
16281
|
+
import { extname as extname6, isAbsolute, join as join16, relative, resolve as resolve11, sep } from "node:path";
|
|
15937
16282
|
function textOf2(bytes) {
|
|
15938
16283
|
if (bytes.length >= TEXT_MAX_BYTES || bytes.includes(0)) return void 0;
|
|
15939
16284
|
try {
|
|
@@ -15942,10 +16287,10 @@ function textOf2(bytes) {
|
|
|
15942
16287
|
return void 0;
|
|
15943
16288
|
}
|
|
15944
16289
|
}
|
|
15945
|
-
async function existingDir(
|
|
15946
|
-
const abs = resolve11(
|
|
16290
|
+
async function existingDir(dir3) {
|
|
16291
|
+
const abs = resolve11(dir3);
|
|
15947
16292
|
const info = await stat3(abs).catch(() => void 0);
|
|
15948
|
-
if (!info?.isDirectory()) throw usageError(`${
|
|
16293
|
+
if (!info?.isDirectory()) throw usageError(`${dir3} is not a directory.`, { field: "dir" });
|
|
15949
16294
|
return abs;
|
|
15950
16295
|
}
|
|
15951
16296
|
function inBundleLayout(bundlePath) {
|
|
@@ -15956,14 +16301,14 @@ function inBundleLayout(bundlePath) {
|
|
|
15956
16301
|
const name = segments[1];
|
|
15957
16302
|
return segments[0] === "samples" && segments.length === 2 && SAMPLE_NAME.test(name) && !TOOL_CONFIG_NAMES.has(name.toLowerCase());
|
|
15958
16303
|
}
|
|
15959
|
-
async function readFolder(
|
|
15960
|
-
const root2 = await existingDir(
|
|
16304
|
+
async function readFolder(dir3, skipped = []) {
|
|
16305
|
+
const root2 = await existingDir(dir3);
|
|
15961
16306
|
const files = [];
|
|
15962
16307
|
const walk = async (folder) => {
|
|
15963
16308
|
const entries2 = await readdir2(folder, { withFileTypes: true });
|
|
15964
16309
|
for (const entry of entries2) {
|
|
15965
16310
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
15966
|
-
const abs =
|
|
16311
|
+
const abs = join16(folder, entry.name);
|
|
15967
16312
|
const path = relative(root2, abs).split(sep).join("/");
|
|
15968
16313
|
if (entry.isDirectory()) {
|
|
15969
16314
|
if (path === "assets" || path.startsWith("assets/") || path === "samples") await walk(abs);
|
|
@@ -15995,7 +16340,7 @@ async function existingFileNoLinks(root2, target2, bundlePath) {
|
|
|
15995
16340
|
const parts2 = relative(root2, target2).split(sep);
|
|
15996
16341
|
let at = root2;
|
|
15997
16342
|
for (const [i, part] of parts2.entries()) {
|
|
15998
|
-
at =
|
|
16343
|
+
at = join16(at, part);
|
|
15999
16344
|
const info = await lstat(at).catch(() => void 0);
|
|
16000
16345
|
if (!info) return false;
|
|
16001
16346
|
if (info.isSymbolicLink()) throw unsafePath(bundlePath, `${at} is a symbolic link`);
|
|
@@ -16008,7 +16353,7 @@ async function existingFileNoLinks(root2, target2, bundlePath) {
|
|
|
16008
16353
|
}
|
|
16009
16354
|
async function readPullState(root2) {
|
|
16010
16355
|
try {
|
|
16011
|
-
const files = JSON.parse(await readFile10(
|
|
16356
|
+
const files = JSON.parse(await readFile10(join16(root2, PULL_STATE), "utf8"))?.files;
|
|
16012
16357
|
if (typeof files !== "object" || files === null) return {};
|
|
16013
16358
|
return Object.fromEntries(Object.entries(files).filter((entry) => typeof entry[1] === "string"));
|
|
16014
16359
|
} catch {
|
|
@@ -16016,7 +16361,7 @@ async function readPullState(root2) {
|
|
|
16016
16361
|
}
|
|
16017
16362
|
}
|
|
16018
16363
|
async function recordPullState(root2, entries2) {
|
|
16019
|
-
const path =
|
|
16364
|
+
const path = join16(root2, PULL_STATE);
|
|
16020
16365
|
await existingFileNoLinks(root2, path, PULL_STATE);
|
|
16021
16366
|
const files = { ...await readPullState(root2), ...Object.fromEntries(entries2) };
|
|
16022
16367
|
await writeFile4(path, `${JSON.stringify({ files }, null, 2)}
|
|
@@ -16226,7 +16571,7 @@ __export(pull_exports, {
|
|
|
16226
16571
|
default: () => pull_default
|
|
16227
16572
|
});
|
|
16228
16573
|
import { mkdir, readFile as readFile11, writeFile as writeFile5 } from "node:fs/promises";
|
|
16229
|
-
import { dirname as dirname2, join as
|
|
16574
|
+
import { dirname as dirname2, join as join17, resolve as resolve12 } from "node:path";
|
|
16230
16575
|
var command51, pull_default;
|
|
16231
16576
|
var init_pull = __esm({
|
|
16232
16577
|
"src/commands/studio/pull.ts"() {
|
|
@@ -16242,6 +16587,7 @@ var init_pull = __esm({
|
|
|
16242
16587
|
resource: "studio",
|
|
16243
16588
|
action: "pull",
|
|
16244
16589
|
summary: "Write a template version's files to a folder",
|
|
16590
|
+
effect: "read",
|
|
16245
16591
|
description: `Reads GET /v1/asset-templates/{templateId}/pull and writes every file under --dir: text files from the answer, binaries downloaded from their signed links. It replaces an existing file only when an earlier pull wrote it or a push sent it and it has not changed since (${PULL_STATE} in the folder records both), or with --force; other files in the folder are left alone. Every path is checked before anything is written: one that is not a file of the Studio bundle layout (studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/, samples/), would land outside --dir, or passes through a symbolic link is refused. --template-version picks the version: draft, latest (published) or a version id; the default is the draft, else the latest published version. --dry-run lists the paths, and the files it would not replace, without writing or downloading anything.`,
|
|
16246
16592
|
flags: {
|
|
16247
16593
|
dir: { type: "string", required: true, description: "The folder to write the files to (created when missing)" },
|
|
@@ -16260,7 +16606,7 @@ var init_pull = __esm({
|
|
|
16260
16606
|
if (version !== void 0 && !/^(draft|latest|\d+)$/.test(version)) {
|
|
16261
16607
|
throw usageError(`--template-version must be draft, latest or a version id (got "${version}").`, { field: "template-version" });
|
|
16262
16608
|
}
|
|
16263
|
-
const
|
|
16609
|
+
const dir3 = resolve12(String(flags.dir));
|
|
16264
16610
|
const res = await ctx.client.request({
|
|
16265
16611
|
method: "GET",
|
|
16266
16612
|
path: `/v1/asset-templates/${templateId}/pull`,
|
|
@@ -16271,17 +16617,17 @@ var init_pull = __esm({
|
|
|
16271
16617
|
if (pulled.skipped?.length) {
|
|
16272
16618
|
ctx.output.warn(`Kenso left out ${pulled.skipped.length} stored file${pulled.skipped.length === 1 ? "" : "s"} outside the bundle layout: ${pulled.skipped.join(", ")}.`);
|
|
16273
16619
|
}
|
|
16274
|
-
const files = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(
|
|
16620
|
+
const files = Object.entries(pulled.files ?? {}).map(([path, file]) => ({ path, file, target: safeJoin(dir3, path) }));
|
|
16275
16621
|
const missing2 = files.find(({ file }) => typeof file.text !== "string" && !file.downloadUrl);
|
|
16276
16622
|
if (missing2) {
|
|
16277
16623
|
throw new KensoError({ code: "pull_incomplete", message: `${missing2.path} came back with neither text nor a download link.`, exitCode: ExitCode.Server });
|
|
16278
16624
|
}
|
|
16279
|
-
const statePath2 =
|
|
16280
|
-
await existingFileNoLinks(
|
|
16281
|
-
const state = await readPullState(
|
|
16625
|
+
const statePath2 = join17(dir3, PULL_STATE);
|
|
16626
|
+
await existingFileNoLinks(dir3, statePath2, PULL_STATE);
|
|
16627
|
+
const state = await readPullState(dir3);
|
|
16282
16628
|
const conflicts = [];
|
|
16283
16629
|
for (const { path, file, target: target2 } of files) {
|
|
16284
|
-
if (!await existingFileNoLinks(
|
|
16630
|
+
if (!await existingFileNoLinks(dir3, target2, path)) continue;
|
|
16285
16631
|
const current = sha2562(await readFile11(target2));
|
|
16286
16632
|
const next = typeof file.text === "string" ? sha2562(Buffer.from(file.text, "utf8")) : file.sha256?.toLowerCase();
|
|
16287
16633
|
if (current !== next && current !== state[path]) conflicts.push(path);
|
|
@@ -16291,7 +16637,7 @@ var init_pull = __esm({
|
|
|
16291
16637
|
dryRun: true,
|
|
16292
16638
|
templateId,
|
|
16293
16639
|
versionId: pulled.versionId,
|
|
16294
|
-
dir:
|
|
16640
|
+
dir: dir3,
|
|
16295
16641
|
files: files.map(({ path }) => path),
|
|
16296
16642
|
...conflicts.length > 0 ? { conflicts } : {}
|
|
16297
16643
|
});
|
|
@@ -16300,22 +16646,22 @@ var init_pull = __esm({
|
|
|
16300
16646
|
if (conflicts.length > 0 && flags.force !== true) {
|
|
16301
16647
|
throw new KensoError({
|
|
16302
16648
|
code: "local_changes",
|
|
16303
|
-
message: `Pulling would replace ${conflicts.length} file${conflicts.length === 1 ? "" : "s"} in ${
|
|
16649
|
+
message: `Pulling would replace ${conflicts.length} file${conflicts.length === 1 ? "" : "s"} in ${dir3} that no earlier pull wrote or push sent, or that changed since: ${conflicts.join(", ")}.`,
|
|
16304
16650
|
exitCode: ExitCode.Conflict,
|
|
16305
16651
|
field: "force",
|
|
16306
16652
|
hint: "They are files you added or changed since the last pull or push. Move them away or compare them with the template first, or add --force to replace them with the template's version. Nothing was written.",
|
|
16307
16653
|
next: commandLine2(ctx, "studio pull", { flags: { ...flags, force: true }, positionals })
|
|
16308
16654
|
});
|
|
16309
16655
|
}
|
|
16310
|
-
await mkdir(
|
|
16656
|
+
await mkdir(dir3, { recursive: true });
|
|
16311
16657
|
const written = await mapLimit(files, PARALLEL_TRANSFERS, async ({ path, file, target: target2 }) => {
|
|
16312
16658
|
const content = typeof file.text === "string" ? Buffer.from(file.text, "utf8") : await download2(file.downloadUrl, path, file.sha256, ctx.signal);
|
|
16313
16659
|
await mkdir(dirname2(target2), { recursive: true });
|
|
16314
16660
|
await writeFile5(target2, content);
|
|
16315
16661
|
return [path, sha2562(content)];
|
|
16316
16662
|
});
|
|
16317
|
-
await recordPullState(
|
|
16318
|
-
ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir:
|
|
16663
|
+
await recordPullState(dir3, written);
|
|
16664
|
+
ctx.output.object({ templateId, versionId: pulled.versionId, files: files.length, dir: dir3, ...conflicts.length > 0 ? { replaced: conflicts } : {} });
|
|
16319
16665
|
return ExitCode.Ok;
|
|
16320
16666
|
}
|
|
16321
16667
|
};
|
|
@@ -16324,24 +16670,24 @@ var init_pull = __esm({
|
|
|
16324
16670
|
});
|
|
16325
16671
|
|
|
16326
16672
|
// src/commands/studio/read.ts
|
|
16327
|
-
async function readLocalTemplate(ctx, templateId,
|
|
16673
|
+
async function readLocalTemplate(ctx, templateId, dir3) {
|
|
16328
16674
|
const skipped = [];
|
|
16329
|
-
const files = await readFolder(
|
|
16675
|
+
const files = await readFolder(dir3, skipped);
|
|
16330
16676
|
if (skipped.length > 0) {
|
|
16331
16677
|
const shown = skipped.length > SHOWN ? `${skipped.slice(0, SHOWN).join(", ")} and ${skipped.length - SHOWN} more` : skipped.join(", ");
|
|
16332
16678
|
ctx.output.warn(`Skipped what is not part of a Studio bundle: ${shown}. A bundle holds only ${LAYOUT}.`);
|
|
16333
16679
|
}
|
|
16334
16680
|
if (files.length === 0) {
|
|
16335
|
-
throw usageError(`${
|
|
16681
|
+
throw usageError(`${dir3} has no template files (only ${LAYOUT} are read; dotfiles and node_modules are skipped).`, {
|
|
16336
16682
|
field: "dir",
|
|
16337
|
-
next: `kenso studio pull ${templateId} --dir ${
|
|
16683
|
+
next: `kenso studio pull ${templateId} --dir ${dir3}`
|
|
16338
16684
|
});
|
|
16339
16685
|
}
|
|
16340
16686
|
refuseOversize(files);
|
|
16341
16687
|
return files;
|
|
16342
16688
|
}
|
|
16343
|
-
async function readTemplateFolder(ctx, templateId,
|
|
16344
|
-
return bundleFiles(ctx, templateId, await readLocalTemplate(ctx, templateId,
|
|
16689
|
+
async function readTemplateFolder(ctx, templateId, dir3) {
|
|
16690
|
+
return bundleFiles(ctx, templateId, await readLocalTemplate(ctx, templateId, dir3));
|
|
16345
16691
|
}
|
|
16346
16692
|
var SHOWN;
|
|
16347
16693
|
var init_read = __esm({
|
|
@@ -16378,6 +16724,7 @@ var init_push = __esm({
|
|
|
16378
16724
|
resource: "studio",
|
|
16379
16725
|
action: "push",
|
|
16380
16726
|
summary: "Save a folder's files to a template's draft and print the validation",
|
|
16727
|
+
effect: "write",
|
|
16381
16728
|
description: "Reads the files of the Studio bundle layout in --dir: studio.json, template.liquid, fallback.liquid, README.md, brief.md, ideas.md, assets/ (images, fonts, pdf, csv) and samples/ (.json, .csv, named in lowercase, never a tool's config name such as package.json). Anything else is skipped, with a note for each file or folder that is not a dotfile or node_modules. Text files (valid UTF-8, no NUL byte, under 1 MB) go inline; every other file is uploaded through a signed upload URL first, 4 at a time, up to 5 MB each. Then one push saves them into the draft and prints the validation result. Files not in the folder stay in the draft unless --delete-missing. With --publish, the new version is published when validation passes. Exit 2 when validation finds errors (the draft is still saved). --dry-run only lists the files a push would send; kenso studio validate checks them without saving.",
|
|
16382
16729
|
flags: {
|
|
16383
16730
|
dir: { type: "string", required: true, description: "The template folder" },
|
|
@@ -16490,6 +16837,7 @@ var init_validate = __esm({
|
|
|
16490
16837
|
resource: "studio",
|
|
16491
16838
|
action: "validate",
|
|
16492
16839
|
summary: "Validate a folder's files against a template without saving them",
|
|
16840
|
+
effect: "write",
|
|
16493
16841
|
description: "Reads --dir the same way as studio push (binaries are uploaded through signed URLs so they can be checked) and validates the files laid over the draft, as a push would. Nothing is saved. With --delete-missing it validates exactly the folder's files. Prints the validation; exit 2 when it has errors.",
|
|
16494
16842
|
flags: {
|
|
16495
16843
|
dir: { type: "string", required: true, description: "The template folder" },
|
|
@@ -16528,8 +16876,8 @@ import { createHash as createHash8 } from "node:crypto";
|
|
|
16528
16876
|
function list(paths) {
|
|
16529
16877
|
return paths.length > SHOWN2 ? `${paths.slice(0, SHOWN2).join(", ")} and ${paths.length - SHOWN2} more` : paths.join(", ");
|
|
16530
16878
|
}
|
|
16531
|
-
async function warnIfFolderDiffers(ctx, templateId,
|
|
16532
|
-
const local = await readFolder(
|
|
16879
|
+
async function warnIfFolderDiffers(ctx, templateId, dir3, versionId, push) {
|
|
16880
|
+
const local = await readFolder(dir3);
|
|
16533
16881
|
const res = await ctx.client.request({
|
|
16534
16882
|
method: "GET",
|
|
16535
16883
|
path: `/v1/asset-templates/${templateId}/pull`,
|
|
@@ -16581,6 +16929,7 @@ var init_preview = __esm({
|
|
|
16581
16929
|
action: "preview",
|
|
16582
16930
|
summary: "Render a saved version for up to 3 accounts; for local edits, studio push them to the draft first",
|
|
16583
16931
|
brief: "push local edits first",
|
|
16932
|
+
effect: "write",
|
|
16584
16933
|
description: "Calls asset-templates.preview: renders the draft (else the latest published version, or --version-id) for --account-ids (up to 3; default the 3 most recently touched accounts, else the bundle's samples) and prints each preview's link, screenshots, console errors and link issues. It takes up to a minute per account. The preview renders what is saved, not local files: with --dir it compares the folder to that version and warns when they differ (run kenso studio push first).",
|
|
16585
16934
|
flags: {
|
|
16586
16935
|
dir: { type: "string", description: "A template folder to compare with the version being rendered; it renders no local edits (studio push them first)" },
|
|
@@ -16602,10 +16951,10 @@ var init_preview = __esm({
|
|
|
16602
16951
|
const ids2 = accountIds(stringFlag(flags["account-ids"]));
|
|
16603
16952
|
const interact = flags.interact !== void 0 ? await readDataArg(String(flags.interact), ctx.stdin) : void 0;
|
|
16604
16953
|
if (interact !== void 0 && !Array.isArray(interact)) throw usageError("--interact must be a JSON array of steps.", { field: "interact" });
|
|
16605
|
-
const
|
|
16606
|
-
if (
|
|
16607
|
-
const push = commandLine2(ctx, "studio push", { flags: { dir:
|
|
16608
|
-
await warnIfFolderDiffers(ctx, templateId,
|
|
16954
|
+
const dir3 = stringFlag(flags.dir);
|
|
16955
|
+
if (dir3 !== void 0) {
|
|
16956
|
+
const push = commandLine2(ctx, "studio push", { flags: { dir: dir3 }, positionals: [String(templateId)] });
|
|
16957
|
+
await warnIfFolderDiffers(ctx, templateId, dir3, versionId, push);
|
|
16609
16958
|
}
|
|
16610
16959
|
const mode = stringFlag(flags.mode);
|
|
16611
16960
|
const sample = stringFlag(flags.sample);
|
|
@@ -16734,7 +17083,7 @@ __export(fill_exports, {
|
|
|
16734
17083
|
});
|
|
16735
17084
|
import { createHash as createHash9 } from "node:crypto";
|
|
16736
17085
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
16737
|
-
import { join as
|
|
17086
|
+
import { join as join18, resolve as resolve14 } from "node:path";
|
|
16738
17087
|
async function readTarget(ctx, flags) {
|
|
16739
17088
|
const accounts = stringFlag(flags.accounts);
|
|
16740
17089
|
const campaign = stringFlag(flags.campaign);
|
|
@@ -16785,7 +17134,7 @@ async function refuseRefill(ctx, args, target2) {
|
|
|
16785
17134
|
code: "already_filled",
|
|
16786
17135
|
exitCode: ExitCode.Conflict,
|
|
16787
17136
|
message: unfinished ? `Run ${earlier.runId} is already filling these ${ids2} (${earlier.status}).` : `Run ${earlier.runId} already filled these ${ids2}.`,
|
|
16788
|
-
hint: unfinished ? "Continue that run instead: a new fill would create every fill run again." : succeeded ? "Every page was filled. Filling again rebuilds and charges every page that is not building or live; to do that anyway, use kenso asset-runs create." : `Filling again rebuilds and charges every page that is not building or live. To retry only the failed ones, put the ${target2.key} values of the failed rows in ${
|
|
17137
|
+
hint: unfinished ? "Continue that run instead: a new fill would create every fill run again." : succeeded ? "Every page was filled. Filling again rebuilds and charges every page that is not building or live; to do that anyway, use kenso asset-runs create." : `Filling again rebuilds and charges every page that is not building or live. To retry only the failed ones, put the ${target2.key} values of the failed rows in ${join18(earlier.dir, "results.csv")} in a file and fill that file.`,
|
|
16789
17138
|
next: unfinished ? `kenso runs resume ${earlier.runId}` : `kenso runs show ${earlier.runId}`
|
|
16790
17139
|
});
|
|
16791
17140
|
}
|
|
@@ -16815,14 +17164,14 @@ async function fillChunk(ctx, templateId, target2, wait3, chunk, chunkCtx) {
|
|
|
16815
17164
|
}
|
|
16816
17165
|
return { results: runResults(chunk, run, target2.key) };
|
|
16817
17166
|
}
|
|
16818
|
-
function estimateOutput(templateId, target2,
|
|
17167
|
+
function estimateOutput(templateId, target2, estimate) {
|
|
16819
17168
|
return {
|
|
16820
17169
|
templateId,
|
|
16821
17170
|
...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
|
|
16822
17171
|
[target2.flag]: target2.items.length,
|
|
16823
17172
|
...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
|
|
16824
17173
|
runs: Math.ceil(target2.items.length / RUN_SIZE),
|
|
16825
|
-
estimate
|
|
17174
|
+
estimate,
|
|
16826
17175
|
...target2.campaignId !== void 0 ? { estimateNote: "An upper bound: it counts one page per lead, and a campaign run builds one page per company." } : {}
|
|
16827
17176
|
};
|
|
16828
17177
|
}
|
|
@@ -16847,6 +17196,7 @@ var init_fill = __esm({
|
|
|
16847
17196
|
action: "fill",
|
|
16848
17197
|
summary: "Fill a template on many accounts or campaign leads (estimate first)",
|
|
16849
17198
|
brief: "estimate first",
|
|
17199
|
+
effect: "spend",
|
|
16850
17200
|
description: "Reads ids one per line, or a CSV/JSONL with an id column (--column, else id, else contactId), from --accounts, or from --contacts with --campaign for a campaign's leads. It always asks for the cost first (asset-runs.estimate) and prints it; --yes then creates one fill run per 500 ids, one after another, and --wait follows each run (every 5 s) until it completes, fails or is cancelled. The summary lists the run ids and their states. A fill charges for every page it builds, so the same ids are not filled twice: an unfinished fill continues, and a finished one is refused (exit 7) with how to retry only the failed ids.",
|
|
16851
17201
|
flags: {
|
|
16852
17202
|
accounts: { type: "string", description: "Account ids: a file, or - for stdin" },
|
|
@@ -16873,10 +17223,10 @@ var init_fill = __esm({
|
|
|
16873
17223
|
const target2 = await readTarget(ctx, flags);
|
|
16874
17224
|
const batchArgs = { ...flags, positionals };
|
|
16875
17225
|
if (ctx.flags.yes === true) await refuseRefill(ctx, batchArgs, target2);
|
|
16876
|
-
const
|
|
17226
|
+
const estimate = await estimateFill(ctx, templateId, target2.items.length);
|
|
16877
17227
|
if (ctx.flags.yes !== true) {
|
|
16878
17228
|
const next = commandLine2(ctx, COMMAND6, { flags: { ...flags, estimate: void 0 }, positionals }, ["--yes"]);
|
|
16879
|
-
ctx.output.object({ ...estimateOutput(templateId, target2,
|
|
17229
|
+
ctx.output.object({ ...estimateOutput(templateId, target2, estimate), next });
|
|
16880
17230
|
return ExitCode.Ok;
|
|
16881
17231
|
}
|
|
16882
17232
|
const wait3 = flags.wait === true;
|
|
@@ -16894,7 +17244,7 @@ var init_fill = __esm({
|
|
|
16894
17244
|
templateId,
|
|
16895
17245
|
...target2.campaignId !== void 0 ? { campaignId: target2.campaignId } : {},
|
|
16896
17246
|
...target2.duplicates > 0 ? { duplicates: target2.duplicates } : {},
|
|
16897
|
-
estimatedMillicredits:
|
|
17247
|
+
estimatedMillicredits: estimate.millicredits,
|
|
16898
17248
|
runs: runsOf(results)
|
|
16899
17249
|
})
|
|
16900
17250
|
},
|
|
@@ -16908,11 +17258,11 @@ var init_fill = __esm({
|
|
|
16908
17258
|
});
|
|
16909
17259
|
|
|
16910
17260
|
// src/commands/studio/index.ts
|
|
16911
|
-
var
|
|
17261
|
+
var actions30;
|
|
16912
17262
|
var init_studio2 = __esm({
|
|
16913
17263
|
"src/commands/studio/index.ts"() {
|
|
16914
17264
|
"use strict";
|
|
16915
|
-
|
|
17265
|
+
actions30 = {
|
|
16916
17266
|
pull: () => Promise.resolve().then(() => (init_pull(), pull_exports)).then((m) => m.default),
|
|
16917
17267
|
push: () => Promise.resolve().then(() => (init_push(), push_exports)).then((m) => m.default),
|
|
16918
17268
|
validate: () => Promise.resolve().then(() => (init_validate(), validate_exports)).then((m) => m.default),
|
|
@@ -17024,6 +17374,7 @@ var init_add2 = __esm({
|
|
|
17024
17374
|
resource: "tasks",
|
|
17025
17375
|
action: "add",
|
|
17026
17376
|
summary: "Add a task: a title, an optional due day and time, assignee and the account, person or deal it is about",
|
|
17377
|
+
effect: "write",
|
|
17027
17378
|
description: "Sends POST /v1/tasks and prints the task. The words after add are the title (1-500 characters). --due takes today, tomorrow, a weekday (the next one: friday or fri), a day (2026-11-20) or an ISO 8601 time with its offset; --at HH:MM puts a time on that day (today without --due). Day words and --at read this computer's clock and time zone (TZ); a time's day is read in the assignee's app time zone. --assignee takes me, a member id or an email; without it the task is yours. Link at most one of --account, --person, --deal: a person's task also shows on their first account, a deal's on its account and primary person. Linking an account on a plan without Accounts is plan_required. --dry-run prints the POST and writes nothing.",
|
|
17028
17379
|
flags: {
|
|
17029
17380
|
due: { type: "string", description: "Due day: today, tomorrow, a weekday, YYYY-MM-DD, or an ISO 8601 time with an offset" },
|
|
@@ -17107,6 +17458,7 @@ var init_done = __esm({
|
|
|
17107
17458
|
resource: "tasks",
|
|
17108
17459
|
action: "done",
|
|
17109
17460
|
summary: "Complete one or more tasks (--undo reopens them)",
|
|
17461
|
+
effect: "write",
|
|
17110
17462
|
description: "Sends PATCH /v1/tasks/{taskId} with status done for each id, in order, and prints the task (one line per task for several): completedAt and completedByMemberId set, and task.completed written on the record's timeline. --undo sends status open, which reopens it and writes task.reopened. A task on an account is plan_required on a plan without Accounts. An error stops at that id; its message names the ids before it, which are done. --dry-run prints the PATCH for each id and changes nothing.",
|
|
17111
17463
|
flags: { undo: { type: "boolean", description: "Reopen the task instead" } },
|
|
17112
17464
|
positionals: [{ name: "taskId", required: true, variadic: true, description: "One or more task ids" }],
|
|
@@ -17158,6 +17510,7 @@ var init_assign = __esm({
|
|
|
17158
17510
|
resource: "tasks",
|
|
17159
17511
|
action: "assign",
|
|
17160
17512
|
summary: "Give a task to a member",
|
|
17513
|
+
effect: "write",
|
|
17161
17514
|
description: "Sends PATCH /v1/tasks/{taskId} with assigneeMemberId and prints the task. The member is me, a member id or a member's email. They get a task_assigned notification unless they assigned it themselves. A member id outside the workspace is invalid_member. A task on an account is plan_required on a plan without Accounts. --dry-run prints the PATCH and changes nothing.",
|
|
17162
17515
|
flags: {},
|
|
17163
17516
|
positionals: [
|
|
@@ -17197,6 +17550,7 @@ var init_queue = __esm({
|
|
|
17197
17550
|
resource: "tasks",
|
|
17198
17551
|
action: "queue",
|
|
17199
17552
|
summary: "Your open work by due day: tasks, touches, call tasks, reply reminders and Ken follow-ups",
|
|
17553
|
+
effect: "read",
|
|
17200
17554
|
description: "Reads every page of GET /v1/task-queue, the rows of the app's Tasks screen and of kenso task-queue list, by due day, due time, then id. Each row has kind (task, touch, call_task, reply_reminder or ken_follow_up), id, title, dueDate, dueAt, dueBucket, overdue, record and href, the app path where it is worked (a task opens in its panel). --scope mine (default), assigned_by_me (tasks only) or everyone.",
|
|
17201
17555
|
flags: {
|
|
17202
17556
|
scope: { type: "string", description: "mine (default), assigned_by_me or everyone" },
|
|
@@ -17219,11 +17573,11 @@ var init_queue = __esm({
|
|
|
17219
17573
|
});
|
|
17220
17574
|
|
|
17221
17575
|
// src/commands/tasks/index.ts
|
|
17222
|
-
var
|
|
17576
|
+
var actions31;
|
|
17223
17577
|
var init_tasks = __esm({
|
|
17224
17578
|
"src/commands/tasks/index.ts"() {
|
|
17225
17579
|
"use strict";
|
|
17226
|
-
|
|
17580
|
+
actions31 = {
|
|
17227
17581
|
add: () => Promise.resolve().then(() => (init_add2(), add_exports2)).then((m) => m.default),
|
|
17228
17582
|
done: () => Promise.resolve().then(() => (init_done(), done_exports)).then((m) => m.default),
|
|
17229
17583
|
assign: () => Promise.resolve().then(() => (init_assign(), assign_exports)).then((m) => m.default),
|
|
@@ -17264,6 +17618,7 @@ var init_pin = __esm({
|
|
|
17264
17618
|
resource: "views",
|
|
17265
17619
|
action: "pin",
|
|
17266
17620
|
summary: "Pin a saved view to your sidebar",
|
|
17621
|
+
effect: "write",
|
|
17267
17622
|
description: "Sends POST /v1/pins with kind view and the view's id, and prints the pin. The view nests under its list's row in your sidebar (an account view under Accounts). Pins are your own: a teammate pins a shared view for themselves. A view already pinned answers its pin. Pinning a person or deal view pins People or Deals too. Same as kenso pins add --kind view --view-id <viewId>; kenso views unpin <viewId> undoes it. --dry-run prints the POST and pins nothing.",
|
|
17268
17623
|
flags: {},
|
|
17269
17624
|
positionals: [{ name: "viewId", required: true, description: "The saved view's id (kenso views list)" }],
|
|
@@ -17283,6 +17638,7 @@ var init_pin = __esm({
|
|
|
17283
17638
|
resource: "views",
|
|
17284
17639
|
action: "unpin",
|
|
17285
17640
|
summary: "Unpin a saved view from your sidebar",
|
|
17641
|
+
effect: "destructive",
|
|
17286
17642
|
description: "Finds your pin of the view (GET /v1/pins) and sends DELETE /v1/pins/{pinId}. Prints the view id and whether a pin was removed: a view you had not pinned prints removed false and changes nothing. The view itself stays. Same as kenso pins remove --pin-id <pinId>. --dry-run reads your pins and prints the DELETE (or removed false), removing nothing.",
|
|
17287
17643
|
flags: {},
|
|
17288
17644
|
positionals: [{ name: "viewId", required: true, description: "The saved view's id (kenso views list)" }],
|
|
@@ -17307,11 +17663,11 @@ var init_pin = __esm({
|
|
|
17307
17663
|
});
|
|
17308
17664
|
|
|
17309
17665
|
// src/commands/views/index.ts
|
|
17310
|
-
var
|
|
17666
|
+
var actions32;
|
|
17311
17667
|
var init_views = __esm({
|
|
17312
17668
|
"src/commands/views/index.ts"() {
|
|
17313
17669
|
"use strict";
|
|
17314
|
-
|
|
17670
|
+
actions32 = {
|
|
17315
17671
|
pin: () => Promise.resolve().then(() => (init_pin(), pin_exports)).then((m) => m.pin),
|
|
17316
17672
|
unpin: () => Promise.resolve().then(() => (init_pin(), pin_exports)).then((m) => m.unpin)
|
|
17317
17673
|
};
|
|
@@ -17320,25 +17676,25 @@ var init_views = __esm({
|
|
|
17320
17676
|
|
|
17321
17677
|
// src/commands/webhooks/local.ts
|
|
17322
17678
|
import { createHmac, randomBytes as randomBytes2 } from "node:crypto";
|
|
17323
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
17324
|
-
import { join as
|
|
17679
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync12, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
17680
|
+
import { join as join19 } from "node:path";
|
|
17325
17681
|
function webhooksDir(env) {
|
|
17326
|
-
const
|
|
17327
|
-
mkdirSync4(
|
|
17328
|
-
return
|
|
17682
|
+
const dir3 = join19(configDir(env), "webhooks");
|
|
17683
|
+
mkdirSync4(dir3, { recursive: true, mode: 448 });
|
|
17684
|
+
return dir3;
|
|
17329
17685
|
}
|
|
17330
17686
|
function signingSecretPath(env) {
|
|
17331
|
-
return
|
|
17687
|
+
return join19(webhooksDir(env), "signing-secret");
|
|
17332
17688
|
}
|
|
17333
17689
|
function signingSecret(env) {
|
|
17334
17690
|
const file = signingSecretPath(env);
|
|
17335
17691
|
try {
|
|
17336
|
-
const saved =
|
|
17692
|
+
const saved = readFileSync12(file, "utf8").trim();
|
|
17337
17693
|
if (/^whsec_[A-Za-z0-9+/]{32,}={0,2}$/.test(saved)) return saved;
|
|
17338
17694
|
} catch {
|
|
17339
17695
|
}
|
|
17340
17696
|
const secret = `whsec_${randomBytes2(24).toString("base64")}`;
|
|
17341
|
-
|
|
17697
|
+
writeFileSync5(file, `${secret}
|
|
17342
17698
|
`, { mode: 384 });
|
|
17343
17699
|
return secret;
|
|
17344
17700
|
}
|
|
@@ -17379,15 +17735,15 @@ async function forward(url, event, secret, signal) {
|
|
|
17379
17735
|
}
|
|
17380
17736
|
}
|
|
17381
17737
|
function statePath(env, workspaceId) {
|
|
17382
|
-
return
|
|
17738
|
+
return join19(webhooksDir(env), `listener-${(workspaceId ?? "default").replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
|
|
17383
17739
|
}
|
|
17384
17740
|
function writeListenerState(env, workspaceId, state) {
|
|
17385
|
-
|
|
17741
|
+
writeFileSync5(statePath(env, workspaceId), `${JSON.stringify(state)}
|
|
17386
17742
|
`, { mode: 384 });
|
|
17387
17743
|
}
|
|
17388
17744
|
function readListenerState(env, workspaceId) {
|
|
17389
17745
|
try {
|
|
17390
|
-
const state = JSON.parse(
|
|
17746
|
+
const state = JSON.parse(readFileSync12(statePath(env, workspaceId), "utf8"));
|
|
17391
17747
|
return typeof state.url === "string" && typeof state.token === "string" ? state : void 0;
|
|
17392
17748
|
} catch {
|
|
17393
17749
|
return void 0;
|
|
@@ -17466,6 +17822,7 @@ var init_listen = __esm({
|
|
|
17466
17822
|
action: "listen",
|
|
17467
17823
|
summary: "Stream the workspace's events and forward them, signed, to a local handler",
|
|
17468
17824
|
brief: "--forward-to",
|
|
17825
|
+
effect: "read",
|
|
17469
17826
|
description: "Polls GET /v1/event-occurrences and prints each event as one JSON line. With --forward-to it also POSTs each event to your handler with the svix-id, svix-timestamp and svix-signature headers a Kenso delivery carries, signed with a local whsec_ secret the documented verifier accepts. The secret is printed at start and stays the same on every run. A live event's body is sparse: the delivery's eventType, eventId, timestamp and clientId, and only the ids, statuses and links the event log keeps, at their delivery paths (no names, emails or reply text). kenso webhooks trigger <event-type> sends a full sample body through the running listener. No webhook endpoint, subscription or tunnel is created.",
|
|
17470
17827
|
flags: {
|
|
17471
17828
|
"forward-to": { type: "string", description: "Your handler's URL, for example http://localhost:3000/hook (http:// is assumed)" },
|
|
@@ -17599,6 +17956,7 @@ var init_trigger = __esm({
|
|
|
17599
17956
|
resource: "webhooks",
|
|
17600
17957
|
action: "trigger",
|
|
17601
17958
|
summary: "Send a sample event of one type through the running kenso webhooks listen",
|
|
17959
|
+
effect: "read",
|
|
17602
17960
|
description: "Takes the event type's sample body from GET /v1/webhook-event-types, gives it a new eventId and the current timestamp, and hands it to the kenso webhooks listen running for this workspace, which prints it and forwards it, signed, like a live event. Nothing is sent to anyone else. Exit 1 when the handler did not answer 2xx.",
|
|
17603
17961
|
flags: {},
|
|
17604
17962
|
positionals: [{ name: "event-type", required: true, description: "An event type, for example reply.received (kenso webhook-event-types list)" }],
|
|
@@ -17657,11 +18015,11 @@ var init_trigger = __esm({
|
|
|
17657
18015
|
});
|
|
17658
18016
|
|
|
17659
18017
|
// src/commands/webhooks/index.ts
|
|
17660
|
-
var
|
|
18018
|
+
var actions33;
|
|
17661
18019
|
var init_webhooks2 = __esm({
|
|
17662
18020
|
"src/commands/webhooks/index.ts"() {
|
|
17663
18021
|
"use strict";
|
|
17664
|
-
|
|
18022
|
+
actions33 = {
|
|
17665
18023
|
listen: () => Promise.resolve().then(() => (init_listen(), listen_exports)).then((m) => m.default),
|
|
17666
18024
|
trigger: () => Promise.resolve().then(() => (init_trigger(), trigger_exports)).then((m) => m.default)
|
|
17667
18025
|
};
|
|
@@ -17685,6 +18043,7 @@ var init_status3 = __esm({
|
|
|
17685
18043
|
action: "status",
|
|
17686
18044
|
summary: "Show the Kenso AI work waiting for your own agent, per kind",
|
|
17687
18045
|
brief: "what waits for your agent",
|
|
18046
|
+
effect: "read",
|
|
17688
18047
|
description: "Calls GET /v1/agent-work and prints one row per kind: executor (kenso_ai, or my_agent when the workspace gave the kind to its agent in Settings), waiting (items your agent can claim now), claimed (items held by open claims), heldBy (billing_blocked, out_of_credits or ai_paused when Kenso holds the kind back) and lastAcceptedAt. --live-only counts only the campaigns Kenso's AI works on by itself, as kenso work run --live-only takes them. A table on a terminal, NDJSON when piped, a JSON array with -o json.",
|
|
17689
18048
|
flags: { campaign: CAMPAIGN_FLAG, "live-only": LIVE_ONLY_FLAG },
|
|
17690
18049
|
examples: ["kenso work status", "kenso work status --live-only", "kenso work status --campaign 812 -o json"],
|
|
@@ -17719,8 +18078,8 @@ var init_status3 = __esm({
|
|
|
17719
18078
|
});
|
|
17720
18079
|
|
|
17721
18080
|
// src/work/files.ts
|
|
17722
|
-
import { closeSync as closeSync2, constants, fchmodSync, fstatSync, lstatSync, openSync as openSync2, readFileSync as
|
|
17723
|
-
import { join as
|
|
18081
|
+
import { closeSync as closeSync2, constants, fchmodSync, fstatSync, lstatSync, openSync as openSync2, readFileSync as readFileSync13, writeFileSync as writeFileSync6 } from "node:fs";
|
|
18082
|
+
import { join as join20 } from "node:path";
|
|
17724
18083
|
function agentName(value) {
|
|
17725
18084
|
if (typeof value !== "string") return void 0;
|
|
17726
18085
|
const name = value.trim().slice(0, MAX_AGENT_NAME);
|
|
@@ -17736,13 +18095,13 @@ function workFileName(claimId) {
|
|
|
17736
18095
|
if (!isPlainFileName(claimId)) throw new Error("claimId is not a plain file name");
|
|
17737
18096
|
return `${claimId}.work.json`;
|
|
17738
18097
|
}
|
|
17739
|
-
function writeWorkFile(
|
|
18098
|
+
function writeWorkFile(dir3, work, mode = 384) {
|
|
17740
18099
|
const name = workFileName(work.claimId);
|
|
17741
18100
|
if (!isPlainFileName(work.answersFile)) throw new Error("answersFile is not a plain file name");
|
|
17742
|
-
const path =
|
|
18101
|
+
const path = join20(dir3, name);
|
|
17743
18102
|
const fd = openSync2(path, "wx", mode);
|
|
17744
18103
|
try {
|
|
17745
|
-
|
|
18104
|
+
writeFileSync6(fd, JSON.stringify(work, null, 2) + "\n", "utf8");
|
|
17746
18105
|
fchmodSync(fd, mode);
|
|
17747
18106
|
} finally {
|
|
17748
18107
|
closeSync2(fd);
|
|
@@ -17757,7 +18116,7 @@ function readRegularFile(path, what) {
|
|
|
17757
18116
|
const stat4 = fstatSync(fd);
|
|
17758
18117
|
if (!stat4.isFile()) return notPlain;
|
|
17759
18118
|
if (stat4.size > MAX_ANSWERS_FILE_BYTES) return { ok: false, error: `the ${what} is too large` };
|
|
17760
|
-
return
|
|
18119
|
+
return readFileSync13(fd, "utf8");
|
|
17761
18120
|
} finally {
|
|
17762
18121
|
closeSync2(fd);
|
|
17763
18122
|
}
|
|
@@ -17844,7 +18203,7 @@ var init_files = __esm({
|
|
|
17844
18203
|
|
|
17845
18204
|
// src/work/agent-user.ts
|
|
17846
18205
|
import { execFile, spawnSync as spawnSync2 } from "node:child_process";
|
|
17847
|
-
import { readFileSync as
|
|
18206
|
+
import { readFileSync as readFileSync14 } from "node:fs";
|
|
17848
18207
|
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
17849
18208
|
function sudoArgs(user, command70, args, keep = [], set2 = {}) {
|
|
17850
18209
|
const assignments = Object.entries(set2).map(([name, value]) => `${name}=${value}`);
|
|
@@ -17901,7 +18260,7 @@ function ids(status, field) {
|
|
|
17901
18260
|
}
|
|
17902
18261
|
function sudoGids(groupFile) {
|
|
17903
18262
|
const gids = /* @__PURE__ */ new Set([0]);
|
|
17904
|
-
for (const line of
|
|
18263
|
+
for (const line of readFileSync14(groupFile, "utf8").split("\n")) {
|
|
17905
18264
|
const [group, , gid] = line.split(":");
|
|
17906
18265
|
if (group !== void 0 && SUDO_GROUPS.has(group) && /^\d+$/.test(gid ?? "")) gids.add(Number(gid));
|
|
17907
18266
|
}
|
|
@@ -17963,7 +18322,7 @@ var init_agent_user = __esm({
|
|
|
17963
18322
|
// src/commands/work/folder.ts
|
|
17964
18323
|
import { existsSync as existsSync9 } from "node:fs";
|
|
17965
18324
|
import { appendFile as appendFile3, symlink as symlink2, unlink as unlink3 } from "node:fs/promises";
|
|
17966
|
-
import { dirname as dirname3, join as
|
|
18325
|
+
import { dirname as dirname3, join as join21, resolve as resolve15 } from "node:path";
|
|
17967
18326
|
var WorkRunFolder;
|
|
17968
18327
|
var init_folder2 = __esm({
|
|
17969
18328
|
"src/commands/work/folder.ts"() {
|
|
@@ -18003,32 +18362,32 @@ var init_folder2 = __esm({
|
|
|
18003
18362
|
async make() {
|
|
18004
18363
|
const root2 = runsRoot(this.ctx.env);
|
|
18005
18364
|
const makeDir = (path) => this.shared ? ensureDir(path, SHARED_DIR_MODE) : ensurePrivateDir2(path);
|
|
18006
|
-
let
|
|
18365
|
+
let dir3;
|
|
18007
18366
|
if (this.outDir === void 0) {
|
|
18008
|
-
|
|
18367
|
+
dir3 = join21(root2, this.runId);
|
|
18009
18368
|
if (!this.shared) ensurePrivateDir2(root2);
|
|
18010
|
-
makeDir(
|
|
18369
|
+
makeDir(dir3);
|
|
18011
18370
|
} else {
|
|
18012
|
-
|
|
18013
|
-
const existing = existsSync9(
|
|
18371
|
+
dir3 = resolve15(this.outDir);
|
|
18372
|
+
const existing = existsSync9(join21(dir3, "run.json")) ? await readRunDir(dir3) : null;
|
|
18014
18373
|
if (existing && !existing.command.startsWith("work ")) {
|
|
18015
|
-
throw usageError(`${
|
|
18374
|
+
throw usageError(`${dir3} already holds run ${existing.runId} (${existing.command}).`, {
|
|
18016
18375
|
field: "out",
|
|
18017
18376
|
hint: "Pick another --out directory, or leave --out off to keep the work under the runs directory."
|
|
18018
18377
|
});
|
|
18019
18378
|
}
|
|
18020
|
-
makeDir(
|
|
18021
|
-
for (const name of ["results.ndjson", "summary.json"]) await unlink3(
|
|
18379
|
+
makeDir(dir3);
|
|
18380
|
+
for (const name of ["results.ndjson", "summary.json"]) await unlink3(join21(dir3, name)).catch(() => void 0);
|
|
18022
18381
|
try {
|
|
18023
18382
|
if (!this.shared) ensurePrivateDir2(root2);
|
|
18024
|
-
await symlink2(
|
|
18383
|
+
await symlink2(dir3, join21(root2, this.runId), "junction");
|
|
18025
18384
|
} catch (err) {
|
|
18026
|
-
this.ctx.output.warn(`Could not link ${
|
|
18385
|
+
this.ctx.output.warn(`Could not link ${dir3} into ${root2} (${err.message}): kenso runs will not list this run.`);
|
|
18027
18386
|
}
|
|
18028
18387
|
}
|
|
18029
|
-
this.dir =
|
|
18388
|
+
this.dir = dir3;
|
|
18030
18389
|
if (this.shared) {
|
|
18031
|
-
this.tmpDir =
|
|
18390
|
+
this.tmpDir = join21(dir3, "tmp");
|
|
18032
18391
|
ensureDir(this.tmpDir, JOB_DIR_MODE);
|
|
18033
18392
|
}
|
|
18034
18393
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -18041,28 +18400,28 @@ var init_folder2 = __esm({
|
|
|
18041
18400
|
status: "running",
|
|
18042
18401
|
chunkCount: 0,
|
|
18043
18402
|
chunksDone: [],
|
|
18044
|
-
dir:
|
|
18403
|
+
dir: dir3,
|
|
18045
18404
|
rows: 0,
|
|
18046
18405
|
cwd: process.cwd(),
|
|
18047
18406
|
pid: process.pid,
|
|
18048
18407
|
updatedAt: now
|
|
18049
18408
|
};
|
|
18050
18409
|
await writeRunRecord(this.record);
|
|
18051
|
-
return
|
|
18410
|
+
return dir3;
|
|
18052
18411
|
}
|
|
18053
18412
|
/**
|
|
18054
18413
|
* A job's folder, jobs/<claimId> (a plain file name): private, or with --agent-user one the agent user's group
|
|
18055
18414
|
* writes (3770) under a jobs folder it can only pass through (2750).
|
|
18056
18415
|
*/
|
|
18057
18416
|
async jobDir(claimId) {
|
|
18058
|
-
const
|
|
18417
|
+
const dir3 = join21(await this.ensure(), "jobs", claimId);
|
|
18059
18418
|
if (this.shared) {
|
|
18060
|
-
ensureDir(dirname3(
|
|
18061
|
-
ensureDir(
|
|
18419
|
+
ensureDir(dirname3(dir3), SHARED_DIR_MODE);
|
|
18420
|
+
ensureDir(dir3, JOB_DIR_MODE);
|
|
18062
18421
|
} else {
|
|
18063
|
-
ensurePrivateDir2(
|
|
18422
|
+
ensurePrivateDir2(dir3);
|
|
18064
18423
|
}
|
|
18065
|
-
return
|
|
18424
|
+
return dir3;
|
|
18066
18425
|
}
|
|
18067
18426
|
/**
|
|
18068
18427
|
* One line of results.ndjson, each string redacted: a failed job's detail is the agent's own stderr, which can hold
|
|
@@ -18071,13 +18430,13 @@ var init_folder2 = __esm({
|
|
|
18071
18430
|
async append(line) {
|
|
18072
18431
|
if (!this.dir) return;
|
|
18073
18432
|
const json = JSON.stringify(line, (_key, value) => typeof value === "string" ? redact(value) : value);
|
|
18074
|
-
await appendFile3(
|
|
18433
|
+
await appendFile3(join21(this.dir, "results.ndjson"), `${json}
|
|
18075
18434
|
`, { mode: 384 });
|
|
18076
18435
|
}
|
|
18077
18436
|
/** summary.json, and run.json with the final status, the claims (chunkCount) and the items (rows). */
|
|
18078
18437
|
async finish(status, claims, items, summary) {
|
|
18079
18438
|
if (!this.dir || !this.record) return;
|
|
18080
|
-
await writeJsonAtomic(
|
|
18439
|
+
await writeJsonAtomic(join21(this.dir, "summary.json"), summary);
|
|
18081
18440
|
this.record = { ...this.record, status, chunkCount: claims, rows: items, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
18082
18441
|
await writeRunRecord(this.record);
|
|
18083
18442
|
}
|
|
@@ -18104,6 +18463,7 @@ var init_pull2 = __esm({
|
|
|
18104
18463
|
action: "pull",
|
|
18105
18464
|
summary: "Claim waiting work into local work files, to answer by hand",
|
|
18106
18465
|
brief: "claims work into files",
|
|
18466
|
+
effect: "write",
|
|
18107
18467
|
description: "Makes one claim per file (POST /v1/agent-work/claims, --per-file items each) up to --files claims, and writes <claimId>.work.json for each into --out or a new folder under the runs directory. Stops early when a claim comes back empty. Prints the folder and, per file, its claim, kind, item count and expiry; never the items' text. Answer each file into <claimId>.answers.json next to it (its rules say how), then send them with kenso work submit. Unanswered items go back to the queue when the claim expires, or at once with kenso work release.",
|
|
18108
18468
|
flags: {
|
|
18109
18469
|
kind: KIND_FLAG,
|
|
@@ -18184,7 +18544,7 @@ var init_pull2 = __esm({
|
|
|
18184
18544
|
// src/commands/work/answers.ts
|
|
18185
18545
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
18186
18546
|
import { existsSync as existsSync10 } from "node:fs";
|
|
18187
|
-
import { basename as basename5, dirname as dirname4, join as
|
|
18547
|
+
import { basename as basename5, dirname as dirname4, join as join22 } from "node:path";
|
|
18188
18548
|
function zeroTotals() {
|
|
18189
18549
|
return { accepted: 0, rejected: 0, expired: 0, duplicate: 0, dropped: 0 };
|
|
18190
18550
|
}
|
|
@@ -18256,7 +18616,7 @@ function droppedResult(d) {
|
|
|
18256
18616
|
return { itemId: d.itemId ?? null, status: "dropped", reason: d.reason, message: `Answer ${d.index + 1} of the file was not sent: ${d.reason.replace(/_/g, " ")}.` };
|
|
18257
18617
|
}
|
|
18258
18618
|
async function writeResults(answersPath, claimId, results, totals) {
|
|
18259
|
-
const path =
|
|
18619
|
+
const path = join22(dirname4(answersPath), `${claimId}.results.json`);
|
|
18260
18620
|
await writeJsonAtomic(path, { version: 1, claimId, submittedAt: (/* @__PURE__ */ new Date()).toISOString(), ...totals, results });
|
|
18261
18621
|
return path;
|
|
18262
18622
|
}
|
|
@@ -18285,7 +18645,7 @@ function workFileNextTo(answersPath) {
|
|
|
18285
18645
|
hint: "Write the answers to <claimId>.answers.json next to its <claimId>.work.json, as the work file's rules say."
|
|
18286
18646
|
});
|
|
18287
18647
|
}
|
|
18288
|
-
const workPath =
|
|
18648
|
+
const workPath = join22(dirname4(answersPath), `${claimId}.work.json`);
|
|
18289
18649
|
if (!existsSync10(workPath)) {
|
|
18290
18650
|
throw usageError(`${workPath} is missing: kenso work submit reads it next to the answers file.`, { field: "answers-file" });
|
|
18291
18651
|
}
|
|
@@ -18333,6 +18693,7 @@ var init_submit = __esm({
|
|
|
18333
18693
|
action: "submit",
|
|
18334
18694
|
summary: "Send answers files to Kenso and write each one's results",
|
|
18335
18695
|
brief: "sends answers files",
|
|
18696
|
+
effect: "write",
|
|
18336
18697
|
description: "Reads each <claimId>.answers.json against its <claimId>.work.json (next to it), sends its answers to POST /v1/agent-work/claims/{claimId}/answers, at most 50 per call, with the agent's cli and model from the file, and writes <claimId>.results.json next to it with one result per item. Every file is checked before anything is sent. Prints one JSON line with the counts: accepted, rejected, expired, duplicate and dropped (answers the file could not use). Exit 5 when an answer was rejected; expired and duplicate answers do not fail the command.",
|
|
18337
18698
|
flags: {},
|
|
18338
18699
|
positionals: [{ name: "answers-file", required: true, variadic: true, description: "One or more <claimId>.answers.json files" }],
|
|
@@ -18395,6 +18756,7 @@ var init_release = __esm({
|
|
|
18395
18756
|
action: "release",
|
|
18396
18757
|
summary: "Give claimed work back to the queue now",
|
|
18397
18758
|
brief: "gives claims back",
|
|
18759
|
+
effect: "write",
|
|
18398
18760
|
description: "Calls DELETE /v1/agent-work/claims/{claimId} for each claim id or <claimId>.work.json given. Its unanswered items go back to the queue at once instead of when the claim expires; answers already accepted stay. A claim already closed releases 0 items.",
|
|
18399
18761
|
flags: {},
|
|
18400
18762
|
positionals: [{ name: "claim", required: true, variadic: true, description: "Claim ids (awc_...) or <claimId>.work.json files" }],
|
|
@@ -18417,7 +18779,7 @@ var init_release = __esm({
|
|
|
18417
18779
|
import { spawn as nodeSpawn3 } from "node:child_process";
|
|
18418
18780
|
import { rmSync as rmSync3, statSync as statSync3 } from "node:fs";
|
|
18419
18781
|
import { access, constants as constants2 } from "node:fs/promises";
|
|
18420
|
-
import { delimiter as delimiter2, join as
|
|
18782
|
+
import { delimiter as delimiter2, join as join23 } from "node:path";
|
|
18421
18783
|
import { setTimeout as delay12 } from "node:timers/promises";
|
|
18422
18784
|
function childEnv(parent, adapter, extra) {
|
|
18423
18785
|
const scrub = new Set(adapter.scrubEnv.map((name) => name.toUpperCase()));
|
|
@@ -18442,7 +18804,7 @@ async function isExecutableFile(path) {
|
|
|
18442
18804
|
function pathDirs(env) {
|
|
18443
18805
|
const key = Object.keys(env).find((name) => name.toUpperCase() === "PATH");
|
|
18444
18806
|
const value = key ? env[key] : void 0;
|
|
18445
|
-
return (value ?? "").split(delimiter2).filter((
|
|
18807
|
+
return (value ?? "").split(delimiter2).filter((dir3) => dir3 !== "");
|
|
18446
18808
|
}
|
|
18447
18809
|
async function resolveBinary(adapter, env, override2) {
|
|
18448
18810
|
const names = override2 !== void 0 && override2 !== "" ? [override2] : adapter.binaries;
|
|
@@ -18452,9 +18814,9 @@ async function resolveBinary(adapter, env, override2) {
|
|
|
18452
18814
|
if (await isExecutableFile(name)) return name;
|
|
18453
18815
|
continue;
|
|
18454
18816
|
}
|
|
18455
|
-
for (const
|
|
18817
|
+
for (const dir3 of pathDirs(env)) {
|
|
18456
18818
|
for (const ext of extensions) {
|
|
18457
|
-
const candidate =
|
|
18819
|
+
const candidate = join23(dir3, name + ext);
|
|
18458
18820
|
if (await isExecutableFile(candidate)) return candidate;
|
|
18459
18821
|
}
|
|
18460
18822
|
}
|
|
@@ -18620,11 +18982,11 @@ async function runAgentJob(adapter, job, deps) {
|
|
|
18620
18982
|
}
|
|
18621
18983
|
let work;
|
|
18622
18984
|
try {
|
|
18623
|
-
work = readWorkFile(
|
|
18985
|
+
work = readWorkFile(join23(job.cwd, job.workFile));
|
|
18624
18986
|
} catch (err) {
|
|
18625
18987
|
return result("fatal", null, `the work file could not be read: ${err.message}`);
|
|
18626
18988
|
}
|
|
18627
|
-
const answersPath =
|
|
18989
|
+
const answersPath = join23(job.cwd, job.answersFile);
|
|
18628
18990
|
try {
|
|
18629
18991
|
rmSync3(answersPath, { force: true });
|
|
18630
18992
|
} catch (err) {
|
|
@@ -19034,7 +19396,7 @@ ${out.stderr}`;
|
|
|
19034
19396
|
});
|
|
19035
19397
|
|
|
19036
19398
|
// src/work/adapters/opencode.ts
|
|
19037
|
-
import { basename as basename6, join as
|
|
19399
|
+
import { basename as basename6, join as join24 } from "node:path";
|
|
19038
19400
|
var opencode;
|
|
19039
19401
|
var init_opencode = __esm({
|
|
19040
19402
|
"src/work/adapters/opencode.ts"() {
|
|
@@ -19078,7 +19440,7 @@ ${out.stderr}`);
|
|
|
19078
19440
|
if (job.model) args.push("--model", job.model);
|
|
19079
19441
|
args.push(job.instruction);
|
|
19080
19442
|
const env = { OPENCODE_CONFIG_CONTENT: JSON.stringify(config) };
|
|
19081
|
-
if (job.tmpDir !== void 0) env.OPENCODE_DB =
|
|
19443
|
+
if (job.tmpDir !== void 0) env.OPENCODE_DB = join24(job.tmpDir, `opencode-${basename6(job.cwd)}.db`);
|
|
19082
19444
|
return { args, env };
|
|
19083
19445
|
},
|
|
19084
19446
|
classify: classifyByExit
|
|
@@ -19283,7 +19645,7 @@ var init_scan = __esm({
|
|
|
19283
19645
|
|
|
19284
19646
|
// src/work/credentials.ts
|
|
19285
19647
|
import { createHash as createHash10 } from "node:crypto";
|
|
19286
|
-
import { join as
|
|
19648
|
+
import { join as join25 } from "node:path";
|
|
19287
19649
|
function unreadable(why) {
|
|
19288
19650
|
return new KensoError({
|
|
19289
19651
|
code: "credentials_unreadable",
|
|
@@ -19371,7 +19733,7 @@ var init_credentials = __esm({
|
|
|
19371
19733
|
}
|
|
19372
19734
|
}
|
|
19373
19735
|
async read(rel) {
|
|
19374
|
-
const r = await sudoExec(this.user, CAT, [
|
|
19736
|
+
const r = await sudoExec(this.user, CAT, [join25(this.user.home, rel)], { maxBuffer: MAX_CREDENTIAL_BYTES });
|
|
19375
19737
|
if (r.exitCode !== 0) return /No such file or directory/.test(r.stderr) ? "missing" : "unreadable";
|
|
19376
19738
|
const digest = createHash10("sha256").update(r.stdout).digest("hex");
|
|
19377
19739
|
if (this.seen.get(rel) !== digest) {
|
|
@@ -19385,18 +19747,18 @@ var init_credentials = __esm({
|
|
|
19385
19747
|
});
|
|
19386
19748
|
|
|
19387
19749
|
// src/work/guide.ts
|
|
19388
|
-
import { closeSync as closeSync3, fchmodSync as fchmodSync2, openSync as openSync3, writeFileSync as
|
|
19389
|
-
import { join as
|
|
19750
|
+
import { closeSync as closeSync3, fchmodSync as fchmodSync2, openSync as openSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
19751
|
+
import { join as join26 } from "node:path";
|
|
19390
19752
|
function agentGuide(opts) {
|
|
19391
19753
|
const browser = opts.browser ?? findOperation("browser-runs", "create") !== void 0;
|
|
19392
19754
|
const parts2 = opts.kensoKey ? [JOB, KENSO, ...browser ? [BROWSER] : [], NEVER] : [JOB, NO_KENSO, NEVER];
|
|
19393
19755
|
return parts2.join("\n");
|
|
19394
19756
|
}
|
|
19395
|
-
function writeAgentGuide(
|
|
19757
|
+
function writeAgentGuide(dir3, text4, mode = WORK_FILE_MODE) {
|
|
19396
19758
|
for (const name of GUIDE_FILES) {
|
|
19397
|
-
const fd = openSync3(
|
|
19759
|
+
const fd = openSync3(join26(dir3, name), "wx", mode);
|
|
19398
19760
|
try {
|
|
19399
|
-
|
|
19761
|
+
writeFileSync7(fd, text4, "utf8");
|
|
19400
19762
|
fchmodSync2(fd, mode);
|
|
19401
19763
|
} finally {
|
|
19402
19764
|
closeSync3(fd);
|
|
@@ -19861,6 +20223,7 @@ var init_run3 = __esm({
|
|
|
19861
20223
|
action: "run",
|
|
19862
20224
|
summary: "Run your own coding agent on the waiting work until the queue is empty",
|
|
19863
20225
|
brief: "runs your agent on the queue",
|
|
20226
|
+
effect: "write",
|
|
19864
20227
|
description: "Claims one work file's worth of items, runs the agent headless on it in a folder that holds only that file, submits the answers the agent wrote, and takes the next, with up to --parallel agents at once. The agent uses its own login and plan, never the Kenso API key. A failed job's claim is released at once; 3 failed jobs in a row stop the run. Stops when the queue is empty (with --watch it checks again every 60 s), at --max-items, when the agent's plan hits its usage limit (exit 6) or its login ends (exit 3), or on Ctrl-C, which stops the agents and releases every open claim. One progress line per job on stderr; one JSON summary on stdout. Only claude is held to the job folder; every other agent needs --allow-unconfined.",
|
|
19865
20228
|
flags: {
|
|
19866
20229
|
agent: { type: "string", required: true, description: `The agent CLI: ${Object.keys(ADAPTERS).join(", ")}` },
|
|
@@ -20024,11 +20387,11 @@ var init_run3 = __esm({
|
|
|
20024
20387
|
}
|
|
20025
20388
|
try {
|
|
20026
20389
|
workFileName(claim.id);
|
|
20027
|
-
const
|
|
20390
|
+
const dir3 = await folder.jobDir(claim.id);
|
|
20028
20391
|
const work = workFileOf(claim);
|
|
20029
|
-
writeWorkFile(
|
|
20030
|
-
if (tools) writeAgentGuide(
|
|
20031
|
-
return { claim, work, dir:
|
|
20392
|
+
writeWorkFile(dir3, work, runAs ? WORK_FILE_MODE : void 0);
|
|
20393
|
+
if (tools) writeAgentGuide(dir3, tools.guide);
|
|
20394
|
+
return { claim, work, dir: dir3 };
|
|
20032
20395
|
} catch (err) {
|
|
20033
20396
|
await releaseOnce(claim.id);
|
|
20034
20397
|
error = err instanceof KensoError ? err : new KensoError({ code: "work_file_failed", message: `Could not write the work file: ${err.message}`, exitCode: ExitCode.Error });
|
|
@@ -20186,11 +20549,11 @@ var init_run3 = __esm({
|
|
|
20186
20549
|
});
|
|
20187
20550
|
|
|
20188
20551
|
// src/commands/work/index.ts
|
|
20189
|
-
var
|
|
20552
|
+
var actions34;
|
|
20190
20553
|
var init_work2 = __esm({
|
|
20191
20554
|
"src/commands/work/index.ts"() {
|
|
20192
20555
|
"use strict";
|
|
20193
|
-
|
|
20556
|
+
actions34 = {
|
|
20194
20557
|
status: () => Promise.resolve().then(() => (init_status3(), status_exports3)).then((m) => m.default),
|
|
20195
20558
|
pull: () => Promise.resolve().then(() => (init_pull2(), pull_exports2)).then((m) => m.default),
|
|
20196
20559
|
submit: () => Promise.resolve().then(() => (init_submit(), submit_exports)).then((m) => m.default),
|
|
@@ -20200,6 +20563,44 @@ var init_work2 = __esm({
|
|
|
20200
20563
|
}
|
|
20201
20564
|
});
|
|
20202
20565
|
|
|
20566
|
+
// src/commands/workflow-runs/index.ts
|
|
20567
|
+
var actions35;
|
|
20568
|
+
var init_workflow_runs = __esm({
|
|
20569
|
+
"src/commands/workflow-runs/index.ts"() {
|
|
20570
|
+
"use strict";
|
|
20571
|
+
actions35 = {};
|
|
20572
|
+
}
|
|
20573
|
+
});
|
|
20574
|
+
|
|
20575
|
+
// src/commands/workflows/file-actions.ts
|
|
20576
|
+
var fileActions;
|
|
20577
|
+
var init_file_actions = __esm({
|
|
20578
|
+
"src/commands/workflows/file-actions.ts"() {
|
|
20579
|
+
"use strict";
|
|
20580
|
+
fileActions = {};
|
|
20581
|
+
}
|
|
20582
|
+
});
|
|
20583
|
+
|
|
20584
|
+
// src/commands/workflows/run-actions.ts
|
|
20585
|
+
var runActions;
|
|
20586
|
+
var init_run_actions = __esm({
|
|
20587
|
+
"src/commands/workflows/run-actions.ts"() {
|
|
20588
|
+
"use strict";
|
|
20589
|
+
runActions = {};
|
|
20590
|
+
}
|
|
20591
|
+
});
|
|
20592
|
+
|
|
20593
|
+
// src/commands/workflows/index.ts
|
|
20594
|
+
var actions36;
|
|
20595
|
+
var init_workflows = __esm({
|
|
20596
|
+
"src/commands/workflows/index.ts"() {
|
|
20597
|
+
"use strict";
|
|
20598
|
+
init_file_actions();
|
|
20599
|
+
init_run_actions();
|
|
20600
|
+
actions36 = { ...fileActions, ...runActions };
|
|
20601
|
+
}
|
|
20602
|
+
});
|
|
20603
|
+
|
|
20203
20604
|
// src/commands/workspace/keys.ts
|
|
20204
20605
|
var keys_exports = {};
|
|
20205
20606
|
__export(keys_exports, {
|
|
@@ -20208,15 +20609,15 @@ __export(keys_exports, {
|
|
|
20208
20609
|
function usage(message, field) {
|
|
20209
20610
|
return new KensoError({ code: "usage_error", message, exitCode: ExitCode.Usage, field });
|
|
20210
20611
|
}
|
|
20211
|
-
function rewrap(err,
|
|
20612
|
+
function rewrap(err, overrides2) {
|
|
20212
20613
|
return new KensoError({
|
|
20213
20614
|
code: err.code,
|
|
20214
|
-
message:
|
|
20615
|
+
message: overrides2.message ?? err.message,
|
|
20215
20616
|
exitCode: err.exitCode,
|
|
20216
20617
|
httpStatus: err.httpStatus,
|
|
20217
20618
|
field: err.field,
|
|
20218
20619
|
hint: err.hint,
|
|
20219
|
-
next:
|
|
20620
|
+
next: overrides2.next ?? err.next,
|
|
20220
20621
|
requestId: err.requestId,
|
|
20221
20622
|
details: err.details
|
|
20222
20623
|
});
|
|
@@ -20236,6 +20637,7 @@ var init_keys = __esm({
|
|
|
20236
20637
|
action: "keys",
|
|
20237
20638
|
summary: "Create an API key the workspace owns",
|
|
20238
20639
|
brief: "create",
|
|
20640
|
+
effect: "write",
|
|
20239
20641
|
description: "Calls POST /v1/workspace-api-keys. The key belongs to the workspace, not to you: it keeps working when you leave and acts with exactly the permissions of the template it is held to (admin, editor or viewer). Workspace admins only. The secret is printed once. No API key may create one (a CLI login key included), so the command reports the API's refusal and the app path (exit 3). In a workspace with workspace keys turned off, the API answers 404 and the command says they are not available (exit 4).",
|
|
20240
20642
|
flags: {
|
|
20241
20643
|
name: { type: "string", required: true, description: "The key's name, 1 to 100 characters" },
|
|
@@ -20321,6 +20723,7 @@ var init_list4 = __esm({
|
|
|
20321
20723
|
resource: "workspace",
|
|
20322
20724
|
action: "list",
|
|
20323
20725
|
summary: "List the workspaces your key can use",
|
|
20726
|
+
effect: "read",
|
|
20324
20727
|
description: "Calls GET /v1/workspaces. Kenso staff are members of many workspaces, so filter by name with --search. Without --all it prints one page and says on stderr when there are more.",
|
|
20325
20728
|
flags: {
|
|
20326
20729
|
search: { type: "string", description: "Only workspaces whose name matches this text", aliases: ["q"] },
|
|
@@ -20366,6 +20769,7 @@ var init_use = __esm({
|
|
|
20366
20769
|
resource: "workspace",
|
|
20367
20770
|
action: "use",
|
|
20368
20771
|
summary: "Set the profile's default workspace",
|
|
20772
|
+
effect: "read",
|
|
20369
20773
|
description: "Checks the workspace with GET /v1/workspaces/{workspaceId}, then saves it to the profile (--profile, KENSO_PROFILE or the active one). --workspace and KENSO_WORKSPACE_ID still win for a single command.",
|
|
20370
20774
|
flags: {},
|
|
20371
20775
|
positionals: [{ name: "workspaceId", required: true, description: "The workspace id (see kenso workspace list)" }],
|
|
@@ -20424,11 +20828,11 @@ var init_use = __esm({
|
|
|
20424
20828
|
});
|
|
20425
20829
|
|
|
20426
20830
|
// src/commands/workspace/index.ts
|
|
20427
|
-
var
|
|
20831
|
+
var actions37;
|
|
20428
20832
|
var init_workspace = __esm({
|
|
20429
20833
|
"src/commands/workspace/index.ts"() {
|
|
20430
20834
|
"use strict";
|
|
20431
|
-
|
|
20835
|
+
actions37 = {
|
|
20432
20836
|
keys: () => Promise.resolve().then(() => (init_keys(), keys_exports)).then((m) => m.default),
|
|
20433
20837
|
list: () => Promise.resolve().then(() => (init_list4(), list_exports4)).then((m) => m.default),
|
|
20434
20838
|
use: () => Promise.resolve().then(() => (init_use(), use_exports)).then((m) => m.default)
|
|
@@ -20457,8 +20861,10 @@ var init_registry = __esm({
|
|
|
20457
20861
|
init_completion2();
|
|
20458
20862
|
init_connect3();
|
|
20459
20863
|
init_contacts();
|
|
20864
|
+
init_credits();
|
|
20460
20865
|
init_dashboards();
|
|
20461
20866
|
init_describe2();
|
|
20867
|
+
init_discover();
|
|
20462
20868
|
init_docs2();
|
|
20463
20869
|
init_doctor();
|
|
20464
20870
|
init_export3();
|
|
@@ -20474,12 +20880,15 @@ var init_registry = __esm({
|
|
|
20474
20880
|
init_reports();
|
|
20475
20881
|
init_runs2();
|
|
20476
20882
|
init_sandbox2();
|
|
20883
|
+
init_signals();
|
|
20477
20884
|
init_skill();
|
|
20478
20885
|
init_studio2();
|
|
20479
20886
|
init_tasks();
|
|
20480
20887
|
init_views();
|
|
20481
20888
|
init_webhooks2();
|
|
20482
20889
|
init_work2();
|
|
20890
|
+
init_workflow_runs();
|
|
20891
|
+
init_workflows();
|
|
20483
20892
|
init_workspace();
|
|
20484
20893
|
handWritten = {
|
|
20485
20894
|
accounts: actions,
|
|
@@ -20490,33 +20899,38 @@ var init_registry = __esm({
|
|
|
20490
20899
|
completion: actions6,
|
|
20491
20900
|
connect: actions7,
|
|
20492
20901
|
contacts: actions8,
|
|
20493
|
-
|
|
20494
|
-
|
|
20495
|
-
|
|
20496
|
-
|
|
20497
|
-
|
|
20498
|
-
|
|
20499
|
-
|
|
20500
|
-
|
|
20902
|
+
credits: actions9,
|
|
20903
|
+
dashboards: actions10,
|
|
20904
|
+
describe: actions11,
|
|
20905
|
+
discover: actions12,
|
|
20906
|
+
docs: actions13,
|
|
20907
|
+
doctor: actions14,
|
|
20908
|
+
export: actions15,
|
|
20909
|
+
import: actions16,
|
|
20910
|
+
jobs: actions17,
|
|
20911
|
+
layouts: actions18,
|
|
20501
20912
|
login: topLevel("login", actions4.login, "kenso auth login"),
|
|
20502
20913
|
logout: topLevel("logout", actions4.logout, "kenso auth logout"),
|
|
20503
|
-
logs:
|
|
20504
|
-
mcp:
|
|
20505
|
-
notes:
|
|
20506
|
-
opportunities:
|
|
20507
|
-
people:
|
|
20508
|
-
pipelines:
|
|
20509
|
-
reports:
|
|
20510
|
-
runs:
|
|
20511
|
-
sandbox:
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
|
|
20515
|
-
|
|
20516
|
-
|
|
20914
|
+
logs: actions19,
|
|
20915
|
+
mcp: actions20,
|
|
20916
|
+
notes: actions21,
|
|
20917
|
+
opportunities: actions22,
|
|
20918
|
+
people: actions23,
|
|
20919
|
+
pipelines: actions24,
|
|
20920
|
+
reports: actions25,
|
|
20921
|
+
runs: actions26,
|
|
20922
|
+
sandbox: actions27,
|
|
20923
|
+
signals: actions28,
|
|
20924
|
+
skill: actions29,
|
|
20925
|
+
studio: actions30,
|
|
20926
|
+
tasks: actions31,
|
|
20927
|
+
views: actions32,
|
|
20928
|
+
webhooks: actions33,
|
|
20517
20929
|
whoami: topLevel("whoami", actions4.status, "kenso auth status"),
|
|
20518
|
-
work:
|
|
20519
|
-
|
|
20930
|
+
work: actions34,
|
|
20931
|
+
"workflow-runs": actions35,
|
|
20932
|
+
workflows: actions36,
|
|
20933
|
+
workspace: actions37
|
|
20520
20934
|
};
|
|
20521
20935
|
resourceAliases = { leads: "contacts" };
|
|
20522
20936
|
}
|
|
@@ -20653,8 +21067,8 @@ async function renderTopHelp(opts) {
|
|
|
20653
21067
|
names.push(withPositionals(spec, spec.action));
|
|
20654
21068
|
groups.set(hint, names);
|
|
20655
21069
|
}
|
|
20656
|
-
const
|
|
20657
|
-
if (
|
|
21070
|
+
const actions39 = [...groups.entries()].map(([hint, names]) => `${names.join(", ")}${hint}`);
|
|
21071
|
+
if (actions39.length > 0) rows.push([resource, actions39.join(", ")]);
|
|
20658
21072
|
}
|
|
20659
21073
|
const at = 4 + Math.min(22, Math.max(0, ...rows.map(([left]) => left.length)));
|
|
20660
21074
|
lines.push(
|
|
@@ -20667,7 +21081,7 @@ async function renderTopHelp(opts) {
|
|
|
20667
21081
|
const [area = "", action = ""] = name.split(" ");
|
|
20668
21082
|
byArea.set(area, [...byArea.get(area) ?? [], action]);
|
|
20669
21083
|
}
|
|
20670
|
-
const named = [...byArea.entries()].map(([area,
|
|
21084
|
+
const named = [...byArea.entries()].map(([area, actions39]) => `${area} ${actions39.join("|")}`);
|
|
20671
21085
|
lines.push(wrap(`Beta, hidden here but they run (the server decides): ${named.join(", ")}.`, " "));
|
|
20672
21086
|
}
|
|
20673
21087
|
const generated = await listGenerated({ features: opts.allCommands ? [] : getFeatures, env: opts.env });
|
|
@@ -20675,13 +21089,13 @@ async function renderTopHelp(opts) {
|
|
|
20675
21089
|
if (visible.length > 0) {
|
|
20676
21090
|
const byResource = /* @__PURE__ */ new Map();
|
|
20677
21091
|
for (const g of visible) {
|
|
20678
|
-
const
|
|
20679
|
-
|
|
20680
|
-
byResource.set(g.resource,
|
|
21092
|
+
const actions39 = byResource.get(g.resource) ?? [];
|
|
21093
|
+
actions39.push(`${g.action}${g.beta ? " (beta)" : ""}`);
|
|
21094
|
+
byResource.set(g.resource, actions39);
|
|
20681
21095
|
}
|
|
20682
21096
|
const sorted2 = [...byResource.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
20683
21097
|
if (opts.allCommands) {
|
|
20684
|
-
const generatedRows = sorted2.map(([resource,
|
|
21098
|
+
const generatedRows = sorted2.map(([resource, actions39]) => [resource, actions39.sort().join(", ")]);
|
|
20685
21099
|
lines.push("", "API resources (kenso <resource> <action>):", columns(generatedRows));
|
|
20686
21100
|
} else {
|
|
20687
21101
|
const names = new Set(sorted2.map(([resource]) => resource));
|
|
@@ -20726,8 +21140,10 @@ async function renderResourceHelp(resource, opts) {
|
|
|
20726
21140
|
});
|
|
20727
21141
|
}
|
|
20728
21142
|
const rows = [
|
|
20729
|
-
...specs.map(
|
|
20730
|
-
|
|
21143
|
+
...specs.map(
|
|
21144
|
+
(s) => [usageLine2(s).slice(`kenso ${resource} `.length).replace(/ ?\[flags\]$/, ""), `${s.summary}${s.beta ? " (beta)" : ""}${effectMark(s.effect)}`]
|
|
21145
|
+
),
|
|
21146
|
+
...generated.map((g) => [g.action, `${g.summary}${g.beta ? " (beta)" : ""}${effectMark(g.effect)}`])
|
|
20731
21147
|
].sort(([a], [b]) => a.localeCompare(b));
|
|
20732
21148
|
const lines = [`Usage: kenso ${resource} <action> [flags]`, "", "Actions:", columns(rows)];
|
|
20733
21149
|
const hiddenActions = [
|
|
@@ -20742,7 +21158,7 @@ async function renderResourceHelp(resource, opts) {
|
|
|
20742
21158
|
return withAgentBlock(lines.join("\n"), opts.agent);
|
|
20743
21159
|
}
|
|
20744
21160
|
function renderCommandHelp(spec, opts) {
|
|
20745
|
-
const lines = [`Usage: ${usageLine2(spec)}`, "", `${spec.summary}${spec.beta ? " (beta)" : ""}
|
|
21161
|
+
const lines = [`Usage: ${usageLine2(spec)}`, "", `${spec.summary}${spec.beta ? " (beta)" : ""}`, ...effectAndCost(spec, opts.rateCards)];
|
|
20746
21162
|
if (spec.description) lines.push("", spec.description);
|
|
20747
21163
|
if (spec.positionals && spec.positionals.length > 0) {
|
|
20748
21164
|
lines.push("", "Arguments:", columns(spec.positionals.map((p) => [`<${p.name}>${p.variadic ? "..." : ""}`, `${p.description}${p.required ? "" : " (optional)"}`])));
|
|
@@ -20763,33 +21179,40 @@ function renderCommandHelp(spec, opts) {
|
|
|
20763
21179
|
if (spec.examples.length > 0) lines.push("", "Examples:", ...spec.examples.map((e) => ` ${e}`));
|
|
20764
21180
|
return withAgentBlock(lines.join("\n"), opts.agent);
|
|
20765
21181
|
}
|
|
20766
|
-
var GLOBAL_FLAG_HELP, GLOBAL_FLAGS_LINE, GLOBAL_FLAGS_LINE_NO_DRY_RUN, COMMON_RESOURCES, EXIT_CODES, FOR_AGENTS;
|
|
21182
|
+
var FORMATS_PIPED, FORMATS_WORDS, GLOBAL_FLAG_HELP, GLOBAL_FLAGS_TAIL, GLOBAL_FLAGS_LINE, GLOBAL_FLAGS_LINE_NO_DRY_RUN, COMMON_RESOURCES, EXIT_CODES, FOR_AGENTS;
|
|
20767
21183
|
var init_help = __esm({
|
|
20768
21184
|
"src/commands/help.ts"() {
|
|
20769
21185
|
"use strict";
|
|
20770
21186
|
init_errors();
|
|
20771
21187
|
init_exit_codes();
|
|
20772
21188
|
init_features();
|
|
21189
|
+
init_output();
|
|
20773
21190
|
init_version();
|
|
20774
21191
|
init_generated_hook();
|
|
21192
|
+
init_help_effect();
|
|
20775
21193
|
init_registry();
|
|
21194
|
+
FORMATS_PIPED = OUTPUT_FORMATS.join("|");
|
|
21195
|
+
FORMATS_WORDS = `${OUTPUT_FORMATS.slice(0, -1).join(", ")} or ${OUTPUT_FORMATS[OUTPUT_FORMATS.length - 1]}`;
|
|
20776
21196
|
GLOBAL_FLAG_HELP = [
|
|
20777
21197
|
["--profile <name>", "Use a saved profile (or KENSO_PROFILE)"],
|
|
20778
21198
|
["--workspace <id>", "Workspace for this command (or KENSO_WORKSPACE_ID)"],
|
|
20779
|
-
["-o, --output <format>",
|
|
21199
|
+
["-o, --output <format>", `${FORMATS_WORDS} (default: table on a terminal, JSON when piped)`],
|
|
20780
21200
|
["--json", "Same as -o json"],
|
|
20781
21201
|
["--fields <a,b.c>", "Keep only these fields"],
|
|
20782
21202
|
["--query <JMESPath>", "Filter or reshape the output in-process"],
|
|
20783
21203
|
["-v, --verbose", "Print each request to stderr (keys redacted)"],
|
|
20784
21204
|
["-y, --yes", "Apply a write; a delete, archive or remove needs it"],
|
|
20785
21205
|
["--dry-run", "Show what a write would do and change nothing"],
|
|
21206
|
+
["--read-only", "Refuse every command that is not a read (or KENSO_READ_ONLY=1)"],
|
|
20786
21207
|
["--progress", "Print progress to stderr even when it is not a terminal"],
|
|
20787
21208
|
["--all-commands", "Show beta commands in help"],
|
|
20788
21209
|
["-h, --help", "Show help"],
|
|
20789
21210
|
["--version", "Print the CLI version (only on its own: kenso --version)"]
|
|
20790
21211
|
];
|
|
20791
|
-
|
|
20792
|
-
|
|
21212
|
+
GLOBAL_FLAGS_TAIL = `--read-only, --profile <name>, --workspace <id>, -o ${FORMATS_PIPED}, --json, --fields, --query, -v.`;
|
|
21213
|
+
GLOBAL_FLAGS_LINE = `Global flags: --dry-run, -y/--yes, ${GLOBAL_FLAGS_TAIL}`;
|
|
21214
|
+
GLOBAL_FLAGS_LINE_NO_DRY_RUN = `Global flags: -y/--yes, ${GLOBAL_FLAGS_TAIL}
|
|
21215
|
+
No --dry-run: this command runs for real, so --dry-run is refused.`;
|
|
20793
21216
|
COMMON_RESOURCES = [
|
|
20794
21217
|
"accounts",
|
|
20795
21218
|
"analytics",
|
|
@@ -20886,9 +21309,39 @@ function applyAliases(argv, spec) {
|
|
|
20886
21309
|
}
|
|
20887
21310
|
return out;
|
|
20888
21311
|
}
|
|
21312
|
+
function normalizeBooleans(argv, names, strict) {
|
|
21313
|
+
const out = [];
|
|
21314
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21315
|
+
const arg = argv[i];
|
|
21316
|
+
if (arg === "--") {
|
|
21317
|
+
out.push(...argv.slice(i));
|
|
21318
|
+
break;
|
|
21319
|
+
}
|
|
21320
|
+
const match = /^--([^=]+)=([\s\S]*)$/.exec(arg);
|
|
21321
|
+
if (!match || !names.has(match[1])) {
|
|
21322
|
+
out.push(arg);
|
|
21323
|
+
continue;
|
|
21324
|
+
}
|
|
21325
|
+
const [, name, value] = match;
|
|
21326
|
+
if (value === "true") out.push(`--${name}`);
|
|
21327
|
+
else if (value === "false") out.push(`--no-${name}`);
|
|
21328
|
+
else if (strict) {
|
|
21329
|
+
throw new KensoError({
|
|
21330
|
+
code: "invalid_flag_value",
|
|
21331
|
+
message: `--${name} takes true or false (got "${value}"). Use --${name}, --no-${name}, --${name}=true or --${name}=false.`,
|
|
21332
|
+
exitCode: ExitCode.Usage,
|
|
21333
|
+
field: name,
|
|
21334
|
+
next: `${strict.command} --help`
|
|
21335
|
+
});
|
|
21336
|
+
} else out.push(arg);
|
|
21337
|
+
}
|
|
21338
|
+
return out;
|
|
21339
|
+
}
|
|
20889
21340
|
var init_flag_names = __esm({
|
|
20890
21341
|
"src/core/flag-names.ts"() {
|
|
20891
21342
|
"use strict";
|
|
21343
|
+
init_errors();
|
|
21344
|
+
init_exit_codes();
|
|
20892
21345
|
}
|
|
20893
21346
|
});
|
|
20894
21347
|
|
|
@@ -20910,15 +21363,68 @@ var init_invoked = __esm({
|
|
|
20910
21363
|
}
|
|
20911
21364
|
});
|
|
20912
21365
|
|
|
21366
|
+
// src/core/pre-run.ts
|
|
21367
|
+
function readOnlySource(ctx) {
|
|
21368
|
+
const value = (ctx.env.KENSO_READ_ONLY ?? "").trim().toLowerCase();
|
|
21369
|
+
if (value !== "" && value !== "0" && value !== "false") return "env";
|
|
21370
|
+
return ctx.flags.readOnly === true ? "flag" : void 0;
|
|
21371
|
+
}
|
|
21372
|
+
function effectOf2(spec, args) {
|
|
21373
|
+
return spec.effectFor?.(args) ?? spec.effect ?? "write";
|
|
21374
|
+
}
|
|
21375
|
+
function shellQuote6(value) {
|
|
21376
|
+
return /^[A-Za-z0-9_\-.,:/@=+%]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
21377
|
+
}
|
|
21378
|
+
function readOnlyError(spec, effect, source, argv) {
|
|
21379
|
+
const name = spec.action ? `kenso ${spec.resource} ${spec.action}` : `kenso ${spec.resource}`;
|
|
21380
|
+
const message = `${name} is a ${effect} command, and this session is read-only.`;
|
|
21381
|
+
if (source === "env") {
|
|
21382
|
+
return new KensoError({ code: "read_only", message, exitCode: ExitCode.Usage, hint: "KENSO_READ_ONLY is set: unset it to run this command." });
|
|
21383
|
+
}
|
|
21384
|
+
if (spec.flags["body-read-only"]) {
|
|
21385
|
+
const hint = "Read-only is on through --read-only, the global flag. This command's own read-only option is --body-read-only.";
|
|
21386
|
+
return new KensoError({ code: "read_only", message, exitCode: ExitCode.Usage, hint });
|
|
21387
|
+
}
|
|
21388
|
+
const end = argv?.indexOf("--") ?? -1;
|
|
21389
|
+
const head = (end === -1 ? argv : argv?.slice(0, end)) ?? [];
|
|
21390
|
+
if (spec.dryRun !== true || !argv || head.some((token) => /^-[A-Za-z]{2,}$/.test(token) && token.includes("y"))) {
|
|
21391
|
+
return new KensoError({ code: "read_only", message, exitCode: ExitCode.Usage, hint: "Read-only is on through --read-only: run the command again without --read-only to make the change." });
|
|
21392
|
+
}
|
|
21393
|
+
const kept = head.filter((token) => token !== "--yes" && token !== "-y" && !token.startsWith("--yes="));
|
|
21394
|
+
const withDryRun = [...kept, "--dry-run", ...end === -1 ? [] : argv.slice(end)];
|
|
21395
|
+
return new KensoError({
|
|
21396
|
+
code: "read_only",
|
|
21397
|
+
message,
|
|
21398
|
+
exitCode: ExitCode.Usage,
|
|
21399
|
+
hint: "Read-only is on through --read-only: next prints the plan. Run the command again without --read-only to make the change.",
|
|
21400
|
+
next: ["kenso", ...withDryRun.map(shellQuote6)].join(" ")
|
|
21401
|
+
});
|
|
21402
|
+
}
|
|
21403
|
+
async function beforeRun(ctx, spec, args, argv) {
|
|
21404
|
+
const source = readOnlySource(ctx);
|
|
21405
|
+
if (!source) return;
|
|
21406
|
+
const effect = effectOf2(spec, args);
|
|
21407
|
+
if (effect === "read") return;
|
|
21408
|
+
if (ctx.flags.dryRun === true && spec.dryRun === true) return;
|
|
21409
|
+
throw readOnlyError(spec, effect, source, argv);
|
|
21410
|
+
}
|
|
21411
|
+
var init_pre_run = __esm({
|
|
21412
|
+
"src/core/pre-run.ts"() {
|
|
21413
|
+
"use strict";
|
|
21414
|
+
init_errors();
|
|
21415
|
+
init_exit_codes();
|
|
21416
|
+
}
|
|
21417
|
+
});
|
|
21418
|
+
|
|
20913
21419
|
// src/core/update-notice.ts
|
|
20914
|
-
import { mkdirSync as mkdirSync5, readFileSync as
|
|
20915
|
-
import { dirname as dirname5, join as
|
|
21420
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync15, realpathSync as realpathSync2, renameSync as renameSync5, writeFileSync as writeFileSync8 } from "node:fs";
|
|
21421
|
+
import { dirname as dirname5, join as join27, sep as sep3 } from "node:path";
|
|
20916
21422
|
function installKind(script = process.argv[1], execPath = process.execPath, platform = process.platform) {
|
|
20917
21423
|
try {
|
|
20918
21424
|
if (!script) return "npm";
|
|
20919
21425
|
const bundle = realpathSync2(script);
|
|
20920
21426
|
const lib = dirname5(dirname5(dirname5(bundle)));
|
|
20921
|
-
if (execPath !==
|
|
21427
|
+
if (execPath !== join27(lib, platform === "win32" ? "node.exe" : "node")) return "npm";
|
|
20922
21428
|
return bundle.includes(`${sep3}Cellar${sep3}kenso${sep3}`) ? "homebrew" : "standalone";
|
|
20923
21429
|
} catch {
|
|
20924
21430
|
return "npm";
|
|
@@ -20931,7 +21437,7 @@ function updateCommand(install, platform) {
|
|
|
20931
21437
|
}
|
|
20932
21438
|
function readCheck(file) {
|
|
20933
21439
|
try {
|
|
20934
|
-
const parsed2 = JSON.parse(
|
|
21440
|
+
const parsed2 = JSON.parse(readFileSync15(file, "utf8"));
|
|
20935
21441
|
if (typeof parsed2?.checkedAt !== "string") return void 0;
|
|
20936
21442
|
return { checkedAt: parsed2.checkedAt, ...typeof parsed2.latest === "string" ? { latest: parsed2.latest } : {} };
|
|
20937
21443
|
} catch {
|
|
@@ -20942,9 +21448,9 @@ function writeCheck(file, check) {
|
|
|
20942
21448
|
try {
|
|
20943
21449
|
mkdirSync5(dirname5(file), { recursive: true, mode: 448 });
|
|
20944
21450
|
const temp = `${file}.${process.pid}.tmp`;
|
|
20945
|
-
|
|
21451
|
+
writeFileSync8(temp, `${JSON.stringify(check)}
|
|
20946
21452
|
`, { mode: 384 });
|
|
20947
|
-
|
|
21453
|
+
renameSync5(temp, file);
|
|
20948
21454
|
} catch {
|
|
20949
21455
|
}
|
|
20950
21456
|
}
|
|
@@ -20978,7 +21484,7 @@ function startUpdateNotice(argv, opts = {}) {
|
|
|
20978
21484
|
const stderr = opts.stderr ?? process.stderr;
|
|
20979
21485
|
const wanted = (opts.stderrIsTTY ?? process.stderr.isTTY === true) && detectAgent(env) === null && env.CI === void 0 && !env.KENSO_NO_UPDATE_NOTIFIER && RELEASE.test(version) && !argv.some((word) => QUIET_COMMANDS.has(word));
|
|
20980
21486
|
if (!wanted) return done;
|
|
20981
|
-
const file =
|
|
21487
|
+
const file = join27(configDir(env), UPDATE_CHECK_FILE);
|
|
20982
21488
|
const now = (opts.now ?? Date.now)();
|
|
20983
21489
|
const cached = readCheck(file);
|
|
20984
21490
|
const checkedAt = Date.parse(cached?.checkedAt ?? "");
|
|
@@ -21040,7 +21546,7 @@ function resources() {
|
|
|
21040
21546
|
const names = Object.entries(handWritten).filter(([, area]) => Object.keys(area).length > 0).map(([resource]) => resource);
|
|
21041
21547
|
return sorted([...names, ...Object.keys(resourceAliases), ...listOperations().map((op) => op.resource)]);
|
|
21042
21548
|
}
|
|
21043
|
-
function
|
|
21549
|
+
function actions38(resource) {
|
|
21044
21550
|
const own = Object.keys(handWritten[resource] ?? {}).filter((action) => action !== "");
|
|
21045
21551
|
return sorted([...own, ...listOperations().filter((op) => op.resource === resource).map((op) => op.action)]);
|
|
21046
21552
|
}
|
|
@@ -21105,7 +21611,7 @@ async function completions(words, globals) {
|
|
|
21105
21611
|
return flagsOf2(spec, globals, positionals.length === 0);
|
|
21106
21612
|
}
|
|
21107
21613
|
if (positionals.length === 0) return resources();
|
|
21108
|
-
if (!spec) return positionals.length === 1 ?
|
|
21614
|
+
if (!spec) return positionals.length === 1 ? actions38(resourceAliases[positionals[0]] ?? positionals[0]) : [];
|
|
21109
21615
|
const given = positionals.length - commandWords2;
|
|
21110
21616
|
const declared = spec.positionals ?? [];
|
|
21111
21617
|
if (given < declared.length || declared.at(-1)?.variadic === true) {
|
|
@@ -21168,40 +21674,12 @@ function leaveRun(active) {
|
|
|
21168
21674
|
graceTimer = void 0;
|
|
21169
21675
|
}
|
|
21170
21676
|
}
|
|
21171
|
-
function normalizeBooleans(argv, names, strict) {
|
|
21172
|
-
const out = [];
|
|
21173
|
-
for (let i = 0; i < argv.length; i++) {
|
|
21174
|
-
const arg = argv[i];
|
|
21175
|
-
if (arg === "--") {
|
|
21176
|
-
out.push(...argv.slice(i));
|
|
21177
|
-
break;
|
|
21178
|
-
}
|
|
21179
|
-
const match = /^--([^=]+)=([\s\S]*)$/.exec(arg);
|
|
21180
|
-
if (!match || !names.has(match[1])) {
|
|
21181
|
-
out.push(arg);
|
|
21182
|
-
continue;
|
|
21183
|
-
}
|
|
21184
|
-
const [, name, value] = match;
|
|
21185
|
-
if (value === "true") out.push(`--${name}`);
|
|
21186
|
-
else if (value === "false") out.push(`--no-${name}`);
|
|
21187
|
-
else if (strict) {
|
|
21188
|
-
throw new KensoError({
|
|
21189
|
-
code: "invalid_flag_value",
|
|
21190
|
-
message: `--${name} takes true or false (got "${value}"). Use --${name}, --no-${name}, --${name}=true or --${name}=false.`,
|
|
21191
|
-
exitCode: ExitCode.Usage,
|
|
21192
|
-
field: name,
|
|
21193
|
-
next: `${strict.command} --help`
|
|
21194
|
-
});
|
|
21195
|
-
} else out.push(arg);
|
|
21196
|
-
}
|
|
21197
|
-
return out;
|
|
21198
|
-
}
|
|
21199
21677
|
async function knownCommands() {
|
|
21200
21678
|
const commands = /* @__PURE__ */ new Set();
|
|
21201
21679
|
for (const [resource, area] of Object.entries(handWritten)) {
|
|
21202
|
-
const
|
|
21203
|
-
if (
|
|
21204
|
-
for (const action of
|
|
21680
|
+
const actions39 = Object.keys(area);
|
|
21681
|
+
if (actions39.length > 0) commands.add(resource);
|
|
21682
|
+
for (const action of actions39) commands.add(action ? `${resource} ${action}` : resource);
|
|
21205
21683
|
}
|
|
21206
21684
|
for (const g of await listGenerated({ features: [] })) {
|
|
21207
21685
|
commands.add(g.resource);
|
|
@@ -21310,6 +21788,7 @@ function globalFlags(values) {
|
|
|
21310
21788
|
verbose: values.verbose === true,
|
|
21311
21789
|
yes: values.yes === true,
|
|
21312
21790
|
dryRun: values["dry-run"] === true,
|
|
21791
|
+
readOnly: values["read-only"] === true,
|
|
21313
21792
|
progress: values.progress === true,
|
|
21314
21793
|
allCommands: values["all-commands"] === true
|
|
21315
21794
|
};
|
|
@@ -21350,11 +21829,11 @@ function commandArgs(spec, parsed2, tokens) {
|
|
|
21350
21829
|
}
|
|
21351
21830
|
return { flags, positionals };
|
|
21352
21831
|
}
|
|
21353
|
-
async function main(argv, env = process.env,
|
|
21354
|
-
const stdout =
|
|
21832
|
+
async function main(argv, env = process.env, overrides2 = {}) {
|
|
21833
|
+
const stdout = overrides2.stdout ?? process.stdout;
|
|
21355
21834
|
guardClosedPipe(stdout);
|
|
21356
21835
|
if (argv[0] === "__complete") return (await Promise.resolve().then(() => (init_complete(), complete_exports))).printCompletions(argv.slice(1), GLOBAL_OPTIONS, stdout);
|
|
21357
|
-
let output = new Output({ stdout:
|
|
21836
|
+
let output = new Output({ stdout: overrides2.stdout, stderr: overrides2.stderr, stdoutIsTTY: overrides2.stdoutIsTTY, stderrIsTTY: overrides2.stderrIsTTY });
|
|
21358
21837
|
const agent = detectAgent(env);
|
|
21359
21838
|
const controller = new AbortController();
|
|
21360
21839
|
const active = { controller, info: (message) => output.info(message) };
|
|
@@ -21369,12 +21848,14 @@ async function main(argv, env = process.env, overrides = {}) {
|
|
|
21369
21848
|
}
|
|
21370
21849
|
verbose = loose.values.verbose === true;
|
|
21371
21850
|
const text4 = (value) => typeof value === "string" ? value : void 0;
|
|
21851
|
+
const lookupFlags = { profile: text4(loose.values.profile), workspace: text4(loose.values.workspace) };
|
|
21852
|
+
const lookupOverrides = { fetchImpl: overrides2.fetchImpl, sleep: overrides2.sleep, signal: controller.signal };
|
|
21372
21853
|
const helpOptions = {
|
|
21373
21854
|
agent,
|
|
21374
21855
|
allCommands: loose.values["all-commands"] === true,
|
|
21375
21856
|
env,
|
|
21376
|
-
// Cached features, else GET /v1/me with a 1,500 ms timeout
|
|
21377
|
-
loadFeatures: () => featuresFromEnv(env,
|
|
21857
|
+
// Cached features, else GET /v1/me with a 1,500 ms timeout.
|
|
21858
|
+
loadFeatures: () => featuresFromEnv(env, lookupFlags, lookupOverrides),
|
|
21378
21859
|
warn: (message) => {
|
|
21379
21860
|
lookupFailed = true;
|
|
21380
21861
|
output.info(message);
|
|
@@ -21413,16 +21894,19 @@ async function main(argv, env = process.env, overrides = {}) {
|
|
|
21413
21894
|
commandTokens = [resourceToken, actionToken];
|
|
21414
21895
|
}
|
|
21415
21896
|
if (wantHelp) {
|
|
21416
|
-
|
|
21897
|
+
const rateCards = spec.cost?.length ? await rateCardsForHelp(env, lookupFlags, lookupOverrides) : void 0;
|
|
21898
|
+
if (rateCards?.[0]?.source === "bundled") lookupFailed = true;
|
|
21899
|
+
stdout.write(renderCommandHelp(spec, { ...helpOptions, rateCards }));
|
|
21417
21900
|
return ExitCode.Ok;
|
|
21418
21901
|
}
|
|
21419
21902
|
const parsed2 = strictParse(argv, spec);
|
|
21420
21903
|
const flags = globalFlags(parsed2.values);
|
|
21421
21904
|
if (flags.dryRun && spec.dryRun !== true) throw noDryRun(spec);
|
|
21422
21905
|
const args = commandArgs(spec, parsed2, commandTokens);
|
|
21423
|
-
const ctx = createContext(flags, env, { ...
|
|
21906
|
+
const ctx = createContext(flags, env, { ...overrides2, signal: controller.signal, noConfig: spec.ownCredential?.(args.flags) === true });
|
|
21424
21907
|
output = ctx.output;
|
|
21425
21908
|
active.graceMs = spec.interruptGraceMs;
|
|
21909
|
+
await beforeRun(ctx, spec, args, argv);
|
|
21426
21910
|
enterRun(active);
|
|
21427
21911
|
try {
|
|
21428
21912
|
const code = await spec.run(ctx, args);
|
|
@@ -21463,6 +21947,8 @@ var init_main = __esm({
|
|
|
21463
21947
|
init_flag_names();
|
|
21464
21948
|
init_invoked();
|
|
21465
21949
|
init_output();
|
|
21950
|
+
init_pre_run();
|
|
21951
|
+
init_rate_card();
|
|
21466
21952
|
init_redact();
|
|
21467
21953
|
init_update_notice();
|
|
21468
21954
|
init_version();
|
|
@@ -21476,6 +21962,7 @@ var init_main = __esm({
|
|
|
21476
21962
|
verbose: { type: "boolean", short: "v" },
|
|
21477
21963
|
yes: { type: "boolean", short: "y" },
|
|
21478
21964
|
"dry-run": { type: "boolean" },
|
|
21965
|
+
"read-only": { type: "boolean" },
|
|
21479
21966
|
progress: { type: "boolean" },
|
|
21480
21967
|
"all-commands": { type: "boolean" },
|
|
21481
21968
|
help: { type: "boolean", short: "h" },
|