Documentation
¶
Overview ¶
Package draftcrew provides a high-performance, idiomatic Go framework for AI agent orchestration.
Includes A2A (agent-to-agent) protocol for inter-agent delegation with HTTP+WebSocket transport, circuit breaker, and agent registry.
Basic usage:
llm := draftcrew.NewOpenAI(os.Getenv("OPENAI_API_KEY"), "gpt-4")
agent := draftcrew.NewAgent(draftcrew.AgentConfig{Role: "Researcher", Goal: "Find trends", LLM: llm})
task := draftcrew.NewTask(draftcrew.TaskConfig{Description: "Research Go 1.22", Agent: agent})
crew := draftcrew.NewCrew(draftcrew.CrewConfig{Agents: []*draftcrew.Agent{agent}, Tasks: []*draftcrew.Task{task}})
result, err := crew.Kickoff(context.Background())
Index ¶
- Constants
- Variables
- func GetOutput[T any](r *crew.Result, taskID string) (T, error)
- type A2AClient
- type A2AMessage
- type A2AServer
- type Agent
- type AgentConfig
- type AskHumanOption
- type Callback
- type CallbackBridge
- type Checkpoint
- type CheckpointStore
- type Crew
- type CrewConfig
- type CrewError
- type Criterion
- type DurationHistogram
- type EvalResult
- type EventBus
- type EventBusConfig
- type EventType
- type Flow
- type FlowEdge
- type FlowNode
- type FlowResult
- type GenerateOption
- type Guardrail
- type KnowledgeChunk
- type KnowledgeSource
- type LLM
- type MemoryEntry
- type MemoryStore
- type Message
- type MetricsSnapshot
- type NodeState
- type OTELBridge
- type OutputCondition
- type Phase
- type ProcessType
- type Response
- type Result
- type StepInfo
- type StreamChunk
- type Task
- type TaskConfig
- type TelemetryEvent
- type TelemetryMetadata
- type Tool
- type ToolCall
- type ToolDef
- type TrainingFeedback
- type TrainingStore
- type Transport
- type Usage
- type YAMLEvalConfig
- type YAMLEvalCriterionConfig
- type YAMLLLMConfig
- type YAMLMCPServerConfig
- type YAMLMCPSetup
Constants ¶
const ( ProcessSequential = crew.ProcessSequential ProcessHierarchical = crew.ProcessHierarchical ProcessConsensual = crew.ProcessConsensual ProcessReflective = crew.ProcessReflective ProcessFlow = crew.ProcessFlow ProcessStateMachine = crew.ProcessStateMachine )
ProcessType constants for crew execution modes.
const ( PhaseAgentInit = callback.PhaseAgentInit PhaseAgentThink = callback.PhaseAgentThink PhaseAgentTool = callback.PhaseAgentTool PhaseAgentOutput = callback.PhaseAgentOutput PhaseAgentComplete = callback.PhaseAgentComplete PhaseAgentError = callback.PhaseAgentError PhaseTaskStart = callback.PhaseTaskStart PhaseTaskComplete = callback.PhaseTaskComplete PhaseTaskError = callback.PhaseTaskError PhaseCrewStart = callback.PhaseCrewStart PhaseCrewComplete = callback.PhaseCrewComplete PhaseCrewError = callback.PhaseCrewError PhaseHumanInput = callback.PhaseHumanInput PhaseReviewRequired = callback.PhaseReviewRequired PhaseFlowStart = callback.PhaseFlowStart PhaseFlowNodeStart = callback.PhaseFlowNodeStart PhaseFlowNodeComplete = callback.PhaseFlowNodeComplete PhaseFlowComplete = callback.PhaseFlowComplete )
Callback phase constants for agent, task, crew, and flow lifecycle events.
const ( EventPhaseTransition = telemetry.EventPhaseTransition EventLLMCall = telemetry.EventLLMCall EventToolExecution = telemetry.EventToolExecution EventError = telemetry.EventError EventCheckpoint = telemetry.EventCheckpoint )
Telemetry event type constants.
const ( PhaseCheckpointSave = callback.PhaseCheckpointSave PhaseCheckpointLoad = callback.PhaseCheckpointLoad PhaseResumeStart = callback.PhaseResumeStart PhaseResumeComplete = callback.PhaseResumeComplete )
Checkpoint and resume callback phases.
Variables ¶
var ( NewTextFileSource = knowledge.NewTextFileSource NewPDFSource = knowledge.NewPDFSource NewCSVSource = knowledge.NewCSVSource NewJSONSource = knowledge.NewJSONSource NewURLSource = knowledge.NewURLSource )
Knowledge source constructors.
var ( NewOpenAI = llm.NewOpenAI NewAnthropic = llm.NewAnthropic NewGemini = llm.NewGemini NewDeepSeek = llm.NewDeepSeek NewMistral = llm.NewMistral NewOpenRouter = llm.NewOpenRouter NewAzureOpenAI = llm.NewAzureOpenAI NewOllama = llm.NewOllama NewOllamaWithURL = llm.NewOllamaWithURL NewGroq = llm.NewGroq NewTogetherAI = llm.NewTogetherAI NewBedrock = llm.NewBedrock NewVertexAI = llm.NewVertexAI NewOpenAICompatible = llm.NewOpenAICompatible WithTemperature = llm.WithTemperature WithMaxTokens = llm.WithMaxTokens WithTopP = llm.WithTopP WithTools = llm.WithTools WithSchema = llm.WithSchema WithToolChoice = llm.WithToolChoice )
LLM provider constructors and options.
var ( NewTool = tools.New ShellTool = tools.ShellTool CalculatorTool = tools.CalculatorTool ReadFileTool = tools.ReadFileTool WriteFileTool = tools.WriteFileTool EditFileTool = tools.EditFileTool DirTool = tools.DirTool WebSearchTool = tools.WebSearchTool NewWebSearchTool = tools.NewWebSearchTool WithNumResults = tools.WithNumResults WithTimeout = tools.WithTimeout AskHumanTool = tools.AskHumanTool NewAskHumanTool = tools.NewAskHumanTool WithEnabled = tools.WithEnabled WithPrompt = tools.WithPrompt WithAskTimeout = tools.WithAskTimeout WithStdout = tools.WithStdout DelegateWorkTool = tools.DelegateWorkTool DelegateToAgentTool = tools.DelegateToAgentTool AskAgentTool = tools.AskAgentTool BrowserTool = tools.BrowserTool WithChromePath = tools.WithChromePath WithTabTimeout = tools.WithTabTimeout WithHeadless = tools.WithHeadless WithRootDir = tools.WithRootDir )
Built-in tool constructors.
var ( NewShortTerm = memory.NewShortTerm NewEntityMemory = memory.NewEntityMemory )
Memory store constructors.
var ( ErrNoAgents = errors.ErrNoAgents ErrNoTasks = errors.ErrNoTasks ErrAgentNil = errors.ErrAgentNil ErrLLMFailed = errors.ErrLLMFailed ErrMaxIterations = errors.ErrMaxIterations ErrMaxRPM = errors.ErrMaxRPM ErrInvalidProcess = errors.ErrInvalidProcess ErrToolFailed = errors.ErrToolFailed ErrGuardrail = errors.ErrGuardrail ErrTaskFailed = errors.ErrTaskFailed ErrNoMatchingPath = errors.ErrNoMatchingPath ErrCycleDetected = errors.ErrCycleDetected ErrPathTraversal = errors.ErrPathTraversal ErrStringNotFound = errors.ErrStringNotFound WrapError = errors.Wrap WrapErrorE = errors.WrapE IsError = errors.Is ErrCheckpointNotFound = errors.ErrCheckpointNotFound )
Sentinel errors and error helpers.
var ( NewFlow = flow.New NewEventBus = telemetry.NewEventBus NewMetricsCollector = telemetry.NewMetricsCollector NewCallbackBridge = telemetry.NewCallbackBridge NewOTELBridge = telemetry.NewOTELBridge )
Constructor functions.
var ( NewRegexGuardrail = guardrail.NewRegexGuardrail NewLengthGuardrail = guardrail.NewLengthGuardrail NewContainsGuardrail = guardrail.NewContainsGuardrail NewBannedWordsGuardrail = guardrail.NewBannedWordsGuardrail NewJSONSchemaGuardrail = guardrail.NewJSONSchemaGuardrail )
Guardrail constructors.
var ( NewTrainingStore = training.NewFileStore NewFileStore = training.NewFileStore ConsolidateFeedback = training.Consolidate // LoadTrainingAdvice loads consolidated advice for an agent. LoadTrainingAdvice = training.LoadAdvice )
Training constructors.
var ( // ParseYAML parses a crew.yaml file. ParseYAML = yamlconfig.Parse ParseYAMLFile = yamlconfig.ParseFile ToCrewConfig = yamlconfig.ToCrewConfig )
CLI entrypoint.
var NewA2AClient = a2a.NewA2AClient
NewA2AClient creates a new A2A client.
var NewA2AServer = a2a.NewA2AServer
NewA2AServer creates a new A2A server.
var NewAgent = agent.New
NewAgent creates a new Agent with the given configuration.
var NewCrew = crew.New
NewCrew creates a new Crew with the given configuration.
var NewTask = task.New
NewTask creates a new Task with the given configuration.
Functions ¶
Types ¶
type A2AMessage ¶ added in v0.2.0
type A2AMessage = a2a.A2AMessage
A2AMessage is a type alias for a2a.A2AMessage.
type AskHumanOption ¶ added in v0.6.0
type AskHumanOption = tools.AskHumanOption
AskHumanOption is a type alias for tools.AskHumanOption.
type CallbackBridge ¶
type CallbackBridge = telemetry.CallbackBridge
CallbackBridge is a type alias for telemetry.CallbackBridge.
type CheckpointStore ¶
type CheckpointStore = crew.CheckpointStore
CheckpointStore is a type alias for crew.CheckpointStore.
type DurationHistogram ¶
type DurationHistogram = telemetry.DurationHistogram
DurationHistogram is a type alias for telemetry.DurationHistogram.
type EventBusConfig ¶ added in v0.6.0
type EventBusConfig = telemetry.EventBusConfig
EventBusConfig is a type alias for telemetry.EventBusConfig.
type GenerateOption ¶
type GenerateOption = llm.GenerateOption
GenerateOption is a type alias for llm.GenerateOption.
type KnowledgeChunk ¶ added in v0.4.0
KnowledgeChunk is a type alias for knowledge.Chunk.
type KnowledgeSource ¶ added in v0.4.0
type KnowledgeSource = knowledge.KnowledgeSource
KnowledgeSource is a type alias for knowledge.KnowledgeSource.
type MetricsSnapshot ¶
type MetricsSnapshot = telemetry.MetricsSnapshot
MetricsSnapshot is a type alias for telemetry.MetricsSnapshot.
type OTELBridge ¶
type OTELBridge = telemetry.OTELBridge
OTELBridge is a type alias for telemetry.OTELBridge.
type OutputCondition ¶
type OutputCondition = flow.OutputCondition
OutputCondition is a type alias for flow.OutputCondition.
type ProcessType ¶
type ProcessType = crew.ProcessType
ProcessType is a type alias for crew.ProcessType.
type StreamChunk ¶
type StreamChunk = llm.StreamChunk
StreamChunk is a type alias for llm.StreamChunk.
type TelemetryEvent ¶
TelemetryEvent is a type alias for telemetry.Event.
type TelemetryMetadata ¶
TelemetryMetadata is a type alias for telemetry.Metadata.
type TrainingFeedback ¶ added in v0.4.0
TrainingFeedback is a type alias for training.Feedback.
type TrainingStore ¶ added in v0.4.0
TrainingStore is a type alias for training.Store.
type YAMLEvalConfig ¶
type YAMLEvalConfig = yamlconfig.EvalConfig
YAMLEvalConfig is a type alias for yamlconfig.EvalConfig.
type YAMLEvalCriterionConfig ¶
type YAMLEvalCriterionConfig = yamlconfig.EvalCriterionConfig
YAMLEvalCriterionConfig is a type alias for yamlconfig.EvalCriterionConfig.
type YAMLLLMConfig ¶
type YAMLLLMConfig = yamlconfig.LLMConfig
YAMLLLMConfig is a type alias for yamlconfig.LLMConfig.
type YAMLMCPServerConfig ¶
type YAMLMCPServerConfig = yamlconfig.MCPServerConfig
YAMLMCPServerConfig is a type alias for yamlconfig.MCPServerConfig.
type YAMLMCPSetup ¶
type YAMLMCPSetup = yamlconfig.MCPSetup
YAMLMCPSetup is a type alias for yamlconfig.MCPSetup.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
a2a
command
@sk-task a2a#polish: A2A example — two agents communicating via HTTP
|
@sk-task a2a#polish: A2A example — two agents communicating via HTTP |
|
ask-human
command
This example demonstrates AskHumanTool.
|
This example demonstrates AskHumanTool. |
|
calc-tool
command
@sk-task calculator-tool documentation: runnable Go example
|
@sk-task calculator-tool documentation: runnable Go example |
|
dashboard
command
@sk-task dashboard-v2#T4.1: Dashboard integration example
|
@sk-task dashboard-v2#T4.1: Dashboard integration example |
|
features/browser
command
@sk-task browser-tool#T4.1: browser example
|
@sk-task browser-tool#T4.1: browser example |
|
features/guardrails
command
This example demonstrates output validation guardrails:
|
This example demonstrates output validation guardrails: |
|
features/knowledge
command
@sk-task knowledge-sources#T4.2: knowledge example
|
@sk-task knowledge-sources#T4.2: knowledge example |
|
features/mcp-stdio
command
@sk-task mcp-stdio-server docs: runnable Go example
|
@sk-task mcp-stdio-server docs: runnable Go example |
|
features/more-llm-providers
command
@sk-task more-llm-providers docs: runnable Go example
|
@sk-task more-llm-providers docs: runnable Go example |
|
features/training
command
This example demonstrates the Training/HITL loop:
|
This example demonstrates the Training/HITL loop: |
|
file-tools
command
@sk-task file-io-tools documentation: runnable Go example (AC-013)
|
@sk-task file-io-tools documentation: runnable Go example (AC-013) |
|
gemini-tool-calling
command
@sk-task gemini-tool-calling#T4.2: gemini tool calling example
|
@sk-task gemini-tool-calling#T4.2: gemini tool calling example |
|
mcp-server
command
MCP server example — exposes a DraftCrew agent as an MCP-compatible endpoint.
|
MCP server example — exposes a DraftCrew agent as an MCP-compatible endpoint. |
|
ollama
command
@sk-task dashboard-v2#T4.1: Ollama example with gemma3:4b
|
@sk-task dashboard-v2#T4.1: Ollama example with gemma3:4b |
|
ollama-dashboard
command
@sk-task dashboard-v2#T4.1: Ollama + Dashboard integration example
|
@sk-task dashboard-v2#T4.1: Ollama + Dashboard integration example |
|
process/flow
command
This example demonstrates a Flow (DAG) process with parallel execution.
|
This example demonstrates a Flow (DAG) process with parallel execution. |
|
process/state_machine
command
This example demonstrates a StateMachine process with conditional transitions.
|
This example demonstrates a StateMachine process with conditional transitions. |
|
quickstart
command
@sk-task foundation#T5.1: write quickstart example (AC-001, AC-015)
|
@sk-task foundation#T5.1: write quickstart example (AC-001, AC-015) |
|
sandbox
command
Sandbox example — runs code in an isolated WASM sandbox.
|
Sandbox example — runs code in an isolated WASM sandbox. |
|
web-search
command
@sk-task websearch-tool docs: runnable web search example
|
@sk-task websearch-tool docs: runnable web search example |
|
src
|
|
|
cmd/draftcrew
command
Package main implements the DraftCrew CLI with cobra and viper.
|
Package main implements the DraftCrew CLI with cobra and viper. |
|
eval
Package eval provides evaluation criteria for validating task outputs.
|
Package eval provides evaluation criteria for validating task outputs. |
|
mcp
Package mcp implements the MCP client with stdio and SSE transports.
|
Package mcp implements the MCP client with stdio and SSE transports. |
|
pkg/a2a
Package a2a provides connection registry for A2A communication graphs.
|
Package a2a provides connection registry for A2A communication graphs. |
|
pkg/dashboard
Package dashboard provides a real-time web UI for monitoring crew execution via SSE.
|
Package dashboard provides a real-time web UI for monitoring crew execution via SSE. |
|
pkg/guardrail
Package guardrail provides output validation guardrails for AI agent responses.
|
Package guardrail provides output validation guardrails for AI agent responses. |
|
pkg/llm
Package llm provides LLM provider abstractions for DraftCrew.
|
Package llm provides LLM provider abstractions for DraftCrew. |
|
pkg/mcp
Package mcp provides a thread-safe registry for discovered MCP tools.
|
Package mcp provides a thread-safe registry for discovered MCP tools. |
|
pkg/sandbox
Package sandbox provides sandboxed code execution via WASM (wazero) or Docker.
|
Package sandbox provides sandboxed code execution via WASM (wazero) or Docker. |
|
pkg/yamlconfig
Package yamlconfig parses DraftCrew YAML configuration files into Go structs.
|
Package yamlconfig parses DraftCrew YAML configuration files into Go structs. |
|
telemetry
module
|