@erdoai/cli 0.231.1 → 0.233.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +87 -47
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1324,13 +1324,6 @@ var ErdoClient = class {
|
|
|
1324
1324
|
`/v1/workstreams/${encodeURIComponent(slug)}/events${qs}`
|
|
1325
1325
|
);
|
|
1326
1326
|
}
|
|
1327
|
-
addWorkstreamPhase(slug, input) {
|
|
1328
|
-
return this.request(
|
|
1329
|
-
"POST",
|
|
1330
|
-
`/v1/workstreams/${encodeURIComponent(slug)}/phases`,
|
|
1331
|
-
input
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
1327
|
armWorkstreamLoop(slug, input) {
|
|
1335
1328
|
return this.request("POST", `/v1/workstreams/${encodeURIComponent(slug)}/arm`, input ?? {});
|
|
1336
1329
|
}
|
|
@@ -1440,7 +1433,6 @@ var ErdoClient = class {
|
|
|
1440
1433
|
if (params?.limit) q.set("limit", String(params.limit));
|
|
1441
1434
|
if (params?.offset) q.set("offset", String(params.offset));
|
|
1442
1435
|
if (params?.categories) q.set("categories", params.categories);
|
|
1443
|
-
if (params?.scope) q.set("scope", params.scope);
|
|
1444
1436
|
if (params?.workstream_slug) q.set("workstream_slug", params.workstream_slug);
|
|
1445
1437
|
const qs = q.toString();
|
|
1446
1438
|
return this.request(
|
|
@@ -1748,6 +1740,24 @@ var ErdoClient = class {
|
|
|
1748
1740
|
deleteDataset(slug) {
|
|
1749
1741
|
return this.request("DELETE", `/v1/datasets/${encodeURIComponent(slug)}`);
|
|
1750
1742
|
}
|
|
1743
|
+
// The /v1 endpoint is a DELETE, whose parameters Encore reads from the query
|
|
1744
|
+
// string, so the keys travel there and never in a body. Not replayed after a
|
|
1745
|
+
// network failure, so rows_affected reports this call's deletions.
|
|
1746
|
+
deleteDatasetRows(slug, input) {
|
|
1747
|
+
const query = new URLSearchParams();
|
|
1748
|
+
if ("delete_all" in input) {
|
|
1749
|
+
query.set("delete_all", "true");
|
|
1750
|
+
} else {
|
|
1751
|
+
query.set("key_column", input.key_column);
|
|
1752
|
+
for (const key of input.keys) query.append("keys", key);
|
|
1753
|
+
}
|
|
1754
|
+
return this.request(
|
|
1755
|
+
"DELETE",
|
|
1756
|
+
`/v1/datasets/${encodeURIComponent(slug)}/rows?${query.toString()}`,
|
|
1757
|
+
void 0,
|
|
1758
|
+
false
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1751
1761
|
setDatasetPurpose(slug, input) {
|
|
1752
1762
|
return this.updateDatasetSchema(slug, input);
|
|
1753
1763
|
}
|
|
@@ -4371,7 +4381,7 @@ wsCmd.command("list").description("List workstreams in the active org").option("
|
|
|
4371
4381
|
fail(e);
|
|
4372
4382
|
}
|
|
4373
4383
|
});
|
|
4374
|
-
wsCmd.command("get <slug>").description("Show a workstream \u2014 status,
|
|
4384
|
+
wsCmd.command("get <slug>").description("Show a workstream \u2014 status, resources, recent log").action(async (slug) => {
|
|
4375
4385
|
try {
|
|
4376
4386
|
print(await new ErdoClient().getWorkstream(slug));
|
|
4377
4387
|
} catch (e) {
|
|
@@ -4413,50 +4423,20 @@ wsCmd.command("events <slug>").description("Show a workstream's full event log (
|
|
|
4413
4423
|
fail(e);
|
|
4414
4424
|
}
|
|
4415
4425
|
});
|
|
4416
|
-
wsCmd.command("
|
|
4417
|
-
async (slug, opts) => {
|
|
4418
|
-
try {
|
|
4419
|
-
print(
|
|
4420
|
-
await new ErdoClient().addWorkstreamPhase(slug, {
|
|
4421
|
-
slug: opts.phaseSlug,
|
|
4422
|
-
title: opts.title,
|
|
4423
|
-
skill_slug: opts.skill
|
|
4424
|
-
})
|
|
4425
|
-
);
|
|
4426
|
-
} catch (e) {
|
|
4427
|
-
fail(e);
|
|
4428
|
-
}
|
|
4429
|
-
}
|
|
4430
|
-
);
|
|
4431
|
-
wsCmd.command("set-state <slug>").description("Update a workstream's status / title / description / phase statuses").option("--status <status>", "active, awaiting_user, blocked, completed").option("--title <title>", "retitle").option("--description <text>", "describe current state / surface a blocker").option(
|
|
4426
|
+
wsCmd.command("set-state <slug>").description("Update a workstream's status / title / description").option("--status <status>", "active, awaiting_user, blocked, completed").option("--title <title>", "retitle").option("--description <text>", "describe current state / surface a blocker").option(
|
|
4432
4427
|
"--token-budget <millicents>",
|
|
4433
4428
|
"spend ceiling in millicents \u2014 100,000 per dollar, so 25000000 = $250; this is how you raise a ceiling a loop has spent through",
|
|
4434
4429
|
(v) => parseInt(v, 10)
|
|
4435
|
-
).option("--escalation-budget <n>", "max urgent attention items per rolling 24h", (v) => parseInt(v, 10)).
|
|
4436
|
-
"--phase <slug=status>",
|
|
4437
|
-
"set one phase's status (repeatable), e.g. --phase brand-brief=completed --phase landing-pages=running; statuses: pending, running, awaiting_user, blocked, completed, skipped, failed",
|
|
4438
|
-
collect,
|
|
4439
|
-
[]
|
|
4440
|
-
).action(
|
|
4430
|
+
).option("--escalation-budget <n>", "max urgent attention items per rolling 24h", (v) => parseInt(v, 10)).action(
|
|
4441
4431
|
async (slug, opts) => {
|
|
4442
4432
|
try {
|
|
4443
|
-
const phaseUpdates = opts.phase.map((raw) => {
|
|
4444
|
-
const eq = raw.indexOf("=");
|
|
4445
|
-
const phaseSlug = eq < 0 ? raw : raw.slice(0, eq);
|
|
4446
|
-
const status = eq < 0 ? "" : raw.slice(eq + 1);
|
|
4447
|
-
if (!phaseSlug || !status) {
|
|
4448
|
-
throw new Error(`--phase expects <slug>=<status>, got "${raw}"`);
|
|
4449
|
-
}
|
|
4450
|
-
return { slug: phaseSlug, status };
|
|
4451
|
-
});
|
|
4452
4433
|
print(
|
|
4453
4434
|
await new ErdoClient().updateWorkState(slug, {
|
|
4454
4435
|
status: opts.status,
|
|
4455
4436
|
title: opts.title,
|
|
4456
4437
|
description: opts.description,
|
|
4457
4438
|
token_budget_millicents: opts.tokenBudget,
|
|
4458
|
-
escalation_budget_per_day: opts.escalationBudget
|
|
4459
|
-
phase_updates: phaseUpdates.length > 0 ? phaseUpdates : void 0
|
|
4439
|
+
escalation_budget_per_day: opts.escalationBudget
|
|
4460
4440
|
})
|
|
4461
4441
|
);
|
|
4462
4442
|
} catch (e) {
|
|
@@ -4519,7 +4499,7 @@ wsCmd.command("recommendations <slug>").description("Read resolved recommendatio
|
|
|
4519
4499
|
fail(e);
|
|
4520
4500
|
}
|
|
4521
4501
|
});
|
|
4522
|
-
wsCmd.command("attach <slug>").description("Link a resource (page, dataset, heartbeat, experiment_run, \u2026) to a workstream").requiredOption("--type <resourceType>", "resource type (page, dataset, heartbeat, experiment_run, \u2026)").requiredOption("--id <resourceId>", "the resource's UUID").requiredOption("--rel <relationshipType>", "output | input | evidence | monitoring | subject | parent | child | running").option("--title <title>", "optional label for the link").
|
|
4502
|
+
wsCmd.command("attach <slug>").description("Link a resource (page, dataset, heartbeat, experiment_run, \u2026) to a workstream").requiredOption("--type <resourceType>", "resource type (page, dataset, heartbeat, experiment_run, \u2026)").requiredOption("--id <resourceId>", "the resource's UUID").requiredOption("--rel <relationshipType>", "output | input | evidence | monitoring | subject | parent | child | running").option("--title <title>", "optional label for the link").action(
|
|
4523
4503
|
async (slug, opts) => {
|
|
4524
4504
|
try {
|
|
4525
4505
|
print(
|
|
@@ -4527,8 +4507,7 @@ wsCmd.command("attach <slug>").description("Link a resource (page, dataset, hear
|
|
|
4527
4507
|
resource_type: opts.type,
|
|
4528
4508
|
resource_id: opts.id,
|
|
4529
4509
|
relationship_type: opts.rel,
|
|
4530
|
-
title: opts.title
|
|
4531
|
-
phase_id: opts.phase
|
|
4510
|
+
title: opts.title
|
|
4532
4511
|
})
|
|
4533
4512
|
);
|
|
4534
4513
|
} catch (e) {
|
|
@@ -6460,14 +6439,13 @@ program.command("activity").alias("feed").description(
|
|
|
6460
6439
|
).option("-n, --limit <n>", "max items (default 20, max 100)", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).option(
|
|
6461
6440
|
"--categories <list>",
|
|
6462
6441
|
"comma-separated: attention,approval,workstream,catalog,job,heartbeat (default: attention,approval,workstream)"
|
|
6463
|
-
).option("--
|
|
6442
|
+
).option("--workstream <slug>", "only this workstream").option("--json", "raw JSON response").action(
|
|
6464
6443
|
async (opts) => {
|
|
6465
6444
|
try {
|
|
6466
6445
|
const feed = await new ErdoClient().listActivityFeed({
|
|
6467
6446
|
limit: opts.limit,
|
|
6468
6447
|
offset: opts.offset,
|
|
6469
6448
|
categories: opts.categories,
|
|
6470
|
-
scope: opts.scope,
|
|
6471
6449
|
workstream_slug: opts.workstream
|
|
6472
6450
|
});
|
|
6473
6451
|
if (opts.json) {
|
|
@@ -8757,6 +8735,68 @@ datasetsCmd.command("write <slug>").description(
|
|
|
8757
8735
|
}
|
|
8758
8736
|
}
|
|
8759
8737
|
);
|
|
8738
|
+
var DELETE_ROWS_BATCH = 100;
|
|
8739
|
+
function parseDeleteKeys(raw) {
|
|
8740
|
+
const text = (readMaybeFile(raw) ?? "").trim();
|
|
8741
|
+
let keys;
|
|
8742
|
+
if (text.startsWith("[")) {
|
|
8743
|
+
try {
|
|
8744
|
+
keys = JSON.parse(text);
|
|
8745
|
+
} catch (error) {
|
|
8746
|
+
throw new Error(`--keys JSON must be valid: ${error instanceof Error ? error.message : String(error)}`);
|
|
8747
|
+
}
|
|
8748
|
+
if (!Array.isArray(keys) || keys.some((key) => typeof key !== "string" && typeof key !== "number")) {
|
|
8749
|
+
throw new Error("--keys JSON must be an array of strings");
|
|
8750
|
+
}
|
|
8751
|
+
keys = keys.map(String);
|
|
8752
|
+
} else {
|
|
8753
|
+
keys = text.split("\n");
|
|
8754
|
+
}
|
|
8755
|
+
const cleaned = [...new Set(keys.map((key) => key.trim()).filter(Boolean))];
|
|
8756
|
+
if (cleaned.length === 0) {
|
|
8757
|
+
throw new Error("--keys names no keys");
|
|
8758
|
+
}
|
|
8759
|
+
return cleaned;
|
|
8760
|
+
}
|
|
8761
|
+
datasetsCmd.command("delete-rows <slug>").description(
|
|
8762
|
+
"Permanently delete rows from a dataset (the erdo_delete_dataset_rows MCP tool): every row whose --key-column equals one of --keys, or with --all every row. Deleted rows also leave the change history, so restore-row cannot bring them back: fetch them first if you may want them. Nothing is deleted without --yes"
|
|
8763
|
+
).option("--key-column <column>", "the column to match --keys against").option("--keys <keys-or-@file>", "keys to delete: a JSON array, or one key per line; @path reads a file").option("--all", "delete every row instead of named keys").option("--yes", "confirm the permanent deletion").action(async (slug, opts) => {
|
|
8764
|
+
try {
|
|
8765
|
+
const keyColumn = opts.keyColumn?.trim();
|
|
8766
|
+
if (opts.all && (keyColumn || opts.keys !== void 0)) {
|
|
8767
|
+
throw new Error("--all cannot be combined with --key-column or --keys");
|
|
8768
|
+
}
|
|
8769
|
+
if (!opts.all && (!keyColumn || opts.keys === void 0)) {
|
|
8770
|
+
throw new Error("name the rows to delete with --key-column and --keys, or pass --all to delete every row");
|
|
8771
|
+
}
|
|
8772
|
+
const keys = opts.all ? [] : parseDeleteKeys(opts.keys);
|
|
8773
|
+
if (!opts.yes) {
|
|
8774
|
+
throw new Error(
|
|
8775
|
+
opts.all ? `deleting every row of ${slug} is permanent; rerun with --yes to delete them` : `deleting up to ${keys.length} key(s) from ${slug} is permanent; rerun with --yes to delete them`
|
|
8776
|
+
);
|
|
8777
|
+
}
|
|
8778
|
+
const client = new ErdoClient();
|
|
8779
|
+
if (opts.all) {
|
|
8780
|
+
print(await client.deleteDatasetRows(slug, { delete_all: true }));
|
|
8781
|
+
return;
|
|
8782
|
+
}
|
|
8783
|
+
let rowsAffected = 0;
|
|
8784
|
+
for (let start = 0; start < keys.length; start += DELETE_ROWS_BATCH) {
|
|
8785
|
+
const batch = keys.slice(start, start + DELETE_ROWS_BATCH);
|
|
8786
|
+
try {
|
|
8787
|
+
rowsAffected += (await client.deleteDatasetRows(slug, { key_column: keyColumn, keys: batch })).rows_affected;
|
|
8788
|
+
} catch (error) {
|
|
8789
|
+
if (start > 0) {
|
|
8790
|
+
console.error(`deleted ${rowsAffected} row(s) for the first ${start} of ${keys.length} keys before this failure`);
|
|
8791
|
+
}
|
|
8792
|
+
throw error;
|
|
8793
|
+
}
|
|
8794
|
+
}
|
|
8795
|
+
print({ rows_affected: rowsAffected, keys_requested: keys.length });
|
|
8796
|
+
} catch (e) {
|
|
8797
|
+
fail(e);
|
|
8798
|
+
}
|
|
8799
|
+
});
|
|
8760
8800
|
function readSchemaFile(path) {
|
|
8761
8801
|
const parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
8762
8802
|
const schema = Array.isArray(parsed) ? { columns: parsed } : parsed;
|