@cfio/cohort-sync 0.27.0 → 0.29.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
@@ -11975,6 +11975,13 @@ var DEFAULT_BEHAVIORAL_PROMPT = `BEFORE RESPONDING:
11975
11975
  - Does your planned response address the task's stated scope? If not, do not comment.
11976
11976
  - Do not post acknowledgment-only responses ("got it", "sounds good", "confirmed"). If you have no new information to add, do not comment.
11977
11977
  - If the work is complete, transition the task to "waiting" and set noReply=true on your final comment, then stop working on this task.`;
11978
+ var ATMENTION_RESPONSE_PROMPT = `YOU WERE DIRECTLY @-MENTIONED. RESPOND.
11979
+
11980
+ - Use the cohort_comment tool to post a reply. Do NOT just think silently and exit.
11981
+ - Reply in your own voice (see your persona in IDENTITY.md).
11982
+ - If you need more context, fetch it via cohort_task before replying \u2014 then reply with what you found and your next step.
11983
+ - A brief, honest reply is better than no reply. If you genuinely have nothing to add, say so explicitly in a comment \u2014 don't go silent.
11984
+ - If the mention is a question, answer it. If it's a request, acknowledge what you'll do (and then do it).`;
11978
11985
  var TOOLS_REFERENCE = `
11979
11986
  TOOLS: Use these \u2014 do NOT call the REST API directly.
11980
11987
  - cohort_comment(task_number, comment) \u2014 post a comment
@@ -12035,9 +12042,16 @@ Comment: "${n.preview}"`;
12035
12042
 
12036
12043
  Scope: ${truncated}`;
12037
12044
  }
12038
- const prompt = n.behavioralPrompt ? `${n.behavioralPrompt}
12045
+ let prompt;
12046
+ if (n.type === "comment" && n.isMentioned) {
12047
+ prompt = n.behavioralPrompt ? `${n.behavioralPrompt}
12048
+
12049
+ ${ATMENTION_RESPONSE_PROMPT}` : ATMENTION_RESPONSE_PROMPT;
12050
+ } else {
12051
+ prompt = n.behavioralPrompt ? `${n.behavioralPrompt}
12039
12052
 
12040
12053
  ${DEFAULT_BEHAVIORAL_PROMPT}` : DEFAULT_BEHAVIORAL_PROMPT;
12054
+ }
12041
12055
  const promptBlock = n.type === "comment" ? `
12042
12056
 
12043
12057
  ---
@@ -13135,6 +13149,48 @@ function buildActivityEntry(agentName, hook, context) {
13135
13149
  model
13136
13150
  };
13137
13151
  }
13152
+ case "model_call_ended": {
13153
+ const outcome = context.outcome;
13154
+ if (outcome !== "error") return null;
13155
+ const errorCategory = context.errorCategory;
13156
+ const provider = context.provider;
13157
+ const failureKind = context.failureKind;
13158
+ const durationMs = context.durationMs;
13159
+ let text;
13160
+ let summary;
13161
+ const where = provider ?? "the LLM provider";
13162
+ if (errorCategory === "auth") {
13163
+ text = `${name} couldn't reach ${where} \u2014 API key rejected. Update it in Settings.`;
13164
+ summary = `${where} API key invalid`;
13165
+ } else if (errorCategory === "rate_limit") {
13166
+ text = `${name} was rate-limited by ${where}.`;
13167
+ summary = `${where} rate limit`;
13168
+ } else if (errorCategory === "overloaded" || errorCategory === "unavailable") {
13169
+ text = `${name} couldn't reach ${where} \u2014 service unavailable.`;
13170
+ summary = `${where} unavailable`;
13171
+ } else if (failureKind === "timeout") {
13172
+ text = `${name}'s LLM call to ${where} timed out.`;
13173
+ summary = `${where} timeout`;
13174
+ } else if (failureKind) {
13175
+ text = `${name}'s LLM call to ${where} failed (${failureKind}).`;
13176
+ summary = `${where} ${failureKind}`;
13177
+ } else {
13178
+ text = `${name}'s LLM call to ${where} failed${errorCategory ? ` (${errorCategory})` : ""}.`;
13179
+ summary = `${where} error${errorCategory ? `: ${errorCategory}` : ""}`;
13180
+ }
13181
+ return {
13182
+ agentName,
13183
+ text,
13184
+ category: "system",
13185
+ timestamp: ts,
13186
+ hook,
13187
+ sessionKey,
13188
+ model,
13189
+ durationMs,
13190
+ error: true,
13191
+ errorSummary: summary
13192
+ };
13193
+ }
13138
13194
  default:
13139
13195
  return null;
13140
13196
  }
@@ -13431,7 +13487,7 @@ function dumpCtx(ctx) {
13431
13487
  function dumpEvent(event) {
13432
13488
  return dumpCtx(event);
13433
13489
  }
13434
- var PLUGIN_VERSION = true ? "0.27.0" : "unknown";
13490
+ var PLUGIN_VERSION = true ? "0.29.0" : "unknown";
13435
13491
  function resolveGatewayToken(api) {
13436
13492
  const token = api.config?.gateway?.auth?.token;
13437
13493
  return typeof token === "string" ? token : null;
@@ -13805,6 +13861,33 @@ function registerHookHandlers(api, logger, getState) {
13805
13861
  log.warn(`cohort-sync: agent_end sync failed: ${String(err)}`);
13806
13862
  }
13807
13863
  });
13864
+ api.on("model_call_ended", async (event, ctx) => {
13865
+ const state = getState();
13866
+ if (!state) return;
13867
+ if (event?.outcome !== "error") return;
13868
+ const { logger: log } = state;
13869
+ log.debug("cohort-sync: hook: model_call_ended (error)", {
13870
+ provider: event.provider,
13871
+ errorCategory: event.errorCategory,
13872
+ failureKind: event.failureKind
13873
+ });
13874
+ try {
13875
+ const agentId = ctx.agentId ?? "main";
13876
+ const agentName = state.resolveAgentName(agentId);
13877
+ const entry = buildActivityEntry(agentName, "model_call_ended", {
13878
+ outcome: event.outcome,
13879
+ errorCategory: event.errorCategory,
13880
+ failureKind: event.failureKind,
13881
+ provider: event.provider,
13882
+ model: event.model,
13883
+ durationMs: event.durationMs,
13884
+ sessionKey: ctx.sessionKey
13885
+ });
13886
+ if (entry) state.activityBatch.add(entry);
13887
+ } catch (err) {
13888
+ log.warn(`cohort-sync: model_call_ended sync failed: ${String(err)}`);
13889
+ }
13890
+ });
13808
13891
  api.on("llm_output", async (event, ctx) => {
13809
13892
  const state = getState();
13810
13893
  if (!state) return;
@@ -72,5 +72,5 @@
72
72
  }
73
73
  }
74
74
  },
75
- "version": "0.27.0"
75
+ "version": "0.29.0"
76
76
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.27.0",
3
+ "version": "0.29.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.27.0",
3
+ "version": "0.29.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",