prompt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package prompt renders the agent's system prompt at run time from the agent's live registrations (tools, connections, MCPs, topics, webhooks, crons, routes) plus the small slice of platform data Airlock supplies at sync (dashboard/route URLs, the sibling address book). The same template was previously rendered server-side in airlock/prompt; moving it here lets the per-run caller filter (caller access level, per-user sibling visibility) take effect without exploding the on-wire payload into N variants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(data AgentData, caller string) (string, error)

Render renders the system prompt for the given caller access. Pass caller as "admin", "user", or "public"; empty means unfiltered admin variant (used by tests). The caller value is also stamped onto data.CallerAccess so templates can branch on tier (e.g. `{{ if .CallerAccess.IsPublic }}…{{ end }}`).

Types

type AgentData

type AgentData struct {
	AgentDashboardURL   string
	AgentRouteURL       string
	CallerAccess        Caller
	Capabilities        Capabilities
	SupportedModalities Modalities
	Tools               []ToolInfo
	Connections         []ConnInfo
	Topics              []TopicInfo
	Webhooks            []WebhookInfo
	Crons               []CronInfo
	Routes              []RouteInfo
	MCPServers          []MCPServerStatus
	Siblings            []SiblingInfo
	Directories         []DirInfo
	ExecEndpoints       []ExecEndpointInfo

	// Per-turn environment, rendered into the <env> block. Each is set
	// explicitly by the dispatch path (never inferred) and omitted from
	// the block when empty.
	Date         string
	Platform     string // web | telegram | discord | a2a
	UserName     string
	UserEmail    string
	Conversation string

	// DirectTools is true when the run exposes each capability as its
	// own typed LLM tool instead of one `run_js` binding. The template
	// branches on this to skip JS-flavoured sections (the TypeScript
	// manifest, `## JavaScript environment`, `var` / `let` guidance, the
	// namespaced binding docs) and emit a short tool-listing block
	// instead. Schemas reach the model via the tool-calling protocol,
	// not the system prompt.
	DirectTools bool
}

AgentData is the template input. Lists are pre-filtered for the caller's access level by Render before the template runs, so the {{ range }} loops don't have to think about access. The CallerAccess field is also exposed so the template CAN branch on it when the difference isn't "include/exclude an item" but "write a different sentence" — e.g. a public-tier preamble or admin-only guidance.

type Caller

type Caller string

Caller wraps the raw access string with template-friendly predicate methods so authors write `{{ if .CallerAccess.IsUser }}` instead of `{{ if eq .CallerAccess "user" }}`.

Empty Caller (zero value) is treated as Admin — matches the unfiltered "render everything" mode Render uses when caller is passed as "".

func (Caller) AtLeastUser

func (c Caller) AtLeastUser() bool

AtLeastUser reports user-or-above. Useful for "everyone except public" branches.

func (Caller) IsAdmin

func (c Caller) IsAdmin() bool

IsAdmin reports whether the caller is at the admin tier.

func (Caller) IsPublic

func (c Caller) IsPublic() bool

IsPublic reports whether the caller is exactly at the public tier — i.e. an anonymous or non-member request.

func (Caller) IsUser

func (c Caller) IsUser() bool

IsUser reports whether the caller is exactly at the user tier (not admin, not public).

type Capabilities

type Capabilities struct {
	Vision        bool
	Transcription bool
	Speech        bool
	Embedding     bool
	Image         bool
	Search        bool
}

Capabilities mirrors agentsdk.Capabilities — duplicated here to avoid an import cycle. buildPromptData copies field-for-field.

type ConnInfo

type ConnInfo struct {
	Slug        string
	Name        string
	Description string
	LLMHint     string
	BaseURL     string
	Access      string
}

type CronInfo

type CronInfo struct {
	Name        string
	Schedule    string
	Description string
}

type DirInfo

type DirInfo struct {
	Path        string
	Description string
	LLMHint     string
	Read        string
	Write       string
	List        string
	// Scope, when non-empty, indicates the directory is per-context.
	// Values: "user", "conv", "run". The template renders an extra
	// note so the LLM understands paths it returns will include a
	// scope key segment (e.g. `<dir>/user-<id>/...`).
	Scope string
}

DirInfo describes one registered storage directory for the prompt. Each cap is shown independently — a caller may, for example, have list+read but not write. The template uses these to tell the LLM which S3 paths it can touch on this run.

type ExecEndpointInfo

type ExecEndpointInfo struct {
	Slug        string
	Description string
	LLMHint     string
	Access      string
}

ExecEndpointInfo carries one registered exec endpoint for the prompt. Bind-time access gating happens in vm.go; the prompt block also access-filters via filterExecEndpoints below so a non-admin caller never sees an admin-only endpoint listed.

type MCPServerStatus

type MCPServerStatus struct {
	Slug   string
	Name   string
	Status string // "connected, 5 tools" or "requires authentication"
	Access string
	// Description is the server-level usage hint the remote MCP server
	// advertised via initialize `instructions`. Empty when unset.
	Description string
	Tools       []ToolInfo
}

MCPServerStatus carries the per-server status line + (when authorized) the discovered tool schemas the template renders into a typed `declare const mcp_{slug}: {...}` block.

type Modalities

type Modalities []string

Modalities is the list of input types the chat model accepts. Wrapped in a type so the template can ask `.SupportedModalities.HasImage` instead of doing string comparisons.

func (Modalities) Has

func (m Modalities) Has(modality string) bool

func (Modalities) HasAudio

func (m Modalities) HasAudio() bool

func (Modalities) HasImage

func (m Modalities) HasImage() bool

HasImage / HasPDF / HasAudio / HasVideo are template-friendly predicates for the modality strings emitted by sol's provider.GetModalities. "text" is always implied so there's no matching predicate for it.

func (Modalities) HasPDF

func (m Modalities) HasPDF() bool

func (Modalities) HasVideo

func (m Modalities) HasVideo() bool

type RouteInfo

type RouteInfo struct {
	Method      string
	Path        string
	Access      string
	Description string
}

type SiblingInfo

type SiblingInfo struct {
	ID          uuid.UUID
	Slug        string
	Name        string
	Description string
	Tools       []ToolInfo
}

SiblingInfo carries one sibling agent record for prompt rendering. ID is the canonical, rename-safe identifier; Slug is the human-readable binding name (`agent_<slug>`). Tools is the sibling's published tool schemas (synced server-side).

type ToolInfo

type ToolInfo struct {
	Name         string
	Description  string
	LLMHint      string
	Access       string
	InputSchema  json.RawMessage
	OutputSchema json.RawMessage
}

ToolInfo carries the hydrated tool record for prompt rendering.

type TopicInfo

type TopicInfo struct {
	Slug        string
	Description string
	LLMHint     string
	Access      string
}

type WebhookInfo

type WebhookInfo struct {
	Path        string
	Description string
}

Jump to

Keyboard shortcuts

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