@cfio/cohort-sync 0.26.0 → 0.28.0

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
@@ -12375,8 +12375,13 @@ function buildConnectFrame(id, token, pluginVersion, identity, nonce) {
12375
12375
  id,
12376
12376
  method: "connect",
12377
12377
  params: {
12378
+ // OpenClaw 2026.5.x bumped the gateway WebSocket protocol from v3 → v4
12379
+ // (see openclaw dist message-handler: `expectedProtocol: 4`). The
12380
+ // server requires `maxProtocol >= 4`. We advertise support for both
12381
+ // v3 and v4 so the same client works against older servers too;
12382
+ // openclaw negotiates the highest mutually-supported version.
12378
12383
  minProtocol: 3,
12379
- maxProtocol: 3,
12384
+ maxProtocol: 4,
12380
12385
  client: {
12381
12386
  id: "gateway-client",
12382
12387
  version: pluginVersion,
@@ -12523,7 +12528,7 @@ var GatewayClient = class {
12523
12528
  this.deviceIdentity,
12524
12529
  challengeNonce
12525
12530
  );
12526
- this.logger.debug("cohort-sync: sending connect", { id, protocol: 3 });
12531
+ this.logger.debug("cohort-sync: sending connect", { id, minProtocol: 3, maxProtocol: 4 });
12527
12532
  ws.send(JSON.stringify(frame));
12528
12533
  const onHelloMessage = (event) => {
12529
12534
  try {
@@ -12548,7 +12553,7 @@ var GatewayClient = class {
12548
12553
  if (result.snapshot) {
12549
12554
  this.emit("snapshot", result.snapshot);
12550
12555
  }
12551
- this.logger.info("cohort-sync: gateway client connected (protocol v3)");
12556
+ this.logger.info("cohort-sync: gateway client connected");
12552
12557
  settle();
12553
12558
  } catch (err) {
12554
12559
  this.logger.debug("cohort-sync: hello failed", { error: String(err) });
@@ -13130,6 +13135,48 @@ function buildActivityEntry(agentName, hook, context) {
13130
13135
  model
13131
13136
  };
13132
13137
  }
13138
+ case "model_call_ended": {
13139
+ const outcome = context.outcome;
13140
+ if (outcome !== "error") return null;
13141
+ const errorCategory = context.errorCategory;
13142
+ const provider = context.provider;
13143
+ const failureKind = context.failureKind;
13144
+ const durationMs = context.durationMs;
13145
+ let text;
13146
+ let summary;
13147
+ const where = provider ?? "the LLM provider";
13148
+ if (errorCategory === "auth") {
13149
+ text = `${name} couldn't reach ${where} \u2014 API key rejected. Update it in Settings.`;
13150
+ summary = `${where} API key invalid`;
13151
+ } else if (errorCategory === "rate_limit") {
13152
+ text = `${name} was rate-limited by ${where}.`;
13153
+ summary = `${where} rate limit`;
13154
+ } else if (errorCategory === "overloaded" || errorCategory === "unavailable") {
13155
+ text = `${name} couldn't reach ${where} \u2014 service unavailable.`;
13156
+ summary = `${where} unavailable`;
13157
+ } else if (failureKind === "timeout") {
13158
+ text = `${name}'s LLM call to ${where} timed out.`;
13159
+ summary = `${where} timeout`;
13160
+ } else if (failureKind) {
13161
+ text = `${name}'s LLM call to ${where} failed (${failureKind}).`;
13162
+ summary = `${where} ${failureKind}`;
13163
+ } else {
13164
+ text = `${name}'s LLM call to ${where} failed${errorCategory ? ` (${errorCategory})` : ""}.`;
13165
+ summary = `${where} error${errorCategory ? `: ${errorCategory}` : ""}`;
13166
+ }
13167
+ return {
13168
+ agentName,
13169
+ text,
13170
+ category: "system",
13171
+ timestamp: ts,
13172
+ hook,
13173
+ sessionKey,
13174
+ model,
13175
+ durationMs,
13176
+ error: true,
13177
+ errorSummary: summary
13178
+ };
13179
+ }
13133
13180
  default:
13134
13181
  return null;
13135
13182
  }
@@ -13426,7 +13473,7 @@ function dumpCtx(ctx) {
13426
13473
  function dumpEvent(event) {
13427
13474
  return dumpCtx(event);
13428
13475
  }
13429
- var PLUGIN_VERSION = true ? "0.26.0" : "unknown";
13476
+ var PLUGIN_VERSION = true ? "0.28.0" : "unknown";
13430
13477
  function resolveGatewayToken(api) {
13431
13478
  const token = api.config?.gateway?.auth?.token;
13432
13479
  return typeof token === "string" ? token : null;
@@ -13800,6 +13847,33 @@ function registerHookHandlers(api, logger, getState) {
13800
13847
  log.warn(`cohort-sync: agent_end sync failed: ${String(err)}`);
13801
13848
  }
13802
13849
  });
13850
+ api.on("model_call_ended", async (event, ctx) => {
13851
+ const state = getState();
13852
+ if (!state) return;
13853
+ if (event?.outcome !== "error") return;
13854
+ const { logger: log } = state;
13855
+ log.debug("cohort-sync: hook: model_call_ended (error)", {
13856
+ provider: event.provider,
13857
+ errorCategory: event.errorCategory,
13858
+ failureKind: event.failureKind
13859
+ });
13860
+ try {
13861
+ const agentId = ctx.agentId ?? "main";
13862
+ const agentName = state.resolveAgentName(agentId);
13863
+ const entry = buildActivityEntry(agentName, "model_call_ended", {
13864
+ outcome: event.outcome,
13865
+ errorCategory: event.errorCategory,
13866
+ failureKind: event.failureKind,
13867
+ provider: event.provider,
13868
+ model: event.model,
13869
+ durationMs: event.durationMs,
13870
+ sessionKey: ctx.sessionKey
13871
+ });
13872
+ if (entry) state.activityBatch.add(entry);
13873
+ } catch (err) {
13874
+ log.warn(`cohort-sync: model_call_ended sync failed: ${String(err)}`);
13875
+ }
13876
+ });
13803
13877
  api.on("llm_output", async (event, ctx) => {
13804
13878
  const state = getState();
13805
13879
  if (!state) return;
@@ -72,5 +72,5 @@
72
72
  }
73
73
  }
74
74
  },
75
- "version": "0.26.0"
75
+ "version": "0.28.0"
76
76
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
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.26.0",
3
+ "version": "0.28.0",
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",