@erdoai/cli 0.47.0 → 0.49.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.
Files changed (2) hide show
  1. package/dist/index.js +96 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -246,6 +246,9 @@ var ErdoClient = class {
246
246
  listOrganizations() {
247
247
  return this.request("GET", "/v1/organizations");
248
248
  }
249
+ createOrganization(input) {
250
+ return this.request("POST", "/v1/organizations", input);
251
+ }
249
252
  // --- API tokens (user credentials; default_org is only the header-absent fallback) ---
250
253
  createToken(input) {
251
254
  return this.request("POST", "/v1/tokens", input);
@@ -544,6 +547,7 @@ var ErdoClient = class {
544
547
  const q = new URLSearchParams();
545
548
  for (const s of params?.statuses ?? []) q.append("statuses", s);
546
549
  if (params?.engine_actions_only) q.set("engine_actions_only", "true");
550
+ if (params?.item_id) q.set("item_id", params.item_id);
547
551
  if (params?.limit) q.set("limit", String(params.limit));
548
552
  if (params?.offset) q.set("offset", String(params.offset));
549
553
  const qs = q.toString();
@@ -898,6 +902,13 @@ var ErdoClient = class {
898
902
  `/v1/approvals${qs ? `?${qs}` : ""}`
899
903
  );
900
904
  }
905
+ // One request in full — the itemized projection, the recorded reason, and the
906
+ // scope options a decision is made against, where the list is sized for
907
+ // scanning. A request belonging to another organization reads as 404, so an id
908
+ // cannot be probed for existence.
909
+ getApproval(id) {
910
+ return this.request("GET", `/v1/approvals/${encodeURIComponent(id)}`);
911
+ }
901
912
  decideApproval(id, input) {
902
913
  return this.request(
903
914
  "POST",
@@ -1254,6 +1265,7 @@ function awaitingApprovalMessage(threadID) {
1254
1265
  return [
1255
1266
  "the run paused for approval.",
1256
1267
  " erdo approvals list --status pending",
1268
+ " erdo approvals show <id>",
1257
1269
  " erdo approvals decide <id> --approve",
1258
1270
  ` erdo agent wait ${threadID}`
1259
1271
  ].join("\n");
@@ -1435,6 +1447,27 @@ org.command("use [idOrSlug]").description("Set the active org for the current ac
1435
1447
  fail(e);
1436
1448
  }
1437
1449
  });
1450
+ org.command("create <name>").description("Create a new organization").option("--slug <slug>", "desired slug (generated from the name if omitted, trying numeric suffixes on collision)").option("--use", "switch the active org to the new one after creation").action(async (name, opts) => {
1451
+ try {
1452
+ const o = await new ErdoClient().createOrganization({
1453
+ name,
1454
+ slug: opts.slug,
1455
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
1456
+ });
1457
+ console.log(`Created org: ${o.name}`);
1458
+ console.log(`slug: ${o.slug}
1459
+ id: ${o.id}`);
1460
+ if (opts.use) {
1461
+ updateActiveAccount({ organizationId: o.id, organizationName: o.name });
1462
+ console.log(`Active org: ${o.name}`);
1463
+ } else {
1464
+ process.stderr.write(`Switch to it with: erdo org use ${o.slug}
1465
+ `);
1466
+ }
1467
+ } catch (e) {
1468
+ fail(e);
1469
+ }
1470
+ });
1438
1471
  org.command("autonomy [mode]").description("Show or set the org's engine-autonomy mode (autopilot | propose | strict)").action(async (mode) => {
1439
1472
  try {
1440
1473
  const api = new ErdoClient();
@@ -2433,6 +2466,67 @@ approvalsCmd.command("list").description("List approval requests, optionally fil
2433
2466
  }
2434
2467
  }
2435
2468
  );
2469
+ function renderApproval(r) {
2470
+ console.log(r.action_headline || r.action_display);
2471
+ const facts = [["status", r.status]];
2472
+ if (r.decision_class) facts.push(["decision", r.decision_class]);
2473
+ if (r.subject_display_name) {
2474
+ facts.push(["subject", r.subject_display_name]);
2475
+ } else if (r.subject_resource_type && r.subject_resource_id) {
2476
+ facts.push(["subject", `${r.subject_resource_type} ${r.subject_resource_id}`]);
2477
+ }
2478
+ if (r.occurrence_count && r.occurrence_count > 1) {
2479
+ facts.push([
2480
+ "proposed",
2481
+ `${r.occurrence_count}\xD7 since ${r.first_proposed_at ?? r.created_at}`
2482
+ ]);
2483
+ }
2484
+ facts.push(["created", r.created_at]);
2485
+ if (r.decided_at) facts.push(["decided", r.decided_at]);
2486
+ if (r.expires_at) facts.push(["expires", r.expires_at]);
2487
+ for (const [label, value] of facts) {
2488
+ console.log(` ${label.padEnd(9)} ${value}`);
2489
+ }
2490
+ if (r.action_context) {
2491
+ console.log("");
2492
+ console.log(`Reason: ${r.action_context}`);
2493
+ }
2494
+ const items = r.action_items ?? [];
2495
+ if (items.length) {
2496
+ console.log("");
2497
+ console.log(items.length === 1 ? "Action:" : `Actions (${items.length}):`);
2498
+ items.forEach((item, i) => {
2499
+ console.log(` ${i + 1}. ${item.what}`);
2500
+ if (item.why) console.log(` why: ${item.why}`);
2501
+ for (const [key, value] of Object.entries(item.params_compact ?? {})) {
2502
+ console.log(` ${key}: ${value}`);
2503
+ }
2504
+ });
2505
+ }
2506
+ if (r.omitted_items && r.omitted_items > 0) {
2507
+ console.log(` \u2026 and ${r.omitted_items} more actions`);
2508
+ }
2509
+ const options = r.scope_options ?? [];
2510
+ if (options.length) {
2511
+ console.log("");
2512
+ console.log("Scope options (`erdo approvals decide --option N`):");
2513
+ options.forEach((o, i) => console.log(` ${i + 1}. ${o.label}`));
2514
+ }
2515
+ }
2516
+ approvalsCmd.command("show <id>").description(
2517
+ "Show one approval request in full: the outcome headline, the actions it covers with the reason each was proposed, the subject it acts on, and the scope options a standing decision can use"
2518
+ ).option("--json", "output raw JSON").action(async (id, opts) => {
2519
+ try {
2520
+ const req = await new ErdoClient().getApproval(id);
2521
+ if (opts.json) {
2522
+ print(req);
2523
+ return;
2524
+ }
2525
+ renderApproval(req);
2526
+ } catch (e) {
2527
+ fail(e);
2528
+ }
2529
+ });
2436
2530
  approvalsCmd.command("decide <id>").description("Approve or reject a pending approval request").option("--approve", "approve the request").option("--reject", "reject the request").option(
2437
2531
  "--scope <scope>",
2438
2532
  "once (default) | always_this_job | always_this_workstream | always_org | always_user",
@@ -2489,7 +2583,7 @@ ${listing}`);
2489
2583
  }
2490
2584
  );
2491
2585
  var attnCmd = program.command("attention").description("The attention feed \u2014 digests, choices, escalations awaiting a human");
2492
- attnCmd.command("list").description("List attention items").option("--status <status...>", "open | answered | dismissed | expired").option("--open", "shorthand for --status open").option("--engine-actions", "only engine-generated items").option("-n, --limit <n>", "max items", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(
2586
+ attnCmd.command("list").description("List attention items").option("--status <status...>", "open | answered | dismissed | expired").option("--open", "shorthand for --status open").option("--engine-actions", "only engine-generated items").option("--item <idOrSlug>", "read one item: its slug or its uuid").option("-n, --limit <n>", "max items", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(
2493
2587
  async (opts) => {
2494
2588
  try {
2495
2589
  const statuses = opts.status?.length ? opts.status : opts.open ? ["open"] : void 0;
@@ -2497,6 +2591,7 @@ attnCmd.command("list").description("List attention items").option("--status <st
2497
2591
  await new ErdoClient().listAttentionItems({
2498
2592
  statuses,
2499
2593
  engine_actions_only: opts.engineActions,
2594
+ item_id: opts.item,
2500
2595
  limit: opts.limit,
2501
2596
  offset: opts.offset
2502
2597
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.47.0",
3
+ "version": "0.49.0",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {