Documentation
¶
Overview ¶
Package skillworker is the local tool-worker runtime for skill run/serve. When a skill agent runs on the server, it dispatches tool tasks (read_skill_file, each script, workspace tools) back to the CLI; this package polls for those tasks, runs them locally, and returns the result. It is layered: the poll→handle→update loop and its two interfaces live here, the Conductor SDK is confined to the runner bridge, and the concrete tool logic lives in the handlers (later stage).
Index ¶
- Constants
- func TaskType(skillName, tool string) string
- type ScriptOptions
- type Task
- type TaskRunner
- type ToolHandler
- func NewGitDiffHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
- func NewGitStatusHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
- func NewListWorkspaceFilesHandler(ws WorkspaceConfig) ToolHandler
- func NewReadSkillFileHandler(skillDir string, resourceFiles []string, sections map[string]string) ToolHandler
- func NewReadWorkspaceFileHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
- func NewScriptHandler(scriptPath, language string, ws WorkspaceConfig, opts ScriptOptions) ToolHandler
- func NewSearchWorkspaceHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
- type Worker
- type WorkspaceConfig
- type WorkspaceRoot
- type WorkspaceRootWire
- type WorkspaceWire
Constants ¶
const ( ToolReadSkillFile = "read_skill_file" ToolListWorkspace = "list_workspace_files" ToolReadWorkspaceFile = "read_workspace_file" ToolSearchWorkspace = "search_workspace" ToolGitStatus = "git_status" ToolGitDiff = "git_diff" )
Tool names (the "{tool}" half of a "{skillName}__{tool}" task type). Shared with the cmd registry that maps them to these handlers.
const ( LangPython = "python" LangNode = "node" LangRuby = "ruby" LangGo = "go" LangBatch = "batch" LangBash = "bash" )
Script languages — the vocabulary produced by the payload builder's extension table and consumed by executeScript, kept in one place to avoid drift.
const ( KindWorkspace = "workspace" // the primary, editable working directory KindFilesystem = "filesystem" // an additional named read-only root )
Workspace root kinds and the reserved default root name.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ScriptOptions ¶
ScriptOptions bounds a script execution (zero values fall back to the defaults).
type Task ¶
type Task struct {
ID string
WorkflowID string
Input json.RawMessage
}
Task is one polled tool task, decoupled from the SDK's model.Task.
type TaskRunner ¶
type TaskRunner interface {
// Poll returns the next task for taskType. ok=false means no task was available
// (poll again); a non-nil err is a real polling failure.
Poll(ctx context.Context, taskType string) (task Task, ok bool, err error)
Complete(ctx context.Context, t Task, output json.RawMessage) error
Fail(ctx context.Context, t Task, reason string) error
}
TaskRunner is the poll/complete/fail seam. The production impl (runner.go) wraps Conductor's TaskResourceApiService; tests inject a fake. It keeps model.Task and *client.TaskResourceApiService out of the worker loop and the handlers.
func NewConductorRunner ¶
func NewConductorRunner(taskClient *client.TaskResourceApiService) TaskRunner
NewConductorRunner returns a TaskRunner backed by the Conductor task client (supplied by the cmd layer via internal.GetTaskClient()).
type ToolHandler ¶
type ToolHandler interface {
Handle(ctx context.Context, input json.RawMessage) (json.RawMessage, error)
}
ToolHandler handles one dispatched tool task. IO is json.RawMessage, so no map crosses this boundary; the concrete tool logic lives in the handlers.
func NewGitDiffHandler ¶
func NewGitDiffHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
NewGitDiffHandler runs "git diff" (optionally staged / against a base / for a path) on a workspace root.
func NewGitStatusHandler ¶
func NewGitStatusHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
NewGitStatusHandler runs "git status --short" on a workspace root.
func NewListWorkspaceFilesHandler ¶
func NewListWorkspaceFilesHandler(ws WorkspaceConfig) ToolHandler
NewListWorkspaceFilesHandler lists files under a workspace root, filtered by glob.
func NewReadSkillFileHandler ¶
func NewReadSkillFileHandler(skillDir string, resourceFiles []string, sections map[string]string) ToolHandler
NewReadSkillFileHandler serves skill resource files and pre-split SKILL.md sections. Only paths in resourceFiles (and "skill_section:{slug}" for each known section) are allowed; expected failures (unknown/unreadable path) are returned as an "ERROR: ..." result string so the agent can see them, matching the original.
func NewReadWorkspaceFileHandler ¶
func NewReadWorkspaceFileHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
NewReadWorkspaceFileHandler reads one workspace file (bounded by fileLimit).
func NewScriptHandler ¶
func NewScriptHandler(scriptPath, language string, ws WorkspaceConfig, opts ScriptOptions) ToolHandler
NewScriptHandler runs one skill script. Script failure is returned as an error whose message includes the captured output, so the failed task's reason carries the diagnostic output.
func NewSearchWorkspaceHandler ¶
func NewSearchWorkspaceHandler(ws WorkspaceConfig, fileLimit int) ToolHandler
NewSearchWorkspaceHandler does a substring search across a workspace root.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker runs the poll→handle→update loop for a single task type over a TaskRunner.
func NewWorker ¶
func NewWorker(runner TaskRunner) *Worker
NewWorker returns a Worker backed by the given TaskRunner.
func (*Worker) Run ¶
func (w *Worker) Run(ctx context.Context, taskType string, h ToolHandler)
Run polls taskType and dispatches each task to h until ctx is cancelled. Transient poll failures back off and retry rather than stop the loop; a handler error fails only that task. Run returns when ctx is done.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
Enabled bool
Roots []WorkspaceRoot
}
WorkspaceConfig is the set of local roots the workspace tools expose. It is resolved from flags in the cmd layer and passed to the handlers; the server only ever sees the wire form (WireConfig) and tool outputs, never these paths.
func (WorkspaceConfig) Root ¶
func (c WorkspaceConfig) Root(name string) (WorkspaceRoot, bool)
Root returns the named root, or the first root for an empty name.
func (WorkspaceConfig) WireConfig ¶
func (c WorkspaceConfig) WireConfig() *WorkspaceWire
WireConfig produces the server-bound workspace section (no local paths), or nil when the workspace is disabled.
type WorkspaceRoot ¶
WorkspaceRoot is one named, absolute, symlink-resolved local root.
func NewWorkspaceRoot ¶
func NewWorkspaceRoot(name, pathValue, kind string) (WorkspaceRoot, error)
NewWorkspaceRoot validates and resolves one root. The name must be filesystem/env-safe and the path must be an existing directory; the returned path is absolute and symlink-resolved. File I/O is expected here — this is the local CLI runtime layer.
type WorkspaceRootWire ¶
WorkspaceRootWire is one named workspace root on the wire (no path).
type WorkspaceWire ¶
type WorkspaceWire struct {
Enabled bool `json:"enabled"`
Roots []WorkspaceRootWire `json:"roots,omitempty"`
}
WorkspaceWire is the workspace section of a skill config as sent to the server: the enable flag and the root names/kinds only — never their local paths.