mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-06-10 04:10:26 +00:00
0926d053b0
- A1+C2: Include token usage in run.completed event payload for WS clients
- A2: Cost tracking with model pricing config, cost calculation, and cost summary API
- A3: Budget enforcement per agent with monthly budget limits (migration 000015)
- C1: External wake/trigger API (POST /v1/agents/{id}/wake) for orchestrators
- C3: Activity audit trail with structured logging and queryable API
- UI: Activity page, cost stat card on overview, budget section in agent detail
- i18n: Complete en/vi/zh translations for all new features
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ActivityLog represents a single audit log entry.
|
|
type ActivityLog struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ActorType string `json:"actor_type"`
|
|
ActorID string `json:"actor_id"`
|
|
Action string `json:"action"`
|
|
EntityType string `json:"entity_type,omitempty"`
|
|
EntityID string `json:"entity_id,omitempty"`
|
|
Details json.RawMessage `json:"details,omitempty"`
|
|
IPAddress string `json:"ip_address,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// ActivityListOpts configures activity log listing.
|
|
type ActivityListOpts struct {
|
|
ActorType string
|
|
ActorID string
|
|
Action string
|
|
EntityType string
|
|
EntityID string
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
// ActivityStore manages activity audit logs.
|
|
type ActivityStore interface {
|
|
Log(ctx context.Context, entry *ActivityLog) error
|
|
List(ctx context.Context, opts ActivityListOpts) ([]ActivityLog, error)
|
|
Count(ctx context.Context, opts ActivityListOpts) (int, error)
|
|
}
|