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

naylence-agent-sdk-ts


naylence-agent-sdk-ts / Agent

Abstract Class: Agent

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

Abstract base class for all agents.

Agents are addressable services that handle tasks over the Fame fabric. This class defines the core protocol methods every agent must implement.

Remarks

Do not extend Agent directly. Instead:

Use Agent.remote or Agent.remoteByAddress to create proxies for communicating with remote agents.

Example

import { BaseAgent, Payload } from '@naylence/agent-sdk'; class EchoAgent extends BaseAgent { async runTask(payload: Payload): Promise<Payload> { return payload; } } const agent = new EchoAgent('echo'); await agent.serve('fame://echo');

Extends

  • RpcMixin

Extended by

Implements

  • FameService

Constructors

Constructor

new Agent(): Agent;

Returns

Agent

Inherited from

RpcMixin.constructor

Accessors

capabilities

Get Signature

get capabilities(): string[] | undefined;

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

Capabilities advertised by this agent for discovery.

Returns

string[] | undefined

Implementation of

FameService.capabilities

name

Get Signature

get abstract name(): string | null;

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

The agent’s name, used for logging and identification.

Returns

string | null


spec

Get Signature

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

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

Returns metadata about this agent (address, capabilities, etc.).

Returns

Record<string, unknown>


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

RpcMixin.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.


authenticate()

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

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

Validates authentication credentials.

Parameters

ParameterTypeDescription
credentials{ [key: string]: unknown; credentials?: string | null; schemes: string[]; }The credentials to validate.
credentials.credentials?string | null-
credentials.schemesstring[]-

Returns

boolean

True if authentication succeeds.


cancelTask()

abstract 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.ts:353

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.


getAgentCard()

abstract 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.ts:318

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; }>


getPushNotificationConfig()

abstract 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.ts:382

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; }; }>


getTaskStatus()

abstract 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.ts:346

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; }; }>


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

RpcMixin.handleRpcRequest

registerPushEndpoint()

abstract 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.ts:374

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; }; }>


runTask()

abstract runTask(payload: Payload, id: string | null): Promise<any>;

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

Executes a task synchronously and returns the result.

Parameters

ParameterTypeDescription
payloadPayloadThe task payload.
idstring | nullOptional task identifier.

Returns

Promise<any>

The task result.


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>


startTask()

abstract 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.ts:332

Initiates a new task.

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 including message and optional metadata.
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 its initial status.


subscribeToTaskUpdates()

abstract 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; }): 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.ts:360

Subscribes to real-time updates for a task.

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-

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; }>

An async iterable of status and artifact update events.


unsubscribeTask()

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

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

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<any>


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.


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.


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.


remoteByAddress()

static remoteByAddress<TAgent>( this: typeof Agent, address: string | FameAddress, options: { fabric?: FameFabric; }): AgentProxy<TAgent>;

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

Creates a proxy for a remote agent by its address.

Type Parameters

Type Parameter
TAgent extends Agent

Parameters

ParameterTypeDescription
thistypeof Agent-
addressstring | FameAddressThe target agent’s address.
options{ fabric?: FameFabric; }Optional fabric configuration.
options.fabric?FameFabric-

Returns

AgentProxy<TAgent>

A proxy for the remote agent.


remoteByCapabilities()

static remoteByCapabilities<TAgent>( this: typeof Agent, capabilities: string[], options: { fabric?: FameFabric; }): AgentProxy<TAgent>;

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

Creates a proxy for a remote agent by required capabilities.

Type Parameters

Type Parameter
TAgent extends Agent

Parameters

ParameterTypeDescription
thistypeof Agent-
capabilitiesstring[]Required capabilities for discovery.
options{ fabric?: FameFabric; }Optional fabric configuration.
options.fabric?FameFabric-

Returns

AgentProxy<TAgent>

A proxy for a matching remote agent.


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.

Last updated on