@cfio/cohort-sync 0.4.2 → 0.4.4

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/dist/index.js CHANGED
@@ -88,8 +88,8 @@ var init_keychain = __esm({
88
88
  });
89
89
 
90
90
  // src/hooks.ts
91
- import fs from "node:fs";
92
- import path from "node:path";
91
+ import fs2 from "node:fs";
92
+ import path2 from "node:path";
93
93
 
94
94
  // ../../node_modules/.pnpm/@sinclair+typebox@0.34.48/node_modules/@sinclair/typebox/build/esm/type/guard/value.mjs
95
95
  var value_exports = {};
@@ -2699,6 +2699,9 @@ var Type = type_exports2;
2699
2699
 
2700
2700
  // src/sync.ts
2701
2701
  import { execSync } from "node:child_process";
2702
+ import fs from "node:fs";
2703
+ import os from "node:os";
2704
+ import path from "node:path";
2702
2705
 
2703
2706
  // ../../node_modules/.pnpm/convex@1.33.0_patch_hash=l43bztwr6e2lbmpd6ao6hmcg24_react@19.2.1/node_modules/convex/dist/esm/index.js
2704
2707
  var version = "1.33.0";
@@ -4554,12 +4557,12 @@ function createApi(pathParts = []) {
4554
4557
  `API path is expected to be of the form \`api.moduleName.functionName\`. Found: \`${found}\``
4555
4558
  );
4556
4559
  }
4557
- const path2 = pathParts.slice(0, -1).join("/");
4560
+ const path3 = pathParts.slice(0, -1).join("/");
4558
4561
  const exportName = pathParts[pathParts.length - 1];
4559
4562
  if (exportName === "default") {
4560
- return path2;
4563
+ return path3;
4561
4564
  } else {
4562
- return path2 + ":" + exportName;
4565
+ return path3 + ":" + exportName;
4563
4566
  }
4564
4567
  } else if (prop === Symbol.toStringTag) {
4565
4568
  return "FunctionReference";
@@ -7628,16 +7631,16 @@ var require_constants = __commonJS({
7628
7631
  });
7629
7632
  var require_node_gyp_build = __commonJS({
7630
7633
  "../common/temp/node_modules/.pnpm/node-gyp-build@4.8.4/node_modules/node-gyp-build/node-gyp-build.js"(exports, module) {
7631
- var fs2 = __require("fs");
7632
- var path2 = __require("path");
7633
- var os = __require("os");
7634
+ var fs3 = __require("fs");
7635
+ var path3 = __require("path");
7636
+ var os2 = __require("os");
7634
7637
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
7635
7638
  var vars = process.config && process.config.variables || {};
7636
7639
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
7637
7640
  var abi = process.versions.modules;
7638
7641
  var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
7639
- var arch = process.env.npm_config_arch || os.arch();
7640
- var platform = process.env.npm_config_platform || os.platform();
7642
+ var arch = process.env.npm_config_arch || os2.arch();
7643
+ var platform = process.env.npm_config_platform || os2.platform();
7641
7644
  var libc = process.env.LIBC || (isAlpine(platform) ? "musl" : "glibc");
7642
7645
  var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
7643
7646
  var uv = (process.versions.uv || "").split(".")[0];
@@ -7646,21 +7649,21 @@ var require_node_gyp_build = __commonJS({
7646
7649
  return runtimeRequire(load.resolve(dir));
7647
7650
  }
7648
7651
  load.resolve = load.path = function(dir) {
7649
- dir = path2.resolve(dir || ".");
7652
+ dir = path3.resolve(dir || ".");
7650
7653
  try {
7651
- var name = runtimeRequire(path2.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
7654
+ var name = runtimeRequire(path3.join(dir, "package.json")).name.toUpperCase().replace(/-/g, "_");
7652
7655
  if (process.env[name + "_PREBUILD"]) dir = process.env[name + "_PREBUILD"];
7653
7656
  } catch (err) {
7654
7657
  }
7655
7658
  if (!prebuildsOnly) {
7656
- var release = getFirst(path2.join(dir, "build/Release"), matchBuild);
7659
+ var release = getFirst(path3.join(dir, "build/Release"), matchBuild);
7657
7660
  if (release) return release;
7658
- var debug = getFirst(path2.join(dir, "build/Debug"), matchBuild);
7661
+ var debug = getFirst(path3.join(dir, "build/Debug"), matchBuild);
7659
7662
  if (debug) return debug;
7660
7663
  }
7661
7664
  var prebuild = resolve(dir);
7662
7665
  if (prebuild) return prebuild;
7663
- var nearby = resolve(path2.dirname(process.execPath));
7666
+ var nearby = resolve(path3.dirname(process.execPath));
7664
7667
  if (nearby) return nearby;
7665
7668
  var target = [
7666
7669
  "platform=" + platform,
@@ -7677,26 +7680,26 @@ var require_node_gyp_build = __commonJS({
7677
7680
  ].filter(Boolean).join(" ");
7678
7681
  throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
7679
7682
  function resolve(dir2) {
7680
- var tuples = readdirSync(path2.join(dir2, "prebuilds")).map(parseTuple);
7683
+ var tuples = readdirSync(path3.join(dir2, "prebuilds")).map(parseTuple);
7681
7684
  var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0];
7682
7685
  if (!tuple) return;
7683
- var prebuilds = path2.join(dir2, "prebuilds", tuple.name);
7686
+ var prebuilds = path3.join(dir2, "prebuilds", tuple.name);
7684
7687
  var parsed = readdirSync(prebuilds).map(parseTags);
7685
7688
  var candidates = parsed.filter(matchTags(runtime, abi));
7686
7689
  var winner = candidates.sort(compareTags(runtime))[0];
7687
- if (winner) return path2.join(prebuilds, winner.file);
7690
+ if (winner) return path3.join(prebuilds, winner.file);
7688
7691
  }
7689
7692
  };
7690
7693
  function readdirSync(dir) {
7691
7694
  try {
7692
- return fs2.readdirSync(dir);
7695
+ return fs3.readdirSync(dir);
7693
7696
  } catch (err) {
7694
7697
  return [];
7695
7698
  }
7696
7699
  }
7697
7700
  function getFirst(dir, filter) {
7698
7701
  var files = readdirSync(dir).filter(filter);
7699
- return files[0] && path2.join(dir, files[0]);
7702
+ return files[0] && path3.join(dir, files[0]);
7700
7703
  }
7701
7704
  function matchBuild(name) {
7702
7705
  return /\.node$/.test(name);
@@ -7783,7 +7786,7 @@ var require_node_gyp_build = __commonJS({
7783
7786
  return typeof window !== "undefined" && window.process && window.process.type === "renderer";
7784
7787
  }
7785
7788
  function isAlpine(platform2) {
7786
- return platform2 === "linux" && fs2.existsSync("/etc/alpine-release");
7789
+ return platform2 === "linux" && fs3.existsSync("/etc/alpine-release");
7787
7790
  }
7788
7791
  load.parseTags = parseTags;
7789
7792
  load.matchTags = matchTags;
@@ -11928,7 +11931,7 @@ function fetchSkills(logger) {
11928
11931
  try {
11929
11932
  const raw = execSync("openclaw skills list --json", {
11930
11933
  encoding: "utf8",
11931
- timeout: 1e4,
11934
+ timeout: 3e4,
11932
11935
  stdio: ["ignore", "pipe", "ignore"],
11933
11936
  env: { ...process.env, NO_COLOR: "1" }
11934
11937
  });
@@ -11947,26 +11950,22 @@ function fetchSkills(logger) {
11947
11950
  }
11948
11951
  function fetchCronJobs(logger) {
11949
11952
  try {
11950
- const raw = execSync("openclaw cron list --all --json", {
11951
- encoding: "utf8",
11952
- timeout: 1e4,
11953
- stdio: ["ignore", "pipe", "ignore"],
11954
- env: { ...process.env, NO_COLOR: "1" }
11955
- });
11956
- const parsed = JSON.parse(extractJson(raw));
11957
- const list = Array.isArray(parsed) ? parsed : parsed?.jobs ?? [];
11958
- return list.map((j) => ({
11959
- id: String(j.jobId ?? j.id ?? "unknown"),
11960
- text: String(j.name ?? j.text ?? ""),
11953
+ const storePath = path.join(os.homedir(), ".openclaw", "cron", "jobs.json");
11954
+ const raw = fs.readFileSync(storePath, "utf-8");
11955
+ const parsed = JSON.parse(raw);
11956
+ const jobs = Array.isArray(parsed?.jobs) ? parsed.jobs : [];
11957
+ return jobs.map((j) => ({
11958
+ id: String(j.id ?? "unknown"),
11959
+ text: String(j.name ?? ""),
11961
11960
  schedule: formatSchedule(j.schedule),
11962
- ...j.nextRunAt != null ? { nextRun: Number(j.nextRunAt) } : {},
11963
- ...j.lastRunAt != null ? { lastRun: Number(j.lastRunAt) } : {},
11964
- ...j.lastStatus ? { lastStatus: String(j.lastStatus) } : {},
11961
+ ...j.state?.nextRunAtMs != null ? { nextRun: Number(j.state.nextRunAtMs) } : {},
11962
+ ...j.state?.lastRunAtMs != null ? { lastRun: Number(j.state.lastRunAtMs) } : {},
11963
+ ...j.state?.lastStatus ? { lastStatus: String(j.state.lastStatus) } : {},
11965
11964
  enabled: j.enabled !== false,
11966
11965
  ...j.agentId != null ? { agentId: String(j.agentId) } : {}
11967
11966
  }));
11968
11967
  } catch (err) {
11969
- logger.warn(`cohort-sync: failed to fetch cron jobs: ${String(err)}`);
11968
+ logger.warn(`cohort-sync: failed to read cron store: ${String(err)}`);
11970
11969
  return null;
11971
11970
  }
11972
11971
  }
@@ -11987,31 +11986,31 @@ var VALID_STATUSES = /* @__PURE__ */ new Set(["idle", "working", "waiting"]);
11987
11986
  function normalizeStatus(status) {
11988
11987
  return VALID_STATUSES.has(status) ? status : "idle";
11989
11988
  }
11990
- async function v1Get(apiUrl, apiKey, path2) {
11991
- const res = await fetch(`${apiUrl.replace(/\/+$/, "")}${path2}`, {
11989
+ async function v1Get(apiUrl, apiKey, path3) {
11990
+ const res = await fetch(`${apiUrl.replace(/\/+$/, "")}${path3}`, {
11992
11991
  headers: { Authorization: `Bearer ${apiKey}` },
11993
11992
  signal: AbortSignal.timeout(1e4)
11994
11993
  });
11995
- if (!res.ok) throw new Error(`GET ${path2} \u2192 ${res.status}`);
11994
+ if (!res.ok) throw new Error(`GET ${path3} \u2192 ${res.status}`);
11996
11995
  return res.json();
11997
11996
  }
11998
- async function v1Patch(apiUrl, apiKey, path2, body) {
11999
- const res = await fetch(`${apiUrl.replace(/\/+$/, "")}${path2}`, {
11997
+ async function v1Patch(apiUrl, apiKey, path3, body) {
11998
+ const res = await fetch(`${apiUrl.replace(/\/+$/, "")}${path3}`, {
12000
11999
  method: "PATCH",
12001
12000
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
12002
12001
  body: JSON.stringify(body),
12003
12002
  signal: AbortSignal.timeout(1e4)
12004
12003
  });
12005
- if (!res.ok) throw new Error(`PATCH ${path2} \u2192 ${res.status}`);
12004
+ if (!res.ok) throw new Error(`PATCH ${path3} \u2192 ${res.status}`);
12006
12005
  }
12007
- async function v1Post(apiUrl, apiKey, path2, body) {
12008
- const res = await fetch(`${apiUrl.replace(/\/+$/, "")}${path2}`, {
12006
+ async function v1Post(apiUrl, apiKey, path3, body) {
12007
+ const res = await fetch(`${apiUrl.replace(/\/+$/, "")}${path3}`, {
12009
12008
  method: "POST",
12010
12009
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
12011
12010
  body: JSON.stringify(body),
12012
12011
  signal: AbortSignal.timeout(1e4)
12013
12012
  });
12014
- if (!res.ok) throw new Error(`POST ${path2} \u2192 ${res.status}`);
12013
+ if (!res.ok) throw new Error(`POST ${path3} \u2192 ${res.status}`);
12015
12014
  }
12016
12015
  async function checkForUpdate(currentVersion, logger) {
12017
12016
  try {
@@ -12688,7 +12687,7 @@ function diag(label, data) {
12688
12687
  const line = `[${ts}] ${label}${payload}
12689
12688
  `;
12690
12689
  try {
12691
- fs.appendFileSync(DIAG_LOG_PATH, line);
12690
+ fs2.appendFileSync(DIAG_LOG_PATH, line);
12692
12691
  } catch {
12693
12692
  }
12694
12693
  }
@@ -12716,16 +12715,16 @@ function dumpEvent(event) {
12716
12715
  }
12717
12716
  var PLUGIN_VERSION = "unknown";
12718
12717
  try {
12719
- const pkgPath = path.join(path.dirname(new URL(import.meta.url).pathname), "package.json");
12720
- const pkgJson = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
12718
+ const pkgPath = path2.join(path2.dirname(new URL(import.meta.url).pathname), "package.json");
12719
+ const pkgJson = JSON.parse(fs2.readFileSync(pkgPath, "utf8"));
12721
12720
  PLUGIN_VERSION = pkgJson.version ?? "unknown";
12722
12721
  } catch {
12723
12722
  }
12724
12723
  diag("MODULE_LOADED", { BUILD_ID, PLUGIN_VERSION });
12725
12724
  function parseIdentityFile(workspaceDir) {
12726
12725
  try {
12727
- const filePath = path.join(workspaceDir, "IDENTITY.md");
12728
- const content = fs.readFileSync(filePath, "utf-8");
12726
+ const filePath = path2.join(workspaceDir, "IDENTITY.md");
12727
+ const content = fs2.readFileSync(filePath, "utf-8");
12729
12728
  const identity = {};
12730
12729
  for (const line of content.split(/\r?\n/)) {
12731
12730
  const cleaned = line.trim().replace(/^\s*-\s*/, "");
@@ -12763,8 +12762,8 @@ function getOrCreateTracker() {
12763
12762
  state.tracker = fresh;
12764
12763
  return fresh;
12765
12764
  }
12766
- var STATE_FILE_PATH = path.join(
12767
- path.dirname(new URL(import.meta.url).pathname),
12765
+ var STATE_FILE_PATH = path2.join(
12766
+ path2.dirname(new URL(import.meta.url).pathname),
12768
12767
  ".session-state.json"
12769
12768
  );
12770
12769
  function saveSessionsToDisk(tracker) {
@@ -12781,14 +12780,14 @@ function saveSessionsToDisk(tracker) {
12781
12780
  data.sessions.push({ agentName: name, key });
12782
12781
  }
12783
12782
  }
12784
- fs.writeFileSync(STATE_FILE_PATH, JSON.stringify(data));
12783
+ fs2.writeFileSync(STATE_FILE_PATH, JSON.stringify(data));
12785
12784
  } catch {
12786
12785
  }
12787
12786
  }
12788
12787
  function loadSessionsFromDisk(tracker, logger) {
12789
12788
  try {
12790
- if (!fs.existsSync(STATE_FILE_PATH)) return;
12791
- const data = JSON.parse(fs.readFileSync(STATE_FILE_PATH, "utf8"));
12789
+ if (!fs2.existsSync(STATE_FILE_PATH)) return;
12790
+ const data = JSON.parse(fs2.readFileSync(STATE_FILE_PATH, "utf8"));
12792
12791
  if (Date.now() - new Date(data.savedAt).getTime() > 864e5) {
12793
12792
  logger.info("cohort-sync: disk session state too old (>24h), skipping");
12794
12793
  return;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Syncs agent status and skills to Cohort dashboard",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Syncs agent status and skills to Cohort dashboard",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.cohort.bot/gateway",