@adhdev/daemon-standalone 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/package.json +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}` : ""}`];
|
|
@@ -49831,6 +49835,12 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
49831
49835
|
status.launchBlockedMessage = readStringValue(bootstrap.error) || "Required worktree bootstrap failed; resolve it before launching an agent into this node.";
|
|
49832
49836
|
return;
|
|
49833
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
|
+
}
|
|
49834
49844
|
}
|
|
49835
49845
|
const connectionState = readStringValue(readObjectRecord(status.connection).state);
|
|
49836
49846
|
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || connectionState === "connected" || isSelfNode);
|
|
@@ -53180,56 +53190,113 @@ ${e?.stderr || ""}`
|
|
|
53180
53190
|
if (!node) return { success: false, error: "Failed to register worktree node" };
|
|
53181
53191
|
this.invalidateAggregateMeshStatus(meshId);
|
|
53182
53192
|
}
|
|
53183
|
-
const
|
|
53184
|
-
|
|
53185
|
-
|
|
53186
|
-
|
|
53187
|
-
|
|
53188
|
-
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
53189
|
-
["submodule", "update", "--init", "--recursive"],
|
|
53190
|
-
{ timeoutMs: 12e4 }
|
|
53191
|
-
);
|
|
53192
|
-
} catch (subErr) {
|
|
53193
|
-
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;
|
|
53194
53198
|
}
|
|
53195
|
-
}
|
|
53196
|
-
const bootstrapState = await runMeshWorktreeBootstrap(mesh, result.worktreePath);
|
|
53197
|
-
node.worktreeBootstrap = bootstrapState;
|
|
53198
|
-
if (!meshRecord.inline) {
|
|
53199
53199
|
try {
|
|
53200
53200
|
const { updateNode: updateNode2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
53201
|
-
updateNode2(meshId, node.id, { worktreeBootstrap:
|
|
53201
|
+
updateNode2(meshId, node.id, { worktreeBootstrap: bootstrapState2 });
|
|
53202
53202
|
this.invalidateAggregateMeshStatus(meshId);
|
|
53203
53203
|
} catch {
|
|
53204
53204
|
}
|
|
53205
|
-
}
|
|
53206
|
-
|
|
53207
|
-
|
|
53208
|
-
|
|
53209
|
-
|
|
53210
|
-
|
|
53211
|
-
|
|
53212
|
-
|
|
53213
|
-
|
|
53214
|
-
|
|
53215
|
-
|
|
53216
|
-
|
|
53217
|
-
|
|
53218
|
-
|
|
53219
|
-
|
|
53220
|
-
|
|
53221
|
-
|
|
53222
|
-
|
|
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
|
+
}
|
|
53223
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);
|
|
53224
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);
|
|
53225
53277
|
});
|
|
53226
|
-
|
|
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
|
+
};
|
|
53227
53292
|
}
|
|
53293
|
+
const { submodulesInitialized, bootstrapState } = setupResult.value;
|
|
53228
53294
|
return {
|
|
53229
53295
|
success: true,
|
|
53230
53296
|
node,
|
|
53231
53297
|
worktreePath: result.worktreePath,
|
|
53232
53298
|
branch: result.branch,
|
|
53299
|
+
submodulesInitialized,
|
|
53233
53300
|
worktreeBootstrap: bootstrapState
|
|
53234
53301
|
};
|
|
53235
53302
|
} catch (e) {
|