mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-09-28 06:22:58 +08:00
fix(federation): sync shim types + guard optional close() to unblock Build V3
Fixes 7 TS errors on main that block Build V3 across all 3 platforms: - src/transport/midstream-aware-loader.ts:39-52 — local AgentMessage/ AgentTransport shim was over-minimized by #2578. Restored required {id, type, payload, metadata?} on AgentMessage and made send/onMessage 2-arg (address, message) to match how plugin.ts actually calls them. - src/transport/midstream-aware-loader.ts:84 — cast dynamic import() through `unknown` since upstream's exported AgentTransport carries a richer InboundMessageHandler surface we intentionally hide behind the minimal shim. - src/plugin.ts:481 — this.transport.close is optional (`?`) on the shim; guard with optional chaining `close?.()`. Local tsc build clean after fix. Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
@@ -478,7 +478,7 @@ export class AgentFederationPlugin implements ClaudeFlowPlugin {
|
||||
}
|
||||
if (this.transport) {
|
||||
try {
|
||||
await this.transport.close();
|
||||
await this.transport.close?.();
|
||||
} catch (err) {
|
||||
this.context?.logger.warn(
|
||||
`Federation transport close error: ${err instanceof Error ? err.message : err}`,
|
||||
|
||||
@@ -36,13 +36,17 @@
|
||||
// with `ERR_MODULE_NOT_FOUND` (issue #2578). agentic-flow remains an
|
||||
// OPTIONAL peer dep, so the loader must compile without touching its
|
||||
// exports map at all.
|
||||
export interface AgentTransport {
|
||||
send?: (msg: AgentMessage) => Promise<void> | void;
|
||||
onMessage?: (handler: (msg: AgentMessage) => void) => void;
|
||||
close?: () => Promise<void> | void;
|
||||
export interface AgentMessage {
|
||||
id: string;
|
||||
type: 'task' | 'result' | 'status' | 'coordination' | 'heartbeat' | string;
|
||||
payload: unknown;
|
||||
metadata?: Record<string, unknown>;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
export interface AgentMessage {
|
||||
export interface AgentTransport {
|
||||
send: (address: string, message: AgentMessage) => Promise<void>;
|
||||
onMessage: (handler: (address: string, message: AgentMessage) => void) => void;
|
||||
close?: () => Promise<void> | void;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
export interface QuicTransportConfig {
|
||||
@@ -77,7 +81,13 @@ async function loadAgenticFlowQuicTransport(
|
||||
};
|
||||
};
|
||||
try {
|
||||
mod = (await import('agentic-flow/transport/loader')) as typeof mod;
|
||||
// Cast through `unknown` because upstream's exported AgentTransport /
|
||||
// AgentMessage carry a richer surface (InboundMessageHandler with an
|
||||
// options bag, extra fields) that intentionally differs from our
|
||||
// locally-declared minimal shim. The shim exists so the plugin can
|
||||
// compile without importing agentic-flow's exports map at all
|
||||
// (#2578). Downstream code (`plugin.ts`) uses our shim types.
|
||||
mod = (await import('agentic-flow/transport/loader')) as unknown as typeof mod;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user