Skip to content

Commit 5c594e4

Browse files
committed
fix(core): remove spurious async from synchronous methods
29 require-await warnings and 1 unused eslint-disable directive. All methods either implement an interface returning Promise<T> with a synchronous body (return Promise.resolve() explicitly) or are private helpers that never needed async in the first place (return bare CommsResult). Files changed: - bridges/pi: eslint-disable for SDK-mandated async handler - discovery backends: Promise.resolve() for interface-compliant stubs - federation: Promise.resolve() for synchronous disconnect - mesh-store: Promise.resolve() for fire-and-forget connectToRemote - store: remove async from throw-only FileStore stubs - transports: Promise.resolve() for synchronous removeListener/shutdown - tool: return bare CommsResult from synchronous query methods - test helper: remove unused eslint-disable directive
1 parent 952047c commit 5c594e4

12 files changed

Lines changed: 60 additions & 40 deletions

src/bridges/pi/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export default function (pi: ExtensionAPI) {
178178

179179
pi.registerCommand("comms-url", {
180180
description: "Show the Agent Comms web UI URL",
181+
// eslint-disable-next-line @typescript-eslint/require-await -- SDK requires Promise<void> return
181182
handler: async (_args, ctx) => {
182183
if (!webHandle) {
183184
ctx.ui.notify("Web UI is not running.", "error");

src/core/discovery-mdns.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class MdnsDiscoveryBackend implements DiscoveryBackend {
6363
return id;
6464
}
6565

66-
async stopAdvertising(id: string): Promise<void> {
66+
stopAdvertising(id: string): Promise<void> {
6767
void id;
6868

6969
if (this.beaconTimer !== undefined) {
@@ -79,10 +79,12 @@ export class MdnsDiscoveryBackend implements DiscoveryBackend {
7979
this.socket = undefined;
8080
this.isListening = false;
8181
}
82+
83+
return Promise.resolve();
8284
}
8385

8486
/** Stop all beacon activity and close the socket. */
85-
async stop(): Promise<void> {
87+
stop(): Promise<void> {
8688
if (this.beaconTimer !== undefined) {
8789
clearInterval(this.beaconTimer);
8890
this.beaconTimer = undefined;
@@ -95,6 +97,8 @@ export class MdnsDiscoveryBackend implements DiscoveryBackend {
9597
this.socket = undefined;
9698
this.isListening = false;
9799
}
100+
101+
return Promise.resolve();
98102
}
99103

100104
async discover(

src/core/discovery-tailscale.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,21 @@ export class TailscaleDiscoveryBackend implements DiscoveryBackend {
5858
readonly name = "tailscale";
5959

6060
/** No-op — the coordinator already listens on the Tailscale IP. */
61-
async startAdvertising(opts: AdvertiseOptions): Promise<string> {
62-
return `tailscale-${String(opts.port)}`;
61+
startAdvertising(opts: AdvertiseOptions): Promise<string> {
62+
return Promise.resolve(`tailscale-${String(opts.port)}`);
6363
}
6464

6565
/** No-op — nothing to stop. */
66-
async stopAdvertising(id: string): Promise<void> {
66+
stopAdvertising(id: string): Promise<void> {
6767
void id;
68+
return Promise.resolve();
6869
}
6970

7071
/** Stop discovery — no-op since Tailscale has no persistent state to clean up. */
71-
async stop(): Promise<void> {
72+
stop(): Promise<void> {
7273
// Tailscale discovery is stateless — each discover() call probes peers fresh.
7374
// No persistent connections or timers to tear down.
75+
return Promise.resolve();
7476
}
7577

7678
/**

src/core/discovery.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,24 +199,24 @@ export class DiscoveryManager {
199199
}
200200
}
201201

202-
private async resumeAllAdvertisements(): Promise<void> {
202+
private resumeAllAdvertisements(): Promise<void> {
203203
// Restart backends first (they may have been stopped in "dark" mode)
204204
// Note: backends reinitialise their sockets on next startAdvertising/discover call.
205205
for (const [id] of this.pausedAdvertisements) {
206206
this.pausedAdvertisements.delete(id);
207207
// We can't fully resume without original opts — the caller must
208208
// re-advertise. Mark as not paused so new advertise calls work.
209209
}
210+
return Promise.resolve();
210211
}
211212

212-
private async resumeAdvertisementsForBackend(
213-
backendName: string,
214-
): Promise<void> {
213+
private resumeAdvertisementsForBackend(backendName: string): Promise<void> {
215214
for (const [id, entry] of this.pausedAdvertisements) {
216215
if (entry.backendName === backendName) {
217216
this.pausedAdvertisements.delete(id);
218217
}
219218
}
219+
return Promise.resolve();
220220
}
221221

222222
/** Stop a previously started advertisement. */

src/core/federation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,17 @@ export class FederationManager {
171171
// -----------------------------------------------------------------------
172172

173173
/** Disconnect a specific federation link. */
174-
async disconnect(linkId: string): Promise<void> {
174+
disconnect(linkId: string): Promise<void> {
175175
const link = this.links.get(linkId);
176-
if (!link) return;
176+
if (!link) return Promise.resolve();
177177

178178
this.clearLinkTimers(linkId);
179179
link.ready = false;
180180
link.socket.unref();
181181
link.socket.destroy();
182182
this.links.delete(linkId);
183+
184+
return Promise.resolve();
183185
}
184186

185187
/** List all active federation links. */

src/core/mesh-store.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ export class MeshStore implements CommsStore {
396396
/** Initiate an outbound connection to a remote coordinator requiring approval.
397397
* Fires the connect_request and returns immediately. The connection
398398
* completes asynchronously when the coordinator accepts or rejects. */
399-
async connectToRemote(host: string, port: number): Promise<void> {
399+
connectToRemote(host: string, port: number): Promise<void> {
400400
const agent = this.agents.get(this.peerId);
401401
// Fire-and-forget: don't await the full approval handshake.
402402
// The coordinator will either accept (triggering normal introduction flow)
@@ -415,6 +415,8 @@ export class MeshStore implements CommsStore {
415415
// Log silently — the calling tool already returned success.
416416
void err;
417417
});
418+
419+
return Promise.resolve();
418420
}
419421

420422
/** Start only the data server without connecting to a coordinator.

src/core/store.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,14 @@ export class FileStore implements CommsStore {
618618
// Listener management — not supported by FileStore
619619
// -----------------------------------------------------------------------
620620

621-
async addListener(): Promise<string> {
621+
addListener(): Promise<string> {
622622
throw new CommsError(
623623
"FileStore does not support listener management",
624624
"NOT_SUPPORTED",
625625
);
626626
}
627627

628-
async removeListener(): Promise<void> {
628+
removeListener(): Promise<void> {
629629
throw new CommsError(
630630
"FileStore does not support listener management",
631631
"NOT_SUPPORTED",
@@ -644,14 +644,14 @@ export class FileStore implements CommsStore {
644644
// Federation — not supported by FileStore
645645
// -----------------------------------------------------------------------
646646

647-
async fedConnect(): Promise<string> {
647+
fedConnect(): Promise<string> {
648648
throw new CommsError(
649649
"FileStore does not support federation",
650650
"NOT_SUPPORTED",
651651
);
652652
}
653653

654-
async fedDisconnect(): Promise<void> {
654+
fedDisconnect(): Promise<void> {
655655
throw new CommsError(
656656
"FileStore does not support federation",
657657
"NOT_SUPPORTED",
@@ -664,14 +664,14 @@ export class FileStore implements CommsStore {
664664
// Connection approval — not supported by FileStore
665665
// -----------------------------------------------------------------------
666666

667-
async acceptConnection(): Promise<void> {
667+
acceptConnection(): Promise<void> {
668668
throw new CommsError(
669669
"FileStore does not support connection approval",
670670
"NOT_SUPPORTED",
671671
);
672672
}
673673

674-
async rejectConnection(): Promise<void> {
674+
rejectConnection(): Promise<void> {
675675
throw new CommsError(
676676
"FileStore does not support connection approval",
677677
"NOT_SUPPORTED",
@@ -688,14 +688,14 @@ export class FileStore implements CommsStore {
688688
return [];
689689
}
690690

691-
async connectToRemote(): Promise<void> {
691+
connectToRemote(): Promise<void> {
692692
throw new CommsError(
693693
"FileStore does not support remote connections",
694694
"NOT_SUPPORTED",
695695
);
696696
}
697697

698-
async startDataServerOnly(): Promise<void> {
698+
startDataServerOnly(): Promise<void> {
699699
throw new CommsError(
700700
"FileStore does not support network operations",
701701
"NOT_SUPPORTED",

src/core/tcp-transport.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export class TcpTransport implements MeshTransport {
344344
return id;
345345
}
346346

347-
async removeListener(id: string): Promise<void> {
347+
removeListener(id: string): Promise<void> {
348348
const listener = this.coordinatorListeners.get(id);
349349
if (!listener) {
350350
throw new Error(`Listener ${id} not found`);
@@ -356,6 +356,8 @@ export class TcpTransport implements MeshTransport {
356356
listener.server.unref();
357357
listener.server.close();
358358
this.coordinatorListeners.delete(id);
359+
360+
return Promise.resolve();
359361
}
360362

361363
listListeners(): ListenerInfo[] {
@@ -516,7 +518,7 @@ export class TcpTransport implements MeshTransport {
516518
// MeshTransport — Shutdown / unref
517519
// -----------------------------------------------------------------------
518520

519-
async shutdown(): Promise<void> {
521+
shutdown(): Promise<void> {
520522
this.shutDown = true;
521523

522524
// Destroy the coordinator client socket
@@ -569,6 +571,8 @@ export class TcpTransport implements MeshTransport {
569571
this.defaultListenerId = undefined;
570572

571573
this._isCoordinator = false;
574+
575+
return Promise.resolve();
572576
}
573577

574578
unref(): void {

src/core/tls-transport.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export class TlsTransport {
398398
return id;
399399
}
400400

401-
async removeListener(id: string): Promise<void> {
401+
removeListener(id: string): Promise<void> {
402402
const listener = this.coordinatorListeners.get(id);
403403
if (!listener) {
404404
throw new Error(`Listener ${id} not found`);
@@ -410,6 +410,8 @@ export class TlsTransport {
410410
listener.server.unref();
411411
listener.server.close();
412412
this.coordinatorListeners.delete(id);
413+
414+
return Promise.resolve();
413415
}
414416

415417
listListeners(): ListenerInfo[] {
@@ -569,7 +571,7 @@ export class TlsTransport {
569571
// MeshTransport — Shutdown / unref
570572
// -----------------------------------------------------------------------
571573

572-
async shutdown(): Promise<void> {
574+
shutdown(): Promise<void> {
573575
this.shutDown = true;
574576

575577
// Destroy the coordinator client socket
@@ -622,6 +624,8 @@ export class TlsTransport {
622624
this.defaultListenerId = undefined;
623625

624626
this._isCoordinator = false;
627+
628+
return Promise.resolve();
625629
}
626630

627631
unref(): void {

src/core/tool.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,31 @@ export class CommsTool {
8383
case "mesh_reject":
8484
return await this.meshReject(ctx, action);
8585
case "mesh_pending":
86-
return await this.meshPending(ctx);
86+
return this.meshPending(ctx);
8787
case "mesh_discover":
8888
return await this.meshDiscover(action);
8989
case "mesh_advertise":
9090
return await this.meshAdvertise(ctx, action);
9191
case "mesh_unadvertise":
9292
return await this.meshUnadvertise(action);
9393
case "mesh_interfaces":
94-
return await this.meshInterfaces();
94+
return this.meshInterfaces();
9595
case "mesh_listen":
9696
return await this.meshListen(ctx, action);
9797
case "mesh_unlisten":
9898
return await this.meshUnlisten(ctx, action);
9999
case "mesh_listeners":
100-
return await this.meshListeners(ctx);
100+
return this.meshListeners(ctx);
101101
case "mesh_set_visibility":
102102
return await this.meshSetVisibility(action);
103103
case "mesh_get_visibility":
104-
return await this.meshGetVisibility(action);
104+
return this.meshGetVisibility(action);
105105
case "mesh_fed_connect":
106106
return await this.meshFedConnect(ctx, action);
107107
case "mesh_fed_disconnect":
108108
return await this.meshFedDisconnect(ctx, action);
109109
case "mesh_fed_links":
110-
return await this.meshFedLinks(ctx);
110+
return this.meshFedLinks(ctx);
111111
default:
112112
return {
113113
content: `Unknown action: ${JSON.stringify(action).slice(0, 100)}`,
@@ -391,7 +391,7 @@ export class CommsTool {
391391
};
392392
}
393393

394-
private async meshInterfaces(): Promise<CommsResult> {
394+
private meshInterfaces(): CommsResult {
395395
const interfaces = this.store.getNetworkInterfaces();
396396
if (interfaces.length === 0)
397397
return { content: "No network interfaces found.", isError: false };
@@ -464,7 +464,7 @@ export class CommsTool {
464464
}
465465
}
466466

467-
private async meshListeners(_ctx: CommsContext): Promise<CommsResult> {
467+
private meshListeners(_ctx: CommsContext): CommsResult {
468468
const listeners = this.store.listListeners();
469469
if (listeners.length === 0)
470470
return { content: "No listeners (not coordinator).", isError: false };
@@ -496,9 +496,9 @@ export class CommsTool {
496496
};
497497
}
498498

499-
private async meshGetVisibility(
499+
private meshGetVisibility(
500500
_action: CommsAction & { action: "mesh_get_visibility" },
501-
): Promise<CommsResult> {
501+
): CommsResult {
502502
if (!this.store.getVisibility) {
503503
return {
504504
content: "Visibility control is not available on this store.",
@@ -588,7 +588,7 @@ export class CommsTool {
588588
}
589589
}
590590

591-
private async meshFedLinks(_ctx: CommsContext): Promise<CommsResult> {
591+
private meshFedLinks(_ctx: CommsContext): CommsResult {
592592
const links = this.store.fedLinks();
593593
if (links.length === 0)
594594
return { content: "No federation links.", isError: false };
@@ -621,7 +621,7 @@ export class CommsTool {
621621
}
622622
}
623623

624-
private async meshPending(_ctx: CommsContext): Promise<CommsResult> {
624+
private meshPending(_ctx: CommsContext): CommsResult {
625625
const pending = this.store.listPendingConnections();
626626
if (pending.length === 0)
627627
return { content: "No pending connections.", isError: false };

0 commit comments

Comments
 (0)