import { init_providers } from "../../providers/index.js";
import { createExtensionAwareStreamFn } from "../../providers/extension-stream-bridge.js";
//#region src/agent/embedded/xopc-stream-bridge.ts
init_providers();
/**
* pi-coding-agent's default {@link createAgentSession} streamFn always routes through
* pi-ai's HTTP `streamSimple`, so xopc plugin providers (whose models carry the sentinel
* `EXTENSION_PROVIDER_BASE_URL`) never reach their {@link ProviderPluginRegistry}
* implementation. Wrap the original streamFn so plugin models go through xopc's bridge
* and everything else falls through to the original auth-aware streamFn.
*
* Use this by reassigning {@link Agent.streamFn} after `createAgentSession` returns.
*/
function wrapStreamFnForXopcExtensions(originalStreamFn) {
	const extensionStreamFn = createExtensionAwareStreamFn();
	return ((model, context, options) => {
		if (model.baseUrl === "extension://provider-plugin") return extensionStreamFn(model, context, options);
		return originalStreamFn(model, context, options);
	});
}
//#endregion
export { wrapStreamFnForXopcExtensions };

//# sourceMappingURL=xopc-stream-bridge.js.map