@adhdev/daemon-core 0.9.82-rc.380 → 0.9.82-rc.381
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.d.ts +4 -2
- package/dist/index.js +222 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -59
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-runtime-store.d.ts +12 -0
- package/dist/mesh/mesh-scheduling-runtime.d.ts +78 -0
- package/dist/repo-mesh-types.d.ts +81 -0
- package/package.json +2 -2
- package/src/config/mesh-config.ts +6 -58
- package/src/index.ts +13 -0
- package/src/mesh/coordinator-prompt.ts +3 -3
- package/src/mesh/mesh-event-forwarding.ts +17 -1
- package/src/mesh/mesh-runtime-store.ts +23 -0
- package/src/mesh/mesh-scheduling-runtime.ts +199 -0
- package/src/repo-mesh-types.ts +164 -0
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ export type { ChatBubbleState, ChatMessage, ExtensionInfo, CommandResult as Core
|
|
|
7
7
|
export type { SessionEntry, CompactSessionEntry, CompactDaemonEntry, CloudDaemonSummaryEntry, DashboardBootstrapDaemonEntry, VersionUpdateReason, CloudStatusReportPayload, DaemonStatusEventPayload, DashboardStatusEventPayload, SessionTransport, SessionKind, SessionCapability, AgentSessionStream, ReadChatCursor, ReadChatSyncResult, TransportTopic, SessionChatTailSubscriptionParams, SessionRuntimeOutputSubscriptionParams, MachineRuntimeSubscriptionParams, SessionHostDiagnosticsSubscriptionParams, SessionModalSubscriptionParams, DaemonMetadataSubscriptionParams, WorkspaceGitSubscriptionParams, SessionChatTailUpdate, MachineRuntimeUpdate, SessionHostDiagnosticsUpdate, SessionModalUpdate, DaemonMetadataUpdate, TopicUpdateEnvelope, SubscribeRequest, UnsubscribeRequest, StandaloneWsStatusPayload, AvailableProviderInfo, AcpConfigOption, AcpMode, ProviderControlSchema, StatusReportPayload, MachineInfo, SessionHostDiagnosticsSnapshot, SessionHostRecord, SessionHostWriteOwner, SessionHostAttachedClient, SessionHostLogEntry, SessionHostRequestTrace, SessionHostRuntimeTransition, DetectedIdeInfo, WorkspaceEntry, ProviderSummaryItem, ProviderSummaryMetadata, ProviderState, ProviderStatus, ProviderErrorReason, SessionActiveChatData, ActiveChatData, IdeProviderState, CliProviderState, AcpProviderState, ExtensionProviderState, MessageInputSupport, InputMediaStrategyDescriptor, InputAttachmentStrategy, InputMediaType, } from './shared-types.js';
|
|
8
8
|
export type { InteractivePrompt, InteractiveQuestion, InteractiveOption, InteractivePromptResponse, InteractiveAnswer, } from './providers/types/interactive-prompt.js';
|
|
9
9
|
export { normalizeInteractivePrompt, normalizeInteractivePromptResponse, buildClaudeInteractiveToolResult, interactivePromptFromClaudeAskUserQuestion, detectClaudeAskUserQuestionPromptFromJson, } from './providers/types/interactive-prompt.js';
|
|
10
|
-
export type { RepoMesh, RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostPairingMetadata, RepoMeshHostStatus, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, RepoMeshPeerConnectionStatus, RepoMeshPeerConnectionState, RepoMeshPeerConnectionTransport, RepoMeshSessionStatus, RepoMeshQueueTask, RepoMeshQueueTaskStatus, RepoMeshQueueSummary, RepoMeshQueueStatus, RepoMeshLedgerEntryStatus, RepoMeshLedgerSummaryStatus, RepoMeshLedgerStatus, MeshAsyncJobLifecycle, RepoMeshSchedulingStrategy, } from './repo-mesh-types.js';
|
|
11
|
-
export { DEFAULT_MESH_POLICY, resolveDelegatedWorkerAutoApprove, MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, normalizeMeshSchedulingStrategy, resolveNodeSchedulingPriority, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, resolveAutoConvergeCodeChange, } from './repo-mesh-types.js';
|
|
10
|
+
export type { RepoMesh, RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostPairingMetadata, RepoMeshHostStatus, RepoMeshNode, RepoMeshNodeHealth, RepoMeshPolicy, RepoMeshNodePolicy, RepoMeshRelatedRepo, RepoMeshNodeCapabilities, DetectedCommand, ProjectContextSnapshot, ProjectContextSource, RepoMeshCoordinatorConfig, LocalMeshConfig, LocalMeshEntry, LocalMeshNodeEntry, RepoMeshStatus, RepoMeshNodeStatus, RepoMeshPeerConnectionStatus, RepoMeshPeerConnectionState, RepoMeshPeerConnectionTransport, RepoMeshSessionStatus, RepoMeshQueueTask, RepoMeshQueueTaskStatus, RepoMeshQueueSummary, RepoMeshQueueStatus, RepoMeshLedgerEntryStatus, RepoMeshLedgerSummaryStatus, RepoMeshLedgerStatus, MeshAsyncJobLifecycle, RepoMeshSchedulingStrategy, RepoMeshSchedulingStatus, RepoMeshNodeSchedulingStatus, RepoMeshNodeProviderSchedulingStatus, } from './repo-mesh-types.js';
|
|
11
|
+
export { DEFAULT_MESH_POLICY, resolveDelegatedWorkerAutoApprove, MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, normalizeMeshSchedulingStrategy, resolveNodeSchedulingPriority, resolveProviderMaxParallel, mergeAndNormalizePolicy, normalizeAutoFastForwardPolicy, resolveMaxParallelTasks, MESH_MAX_PARALLEL_TASKS_MIN, MESH_MAX_PARALLEL_TASKS_MAX, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, resolveAutoConvergeCodeChange, } from './repo-mesh-types.js';
|
|
12
12
|
export * from './git/index.js';
|
|
13
13
|
import type { RuntimeWriteOwner as _RuntimeWriteOwner } from './shared-types-extra.js';
|
|
14
14
|
import type { RuntimeAttachedClient as _RuntimeAttachedClient } from './shared-types-extra.js';
|
|
@@ -58,6 +58,8 @@ export type { StaleDirectPruneClassification, StaleDirectPruneResult, PruneStale
|
|
|
58
58
|
export type { MeshActiveWorkRecord, MeshActiveWorkStatus, MeshActiveWorkSummary, MeshActiveWorkSource, MeshStaleDirectWorkSummary } from './mesh/mesh-active-work.js';
|
|
59
59
|
export { buildMeshAsyncRefineJobs, summarizeMeshAsyncRefineJobs, STALE_TERMINAL_REFINE_WINDOW_MS, RECENT_TERMINAL_REFINE_CAP } from './mesh/mesh-refine-status.js';
|
|
60
60
|
export type { MeshAsyncRefineJobStatus, MeshAsyncRefineJobSummary, MeshAsyncRefineJobsSummary } from './mesh/mesh-refine-status.js';
|
|
61
|
+
export { buildMeshSchedulingRuntime } from './mesh/mesh-scheduling-runtime.js';
|
|
62
|
+
export type { MeshSchedulingRuntime, MeshNodeSchedulingRuntime, MeshNodeProviderSchedulingRuntime } from './mesh/mesh-scheduling-runtime.js';
|
|
61
63
|
export { buildMeshHostRequiredFailure, createDefaultMeshHostMetadata, isMeshHostOwner, normalizeMeshDaemonRole, requireMeshHostQueueOwner, resolveMeshHostStatus } from './mesh/mesh-host-ownership.js';
|
|
62
64
|
export { triggerMeshQueue, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, queuePendingMeshCoordinatorEvent, reconcileDirectDispatchCompletionFromTranscript } from './mesh/mesh-events.js';
|
|
63
65
|
export type { PendingMeshCoordinatorEvent } from './mesh/mesh-events.js';
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,56 @@ function resolveNodeSchedulingPriority(nodePolicy) {
|
|
|
43
43
|
function resolveAutoConvergeCodeChange(policy) {
|
|
44
44
|
return policy?.autoConvergeCodeChange === true;
|
|
45
45
|
}
|
|
46
|
+
function resolveMaxParallelTasks(value) {
|
|
47
|
+
const n = Number(value);
|
|
48
|
+
if (!Number.isFinite(n)) return DEFAULT_MESH_POLICY.maxParallelTasks;
|
|
49
|
+
return Math.max(MESH_MAX_PARALLEL_TASKS_MIN, Math.min(MESH_MAX_PARALLEL_TASKS_MAX, Math.floor(n)));
|
|
50
|
+
}
|
|
51
|
+
function normalizeAutoFastForwardPolicy(value) {
|
|
52
|
+
const record = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
53
|
+
const maxBehind = Number(record.maxBehind);
|
|
54
|
+
return {
|
|
55
|
+
enabled: record.enabled !== false,
|
|
56
|
+
...Number.isFinite(maxBehind) && maxBehind >= 0 ? { maxBehind: Math.floor(maxBehind) } : {},
|
|
57
|
+
requireCleanSubmodules: record.requireCleanSubmodules !== false
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function mergeAndNormalizePolicy(base, patch) {
|
|
61
|
+
const autoFastForward = normalizeAutoFastForwardPolicy({
|
|
62
|
+
...DEFAULT_MESH_POLICY.autoFastForward,
|
|
63
|
+
...base?.autoFastForward && typeof base.autoFastForward === "object" ? base.autoFastForward : {},
|
|
64
|
+
...patch?.autoFastForward && typeof patch.autoFastForward === "object" ? patch.autoFastForward : {}
|
|
65
|
+
});
|
|
66
|
+
const policy = {
|
|
67
|
+
...DEFAULT_MESH_POLICY,
|
|
68
|
+
...base || {},
|
|
69
|
+
...patch || {},
|
|
70
|
+
autoFastForward
|
|
71
|
+
};
|
|
72
|
+
if (!DIRTY_WORKSPACE_BEHAVIORS.has(policy.dirtyWorkspaceBehavior)) {
|
|
73
|
+
policy.dirtyWorkspaceBehavior = "warn";
|
|
74
|
+
}
|
|
75
|
+
policy.maxParallelTasks = resolveMaxParallelTasks(policy.maxParallelTasks);
|
|
76
|
+
policy.allowAutoPublishSubmoduleMainCommits = policy.allowAutoPublishSubmoduleMainCommits === true;
|
|
77
|
+
if (!SESSION_CLEANUP_MODES.has(policy.sessionCleanupOnNodeRemove)) {
|
|
78
|
+
policy.sessionCleanupOnNodeRemove = "preserve";
|
|
79
|
+
}
|
|
80
|
+
if (!SPAWNED_SESSION_VISIBILITY_MODES.has(policy.spawnedSessionVisibility)) {
|
|
81
|
+
policy.spawnedSessionVisibility = DEFAULT_MESH_POLICY.spawnedSessionVisibility;
|
|
82
|
+
}
|
|
83
|
+
const normalizedStrategy = normalizeMeshSchedulingStrategy(policy.schedulingStrategy);
|
|
84
|
+
if (normalizedStrategy === "first_eligible") {
|
|
85
|
+
delete policy.schedulingStrategy;
|
|
86
|
+
} else {
|
|
87
|
+
policy.schedulingStrategy = normalizedStrategy;
|
|
88
|
+
}
|
|
89
|
+
if (policy.autoConvergeCodeChange === true) {
|
|
90
|
+
policy.autoConvergeCodeChange = true;
|
|
91
|
+
} else {
|
|
92
|
+
delete policy.autoConvergeCodeChange;
|
|
93
|
+
}
|
|
94
|
+
return policy;
|
|
95
|
+
}
|
|
46
96
|
function resolveDelegatedWorkerAutoApprove(meshPolicy, nodePolicy) {
|
|
47
97
|
if (typeof nodePolicy?.delegatedWorkerAutoApprove === "boolean") {
|
|
48
98
|
return nodePolicy.delegatedWorkerAutoApprove;
|
|
@@ -67,7 +117,7 @@ function resolveProviderMaxParallel(nodePolicy, providerType) {
|
|
|
67
117
|
}
|
|
68
118
|
return void 0;
|
|
69
119
|
}
|
|
70
|
-
var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, DEFAULT_MESH_POLICY;
|
|
120
|
+
var MESH_SCHEDULING_STRATEGIES, DEFAULT_MESH_SCHEDULING_STRATEGY, MESH_CONVERGE_REFINE_TAG, MESH_CONVERGE_FAST_FORWARD_TAG, DEFAULT_MESH_POLICY, SESSION_CLEANUP_MODES, SPAWNED_SESSION_VISIBILITY_MODES, DIRTY_WORKSPACE_BEHAVIORS, MESH_MAX_PARALLEL_TASKS_MIN, MESH_MAX_PARALLEL_TASKS_MAX;
|
|
71
121
|
var init_repo_mesh_types = __esm({
|
|
72
122
|
"src/repo-mesh-types.ts"() {
|
|
73
123
|
"use strict";
|
|
@@ -97,6 +147,23 @@ var init_repo_mesh_types = __esm({
|
|
|
97
147
|
autoFastForward: { enabled: true },
|
|
98
148
|
maxTaskRetries: 1
|
|
99
149
|
};
|
|
150
|
+
SESSION_CLEANUP_MODES = /* @__PURE__ */ new Set([
|
|
151
|
+
"preserve",
|
|
152
|
+
"stop",
|
|
153
|
+
"delete_stopped",
|
|
154
|
+
"stop_and_delete"
|
|
155
|
+
]);
|
|
156
|
+
SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set([
|
|
157
|
+
"visible",
|
|
158
|
+
"hidden"
|
|
159
|
+
]);
|
|
160
|
+
DIRTY_WORKSPACE_BEHAVIORS = /* @__PURE__ */ new Set([
|
|
161
|
+
"block",
|
|
162
|
+
"warn",
|
|
163
|
+
"checkpoint_then_continue"
|
|
164
|
+
]);
|
|
165
|
+
MESH_MAX_PARALLEL_TASKS_MIN = 1;
|
|
166
|
+
MESH_MAX_PARALLEL_TASKS_MAX = 8;
|
|
100
167
|
}
|
|
101
168
|
});
|
|
102
169
|
|
|
@@ -316,10 +383,10 @@ function readInjected(value) {
|
|
|
316
383
|
}
|
|
317
384
|
function getDaemonBuildInfo() {
|
|
318
385
|
if (cached) return cached;
|
|
319
|
-
const commit = readInjected(true ? "
|
|
320
|
-
const commitShort = readInjected(true ? "
|
|
321
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
322
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
386
|
+
const commit = readInjected(true ? "18afac213951f79c502feb6b25b7399fe4d709b3" : void 0) ?? "unknown";
|
|
387
|
+
const commitShort = readInjected(true ? "18afac21" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
388
|
+
const version = readInjected(true ? "0.9.82-rc.381" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
389
|
+
const builtAt = readInjected(true ? "2026-06-25T11:44:40.598Z" : void 0);
|
|
323
390
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
324
391
|
return cached;
|
|
325
392
|
}
|
|
@@ -2369,52 +2436,6 @@ function normalizeRepoIdentity(remoteUrl) {
|
|
|
2369
2436
|
if (sshMatch) return `${sshMatch[1]}/${sshMatch[2]}`;
|
|
2370
2437
|
return identity;
|
|
2371
2438
|
}
|
|
2372
|
-
function mergeMeshPolicy(base, patch) {
|
|
2373
|
-
const autoFastForward = normalizeAutoFastForwardPolicy({
|
|
2374
|
-
...DEFAULT_MESH_POLICY.autoFastForward,
|
|
2375
|
-
...base?.autoFastForward && typeof base.autoFastForward === "object" ? base.autoFastForward : {},
|
|
2376
|
-
...patch?.autoFastForward && typeof patch.autoFastForward === "object" ? patch.autoFastForward : {}
|
|
2377
|
-
});
|
|
2378
|
-
const policy = {
|
|
2379
|
-
...DEFAULT_MESH_POLICY,
|
|
2380
|
-
...base || {},
|
|
2381
|
-
...patch || {},
|
|
2382
|
-
autoFastForward
|
|
2383
|
-
};
|
|
2384
|
-
if (!["block", "warn", "checkpoint_then_continue"].includes(policy.dirtyWorkspaceBehavior)) {
|
|
2385
|
-
policy.dirtyWorkspaceBehavior = "warn";
|
|
2386
|
-
}
|
|
2387
|
-
const maxParallelTasks = Number(policy.maxParallelTasks);
|
|
2388
|
-
policy.maxParallelTasks = Number.isFinite(maxParallelTasks) ? Math.max(1, Math.min(8, Math.floor(maxParallelTasks))) : 2;
|
|
2389
|
-
policy.allowAutoPublishSubmoduleMainCommits = policy.allowAutoPublishSubmoduleMainCommits === true;
|
|
2390
|
-
if (!SESSION_CLEANUP_MODES.has(String(policy.sessionCleanupOnNodeRemove))) {
|
|
2391
|
-
policy.sessionCleanupOnNodeRemove = "preserve";
|
|
2392
|
-
}
|
|
2393
|
-
if (!SPAWNED_SESSION_VISIBILITY_MODES.has(String(policy.spawnedSessionVisibility))) {
|
|
2394
|
-
policy.spawnedSessionVisibility = DEFAULT_MESH_POLICY.spawnedSessionVisibility;
|
|
2395
|
-
}
|
|
2396
|
-
const normalizedStrategy = normalizeMeshSchedulingStrategy(policy.schedulingStrategy);
|
|
2397
|
-
if (normalizedStrategy === "first_eligible") {
|
|
2398
|
-
delete policy.schedulingStrategy;
|
|
2399
|
-
} else {
|
|
2400
|
-
policy.schedulingStrategy = normalizedStrategy;
|
|
2401
|
-
}
|
|
2402
|
-
if (policy.autoConvergeCodeChange === true) {
|
|
2403
|
-
policy.autoConvergeCodeChange = true;
|
|
2404
|
-
} else {
|
|
2405
|
-
delete policy.autoConvergeCodeChange;
|
|
2406
|
-
}
|
|
2407
|
-
return policy;
|
|
2408
|
-
}
|
|
2409
|
-
function normalizeAutoFastForwardPolicy(value) {
|
|
2410
|
-
const record = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2411
|
-
const maxBehind = Number(record.maxBehind);
|
|
2412
|
-
return {
|
|
2413
|
-
enabled: record.enabled !== false,
|
|
2414
|
-
...Number.isFinite(maxBehind) && maxBehind >= 0 ? { maxBehind: Math.floor(maxBehind) } : {},
|
|
2415
|
-
requireCleanSubmodules: record.requireCleanSubmodules !== false
|
|
2416
|
-
};
|
|
2417
|
-
}
|
|
2418
2439
|
function listMeshes() {
|
|
2419
2440
|
return loadMeshConfig().meshes;
|
|
2420
2441
|
}
|
|
@@ -2713,7 +2734,7 @@ function updateNode(meshId, nodeId, opts) {
|
|
|
2713
2734
|
saveMeshConfig(config);
|
|
2714
2735
|
return node;
|
|
2715
2736
|
}
|
|
2716
|
-
var import_fs3, import_path3, import_crypto3,
|
|
2737
|
+
var import_fs3, import_path3, import_crypto3, mergeMeshPolicy;
|
|
2717
2738
|
var init_mesh_config = __esm({
|
|
2718
2739
|
"src/config/mesh-config.ts"() {
|
|
2719
2740
|
"use strict";
|
|
@@ -2724,8 +2745,7 @@ var init_mesh_config = __esm({
|
|
|
2724
2745
|
init_config();
|
|
2725
2746
|
init_repo_mesh_types();
|
|
2726
2747
|
init_mesh_host_ownership();
|
|
2727
|
-
|
|
2728
|
-
SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set(["visible", "hidden"]);
|
|
2748
|
+
mergeMeshPolicy = mergeAndNormalizePolicy;
|
|
2729
2749
|
}
|
|
2730
2750
|
});
|
|
2731
2751
|
|
|
@@ -3046,7 +3066,7 @@ Default branch: \`${mesh.defaultBranch}\`` : ""}`);
|
|
|
3046
3066
|
if (recentActivity) sections.push(recentActivity);
|
|
3047
3067
|
const operatingNotes = buildOperatingNotesSection(ctx.operatingNotes);
|
|
3048
3068
|
if (operatingNotes) sections.push(operatingNotes);
|
|
3049
|
-
sections.push(buildPolicySection(
|
|
3069
|
+
sections.push(buildPolicySection(mergeAndNormalizePolicy(void 0, mesh.policy)));
|
|
3050
3070
|
sections.push(TOOLS_SECTION);
|
|
3051
3071
|
sections.push(TOOL_EXPOSURE_PREFLIGHT_SECTION);
|
|
3052
3072
|
sections.push(WORKFLOW_SECTION);
|
|
@@ -3079,7 +3099,7 @@ function expandPromptPlaceholders(template, ctx) {
|
|
|
3079
3099
|
mission: ctx.missionSection?.trim() || "",
|
|
3080
3100
|
recentActivity: buildRecentActivitySection(ctx.recentActivity) || "",
|
|
3081
3101
|
operatingNotes: buildOperatingNotesSection(ctx.operatingNotes) || "",
|
|
3082
|
-
policy: buildPolicySection(
|
|
3102
|
+
policy: buildPolicySection(mergeAndNormalizePolicy(void 0, mesh.policy)),
|
|
3083
3103
|
tools: TOOLS_SECTION,
|
|
3084
3104
|
workflow: WORKFLOW_SECTION,
|
|
3085
3105
|
rules: buildRulesSection(coordinatorCliType),
|
|
@@ -5748,6 +5768,28 @@ var init_mesh_runtime_store = __esm({
|
|
|
5748
5768
|
AND status NOT IN ('completed', 'failed')
|
|
5749
5769
|
`).run({ status, meshId, sessionId, updatedAt: now });
|
|
5750
5770
|
}
|
|
5771
|
+
/**
|
|
5772
|
+
* MESH-DISPATCH-MISROUTE (fix 3, consumer residual): resolve the task_id of the SINGLE
|
|
5773
|
+
* non-terminal direct dispatch a session owns. Returns the task_id only when the session
|
|
5774
|
+
* holds exactly ONE active ('dispatched'/'acked') row — the case where a taskId-less
|
|
5775
|
+
* lifecycle event (a legacy/relayed worker whose producer never stamped meshActiveTaskId)
|
|
5776
|
+
* unambiguously belongs to that one dispatch. With zero rows there is nothing to ack; with
|
|
5777
|
+
* two or more (a re-dispatch/nudge sibling) the firing event's owner is ambiguous, so we
|
|
5778
|
+
* return null and the caller MUST NOT fall back to the session_id sweep that would flip a
|
|
5779
|
+
* sibling row ("may flip a sibling dispatch row"). This narrows the legacy fallback to the
|
|
5780
|
+
* only safe case instead of removing the producer-side TASKIDLESS stamp's safety net.
|
|
5781
|
+
*/
|
|
5782
|
+
getSoleActiveDirectDispatchTaskId(meshId, sessionId) {
|
|
5783
|
+
if (!sessionId) return null;
|
|
5784
|
+
const rows = this.db.prepare(`
|
|
5785
|
+
SELECT task_id FROM mesh_direct_dispatches
|
|
5786
|
+
WHERE mesh_id = ? AND session_id = ?
|
|
5787
|
+
AND status NOT IN ('completed', 'failed', 'stale')
|
|
5788
|
+
`).all(meshId, sessionId);
|
|
5789
|
+
if (rows.length !== 1) return null;
|
|
5790
|
+
const taskId = typeof rows[0]?.task_id === "string" ? rows[0].task_id.trim() : "";
|
|
5791
|
+
return taskId || null;
|
|
5792
|
+
}
|
|
5751
5793
|
cleanupTerminalDirectDispatches(olderThanMs) {
|
|
5752
5794
|
const cutoff = new Date(Date.now() - olderThanMs).toISOString();
|
|
5753
5795
|
this.db.prepare(`
|
|
@@ -10819,8 +10861,8 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
|
10819
10861
|
const maxParallelTasks = Math.max(1, Math.floor(Number(mesh?.policy?.maxParallelTasks) || 2));
|
|
10820
10862
|
const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
|
|
10821
10863
|
for (const task of pending) {
|
|
10822
|
-
const
|
|
10823
|
-
if (
|
|
10864
|
+
const isReadonly2 = task.taskMode === "live_debug_readonly";
|
|
10865
|
+
if (isReadonly2) {
|
|
10824
10866
|
if (activeReadonlyAssignedCount(meshId) >= maxReadonlyParallelTasks) {
|
|
10825
10867
|
markAutoLaunch(meshId, task.id, { status: "skipped", reason: "max_readonly_parallel_tasks_reached" });
|
|
10826
10868
|
continue;
|
|
@@ -14249,8 +14291,19 @@ function injectMeshSystemMessage(components, args) {
|
|
|
14249
14291
|
}
|
|
14250
14292
|
if (sessionId) {
|
|
14251
14293
|
const startedTaskId = readNonEmptyString2(args.metadataEvent.taskId) || void 0;
|
|
14252
|
-
if (startedTaskId
|
|
14294
|
+
if (startedTaskId) {
|
|
14253
14295
|
updateDirectDispatchStatus(args.meshId, sessionId, "acked", startedTaskId);
|
|
14296
|
+
} else if (sessionHasActiveAssignment(args.meshId, sessionId)) {
|
|
14297
|
+
const soleTaskId = (() => {
|
|
14298
|
+
try {
|
|
14299
|
+
return MeshRuntimeStore.getInstance().getSoleActiveDirectDispatchTaskId(args.meshId, sessionId);
|
|
14300
|
+
} catch {
|
|
14301
|
+
return null;
|
|
14302
|
+
}
|
|
14303
|
+
})();
|
|
14304
|
+
if (soleTaskId) {
|
|
14305
|
+
updateDirectDispatchStatus(args.meshId, sessionId, "acked", soleTaskId);
|
|
14306
|
+
}
|
|
14254
14307
|
}
|
|
14255
14308
|
const activeDeliveries = (() => {
|
|
14256
14309
|
try {
|
|
@@ -21110,6 +21163,8 @@ __export(index_exports, {
|
|
|
21110
21163
|
MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
|
|
21111
21164
|
MESH_CONVERGE_FAST_FORWARD_TAG: () => MESH_CONVERGE_FAST_FORWARD_TAG,
|
|
21112
21165
|
MESH_CONVERGE_REFINE_TAG: () => MESH_CONVERGE_REFINE_TAG,
|
|
21166
|
+
MESH_MAX_PARALLEL_TASKS_MAX: () => MESH_MAX_PARALLEL_TASKS_MAX,
|
|
21167
|
+
MESH_MAX_PARALLEL_TASKS_MIN: () => MESH_MAX_PARALLEL_TASKS_MIN,
|
|
21113
21168
|
MESH_MISSION_STATUSES: () => MESH_MISSION_STATUSES,
|
|
21114
21169
|
MESH_NODE_LIVE_TRUTH_MARKER: () => MESH_NODE_LIVE_TRUTH_MARKER,
|
|
21115
21170
|
MESH_REFINE_CONFIG_LOCATIONS: () => MESH_REFINE_CONFIG_LOCATIONS,
|
|
@@ -21160,6 +21215,7 @@ __export(index_exports, {
|
|
|
21160
21215
|
buildMeshNodeCapabilityTags: () => buildMeshNodeCapabilityTags,
|
|
21161
21216
|
buildMeshNodeDataFreshness: () => buildMeshNodeDataFreshness,
|
|
21162
21217
|
buildMeshNodeProbeFreshness: () => buildMeshNodeProbeFreshness,
|
|
21218
|
+
buildMeshSchedulingRuntime: () => buildMeshSchedulingRuntime,
|
|
21163
21219
|
buildMissionPromptSection: () => buildMissionPromptSection,
|
|
21164
21220
|
buildP2pRelayFailurePayload: () => buildP2pRelayFailurePayload,
|
|
21165
21221
|
buildPinnedGlobalInstallCommand: () => buildPinnedGlobalInstallCommand,
|
|
@@ -21308,11 +21364,13 @@ __export(index_exports, {
|
|
|
21308
21364
|
markSetupComplete: () => markSetupComplete,
|
|
21309
21365
|
markStaleDirectDispatches: () => markStaleDirectDispatches,
|
|
21310
21366
|
maybeRunDaemonUpgradeHelperFromEnv: () => maybeRunDaemonUpgradeHelperFromEnv,
|
|
21367
|
+
mergeAndNormalizePolicy: () => mergeAndNormalizePolicy,
|
|
21311
21368
|
meshNodeIdMatches: () => meshNodeIdMatches,
|
|
21312
21369
|
namedKeyToAnsi: () => namedKeyToAnsi,
|
|
21313
21370
|
namedKeysToAnsi: () => namedKeysToAnsi,
|
|
21314
21371
|
nodeSatisfiesRequiredTags: () => nodeSatisfiesRequiredTags,
|
|
21315
21372
|
normalizeActiveChatData: () => normalizeActiveChatData,
|
|
21373
|
+
normalizeAutoFastForwardPolicy: () => normalizeAutoFastForwardPolicy,
|
|
21316
21374
|
normalizeChatMessage: () => normalizeChatMessage,
|
|
21317
21375
|
normalizeChatMessageKind: () => normalizeChatMessageKind,
|
|
21318
21376
|
normalizeChatMessages: () => normalizeChatMessages,
|
|
@@ -21374,11 +21432,13 @@ __export(index_exports, {
|
|
|
21374
21432
|
resolveDelegatedWorkerAutoApprove: () => resolveDelegatedWorkerAutoApprove,
|
|
21375
21433
|
resolveDeliveryDecision: () => resolveDeliveryDecision,
|
|
21376
21434
|
resolveGitRepository: () => resolveGitRepository,
|
|
21435
|
+
resolveMaxParallelTasks: () => resolveMaxParallelTasks,
|
|
21377
21436
|
resolveMeshHostStatus: () => resolveMeshHostStatus,
|
|
21378
21437
|
resolveMeshNodeAttribution: () => resolveMeshNodeAttribution,
|
|
21379
21438
|
resolveMeshRefineValidationPlan: () => resolveMeshRefineValidationPlan,
|
|
21380
21439
|
resolveMeshSurfacedSessionPreview: () => resolveMeshSurfacedSessionPreview,
|
|
21381
21440
|
resolveNodeSchedulingPriority: () => resolveNodeSchedulingPriority,
|
|
21441
|
+
resolveProviderMaxParallel: () => resolveProviderMaxParallel,
|
|
21382
21442
|
resolveSessionHostAppName: () => resolveSessionHostAppName,
|
|
21383
21443
|
resolveSessionHostAppNameResolution: () => resolveSessionHostAppNameResolution,
|
|
21384
21444
|
resolveWorktreePath: () => resolveWorktreePath,
|
|
@@ -23295,6 +23355,102 @@ function buildMeshLedgerReconciliationEvidence(meshId, replicas) {
|
|
|
23295
23355
|
init_mesh_work_queue();
|
|
23296
23356
|
init_mesh_active_work();
|
|
23297
23357
|
init_mesh_refine_status();
|
|
23358
|
+
|
|
23359
|
+
// src/mesh/mesh-scheduling-runtime.ts
|
|
23360
|
+
init_repo_mesh_types();
|
|
23361
|
+
init_dist();
|
|
23362
|
+
function isReadonly(task) {
|
|
23363
|
+
return task.taskMode === "live_debug_readonly";
|
|
23364
|
+
}
|
|
23365
|
+
function isAssigned(task) {
|
|
23366
|
+
return task.status === "assigned";
|
|
23367
|
+
}
|
|
23368
|
+
function buildMeshSchedulingRuntime(mesh, queue) {
|
|
23369
|
+
const strategy = normalizeMeshSchedulingStrategy(mesh?.policy?.schedulingStrategy);
|
|
23370
|
+
const maxParallelTasks = resolveMaxParallelTasks(mesh?.policy?.maxParallelTasks);
|
|
23371
|
+
const maxReadonlyParallelTasks = Math.max(2, maxParallelTasks * 2);
|
|
23372
|
+
const assignedTasks = (Array.isArray(queue) ? queue : []).filter(isAssigned);
|
|
23373
|
+
const activeWriteAssigned = assignedTasks.filter((t) => !isReadonly(t)).length;
|
|
23374
|
+
const activeReadonlyAssigned = assignedTasks.filter(isReadonly).length;
|
|
23375
|
+
const globalWriteCapReached = activeWriteAssigned >= maxParallelTasks;
|
|
23376
|
+
const globalReadonlyCapReached = activeReadonlyAssigned >= maxReadonlyParallelTasks;
|
|
23377
|
+
const writeAssignedByNode = /* @__PURE__ */ new Map();
|
|
23378
|
+
const assignedByNode = /* @__PURE__ */ new Map();
|
|
23379
|
+
const providerCountByNode = /* @__PURE__ */ new Map();
|
|
23380
|
+
for (const task of assignedTasks) {
|
|
23381
|
+
const nodeId = typeof task.assignedNodeId === "string" ? task.assignedNodeId.trim() : "";
|
|
23382
|
+
if (!nodeId) continue;
|
|
23383
|
+
assignedByNode.set(nodeId, (assignedByNode.get(nodeId) ?? 0) + 1);
|
|
23384
|
+
if (!isReadonly(task)) {
|
|
23385
|
+
writeAssignedByNode.set(nodeId, (writeAssignedByNode.get(nodeId) ?? 0) + 1);
|
|
23386
|
+
}
|
|
23387
|
+
const provider = typeof task.assignedProviderType === "string" ? task.assignedProviderType : "";
|
|
23388
|
+
if (provider) {
|
|
23389
|
+
let byProvider = providerCountByNode.get(nodeId);
|
|
23390
|
+
if (!byProvider) {
|
|
23391
|
+
byProvider = /* @__PURE__ */ new Map();
|
|
23392
|
+
providerCountByNode.set(nodeId, byProvider);
|
|
23393
|
+
}
|
|
23394
|
+
byProvider.set(provider, (byProvider.get(provider) ?? 0) + 1);
|
|
23395
|
+
}
|
|
23396
|
+
}
|
|
23397
|
+
const nodes = [];
|
|
23398
|
+
for (const rawNode of Array.isArray(mesh?.nodes) ? mesh.nodes : []) {
|
|
23399
|
+
const nodeId = normalizeMeshNodeId(rawNode);
|
|
23400
|
+
if (!nodeId) continue;
|
|
23401
|
+
const policy = rawNode?.policy || void 0;
|
|
23402
|
+
const load4 = assignedByNode.get(nodeId) ?? 0;
|
|
23403
|
+
const schedulingPriority = resolveNodeSchedulingPriority(policy);
|
|
23404
|
+
const capReasons = [];
|
|
23405
|
+
if (globalWriteCapReached) capReasons.push("global_max_parallel_tasks_reached");
|
|
23406
|
+
if ((writeAssignedByNode.get(nodeId) ?? 0) > 0) capReasons.push("node_has_active_assignment");
|
|
23407
|
+
let providerRoles;
|
|
23408
|
+
const declaredRoles = Array.isArray(policy?.providerRoles) ? policy.providerRoles : [];
|
|
23409
|
+
if (declaredRoles.length) {
|
|
23410
|
+
const byProvider = providerCountByNode.get(nodeId);
|
|
23411
|
+
providerRoles = [];
|
|
23412
|
+
for (const role of declaredRoles) {
|
|
23413
|
+
if (!role || typeof role !== "object") continue;
|
|
23414
|
+
const providerType = typeof role.providerType === "string" ? role.providerType.trim() : "";
|
|
23415
|
+
if (!providerType) continue;
|
|
23416
|
+
const maxParallel = resolveProviderMaxParallel(policy, providerType);
|
|
23417
|
+
const activeAssigned = byProvider?.get(providerType) ?? 0;
|
|
23418
|
+
const capReached = maxParallel !== void 0 && activeAssigned >= maxParallel;
|
|
23419
|
+
providerRoles.push({
|
|
23420
|
+
providerType,
|
|
23421
|
+
...maxParallel !== void 0 ? { maxParallel } : {},
|
|
23422
|
+
activeAssigned,
|
|
23423
|
+
capReached
|
|
23424
|
+
});
|
|
23425
|
+
if (capReached) capReasons.push(`max_provider_parallel_reached:${providerType}`);
|
|
23426
|
+
}
|
|
23427
|
+
if (!providerRoles.length) providerRoles = void 0;
|
|
23428
|
+
}
|
|
23429
|
+
const maxConcurrentSessions = Number(policy?.maxConcurrentSessions);
|
|
23430
|
+
const hasSessionCap = Number.isFinite(maxConcurrentSessions) && maxConcurrentSessions >= 0;
|
|
23431
|
+
nodes.push({
|
|
23432
|
+
nodeId,
|
|
23433
|
+
load: load4,
|
|
23434
|
+
schedulingPriority,
|
|
23435
|
+
...hasSessionCap ? { maxConcurrentSessions: Math.floor(maxConcurrentSessions) } : {},
|
|
23436
|
+
...providerRoles ? { providerRoles } : {},
|
|
23437
|
+
capReached: capReasons.length > 0,
|
|
23438
|
+
capReasons
|
|
23439
|
+
});
|
|
23440
|
+
}
|
|
23441
|
+
return {
|
|
23442
|
+
strategy,
|
|
23443
|
+
maxParallelTasks,
|
|
23444
|
+
maxReadonlyParallelTasks,
|
|
23445
|
+
activeWriteAssigned,
|
|
23446
|
+
activeReadonlyAssigned,
|
|
23447
|
+
globalWriteCapReached,
|
|
23448
|
+
globalReadonlyCapReached,
|
|
23449
|
+
nodes
|
|
23450
|
+
};
|
|
23451
|
+
}
|
|
23452
|
+
|
|
23453
|
+
// src/index.ts
|
|
23298
23454
|
init_mesh_host_ownership();
|
|
23299
23455
|
init_mesh_events();
|
|
23300
23456
|
init_mesh_events_utils();
|
|
@@ -62572,6 +62728,8 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
62572
62728
|
MAX_LEDGER_SLICE_LIMIT,
|
|
62573
62729
|
MESH_CONVERGE_FAST_FORWARD_TAG,
|
|
62574
62730
|
MESH_CONVERGE_REFINE_TAG,
|
|
62731
|
+
MESH_MAX_PARALLEL_TASKS_MAX,
|
|
62732
|
+
MESH_MAX_PARALLEL_TASKS_MIN,
|
|
62575
62733
|
MESH_MISSION_STATUSES,
|
|
62576
62734
|
MESH_NODE_LIVE_TRUTH_MARKER,
|
|
62577
62735
|
MESH_REFINE_CONFIG_LOCATIONS,
|
|
@@ -62622,6 +62780,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
62622
62780
|
buildMeshNodeCapabilityTags,
|
|
62623
62781
|
buildMeshNodeDataFreshness,
|
|
62624
62782
|
buildMeshNodeProbeFreshness,
|
|
62783
|
+
buildMeshSchedulingRuntime,
|
|
62625
62784
|
buildMissionPromptSection,
|
|
62626
62785
|
buildP2pRelayFailurePayload,
|
|
62627
62786
|
buildPinnedGlobalInstallCommand,
|
|
@@ -62770,11 +62929,13 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
62770
62929
|
markSetupComplete,
|
|
62771
62930
|
markStaleDirectDispatches,
|
|
62772
62931
|
maybeRunDaemonUpgradeHelperFromEnv,
|
|
62932
|
+
mergeAndNormalizePolicy,
|
|
62773
62933
|
meshNodeIdMatches,
|
|
62774
62934
|
namedKeyToAnsi,
|
|
62775
62935
|
namedKeysToAnsi,
|
|
62776
62936
|
nodeSatisfiesRequiredTags,
|
|
62777
62937
|
normalizeActiveChatData,
|
|
62938
|
+
normalizeAutoFastForwardPolicy,
|
|
62778
62939
|
normalizeChatMessage,
|
|
62779
62940
|
normalizeChatMessageKind,
|
|
62780
62941
|
normalizeChatMessages,
|
|
@@ -62836,11 +62997,13 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
62836
62997
|
resolveDelegatedWorkerAutoApprove,
|
|
62837
62998
|
resolveDeliveryDecision,
|
|
62838
62999
|
resolveGitRepository,
|
|
63000
|
+
resolveMaxParallelTasks,
|
|
62839
63001
|
resolveMeshHostStatus,
|
|
62840
63002
|
resolveMeshNodeAttribution,
|
|
62841
63003
|
resolveMeshRefineValidationPlan,
|
|
62842
63004
|
resolveMeshSurfacedSessionPreview,
|
|
62843
63005
|
resolveNodeSchedulingPriority,
|
|
63006
|
+
resolveProviderMaxParallel,
|
|
62844
63007
|
resolveSessionHostAppName,
|
|
62845
63008
|
resolveSessionHostAppNameResolution,
|
|
62846
63009
|
resolveWorktreePath,
|