Documentation
¶
Overview ¶
Package decision holds app-layer decision DTOs and shared waiting primitives. Storage is intentionally still owned by the kind-specific services: toolapproval uses tool_approval_requests, and userinput uses user_input_requests.
Index ¶
- Constants
- func InCreateTransaction(ctx context.Context, queries dbstore.Queries, botID, sessionID string, ...) error
- func ResumeNativeContinuation(ctx context.Context, queries dbstore.Queries, ...) error
- func WithNativeContinuation(ctx context.Context) context.Context
- func WithResponseIdentity(ctx context.Context, identity ResponseIdentity) context.Context
- type ContinuationCheckpoint
- type Request
- type ResponseIdentity
- type Waiter
Constants ¶
const ( KindApproval = "approval" KindUserInput = "user_input" )
const DefaultFallbackInterval = 500 * time.Millisecond
Variables ¶
This section is empty.
Functions ¶
func InCreateTransaction ¶
func InCreateTransaction(ctx context.Context, queries dbstore.Queries, botID, sessionID string, create func(dbstore.Queries) error) error
InCreateTransaction serializes per-session decision short IDs before the INSERT statement takes its MVCC snapshot. Non-transactional test stores retain their own local serialization.
func ResumeNativeContinuation ¶ added in v0.21.0
func ResumeNativeContinuation(ctx context.Context, queries dbstore.Queries, botID, sessionID, runID, decisionID pgtype.UUID, token pgtype.Int8, kind string) error
ResumeNativeContinuation must run inside the decision response's fenced transaction: either both the answer and running checkpoint commit, or neither.
func WithNativeContinuation ¶ added in v0.21.0
WithNativeContinuation is set by the application after runtime classification. Inline waiters must keep their original waiting/last-answer semantics.
func WithResponseIdentity ¶
func WithResponseIdentity(ctx context.Context, identity ResponseIdentity) context.Context
Types ¶
type ContinuationCheckpoint ¶ added in v0.21.0
ContinuationCheckpoint records accepted native decisions. A tool marked executing may have produced effects even if its result never reached history. Recovery reconstructs context from the decision row; it never replays a tool.
type Request ¶
type Request struct {
ID string `json:"id"`
BotID string `json:"bot_id"`
SessionID string `json:"session_id"`
RouteID string `json:"route_id,omitempty"`
ChannelIdentityID string `json:"channel_identity_id,omitempty"`
WorkspaceTargetID string `json:"workspace_target_id,omitempty"`
Kind string `json:"kind"`
ToolCallID string `json:"tool_call_id"`
ToolName string `json:"tool_name"`
ToolInput map[string]any `json:"tool_input,omitempty"`
UIPayloadRaw []byte `json:"-"`
Result map[string]any `json:"result,omitempty"`
ProviderMetadata map[string]any `json:"-"`
ShortID int `json:"short_id"`
Status string `json:"status"`
DecisionReason string `json:"decision_reason,omitempty"`
PromptExternalMessageID string `json:"prompt_external_message_id,omitempty"`
SourcePlatform string `json:"source_platform,omitempty"`
ReplyTarget string `json:"reply_target,omitempty"`
ConversationType string `json:"conversation_type,omitempty"`
CreatedAt time.Time `json:"created_at"`
DecidedAt *time.Time `json:"decided_at,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
}
Request is the app-layer decision DTO. Storage remains owned by the kind-specific services: toolapproval writes tool_approval_requests, and userinput writes user_input_requests.
type ResponseIdentity ¶
ResponseIdentity is the client retry identity attached to one durable decision transition.
func ResponseIdentityFromContext ¶
func ResponseIdentityFromContext(ctx context.Context) (ResponseIdentity, bool)
type Waiter ¶
type Waiter[T any] struct { // contains filtered or unexported fields }
Waiter is the single in-process waiting mechanism: instant in-memory broadcast for the common case, with a DB-fallback poll (the caller's poll func) so decisions recorded by another process or missed broadcasts still resolve. The registry (Register/Has) lets delivery paths distinguish "a live consumer owns this request" from an orphaned row.
func (*Waiter[T]) Await ¶
func (w *Waiter[T]) Await(ctx context.Context, id string, fallback time.Duration, poll func(context.Context) (T, bool, error)) (T, error)
Await blocks until the request resolves: instantly via broadcast, or via the fallback poll (poll returns done=true with the terminal value). poll runs once immediately - a decision may already have landed - and then on every fallback interval. On ctx cancellation a last-chance channel drain runs so a decision delivered concurrently with cancellation is not lost.
func (*Waiter[T]) Notify ¶
Notify wakes every subscriber of the request with the resolved value. Buffered, non-blocking sends: a subscriber that already left misses nothing - its fallback poll covers it.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package-shared MCP form-elicitation core: translates an MCP elicitation requestedSchema into the strict ask_user question payload and maps the submitted answers back into schema-conformant content.
|
Package-shared MCP form-elicitation core: translates an MCP elicitation requestedSchema into the strict ask_user question payload and maps the submitted answers back into schema-conformant content. |