@cfio/cohort-sync 0.1.1 → 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 +25 -2
- package/dist/package.json +1 -1
- package/package.json +1 -1
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");
|
|
@@ -11843,11 +11859,11 @@ async function reconcileRoster(openClawAgents, cfg, logger) {
|
|
|
11843
11859
|
const openClawNames = new Set(
|
|
11844
11860
|
openClawAgents.map((a) => {
|
|
11845
11861
|
const nameMap = cfg.agentNameMap;
|
|
11846
|
-
return (nameMap?.[a.id] ?? a.id).toLowerCase();
|
|
11862
|
+
return (nameMap?.[a.id] ?? a.identity?.name ?? a.id).toLowerCase();
|
|
11847
11863
|
})
|
|
11848
11864
|
);
|
|
11849
11865
|
for (const oc of openClawAgents) {
|
|
11850
|
-
const agentName = (cfg.agentNameMap?.[oc.id] ?? oc.id).toLowerCase();
|
|
11866
|
+
const agentName = (cfg.agentNameMap?.[oc.id] ?? oc.identity?.name ?? oc.id).toLowerCase();
|
|
11851
11867
|
const existing = cohortByName.get(agentName);
|
|
11852
11868
|
if (!existing) {
|
|
11853
11869
|
try {
|
|
@@ -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