feat: add workspace-isolated toolhost runtime and capability-gap skill loop

This commit is contained in:
2026-02-28 17:48:33 +08:00
parent ce9346e350
commit 7d6cf6b435
28 changed files with 2223 additions and 143 deletions

32
internal/logger/trace.go Normal file
View File

@@ -0,0 +1,32 @@
package logger
import (
"context"
"fmt"
"math/rand"
"time"
)
type traceIDKey struct{}
func NewTraceID() string {
now := time.Now().UTC().UnixNano()
randPart := rand.Int63()
return fmt.Sprintf("tr-%x-%x", now, randPart)
}
func WithTraceID(ctx context.Context, traceID string) context.Context {
if traceID == "" {
return ctx
}
return context.WithValue(ctx, traceIDKey{}, traceID)
}
func TraceIDFromContext(ctx context.Context) string {
if ctx == nil {
return ""
}
v := ctx.Value(traceIDKey{})
s, _ := v.(string)
return s
}