command

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package services Description: This file contains the implementation of the CommandServer interface for macOS and Linux.

Index

Constants

View Source
const (
	CommandPromptDefault = `` /* 1621-byte string literal not displayed */

)
View Source
const (
	CommandServerName comm.MoLingServerType = "Command"
)

Variables

View Source
var (
	// ErrCommandNotFound is returned when the command is not found.
	ErrCommandNotFound = fmt.Errorf("command not found")
	// ErrCommandNotAllowed is returned when the command is not allowed.
	ErrCommandNotAllowed = fmt.Errorf("command not allowed")
)

Functions

func ExecCommand

func ExecCommand(command string) (string, error)

ExecCommand executes a command and returns its output.

func NewCommandServer

func NewCommandServer(ctx context.Context) (abstract.Service, error)

NewCommandServer creates a new CommandServer with the given allowed commands.

Types

type CommandConfig

type CommandConfig struct {
	PromptFile string `json:"prompt_file"` // PromptFile is the prompt file for the command.

	AllowedCommand string `json:"allowed_command"` // AllowedCommand is a list of allowed command. split by comma. e.g. ls,cat,echo
	// contains filtered or unexported fields
}

CommandConfig represents the configuration for allowed commands.

func NewCommandConfig

func NewCommandConfig() *CommandConfig

NewCommandConfig creates a new CommandConfig with the given allowed commands.

func (*CommandConfig) Check

func (cc *CommandConfig) Check() error

Check validates the allowed commands in the CommandConfig.

type CommandServer

type CommandServer struct {
	abstract.MLService
	// contains filtered or unexported fields
}

CommandServer implements the Service interface and provides methods to execute named commands.

func (*CommandServer) Close

func (cs *CommandServer) Close() error

func (*CommandServer) Config

func (cs *CommandServer) Config() string

Config returns the configuration of the service as a string.

func (*CommandServer) Init

func (cs *CommandServer) Init() error

func (*CommandServer) LoadConfig

func (cs *CommandServer) LoadConfig(jsonData map[string]any) error

LoadConfig loads the configuration from a JSON object.

func (*CommandServer) Name

func (cs *CommandServer) Name() comm.MoLingServerType

Jump to

Keyboard shortcuts

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