Documentation
¶
Index ¶
- type AgentTurn
- 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) CountPending(ctx context.Context, sessionID string) (int, error)
- func (s *Store) CreateSession(ctx context.Context, id, workspaceID, title, source string, externalID *string) error
- func (s *Store) EnqueueTurn(ctx context.Context, t AgentTurn) 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) GetTurn(ctx context.Context, turnID string) (*AgentTurn, error)
- func (s *Store) GetTurnEvents(ctx context.Context, turnID string, sinceSeqNum int64) ([]TurnEvent, error)
- func (s *Store) InsertEvents(ctx context.Context, sessionID string, epoch int, events []EventInput) ([]InsertedEvent, error)
- func (s *Store) InsertEventsWithTurn(ctx context.Context, sessionID string, epoch int, turnID string, ...) ([]InsertedEvent, error)
- func (s *Store) ListSessionTurns(ctx context.Context, sessionID string, limit int) ([]AgentTurn, error)
- func (s *Store) ListSessionsWithPending(ctx context.Context) ([]string, error)
- func (s *Store) MarkTurnCancelled(ctx context.Context, turnID string) error
- func (s *Store) MarkTurnDone(ctx context.Context, turnID string) error
- func (s *Store) MarkTurnFailed(ctx context.Context, turnID, errMsg string) error
- func (s *Store) MarkTurnRunning(ctx context.Context, turnID string) error
- func (s *Store) PickNextPending(ctx context.Context, sessionID string) (*AgentTurn, error)
- func (s *Store) ResetRunningToQueued(ctx context.Context) (int, error)
- type StreamClientEvent
- type TurnEvent
- type TurnMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentTurn ¶ added in v0.49.1
type AgentTurn struct {
ID string
SessionID string
WorkspaceID string
State string // queued|running|done|cancelled|failed
UserEventID string
UserMessage string
Metadata json.RawMessage
IMChannelID sql.NullString
IMUserID sql.NullString
ErrorMsg sql.NullString
EnqueuedAt time.Time
StartedAt sql.NullTime
FinishedAt sql.NullTime
}
AgentTurn mirrors a row in the agent_turns table.
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"`
TurnID string `json:"turn_id,omitempty"` // optional caller-supplied id
}
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 Server ¶
type Server struct {
// contains filtered or unexported fields
}
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) CountPending ¶ added in v0.49.1
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) EnqueueTurn ¶ added in v0.49.1
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) GetTurnEvents ¶ added in v0.49.1
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.
func (*Store) InsertEventsWithTurn ¶ added in v0.49.1
func (s *Store) InsertEventsWithTurn(ctx context.Context, sessionID string, epoch int, turnID string, events []EventInput) ([]InsertedEvent, error)
InsertEventsWithTurn is identical to InsertEvents but tags each row with turn_id.
func (*Store) ListSessionTurns ¶ added in v0.49.1
func (*Store) ListSessionsWithPending ¶ added in v0.49.1
func (*Store) MarkTurnCancelled ¶ added in v0.49.1
func (*Store) MarkTurnDone ¶ added in v0.49.1
func (*Store) MarkTurnFailed ¶ added in v0.49.1
func (*Store) MarkTurnRunning ¶ added in v0.49.1
func (*Store) PickNextPending ¶ added in v0.49.1
type StreamClientEvent ¶
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"`
}
TurnMetadata carries optional per-turn metadata sent by TUI / API callers.
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. |