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