@erdoai/cli 0.42.0 → 0.44.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 +48 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -772,8 +772,11 @@ var ErdoClient = class {
772
772
  );
773
773
  }
774
774
  // --- knowledge ---
775
- listKnowledge() {
776
- return this.request("GET", "/v1/knowledge");
775
+ listKnowledge(visibility) {
776
+ const params = new URLSearchParams();
777
+ if (visibility) params.set("visibility", visibility);
778
+ const qs = params.toString();
779
+ return this.request("GET", `/v1/knowledge${qs ? `?${qs}` : ""}`);
777
780
  }
778
781
  searchKnowledge(query, limit) {
779
782
  const params = new URLSearchParams({ query });
@@ -785,14 +788,18 @@ var ErdoClient = class {
785
788
  }
786
789
  // --- automations (heartbeats) ---
787
790
  listHeartbeats() {
788
- return this.request(
789
- "GET",
790
- "/v1/heartbeats"
791
- );
791
+ return this.request("GET", "/v1/heartbeats");
792
792
  }
793
793
  runHeartbeat(id) {
794
794
  return this.request("POST", `/v1/heartbeats/${encodeURIComponent(id)}/run`, {});
795
795
  }
796
+ updateHeartbeat(id, body) {
797
+ return this.request(
798
+ "PATCH",
799
+ `/v1/heartbeats/${encodeURIComponent(id)}`,
800
+ body
801
+ );
802
+ }
796
803
  setHeartbeatState(id, state) {
797
804
  return this.request(
798
805
  "POST",
@@ -3132,9 +3139,12 @@ pipelinesCmd.command("executions <slug>").description("Show an event pipeline's
3132
3139
  }
3133
3140
  });
3134
3141
  var knowledgeCmd = program.command("knowledge").description("Knowledge objects");
3135
- knowledgeCmd.command("list").description("List knowledge objects").action(async () => {
3142
+ knowledgeCmd.command("list").description("List knowledge objects").option(
3143
+ "--public",
3144
+ "only entries opted into anonymous external surfaces (website widgets)"
3145
+ ).action(async (opts) => {
3136
3146
  try {
3137
- print(await new ErdoClient().listKnowledge());
3147
+ print(await new ErdoClient().listKnowledge(opts.public ? "public" : void 0));
3138
3148
  } catch (e) {
3139
3149
  fail(e);
3140
3150
  }
@@ -3171,6 +3181,36 @@ autoCmd.command("run <id>").description("Trigger an automation now").action(asyn
3171
3181
  fail(e);
3172
3182
  }
3173
3183
  });
3184
+ autoCmd.command("update <id>").description("Edit an automation \u2014 rename, reschedule, or replace its script/instructions").option("--name <name>", "New name").option("--description <text>", "New description").option("--instructions <text>", "Replacement instructions (agent automation)").option("--script-js <js>", "Replacement script body (scripted automation)").option(
3185
+ "--script-file <path>",
3186
+ "Read the replacement script body from a file (scripted automation)"
3187
+ ).option("--interval <minutes>", "New interval in minutes (minimum 5)", (v) => parseInt(v, 10)).option("--timezone <tz>", "New scheduling timezone, e.g. America/New_York").action(
3188
+ async (id, opts) => {
3189
+ try {
3190
+ if (opts.scriptJs && opts.scriptFile) {
3191
+ fail(new Error("pass either --script-js or --script-file, not both"));
3192
+ return;
3193
+ }
3194
+ const scriptJs = opts.scriptFile ? readFileSync2(opts.scriptFile, "utf8") : opts.scriptJs;
3195
+ const body = {
3196
+ name: opts.name,
3197
+ description: opts.description,
3198
+ instructions: opts.instructions,
3199
+ script_js: scriptJs,
3200
+ interval_minutes: opts.interval,
3201
+ timezone: opts.timezone
3202
+ };
3203
+ if (Object.values(body).every((v) => v === void 0)) {
3204
+ fail(new Error("nothing to update \u2014 pass at least one field to change"));
3205
+ return;
3206
+ }
3207
+ const h = await new ErdoClient().updateHeartbeat(id, body);
3208
+ console.log(`${h.id} ${h.state} ${h.name}`);
3209
+ } catch (e) {
3210
+ fail(e);
3211
+ }
3212
+ }
3213
+ );
3174
3214
  autoCmd.command("disable <id>").description("Disable an automation so it stops running").action(async (id) => {
3175
3215
  try {
3176
3216
  const h = await new ErdoClient().setHeartbeatState(id, "disabled");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.42.0",
4
- "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
3
+ "version": "0.44.0",
4
+ "description": "Erdo CLI drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "erdo": "dist/index.js"