Skip to Content
Naylence Docs are in active development. Share feedback in Discord.

naylence-agent-sdk-ts


naylence-agent-sdk-ts / AgentProxy

Class: AgentProxy<TAgent>

Defined in: src/naylence/agent/agent-proxy.ts:174

Client-side proxy for communicating with remote agents.

AgentProxy implements the Agent interface, allowing you to call remote agents as if they were local objects. Method calls are serialized and sent over the Fame fabric.

Remarks

Do not instantiate AgentProxy directly. Use the factory methods on Agent to create proxies:

The proxy also supports arbitrary RPC method calls. Any method not defined on the proxy class is forwarded as an RPC call to the remote agent.

Example

import { Agent } from '@naylence/agent-sdk'; // Create a proxy to a remote agent const proxy = Agent.remoteByAddress('fame://calculator'); // Run a task synchronously const result = await proxy.runTask({ a: 1, b: 2 }); // Or start a task and poll for completion const task = await proxy.startTask({ id: 'task-1', message: { role: 'user', parts: [{ type: 'text', text: 'compute' }] }, });

Extends

Type Parameters

Type ParameterDefault typeDescription
TAgent extends AgentAgentThe type of the remote agent for result typing.

Indexable

[key: string]: any

Index signature allowing arbitrary RPC method calls. Methods not defined on AgentProxy are forwarded to the remote agent.

Accessors

address

Get Signature

get address(): FameAddress | null;

Defined in: src/naylence/agent/agent-proxy.ts:243

The target agent’s address, if specified.

Returns

FameAddress | null


addressRef

Get Signature

get addressRef(): FameAddress | null;

Defined in: src/naylence/agent/agent-proxy.ts:238

The target agent’s address, if specified.

Deprecated

Use AgentProxy.address instead.

Returns

FameAddress | null


capabilities

Get Signature

get capabilities(): string[] | undefined;

Defined in: src/naylence/agent/agent-proxy.ts:248

The required capabilities for discovery, if specified.

Returns

string[] | undefined

Overrides

Agent.capabilities


name

Get Signature

get name(): string | null;

Defined in: src/naylence/agent/agent-proxy.ts:213

Returns null as proxies do not have a local name.

Returns

string | null

Overrides

Agent.name


proxyFabric

Get Signature

get proxyFabric(): FameFabric;

Defined in: src/naylence/agent/agent-proxy.ts:253

The fabric this proxy uses for communication.

Returns

FameFabric


spec

Get Signature

get spec(): Record<string, unknown>;

Defined in: src/naylence/agent/agent-proxy.ts:218

Returns the proxy’s targeting specification.

Returns

Record<string, unknown>

Overrides

Agent.spec


rpcRegistry

Get Signature

get static rpcRegistry(): ReadonlyMap<string, RpcRegistryEntry>;

Defined in: node_modules/@naylence/runtime/dist/types/naylence/fame/service/rpc.d.ts:14

Returns

ReadonlyMap<string, RpcRegistryEntry>

Inherited from

Agent.rpcRegistry

Methods

aserve()

aserve(address: string | FameAddress, options: AgentServeOptions): Promise<void>;

Defined in: src/naylence/agent/agent.ts:573

Starts serving this agent at the given address.

Parameters

ParameterTypeDescription
addressstring | FameAddressThe address to serve at (e.g., ‘fame://my-agent’).
optionsAgentServeOptionsServe options including log level and fabric config.

Returns

Promise<void>

Remarks

In Node.js, the agent listens for SIGINT/SIGTERM to shut down gracefully. The method returns when the agent stops serving.

Inherited from

Agent.aserve


authenticate()

authenticate(_credentials: { [key: string]: unknown; credentials?: string | null; schemes: string[]; }): boolean;

Defined in: src/naylence/agent/agent-proxy.ts:261

Validates authentication credentials.

Parameters

ParameterType
_credentials{ [key: string]: unknown; credentials?: string | null; schemes: string[]; }
_credentials.credentials?string | null
_credentials.schemesstring[]

Returns

boolean

True if authentication succeeds.

Overrides

Agent.authenticate


cancelTask()

cancelTask(params: { id: string; metadata?: Metadata | null; }): Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>;

Defined in: src/naylence/agent/agent-proxy.ts:427

Requests cancellation of a running task.

Parameters

ParameterTypeDescription
params{ id: string; metadata?: Metadata | null; }Parameters including the task ID.
params.idstring-
params.metadata?Metadata | null-

Returns

Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>

The task with updated status.

Overrides

Agent.cancelTask


getAgentCard()

getAgentCard(): Promise<{ authentication?: | { credentials?: string | null; schemes: string[]; } | null; capabilities: { pushNotifications: boolean; stateTransitionHistory: boolean; streaming: boolean; }; defaultInputModes: string[]; defaultOutputModes: string[]; description?: string | null; documentationUrl?: string | null; name: string; provider?: | { organization: string; url?: string | null; } | null; skills: { description?: string | null; examples?: string[] | null; id: string; inputModes?: string[] | null; name: string; outputModes?: string[] | null; tags?: string[] | null; }[]; url: string; version: string; }>;

Defined in: src/naylence/agent/agent-proxy.ts:257

Returns the agent’s card describing its capabilities and metadata.

Returns

Promise<{ authentication?: | { credentials?: string | null; schemes: string[]; } | null; capabilities: { pushNotifications: boolean; stateTransitionHistory: boolean; streaming: boolean; }; defaultInputModes: string[]; defaultOutputModes: string[]; description?: string | null; documentationUrl?: string | null; name: string; provider?: | { organization: string; url?: string | null; } | null; skills: { description?: string | null; examples?: string[] | null; id: string; inputModes?: string[] | null; name: string; outputModes?: string[] | null; tags?: string[] | null; }[]; url: string; version: string; }>

Overrides

Agent.getAgentCard


getPushNotificationConfig()

getPushNotificationConfig(params: { id: string; metadata?: Metadata | null; }): Promise<{ id: string; pushNotificationConfig: { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }; }>;

Defined in: src/naylence/agent/agent-proxy.ts:494

Retrieves the push notification config for a task.

Parameters

ParameterTypeDescription
params{ id: string; metadata?: Metadata | null; }Parameters including the task ID.
params.idstring-
params.metadata?Metadata | null-

Returns

Promise<{ id: string; pushNotificationConfig: { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }; }>

The push notification configuration.

Overrides

Agent.getPushNotificationConfig


getTaskStatus()

getTaskStatus(params: { historyLength?: number | null; id: string; metadata?: Metadata | null; }): Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>;

Defined in: src/naylence/agent/agent-proxy.ts:415

Retrieves the current status of a task.

Parameters

ParameterTypeDescription
params{ historyLength?: number | null; id: string; metadata?: Metadata | null; }Query parameters including the task ID.
params.historyLength?number | null-
params.idstring-
params.metadata?Metadata | null-

Returns

Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>

The task with current status.

Overrides

Agent.getTaskStatus


handleRpcRequest()

handleRpcRequest(method: string, params: Record<string, any>): Promise<any>;

Defined in: node_modules/@naylence/runtime/dist/types/naylence/fame/service/rpc.d.ts:16

Parameters

ParameterType
methodstring
paramsRecord<string, any>

Returns

Promise<any>

Inherited from

Agent.handleRpcRequest


registerPushEndpoint()

registerPushEndpoint(config: { id: string; pushNotificationConfig: { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }; }): Promise<{ id: string; pushNotificationConfig: { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }; }>;

Defined in: src/naylence/agent/agent-proxy.ts:480

Registers a push notification endpoint for task updates.

Parameters

ParameterTypeDescription
config{ id: string; pushNotificationConfig: { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }; }Push notification configuration.
config.idstring-
config.pushNotificationConfig{ authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }-
config.pushNotificationConfig.authentication?| { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null-
config.pushNotificationConfig.token?string | null-
config.pushNotificationConfig.urlstring-

Returns

Promise<{ id: string; pushNotificationConfig: { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }; }>

The registered configuration.

Overrides

Agent.registerPushEndpoint


runTask()

runTask(payload: Payload, id: string | null): Promise<Awaited<ReturnType<TAgent["runTask"]>>>;

Defined in: src/naylence/agent/agent-proxy.ts:284

Executes a task on the remote agent and waits for completion.

Starts the task, subscribes to updates, and returns when the task reaches a terminal state (completed, failed, or canceled).

Parameters

ParameterTypeDefault valueDescription
payloadPayloadnullThe task payload to send.
idstring | nullnullOptional task identifier. Generated if not provided.

Returns

Promise<Awaited<ReturnType<TAgent["runTask"]>>>

The task result extracted from the final status message.

Throws

Error if the task fails.

Example

const proxy = Agent.remoteByAddress('fame://echo'); const result = await proxy.runTask('hello'); console.log(result); // 'hello'

Overrides

Agent.runTask


serve()

serve(address: string | FameAddress, options: AgentServeOptions): Promise<void>;

Defined in: src/naylence/agent/agent.ts:612

Alias for Agent.aserve.

Parameters

ParameterTypeDescription
addressstring | FameAddressThe address to serve at.
optionsAgentServeOptionsServe options.

Returns

Promise<void>

Inherited from

Agent.serve


startTask()

Call Signature

startTask(params: { acceptedOutputModes?: string[] | null; historyLength?: number | null; id: string; message: { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }; metadata?: Metadata | null; pushNotification?: | { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null; sessionId: string; }): Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>;

Defined in: src/naylence/agent/agent-proxy.ts:359

Initiates a task on the remote agent.

Returns immediately with the initial task status. Use AgentProxy.subscribeToTaskUpdates or polling with AgentProxy.getTaskStatus to track progress.

Parameters
ParameterTypeDescription
params{ acceptedOutputModes?: string[] | null; historyLength?: number | null; id: string; message: { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }; metadata?: Metadata | null; pushNotification?: | { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null; sessionId: string; }Task parameters or convenience options.
params.acceptedOutputModes?string[] | null-
params.historyLength?number | null-
params.idstring-
params.message{ metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }-
params.message.metadata?Metadata | null-
params.message.parts( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]-
params.message.role"user" | "agent"-
params.metadata?Metadata | null-
params.pushNotification?| { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null-
params.sessionIdstring-
Returns

Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>

The created task with initial status.

Overrides

Agent.startTask

Call Signature

startTask(options: { acceptedOutputModes?: string[] | null; historyLength?: number | null; id: string; metadata?: Record<string, unknown> | null; payload: Payload; pushNotification?: | { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null; role?: "user" | "agent"; sessionId?: string | null; }): Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>;

Defined in: src/naylence/agent/agent-proxy.ts:360

Initiates a task on the remote agent.

Returns immediately with the initial task status. Use AgentProxy.subscribeToTaskUpdates or polling with AgentProxy.getTaskStatus to track progress.

Parameters
ParameterType
options{ acceptedOutputModes?: string[] | null; historyLength?: number | null; id: string; metadata?: Record<string, unknown> | null; payload: Payload; pushNotification?: | { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null; role?: "user" | "agent"; sessionId?: string | null; }
options.acceptedOutputModes?string[] | null
options.historyLength?number | null
options.idstring
options.metadata?Record<string, unknown> | null
options.payloadPayload
options.pushNotification?| { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null
options.role?"user" | "agent"
options.sessionId?string | null
Returns

Promise<{ artifacts?: | { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }[] | null; history?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }[] | null; id: string; metadata?: Metadata | null; sessionId?: string | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; }>

The created task with initial status.

Overrides
Agent.startTask

subscribeToTaskUpdates()

subscribeToTaskUpdates(params: { acceptedOutputModes?: string[] | null; historyLength?: number | null; id: string; message: { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }; metadata?: Metadata | null; pushNotification?: | { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null; sessionId: string; }, options: StreamOptions): AsyncIterable< | { final: boolean; id: string; metadata?: Metadata | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: ... | ... | ...; mimeType?: ... | ... | ...; name?: ... | ... | ...; uri?: ... | ... | ...; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; } | { artifact: { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }; id: string; metadata?: Metadata | null; }>;

Defined in: src/naylence/agent/agent-proxy.ts:443

Subscribes to real-time updates for a task.

Returns an async iterable that yields status and artifact events until the task reaches a terminal state or the stream is closed.

Parameters

ParameterTypeDescription
params{ acceptedOutputModes?: string[] | null; historyLength?: number | null; id: string; message: { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }; metadata?: Metadata | null; pushNotification?: | { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null; sessionId: string; }Task parameters.
params.acceptedOutputModes?string[] | null-
params.historyLength?number | null-
params.idstring-
params.message{ metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; }-
params.message.metadata?Metadata | null-
params.message.parts( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]-
params.message.role"user" | "agent"-
params.metadata?Metadata | null-
params.pushNotification?| { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; } | null-
params.sessionIdstring-
optionsStreamOptionsOptional timeout and item limit settings.

Returns

AsyncIterable< | { final: boolean; id: string; metadata?: Metadata | null; status: { message?: | { metadata?: Metadata | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: … | … | …; mimeType?: … | … | …; name?: … | … | …; uri?: … | … | …; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; role: "user" | "agent"; } | null; state: TaskState; timestamp: Date; }; } | { artifact: { append?: boolean | null; description?: string | null; index: number; lastChunk?: boolean | null; metadata?: Metadata | null; name?: string | null; parts: ( | { metadata?: Metadata | null; text: string; type: "text"; } | { file: { bytes?: string | null; mimeType?: string | null; name?: string | null; uri?: string | null; }; metadata?: Metadata | null; type: "file"; } | { data: Metadata; metadata?: Metadata | null; type: "data"; })[]; }; id: string; metadata?: Metadata | null; }>

Async iterable of task events.

Overrides

Agent.subscribeToTaskUpdates


unsubscribeTask()

unsubscribeTask(params: { id: string; metadata?: Metadata | null; }): Promise<unknown>;

Defined in: src/naylence/agent/agent-proxy.ts:469

Cancels a task subscription.

Parameters

ParameterTypeDescription
params{ id: string; metadata?: Metadata | null; }Parameters including the task ID.
params.idstring-
params.metadata?Metadata | null-

Returns

Promise<unknown>

Overrides

Agent.unsubscribeTask


broadcast()

static broadcast( this: typeof Agent, addresses: (string | FameAddress)[], payload: Payload, options: AgentRunManyOptions): Promise<[string, any][]>;

Defined in: src/naylence/agent/agent.ts:499

Sends the same payload to multiple agents.

Parameters

ParameterTypeDefault valueDescription
thistypeof Agentundefined-
addresses(string | FameAddress)[]undefinedList of agent addresses.
payloadPayloadnullPayload to send to all agents.
optionsAgentRunManyOptions{}Execution options.

Returns

Promise<[string, any][]>

Array of [address, result|error] tuples.

Inherited from

Agent.broadcast


fromHandler()

static fromHandler(handler: AgentTaskHandler): Promise<Agent>;

Defined in: src/naylence/agent/agent.ts:471

Creates an agent from a simple handler function.

Parameters

ParameterTypeDescription
handlerAgentTaskHandlerFunction that processes task payloads.

Returns

Promise<Agent>

A new agent instance wrapping the handler.

Remarks

Useful for quick prototyping without defining a full agent class.

Inherited from

Agent.fromHandler


remote()

static remote<TAgent>(this: typeof Agent, options: AgentRemoteOptions): AgentProxy<TAgent>;

Defined in: src/naylence/agent/agent.ts:400

Creates a proxy for communicating with a remote agent.

Type Parameters

Type Parameter
TAgent extends Agent

Parameters

ParameterTypeDescription
thistypeof Agent-
optionsAgentRemoteOptionsRemote agent options.

Returns

AgentProxy<TAgent>

A proxy for the remote agent.

Remarks

Provide exactly one of address or capabilities in the options.

Example

const proxy = Agent.remote<EchoAgent>({ address: 'fame://echo' }); const result = await proxy.runTask('hello');

Throws

Error if both or neither of address/capabilities are provided.

Inherited from

Agent.remote


runMany()

static runMany<TAgent>( this: typeof Agent, targets: Targets, options: AgentRunManyOptions): Promise<[string, any][]>;

Defined in: src/naylence/agent/agent.ts:518

Runs tasks on multiple agents with individual payloads.

Type Parameters

Type Parameter
TAgent extends Agent

Parameters

ParameterTypeDescription
thistypeof Agent-
targetsTargetsIterable of [address, payload] pairs.
optionsAgentRunManyOptionsExecution options.

Returns

Promise<[string, any][]>

Array of [address, result|error] tuples.

Inherited from

Agent.runMany

Last updated on