@adhdev/daemon-core 0.9.77-rc.20 → 0.9.77-rc.21
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 +10 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/mesh/mesh-events.ts +11 -5
package/package.json
CHANGED
package/src/mesh/mesh-events.ts
CHANGED
|
@@ -69,7 +69,9 @@ export function tryAssignQueueTask(
|
|
|
69
69
|
providerType: string
|
|
70
70
|
): boolean {
|
|
71
71
|
const task = claimNextTask(meshId, nodeId, sessionId);
|
|
72
|
-
if (!task)
|
|
72
|
+
if (!task) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
73
75
|
|
|
74
76
|
LOG.info('MeshQueue', `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
|
|
75
77
|
|
|
@@ -165,6 +167,7 @@ function buildMeshSystemMessage(args: {
|
|
|
165
167
|
function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
166
168
|
meshId: string;
|
|
167
169
|
sourceInstanceId?: string;
|
|
170
|
+
nodeId?: string;
|
|
168
171
|
nodeLabel: string;
|
|
169
172
|
event: string;
|
|
170
173
|
metadataEvent: Record<string, unknown>;
|
|
@@ -172,7 +175,7 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
172
175
|
// ── Task Queue & Ledger ──
|
|
173
176
|
if (args.event === 'agent:generating_completed') {
|
|
174
177
|
const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
|
|
175
|
-
const nodeId = readNonEmptyString(args.
|
|
178
|
+
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
176
179
|
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
177
180
|
|
|
178
181
|
if (sessionId) {
|
|
@@ -186,7 +189,7 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
186
189
|
}
|
|
187
190
|
} else if (args.event === 'agent:ready') {
|
|
188
191
|
const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
|
|
189
|
-
const nodeId = readNonEmptyString(args.
|
|
192
|
+
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
190
193
|
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
191
194
|
|
|
192
195
|
if (sessionId && nodeId && providerType) {
|
|
@@ -206,7 +209,7 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
206
209
|
try {
|
|
207
210
|
appendLedgerEntry(args.meshId, {
|
|
208
211
|
kind: ledgerKind,
|
|
209
|
-
nodeId: readNonEmptyString(args.
|
|
212
|
+
nodeId: readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId) || undefined,
|
|
210
213
|
sessionId: readNonEmptyString(args.metadataEvent.targetSessionId) || undefined,
|
|
211
214
|
providerType: readNonEmptyString(args.metadataEvent.providerType) || undefined,
|
|
212
215
|
payload: {
|
|
@@ -230,7 +233,7 @@ function injectMeshSystemMessage(components: DaemonComponents, args: {
|
|
|
230
233
|
|
|
231
234
|
recoveryContext = getSessionRecoveryContext(args.meshId, {
|
|
232
235
|
sessionId: readNonEmptyString(args.metadataEvent.targetSessionId) || undefined,
|
|
233
|
-
nodeId: readNonEmptyString(args.
|
|
236
|
+
nodeId: readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId) || undefined,
|
|
234
237
|
maxRetries,
|
|
235
238
|
});
|
|
236
239
|
recoveryContext.failedProviderType = readNonEmptyString(args.metadataEvent.providerType) || null;
|
|
@@ -338,6 +341,7 @@ export function handleMeshForwardEvent(components: DaemonComponents, payload: Re
|
|
|
338
341
|
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : 'Remote agent';
|
|
339
342
|
return injectMeshSystemMessage(components, {
|
|
340
343
|
meshId,
|
|
344
|
+
nodeId,
|
|
341
345
|
nodeLabel,
|
|
342
346
|
event: eventName,
|
|
343
347
|
metadataEvent: {
|
|
@@ -385,6 +389,7 @@ export function setupMeshEventForwarding(components: DaemonComponents) {
|
|
|
385
389
|
// Determine node label. Inline/cloud meshes may be unavailable here, so preserve runtime node id.
|
|
386
390
|
const targetNode = mesh?.nodes?.find((n: any) => n.workspace === workspace);
|
|
387
391
|
const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
|
|
392
|
+
const resolvedNodeId = targetNode?.id || runtimeNodeId;
|
|
388
393
|
const nodeLabel = targetNode
|
|
389
394
|
? `Node '${targetNode.id}'`
|
|
390
395
|
: runtimeNodeId
|
|
@@ -394,6 +399,7 @@ export function setupMeshEventForwarding(components: DaemonComponents) {
|
|
|
394
399
|
injectMeshSystemMessage(components, {
|
|
395
400
|
meshId,
|
|
396
401
|
sourceInstanceId: instanceId,
|
|
402
|
+
nodeId: resolvedNodeId,
|
|
397
403
|
nodeLabel,
|
|
398
404
|
event: event.event,
|
|
399
405
|
metadataEvent: event,
|