@adhdev/daemon-standalone 0.9.82-rc.115 → 0.9.82-rc.117
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 +132 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +42 -1
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -36903,6 +36903,10 @@ ${effect.notification.body || ""}`.trim();
|
|
|
36903
36903
|
function normalizeApprovalLabel(value) {
|
|
36904
36904
|
return String(value || "").toLowerCase().replace(/^[\s\[(<{]*\d+(?:\s*[.)\]}>:-]|\s)+/, "").replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
36905
36905
|
}
|
|
36906
|
+
function isNegativeApprovalLabel(value) {
|
|
36907
|
+
const label = normalizeApprovalLabel(value);
|
|
36908
|
+
return /^(no|deny|reject|cancel|skip|exit|stop)\b/.test(label) || /\bwithout\b/.test(label) || /\bdo not\b/.test(label);
|
|
36909
|
+
}
|
|
36906
36910
|
function getApprovalPositiveHints(provider) {
|
|
36907
36911
|
const customHints = Array.isArray(provider?.approvalPositiveHints) ? provider.approvalPositiveHints.map((hint) => normalizeApprovalLabel(String(hint || ""))).filter(Boolean) : [];
|
|
36908
36912
|
return customHints.length > 0 ? customHints : DEFAULT_APPROVAL_POSITIVE_HINTS;
|
|
@@ -36910,19 +36914,19 @@ ${effect.notification.body || ""}`.trim();
|
|
|
36910
36914
|
function pickApprovalButton(buttons, provider) {
|
|
36911
36915
|
const labels = (buttons || []).map((button) => String(button || "").trim()).filter(Boolean);
|
|
36912
36916
|
if (labels.length === 0) {
|
|
36913
|
-
return { index:
|
|
36917
|
+
return { index: -1, label: "" };
|
|
36914
36918
|
}
|
|
36915
36919
|
const normalizedButtons = labels.map((label) => normalizeApprovalLabel(label));
|
|
36916
36920
|
const hints = getApprovalPositiveHints(provider);
|
|
36917
36921
|
for (const hint of hints) {
|
|
36918
|
-
const exactIndex = normalizedButtons.findIndex((label) => label === hint);
|
|
36922
|
+
const exactIndex = normalizedButtons.findIndex((label, index) => label === hint && !isNegativeApprovalLabel(labels[index]));
|
|
36919
36923
|
if (exactIndex >= 0) return { index: exactIndex, label: labels[exactIndex] };
|
|
36920
|
-
const prefixIndex = normalizedButtons.findIndex((label) => label.startsWith(hint));
|
|
36924
|
+
const prefixIndex = normalizedButtons.findIndex((label, index) => label.startsWith(hint) && !isNegativeApprovalLabel(labels[index]));
|
|
36921
36925
|
if (prefixIndex >= 0) return { index: prefixIndex, label: labels[prefixIndex] };
|
|
36922
|
-
const includeIndex = normalizedButtons.findIndex((label) => label.includes(hint));
|
|
36926
|
+
const includeIndex = normalizedButtons.findIndex((label, index) => label.includes(hint) && !isNegativeApprovalLabel(labels[index]));
|
|
36923
36927
|
if (includeIndex >= 0) return { index: includeIndex, label: labels[includeIndex] };
|
|
36924
36928
|
}
|
|
36925
|
-
return { index:
|
|
36929
|
+
return { index: -1, label: "" };
|
|
36926
36930
|
}
|
|
36927
36931
|
function formatAutoApprovalMessage(modalMessage, buttonLabel) {
|
|
36928
36932
|
const lines = [`Auto-approved${buttonLabel ? `: ${buttonLabel}` : ""}`];
|
|
@@ -38979,16 +38983,39 @@ ${effect.notification.body || ""}`.trim();
|
|
|
38979
38983
|
return false;
|
|
38980
38984
|
}
|
|
38981
38985
|
function hasSafeNativeHistoryMapping(args) {
|
|
38986
|
+
const isCoordinatorTranscript = args.nativeMessages.some((m) => {
|
|
38987
|
+
const text = typeof m?.content === "string" ? m.content : JSON.stringify(m?.content || "");
|
|
38988
|
+
return text.includes("mesh_send_task") || text.includes("mesh_status") || text.includes("mesh_read_chat") || text.includes("mesh_launch_session");
|
|
38989
|
+
});
|
|
38982
38990
|
const explicitSessionId = String(args.historySessionId || args.providerSessionId || "").trim();
|
|
38983
38991
|
if (explicitSessionId) {
|
|
38984
38992
|
const messageSessionIds = args.nativeMessages.map((message) => typeof message?.historySessionId === "string" ? message.historySessionId.trim() : "").filter(Boolean);
|
|
38985
|
-
if (messageSessionIds.length
|
|
38986
|
-
|
|
38993
|
+
if (messageSessionIds.length > 0) {
|
|
38994
|
+
return messageSessionIds.some((id) => id === explicitSessionId);
|
|
38995
|
+
}
|
|
38996
|
+
if (isCoordinatorTranscript && args.ptyMessages && args.ptyMessages.length > 0) {
|
|
38997
|
+
const ptyHasCoordinator = args.ptyMessages.some((m) => {
|
|
38998
|
+
const text = typeof m?.content === "string" ? m.content : JSON.stringify(m?.content || "");
|
|
38999
|
+
return text.includes("mesh_send_task") || text.includes("mesh_status") || text.includes("mesh_read_chat");
|
|
39000
|
+
});
|
|
39001
|
+
if (!ptyHasCoordinator) {
|
|
39002
|
+
return false;
|
|
39003
|
+
}
|
|
39004
|
+
}
|
|
38987
39005
|
}
|
|
38988
39006
|
const workspace = String(args.workspace || "").trim();
|
|
38989
39007
|
if (!workspace) return false;
|
|
38990
39008
|
const workspaceMatches = args.nativeMessages.some((message) => String(message?.workspace || "").trim() === workspace);
|
|
38991
39009
|
if (!workspaceMatches) return false;
|
|
39010
|
+
if (isCoordinatorTranscript && args.ptyMessages && args.ptyMessages.length > 0) {
|
|
39011
|
+
const ptyHasCoordinator = args.ptyMessages.some((m) => {
|
|
39012
|
+
const text = typeof m?.content === "string" ? m.content : JSON.stringify(m?.content || "");
|
|
39013
|
+
return text.includes("mesh_send_task") || text.includes("mesh_status") || text.includes("mesh_read_chat");
|
|
39014
|
+
});
|
|
39015
|
+
if (!ptyHasCoordinator) {
|
|
39016
|
+
return false;
|
|
39017
|
+
}
|
|
39018
|
+
}
|
|
38992
39019
|
if (!args.requireWorkspaceContentOverlap) return true;
|
|
38993
39020
|
return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
|
|
38994
39021
|
}
|
|
@@ -49808,6 +49835,12 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
49808
49835
|
status.launchBlockedMessage = readStringValue(bootstrap.error) || "Required worktree bootstrap failed; resolve it before launching an agent into this node.";
|
|
49809
49836
|
return;
|
|
49810
49837
|
}
|
|
49838
|
+
if (bootstrap.status === "running" && bootstrap.required !== false) {
|
|
49839
|
+
status.launchReady = false;
|
|
49840
|
+
status.launchBlockedReason = "worktree_bootstrap_running";
|
|
49841
|
+
status.launchBlockedMessage = "Required worktree bootstrap is still running; wait for it to finish before launching an agent into this node.";
|
|
49842
|
+
return;
|
|
49843
|
+
}
|
|
49811
49844
|
}
|
|
49812
49845
|
const connectionState = readStringValue(readObjectRecord(status.connection).state);
|
|
49813
49846
|
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || connectionState === "connected" || isSelfNode);
|
|
@@ -53157,56 +53190,113 @@ ${e?.stderr || ""}`
|
|
|
53157
53190
|
if (!node) return { success: false, error: "Failed to register worktree node" };
|
|
53158
53191
|
this.invalidateAggregateMeshStatus(meshId);
|
|
53159
53192
|
}
|
|
53160
|
-
const
|
|
53161
|
-
|
|
53162
|
-
|
|
53163
|
-
|
|
53164
|
-
|
|
53165
|
-
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
53166
|
-
["submodule", "update", "--init", "--recursive"],
|
|
53167
|
-
{ timeoutMs: 12e4 }
|
|
53168
|
-
);
|
|
53169
|
-
} catch (subErr) {
|
|
53170
|
-
console.warn("[mesh] Submodule init failed for worktree:", subErr.message);
|
|
53193
|
+
const persistWorktreeSetupState = async (bootstrapState2) => {
|
|
53194
|
+
node.worktreeBootstrap = bootstrapState2;
|
|
53195
|
+
if (meshRecord.inline) {
|
|
53196
|
+
this.updateInlineMeshNode(meshId, mesh, node);
|
|
53197
|
+
return;
|
|
53171
53198
|
}
|
|
53172
|
-
}
|
|
53173
|
-
const bootstrapState = await runMeshWorktreeBootstrap(mesh, result.worktreePath);
|
|
53174
|
-
node.worktreeBootstrap = bootstrapState;
|
|
53175
|
-
if (!meshRecord.inline) {
|
|
53176
53199
|
try {
|
|
53177
53200
|
const { updateNode: updateNode2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
53178
|
-
updateNode2(meshId, node.id, { worktreeBootstrap:
|
|
53201
|
+
updateNode2(meshId, node.id, { worktreeBootstrap: bootstrapState2 });
|
|
53179
53202
|
this.invalidateAggregateMeshStatus(meshId);
|
|
53180
53203
|
} catch {
|
|
53181
53204
|
}
|
|
53182
|
-
}
|
|
53183
|
-
|
|
53184
|
-
|
|
53185
|
-
|
|
53186
|
-
|
|
53187
|
-
|
|
53188
|
-
|
|
53189
|
-
|
|
53190
|
-
|
|
53191
|
-
|
|
53192
|
-
|
|
53193
|
-
|
|
53194
|
-
|
|
53195
|
-
|
|
53196
|
-
|
|
53197
|
-
|
|
53198
|
-
|
|
53199
|
-
|
|
53205
|
+
};
|
|
53206
|
+
const appendCloneLedger = async (initSubmodules2, bootstrapState2) => {
|
|
53207
|
+
try {
|
|
53208
|
+
const { appendLedgerEntry: appendLedgerEntry2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
53209
|
+
appendLedgerEntry2(meshId, {
|
|
53210
|
+
kind: "node_cloned",
|
|
53211
|
+
nodeId: node.id,
|
|
53212
|
+
payload: {
|
|
53213
|
+
sourceNodeId,
|
|
53214
|
+
branch: result.branch,
|
|
53215
|
+
worktreePath: result.worktreePath,
|
|
53216
|
+
submodulesInitialized: initSubmodules2,
|
|
53217
|
+
worktreeBootstrap: {
|
|
53218
|
+
status: bootstrapState2.status,
|
|
53219
|
+
required: bootstrapState2.required,
|
|
53220
|
+
configSource: bootstrapState2.configSource,
|
|
53221
|
+
configSourceType: bootstrapState2.configSourceType,
|
|
53222
|
+
lastCommand: bootstrapState2.lastCommand,
|
|
53223
|
+
exitCode: bootstrapState2.exitCode
|
|
53224
|
+
}
|
|
53200
53225
|
}
|
|
53226
|
+
});
|
|
53227
|
+
} catch {
|
|
53228
|
+
}
|
|
53229
|
+
};
|
|
53230
|
+
const initSubmodules = sourceNode.policy?.initSubmodulesOnClone !== false;
|
|
53231
|
+
const loadedBootstrap = loadMeshWorktreeBootstrapConfig(mesh, result.worktreePath);
|
|
53232
|
+
const runningBootstrapState = {
|
|
53233
|
+
status: "running",
|
|
53234
|
+
required: loadedBootstrap.config?.required !== false,
|
|
53235
|
+
configSource: loadedBootstrap.path || loadedBootstrap.source,
|
|
53236
|
+
configSourceType: loadedBootstrap.sourceType,
|
|
53237
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
53238
|
+
};
|
|
53239
|
+
await persistWorktreeSetupState(runningBootstrapState);
|
|
53240
|
+
const finishWorktreeSetup = async () => {
|
|
53241
|
+
let submodulesInitialized2 = false;
|
|
53242
|
+
if (initSubmodules) {
|
|
53243
|
+
try {
|
|
53244
|
+
const { runGit: runGit3 } = await Promise.resolve().then(() => (init_git_executor(), git_executor_exports));
|
|
53245
|
+
await runGit3(
|
|
53246
|
+
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
53247
|
+
["submodule", "update", "--init", "--recursive"],
|
|
53248
|
+
{ timeoutMs: 12e4 }
|
|
53249
|
+
);
|
|
53250
|
+
submodulesInitialized2 = true;
|
|
53251
|
+
} catch (subErr) {
|
|
53252
|
+
console.warn("[mesh] Submodule init failed for worktree:", subErr.message);
|
|
53201
53253
|
}
|
|
53254
|
+
}
|
|
53255
|
+
const bootstrapState2 = await runMeshWorktreeBootstrap(mesh, result.worktreePath);
|
|
53256
|
+
await persistWorktreeSetupState(bootstrapState2);
|
|
53257
|
+
await appendCloneLedger(submodulesInitialized2, bootstrapState2);
|
|
53258
|
+
return { submodulesInitialized: submodulesInitialized2, bootstrapState: bootstrapState2 };
|
|
53259
|
+
};
|
|
53260
|
+
const requestedSetupWaitMs = Number(args?.setupWaitMs ?? args?.bootstrapWaitMs ?? 8e3);
|
|
53261
|
+
const setupWaitMs = Number.isFinite(requestedSetupWaitMs) ? Math.min(Math.max(requestedSetupWaitMs, 0), 14e3) : 8e3;
|
|
53262
|
+
const setupPromise = finishWorktreeSetup();
|
|
53263
|
+
const setupResult = await Promise.race([
|
|
53264
|
+
setupPromise.then((value) => ({ completed: true, value })),
|
|
53265
|
+
new Promise((resolve17) => setTimeout(() => resolve17({ completed: false }), setupWaitMs))
|
|
53266
|
+
]);
|
|
53267
|
+
if (!setupResult.completed) {
|
|
53268
|
+
setupPromise.catch((error48) => {
|
|
53269
|
+
const failedState = {
|
|
53270
|
+
...runningBootstrapState,
|
|
53271
|
+
status: "failed",
|
|
53272
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
53273
|
+
error: error48?.message || String(error48)
|
|
53274
|
+
};
|
|
53275
|
+
void persistWorktreeSetupState(failedState);
|
|
53276
|
+
void appendCloneLedger(false, failedState);
|
|
53202
53277
|
});
|
|
53203
|
-
|
|
53278
|
+
return {
|
|
53279
|
+
success: true,
|
|
53280
|
+
async: true,
|
|
53281
|
+
status: "accepted",
|
|
53282
|
+
node,
|
|
53283
|
+
worktreePath: result.worktreePath,
|
|
53284
|
+
branch: result.branch,
|
|
53285
|
+
worktreeBootstrap: runningBootstrapState,
|
|
53286
|
+
worktreeSetup: {
|
|
53287
|
+
status: "running",
|
|
53288
|
+
setupWaitMs,
|
|
53289
|
+
message: "Worktree node is registered; submodule/bootstrap setup is continuing in the background."
|
|
53290
|
+
}
|
|
53291
|
+
};
|
|
53204
53292
|
}
|
|
53293
|
+
const { submodulesInitialized, bootstrapState } = setupResult.value;
|
|
53205
53294
|
return {
|
|
53206
53295
|
success: true,
|
|
53207
53296
|
node,
|
|
53208
53297
|
worktreePath: result.worktreePath,
|
|
53209
53298
|
branch: result.branch,
|
|
53299
|
+
submodulesInitialized,
|
|
53210
53300
|
worktreeBootstrap: bootstrapState
|
|
53211
53301
|
};
|
|
53212
53302
|
} catch (e) {
|