@cfio/cohort-sync 0.1.2 → 0.1.7

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
@@ -11791,6 +11791,22 @@ async function v1Post(apiUrl, apiKey, path2, body) {
11791
11791
  });
11792
11792
  if (!res.ok) throw new Error(`POST ${path2} \u2192 ${res.status}`);
11793
11793
  }
11794
+ async function checkForUpdate(currentVersion, logger) {
11795
+ try {
11796
+ const res = await fetch("https://registry.npmjs.org/@cfio/cohort-sync/latest", {
11797
+ signal: AbortSignal.timeout(5e3)
11798
+ });
11799
+ if (!res.ok) return;
11800
+ const data = await res.json();
11801
+ const latest = data.version;
11802
+ if (latest && latest !== currentVersion) {
11803
+ logger.warn(
11804
+ `cohort-sync: update available (${currentVersion} \u2192 ${latest}) \u2014 run "npm install -g @cfio/cohort-sync" to update`
11805
+ );
11806
+ }
11807
+ } catch {
11808
+ }
11809
+ }
11794
11810
  async function syncAgentStatus(agentName, status, model, cfg, logger) {
11795
11811
  try {
11796
11812
  const data = await v1Get(cfg.apiUrl, cfg.apiKey, "/api/v1/agents?limit=100");
@@ -12120,6 +12136,13 @@ function registerHooks(api, cfg) {
12120
12136
  logger.info(`cohort-sync: heartbeat pushed for ${allAgentIds.length} agents`);
12121
12137
  }
12122
12138
  api.on("gateway_start", async (event) => {
12139
+ try {
12140
+ const pkgPath = path.join(path.dirname(new URL(import.meta.url).pathname), "package.json");
12141
+ const pkgJson = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
12142
+ checkForUpdate(pkgJson.version, logger).catch(() => {
12143
+ });
12144
+ } catch {
12145
+ }
12123
12146
  try {
12124
12147
  const agentList = (config?.agents?.list ?? []).map((a) => ({
12125
12148
  id: a.id,
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.1.2",
3
+ "version": "0.1.7",
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.1.2",
3
+ "version": "0.1.7",
4
4
  "description": "Syncs agent status and skills to Cohort dashboard",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.cohort.bot/gateway",