diff --git a/README.md b/README.md index f691056..097a46d 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,12 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the ## Using the Sandbox -1. **Neuron Path**: Enter your Neuron's path in the format `organization/neuron-slug` +1. **Neuron Path**: Enter your Neuron's path in the format `organization/neuron-slug/revisionId` 2. **Authentication** (Optional): If your Neuron requires authentication, enter your API key or JWT token -3. **Input**: Type your input in the text area -4. **Cache Control**: Toggle the "Bypass Cache" option if you need fresh responses -5. **Run**: Click the "Run" button to execute the Neuron and see the results +3. **Key** (Optional): Key is required when running a specific neuron revision, to prevent public access to unpublished versions. +4. **Input**: Type your input in the text area +5. **Cache Control**: Toggle the "Bypass Cache" option if you need fresh responses +6. **Run**: Click the "Run" button to execute the Neuron and see the results The Sandbox respects all Neuron security settings. If a Neuron requires authentication, you'll need to provide valid credentials to access it. @@ -43,5 +44,6 @@ The Sandbox is open source and available on [GitHub](https://github.com/prompteu ## Learn More To learn more about Prompteus and its features, visit: + - [Prompteus Documentation](https://docs.prompteus.com) - [Prompteus Sandbox Documentation](https://docs.prompteus.com/features/sandbox) diff --git a/app/favicon.ico b/app/favicon.ico index 718d6fe..5d5eeb5 100644 Binary files a/app/favicon.ico and b/app/favicon.ico differ diff --git a/app/page.tsx b/app/page.tsx index 9362df8..0251b3e 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -18,6 +18,7 @@ function SandboxContent() { const [neuronPath, setNeuronPath] = useState(""); const [bypassCache, setBypassCache] = useState(false); const [authToken, setAuthToken] = useState(""); + const [key, setKey] = useState(""); const [isExecutionStopped, setIsExecutionStopped] = useState(false); useEffect(() => { @@ -48,18 +49,41 @@ function SandboxContent() { } }, [neuronPath, router, searchParams]); + useEffect(() => { + const keyFromUrl = searchParams.get("key"); + + if (keyFromUrl) { + setKey(decodeURIComponent(keyFromUrl)); + } else { + const savedKey = localStorage.getItem("key"); + + if (savedKey) { + setKey(savedKey); + } + } + }, [searchParams]); + useEffect(() => { localStorage.setItem("authToken", authToken); }, [authToken]); + useEffect(() => { + if (key) { + localStorage.setItem("key", key); + const params = new URLSearchParams(searchParams.toString()); + params.set("key", encodeURIComponent(key)); + router.push(`?${params.toString()}`); + } + }, [key, neuronPath, router, searchParams]); + const handleRun = async () => { try { setIsLoading(true); setOutput(""); const input = document.querySelector("textarea")?.value || ""; - // Split the neuron path into org and neuron slugs - const [orgSlug, neuronSlug] = neuronPath.split("/"); + // Split the neuron path into org and neuron slugs and revisionId + const [orgSlug, neuronSlug, revisionId] = neuronPath.split("/"); if (!orgSlug || !neuronSlug) { throw new Error( "Invalid neuron path. Use format: organization/neuron-slug" @@ -75,6 +99,8 @@ function SandboxContent() { input, bypassCache, rawOutput: false, + revisionId, + key, }); setOutput(result.output || ""); @@ -111,7 +137,7 @@ function SandboxContent() { setNeuronPath(e.target.value)} /> @@ -129,6 +155,19 @@ function SandboxContent() { The sandbox respects all neuron security settings.
++ Note: Key is required when running a specific neuron revision, to + prevent public access to unpublished versions. +
+