@adhdev/daemon-core 0.9.82-rc.116 → 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 +107 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/router.ts +106 -39
- package/src/providers/approval-utils.ts +12 -5
package/dist/index.mjs
CHANGED
|
@@ -14577,6 +14577,10 @@ var DEFAULT_APPROVAL_POSITIVE_HINTS = [
|
|
|
14577
14577
|
function normalizeApprovalLabel(value) {
|
|
14578
14578
|
return String(value || "").toLowerCase().replace(/^[\s\[(<{]*\d+(?:\s*[.)\]}>:-]|\s)+/, "").replace(/[^\p{L}\p{N}]+/gu, " ").trim();
|
|
14579
14579
|
}
|
|
14580
|
+
function isNegativeApprovalLabel(value) {
|
|
14581
|
+
const label = normalizeApprovalLabel(value);
|
|
14582
|
+
return /^(no|deny|reject|cancel|skip|exit|stop)\b/.test(label) || /\bwithout\b/.test(label) || /\bdo not\b/.test(label);
|
|
14583
|
+
}
|
|
14580
14584
|
function getApprovalPositiveHints(provider) {
|
|
14581
14585
|
const customHints = Array.isArray(provider?.approvalPositiveHints) ? provider.approvalPositiveHints.map((hint) => normalizeApprovalLabel(String(hint || ""))).filter(Boolean) : [];
|
|
14582
14586
|
return customHints.length > 0 ? customHints : DEFAULT_APPROVAL_POSITIVE_HINTS;
|
|
@@ -14584,19 +14588,19 @@ function getApprovalPositiveHints(provider) {
|
|
|
14584
14588
|
function pickApprovalButton(buttons, provider) {
|
|
14585
14589
|
const labels = (buttons || []).map((button) => String(button || "").trim()).filter(Boolean);
|
|
14586
14590
|
if (labels.length === 0) {
|
|
14587
|
-
return { index:
|
|
14591
|
+
return { index: -1, label: "" };
|
|
14588
14592
|
}
|
|
14589
14593
|
const normalizedButtons = labels.map((label) => normalizeApprovalLabel(label));
|
|
14590
14594
|
const hints = getApprovalPositiveHints(provider);
|
|
14591
14595
|
for (const hint of hints) {
|
|
14592
|
-
const exactIndex = normalizedButtons.findIndex((label) => label === hint);
|
|
14596
|
+
const exactIndex = normalizedButtons.findIndex((label, index) => label === hint && !isNegativeApprovalLabel(labels[index]));
|
|
14593
14597
|
if (exactIndex >= 0) return { index: exactIndex, label: labels[exactIndex] };
|
|
14594
|
-
const prefixIndex = normalizedButtons.findIndex((label) => label.startsWith(hint));
|
|
14598
|
+
const prefixIndex = normalizedButtons.findIndex((label, index) => label.startsWith(hint) && !isNegativeApprovalLabel(labels[index]));
|
|
14595
14599
|
if (prefixIndex >= 0) return { index: prefixIndex, label: labels[prefixIndex] };
|
|
14596
|
-
const includeIndex = normalizedButtons.findIndex((label) => label.includes(hint));
|
|
14600
|
+
const includeIndex = normalizedButtons.findIndex((label, index) => label.includes(hint) && !isNegativeApprovalLabel(labels[index]));
|
|
14597
14601
|
if (includeIndex >= 0) return { index: includeIndex, label: labels[includeIndex] };
|
|
14598
14602
|
}
|
|
14599
|
-
return { index:
|
|
14603
|
+
return { index: -1, label: "" };
|
|
14600
14604
|
}
|
|
14601
14605
|
function formatAutoApprovalMessage(modalMessage, buttonLabel) {
|
|
14602
14606
|
const lines = [`Auto-approved${buttonLabel ? `: ${buttonLabel}` : ""}`];
|
|
@@ -27604,6 +27608,12 @@ function finalizeMeshNodeStatus(args) {
|
|
|
27604
27608
|
status.launchBlockedMessage = readStringValue(bootstrap.error) || "Required worktree bootstrap failed; resolve it before launching an agent into this node.";
|
|
27605
27609
|
return;
|
|
27606
27610
|
}
|
|
27611
|
+
if (bootstrap.status === "running" && bootstrap.required !== false) {
|
|
27612
|
+
status.launchReady = false;
|
|
27613
|
+
status.launchBlockedReason = "worktree_bootstrap_running";
|
|
27614
|
+
status.launchBlockedMessage = "Required worktree bootstrap is still running; wait for it to finish before launching an agent into this node.";
|
|
27615
|
+
return;
|
|
27616
|
+
}
|
|
27607
27617
|
}
|
|
27608
27618
|
const connectionState = readStringValue(readObjectRecord(status.connection).state);
|
|
27609
27619
|
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || connectionState === "connected" || isSelfNode);
|
|
@@ -30953,56 +30963,113 @@ var DaemonCommandRouter = class {
|
|
|
30953
30963
|
if (!node) return { success: false, error: "Failed to register worktree node" };
|
|
30954
30964
|
this.invalidateAggregateMeshStatus(meshId);
|
|
30955
30965
|
}
|
|
30956
|
-
const
|
|
30957
|
-
|
|
30958
|
-
|
|
30959
|
-
|
|
30960
|
-
|
|
30961
|
-
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
30962
|
-
["submodule", "update", "--init", "--recursive"],
|
|
30963
|
-
{ timeoutMs: 12e4 }
|
|
30964
|
-
);
|
|
30965
|
-
} catch (subErr) {
|
|
30966
|
-
console.warn("[mesh] Submodule init failed for worktree:", subErr.message);
|
|
30966
|
+
const persistWorktreeSetupState = async (bootstrapState2) => {
|
|
30967
|
+
node.worktreeBootstrap = bootstrapState2;
|
|
30968
|
+
if (meshRecord.inline) {
|
|
30969
|
+
this.updateInlineMeshNode(meshId, mesh, node);
|
|
30970
|
+
return;
|
|
30967
30971
|
}
|
|
30968
|
-
}
|
|
30969
|
-
const bootstrapState = await runMeshWorktreeBootstrap(mesh, result.worktreePath);
|
|
30970
|
-
node.worktreeBootstrap = bootstrapState;
|
|
30971
|
-
if (!meshRecord.inline) {
|
|
30972
30972
|
try {
|
|
30973
30973
|
const { updateNode: updateNode2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
30974
|
-
updateNode2(meshId, node.id, { worktreeBootstrap:
|
|
30974
|
+
updateNode2(meshId, node.id, { worktreeBootstrap: bootstrapState2 });
|
|
30975
30975
|
this.invalidateAggregateMeshStatus(meshId);
|
|
30976
30976
|
} catch {
|
|
30977
30977
|
}
|
|
30978
|
-
}
|
|
30979
|
-
|
|
30980
|
-
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
30989
|
-
|
|
30990
|
-
|
|
30991
|
-
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
|
|
30995
|
-
|
|
30978
|
+
};
|
|
30979
|
+
const appendCloneLedger = async (initSubmodules2, bootstrapState2) => {
|
|
30980
|
+
try {
|
|
30981
|
+
const { appendLedgerEntry: appendLedgerEntry2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
30982
|
+
appendLedgerEntry2(meshId, {
|
|
30983
|
+
kind: "node_cloned",
|
|
30984
|
+
nodeId: node.id,
|
|
30985
|
+
payload: {
|
|
30986
|
+
sourceNodeId,
|
|
30987
|
+
branch: result.branch,
|
|
30988
|
+
worktreePath: result.worktreePath,
|
|
30989
|
+
submodulesInitialized: initSubmodules2,
|
|
30990
|
+
worktreeBootstrap: {
|
|
30991
|
+
status: bootstrapState2.status,
|
|
30992
|
+
required: bootstrapState2.required,
|
|
30993
|
+
configSource: bootstrapState2.configSource,
|
|
30994
|
+
configSourceType: bootstrapState2.configSourceType,
|
|
30995
|
+
lastCommand: bootstrapState2.lastCommand,
|
|
30996
|
+
exitCode: bootstrapState2.exitCode
|
|
30997
|
+
}
|
|
30996
30998
|
}
|
|
30999
|
+
});
|
|
31000
|
+
} catch {
|
|
31001
|
+
}
|
|
31002
|
+
};
|
|
31003
|
+
const initSubmodules = sourceNode.policy?.initSubmodulesOnClone !== false;
|
|
31004
|
+
const loadedBootstrap = loadMeshWorktreeBootstrapConfig(mesh, result.worktreePath);
|
|
31005
|
+
const runningBootstrapState = {
|
|
31006
|
+
status: "running",
|
|
31007
|
+
required: loadedBootstrap.config?.required !== false,
|
|
31008
|
+
configSource: loadedBootstrap.path || loadedBootstrap.source,
|
|
31009
|
+
configSourceType: loadedBootstrap.sourceType,
|
|
31010
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
31011
|
+
};
|
|
31012
|
+
await persistWorktreeSetupState(runningBootstrapState);
|
|
31013
|
+
const finishWorktreeSetup = async () => {
|
|
31014
|
+
let submodulesInitialized2 = false;
|
|
31015
|
+
if (initSubmodules) {
|
|
31016
|
+
try {
|
|
31017
|
+
const { runGit: runGit3 } = await Promise.resolve().then(() => (init_git_executor(), git_executor_exports));
|
|
31018
|
+
await runGit3(
|
|
31019
|
+
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
31020
|
+
["submodule", "update", "--init", "--recursive"],
|
|
31021
|
+
{ timeoutMs: 12e4 }
|
|
31022
|
+
);
|
|
31023
|
+
submodulesInitialized2 = true;
|
|
31024
|
+
} catch (subErr) {
|
|
31025
|
+
console.warn("[mesh] Submodule init failed for worktree:", subErr.message);
|
|
30997
31026
|
}
|
|
31027
|
+
}
|
|
31028
|
+
const bootstrapState2 = await runMeshWorktreeBootstrap(mesh, result.worktreePath);
|
|
31029
|
+
await persistWorktreeSetupState(bootstrapState2);
|
|
31030
|
+
await appendCloneLedger(submodulesInitialized2, bootstrapState2);
|
|
31031
|
+
return { submodulesInitialized: submodulesInitialized2, bootstrapState: bootstrapState2 };
|
|
31032
|
+
};
|
|
31033
|
+
const requestedSetupWaitMs = Number(args?.setupWaitMs ?? args?.bootstrapWaitMs ?? 8e3);
|
|
31034
|
+
const setupWaitMs = Number.isFinite(requestedSetupWaitMs) ? Math.min(Math.max(requestedSetupWaitMs, 0), 14e3) : 8e3;
|
|
31035
|
+
const setupPromise = finishWorktreeSetup();
|
|
31036
|
+
const setupResult = await Promise.race([
|
|
31037
|
+
setupPromise.then((value) => ({ completed: true, value })),
|
|
31038
|
+
new Promise((resolve17) => setTimeout(() => resolve17({ completed: false }), setupWaitMs))
|
|
31039
|
+
]);
|
|
31040
|
+
if (!setupResult.completed) {
|
|
31041
|
+
setupPromise.catch((error) => {
|
|
31042
|
+
const failedState = {
|
|
31043
|
+
...runningBootstrapState,
|
|
31044
|
+
status: "failed",
|
|
31045
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
31046
|
+
error: error?.message || String(error)
|
|
31047
|
+
};
|
|
31048
|
+
void persistWorktreeSetupState(failedState);
|
|
31049
|
+
void appendCloneLedger(false, failedState);
|
|
30998
31050
|
});
|
|
30999
|
-
|
|
31051
|
+
return {
|
|
31052
|
+
success: true,
|
|
31053
|
+
async: true,
|
|
31054
|
+
status: "accepted",
|
|
31055
|
+
node,
|
|
31056
|
+
worktreePath: result.worktreePath,
|
|
31057
|
+
branch: result.branch,
|
|
31058
|
+
worktreeBootstrap: runningBootstrapState,
|
|
31059
|
+
worktreeSetup: {
|
|
31060
|
+
status: "running",
|
|
31061
|
+
setupWaitMs,
|
|
31062
|
+
message: "Worktree node is registered; submodule/bootstrap setup is continuing in the background."
|
|
31063
|
+
}
|
|
31064
|
+
};
|
|
31000
31065
|
}
|
|
31066
|
+
const { submodulesInitialized, bootstrapState } = setupResult.value;
|
|
31001
31067
|
return {
|
|
31002
31068
|
success: true,
|
|
31003
31069
|
node,
|
|
31004
31070
|
worktreePath: result.worktreePath,
|
|
31005
31071
|
branch: result.branch,
|
|
31072
|
+
submodulesInitialized,
|
|
31006
31073
|
worktreeBootstrap: bootstrapState
|
|
31007
31074
|
};
|
|
31008
31075
|
} catch (e) {
|