@erdoai/cli 0.224.0 → 0.225.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 +36 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2547,9 +2547,12 @@ var ErdoClient = class {
2547
2547
  if (audience) body.audience = audience;
2548
2548
  return this.request("POST", "/v1/page-reviews", body);
2549
2549
  }
2550
- reviewAd(input) {
2550
+ reviewCritic(input) {
2551
2551
  return this.request("POST", "/v1/critic/reviews", input);
2552
2552
  }
2553
+ reviewAd(input) {
2554
+ return this.reviewCritic(input);
2555
+ }
2553
2556
  assessInvestigation(input) {
2554
2557
  return this.request("POST", "/v1/investigations", input);
2555
2558
  }
@@ -6867,16 +6870,35 @@ reviewsCmd.command("decide <id>").description(
6867
6870
  );
6868
6871
  var pagesCmd = program.command("pages").description("Create and manage pages/artifacts");
6869
6872
  var criticCmd = program.command("critic").description("Review campaign creative");
6870
- criticCmd.command("review").description("Review an ad creative request from a JSON file and print per-lens findings").requiredOption("-f, --file <path>", "JSON file containing the full critic review request envelope").option("--json", "print the complete raw JSON response").action(async (opts) => {
6871
- try {
6872
- const input = JSON.parse(readFileSync5(opts.file, "utf8"));
6873
- const result = await new ErdoClient().reviewAd(input);
6873
+ criticCmd.command("review").description("Review an ad or document and print per-lens findings").option("-f, --file <path>", "JSON file containing the full critic review request envelope").option("--text <text>", "Document text to review (use instead of --file)").option("--claims-dataset <slug>", "Claims dataset slug for document reviews").option("--wait", "Poll a running document review's run until it completes").option("--json", "print the complete raw JSON response").action(async (opts) => {
6874
+ try {
6875
+ if (!opts.file && !opts.text) throw new Error("provide --file or --text");
6876
+ const input = opts.text ? { subject_kind: "document", document: { text: opts.text, claims_dataset_slug: opts.claimsDataset } } : JSON.parse(readFileSync5(opts.file, "utf8"));
6877
+ const result = await new ErdoClient().reviewCritic(input);
6878
+ let finalResult = result;
6879
+ if (opts.wait && result.status === "running" && result.run_id) {
6880
+ for (; ; ) {
6881
+ await sleep2(5e3);
6882
+ const run = await new ErdoClient().getAgentRun(result.run_id);
6883
+ if (!["running", "pending", "queued"].includes(run.run.status)) {
6884
+ if (!run.run.output) throw new Error(run.run.error || `critic run ended with status ${run.run.status}`);
6885
+ finalResult = JSON.parse(run.run.output);
6886
+ break;
6887
+ }
6888
+ }
6889
+ }
6874
6890
  if (opts.json) {
6875
- print(result);
6891
+ print(finalResult);
6876
6892
  return;
6877
6893
  }
6878
- console.log(result.summary);
6879
- for (const lens of result.lenses) {
6894
+ if (finalResult.status === "running") {
6895
+ console.log("Review is running.");
6896
+ if (finalResult.run_id) console.log(`run id: ${finalResult.run_id}`);
6897
+ if (finalResult.review_thread_id) console.log(`review thread id: ${finalResult.review_thread_id}`);
6898
+ return;
6899
+ }
6900
+ console.log(finalResult.summary);
6901
+ for (const lens of finalResult.lenses) {
6880
6902
  console.log(`
6881
6903
  ${lens.lens_slug}: ${lens.summary}`);
6882
6904
  for (const finding of lens.findings) {
@@ -6884,7 +6906,13 @@ ${lens.lens_slug}: ${lens.summary}`);
6884
6906
  console.log(` Evidence: ${finding.evidence}`);
6885
6907
  console.log(` Suggested rewrite: ${finding.suggested_rewrite}`);
6886
6908
  }
6909
+ for (const claim of lens.claims ?? []) {
6910
+ console.log(` Claim ${claim.claim_id}: ${claim.verdict} \u2014 ${claim.claim}`);
6911
+ if (claim.note) console.log(` Note: ${claim.note}`);
6912
+ }
6887
6913
  }
6914
+ if (finalResult.usage) console.log(`
6915
+ Usage: ${JSON.stringify(finalResult.usage)}`);
6888
6916
  } catch (e) {
6889
6917
  fail(e);
6890
6918
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.224.0",
3
+ "version": "0.225.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {