@cfio/cohort-sync 0.4.1 → 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 +28 -24
- package/dist/package.json +1 -1
- package/package.json +1 -1
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
|
-
|
|
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 {
|
|
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,9 +11760,11 @@ 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
|
-
|
|
11764
|
-
|
|
11763
|
+
const freshJobs = await fetchCronJobs(logger);
|
|
11764
|
+
if (freshJobs !== null) {
|
|
11765
|
+
const resolvedJobs = resolveAgentName ? freshJobs.map((j) => ({ ...j, agentId: j.agentId ? resolveAgentName(j.agentId) : j.agentId })) : freshJobs;
|
|
11766
|
+
await pushCronSnapshot(cfg.apiKey, resolvedJobs);
|
|
11767
|
+
}
|
|
11765
11768
|
} catch (snapErr) {
|
|
11766
11769
|
logger.warn(`cohort-sync: post-command snapshot push failed: ${String(snapErr)}`);
|
|
11767
11770
|
}
|
|
@@ -11912,6 +11915,7 @@ function getChannelAgent(channelId) {
|
|
|
11912
11915
|
}
|
|
11913
11916
|
|
|
11914
11917
|
// src/sync.ts
|
|
11918
|
+
var execFileAsync = promisify(execFile);
|
|
11915
11919
|
function extractJson(raw) {
|
|
11916
11920
|
const jsonStart = raw.search(/[\[{]/);
|
|
11917
11921
|
const jsonEndBracket = raw.lastIndexOf("]");
|
|
@@ -11922,15 +11926,14 @@ function extractJson(raw) {
|
|
|
11922
11926
|
}
|
|
11923
11927
|
return raw.slice(jsonStart, jsonEnd + 1);
|
|
11924
11928
|
}
|
|
11925
|
-
function fetchSkills(logger) {
|
|
11929
|
+
async function fetchSkills(logger) {
|
|
11926
11930
|
try {
|
|
11927
|
-
const
|
|
11931
|
+
const { stdout } = await execFileAsync("openclaw", ["skills", "list", "--json"], {
|
|
11928
11932
|
encoding: "utf8",
|
|
11929
11933
|
timeout: 1e4,
|
|
11930
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
11931
11934
|
env: { ...process.env, NO_COLOR: "1" }
|
|
11932
11935
|
});
|
|
11933
|
-
const parsed = JSON.parse(extractJson(
|
|
11936
|
+
const parsed = JSON.parse(extractJson(stdout));
|
|
11934
11937
|
const list = Array.isArray(parsed) ? parsed : parsed?.skills ?? [];
|
|
11935
11938
|
return list.map((s) => ({
|
|
11936
11939
|
name: String(s.name ?? s.id ?? "unknown"),
|
|
@@ -11943,15 +11946,14 @@ function fetchSkills(logger) {
|
|
|
11943
11946
|
return [];
|
|
11944
11947
|
}
|
|
11945
11948
|
}
|
|
11946
|
-
function fetchCronJobs(logger) {
|
|
11949
|
+
async function fetchCronJobs(logger) {
|
|
11947
11950
|
try {
|
|
11948
|
-
const
|
|
11951
|
+
const { stdout } = await execFileAsync("openclaw", ["cron", "list", "--all", "--json"], {
|
|
11949
11952
|
encoding: "utf8",
|
|
11950
11953
|
timeout: 1e4,
|
|
11951
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
11952
11954
|
env: { ...process.env, NO_COLOR: "1" }
|
|
11953
11955
|
});
|
|
11954
|
-
const parsed = JSON.parse(extractJson(
|
|
11956
|
+
const parsed = JSON.parse(extractJson(stdout));
|
|
11955
11957
|
const list = Array.isArray(parsed) ? parsed : parsed?.jobs ?? [];
|
|
11956
11958
|
return list.map((j) => ({
|
|
11957
11959
|
id: String(j.jobId ?? j.id ?? "unknown"),
|
|
@@ -11965,7 +11967,7 @@ function fetchCronJobs(logger) {
|
|
|
11965
11967
|
}));
|
|
11966
11968
|
} catch (err) {
|
|
11967
11969
|
logger.warn(`cohort-sync: failed to fetch cron jobs: ${String(err)}`);
|
|
11968
|
-
return
|
|
11970
|
+
return null;
|
|
11969
11971
|
}
|
|
11970
11972
|
}
|
|
11971
11973
|
function formatSchedule(schedule) {
|
|
@@ -12170,7 +12172,7 @@ async function fullSync(agentName, model, cfg, logger, openClawAgents) {
|
|
|
12170
12172
|
} else {
|
|
12171
12173
|
await syncAgentStatus(agentName, "working", model, cfg, logger);
|
|
12172
12174
|
}
|
|
12173
|
-
const skills = fetchSkills(logger);
|
|
12175
|
+
const skills = await fetchSkills(logger);
|
|
12174
12176
|
if (skills.length > 0) {
|
|
12175
12177
|
await syncSkillsToV1(skills, cfg, logger);
|
|
12176
12178
|
}
|
|
@@ -13114,12 +13116,14 @@ Do not attempt to make more comments until ${resetAt}.`
|
|
|
13114
13116
|
}
|
|
13115
13117
|
saveSessionsToDisk(tracker);
|
|
13116
13118
|
try {
|
|
13117
|
-
const cronJobs2 = fetchCronJobs(logger);
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13119
|
+
const cronJobs2 = await fetchCronJobs(logger);
|
|
13120
|
+
if (cronJobs2 !== null) {
|
|
13121
|
+
const resolvedJobs = cronJobs2.map((job) => ({
|
|
13122
|
+
...job,
|
|
13123
|
+
agentId: job.agentId ? resolveAgentName(job.agentId) : job.agentId
|
|
13124
|
+
}));
|
|
13125
|
+
await pushCronSnapshot(cfg.apiKey, resolvedJobs);
|
|
13126
|
+
}
|
|
13123
13127
|
} catch (err) {
|
|
13124
13128
|
logger.warn(`cohort-sync: heartbeat cron push failed: ${String(err)}`);
|
|
13125
13129
|
}
|
|
@@ -13502,7 +13506,7 @@ Do not attempt to make more comments until ${resetAt}.`
|
|
|
13502
13506
|
}
|
|
13503
13507
|
|
|
13504
13508
|
// src/cli.ts
|
|
13505
|
-
import { execFile as
|
|
13509
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
13506
13510
|
|
|
13507
13511
|
// src/device-auth.ts
|
|
13508
13512
|
function baseUrl(apiUrl) {
|
|
@@ -13583,7 +13587,7 @@ init_keychain();
|
|
|
13583
13587
|
function openBrowser(url) {
|
|
13584
13588
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
13585
13589
|
const args = process.platform === "win32" ? ["/c", "start", url] : [url];
|
|
13586
|
-
|
|
13590
|
+
execFile3(cmd, args, () => {
|
|
13587
13591
|
});
|
|
13588
13592
|
}
|
|
13589
13593
|
function registerCohortCli(ctx, cfg) {
|
package/dist/package.json
CHANGED