@threadplane/ag-uiFunctionv0.3.4

toAgent

Wraps an AG-UI AbstractAgent into the runtime-neutral Agent contract.

The adapter subscribes to source.subscribe({ onEvent }) and reduces every event into the produced Agent's signals. submit() optimistically appends the user message to both our signals and the source agent's internal message list, then calls source.runAgent(). stop() calls source.abortRun().

Subscription cleanup: providers dispose the adapter with their injector. Direct callers must call dispose() when they no longer need the adapter.

import { toAgent } from '@threadplane/ag-ui';

Declaration · overload 1

export declare function toAgent(source: AbstractAgent, options?: ToAgentOptions): AgUiAgent;

Parameters

source · required
AbstractAgent
options · optional
ToAgentOptions

Returns

AgUiAgent

Examples

import { HttpAgent } from '@ag-ui/client';
import { toAgent } from '@threadplane/ag-ui';

const agent = toAgent(new HttpAgent({ url: '/api/agent' }));