Documentation
¶
Index ¶
- Variables
- func AuthorizeAgentRequest(ctx context.Context, policyClient interfaces.PolicyClient, noAuthz bool, ...) error
- func LoadSessionHistory(ctx context.Context, sessionID types.SessionID, storageSvc *storage.Service) (*gollem.History, error)
- func NewProgressHandlePresenter(h ProgressHandle, taskTitle, userID string) hitlService.Presenter
- func ProgressMessageID(h ProgressHandle) string
- func SaveSessionHistory(ctx context.Context, sessionID types.SessionID, storageSvc *storage.Service, ...) error
- type ChatSink
- type MessageBound
- type Option
- type ProgressHandle
- type RunContext
- type Strategy
- type UseCase
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAgentAuthPolicyNotDefined is returned when agent authorization policy is not defined ErrAgentAuthPolicyNotDefined = errors.New("agent authorization policy not defined") // ErrAgentAuthDenied is returned when agent authorization is denied ErrAgentAuthDenied = errors.New("agent request not authorized") )
var ( // ErrSessionAborted is returned when a session is aborted by user request ErrSessionAborted = goerr.New("session aborted by user") )
Functions ¶
func AuthorizeAgentRequest ¶
func AuthorizeAgentRequest(ctx context.Context, policyClient interfaces.PolicyClient, noAuthz bool, message string) error
AuthorizeAgentRequest checks policy-based authorization for agent execution.
func LoadSessionHistory ¶ added in v0.16.0
func LoadSessionHistory(ctx context.Context, sessionID types.SessionID, storageSvc *storage.Service) (*gollem.History, error)
LoadSessionHistory loads the gollem.History for a Session. Returns (nil, nil) when the Session has no saved history yet so callers can start with an empty gollem session.
chat-session-redesign Phase 4: keyed on SessionID so Slack (long-lived) and Web/CLI (per-invocation) sessions keep independent working memory. The pre-redesign ticket-scoped `LoadHistory` / `SaveHistory` functions were removed together with the `Repository.GetLatestHistory` / `PutHistory` surface they relied on.
func NewProgressHandlePresenter ¶ added in v0.16.0
func NewProgressHandlePresenter(h ProgressHandle, taskTitle, userID string) hitlService.Presenter
NewProgressHandlePresenter returns a hitl.Presenter that renders on the given ProgressHandle.
func ProgressMessageID ¶ added in v0.16.0
func ProgressMessageID(h ProgressHandle) string
ProgressMessageID returns the SessionMessage ID for h when h implements MessageBound, or "" otherwise.
func SaveSessionHistory ¶ added in v0.16.0
func SaveSessionHistory(ctx context.Context, sessionID types.SessionID, storageSvc *storage.Service, history *gollem.History) error
SaveSessionHistory writes history into the Session's rolling storage slot. Errors are logged but not returned so a storage hiccup cannot interrupt the chat response path.
Types ¶
type ChatSink ¶ added in v0.16.0
type ChatSink interface {
// PostComment posts a final-form message (Slack: regular comment,
// Web: session_message type=response). Used by the chat pipeline
// for planner messages, final responses, and warnings-as-comments.
PostComment(ctx context.Context, text string) error
// PostContextBlock posts an ephemeral status line (Slack: context
// block, Web: session_message type=trace). Used for "Investigating",
// reflection completion, etc.
PostContextBlock(ctx context.Context, text string) error
// PostSectionBlock posts a prominent block (Slack: section block,
// Web: session_message type=response). Used for per-task completion
// summaries.
PostSectionBlock(ctx context.Context, text string) error
// PostDivider posts a visual separator (Slack: divider block,
// Web: session_message type=trace with a divider marker).
PostDivider(ctx context.Context) error
// NewUpdatableMessage returns a closure that updates a single
// message in-place. The initial text is posted immediately.
// Used by msg.Trace routing for the Slack updatable trace block
// and by Web for a collapsible progress entry.
NewUpdatableMessage(ctx context.Context, initial string) func(ctx context.Context, text string)
}
ChatSink is the narrow output surface aster/bluebell use to emit non-HITL progress to the user. Implementations route calls to the appropriate transport for the active Session.Source:
- Slack: interfaces.SlackThreadService already satisfies ChatSink via structural typing; no wrapper is needed.
- Web: persists each call as a session.Message and publishes the matching WebSocket Envelope so the Conversation UI receives it.
- CLI: routes through the legacy msg.Notify / msg.Trace handlers already installed on the context, so stdout display is preserved.
The design is deliberately transport-agnostic: Slack-specific block structures never cross this boundary. HITL rendering lives in QuestionTarget / ApprovalTarget below and their transport-specific Presenter implementations, not here.
func ResolveSink ¶ added in v0.16.0
func ResolveSink(chatCtx *chatModel.ChatContext, slackSvc *slackService.Service, repo interfaces.Repository) ChatSink
ResolveSink returns the ChatSink appropriate for the Session bound to chatCtx. Returns nil when no transport can deliver output (e.g. a Slack ticket with no slackService, or a ChatContext with no Session and no Slack thread).
The explicit source-aware selection is the single policy gate that stops Web/CLI Sessions from leaking into Slack: on the Web path we never touch slackSvc even when the ticket happens to carry a SlackThread pointer. That pointer is structural ("this ticket originated from a Slack alert") and MUST NOT be conflated with "this chat should post to Slack".
type MessageBound ¶ added in v0.16.0
type MessageBound interface {
ProgressMessageID() string
}
MessageBound is an optional interface that ProgressHandle impls may satisfy to report the underlying SessionMessage ID backing the display row. Used by the WebSocket handler to bind a HITL prompt to an existing progress message so the UI can render approval UI in place. Slack / CLI impls return "".
type Option ¶ added in v0.15.0
type Option func(*UseCase)
Option configures a UseCase.
func WithFrontendURL ¶ added in v0.15.0
WithFrontendURL sets the frontend URL for session links.
func WithNoAuthorization ¶ added in v0.15.0
WithNoAuthorization disables policy-based authorization checks.
func WithPolicyClient ¶ added in v0.15.0
func WithPolicyClient(pc interfaces.PolicyClient) Option
WithPolicyClient sets the policy client for authorization.
func WithRepository ¶ added in v0.15.0
func WithRepository(repo interfaces.Repository) Option
WithRepository sets the repository.
func WithSlackService ¶ added in v0.15.0
func WithSlackService(svc *slackService.Service) Option
WithSlackService sets the Slack service for message routing.
type ProgressHandle ¶ added in v0.16.0
type ProgressHandle interface {
// UpdateText replaces the display row with plain text.
UpdateText(ctx context.Context, text string)
// PresentHITL renders a HITL request on this handle.
// taskTitle/userID are passed through for transport-specific
// labelling (Slack includes them in block headers).
PresentHITL(ctx context.Context, req *hitl.Request, taskTitle, userID string) error
}
ProgressHandle is a single live-updating display row attached to a task (aster/bluebell setupTaskMessageRouting). It is the unified surface for:
- Progress text updates during task execution.
- In-place HITL prompts (tool approval / question) that replace the progress display with interactive UI, then yield it back to progress once the user has responded.
Transport-specific layouts are chosen inside each implementation: Slack builds []slack.Block via BuildToolApprovalBlocks and calls UpdatableBlockMessage.UpdateBlocks; Web emits a `hitl_request_pending` envelope; CLI blocks execution (default-deny).
func NewProgressHandle ¶ added in v0.16.0
func NewProgressHandle(ctx context.Context, chatCtx *chatModel.ChatContext, slackSvc *slackService.Service, repo interfaces.Repository, initialText string) ProgressHandle
NewProgressHandle constructs a ProgressHandle for a task-specific live-updating display. Returns nil (and a no-op mark function) when no transport is configured for the active Session.
initialText is posted immediately. chatCtx drives both the transport selection and the persistence binding (for Web: the SessionMessage is created under chatCtx.Session).
type RunContext ¶ added in v0.15.0
type RunContext struct {
Session *session.Session
Message string
ChatCtx *chatModel.ChatContext
}
RunContext holds all the pre-initialized resources that UseCase passes to a Strategy after completing common setup.
type Strategy ¶ added in v0.15.0
type Strategy interface {
Execute(ctx context.Context, rc *RunContext) error
}
Strategy defines the interface for chat execution strategies. Implementations receive a RunContext with a pre-initialized Warren session (session created, message routing configured, authorization verified). The strategy is responsible for its own gollem LLM session management and execution workflow (planning, task execution, replanning, etc.).
type UseCase ¶ added in v0.15.0
type UseCase struct {
// contains filtered or unexported fields
}
UseCase implements interfaces.ChatUseCase by performing common setup (Warren session management, message routing, authorization) and delegating strategy-specific execution to a Strategy implementation.
func NewUseCase ¶ added in v0.15.0
NewUseCase creates a new UseCase with the given strategy and options.