@adhdev/daemon-core 0.9.82-rc.367 → 0.9.82-rc.369
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/boot/daemon-lifecycle.d.ts +1 -0
- package/dist/commands/router.d.ts +37 -32
- package/dist/index.js +297 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +297 -96
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-warmup-deadline.d.ts +68 -0
- package/package.json +2 -2
- package/src/boot/daemon-lifecycle.ts +8 -0
- package/src/commands/cli-manager.ts +79 -10
- package/src/commands/high-family/mesh-status.ts +6 -3
- package/src/commands/router.ts +188 -94
- package/src/mesh/mesh-events-coordinator.ts +172 -33
- package/src/mesh/mesh-warmup-deadline.ts +152 -0
|
@@ -81,6 +81,7 @@ export interface DaemonComponents {
|
|
|
81
81
|
};
|
|
82
82
|
refreshProviderAvailability: (providerType?: string) => Promise<void>;
|
|
83
83
|
dispatchMeshCommand?: (daemonId: string, command: string, args: Record<string, unknown>) => Promise<any>;
|
|
84
|
+
getMeshPeerConnectionStatus?: (daemonId: string) => Record<string, unknown> | null;
|
|
84
85
|
onMeshCoordinatorEventForwarded?: (payload: Record<string, unknown>) => void;
|
|
85
86
|
meshReconcileLoop?: {
|
|
86
87
|
stop(): void;
|
|
@@ -14,6 +14,7 @@ import { DaemonCliManager } from './cli-manager.js';
|
|
|
14
14
|
import type { ProviderLoader } from '../providers/provider-loader.js';
|
|
15
15
|
import type { ProviderInstanceManager } from '../providers/provider-instance-manager.js';
|
|
16
16
|
import { SessionRegistry } from '../sessions/registry.js';
|
|
17
|
+
import { awaitWithWarmupDeadline } from '../mesh/mesh-warmup-deadline.js';
|
|
17
18
|
export declare function readProviderPriorityFromPolicy(policy: unknown): string[];
|
|
18
19
|
/**
|
|
19
20
|
* Normalize a providerRoles array (RepoMeshNodePolicy.providerRoles) from raw
|
|
@@ -78,11 +79,46 @@ export declare function resolveMeshNodeAttribution(node: unknown): {
|
|
|
78
79
|
machineName?: string;
|
|
79
80
|
};
|
|
80
81
|
export declare function readCachedInlineMeshActiveSessionDetails(node: any): Array<Record<string, unknown>>;
|
|
82
|
+
/**
|
|
83
|
+
* Transient per-node marker the mesh_status render loop stamps onto a node
|
|
84
|
+
* `status` at the two sites that obtain git truth from a FRESH probe this call
|
|
85
|
+
* (a successful local `getGitRepoStatus`, or a successful P2P `git_status`
|
|
86
|
+
* round-trip). finalizeMeshNodeStatus consumes and deletes it. Held/standing
|
|
87
|
+
* truth (node.lastGit / cachedStatus / inline transit) is deliberately NOT
|
|
88
|
+
* stamped — its absence is exactly how the freshness marker tells "live" apart
|
|
89
|
+
* from "cached". Internal only; never serialized in the response.
|
|
90
|
+
*/
|
|
91
|
+
export declare const MESH_NODE_LIVE_TRUTH_MARKER = "__liveTruthProbed";
|
|
92
|
+
/**
|
|
93
|
+
* Build the additive per-node `dataFreshness` marker. This NEVER mutates any
|
|
94
|
+
* existing field — it only adds an explicit, machine-readable answer to the
|
|
95
|
+
* question the legacy fields blurred: is this node's data live (just probed),
|
|
96
|
+
* cached (held truth, maybe old), or absent because the peer was unreachable?
|
|
97
|
+
*
|
|
98
|
+
* The crucial separation: an UNREACHABLE peer (P2P probe failed / not connected)
|
|
99
|
+
* is no longer indistinguishable from an idle/EMPTY node. Both used to render as
|
|
100
|
+
* `health:'unknown'` with no sessions; now `dataFreshness.dataSource` and
|
|
101
|
+
* `reachable` tell them apart so a coordinator never reads a dead peer as "online
|
|
102
|
+
* but doing nothing".
|
|
103
|
+
*/
|
|
104
|
+
export declare function buildMeshNodeDataFreshness(args: {
|
|
105
|
+
status: Record<string, unknown>;
|
|
106
|
+
node?: any;
|
|
107
|
+
isSelfNode: boolean;
|
|
108
|
+
daemonId?: string;
|
|
109
|
+
/** True when this node was stamped with a fresh live git probe this call. */
|
|
110
|
+
liveTruthProbed: boolean;
|
|
111
|
+
/** True when direct-peer-truth accounting classified this node unavailable. */
|
|
112
|
+
directTruthUnavailable?: boolean;
|
|
113
|
+
now?: () => number;
|
|
114
|
+
}): Record<string, unknown>;
|
|
81
115
|
export declare function finalizeMeshNodeStatus(args: {
|
|
82
116
|
status: Record<string, unknown>;
|
|
83
117
|
node: any;
|
|
84
118
|
daemonId?: string;
|
|
85
119
|
isSelfNode: boolean;
|
|
120
|
+
/** True when direct-peer-truth accounting classified this node unavailable. */
|
|
121
|
+
directTruthUnavailable?: boolean;
|
|
86
122
|
}): void;
|
|
87
123
|
export declare const MESH_DIRECT_PROBE_TIMEOUT_MS: number;
|
|
88
124
|
export declare const MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS: number;
|
|
@@ -117,37 +153,7 @@ export declare class MeshGitProbeCache {
|
|
|
117
153
|
*/
|
|
118
154
|
probe(daemonId: string, workspace: string, probe: () => Promise<Record<string, unknown> | null>): Promise<Record<string, unknown> | null>;
|
|
119
155
|
}
|
|
120
|
-
|
|
121
|
-
* Await `work` under a warmup-aware deadline so a cold-open DataChannel handshake
|
|
122
|
-
* is NOT charged against the command response budget — the root cause of the
|
|
123
|
-
* "first mesh probe to a cold peer false-times-out, the warm retry succeeds"
|
|
124
|
-
* signature. Two budgets, switched by the live peer connection state:
|
|
125
|
-
*
|
|
126
|
-
* - While `isConnected()` returns false the peer's channel is still opening; the
|
|
127
|
-
* cold-open `connectTimeoutMs` budget applies. This phase is deliberately
|
|
128
|
-
* generous because a TURN-relayed cross-machine handshake legitimately needs
|
|
129
|
-
* many seconds — but a genuine connect *failure* is surfaced by `work`
|
|
130
|
-
* rejecting on its own (the mesh manager fails the peer the instant its
|
|
131
|
-
* PeerConnection state goes terminal), so a real failure is never masked for
|
|
132
|
-
* the whole window.
|
|
133
|
-
* - The first time `isConnected()` returns true the channel is warm; from that
|
|
134
|
-
* instant the tight `responseTimeoutMs` governs how long the handler may take.
|
|
135
|
-
* Warm-channel callers therefore see behavior identical to the old single
|
|
136
|
-
* `Promise.race(work, responseTimeoutMs)`.
|
|
137
|
-
*
|
|
138
|
-
* Rejects with `Error('timeout')` when either budget is exhausted, mirroring the
|
|
139
|
-
* previous single-race contract. Pure except for timers + the injected
|
|
140
|
-
* `isConnected` probe, so it is unit-testable under fake timers without any real
|
|
141
|
-
* WebRTC. When no connection getter is wired `isConnected` should be `() => true`
|
|
142
|
-
* (the caller's choice) so the response deadline governs from t0 — the legacy
|
|
143
|
-
* single-budget behavior, never a combined connect+response window.
|
|
144
|
-
*/
|
|
145
|
-
export declare function awaitWithWarmupDeadline<T>(work: Promise<T>, opts: {
|
|
146
|
-
isConnected: () => boolean;
|
|
147
|
-
connectTimeoutMs: number;
|
|
148
|
-
responseTimeoutMs: number;
|
|
149
|
-
pollIntervalMs?: number;
|
|
150
|
-
}): Promise<T>;
|
|
156
|
+
export { awaitWithWarmupDeadline };
|
|
151
157
|
/**
|
|
152
158
|
* Probe a remote peer's git_status with a bounded retry budget, but only while
|
|
153
159
|
* the peer is reported `connected`. A single slow (often TURN-relayed) peer can
|
|
@@ -781,4 +787,3 @@ export declare class DaemonCommandRouter {
|
|
|
781
787
|
*/
|
|
782
788
|
private stopIde;
|
|
783
789
|
}
|
|
784
|
-
export {};
|