remove acme log window in favor of external script
This commit is contained in:
parent
b47f6ba97d
commit
851ac311b0
|
|
@ -92,7 +92,7 @@ func main() {
|
|||
defer w.CloseFiles()
|
||||
|
||||
w.Name(windowName)
|
||||
w.Write("tag", []byte("Get Attach Stop Restart Kill Alias Context Log Daemon Sandbox "))
|
||||
w.Write("tag", []byte("Get Attach Stop Restart Kill Alias Context Daemon Sandbox "))
|
||||
refreshList(w)
|
||||
w.Ctl("clean")
|
||||
|
||||
|
|
@ -221,19 +221,7 @@ func main() {
|
|||
if err := openContextWindow(sess); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error opening context window: %v\n", err)
|
||||
}
|
||||
case "Log":
|
||||
if arg == "" {
|
||||
fmt.Fprintf(os.Stderr, "Usage: Log <session-id>\n")
|
||||
continue
|
||||
}
|
||||
sess, err := getSession(arg)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Session not found: %s\n", arg)
|
||||
continue
|
||||
}
|
||||
if err := openLogWindow(sess); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error opening log window: %v\n", err)
|
||||
}
|
||||
|
||||
case "Sandbox":
|
||||
if err := openSandboxWindow(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error opening sandbox window: %v\n", err)
|
||||
|
|
@ -605,56 +593,6 @@ func openContextWindow(sess *SessionInfo) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func openLogWindow(sess *SessionInfo) error {
|
||||
go func() {
|
||||
displayName := sess.Alias
|
||||
if displayName == "" {
|
||||
displayName = sess.ID
|
||||
}
|
||||
|
||||
w, err := acme.New()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error creating log window: %v\n", err)
|
||||
return
|
||||
}
|
||||
defer w.CloseFiles()
|
||||
|
||||
w.Name(fmt.Sprintf("/AnviLLM/Log.%s", displayName))
|
||||
w.Ctl("clean")
|
||||
|
||||
// Stream log using external command
|
||||
logPath := fmt.Sprintf("agent/%s/log", sess.ID)
|
||||
cmd := exec.Command("9p", "read", logPath)
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error creating pipe: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error starting 9p read: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Stream output to window
|
||||
buf := make([]byte, 8192)
|
||||
for {
|
||||
n, err := stdout.Read(buf)
|
||||
if n > 0 {
|
||||
w.Addr("$")
|
||||
w.Write("data", buf[:n])
|
||||
w.Ctl("clean")
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
cmd.Wait()
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleContextWindow(w *acme.Win, sess *SessionInfo) {
|
||||
defer w.CloseFiles()
|
||||
|
|
|
|||
2
mkfile
2
mkfile
|
|
@ -7,6 +7,8 @@ build:V:
|
|||
go build -o $INSTALL_PATH/Assist ./cmd/Assist
|
||||
go build -o $INSTALL_PATH/anvillm ./cmd/anvillm
|
||||
go build -o $INSTALL_PATH/anvilweb ./cmd/anvilweb
|
||||
cp scripts/Alog $INSTALL_PATH/Alog
|
||||
chmod 0755 $INSTALL_PATH/Alog
|
||||
mkdir -p $INSTALL_PATH/Workflows
|
||||
cp scripts/DevReview $INSTALL_PATH/Workflows/DevReview
|
||||
chmod 0755 $INSTALL_PATH/Workflows/DevReview
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env rc
|
||||
|
||||
# Alog - Stream AnviLLM session log to Acme window
|
||||
|
||||
if(~ $#* 1) {
|
||||
sess=$1
|
||||
|
||||
# Get alias for display name
|
||||
alias=`{9p read agent/$sess/alias >[2]/dev/null}
|
||||
if(~ $alias '') {
|
||||
name=$sess
|
||||
}
|
||||
if not {
|
||||
name=$alias
|
||||
}
|
||||
|
||||
# Create window and get its ID
|
||||
winid=`{9p read acme/new/ctl | awk '{print $1}'}
|
||||
echo name /AnviLLM/Log.$name | 9p write acme/$winid/ctl
|
||||
echo clean | 9p write acme/$winid/ctl
|
||||
|
||||
# Stream log to window
|
||||
9p read agent/$sess/log | 9p write acme/$winid/data
|
||||
}
|
||||
if not {
|
||||
echo 'Usage: Alog <session-id>' >[1=2]
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue