api

package
v0.0.0-...-6431184 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DocsDir string

DocsDir is set by InitModules to the extracted docs directory (dataDir/docs).

View Source
var MCPHandler http.Handler
View Source
var TextureWorkdir string

TextureWorkdir is set by InitModules from the configured dataDir.

View Source
var Turtles []Turtle
View Source
var Upgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool { return true },
}

Functions

func CreateApiServer

func CreateApiServer(domain string, port int, dataDir string, staticFS embed.FS, docsFS embed.FS)

func EnsureDocRepos

func EnsureDocRepos()

EnsureDocRepos checks each entry in the manifest and clones the repo if the target directory does not already contain a git repository. Runs each clone sequentially; call in a goroutine to avoid blocking startup.

func ExtractResources

func ExtractResources()

func GetDocs

func GetDocs(w http.ResponseWriter, r *http.Request)

func GetManifest

func GetManifest(w http.ResponseWriter, r *http.Request)

func InitModules

func InitModules(m *mux.Router, dataDir string, docsFS embed.FS)

func InitWorldMap

func InitWorldMap(dbPath string) error

InitWorldMap opens (or creates) the SQLite world map database.

func ListDocs

func ListDocs(w http.ResponseWriter, r *http.Request)

func RecordTurtleSight

func RecordTurtleSight(t Turtle)

RecordTurtleSight extracts block observations from a turtle's sight data and upserts them into the world map. Called on every heartbeat.

func ReturnData

func ReturnData(w http.ResponseWriter, data interface{})

ReturnData returns data as json to the client

func ReturnDataRaw

func ReturnDataRaw(w http.ResponseWriter, data []byte, headers map[string]string)

func ReturnError

func ReturnError(w http.ResponseWriter, code int, message string)

ReturnError returns an error to the client with the specified status code and message

func TextureHandle

func TextureHandle(w http.ResponseWriter, r *http.Request)

func TurtleHandle

func TurtleHandle(w http.ResponseWriter, r *http.Request)

func TurtleHandleWs

func TurtleHandleWs(w http.ResponseWriter, r *http.Request)

handle turtle websocket

func TurtleUsage

func TurtleUsage() string

func Name() string { return `turtle` } //OP func Version() string { return `0.1.0` } func Desc() string { return `The Base turtle control API` } //OP

Types

type ActiveConnections

type ActiveConnections struct {
	// contains filtered or unexported fields
}

Connection tracking for synchronous command execution

type BlockRecord

type BlockRecord struct {
	X          int                    `json:"x"`
	Y          int                    `json:"y"`
	Z          int                    `json:"z"`
	Name       *string                `json:"name"`
	State      interface{}            `json:"state,omitempty"`
	Extra      map[string]interface{} `json:"extra,omitempty"`
	ObservedAt int64                  `json:"observed_at"`
	ObservedBy int                    `json:"observed_by"`
}

func FindBlock

func FindBlock(nameSearch string, limit int) ([]BlockRecord, error)

FindBlock returns all known coordinates where name contains the search string. Results capped at limit (max 500).

func GetBlock

func GetBlock(x, y, z int) (*BlockRecord, error)

GetBlock returns the known data for a single coordinate, or nil if unknown.

func GetRegion

func GetRegion(x1, y1, z1, x2, y2, z2 int) ([]BlockRecord, error)

GetRegion returns all known blocks within a bounding box. Capped at 1000.

type CommandError

type CommandError struct {
	Message string
}

Custom error type for command execution

func (*CommandError) Error

func (e *CommandError) Error() string

type CommandRequest

type CommandRequest struct {
	Command   string `json:"command"`
	RequestID string `json:"requestId"`
}

Command request/response structures

type CommandResponse

type CommandResponse struct {
	RequestID string      `json:"requestId"`
	Result    interface{} `json:"result"`
	Success   bool        `json:"success"`
}

type DocEntry

type DocEntry struct {
	Name  string `json:"name"`
	Repo  string `json:"repo"`
	Root  string `json:"root"`
	Local bool   `json:"local,omitempty"`
}

DocEntry mirrors one entry in mcp/docs/manifest.json

type DocManifest

type DocManifest struct {
	Docs []DocEntry `json:"docs"`
}

DocManifest is the top-level structure of manifest.json

func ReadManifest

func ReadManifest() (*DocManifest, error)

ReadManifest reads and parses manifest.json from DocsDir.

type Turtle

type Turtle struct {
	Name         string        `json:"name"`
	ID           int           `json:"id"`
	Inventory    []interface{} `json:"inventory"`
	SelectedSlot int           `json:"selectedSlot"`
	Pos          struct {
		Y     int    `json:"y"`
		X     int    `json:"x"`
		Z     int    `json:"z"`
		R     int    `json:"r"`
		Rname string `json:"rname"`
	} `json:"pos"`
	Fuel struct {
		Current int `json:"current"`
		Max     int `json:"max"`
	} `json:"fuel"`
	Sight struct {
		Up    interface{} `json:"up"`
		Down  interface{} `json:"down"`
		Front interface{} `json:"front"`
		Left  interface{} `json:"left,omitempty"`
		Right interface{} `json:"right,omitempty"`
		Back  interface{} `json:"back,omitempty"`
	} `json:"sight"`
	CmdResult interface{} `json:"cmdResult"`
	CmdQueue  []string    `json:"cmdQueue"`
	Misc      interface{} `json:"misc"`
	HeartBeat int         `json:"heartbeat"`
}

type TurtleCommandMutex

type TurtleCommandMutex struct {
	// contains filtered or unexported fields
}

Per-turtle command serialization

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL