@cfio/cohort-sync 0.13.0 → 0.14.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 +20 -16
- package/dist/openclaw.plugin.json +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11700,14 +11700,16 @@ async function executeCommand(cmd, gwClient, cfg, resolveAgentName, logger) {
|
|
|
11700
11700
|
throw new Error(`Cron message exceeds maximum length of ${MAX_CRON_MESSAGE_LENGTH} characters`);
|
|
11701
11701
|
}
|
|
11702
11702
|
if (cmd.type === "restart") {
|
|
11703
|
-
if (
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
logger.warn(`cohort-sync: RESTART command received (id=${cmd._id}), no gateway client \u2014 falling back to SIGTERM`);
|
|
11708
|
-
await new Promise((r) => setTimeout(r, 500));
|
|
11709
|
-
process.kill(process.pid, "SIGTERM");
|
|
11703
|
+
if (cfg.commandsRestartEnabled !== true) {
|
|
11704
|
+
throw new Error(
|
|
11705
|
+
"Gateway restart is not authorized. Set `commands.restart: true` in your OpenClaw config and restart the gateway once. See https://docs.cohort.bot/gateway/restart"
|
|
11706
|
+
);
|
|
11710
11707
|
}
|
|
11708
|
+
logger.warn(
|
|
11709
|
+
`cohort-sync: RESTART command received (id=${cmd._id}), sending SIGUSR1 for graceful in-process restart`
|
|
11710
|
+
);
|
|
11711
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
11712
|
+
process.kill(process.pid, "SIGUSR1");
|
|
11711
11713
|
return;
|
|
11712
11714
|
}
|
|
11713
11715
|
if (cmd.type.startsWith("cron")) {
|
|
@@ -13370,7 +13372,7 @@ function dumpCtx(ctx) {
|
|
|
13370
13372
|
function dumpEvent(event) {
|
|
13371
13373
|
return dumpCtx(event);
|
|
13372
13374
|
}
|
|
13373
|
-
var PLUGIN_VERSION = true ? "0.
|
|
13375
|
+
var PLUGIN_VERSION = true ? "0.14.0" : "unknown";
|
|
13374
13376
|
function resolveGatewayToken(api) {
|
|
13375
13377
|
const token = api.config?.gateway?.auth?.token;
|
|
13376
13378
|
return typeof token === "string" ? token : null;
|
|
@@ -13576,7 +13578,7 @@ async function handleGatewayStart(event, state) {
|
|
|
13576
13578
|
tracker.updateStatus(agentName, "idle");
|
|
13577
13579
|
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
13578
13580
|
if (snapshot) {
|
|
13579
|
-
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13581
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13580
13582
|
tracker.markTelemetryPushed(agentName);
|
|
13581
13583
|
}
|
|
13582
13584
|
} catch (err) {
|
|
@@ -13590,7 +13592,7 @@ async function handleGatewayStart(event, state) {
|
|
|
13590
13592
|
const agentName = state.resolveAgentName(agentId);
|
|
13591
13593
|
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
13592
13594
|
if (snapshot) {
|
|
13593
|
-
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} }).catch(() => {
|
|
13595
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} }).catch(() => {
|
|
13594
13596
|
});
|
|
13595
13597
|
}
|
|
13596
13598
|
}
|
|
@@ -13668,7 +13670,7 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
13668
13670
|
if (tracker.shouldPushTelemetry(agentName)) {
|
|
13669
13671
|
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
13670
13672
|
if (snapshot) {
|
|
13671
|
-
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13673
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13672
13674
|
tracker.markTelemetryPushed(agentName);
|
|
13673
13675
|
}
|
|
13674
13676
|
}
|
|
@@ -13730,7 +13732,7 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
13730
13732
|
if (tracker.shouldPushTelemetry(agentName)) {
|
|
13731
13733
|
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
13732
13734
|
if (snapshot) {
|
|
13733
|
-
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13735
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13734
13736
|
tracker.markTelemetryPushed(agentName);
|
|
13735
13737
|
}
|
|
13736
13738
|
}
|
|
@@ -13758,7 +13760,7 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
13758
13760
|
if (tracker.shouldPushTelemetry(agentName)) {
|
|
13759
13761
|
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
13760
13762
|
if (snapshot) {
|
|
13761
|
-
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13763
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13762
13764
|
tracker.markTelemetryPushed(agentName);
|
|
13763
13765
|
}
|
|
13764
13766
|
}
|
|
@@ -13800,7 +13802,7 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
13800
13802
|
if (tracker.shouldPushTelemetry(agentName)) {
|
|
13801
13803
|
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
13802
13804
|
if (snapshot) {
|
|
13803
|
-
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13805
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
13804
13806
|
tracker.markTelemetryPushed(agentName);
|
|
13805
13807
|
}
|
|
13806
13808
|
}
|
|
@@ -14004,7 +14006,7 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
14004
14006
|
tracker.updateStatus(agentName, "unreachable");
|
|
14005
14007
|
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
14006
14008
|
if (snapshot) {
|
|
14007
|
-
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
14009
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
14008
14010
|
}
|
|
14009
14011
|
} catch (err) {
|
|
14010
14012
|
log.warn(`cohort-sync: final unreachable push failed for ${agentName}: ${String(err)}`);
|
|
@@ -14475,11 +14477,13 @@ Do not attempt more comments until tomorrow.`);
|
|
|
14475
14477
|
}
|
|
14476
14478
|
api.logger.info(`cohort-sync: activated (api: ${apiUrl2})`);
|
|
14477
14479
|
if (!sharedHookState) {
|
|
14480
|
+
const commandsRestartEnabled = api.config?.commands?.restart === true;
|
|
14478
14481
|
sharedHookState = initializeHookState(api, {
|
|
14479
14482
|
apiUrl: apiUrl2,
|
|
14480
14483
|
apiKey: apiKey2,
|
|
14481
14484
|
stateDir: svcCtx.stateDir,
|
|
14482
|
-
agentNameMap: cfg?.agentNameMap
|
|
14485
|
+
agentNameMap: cfg?.agentNameMap,
|
|
14486
|
+
commandsRestartEnabled
|
|
14483
14487
|
});
|
|
14484
14488
|
}
|
|
14485
14489
|
},
|
package/dist/package.json
CHANGED
package/package.json
CHANGED