@cfio/cohort-sync 0.14.0 → 0.15.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 +31 -19
- package/dist/openclaw.plugin.json +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13372,7 +13372,7 @@ function dumpCtx(ctx) {
|
|
|
13372
13372
|
function dumpEvent(event) {
|
|
13373
13373
|
return dumpCtx(event);
|
|
13374
13374
|
}
|
|
13375
|
-
var PLUGIN_VERSION = true ? "0.
|
|
13375
|
+
var PLUGIN_VERSION = true ? "0.15.0" : "unknown";
|
|
13376
13376
|
function resolveGatewayToken(api) {
|
|
13377
13377
|
const token = api.config?.gateway?.auth?.token;
|
|
13378
13378
|
return typeof token === "string" ? token : null;
|
|
@@ -13988,28 +13988,36 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
13988
13988
|
state.logger.warn(`cohort-sync: before_reset activity failed: ${String(err)}`);
|
|
13989
13989
|
}
|
|
13990
13990
|
});
|
|
13991
|
-
api.on("gateway_stop", async (
|
|
13991
|
+
api.on("gateway_stop", async (event, _ctx) => {
|
|
13992
13992
|
const state = getState();
|
|
13993
13993
|
if (!state) return;
|
|
13994
13994
|
const { cfg, tracker, logger: log, config } = state;
|
|
13995
|
-
|
|
13995
|
+
const reason = typeof event?.reason === "string" ? event.reason : "";
|
|
13996
|
+
const isRestart = reason.toLowerCase().includes("restart");
|
|
13997
|
+
log.debug("cohort-sync: hook: gateway_stop", {
|
|
13998
|
+
reason,
|
|
13999
|
+
isRestart,
|
|
14000
|
+
bridgeState: Object.fromEntries(getChannelAgentBridge())
|
|
14001
|
+
});
|
|
13996
14002
|
if (state.keepaliveInterval) {
|
|
13997
14003
|
clearInterval(state.keepaliveInterval);
|
|
13998
14004
|
state.keepaliveInterval = null;
|
|
13999
14005
|
}
|
|
14000
14006
|
state.activityBatch.drain();
|
|
14001
|
-
|
|
14002
|
-
|
|
14003
|
-
|
|
14004
|
-
const
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
|
|
14007
|
+
if (!isRestart) {
|
|
14008
|
+
const shutdownConfigIds = (config?.agents?.list ?? []).map((a) => a.id);
|
|
14009
|
+
const allAgentIds = shutdownConfigIds.includes("main") ? shutdownConfigIds : ["main", ...shutdownConfigIds];
|
|
14010
|
+
for (const agentId of allAgentIds) {
|
|
14011
|
+
const agentName = state.resolveAgentName(agentId);
|
|
14012
|
+
try {
|
|
14013
|
+
tracker.updateStatus(agentName, "unreachable");
|
|
14014
|
+
const snapshot = tracker.getTelemetrySnapshot(agentName);
|
|
14015
|
+
if (snapshot) {
|
|
14016
|
+
await pushTelemetry(cfg.apiKey, { ...snapshot, pluginVersion: PLUGIN_VERSION, commandsRestartEnabled: cfg.commandsRestartEnabled, ...state.latestPluginVersion ? { latestPluginVersion: state.latestPluginVersion } : {} });
|
|
14017
|
+
}
|
|
14018
|
+
} catch (err) {
|
|
14019
|
+
log.warn(`cohort-sync: final unreachable push failed for ${agentName}: ${String(err)}`);
|
|
14010
14020
|
}
|
|
14011
|
-
} catch (err) {
|
|
14012
|
-
log.warn(`cohort-sync: final unreachable push failed for ${agentName}: ${String(err)}`);
|
|
14013
14021
|
}
|
|
14014
14022
|
}
|
|
14015
14023
|
saveSessionsToDisk(tracker, state.stateFilePath);
|
|
@@ -14018,14 +14026,18 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
14018
14026
|
state.persistentGwClient = null;
|
|
14019
14027
|
state.gwClientInitialized = false;
|
|
14020
14028
|
}
|
|
14021
|
-
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14029
|
+
if (!isRestart) {
|
|
14030
|
+
try {
|
|
14031
|
+
await markAllUnreachable(cfg, log);
|
|
14032
|
+
} catch (err) {
|
|
14033
|
+
log.warn(`cohort-sync: markAllUnreachable failed: ${String(err)}`);
|
|
14034
|
+
}
|
|
14025
14035
|
}
|
|
14026
14036
|
tracker.clear();
|
|
14027
14037
|
closeBridge();
|
|
14028
|
-
log.info(
|
|
14038
|
+
log.info(
|
|
14039
|
+
isRestart ? "cohort-sync: gateway restarting, resources cleaned up (agents kept online)" : "cohort-sync: gateway stopped, all resources cleaned up"
|
|
14040
|
+
);
|
|
14029
14041
|
});
|
|
14030
14042
|
}
|
|
14031
14043
|
function initializeHookState(api, cfg) {
|
package/dist/package.json
CHANGED
package/package.json
CHANGED