store

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound 资源未找到错误
	ErrNotFound = &StoreError{Code: "not_found", Message: "resource not found"}
	// ErrAlreadyExists 资源已存在错误
	ErrAlreadyExists = &StoreError{Code: "already_exists", Message: "resource already exists"}
)

Functions

func DecodeValue

func DecodeValue(src interface{}, dest interface{}) error

DecodeValue 将 interface{} 解码为具体类型

Types

type JSONStore

type JSONStore struct {
	// contains filtered or unexported fields
}

JSONStore JSON文件存储实现

func NewJSONStore

func NewJSONStore(baseDir string) (*JSONStore, error)

NewJSONStore 创建JSON存储

func (*JSONStore) Delete

func (js *JSONStore) Delete(ctx context.Context, collection, key string) error

Delete 删除资源

func (*JSONStore) DeleteAgent

func (js *JSONStore) DeleteAgent(ctx context.Context, agentID string) error

DeleteAgent 删除Agent所有数据

func (*JSONStore) Exists

func (js *JSONStore) Exists(ctx context.Context, collection, key string) (bool, error)

Exists 检查资源是否存在

func (*JSONStore) Get

func (js *JSONStore) Get(ctx context.Context, collection, key string, dest interface{}) error

Get 获取单个资源

func (*JSONStore) List

func (js *JSONStore) List(ctx context.Context, collection string) ([]interface{}, error)

List 列出资源

func (*JSONStore) ListAgents

func (js *JSONStore) ListAgents(ctx context.Context) ([]string, error)

ListAgents 列出所有Agent

func (*JSONStore) ListSnapshots

func (js *JSONStore) ListSnapshots(ctx context.Context, agentID string) ([]types.Snapshot, error)

ListSnapshots 列出快照

func (*JSONStore) LoadInfo

func (js *JSONStore) LoadInfo(ctx context.Context, agentID string) (*types.AgentInfo, error)

LoadInfo 加载Agent元信息

func (*JSONStore) LoadMessages

func (js *JSONStore) LoadMessages(ctx context.Context, agentID string) ([]types.Message, error)

LoadMessages 加载消息列表

func (*JSONStore) LoadSnapshot

func (js *JSONStore) LoadSnapshot(ctx context.Context, agentID string, snapshotID string) (*types.Snapshot, error)

LoadSnapshot 加载快照

func (*JSONStore) LoadTodos

func (js *JSONStore) LoadTodos(ctx context.Context, agentID string) (interface{}, error)

LoadTodos 加载Todo列表

func (*JSONStore) LoadToolCallRecords

func (js *JSONStore) LoadToolCallRecords(ctx context.Context, agentID string) ([]types.ToolCallRecord, error)

LoadToolCallRecords 加载工具调用记录

func (*JSONStore) SaveInfo

func (js *JSONStore) SaveInfo(ctx context.Context, agentID string, info types.AgentInfo) error

SaveInfo 保存Agent元信息

func (*JSONStore) SaveMessages

func (js *JSONStore) SaveMessages(ctx context.Context, agentID string, messages []types.Message) error

SaveMessages 保存消息列表

func (*JSONStore) SaveSnapshot

func (js *JSONStore) SaveSnapshot(ctx context.Context, agentID string, snapshot types.Snapshot) error

SaveSnapshot 保存快照

func (*JSONStore) SaveTodos

func (js *JSONStore) SaveTodos(ctx context.Context, agentID string, todos interface{}) error

SaveTodos 保存Todo列表

func (*JSONStore) SaveToolCallRecords

func (js *JSONStore) SaveToolCallRecords(ctx context.Context, agentID string, records []types.ToolCallRecord) error

SaveToolCallRecords 保存工具调用记录

func (*JSONStore) Set

func (js *JSONStore) Set(ctx context.Context, collection, key string, value interface{}) error

Set 设置资源

type Store

type Store interface {
	// SaveMessages 保存消息列表
	SaveMessages(ctx context.Context, agentID string, messages []types.Message) error

	// LoadMessages 加载消息列表
	LoadMessages(ctx context.Context, agentID string) ([]types.Message, error)

	// SaveToolCallRecords 保存工具调用记录
	SaveToolCallRecords(ctx context.Context, agentID string, records []types.ToolCallRecord) error

	// LoadToolCallRecords 加载工具调用记录
	LoadToolCallRecords(ctx context.Context, agentID string) ([]types.ToolCallRecord, error)

	// SaveSnapshot 保存快照
	SaveSnapshot(ctx context.Context, agentID string, snapshot types.Snapshot) error

	// LoadSnapshot 加载快照
	LoadSnapshot(ctx context.Context, agentID string, snapshotID string) (*types.Snapshot, error)

	// ListSnapshots 列出快照
	ListSnapshots(ctx context.Context, agentID string) ([]types.Snapshot, error)

	// SaveInfo 保存Agent元信息
	SaveInfo(ctx context.Context, agentID string, info types.AgentInfo) error

	// LoadInfo 加载Agent元信息
	LoadInfo(ctx context.Context, agentID string) (*types.AgentInfo, error)

	// SaveTodos 保存Todo列表
	SaveTodos(ctx context.Context, agentID string, todos interface{}) error

	// LoadTodos 加载Todo列表
	LoadTodos(ctx context.Context, agentID string) (interface{}, error)

	// DeleteAgent 删除Agent所有数据
	DeleteAgent(ctx context.Context, agentID string) error

	// ListAgents 列出所有Agent
	ListAgents(ctx context.Context) ([]string, error)

	// Get 获取单个资源
	Get(ctx context.Context, collection, key string, dest interface{}) error

	// Set 设置资源
	Set(ctx context.Context, collection, key string, value interface{}) error

	// Delete 删除资源
	Delete(ctx context.Context, collection, key string) error

	// List 列出资源
	List(ctx context.Context, collection string) ([]interface{}, error)

	// Exists 检查资源是否存在
	Exists(ctx context.Context, collection, key string) (bool, error)
}

Store 持久化存储接口

type StoreError

type StoreError struct {
	Code    string
	Message string
	Err     error
}

StoreError Store 错误类型

func (*StoreError) Error

func (e *StoreError) Error() string

func (*StoreError) Unwrap

func (e *StoreError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL