kenso 0.1.160 → 0.1.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/discover.json +1 -1
- package/dist/kenso.js +34 -10
- package/dist/operations.index.json +1 -1
- package/dist/operations.json +1 -1
- package/docs/reference.md +9 -3
- package/package.json +2 -2
package/dist/kenso.js
CHANGED
|
@@ -3422,7 +3422,7 @@ var VERSION;
|
|
|
3422
3422
|
var init_version = __esm({
|
|
3423
3423
|
"src/core/version.ts"() {
|
|
3424
3424
|
"use strict";
|
|
3425
|
-
VERSION = true ? "0.1.
|
|
3425
|
+
VERSION = true ? "0.1.161" : "0.0.0-dev";
|
|
3426
3426
|
}
|
|
3427
3427
|
});
|
|
3428
3428
|
|
|
@@ -5048,6 +5048,7 @@ async function dryRun(spec, ctx, plan2) {
|
|
|
5048
5048
|
});
|
|
5049
5049
|
}
|
|
5050
5050
|
const files = filesOf(dir3);
|
|
5051
|
+
const nothingValid = spec.items.length === 0 && plan2.invalid.length > 0;
|
|
5051
5052
|
const planBody = {
|
|
5052
5053
|
dryRun: true,
|
|
5053
5054
|
command: spec.command,
|
|
@@ -5057,7 +5058,7 @@ async function dryRun(spec, ctx, plan2) {
|
|
|
5057
5058
|
chunks: plan2.chunkCount,
|
|
5058
5059
|
chunkSize: spec.chunkSize,
|
|
5059
5060
|
...spec.dryRunExtra,
|
|
5060
|
-
next: spec.applyCommand
|
|
5061
|
+
next: nothingValid ? `No row is valid, so --yes would start nothing. Fix the rows listed in ${files.invalidCsv} (its reason and error columns say why each was refused), then plan again with --dry-run.` : spec.applyCommand
|
|
5061
5062
|
};
|
|
5062
5063
|
await writeJsonAtomic(files.planJson, planBody);
|
|
5063
5064
|
if (plan2.invalid.length > 0) await writeFileAtomic(files.invalidCsv, resultsToCsv(byRow(plan2.invalid)));
|
|
@@ -18052,6 +18053,7 @@ async function callSkillTool(ctx, tool, args) {
|
|
|
18052
18053
|
const result = await mcpClient(ctx).callTool(tool, args);
|
|
18053
18054
|
const text4 = (result.content ?? []).flatMap((part) => part.type === "text" && typeof part.text === "string" ? [part.text] : []).join("\n");
|
|
18054
18055
|
let data = result.structuredContent;
|
|
18056
|
+
if (isRecord10(data) && Object.keys(data).length === 1 && "result" in data) data = data.result;
|
|
18055
18057
|
if (data === void 0) {
|
|
18056
18058
|
try {
|
|
18057
18059
|
data = JSON.parse(text4);
|
|
@@ -18091,9 +18093,8 @@ var init_list4 = __esm({
|
|
|
18091
18093
|
examples: ["kenso skill list", "kenso skill list --fields name,title", "kenso skill list -o csv"],
|
|
18092
18094
|
operationIds: [],
|
|
18093
18095
|
async run(ctx) {
|
|
18094
|
-
const
|
|
18095
|
-
|
|
18096
|
-
if (rows === void 0) throw unexpectedAnswer("list_skills");
|
|
18096
|
+
const rows = await callSkillTool(ctx, "list_skills", {});
|
|
18097
|
+
if (!Array.isArray(rows)) throw unexpectedAnswer("list_skills");
|
|
18097
18098
|
await ctx.output.list(
|
|
18098
18099
|
rows.filter(isRecord10).map((skill) => ({
|
|
18099
18100
|
name: skill.name,
|
|
@@ -22658,6 +22659,14 @@ var init_files2 = __esm({
|
|
|
22658
22659
|
|
|
22659
22660
|
// src/commands/workflows/run-wait.ts
|
|
22660
22661
|
import { setTimeout as delay13 } from "node:timers/promises";
|
|
22662
|
+
function waitStatusLine(counts2, elapsedMs) {
|
|
22663
|
+
const order = [...OPEN_RUN_STATUSES];
|
|
22664
|
+
const rank2 = (status) => order.includes(status) ? order.indexOf(status) : order.length;
|
|
22665
|
+
const parts2 = [...counts2].sort(([a], [b]) => rank2(a) - rank2(b) || a.localeCompare(b)).map(([status, n]) => `${n} ${status}`);
|
|
22666
|
+
const total = [...counts2.values()].reduce((sum, n) => sum + n, 0);
|
|
22667
|
+
const line = `still waiting after ${Math.floor(elapsedMs / 6e4)}m: ${parts2.join(", ")} of ${total} runs`;
|
|
22668
|
+
return (counts2.get("queued") ?? 0) > 0 ? `${line}. A queued AI step can wait up to ${AI_BATCH_WINDOW_MINUTES} minutes for its batch to start.` : line;
|
|
22669
|
+
}
|
|
22661
22670
|
function roundCredits(value) {
|
|
22662
22671
|
return Math.round(value * 1e3) / 1e3;
|
|
22663
22672
|
}
|
|
@@ -22679,9 +22688,11 @@ async function waitForRuns(client, runIds, opts) {
|
|
|
22679
22688
|
const now = opts.now ?? Date.now;
|
|
22680
22689
|
const sleep = opts.sleep ?? ((ms) => delay13(ms, void 0, { signal: opts.signal }));
|
|
22681
22690
|
const runs = /* @__PURE__ */ new Map();
|
|
22682
|
-
|
|
22691
|
+
const ids2 = [...new Set(runIds)];
|
|
22692
|
+
let open2 = ids2;
|
|
22683
22693
|
const total = open2.length;
|
|
22684
22694
|
const started = now();
|
|
22695
|
+
let statusAt = started;
|
|
22685
22696
|
try {
|
|
22686
22697
|
for (; ; ) {
|
|
22687
22698
|
let next = 0;
|
|
@@ -22700,6 +22711,15 @@ async function waitForRuns(client, runIds, opts) {
|
|
|
22700
22711
|
if (failures.length > 0) throw failures[0];
|
|
22701
22712
|
open2 = open2.filter((id) => OPEN_RUN_STATUSES.has(runs.get(id)?.status ?? "queued"));
|
|
22702
22713
|
opts.onProgress?.(open2.length, total);
|
|
22714
|
+
if (opts.onStatus && open2.length > 0 && now() - statusAt >= STATUS_INTERVAL_MS) {
|
|
22715
|
+
statusAt = now();
|
|
22716
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
22717
|
+
for (const id of ids2) {
|
|
22718
|
+
const status = runs.get(id)?.status ?? "queued";
|
|
22719
|
+
counts2.set(status, (counts2.get(status) ?? 0) + 1);
|
|
22720
|
+
}
|
|
22721
|
+
opts.onStatus(counts2, statusAt - started);
|
|
22722
|
+
}
|
|
22703
22723
|
const elapsed = now() - started;
|
|
22704
22724
|
if (open2.length === 0 || elapsed >= opts.timeoutMs) return { runs, interrupted: false };
|
|
22705
22725
|
await sleep(Math.min(elapsed >= FAST_PHASE_MS2 ? SLOW_INTERVAL_MS2 : FAST_INTERVAL_MS, opts.timeoutMs - elapsed));
|
|
@@ -22709,7 +22729,7 @@ async function waitForRuns(client, runIds, opts) {
|
|
|
22709
22729
|
return { runs, interrupted: false, stopped: err instanceof Error ? err.message : String(err) };
|
|
22710
22730
|
}
|
|
22711
22731
|
}
|
|
22712
|
-
var OPEN_RUN_STATUSES, MAX_PARALLEL_READS, FAST_INTERVAL_MS, SLOW_INTERVAL_MS2, FAST_PHASE_MS2;
|
|
22732
|
+
var OPEN_RUN_STATUSES, MAX_PARALLEL_READS, FAST_INTERVAL_MS, SLOW_INTERVAL_MS2, FAST_PHASE_MS2, STATUS_INTERVAL_MS, AI_BATCH_WINDOW_MINUTES;
|
|
22713
22733
|
var init_run_wait = __esm({
|
|
22714
22734
|
"src/commands/workflows/run-wait.ts"() {
|
|
22715
22735
|
"use strict";
|
|
@@ -22721,6 +22741,8 @@ var init_run_wait = __esm({
|
|
|
22721
22741
|
FAST_INTERVAL_MS = 2e3;
|
|
22722
22742
|
SLOW_INTERVAL_MS2 = 1e4;
|
|
22723
22743
|
FAST_PHASE_MS2 = 6e4;
|
|
22744
|
+
STATUS_INTERVAL_MS = 6e4;
|
|
22745
|
+
AI_BATCH_WINDOW_MINUTES = 15;
|
|
22724
22746
|
}
|
|
22725
22747
|
});
|
|
22726
22748
|
|
|
@@ -24027,7 +24049,9 @@ async function finishRun(ctx, input) {
|
|
|
24027
24049
|
const waited = await waitForRuns(ctx.client, runIds, {
|
|
24028
24050
|
timeoutMs: flags.timeoutMs,
|
|
24029
24051
|
signal: ctx.signal,
|
|
24030
|
-
onProgress: (open2, total) => ctx.output.progress(`runs: ${total - open2}/${total} ended`)
|
|
24052
|
+
onProgress: (open2, total) => ctx.output.progress(`runs: ${total - open2}/${total} ended`),
|
|
24053
|
+
// stderr on any terminal or pipe, so an agent sees why a few queued AI runs take 15 minutes; never in the JSON.
|
|
24054
|
+
onStatus: (counts3, elapsedMs) => ctx.output.info(`workflow ${workflowId} ${waitStatusLine(counts3, elapsedMs)}`)
|
|
24031
24055
|
});
|
|
24032
24056
|
runs = waited.runs;
|
|
24033
24057
|
interrupted7 = waited.interrupted;
|
|
@@ -24219,7 +24243,7 @@ var init_run4 = __esm({
|
|
|
24219
24243
|
action: "run",
|
|
24220
24244
|
summary: "Run a published workflow on records from an ids file or a CSV",
|
|
24221
24245
|
brief: "on ids or a CSV",
|
|
24222
|
-
description: "Starts one run per record on the workflow's published version. The target is a workflow id, or a workflow file bound in kenso.json that equals the published version. --ids is one id per line; --file is a CSV with an id column, or for a workflow that runs on people a CSV of people (the columns of kenso people import), matched or created first. Without --yes it prints the plan with the credit estimate and starts nothing. --max-credits starts only as many records as the cap covers and reports the rest as not_started. The same command on the same input never starts its records twice; another --max-credits on that input is refused with an ids file of the records not started yet. Exit 5 when some records failed, were not found or were not started, 6 when the cap starts nothing or the workspace is out of credits, 7 when the file differs from the published version or the workflow is not live. --wait reads each started run until it ends (--timeout, default 30m); --out writes one row per record with each step's output, because a succeeded run's step outputs are dropped 7 days after it ends unless the workflow keeps success details.",
|
|
24246
|
+
description: "Starts one run per record on the workflow's published version. The target is a workflow id, or a workflow file bound in kenso.json that equals the published version. --ids is one id per line; --file is a CSV with an id column, or for a workflow that runs on people a CSV of people (the columns of kenso people import), matched or created first. Without --yes it prints the plan with the credit estimate and starts nothing. --max-credits starts only as many records as the cap covers and reports the rest as not_started. The same command on the same input never starts its records twice; another --max-credits on that input is refused with an ids file of the records not started yet. Exit 5 when some records failed, were not found or were not started, 6 when the cap starts nothing or the workspace is out of credits, 7 when the file differs from the published version or the workflow is not live. --wait reads each started run until it ends (--timeout, default 30m) and prints the runs' counts by status on stderr once a minute (a queued AI step can wait up to 15 minutes for its batch); --out writes one row per record with each step's output, because a succeeded run's step outputs are dropped 7 days after it ends unless the workflow keeps success details.",
|
|
24223
24247
|
effect: "send",
|
|
24224
24248
|
doc: {
|
|
24225
24249
|
when: "You have a published workflow and the records to run it on.",
|
|
@@ -24323,7 +24347,7 @@ var init_run4 = __esm({
|
|
|
24323
24347
|
});
|
|
24324
24348
|
if (!apply) {
|
|
24325
24349
|
const planned = await runBatch(spec(true, input.records, input.invalid), ctx);
|
|
24326
|
-
if (ctx.flags.dryRun === true || !canAsk(ctx) || estimateError || balanceError) return planned.exitCode;
|
|
24350
|
+
if (ctx.flags.dryRun === true || !canAsk(ctx) || estimateError || balanceError || input.records.length === 0) return planned.exitCode;
|
|
24327
24351
|
await confirmDestructive(ctx, `Start ${cap ? cap.willStart : input.records.length} of ${rows} records on workflow ${workflowId}`, applyCommand);
|
|
24328
24352
|
}
|
|
24329
24353
|
const done2 = await earlierRun(ctx, args, input.input.sha256, workflowId);
|