{"modulePath":"github.com/OpenSIN-Code/SIN-Code-Bundle","version":"v1.9.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package orchestrator\n\nSPDX-License-Identifier: MIT Purpose: Agent abstraction + mock implementation. Real LLM-backed implementations would call a model API; for now, agents can be run in \"mock\" mode that produces deterministic placeholder output (useful for testing the dispatcher, planner, and aggregator in isolation).\n\nSPDX-License-Identifier: MIT Purpose: aggregator — combines sub-task results into a final response for the user. Validates success, formats output.\n\nSPDX-License-Identifier: MIT Purpose: dispatcher — runs plan tasks in parallel with dependency-aware scheduling. Tasks whose DependsOn are still running block until those complete. Results are merged into a shared scratchpad.\n\nSPDX-License-Identifier: MIT Purpose: small helpers shared across orchestrator files.\n\nSPDX-License-Identifier: MIT Purpose: orchestrator data model — Plan, Task, Agent, Result, ScratchpadEntry.\n\nSPDX-License-Identifier: MIT Purpose: LLMAgent — provider-agnostic LLM-backed agent. Uses the Provider field in AgentConfig to pick a backend (nim, openai, anthropic, ollama, groq, custom). Backwards-compatible: NIMAgent is a thin wrapper.\n\nSPDX-License-Identifier: MIT Purpose: top-level Orchestrator — wires together Router, Planner, Dispatcher, Registry, Scratchpad, Aggregator. This is the main entry point.\n\nSPDX-License-Identifier: MIT Purpose: planner — turns a user prompt + classified intent into a Plan with ordered sub-tasks, each bound to a specialized agent.\n\nSPDX-License-Identifier: MIT Purpose: agent registry — loads default agents, merges user agents from ~/.config/sin-code/agents/{name}/agent.toml, picks the right agent for a task type. Uses NIMAgent when SIN\\_NIM\\_API\\_KEY is set, MockAgent otherwise.\n\nSPDX-License-Identifier: MIT Purpose: Pre-LLM router — cheap intent classification using keyword heuristics. In production, this would call a Haiku-class model. For now, deterministic keyword scoring is the fallback when no LLM is configured.\n\n## Functions\n\n```go\nfunc DefaultUserAgentsPath() string\n```\n\n```go\nfunc GenerateID(prefix string) string\n```\n\n```go\nfunc UseLLM() bool\n```\nUseLLM returns true if any LLM provider is configured.\n\n```go\nfunc UseNIM() bool\n```\n\n## Types\n\n```go\ntype Agent interface {\n\tName() string\n\tConfig() AgentConfig\n\tRun(ctx context.Context, task *Task, scratch *Scratchpad) (string, error)\n}\n```\n\n```go\ntype AgentConfig struct {\n\tName          string   `toml:\"name\"`\n\tDescription   string   `toml:\"description\"`\n\tType          TaskType `toml:\"type\"`\n\tProvider      string   `toml:\"provider\"`\n\tBaseURL       string   `toml:\"base_url\"`\n\tModel         string   `toml:\"model\"`\n\tMaxTokens     int      `toml:\"max_tokens\"`\n\tTemperature   float64  `toml:\"temperature\"`\n\tSystemFile    string   `toml:\"system_file\"`\n\tMaxContext    int      `toml:\"max_context_tokens\"`\n\tToolsAllow    []string `toml:\"tools_allow\"`\n\tToolsDeny     []string `toml:\"tools_deny\"`\n\tMemoryNS      string   `toml:\"memory_namespace\"`\n\tRetentionDays int      `toml:\"retention_days\"`\n}\n```\n\n```go\nfunc DefaultAgents() []AgentConfig\n```\n\n```go\nfunc LoadUserAgents(baseDir string) ([]AgentConfig, error)\n```\n\n```go\ntype Aggregator struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewAggregator(scratch *Scratchpad) *Aggregator\n```\n\n```go\nfunc (a *Aggregator) Aggregate(plan *Plan) *Result\n```\n\n```go\ntype Dispatcher struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewDispatcher(registry *Registry, scratch *Scratchpad, maxParallel int) *Dispatcher\n```\n\n```go\nfunc (d *Dispatcher) Dispatch(ctx context.Context, plan *Plan) error\n```\n\n```go\ntype Intent string\n```\n\n```go\nconst (\n\tIntentCodebase     Intent = \"codebase_change\"\n\tIntentTest         Intent = \"test_work\"\n\tIntentReview       Intent = \"code_review\"\n\tIntentDocs         Intent = \"documentation\"\n\tIntentSecurity     Intent = \"security_audit\"\n\tIntentArchitecture Intent = \"architecture\"\n\tIntentGeneral      Intent = \"general_query\"\n)\n```\n\n```go\ntype LLMAgent struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewLLMAgent(cfg AgentConfig) *LLMAgent\n```\n\n```go\nfunc NewLLMAgentWithClient(cfg AgentConfig, client *llm.Client) *LLMAgent\n```\n\n```go\nfunc (a *LLMAgent) Config() AgentConfig\n```\n\n```go\nfunc (a *LLMAgent) Name() string\n```\n\n```go\nfunc (a *LLMAgent) Run(ctx context.Context, task *Task, scratch *Scratchpad) (string, error)\n```\n\n```go\ntype MockAgent struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewMockAgent(cfg AgentConfig) *MockAgent\n```\n\n```go\nfunc (m *MockAgent) Config() AgentConfig\n```\n\n```go\nfunc (m *MockAgent) Name() string\n```\n\n```go\nfunc (m *MockAgent) Run(ctx context.Context, task *Task, scratch *Scratchpad) (string, error)\n```\n\n```go\ntype NIMAgent = LLMAgent\n```\nBackwards-compat alias.\n\n```go\nfunc NewNIMAgent(cfg AgentConfig) *NIMAgent\n```\n\n```go\nfunc NewNIMAgentWithClient(cfg AgentConfig, client *llm.Client) *NIMAgent\n```\n\n```go\ntype Orchestrator struct {\n\tRegistry    *Registry\n\tPlanner     *Planner\n\tDispatcher  *Dispatcher\n\tAggregator  *Aggregator\n\tScratchpad  *Scratchpad\n\tMaxParallel int\n}\n```\n\n```go\nfunc New() *Orchestrator\n```\n\n```go\nfunc NewWithAgents(extraConfigs []AgentConfig) *Orchestrator\n```\n\n```go\nfunc (o *Orchestrator) Plan(prompt string) *Plan\n```\n\n```go\nfunc (o *Orchestrator) Run(ctx context.Context, prompt string, opts ...RunOption) (*Result, error)\n```\n\n```go\nfunc (o *Orchestrator) String() string\n```\n\n```go\ntype Plan struct {\n\tID         string    `json:\"id\"`\n\tPrompt     string    `json:\"prompt\"`\n\tIntent     Intent    `json:\"intent\"`\n\tTasks      []*Task   `json:\"tasks\"`\n\tCreated    time.Time `json:\"created\"`\n\tStarted    time.Time `json:\"started\"`\n\tCompleted  time.Time `json:\"completed\"`\n\tTotalCost  float64   `json:\"total_cost\"`\n\tTokensUsed int       `json:\"tokens_used\"`\n\tSuccess    bool      `json:\"success\"`\n}\n```\n\n```go\ntype Planner struct {\n\tRouter *Router\n\tAgents []AgentConfig\n}\n```\n\n```go\nfunc NewPlanner(agents []AgentConfig) *Planner\n```\n\n```go\nfunc (p *Planner) BuildPlan(prompt string) *Plan\n```\n\n```go\ntype Registry struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewRegistry(agents []Agent) *Registry\n```\n\n```go\nfunc NewRegistryWithDefaults(extraConfigs []AgentConfig) *Registry\n```\n\n```go\nfunc (r *Registry) ForType(tt TaskType) (Agent, bool)\n```\n\n```go\nfunc (r *Registry) Get(name string) (Agent, bool)\n```\n\n```go\nfunc (r *Registry) List() []AgentConfig\n```\n\n```go\nfunc (r *Registry) Register(a Agent)\n```\n\n```go\ntype Result struct {\n\tPlan        *Plan\n\tSections    map[string]string\n\tTotalTasks  int\n\tOKTasks     int\n\tFailedTasks int\n\tSummary     string\n}\n```\n\n```go\ntype Router struct {\n\tKeywords map[Intent][]string\n}\n```\n\n```go\nfunc NewRouter() *Router\n```\n\n```go\nfunc (r *Router) Classify(prompt string) Intent\n```\n\n```go\nfunc (r *Router) SubIntents(prompt string) []Intent\n```\n\n```go\ntype RunOption func(*runConfig)\n```\n\n```go\nfunc WithMaxParallel(n int) RunOption\n```\n\n```go\nfunc WithTimeout(d time.Duration) RunOption\n```\n\n```go\ntype Scratchpad struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewScratchpad() *Scratchpad\n```\n\n```go\nfunc (s *Scratchpad) Merge(other *Scratchpad)\n```\n\n```go\nfunc (s *Scratchpad) Read(section string) (string, bool)\n```\n\n```go\nfunc (s *Scratchpad) ReadAll() map[string]*ScratchpadEntry\n```\n\n```go\nfunc (s *Scratchpad) Write(agent, section, content string)\n```\n\n```go\ntype ScratchpadEntry struct {\n\tTimestamp time.Time `json:\"timestamp\"`\n\tAgent     string    `json:\"agent\"`\n\tSection   string    `json:\"section\"`\n\tContent   string    `json:\"content\"`\n\tVersion   int       `json:\"version\"`\n}\n```\n\n```go\ntype Task struct {\n\tID          string     `json:\"id\"`\n\tType        TaskType   `json:\"type\"`\n\tDescription string     `json:\"description\"`\n\tAgentName   string     `json:\"agent\"`\n\tDependsOn   []string   `json:\"depends_on,omitempty\"`\n\tStatus      TaskStatus `json:\"status\"`\n\tResult      string     `json:\"result,omitempty\"`\n\tError       string     `json:\"error,omitempty\"`\n\tCreated     time.Time  `json:\"created\"`\n\tStarted     *time.Time `json:\"started,omitempty\"`\n\tCompleted   *time.Time `json:\"completed,omitempty\"`\n\tTokensUsed  int        `json:\"tokens_used\"`\n\tCost        float64    `json:\"cost\"`\n}\n```\n\n```go\ntype TaskStatus string\n```\n\n```go\nconst (\n\tTaskPending   TaskStatus = \"pending\"\n\tTaskRunning   TaskStatus = \"running\"\n\tTaskCompleted TaskStatus = \"completed\"\n\tTaskFailed    TaskStatus = \"failed\"\n\tTaskCancelled TaskStatus = \"cancelled\"\n\tTaskBlocked   TaskStatus = \"blocked\"\n)\n```\n\n```go\ntype TaskType string\n```\n\n```go\nconst (\n\tTaskCode      TaskType = \"code\"\n\tTaskTest      TaskType = \"test\"\n\tTaskReview    TaskType = \"review\"\n\tTaskDocs      TaskType = \"docs\"\n\tTaskSecurity  TaskType = \"security\"\n\tTaskArchitect TaskType = \"architect\"\n\tTaskGeneral   TaskType = \"general\"\n)\n```\n\n","path":"github.com/OpenSIN-Code/SIN-Code-Bundle/cmd/sin-code/internal/orchestrator","name":"orchestrator","synopsis":"SPDX-License-Identifier: MIT Purpose: Agent abstraction + mock implementation.","isRedistributable":true}
