@cfio/cohort-sync 0.31.5 → 0.31.7

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
@@ -11971,6 +11971,7 @@ var acknowledgeCommandRef = makeFunctionReference("gatewayCommands:acknowledgeCo
11971
11971
  var failCommandRef = makeFunctionReference("gatewayCommands:failCommand");
11972
11972
  var getChannelsForPlugin = makeFunctionReference("cloudGatewayChannels:listForPlugin");
11973
11973
  var addCommentFromPluginRef = makeFunctionReference("comments:addCommentFromPlugin");
11974
+ var transitionFromPluginRef = makeFunctionReference("tasks:transitionFromPlugin");
11974
11975
  async function pushTelemetry(apiKey2, data) {
11975
11976
  if (authCircuitOpen) return;
11976
11977
  const c = getClient();
@@ -12073,6 +12074,30 @@ async function callAddCommentFromPlugin(apiKey2, args) {
12073
12074
  throw err;
12074
12075
  }
12075
12076
  }
12077
+ async function callTransitionFromPlugin(apiKey2, args) {
12078
+ if (authCircuitOpen) {
12079
+ throw new Error(
12080
+ 'cohort-sync: API key rejected \u2014 all outbound mutations disabled until gateway restart.\n 1. Create a new key at https://my.cohort.bot/settings/api-keys\n 2. Run: openclaw config set plugins.entries.cohort-sync.config.apiKey "ch_live_..."'
12081
+ );
12082
+ }
12083
+ const c = getClient();
12084
+ if (!c) {
12085
+ throw new Error("Convex client not initialized \u2014 subscription may not be active");
12086
+ }
12087
+ try {
12088
+ return await c.mutation(transitionFromPluginRef, {
12089
+ apiKeyHash: hashApiKey(apiKey2),
12090
+ taskNumber: args.taskNumber,
12091
+ agentName: args.agentName,
12092
+ targetStatus: args.targetStatus
12093
+ });
12094
+ } catch (err) {
12095
+ if (isUnauthorizedError(err)) {
12096
+ tripAuthCircuit();
12097
+ }
12098
+ throw err;
12099
+ }
12100
+ }
12076
12101
  var DEFAULT_BEHAVIORAL_PROMPT = `BEFORE RESPONDING:
12077
12102
  - Does your planned response address the task's stated scope? If not, do not comment.
12078
12103
  - Do not post acknowledgment-only responses ("got it", "sounds good", "confirmed"). If you have no new information to add, do not comment.
@@ -12083,7 +12108,9 @@ var ATMENTION_RESPONSE_PROMPT = `YOU WERE DIRECTLY @-MENTIONED. RESPOND.
12083
12108
  - Reply in your own voice (see your persona in IDENTITY.md).
12084
12109
  - If you need more context, fetch it via cohort_task before replying \u2014 then reply with what you found and your next step.
12085
12110
  - 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.
12086
- - If the mention is a question, answer it. If it's a request, acknowledge what you'll do (and then do it).`;
12111
+ - If the mention is a question, answer it. If it's a request, acknowledge what you'll do (and then do it).
12112
+ - For coding requests, do not stop at local implementation; source scripts/agent-dev-env.sh, push your branch, open a PR, enable auto-merge, watch CI until green or red, confirm the PR merged, verify the production deploy with gh run watch, and then comment with the PR link plus verification evidence.
12113
+ - Do not stop because Vercel CLI is not authenticated; Cohort deploys through GitHub Actions after merge.`;
12087
12114
  var TOOLS_REFERENCE = `
12088
12115
  TOOLS: Use these \u2014 do NOT call the REST API directly.
12089
12116
  - cohort_comment(task_number, comment) \u2014 post a comment
@@ -13638,7 +13665,7 @@ function dumpEvent(event) {
13638
13665
  function positiveNumber(value) {
13639
13666
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
13640
13667
  }
13641
- var PLUGIN_VERSION = true ? "0.31.5" : "unknown";
13668
+ var PLUGIN_VERSION = true ? "0.31.7" : "unknown";
13642
13669
  function resolveGatewayToken(api) {
13643
13670
  const token2 = api.config?.gateway?.auth?.token;
13644
13671
  return typeof token2 === "string" ? token2 : null;
@@ -13982,10 +14009,6 @@ function registerHookHandlers(api, logger, getState) {
13982
14009
  state.logger.debug("cohort-sync: resolve agent: result", { method: "fallback_main", resolved });
13983
14010
  return resolved;
13984
14011
  }
13985
- function isHeartbeatCronSession(ctx) {
13986
- const sessionKey = ctx.sessionKey ?? ctx.sessionId;
13987
- return typeof sessionKey === "string" && sessionKey.includes(":cron:heartbeat");
13988
- }
13989
14012
  api.on("agent_end", async (event, ctx) => {
13990
14013
  const state = getState();
13991
14014
  if (!state) return;
@@ -14058,15 +14081,6 @@ function registerHookHandlers(api, logger, getState) {
14058
14081
  if (!state) return;
14059
14082
  if (event?.outcome !== "error") return;
14060
14083
  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
- }
14070
14084
  log.debug("cohort-sync: hook: model_call_ended (error)", {
14071
14085
  provider: event.provider,
14072
14086
  errorCategory: event.errorCategory,
@@ -14606,7 +14620,8 @@ var POCKET_GUIDE = `# Cohort Agent Guide (Pocket Version)
14606
14620
  - You cannot transition tasks to "done" unless your workspace admin has enabled it. Only humans close tasks by default.
14607
14621
  - When moving to "in_progress", you are claiming ownership \u2014 only claim tasks you can actively work on.
14608
14622
  - When moving to "waiting", comment what you are blocked on and who/what can unblock you.
14609
- - When work is complete, comment with evidence: PR link, test output, or summary of changes.
14623
+ - For code changes, work is not complete when it is implemented locally; push your branch, open a PR, enable auto-merge, watch CI until green or red, confirm the PR merged, verify the production deploy, then comment with the PR link, deploy result, and verification evidence.
14624
+ - Use GitHub for deployment: after opening the PR, run gh pr merge --auto --rebase --delete-branch, gh pr checks <PR> --watch, confirm the merge, then run gh run watch <deploy-run-id> for the Deploy Production workflow. Do not stop because Vercel CLI is not authenticated; Cohort deploys through GitHub Actions after merge.
14610
14625
 
14611
14626
  ## Comments
14612
14627
  - Comment before every status transition explaining what happened.
@@ -14625,6 +14640,9 @@ var POCKET_GUIDE = `# Cohort Agent Guide (Pocket Version)
14625
14640
  - If rate limited (429), wait per Retry-After header.
14626
14641
  - If 404, verify you are using the correct task number or ID (both accepted).
14627
14642
  - If 500, retry once after a brief pause. If it fails again, stop and report.
14643
+ - At the start of repository work, run source scripts/agent-dev-env.sh from the repo root so nvm, pnpm, gh, and Homebrew tools are on PATH.
14644
+ - A dirty checkout, missing node_modules, missing local test dependencies, or unrelated local type errors are environment snags, not a reason to stop; fix the local environment when practical, otherwise push the branch and use CI to get a clean signal.
14645
+ - Do not stop at implemented locally. Keep going until the code is reviewed by CI, merged, deployed, and verified, or until you have a concrete external blocker you cannot resolve.
14628
14646
 
14629
14647
  ## What Not To Do
14630
14648
  - Don't poll /tasks in a loop \u2014 check assignments, then do your work.
@@ -14839,7 +14857,8 @@ Do not attempt more comments until tomorrow.`);
14839
14857
  }
14840
14858
  };
14841
14859
  });
14842
- api.registerTool(() => {
14860
+ api.registerTool((toolCtx) => {
14861
+ const agentId = toolCtx.agentId ?? "main";
14843
14862
  return {
14844
14863
  name: "cohort_transition",
14845
14864
  label: "cohort_transition",
@@ -14857,21 +14876,13 @@ Do not attempt more comments until tomorrow.`);
14857
14876
  if (!validStatuses.includes(params.status)) {
14858
14877
  return textResult(`Invalid status "${params.status}". Valid statuses: ${validStatuses.join(", ")}`);
14859
14878
  }
14879
+ const agentName = rt.resolveAgentName(agentId);
14860
14880
  try {
14861
- const res = await fetch(`${rt.apiUrl}/api/v1/tasks/${params.task_number}/transition`, {
14862
- method: "POST",
14863
- headers: {
14864
- "Authorization": `Bearer ${rt.apiKey}`,
14865
- "Content-Type": "application/json"
14866
- },
14867
- body: JSON.stringify({ to: params.status }),
14868
- signal: AbortSignal.timeout(1e4)
14881
+ await callTransitionFromPlugin(rt.apiKey, {
14882
+ taskNumber: params.task_number,
14883
+ agentName,
14884
+ targetStatus: params.status
14869
14885
  });
14870
- if (!res.ok) {
14871
- const body = await res.text();
14872
- return textResult(`Failed to transition task #${params.task_number} to "${params.status}": ${res.status} ${body.slice(0, 200)}`);
14873
- }
14874
- const task = await res.json();
14875
14886
  return textResult(`Task #${params.task_number} transitioned to "${params.status}".`);
14876
14887
  } catch (err) {
14877
14888
  return textResult(`Failed to transition task #${params.task_number}: ${err instanceof Error ? err.message : String(err)}`);
@@ -14879,8 +14890,7 @@ Do not attempt more comments until tomorrow.`);
14879
14890
  }
14880
14891
  };
14881
14892
  });
14882
- api.registerTool((toolCtx) => {
14883
- const agentId = toolCtx.agentId ?? "main";
14893
+ api.registerTool(() => {
14884
14894
  return {
14885
14895
  name: "cohort_assign",
14886
14896
  label: "cohort_assign",
@@ -14912,7 +14922,7 @@ Do not attempt more comments until tomorrow.`);
14912
14922
  const body = await res.text();
14913
14923
  return textResult(`Failed to assign task #${params.task_number}: ${res.status} ${body.slice(0, 200)}`);
14914
14924
  }
14915
- const task = await res.json();
14925
+ await res.json();
14916
14926
  const msg = assignee ? `Task #${params.task_number} assigned to ${assignee}.` : `Task #${params.task_number} unassigned.`;
14917
14927
  return textResult(msg);
14918
14928
  } catch (err) {
@@ -72,5 +72,5 @@
72
72
  }
73
73
  }
74
74
  },
75
- "version": "0.31.5"
75
+ "version": "0.31.7"
76
76
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.31.5",
3
+ "version": "0.31.7",
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.5",
3
+ "version": "0.31.7",
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",