@erdoai/cli 0.164.0 → 0.166.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 +59 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -986,6 +986,20 @@ var ErdoClient = class {
986
986
  `/v1/workstreams/${encodeURIComponent(slug)}/ledger${qs}`
987
987
  );
988
988
  }
989
+ async readWorkstreamRecommendations(slug) {
990
+ const ledger = await this.request("GET", `/v1/workstreams/${encodeURIComponent(slug)}/ledger`);
991
+ if (!Array.isArray(ledger.recommendations) || !ledger.recommendation_review) {
992
+ throw new Error("This connection does not expose the Recommendations contract yet.");
993
+ }
994
+ return ledger;
995
+ }
996
+ manageWorkstreamRecommendations(slug, input) {
997
+ return this.request(
998
+ "POST",
999
+ `/v1/workstreams/${encodeURIComponent(slug)}/recommendations`,
1000
+ input
1001
+ );
1002
+ }
989
1003
  attachWorkstreamResource(slug, input) {
990
1004
  return this.request(
991
1005
  "POST",
@@ -1971,6 +1985,7 @@ var ErdoClient = class {
1971
1985
  listApprovals(opts) {
1972
1986
  const params = new URLSearchParams();
1973
1987
  if (opts.status) params.set("status", opts.status);
1988
+ if (opts.agent_run_id) params.set("agent_run_id", opts.agent_run_id);
1974
1989
  if (opts.limit) params.set("limit", String(opts.limit));
1975
1990
  if (opts.workstream_slug) params.set("workstream_slug", opts.workstream_slug);
1976
1991
  if (opts.subject_resource_type) params.set("subject_resource_type", opts.subject_resource_type);
@@ -2029,6 +2044,13 @@ var ErdoClient = class {
2029
2044
  }
2030
2045
  // One decision in full. A slug belonging to another organization reads as 404,
2031
2046
  // so it cannot be probed for existence.
2047
+ retireDecision(slug, reason, organization_slug) {
2048
+ return this.request(
2049
+ "POST",
2050
+ `/v1/decisions/${encodeURIComponent(slug)}/retire`,
2051
+ { reason, organization_slug }
2052
+ );
2053
+ }
2032
2054
  getDecision(slug) {
2033
2055
  return this.request(
2034
2056
  "GET",
@@ -3733,6 +3755,26 @@ wsCmd.command("ledger <slug>").description(
3733
3755
  fail(e);
3734
3756
  }
3735
3757
  });
3758
+ wsCmd.command("recommendations <slug>").description("Read resolved recommendations and review state, or apply an exact JSON mutation").option("--input-file <path>", "JSON file containing the exact ManageRecommendationRequest body").action(async (slug, opts) => {
3759
+ try {
3760
+ const client = new ErdoClient();
3761
+ if (opts.inputFile) {
3762
+ const body = JSON.parse(readFileSync4(opts.inputFile, "utf8"));
3763
+ if (body === null || typeof body !== "object" || Array.isArray(body)) {
3764
+ throw new Error("--input-file must contain a JSON object");
3765
+ }
3766
+ print(await client.manageWorkstreamRecommendations(slug, body));
3767
+ return;
3768
+ }
3769
+ const ledger = await client.readWorkstreamRecommendations(slug);
3770
+ print({
3771
+ recommendations: ledger.recommendations,
3772
+ recommendation_review: ledger.recommendation_review
3773
+ });
3774
+ } catch (e) {
3775
+ fail(e);
3776
+ }
3777
+ });
3736
3778
  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").option("--phase <phaseId>", "optional phase to attach under").action(
3737
3779
  async (slug, opts) => {
3738
3780
  try {
@@ -5088,6 +5130,21 @@ function renderDecision(detail) {
5088
5130
  console.log(" The approval card could not be loaded.");
5089
5131
  }
5090
5132
  }
5133
+ decisionsCmd.command("retire <slug>").description("End a standing workstream commitment without changing provider state (admin or owner)").requiredOption("--reason <text>", "why this commitment is no longer applicable").option("--organization <slug>", "target organization, including an authorized managed client").option("--json", "output raw JSON").action(async (slug, opts) => {
5134
+ try {
5135
+ if (!opts.reason.trim()) throw new Error("--reason must not be blank");
5136
+ const result = await new ErdoClient().retireDecision(slug, opts.reason, opts.organization);
5137
+ if (opts.json) {
5138
+ print(result);
5139
+ return;
5140
+ }
5141
+ console.log(`${result.decision.slug} ${result.created ? "retired" : "already ended"}`);
5142
+ if (result.decision.superseded_by_decision_slug) console.log(`Superseded by: ${result.decision.superseded_by_decision_slug}`);
5143
+ if (result.decision.lapsed) console.log(`Lapsed at: ${result.decision.review_by}`);
5144
+ } catch (e) {
5145
+ fail(e);
5146
+ }
5147
+ });
5091
5148
  decisionsCmd.command("show <slug>").description(
5092
5149
  "Show one decision in full: the commitment and its authority, every exact action it authorized with how each one ended, every declared effect with the evidence that settled it, and what it replaced or was replaced by"
5093
5150
  ).option("--json", "output raw JSON").action(async (slug, opts) => {
@@ -5192,11 +5249,12 @@ var approvalsCmd = program.command("approvals").description("List and decide app
5192
5249
  approvalsCmd.command("list").description("List approval requests, optionally filtered by status").option("-s, --status <status>", "pending | approved | rejected | expired (default: all)").option("-l, --limit <n>", "max requests", (v) => parseInt(v, 10)).option("--workstream <slug>", "only approvals for this workstream").option(
5193
5250
  "--subject-type <type>",
5194
5251
  "only approvals whose subject resource is of this type (e.g. paid_media_campaign)"
5195
- ).option("--subject-id <id>", "only approvals whose subject resource has this id").option("--json", "output raw JSON").action(
5252
+ ).option("--subject-id <id>", "only approvals whose subject resource has this id").option("--agent-run-id <uuid>", "only approvals for this agent run").option("--json", "output raw JSON").action(
5196
5253
  async (opts) => {
5197
5254
  try {
5198
5255
  const res = await new ErdoClient().listApprovals({
5199
5256
  status: opts.status,
5257
+ agent_run_id: opts.agentRunId,
5200
5258
  limit: opts.limit,
5201
5259
  workstream_slug: opts.workstream,
5202
5260
  subject_resource_type: opts.subjectType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.164.0",
3
+ "version": "0.166.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {