Documentation
¶
Index ¶
- Constants
- func AppendPrompt(workspace string, sessionID corepkg.SessionID, prompt string, at time.Time) error
- func DefaultPromptHistoryPath() (string, error)
- func NewRuntimeTaskEventAdapter(store TaskStore) runtimepkg.TaskEventStore
- func ReadLatestJSONLSnapshot(files *SessionFileStore, path, eventType string) (json.RawMessage, error)
- func WorkspaceProjectID(workspace string) string
- func WriteJSONLSnapshot(files *SessionFileStore, path, eventType string, schemaVersion int, ...) error
- type AuditEvent
- type AuditStore
- type CompositeLocker
- type ErrorCode
- type FileAuditStore
- type FileLocker
- type FileTaskStore
- func NewDefaultTaskStore(locker Locker) (*FileTaskStore, error)
- func NewDefaultTaskStoreWithOptions(locker Locker, options TaskStoreOptions) (*FileTaskStore, error)
- func NewFileTaskStore(root string, locker Locker) (*FileTaskStore, error)
- func NewFileTaskStoreWithOptions(root string, locker Locker, options TaskStoreOptions) (*FileTaskStore, error)
- type InMemoryLocker
- type Locker
- type NopAuditStore
- type NopPromptHistoryStore
- type PromptEntry
- type PromptHistoryStore
- type PromptHistoryWriter
- type PromptSearchQuery
- type RuntimeTaskEventAdapter
- type RuntimeTaskStoredeprecated
- type SessionFileStore
- func (s *SessionFileStore) AppendLine(path string, line []byte) error
- func (s *SessionFileStore) FindNewestByName(fileName string) (string, error)
- func (s *SessionFileStore) ListByExt(ext string) ([]string, error)
- func (s *SessionFileStore) Read(path string) ([]byte, error)
- func (s *SessionFileStore) Root() string
- func (s *SessionFileStore) SessionPath(projectID, sessionID string) (string, error)
- func (s *SessionFileStore) WriteAtomic(path string, content []byte) error
- type TaskLogRecord
- type TaskStore
- type TaskStoreOptions
- type UnlockFunc
Constants ¶
const ( TaskRecordTypeTaskEventStatus = "task_event.status" TaskRecordTypeTaskEventResult = "task_event.result" TaskRecordTypeTaskEventError = "task_event.error" TaskRecordTypeTaskEventLog = "task_event.log" TaskRecordTypeTaskLog = "task_log" )
Variables ¶
This section is empty.
Functions ¶
func AppendPrompt ¶
func NewRuntimeTaskEventAdapter ¶
func NewRuntimeTaskEventAdapter(store TaskStore) runtimepkg.TaskEventStore
func ReadLatestJSONLSnapshot ¶
func ReadLatestJSONLSnapshot(files *SessionFileStore, path, eventType string) (json.RawMessage, error)
func WorkspaceProjectID ¶
func WriteJSONLSnapshot ¶
Types ¶
type AuditEvent ¶
type AuditEvent struct {
EventID corepkg.EventID `json:"event_id"`
SessionID corepkg.SessionID `json:"session_id,omitempty"`
TaskID corepkg.TaskID `json:"task_id,omitempty"`
TraceID corepkg.TraceID `json:"trace_id,omitempty"`
Timestamp time.Time `json:"timestamp"`
Actor string `json:"actor,omitempty"`
Action string `json:"action"`
Decision corepkg.Decision `json:"decision,omitempty"`
ReasonCode string `json:"reason_code,omitempty"`
RiskLevel corepkg.RiskLevel `json:"risk_level,omitempty"`
Result string `json:"result,omitempty"`
LatencyMS int64 `json:"latency_ms,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
type AuditStore ¶
type AuditStore interface {
Append(ctx context.Context, event AuditEvent) error
}
func NewDefaultAuditStore ¶
func NewDefaultAuditStore() (AuditStore, error)
type CompositeLocker ¶
type CompositeLocker struct {
// contains filtered or unexported fields
}
func (*CompositeLocker) LockSession ¶
func (l *CompositeLocker) LockSession(acquireCtx context.Context, sessionID corepkg.SessionID) (UnlockFunc, error)
func (*CompositeLocker) LockTask ¶
func (l *CompositeLocker) LockTask(acquireCtx context.Context, taskID corepkg.TaskID) (UnlockFunc, error)
type FileAuditStore ¶
type FileAuditStore struct {
// contains filtered or unexported fields
}
func NewFileAuditStore ¶
func NewFileAuditStore(dir string) (*FileAuditStore, error)
func (*FileAuditStore) Append ¶
func (s *FileAuditStore) Append(_ context.Context, event AuditEvent) error
type FileLocker ¶
type FileLocker struct {
// contains filtered or unexported fields
}
func NewFileLocker ¶
func NewFileLocker(dir string) (*FileLocker, error)
func NewFileLockerWithConfig ¶
func NewFileLockerWithConfig(dir string, pollInterval, staleAfter, heartbeatInterval time.Duration) (*FileLocker, error)
func NewFileLockerWithPollInterval ¶
func NewFileLockerWithPollInterval(dir string, pollInterval time.Duration) (*FileLocker, error)
func (*FileLocker) LockSession ¶
func (l *FileLocker) LockSession(acquireCtx context.Context, sessionID corepkg.SessionID) (UnlockFunc, error)
func (*FileLocker) LockTask ¶
func (l *FileLocker) LockTask(acquireCtx context.Context, taskID corepkg.TaskID) (UnlockFunc, error)
type FileTaskStore ¶
type FileTaskStore struct {
// contains filtered or unexported fields
}
func NewDefaultTaskStore ¶
func NewDefaultTaskStore(locker Locker) (*FileTaskStore, error)
func NewDefaultTaskStoreWithOptions ¶
func NewDefaultTaskStoreWithOptions(locker Locker, options TaskStoreOptions) (*FileTaskStore, error)
func NewFileTaskStore ¶
func NewFileTaskStore(root string, locker Locker) (*FileTaskStore, error)
func NewFileTaskStoreWithOptions ¶
func NewFileTaskStoreWithOptions(root string, locker Locker, options TaskStoreOptions) (*FileTaskStore, error)
func (*FileTaskStore) AppendLog ¶
func (s *FileTaskStore) AppendLog(ctx context.Context, taskID corepkg.TaskID, record TaskLogRecord) (offset int64, err error)
func (*FileTaskStore) ReadLogFrom ¶
func (s *FileTaskStore) ReadLogFrom(ctx context.Context, taskID corepkg.TaskID, offset int64, limit int) ([]TaskLogRecord, int64, error)
type InMemoryLocker ¶
type InMemoryLocker struct {
// contains filtered or unexported fields
}
func NewInMemoryLocker ¶
func NewInMemoryLocker() *InMemoryLocker
func (*InMemoryLocker) LockSession ¶
func (l *InMemoryLocker) LockSession(ctx context.Context, sessionID corepkg.SessionID) (UnlockFunc, error)
func (*InMemoryLocker) LockTask ¶
func (l *InMemoryLocker) LockTask(ctx context.Context, taskID corepkg.TaskID) (UnlockFunc, error)
type Locker ¶
type Locker interface {
// LockSession acquires the session-scoped lock.
// acquireCtx is only for acquisition waiting/cancellation.
// Implementations must not bind lock lifetime to acquireCtx after acquisition.
LockSession(acquireCtx context.Context, sessionID corepkg.SessionID) (UnlockFunc, error)
// LockTask acquires the task-scoped lock.
// acquireCtx is only for acquisition waiting/cancellation.
// Implementations must not bind lock lifetime to acquireCtx after acquisition.
LockTask(acquireCtx context.Context, taskID corepkg.TaskID) (UnlockFunc, error)
}
func NewCompositeLocker ¶
func NewDefaultLocker ¶
type NopAuditStore ¶
type NopAuditStore struct{}
func (NopAuditStore) Append ¶
func (NopAuditStore) Append(context.Context, AuditEvent) error
type NopPromptHistoryStore ¶
type NopPromptHistoryStore struct{}
type PromptEntry ¶
type PromptEntry struct {
Timestamp time.Time `json:"timestamp"`
Workspace string `json:"workspace"`
SessionID corepkg.SessionID `json:"session_id"`
Prompt string `json:"prompt"`
}
func FilterPromptEntries ¶
func FilterPromptEntries(entries []PromptEntry, rawQuery string, limit int) []PromptEntry
FilterPromptEntries filters and ranks prompt history entries newest-first.
func LoadRecentPrompts ¶
func LoadRecentPrompts(limit int) ([]PromptEntry, error)
type PromptHistoryStore ¶
type PromptHistoryStore struct {
// contains filtered or unexported fields
}
func NewDefaultPromptHistoryStore ¶
func NewDefaultPromptHistoryStore() (*PromptHistoryStore, error)
func (*PromptHistoryStore) LoadRecent ¶
func (s *PromptHistoryStore) LoadRecent(limit int) ([]PromptEntry, error)
type PromptHistoryWriter ¶
type PromptSearchQuery ¶
PromptSearchQuery is the normalized filter expression for prompt history.
func ParsePromptSearchQuery ¶
func ParsePromptSearchQuery(raw string) PromptSearchQuery
ParsePromptSearchQuery parses free text into content tokens and scope filters.
type RuntimeTaskEventAdapter ¶
type RuntimeTaskEventAdapter struct {
// contains filtered or unexported fields
}
func (*RuntimeTaskEventAdapter) AppendTaskEvent ¶
func (a *RuntimeTaskEventAdapter) AppendTaskEvent(ctx context.Context, event runtimepkg.TaskEvent) error
func (*RuntimeTaskEventAdapter) AppendTaskLog ¶
func (a *RuntimeTaskEventAdapter) AppendTaskLog(ctx context.Context, taskID corepkg.TaskID, entry runtimepkg.TaskLogEntry) error
type RuntimeTaskStore
deprecated
type RuntimeTaskStore struct {
// contains filtered or unexported fields
}
RuntimeTaskStore writes task events to ~/.bytemind/runtime/tasks/events|logs.
Deprecated: use NewDefaultTaskStore + NewRuntimeTaskEventAdapter so runtime task events and logs are persisted into ~/.bytemind/tasks/<task-id>.log.
func NewDefaultRuntimeTaskStore
deprecated
func NewDefaultRuntimeTaskStore() (*RuntimeTaskStore, error)
NewDefaultRuntimeTaskStore creates the legacy runtime task store.
Deprecated: use NewDefaultTaskStore + NewRuntimeTaskEventAdapter instead.
func (*RuntimeTaskStore) AppendTaskEvent ¶
func (s *RuntimeTaskStore) AppendTaskEvent(_ context.Context, event runtimepkg.TaskEvent) error
func (*RuntimeTaskStore) AppendTaskLog ¶
func (s *RuntimeTaskStore) AppendTaskLog(_ context.Context, taskID corepkg.TaskID, entry runtimepkg.TaskLogEntry) error
type SessionFileStore ¶
type SessionFileStore struct {
// contains filtered or unexported fields
}
SessionFileStore owns low-level filesystem concerns for session snapshots.
func NewSessionFileStore ¶
func NewSessionFileStore(root string) (*SessionFileStore, error)
func (*SessionFileStore) AppendLine ¶
func (s *SessionFileStore) AppendLine(path string, line []byte) error
func (*SessionFileStore) FindNewestByName ¶
func (s *SessionFileStore) FindNewestByName(fileName string) (string, error)
func (*SessionFileStore) ListByExt ¶
func (s *SessionFileStore) ListByExt(ext string) ([]string, error)
func (*SessionFileStore) Root ¶
func (s *SessionFileStore) Root() string
func (*SessionFileStore) SessionPath ¶
func (s *SessionFileStore) SessionPath(projectID, sessionID string) (string, error)
func (*SessionFileStore) WriteAtomic ¶
func (s *SessionFileStore) WriteAtomic(path string, content []byte) error
type TaskLogRecord ¶
type TaskLogRecord struct {
TaskID corepkg.TaskID `json:"-"`
Offset int64 `json:"-"`
EventID string `json:"event_id"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload,omitempty"`
CreatedAt time.Time `json:"ts"`
}
func ReplayTaskLog ¶
func ReplayTaskLog(ctx context.Context, store TaskStore, taskID corepkg.TaskID, pageSize int) ([]TaskLogRecord, error)
ReplayTaskLog replays a task log by paginating from offset 0, de-duplicating by event_id and keeping records in offset order.
type TaskStoreOptions ¶
type TaskStoreOptions struct {
// SyncOnAppend controls whether AppendLog calls fsync per record.
SyncOnAppend bool
}
type UnlockFunc ¶
type UnlockFunc func() error