Documentation
¶
Index ¶
- Constants
- type JobEvent
- type JobEventKind
- type JobInfo
- type Jobs
- type Options
- type Output
- type Run
- type Shell
- func (s *Shell) Close()
- func (s *Shell) Command() tool.Tool
- func (s *Shell) Dir() string
- func (s *Shell) Fork(ctx context.Context, line string, stdout, stderr io.Writer, ...) Output
- func (s *Shell) Job(id string) (JobInfo, bool)
- func (s *Shell) Jobs() []JobInfo
- func (s *Shell) Kill() tool.Tool
- func (s *Shell) KillJob(ctx context.Context, id string) error
- func (s *Shell) Output() tool.Tool
- func (s *Shell) RunWith(ctx context.Context, line string, stdout, stderr io.Writer, ...) Output
- func (s *Shell) StartJob(callID, description, line string, timeout time.Duration) (string, error)
- func (s *Shell) Tail(id string, from int64) (data []byte, next int64, dropped int64, ok bool)
- func (s *Shell) Tools() []tool.Tool
- func (s *Shell) Wait(id string) (<-chan struct{}, bool)
Constants ¶
const ( ShellName = "Shell" OutputName = "ShellOutput" KillName = "KillShell" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JobEvent ¶
type JobEvent struct {
Kind JobEventKind
Job JobInfo
// Output chunk on output events
Data []byte
}
What changed about a background job
type JobEventKind ¶
type JobEventKind string
const ( JobStarted JobEventKind = "started" JobOutput JobEventKind = "output" JobFinished JobEventKind = "finished" )
type JobInfo ¶
type JobInfo struct {
ID string
CallID string
Line string
Description string
Dir string
Started time.Time
Finished time.Time
Running bool
ExitCode int
TimedOut bool
// Bytes of output produced so far
Bytes int64
}
Snapshot of one background job
type Jobs ¶
type Jobs struct {
// contains filtered or unexported fields
}
Table of background jobs keyed by id
type Options ¶
type Options struct {
// Starting directory, the process working directory when empty
Dir string
// KEY=VALUE pairs layered over the environment the shell starts with
Env []string
// Run allowed a command the model names no timeout for, unlimited when zero
Timeout time.Duration
// Largest timeout the model may ask for, any when zero
MaxTimeout time.Duration
// Receives every background job start, output chunk and finish
OnJob func(JobEvent)
}
Settings shared by the shell tools
type Output ¶
type Output struct {
ExitCode int
// Exit code of every stage of the last pipeline the command ran, empty when it ran none
Pipeline []int
// Command name of every stage of that pipeline
Commands []string
Dir string
TimedOut bool
// The command ended the shell with exit
Exited bool
Duration time.Duration
}
How a command ended, with the working directory it left behind
type Run ¶
type Run struct {
Command string
Description string
Dir string
ExitCode int
Pipeline []int
TimedOut bool
// The command ended the shell with exit and the next call starts a fresh one
Exited bool
Duration time.Duration
Stdout string
Stderr string
}
Structured outcome of a foreground Shell call
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell state shared by Shell, ShellOutput and KillShell
func (*Shell) Close ¶
func (s *Shell) Close()
Stops every background job, then the shell with everything it started
func (*Shell) Command ¶
Tool that runs a command line in the shell, foreground or as a background job
func (*Shell) Fork ¶
func (s *Shell) Fork(ctx context.Context, line string, stdout, stderr io.Writer, timeout time.Duration) Output
Fork runs a command line beside the agent's shell, on a copy of it as it stands with the same directory and environment, so a long scan never queues behind the agent's own Shell calls and the agent never waits behind it
func (*Shell) Output ¶
Tool that returns the output a background job produced since the previous call
func (*Shell) RunWith ¶
func (s *Shell) RunWith(ctx context.Context, line string, stdout, stderr io.Writer, timeout time.Duration) Output
RunWith runs a command line with explicit writers and timeout on the shell itself, so it waits behind whatever the agent has running. Extensions that must not queue behind the agent use Fork instead
func (*Shell) StartJob ¶
StartJob runs line as a background job on a copy of the shell as it stands, the way the Shell tool does, and reports its id so ShellOutput, KillShell and Wait take it