data

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Overview

Package data provides Datly-backed read/write persistence services.

It wraps generated components for conversations, messages, turns, runs, tool calls, payloads, and related pagination/patch/delete operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrPermissionDenied = errors.New("permission denied")

Functions

func NewDatly

func NewDatly(ctx context.Context) (*datly.Service, error)

NewDatly creates a singleton datly service with configured connector. It expects AGENTLY_DB_DSN and AGENTLY_DB_DRIVER to be set.

func NewDatlyFromWorkspace

func NewDatlyFromWorkspace(ctx context.Context, root string) (*datly.Service, error)

NewDatlyFromWorkspace creates a datly service backed by file-based SQLite in the given workspace root directory ({root}/db/agently-core.db). Data persists across restarts.

func NewDatlyInMemory

func NewDatlyInMemory(ctx context.Context) (*datly.Service, error)

NewDatlyInMemory creates a non-singleton datly service backed by in-memory sqlite.

func NewDatlyServiceFromEnv

func NewDatlyServiceFromEnv(ctx context.Context) (*datly.Service, error)

NewDatlyServiceFromEnv is an alias kept for compatibility with existing patterns.

Types

type ConversationPage

type ConversationPage struct {
	Rows       []*agconvlist.ConversationRowsView
	NextCursor string
	PrevCursor string
	HasMore    bool
}

type Direction

type Direction string
const (
	DirectionBefore Direction = "before"
	DirectionAfter  Direction = "after"
	DirectionLatest Direction = "latest"
)

type MessagePage

type MessagePage struct {
	Rows       []*agmessagelist.MessageRowsView
	NextCursor string
	PrevCursor string
	HasMore    bool
}

type Option

type Option func(*options)

Option customizes read execution without changing generated input DTOs.

func WithAdminPrincipal

func WithAdminPrincipal(userID string) Option

WithAdminPrincipal bypasses visibility restrictions.

func WithPrincipal

func WithPrincipal(userID string) Option

WithPrincipal enforces conversation visibility rules for reads.

func WithQuerySelector

func WithQuerySelector(selectors ...*hstate.NamedQuerySelector) Option

WithQuerySelector delegates pagination/projection/order constraints to Datly selectors.

type PageInput

type PageInput struct {
	Limit     int
	Cursor    string
	Direction Direction
}

type RunStepPage

type RunStepPage struct {
	Rows       []*agrunsteps.RunStepsView
	NextCursor string
	PrevCursor string
	HasMore    bool
}

type Service

type Service interface {
	Raw() *datly.Service

	GetConversation(ctx context.Context, id string, in *agconv.ConversationInput, opts ...Option) (*agconv.ConversationView, error)
	ListConversations(ctx context.Context, in *agconvlist.ConversationRowsInput, page *PageInput, opts ...Option) (*ConversationPage, error)
	GetMessage(ctx context.Context, id string, in *agmessage.MessageInput, opts ...Option) (*agmessage.MessageView, error)
	GetMessagesPage(ctx context.Context, in *agmessagelist.MessageRowsInput, page *PageInput, opts ...Option) (*MessagePage, error)
	GetMessageByElicitation(ctx context.Context, conversationID, elicitationID string, opts ...Option) (*elicitationmsg.MessageView, error)

	GetRun(ctx context.Context, id string, in *agrun.RunRowsInput, opts ...Option) (*agrun.RunRowsView, error)
	GetRunStepsPage(ctx context.Context, in *agrunsteps.RunStepsInput, page *PageInput, opts ...Option) (*RunStepPage, error)
	GetActiveRun(ctx context.Context, in *agrunactive.ActiveRunsInput, opts ...Option) (*agrunactive.ActiveRunsView, error)
	ListStaleRuns(ctx context.Context, in *agrunstale.StaleRunsInput, opts ...Option) ([]*agrunstale.StaleRunsView, error)

	GetActiveTurn(ctx context.Context, in *agturnactive.ActiveTurnsInput, opts ...Option) (*agturnactive.ActiveTurnsView, error)
	GetTurnByID(ctx context.Context, in *agturnbyid.TurnLookupInput, opts ...Option) (*agturnbyid.TurnLookupView, error)
	GetTurnsPage(ctx context.Context, in *agturnlistall.TurnRowsInput, page *PageInput, opts ...Option) (*TurnPage, error)
	GetNextQueuedTurn(ctx context.Context, in *agturnnext.QueuedTurnInput, opts ...Option) (*agturnnext.QueuedTurnView, error)
	ListQueuedTurns(ctx context.Context, in *agturnlist.QueuedTurnsInput, opts ...Option) ([]*agturnlist.QueuedTurnsView, error)
	CountQueuedTurns(ctx context.Context, in *agturncount.QueuedTotalInput, opts ...Option) (int, error)

	GetToolCallByOp(ctx context.Context, opID string, in *agtoolcall.ToolCallRowsInput, opts ...Option) ([]*agtoolcall.ToolCallRowsView, error)
	ListPayloadRows(ctx context.Context, in *agpayload.PayloadRowsInput, opts ...Option) ([]*agpayload.PayloadRowsView, error)

	ListGeneratedFiles(ctx context.Context, conversationID string, opts ...Option) ([]*gfread.GeneratedFileView, error)

	PatchConversations(ctx context.Context, rows []*agconvwrite.MutableConversationView) ([]*agconvwrite.MutableConversationView, error)
	PatchMessages(ctx context.Context, rows []*agmessagewrite.MutableMessageView) ([]*agmessagewrite.MutableMessageView, error)
	PatchTurns(ctx context.Context, rows []*agturnwrite.MutableTurnView) ([]*agturnwrite.MutableTurnView, error)
	PatchModelCalls(ctx context.Context, rows []*agmodelcallwrite.MutableModelCallView) ([]*agmodelcallwrite.MutableModelCallView, error)
	PatchToolCalls(ctx context.Context, rows []*agtoolcallwrite.MutableToolCallView) ([]*agtoolcallwrite.MutableToolCallView, error)
	PatchPayloads(ctx context.Context, rows []*agpayloadwrite.MutablePayloadView) ([]*agpayloadwrite.MutablePayloadView, error)
	PatchRuns(ctx context.Context, rows []*agrunwrite.MutableRunView) ([]*agrunwrite.MutableRunView, error)

	DeleteConversations(ctx context.Context, ids ...string) error
	DeleteMessages(ctx context.Context, ids ...string) error
	DeleteTurns(ctx context.Context, ids ...string) error
	DeleteModelCalls(ctx context.Context, messageIDs ...string) error
	DeleteToolCalls(ctx context.Context, messageIDs ...string) error
	DeletePayloads(ctx context.Context, ids ...string) error
	DeleteRuns(ctx context.Context, ids ...string) error
}

Service is a thin facade over generated Datly read components.

func NewService

func NewService(dao *datly.Service) Service

NewService creates a thin data service on top of a Datly DAO.

func NewThinServiceFromEnv

func NewThinServiceFromEnv(ctx context.Context) (Service, error)

NewThinServiceFromEnv creates a thin data.Service backed by env-configured Datly.

func NewThinServiceInMemory

func NewThinServiceInMemory(ctx context.Context) (Service, error)

NewThinServiceInMemory creates a thin data.Service backed by in-memory sqlite.

type TurnPage

type TurnPage struct {
	Rows       []*agturnlistall.TurnRowsView
	NextCursor string
	PrevCursor string
	HasMore    bool
}

Directories

Path Synopsis
Package memory provides an in-memory conversation client implementation.
Package memory provides an in-memory conversation client implementation.

Jump to

Keyboard shortcuts

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