@adhdev/daemon-core 0.9.76-rc.32 → 0.9.76-rc.34
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 +119 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -58
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-events.d.ts +9 -0
- package/package.json +1 -1
- package/src/commands/chat-commands.ts +26 -0
- package/src/commands/router.ts +5 -0
- package/src/mesh/mesh-events.ts +76 -33
package/dist/index.mjs
CHANGED
|
@@ -12048,6 +12048,14 @@ function buildChatDebugBundleSummary(bundle) {
|
|
|
12048
12048
|
const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
|
|
12049
12049
|
const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
|
|
12050
12050
|
const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
|
|
12051
|
+
const debugReadChat = readChat.debugReadChat && typeof readChat.debugReadChat === "object" ? readChat.debugReadChat : {};
|
|
12052
|
+
const parsedStatus = cli?.parsedStatus && typeof cli.parsedStatus === "object" ? cli.parsedStatus : null;
|
|
12053
|
+
const cliParsedMessageCount = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages.length : void 0;
|
|
12054
|
+
const readChatReturnedMessages = Array.isArray(readChat.messagesTail) ? readChat.messagesTail.length : void 0;
|
|
12055
|
+
const cliPartialResponse = typeof cli?.partialResponse === "string" ? cli.partialResponse : "";
|
|
12056
|
+
const readChatStatus = typeof readChat.status === "string" ? readChat.status : "";
|
|
12057
|
+
const cliStatus = typeof cli?.status === "string" ? cli.status : "";
|
|
12058
|
+
const cliParsedStatus = typeof parsedStatus?.status === "string" ? parsedStatus.status : "";
|
|
12051
12059
|
return {
|
|
12052
12060
|
createdAt: bundle.createdAt,
|
|
12053
12061
|
targetSessionId: target.targetSessionId,
|
|
@@ -12056,8 +12064,22 @@ function buildChatDebugBundleSummary(bundle) {
|
|
|
12056
12064
|
readChatSuccess: readChat.success,
|
|
12057
12065
|
readChatStatus: readChat.status,
|
|
12058
12066
|
readChatTotalMessages: readChat.totalMessages,
|
|
12067
|
+
readChatReturnedMessages,
|
|
12059
12068
|
cliStatus: cli?.status,
|
|
12069
|
+
cliParsedStatus: cliParsedStatus || void 0,
|
|
12060
12070
|
cliMessageCount: cli?.messageCount,
|
|
12071
|
+
cliParsedMessageCount,
|
|
12072
|
+
cliPartialResponseChars: cliPartialResponse.length,
|
|
12073
|
+
parserAdapterStatusMismatch: Boolean(cliStatus && cliParsedStatus && cliStatus !== cliParsedStatus),
|
|
12074
|
+
parserReadChatStatusMismatch: Boolean(readChatStatus && cliParsedStatus && readChatStatus !== cliParsedStatus),
|
|
12075
|
+
readChatDebug: Object.keys(debugReadChat).length ? {
|
|
12076
|
+
adapterStatus: debugReadChat.adapterStatus,
|
|
12077
|
+
parsedStatus: debugReadChat.parsedStatus,
|
|
12078
|
+
returnedStatus: debugReadChat.returnedStatus,
|
|
12079
|
+
parsedMsgCount: debugReadChat.parsedMsgCount,
|
|
12080
|
+
returnedMsgCount: debugReadChat.returnedMsgCount,
|
|
12081
|
+
shouldPreferAdapterMessages: debugReadChat.shouldPreferAdapterMessages
|
|
12082
|
+
} : void 0,
|
|
12061
12083
|
hasFrontendSnapshot: !!frontend
|
|
12062
12084
|
};
|
|
12063
12085
|
}
|
|
@@ -20333,6 +20355,100 @@ function normalizeExistingPath(filePath) {
|
|
|
20333
20355
|
}
|
|
20334
20356
|
}
|
|
20335
20357
|
|
|
20358
|
+
// src/mesh/mesh-events.ts
|
|
20359
|
+
init_mesh_config();
|
|
20360
|
+
init_logger();
|
|
20361
|
+
function readNonEmptyString(value) {
|
|
20362
|
+
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
20363
|
+
}
|
|
20364
|
+
function formatCompletionMetadata(event) {
|
|
20365
|
+
const parts = [
|
|
20366
|
+
readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
|
|
20367
|
+
readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
|
|
20368
|
+
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
|
|
20369
|
+
].filter(Boolean);
|
|
20370
|
+
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
20371
|
+
}
|
|
20372
|
+
function buildMeshSystemMessage(args) {
|
|
20373
|
+
const metadata = formatCompletionMetadata(args.metadataEvent);
|
|
20374
|
+
if (args.event === "agent:generating_completed") {
|
|
20375
|
+
return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
|
|
20376
|
+
}
|
|
20377
|
+
if (args.event === "agent:waiting_approval") {
|
|
20378
|
+
return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
20379
|
+
}
|
|
20380
|
+
return "";
|
|
20381
|
+
}
|
|
20382
|
+
function injectMeshSystemMessage(components, args) {
|
|
20383
|
+
const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
|
|
20384
|
+
const instState = inst.getState();
|
|
20385
|
+
if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
|
|
20386
|
+
if (args.sourceInstanceId && instState.instanceId === args.sourceInstanceId) return false;
|
|
20387
|
+
return true;
|
|
20388
|
+
});
|
|
20389
|
+
if (coordinatorInstances.length === 0) return { success: true, forwarded: 0 };
|
|
20390
|
+
const messageText = buildMeshSystemMessage({
|
|
20391
|
+
event: args.event,
|
|
20392
|
+
nodeLabel: args.nodeLabel,
|
|
20393
|
+
metadataEvent: args.metadataEvent
|
|
20394
|
+
});
|
|
20395
|
+
if (!messageText) return { success: false, error: "unsupported mesh event" };
|
|
20396
|
+
for (const coord of coordinatorInstances) {
|
|
20397
|
+
const coordState = coord.getState();
|
|
20398
|
+
LOG.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
|
|
20399
|
+
coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
|
|
20400
|
+
}
|
|
20401
|
+
return { success: true, forwarded: coordinatorInstances.length };
|
|
20402
|
+
}
|
|
20403
|
+
function handleMeshForwardEvent(components, payload) {
|
|
20404
|
+
const eventName = readNonEmptyString(payload.event);
|
|
20405
|
+
if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
|
|
20406
|
+
return { success: false, error: "unsupported mesh event" };
|
|
20407
|
+
}
|
|
20408
|
+
const meshId = readNonEmptyString(payload.meshId);
|
|
20409
|
+
if (!meshId) return { success: false, error: "meshId required" };
|
|
20410
|
+
const nodeId = readNonEmptyString(payload.nodeId);
|
|
20411
|
+
const workspace = readNonEmptyString(payload.workspace);
|
|
20412
|
+
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
|
|
20413
|
+
return injectMeshSystemMessage(components, {
|
|
20414
|
+
meshId,
|
|
20415
|
+
nodeLabel,
|
|
20416
|
+
event: eventName,
|
|
20417
|
+
metadataEvent: {
|
|
20418
|
+
targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId),
|
|
20419
|
+
providerType: readNonEmptyString(payload.providerType),
|
|
20420
|
+
providerSessionId: readNonEmptyString(payload.providerSessionId)
|
|
20421
|
+
}
|
|
20422
|
+
});
|
|
20423
|
+
}
|
|
20424
|
+
function setupMeshEventForwarding(components) {
|
|
20425
|
+
components.instanceManager.onEvent((event) => {
|
|
20426
|
+
if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
|
|
20427
|
+
const instanceId = readNonEmptyString(event.instanceId);
|
|
20428
|
+
if (!instanceId) return;
|
|
20429
|
+
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
20430
|
+
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
20431
|
+
const state = sourceInstance.getState();
|
|
20432
|
+
const workspace = readNonEmptyString(state.workspace);
|
|
20433
|
+
if (!workspace) return;
|
|
20434
|
+
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
20435
|
+
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
|
|
20436
|
+
const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
|
|
20437
|
+
const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
|
|
20438
|
+
if (!meshId) return;
|
|
20439
|
+
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
20440
|
+
const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
|
|
20441
|
+
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
20442
|
+
injectMeshSystemMessage(components, {
|
|
20443
|
+
meshId,
|
|
20444
|
+
sourceInstanceId: instanceId,
|
|
20445
|
+
nodeLabel,
|
|
20446
|
+
event: event.event,
|
|
20447
|
+
metadataEvent: event
|
|
20448
|
+
});
|
|
20449
|
+
});
|
|
20450
|
+
}
|
|
20451
|
+
|
|
20336
20452
|
// src/status/snapshot.ts
|
|
20337
20453
|
init_config();
|
|
20338
20454
|
import * as os18 from "os";
|
|
@@ -21302,6 +21418,9 @@ var DaemonCommandRouter = class {
|
|
|
21302
21418
|
async executeDaemonCommand(cmd, args) {
|
|
21303
21419
|
switch (cmd) {
|
|
21304
21420
|
// ─── CLI / ACP commands ───
|
|
21421
|
+
case "mesh_forward_event": {
|
|
21422
|
+
return handleMeshForwardEvent({ instanceManager: this.deps.instanceManager }, args);
|
|
21423
|
+
}
|
|
21305
21424
|
case "launch_cli":
|
|
21306
21425
|
case "stop_cli":
|
|
21307
21426
|
case "set_cli_view_mode":
|
|
@@ -29929,64 +30048,6 @@ var SessionRegistry = class {
|
|
|
29929
30048
|
// src/boot/daemon-lifecycle.ts
|
|
29930
30049
|
init_logger();
|
|
29931
30050
|
init_config();
|
|
29932
|
-
|
|
29933
|
-
// src/mesh/mesh-events.ts
|
|
29934
|
-
init_mesh_config();
|
|
29935
|
-
init_logger();
|
|
29936
|
-
function readNonEmptyString(value) {
|
|
29937
|
-
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
29938
|
-
}
|
|
29939
|
-
function formatCompletionMetadata(event) {
|
|
29940
|
-
const parts = [
|
|
29941
|
-
readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
|
|
29942
|
-
readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
|
|
29943
|
-
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
|
|
29944
|
-
].filter(Boolean);
|
|
29945
|
-
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
29946
|
-
}
|
|
29947
|
-
function setupMeshEventForwarding(components) {
|
|
29948
|
-
components.instanceManager.onEvent((event) => {
|
|
29949
|
-
if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
|
|
29950
|
-
const instanceId = readNonEmptyString(event.instanceId);
|
|
29951
|
-
if (!instanceId) return;
|
|
29952
|
-
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
29953
|
-
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
29954
|
-
const state = sourceInstance.getState();
|
|
29955
|
-
const workspace = readNonEmptyString(state.workspace);
|
|
29956
|
-
if (!workspace) return;
|
|
29957
|
-
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
29958
|
-
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
|
|
29959
|
-
const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
|
|
29960
|
-
const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
|
|
29961
|
-
if (!meshId) return;
|
|
29962
|
-
const allInstances = components.instanceManager.getByCategory("cli");
|
|
29963
|
-
const coordinatorInstances = allInstances.filter((inst) => {
|
|
29964
|
-
const instState = inst.getState();
|
|
29965
|
-
if (instState.settings?.meshCoordinatorFor !== meshId) return false;
|
|
29966
|
-
if (instState.instanceId === instanceId) return false;
|
|
29967
|
-
return true;
|
|
29968
|
-
});
|
|
29969
|
-
if (coordinatorInstances.length === 0) return;
|
|
29970
|
-
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
29971
|
-
const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
|
|
29972
|
-
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
29973
|
-
const metadata = formatCompletionMetadata(event);
|
|
29974
|
-
let messageText = "";
|
|
29975
|
-
if (event.event === "agent:generating_completed") {
|
|
29976
|
-
messageText = `[System] ${nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
|
|
29977
|
-
} else if (event.event === "agent:waiting_approval") {
|
|
29978
|
-
messageText = `[System] ${nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
29979
|
-
}
|
|
29980
|
-
if (!messageText) return;
|
|
29981
|
-
for (const coord of coordinatorInstances) {
|
|
29982
|
-
const coordState = coord.getState();
|
|
29983
|
-
LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
|
|
29984
|
-
coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
|
|
29985
|
-
}
|
|
29986
|
-
});
|
|
29987
|
-
}
|
|
29988
|
-
|
|
29989
|
-
// src/boot/daemon-lifecycle.ts
|
|
29990
30051
|
async function initDaemonComponents(config) {
|
|
29991
30052
|
installGlobalInterceptor();
|
|
29992
30053
|
const appConfig = loadConfig();
|