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:
- Agent.remote for flexible options
- Agent.remoteByAddress for direct addressing
- Agent.remoteByCapabilities for capability-based discovery
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 Parameter | Default type | Description |
|---|---|---|
TAgent extends Agent | Agent | The type of the remote agent for result typing. |
Indexable
[key: string]: anyIndex 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
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
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
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
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
| Parameter | Type | Description |
|---|---|---|
address | string | FameAddress | The address to serve at (e.g., ‘fame://my-agent’). |
options | AgentServeOptions | Serve 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
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
| Parameter | Type |
|---|---|
_credentials | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } |
_credentials.credentials? | string | null |
_credentials.schemes | string[] |
Returns
boolean
True if authentication succeeds.
Overrides
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
| Parameter | Type | Description |
|---|---|---|
params | { id: string; metadata?: Metadata | null; } | Parameters including the task ID. |
params.id | string | - |
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
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
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
| Parameter | Type | Description |
|---|---|---|
params | { id: string; metadata?: Metadata | null; } | Parameters including the task ID. |
params.id | string | - |
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
| Parameter | Type | Description |
|---|---|---|
params | { historyLength?: number | null; id: string; metadata?: Metadata | null; } | Query parameters including the task ID. |
params.historyLength? | number | null | - |
params.id | string | - |
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
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
| Parameter | Type |
|---|---|
method | string |
params | Record<string, any> |
Returns
Promise<any>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
config | { id: string; pushNotificationConfig: { authentication?: | { [key: string]: unknown; credentials?: string | null; schemes: string[]; } | null; token?: string | null; url: string; }; } | Push notification configuration. |
config.id | string | - |
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.url | string | - |
Returns
Promise<{
id: string;
pushNotificationConfig: {
authentication?: | {
[key: string]: unknown;
credentials?: string | null;
schemes: string[];
}
| null;
token?: string | null;
url: string;
};
}>
The registered configuration.
Overrides
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
payload | Payload | null | The task payload to send. |
id | string | null | null | Optional 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
serve()
serve(address: string | FameAddress, options: AgentServeOptions): Promise<void>;Defined in: src/naylence/agent/agent.ts:612
Alias for Agent.aserve.
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | FameAddress | The address to serve at. |
options | AgentServeOptions | Serve options. |
Returns
Promise<void>
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
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.id | string | - |
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.sessionId | string | - |
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
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
| Parameter | Type |
|---|---|
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.id | string |
options.metadata? | Record<string, unknown> | null |
options.payload | Payload |
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.startTasksubscribeToTaskUpdates()
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
| Parameter | Type | Description |
|---|---|---|
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.id | string | - |
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.sessionId | string | - |
options | StreamOptions | Optional 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
unsubscribeTask()
unsubscribeTask(params: {
id: string;
metadata?: Metadata | null;
}): Promise<unknown>;Defined in: src/naylence/agent/agent-proxy.ts:469
Cancels a task subscription.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { id: string; metadata?: Metadata | null; } | Parameters including the task ID. |
params.id | string | - |
params.metadata? | Metadata | null | - |
Returns
Promise<unknown>
Overrides
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
this | typeof Agent | undefined | - |
addresses | (string | FameAddress)[] | undefined | List of agent addresses. |
payload | Payload | null | Payload to send to all agents. |
options | AgentRunManyOptions | {} | Execution options. |
Returns
Promise<[string, any][]>
Array of [address, result|error] tuples.
Inherited from
fromHandler()
static fromHandler(handler: AgentTaskHandler): Promise<Agent>;Defined in: src/naylence/agent/agent.ts:471
Creates an agent from a simple handler function.
Parameters
| Parameter | Type | Description |
|---|---|---|
handler | AgentTaskHandler | Function 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
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
| Parameter | Type | Description |
|---|---|---|
this | typeof Agent | - |
options | AgentRemoteOptions | Remote 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
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
| Parameter | Type | Description |
|---|---|---|
this | typeof Agent | - |
targets | Targets | Iterable of [address, payload] pairs. |
options | AgentRunManyOptions | Execution options. |
Returns
Promise<[string, any][]>
Array of [address, result|error] tuples.