ESM
import { createAgentMiddleware, createToolMiddleware } from "@arcgis/ai-components/agent-utils/middlewares/middleware.js";

Functions

createAgentMiddleware

Function
Type parameters
<TCustomState extends AgentData = EmptyAgentData>
Since
ArcGIS Maps SDK for JavaScript 5.1

Creates an agent middleware with the specified hooks and options.

Signature
createAgentMiddleware <TCustomState extends AgentData = EmptyAgentData>(name: string, hooks: AgentMiddlewareHooks<TCustomState>, options?: { outputKey?: keyof AgentGraphState<TCustomState>; }): AgentMiddleware<TCustomState>

Parameters

ParameterTypeDescriptionRequired
name

The name of the middleware.

hooks

The hooks to be used in the middleware.

options
{ outputKey?: keyof AgentGraphState; }

Optional configuration for the middleware, such as the output key.

Returns
AgentMiddleware

The created agent middleware.

createToolMiddleware

Function
Type parameters
<TInput extends AgentData = AgentData, TOutput = unknown>
Since
ArcGIS Maps SDK for JavaScript 5.1

Creates a tool middleware with the specified hooks and options.

Signature
createToolMiddleware <TInput extends AgentData = AgentData, TOutput = unknown>(name: string, hooks: ToolMiddlewareHooks<TInput, TOutput>, options?: { outputKey?: string; }): FunctionToolMiddleware<TInput, TOutput>

Parameters

ParameterTypeDescriptionRequired
name

The name of the middleware.

hooks
ToolMiddlewareHooks<TInput, TOutput>

The hooks to be used in the middleware.

options
{ outputKey?: string; }

Optional configuration for the middleware, such as the output key.

Returns
FunctionToolMiddleware<TInput, TOutput>

The created function tool middleware.