Documentation
¶
Index ¶
- Constants
- func DashboardFiltersFromContext(ctx context.Context) map[string]*metricsview.Expression
- func ExternalToolName(connector, tool string) string
- func IsMCPAppOnlyTool(toolName string) bool
- func MCPAppToolMeta(toolName string, a *mcpapp.Asset) map[string]any
- func MCPToolSpecs() map[string]*mcp.Tool
- func MCPUserAgent(userAgent string) string
- func MemoryAvailable(ctx context.Context, rt *runtime.Runtime, instanceID string, ...) (bool, error)
- func MemoryEnabledByUser(ctx context.Context, catalog drivers.CatalogStore, ownerID string) (bool, error)
- func NewInternalError(err error) error
- func NewTextCompletionMessage(role Role, content string) *aiv1.CompletionMessage
- func RegisterTool[In, Out any](s *Runner, t Tool[In, Out])
- func SanitizeMemoryContent(content string) string
- func WithDashboardFilters(ctx context.Context, filters map[string]*metricsview.Expression) context.Context
- func WithSession(ctx context.Context, s *Session) context.Context
- func WithUIContext(ctx context.Context, ui *UIContext) context.Context
- type AddMessageOptions
- type AnalystAgent
- type AnalystAgentArgs
- type AnalystAgentResult
- type BaseSession
- func (s *BaseSession) CatalogSession() *drivers.AISession
- func (s *BaseSession) Claims() *runtime.SecurityClaims
- func (s *BaseSession) ExpandMessages(msgs []*Message, fn func(m *Message) []*Message) []*Message
- func (s *BaseSession) ExternalServerPromptData(ctx context.Context, agent string) map[string]any
- func (s *BaseSession) ExternalServers(ctx context.Context) []*ExternalServer
- func (s *BaseSession) ExternalToolNames(ctx context.Context, agent string) []string
- func (s *BaseSession) FeatureFlags(ctx context.Context) (map[string]bool, error)
- func (s *BaseSession) Flush(ctx context.Context) error
- func (s *BaseSession) Forked() bool
- func (s *BaseSession) ID() string
- func (s *BaseSession) InstanceID() string
- func (s *BaseSession) LatestMessage(predicates ...Predicate) (*Message, bool)
- func (s *BaseSession) LatestRootCall() *Message
- func (s *BaseSession) MemoryEnabled() bool
- func (s *BaseSession) Message(predicates ...Predicate) (*Message, bool)
- func (s *BaseSession) Messages(predicates ...Predicate) []*Message
- func (s *BaseSession) MessagesWithChildren(predicates ...Predicate) []*Message
- func (s *BaseSession) MessagesWithDescendents(predicates ...Predicate) []*Message
- func (s *BaseSession) MessagesWithResults(predicates ...Predicate) []*Message
- func (s *BaseSession) NextIndex() int
- func (s *BaseSession) ProjectInstructions() string
- func (s *BaseSession) SetLLM(acquireLLM func(ctx context.Context) (drivers.AIService, func(), error))
- func (s *BaseSession) Shared() bool
- func (s *BaseSession) Skills(ctx context.Context) ([]*Skill, error)
- func (s *BaseSession) Subscribe() chan *Message
- func (s *BaseSession) Title() string
- func (s *BaseSession) Unsubscribe(ch chan *Message)
- func (s *BaseSession) UpdateSharedUntilMessageID(ctx context.Context, messageID string) error
- func (s *BaseSession) UpdateTitle(ctx context.Context, title string) error
- func (s *BaseSession) UpdateUserAgent(ctx context.Context, userAgent string) error
- func (s *BaseSession) UserMemories() []*drivers.AIMemory
- func (s *BaseSession) WithParent(messageID string) *Session
- type CallOptions
- type CallResult
- type CallToolOptions
- type ChartData
- func (t *ChartData) CheckAccess(ctx context.Context) (bool, error)
- func (t *ChartData) DecorateMCPResult(ctx context.Context, out *ChartDataOutput, res *mcp.CallToolResult)
- func (t *ChartData) Handler(ctx context.Context, args ChartDataArgs) (*ChartDataOutput, error)
- func (t *ChartData) MCPAppUI() *mcpapp.ToolUI
- func (t *ChartData) Spec() *mcp.Tool
- type ChartDataArgs
- type ChartDataOutput
- type ChartDataResult
- type ChartField
- type ChartInput
- type ChartMetricsView
- type ClickUI
- type ClickUIArgs
- type ClickUIResult
- type ColumnInfo
- type CompiledTool
- type CompleteOptions
- type CreateChart
- func (t *CreateChart) CheckAccess(ctx context.Context) (bool, error)
- func (t *CreateChart) DecorateMCPResult(ctx context.Context, out *CreateChartResult, res *mcp.CallToolResult)
- func (t *CreateChart) Handler(ctx context.Context, args CreateChartArgs) (*CreateChartResult, error)
- func (t *CreateChart) MCPAppUI() *mcpapp.ToolUI
- func (t *CreateChart) MCPSpec() *mcp.Tool
- func (t *CreateChart) Spec() *mcp.Tool
- type CreateChartArgs
- type CreateChartResult
- type DevelopFile
- type DevelopFileArgs
- type DevelopFileResult
- type DeveloperAgent
- type DeveloperAgentArgs
- type DeveloperAgentResult
- type ExternalAuthorizationRequiredError
- type ExternalServer
- type ExternalToolInfo
- type ExternalToolResult
- type FeedbackAgent
- type FeedbackAgentArgs
- type FeedbackAgentResult
- type GetCanvas
- type GetCanvasArgs
- type GetCanvasResult
- type GetMetricsView
- type GetMetricsViewArgs
- type GetMetricsViewResult
- type InternalError
- type LLMMarshaler
- type ListBucketObjects
- type ListBucketObjectsArgs
- type ListBucketObjectsResult
- type ListBuckets
- type ListBucketsArgs
- type ListBucketsResult
- type ListFiles
- type ListFilesArgs
- type ListFilesResult
- type ListMetricsViews
- type ListMetricsViewsArgs
- type ListMetricsViewsResult
- type ListSkills
- type ListSkillsArgs
- type ListSkillsResult
- type ListTables
- type ListTablesArgs
- type ListTablesResult
- type LoadSkill
- type LoadSkillArgs
- type LoadSkillResult
- type MCPAppTool
- type MCPResultDecorator
- type MCPSpecProvider
- type MemoryUpdateResult
- type Message
- type MessageContentType
- type MessageType
- type Navigate
- type NavigateArgs
- type NavigateResult
- type ObjectInfo
- type Predicate
- type ProjectStatus
- type ProjectStatusArgs
- type ProjectStatusResult
- type QueryMetricsView
- type QueryMetricsViewArgs
- type QueryMetricsViewResult
- type QueryMetricsViewSummary
- type QueryMetricsViewSummaryArgs
- type QueryMetricsViewSummaryResult
- type QuerySQL
- type QuerySQLArgs
- type QuerySQLResult
- type ReadFile
- type ReadFileArgs
- type ReadFileResult
- type Role
- type RouterAgent
- type RouterAgentArgs
- type RouterAgentResult
- type Runner
- func (r *Runner) DiscoverExternalServers(ctx context.Context, instanceID string, claims *runtime.SecurityClaims) ([]*ExternalServer, error)
- func (r *Runner) ForkSession(ctx context.Context, opts *SessionOptions) (string, error)
- func (r *Runner) Session(ctx context.Context, opts *SessionOptions) (res *Session, resErr error)
- type SchemaField
- type SearchExternalTools
- type SearchExternalToolsArgs
- type SearchExternalToolsResult
- type SearchFiles
- type SearchFilesArgs
- type SearchFilesResult
- type SearchMatch
- type Session
- func (s *Session) AddMessage(opts *AddMessageOptions) *Message
- func (s *Session) Call(ctx context.Context, opts *CallOptions) (*CallResult, error)
- func (s *Session) CallTool(ctx context.Context, role Role, toolName string, out, args any) (*CallResult, error)
- func (s *Session) CallToolWithOptions(ctx context.Context, opts *CallToolOptions) (*CallResult, error)
- func (s *Session) Complete(ctx context.Context, name string, out any, opts *CompleteOptions) error
- func (s *Session) MCPServer(ctx context.Context) *mcp.Server
- func (s *Session) MustUnmarshalMessageContent(m *Message) any
- func (s *Session) NewCompletionMessage(m *Message) (*aiv1.CompletionMessage, error)
- func (s *Session) NewCompletionMessages(msgs []*Message) []*aiv1.CompletionMessage
- func (s *Session) RootID() string
- func (s *Session) Tool(toolName string) (*CompiledTool, bool)
- func (s *Session) UnmarshalMessageContent(m *Message) (any, error)
- type SessionOptions
- type ShowTable
- type ShowTableArgs
- type ShowTableResult
- type Skill
- type SkillInfo
- type TableInfo
- type Tool
- type UIAction
- type UIContext
- type UpdateMemory
- type UpdateMemoryArgs
- type WriteFile
- type WriteFileArgs
- type WriteFileResult
Constants ¶
const ( // ExternalToolPrefix prefixes the names of tools contributed by external MCP servers. ExternalToolPrefix = "mcp__" // ErrorCodeMCPAuthorizationRequired is the error code in the JSON error emitted when a user must authorize a server. ErrorCodeMCPAuthorizationRequired = "mcp_authorization_required" )
const ( MemoryOpAdd = "add" MemoryOpUpdate = "update" MemoryOpDelete = "delete" MemoryOpNoop = "noop" )
Memory operations.
const ( // MaxMemories is the maximum number of memories per (instance, owner). MaxMemories = 50 // MaxMemoryContentChars is the maximum length of a single memory. MaxMemoryContentChars = 300 )
Limits that bound the size of a user's memory.
const AnalystAgentName = "analyst_agent"
const ChartDataName = "chart_data"
const ClickUIName = "click_ui"
const CreateChartName = "create_chart"
const DevelopFileName = "develop_file"
const DeveloperAgentName = "developer_agent"
const FeedbackAgentName = "feedback_agent"
FeedbackAgentName is the name of the feedback agent.
const GetCanvasName = "get_canvas"
const GetMetricsViewName = "get_metrics_view"
const ListBucketObjectsName = "list_bucket_objects"
const ListBucketsName = "list_buckets"
const ListFilesName = "list_files"
const ListMetricsViewsName = "list_metrics_views"
const ListSkillsName = "list_skills"
const ListTablesName = "list_tables"
const LoadSkillName = "load_skill"
const MCPInstructions = `` /* 2172-byte string literal not displayed */
MCPInstructions are the instructions advertised by the MCP server. It is exported so the unified MCP server in the admin service, which serves all projects, can extend it instead of restating it.
const MemoryFeatureFlag = "chat_memory"
MemoryFeatureFlag is the feature flag that controls the memory feature. It can be disabled in rill.yaml.
const ProjectStatusName = "project_status"
const QueryMetricsViewName = "query_metrics_view"
const QueryMetricsViewSummaryName = "query_metrics_view_summary"
const QuerySQLName = "query_sql"
const ReadFileName = "read_file"
const RouterAgentName = "router_agent"
const (
SearchExternalToolsName = "search_external_tools"
)
const SearchFilesName = "search_files"
const ShowTableName = "show_table"
const UpdateMemoryName = "update_memory"
UpdateMemoryName is the name of the tool that lets the agents remember or forget something about the user.
const WriteFileName = "write_file"
Variables ¶
This section is empty.
Functions ¶
func DashboardFiltersFromContext ¶
func DashboardFiltersFromContext(ctx context.Context) map[string]*metricsview.Expression
DashboardFiltersFromContext returns the filters applied to the dashboard being analyzed, keyed by lower-cased metrics view name. It returns nil when the user is not viewing a filtered dashboard.
func ExternalToolName ¶
ExternalToolName returns the prefixed name used for a tool of an external server. Names are limited to the characters and length LLM providers accept. Sanitizing is lossy ("get.item" and "get_item" both become "get_item"), so whenever either part changes under sanitizing, or contains the "__" separator, a hash of the original identifiers is appended to keep distinct tools distinct. Over-long names are shortened in front of the same hash. With an empty tool, it returns the prefix shared by all of the server's tools.
func IsMCPAppOnlyTool ¶
IsMCPAppOnlyTool reports whether only the MCP Apps widget may call a tool (see mcpapp.ToolUI.AppOnly). Such tools should only be advertised by servers that serve the widget.
func MCPAppToolMeta ¶
MCPAppToolMeta returns the _meta.ui to register a tool with: the link to the widget when it is served (a may be nil), the visibility of an app-only tool regardless, and nil for tools without a UI. It is exported for the unified MCP server in the admin service, which advertises the tools without being able to run them.
func MCPToolSpecs ¶ added in v0.90.0
MCPToolSpecs returns the specs of all registered tools as advertised on MCP servers, keyed by name (see CompiledTool.mcpSpec). The specs are copies owned by the caller, so they may be extended, for example with extra input properties or _meta. It is used by the unified MCP server in the admin service, which advertises the tools without being able to run them.
func MCPUserAgent ¶
MCPUserAgent returns the user agent to record for an MCP client: the one it reports, or "mcp/unknown" when it reports none. MCP clients are external by definition, so a user agent that would pass for one of Rill's own clients is prefixed with "mcp/". Otherwise a client named, say, "rill-cli" would put its session in in-app mode (see isRillUserAgent): the MCP server would offer it the tools of Rill's own chat, and the session would be listed among the user's in-app conversations. The prefix is matched case-insensitively, since that listing matches user agents with a SQL LIKE.
func MemoryAvailable ¶
func MemoryAvailable(ctx context.Context, rt *runtime.Runtime, instanceID string, claims *runtime.SecurityClaims) (bool, error)
MemoryAvailable reports whether memory is available to the given claims in an instance. It is false for users without the AI permission, for anonymous users, and when the chat_memory feature flag is off.
func MemoryEnabledByUser ¶
func MemoryEnabledByUser(ctx context.Context, catalog drivers.CatalogStore, ownerID string) (bool, error)
MemoryEnabledByUser reports whether the owner has memory turned on. It is on until the owner turns it off.
func NewInternalError ¶
NewInternalError creates a new internal error. See InternalError for details.
func NewTextCompletionMessage ¶
func NewTextCompletionMessage(role Role, content string) *aiv1.CompletionMessage
NewTextCompletionMessage is a utility function for creating a text completion message.
func RegisterTool ¶
RegisterTool registers a new tool with the Runner.
func SanitizeMemoryContent ¶
SanitizeMemoryContent prepares content for storage. It runs on every write path, so stored content never needs cleaning when rendered. It strips angle brackets, then trims and collapses all whitespace (including newlines) to single spaces, so a memory is always a single line that cannot close the <user_memory> block it is rendered in.
func WithDashboardFilters ¶
func WithDashboardFilters(ctx context.Context, filters map[string]*metricsview.Expression) context.Context
WithDashboardFilters records the filters applied to the dashboard the user is viewing, keyed by metrics view name. The analyst agent sets it for its completion loop so that tools can check their arguments against the dashboard's filters. Empty filters are dropped, so a metrics view is present only if a filter actually applies to it. Resource names are case-insensitive, so the keys are lower-cased.
func WithSession ¶
WithSession adds a session to a context.
Types ¶
type AddMessageOptions ¶
type AddMessageOptions struct {
Role Role
Type MessageType
Tool string
ContentType MessageContentType
Content string
}
AddMessageOptions provides options for Session.AddMessage.
type AnalystAgent ¶
func (*AnalystAgent) CheckAccess ¶
func (t *AnalystAgent) CheckAccess(ctx context.Context) (bool, error)
func (*AnalystAgent) Handler ¶
func (t *AnalystAgent) Handler(ctx context.Context, args *AnalystAgentArgs) (*AnalystAgentResult, error)
func (*AnalystAgent) Spec ¶
func (t *AnalystAgent) Spec() *mcp.Tool
type AnalystAgentArgs ¶
type AnalystAgentArgs struct {
Prompt string `json:"prompt"`
Explore string `` /* 149-byte string literal not displayed */
Dimensions []string `` /* 161-byte string literal not displayed */
Measures []string `` /* 153-byte string literal not displayed */
Canvas string `` /* 133-byte string literal not displayed */
CanvasComponent string `` /* 173-byte string literal not displayed */
WherePerMetricsView map[string]*metricsview.Expression `` /* 203-byte string literal not displayed */
Where *metricsview.Expression `` /* 134-byte string literal not displayed */
TimeStart time.Time `` /* 144-byte string literal not displayed */
TimeEnd time.Time `` /* 138-byte string literal not displayed */
ComparisonTimeStart time.Time `json:"comparison_time_start" yaml:"comparison_time_start" jsonschema:"Optional comparison period start time."`
ComparisonTimeEnd time.Time `json:"comparison_time_end" yaml:"comparison_time_end" jsonschema:"Optional comparison period end time."`
DisableCharts bool `json:"disable_charts" yaml:"disable_charts" jsonschema:"Flag indicating whether to disable chart creation in the analysis."`
IsReport bool `json:"is_report" yaml:"is_report" jsonschema:"Flag indicating this is an automated report."`
}
func (*AnalystAgentArgs) ToLLM ¶
func (a *AnalystAgentArgs) ToLLM() *aiv1.ContentBlock
type AnalystAgentResult ¶
type AnalystAgentResult struct {
Response string `json:"response"`
}
func (*AnalystAgentResult) ToLLM ¶
func (r *AnalystAgentResult) ToLLM() *aiv1.ContentBlock
type BaseSession ¶
type BaseSession struct {
// contains filtered or unexported fields
}
BaseSession contains the session implementation that is not specific to the current call.
func (*BaseSession) CatalogSession ¶
func (s *BaseSession) CatalogSession() *drivers.AISession
func (*BaseSession) Claims ¶
func (s *BaseSession) Claims() *runtime.SecurityClaims
func (*BaseSession) ExpandMessages ¶
func (s *BaseSession) ExpandMessages(msgs []*Message, fn func(m *Message) []*Message) []*Message
func (*BaseSession) ExternalServerPromptData ¶
ExternalServerPromptData returns template data describing the external servers for the given agent's prompt.
func (*BaseSession) ExternalServers ¶
func (s *BaseSession) ExternalServers(ctx context.Context) []*ExternalServer
ExternalServers returns the external MCP servers available to the session's user, discovering them on first use. Discovery is best-effort: a server that cannot be reached is returned with Err set and no tools.
func (*BaseSession) ExternalToolNames ¶
func (s *BaseSession) ExternalToolNames(ctx context.Context, agent string) []string
ExternalToolNames returns the names of the external tools available to the given agent, sorted for stable prompts.
func (*BaseSession) FeatureFlags ¶
FeatureFlags returns the feature flags resolved for the session's instance and claims. They are resolved on the first call and cached for the lifetime of the session (an MCP session lives for one request), since the MCP server and the access checks of several tools consult them. The returned map must not be modified.
func (*BaseSession) Forked ¶ added in v0.79.0
func (s *BaseSession) Forked() bool
func (*BaseSession) ID ¶
func (s *BaseSession) ID() string
func (*BaseSession) InstanceID ¶
func (s *BaseSession) InstanceID() string
func (*BaseSession) LatestMessage ¶
func (s *BaseSession) LatestMessage(predicates ...Predicate) (*Message, bool)
func (*BaseSession) LatestRootCall ¶
func (s *BaseSession) LatestRootCall() *Message
func (*BaseSession) MemoryEnabled ¶
func (s *BaseSession) MemoryEnabled() bool
MemoryEnabled reports whether memory applies to this session: its memories are injected into prompts and new ones may be written. It is false when memory is not available to the owner and when the owner has turned memory off (see loadUserMemories).
func (*BaseSession) Message ¶
func (s *BaseSession) Message(predicates ...Predicate) (*Message, bool)
func (*BaseSession) Messages ¶
func (s *BaseSession) Messages(predicates ...Predicate) []*Message
func (*BaseSession) MessagesWithChildren ¶
func (s *BaseSession) MessagesWithChildren(predicates ...Predicate) []*Message
func (*BaseSession) MessagesWithDescendents ¶
func (s *BaseSession) MessagesWithDescendents(predicates ...Predicate) []*Message
func (*BaseSession) MessagesWithResults ¶
func (s *BaseSession) MessagesWithResults(predicates ...Predicate) []*Message
func (*BaseSession) NextIndex ¶
func (s *BaseSession) NextIndex() int
func (*BaseSession) ProjectInstructions ¶
func (s *BaseSession) ProjectInstructions() string
func (*BaseSession) Shared ¶ added in v0.79.0
func (s *BaseSession) Shared() bool
func (*BaseSession) Skills ¶ added in v0.90.0
func (s *BaseSession) Skills(ctx context.Context) ([]*Skill, error)
Skills lazily loads the project's skills from the catalog, memoizing the result for the lifetime of the session.
func (*BaseSession) Subscribe ¶
func (s *BaseSession) Subscribe() chan *Message
func (*BaseSession) Title ¶
func (s *BaseSession) Title() string
func (*BaseSession) Unsubscribe ¶
func (s *BaseSession) Unsubscribe(ch chan *Message)
func (*BaseSession) UpdateSharedUntilMessageID ¶ added in v0.79.0
func (s *BaseSession) UpdateSharedUntilMessageID(ctx context.Context, messageID string) error
func (*BaseSession) UpdateTitle ¶
func (s *BaseSession) UpdateTitle(ctx context.Context, title string) error
func (*BaseSession) UpdateUserAgent ¶
func (s *BaseSession) UpdateUserAgent(ctx context.Context, userAgent string) error
func (*BaseSession) UserMemories ¶
func (s *BaseSession) UserMemories() []*drivers.AIMemory
UserMemories returns the owner's memories. It is empty when memory is not enabled.
func (*BaseSession) WithParent ¶
func (s *BaseSession) WithParent(messageID string) *Session
type CallOptions ¶
type CallOptions struct {
Role Role
Name string
Unwrap bool
Out any
Args any
Handler func(context.Context) (any, error)
}
CallOptions provides options for Session.Call.
type CallResult ¶
CallResult contains the messages created during a tool call.
type CallToolOptions ¶
CallToolOptions provides options for Session.CallTool.
type ChartData ¶
ChartData returns the data of a chart without creating a chart in the conversation. It is an app-only tool: the MCP Apps widget calls it (through the host) to refetch data when the user changes the time grain, limits or comparison of a chart created with create_chart. Its _meta.ui marks it app-only, so hosts that support MCP Apps hide it from the model; its description tells other clients not to call it directly.
func (*ChartData) DecorateMCPResult ¶
func (t *ChartData) DecorateMCPResult(ctx context.Context, out *ChartDataOutput, res *mcp.CallToolResult)
DecorateMCPResult replaces the text content the SDK would derive from the result, which repeats all of structuredContent, with a one-line summary: the widget renders from structuredContent, and the model is not meant to see the result.
func (*ChartData) Handler ¶
func (t *ChartData) Handler(ctx context.Context, args ChartDataArgs) (*ChartDataOutput, error)
func (*ChartData) MCPAppUI ¶
MCPAppUI restricts chart_data to the widget: hosts hide tools with app visibility from the model. Being app-only also makes its calls plumbing rather than conversation turns (see MCPAppTool).
func (*ChartData) Spec ¶
Spec defines the tool for MCP clients only: Rill's own clients fetch chart data themselves (see CheckAccess). The input schema is deliberately minimal, since hosts without MCP Apps list the tool to the model, which should not call it, and every byte of a tool list is sent with each request. The arguments are validated by the handler like those of create_chart.
type ChartDataArgs ¶
ChartDataArgs are the arguments of chart_data, which are the same as those of create_chart.
type ChartDataOutput ¶
type ChartDataOutput struct {
Input *ChartInput `json:"input,omitempty"`
*ChartDataResult
}
ChartDataOutput is the result of chart_data: the data section of a create_chart result and the effective input (see ChartInput), so that the widget shows the limits and the grain that were applied.
type ChartDataResult ¶
type ChartDataResult struct {
TimeGrain string `json:"time_grain,omitempty"`
Data []map[string]any `json:"data,omitzero"`
Fields map[string]*ChartField `json:"fields,omitempty"`
// SemanticTypes and FieldDisplayNames are the per-field inputs of the Flint chart compiler (see chartSemantics),
// including the comparison values of the measures when a comparison is set.
SemanticTypes map[string]string `json:"semantic_types,omitempty"`
FieldDisplayNames map[string]string `json:"field_display_names,omitempty"`
DomainValues map[string][]any `json:"domain_values,omitempty"`
Totals map[string]any `json:"totals,omitempty"`
ResolvedTimeRange *chartquery.TimeRange `json:"resolved_time_range,omitempty"`
ResolvedComparisonTimeRange *chartquery.TimeRange `json:"resolved_comparison_time_range,omitempty"`
// Truncated reports any truncation (top-N or rows); RowsTruncated reports that rows were cut,
// in which case a temporal chart keeps its newest buckets (see chartquery.Output).
Truncated bool `json:"truncated,omitempty"`
RowsTruncated bool `json:"rows_truncated,omitempty"`
TruncationWarning string `json:"truncation_warning,omitempty"`
}
ChartDataResult is the chart-ready data shared by create_chart (for external clients) and chart_data. Rows are keyed by field name; comparison values are under <measure>_prev and temporal values are RFC3339 UTC strings. Data is always present when the data was queried, as [] when there are no rows, so that a renderer can tell an empty chart from a result without data. It is tagged omitzero rather than omitempty for that: a nil slice (never produced by chartquery) is omitted while an empty one is kept, and the inferred output schema keeps it optional, which the MCP server's output validation needs for in-app results, whose embedded ChartDataResult is nil.
type ChartField ¶
type ChartField struct {
Name string `json:"name"`
// Kind is "measure", "dimension" or "time".
Kind string `json:"kind"`
DisplayName string `json:"display_name,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
FormatPreset string `json:"format_preset,omitempty"`
FormatD3 string `json:"format_d3,omitempty"`
FormatD3Locale map[string]any `json:"format_d3_locale,omitempty"`
LowerIsBetter bool `json:"lower_is_better,omitempty"`
}
ChartField describes a metrics view field used by a chart, with what a renderer needs to label and format it.
type ChartInput ¶
type ChartInput struct {
ChartSpec map[string]any `json:"chart_spec"`
Data map[string]any `json:"data"`
SemanticTypes map[string]any `json:"semantic_types,omitempty"`
}
ChartInput is the effective Flint input echoed in a create_chart or chart_data result: the chart spec with the applied top-N limits, the data binding with the resolved grain, and the caller's semantic type overrides, so that the widget sends them back when it refetches the data.
type ChartMetricsView ¶
type ChartMetricsView struct {
Name string `json:"name"`
DisplayName string `json:"display_name,omitempty"`
TimeDimension string `json:"time_dimension,omitempty"`
SmallestTimeGrain string `json:"smallest_time_grain,omitempty"`
}
ChartMetricsView summarizes the metrics view a chart is built on.
type ClickUI ¶
type ClickUI struct{}
func (*ClickUI) Handler ¶
func (t *ClickUI) Handler(ctx context.Context, args *ClickUIArgs) (*ClickUIResult, error)
type ClickUIArgs ¶
type ClickUIArgs struct {
ActionID string `json:"action_id" jsonschema:"Exact ID of a currently available UI action. Only use IDs provided in the current UI context."`
}
type ClickUIResult ¶
type ClickUIResult struct{}
type ColumnInfo ¶ added in v0.79.0
type CompiledTool ¶
type CompiledTool struct {
Name string
Spec *mcp.Tool
CheckAccess func(context.Context) (bool, error)
UnmarshalArgs func(content string) (any, error)
UnmarshalResult func(content string) (any, error)
JSONHandler func(ctx context.Context, input json.RawMessage) (json.RawMessage, error)
// RegisterWithMCPServer registers the tool on an MCP server.
// A non-nil meta is merged into the _meta of a shallow copy of the spec, so Spec itself (and AsProto) never carries it.
RegisterWithMCPServer func(srv *mcp.Server, meta map[string]any)
// MCPSpec is set for tools that implement MCPSpecProvider; see mcpSpec.
MCPSpec *mcp.Tool
// AppUI is set for tools that implement MCPAppTool.
AppUI *mcpapp.ToolUI
}
CompiledTool is the internal representation of a registered tool.
type CompleteOptions ¶
type CompleteOptions struct {
Messages []*aiv1.CompletionMessage
Tools []string
MaxIterations int
// The complete loop will add intermediate messages for LLM thinking and tool calls to session under the current call.
// In some cases, it's desirable to capture these intermediate messages in the parent call's context, in other cases it's better to isolate them and only expose the final result to the parent context.
// When UnwrapCall is true, we run the completion loop within the current call, otherwise we wrap the complete loop in a new call to isolate internal messages.
UnwrapCall bool
}
CompleteOptions provides options for Session.Complete.
type CreateChart ¶
func (*CreateChart) CheckAccess ¶
func (t *CreateChart) CheckAccess(ctx context.Context) (bool, error)
func (*CreateChart) DecorateMCPResult ¶
func (t *CreateChart) DecorateMCPResult(ctx context.Context, out *CreateChartResult, res *mcp.CallToolResult)
DecorateMCPResult renders the chart as markdown for MCP clients that cannot render the widget: a title line with the time range, a table of the first rows, the row count and the link to open the chart in Rill.
func (*CreateChart) Handler ¶
func (t *CreateChart) Handler(ctx context.Context, args CreateChartArgs) (*CreateChartResult, error)
func (*CreateChart) MCPAppUI ¶
func (t *CreateChart) MCPAppUI() *mcpapp.ToolUI
MCPAppUI links create_chart to the MCP Apps widget, which renders the chart from the result.
func (*CreateChart) MCPSpec ¶
func (t *CreateChart) MCPSpec() *mcp.Tool
MCPSpec is the definition advertised on the MCP server: the Flint shape of the arguments (a chart spec of chart type and channel bindings plus a data block naming the metrics view), described from the embedded chart catalog. See chart_flint.go.
func (*CreateChart) Spec ¶
func (t *CreateChart) Spec() *mcp.Tool
Spec is the in-app definition of the tool: Rill's own chart types and spec vocabulary, which the in-app chat renders itself. External MCP clients get the Flint shape instead (see MCPSpec).
type CreateChartArgs ¶
type CreateChartResult ¶
type CreateChartResult struct {
// Widget selects the mode of the MCP Apps widget bundle.
Widget string `json:"widget"`
ChartType string `json:"chart_type"`
// Spec is the chart spec of an in-app result; Input is the effective input of an external one (see ChartInput).
Spec map[string]any `json:"spec,omitempty"`
Input *ChartInput `json:"input,omitempty"`
Message string `json:"message"`
Title string `json:"title,omitempty"`
MetricsView *ChartMetricsView `json:"metrics_view,omitempty"`
*ChartDataResult
// Theme is the protojson form of the project's default theme spec, when the project has one.
Theme map[string]any `json:"theme,omitempty"`
OpenURL string `json:"open_url,omitempty"`
}
CreateChartResult is the result of create_chart. The in-app chat renders the chart from the spec and fetches the data itself, so it only receives the widget mode, chart type, spec and message. External MCP clients cannot query Rill, so their result carries the effective Flint input instead of the spec (see ChartInput), the chart-ready data (see ChartDataResult), the field metadata needed to format it, the project theme and a link that opens the chart in Rill. The fields a result does not carry are omitted.
type DevelopFile ¶ added in v0.80.0
func (*DevelopFile) CheckAccess ¶ added in v0.80.0
func (t *DevelopFile) CheckAccess(ctx context.Context) (bool, error)
func (*DevelopFile) Handler ¶ added in v0.80.0
func (t *DevelopFile) Handler(ctx context.Context, args *DevelopFileArgs) (*DevelopFileResult, error)
func (*DevelopFile) Spec ¶ added in v0.80.0
func (t *DevelopFile) Spec() *mcp.Tool
type DevelopFileArgs ¶ added in v0.80.0
type DevelopFileResult ¶ added in v0.80.0
type DevelopFileResult struct {
Response string `json:"response" jsonschema:"The developer's response summarizing the actions taken."`
}
type DeveloperAgent ¶
func (*DeveloperAgent) CheckAccess ¶
func (t *DeveloperAgent) CheckAccess(ctx context.Context) (bool, error)
func (*DeveloperAgent) Handler ¶
func (t *DeveloperAgent) Handler(ctx context.Context, args *DeveloperAgentArgs) (*DeveloperAgentResult, error)
func (*DeveloperAgent) Spec ¶
func (t *DeveloperAgent) Spec() *mcp.Tool
type DeveloperAgentArgs ¶
type DeveloperAgentArgs struct {
Prompt string `json:"prompt" jsonschema:"User prompt for the developer agent."`
InitProject bool `` /* 243-byte string literal not displayed */
CurrentFilePath string `json:"current_file_path,omitempty" jsonschema:"Optional path to the file that the user is currently viewing/editing."`
}
type DeveloperAgentResult ¶
type DeveloperAgentResult struct {
Response string `json:"response"`
}
type ExternalAuthorizationRequiredError ¶
type ExternalAuthorizationRequiredError struct {
Connector string `json:"connector"`
DisplayName string `json:"display_name"`
}
ExternalAuthorizationRequiredError is returned by an external tool when the user must (re)authorize the server. Its message is a JSON envelope: the chat UI recognizes it to show a Connect card, and the LLM can read the explanation.
func (*ExternalAuthorizationRequiredError) Error ¶
func (e *ExternalAuthorizationRequiredError) Error() string
type ExternalServer ¶
type ExternalServer struct {
Connector string
DisplayName string
Instructions string
// Agents the server is scoped to. Empty means all agents.
Agents []string
// OAuth is true if the server requires a per-user OAuth authorization.
OAuth bool
// Authorized is true if the user has granted the server an OAuth authorization that Rill still holds.
// Unlike Connected, it does not depend on the server being reachable, so the user can disconnect a server that is down.
// It is only set for servers with OAuth.
Authorized bool
// Connected is true if the server can be used by the user right now. It is always true for reachable servers without OAuth.
Connected bool
// Tools the server exposes to the user, after applying the connector's security policy.
Tools []*drivers.MCPTool
// Compiled are the Tools compiled for use by the agents, keyed by their prefixed name.
Compiled map[string]*CompiledTool
// Err is set if the server could not be reached or its tools could not be listed.
Err error
// contains filtered or unexported fields
}
ExternalServer describes an external MCP server from the perspective of a specific user.
func (*ExternalServer) AllowsAgent ¶
func (s *ExternalServer) AllowsAgent(agent string) bool
AllowsAgent reports whether the server may be used by the named agent.
type ExternalToolInfo ¶
type ExternalToolInfo struct {
Name string `json:"name"`
Server string `json:"server"`
Description string `json:"description,omitempty"`
}
ExternalToolInfo describes a loaded external tool. Its input schema is not included: the LLM gets it as a tool definition.
type ExternalToolResult ¶
type ExternalToolResult struct {
Content string `json:"content,omitempty"`
StructuredContent json.RawMessage `json:"structured_content,omitempty"`
Truncated bool `json:"truncated,omitempty"`
}
ExternalToolResult is the result of an external tool call as seen by the LLM and the chat UI.
type FeedbackAgent ¶ added in v0.82.0
FeedbackAgent handles user feedback on AI responses. For negative feedback, it runs attribution to help triage issues.
func (*FeedbackAgent) CheckAccess ¶ added in v0.82.0
func (t *FeedbackAgent) CheckAccess(ctx context.Context) (bool, error)
func (*FeedbackAgent) Handler ¶ added in v0.82.0
func (t *FeedbackAgent) Handler(ctx context.Context, args *FeedbackAgentArgs) (*FeedbackAgentResult, error)
func (*FeedbackAgent) Spec ¶ added in v0.82.0
func (t *FeedbackAgent) Spec() *mcp.Tool
type FeedbackAgentArgs ¶ added in v0.82.0
type FeedbackAgentArgs struct {
TargetMessageID string `json:"target_message_id" jsonschema:"The ID of the message being rated."`
Sentiment string `json:"sentiment" jsonschema:"The sentiment of the feedback: positive or negative.,enum=positive,enum=negative"`
Categories []string `json:"categories,omitempty" jsonschema:"Feedback categories (only for negative sentiment)."`
Comment string `json:"comment,omitempty" jsonschema:"Optional free-text comment."`
}
FeedbackAgentArgs represents the input arguments for the feedback agent.
type FeedbackAgentResult ¶ added in v0.82.0
type FeedbackAgentResult struct {
Response string `json:"response"`
PredictedAttribution string `json:"predicted_attribution,omitempty"`
AttributionReasoning string `json:"attribution_reasoning,omitempty"`
SuggestedAction *string `json:"suggested_action,omitempty"`
}
FeedbackAgentResult represents the result of recording user feedback. For negative feedback, includes attribution prediction for analytics and LLM context.
type GetCanvas ¶ added in v0.82.0
func (*GetCanvas) CheckAccess ¶ added in v0.82.0
func (*GetCanvas) Handler ¶ added in v0.82.0
func (t *GetCanvas) Handler(ctx context.Context, args *GetCanvasArgs) (*GetCanvasResult, error)
type GetCanvasArgs ¶ added in v0.82.0
type GetCanvasArgs struct {
Canvas string `json:"canvas" jsonschema:"Name of the canvas"`
}
type GetCanvasResult ¶ added in v0.82.0
type GetMetricsView ¶
func (*GetMetricsView) CheckAccess ¶
func (t *GetMetricsView) CheckAccess(ctx context.Context) (bool, error)
func (*GetMetricsView) Handler ¶
func (t *GetMetricsView) Handler(ctx context.Context, args *GetMetricsViewArgs) (*GetMetricsViewResult, error)
func (*GetMetricsView) Spec ¶
func (t *GetMetricsView) Spec() *mcp.Tool
type GetMetricsViewArgs ¶
type GetMetricsViewArgs struct {
MetricsView string `json:"metrics_view" jsonschema:"Name of the metrics view"`
}
type GetMetricsViewResult ¶
type InternalError ¶
type InternalError struct {
// contains filtered or unexported fields
}
InternalError represents an internal error in a tool call. This is needed because by default, downstream logic (such as the MCP middleware) treats errors returned from tool handlers as user errors, not internal errors.
func (InternalError) Error ¶
func (e InternalError) Error() string
Error implements the error interface.
type LLMMarshaler ¶
type LLMMarshaler interface {
ToLLM() *aiv1.ContentBlock
}
LLMMarshaler is an interface for tool args and results types that want to customize their serialization to LLM content blocks. It is not used for tool calls/results invoked by the assistant, only for user-invoked calls/results.
type ListBucketObjects ¶ added in v0.79.0
func (*ListBucketObjects) CheckAccess ¶ added in v0.79.0
func (t *ListBucketObjects) CheckAccess(ctx context.Context) (bool, error)
func (*ListBucketObjects) Handler ¶ added in v0.79.0
func (t *ListBucketObjects) Handler(ctx context.Context, args *ListBucketObjectsArgs) (*ListBucketObjectsResult, error)
func (*ListBucketObjects) Spec ¶ added in v0.79.0
func (t *ListBucketObjects) Spec() *mcp.Tool
type ListBucketObjectsArgs ¶ added in v0.79.0
type ListBucketObjectsArgs struct {
Connector string `json:"connector" jsonschema:"The name of an object store connector (e.g., s3, gcs, azure)."`
Bucket string `json:"bucket" jsonschema:"The bucket name to list objects from."`
Path string `` /* 167-byte string literal not displayed */
PageSize int `json:"page_size,omitempty" jsonschema:"Maximum number of objects to return. Defaults to 10."`
PageToken string `json:"page_token,omitempty" jsonschema:"Token for pagination. Use next_page_token from previous response to get next page."`
}
type ListBucketObjectsResult ¶ added in v0.79.0
type ListBucketObjectsResult struct {
Objects []ObjectInfo `json:"objects"`
NextPageToken string `json:"next_page_token,omitempty"`
}
type ListBuckets ¶ added in v0.79.0
func (*ListBuckets) CheckAccess ¶ added in v0.79.0
func (t *ListBuckets) CheckAccess(ctx context.Context) (bool, error)
func (*ListBuckets) Handler ¶ added in v0.79.0
func (t *ListBuckets) Handler(ctx context.Context, args *ListBucketsArgs) (*ListBucketsResult, error)
func (*ListBuckets) Spec ¶ added in v0.79.0
func (t *ListBuckets) Spec() *mcp.Tool
type ListBucketsArgs ¶ added in v0.79.0
type ListBucketsArgs struct {
Connector string `json:"connector" jsonschema:"The name of an object store connector (e.g., s3, gcs, azure)."`
}
type ListBucketsResult ¶ added in v0.79.0
type ListBucketsResult struct {
Buckets []string `json:"buckets"`
}
type ListFiles ¶
func (*ListFiles) Handler ¶
func (t *ListFiles) Handler(ctx context.Context, args *ListFilesArgs) (*ListFilesResult, error)
type ListFilesArgs ¶
type ListFilesArgs struct{}
type ListFilesResult ¶
type ListMetricsViews ¶
func (*ListMetricsViews) CheckAccess ¶
func (t *ListMetricsViews) CheckAccess(ctx context.Context) (bool, error)
func (*ListMetricsViews) Handler ¶
func (t *ListMetricsViews) Handler(ctx context.Context, args *ListMetricsViewsArgs) (*ListMetricsViewsResult, error)
func (*ListMetricsViews) Spec ¶
func (t *ListMetricsViews) Spec() *mcp.Tool
type ListMetricsViewsArgs ¶
type ListMetricsViewsArgs struct{}
type ListMetricsViewsResult ¶
type ListSkills ¶ added in v0.90.0
func (*ListSkills) CheckAccess ¶ added in v0.90.0
func (t *ListSkills) CheckAccess(ctx context.Context) (bool, error)
func (*ListSkills) Handler ¶ added in v0.90.0
func (t *ListSkills) Handler(ctx context.Context, args *ListSkillsArgs) (*ListSkillsResult, error)
func (*ListSkills) Spec ¶ added in v0.90.0
func (t *ListSkills) Spec() *mcp.Tool
type ListSkillsArgs ¶ added in v0.90.0
type ListSkillsArgs struct{}
type ListSkillsResult ¶ added in v0.90.0
type ListSkillsResult struct {
Skills []*SkillInfo `json:"skills"`
}
type ListTables ¶ added in v0.79.0
func (*ListTables) CheckAccess ¶ added in v0.79.0
func (t *ListTables) CheckAccess(ctx context.Context) (bool, error)
func (*ListTables) Handler ¶ added in v0.79.0
func (t *ListTables) Handler(ctx context.Context, args *ListTablesArgs) (*ListTablesResult, error)
func (*ListTables) Spec ¶ added in v0.79.0
func (t *ListTables) Spec() *mcp.Tool
type ListTablesArgs ¶ added in v0.79.0
type ListTablesArgs struct {
Connector string `json:"connector,omitempty" jsonschema:"Optional OLAP connector name. Defaults to the instance's default OLAP connector."`
SearchPattern string `json:"search_pattern,omitempty" jsonschema:"Optional pattern to filter table names (uses SQL LIKE syntax)."`
PageSize int `json:"page_size,omitempty" jsonschema:"Maximum number of tables to return. Defaults to 100."`
PageToken string `json:"page_token,omitempty" jsonschema:"Token for pagination. Use next_page_token from previous response to get next page."`
}
type ListTablesResult ¶ added in v0.79.0
type LoadSkill ¶ added in v0.90.0
func (*LoadSkill) CheckAccess ¶ added in v0.90.0
func (*LoadSkill) Handler ¶ added in v0.90.0
func (t *LoadSkill) Handler(ctx context.Context, args *LoadSkillArgs) (*LoadSkillResult, error)
type LoadSkillArgs ¶ added in v0.90.0
type LoadSkillArgs struct {
Name string `json:"name" jsonschema:"Name of the skill to load"`
}
type LoadSkillResult ¶ added in v0.90.0
type MCPAppTool ¶
MCPAppTool is an optional interface for tools that take part in the MCP Apps widget (see package mcpapp). The returned UI drives the _meta.ui the tool is registered with on the MCP server. App-only tools (see mcpapp.ToolUI.AppOnly) are called by the widget rather than the model, so their calls are plumbing: they are not added to the session's messages. They still count in the tool_call metric, since they run real queries (see CallToolWithOptions).
type MCPResultDecorator ¶
type MCPResultDecorator[Out any] interface { DecorateMCPResult(ctx context.Context, out Out, res *mcp.CallToolResult) }
MCPResultDecorator is an optional interface for tools that customize the MCP representation of their result. The MCP SDK fills structuredContent from the result as usual; the decorator can set the content blocks (for example a markdown rendering for clients that cannot show the structured result) and the result's _meta. It only affects the MCP server: the result persisted in the session and sent to the in-app LLM is unchanged.
type MCPSpecProvider ¶
MCPSpecProvider is an optional interface for tools whose definition on the MCP server differs from their in-app definition. The MCP server (and the admin service's unified MCP server, see MCPToolSpecs) advertises and validates against the spec it returns, while Spec stays what the in-app LLM sees (see AsProto). The returned spec inherits the in-app input and output schemas where it sets none.
type MemoryUpdateResult ¶
type MemoryUpdateResult struct {
Op string `json:"op" jsonschema:"The operation that was applied: add, update or delete; noop if nothing changed."`
MemoryID int64 `json:"memory_id,omitempty" jsonschema:"ID of the memory that was added, updated or deleted."`
Content string `json:"content,omitempty" jsonschema:"The memory's content after the operation, or the content that was deleted."`
Reason string `json:"reason,omitempty" jsonschema:"Why the operation was rejected."`
}
MemoryUpdateResult is the outcome of update_memory: the operation that was applied, or a noop with the reason the operation was rejected. The frontend renders applied operations as a "Memory updated" notice.
type Message ¶
type Message struct {
// ID is unique for each message.
ID string `json:"id" yaml:"id"`
// ParentID is the ID of the parent message, usually the current tool call.
ParentID string `json:"parent_id" yaml:"parent_id"`
// SessionID is the ID of the session this message belongs to.
SessionID string `json:"session_id" yaml:"session_id"`
// Time the message was created.
Time time.Time `json:"time" yaml:"time"`
// Index of the message in the session. Used to order messages returned at the same time.
Index int `json:"index" yaml:"index"`
// Role is the actor that created the message.
Role Role `json:"role" yaml:"role"`
// Type is the type of the message.
// For any given call, there will be only one "result" or "error" message.
Type MessageType `json:"type" yaml:"type"`
// Tool is the name of the tool that emitted the message, if any.
Tool string `json:"tool"`
// ContentType is the type of the Content string.
ContentType MessageContentType `json:"content_type" yaml:"content_type"`
// Content is the content of the message.
Content string `json:"content" yaml:"content"`
// contains filtered or unexported fields
}
Message represents a message in an AI session. Unlike lower-level LLM messages, the messages here include a call hierarchy, enabling tracking of calls and results inside tool calls.
Mental model: - Messages represent user input, tool calls/results, LLM thinking, LLM responses. - Messages can be called by users, deterministic code, or LLMs. - LLM invocations retrieve messages from current scope for context.
type MessageContentType ¶
type MessageContentType string
MessageContentType is the type of content contained in a message.
const ( MessageContentTypeText MessageContentType = "text" MessageContentTypeJSON MessageContentType = "json" MessageContentTypeError MessageContentType = "error" )
type MessageType ¶
type MessageType string
MessageType is the type of message being sent.
const ( MessageTypeCall MessageType = "call" MessageTypeProgress MessageType = "progress" MessageTypeResult MessageType = "result" )
type Navigate ¶ added in v0.81.0
type Navigate struct{}
func (*Navigate) CheckAccess ¶ added in v0.81.0
func (*Navigate) Handler ¶ added in v0.81.0
func (t *Navigate) Handler(ctx context.Context, args *NavigateArgs) (*NavigateResult, error)
type NavigateArgs ¶ added in v0.81.0
type NavigateArgs struct {
}
type NavigateResult ¶ added in v0.81.0
type NavigateResult struct{}
type ObjectInfo ¶ added in v0.79.0
type Predicate ¶
func FilterByID ¶
func FilterByParent ¶
func FilterByRoot ¶
func FilterByRoot() Predicate
func FilterByTool ¶
func FilterByType ¶
func FilterByType(typ MessageType) Predicate
type ProjectStatus ¶ added in v0.79.0
func (*ProjectStatus) CheckAccess ¶ added in v0.79.0
func (t *ProjectStatus) CheckAccess(ctx context.Context) (bool, error)
func (*ProjectStatus) Handler ¶ added in v0.79.0
func (t *ProjectStatus) Handler(ctx context.Context, args *ProjectStatusArgs) (*ProjectStatusResult, error)
func (*ProjectStatus) Spec ¶ added in v0.79.0
func (t *ProjectStatus) Spec() *mcp.Tool
type ProjectStatusArgs ¶ added in v0.79.0
type ProjectStatusArgs struct {
WhereError bool `json:"where_error,omitempty" jsonschema:"Optional flag to only return resources that have reconcile errors."`
Kind string `` /* 229-byte string literal not displayed */
Name string `` /* 164-byte string literal not displayed */
Path string `json:"path,omitempty" jsonschema:"Optional filter to only return resources declared in the specified file path."`
WaitUntilIdle bool `` /* 243-byte string literal not displayed */
WaitUntilIdleTimeoutSeconds int `` /* 166-byte string literal not displayed */
TailLogsCount int `` /* 242-byte string literal not displayed */
}
type ProjectStatusResult ¶ added in v0.79.0
type ProjectStatusResult struct {
DefaultOLAPConnector string `` /* 160-byte string literal not displayed */
Env []string `` /* 131-byte string literal not displayed */
Resources []map[string]any `json:"resources" jsonschema:"List of resources and their status."`
ParseErrors []map[string]any `json:"parse_errors" jsonschema:"List of parse errors encountered when parsing project files."`
Logs []map[string]any `json:"logs,omitempty" jsonschema:"Log entries based on the tail_logs parameter, ordered oldest to newest."`
}
type QueryMetricsView ¶
func (*QueryMetricsView) CheckAccess ¶
func (t *QueryMetricsView) CheckAccess(ctx context.Context) (bool, error)
func (*QueryMetricsView) Handler ¶
func (t *QueryMetricsView) Handler(ctx context.Context, args QueryMetricsViewArgs) (*QueryMetricsViewResult, error)
func (*QueryMetricsView) Spec ¶
func (t *QueryMetricsView) Spec() *mcp.Tool
type QueryMetricsViewArgs ¶
type QueryMetricsViewResult ¶
type QueryMetricsViewResult struct {
Schema []SchemaField `json:"schema"`
Data [][]any `json:"data"`
// ResolvedTimeRange & ResolvedComparisonTimeRange store the exact time ranges used for the query.
// This helps when opening the citation url and get the exact time range for relative time ranges.
ResolvedTimeRange *metricsview.TimeRange `json:"resolved_time_range,omitempty"`
ResolvedComparisonTimeRange *metricsview.TimeRange `json:"resolved_comparison_time_range,omitempty"`
OpenURL string `json:"open_url,omitempty"`
TruncationWarning string `json:"truncation_warning,omitempty"`
}
type QueryMetricsViewSummary ¶
func (*QueryMetricsViewSummary) CheckAccess ¶
func (t *QueryMetricsViewSummary) CheckAccess(ctx context.Context) (bool, error)
func (*QueryMetricsViewSummary) Handler ¶
func (t *QueryMetricsViewSummary) Handler(ctx context.Context, args *QueryMetricsViewSummaryArgs) (*QueryMetricsViewSummaryResult, error)
func (*QueryMetricsViewSummary) Spec ¶
func (t *QueryMetricsViewSummary) Spec() *mcp.Tool
type QueryMetricsViewSummaryArgs ¶
type QueryMetricsViewSummaryArgs struct {
MetricsView string `json:"metrics_view" jsonschema:"Name of the metrics view"`
}
type QuerySQL ¶ added in v0.79.0
func (*QuerySQL) CheckAccess ¶ added in v0.79.0
func (*QuerySQL) Handler ¶ added in v0.79.0
func (t *QuerySQL) Handler(ctx context.Context, args *QuerySQLArgs) (*QuerySQLResult, error)
type QuerySQLArgs ¶ added in v0.79.0
type QuerySQLArgs struct {
Connector string `json:"connector,omitempty" jsonschema:"Optional OLAP connector name. Defaults to the instance's default OLAP connector."`
SQL string `` /* 276-byte string literal not displayed */
TimeoutSeconds int `json:"timeout_seconds,omitempty" jsonschema:"Query timeout in seconds. Defaults to 30."`
}
type QuerySQLResult ¶ added in v0.79.0
type QuerySQLResult struct {
Schema []SchemaField `json:"schema"`
Data [][]any `json:"data"`
TruncationWarning string `json:"truncation_warning,omitempty"`
}
type ReadFile ¶
func (*ReadFile) Handler ¶
func (t *ReadFile) Handler(ctx context.Context, args *ReadFileArgs) (*ReadFileResult, error)
type ReadFileArgs ¶
type ReadFileArgs struct {
Path string `json:"path" jsonschema:"The path of the file to read"`
}
type ReadFileResult ¶
type ReadFileResult struct {
Contents string
}
type RouterAgent ¶
RouterAgent accepts a human prompt and related context, determines which agent is best suited to handling it, and invokes that agent. It is usually the entrypoint for processing human completion requests.
func (*RouterAgent) CheckAccess ¶
func (t *RouterAgent) CheckAccess(ctx context.Context) (bool, error)
func (*RouterAgent) Handler ¶
func (t *RouterAgent) Handler(ctx context.Context, args *RouterAgentArgs) (*RouterAgentResult, error)
func (*RouterAgent) Spec ¶
func (t *RouterAgent) Spec() *mcp.Tool
type RouterAgentArgs ¶
type RouterAgentArgs struct {
Prompt string `json:"prompt" jsonschema:"The user's prompt to be routed."`
Agent string `` /* 131-byte string literal not displayed */
AnalystAgentArgs *AnalystAgentArgs `` /* 136-byte string literal not displayed */
DeveloperAgentArgs *DeveloperAgentArgs `` /* 142-byte string literal not displayed */
FeedbackAgentArgs *FeedbackAgentArgs `` /* 139-byte string literal not displayed */
SkipHandoff bool `` /* 158-byte string literal not displayed */
}
type RouterAgentResult ¶
type Runner ¶
type Runner struct {
Runtime *runtime.Runtime
Activity *activity.Client
Tools map[string]*CompiledTool
}
Runner tracks available tools and manages the lifecycle of AI sessions.
func (*Runner) DiscoverExternalServers ¶
func (r *Runner) DiscoverExternalServers(ctx context.Context, instanceID string, claims *runtime.SecurityClaims) ([]*ExternalServer, error)
DiscoverExternalServers lists the external MCP servers the user may use, listing and compiling their tools. Servers the user is denied by the connector's security policy are omitted entirely.
func (*Runner) ForkSession ¶ added in v0.79.0
ForkSession creates a new session cloned from an existing session.
type SchemaField ¶ added in v0.82.0
SchemaField represents a field a result's schema. Used to reduce result size through resolverResultToTabular.
type SearchExternalTools ¶
SearchExternalTools finds tools of the connected external MCP servers and loads them, so their full definitions are offered to the LLM from its next iteration on. External tools are loaded on demand to keep their schemas out of requests that don't need them, and to support servers with more tools than the LLM providers accept in one request.
func (*SearchExternalTools) CheckAccess ¶
func (t *SearchExternalTools) CheckAccess(ctx context.Context) (bool, error)
CheckAccess only allows the tool inside an agent with external tools. This also keeps it off Rill's own MCP server, which never exposes external tools.
func (*SearchExternalTools) Handler ¶
func (t *SearchExternalTools) Handler(ctx context.Context, args *SearchExternalToolsArgs) (*SearchExternalToolsResult, error)
func (*SearchExternalTools) Spec ¶
func (t *SearchExternalTools) Spec() *mcp.Tool
type SearchExternalToolsArgs ¶
type SearchExternalToolsArgs struct {
Names []string `json:"names,omitempty" jsonschema:"Exact names of tools to load, as listed in the system prompt."`
Query string `json:"query,omitempty" jsonschema:"Keywords describing the tools to find, such as 'create issue'."`
MaxResults int `json:"max_results,omitempty" jsonschema:"Maximum number of tools to return for the query. Defaults to 5."`
}
type SearchExternalToolsResult ¶
type SearchExternalToolsResult struct {
Tools []*ExternalToolInfo `json:"tools"`
NotFound []string `json:"not_found,omitempty"`
Message string `json:"message,omitempty"`
}
type SearchFiles ¶
func (*SearchFiles) CheckAccess ¶
func (t *SearchFiles) CheckAccess(ctx context.Context) (bool, error)
func (*SearchFiles) Handler ¶
func (t *SearchFiles) Handler(ctx context.Context, args *SearchFilesArgs) (*SearchFilesResult, error)
func (*SearchFiles) Spec ¶
func (t *SearchFiles) Spec() *mcp.Tool
type SearchFilesArgs ¶
type SearchFilesArgs struct {
Pattern string `json:"pattern" jsonschema:"The pattern to search for. Supports regular expressions."`
CaseSensitive bool `json:"case_sensitive,omitempty" jsonschema:"Whether the search should be case-sensitive. Defaults to false."`
GlobPattern string `` /* 152-byte string literal not displayed */
}
type SearchFilesResult ¶
type SearchFilesResult struct {
Matches []SearchMatch `json:"matches"`
}
type SearchMatch ¶
type Session ¶
type Session struct {
*BaseSession
ParentID string
}
Session wraps a BaseSession with a reference to the current call's parent message.
func GetSession ¶
GetSession retrieves a session from a context.
func (*Session) AddMessage ¶
func (s *Session) AddMessage(opts *AddMessageOptions) *Message
AddMessage adds a message linked to the current session's parent call.
func (*Session) Call ¶
func (s *Session) Call(ctx context.Context, opts *CallOptions) (*CallResult, error)
Call is the primary implementation for execution of tool calls. NOTE: This will be the primary implementation site for durable execution.
func (*Session) CallTool ¶
func (s *Session) CallTool(ctx context.Context, role Role, toolName string, out, args any) (*CallResult, error)
CallTool is a convenience wrapper around CallToolWithOptions that makes a normal assistant tool call.
func (*Session) CallToolWithOptions ¶
func (s *Session) CallToolWithOptions(ctx context.Context, opts *CallToolOptions) (*CallResult, error)
CallToolWithOptions runs a tool call in the current session and adds it, its result, and all messages from nested calls to the session.
func (*Session) Complete ¶
Complete runs LLM completions. If tools are provided, it runs a completion loop involving multiple LLM invocations. If the output pointer is not a string and not nil, it infers the output schema using reflection and instructs the LLM to produce structured output.
func (*Session) MCPServer ¶
MCPServer returns a new MCP server scoped to the current session. Since it is scoped to the session, a new MCP server should be created for each client connection. Using a separate MCP server for each client enables tailoring the server's instructions and available tools to the end user's claims. The session must be one recorded for an MCP client (see MCPUserAgent): a session of Rill's own chat gets the in-app tools, which are not meant for MCP clients (and the agents' input schemas do not even resolve as MCP tool schemas).
func (*Session) MustUnmarshalMessageContent ¶ added in v0.80.0
MustUnmarshalMessageContent is like UnmarshalMessageContent but panics on error. This should only be used in tests.
func (*Session) NewCompletionMessage ¶
func (s *Session) NewCompletionMessage(m *Message) (*aiv1.CompletionMessage, error)
NewCompletionMessage converts the message to an aiv1.CompletionMessage
func (*Session) NewCompletionMessages ¶
func (s *Session) NewCompletionMessages(msgs []*Message) []*aiv1.CompletionMessage
NewCompletionMessages is a utility function for creating a list of completion messages from a list of session messages. NOTE: To support chaining, it panics on serialization errors. TODO: Move to a better chaining setup that enables error propagation.
type SessionOptions ¶
type SessionOptions struct {
InstanceID string
SessionID string
// CreateIfNotExists creates the session if it does not exist.
// If SessionID is set, the session is created with that ID.
CreateIfNotExists bool
// Transient makes a new session in-memory only: it is not inserted in the catalog and Flush is a no-op.
// It serves MCP requests that are not part of a conversation (such as resources/list or ping from a client
// that has not sent a session ID), which would otherwise leave orphan sessions behind.
Transient bool
Claims *runtime.SecurityClaims
UserAgent string
}
SessionOptions provides options for initializing a new session.
type ShowTable ¶ added in v0.79.0
func (*ShowTable) CheckAccess ¶ added in v0.79.0
func (*ShowTable) Handler ¶ added in v0.79.0
func (t *ShowTable) Handler(ctx context.Context, args *ShowTableArgs) (*ShowTableResult, error)
type ShowTableArgs ¶ added in v0.79.0
type ShowTableArgs struct {
Connector string `json:"connector,omitempty" jsonschema:"Optional OLAP connector name. Defaults to the instance's default OLAP connector."`
Table string `` /* 153-byte string literal not displayed */
Database string `` /* 133-byte string literal not displayed */
DatabaseSchema string `` /* 145-byte string literal not displayed */
}
type ShowTableResult ¶ added in v0.79.0
type ShowTableResult struct {
Name string `json:"name"`
IsView bool `json:"is_view"`
Columns []ColumnInfo `json:"columns"`
PhysicalSizeBytes int64 `` /* 142-byte string literal not displayed */
DDL string `json:"ddl,omitempty" jsonschema:"The SQL DDL statement (CREATE TABLE/VIEW) for this table, if available."`
}
type Skill ¶ added in v0.90.0
type Skill struct {
Name string
Description string
MetricsViews []string
Agents []string
AlwaysApply bool
Body string
}
Skill is a user-defined instruction file that teaches Rill's AI agents project-specific practices, such as analysis playbooks, business glossaries, or development conventions. Skills are parsed from SKILL.md files into catalog resources; see runtime/parser/parse_skill.go.
type SkillInfo ¶ added in v0.90.0
type SkillInfo struct {
Name string `json:"name"`
Description string `json:"description"`
MetricsViews []string `json:"metrics_views,omitempty"`
Agents []string `json:"agents"`
AlwaysApply bool `json:"always_apply"`
}
SkillInfo describes a skill without its body. Use load_skill to fetch the full instructions.
type Tool ¶
type Tool[In, Out any] interface { Spec() *mcp.Tool CheckAccess(context.Context) (bool, error) Handler(ctx context.Context, args In) (Out, error) }
Tool is an interface for an AI tool.
type UIContext ¶
type UIContext struct {
Actions []UIAction `json:"actions"`
}
UIContext describes the safe UI actions available on the user's current page. It is transient request context and is not persisted in the conversation. The agents already know which dashboard or file the user is viewing from their own context, so no page identifier is carried here.
type UpdateMemory ¶
UpdateMemory is the tool through which the AI writes to the user's memory. The agents call it when the user states a durable preference or explicitly asks the AI to remember or forget something. A memory is scoped to the agent that learned it, so the analyst and the developer agent keep separate memories.
func (*UpdateMemory) CheckAccess ¶
func (t *UpdateMemory) CheckAccess(ctx context.Context) (bool, error)
func (*UpdateMemory) Handler ¶
func (t *UpdateMemory) Handler(ctx context.Context, args *UpdateMemoryArgs) (*MemoryUpdateResult, error)
Handler validates and applies the operation for the session's user. It is deterministic and never calls an LLM. A rejected operation is returned as a noop with a reason rather than as an error, so the agent can tell the user what happened.
func (*UpdateMemory) Spec ¶
func (t *UpdateMemory) Spec() *mcp.Tool
type UpdateMemoryArgs ¶
type WriteFile ¶
func (*WriteFile) Handler ¶
func (t *WriteFile) Handler(ctx context.Context, args *WriteFileArgs) (*WriteFileResult, error)
type WriteFileArgs ¶
type WriteFileResult ¶
type WriteFileResult struct {
Diff string `json:"diff,omitempty" jsonschema:"Diff of the file contents."`
IsNewFile bool `json:"is_new_file,omitempty" jsonschema:"Indicates if the tool created a new file."`
Resources []map[string]any `json:"resources,omitempty" jsonschema:"The Rill resources declared in the file, if any."`
ParseError string `json:"parse_error,omitempty" jsonschema:"Parse error encountered when parsing the file, if any."`
ParseWarnings []string `` /* 171-byte string literal not displayed */
}
Source Files
¶
- ai.go
- analyst_agent.go
- canvas_get.go
- chart_data.go
- chart_flint.go
- chart_semantics.go
- click_ui.go
- create_chart.go
- develop_file.go
- developer_agent.go
- external_tools.go
- external_tools_search.go
- feedback_agent.go
- file_list.go
- file_read.go
- file_search.go
- file_write.go
- list_bucket_objects.go
- list_buckets.go
- list_tables.go
- mcp.go
- memory.go
- memory_update.go
- metrics_view_get.go
- metrics_view_list.go
- metrics_view_query.go
- metrics_view_summary.go
- navigate.go
- project_status.go
- query_sql.go
- router_agent.go
- show_table.go
- skill_list.go
- skill_load.go
- skill_references.go
- skills.go
- ui_context.go
- util.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chartquery turns a Flint chart spec bound to a metrics view (the arguments external MCP clients pass to create_chart and chart_data) into the metrics view queries that fetch its data, and runs them within fixed budgets.
|
Package chartquery turns a Flint chart spec bound to a metrics view (the arguments external MCP clients pass to create_chart and chart_data) into the metrics view queries that fetch its data, and runs them within fixed budgets. |
|
Package mcpapp serves the MCP Apps widget that renders Rill charts inside MCP hosts such as Claude and ChatGPT.
|
Package mcpapp serves the MCP Apps widget that renders Rill charts inside MCP hosts such as Claude and ChatGPT. |