@cfio/cohort-sync 0.4.0 → 0.4.1
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 +17 -4
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11728,7 +11728,7 @@ async function initSubscription(port, cfg, hooksToken, logger) {
|
|
|
11728
11728
|
}
|
|
11729
11729
|
state.unsubscribers = [...unsubscribers];
|
|
11730
11730
|
}
|
|
11731
|
-
function initCommandSubscription(cfg, logger) {
|
|
11731
|
+
function initCommandSubscription(cfg, logger, resolveAgentName) {
|
|
11732
11732
|
const c = getOrCreateClient();
|
|
11733
11733
|
if (!c) {
|
|
11734
11734
|
logger.warn("cohort-sync: no ConvexClient \u2014 command subscription skipped");
|
|
@@ -11760,7 +11760,8 @@ function initCommandSubscription(cfg, logger) {
|
|
|
11760
11760
|
handleCronCommand(cmd.type, cmd.payload.jobId, logger);
|
|
11761
11761
|
try {
|
|
11762
11762
|
const freshJobs = fetchCronJobs(logger);
|
|
11763
|
-
|
|
11763
|
+
const resolvedJobs = resolveAgentName ? freshJobs.map((j) => ({ ...j, agentId: j.agentId ? resolveAgentName(j.agentId) : j.agentId })) : freshJobs;
|
|
11764
|
+
await pushCronSnapshot(cfg.apiKey, resolvedJobs);
|
|
11764
11765
|
} catch (snapErr) {
|
|
11765
11766
|
logger.warn(`cohort-sync: post-command snapshot push failed: ${String(snapErr)}`);
|
|
11766
11767
|
}
|
|
@@ -12847,6 +12848,18 @@ function registerHooks(api, cfg) {
|
|
|
12847
12848
|
setLogger(logger);
|
|
12848
12849
|
restoreFromHotReload(logger);
|
|
12849
12850
|
restoreRosterFromHotReload(getRosterHotState(), logger);
|
|
12851
|
+
const identityNameMap = {};
|
|
12852
|
+
const mainIdentity = parseIdentityFile(process.cwd());
|
|
12853
|
+
if (mainIdentity?.name) {
|
|
12854
|
+
identityNameMap["main"] = mainIdentity.name.toLowerCase();
|
|
12855
|
+
}
|
|
12856
|
+
for (const agent of config?.agents?.list ?? []) {
|
|
12857
|
+
const identity = resolveIdentity(agent.identity, agent.workspace);
|
|
12858
|
+
if (identity?.name) {
|
|
12859
|
+
identityNameMap[agent.id] = identity.name.toLowerCase();
|
|
12860
|
+
}
|
|
12861
|
+
}
|
|
12862
|
+
diag("IDENTITY_NAME_MAP", { identityNameMap });
|
|
12850
12863
|
if (tracker.getAgentNames().length === 0) {
|
|
12851
12864
|
loadSessionsFromDisk(tracker, logger);
|
|
12852
12865
|
const restoredAgents = tracker.getAgentNames();
|
|
@@ -12863,7 +12876,7 @@ function registerHooks(api, cfg) {
|
|
|
12863
12876
|
}
|
|
12864
12877
|
}
|
|
12865
12878
|
function resolveAgentName(agentId) {
|
|
12866
|
-
return (nameMap?.[agentId] ?? agentId).toLowerCase();
|
|
12879
|
+
return (nameMap?.[agentId] ?? identityNameMap[agentId] ?? agentId).toLowerCase();
|
|
12867
12880
|
}
|
|
12868
12881
|
function resolveAgentFromContext(ctx) {
|
|
12869
12882
|
const allCtxKeys = Object.keys(ctx);
|
|
@@ -13155,7 +13168,7 @@ Do not attempt to make more comments until ${resetAt}.`
|
|
|
13155
13168
|
).catch((err) => {
|
|
13156
13169
|
logger.error(`cohort-sync: subscription init failed: ${String(err)}`);
|
|
13157
13170
|
});
|
|
13158
|
-
initCommandSubscription(cfg, logger);
|
|
13171
|
+
initCommandSubscription(cfg, logger, resolveAgentName);
|
|
13159
13172
|
const allAgentIds = ["main", ...(config?.agents?.list ?? []).map((a) => a.id)];
|
|
13160
13173
|
for (const agentId of allAgentIds) {
|
|
13161
13174
|
const agentName = resolveAgentName(agentId);
|
package/dist/package.json
CHANGED