Skip to content

@ChannelRole

The @ChannelRole decorator ("@agboss/core") defines a transport-independent human-in-the-loop pause contract. Tools (@Tool({ channel: RefundApprovalChannel })) reference the abstract @ChannelRole class, while @Application({ providers }) binds the concrete @Channel implementation (such as Slack, webhook, or AutoApproveChannel in tests) by class inheritance.

Every @ChannelRole class extends ChannelOf<Self>, has a name ending with -channel, requires answeredBy (PauseAnswerer.Channel or PauseAnswerer.ThreadOwner), and uses one of two forms — tool approval (approves) or custom question/answer (ask + answer):

Option Type Required Description
name string Yes Unique kebab-case identifier ending with -channel ("refund-approval-channel").
description string Yes Explains what human decision this pause role requests.
answeredBy PauseAnswerer.Channel | PauseAnswerer.ThreadOwner Yes Who may call app.resume(): the external channel (PauseAnswerer.Channel, requiring { answeredBy }) or the thread’s owner (PauseAnswerer.ThreadOwner, checked against ownerId).
approves DtoClass Form 1* Input DTO class of the @Tools this role approves ([channel.wrong-tool] if a tool with another input DTO names this role). *Mutually exclusive with ask/answer.
ask & answer DtoClass Form 2* Custom question and answer DTO classes (*mutually exclusive with approves).
replyInterpreter Class No Optional @ReplyInterpreter class that turns free-text app.resume({ pauseId, reply }) messages into the role’s typed decision.
Section titled “What related entities work with @ChannelRole?”
Related Entity Import Path Purpose
@Channel & ChannelOf<Role> "@agboss/core" Concrete transport implementation bound in @Application({ providers }) by extending the @ChannelRole class.
@ReplyInterpreter "@agboss/core" Parses free-text human replies (app.resume({ pauseId, reply })) into the role’s typed decision.
AutoApproveChannel & AutoRejectChannel "@agboss/core" Built-in test channels for automated approval or rejection.
ToolCallApprovalAskDto & ToolCallApprovalDecisionDto "@agboss/core/dto" Standard DTOs used by @ChannelRole({ approves }).