@cfio/cohort-sync 0.11.4 → 0.11.5

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
@@ -2722,6 +2722,22 @@ async function reconcileRoster(openClawAgents, cfg, logger) {
2722
2722
  const agentName = (cfg.agentNameMap?.[oc.id] ?? oc.identity?.name ?? oc.id).toLowerCase();
2723
2723
  const existing = cohortByName.get(agentName);
2724
2724
  if (!existing) {
2725
+ if (agentName === oc.id.toLowerCase() && oc.identity?.name) {
2726
+ const identityName = oc.identity.name.toLowerCase();
2727
+ if (cohortByName.has(identityName)) {
2728
+ logger.info(`cohort-sync: skipping phantom "${agentName}" \u2014 agent exists as "${identityName}"`);
2729
+ continue;
2730
+ }
2731
+ }
2732
+ if (agentName === oc.id.toLowerCase() && cohortByName.size > 0) {
2733
+ const alreadyRegistered = cohortAgents.some(
2734
+ (ca) => openClawNames.has(ca.name.toLowerCase()) && ca.name.toLowerCase() !== agentName
2735
+ );
2736
+ if (alreadyRegistered) {
2737
+ logger.info(`cohort-sync: skipping raw-ID agent "${agentName}" \u2014 identity-resolved agent already exists`);
2738
+ continue;
2739
+ }
2740
+ }
2725
2741
  try {
2726
2742
  await v1Post(cfg.apiUrl, cfg.apiKey, "/api/v1/agents", {
2727
2743
  name: agentName,
@@ -13334,7 +13350,7 @@ function dumpCtx(ctx) {
13334
13350
  function dumpEvent(event) {
13335
13351
  return dumpCtx(event);
13336
13352
  }
13337
- var PLUGIN_VERSION = true ? "0.11.4" : "unknown";
13353
+ var PLUGIN_VERSION = true ? "0.11.5" : "unknown";
13338
13354
  function resolveGatewayToken(api) {
13339
13355
  const token = api.config?.gateway?.auth?.token;
13340
13356
  return typeof token === "string" ? token : null;
@@ -13515,7 +13531,8 @@ async function handleGatewayStart(event, state) {
13515
13531
  logger.debug("cohort-sync: no gateway token");
13516
13532
  logger.warn("cohort-sync: no gateway auth token \u2014 cron operations disabled");
13517
13533
  }
13518
- const allAgentIds = ["main", ...(config?.agents?.list ?? []).map((a) => a.id)];
13534
+ const configIds = (config?.agents?.list ?? []).map((a) => a.id);
13535
+ const allAgentIds = configIds.includes("main") ? configIds : ["main", ...configIds];
13519
13536
  const resolvedNameMap = {};
13520
13537
  for (const agentId of allAgentIds) {
13521
13538
  resolvedNameMap[agentId] = state.resolveAgentName(agentId);
@@ -13954,7 +13971,8 @@ function registerHookHandlers(api, logger, getState) {
13954
13971
  state.keepaliveInterval = null;
13955
13972
  }
13956
13973
  state.activityBatch.drain();
13957
- const allAgentIds = ["main", ...(config?.agents?.list ?? []).map((a) => a.id)];
13974
+ const shutdownConfigIds = (config?.agents?.list ?? []).map((a) => a.id);
13975
+ const allAgentIds = shutdownConfigIds.includes("main") ? shutdownConfigIds : ["main", ...shutdownConfigIds];
13958
13976
  for (const agentId of allAgentIds) {
13959
13977
  const agentName = state.resolveAgentName(agentId);
13960
13978
  try {
@@ -13992,16 +14010,19 @@ function initializeHookState(api, cfg) {
13992
14010
  createClient(convexUrl);
13993
14011
  setLogger(logger);
13994
14012
  const identityNameMap = {};
13995
- const mainIdentity = parseIdentityFile(process.cwd());
13996
- if (mainIdentity?.name) {
13997
- identityNameMap["main"] = mainIdentity.name.toLowerCase();
13998
- }
13999
14013
  for (const agent of config?.agents?.list ?? []) {
14000
- const identity = resolveIdentity(agent.identity, agent.workspace);
14014
+ const workspaceDir = agent.workspace ?? (agent.id === "main" ? process.cwd() : void 0);
14015
+ const identity = resolveIdentity(agent.identity, workspaceDir);
14001
14016
  if (identity?.name) {
14002
14017
  identityNameMap[agent.id] = identity.name.toLowerCase();
14003
14018
  }
14004
14019
  }
14020
+ if (!identityNameMap["main"]) {
14021
+ const mainIdentity = parseIdentityFile(process.cwd());
14022
+ if (mainIdentity?.name) {
14023
+ identityNameMap["main"] = mainIdentity.name.toLowerCase();
14024
+ }
14025
+ }
14005
14026
  logger.debug("cohort-sync: identity name map", { identityNameMap });
14006
14027
  function resolveAgentName(agentId) {
14007
14028
  return (nameMap?.[agentId] ?? identityNameMap[agentId] ?? agentId).toLowerCase();
@@ -55,5 +55,5 @@
55
55
  }
56
56
  }
57
57
  },
58
- "version": "0.11.4"
58
+ "version": "0.11.5"
59
59
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "OpenClaw plugin — syncs agent telemetry, sessions, and activity to the 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.11.4",
3
+ "version": "0.11.5",
4
4
  "description": "OpenClaw plugin — syncs agent telemetry, sessions, and activity to the Cohort dashboard",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.cohort.bot/gateway",