diff --git a/packages/appkit/src/plugin/plugin.ts b/packages/appkit/src/plugin/plugin.ts index fbe5fcb1a..7dbd7a99c 100644 --- a/packages/appkit/src/plugin/plugin.ts +++ b/packages/appkit/src/plugin/plugin.ts @@ -251,7 +251,7 @@ export abstract class Plugin< config.name ?? (this.constructor as { manifest?: { name: string } }).manifest?.name ?? "plugin"; - this.streamManager = new StreamManager(); + this.streamManager = new StreamManager(config.streamConfig); this.app = new AppManager(); this.devFileReader = DevFileReader.getInstance(); this.context = (config as Record).context as diff --git a/packages/appkit/src/plugin/tests/plugin.test.ts b/packages/appkit/src/plugin/tests/plugin.test.ts index 12108f7c4..d42da93ad 100644 --- a/packages/appkit/src/plugin/tests/plugin.test.ts +++ b/packages/appkit/src/plugin/tests/plugin.test.ts @@ -261,6 +261,19 @@ describe("Plugin", () => { expect(AppManager).toHaveBeenCalledTimes(1); expect(StreamManager).toHaveBeenCalledTimes(1); }); + + test("should forward streamConfig to the StreamManager", () => { + const streamConfig = { maxEventSize: 20 * 1024 * 1024 }; + new TestPlugin({ ...config, streamConfig }); + + expect(StreamManager).toHaveBeenCalledWith(streamConfig); + }); + + test("should construct the StreamManager with defaults when no streamConfig", () => { + new TestPlugin(config); + + expect(StreamManager).toHaveBeenCalledWith(undefined); + }); }); describe("setup", () => { diff --git a/packages/shared/src/plugin.ts b/packages/shared/src/plugin.ts index 15148895e..0296e46c9 100644 --- a/packages/shared/src/plugin.ts +++ b/packages/shared/src/plugin.ts @@ -1,6 +1,7 @@ import type express from "express"; import type { JSONSchema7 } from "json-schema"; +import type { StreamConfig } from "./execute"; import type { DiscoveryDescriptor, PluginManifest as GeneratedPluginManifest, @@ -72,6 +73,14 @@ export interface BasePluginConfig { * @default true for all telemetry types */ telemetry?: TelemetryOptions; + + /** + * SSE stream configuration for this plugin's `executeStream()` calls (buffer + * sizes, `maxEventSize`, TTL, heartbeat). Sets the plugin's StreamManager + * defaults; a per-call `stream` config still overrides these. Use it to raise + * `maxEventSize` above the 5 MiB default when a stream emits larger events. + */ + streamConfig?: StreamConfig; } export type TelemetryOptions =