Documentation
¶
Index ¶
- Constants
- func AttachFile(options AttachFileOptions) fantasy.AgentTool
- func ComputerUseProviderTool(declaredWidth, declaredHeight int) fantasy.Tool
- func CreateWorkspace(organizationID uuid.UUID, db database.Store, options CreateWorkspaceOptions) fantasy.AgentTool
- func EditFiles(options EditFilesOptions) fantasy.AgentTool
- func Execute(options ExecuteOptions) fantasy.AgentTool
- func FormatSkillIndex(skills []SkillMeta) string
- func ListTemplates(organizationID uuid.UUID, db database.Store, options ListTemplatesOptions) fantasy.AgentTool
- func LoadSkillFile(ctx context.Context, conn workspacesdk.AgentConn, skill SkillMeta, ...) (string, error)
- func LooksLikeHomePlanFile(requestedPath, home string) bool
- func NewAskUserQuestionTool() fantasy.AgentTool
- func NewComputerUseTool(declaredWidth, declaredHeight int, ...) fantasy.AgentTool
- func PlanPathForChat(home string, chatID uuid.UUID) string
- func ProcessList(options ProcessToolOptions) fantasy.AgentTool
- func ProcessOutput(options ProcessToolOptions) fantasy.AgentTool
- func ProcessSignal(options ProcessToolOptions) fantasy.AgentTool
- func ProposePlan(options ProposePlanOptions) fantasy.AgentTool
- func ReadFile(options ReadFileOptions) fantasy.AgentTool
- func ReadSkill(options ReadSkillOptions) fantasy.AgentTool
- func ReadSkillFile(options ReadSkillOptions) fantasy.AgentTool
- func ReadTemplate(organizationID uuid.UUID, db database.Store, options ReadTemplateOptions) fantasy.AgentTool
- func ResolveWorkspaceHome(ctx context.Context, conn workspacesdk.AgentConn) (string, error)
- func StartWorkspace(options StartWorkspaceOptions) fantasy.AgentTool
- func WithAttachments(response fantasy.ToolResponse, attachments ...AttachmentMetadata) fantasy.ToolResponse
- func WriteFile(options WriteFileOptions) fantasy.AgentTool
- type AgentConnFunc
- type AttachFileArgs
- type AttachFileOptions
- type AttachmentMetadata
- type CreateWorkspaceFn
- type CreateWorkspaceOptions
- type EditFilesArgs
- type EditFilesOptions
- type ExecuteArgs
- type ExecuteOptions
- type ExecuteResult
- type ListTemplatesOptions
- type ProcessOutputArgs
- type ProcessSignalArgs
- type ProcessToolOptions
- type ProposePlanArgs
- type ProposePlanOptions
- type ReadFileArgs
- type ReadFileOptions
- type ReadSkillArgs
- type ReadSkillFileArgs
- type ReadSkillOptions
- type ReadTemplateOptions
- type SkillContent
- type SkillMeta
- type StartWorkspaceFn
- type StartWorkspaceOptions
- type StoreFileFunc
- type WorkspaceMCPTool
- func (t *WorkspaceMCPTool) Info() fantasy.ToolInfo
- func (t *WorkspaceMCPTool) ProviderOptions() fantasy.ProviderOptions
- func (t *WorkspaceMCPTool) Run(ctx context.Context, params fantasy.ToolCall) (fantasy.ToolResponse, error)
- func (t *WorkspaceMCPTool) SetProviderOptions(opts fantasy.ProviderOptions)
- type WriteFileArgs
- type WriteFileOptions
Constants ¶
const ( // ComputerUseModelProvider is the provider for the computer // use model. ComputerUseModelProvider = "anthropic" // ComputerUseModelName is the model used for computer use // subagents. ComputerUseModelName = "claude-opus-4-6" )
const DefaultSkillMetaFile = "SKILL.md"
DefaultSkillMetaFile is the fallback skill meta file name used when loading skill bodies on demand from older agents.
LegacySharedPlanPath is the original shared plan file path used by every chat in a workspace.
Variables ¶
This section is empty.
Functions ¶
func AttachFile ¶ added in v2.33.0
func AttachFile(options AttachFileOptions) fantasy.AgentTool
AttachFile returns a tool that stores a workspace file as a durable chat attachment so the user can download it directly from the conversation.
func ComputerUseProviderTool ¶
ComputerUseProviderTool creates the provider-defined Anthropic computer-use tool definition using the declared model-facing desktop geometry.
func CreateWorkspace ¶
func CreateWorkspace(organizationID uuid.UUID, db database.Store, options CreateWorkspaceOptions) fantasy.AgentTool
CreateWorkspace returns a tool that creates a new workspace from a template. The tool is idempotent: if the chat already has a workspace that is building or running, it returns the existing workspace instead of creating a new one. A mutex prevents parallel calls from creating duplicate workspaces.
func EditFiles ¶
func EditFiles(options EditFilesOptions) fantasy.AgentTool
func Execute ¶
func Execute(options ExecuteOptions) fantasy.AgentTool
Execute returns an AgentTool that runs a shell command in the workspace via the agent HTTP API.
func FormatSkillIndex ¶
FormatSkillIndex renders an XML block listing all discovered skills. This block is injected into the system prompt so the model knows which skills are available and how to load them.
func ListTemplates ¶
func ListTemplates(organizationID uuid.UUID, db database.Store, options ListTemplatesOptions) fantasy.AgentTool
ListTemplates returns a tool that lists available workspace templates. The agent uses this to discover templates before creating a workspace. Results are ordered by number of active developers (most popular first) and paginated at 10 per page.
func LoadSkillFile ¶
func LoadSkillFile( ctx context.Context, conn workspacesdk.AgentConn, skill SkillMeta, relativePath string, ) (string, error)
LoadSkillFile reads a supporting file from a skill's directory. The relativePath is validated to prevent directory traversal and access to hidden files.
func LooksLikeHomePlanFile ¶ added in v2.33.0
LooksLikeHomePlanFile reports whether requestedPath is a plan.md variant (case-insensitive) sitting directly in the workspace home directory. The filename is compared case-insensitively because LLM output varies.
func NewAskUserQuestionTool ¶ added in v2.33.0
NewAskUserQuestionTool creates the ask_user_question tool.
func NewComputerUseTool ¶
func NewComputerUseTool( declaredWidth, declaredHeight int, getWorkspaceConn func(ctx context.Context) (workspacesdk.AgentConn, error), storeFile StoreFileFunc, clock quartz.Clock, logger slog.Logger, ) fantasy.AgentTool
NewComputerUseTool creates a computer use AgentTool that delegates to the agent's desktop endpoints. declaredWidth and declaredHeight are the model-facing desktop dimensions advertised to Anthropic and requested for screenshots.
func PlanPathForChat ¶ added in v2.33.0
PlanPathForChat returns the per-chat plan file path rooted in the workspace home directory.
func ProcessList ¶
func ProcessList(options ProcessToolOptions) fantasy.AgentTool
ProcessList returns an AgentTool that lists all tracked processes on the workspace agent.
func ProcessOutput ¶
func ProcessOutput(options ProcessToolOptions) fantasy.AgentTool
ProcessOutput returns an AgentTool that retrieves the output of a tracked process by its ID.
func ProcessSignal ¶
func ProcessSignal(options ProcessToolOptions) fantasy.AgentTool
ProcessSignal returns an AgentTool that sends a signal to a tracked process on the workspace agent by its ID.
func ProposePlan ¶
func ProposePlan(options ProposePlanOptions) fantasy.AgentTool
ProposePlan returns a tool that presents a Markdown plan file from the workspace for user review.
func ReadFile ¶
func ReadFile(options ReadFileOptions) fantasy.AgentTool
func ReadSkill ¶
func ReadSkill(options ReadSkillOptions) fantasy.AgentTool
ReadSkill returns an AgentTool that reads the full instructions for a skill by name. The model should call this before following any skill's instructions.
func ReadSkillFile ¶
func ReadSkillFile(options ReadSkillOptions) fantasy.AgentTool
ReadSkillFile returns an AgentTool that reads a supporting file from a skill's directory.
func ReadTemplate ¶
func ReadTemplate(organizationID uuid.UUID, db database.Store, options ReadTemplateOptions) fantasy.AgentTool
ReadTemplate returns a tool that retrieves details about a specific template, including its configurable rich parameters. The agent uses this after list_templates and before create_workspace.
func ResolveWorkspaceHome ¶ added in v2.33.0
ResolveWorkspaceHome returns the workspace user's home directory.
func StartWorkspace ¶
func StartWorkspace(options StartWorkspaceOptions) fantasy.AgentTool
StartWorkspace returns a tool that starts a stopped workspace associated with the current chat. The tool is idempotent: if the workspace is already running or building, it returns immediately.
func WithAttachments ¶ added in v2.33.0
func WithAttachments( response fantasy.ToolResponse, attachments ...AttachmentMetadata, ) fantasy.ToolResponse
WithAttachments stores durable attachment metadata on a tool response so the persistence layer can promote the files into assistant chat attachments.
func WriteFile ¶
func WriteFile(options WriteFileOptions) fantasy.AgentTool
Types ¶
type AgentConnFunc ¶
type AgentConnFunc func( ctx context.Context, agentID uuid.UUID, ) (workspacesdk.AgentConn, func(), error)
AgentConnFunc provides access to workspace agent connections.
type AttachFileArgs ¶ added in v2.33.0
AttachFileArgs are the arguments for the attach_file tool.
type AttachFileOptions ¶ added in v2.33.0
type AttachFileOptions struct {
GetWorkspaceConn func(context.Context) (workspacesdk.AgentConn, error)
StoreFile StoreFileFunc
}
AttachFileOptions configures the attach_file tool.
type AttachmentMetadata ¶ added in v2.33.0
type AttachmentMetadata struct {
FileID uuid.UUID `json:"file_id"`
MediaType string `json:"media_type"`
Name string `json:"name,omitempty"`
}
AttachmentMetadata identifies a durable chat attachment that should be promoted into a standard file message part for the user.
func AttachmentsFromMetadata ¶ added in v2.33.0
func AttachmentsFromMetadata(metadata string) ([]AttachmentMetadata, error)
AttachmentsFromMetadata decodes durable attachment metadata from a tool response so the persistence layer can promote them into assistant file parts.
type CreateWorkspaceFn ¶
type CreateWorkspaceFn func( ctx context.Context, ownerID uuid.UUID, req codersdk.CreateWorkspaceRequest, ) (codersdk.Workspace, error)
CreateWorkspaceFn creates a workspace for the given owner.
type CreateWorkspaceOptions ¶
type CreateWorkspaceOptions struct {
OwnerID uuid.UUID
ChatID uuid.UUID
CreateFn CreateWorkspaceFn
AgentConnFn AgentConnFunc
AgentInactiveDisconnectTimeout time.Duration
WorkspaceMu *sync.Mutex
OnChatUpdated func(database.Chat)
Logger slog.Logger
AllowedTemplateIDs func() map[uuid.UUID]bool
}
CreateWorkspaceOptions configures the create_workspace tool.
type EditFilesArgs ¶
type EditFilesArgs struct {
Files []workspacesdk.FileEdits `json:"files"`
}
type EditFilesOptions ¶
type ExecuteArgs ¶
type ExecuteArgs struct {
Command string `json:"command" description:"The shell command to execute."`
Timeout *string `` /* 235-byte string literal not displayed */
WorkDir *string `json:"workdir,omitempty" description:"Working directory for the command."`
RunInBackground *bool `` /* 439-byte string literal not displayed */
}
ExecuteArgs are the parameters accepted by the execute tool.
type ExecuteOptions ¶
type ExecuteOptions struct {
GetWorkspaceConn func(context.Context) (workspacesdk.AgentConn, error)
DefaultTimeout time.Duration
}
ExecuteOptions configures the execute tool.
type ExecuteResult ¶
type ExecuteResult struct {
Success bool `json:"success"`
Output string `json:"output,omitempty"`
ExitCode int `json:"exit_code"`
WallDurationMs int64 `json:"wall_duration_ms"`
Error string `json:"error,omitempty"`
Truncated *workspacesdk.ProcessTruncation `json:"truncated,omitempty"`
Note string `json:"note,omitempty"`
BackgroundProcessID string `json:"background_process_id,omitempty"`
}
ExecuteResult is the structured response from the execute tool.
type ListTemplatesOptions ¶
ListTemplatesOptions configures the list_templates tool.
type ProcessOutputArgs ¶
type ProcessOutputArgs struct {
ProcessID string `json:"process_id"`
WaitTimeout *string `` /* 207-byte string literal not displayed */
}
ProcessOutputArgs are the parameters accepted by the process_output tool.
type ProcessSignalArgs ¶
type ProcessSignalArgs struct {
ProcessID string `json:"process_id"`
Signal string `json:"signal"`
}
ProcessSignalArgs are the parameters accepted by the process_signal tool.
type ProcessToolOptions ¶
type ProcessToolOptions struct {
GetWorkspaceConn func(context.Context) (workspacesdk.AgentConn, error)
}
ProcessToolOptions configures a process management tool (process_output, process_list, or process_signal). Each of these tools only needs a workspace connection resolver.
type ProposePlanArgs ¶
type ProposePlanArgs struct {
Path string `json:"path"`
}
ProposePlanArgs are the arguments for the propose_plan tool.
type ProposePlanOptions ¶
type ProposePlanOptions struct {
GetWorkspaceConn func(context.Context) (workspacesdk.AgentConn, error)
ResolvePlanPath func(context.Context) (chatPath string, home string, err error)
StoreFile StoreFileFunc
IsPlanTurn bool
}
ProposePlanOptions configures the propose_plan tool.
type ReadFileArgs ¶
type ReadFileOptions ¶
type ReadFileOptions struct {
GetWorkspaceConn func(context.Context) (workspacesdk.AgentConn, error)
}
type ReadSkillArgs ¶
type ReadSkillArgs struct {
Name string `json:"name" description:"The kebab-case name of the skill to read."`
}
ReadSkillArgs are the parameters accepted by read_skill.
type ReadSkillFileArgs ¶
type ReadSkillFileArgs struct {
Name string `json:"name" description:"The kebab-case name of the skill."`
Path string `json:"path" description:"Relative path to a file in the skill directory (e.g. roles/security-reviewer.md)."`
}
ReadSkillFileArgs are the parameters accepted by read_skill_file.
type ReadSkillOptions ¶
type ReadSkillOptions struct {
GetWorkspaceConn func(context.Context) (workspacesdk.AgentConn, error)
GetSkills func() []SkillMeta
}
ReadSkillOptions configures the read_skill and read_skill_file tools.
type ReadTemplateOptions ¶
ReadTemplateOptions configures the read_template tool.
type SkillContent ¶
type SkillContent struct {
SkillMeta
// Body is the markdown content after the frontmatter
// delimiters have been stripped.
Body string
// Files lists relative paths of supporting files in the
// skill directory (everything except the skill meta file).
Files []string
}
SkillContent is the full body of a skill, loaded on demand when the model calls read_skill.
func LoadSkillBody ¶
func LoadSkillBody( ctx context.Context, conn workspacesdk.AgentConn, skill SkillMeta, metaFile string, ) (SkillContent, error)
LoadSkillBody reads the full skill meta file for a discovered skill and lists the supporting files in its directory.
type SkillMeta ¶
type SkillMeta struct {
Name string
Description string
// Dir is the absolute path to the skill directory inside
// the workspace filesystem.
Dir string
// MetaFile is the basename of the skill meta file (e.g.
// "SKILL.md"). When empty, DefaultSkillMetaFile is used.
MetaFile string
}
SkillMeta is the frontmatter from a skill meta file discovered in a workspace. It carries just enough information to list the skill in the prompt index without reading the full body.
type StartWorkspaceFn ¶
type StartWorkspaceFn func( ctx context.Context, ownerID uuid.UUID, workspaceID uuid.UUID, req codersdk.CreateWorkspaceBuildRequest, ) (codersdk.WorkspaceBuild, error)
StartWorkspaceFn starts a workspace by creating a new build with the "start" transition.
type StartWorkspaceOptions ¶
type StartWorkspaceOptions struct {
DB database.Store
OwnerID uuid.UUID
ChatID uuid.UUID
StartFn StartWorkspaceFn
AgentConnFn AgentConnFunc
WorkspaceMu *sync.Mutex
OnChatUpdated func(database.Chat)
Logger slog.Logger
}
StartWorkspaceOptions configures the start_workspace tool.
type StoreFileFunc ¶ added in v2.33.0
type StoreFileFunc func(ctx context.Context, name string, detectName string, data []byte) (AttachmentMetadata, error)
StoreFileFunc persists a chat attachment after classifying it for durable storage and returns the stored attachment metadata.
type WorkspaceMCPTool ¶
type WorkspaceMCPTool struct {
// contains filtered or unexported fields
}
WorkspaceMCPTool wraps a single MCP tool discovered in a workspace, proxying calls through the workspace agent connection. It implements fantasy.AgentTool so it can be registered alongside built-in chat tools.
func NewWorkspaceMCPTool ¶
func NewWorkspaceMCPTool( tool workspacesdk.MCPToolInfo, getConn func(context.Context) (workspacesdk.AgentConn, error), invalidateCache func(), ) *WorkspaceMCPTool
NewWorkspaceMCPTool creates a tool wrapper from an MCPToolInfo discovered on a workspace agent. Each tool proxies calls back through the agent connection. The optional invalidateCache callback is invoked when CallMCPTool returns a 404 error, indicating that the server was removed and the chat's cached tool list should be dropped.
func (*WorkspaceMCPTool) Info ¶
func (t *WorkspaceMCPTool) Info() fantasy.ToolInfo
func (*WorkspaceMCPTool) ProviderOptions ¶
func (t *WorkspaceMCPTool) ProviderOptions() fantasy.ProviderOptions
func (*WorkspaceMCPTool) Run ¶
func (t *WorkspaceMCPTool) Run( ctx context.Context, params fantasy.ToolCall, ) (fantasy.ToolResponse, error)
func (*WorkspaceMCPTool) SetProviderOptions ¶
func (t *WorkspaceMCPTool) SetProviderOptions( opts fantasy.ProviderOptions, )