@erdoai/cli 0.43.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 +38 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -788,14 +788,18 @@ var ErdoClient = class {
788
788
  }
789
789
  // --- automations (heartbeats) ---
790
790
  listHeartbeats() {
791
- return this.request(
792
- "GET",
793
- "/v1/heartbeats"
794
- );
791
+ return this.request("GET", "/v1/heartbeats");
795
792
  }
796
793
  runHeartbeat(id) {
797
794
  return this.request("POST", `/v1/heartbeats/${encodeURIComponent(id)}/run`, {});
798
795
  }
796
+ updateHeartbeat(id, body) {
797
+ return this.request(
798
+ "PATCH",
799
+ `/v1/heartbeats/${encodeURIComponent(id)}`,
800
+ body
801
+ );
802
+ }
799
803
  setHeartbeatState(id, state) {
800
804
  return this.request(
801
805
  "POST",
@@ -3177,6 +3181,36 @@ autoCmd.command("run <id>").description("Trigger an automation now").action(asyn
3177
3181
  fail(e);
3178
3182
  }
3179
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
+ );
3180
3214
  autoCmd.command("disable <id>").description("Disable an automation so it stops running").action(async (id) => {
3181
3215
  try {
3182
3216
  const h = await new ErdoClient().setHeartbeatState(id, "disabled");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {