Files
gnoma/internal/tool/tool.go
vikingowl f0633d8ac6 feat: complete M1 — core engine with Mistral provider
Mistral provider adapter with streaming, tool calls (single-chunk
pattern), stop reason inference, model listing, capabilities, and
JSON output support.

Tool system: bash (7 security checks, shell alias harvesting for
bash/zsh/fish), file ops (read, write, edit, glob, grep, ls).
Alias harvesting collects 300+ aliases from user's shell config.

Engine agentic loop: stream → tool execution → re-query → until
done. Tool gating on model capabilities. Max turns safety limit.

CLI pipe mode: echo "prompt" | gnoma streams response to stdout.
Flags: --provider, --model, --system, --api-key, --max-turns,
--verbose, --version.

Provider interface expanded: Models(), DefaultModel(), Capabilities
(ToolUse, JSONOutput, Vision, Thinking, ContextWindow, MaxOutput),
ResponseFormat with JSON schema support.

Live verified: text streaming + tool calling with devstral-small.
117 tests across 8 packages, 10MB binary.
2026-04-03 12:01:55 +02:00

23 lines
716 B
Go

package tool
import (
"context"
"encoding/json"
)
// Tool is the interface every tool must implement.
type Tool interface {
// Name returns the tool's identifier (used in LLM tool schemas).
Name() string
// Description returns a human-readable description for the LLM.
Description() string
// Parameters returns the JSON Schema for the tool's input.
Parameters() json.RawMessage
// Execute runs the tool with the given JSON arguments.
Execute(ctx context.Context, args json.RawMessage) (Result, error)
// IsReadOnly returns true if the tool only reads (safe for concurrent execution).
IsReadOnly() bool
// IsDestructive returns true if the tool can cause irreversible changes.
IsDestructive() bool
}