Class References
Function References
- text
- textOptions
- combineStrategies
- convertMessagesToModelMessages
- convertZodToJsonSchema
- createReplayStream
- embedding
- generateMessageId
- maxIterations
- messages
- modelMessageToUIMessage
- modelMessagesToUIMessages
- normalizeToUIMessage
- parsePartialJSON
- summarize
- toServerSentEventsStream
- toServerSentEventsResponse
- toolDefinition
- uiMessageToModelMessages
- realtimeToken
- untilFinishReason
Interface References
- AIAdapter
- AIAdapterConfig
- AgentLoopState
- AudioPart
- AudioVisualization
- BaseStreamChunk
- TextCompletionChunk
- TextOptions
- ChunkRecording
- ChunkStrategy
- ClientTool
- ContentPartSource
- ContentStreamChunk
- DefaultMessageMetadataByModality
- DocumentPart
- DoneStreamChunk
- EmbeddingOptions
- EmbeddingResult
- ErrorStreamChunk
- ImagePart
- InternalToolCallState
- JSONParser
- ModelMessage
- ProcessorResult
- ProcessorState
- RealtimeAdapter
- RealtimeClientOptions
- RealtimeConnection
- RealtimeMessage
- RealtimeSessionConfig
- RealtimeToken
- RealtimeTokenAdapter
- RealtimeTokenOptions
- ResponseFormat
- ServerTool
- StreamProcessorEvents
- StreamProcessorHandlers
- StreamProcessorOptions
- SummarizationOptions
- SummarizationResult
- TextPart
- ThinkingPart
- ThinkingStreamChunk
- Tool
- ToolCall
- ToolCallPart
- ToolCallStreamChunk
- ToolConfig
- ToolDefinition
- ToolDefinitionConfig
- ToolDefinitionInstance
- ToolInputAvailableStreamChunk
- ToolResultPart
- ToolResultStreamChunk
- UIMessage
- VideoPart
Type Alias References
- AgentLoopStrategy
- AnyClientTool
- TextStreamOptionsForModel
- TextStreamOptionsUnion
- ConstrainedContent
- ConstrainedModelMessage
- ContentPart
- ContentPartForModalities
- ExtractModalitiesForModel
- ExtractModelsFromAdapter
- InferToolInput
- InferToolName
- InferToolOutput
- MessagePart
- RealtimeEvent
- RealtimeMessagePart
- RealtimeMode
- RealtimeStatus
- ModalitiesArrayToUnion
- Modality
- StreamChunk
- ToolCallState
- ToolResultState
Variable References
createCapability
function createCapability<TValue>(): <TName>(name) => Capability<TValue, TName>;Defined in: packages/ai/src/activities/chat/middleware/capabilities.ts:114
Create a capability. Returns a hybrid handle that destructures to [get, provide] and is itself the identity for requires/provides.
Curried so the value type is supplied explicitly while the name literal is INFERRED from the argument: createCapability<T>()('name'). (A single call createCapability<T>('name') cannot work — supplying T explicitly stops TypeScript inferring the name, collapsing it to string and defeating the compile-time coverage check that keys on the literal name.)
Type Parameters#
TValue#
TValue = unknown
Returns#
<TName>(name) => Capability<TValue, TName>
Example#
Provider + consumer middleware
const counterCapability = createCapability<{ value: number }>()('counter')
const [getCounter, provideCounter] = counterCapability
const withCounter = defineChatMiddleware({
name: 'counter',
provides: [counterCapability],
setup(ctx) { provideCounter(ctx, { value: 0 }) },
})
const readsCounter = defineChatMiddleware({
name: 'reads-counter',
requires: [counterCapability],
onChunk(ctx) { getCounter(ctx).value++ },
})
chat({ adapter, messages, middleware: [withCounter, readsCounter] })Remarks#
Capability names must be unique across your app: compile-time coverage tracking keys on the name literal (runtime keys on reference).