@cfio/cohort-sync 0.31.3 → 0.31.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
@@ -13635,7 +13635,10 @@ function dumpCtx(ctx) {
13635
13635
  function dumpEvent(event) {
13636
13636
  return dumpCtx(event);
13637
13637
  }
13638
- var PLUGIN_VERSION = true ? "0.31.3" : "unknown";
13638
+ function positiveNumber(value) {
13639
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
13640
+ }
13641
+ var PLUGIN_VERSION = true ? "0.31.5" : "unknown";
13639
13642
  function resolveGatewayToken(api) {
13640
13643
  const token2 = api.config?.gateway?.auth?.token;
13641
13644
  return typeof token2 === "string" ? token2 : null;
@@ -13979,6 +13982,10 @@ function registerHookHandlers(api, logger, getState) {
13979
13982
  state.logger.debug("cohort-sync: resolve agent: result", { method: "fallback_main", resolved });
13980
13983
  return resolved;
13981
13984
  }
13985
+ function isHeartbeatCronSession(ctx) {
13986
+ const sessionKey = ctx.sessionKey ?? ctx.sessionId;
13987
+ return typeof sessionKey === "string" && sessionKey.includes(":cron:heartbeat");
13988
+ }
13982
13989
  api.on("agent_end", async (event, ctx) => {
13983
13990
  const state = getState();
13984
13991
  if (!state) return;
@@ -14051,6 +14058,15 @@ function registerHookHandlers(api, logger, getState) {
14051
14058
  if (!state) return;
14052
14059
  if (event?.outcome !== "error") return;
14053
14060
  const { logger: log } = state;
14061
+ if (isHeartbeatCronSession(ctx)) {
14062
+ log.debug("cohort-sync: suppressing heartbeat model error activity", {
14063
+ provider: event.provider,
14064
+ errorCategory: event.errorCategory,
14065
+ failureKind: event.failureKind,
14066
+ sessionKey: ctx.sessionKey
14067
+ });
14068
+ return;
14069
+ }
14054
14070
  log.debug("cohort-sync: hook: model_call_ended (error)", {
14055
14071
  provider: event.provider,
14056
14072
  errorCategory: event.errorCategory,
@@ -14078,7 +14094,8 @@ function registerHookHandlers(api, logger, getState) {
14078
14094
  const { cfg, tracker, logger: log } = state;
14079
14095
  const usage = normalizeLlmUsage(event.usage);
14080
14096
  const model = event.model ?? state.resolveModel(ctx.agentId ?? "main");
14081
- const contextLimit = state.getModelContextLimit(model);
14097
+ const contextLimit = positiveNumber(event.contextTokenBudget) ?? state.getModelContextLimit(model);
14098
+ const contextTokens = usage.contextTokens || positiveNumber(event.contextWindowReferenceTokens) || 0;
14082
14099
  const agentId = ctx.agentId ?? "main";
14083
14100
  const agentName = state.resolveAgentName(agentId);
14084
14101
  try {
@@ -14093,7 +14110,7 @@ function registerHookHandlers(api, logger, getState) {
14093
14110
  tokensOut: usage.outputTokens,
14094
14111
  cacheReadTokens: usage.cachedInputTokens,
14095
14112
  cacheWriteTokens: usage.cacheWriteTokens,
14096
- contextTokens: usage.contextTokens,
14113
+ contextTokens,
14097
14114
  contextLimit
14098
14115
  });
14099
14116
  tracker.updateSessionKey(agentName, sessionKey);
@@ -72,5 +72,5 @@
72
72
  }
73
73
  }
74
74
  },
75
- "version": "0.31.3"
75
+ "version": "0.31.5"
76
76
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.31.3",
3
+ "version": "0.31.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.31.3",
3
+ "version": "0.31.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",