Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EnvironmentDefinition = BuiltinDefinition{ Description: "Get all environment variables of the user's system.", Parameter: map[string]any{ "type": "object", "properties": map[string]any{}, "additionalProperties": false, "required": []string{}, }, Function: func(ctx context.Context, jsonArguments string) ([]byte, error) { var pArgs EnvironmentArguments err := json.Unmarshal([]byte(jsonArguments), &pArgs) if err != nil { return nil, fmt.Errorf("error parsing arguments: %w", err) } result := EnvironmentResult{ Environment: map[string]string{}, } for _, e := range os.Environ() { pair := strings.SplitN(e, "=", 2) result.Environment[pair[0]] = pair[1] } return json.Marshal(result) }, }
View Source
var SystemInfoDefinition = BuiltinDefinition{ Description: "Get the following information about the user's system: OS, architecture, number of CPUs, hostname, user directory, user ID, group ID, working directory, process ID.", Parameter: map[string]any{ "type": "object", "properties": map[string]any{}, "required": []string{}, }, Function: func(ctx context.Context, jsonArguments string) ([]byte, error) { return json.Marshal(SystemInfoResult{ OS: runtime.GOOS, Arch: runtime.GOARCH, CPU: runtime.NumCPU(), Hostname: func() string { h, err := os.Hostname() if err != nil { return "unknown" } return h }(), UserDir: func() string { home, err := os.UserHomeDir() if err != nil { return "unknown" } return home }(), UserId: os.Getuid(), GroupId: os.Getgid(), WorkDir: func() string { dir, err := os.Getwd() if err != nil { return "unknown" } return dir }(), PID: os.Getpid(), }) }, }
View Source
var SystemTimeDefinition = BuiltinDefinition{ Description: "Get the current system time.", Parameter: map[string]any{ "type": "object", "properties": map[string]any{}, "required": []string{}, }, Function: func(ctx context.Context, jsonArguments string) ([]byte, error) { return []byte(time.Now().String()), nil }, }
Functions ¶
This section is empty.
Types ¶
type BuiltinDefinition ¶
type EnvironmentArguments ¶
type EnvironmentArguments struct {
}
type EnvironmentResult ¶
type SystemInfoArguments ¶
type SystemInfoArguments struct {
}
type SystemInfoResult ¶
Click to show internal directories.
Click to hide internal directories.