@cfio/cohort-sync 0.11.2 → 0.11.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
@@ -12034,7 +12034,7 @@ async function injectNotification(port, hooksToken, n, agentId = "main") {
12034
12034
  }
12035
12035
  var deliveryFailures = /* @__PURE__ */ new Map();
12036
12036
  var MAX_DELIVERY_ATTEMPTS = 3;
12037
- async function startNotificationSubscription(port, cfg, hooksToken, logger, gwClient) {
12037
+ async function startNotificationSubscription(port, cfg, hooksToken, logger, gwClient, resolvedNameMap) {
12038
12038
  const c = getClient();
12039
12039
  if (!c) {
12040
12040
  logger.warn("cohort-sync: no ConvexClient \u2014 notification subscription skipped");
@@ -12045,15 +12045,15 @@ async function startNotificationSubscription(port, cfg, hooksToken, logger, gwCl
12045
12045
  `cohort-sync: hooks.token not configured \u2014 real-time notifications disabled (telemetry will still be pushed).`
12046
12046
  );
12047
12047
  }
12048
- const agentNames = cfg.agentNameMap ? Object.values(cfg.agentNameMap) : ["main"];
12049
- const reverseNameMap = {};
12050
- if (cfg.agentNameMap) {
12051
- for (const [openclawId, cohortName] of Object.entries(cfg.agentNameMap)) {
12052
- reverseNameMap[cohortName] = openclawId;
12048
+ const sourceMap = resolvedNameMap ?? cfg.agentNameMap ?? { main: "main" };
12049
+ const subscriptionTargets = /* @__PURE__ */ new Map();
12050
+ for (const [openclawId, cohortName] of Object.entries(sourceMap)) {
12051
+ subscriptionTargets.set(cohortName, openclawId);
12052
+ if (openclawId !== cohortName) {
12053
+ subscriptionTargets.set(openclawId, openclawId);
12053
12054
  }
12054
12055
  }
12055
- for (const agentName of agentNames) {
12056
- const openclawAgentId = reverseNameMap[agentName] ?? agentName;
12056
+ for (const [agentName, openclawAgentId] of subscriptionTargets) {
12057
12057
  logger.info(`cohort-sync: subscribing to notifications for agent "${agentName}" (openclawId: "${openclawAgentId}")`);
12058
12058
  let processing = false;
12059
12059
  const apiKeyHash = hashApiKey(cfg.apiKey);
@@ -13334,7 +13334,7 @@ function dumpCtx(ctx) {
13334
13334
  function dumpEvent(event) {
13335
13335
  return dumpCtx(event);
13336
13336
  }
13337
- var PLUGIN_VERSION = true ? "0.11.2" : "unknown";
13337
+ var PLUGIN_VERSION = true ? "0.11.4" : "unknown";
13338
13338
  function resolveGatewayToken(api) {
13339
13339
  const token = api.config?.gateway?.auth?.token;
13340
13340
  return typeof token === "string" ? token : null;
@@ -13515,16 +13515,21 @@ async function handleGatewayStart(event, state) {
13515
13515
  logger.debug("cohort-sync: no gateway token");
13516
13516
  logger.warn("cohort-sync: no gateway auth token \u2014 cron operations disabled");
13517
13517
  }
13518
+ const allAgentIds = ["main", ...(config?.agents?.list ?? []).map((a) => a.id)];
13519
+ const resolvedNameMap = {};
13520
+ for (const agentId of allAgentIds) {
13521
+ resolvedNameMap[agentId] = state.resolveAgentName(agentId);
13522
+ }
13518
13523
  await startNotificationSubscription(
13519
13524
  event.port,
13520
13525
  cfg,
13521
13526
  api.config.hooks?.token,
13522
13527
  logger,
13523
- state.persistentGwClient
13528
+ state.persistentGwClient,
13529
+ resolvedNameMap
13524
13530
  ).catch((err) => {
13525
13531
  logger.error(`cohort-sync: subscription init failed: ${String(err)}`);
13526
13532
  });
13527
- const allAgentIds = ["main", ...(config?.agents?.list ?? []).map((a) => a.id)];
13528
13533
  for (const agentId of allAgentIds) {
13529
13534
  const agentName = state.resolveAgentName(agentId);
13530
13535
  try {
@@ -55,5 +55,5 @@
55
55
  }
56
56
  }
57
57
  },
58
- "version": "0.11.2"
58
+ "version": "0.11.4"
59
59
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
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.2",
3
+ "version": "0.11.4",
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",