Documentation
¶
Index ¶
- Constants
- func AttachFile(options AttachFileOptions) fantasy.AgentTool
- func ComputerUseProviderTool(provider codersdk.ChatComputerUseProvider, declaredWidth, declaredHeight int) (fantasy.Tool, error)
- func CreateWorkspace(db database.Store, organizationID, chatID uuid.UUID, ...) fantasy.AgentTool
- func DefaultComputerUseDesktopGeometry(provider codersdk.ChatComputerUseProvider) workspacesdk.DesktopGeometry
- func DefaultComputerUseModel(provider codersdk.ChatComputerUseProvider) (modelProvider, modelName string, ok bool)
- func DefaultComputerUseProvider(provider codersdk.ChatComputerUseProvider) codersdk.ChatComputerUseProvider
- func EditFiles(options EditFilesOptions) fantasy.AgentTool
- func Execute(options ExecuteOptions) fantasy.AgentTool
- func ExternalAgentUnavailableMessage(agent database.WorkspaceAgent) string
- func FindTools(options FindToolsOptions) fantasy.AgentTool
- func FormatResolvedSkillIndex(resolved []skillspkg.ResolvedSkill) string
- func IsExternalWorkspaceAgent(ctx context.Context, db database.Store, agent database.WorkspaceAgent) (bool, error)
- func ListTemplates(db database.Store, organizationID uuid.UUID, 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(provider codersdk.ChatComputerUseProvider, declaredWidth, declaredHeight int, ...) fantasy.AgentTool
- func NewWorkspaceMCPTools(infos []workspacesdk.MCPToolInfo, ...) []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(db database.Store, organizationID uuid.UUID, options ReadTemplateOptions) fantasy.AgentTool
- func ResolveWorkspaceHome(ctx context.Context, conn workspacesdk.AgentConn) (string, error)
- func StartWorkspace(db database.Store, chatID uuid.UUID, options StartWorkspaceOptions) fantasy.AgentTool
- func StopWorkspace(db database.Store, chatID uuid.UUID, options StopWorkspaceOptions) fantasy.AgentTool
- func SupportedComputerUseProviders() []string
- 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 FindToolCatalogEntry
- type FindToolsArgs
- type FindToolsCall
- type FindToolsMatch
- type FindToolsOptions
- type FindToolsResult
- 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 SearchBudget
- type SkillContent
- type SkillMeta
- type StartWorkspaceFn
- type StartWorkspaceOptions
- type StopWorkspaceFn
- type StopWorkspaceOptions
- 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) ServerName() string
- func (t *WorkspaceMCPTool) SetProviderOptions(opts fantasy.ProviderOptions)
- type WriteFileArgs
- type WriteFileOptions
Constants ¶
const ( // ComputerUseAnthropicModelName is the default Anthropic model used for // computer use subagents. It must support the computer_20251124 tool // version pinned in ComputerUseProviderTool. ComputerUseAnthropicModelName = "claude-opus-5" // ComputerUseOpenAIModelName is the default OpenAI model used for computer // use. It must be served over the Responses API, which carries the GA // computer_use tool. ComputerUseOpenAIModelName = "gpt-5.6-sol" )
const ( NextStepUseRecommended = "Use recommended_template_id with create_workspace. Call read_template first only if you need parameter or preset details." NextStepAskUser = "Do not call create_workspace yet. Ask the user to choose a template, unless they already named one." NextStepNoMatches = "No templates matched the query. Retry without a query or ask the user." NextStepNoTemplates = "No templates are available to this chat. Inform the user." )
Next-step instructions returned with every list_templates result.
const ( // AvailableSkillsOpenTag is the XML start tag for the skill index block. AvailableSkillsOpenTag = "<available-skills>" // AvailableSkillsCloseTag is the XML end tag for the skill index block. AvailableSkillsCloseTag = "</available-skills>" )
const DefaultSkillMetaFile = "SKILL.md"
DefaultSkillMetaFile is the fallback skill meta file name used when loading skill bodies on demand from older agents.
const ExecuteToolName = "execute"
ExecuteToolName is the registered name of the execute tool.
const ExternalAgentResourceType = "coder_external_agent"
ExternalAgentResourceType is the Terraform resource type for externally managed agents.
const (
FindToolsName = "find_tools"
)
LegacySharedPlanPath is the original shared plan file path used by every chat in a workspace.
const ( // ListTemplatesReadmeExcerptMaxRunes bounds the README excerpt surfaced // per template by list_templates. ListTemplatesReadmeExcerptMaxRunes = 1000 )
const NextStepField = "next_step"
NextStepField is the list_templates result field carrying the instruction the model should follow next. Tool descriptions and prompts reference it by name.
const ReadTemplateReadmeMaxRunes = 8000
ReadTemplateReadmeMaxRunes bounds the full README returned by read_template so one large README cannot dominate a single tool response.
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 ¶
func ComputerUseProviderTool(provider codersdk.ChatComputerUseProvider, declaredWidth, declaredHeight int) (fantasy.Tool, error)
ComputerUseProviderTool creates the provider-defined computer-use tool definition using the declared model-facing desktop geometry.
func CreateWorkspace ¶
func CreateWorkspace(db database.Store, organizationID, chatID uuid.UUID, 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. db must not be nil and chatID must not be uuid.Nil.
func DefaultComputerUseDesktopGeometry ¶ added in v2.34.0
func DefaultComputerUseDesktopGeometry(provider codersdk.ChatComputerUseProvider) workspacesdk.DesktopGeometry
DefaultComputerUseDesktopGeometry returns provider-specific model-facing desktop geometry for computer use.
func DefaultComputerUseModel ¶ added in v2.34.0
func DefaultComputerUseModel(provider codersdk.ChatComputerUseProvider) (modelProvider, modelName string, ok bool)
DefaultComputerUseModel returns the default model for a computer use provider.
func DefaultComputerUseProvider ¶ added in v2.34.0
func DefaultComputerUseProvider(provider codersdk.ChatComputerUseProvider) codersdk.ChatComputerUseProvider
DefaultComputerUseProvider returns the effective computer use provider.
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 ExternalAgentUnavailableMessage ¶ added in v2.34.0
func ExternalAgentUnavailableMessage(agent database.WorkspaceAgent) string
ExternalAgentUnavailableMessage explains how to make an externally managed agent usable based on its connection history.
func FindTools ¶ added in v2.37.0
func FindTools(options FindToolsOptions) fantasy.AgentTool
FindTools returns the built-in used to discover deferred MCP tool schemas.
func FormatResolvedSkillIndex ¶ added in v2.34.0
func FormatResolvedSkillIndex(resolved []skillspkg.ResolvedSkill) string
FormatResolvedSkillIndex renders an XML block listing all source-aware skills. Aliases are the names the model should pass to the skill tools.
func IsExternalWorkspaceAgent ¶ added in v2.34.0
func IsExternalWorkspaceAgent(ctx context.Context, db database.Store, agent database.WorkspaceAgent) (bool, error)
IsExternalWorkspaceAgent reports whether agent belongs to an external resource.
func ListTemplates ¶
func ListTemplates(db database.Store, organizationID uuid.UUID, options ListTemplatesOptions) fantasy.AgentTool
ListTemplates returns a tool that lists workspace templates as a ranked shortlist, ordered by query relevance, the user's recent usage, and organization popularity. db must not be nil.
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( provider codersdk.ChatComputerUseProvider, declaredWidth, declaredHeight int, getWorkspaceConn func(ctx context.Context) (workspacesdk.AgentConn, error), storeFile StoreFileFunc, clock quartz.Clock, logger slog.Logger, ) fantasy.AgentTool
NewComputerUseTool creates a provider-aware computer use AgentTool that delegates to the agent's desktop endpoints. declaredWidth and declaredHeight are the model-facing desktop dimensions advertised to providers and requested for screenshots.
func NewWorkspaceMCPTools ¶ added in v2.36.0
func NewWorkspaceMCPTools( infos []workspacesdk.MCPToolInfo, getConn func(context.Context) (workspacesdk.AgentConn, error), invalidateCache func(), ) []fantasy.AgentTool
NewWorkspaceMCPTools builds wrappers for a set of workspace MCP tools. Because the model-facing name is sanitized and length-capped, two distinct servers or tools can normalize to the same string (for example server keys "foo.bar" and "foo_bar" each exposing "echo", or names that share the first maxModelToolNameLen bytes). Duplicate names would be sent to the provider, which can reject the request, and the model's name-keyed dispatch would make one tool unreachable. To keep every tool addressable, colliding model-facing names are disambiguated with a numeric suffix while each tool keeps its own original routing name. Tools are sorted by routing name first so the suffix assignment is stable across turns.
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(db database.Store, organizationID uuid.UUID, 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 when it needs parameters or presets before create_workspace. db must not be nil.
func ResolveWorkspaceHome ¶ added in v2.33.0
ResolveWorkspaceHome returns the workspace user's home directory.
func StartWorkspace ¶
func StartWorkspace(db database.Store, chatID uuid.UUID, 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. db must not be nil and chatID must not be uuid.Nil.
func StopWorkspace ¶ added in v2.34.0
func StopWorkspace(db database.Store, chatID uuid.UUID, options StopWorkspaceOptions) fantasy.AgentTool
StopWorkspace returns a tool that stops the workspace associated with the current chat. The tool is idempotent when the workspace is already stopped. db must not be nil and chatID must not be uuid.Nil.
func SupportedComputerUseProviders ¶ added in v2.34.0
func SupportedComputerUseProviders() []string
SupportedComputerUseProviders returns the providers supported by computer use. The returned slice is a fresh copy and safe to mutate.
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
CreateFn CreateWorkspaceFn
AgentConnFn AgentConnFunc
AgentInactiveDisconnectTimeout time.Duration
WorkspaceMu *sync.Mutex
OnChatUpdated func(database.Chat)
Logger slog.Logger
}
CreateWorkspaceOptions configures the create_workspace tool.
type EditFilesArgs ¶
type EditFilesArgs struct {
Files []workspacesdk.FileEdits `json:"files" description:"Files to edit. Every entry must include path and at least one edit."`
}
EditFilesArgs is the tool input schema, auto-generated by the fantasy framework from these struct tags.
type EditFilesOptions ¶
type ExecuteArgs ¶
type ExecuteArgs struct {
Command string `json:"command" description:"The shell command to execute. Runs under \"sh -c\" (POSIX)."`
ModelIntent *string `` /* 533-byte string literal not displayed */
Timeout *string `` /* 235-byte string literal not displayed */
WorkDir *string `json:"workdir,omitempty" description:"Working directory for the command."`
RunInBackground *bool `` /* 436-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
// AgentBrowserSession, when non-empty, is exported as
// AGENT_BROWSER_SESSION so agent-browser CLI invocations land in a
// browser session scoped to this chat instead of a shared default.
AgentBrowserSession string
}
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"`
Command string `json:"command,omitempty"`
Running bool `json:"running,omitempty"`
Backgrounded bool `json:"backgrounded,omitempty"`
}
ExecuteResult is the structured response from the execute tool.
type FindToolCatalogEntry ¶ added in v2.37.0
type FindToolCatalogEntry struct {
Name string
Description string
Server string
ServerDescription string
ParameterText string
// SchemaTokens is the estimated prompt weight of the tool's full
// definition, used to cap how much one search may activate.
SchemaTokens float64
}
FindToolCatalogEntry is the searchable metadata for one deferred tool.
type FindToolsArgs ¶ added in v2.37.0
type FindToolsCall ¶ added in v2.37.0
type FindToolsCall struct {
Queries []string
Names []string
MatchCount int
Activated []string
TotalDeferred int
// Rejection is empty for successful searches. Rejected calls carry
// "budget" or "arguments" so callers can count them without
// polluting match or activation statistics.
Rejection string
}
FindToolsCall records one catalog search for logging and metrics.
type FindToolsMatch ¶ added in v2.37.0
type FindToolsOptions ¶ added in v2.37.0
type FindToolsOptions struct {
Entries []FindToolCatalogEntry
// SchemaTokenBudget caps the aggregate SchemaTokens all searches on
// this tool instance may activate, so results never report
// activations that the activation budget would immediately shed.
// The budget is shared across calls because one step can execute
// several searches concurrently. <= 0 means unbounded.
SchemaTokenBudget float64
// CatalogTokenBudget lowers the default catalog size cap so small
// context windows are not consumed by the catalog itself. <= 0 or
// values above the default keep the default.
CatalogTokenBudget float64
OnCall func(context.Context, FindToolsCall)
}
type FindToolsResult ¶ added in v2.37.0
type FindToolsResult struct {
Matches []FindToolsMatch `json:"matches"`
Activated []string `json:"activated"`
TotalDeferred int `json:"total_deferred"`
}
FindToolsResult is persisted as the tool result and re-read on later steps.
func SearchTools ¶ added in v2.37.0
func SearchTools(entries []FindToolCatalogEntry, args FindToolsArgs, budget SearchBudget) (FindToolsResult, int)
SearchTools prioritizes exact names, then keyword matches ranked by distinct query terms matched before raw score. Exact names bypass the per-call limit, but a hard cap keeps the persisted result safe from generic tool-result truncation; the second return counts budget-skipped matches.
type ListTemplatesOptions ¶
ListTemplatesOptions configures the list_templates tool. OwnerID is required; Clock defaults to a real clock when nil.
type ProcessOutputArgs ¶
type ProcessOutputArgs struct {
ProcessID string `json:"process_id"`
WaitTimeout *string `` /* 207-byte string literal not displayed */
ModelIntent *string `` /* 513-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 name or qualified alias of the skill to read."`
}
ReadSkillArgs are the parameters accepted by read_skill.
type ReadSkillFileArgs ¶
type ReadSkillFileArgs struct {
Name string `json:"name" description:"The name or qualified alias of the skill to read."`
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
ResolveAlias func(string) (skillspkg.ResolvedSkill, error)
LoadPersonalSkillBody func(context.Context, string) (skillspkg.ParsedSkill, error)
}
ReadSkillOptions configures the read_skill and read_skill_file tools.
type ReadTemplateOptions ¶
ReadTemplateOptions configures the read_template tool.
type SearchBudget ¶ added in v2.37.0
type SearchBudget struct {
// SchemaTokens is the remaining activation budget. <= 0 means
// unbounded.
SchemaTokens float64
// AllowFirstOverBudget admits the first match even over budget.
// Callers set it only while the shared budget is untouched, where
// derivation's newest-keep rule retains a sole over-budget claim.
AllowFirstOverBudget bool
}
SearchBudget bounds the schema weight one search may activate.
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.
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
// Meta is the verbatim skill meta file (SKILL.md) content the
// agent pushed in the workspace context snapshot: front-matter
// plus body. When present, read_skill serves the body from it
// instead of reading the file back over the workspace
// connection, so a pinned chat keeps returning the same
// instructions even when the workspace is unreachable. It is
// empty on the legacy per-turn discovery path, where the body is
// read live.
Meta []byte
}
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 {
OwnerID uuid.UUID
StartFn StartWorkspaceFn
AgentConnFn AgentConnFunc
WorkspaceMu *sync.Mutex
OnChatUpdated func(database.Chat)
Logger slog.Logger
}
StartWorkspaceOptions configures the start_workspace tool.
type StopWorkspaceFn ¶ added in v2.34.0
type StopWorkspaceFn func( ctx context.Context, ownerID uuid.UUID, workspaceID uuid.UUID, req codersdk.CreateWorkspaceBuildRequest, ) (codersdk.WorkspaceBuild, error)
StopWorkspaceFn stops a workspace by creating a new build with the "stop" transition.
type StopWorkspaceOptions ¶ added in v2.34.0
type StopWorkspaceOptions struct {
OwnerID uuid.UUID
StopFn StopWorkspaceFn
WorkspaceMu *sync.Mutex
OnChatUpdated func(database.Chat)
Logger slog.Logger
}
StopWorkspaceOptions configures the stop_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 single 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.
The model-facing name is sanitized to the provider-safe character set and length so a server or tool name containing a character such as "@" cannot produce an invalid tool name that the provider rejects. The unsanitized name is retained as routingName so the workspace agent can still route the call to the original server and tool.
Prefer NewWorkspaceMCPTools when building a set of tools, because that path also disambiguates names that collide after sanitization. This single-tool constructor cannot detect collisions on its own.
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) ServerName ¶ added in v2.37.0
func (t *WorkspaceMCPTool) ServerName() string
ServerName returns the originating MCP server name from the unsanitized routing name. The model-facing info.Name can lose the "__" separator to sanitization or length capping, so it cannot be parsed for the server.
func (*WorkspaceMCPTool) SetProviderOptions ¶
func (t *WorkspaceMCPTool) SetProviderOptions( opts fantasy.ProviderOptions, )
type WriteFileArgs ¶
Source Files
¶
- askuserquestion.go
- attachfile.go
- attachment.go
- chattool.go
- computeruse.go
- createworkspace.go
- editfiles.go
- execute.go
- external_agents.go
- findtools.go
- listtemplates.go
- mcpworkspace.go
- planpath.go
- planpathmessage.go
- planpathresolve.go
- proposeplan.go
- quotaerror.go
- readfile.go
- readme.go
- readtemplate.go
- skill.go
- startworkspace.go
- stopworkspace.go
- writefile.go