From 9bd556755250fe11dd36a074adcc420dfbe5c648 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 7 Oct 2024 22:50:57 -0700 Subject: [PATCH] enh: 'execute' event type --- src/lib/components/chat/Chat.svelte | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 6b879c8be..cd200cb1a 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -199,6 +199,13 @@ eventConfirmationTitle = data.title; eventConfirmationMessage = data.message; + } else if (type === 'execute') { + try { + // Use Function constructor to evaluate code in a safer way + new Function(data.code)(); + } catch (error) { + console.error('Error executing code:', error); + } } else if (type === 'input') { eventCallback = cb;