b9e5c5d941
Keep streamFn required for typed callers while preserving the legacy runtime fallback for extensions that omit it.\n\nfixes #6915
21 lines
683 B
TypeScript
21 lines
683 B
TypeScript
import type { StreamFn } from "./types.ts";
|
|
|
|
let defaultStreamFn: StreamFn | undefined;
|
|
|
|
/**
|
|
* Configure the fallback used by Agent and low-level loops when callers omit streamFn.
|
|
*
|
|
* Hosts that provide a default model runtime can install its stream function here
|
|
* without making pi-agent-core depend on a provider catalog or compatibility layer.
|
|
*/
|
|
export function setDefaultStreamFn(streamFn: StreamFn | undefined): void {
|
|
defaultStreamFn = streamFn;
|
|
}
|
|
|
|
export function getDefaultStreamFn(): StreamFn {
|
|
if (!defaultStreamFn) {
|
|
throw new Error("No default stream function configured. Pass streamFn explicitly or call setDefaultStreamFn().");
|
|
}
|
|
return defaultStreamFn;
|
|
}
|