@saleso.innovations/bridge 0.1.14 → 0.1.15

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.
package/README.md CHANGED
@@ -34,7 +34,7 @@ This installs the latest package, refreshes the CLI symlink, and restarts `cleos
34
34
  To pin a specific release (e.g. after a Cleos update):
35
35
 
36
36
  ```bash
37
- curl -fsSL https://amicable-elephant-407.convex.site/update-bridge.sh | bash -s -- 0.1.14
37
+ curl -fsSL https://amicable-elephant-407.convex.site/update-bridge.sh | bash -s -- 0.1.15
38
38
  ```
39
39
 
40
40
  ## Manual usage
@@ -0,0 +1,5 @@
1
+ export type ListHermesCronJobsOptions = {
2
+ all?: boolean;
3
+ };
4
+ export declare function listHermesCronJobs(options?: ListHermesCronJobsOptions): Promise<unknown>;
5
+ //# sourceMappingURL=cronList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cronList.d.ts","sourceRoot":"","sources":["../src/cronList.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AA6CF,wBAAsB,kBAAkB,CACtC,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,OAAO,CAAC,CAelB"}
@@ -0,0 +1,62 @@
1
+ import { execFile } from "node:child_process";
2
+ import { readFileSync, existsSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { promisify } from "node:util";
6
+ const execFileAsync = promisify(execFile);
7
+ const HERMES_CRON_JOBS_FILE = join(homedir(), ".hermes", "cron", "jobs.json");
8
+ const LIST_TIMEOUT_MS = 30_000;
9
+ const MAX_OUTPUT_BYTES = 10 * 1024 * 1024;
10
+ function normalizeJobsPayload(value) {
11
+ if (Array.isArray(value)) {
12
+ return { jobs: value };
13
+ }
14
+ if (value && typeof value === "object") {
15
+ const record = value;
16
+ for (const key of ["jobs", "items", "data", "results"]) {
17
+ if (Array.isArray(record[key])) {
18
+ return { jobs: record[key] };
19
+ }
20
+ }
21
+ return value;
22
+ }
23
+ return { jobs: [] };
24
+ }
25
+ function readJobsFromFile() {
26
+ if (!existsSync(HERMES_CRON_JOBS_FILE)) {
27
+ return { jobs: [] };
28
+ }
29
+ const raw = readFileSync(HERMES_CRON_JOBS_FILE, "utf8");
30
+ return normalizeJobsPayload(JSON.parse(raw));
31
+ }
32
+ async function runHermesCronListJson(all) {
33
+ const args = ["cron", "list"];
34
+ if (all)
35
+ args.push("--all");
36
+ args.push("--json");
37
+ try {
38
+ const { stdout } = await execFileAsync("hermes", args, {
39
+ timeout: LIST_TIMEOUT_MS,
40
+ maxBuffer: MAX_OUTPUT_BYTES,
41
+ env: process.env,
42
+ });
43
+ const trimmed = stdout.trim();
44
+ if (!trimmed)
45
+ return null;
46
+ return normalizeJobsPayload(JSON.parse(trimmed));
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ export async function listHermesCronJobs(options = {}) {
53
+ const includeAll = options.all === true;
54
+ const jsonResult = await runHermesCronListJson(includeAll);
55
+ if (jsonResult != null) {
56
+ return jsonResult;
57
+ }
58
+ if (includeAll) {
59
+ return readJobsFromFile();
60
+ }
61
+ throw new Error("Could not list Hermes cron jobs. Ensure `hermes` is installed and supports `hermes cron list --json`.");
62
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"hermesCommands.d.ts","sourceRoot":"","sources":["../src/hermesCommands.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,qYAwBvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,iBAAiB,CAE7E;AAED,MAAM,MAAM,sBAAsB,GAC9B,qBAAqB,GACrB,oBAAoB,GACpB,uBAAuB,GACvB,sBAAsB,GACtB,qBAAqB,CAAC;AAE1B,qBAAa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AC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GACjE,OAAO,CAAC,OAAO,CAAC,CAkKlB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,sBAAsB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAetG"}
@@ -1,5 +1,6 @@
1
1
  import { resolveHermesApiConfig } from "./hermesForwarder.js";
2
2
  import { restartHermesGateway, startHermesGateway, stopHermesGateway } from "./gatewayControl.js";
3
+ import { listHermesCronJobs } from "./cronList.js";
3
4
  import { runHermesUpdate } from "./hermesUpdate.js";
4
5
  export const HERMES_COMMAND_NAMES = [
5
6
  "runtime.health",
@@ -177,8 +178,13 @@ export async function executeHermesCommand(command, args, options = {}) {
177
178
  body: JSON.stringify({}),
178
179
  });
179
180
  }
180
- case "jobs.list":
181
+ case "jobs.list": {
182
+ const includeAll = args.all === true || args.includeInactive === true;
183
+ if (includeAll) {
184
+ return await listHermesCronJobs({ all: true });
185
+ }
181
186
  return await hermesFetchJson(config, "/api/jobs");
187
+ }
182
188
  case "jobs.get": {
183
189
  const jobId = requireString(args, "jobId");
184
190
  return await hermesFetchJson(config, `/api/jobs/${encodeURIComponent(jobId)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saleso.innovations/bridge",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Connect your Hermes agent to the Cleos iOS app via pairing code.",
5
5
  "type": "module",
6
6
  "license": "MIT",