Documentation
¶
Index ¶
- Constants
- Variables
- func CatalogDetailIDs(resp Response) []string
- func ContainsMutationOperation(query string) bool
- func DefaultClientFactory(cfg Config) (ax.AIClient, error)
- func EffectiveTimeoutSeconds(timeoutSeconds int) int
- func MutationRootFields(query string) []string
- func PromptRegistryHash() string
- func ProtocolViolationCodes(resp Response) []string
- func QueryRootFields(query string) []string
- func SummarizeCatalogCards(cards []core.CatalogCard) []core.CatalogCard
- func TruncationMessage(roots []core.TruncatedRootInfo) string
- type ActionEvent
- type Agent
- type CapabilityProfile
- type CatalogSearchFeatures
- type ClientFactory
- type Config
- type ErrorInfo
- type GraphRuntime
- type Option
- type Program
- type ProgramFactory
- type Refusal
- type Request
- type Response
- type ResponseNotice
- type SkillUsage
- type TruncationInfo
- type Turn
- type UnblockStep
Constants ¶
const ( StatusAnswered = "answered" StatusNeedsClarification = "needs_clarification" StatusBlocked = "blocked" StatusError = "error" // MaxCatalogBatchIDs caps one batched query_catalog({ids: [...]}) call. MaxCatalogBatchIDs = 20 )
const ( // MaxCatalogCoverageSearches is the largest semantic coverage batch the // service-owned agent may request in one run. MaxCatalogCoverageSearches = 3 // MaxCatalogCoverageSearchBytes bounds each UTF-8 search phrase by its // encoded size so the internal tool contract remains predictable. MaxCatalogCoverageSearchBytes = 512 )
Variables ¶
var ( ErrMissingInstruction = errors.New("agent instruction is required") ErrInstructionTooLong = errors.New("agent instruction exceeds the maximum length") ErrMissingAPIKey = errors.New("agent provider API key is not configured") ErrMissingGraphJin = errors.New("graphjin core instance is required") )
Functions ¶
func CatalogDetailIDs ¶
CatalogDetailIDs returns the catalog detail ids established by a response's protocol evidence. It accepts both the bare protocol evidence shape and the wrapped {protocol, model} shape produced when model evidence is also present.
func EffectiveTimeoutSeconds ¶
func MutationRootFields ¶
MutationRootFields returns the top-level field names of mutation operations in query, using the same string/comment-safe scan as ContainsMutationOperation. It is intentionally conservative: over-collecting a name only makes the mutation-evidence guard demand more evidence, never less.
func PromptRegistryHash ¶
func PromptRegistryHash() string
PromptRegistryHash identifies the GraphJin-owned agent signature, runtime instructions, and built-in skill registry compiled into this binary. It is stable for identical registry content and is intended for run provenance.
func ProtocolViolationCodes ¶
ProtocolViolationCodes returns stable violation codes from protocol evidence, accepting both wrapped and bare evidence shapes.
func QueryRootFields ¶
QueryRootFields returns the top-level field names of query and subscription operations, used to decide whether an approved saved query already covers a raw query the model authored.
func SummarizeCatalogCards ¶
func SummarizeCatalogCards(cards []core.CatalogCard) []core.CatalogCard
SummarizeCatalogCards strips heavy detail blobs from search-mode results so broad discovery stays cheap; id/ids detail lookups keep full cards. Fields that drive routing and follow-up (id, kind, names, source_kind, risk, suggested_next, detail_ref) are preserved.
func TruncationMessage ¶
func TruncationMessage(roots []core.TruncatedRootInfo) string
TruncationMessage renders the model-facing warning for limit-clamped lists. Hedged like the catalog's truncation wording: reaching the limit means more rows MAY exist, never a certainty.
Types ¶
type ActionEvent ¶
type ActionEvent struct {
Index int `json:"index"` // 1-based action counter
Source string `json:"source"`
Tool string `json:"tool"`
Args map[string]any `json:"args,omitempty"`
Status string `json:"status"`
Summary map[string]any `json:"summary,omitempty"`
Error string `json:"error,omitempty"`
ElapsedMS int64 `json:"elapsed_ms"`
}
ActionEvent describes one completed (or rejected) tool call inside a run. Args and Summary reuse the protocol redaction, so events are safe to stream.
type CapabilityProfile ¶
type CapabilityProfile struct {
RoleClass string `json:"role_class,omitempty"`
Authenticated bool `json:"authenticated"`
Mode string `json:"mode,omitempty"`
CatalogRevision string `json:"catalog_revision,omitempty"`
AvailableTools []string `json:"available_tools,omitempty"`
AvailableSystemRoots []string `json:"available_system_roots,omitempty"`
BlockedSystemRoots []string `json:"blocked_system_roots,omitempty"`
RecommendedEntrypoint string `json:"recommended_entrypoint,omitempty"`
SafetyNotes []string `json:"safety_notes,omitempty"`
}
CapabilityProfile is an opaque, caller-derived snapshot of what this request is allowed to see and do. It is built by the service from the same machinery that powers the MCP capability profile and handed to the agent as read-only input.
Invariant: the *SystemRoots fields only ever contain the fixed gj_* system roots (gj_catalog, gj_security, gj_runtime, gj_config, gj_workflow, gj_workflow_execution, gj_artifacts, gj_watch, gj_watch_event, gj_task, and gj_task_entry). Application/database roots (potentially tens of thousands of tables) are NEVER enumerated here — they stay behind the catalog and progressive discovery, and their authorization remains core RLS per-table at execution.
type CatalogSearchFeatures ¶
CatalogSearchFeatures describes service-owned catalog retrieval features that are safe to expose to the internal agent. It is intentionally separate from Config: embedded-core and public MCP users retain their existing API.
type Config ¶
type Config struct {
Enabled bool `` /* 177-byte string literal not displayed */
Provider string `mapstructure:"provider" jsonschema:"title=Agent Provider,default=openai"`
Model string `mapstructure:"model" jsonschema:"title=Agent Model"`
APIKeyEnv string `mapstructure:"api_key_env" jsonschema:"title=Agent API Key Environment Variable,default=OPENAI_API_KEY"`
BaseURL string `mapstructure:"base_url" jsonschema:"title=Agent Provider Base URL"`
MaxSteps int `mapstructure:"max_steps" jsonschema:"title=Agent Max Steps,default=8"`
TimeoutSeconds int `mapstructure:"timeout_seconds" jsonschema:"title=Agent Timeout Seconds,default=50"`
ReadOnly bool `mapstructure:"read_only" jsonschema:"title=Force Agent Read-Only,default=false"`
ReturnTrace bool `mapstructure:"return_trace" jsonschema:"title=Return Agent Trace,default=false"`
// SeedLimit caps the initial query_catalog(search: instruction) seed rows.
SeedLimit int `mapstructure:"seed_limit" jsonschema:"title=Agent Seed Catalog Limit,default=40"`
// CatalogDefaultLimit is the default row limit for model-issued catalog queries.
CatalogDefaultLimit int `mapstructure:"catalog_default_limit" jsonschema:"title=Agent Catalog Default Limit,default=20"`
}
type GraphRuntime ¶
type GraphRuntime interface {
GraphQLHelp(context.Context, map[string]any) (any, error)
QueryCatalog(context.Context, map[string]any) (any, error)
ValidateWhereClause(context.Context, map[string]any) (any, error)
ExecuteSavedQuery(context.Context, map[string]any) (any, error)
ExecuteGraphQL(context.Context, map[string]any) (any, error)
}
func NewCoreRuntime ¶
func NewCoreRuntime(gj *core.GraphJin, config Config) (GraphRuntime, error)
type Option ¶
type Option func(*Agent)
func WithCatalogSearchFeatures ¶
func WithCatalogSearchFeatures(features CatalogSearchFeatures) Option
WithCatalogSearchFeatures enables service-internal agent guidance and tool fields only after the service has successfully constructed semantic search.
func WithClientFactory ¶
func WithClientFactory(factory ClientFactory) Option
func WithProgramFactory ¶
func WithProgramFactory(factory ProgramFactory) Option
func WithRuntime ¶
func WithRuntime(rt GraphRuntime) Option
type Refusal ¶
type Refusal struct {
Code string `json:"code"`
BlockedAction string `json:"blocked_action,omitempty"`
Because []string `json:"because,omitempty"`
Unblock []UnblockStep `json:"unblock,omitempty"`
LawfulAlternative string `json:"lawful_alternative,omitempty"`
PolicyFinal bool `json:"policy_final,omitempty"`
Retryable bool `json:"retryable,omitempty"`
}
type Request ¶
type Request struct {
Instruction string `json:"instruction"`
Context map[string]any `json:"context,omitempty"`
Namespace string `json:"namespace,omitempty"`
// TaskID is an owner-scoped correlation label used by the service to load
// declared task context and append a run trail. Like History, it never
// satisfies a protocol evidence guard and never grants access.
TaskID string `json:"task_id,omitempty"`
MaxSteps int `json:"max_steps,omitempty"`
ReturnTrace *bool `json:"return_trace,omitempty"`
// History carries prior conversation turns for follow-up resolution. It is
// untrusted model context: it reaches the model only as an ax context field
// (available to runtime code as inputs.history) and never satisfies a
// protocol guard — every run must re-establish its own tool evidence.
History []Turn `json:"history,omitempty"`
// Capabilities is the caller's role/visibility profile. It is intentionally
// json:"-" so it can never be supplied or spoofed from the REST body or MCP
// arguments; the service populates it after unmarshalling the wire request.
// It is read-only policy input and is not forwarded into the LLM prompt.
Capabilities *CapabilityProfile `json:"-"`
// Observer receives one ActionEvent per executed tool action (progress
// streaming). Server-populated only; never part of the wire request.
Observer func(ActionEvent) `json:"-"`
}
type Response ¶
type Response struct {
Status string `json:"status"`
Answer string `json:"answer,omitempty"`
Skills []SkillUsage `json:"skills,omitempty"`
Skill string `json:"skill,omitempty"` // Deprecated through v3.
Data any `json:"data,omitempty"`
Evidence any `json:"evidence,omitempty"`
Actions any `json:"actions,omitempty"`
Next any `json:"next,omitempty"`
Refusal *Refusal `json:"refusal,omitempty"`
Notices []ResponseNotice `json:"notices,omitempty"`
Errors []ErrorInfo `json:"errors,omitempty"`
Usage any `json:"usage,omitempty"`
Trace any `json:"trace,omitempty"`
TraceID string `json:"trace_id,omitempty"`
}
type ResponseNotice ¶
type ResponseNotice struct {
Kind string `json:"kind"`
Message string `json:"message"`
Count int `json:"count,omitempty"`
Since string `json:"since,omitempty"`
WatchIDs []string `json:"watch_ids,omitempty"`
TaskIDs []string `json:"task_ids,omitempty"`
AnnotationIDs []string `json:"annotation_ids,omitempty"`
}
type SkillUsage ¶
type TruncationInfo ¶
type TruncationInfo struct {
Roots []core.TruncatedRootInfo `json:"roots"`
Message string `json:"message"`
}
TruncationInfo is attached to execution results whose lists hit their compiled row limit. Exported so the serv layer can reuse it on the MCP execute tools.
type Turn ¶
type Turn struct {
Role string `json:"role"` // "user" or "assistant"
Content string `json:"content"` // user instruction or assistant answer
Status string `json:"status,omitempty"` // assistant turns: answered/blocked/needs_clarification
// CatalogIDs are detail ids the prior run inspected — advisory warm-start
// hints for this run's own discovery, never evidence.
CatalogIDs []string `json:"catalog_ids,omitempty"`
}
Turn is one prior conversation exchange, most recent last.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
skill-eval
command
Data-accuracy ("ground truth") evaluation mode.
|
Data-accuracy ("ground truth") evaluation mode. |
|
Package eval provides GraphJin's versioned evaluation and benchmark engine.
|
Package eval provides GraphJin's versioned evaluation and benchmark engine. |