터미널 세션 core와 CLI mode executor 경계를 분리해 후속 remote terminal bridge가 재사용할 내부 실행 기반을 만든다. adapter 기본값과 vLLM experimental surface도 명시해 production 실행 경로가 mock fallback이나 미구현 실행으로 숨지 않게 한다.
43 lines
891 B
Go
43 lines
891 B
Go
package status
|
|
|
|
import (
|
|
"strings"
|
|
"sync"
|
|
)
|
|
|
|
// TailBuffer holds a bounded buffer of terminal output.
|
|
type TailBuffer struct {
|
|
mu sync.Mutex
|
|
buf strings.Builder
|
|
max int
|
|
}
|
|
|
|
// NewTailBuffer creates a new TailBuffer with the given maximum capacity in bytes.
|
|
func NewTailBuffer(max int) *TailBuffer {
|
|
return &TailBuffer{max: max}
|
|
}
|
|
|
|
// Append appends a string to the buffer, truncating from the front if it exceeds capacity.
|
|
func (tb *TailBuffer) Append(s string) {
|
|
tb.mu.Lock()
|
|
defer tb.mu.Unlock()
|
|
tb.buf.WriteString(s)
|
|
raw := tb.buf.String()
|
|
if len(raw) <= tb.max {
|
|
return
|
|
}
|
|
tb.buf.Reset()
|
|
tb.buf.WriteString(raw[len(raw)-tb.max:])
|
|
}
|
|
|
|
// String returns the contents of the buffer.
|
|
func (tb *TailBuffer) String() string {
|
|
tb.mu.Lock()
|
|
defer tb.mu.Unlock()
|
|
return tb.buf.String()
|
|
}
|
|
|
|
// Snapshot holds a snapshot of a terminal session.
|
|
type Snapshot struct {
|
|
Tail string
|
|
}
|