@erdoai/cli 0.23.1 → 0.25.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 +98 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -427,6 +427,32 @@ var ErdoClient = class {
427
427
  input
428
428
  );
429
429
  }
430
+ // --- knowledge review queue ---
431
+ listReviewItems(params) {
432
+ const q = new URLSearchParams();
433
+ if (params?.status !== void 0) q.set("status", params.status);
434
+ if (params?.type) q.set("type", params.type);
435
+ if (params?.limit) q.set("limit", String(params.limit));
436
+ if (params?.offset) q.set("offset", String(params.offset));
437
+ const qs = q.toString();
438
+ return this.request(
439
+ "GET",
440
+ `/v1/review-items${qs ? `?${qs}` : ""}`
441
+ );
442
+ }
443
+ getReviewItem(id) {
444
+ return this.request(
445
+ "GET",
446
+ `/v1/review-items/${encodeURIComponent(id)}`
447
+ );
448
+ }
449
+ decideReviewItem(id, input) {
450
+ return this.request(
451
+ "POST",
452
+ `/v1/review-items/${encodeURIComponent(id)}/decide`,
453
+ input
454
+ );
455
+ }
430
456
  // --- agents ---
431
457
  ask(input) {
432
458
  return this.request("POST", "/v1/ask", input);
@@ -922,13 +948,13 @@ function awaitingApprovalMessage(threadID) {
922
948
  "the run paused for approval.",
923
949
  " erdo approvals list --status pending",
924
950
  " erdo approvals decide <id> --approve",
925
- ` erdo agent messages ${threadID}`
951
+ ` erdo agent wait ${threadID}`
926
952
  ].join("\n");
927
953
  }
928
954
  function timedOutMessage(threadID) {
929
955
  return [
930
956
  "timed out waiting for the run to finish \u2014 it is still running on its thread.",
931
- ` erdo agent messages ${threadID}`,
957
+ ` erdo agent wait ${threadID}`,
932
958
  ` erdo runs list --thread ${threadID}`
933
959
  ].join("\n");
934
960
  }
@@ -1831,6 +1857,22 @@ agentCmd.command("send <threadId> <message>").description("Send a message to a t
1831
1857
  fail(e);
1832
1858
  }
1833
1859
  });
1860
+ agentCmd.command("wait <threadId>").description("Re-attach to a thread's latest run and wait for it to finish; prints the answer").action(async (threadId) => {
1861
+ try {
1862
+ const client = new ErdoClient();
1863
+ process.stderr.write("waiting\u2026");
1864
+ const run = await client.waitForThreadRun(threadId, {
1865
+ onTick: () => process.stderr.write(".")
1866
+ });
1867
+ process.stderr.write("\n");
1868
+ if (!run) throw new Error(timedOutMessage(threadId));
1869
+ if (run.status === "awaiting_approval") throw new Error(awaitingApprovalMessage(threadId));
1870
+ if (run.error) throw new Error(run.error);
1871
+ console.log(run.output || `(status: ${run.status})`);
1872
+ } catch (e) {
1873
+ fail(e);
1874
+ }
1875
+ });
1834
1876
  agentCmd.command("thread").description("Create a thread; prints its id").option("-n, --name <name>", "thread name").option("-d, --datasets <csv>", "dataset UUIDs to attach").action(async (opts) => {
1835
1877
  try {
1836
1878
  const res = await new ErdoClient().createThread({
@@ -1966,6 +2008,60 @@ attnCmd.command("respond <id>").description(
1966
2008
  fail(e);
1967
2009
  }
1968
2010
  });
2011
+ var reviewsCmd = program.command("reviews").description(
2012
+ "The Knowledge Review queue \u2014 knowledge patches the critic proposes, investigations, and deduplicated failure signals awaiting a human decision"
2013
+ );
2014
+ reviewsCmd.command("list").description("List review items (decision items rank above failure signals)").option("--status <status>", "open (default) | snoozed | resolved | rejected | '' for all").option("--type <type>", "filter by type, e.g. knowledge_patch, eval_failure, failed_run").option("-n, --limit <n>", "max items", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(
2015
+ async (opts) => {
2016
+ try {
2017
+ print(
2018
+ await new ErdoClient().listReviewItems({
2019
+ status: opts.status,
2020
+ type: opts.type,
2021
+ limit: opts.limit,
2022
+ offset: opts.offset
2023
+ })
2024
+ );
2025
+ } catch (e) {
2026
+ fail(e);
2027
+ }
2028
+ }
2029
+ );
2030
+ reviewsCmd.command("show <id>").description("Show one review item with its full payload (the proposed patch body for a knowledge_patch)").action(async (id) => {
2031
+ try {
2032
+ print(await new ErdoClient().getReviewItem(id));
2033
+ } catch (e) {
2034
+ fail(e);
2035
+ }
2036
+ });
2037
+ reviewsCmd.command("decide <id>").description(
2038
+ "Decide a review item: --apply a knowledge patch (mutates Knowledge, then resolves), --resolve, --reject, or --snooze [minutes]"
2039
+ ).option("--apply", "apply a knowledge_patch: create/update the proposed Knowledge object, then resolve").option("--resolve", "close as handled").option("--reject", "close as declined").option("--snooze [minutes]", "hide the item for [minutes] (default 7 days)").option("--note <note>", "resolution note recorded on the item").action(
2040
+ async (id, opts) => {
2041
+ try {
2042
+ const chosen = [
2043
+ opts.apply ? "apply" : null,
2044
+ opts.resolve ? "resolve" : null,
2045
+ opts.reject ? "reject" : null,
2046
+ opts.snooze !== void 0 ? "snooze" : null
2047
+ ].filter(Boolean);
2048
+ if (chosen.length !== 1) {
2049
+ fail(new Error("provide exactly one of --apply, --resolve, --reject, or --snooze"));
2050
+ }
2051
+ const action = chosen[0];
2052
+ let minutes;
2053
+ if (action === "snooze" && typeof opts.snooze === "string") {
2054
+ minutes = parseInt(opts.snooze, 10);
2055
+ if (Number.isNaN(minutes)) {
2056
+ throw new Error("--snooze minutes must be a number");
2057
+ }
2058
+ }
2059
+ print(await new ErdoClient().decideReviewItem(id, { action, minutes, note: opts.note }));
2060
+ } catch (e) {
2061
+ fail(e);
2062
+ }
2063
+ }
2064
+ );
1969
2065
  var pagesCmd = program.command("pages").description("Create and manage pages/artifacts");
1970
2066
  function readMaybeFile(v) {
1971
2067
  if (!v) return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.23.1",
3
+ "version": "0.25.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {