Lists exported types, functions, methods and key notes by package. For brevity, only externally available members and necessary comments are listed.
Package import prefix: github.com/TencentCloudAgentRuntime/ags-go-sdk
Import: github.com/TencentCloudAgentRuntime/ags-go-sdk/connection
type Config struct {
Domain string
AccessToken string
Headers http.Header
Proxy *url.URL
}func NewConfig() *Config- Used for connection information of various tool clients.
Domainis in the format"<sandboxId>.<region>.tencentags.com"(generated bysandbox/core).Domainintool/codeand other Clients includes the corresponding port, in the format"{port}-{sandboxId}.{region}.tencentags.com"AccessTokenis issued internally bycore.Create/Connect.
Import: github.com/TencentCloudAgentRuntime/ags-go-sdk/constant
const (
AgentSandboxInternalEndpoint = "ags.internal.tencentcloudapi.com"
EnvdPort = 49983
CodePort = 49999
)Import: github.com/TencentCloudAgentRuntime/ags-go-sdk/sandbox/core
type Core struct {
SandboxId string
ConnectionConfig *connection.Config
// Internal fields: client
}func NewCore(client *ags.Client, sandboxId string, cfg *connection.Config) *CoreCreates a new Core instance.
func (c *Core) GetHost(port int) stringGenerates a domain in the format "{port}-{sandboxId}.{region}.tencentags.com".
func (c *Core) Kill(ctx context.Context) errorTerminates the sandbox instance.
func (c *Core) SetTimeoutSeconds(ctx context.Context, seconds int) errorSets the sandbox timeout in seconds.
func (c *Core) GetInfo(ctx context.Context) (*ags.SandboxInstance, error)Gets detailed sandbox information.
func Create(ctx context.Context, toolName string, opts ...CreateOption) (*Core, error)Creates a new sandbox and returns a Core instance.
func Connect(ctx context.Context, sandboxId string, opts ...ConnectOption) (*Core, error)Connects to an existing sandbox and returns a Core instance.
func List(ctx context.Context, opts ...ListOption) ([]*ags.SandboxInstance, error)Lists all sandbox instances.
func Kill(ctx context.Context, sandboxId string, opts ...KillOption) errorDestroys the specified sandbox.
type ClientOption interface {
CreateOption
ConnectOption
ListOption
KillOption
}func WithClient(client *ags.Client) ClientOptionSets the AGS client instance. This option takes precedence over WithCredential and WithRegion.
func WithCredential(cred common.CredentialIface) ClientOptionSets Tencent Cloud credentials. Must be used with WithRegion to create a new AGS client.
func WithRegion(region string) ClientOptionSets the Tencent Cloud region. Must be used with WithCredential to create a new AGS client. Default region is ap-guangzhou.
- When
WithClientis not specified, bothWithCredentialandWithRegionmust be provided to create an AGS Client. - The Core returned by
Createhas built-inConnectionConfig, which can be used to initialize various tool clients.
Import: github.com/TencentCloudAgentRuntime/ags-go-sdk/sandbox/code
type Sandbox struct {
*core.Core
Files *filesystem.Client
Commands *command.Client
Code *code.Client
}Code sandbox instance, embeds core.Core and provides three tool clients.
func Create(ctx context.Context, toolName string, opts ...CreateOption) (*Sandbox, error)Creates a sandbox and initializes Files/Commands/Code three clients.
func Connect(ctx context.Context, sandboxId string, opts ...ConnectOption) (*Sandbox, error)Connects to an existing sandbox and initializes three clients.
func List(ctx context.Context, opts ...ListOption) ([]*ags.SandboxInstance, error)Lists all sandbox instances.
func Kill(ctx context.Context, sandboxId string, opts ...KillOption) errorDestroys the specified sandbox.
type ClientOption interface {
CreateOption
ConnectOption
ListOption
KillOption
}func WithClient(client *ags.Client) ClientOption
func WithCredential(cred common.CredentialIface) ClientOption
func WithRegion(region string) ClientOptionOptions are similar to those in sandbox/core, passed through to underlying core operations.
Import: github.com/TencentCloudAgentRuntime/ags-go-sdk/tool/code
type Client struct {
// Internal fields: config, httpClient
}func New(cfg *connection.Config) *ClientCreates a new code execution client.
func (c *Client) RunCode(ctx context.Context, code string, config *RunCodeConfig, onOutput *OnOutputConfig) (*Execution, error)Executes code and returns execution results.
- If
configsets bothLanguageandContextId, an error will be returned. - Default
Language=python(when neitherLanguagenorContextIdis specified). onOutputis optional: real-time output callback (stdout/stderr), does not affect the final aggregated result.
func (c *Client) CreateCodeContext(ctx context.Context, config *CreateCodeContextConfig) (*CodeContext, error)Creates a code execution context.
type RunCodeConfig struct {
Language string
ContextId string
Envs map[string]string
}Code execution configuration.
type OnOutputConfig struct {
OnStdout func(string)
OnStderr func(string)
}Output callback configuration:
OnStdout: Receives real-time stdout textOnStderr: Receives real-time stderr text- If
nilis passed or any callback isnil, the corresponding callback will not be called; the finalExecution.Logsstill retains aggregated logs
type CreateCodeContextConfig struct {
Cwd string
Language string
}Context creation configuration. Default Cwd="/home/user", Language="python".
type Execution struct {
Results []Result
Logs Logs
Error *ExecutionError
ExecutionCount *int
}Code execution result summary.
type Result struct {
Text *string
Html *string
Markdown *string
Svg *string
Png *string
Jpeg *string
Pdf *string
Latex *string
Javascript *string
Json map[string]any
Data map[string]any
Chart map[string]any
IsMainResult bool
Extra map[string]any
}Single execution result, supports multiple formats.
type Logs struct {
Stdout []string
Stderr []string
}Standard output and standard error logs.
type ExecutionError struct {
Name string
Value string
Traceback string
}Execution error information.
type CodeContext struct {
Id string
Language string
Cwd string
}Code context information.
Import: github.com/TencentCloudAgentRuntime/ags-go-sdk/tool/command
type Client struct {
// Internal fields: config, httpClient, rpcClient
}func New(cfg *connection.Config) (*Client, error)Creates a new command execution client.
func (c *Client) Run(ctx context.Context, cmd string, config *ProcessConfig, onOutput *OnOutputConfig) (*Result, error)Convenient foreground command execution, aggregates stdout/stderr and exit code.
func (c *Client) Start(ctx context.Context, cmd string, config *ProcessConfig, onOutput *OnOutputConfig) (*Handle, error)Background command execution, returns Handle.
func (c *Client) Connect(ctx context.Context, pid uint32, onOutput *OnOutputConfig) (*Handle, error)Connects to an existing process.
func (c *Client) List(ctx context.Context) ([]ProcessInfo, error)Lists currently running processes.
type ProcessConfig struct {
User string
Args []string
Envs map[string]string
Cwd *string
}Process configuration. User defaults to "user", only allows "user" or "root".
type OnOutputConfig struct {
OnStdout func([]byte)
OnStderr func([]byte)
}Output callback configuration.
type ProcessInfo struct {
Pid uint32
Tag *string
Cmd string
Args []string
Envs map[string]string
Cwd *string
}Process information.
type ProcessResult struct {
ExitCode int32
Error *string
}Process execution result.
type Result struct {
ExitCode int32
Stdout []byte
Stderr []byte
Error *string
}Aggregated foreground execution result.
type Handle struct {
Pid uint32
// Internal fields: cancel, stream, client, onStdout, onStderr
}Process handle for controlling and monitoring processes.
func (h *Handle) Wait(ctx context.Context) (*ProcessResult, error)Waits for the process to end and returns the result.
func (h *Handle) Kill(ctx context.Context) errorSends SIGKILL signal to terminate the process.
func (h *Handle) Disconnect(ctx context.Context) errorDisconnects without terminating the process.
func (h *Handle) SendInput(ctx context.Context, pid uint32, stdin []byte) errorSends input to the process.
func (h *Handle) SendSignal(ctx context.Context, pid uint32, sig process.Signal) errorSends a signal to the process. Signal values e.g.: 15 (SIGTERM), 9 (SIGKILL).
Import: github.com/TencentCloudAgentRuntime/ags-go-sdk/tool/filesystem
type Client struct {
// Internal fields: config, httpClient, rpcClient
}func New(cfg *connection.Config) (*Client, error)Creates a new filesystem client.
func (c *Client) Read(ctx context.Context, path string, config *ReadConfig) (io.Reader, error)Reads file content.
func (c *Client) Write(ctx context.Context, path string, data io.Reader, config *WriteConfig) (*WriteInfo, error)Writes to a file.
func (c *Client) List(ctx context.Context, path string, config *ListConfig) ([]EntryInfo, error)Lists directory contents.
func (c *Client) Exists(ctx context.Context, path string, config *ExistsConfig) (bool, error)Checks if a file or directory exists.
func (c *Client) GetInfo(ctx context.Context, path string, config *GetInfoConfig) (*EntryInfo, error)Gets detailed file or directory information.
func (c *Client) Remove(ctx context.Context, path string, config *RemoveConfig) errorRemoves a file or directory.
func (c *Client) Rename(ctx context.Context, oldPath, newPath string, config *RenameConfig) errorRenames or moves a file/directory.
func (c *Client) MakeDir(ctx context.Context, path string, config *MakeDirConfig) (bool, error)Creates a directory. Returns true if creation was successful.
type FileType string
const (
File FileType = "file"
Dir FileType = "dir"
)File type constants.
type WriteInfo struct {
Name string
Type *FileType
Path string
}Basic information returned by write operations.
type EntryInfo struct {
WriteInfo
Size int64
Mode int
Permissions string
Owner string
Group string
ModifiedTime time.Time
SymlinkTarget *string
}Detailed file or directory information.
type FilesystemEventType string
const (
EventCreate FilesystemEventType = "create"
EventWrite FilesystemEventType = "write"
EventRemove FilesystemEventType = "remove"
EventRename FilesystemEventType = "rename"
EventChmod FilesystemEventType = "chmod"
)Filesystem event types (currently reserved functionality).
All filesystem operation configuration types:
type ReadConfig struct{ User string }
type WriteConfig struct{ User string }
type ListConfig struct{ Depth int; User string }
type ExistsConfig struct{ User string }
type GetInfoConfig struct{ User string }
type RemoveConfig struct{ User string }
type RenameConfig struct{ User string }
type MakeDirConfig struct{ User string }- All
*Config.Useronly allows "user" or "root"; defaults to "user" when empty. Read/Writeuse HTTP/filesendpoint; others use RPC interface.ListConfig.Depthspecifies recursion depth, default is 1.