@cfio/cohort-sync 0.4.2 → 0.4.3

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
@@ -15,10 +15,10 @@ __export(keychain_exports, {
15
15
  getCredential: () => getCredential,
16
16
  setCredential: () => setCredential
17
17
  });
18
- import { execFile } from "node:child_process";
18
+ import { execFile as execFile2 } from "node:child_process";
19
19
  function securityCmd(args) {
20
20
  return new Promise((resolve, reject) => {
21
- execFile("security", args, { timeout: 5e3 }, (err, stdout, stderr) => {
21
+ execFile2("security", args, { timeout: 5e3 }, (err, stdout, stderr) => {
22
22
  if (err) {
23
23
  reject(Object.assign(err, { stderr }));
24
24
  } else {
@@ -2698,7 +2698,8 @@ __export(type_exports2, {
2698
2698
  var Type = type_exports2;
2699
2699
 
2700
2700
  // src/sync.ts
2701
- import { execSync } from "node:child_process";
2701
+ import { execFile } from "node:child_process";
2702
+ import { promisify } from "node:util";
2702
2703
 
2703
2704
  // ../../node_modules/.pnpm/convex@1.33.0_patch_hash=l43bztwr6e2lbmpd6ao6hmcg24_react@19.2.1/node_modules/convex/dist/esm/index.js
2704
2705
  var version = "1.33.0";
@@ -11759,7 +11760,7 @@ function initCommandSubscription(cfg, logger, resolveAgentName) {
11759
11760
  if (cmd.type.startsWith("cron") && cmd.payload?.jobId) {
11760
11761
  handleCronCommand(cmd.type, cmd.payload.jobId, logger);
11761
11762
  try {
11762
- const freshJobs = fetchCronJobs(logger);
11763
+ const freshJobs = await fetchCronJobs(logger);
11763
11764
  if (freshJobs !== null) {
11764
11765
  const resolvedJobs = resolveAgentName ? freshJobs.map((j) => ({ ...j, agentId: j.agentId ? resolveAgentName(j.agentId) : j.agentId })) : freshJobs;
11765
11766
  await pushCronSnapshot(cfg.apiKey, resolvedJobs);
@@ -11914,6 +11915,7 @@ function getChannelAgent(channelId) {
11914
11915
  }
11915
11916
 
11916
11917
  // src/sync.ts
11918
+ var execFileAsync = promisify(execFile);
11917
11919
  function extractJson(raw) {
11918
11920
  const jsonStart = raw.search(/[\[{]/);
11919
11921
  const jsonEndBracket = raw.lastIndexOf("]");
@@ -11924,15 +11926,14 @@ function extractJson(raw) {
11924
11926
  }
11925
11927
  return raw.slice(jsonStart, jsonEnd + 1);
11926
11928
  }
11927
- function fetchSkills(logger) {
11929
+ async function fetchSkills(logger) {
11928
11930
  try {
11929
- const raw = execSync("openclaw skills list --json", {
11931
+ const { stdout } = await execFileAsync("openclaw", ["skills", "list", "--json"], {
11930
11932
  encoding: "utf8",
11931
11933
  timeout: 1e4,
11932
- stdio: ["ignore", "pipe", "ignore"],
11933
11934
  env: { ...process.env, NO_COLOR: "1" }
11934
11935
  });
11935
- const parsed = JSON.parse(extractJson(raw));
11936
+ const parsed = JSON.parse(extractJson(stdout));
11936
11937
  const list = Array.isArray(parsed) ? parsed : parsed?.skills ?? [];
11937
11938
  return list.map((s) => ({
11938
11939
  name: String(s.name ?? s.id ?? "unknown"),
@@ -11945,15 +11946,14 @@ function fetchSkills(logger) {
11945
11946
  return [];
11946
11947
  }
11947
11948
  }
11948
- function fetchCronJobs(logger) {
11949
+ async function fetchCronJobs(logger) {
11949
11950
  try {
11950
- const raw = execSync("openclaw cron list --all --json", {
11951
+ const { stdout } = await execFileAsync("openclaw", ["cron", "list", "--all", "--json"], {
11951
11952
  encoding: "utf8",
11952
11953
  timeout: 1e4,
11953
- stdio: ["ignore", "pipe", "ignore"],
11954
11954
  env: { ...process.env, NO_COLOR: "1" }
11955
11955
  });
11956
- const parsed = JSON.parse(extractJson(raw));
11956
+ const parsed = JSON.parse(extractJson(stdout));
11957
11957
  const list = Array.isArray(parsed) ? parsed : parsed?.jobs ?? [];
11958
11958
  return list.map((j) => ({
11959
11959
  id: String(j.jobId ?? j.id ?? "unknown"),
@@ -12172,7 +12172,7 @@ async function fullSync(agentName, model, cfg, logger, openClawAgents) {
12172
12172
  } else {
12173
12173
  await syncAgentStatus(agentName, "working", model, cfg, logger);
12174
12174
  }
12175
- const skills = fetchSkills(logger);
12175
+ const skills = await fetchSkills(logger);
12176
12176
  if (skills.length > 0) {
12177
12177
  await syncSkillsToV1(skills, cfg, logger);
12178
12178
  }
@@ -13116,7 +13116,7 @@ Do not attempt to make more comments until ${resetAt}.`
13116
13116
  }
13117
13117
  saveSessionsToDisk(tracker);
13118
13118
  try {
13119
- const cronJobs2 = fetchCronJobs(logger);
13119
+ const cronJobs2 = await fetchCronJobs(logger);
13120
13120
  if (cronJobs2 !== null) {
13121
13121
  const resolvedJobs = cronJobs2.map((job) => ({
13122
13122
  ...job,
@@ -13506,7 +13506,7 @@ Do not attempt to make more comments until ${resetAt}.`
13506
13506
  }
13507
13507
 
13508
13508
  // src/cli.ts
13509
- import { execFile as execFile2 } from "node:child_process";
13509
+ import { execFile as execFile3 } from "node:child_process";
13510
13510
 
13511
13511
  // src/device-auth.ts
13512
13512
  function baseUrl(apiUrl) {
@@ -13587,7 +13587,7 @@ init_keychain();
13587
13587
  function openBrowser(url) {
13588
13588
  const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
13589
13589
  const args = process.platform === "win32" ? ["/c", "start", url] : [url];
13590
- execFile2(cmd, args, () => {
13590
+ execFile3(cmd, args, () => {
13591
13591
  });
13592
13592
  }
13593
13593
  function registerCohortCli(ctx, cfg) {
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfio/cohort-sync",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Syncs agent status and skills to 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.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Syncs agent status and skills to Cohort dashboard",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.cohort.bot/gateway",