Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/agent-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ export async function loadAgent(agentPath: string): Promise<FluxAgent> {
const moduleUrl = pathToFileURL(agentPath).href;
const agentModule = await import(moduleUrl);
return agentModule.default as FluxAgent;
}
}
5 changes: 3 additions & 2 deletions src/flux-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class FluxClient {
},
});

this.client = await createGrpcClient(GRPC_SERVER_ADDRESS, clientImpl);
this.client = (await createGrpcClient(GRPC_SERVER_ADDRESS, clientImpl)) as unknown as Awaited<ReturnType<typeof createGrpcClient>>;
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type assertion is redundant and potentially problematic. The expression casts the result of createGrpcClient to Awaited<ReturnType<typeof createGrpcClient>>, which is the same type it already returns. Using as unknown as to cast something to its own type suggests a workaround for a type system issue that should be addressed differently.

Looking at line 9, the client property is already typed as Awaited<ReturnType<typeof createGrpcClient>> | null, and auth.ts uses createGrpcClient without any type assertions (lines 80, 88, 113, 170, 187). The assertion should be removed entirely, allowing TypeScript to infer the correct type naturally.

Suggested change
this.client = (await createGrpcClient(GRPC_SERVER_ADDRESS, clientImpl)) as unknown as Awaited<ReturnType<typeof createGrpcClient>>;
this.client = await createGrpcClient(GRPC_SERVER_ADDRESS, clientImpl);

Copilot uses AI. Check for mistakes.
console.log(`[FLUX] Connected to server at ${GRPC_SERVER_ADDRESS}`);
}

Expand All @@ -49,7 +49,8 @@ export class FluxClient {
if (!this.client) return;

(async () => {
for await (const [message] of this.client!.FluxService.messageStream) {
const stream = this.client!.FluxService.messageStream;
for await (const [message] of stream as AsyncIterable<[IncomingMessage | { ack: string }]>) {
Copy link

Copilot AI Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The destructuring pattern and type assertion here appear unusual. The type assertion declares that the stream yields tuples [IncomingMessage | { ack: string }], but this single-element tuple pattern is unconventional.

Typically, bidirectional gRPC streams would either:

  1. Yield values directly: for await (const message of stream as AsyncIterable<IncomingMessage | { ack: string }>)
  2. Yield multi-element tuples if there's metadata: for await (const [message, metadata] of stream)

Verify that the better-grpc library actually yields single-element tuples, or simplify the destructuring if the tuple wrapper is unnecessary.

Suggested change
for await (const [message] of stream as AsyncIterable<[IncomingMessage | { ack: string }]>) {
for await (const message of stream as AsyncIterable<IncomingMessage | { ack: string }>) {

Copilot uses AI. Check for mistakes.
if ("ack" in message) {
console.log(`[FLUX] Received ack: ${message.ack}`);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@ async function main() {
}
}

main().catch(console.error);
main().catch(console.error);