@adhdev/daemon-core 0.9.76-rc.30 → 0.9.76-rc.31
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 +25 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/mesh/mesh-events.ts +40 -17
package/dist/index.js
CHANGED
|
@@ -30121,33 +30121,49 @@ init_config();
|
|
|
30121
30121
|
// src/mesh/mesh-events.ts
|
|
30122
30122
|
init_mesh_config();
|
|
30123
30123
|
init_logger();
|
|
30124
|
+
function readNonEmptyString(value) {
|
|
30125
|
+
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
30126
|
+
}
|
|
30127
|
+
function formatCompletionMetadata(event) {
|
|
30128
|
+
const parts = [
|
|
30129
|
+
readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
|
|
30130
|
+
readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
|
|
30131
|
+
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
|
|
30132
|
+
].filter(Boolean);
|
|
30133
|
+
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
30134
|
+
}
|
|
30124
30135
|
function setupMeshEventForwarding(components) {
|
|
30125
30136
|
components.instanceManager.onEvent((event) => {
|
|
30126
30137
|
if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
|
|
30127
|
-
const instanceId = event.instanceId;
|
|
30138
|
+
const instanceId = readNonEmptyString(event.instanceId);
|
|
30128
30139
|
if (!instanceId) return;
|
|
30129
30140
|
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
30130
30141
|
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
30131
30142
|
const state = sourceInstance.getState();
|
|
30132
|
-
const workspace = state.workspace;
|
|
30143
|
+
const workspace = readNonEmptyString(state.workspace);
|
|
30133
30144
|
if (!workspace) return;
|
|
30134
|
-
const
|
|
30135
|
-
|
|
30145
|
+
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
30146
|
+
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
|
|
30147
|
+
const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
|
|
30148
|
+
const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
|
|
30149
|
+
if (!meshId) return;
|
|
30136
30150
|
const allInstances = components.instanceManager.getByCategory("cli");
|
|
30137
30151
|
const coordinatorInstances = allInstances.filter((inst) => {
|
|
30138
30152
|
const instState = inst.getState();
|
|
30139
|
-
if (instState.settings?.meshCoordinatorFor !==
|
|
30153
|
+
if (instState.settings?.meshCoordinatorFor !== meshId) return false;
|
|
30140
30154
|
if (instState.instanceId === instanceId) return false;
|
|
30141
30155
|
return true;
|
|
30142
30156
|
});
|
|
30143
30157
|
if (coordinatorInstances.length === 0) return;
|
|
30144
|
-
const targetNode = mesh
|
|
30145
|
-
const
|
|
30158
|
+
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
30159
|
+
const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
|
|
30160
|
+
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
30161
|
+
const metadata = formatCompletionMetadata(event);
|
|
30146
30162
|
let messageText = "";
|
|
30147
30163
|
if (event.event === "agent:generating_completed") {
|
|
30148
|
-
messageText = `[System] ${nodeLabel} has completed its task and is now idle. You may use mesh_read_chat to review its progress.`;
|
|
30164
|
+
messageText = `[System] ${nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
|
|
30149
30165
|
} else if (event.event === "agent:waiting_approval") {
|
|
30150
|
-
messageText = `[System] ${nodeLabel} is waiting for approval to proceed. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
30166
|
+
messageText = `[System] ${nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
30151
30167
|
}
|
|
30152
30168
|
if (!messageText) return;
|
|
30153
30169
|
for (const coord of coordinatorInstances) {
|