Documentation
¶
Index ¶
- type Config
- type EventInput
- type InsertedEvent
- type ProcessTurnRequest
- type SSEBroker
- type SSESubscriber
- type Server
- type Session
- type SessionEvent
- type Store
- func (s *Store) BumpSessionEpoch(ctx context.Context, id string) (int, error)
- func (s *Store) Close() error
- func (s *Store) CreateSession(ctx context.Context, id, workspaceID, title, source string, externalID *string) error
- func (s *Store) GetSession(ctx context.Context, id string) (*Session, error)
- func (s *Store) GetSessionEpoch(ctx context.Context, sessionID string) (int, error)
- func (s *Store) InsertEvents(ctx context.Context, sessionID string, epoch int, events []EventInput) ([]InsertedEvent, error)
- type StreamClientEvent
- type TurnLock
- type TurnMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Port string
DatabaseURL string
LogLevel slog.Level
ExecutorRegistryURL string
AgentserverURL string
S3Endpoint string
S3Region string
S3Bucket string
S3AccessKeyID string
S3SecretAccessKey string
S3PathStyle bool
IMBridgeURL string
IMBridgeSecret string
// Phase 1 Task 13: turn-finished callback to agentserver.
AgentserverInternalURL string // env: AGENTSERVER_INTERNAL_URL
InternalAPISecret string // env: INTERNAL_API_SECRET
// LLM proxy URL: cc-broker injects this as ANTHROPIC_BASE_URL on the
// spawned Claude CLI so LLM traffic is authenticated against llmproxy
// using the per-workspace proxy token (not directly to upstream).
LLMProxyURL string // env: CCBROKER_LLMPROXY_URL
}
func LoadConfigFromEnv ¶
type EventInput ¶
type EventInput struct {
EventID string
Payload json.RawMessage
Ephemeral bool
}
type InsertedEvent ¶
type ProcessTurnRequest ¶
type ProcessTurnRequest struct {
SessionID string `json:"session_id"`
WorkspaceID string `json:"workspace_id"`
UserMessage string `json:"user_message"`
IMChannelID string `json:"im_channel_id,omitempty"`
IMUserID string `json:"im_user_id,omitempty"`
Metadata TurnMetadata `json:"metadata,omitempty"`
}
ProcessTurnRequest is the external API request body for POST /api/turns.
IMChannelID and IMUserID are optional. When set (for turns originated by an IM inbound) the cc-broker ToolRouter can route send_* MCP tool calls back through imbridge to the originating IM channel / user.
Metadata is optional. When absent (legacy IM turns), defaults apply.
type SSEBroker ¶
type SSEBroker struct {
// contains filtered or unexported fields
}
SSEBroker fans out events to per-session subscribers.
func (*SSEBroker) Publish ¶
func (b *SSEBroker) Publish(sessionID string, event *StreamClientEvent)
Publish sends an event to all subscribers of a session. If a subscriber's channel is full, it is closed (force reconnect).
func (*SSEBroker) Subscribe ¶
func (b *SSEBroker) Subscribe(sessionID string) *SSESubscriber
Subscribe creates a new subscriber for a session.
func (*SSEBroker) Unsubscribe ¶
func (b *SSEBroker) Unsubscribe(sessionID string, sub *SSESubscriber)
Unsubscribe removes a subscriber.
type SSESubscriber ¶
type SSESubscriber struct {
Ch chan *StreamClientEvent
// contains filtered or unexported fields
}
SSESubscriber receives events for a single session.
func (*SSESubscriber) Done ¶
func (s *SSESubscriber) Done() <-chan struct{}
Done returns a channel closed when the subscriber is removed.
type Session ¶
type Session struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
Title string `json:"title,omitempty"`
Status string `json:"status"`
Epoch int `json:"epoch"`
ExternalID *string `json:"external_id,omitempty"`
Source string `json:"source,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type SessionEvent ¶
type SessionEvent struct {
ID int64 `json:"id"`
SessionID string `json:"session_id"`
EventID string `json:"event_id"`
EventType string `json:"event_type"`
Source string `json:"source"`
Epoch int `json:"epoch"`
Payload json.RawMessage `json:"payload"`
Ephemeral bool `json:"ephemeral"`
CreatedAt time.Time `json:"created_at"`
}
type Store ¶
Store provides database access for the cc-broker.
func (*Store) BumpSessionEpoch ¶
BumpSessionEpoch atomically increments the epoch and returns the new value.
func (*Store) CreateSession ¶
func (s *Store) CreateSession(ctx context.Context, id, workspaceID, title, source string, externalID *string) error
CreateSession inserts a new session.
func (*Store) GetSession ¶
GetSession retrieves a session by ID. Returns nil if not found.
func (*Store) GetSessionEpoch ¶
GetSessionEpoch returns the current epoch for a session.
func (*Store) InsertEvents ¶
func (s *Store) InsertEvents(ctx context.Context, sessionID string, epoch int, events []EventInput) ([]InsertedEvent, error)
InsertEvents inserts a batch of events, skipping duplicates. Returns only the successfully inserted events with their sequence numbers.
type StreamClientEvent ¶
type TurnLock ¶
type TurnLock struct {
// contains filtered or unexported fields
}
func NewTurnLock ¶
func NewTurnLock() *TurnLock
type TurnMetadata ¶ added in v0.47.0
type TurnMetadata struct {
ChannelType string `json:"channel_type,omitempty"`
CreatorUserID string `json:"creator_user_id,omitempty"`
PermissionMode string `json:"permission_mode,omitempty"`
Model string `json:"model,omitempty"`
PreferredExecutorID string `json:"preferred_executor_id,omitempty"`
TurnKind string `json:"turn_kind,omitempty"` // "user" | "compaction"
}
TurnMetadata carries optional per-turn metadata sent by TUI / API callers. IM inbound turns omit this field entirely; defaults apply (ChannelType="im", PermissionMode="bypass").
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal/ccbroker/tools/permission.go
|
internal/ccbroker/tools/permission.go |
|
Package wstoken acquires per-workspace proxy tokens from agentserver and caches them in-process so cc-broker can stamp them onto every spawned Claude CLI's ANTHROPIC_AUTH_TOKEN env without hitting the network on every turn.
|
Package wstoken acquires per-workspace proxy tokens from agentserver and caches them in-process so cc-broker can stamp them onto every spawned Claude CLI's ANTHROPIC_AUTH_TOKEN env without hitting the network on every turn. |