feat: propagate safeMode status via context

This commit is contained in:
AI Engineer 2026-05-30 19:26:01 +08:00
parent 57810a5553
commit 147579b0d1

View File

@ -1,6 +1,22 @@
package jsmod package jsmod
import "sync" import (
"context"
"sync"
)
type contextKey string
const SafeModeKey contextKey = "SafeMode"
// IsSafeMode checks if the provided context indicates that the execution is in safe mode.
func IsSafeMode(ctx context.Context) bool {
v := ctx.Value(SafeModeKey)
if sm, ok := v.(bool); ok {
return sm
}
return false // Default to false if not specified (internal trusted caller)
}
type Module struct { type Module struct {
Exports map[string]any Exports map[string]any