### Example Pinokio Script with Conditional Installation Source: https://pinokio.co/docs/index This example script demonstrates how to conditionally install PyTorch based on the GPU type. It uses the 'jump' method to navigate between 'cpu' and 'cuda' specific installation instructions, controlled by a ternary expression evaluating the 'gpu' variable. ```json { "run": [ { "method": "jump", "params": { "id": "{{gpu === 'nvidia' ? 'cuda' : 'cpu'}}" } }, { "id": "cpu", "method": "shell.run", "params": { "message": "pip install torch torchvision torchaudio" } }, { "id": "cuda", "method": "shell.run", "params": { "message": "pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121" } } ] } ``` -------------------------------- ### Dynamic Menu Rendering Example in Pinokio Source: https://pinokio.co/docs/index This example demonstrates how to use the 'menu' property as an async function to dynamically render sidebar menu items. It utilizes the 'info' object to check script statuses (running, exists) and retrieve local variables to determine the appropriate menu options, such as 'Install', 'Start', 'Web UI', or 'Terminal'. ```javascript const path = require("path") module.exports = { version: "2.0", title: "InvokeAI", description: "Generative AI for Professional Creatives", icon: "icon.jpeg", menu: async (kernel, info) => { /********************************************************************************************** info has 4 methods (where `filepath` may be a relative path or an absolute path.): - info.local(filepath): get the local variable object of a script running at `filepath`. - info.running(filepath): get the running status of a script at `filepath`. - info.exists(filepath): check if a file exists at `filepath`. - info.path(filepath): get the absolute path of a `fileapth`. **********************************************************************************************/ let installing = info.running("install.json") let installed = info.exists("app/env") if (installing) { return [{ icon: "fa-solid fa-plug", text: "Installing...", href: "install.json" }] } else if (installed) { let running = info.running("start.json") if (running) { let memory = info.local("start.json") if (memory && memory.url) { return [ { icon: "fa-solid fa-rocket", text: "Web UI", href: memory.url }, { icon: "fa-solid fa-terminal", text: "Terminal", href: "start.json" }, { icon: "fa-solid fa-rotate", text: "Update", href: "update.json" }, ] } else { return [ { icon: "fa-solid fa-terminal", text: "Terminal", href: "start.json" }, { icon: "fa-solid fa-rotate", text: "Update", href: "update.json" }, ] } } else { return [{ icon: "fa-solid fa-power-off", text: "Start", href: "start.json", }, { icon: "fa-solid fa-rotate", text: "Update", href: "update.json" }, { icon: "fa-solid fa-plug", text: "Reinstall", href: "install.json" }, { icon: "fa-solid fa-broom", text: "Factory Reset", href: "reset.json" }] } } else { return [ { icon: "fa-solid fa-plug", text: "Install", href: "install.json" }, { icon: "fa-solid fa-rotate", text: "Update", href: "update.json" } ] } } } ``` -------------------------------- ### Example: Sharing Models Between Fooocus, Stable Diffusion WebUI, and ComfyUI Source: https://pinokio.co/docs/index This example demonstrates how to configure install scripts for Fooocus, Stable Diffusion WebUI, and ComfyUI to use peer linking. Each script clones its respective application and then uses `fs.link` to define its model directories, listing the other two applications as peers. ```APIDOC ## Install Script for Fooocus ### Description Clones the Fooocus repository and then links its model directories, declaring Stable Diffusion WebUI and ComfyUI as peers. ### Method POST ### Endpoint /run ### Request Body ```json { "run": [ { "method": "shell.run", "params": { "message": "git clone https://github.com/lllyasviel/Fooocus app" } }, { "method": "fs.link", "params": { "drive": { "checkpoints": "app/models/checkpoints", "clip": "app/models/clip", "clip_vision": "app/models/clip_vision", "configs": "app/models/configs", "controlnet": "app/models/controlnet", "diffusers": "app/models/diffusers", "embeddings": "app/models/embeddings", "gligen": "app/models/gligen", "hypernetworks": "app/models/hypernetworks", "inpaint": "app/models/inpaint", "loras": "app/models/loras", "prompt_expansion": "app/models/prompt_expansion", "style_models": "app/models/style_models", "unet": "app/models/unet", "upscale_models": "app/models/upscale_models", "vae": "app/models/vae", "vae_approx": "app/models/vae_approx" }, "peers": [ "https://github.com/cocktailpeanutlabs/automatic1111.git", "https://github.com/cocktailpeanutlabs/comfyui.git" ] } } ] } ``` ## Install Script for Stable Diffusion WebUI ### Description Clones the Stable Diffusion WebUI repository and then links its model directories, declaring ComfyUI and Fooocus as peers. ### Method POST ### Endpoint /run ### Request Body ```json { "run": [ { "method": "shell.run", "params": { "message": "git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui app" } }, { "method": "fs.link", "params": { "drive": { "checkpoints": "app/models/Stable-diffusion", "vae": "app/models/VAE", "loras": [ "app/models/Lora", "app/models/LyCORIS" ], "upscale_models": [ "app/models/ESRGAN", "app/models/RealESRGAN", "app/models/SwinIR" ], "embeddings": "app/embeddings", "hypernetworks": "app/models/hypernetworks", "controlnet": "app/models/ControlNet" }, "peers": [ "https://github.com/cocktailpeanutlabs/comfyui.git", "https://github.com/cocktailpeanutlabs/fooocus.git" ] } } ] } ``` ## Install Script for ComfyUI ### Description Clones the ComfyUI repository and then links its model directories, declaring Stable Diffusion WebUI and Fooocus as peers. ### Method POST ### Endpoint /run ### Request Body ```json { "run": [ { "method": "shell.run", "params": { "message": "git clone https://github.com/comfyanonymous/ComfyUI.git app" } }, { "method": "fs.link", "params": { "drive": { "checkpoints": "app/models/checkpoints", "clip": "app/models/clip", "clip_vision": "app/models/clip_vision", "configs": "app/models/configs", "controlnet": "app/models/controlnet", "embeddings": "app/models/embeddings", "loras": "app/models/loras", "upscale_models": "app/models/upscale_models", "vae": "app/models/vae" }, "peers": [ "https://github.com/cocktailpeanutlabs/automatic1111.git", "https://github.com/cocktailpeanutlabs/fooocus.git" ] } } ] } ``` ``` -------------------------------- ### Environment File Example with Comment Source: https://pinokio.co/docs/index An example of an `ENVIRONMENT` file showing how to define variables and include comments for clarity. The `SD_INSTALL_CHECKPOINT` variable is used to specify a download URL for a checkpoint file. ```shell ##################################################################################################################### # # SD_INSTALL_CHECKPOINT # - Delete this field if you don't want to auto-download a checkpoint when installing # - Replace the URL with another checkpoint link if you want a different checkpoint # ##################################################################################################################### SD_INSTALL_CHECKPOINT=https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors ``` -------------------------------- ### Example: Open File Picker and View Selected File Source: https://pinokio.co/docs/index Demonstrates a sequence of operations: first, opening a file picker dialog starting from the 'images' directory, and second, opening the selected file using the file system 'open' method. The selected file path is passed from the file picker to the file system open method. ```json { "run": [ { "method": "filepicker.open", "params": { "path": "images" } }, { "method": "fs.open", "params": { "action": "view", "path": "{{input.paths[0]}}" } } ] } ``` -------------------------------- ### Check if script is running - JSON Source: https://pinokio.co/docs/index Starts an 'install.js' script and then logs whether it is currently running. This example demonstrates how to initiate a script and subsequently monitor its execution status. ```json { "run": [{ "method": "script.start", "params": { "uri": "install.js" } }, { "method": "log", "params": { "text": "{{kernel.script.running(cwd, 'install.js')}}" } }] } ``` -------------------------------- ### Launch Application with Install Flow Source: https://pinokio.co/docs/index Demonstrates launching an application that may not be installed. It includes custom arguments, an installation URL, and specific timeouts for the install and polling intervals. ```json { "method": "app.launch", "params": { "app": "Cursor", "args": ["--new-window"], "install": "https://cursor.sh/", "installTimeout": 600000, "installPollInterval": 5000 } } ``` -------------------------------- ### Launch Application by Name Source: https://pinokio.co/docs/index A specific example of launching an application using its name, without any additional parameters or install flows. ```json { "method": "app.launch", "params": { "app": "Safari" } } ``` -------------------------------- ### Install, Start, and Stop Remote Scripts Source: https://pinokio.co/docs/index Explains how to download, install, run, and stop remote scripts from other repositories, commonly used for managing AI models and applications. ```APIDOC ## Install, start, and stop remote scripts This API allows you to manage scripts residing in remote repositories, including downloading, installing, running, and terminating them. ### Methods * **`script.start`**: Starts a remote script. If the repository does not exist locally, it will be cloned first. * **`gradio.predict`**: Interacts with a Gradio application endpoint. * **`script.stop`**: Stops a running script, freeing up system resources. ### Example: Running a remote Gradio application (`moondream2`) **`install.json`**: (Located in `api/remotescript/`) ```json { "run": [ { "method": "script.start", "params": { "uri": "https://github.com/cocktailpeanutlabs/moondream2.git/install.js" } }, { "method": "script.start", "params": { "uri": "https://github.com/cocktailpeanutlabs/moondream2.git/start.js" } }, { "id": "run", "method": "gradio.predict", "params": { "uri": "{{kernel.script.local('https://github.com/cocktailpeanutlabs/moondream2.git/start.js').url}}", "path": "/answer_question_1", "params": [ { "path": "https://media.timeout.com/images/105795964/750/422/image.jpg" }, "Explain what is going on here" ] } }, { "method": "log", "params": { "json2": "{{input}}" } }, { "method": "script.stop", "params": { "uri": "https://github.com/cocktailpeanutlabs/moondream2.git/start.js" } } ] } ``` **Explanation**: 1. **Install and Start**: The `install.js` and `start.js` scripts from the `moondream2` repository are executed. If the repository isn't local, it's cloned first. 2. **Predict**: The `gradio.predict` method is used to query the running Gradio application. It utilizes `kernel.script.local()` to get the local URL of the `start.js` script and specifies the endpoint (`/answer_question_1`) and parameters (an image URL and a text prompt). 3. **Log Response**: The output from the `gradio.predict` call is logged. 4. **Stop Script**: The `script.stop` method is called to terminate the `moondream2/start.js` process, releasing system memory. This is crucial for managing resources on personal computers. *This pattern of starting, using, and stopping scripts is highly beneficial for running memory-intensive AI applications efficiently on local hardware.* ``` -------------------------------- ### Install, Start, Predict, and Stop Remote Script (JSON) Source: https://pinokio.co/docs/index Shows how to manage a remote script from a Git repository. It uses 'script.start' to clone and install if necessary, then start the script. It then interacts with a Gradio endpoint using 'gradio.predict' and finally stops the remote script using 'script.stop' to free up resources. ```json { "run": [ { "method": "script.start", "params": { "uri": "https://github.com/cocktailpeanutlabs/moondream2.git/install.js" } }, { "method": "script.start", "params": { "uri": "https://github.com/cocktailpeanutlabs/moondream2.git/start.js" } }, { "id": "run", "method": "gradio.predict", "params": { "uri": "{{kernel.script.local('https://github.com/cocktailpeanutlabs/moondream2.git/start.js').url}}", "path": "/answer_question_1", "params": [ { "path": "https://media.timeout.com/images/105795964/750/422/image.jpg" }, "Explain what is going on here" ] } }, { "method": "log", "params": { "json2": "{{input}}" } }, { "method": "script.stop", "params": { "uri": "https://github.com/cocktailpeanutlabs/moondream2.git/start.js" } } ] } ``` -------------------------------- ### Example: Pinokio Project with User Input and File Operations Source: https://pinokio.co/docs/index This example illustrates a multi-step Pinokio project. It first prompts the user for input, then uses this input to copy template files, write a configuration file, and execute git commands. It leverages Node.js's `fs` and `path` modules, and Pinokio's `kernel.exec` for shell command execution. The output includes a success notification referencing the created file. ```javascript const fs = require('fs') const path = require('path') module.exports = { run: [ { method: "input", params: { title: "Command Launcher", form: [{ title: "Enter the launch command", key: "start" }] } }, { method: async (req, ondata, kernel) => { // copy some template files into the execution folder (req.cwd) await fs.promises.cp(path.resolve(__dirname, "template"), req.cwd, { recursive: true }) // write a start.json file into the execution folder (req.cwd) using the `req.input.start` value from the previous step. await fs.promises.writeFile(path.resolve(req.cwd, "start.json"), JSON.stringify({ run: [{ method: "shell.run", params: { input: true, message: req.input.start } }] }, null, 2)) // you can even run some commands in the terminal using the `kernel.exec` API await kernel.exec({ message: [ "git init", "git add .", "git commit -am init" ], path: req.cwd }, (e) => { ondata(e) }) return { filepath: path.resolve(req.cwd, "start.json") } }, }, { method: "notify", params: { text: "File written to {{input.filepath}}" } } ] } ``` -------------------------------- ### Get VSCode Application Information Source: https://pinokio.co/docs/index An example of retrieving information for the VSCode application, forcing a rescan before fetching the details. ```json { "method": "app.info", "params": { "id": "com.microsoft.VSCode", "refresh": true } } ``` -------------------------------- ### Start Script Execution - script.start Source: https://pinokio.co/docs/index Starts the execution of a specified script, which can be local or remote. It supports downloading from git URIs, switching branches, and passing parameters to the script. Parameters passed to the script are available as 'args' throughout its execution and as 'input' for the first step. The return value of a called script can be captured as 'input' in the calling script. ```json { "method": "script.start", "params": { "uri": , "hash": , "branch": , "pull": , "params": { "a": "hello", "b": "world" } } } ``` ```json { "run": [ { "method": "script.start", "params": { "uri": "callee.json", "params": { "a": "hello", "b": "world" } } }, { "method": "log", "params": { "json2": "{{input}}" } } ] } ``` ```json { "run": [ { "method": "log", "params": { "json2": "{{input}}" } }, { "method": "log", "params": { "text": "{{args.a + ' ' + args.b}}" } }, { "method": "log", "params": { "json2": "{{args}}" } }, { "method": "script.return", "params": { "response": "{{args.a + ' + ' + args.b}}" } } ] } ``` ```json { "run": [ { "method": "script.start", "params": { "uri": "https://github.com/cocktailpeanutlabs/torch.git/install.js", "branch": "main", "params": { "venv": "{{path.resolve(cwd, 'env')}}" } } } ] } ``` -------------------------------- ### Pinokio Config Display Example (pinokio.json) Source: https://pinokio.co/docs/index Provides an example of how `title`, `description`, and `icon` fields in `pinokio.json` are used to configure the display of a Pinokio project launcher. ```json { "title": "Comfyui", "description": "The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. https://github.com/comfyanonymous/ComfyUI", "icon": "icon.jpeg" } ``` -------------------------------- ### Launch Application with Options Source: https://pinokio.co/docs/index Launches a desktop application by its ID or name. It supports passing command-line arguments, initiating an installation process if the app is missing (with custom timeouts and polling intervals), and forcing a rescan of installed applications before launch. ```json { "method": "app.launch", "params": { "id": "", "app": "", "args": [ "", "..." ], "refresh": , "install": "", "installTimeout": , "installPollInterval": } } ``` -------------------------------- ### Example: Read Image as Base64 and Log Source: https://pinokio.co/docs/index An example demonstrating reading an image file ('img.png') in base64 encoding and then logging the content, prefixed with a data URI scheme. This is useful for displaying images in web contexts. ```json { "run": [ { "method": "fs.read", "params": { "path": "img.png", "encoding": "base64" } }, { "method": "log", "params": { "raw": "data:image/png;base64,{{input}}" } } ] } ``` -------------------------------- ### Start script with Git path - JSON Source: https://pinokio.co/docs/index Starts a JavaScript file from a Git repository using 'script.start' and logs its local representation. This allows execution of scripts hosted remotely, making them accessible locally. ```json { "run": [{ "method": "script.start", "params": { "uri": "https://github.com/cocktailpeanutlabs/moondream2.git/start.js" } }, { "method": "log", "params": { "json2": "{{kernel.script.local('https://github.com/cocktailpeanutlabs/moondream2.git/start.js')}}" } }] } ``` -------------------------------- ### Text Input Field Example (JSON) Source: https://pinokio.co/docs/index This example demonstrates how to create a simple input modal with a single text field. It shows the basic structure for defining a text input, including its key, title, description, and placeholder. This is the default input type if none is specified. ```json { "method": "input", "params": { "title": "Login", "description": "Enter your credentials", "form": [{ "key": "username", "title": "Username", "description": "Enter the username", "placeholder": "(ex: cocktailpeanut, etc.)", "default": "" }] } } ``` -------------------------------- ### Example Pinokio Execution Flow Source: https://pinokio.co/docs/index Presents a complete example of a Pinokio execution sequence. It includes running a Python script, handling a specific HTTP event by keeping the shell running, setting a local variable with the matched URL, and logging the final URL. ```json { "daemon": true, "run": [ { "method": "shell.run", "params": { "message": "python app.py", "venv": "env", "on": [ { "event": "/http:\\/[0-9.:]+\/", "done": true } ] } }, { "method": "local.set", "params": { "url": "{{input.event[0]}}" } }, { "method": "log", "params": { "raw": "Running on {{local.url}}" } } ] } ``` -------------------------------- ### Example: Delete a Folder Source: https://pinokio.co/docs/index Provides an example of how to use the `fs.rm` method to delete a folder named 'app' located in the current directory. ```json { "run": [ { "method": "fs.rm", "params": { "path": "app" } } ] } ``` -------------------------------- ### Define Prerequisites with 'pre' Array Source: https://pinokio.co/docs/index Illustrates how to use the 'pre' array in pinokio.js to specify prerequisites for a script. Each item in the 'pre' array can include text, an icon, a URL ('href'), and file system actions ('fs') to guide the user in installing necessary third-party programs before the main script execution. ```javascript module.exports = { version: "2.0", title: "LLM App", pre: [{ icon: "ollama.png", title: "Ollama", description: "Get up and running with large language models.", href: "https://ollama.com/" }], ... } ``` -------------------------------- ### Run a Local Web Server with Pinokio Source: https://pinokio.co/docs/index This JSON script uses the 'shell.run' method to launch a local web server using `npx http-server`. It's a basic example of starting a service within Pinokio. ```json { "run": [{ "method": "shell.run", "params": { "message": "npx -y http-server" } }] } ``` -------------------------------- ### Start script with relative path - JSON Source: https://pinokio.co/docs/index Starts a local JavaScript file using the 'script.start' method and logs its local URL. It retrieves the URL of the 'start.js' script, assuming it's available in the current working directory. ```json { "run": [{ "method": "script.start", "params": { "uri": "start.js" } }, { "method": "log", "params": { "text": "{{kernel.script.local(cwd, 'start.js').url}}" } }] } ``` -------------------------------- ### script.start Source: https://pinokio.co/docs/index Starts a script, either locally or from a remote Git repository. Allows passing parameters to the script and accessing them within the script's execution context. ```APIDOC ## script.start ### Description Starts the specified script, which can be a local path or a remote Git URI. Parameters can be passed to the script and will be available as `args` and `input` within the script. ### Method script.start ### Parameters #### Request Body - **uri** (string) - Required - The script path or Git URI to start running. - **hash** (string) - Optional - The git commit hash to switch to after downloading (if the URI is a Git URI). - **branch** (string) - Optional - The git branch to switch to after downloading (if the URI is a Git URI). - **pull** (boolean) - Optional - If set to `true`, always run `git pull` before running code (in case there's been an update made to the remote branch). - **params** (object) - Optional - The parameters to pass to the script. These will be available as `args` (persistent throughout script execution) and `input` (from the previous step). ### Request Example ```json { "method": "script.start", "params": { "uri": "", "hash": "", "branch": "", "pull": , "params": { "a": "hello", "b": "world" } } } ``` ### Response #### Success Response (200) - **input** (any) - The value returned by the called script via `script.return`. #### Response Example ```json { "response": "hello + world" } ``` ### Examples #### Local Script Call **index.json**: ```json { "run": [ { "method": "script.start", "params": { "uri": "callee.json", "params": { "a": "hello", "b": "world" } } }, { "method": "log", "params": { "json2": "{{input}}" } } ] } ``` **callee.json**: ```json { "run": [ { "method": "log", "params": { "json2": "{{input}}" } }, { "method": "log", "params": { "text": "{{args.a + ' ' + args.b}}" } }, { "method": "log", "params": { "json2": "{{args}}" } }, { "method": "script.return", "params": { "response": "{{args.a + ' + ' + args.b}}" } } ] } ``` #### Remote Script Call **Example script at `/PINOKIO_HOME/api/myapp/install.json`**: ```json { "run": [{ "method": "script.start", "params": { "uri": "https://github.com/cocktailpeanutlabs/torch.git/install.js", "branch": "main", "params": { "venv": "{{path.resolve(cwd, 'env')}}" } } }] } ``` ``` -------------------------------- ### Fooocus Install Script with Peer Linking Source: https://pinokio.co/docs/index This script installs Fooocus and links its model directories to a shared virtual drive, declaring Automatic1111 and ComfyUI as peers. This ensures that if a virtual drive already exists for either peer, it will be used; otherwise, a new one will be created for Fooocus. This allows Fooocus to share model files with the specified peer applications. ```json { "run": [ { "method": "shell.run", "params": { "message": "git clone https://github.com/lllyasviel/Fooocus app" } }, { "method": "fs.link", "params": { "drive": { "checkpoints": "app/models/checkpoints", "clip": "app/models/clip", "clip_vision": "app/models/clip_vision", "configs": "app/models/configs", "controlnet": "app/models/controlnet", "diffusers": "app/models/diffusers", "embeddings": "app/models/embeddings", "gligen": "app/models/gligen", "hypernetworks": "app/models/hypernetworks", "inpaint": "app/models/inpaint", "loras": "app/models/loras", "prompt_expansion": "app/models/prompt_expansion", "style_models": "app/models/style_models", "unet": "app/models/unet", "upscale_models": "app/models/upscale_models", "vae": "app/models/vae", "vae_approx": "app/models/vae_approx" }, "peers": [ "https://github.com/cocktailpeanutlabs/automatic1111.git", "https://github.com/cocktailpeanutlabs/comfyui.git" ] } } ] } ``` -------------------------------- ### Shell API Source: https://pinokio.co/docs/index The shell API allows you to start an instant shell session. You can configure whether the shell is interactive, the message to send, the starting path, environment variables, and virtual environment settings. ```APIDOC ## POST /shell ### Description Starts an instant shell session in a new tab with configurable options. ### Method POST ### Endpoint /shell ### Parameters #### Request Body - **shell** (object) - Required - Configuration for the shell session. - **input** (boolean) - Optional - Whether the shell is interactive. `true` for interactive mode, `false` (or not specified) for non-interactive mode. - **message** (string) - Required - The message/command to enter into the shell. - **path** (string) - Optional - The starting path for the shell session. Defaults to the current script's path. - **env** (object) - Optional - Key/value pairs for custom environment variables. - **venv_path** (string) - Optional - Path to create or activate a virtual environment. If not specified, no venv is used. - **conda_config** (string | object) - Optional - Configuration for activating a conda environment. - **string**: Path to the conda environment. - **object**: Configuration with `path`, `name`, `skip`, and `python` properties for advanced conda environment management. ### Request Example ```json { "menu": [ { "icon": "fa-solid fa-rocket", "text": "Launch a web server", "shell": { "message": "npx -y http-server" } } ] } ``` ### Response #### Success Response (200) (Typically, shell operations do not return a specific JSON response body for success, but rather execute the command in a new shell.) #### Response Example (No specific JSON response example for success.) ``` -------------------------------- ### Input API - Text Input Source: https://pinokio.co/docs/index Example of using the Input API to create a simple text input field. ```APIDOC ## POST /input (Text Input) ### Description Creates a modal with a default text input field. ### Method POST ### Endpoint /input ### Parameters #### Request Body - **method** (string) - Required - Must be 'input'. - **params** (object) - Required - Contains the configuration for the input modal. - **title** (string) - The input modal title. - **description** (string) - The input modal description. - **form** (array) - Required - An array containing a single text input configuration. - **key** (string) - Required - The key for the text input field (e.g., 'username'). - **title** (string) - Optional - The title for the input field. - **description** (string) - Optional - The description for the input field. - **placeholder** (string) - Optional - The placeholder text. - **default** (string) - Optional - The default value. ### Request Example ```json { "method": "input", "params": { "title": "Login", "description": "Enter your credentials", "form": [ { "key": "username", "title": "Username", "description": "Enter the username", "placeholder": "(ex: cocktailpeanut, etc.)", "default": "" } ] } } ``` ### Response #### Success Response (200) - **data** (object) - Contains the user's input for the text field. - **username** (string) - The entered username. #### Response Example ```json { "data": { "username": "some_user" } } ``` ``` -------------------------------- ### Input API - Password Input Source: https://pinokio.co/docs/index Example of using the Input API to create a password input field. ```APIDOC ## POST /input (Password Input) ### Description Creates a modal with a password input field. ### Method POST ### Endpoint /input ### Parameters #### Request Body - **method** (string) - Required - Must be 'input'. - **params** (object) - Required - Contains the configuration for the input modal. - **title** (string) - The input modal title. - **description** (string) - The input modal description. - **form** (array) - Required - An array containing a password input configuration. - **type** (string) - Set to 'password'. - **key** (string) - Required - The key for the password input field (e.g., 'pw'). - **title** (string) - Optional - The title for the input field. - **description** (string) - Optional - The description for the input field. - **placeholder** (string) - Optional - The placeholder text. ### Request Example ```json { "method": "input", "params": { "title": "Login", "description": "Enter your credentials", "form": [ { "type": "password", "key": "pw", "title": "Password", "description": "Enter the password", "placeholder": "******" } ] } } ``` ### Response #### Success Response (200) - **data** (object) - Contains the user's input for the password field. - **pw** (string) - The entered password. #### Response Example ```json { "data": { "pw": "user_password" } } ``` ``` -------------------------------- ### Specifying Shell Start Path Source: https://pinokio.co/docs/index Control the working directory for shell commands using the `path` parameter. ```APIDOC ## POST shell.run (Specify Path) ### Description Specifies the starting directory for the shell session using the `path` parameter. This is useful for running commands relative to a specific directory. ### Method POST ### Endpoint /websites/pinokio_co ### Parameters #### Request Body - **run** (array) - Required - An array of commands to execute. - **method** (string) - Required - Must be "shell.run". - **params** (object) - Required - Parameters for the shell.run method. - **path** (string) - Optional - The directory from which the shell should start. - **message** (string) - Required - The command to execute. ### Request Example ```json { "run": [ { "method": "shell.run", "params": { "path": "app", "message": "python app.py" } } ] } ``` ### Response #### Success Response (200) - **output** (string) - The output from the shell command executed in the specified path. #### Response Example ```json { "output": "Output from python app.py running in app/ folder..." } ``` ``` -------------------------------- ### Input API - Email Input Source: https://pinokio.co/docs/index Example of using the Input API to create an email input field. ```APIDOC ## POST /input (Email Input) ### Description Creates a modal with an email input field. ### Method POST ### Endpoint /input ### Parameters #### Request Body - **method** (string) - Required - Must be 'input'. - **params** (object) - Required - Contains the configuration for the input modal. - **title** (string) - The input modal title. - **description** (string) - The input modal description. - **form** (array) - Required - An array containing an email input configuration. - **type** (string) - Set to 'email'. - **key** (string) - Required - The key for the email input field (e.g., 'email'). - **title** (string) - Optional - The title for the input field. - **description** (string) - Optional - The description for the input field. - **placeholder** (string) - Optional - The placeholder text. ### Request Example ```json { "method": "input", "params": { "title": "Login", "description": "Enter your credentials", "form": [ { "type": "email", "key": "email", "title": "e-mail", "description": "Enter the email", "placeholder": "you@example.com" } ] } } ``` ### Response #### Success Response (200) - **data** (object) - Contains the user's input for the email field. - **email** (string) - The entered email address. #### Response Example ```json { "data": { "email": "user@example.com" } } ``` ``` -------------------------------- ### ComfyUI Install Script with Peer Linking Source: https://pinokio.co/docs/index This script installs ComfyUI and sets up a virtual drive for its models, listing Automatic1111 and Fooocus as peers. If a virtual drive has already been established by either of the peer repositories, ComfyUI will leverage that existing drive. This configuration is designed to efficiently share common model files among these three Stable Diffusion applications. ```json { "run": [ { "method": "shell.run", "params": { "message": "git clone https://github.com/comfyanonymous/ComfyUI.git app" } }, { "method": "fs.link", "params": { "drive": { "checkpoints": "app/models/checkpoints", "clip": "app/models/clip", "clip_vision": "app/models/clip_vision", "configs": "app/models/configs", "controlnet": "app/models/controlnet", "embeddings": "app/models/embeddings", "loras": "app/models/loras", "upscale_models": "app/models/upscale_models", "vae": "app/models/vae" }, "peers": [ "https://github.com/cocktailpeanutlabs/automatic1111.git", "https://github.com/cocktailpeanutlabs/fooocus.git" ] } } ] } ``` -------------------------------- ### App Launch API Source: https://pinokio.co/docs/index Launch a desktop application by its ID or name. Supports an install flow if the application is missing. ```APIDOC ## POST /app/launch ### Description Launch a desktop application by id or name. If the app is missing and an `install` URL is provided, Pinokio opens an install modal, waits for detection, handles macOS first-launch prompts, and then launches. ### Method POST ### Endpoint /app/launch ### Parameters #### Request Body - **id** (string) - Optional - The unique identifier for the app (preferred). - **app** (string) - Optional - The name of the app to search for if the ID is unknown. - **args** (array of strings) - Optional - Command-line arguments to pass to the application. - **refresh** (boolean) - Optional - Force a rescan of installed apps before launching. - **install** (string) - Optional - URL to open if the app is missing. Triggers an install flow. - **installTimeout** (integer) - Optional - Timeout in milliseconds for the install flow (default 5 minutes). - **installPollInterval** (integer) - Optional - Poll interval in milliseconds during the install flow (default 5 seconds). ### Request Example ```json { "method": "app.launch", "params": { "app": "Safari" } } ``` ```json { "method": "app.launch", "params": { "app": "Cursor", "args": ["--new-window"], "install": "https://cursor.sh/", "installTimeout": 600000, "installPollInterval": 5000 } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the launch was successful. - **id** (string) - The ID of the launched application. - **name** (string) - The name of the launched application. - **kind** (string) - The type or kind of the application. - **platform** (string) - The platform the app is running on (e.g., 'darwin'). - **detail** (string) - Additional details about the app. - **pid** (integer) - The process ID of the launched application. - **confidence** (number) - A confidence score for the launch. #### Response Example ```json { "success": true, "id": "com.apple.Safari", "name": "Safari", "kind": "macos-bundle", "platform": "darwin", "detail": "com.apple.Safari", "pid": 12345, "confidence": 0.92 } ``` #### Error Response (APP_NOT_FOUND) - **code**: "APP_NOT_FOUND" - **message**: "App not found and no install URL provided." ``` -------------------------------- ### Search for Chrome Application Source: https://pinokio.co/docs/index An example of searching for applications with the query 'chrome' and limiting the results to 5. ```json { "method": "app.search", "params": { "query": "chrome", "limit": 5 } } ``` -------------------------------- ### Input API - Textarea Input Source: https://pinokio.co/docs/index Example of using the Input API to create a textarea input field. ```APIDOC ## POST /input (Textarea Input) ### Description Creates a modal with a textarea input field for multi-line text entry. ### Method POST ### Endpoint /input ### Parameters #### Request Body - **method** (string) - Required - Must be 'input'. - **params** (object) - Required - Contains the configuration for the input modal. - **title** (string) - The input modal title. - **description** (string) - The input modal description. - **form** (array) - Required - An array containing a textarea input configuration. - **type** (string) - Set to 'textarea'. - **key** (string) - Required - The key for the textarea field (e.g., 'prompt'). - **title** (string) - Optional - The title for the input field. - **description** (string) - Optional - The description for the input field. - **placeholder** (string) - Optional - The placeholder text. ### Request Example ```json { "method": "input", "params": { "title": "Prompt", "description": "Enter a prompt", "form": [ { "type": "textarea", "key": "prompt", "title": "Prompt", "placeholder": "Describe what you want to generate..." } ] } } ``` ### Response #### Success Response (200) - **data** (object) - Contains the user's input for the textarea field. - **prompt** (string) - The entered multi-line text. #### Response Example ```json { "data": { "prompt": "A detailed description of the desired output." } } ``` ```