@adhdev/daemon-standalone 0.9.77-rc.2 → 0.9.77-rc.20
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 +128 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{index-6WEc6L46.js → index-CWWeDAva.js} +2 -2
- package/public/assets/{terminal-BeBmUW3m.js → terminal-B-dmfv31.js} +11 -11
- package/public/index.html +1 -1
- package/vendor/mcp-server/index.js +155 -25
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -32538,7 +32538,7 @@ Follow these recovery rules:
|
|
|
32538
32538
|
targetSessionId: sessionId,
|
|
32539
32539
|
cliType: providerType,
|
|
32540
32540
|
action: "send_chat",
|
|
32541
|
-
|
|
32541
|
+
message: task.message
|
|
32542
32542
|
}).catch((e) => {
|
|
32543
32543
|
LOG2.error("MeshQueue", `Failed to dispatch task to node ${nodeId}: ${e?.message}`);
|
|
32544
32544
|
});
|
|
@@ -32620,6 +32620,15 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32620
32620
|
}, 500);
|
|
32621
32621
|
}
|
|
32622
32622
|
}
|
|
32623
|
+
} else if (args.event === "agent:ready") {
|
|
32624
|
+
const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
|
|
32625
|
+
const nodeId = readNonEmptyString(args.metadataEvent.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
32626
|
+
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
32627
|
+
if (sessionId && nodeId && providerType) {
|
|
32628
|
+
setTimeout(() => {
|
|
32629
|
+
tryAssignQueueTask(components, args.meshId, nodeId, sessionId, providerType);
|
|
32630
|
+
}, 500);
|
|
32631
|
+
}
|
|
32623
32632
|
} else if (args.event === "agent:stopped") {
|
|
32624
32633
|
const sessionId = readNonEmptyString(args.metadataEvent.targetSessionId);
|
|
32625
32634
|
if (sessionId) {
|
|
@@ -32802,6 +32811,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32802
32811
|
"agent:generating_completed",
|
|
32803
32812
|
"agent:waiting_approval",
|
|
32804
32813
|
"agent:stopped",
|
|
32814
|
+
"agent:ready",
|
|
32805
32815
|
"monitor:long_generating"
|
|
32806
32816
|
]);
|
|
32807
32817
|
EVENT_TO_LEDGER_KIND = {
|
|
@@ -33914,6 +33924,8 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
33914
33924
|
statusHistory = [];
|
|
33915
33925
|
// ─── CLI Scripts (script-based parsing) ───
|
|
33916
33926
|
cliScripts;
|
|
33927
|
+
/** Per-session opaque state object created by cliScripts.createState(), reset on stop. */
|
|
33928
|
+
scriptState = null;
|
|
33917
33929
|
runtimeSettings = {};
|
|
33918
33930
|
/** Full accumulated rendered PTY transcript for parser/readback use */
|
|
33919
33931
|
accumulatedBuffer = "";
|
|
@@ -34095,6 +34107,7 @@ ${lastSnapshot}`;
|
|
|
34095
34107
|
this.cliScripts = scripts;
|
|
34096
34108
|
this.parsedStatusCache = null;
|
|
34097
34109
|
this.parseErrorMessage = null;
|
|
34110
|
+
this.scriptState = typeof scripts.createState === "function" ? scripts.createState() : null;
|
|
34098
34111
|
const scriptNames = listCliScriptNames(scripts);
|
|
34099
34112
|
LOG2.info("CLI", `[${this.cliType}] CLI scripts injected: [${scriptNames.join(", ")}]`);
|
|
34100
34113
|
}
|
|
@@ -34212,6 +34225,7 @@ ${lastSnapshot}`;
|
|
|
34212
34225
|
this.ready = false;
|
|
34213
34226
|
this.startupParseGate = false;
|
|
34214
34227
|
this.spawnAt = 0;
|
|
34228
|
+
this.scriptState = null;
|
|
34215
34229
|
this.onStatusChange?.();
|
|
34216
34230
|
});
|
|
34217
34231
|
this.spawnAt = Date.now();
|
|
@@ -34985,7 +34999,7 @@ ${lastSnapshot}`;
|
|
|
34985
34999
|
scope: this.currentTurnScope,
|
|
34986
35000
|
runtimeSettings: this.runtimeSettings
|
|
34987
35001
|
});
|
|
34988
|
-
const session = this.cliScripts.parseSession({ ...input, tail, tailScreen: buildCliScreenSnapshot(tail) });
|
|
35002
|
+
const session = this.cliScripts.parseSession(this.scriptState, { ...input, tail, tailScreen: buildCliScreenSnapshot(tail) });
|
|
34989
35003
|
this.parseErrorMessage = null;
|
|
34990
35004
|
return session && typeof session === "object" ? session : null;
|
|
34991
35005
|
} catch (e) {
|
|
@@ -34999,7 +35013,7 @@ ${lastSnapshot}`;
|
|
|
34999
35013
|
if (!this.cliScripts?.detectStatus) return null;
|
|
35000
35014
|
try {
|
|
35001
35015
|
const screenText = this.terminalScreen.getText();
|
|
35002
|
-
const status = this.cliScripts.detectStatus({
|
|
35016
|
+
const status = this.cliScripts.detectStatus(this.scriptState, {
|
|
35003
35017
|
tail: text.slice(-500),
|
|
35004
35018
|
screenText,
|
|
35005
35019
|
rawBuffer: this.accumulatedRawBuffer,
|
|
@@ -35018,7 +35032,7 @@ ${lastSnapshot}`;
|
|
|
35018
35032
|
try {
|
|
35019
35033
|
const screenText = this.terminalScreen.getText();
|
|
35020
35034
|
const buffer = screenText || this.accumulatedBuffer;
|
|
35021
|
-
return this.cliScripts.parseApproval({
|
|
35035
|
+
return this.cliScripts.parseApproval(this.scriptState, {
|
|
35022
35036
|
buffer,
|
|
35023
35037
|
screenText,
|
|
35024
35038
|
rawBuffer: this.accumulatedRawBuffer,
|
|
@@ -35126,7 +35140,7 @@ ${lastSnapshot}`;
|
|
|
35126
35140
|
scope: this.currentTurnScope,
|
|
35127
35141
|
runtimeSettings: this.runtimeSettings
|
|
35128
35142
|
});
|
|
35129
|
-
return await Promise.resolve(fn2({
|
|
35143
|
+
return await Promise.resolve(fn2(this.scriptState, {
|
|
35130
35144
|
...input,
|
|
35131
35145
|
args: args && typeof args === "object" ? { ...args } : {}
|
|
35132
35146
|
}));
|
|
@@ -46296,11 +46310,13 @@ ${effect.notification.body || ""}`.trim();
|
|
|
46296
46310
|
async function handlePtyInput(h, args) {
|
|
46297
46311
|
const { cliType, data, targetSessionId } = args || {};
|
|
46298
46312
|
if (!data) return { success: false, error: "data required" };
|
|
46313
|
+
const cleanData = typeof data === "string" ? data.replace(/\x1b\[[?>][0-9;]*c/g, "") : data;
|
|
46314
|
+
if (!cleanData) return { success: true };
|
|
46299
46315
|
const adapter = h.getCliAdapter(targetSessionId || cliType);
|
|
46300
46316
|
if (!adapter || typeof adapter.writeRaw !== "function") {
|
|
46301
46317
|
return { success: false, error: `CLI adapter not found: ${targetSessionId || cliType || "unknown"}` };
|
|
46302
46318
|
}
|
|
46303
|
-
await adapter.writeRaw(
|
|
46319
|
+
await adapter.writeRaw(cleanData);
|
|
46304
46320
|
return { success: true };
|
|
46305
46321
|
}
|
|
46306
46322
|
function handlePtyResize(_h, args) {
|
|
@@ -47918,6 +47934,8 @@ ${effect.notification.body || ""}`.trim();
|
|
|
47918
47934
|
this.completedDebounceTimer = null;
|
|
47919
47935
|
}, 3e3);
|
|
47920
47936
|
}
|
|
47937
|
+
} else if (newStatus === "idle" && this.lastStatus === "starting") {
|
|
47938
|
+
this.pushEvent({ event: "agent:ready", chatTitle, timestamp: now });
|
|
47921
47939
|
} else if (newStatus === "stopped") {
|
|
47922
47940
|
if (this.generatingDebounceTimer) {
|
|
47923
47941
|
clearTimeout(this.generatingDebounceTimer);
|
|
@@ -49653,9 +49671,6 @@ ${rawInput}` : rawInput;
|
|
|
49653
49671
|
const cliType = String(input.cliType || "").trim();
|
|
49654
49672
|
const cliArgs = Array.isArray(input.cliArgs) ? [...input.cliArgs] : [];
|
|
49655
49673
|
const env2 = { ...input.env || {}, ...COORDINATOR_DELEGATED_ENV_UNSETS };
|
|
49656
|
-
if (cliType === "hermes-cli" && !hasCliArg(cliArgs, "--ignore-user-config")) {
|
|
49657
|
-
cliArgs.unshift("--ignore-user-config");
|
|
49658
|
-
}
|
|
49659
49674
|
if (cliType === "claude-cli" && !hasCliArg(cliArgs, "--mcp-config")) {
|
|
49660
49675
|
cliArgs.unshift("--mcp-config", ensureEmptyDelegatedMcpConfig(input.workspace));
|
|
49661
49676
|
}
|
|
@@ -52970,6 +52985,22 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
52970
52985
|
if (!instructions || !template?.trim()) {
|
|
52971
52986
|
return { kind: "unsupported", reason: "Provider manual MCP setup is missing instructions or template" };
|
|
52972
52987
|
}
|
|
52988
|
+
const renderedTemplate = renderMeshCoordinatorTemplate(template, {
|
|
52989
|
+
meshId,
|
|
52990
|
+
workspace,
|
|
52991
|
+
serverName,
|
|
52992
|
+
adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
|
|
52993
|
+
});
|
|
52994
|
+
const isCliCommand = !renderedTemplate.trim().includes("\n") && !renderedTemplate.trim().startsWith("{");
|
|
52995
|
+
if (isCliCommand) {
|
|
52996
|
+
return {
|
|
52997
|
+
kind: "cli_command",
|
|
52998
|
+
serverName,
|
|
52999
|
+
command: renderedTemplate.trim(),
|
|
53000
|
+
requiresRestart: mcpConfig.requiresRestart === true,
|
|
53001
|
+
instructions
|
|
53002
|
+
};
|
|
53003
|
+
}
|
|
52973
53004
|
return {
|
|
52974
53005
|
kind: "manual",
|
|
52975
53006
|
serverName,
|
|
@@ -52977,12 +53008,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
52977
53008
|
configPathCommand: mcpConfig.configPathCommand,
|
|
52978
53009
|
requiresRestart: mcpConfig.requiresRestart === true,
|
|
52979
53010
|
instructions,
|
|
52980
|
-
template:
|
|
52981
|
-
meshId,
|
|
52982
|
-
workspace,
|
|
52983
|
-
serverName,
|
|
52984
|
-
adhdevMcpCommand: options.adhdevMcpCommand || DEFAULT_ADHDEV_MCP_COMMAND
|
|
52985
|
-
})
|
|
53011
|
+
template: renderedTemplate
|
|
52986
53012
|
};
|
|
52987
53013
|
}
|
|
52988
53014
|
return {
|
|
@@ -55156,6 +55182,93 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
55156
55182
|
meshCoordinatorSetup: coordinatorSetup
|
|
55157
55183
|
};
|
|
55158
55184
|
}
|
|
55185
|
+
if (coordinatorSetup.kind === "cli_command") {
|
|
55186
|
+
let cliCmdSystemPrompt = "";
|
|
55187
|
+
try {
|
|
55188
|
+
cliCmdSystemPrompt = buildCoordinatorSystemPrompt2({ mesh, coordinatorCliType: cliType });
|
|
55189
|
+
} catch (error48) {
|
|
55190
|
+
const message = error48?.message || String(error48);
|
|
55191
|
+
LOG2.error("MeshCoordinator", `Failed to build coordinator prompt: ${message}`);
|
|
55192
|
+
return {
|
|
55193
|
+
success: false,
|
|
55194
|
+
code: "mesh_coordinator_prompt_failed",
|
|
55195
|
+
error: `Failed to build Repo Mesh coordinator prompt: ${message}`,
|
|
55196
|
+
meshId,
|
|
55197
|
+
cliType,
|
|
55198
|
+
workspace
|
|
55199
|
+
};
|
|
55200
|
+
}
|
|
55201
|
+
try {
|
|
55202
|
+
const { execFileSync: execCmdSync } = await import("child_process");
|
|
55203
|
+
const cmdParts = coordinatorSetup.command.trim().split(/\s+/);
|
|
55204
|
+
const [regCmd, ...regArgs] = cmdParts;
|
|
55205
|
+
LOG2.info("MeshCoordinator", `Running MCP registration: ${coordinatorSetup.command}`);
|
|
55206
|
+
execCmdSync(regCmd, regArgs, { stdio: "pipe", timeout: 15e3 });
|
|
55207
|
+
} catch (error48) {
|
|
55208
|
+
LOG2.warn("MeshCoordinator", `MCP registration command failed (may be pre-registered): ${error48?.message || error48}`);
|
|
55209
|
+
}
|
|
55210
|
+
const cliCmdArgs = [];
|
|
55211
|
+
const cliCmdEnv = {};
|
|
55212
|
+
if (cliCmdSystemPrompt) {
|
|
55213
|
+
if (cliType === "codex-cli") {
|
|
55214
|
+
cliCmdArgs.push("-c", `developer_instructions=${JSON.stringify(cliCmdSystemPrompt)}`);
|
|
55215
|
+
} else if (cliType === "gemini-cli") {
|
|
55216
|
+
try {
|
|
55217
|
+
const { writeFileSync: wfs, existsSync: efs, readFileSync: rfs } = await import("fs");
|
|
55218
|
+
const geminiMdPath = `${workspace}/GEMINI.md`;
|
|
55219
|
+
const marker = "<!-- adhdev-mesh-coordinator-prompt -->";
|
|
55220
|
+
const markerEnd = "<!-- /adhdev-mesh-coordinator-prompt -->";
|
|
55221
|
+
const block = `${marker}
|
|
55222
|
+
${cliCmdSystemPrompt}
|
|
55223
|
+
${markerEnd}`;
|
|
55224
|
+
if (efs(geminiMdPath)) {
|
|
55225
|
+
const existing = rfs(geminiMdPath, "utf-8");
|
|
55226
|
+
const replaced = existing.replace(
|
|
55227
|
+
new RegExp(`${marker}[\\s\\S]*?${markerEnd}`, "g"),
|
|
55228
|
+
block
|
|
55229
|
+
);
|
|
55230
|
+
wfs(geminiMdPath, replaced.includes(marker) ? replaced : `${existing}
|
|
55231
|
+
|
|
55232
|
+
${block}`);
|
|
55233
|
+
} else {
|
|
55234
|
+
wfs(geminiMdPath, block);
|
|
55235
|
+
}
|
|
55236
|
+
LOG2.info("MeshCoordinator", `Wrote coordinator prompt to ${workspace}/GEMINI.md`);
|
|
55237
|
+
} catch (e) {
|
|
55238
|
+
LOG2.warn("MeshCoordinator", `Could not write GEMINI.md: ${e?.message || e}`);
|
|
55239
|
+
}
|
|
55240
|
+
}
|
|
55241
|
+
}
|
|
55242
|
+
const cliCmdLaunch = await this.deps.cliManager.handleCliCommand("launch_cli", {
|
|
55243
|
+
cliType,
|
|
55244
|
+
dir: workspace,
|
|
55245
|
+
cliArgs: cliCmdArgs.length > 0 ? cliCmdArgs : void 0,
|
|
55246
|
+
env: Object.keys(cliCmdEnv).length > 0 ? cliCmdEnv : void 0,
|
|
55247
|
+
settings: { meshCoordinatorFor: meshId }
|
|
55248
|
+
});
|
|
55249
|
+
if (!cliCmdLaunch?.success) {
|
|
55250
|
+
return { success: false, error: cliCmdLaunch?.error || "Failed to launch CLI session" };
|
|
55251
|
+
}
|
|
55252
|
+
LOG2.info("MeshCoordinator", `Launched ${cliType} coordinator (cli_command) for mesh ${meshId}`);
|
|
55253
|
+
try {
|
|
55254
|
+
const { appendLedgerEntry: appendLedgerEntry2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
55255
|
+
appendLedgerEntry2(meshId, {
|
|
55256
|
+
kind: "coordinator_started",
|
|
55257
|
+
sessionId: cliCmdLaunch.sessionId || cliCmdLaunch.id,
|
|
55258
|
+
providerType: cliType,
|
|
55259
|
+
payload: { workspace }
|
|
55260
|
+
});
|
|
55261
|
+
} catch {
|
|
55262
|
+
}
|
|
55263
|
+
return {
|
|
55264
|
+
success: true,
|
|
55265
|
+
meshId,
|
|
55266
|
+
cliType,
|
|
55267
|
+
workspace,
|
|
55268
|
+
sessionId: cliCmdLaunch.sessionId || cliCmdLaunch.id,
|
|
55269
|
+
mcpRegistered: true
|
|
55270
|
+
};
|
|
55271
|
+
}
|
|
55159
55272
|
const configFormat = coordinatorSetup.configFormat;
|
|
55160
55273
|
if (configFormat !== "claude_mcp_json" && configFormat !== "hermes_config_yaml") {
|
|
55161
55274
|
return {
|