From 147579b0d11fc14d48d4481dfa7fab2deb96bf5b Mon Sep 17 00:00:00 2001 From: AI Engineer Date: Sat, 30 May 2026 19:26:01 +0800 Subject: [PATCH] feat: propagate safeMode status via context --- jsmod.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/jsmod.go b/jsmod.go index 2b95128..2176442 100644 --- a/jsmod.go +++ b/jsmod.go @@ -1,6 +1,22 @@ 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 { Exports map[string]any