Files
archie/internal/domain/messaging/chat_stream.go
T
sam de47bf2398 fix(webhook): reject rate-limited deliveries with 429 instead of chat prose or a false 202
Router.Route returned the chat-facing rate-limit prose with a nil error, so
the webhook handler had no way to tell a genuine dispatch outcome from a
rejection: DeliverTo "origin" echoed the prose as a 200 reply, and any
other route got a 202 for an event that was actually dropped before
reaching the LLM, so the source never retries it.

ChatReply now carries RateLimited, set by a new Router.RouteResult (Route
is now a thin wrapper over it) so chat channels that render Text to a
human are unaffected. The webhook handler checks it and answers 429,
matching the precedent internal/webhookguard.RateLimiter's other callers
already set.
2026-09-27 05:20:30 +10:00

56 lines
1.7 KiB
Go

package messaging
// ChatSnapshot is what Snapshot returns: the full chat state a dashboard
// renders in one read.
type ChatSnapshot struct {
Sessions []SessionContext
Models []string
ModelsByProvider map[string][]string
Providers []string
ActiveModel string
ActiveProvider string
Personas []string
ActivePersonas map[string]string
// Version is the Gateway's rendered component-version block. Channel
// frontends display it rather than stamping their own build, so a
// partially upgraded deployment cannot report itself as matched.
Version string
RestartAvailable bool
CancellationAvailable bool
PersonasAvailable bool
}
// ChatReply is the blocking reply from Route.
type ChatReply struct {
Text string
SessionID string
// RateLimited reports whether Text is the inbound rate-limit reply rather
// than a real dispatch outcome. A human-facing channel can ignore it and
// send Text as usual; a channel with no human reading replies (a webhook)
// must not treat it as a normal reply or a delivered event -- see
// archie-core-1173.
RateLimited bool
}
// ChatCancellation is what Cancel returns.
type ChatCancellation struct {
Cancelled bool
Dropped int
}
// ChatEvent contains values only; Text holds the error message for error events.
type ChatEvent struct {
Kind string
Text string
SessionID string
Tool ToolCallEvent
Media MediaEvent
}
// DashboardNavigateResult is what dashboard_navigate returns. The web UI
// renders it as a clickable chip that routes the operator to the page.
type DashboardNavigateResult struct {
Path string `json:"path"`
Label string `json:"label"`
}