adhdev 0.9.82-rc.58 → 0.9.82-rc.59
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/cli/index.js +367 -66
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +367 -66
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/vendor/mcp-server/index.js +114 -20
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -6541,6 +6541,7 @@ __export(mesh_ledger_exports, {
|
|
|
6541
6541
|
getSessionRecoveryContext: () => getSessionRecoveryContext,
|
|
6542
6542
|
isIntentionalCleanupStopEntry: () => isIntentionalCleanupStopEntry,
|
|
6543
6543
|
meshLedgerEvents: () => meshLedgerEvents,
|
|
6544
|
+
normalizeMeshWorkerResult: () => normalizeMeshWorkerResult,
|
|
6544
6545
|
readLedgerEntries: () => readLedgerEntries,
|
|
6545
6546
|
readLedgerSlice: () => readLedgerSlice
|
|
6546
6547
|
});
|
|
@@ -6564,6 +6565,86 @@ function getRotatedPath(meshId, index) {
|
|
|
6564
6565
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
6565
6566
|
return (0, import_path4.join)(getLedgerDir(), `${safe}.${index}.jsonl`);
|
|
6566
6567
|
}
|
|
6568
|
+
function readNonEmptyString(value) {
|
|
6569
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
6570
|
+
}
|
|
6571
|
+
function readStringArray(value) {
|
|
6572
|
+
if (!Array.isArray(value)) return [];
|
|
6573
|
+
return value.map((item) => readNonEmptyString(item)).filter(Boolean);
|
|
6574
|
+
}
|
|
6575
|
+
function extractJsonObjectFromSummary(summary) {
|
|
6576
|
+
const text = readNonEmptyString(summary);
|
|
6577
|
+
if (!text) return void 0;
|
|
6578
|
+
const fenced = text.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
6579
|
+
const candidates = [fenced?.[1], text].filter(Boolean);
|
|
6580
|
+
for (const candidate of candidates) {
|
|
6581
|
+
const trimmed = candidate.trim();
|
|
6582
|
+
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) continue;
|
|
6583
|
+
try {
|
|
6584
|
+
const parsed = JSON.parse(trimmed);
|
|
6585
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
|
6586
|
+
} catch {
|
|
6587
|
+
}
|
|
6588
|
+
}
|
|
6589
|
+
return void 0;
|
|
6590
|
+
}
|
|
6591
|
+
function normalizeValidationResults(value) {
|
|
6592
|
+
if (!Array.isArray(value)) return [];
|
|
6593
|
+
return value.filter((item) => item && typeof item === "object" && !Array.isArray(item)).map((item) => {
|
|
6594
|
+
const status = ["passed", "failed", "skipped", "unknown"].includes(item.status) ? item.status : "unknown";
|
|
6595
|
+
return {
|
|
6596
|
+
...readNonEmptyString(item.command) ? { command: readNonEmptyString(item.command) } : {},
|
|
6597
|
+
status,
|
|
6598
|
+
...Number.isFinite(Number(item.durationMs)) ? { durationMs: Number(item.durationMs) } : {},
|
|
6599
|
+
...readNonEmptyString(item.outputPath) ? { outputPath: readNonEmptyString(item.outputPath) } : {},
|
|
6600
|
+
...readNonEmptyString(item.summary) ? { summary: readNonEmptyString(item.summary) } : {}
|
|
6601
|
+
};
|
|
6602
|
+
});
|
|
6603
|
+
}
|
|
6604
|
+
function normalizeProcessArtifacts(value) {
|
|
6605
|
+
if (!Array.isArray(value)) return [];
|
|
6606
|
+
const kinds = /* @__PURE__ */ new Set(["process", "log", "port", "window", "session", "file", "url", "other"]);
|
|
6607
|
+
return value.filter((item) => item && typeof item === "object" && !Array.isArray(item)).map((item) => ({
|
|
6608
|
+
kind: kinds.has(item.kind) ? item.kind : "other",
|
|
6609
|
+
...readNonEmptyString(item.id) ? { id: readNonEmptyString(item.id) } : {},
|
|
6610
|
+
...readNonEmptyString(item.label) ? { label: readNonEmptyString(item.label) } : {},
|
|
6611
|
+
...readNonEmptyString(item.locator) ? { locator: readNonEmptyString(item.locator) } : {},
|
|
6612
|
+
...Number.isFinite(Number(item.pid)) ? { pid: Number(item.pid) } : {},
|
|
6613
|
+
...Number.isFinite(Number(item.port)) ? { port: Number(item.port) } : {},
|
|
6614
|
+
...readNonEmptyString(item.url) ? { url: readNonEmptyString(item.url) } : {},
|
|
6615
|
+
...readNonEmptyString(item.path) ? { path: readNonEmptyString(item.path) } : {},
|
|
6616
|
+
...readNonEmptyString(item.sessionId) ? { sessionId: readNonEmptyString(item.sessionId) } : {},
|
|
6617
|
+
...typeof item.keepRunning === "boolean" ? { keepRunning: item.keepRunning } : {},
|
|
6618
|
+
...item.metadata && typeof item.metadata === "object" && !Array.isArray(item.metadata) ? { metadata: item.metadata } : {}
|
|
6619
|
+
}));
|
|
6620
|
+
}
|
|
6621
|
+
function normalizeMeshWorkerResult(input, source = "explicit_metadata") {
|
|
6622
|
+
const raw = input && typeof input === "object" ? input : {};
|
|
6623
|
+
const status = ["completed", "failed", "blocked", "partial", "unknown"].includes(String(raw.status)) ? raw.status : "unknown";
|
|
6624
|
+
const gitStatus = raw.gitStatus && typeof raw.gitStatus === "object" && !Array.isArray(raw.gitStatus) ? raw.gitStatus : void 0;
|
|
6625
|
+
return {
|
|
6626
|
+
status,
|
|
6627
|
+
...readNonEmptyString(raw.classification) ? { classification: readNonEmptyString(raw.classification) } : {},
|
|
6628
|
+
changedFiles: readStringArray(raw.changedFiles),
|
|
6629
|
+
validationResults: normalizeValidationResults(raw.validationResults),
|
|
6630
|
+
...gitStatus ? { gitStatus } : {},
|
|
6631
|
+
processArtifacts: normalizeProcessArtifacts(raw.processArtifacts),
|
|
6632
|
+
errors: readStringArray(raw.errors),
|
|
6633
|
+
...readNonEmptyString(raw.nextAction) ? { nextAction: readNonEmptyString(raw.nextAction) } : {},
|
|
6634
|
+
requiresUserAction: raw.requiresUserAction === true,
|
|
6635
|
+
source
|
|
6636
|
+
};
|
|
6637
|
+
}
|
|
6638
|
+
function resolveWorkerResult(opts) {
|
|
6639
|
+
if (opts.workerResult && typeof opts.workerResult === "object") {
|
|
6640
|
+
return normalizeMeshWorkerResult(opts.workerResult, "explicit_metadata");
|
|
6641
|
+
}
|
|
6642
|
+
const parsed = extractJsonObjectFromSummary(opts.finalSummary);
|
|
6643
|
+
if (parsed) {
|
|
6644
|
+
return normalizeMeshWorkerResult(parsed, "final_summary_json");
|
|
6645
|
+
}
|
|
6646
|
+
return normalizeMeshWorkerResult(void 0, "default");
|
|
6647
|
+
}
|
|
6567
6648
|
function buildTaskCompletionEvidence(opts) {
|
|
6568
6649
|
const providerSessionId = opts.providerSessionId?.trim() || void 0;
|
|
6569
6650
|
const providerType = opts.providerType?.trim() || void 0;
|
|
@@ -6580,6 +6661,7 @@ function buildTaskCompletionEvidence(opts) {
|
|
|
6580
6661
|
providerSessionId,
|
|
6581
6662
|
finalSummaryAvailable: typeof opts.finalSummary === "string" && opts.finalSummary.trim().length > 0
|
|
6582
6663
|
},
|
|
6664
|
+
workerResult: resolveWorkerResult(opts),
|
|
6583
6665
|
git: {
|
|
6584
6666
|
status: "deferred",
|
|
6585
6667
|
reason: "ordinary_completion_git_status_not_checked"
|
|
@@ -7298,16 +7380,45 @@ var mesh_work_queue_exports = {};
|
|
|
7298
7380
|
__export(mesh_work_queue_exports, {
|
|
7299
7381
|
ACTIVE_MESH_QUEUE_STATUSES: () => ACTIVE_MESH_QUEUE_STATUSES,
|
|
7300
7382
|
HISTORICAL_MESH_QUEUE_STATUSES: () => HISTORICAL_MESH_QUEUE_STATUSES,
|
|
7383
|
+
MESH_TASK_MODES: () => MESH_TASK_MODES,
|
|
7301
7384
|
cancelTask: () => cancelTask,
|
|
7302
7385
|
claimNextTask: () => claimNextTask,
|
|
7303
7386
|
enqueueTask: () => enqueueTask,
|
|
7304
7387
|
getMeshQueueStats: () => getMeshQueueStats,
|
|
7305
7388
|
getQueue: () => getQueue,
|
|
7389
|
+
normalizeMeshTaskMode: () => normalizeMeshTaskMode,
|
|
7306
7390
|
recordTaskAutoLaunch: () => recordTaskAutoLaunch,
|
|
7307
7391
|
requeueTask: () => requeueTask,
|
|
7308
7392
|
updateSessionTaskStatus: () => updateSessionTaskStatus,
|
|
7309
|
-
updateTaskStatus: () => updateTaskStatus
|
|
7393
|
+
updateTaskStatus: () => updateTaskStatus,
|
|
7394
|
+
validateMeshTaskModeRequest: () => validateMeshTaskModeRequest
|
|
7310
7395
|
});
|
|
7396
|
+
function normalizeMeshTaskMode(value) {
|
|
7397
|
+
if (typeof value !== "string") return void 0;
|
|
7398
|
+
const normalized = value.trim();
|
|
7399
|
+
return MESH_TASK_MODES.includes(normalized) ? normalized : void 0;
|
|
7400
|
+
}
|
|
7401
|
+
function validateMeshTaskModeRequest(mode, message) {
|
|
7402
|
+
const taskMode = normalizeMeshTaskMode(mode);
|
|
7403
|
+
if (!taskMode) {
|
|
7404
|
+
return { valid: true, violations: [] };
|
|
7405
|
+
}
|
|
7406
|
+
if (taskMode !== "live_debug_readonly") {
|
|
7407
|
+
return { valid: true, taskMode, violations: [] };
|
|
7408
|
+
}
|
|
7409
|
+
const violations = LIVE_DEBUG_READONLY_FORBIDDEN.filter((rule) => rule.pattern.test(message || "")).map((rule) => rule.label);
|
|
7410
|
+
return {
|
|
7411
|
+
valid: violations.length === 0,
|
|
7412
|
+
taskMode,
|
|
7413
|
+
violations,
|
|
7414
|
+
allowedOperations: [
|
|
7415
|
+
"process/log/window/port/session inspection",
|
|
7416
|
+
"read-only filesystem listing/reading",
|
|
7417
|
+
"status probes and keep-running handle reporting",
|
|
7418
|
+
"diagnostic summaries without source edits, commits, checkpoints, pushes, deploys, resets, rebases, or destructive cleanups"
|
|
7419
|
+
]
|
|
7420
|
+
};
|
|
7421
|
+
}
|
|
7311
7422
|
function getQueuePath(meshId) {
|
|
7312
7423
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7313
7424
|
return (0, import_path5.join)(getLedgerDir(), `${safe}.queue.json`);
|
|
@@ -7358,6 +7469,10 @@ function writeQueue(meshId, queue) {
|
|
|
7358
7469
|
}
|
|
7359
7470
|
function enqueueTask(meshId, message, opts) {
|
|
7360
7471
|
requireMeshHostQueueOwner(opts);
|
|
7472
|
+
const modeValidation = validateMeshTaskModeRequest(opts?.taskMode, message);
|
|
7473
|
+
if (!modeValidation.valid) {
|
|
7474
|
+
throw new Error(`live_debug_readonly_guardrail_violation: forbidden operations (${modeValidation.violations.join(", ")})`);
|
|
7475
|
+
}
|
|
7361
7476
|
return withQueueLock(meshId, () => {
|
|
7362
7477
|
const queue = readQueue(meshId);
|
|
7363
7478
|
const entry = {
|
|
@@ -7365,6 +7480,7 @@ function enqueueTask(meshId, message, opts) {
|
|
|
7365
7480
|
meshId,
|
|
7366
7481
|
message,
|
|
7367
7482
|
status: "pending",
|
|
7483
|
+
taskMode: modeValidation.taskMode,
|
|
7368
7484
|
targetNodeId: opts?.targetNodeId,
|
|
7369
7485
|
targetSessionId: opts?.targetSessionId,
|
|
7370
7486
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -7526,7 +7642,7 @@ function getMeshQueueStats(meshId) {
|
|
|
7526
7642
|
}))
|
|
7527
7643
|
};
|
|
7528
7644
|
}
|
|
7529
|
-
var import_fs5, import_path5, import_crypto5, ACTIVE_MESH_QUEUE_STATUSES, HISTORICAL_MESH_QUEUE_STATUSES;
|
|
7645
|
+
var import_fs5, import_path5, import_crypto5, ACTIVE_MESH_QUEUE_STATUSES, HISTORICAL_MESH_QUEUE_STATUSES, MESH_TASK_MODES, LIVE_DEBUG_READONLY_FORBIDDEN;
|
|
7530
7646
|
var init_mesh_work_queue = __esm({
|
|
7531
7647
|
"../../oss/packages/daemon-core/src/mesh/mesh-work-queue.ts"() {
|
|
7532
7648
|
"use strict";
|
|
@@ -7537,6 +7653,164 @@ var init_mesh_work_queue = __esm({
|
|
|
7537
7653
|
init_mesh_host_ownership();
|
|
7538
7654
|
ACTIVE_MESH_QUEUE_STATUSES = ["pending", "assigned"];
|
|
7539
7655
|
HISTORICAL_MESH_QUEUE_STATUSES = ["completed", "failed", "cancelled"];
|
|
7656
|
+
MESH_TASK_MODES = ["code_change", "validation", "live_debug_readonly", "launch_app", "convergence"];
|
|
7657
|
+
LIVE_DEBUG_READONLY_FORBIDDEN = [
|
|
7658
|
+
{ label: "source_edit", pattern: /\b(edit|modify|patch|apply\s+patch|write\s+(?:to\s+)?(?:file|source)|overwrite|delete\s+file|remove\s+file|create\s+file|touch\s+file)\b/i },
|
|
7659
|
+
{ label: "git_mutation", pattern: /\b(?:git\s+(?:add|commit|push|reset|rebase|clean|checkout|switch|merge|tag|restore|rm|mv)|push\b)/i },
|
|
7660
|
+
{ label: "checkpoint", pattern: /\b(checkpoint|mesh_checkpoint)\b/i },
|
|
7661
|
+
{ label: "deploy_or_version_bump", pattern: /\b(deploy|wrangler\s+deploy|version[-\s]?bump|npm\s+version|release)\b/i },
|
|
7662
|
+
{ label: "destructive_shell", pattern: /\b(rm\s+-rf|mv\s+\S+\s+\S+|truncate\s|tee\s+\S+|sed\s+-i)\b/i }
|
|
7663
|
+
];
|
|
7664
|
+
}
|
|
7665
|
+
});
|
|
7666
|
+
|
|
7667
|
+
// ../../oss/packages/daemon-core/src/mesh/mesh-active-work.ts
|
|
7668
|
+
function readString2(value) {
|
|
7669
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
7670
|
+
}
|
|
7671
|
+
function summarizeMessage(message) {
|
|
7672
|
+
const oneLine = message.replace(/\s+/g, " ").trim();
|
|
7673
|
+
const title = oneLine.length > 96 ? `${oneLine.slice(0, 93)}...` : oneLine;
|
|
7674
|
+
return { title: title || "(untitled task)", summary: oneLine };
|
|
7675
|
+
}
|
|
7676
|
+
function elapsedSince(value, now) {
|
|
7677
|
+
const started = value ? new Date(value).getTime() : Number.NaN;
|
|
7678
|
+
return Number.isFinite(started) ? Math.max(0, now - started) : 0;
|
|
7679
|
+
}
|
|
7680
|
+
function sessionStatusFromNodes(nodes, nodeId, sessionId) {
|
|
7681
|
+
if (!nodeId || !sessionId || !Array.isArray(nodes)) return void 0;
|
|
7682
|
+
const node = nodes.find((item) => readString2(item?.id) === nodeId || readString2(item?.nodeId) === nodeId || readString2(item?.node_id) === nodeId);
|
|
7683
|
+
if (!node) return void 0;
|
|
7684
|
+
const candidates = [];
|
|
7685
|
+
for (const value of [node.sessions, node.activeSessions, node.active_sessions, node.lastProbe?.sessions, node.last_probe?.sessions, node.lastProbe?.status?.sessions, node.last_probe?.status?.sessions]) {
|
|
7686
|
+
if (Array.isArray(value)) candidates.push(...value);
|
|
7687
|
+
}
|
|
7688
|
+
for (const value of [node.activeSession, node.active_session, node.currentSession, node.current_session, node.runtimeSession, node.runtime_session, node.session]) {
|
|
7689
|
+
if (value && typeof value === "object") candidates.push(value);
|
|
7690
|
+
}
|
|
7691
|
+
const session = candidates.find((item) => {
|
|
7692
|
+
const id = readString2(item?.id) || readString2(item?.sessionId) || readString2(item?.session_id) || readString2(item?.runtimeSessionId) || readString2(item?.instanceId);
|
|
7693
|
+
return id === sessionId;
|
|
7694
|
+
});
|
|
7695
|
+
if (!session) return void 0;
|
|
7696
|
+
const raw = `${readString2(session.status) || ""} ${readString2(session.lifecycle) || ""} ${readString2(session.state) || ""} ${readString2(session.activeChat?.status) || ""}`.toLowerCase();
|
|
7697
|
+
if (raw.includes("approval")) return "awaiting_approval";
|
|
7698
|
+
if (raw.includes("generating") || raw.includes("running") || raw.includes("busy")) return "generating";
|
|
7699
|
+
if (raw.includes("failed") || raw.includes("stopped") || raw.includes("terminated") || raw.includes("exited")) return "failed";
|
|
7700
|
+
if (raw.includes("idle") || raw.includes("waiting_input") || raw.includes("ready")) return "idle";
|
|
7701
|
+
return void 0;
|
|
7702
|
+
}
|
|
7703
|
+
function isDirectDispatch(entry) {
|
|
7704
|
+
if (entry.kind !== "task_dispatched") return false;
|
|
7705
|
+
const payload = entry.payload || {};
|
|
7706
|
+
if (payload.source === "direct") return true;
|
|
7707
|
+
const via = readString2(payload.via);
|
|
7708
|
+
return Boolean(via && DIRECT_DISPATCH_VIA.has(via) && payload.source !== "queue");
|
|
7709
|
+
}
|
|
7710
|
+
function directDispatchTaskId(entry) {
|
|
7711
|
+
return readString2(entry.payload?.taskId) || entry.id;
|
|
7712
|
+
}
|
|
7713
|
+
function terminalMatchesDispatch(terminal2, dispatch, taskId) {
|
|
7714
|
+
const terminalTaskId = readString2(terminal2.payload?.taskId);
|
|
7715
|
+
if (terminalTaskId && terminalTaskId === taskId) return true;
|
|
7716
|
+
if (terminalTaskId && terminalTaskId !== taskId) return false;
|
|
7717
|
+
if (dispatch.sessionId && terminal2.sessionId === dispatch.sessionId) return true;
|
|
7718
|
+
return Boolean(dispatch.nodeId && terminal2.nodeId === dispatch.nodeId && !dispatch.sessionId);
|
|
7719
|
+
}
|
|
7720
|
+
function statusFromTerminal(entry) {
|
|
7721
|
+
if (entry.kind === "task_approval_needed") return "awaiting_approval";
|
|
7722
|
+
if (entry.kind === "task_completed") return "idle";
|
|
7723
|
+
return "failed";
|
|
7724
|
+
}
|
|
7725
|
+
function buildMeshActiveWorkSummary(activeWork) {
|
|
7726
|
+
const statusCounts = {
|
|
7727
|
+
pending: 0,
|
|
7728
|
+
assigned: 0,
|
|
7729
|
+
generating: 0,
|
|
7730
|
+
idle: 0,
|
|
7731
|
+
failed: 0,
|
|
7732
|
+
awaiting_approval: 0
|
|
7733
|
+
};
|
|
7734
|
+
const sourceCounts = { queue: 0, direct: 0 };
|
|
7735
|
+
for (const item of activeWork) {
|
|
7736
|
+
sourceCounts[item.source] += 1;
|
|
7737
|
+
statusCounts[item.status] += 1;
|
|
7738
|
+
}
|
|
7739
|
+
return {
|
|
7740
|
+
totalActiveCount: activeWork.length,
|
|
7741
|
+
queueActiveCount: sourceCounts.queue,
|
|
7742
|
+
directActiveCount: sourceCounts.direct,
|
|
7743
|
+
awaitingApprovalCount: statusCounts.awaiting_approval,
|
|
7744
|
+
generatingCount: statusCounts.generating,
|
|
7745
|
+
failedCount: statusCounts.failed,
|
|
7746
|
+
idleCount: statusCounts.idle,
|
|
7747
|
+
sourceCounts,
|
|
7748
|
+
statusCounts
|
|
7749
|
+
};
|
|
7750
|
+
}
|
|
7751
|
+
function buildMeshActiveWork(opts) {
|
|
7752
|
+
const now = opts.now ?? Date.now();
|
|
7753
|
+
const records = [];
|
|
7754
|
+
for (const task of opts.queue || []) {
|
|
7755
|
+
if (task.status !== "pending" && task.status !== "assigned") continue;
|
|
7756
|
+
const { title, summary } = summarizeMessage(task.message || "");
|
|
7757
|
+
records.push({
|
|
7758
|
+
taskId: task.id,
|
|
7759
|
+
source: "queue",
|
|
7760
|
+
status: task.status,
|
|
7761
|
+
nodeId: task.assignedNodeId || task.targetNodeId,
|
|
7762
|
+
sessionId: task.assignedSessionId || task.targetSessionId,
|
|
7763
|
+
taskTitle: title,
|
|
7764
|
+
taskSummary: summary,
|
|
7765
|
+
message: task.message,
|
|
7766
|
+
taskMode: task.taskMode,
|
|
7767
|
+
createdAt: task.createdAt,
|
|
7768
|
+
updatedAt: task.updatedAt,
|
|
7769
|
+
dispatchedAt: task.dispatchTimestamp,
|
|
7770
|
+
elapsedMs: elapsedSince(task.dispatchTimestamp || task.createdAt, now)
|
|
7771
|
+
});
|
|
7772
|
+
}
|
|
7773
|
+
const ledgerEntries = (opts.ledgerEntries || []).slice().sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
7774
|
+
const terminals = ledgerEntries.filter((entry) => TERMINAL_LEDGER_KINDS.has(entry.kind) || entry.kind === "task_approval_needed");
|
|
7775
|
+
for (const dispatch of ledgerEntries.filter(isDirectDispatch)) {
|
|
7776
|
+
const taskId = directDispatchTaskId(dispatch);
|
|
7777
|
+
const terminal2 = terminals.filter((entry) => new Date(entry.timestamp).getTime() >= new Date(dispatch.timestamp).getTime()).find((entry) => terminalMatchesDispatch(entry, dispatch, taskId));
|
|
7778
|
+
const terminalStatus = terminal2 ? statusFromTerminal(terminal2) : void 0;
|
|
7779
|
+
const liveStatus = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
|
|
7780
|
+
const status = terminalStatus || liveStatus || "assigned";
|
|
7781
|
+
const terminalRow = Boolean(terminal2 && terminal2.kind !== "task_approval_needed");
|
|
7782
|
+
if (terminalRow && opts.includeTerminalDirect !== true) continue;
|
|
7783
|
+
const message = readString2(dispatch.payload?.message) || readString2(dispatch.payload?.summary) || "";
|
|
7784
|
+
const { title, summary } = summarizeMessage(message);
|
|
7785
|
+
records.push({
|
|
7786
|
+
taskId,
|
|
7787
|
+
source: "direct",
|
|
7788
|
+
status,
|
|
7789
|
+
nodeId: dispatch.nodeId,
|
|
7790
|
+
sessionId: dispatch.sessionId,
|
|
7791
|
+
providerType: dispatch.providerType || readString2(dispatch.payload?.providerType),
|
|
7792
|
+
taskTitle: readString2(dispatch.payload?.taskTitle) || title,
|
|
7793
|
+
taskSummary: readString2(dispatch.payload?.taskSummary) || summary,
|
|
7794
|
+
message,
|
|
7795
|
+
taskMode: readString2(dispatch.payload?.taskMode),
|
|
7796
|
+
createdAt: dispatch.timestamp,
|
|
7797
|
+
updatedAt: terminal2?.timestamp || dispatch.timestamp,
|
|
7798
|
+
dispatchedAt: dispatch.timestamp,
|
|
7799
|
+
elapsedMs: elapsedSince(dispatch.timestamp, now),
|
|
7800
|
+
terminal: terminalRow,
|
|
7801
|
+
terminalKind: terminal2?.kind,
|
|
7802
|
+
terminalAt: terminal2?.timestamp
|
|
7803
|
+
});
|
|
7804
|
+
}
|
|
7805
|
+
records.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
7806
|
+
return { activeWork: records, summary: buildMeshActiveWorkSummary(records) };
|
|
7807
|
+
}
|
|
7808
|
+
var DIRECT_DISPATCH_VIA, TERMINAL_LEDGER_KINDS;
|
|
7809
|
+
var init_mesh_active_work = __esm({
|
|
7810
|
+
"../../oss/packages/daemon-core/src/mesh/mesh-active-work.ts"() {
|
|
7811
|
+
"use strict";
|
|
7812
|
+
DIRECT_DISPATCH_VIA = /* @__PURE__ */ new Set(["p2p_direct", "local_direct", "mesh_send_task"]);
|
|
7813
|
+
TERMINAL_LEDGER_KINDS = /* @__PURE__ */ new Set(["task_completed", "task_failed", "task_stalled"]);
|
|
7540
7814
|
}
|
|
7541
7815
|
});
|
|
7542
7816
|
|
|
@@ -7901,6 +8175,9 @@ __export(mesh_events_exports, {
|
|
|
7901
8175
|
triggerMeshQueue: () => triggerMeshQueue,
|
|
7902
8176
|
tryAssignQueueTask: () => tryAssignQueueTask
|
|
7903
8177
|
});
|
|
8178
|
+
function readWorkerResultMetadata(event) {
|
|
8179
|
+
return readRecord(event.workerResult) || readRecord(event.meshWorkerResult) || readRecord(event.structuredResult);
|
|
8180
|
+
}
|
|
7904
8181
|
function sweepExpiredRemoteIdleSessions() {
|
|
7905
8182
|
const now = Date.now();
|
|
7906
8183
|
for (const [key, session] of remoteIdleSessions) {
|
|
@@ -7966,23 +8243,26 @@ function clearPendingMeshCoordinatorEvents(meshId) {
|
|
|
7966
8243
|
} catch {
|
|
7967
8244
|
}
|
|
7968
8245
|
}
|
|
7969
|
-
function
|
|
8246
|
+
function readNonEmptyString2(value) {
|
|
7970
8247
|
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
7971
8248
|
}
|
|
8249
|
+
function readRecord(value) {
|
|
8250
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
8251
|
+
}
|
|
7972
8252
|
function resolveEventSessionId(event, fallback2) {
|
|
7973
|
-
return
|
|
8253
|
+
return readNonEmptyString2(event.targetSessionId) || readNonEmptyString2(event.sessionId) || readNonEmptyString2(event.instanceId) || readNonEmptyString2(fallback2);
|
|
7974
8254
|
}
|
|
7975
8255
|
function isMeshCoordinatorEvent(eventName) {
|
|
7976
8256
|
return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
|
|
7977
8257
|
}
|
|
7978
8258
|
function formatCompletionMetadata(event) {
|
|
7979
8259
|
const completionDiagnostic = event.completionDiagnostic && typeof event.completionDiagnostic === "object" ? event.completionDiagnostic : null;
|
|
7980
|
-
const diagnosticReason = completionDiagnostic ?
|
|
8260
|
+
const diagnosticReason = completionDiagnostic ? readNonEmptyString2(completionDiagnostic.blockReason) || "present" : "";
|
|
7981
8261
|
const finalAssistantPresent = typeof completionDiagnostic?.finalAssistantPresent === "boolean" ? String(completionDiagnostic.finalAssistantPresent) : "";
|
|
7982
8262
|
const parts = [
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
8263
|
+
readNonEmptyString2(event.targetSessionId) ? `session_id=${readNonEmptyString2(event.targetSessionId)}` : "",
|
|
8264
|
+
readNonEmptyString2(event.providerType) ? `provider=${readNonEmptyString2(event.providerType)}` : "",
|
|
8265
|
+
readNonEmptyString2(event.providerSessionId) ? `provider_session_id=${readNonEmptyString2(event.providerSessionId)}` : "",
|
|
7986
8266
|
diagnosticReason ? `completion_diagnostic=${diagnosticReason}` : "",
|
|
7987
8267
|
finalAssistantPresent ? `final_assistant=${finalAssistantPresent}` : ""
|
|
7988
8268
|
].filter(Boolean);
|
|
@@ -8026,7 +8306,7 @@ function readEventTimestamp(value) {
|
|
|
8026
8306
|
return null;
|
|
8027
8307
|
}
|
|
8028
8308
|
function buildMeshCompletionFingerprint(args) {
|
|
8029
|
-
const timestampPart = Number.isFinite(args.timestamp) ? String(args.timestamp) :
|
|
8309
|
+
const timestampPart = Number.isFinite(args.timestamp) ? String(args.timestamp) : readNonEmptyString2(args.finalSummary).slice(0, 200);
|
|
8030
8310
|
return [
|
|
8031
8311
|
args.meshId,
|
|
8032
8312
|
args.event,
|
|
@@ -8104,7 +8384,7 @@ function isTerminalSessionStatus(status) {
|
|
|
8104
8384
|
return ["stopped", "failed", "terminated", "exited", "closed"].includes(status);
|
|
8105
8385
|
}
|
|
8106
8386
|
function isIdleSessionState(state) {
|
|
8107
|
-
const status =
|
|
8387
|
+
const status = readNonEmptyString2(state?.status).toLowerCase();
|
|
8108
8388
|
if (isTerminalSessionStatus(status)) return false;
|
|
8109
8389
|
return status === "idle" || state?.activeChat?.status === "waiting_input";
|
|
8110
8390
|
}
|
|
@@ -8113,15 +8393,15 @@ function isDirtyNode(node) {
|
|
|
8113
8393
|
}
|
|
8114
8394
|
function isLaunchableNode(node) {
|
|
8115
8395
|
if (!node || node.status === "disabled" || node.status === "removed") return false;
|
|
8116
|
-
const health =
|
|
8396
|
+
const health = readNonEmptyString2(node.health).toLowerCase();
|
|
8117
8397
|
if (!health) return true;
|
|
8118
8398
|
return health === "online" || health === "unknown";
|
|
8119
8399
|
}
|
|
8120
8400
|
function localAutoLaunchSkipReason(node) {
|
|
8121
|
-
const daemonId =
|
|
8122
|
-
const machineId =
|
|
8401
|
+
const daemonId = readNonEmptyString2(node?.daemonId);
|
|
8402
|
+
const machineId = readNonEmptyString2(node?.machineId);
|
|
8123
8403
|
const appConfig = loadConfig();
|
|
8124
|
-
const localMachineId =
|
|
8404
|
+
const localMachineId = readNonEmptyString2(appConfig.machineId) || readNonEmptyString2(appConfig.registeredMachineId);
|
|
8125
8405
|
const cloudDaemonId = localMachineId ? `daemon_${localMachineId}` : "";
|
|
8126
8406
|
const standaloneDaemonId = localMachineId ? `standalone_${localMachineId}` : "";
|
|
8127
8407
|
const daemonMatchesLocal = !daemonId || daemonId === cloudDaemonId || daemonId === standaloneDaemonId;
|
|
@@ -8144,10 +8424,10 @@ function liveSessionCountForNode(components, meshId, nodeId) {
|
|
|
8144
8424
|
return components.instanceManager.getByCategory("cli").filter((inst) => {
|
|
8145
8425
|
const state = inst.getState();
|
|
8146
8426
|
const settings = state.settings || {};
|
|
8147
|
-
if (
|
|
8148
|
-
const instNodeId =
|
|
8427
|
+
if (readNonEmptyString2(settings.meshNodeFor) !== meshId) return false;
|
|
8428
|
+
const instNodeId = readNonEmptyString2(settings.meshNodeId) || readNonEmptyString2(settings.nodeId);
|
|
8149
8429
|
if (instNodeId !== nodeId) return false;
|
|
8150
|
-
const status =
|
|
8430
|
+
const status = readNonEmptyString2(state.status).toLowerCase();
|
|
8151
8431
|
return !isTerminalSessionStatus(status);
|
|
8152
8432
|
}).length;
|
|
8153
8433
|
}
|
|
@@ -8239,7 +8519,7 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
|
8239
8519
|
continue;
|
|
8240
8520
|
}
|
|
8241
8521
|
for (const node of candidateNodes) {
|
|
8242
|
-
const nodeId =
|
|
8522
|
+
const nodeId = readNonEmptyString2(node?.id);
|
|
8243
8523
|
if (!nodeId) continue;
|
|
8244
8524
|
const launchKey = `${meshId}:${nodeId}`;
|
|
8245
8525
|
const cooldownUntil = autoLaunchCooldownUntil.get(launchKey) || 0;
|
|
@@ -8298,7 +8578,7 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
|
8298
8578
|
autoLaunchCooldownUntil.set(launchKey, Date.now() + AUTO_LAUNCH_COOLDOWN_MS);
|
|
8299
8579
|
return false;
|
|
8300
8580
|
}
|
|
8301
|
-
const sessionId =
|
|
8581
|
+
const sessionId = readNonEmptyString2(launchResult.sessionId) || readNonEmptyString2(launchResult.id) || readNonEmptyString2(launchResult.runtimeSessionId);
|
|
8302
8582
|
if (!sessionId) {
|
|
8303
8583
|
markAutoLaunch(meshId, task.id, { status: "failed", reason: "launch_missing_session_id", nodeId, providerType: resolved.providerType });
|
|
8304
8584
|
autoLaunchCooldownUntil.set(launchKey, Date.now() + AUTO_LAUNCH_COOLDOWN_MS);
|
|
@@ -8325,13 +8605,13 @@ async function triggerMeshQueue(components, meshId) {
|
|
|
8325
8605
|
for (const inst of cliInstances) {
|
|
8326
8606
|
const state = inst.getState();
|
|
8327
8607
|
const settings = state.settings || {};
|
|
8328
|
-
const instMeshId =
|
|
8608
|
+
const instMeshId = readNonEmptyString2(settings.meshNodeFor);
|
|
8329
8609
|
if (instMeshId !== meshId) continue;
|
|
8330
|
-
const nodeId =
|
|
8610
|
+
const nodeId = readNonEmptyString2(settings.meshNodeId) || readNonEmptyString2(settings.nodeId);
|
|
8331
8611
|
if (!nodeId) continue;
|
|
8332
8612
|
if (!isIdleSessionState(state)) continue;
|
|
8333
8613
|
const sessionId = state.instanceId;
|
|
8334
|
-
const providerType = state.type ||
|
|
8614
|
+
const providerType = state.type || readNonEmptyString2(settings.providerType);
|
|
8335
8615
|
if (providerType) {
|
|
8336
8616
|
tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType);
|
|
8337
8617
|
}
|
|
@@ -8393,7 +8673,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
8393
8673
|
}
|
|
8394
8674
|
function injectMeshSystemMessage(components, args) {
|
|
8395
8675
|
const eventSessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
8396
|
-
const eventNodeId =
|
|
8676
|
+
const eventNodeId = readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId);
|
|
8397
8677
|
const intentionalCleanupStop = shouldSuppressIntentionalCleanupStop({
|
|
8398
8678
|
event: args.event,
|
|
8399
8679
|
meshId: args.meshId,
|
|
@@ -8414,10 +8694,10 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8414
8694
|
meshId: args.meshId,
|
|
8415
8695
|
event: args.event,
|
|
8416
8696
|
sessionId: eventSessionId,
|
|
8417
|
-
providerType:
|
|
8418
|
-
providerSessionId:
|
|
8697
|
+
providerType: readNonEmptyString2(args.metadataEvent.providerType) || void 0,
|
|
8698
|
+
providerSessionId: readNonEmptyString2(args.metadataEvent.providerSessionId) || void 0,
|
|
8419
8699
|
timestamp: eventTimestamp,
|
|
8420
|
-
finalSummary:
|
|
8700
|
+
finalSummary: readNonEmptyString2(args.metadataEvent.finalSummary) || void 0
|
|
8421
8701
|
});
|
|
8422
8702
|
if (duplicateCompletion) {
|
|
8423
8703
|
LOG.info("MeshEvents", `Suppressed duplicate completion for mesh ${args.meshId} session ${eventSessionId}`);
|
|
@@ -8427,8 +8707,8 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8427
8707
|
let completedTaskForLedger = null;
|
|
8428
8708
|
if (args.event === "agent:generating_completed") {
|
|
8429
8709
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
8430
|
-
const nodeId =
|
|
8431
|
-
const providerType =
|
|
8710
|
+
const nodeId = readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId);
|
|
8711
|
+
const providerType = readNonEmptyString2(args.metadataEvent.providerType);
|
|
8432
8712
|
if (sessionId) {
|
|
8433
8713
|
const completedTask = updateSessionTaskStatus(args.meshId, sessionId, "completed", {
|
|
8434
8714
|
occurredAt: eventTimestamp !== null ? new Date(eventTimestamp).toISOString() : void 0
|
|
@@ -8442,8 +8722,11 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8442
8722
|
}
|
|
8443
8723
|
} else if (args.event === "agent:ready") {
|
|
8444
8724
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
8445
|
-
const nodeId =
|
|
8446
|
-
const providerType =
|
|
8725
|
+
const nodeId = readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId);
|
|
8726
|
+
const providerType = readNonEmptyString2(args.metadataEvent.providerType);
|
|
8727
|
+
const providerSessionId = readNonEmptyString2(args.metadataEvent.providerSessionId) || void 0;
|
|
8728
|
+
const finalSummary = readNonEmptyString2(args.metadataEvent.finalSummary) || void 0;
|
|
8729
|
+
const workerResult = readWorkerResultMetadata(args.metadataEvent);
|
|
8447
8730
|
const completedTask = sessionId ? updateSessionTaskStatus(args.meshId, sessionId, "completed") : null;
|
|
8448
8731
|
if (completedTask) {
|
|
8449
8732
|
completedTaskForLedger = { id: completedTask.id };
|
|
@@ -8458,15 +8741,17 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8458
8741
|
nodeLabel: args.nodeLabel,
|
|
8459
8742
|
taskId: completedTask.id,
|
|
8460
8743
|
completedViaReady: true,
|
|
8461
|
-
providerSessionId
|
|
8462
|
-
finalSummary
|
|
8744
|
+
providerSessionId,
|
|
8745
|
+
finalSummary,
|
|
8746
|
+
workerResult,
|
|
8463
8747
|
evidence: buildTaskCompletionEvidence({
|
|
8464
8748
|
event: "agent:ready",
|
|
8465
8749
|
nodeId,
|
|
8466
8750
|
sessionId,
|
|
8467
8751
|
providerType: providerType || void 0,
|
|
8468
|
-
providerSessionId
|
|
8469
|
-
finalSummary
|
|
8752
|
+
providerSessionId,
|
|
8753
|
+
finalSummary,
|
|
8754
|
+
workerResult
|
|
8470
8755
|
})
|
|
8471
8756
|
}
|
|
8472
8757
|
});
|
|
@@ -8489,13 +8774,13 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8489
8774
|
}
|
|
8490
8775
|
} else if (args.event === "agent:generating_started") {
|
|
8491
8776
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
8492
|
-
const nodeId =
|
|
8777
|
+
const nodeId = readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId);
|
|
8493
8778
|
if (sessionId && nodeId) {
|
|
8494
8779
|
remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
|
|
8495
8780
|
}
|
|
8496
8781
|
} else if (args.event === "agent:stopped") {
|
|
8497
8782
|
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
8498
|
-
const nodeId =
|
|
8783
|
+
const nodeId = readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId);
|
|
8499
8784
|
if (sessionId && nodeId) {
|
|
8500
8785
|
remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
|
|
8501
8786
|
}
|
|
@@ -8506,16 +8791,20 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8506
8791
|
const ledgerKind = EVENT_TO_LEDGER_KIND[args.event];
|
|
8507
8792
|
if (ledgerKind) {
|
|
8508
8793
|
try {
|
|
8509
|
-
const ledgerNodeId =
|
|
8794
|
+
const ledgerNodeId = readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId) || void 0;
|
|
8510
8795
|
const ledgerSessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId) || void 0;
|
|
8511
|
-
const ledgerProviderType =
|
|
8796
|
+
const ledgerProviderType = readNonEmptyString2(args.metadataEvent.providerType) || void 0;
|
|
8797
|
+
const providerSessionId = readNonEmptyString2(args.metadataEvent.providerSessionId) || void 0;
|
|
8798
|
+
const finalSummary = readNonEmptyString2(args.metadataEvent.finalSummary) || void 0;
|
|
8799
|
+
const workerResult = readWorkerResultMetadata(args.metadataEvent);
|
|
8512
8800
|
const completionEvidence = ledgerKind === "task_completed" && ledgerNodeId && ledgerSessionId ? buildTaskCompletionEvidence({
|
|
8513
8801
|
event: "agent:generating_completed",
|
|
8514
8802
|
nodeId: ledgerNodeId,
|
|
8515
8803
|
sessionId: ledgerSessionId,
|
|
8516
8804
|
providerType: ledgerProviderType,
|
|
8517
|
-
providerSessionId
|
|
8518
|
-
finalSummary
|
|
8805
|
+
providerSessionId,
|
|
8806
|
+
finalSummary,
|
|
8807
|
+
workerResult
|
|
8519
8808
|
}) : void 0;
|
|
8520
8809
|
appendLedgerEntry(args.meshId, {
|
|
8521
8810
|
kind: ledgerKind,
|
|
@@ -8526,8 +8815,9 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8526
8815
|
event: args.event,
|
|
8527
8816
|
nodeLabel: args.nodeLabel,
|
|
8528
8817
|
taskId: completedTaskForLedger?.id || void 0,
|
|
8529
|
-
providerSessionId
|
|
8530
|
-
finalSummary
|
|
8818
|
+
providerSessionId,
|
|
8819
|
+
finalSummary,
|
|
8820
|
+
workerResult,
|
|
8531
8821
|
completionDiagnostic: args.metadataEvent.completionDiagnostic && typeof args.metadataEvent.completionDiagnostic === "object" ? args.metadataEvent.completionDiagnostic : void 0,
|
|
8532
8822
|
evidence: completionEvidence
|
|
8533
8823
|
}
|
|
@@ -8543,10 +8833,10 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8543
8833
|
const maxRetries = mesh?.policy?.maxTaskRetries ?? 1;
|
|
8544
8834
|
recoveryContext = getSessionRecoveryContext(args.meshId, {
|
|
8545
8835
|
sessionId: resolveEventSessionId(args.metadataEvent, args.sourceInstanceId) || void 0,
|
|
8546
|
-
nodeId:
|
|
8836
|
+
nodeId: readNonEmptyString2(args.nodeId) || readNonEmptyString2(args.metadataEvent.meshNodeId) || void 0,
|
|
8547
8837
|
maxRetries
|
|
8548
8838
|
});
|
|
8549
|
-
recoveryContext.failedProviderType =
|
|
8839
|
+
recoveryContext.failedProviderType = readNonEmptyString2(args.metadataEvent.providerType) || null;
|
|
8550
8840
|
if (recoveryContext.retryRecommended && recoveryContext.consecutiveNodeFailures > 0) {
|
|
8551
8841
|
appendLedgerEntry(args.meshId, {
|
|
8552
8842
|
kind: "recovery_attempted",
|
|
@@ -8602,7 +8892,7 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8602
8892
|
meshId: args.meshId,
|
|
8603
8893
|
nodeLabel: args.nodeLabel,
|
|
8604
8894
|
nodeId: args.nodeId || void 0,
|
|
8605
|
-
workspace:
|
|
8895
|
+
workspace: readNonEmptyString2(args.metadataEvent.workspace),
|
|
8606
8896
|
metadataEvent: {
|
|
8607
8897
|
...args.metadataEvent,
|
|
8608
8898
|
...recoveryContext ? { recoveryContext } : {}
|
|
@@ -8628,14 +8918,14 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8628
8918
|
return { success: true, forwarded: coordinatorInstances.length };
|
|
8629
8919
|
}
|
|
8630
8920
|
function handleMeshForwardEvent(components, payload) {
|
|
8631
|
-
const eventName =
|
|
8921
|
+
const eventName = readNonEmptyString2(payload.event);
|
|
8632
8922
|
if (!isMeshCoordinatorEvent(eventName)) {
|
|
8633
8923
|
return { success: false, error: "unsupported mesh event" };
|
|
8634
8924
|
}
|
|
8635
|
-
const meshId =
|
|
8925
|
+
const meshId = readNonEmptyString2(payload.meshId);
|
|
8636
8926
|
if (!meshId) return { success: false, error: "meshId required" };
|
|
8637
|
-
const nodeId =
|
|
8638
|
-
const workspace =
|
|
8927
|
+
const nodeId = readNonEmptyString2(payload.nodeId);
|
|
8928
|
+
const workspace = readNonEmptyString2(payload.workspace);
|
|
8639
8929
|
const nodeLabel = nodeId ? `Node '${nodeId}'` : workspace ? `Agent at ${workspace}` : "Remote agent";
|
|
8640
8930
|
return injectMeshSystemMessage(components, {
|
|
8641
8931
|
meshId,
|
|
@@ -8643,41 +8933,41 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
8643
8933
|
nodeLabel,
|
|
8644
8934
|
event: eventName,
|
|
8645
8935
|
metadataEvent: {
|
|
8646
|
-
targetSessionId:
|
|
8647
|
-
providerType:
|
|
8648
|
-
providerSessionId:
|
|
8649
|
-
finalSummary:
|
|
8936
|
+
targetSessionId: readNonEmptyString2(payload.targetSessionId) || readNonEmptyString2(payload.sessionId) || readNonEmptyString2(payload.instanceId),
|
|
8937
|
+
providerType: readNonEmptyString2(payload.providerType),
|
|
8938
|
+
providerSessionId: readNonEmptyString2(payload.providerSessionId),
|
|
8939
|
+
finalSummary: readNonEmptyString2(payload.finalSummary) || readNonEmptyString2(payload.summary),
|
|
8650
8940
|
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {},
|
|
8651
8941
|
intentional: payload.intentional === true,
|
|
8652
8942
|
intentionalStop: payload.intentionalStop === true,
|
|
8653
8943
|
operatorCleanup: payload.operatorCleanup === true,
|
|
8654
|
-
reason:
|
|
8655
|
-
stopReason:
|
|
8656
|
-
cleanupReason:
|
|
8657
|
-
source:
|
|
8944
|
+
reason: readNonEmptyString2(payload.reason),
|
|
8945
|
+
stopReason: readNonEmptyString2(payload.stopReason),
|
|
8946
|
+
cleanupReason: readNonEmptyString2(payload.cleanupReason),
|
|
8947
|
+
source: readNonEmptyString2(payload.source)
|
|
8658
8948
|
}
|
|
8659
8949
|
});
|
|
8660
8950
|
}
|
|
8661
8951
|
function setupMeshEventForwarding(components) {
|
|
8662
8952
|
components.instanceManager.onEvent((event) => {
|
|
8663
8953
|
if (!isMeshCoordinatorEvent(event.event)) return;
|
|
8664
|
-
const instanceId =
|
|
8954
|
+
const instanceId = readNonEmptyString2(event.instanceId);
|
|
8665
8955
|
if (!instanceId) return;
|
|
8666
8956
|
const sourceInstance = components.instanceManager.getInstance(instanceId);
|
|
8667
8957
|
if (!sourceInstance || sourceInstance.category !== "cli") return;
|
|
8668
8958
|
const state = sourceInstance.getState();
|
|
8669
|
-
const workspace =
|
|
8959
|
+
const workspace = readNonEmptyString2(state.workspace);
|
|
8670
8960
|
if (!workspace) return;
|
|
8671
8961
|
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
8672
|
-
if (
|
|
8673
|
-
const meshIdFromRuntime =
|
|
8962
|
+
if (readNonEmptyString2(settings.meshCoordinatorFor)) return;
|
|
8963
|
+
const meshIdFromRuntime = readNonEmptyString2(settings.meshNodeFor);
|
|
8674
8964
|
const isMeshDelegate = Boolean(meshIdFromRuntime || settings.launchedByCoordinator);
|
|
8675
8965
|
if (!isMeshDelegate) return;
|
|
8676
8966
|
const mesh = meshIdFromRuntime ? getMeshWithCache(components, meshIdFromRuntime) : getMeshByRepo(workspace);
|
|
8677
|
-
const meshId = meshIdFromRuntime ||
|
|
8967
|
+
const meshId = meshIdFromRuntime || readNonEmptyString2(mesh?.id);
|
|
8678
8968
|
if (!meshId) return;
|
|
8679
8969
|
const targetNode = mesh?.nodes?.find((n) => n.workspace === workspace);
|
|
8680
|
-
const runtimeNodeId =
|
|
8970
|
+
const runtimeNodeId = readNonEmptyString2(settings.meshNodeId);
|
|
8681
8971
|
const resolvedNodeId = targetNode?.id || runtimeNodeId;
|
|
8682
8972
|
const nodeLabel = targetNode ? `Node '${targetNode.id}'` : runtimeNodeId ? `Node '${runtimeNodeId}'` : `Agent at ${workspace}`;
|
|
8683
8973
|
injectMeshSystemMessage(components, {
|
|
@@ -47841,6 +48131,9 @@ function reconcileInlineMeshCache(cached2, incoming) {
|
|
|
47841
48131
|
const cachedNodes = Array.isArray(cached2.nodes) ? cached2.nodes : [];
|
|
47842
48132
|
const incomingNodes = Array.isArray(incoming.nodes) ? incoming.nodes : [];
|
|
47843
48133
|
if (!cachedNodes.length || !incomingNodes.length) return { ...cached2, ...incoming };
|
|
48134
|
+
const cachedUpdatedAt = Date.parse(readStringValue(cached2.updatedAt, cached2.updated_at) || "");
|
|
48135
|
+
const incomingUpdatedAt = Date.parse(readStringValue(incoming.updatedAt, incoming.updated_at) || "");
|
|
48136
|
+
const preserveCachedMembership = Number.isFinite(cachedUpdatedAt) && (!Number.isFinite(incomingUpdatedAt) || cachedUpdatedAt > incomingUpdatedAt);
|
|
47844
48137
|
const cachedById = /* @__PURE__ */ new Map();
|
|
47845
48138
|
for (const node of cachedNodes) {
|
|
47846
48139
|
const nodeId = readInlineMeshNodeId(node);
|
|
@@ -47849,12 +48142,13 @@ function reconcileInlineMeshCache(cached2, incoming) {
|
|
|
47849
48142
|
const nodes = incomingNodes.map((incomingNode) => {
|
|
47850
48143
|
const nodeId = readInlineMeshNodeId(incomingNode);
|
|
47851
48144
|
const cachedNode = nodeId ? cachedById.get(nodeId) : void 0;
|
|
48145
|
+
if (!cachedNode && preserveCachedMembership) return null;
|
|
47852
48146
|
if (!cachedNode) return incomingNode;
|
|
47853
48147
|
if (hasInlineMeshTransientNodeState(incomingNode)) {
|
|
47854
48148
|
return { ...cachedNode, ...incomingNode };
|
|
47855
48149
|
}
|
|
47856
48150
|
return { ...stripInlineMeshTransientNodeState(cachedNode), ...incomingNode };
|
|
47857
|
-
});
|
|
48151
|
+
}).filter(Boolean);
|
|
47858
48152
|
return {
|
|
47859
48153
|
...cached2,
|
|
47860
48154
|
...incoming,
|
|
@@ -59568,6 +59862,8 @@ __export(src_exports, {
|
|
|
59568
59862
|
buildChatTailDeliverySignature: () => buildChatTailDeliverySignature,
|
|
59569
59863
|
buildCoordinatorSystemPrompt: () => buildCoordinatorSystemPrompt,
|
|
59570
59864
|
buildMachineInfo: () => buildMachineInfo,
|
|
59865
|
+
buildMeshActiveWork: () => buildMeshActiveWork,
|
|
59866
|
+
buildMeshActiveWorkSummary: () => buildMeshActiveWorkSummary,
|
|
59571
59867
|
buildMeshHostRequiredFailure: () => buildMeshHostRequiredFailure,
|
|
59572
59868
|
buildMeshLedgerReconciliationEvidence: () => buildMeshLedgerReconciliationEvidence,
|
|
59573
59869
|
buildMeshLedgerReplicaEvidence: () => buildMeshLedgerReplicaEvidence,
|
|
@@ -59578,6 +59874,7 @@ __export(src_exports, {
|
|
|
59578
59874
|
buildSessionModalDeliverySignature: () => buildSessionModalDeliverySignature,
|
|
59579
59875
|
buildStatusSnapshot: () => buildStatusSnapshot,
|
|
59580
59876
|
buildSystemChatMessage: () => buildSystemChatMessage,
|
|
59877
|
+
buildTaskCompletionEvidence: () => buildTaskCompletionEvidence,
|
|
59581
59878
|
buildTerminalChatMessage: () => buildTerminalChatMessage,
|
|
59582
59879
|
buildThoughtChatMessage: () => buildThoughtChatMessage,
|
|
59583
59880
|
buildToolChatMessage: () => buildToolChatMessage,
|
|
@@ -59688,6 +59985,8 @@ __export(src_exports, {
|
|
|
59688
59985
|
normalizeInputEnvelope: () => normalizeInputEnvelope,
|
|
59689
59986
|
normalizeManagedStatus: () => normalizeManagedStatus,
|
|
59690
59987
|
normalizeMeshDaemonRole: () => normalizeMeshDaemonRole,
|
|
59988
|
+
normalizeMeshTaskMode: () => normalizeMeshTaskMode,
|
|
59989
|
+
normalizeMeshWorkerResult: () => normalizeMeshWorkerResult,
|
|
59691
59990
|
normalizeMessageParts: () => normalizeMessageParts,
|
|
59692
59991
|
normalizeRepoIdentity: () => normalizeRepoIdentity,
|
|
59693
59992
|
normalizeSessionModalFields: () => normalizeSessionModalFields,
|
|
@@ -59743,7 +60042,8 @@ __export(src_exports, {
|
|
|
59743
60042
|
updateSessionTaskStatus: () => updateSessionTaskStatus,
|
|
59744
60043
|
updateTaskStatus: () => updateTaskStatus,
|
|
59745
60044
|
upsertSavedProviderSession: () => upsertSavedProviderSession,
|
|
59746
|
-
validateMeshRefineConfig: () => validateMeshRefineConfig
|
|
60045
|
+
validateMeshRefineConfig: () => validateMeshRefineConfig,
|
|
60046
|
+
validateMeshTaskModeRequest: () => validateMeshTaskModeRequest
|
|
59747
60047
|
});
|
|
59748
60048
|
var init_src = __esm({
|
|
59749
60049
|
"../../oss/packages/daemon-core/src/index.ts"() {
|
|
@@ -59762,6 +60062,7 @@ var init_src = __esm({
|
|
|
59762
60062
|
init_mesh_fast_forward();
|
|
59763
60063
|
init_mesh_ledger_reconciliation();
|
|
59764
60064
|
init_mesh_work_queue();
|
|
60065
|
+
init_mesh_active_work();
|
|
59765
60066
|
init_mesh_host_ownership();
|
|
59766
60067
|
init_mesh_events();
|
|
59767
60068
|
init_p2p_relay_failure();
|
|
@@ -100579,7 +100880,7 @@ var init_adhdev_daemon = __esm({
|
|
|
100579
100880
|
init_version();
|
|
100580
100881
|
init_src();
|
|
100581
100882
|
init_runtime_defaults();
|
|
100582
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
100883
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.59" });
|
|
100583
100884
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
100584
100885
|
localHttpServer = null;
|
|
100585
100886
|
localWss = null;
|