@adhdev/daemon-core 0.9.76-rc.31 → 0.9.76-rc.33
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 +99 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -61
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-events.d.ts +9 -0
- package/package.json +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +7 -3
- package/src/commands/router.ts +5 -0
- package/src/mesh/mesh-events.ts +76 -33
package/dist/index.js
CHANGED
|
@@ -3274,9 +3274,8 @@ ${lastSnapshot}`;
|
|
|
3274
3274
|
};
|
|
3275
3275
|
this.recordTrace("submit_echo_missing", diagnostic);
|
|
3276
3276
|
if (this.requirePromptEchoBeforeSubmit) {
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
completion.rejectOnce(new Error(message));
|
|
3277
|
+
LOG.warn("CLI", `[${this.cliType}] prompt echo was not observed before submit; sending guarded submit key anyway elapsed=${elapsed}ms maxEchoWaitMs=${state.maxEchoWaitMs} screen=${JSON.stringify(diagnostic.screenText).slice(0, 240)}`);
|
|
3278
|
+
this.submitSendKey(state, completion);
|
|
3280
3279
|
return;
|
|
3281
3280
|
}
|
|
3282
3281
|
LOG.warn("CLI", `[${this.cliType}] prompt echo was not observed before submit; sending submit key anyway elapsed=${elapsed}ms maxEchoWaitMs=${state.maxEchoWaitMs}`);
|
|
@@ -20526,6 +20525,100 @@ function normalizeExistingPath(filePath) {
|
|
|
20526
20525
|
}
|
|
20527
20526
|
}
|
|
20528
20527
|
|
|
20528
|
+
// src/mesh/mesh-events.ts
|
|
20529
|
+
init_mesh_config();
|
|
20530
|
+
init_logger();
|
|
20531
|
+
function readNonEmptyString(value) {
|
|
20532
|
+
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
20533
|
+
}
|
|
20534
|
+
function formatCompletionMetadata(event) {
|
|
20535
|
+
const parts = [
|
|
20536
|
+
readNonEmptyString(event.targetSessionId) ? `session_id=${readNonEmptyString(event.targetSessionId)}` : "",
|
|
20537
|
+
readNonEmptyString(event.providerType) ? `provider=${readNonEmptyString(event.providerType)}` : "",
|
|
20538
|
+
readNonEmptyString(event.providerSessionId) ? `provider_session_id=${readNonEmptyString(event.providerSessionId)}` : ""
|
|
20539
|
+
].filter(Boolean);
|
|
20540
|
+
return parts.length > 0 ? ` (${parts.join("; ")})` : "";
|
|
20541
|
+
}
|
|
20542
|
+
function buildMeshSystemMessage(args) {
|
|
20543
|
+
const metadata = formatCompletionMetadata(args.metadataEvent);
|
|
20544
|
+
if (args.event === "agent:generating_completed") {
|
|
20545
|
+
return `[System] ${args.nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
|
|
20546
|
+
}
|
|
20547
|
+
if (args.event === "agent:waiting_approval") {
|
|
20548
|
+
return `[System] ${args.nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
20549
|
+
}
|
|
20550
|
+
return "";
|
|
20551
|
+
}
|
|
20552
|
+
function injectMeshSystemMessage(components, args) {
|
|
20553
|
+
const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
|
|
20554
|
+
const instState = inst.getState();
|
|
20555
|
+
if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
|
|
20556
|
+
if (args.sourceInstanceId && instState.instanceId === args.sourceInstanceId) return false;
|
|
20557
|
+
return true;
|
|
20558
|
+
});
|
|
20559
|
+
if (coordinatorInstances.length === 0) return { success: true, forwarded: 0 };
|
|
20560
|
+
const messageText = buildMeshSystemMessage({
|
|
20561
|
+
event: args.event,
|
|
20562
|
+
nodeLabel: args.nodeLabel,
|
|
20563
|
+
metadataEvent: args.metadataEvent
|
|
20564
|
+
});
|
|
20565
|
+
if (!messageText) return { success: false, error: "unsupported mesh event" };
|
|
20566
|
+
for (const coord of coordinatorInstances) {
|
|
20567
|
+
const coordState = coord.getState();
|
|
20568
|
+
LOG.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}`);
|
|
20569
|
+
coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
|
|
20570
|
+
}
|
|
20571
|
+
return { success: true, forwarded: coordinatorInstances.length };
|
|
20572
|
+
}
|
|
20573
|
+
function handleMeshForwardEvent(components, payload) {
|
|
20574
|
+
const eventName = readNonEmptyString(payload.event);
|
|
20575
|
+
if (eventName !== "agent:generating_completed" && eventName !== "agent:waiting_approval") {
|
|
20576
|
+
return { success: false, error: "unsupported mesh event" };
|
|
20577
|
+
}
|
|
20578
|
+
const meshId = readNonEmptyString(payload.meshId);
|
|
20579
|
+
if (!meshId) return { success: false, error: "meshId required" };
|
|
20580
|
+
const nodeId = readNonEmptyString(payload.nodeId);
|
|
20581
|
+
const workspace = readNonEmptyString(payload.workspace);
|
|
20582
|
+
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
|
|
20583
|
+
return injectMeshSystemMessage(components, {
|
|
20584
|
+
meshId,
|
|
20585
|
+
nodeLabel,
|
|
20586
|
+
event: eventName,
|
|
20587
|
+
metadataEvent: {
|
|
20588
|
+
targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId),
|
|
20589
|
+
providerType: readNonEmptyString(payload.providerType),
|
|
20590
|
+
providerSessionId: readNonEmptyString(payload.providerSessionId)
|
|
20591
|
+
}
|
|
20592
|
+
});
|
|
20593
|
+
}
|
|
20594
|
+
function setupMeshEventForwarding(components) {
|
|
20595
|
+
components.instanceManager.onEvent((event) => {
|
|
20596
|
+
if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
|
|
20597
|
+
const instanceId = readNonEmptyString(event.instanceId);
|
|
20598
|
+
if (!instanceId) return;
|
|
20599
|
+
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
20600
|
+
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
20601
|
+
const state = sourceInstance.getState();
|
|
20602
|
+
const workspace = readNonEmptyString(state.workspace);
|
|
20603
|
+
if (!workspace) return;
|
|
20604
|
+
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
20605
|
+
const meshIdFromRuntime = readNonEmptyString(settings.meshNodeFor);
|
|
20606
|
+
const mesh = meshIdFromRuntime ? getMesh(meshIdFromRuntime) : getMeshByRepo(workspace);
|
|
20607
|
+
const meshId = meshIdFromRuntime || readNonEmptyString(mesh?.id);
|
|
20608
|
+
if (!meshId) return;
|
|
20609
|
+
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
20610
|
+
const runtimeNodeId = readNonEmptyString(settings.meshNodeId);
|
|
20611
|
+
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
20612
|
+
injectMeshSystemMessage(components, {
|
|
20613
|
+
meshId,
|
|
20614
|
+
sourceInstanceId: instanceId,
|
|
20615
|
+
nodeLabel,
|
|
20616
|
+
event: event.event,
|
|
20617
|
+
metadataEvent: event
|
|
20618
|
+
});
|
|
20619
|
+
});
|
|
20620
|
+
}
|
|
20621
|
+
|
|
20529
20622
|
// src/status/snapshot.ts
|
|
20530
20623
|
var os18 = __toESM(require("os"));
|
|
20531
20624
|
init_config();
|
|
@@ -21495,6 +21588,9 @@ var DaemonCommandRouter = class {
|
|
|
21495
21588
|
async executeDaemonCommand(cmd, args) {
|
|
21496
21589
|
switch (cmd) {
|
|
21497
21590
|
// ─── CLI / ACP commands ───
|
|
21591
|
+
case "mesh_forward_event": {
|
|
21592
|
+
return handleMeshForwardEvent({ instanceManager: this.deps.instanceManager }, args);
|
|
21593
|
+
}
|
|
21498
21594
|
case "launch_cli":
|
|
21499
21595
|
case "stop_cli":
|
|
21500
21596
|
case "set_cli_view_mode":
|
|
@@ -30117,64 +30213,6 @@ var SessionRegistry = class {
|
|
|
30117
30213
|
// src/boot/daemon-lifecycle.ts
|
|
30118
30214
|
init_logger();
|
|
30119
30215
|
init_config();
|
|
30120
|
-
|
|
30121
|
-
// src/mesh/mesh-events.ts
|
|
30122
|
-
init_mesh_config();
|
|
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
|
-
}
|
|
30135
|
-
function setupMeshEventForwarding(components) {
|
|
30136
|
-
components.instanceManager.onEvent((event) => {
|
|
30137
|
-
if (event.event !== "agent:generating_completed" && event.event !== "agent:waiting_approval") return;
|
|
30138
|
-
const instanceId = readNonEmptyString(event.instanceId);
|
|
30139
|
-
if (!instanceId) return;
|
|
30140
|
-
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
30141
|
-
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
30142
|
-
const state = sourceInstance.getState();
|
|
30143
|
-
const workspace = readNonEmptyString(state.workspace);
|
|
30144
|
-
if (!workspace) return;
|
|
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;
|
|
30150
|
-
const allInstances = components.instanceManager.getByCategory("cli");
|
|
30151
|
-
const coordinatorInstances = allInstances.filter((inst) => {
|
|
30152
|
-
const instState = inst.getState();
|
|
30153
|
-
if (instState.settings?.meshCoordinatorFor !== meshId) return false;
|
|
30154
|
-
if (instState.instanceId === instanceId) return false;
|
|
30155
|
-
return true;
|
|
30156
|
-
});
|
|
30157
|
-
if (coordinatorInstances.length === 0) return;
|
|
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);
|
|
30162
|
-
let messageText = "";
|
|
30163
|
-
if (event.event === "agent:generating_completed") {
|
|
30164
|
-
messageText = `[System] ${nodeLabel} has completed its task and is now idle${metadata}. You may use mesh_read_chat to review its progress.`;
|
|
30165
|
-
} else if (event.event === "agent:waiting_approval") {
|
|
30166
|
-
messageText = `[System] ${nodeLabel} is waiting for approval to proceed${metadata}. You may use mesh_read_chat and mesh_approve to handle it.`;
|
|
30167
|
-
}
|
|
30168
|
-
if (!messageText) return;
|
|
30169
|
-
for (const coord of coordinatorInstances) {
|
|
30170
|
-
const coordState = coord.getState();
|
|
30171
|
-
LOG.info("MeshEvents", `Forwarding event from ${workspace} to coordinator ${coordState.instanceId}`);
|
|
30172
|
-
coord.onEvent("send_message", { input: { text: messageText, textFallback: messageText } });
|
|
30173
|
-
}
|
|
30174
|
-
});
|
|
30175
|
-
}
|
|
30176
|
-
|
|
30177
|
-
// src/boot/daemon-lifecycle.ts
|
|
30178
30216
|
async function initDaemonComponents(config) {
|
|
30179
30217
|
installGlobalInterceptor();
|
|
30180
30218
|
const appConfig = loadConfig();
|