]> git.giacomolli.uk - onechat/blobdiff - tools.go
Exempt tracker metadata from commit signing
[onechat] / tools.go
index 11e208d49e82dd4b8c51b128d3558eba9e7c48af..24e745bb51192a2575472c83d5e3f69670dad2e7 100644 (file)
--- a/tools.go
+++ b/tools.go
@@ -419,10 +419,15 @@ func (b *Toolbox) zoomAgent(ctx context.Context, name string) (string, error) {
 
        subagent, err := b.subagents.Get(ctx, name)
        if err != nil {
 
        subagent, err := b.subagents.Get(ctx, name)
        if err != nil {
-               return "", err
+               return "", fmt.Errorf("open worker log: %w", err)
        }
 
        }
 
-       return subagent.Show()
+       text, err := subagent.Show()
+       if err != nil {
+               return text, fmt.Errorf("read worker log: %w", err)
+       }
+
+       return text, nil
 }
 
 // zoom returns message id whole for n = 1, or else the two lines under the line
 }
 
 // zoom returns message id whole for n = 1, or else the two lines under the line
@@ -494,9 +499,11 @@ func (b *Toolbox) shell(ctx context.Context, command string) string {
        cmd.SysProcAttr = &syscall.SysProcAttr{
                Setpgid: true,
        }
        cmd.SysProcAttr = &syscall.SysProcAttr{
                Setpgid: true,
        }
+
        cmd.Cancel = func() error {
                return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
        }
        cmd.Cancel = func() error {
                return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
        }
+
        cmd.WaitDelay = toolShellOutputTimeout
 
        output := &ToolHeadTail{}
        cmd.WaitDelay = toolShellOutputTimeout
 
        output := &ToolHeadTail{}
@@ -542,8 +549,7 @@ func (b *Toolbox) read(path string) (text string, err error) {
        return output.String(), nil
 }
 
        return output.String(), nil
 }
 
-// write replaces the file at path with text, and makes its missing
-// directories.
+// write replaces the file at path with text, and makes its missing directories.
 func (b *Toolbox) write(path, text string) (string, error) {
        path = b.path(path)
        err := os.MkdirAll(filepath.Dir(path), 0o755)
 func (b *Toolbox) write(path, text string) (string, error) {
        path = b.path(path)
        err := os.MkdirAll(filepath.Dir(path), 0o755)
@@ -559,8 +565,8 @@ func (b *Toolbox) write(path, text string) (string, error) {
        return fmt.Sprintf("wrote %d bytes to %s", len(text), path), nil
 }
 
        return fmt.Sprintf("wrote %d bytes to %s", len(text), path), nil
 }
 
-// edit replaces the one occurrence of old in the file at path with
-// replacement. It keeps the mode of the file.
+// edit replaces the one occurrence of old in the file at path with replacement.
+// It keeps the mode of the file.
 func (b *Toolbox) edit(path, old, replacement string) (string, error) {
        path = b.path(path)
        data, err := os.ReadFile(path)
 func (b *Toolbox) edit(path, old, replacement string) (string, error) {
        path = b.path(path)
        data, err := os.ReadFile(path)
@@ -590,8 +596,7 @@ func (b *Toolbox) edit(path, old, replacement string) (string, error) {
        return "edited " + path, nil
 }
 
        return "edited " + path, nil
 }
 
-// path returns path, relative to the working directory when it is not
-// absolute.
+// path returns path, relative to the working directory when it is not absolute.
 func (b *Toolbox) path(path string) string {
        if filepath.IsAbs(path) {
                return path
 func (b *Toolbox) path(path string) string {
        if filepath.IsAbs(path) {
                return path