@ai-agent-forge/plugin-sdk 0.86.4 → 0.86.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1755,6 +1755,40 @@ export interface ProviderHeaderTransformRequest {
1755
1755
  * result.
1756
1756
  */
1757
1757
  export type ProviderHeaderTransform = (request: ProviderHeaderTransformRequest) => Record<string, string | null> | Promise<Record<string, string | null>>;
1758
+ /**
1759
+ * Host closure capabilities handed to every {@link StreamFnWrapper} call.
1760
+ * `model`/`context`/`options` stay untyped on this face because the SDK keeps
1761
+ * no dependency on the provider message model; the host and embedded plugins
1762
+ * cast at their boundary.
1763
+ */
1764
+ export interface StreamFnWrapperHostV1 {
1765
+ /**
1766
+ * Resolve one complete model object (provider catalog entry: compat,
1767
+ * sampling params, baseUrl) from the host's merged model catalog.
1768
+ * `undefined` when the host does not know the provider/model pair —
1769
+ * callers must treat that as "no failover candidate".
1770
+ */
1771
+ resolveModel(provider: string, modelId: string): unknown | undefined;
1772
+ }
1773
+ /**
1774
+ * The remainder of the stream-function chain ending at the host's default
1775
+ * stream call. A wrapper calls it with the request it wants issued (same
1776
+ * context, possibly a substituted model and sanitized options) and consumes
1777
+ * the returned event stream.
1778
+ */
1779
+ export type StreamFnNext = (model: unknown, context: unknown, options: unknown) => unknown;
1780
+ /**
1781
+ * Experimental request-time stream-function middleware (provider-failover
1782
+ * family): observe the provider stream's terminal state, substitute the
1783
+ * request model, and replay. Wrappers run in registration order — the first
1784
+ * registered wrapper is the outermost, its `next` covering every later
1785
+ * wrapper plus the host default. Must return (a promise of) the event stream
1786
+ * the caller consumes; failures belong inside the stream protocol, matching
1787
+ * the host stream-function contract. A session whose caller supplied an
1788
+ * explicit stream function bypasses the host default assembly entirely and
1789
+ * never sees these wrappers.
1790
+ */
1791
+ export type StreamFnWrapper = (model: unknown, context: unknown, options: unknown, next: StreamFnNext, host: StreamFnWrapperHostV1) => unknown;
1758
1792
  /**
1759
1793
  * Hook positions on the default agent loop. Links run in registration order
1760
1794
  * after the host's legacy chain head.
@@ -1937,6 +1971,7 @@ export interface CapabilityAPI {
1937
1971
  */
1938
1972
  registerEntryProjection(projection: EntryProjection): DisposableRegistration;
1939
1973
  registerProviderHeaderTransform(name: string, transform: ProviderHeaderTransform): DisposableRegistration;
1974
+ registerStreamFnWrapper(name: string, wrapper: StreamFnWrapper): DisposableRegistration;
1940
1975
  registerSkill(definition: SkillDefinition): DisposableRegistration;
1941
1976
  registerRetryPolicy(name: string, policy: RetryPolicy): DisposableRegistration;
1942
1977
  registerCompactionPolicy(name: string, policy: CompactionPolicy): DisposableRegistration;