agent_cmd

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectCmd = &cli.Command{
	Name:        "connect",
	Usage:       "Connect to the Server",
	Description: "Asks the running agent to generate a new API key on the server and stores it in the local config.",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:         "tls-skip-verify",
			Usage:        "Skip TLS verification when talking to server.",
			ConfigPath:   []string{"tls.skip_verify"},
			EnvVars:      []string{config.CONFIG_ENV_PREFIX + "_TLS_SKIP_VERIFY"},
			DefaultValue: true,
			Global:       true,
		},
	},
	Commands: []*cli.Command{
		connectcmd.ConnectListCmd,
		connectcmd.ConnectDeleteCmd,
	},
	Run: func(ctx context.Context, cmd *cli.Command) error {
		var response agentlink.ConnectResponse

		err := agentlink.SendWithResponseMsg(agentlink.CommandConnect, nil, &response)
		if err != nil {
			return fmt.Errorf("unable to connect to the agent, please check that the agent is running: %w", err)
		}

		if !response.Success {
			return fmt.Errorf("failed to create an API token: %w", err)
		}

		if err := config.SaveConnection("default", response.Server, response.Token, cmd); err != nil {
			return fmt.Errorf("failed to save connection details: %w", err)
		}

		fmt.Println("Successfully connected to server:", response.Server)
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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