### Install dependencies and run dev server Source: https://github.com/howdeploy/canvastty/blob/main/README.md Run these commands from the project root to install dependencies and start the development server. Requires Node.js and npm. ```bash npm install npm run dev ``` -------------------------------- ### Install and build commands Source: https://github.com/howdeploy/canvastty/blob/main/integrations/even-g2/README.md Run these commands from the repository root to install dependencies, run tests, build, and package the Even G2 integration. ```sh npm ci npm run test:even npm run build npm run pack:even ``` -------------------------------- ### Example file layout for session-usage widget Source: https://github.com/howdeploy/canvastty/blob/main/docs/widget-authoring.md A naming example, not a runtime plugin ABI, showing the file structure for a session-usage widget. It lists the contracts, main services, IPC registration, preload, renderer feature files, and tests. ```text src/shared/contracts.ts src/main/services/SessionUsageService.ts src/main/ipc/registerIpc.ts src/preload/index.ts src/renderer/src/features/session-usage/ ├── SessionUsageWidget.tsx ├── sessionUsageModel.ts └── sessionUsage.css tests/session-usage.test.mjs ``` -------------------------------- ### Linux setup: prepare Python environment and run dev Source: https://github.com/howdeploy/canvastty/blob/main/docs/mascots.md From a source checkout, create a virtual environment, install the mascot pipeline requirements, set the CANVASTTY_MASCOT_PYTHON environment variable, and run the development server. This avoids modifying the system Python. ```sh python3 -m venv "$HOME/.local/share/canvastty-mascot-venv" "$HOME/.local/share/canvastty-mascot-venv/bin/python" -m pip install -r assets/mascot-pipeline/requirements.txt export CANVASTTY_MASCOT_PYTHON="$HOME/.local/share/canvastty-mascot-venv/bin/python" npm run dev ``` -------------------------------- ### Install approved build Source: https://github.com/howdeploy/canvastty/blob/main/assets/mascot-pipeline/SKILL.md After the user's installation decision, set installation_approved: true for that build and run this command. It writes mascot-result.json with ready_for_host, matching buildId, installationApproved: true, actions, plugin directory, and transparent/resizable presentation. ```text python scripts/finalize_mascot.py /character.json --install-approved ``` -------------------------------- ### Record accepted draft without installation Source: https://github.com/howdeploy/canvastty/blob/main/assets/mascot-pipeline/SKILL.md Run this command to record an accepted draft without requesting installation. Use --draft --install-approved only with separate installation consent for that draft. ```text python scripts/finalize_mascot.py /character.json --draft ``` -------------------------------- ### Manifest v1 JSON example Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md A complete manifest v1 example for a plugin named Studio Kit. It declares permissions, a hook, a settings contribution, and three contributions (home-widget, canvas-app, window). Plugin and contribution IDs are stable persistence keys and must not be renamed after publishing. ```json { "apiVersion": 1, "id": "com.example.studio-kit", "name": "Studio Kit", "version": "1.0.0", "description": "Small CanvasTTY surfaces backed by real host state.", "permissions": ["storage", "secrets", "sessions:read", "launcher:open"], "hooks": [ { "id": "audit", "title": "Local audit log", "description": "Writes selected agent lifecycle events to a user-managed log.", "entry": "hooks/audit.mjs", "providers": ["codex", "claude", "kimi"], "events": ["session-start", "permission-request", "session-end"] } ], "settingsContribution": "notes", "contributions": [ { "id": "session-status", "kind": "home-widget", "title": "Session status", "entry": "widgets/status.html", "defaultSize": { "columns": 4, "rows": 2 } }, { "id": "notes", "kind": "canvas-app", "title": "Notes", "entry": "apps/notes.html", "defaultSize": { "width": 680, "height": 440 }, "minSize": { "width": 320, "height": 180 } }, { "id": "focus", "kind": "window", "title": "Focus", "entry": "windows/focus.html", "defaultSize": { "width": 900, "height": 620 } } ] } ``` -------------------------------- ### Install dependencies and package for current OS Source: https://github.com/howdeploy/canvastty/blob/main/docs/installing-and-security.md Run npm install and npm run package to create an unpacked app for the current operating system. Requires Go 1.21 or newer for the native helper; without Go, a warning is printed and only JavaScript helpers are included. Set CANVASTTY_REQUIRE_NATIVE_HELPERS=1 to make the missing Go an error. ```bash npm install npm run package ``` -------------------------------- ### Produce reviewed status without installation request Source: https://github.com/howdeploy/canvastty/blob/main/assets/mascot-pipeline/SKILL.md Run this command to produce status: reviewed, which does not request installation. Ask separately whether to install or replace the project/build on the canvas unless already authorized. ```text python scripts/finalize_mascot.py /character.json ``` -------------------------------- ### Run apply-collector.sh installer Source: https://github.com/howdeploy/canvastty/blob/main/docs/diagnostics.md Run the one-time installer to deploy the updated collector. It checks the reviewed original collector hash, creates a private backup, checks JavaScript syntax, replaces only the collector script, restarts its service, and checks local health. A failure attempts to restore the original script and restart the service. If the deployed source hash differs, stop and review it instead of bypassing the check. ```sh sudo bash /PATH/TO/PACKAGE/apply-collector.sh ``` -------------------------------- ### canvastty.launch.prepare Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Request sent by the host to a service before an agent starts, allowing the service to add environment variables, secrets, arguments, files, or refuse the launch. ```APIDOC ## canvastty.launch.prepare ### Description Before the agent starts, the host sends the service a `canvastty.launch.prepare` request. The service can respond with `null` (nothing to add) or an object with optional fields to modify the launch. ### Request - **sessionId** (string) - The session identifier. - **provider** (string) - The provider identifier. - **profile** (string) - The profile name. - **role** (string) - The role, e.g., "agent". - **cwd** (string) - The working directory. - **restoring** (boolean) - Whether the session is being restored. - **resume** (boolean) - Whether the session is being resumed. - **options** (object) - Launch options, e.g., `enabled`, `greeting`, `mode`. - **chosen** (boolean) - Whether the launch was chosen. - **environment** (object or null) - The environment. ### Response - **null** - Nothing to add. - **env** (object) - Optional. Map of environment variable names to values. Limit: 32 names, 8 KB per value. - **secretEnv** (object) - Optional. Map of environment variable names to secret keys. Limit: 16 names; requires `secrets`. The host reads the plugin's own secret and sets it; the value never reaches the service or UI and is masked as ``. - **args** (array of strings) - Optional. Arguments appended after CanvasTTY's own arguments, before resume selection. Limit: 32, 1024 characters each, no control characters. - **files** (array of objects) - Optional. Files to write to a private folder for this run. Each object has `relPath` and `content`. Limit: 16 files, 256 KB, plain relative paths. `{launchFiles}` in `env` values and `args` becomes that folder. - **thirdPartyModel** (boolean) - Optional. If `true`, the agent runs on another model than its vendor's. Profile `auto` then runs as accept-edits for this launch. - **refuse** (object) - Optional. Contains `reason` (string, 240 characters) to refuse the launch. ### Notes - The host enforces all rules and never skips them. - A refused, failed, or cancelled launch fails the call with the reason and session id; the card stays. - The control CLI answers `NOT_READY` for such a card. ``` -------------------------------- ### Verify draft with installation approval Source: https://github.com/howdeploy/canvastty/blob/main/assets/mascot-pipeline/SKILL.md The host verifies the same draft mode with this command, which does not rewrite the requested result. ```text python scripts/finalize_mascot.py /character.json --draft --verify-only --install-approved ``` -------------------------------- ### Create platform-specific installers Source: https://github.com/howdeploy/canvastty/blob/main/docs/installing-and-security.md Run the platform-specific package script on its matching operating system. Cross-compilation is not considered proof of compatibility because node-pty is native. ```bash npm run package:linux npm run package:win npm run package:mac ``` -------------------------------- ### Use CanvasTTYPlugin to get a draft Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to get a draft. ```javascript const draft = await host.storage.get('draft'); ``` -------------------------------- ### Use CanvasTTYPlugin to write a playlist Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to write a playlist. ```javascript await host.playlists.write('favorites.m3u8', '#EXTM3U\n'); ``` -------------------------------- ### Use CanvasTTYPlugin to open a browser Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to open a browser. ```javascript await host.browser.open('http://localhost:9210'); ``` -------------------------------- ### Run validation commands (npm test, typecheck, build, smoke test) Source: https://github.com/howdeploy/canvastty/blob/main/docs/agent-orchestration.md Run the project's test suite, type checking, build, and an opt-in live smoke test for agent control. The smoke test uses the actual CLI client, native PTY, installed Codex, and authenticated lifecycle/result hooks. It creates and edits a uniquely named proof file, verifies its bytes, and retains evidence. It never controls the user's desktop window, uses existing Codex authentication, and consumes provider usage. The smoke prints its session ID and private connection/client paths at startup; if a startup menu blocks it, inspect that session with the CLI using those paths and resolve only reviewed, authorized choices. It waits up to two minutes for a ready composer and does not silently trust hooks or approve permissions. ```sh npm test npm run typecheck npm run build node scripts/smoke-agent-control.mjs --live --cwd /already/trusted/test-directory --artifacts /private/acceptance-directory ``` -------------------------------- ### Read a report with gzip -dc Source: https://github.com/howdeploy/canvastty/blob/main/docs/diagnostics.md Use this command to decompress and print a saved report file. The report contains receivedAt and report fields; report.description is the complaint, report.context describes the installation, and report.logs contains recent events. Requires sudo for the deployed private directory. ```sh gzip -dc /var/lib/canvastty-reports/REPORT-UUID.json.gz ``` -------------------------------- ### Use CanvasTTYPlugin to scan media Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to scan media. ```javascript const media = await host.media.scan(); ``` -------------------------------- ### Use CanvasTTYPlugin to list playlists Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to list playlists. ```javascript const playlists = await host.playlists.list(); ``` -------------------------------- ### Create a native worker with explicit directory and title Source: https://github.com/howdeploy/canvastty/blob/main/agent/orchestrator/SKILL.md Use this command to create a CanvasTTY worker with a specific provider, working directory, and task title. Run 'providers' first to see installed providers. Add --model if a model is named, and --effort for Codex, Claude, and Grok. --provider accepts codex, claude, qwen, kimi, opencode, hermes, grok, omp, and pi. ```bash node scripts/canvastty-control.mjs create --provider codex --cwd --title ``` -------------------------------- ### Maintainer setup for Sparkle signing Source: https://github.com/howdeploy/canvastty/blob/main/docs/installing-and-security.md Commands to set up Sparkle signing keys and configure GitHub Actions variables and secrets for CanvasTTY. Requires a trusted Mac, pinned Sparkle 2.10.0 tools, and authenticated GitHub CLI. The private key is stored in the login Keychain and exported to a temporary file for setting the secret. ```bash npm ci npm run build:mac-updater gh auth status artifacts/sparkle/distribution/bin/generate_keys --account howdeploy.CanvasTTY gh variable set SPARKLE_PUBLIC_ED_KEY --repo howdeploy/CanvasTTY \ --body "$(artifacts/sparkle/distribution/bin/generate_keys --account howdeploy.CanvasTTY -p)" ( umask 077 key_dir="$(mktemp -d)" trap 'rm -f "$key_dir/private.key"; rmdir "$key_dir"' EXIT artifacts/sparkle/distribution/bin/generate_keys --account howdeploy.CanvasTTY -x "$key_dir/private.key" gh secret set SPARKLE_EDDSA_PRIVATE_KEY --app actions --repo howdeploy/CanvasTTY < "$key_dir/private.key" ) ``` -------------------------------- ### Use CanvasTTYPlugin to open a canvas Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to open a canvas. ```javascript await host.canvas.open('notes'); ``` -------------------------------- ### systemd unit for the collector Source: https://github.com/howdeploy/canvastty/blob/main/docs/diagnostics.md Example systemd unit for running the collector as a service. Assumes a dedicated 'canvastty-reports' account and the script placed at /opt/canvastty-reports/collector.mjs. The unit sets the reports directory and port via environment variables and applies several security hardening options. ```ini [Unit] Description=CanvasTTY diagnostic report collector After=network.target [Service] Type=simple User=canvastty-reports Group=canvastty-reports StateDirectory=canvastty-reports StateDirectoryMode=0700 Environment=REPORTS_DIRECTORY=/var/lib/canvastty-reports Environment=PORT=8787 ExecStart=/usr/bin/node /opt/canvastty-reports/collector.mjs Restart=on-failure UMask=0077 NoNewPrivileges=true PrivateTmp=true ProtectSystem=strict ProtectHome=true [Install] WantedBy=multi-user.target ``` -------------------------------- ### CanvasTTY Services Manifest Example Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Shows a services array in a manifest with apiVersion 2. Declares a service with id 'echo', title, description, and entry 'services/echo.mjs'. ```json "services": [ { "id": "echo", "title": "Echo", "description": "Echoes requests.", "entry": "services/echo.mjs" } ] ``` -------------------------------- ### Configure AppArmor profile for bubblewrap Source: https://github.com/howdeploy/canvastty/blob/main/docs/installing-and-security.md Creates an AppArmor profile for /usr/bin/bwrap with unconfined flag and userns permission, then reloads the profile. Recommended for Ubuntu 24.04+ when bubblewrap cannot start due to unprivileged user namespace restrictions. ```sh sudo tee /etc/apparmor.d/bwrap >/dev/null <<'EOF' abi , include profile bwrap /usr/bin/bwrap flags=(unconfined) { userns, include if exists } EOF sudo apparmor_parser -r /etc/apparmor.d/bwrap ``` -------------------------------- ### Validation commands for mascot installation pipeline Source: https://github.com/howdeploy/canvastty/blob/main/docs/mascots.md Run these commands from the repository root in a Python environment with Pillow and NumPy. The Node.js tests cover mascot installation, plugin bounds, plugin manager, settings normalizer, agent runtime provider launch, and terminal launch. The Python scripts run smoke and placement regression tests. ```text npm run typecheck node --test tests/mascot-installation.test.mjs tests/plugin-bounds.test.mjs tests/plugin-manager.test.mjs tests/settings-normalizer.test.mjs tests/agent-runtime-provider-launch.test.mjs tests/terminal-launch.test.mjs python -B assets/mascot-pipeline/tests/smoke_pipeline.py python -B assets/mascot-pipeline/tests/placement_regression.py ``` -------------------------------- ### Use CanvasTTYPlugin to list sessions Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to list sessions. ```javascript const sessions = await host.sessions.list(); ``` -------------------------------- ### Use CanvasTTYPlugin to store a draft Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to store a draft. ```javascript await host.storage.set('draft', { text: 'Local to this plugin' }); ``` -------------------------------- ### Build and test commands for CanvasTTY Even G2 Source: https://github.com/howdeploy/canvastty/blob/main/docs/even-g2.md Run these commands in order to install dependencies, run tests, build, and package the Even G2 integration. The macOS build downloads a pinned native runtime archive and verifies its hash. Use CANVASTTY_SPEECH_ARCH=x64 for an Intel build. ```sh npm ci npm test npm run test:even npm run build npx electron-builder --dir --mac --arm64 --publish never npm run pack:even ``` -------------------------------- ### Build adapted frontend with Rust 1.95.0 Source: https://github.com/howdeploy/canvastty/blob/main/docs/linux-native-editing.md Run from the adapted frontend checkout (../codex-macos-tui/codex-rs). Installs Rust 1.95.0 with the minimal profile and builds the canvastty-codex-tui binary with debug info disabled. The build uses --locked and -j 6. ```shell cd ../codex-macos-tui/codex-rs rustup toolchain install 1.95.0 --profile minimal CARGO_PROFILE_DEV_DEBUG=0 rustup run 1.95.0 cargo build --locked -j 6 -p codex-tui --bin canvastty-codex-tui ``` -------------------------------- ### list_providers Source: https://github.com/howdeploy/canvastty/blob/main/docs/agent-orchestration.md Lists the agent providers CanvasTTY can launch as subagents, including their IDs, names, installation status, sign-in state, model support, and plugin launch options. It uses cached state only and makes no network calls. ```APIDOC ## list_providers ### Description Lists the agent providers CanvasTTY can launch as subagents. Returns provider details such as id, name, installed/available status, sign-in state, model support, and plugin launch options. Uses cached state only, no network calls. ### Method MCP Tool ### Endpoint canvastty_agents.list_providers ### Parameters None ### Response #### Success Response - **providers** (array) - List of provider objects with fields: `id` (string), `name` (string), `installed` (boolean), `available` (boolean), `signIn` (string: ok, signed_out, expired, unknown), `subagent` (boolean), `orchestrator` (boolean), `model` (object), `efforts` (array), `launchOptions` (object), `launchOptionTools` (array), `profiles` (array) #### Response Example ```json { "providers": [ { "id": "codex", "name": "Codex", "installed": true, "available": true, "signIn": "ok", "subagent": true, "orchestrator": true, "model": { "supported": true, "format": "--model" }, "efforts": ["low", "medium", "high"], "launchOptions": {}, "launchOptionTools": [], "profiles": ["auto", "normal", "acceptEdits", "plan"] } ] } ``` ``` -------------------------------- ### Validate pixel skin ZIP with node script Source: https://github.com/howdeploy/canvastty/blob/main/docs/pixel-skin-agent-start.md Run from the repository root to validate the theme install ZIP. It uses the same ZIP importer as CanvasTTY in an isolated temporary profile, checking the exact file set and new-theme frame dimensions. A successful structural check does not prove the art looks good. ```sh node scripts/validate-pixel-skin-zip.mjs /absolute/path/theme-install.zip ``` -------------------------------- ### Start CanvasTTY with agent control enabled Source: https://github.com/howdeploy/canvastty/blob/main/docs/agent-orchestration.md Use this command to force the agent orchestration endpoint on for a single invocation, regardless of the global setting. It does not modify global settings or enable a network listener. A currently running app without this flag must be restarted by its user before the endpoint is available. ```sh CANVASTTY_AGENT_CONTROL=1 npm run dev ``` -------------------------------- ### Use CanvasTTYPlugin to get state Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to get state. ```javascript const state = await host.getState(); ``` -------------------------------- ### Use CanvasTTYPlugin to get a secret Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to get a secret. ```javascript const token = await host.secrets.get('oauth-token'); ``` -------------------------------- ### Build and run runtime benchmark commands Source: https://github.com/howdeploy/canvastty/blob/main/docs/performance-benchmark.md Commands to build the app and run the runtime benchmark. The first builds the app for the scenarios to measure. The second runs 3 runs with medians. The third runs a single run with micro-only. The fourth runs a single run with pan-only (about 30 s). The fifth runs with custom terminals, kbps, flood-seconds, and outputs JSON to bench.json. ```sh npx electron-vite build # the app scenarios measure out/ node scripts/bench-runtime.mjs # 3 runs, medians node scripts/bench-runtime.mjs --runs 1 --micro-only node scripts/bench-runtime.mjs --runs 1 --pan-only # cards and the pan only, about 30 s node scripts/bench-runtime.mjs --terminals 8 --kbps 1024 --flood-seconds 20 --json bench.json ``` -------------------------------- ### Pipeline commands for QA, scaffold, build, preview, and review Source: https://github.com/howdeploy/canvastty/blob/main/assets/mascot-pipeline/SKILL.md Run these commands in order from the pipeline directory, using project-relative paths. The scripts are qa_frames.py, scaffold_plugin.py, build_sprite.py, preview_animation.py, and review_continuity.py. The preview command requires an action ID. ```text python scripts/qa_frames.py /character.json python scripts/scaffold_plugin.py /character.json python scripts/build_sprite.py /character.json python scripts/preview_animation.py /character.json --action python scripts/review_continuity.py /character.json ``` -------------------------------- ### host.media.pickLibrary() Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Opens the native directory picker and persists the grant. Returns an object with id and name, or null if cancelled. ```APIDOC ## host.media.pickLibrary() ### Description Opens the native directory picker and persists the grant. Returns `{ id, name }` or `null` when cancelled. ### Method SDK Call ### Endpoint `host.media.pickLibrary()` ### Parameters None ### Request Example ```js const library = await host.media.pickLibrary(); ``` ### Response #### Success Response - **id** (string) - The library identifier. - **name** (string) - The display name of the selected folder. #### Response Example ```json { "id": "library-id", "name": "Music" } ``` ``` -------------------------------- ### host.media.pickLibrary Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Prompts the user to pick a music library and returns the selected library object. ```APIDOC ## host.media.pickLibrary ### Description Prompts the user to pick a music library and returns the selected library object. ### Method pickLibrary ### Request Example ```js const library = await host.media.pickLibrary(); ``` ### Response Returns a library object with an `id` field, or `null` if the user cancels. ``` -------------------------------- ### Use CanvasTTYPlugin to set a secret Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Example of using the CanvasTTYPlugin API to set a secret. ```javascript await host.secrets.set('oauth-token', token); ``` -------------------------------- ### Launch CanvasTTY with QA frontend and isolated profile Source: https://github.com/howdeploy/canvastty/blob/main/docs/linux-native-editing.md Run from the canvastty checkout after building. Sets PATH to the isolated official Codex backend, a separate user-data directory, and QA environment variables pointing to the built frontend and launcher. The prefixed PATH lets the provider registry resolve the official 0.159.2 executable. Keep the profile path short because browser gateway sockets are created below it and must fit the Unix socket path limit. ```shell cd ../../canvastty mkdir -p ../ctty-qa PATH="$PWD/artifacts/codex-native-backend:$PATH" \ CANVASTTY_USER_DATA_DIR="$PWD/../ctty-qa" \ CANVASTTY_CODEX_TUI_QA="$PWD/../codex-macos-tui/codex-rs/target/debug/canvastty-codex-tui" \ CANVASTTY_CODEX_TUI_LAUNCHER_QA="$PWD/../codex-macos-tui/macos/codex-tui-launch.mjs" \ node_modules/.bin/electron . ``` -------------------------------- ### canvastty.launch.options Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Request sent by the launcher to a service to list dynamic choices for fields with optionsFrom: service. The service responds with up to 64 choices per field. ```APIDOC ## canvastty.launch.options ### Description When a launcher opens, CanvasTTY asks the service `canvastty.launch.options` to list choices for fields that use `"optionsFrom": "service"`. The service may respond with additional choices that are added after the declared ones. ### Request - **provider** (string) - The provider identifier. - **fields** (array of strings) - The keys of the fields for which choices are requested. ### Response - **``** (array of objects) - For each requested field, an array of choice objects, each with `value` and `label`. - **value** (string) - The value of the choice. - **label** (string) - The display label for the choice. ### Notes - The service must respond within 3 seconds. - Up to 64 choices per field are added. - The declared options remain required and are always shown. - If the service does not answer, only the declared options are shown. - The value of such a field is accepted as any text up to 200 characters without control characters. - `canvastty.launch.prepare` must check the value and refuse it if it is no longer known. ``` -------------------------------- ### UI Channel: host.service.request and host.service.onEvent Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Sandboxed surfaces call their own plugin's services using these methods. The permission is implicit when the plugin declares a service. ```APIDOC ## UI Channel: host.service.request and host.service.onEvent ### Description Sandboxed surfaces call their own plugin's services using these methods. The permission is implicit when the plugin declares a service. The host relays opaque JSON and never adds credentials. ### Methods #### `host.service.request` - **Parameters**: `(serviceId, method, params)` - Example: `host.service.request("echo", "echo", { text: "hi" })` - **Result**: A promise that resolves with the reply from the service. - **Errors**: Rejects with an error if the service is not running (not trusted yet, disabled, restarting, failed) or if the request times out. #### `host.service.onEvent` - **Parameters**: `(callback)` - The callback receives an object with `serviceId`, `event`, and `data`. - **Result**: Registers a handler for events sent from the service via the `event` host method. ### Example ```js const reply = await host.service.request("echo", "echo", { text: "hi" }); host.service.onEvent(({ serviceId, event, data }) => { /* … */ }); ``` ``` -------------------------------- ### host.media.listLibraries() Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Restores this plugin's granted libraries after a restart without exposing absolute paths. ```APIDOC ## host.media.listLibraries() ### Description Restores this plugin's granted libraries after a restart without exposing absolute paths. ### Method SDK Call ### Endpoint `host.media.listLibraries()` ### Parameters None ### Request Example ```js const libraries = await host.media.listLibraries(); ``` ### Response #### Success Response - **id** (string) - The library identifier. - **name** (string) - The display name of the library. #### Response Example ```json [ { "id": "library-id", "name": "Music" } ] ``` ``` -------------------------------- ### Run CanvasTTY Quick Checks Source: https://github.com/howdeploy/canvastty/blob/main/README.md Use these npm commands to run tests, type checking, and build for the CanvasTTY project. Run them in the project root. ```bash npm test npm run test:even npm run typecheck npm run build ``` -------------------------------- ### UI channel: host.service.request and onEvent Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Shows how a sandboxed surface calls its own plugin's service and listens for events. The permission is implicit when the plugin declares a service. The host relays opaque JSON and never adds credentials. ```javascript const reply = await host.service.request("echo", "echo", { text: "hi" }); host.service.onEvent(({ serviceId, event, data }) => { /* … */ }); ``` -------------------------------- ### get_agent_result Source: https://github.com/howdeploy/canvastty/blob/main/docs/agent-orchestration.md Retrieves the final answer of a subagent's last turn, along with its status and masked terminal tail. The answer is limited to 4096 characters and is cleared when the next turn starts. ```APIDOC ## get_agent_result ### Description Retrieves the final answer of the subagent's last turn as reported by the agent itself, along with the exit state and masked terminal tail. The answer is limited to 4096 characters and is cleared when the next turn starts. ### Method MCP Tool ### Endpoint canvastty_agents.get_agent_result ### Parameters #### Request Body - **sessionId** (string) - Required - The session ID of the subagent. ### Request Example ```json { "sessionId": "abc123" } ``` ### Response #### Success Response - **answer** (string) - The final reply of the subagent's last turn, up to 4096 characters. - **status** (string) - The exit state. - **tail** (string) - The masked terminal tail. #### Response Example ```json { "answer": "The task is complete.", "status": "done", "tail": "masked terminal output" } ``` ``` -------------------------------- ### Open media picker Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Opens the native media picker to select a media file. ```javascript host.media.pickLibrary() ``` -------------------------------- ### List media libraries Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Lists all available media libraries. ```javascript host.media.listLibraries() ``` -------------------------------- ### host.request Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Invokes a host request by name with optional arguments. Supported request names include sessions.list, launcher.open, window.open, browser.open, and service.request. ```APIDOC ## host.request ### Description Invokes a host request by name with optional arguments. Supported request names include sessions.list, launcher.open, window.open, browser.open, and service.request. ### Method request ### Parameters #### Request Name - **name** (string) - Required - The request name, e.g. `sessions.list`, `launcher.open`, `window.open`, `browser.open`, `service.request`. #### Arguments - **args** (object) - Optional - Arguments for the request. For `launcher.open`, use `{ provider: "codex" }`. For `window.open`, use `{ contributionId: "focus" }`. For `browser.open`, use `{ url: "http://localhost:9210" }`. ### Request Example ```js const sessions = await host.request("sessions.list"); await host.request("launcher.open", { provider: "codex" }); await host.request("window.open", { contributionId: "focus" }); await host.request("browser.open", { url: "http://localhost:9210" }); ``` ### Response Returns the result of the request. For `sessions.list`, returns a list of sessions. ``` -------------------------------- ### Launch Contributors (launch:contribute) Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Configuration for a service to contribute fields to the agent launcher. One service per plugin may add a launch block. ```APIDOC ## Launch Contributors (launch:contribute) ### Description One service per plugin may add a `launch` block. Its fields appear in the agent launcher under **Advanced** once the plugin's native code is trusted. The person turns the plugin on for one launch with **Use _plugin name_** and sets its fields. Only launches where the person chose the plugin, and restarts and restores of those cards, ask the plugin anything. ### Configuration - **Permission**: `launch:contribute` - **Service definition**: The service must include a `launch` block with the following properties: - `appliesTo` (array of strings) - Lists agent providers; omitted means every agent. - `fields` (array of objects) - Up to 8 fields. Each field has: - `key` (string) - Field identifier. - `label` (string) - Display label. - `kind` (string) - `boolean`, `select`, or `text`. - `default` (any) - Default value. - For `select`: `options` array with `value` and `label` (1–16 options). - For `text`: `maxLength` (optional, at most 200 characters). ### Example ```json "permissions": ["launch:contribute"], "services": [{ "id": "launcher", "title": "Launch env", "entry": "services/launcher.mjs", "launch": { "appliesTo": ["claude"], "fields": [ { "key": "enabled", "label": "Add the variable", "kind": "boolean", "default": true }, { "key": "greeting", "label": "Value", "kind": "text", "default": "hello", "maxLength": 60 }, { "key": "mode", "label": "Mode", "kind": "select", "default": "plain", "options": [{ "value": "plain", "label": "Plain" }, { "value": "loud", "label": "Loud" }] } ] } }] ``` ### Notes - The chosen values are checked against the fields, saved in the card's session record (at most 4 KB per plugin), and reused on restart and restore. - They are not secret: put keys in the plugin's `secrets`, never in a field. ``` -------------------------------- ### Launch contributor service configuration Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md JSON configuration for a service with a launch block. Fields appear in the agent launcher under Advanced once the plugin's native code is trusted. Up to 8 fields; kind is boolean, select (1–16 options) or text (at most 200 characters, or maxLength). appliesTo lists agent providers; omitted means every agent. Chosen values are saved in the card's session record (at most 4 KB per plugin) and reused on restart and restore. ```json "permissions": ["launch:contribute"], "services": [{ "id": "launcher", "title": "Launch env", "entry": "services/launcher.mjs", "launch": { "appliesTo": ["claude"], "fields": [ { "key": "enabled", "label": "Add the variable", "kind": "boolean", "default": true }, { "key": "greeting", "label": "Value", "kind": "text", "default": "hello", "maxLength": 60 }, { "key": "mode", "label": "Mode", "kind": "select", "default": "plain", "options": [{ "value": "plain", "label": "Plain" }, { "value": "loud", "label": "Loud" }] } ] } }] ``` -------------------------------- ### host.playlists.write(libraryId, name, content) Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Atomically writes .m3u, .m3u8, .pls, or .json under the library's Playlists/ directory, up to 4 MB. ```APIDOC ## host.playlists.write(libraryId, name, content) ### Description Atomically writes `.m3u`, `.m3u8`, `.pls`, or `.json` under the library's `Playlists/` directory, up to 4 MB. ### Method SDK Call ### Endpoint `host.playlists.write(libraryId, name, content)` ### Parameters #### Path Parameters - **libraryId** (string) - Required - The identifier of the library. - **name** (string) - Required - The name of the playlist file (including extension). - **content** (string) - Required - The playlist content to write. ### Request Example ```js await host.playlists.write(libraryId, 'My Playlist.m3u', '#EXTM3U\n#EXTINF:123,Song\nrelative/path.mp3'); ``` ### Response #### Success Response No content returned. ``` -------------------------------- ### Run the collector with environment variables Source: https://github.com/howdeploy/canvastty/blob/main/docs/diagnostics.md Run the collector in the foreground with Node.js 22 or newer. Set REPORTS_DIRECTORY to an existing writable private directory and PORT to 8787. The HTTP listener binds only to 127.0.0.1, so it must be placed behind an HTTPS reverse proxy and not exposed publicly. ```sh REPORTS_DIRECTORY=/path/to/private/reports PORT=8787 node /path/to/collector.mjs ``` -------------------------------- ### host.hermesHud.open Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Opens the Hermes HUD using a fixed control contract. ```APIDOC ## host.hermesHud.open ### Description Opens the Hermes HUD using a fixed control contract. ### Method open ### Request Example ```js await host.hermesHud.open(); ``` ### Response No return value documented. ``` -------------------------------- ### host.onContext Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Registers a callback that receives the current appearance and contribution context. ```APIDOC ## host.onContext ### Description Registers a callback that receives the current appearance and contribution context. ### Method onContext ### Parameters #### Callback - **callback** (function) - Required - Receives an object with `appearance` and `contribution` fields. ### Request Example ```js host.onContext(({ appearance, contribution }) => { document.documentElement.dataset.palette = appearance.palette; document.title = contribution.title; }); ``` ### Response No return value documented. ``` -------------------------------- ### Plugin configuration with decision:provide service Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Declares a plugin service that provides decision hooks for pre-tool events, applying to Claude and Codex agents with a 3000ms timeout. ```json { "permissions": ["decision:provide"], "services": [{ "id": "guard", "title": "rm -rf guard", "entry": "services/guard.mjs", "decide": { "events": ["pre-tool"], "appliesTo": ["claude", "codex"], "timeoutMs": 3000 } }] } ``` -------------------------------- ### host.playlists.write Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Writes playlist contents to a playlist in a music library. ```APIDOC ## host.playlists.write ### Description Writes playlist contents to a playlist in a music library. ### Method write ### Parameters #### Library ID - **libraryId** (string) - Required - The ID of the library. #### Playlist Name - **playlistName** (string) - Required - The name of the playlist file, e.g. `favorites.m3u8`. #### Contents - **contents** (string) - Required - The playlist contents to write. ### Request Example ```js await host.playlists.write(library.id, "favorites.m3u8", text || "#EXTM3U\n"); ``` ### Response No return value documented. ``` -------------------------------- ### Agent task brief template Source: https://github.com/howdeploy/canvastty/blob/main/docs/widget-authoring.md Copy this text into the agent task and replace the bracketed fields. It instructs the agent to read architecture docs, follow the existing feature pattern, and respect constraints like context isolation and typed contracts. ```text Add a CanvasTTY widget called [NAME] that shows [USER VALUE]. Before editing, read docs/ARCHITECTURE.md and docs/UI_CONTRACT.md and find the closest existing feature pattern. CanvasTTY is an Electron MVP with context isolation: privileged work stays in main, cross-process data is declared in src/shared/contracts.ts, IPC is allow-listed, and preload exposes only a typed, sanitized capability. Data source: [STRUCTURED SOURCE]. Never parse terminal/TUI text and never invent values. Render explicit loading, available, stale, unavailable, and error states. Do not expose credentials, raw provider responses, prompts, or unbounded history. Visual direction: calm spatial desktop; large flat tile; soft radius; restrained shadow; graphite operational surfaces with sage/pink/blue/yellow accents; short labels; readable at canvas zoom. Reuse vendored Lucide/provider assets. Do not add decorative status dots, hover-only core controls, nested frames, or custom SVG in TSX. Preserve wheel ownership rules. Scope: [HOME PASSIVE / HOME MAIN-BACKED / CANVAS ENTITY]. Add focused tests for normalization and state selection. Run npm test, npm run typecheck, npm run build, then inspect the affected flow in the real Electron window. Do not add packages. ``` -------------------------------- ### adb reverse for Web companion USB testing Source: https://github.com/howdeploy/canvastty/blob/main/CHANGELOG.md Exposes the loopback-only listener to the phone at `http://127.0.0.1:3481/mobile/` for testing without a phone VPN. USB debugging should be disabled and its authorization revoked afterward. ```bash adb reverse tcp:3481 tcp:3481 ``` -------------------------------- ### spawn_agent Source: https://github.com/howdeploy/canvastty/blob/main/docs/agent-orchestration.md Launches a subagent with the specified provider and optional model and effort. The provider must be a valid id from list_providers; unknown providers are refused with INVALID_REQUEST. The subagent's profile can be specified or inherited from the orchestrator. ```APIDOC ## spawn_agent ### Description Launches a subagent. The provider must be a valid id from `list_providers`; unknown providers are refused with `INVALID_REQUEST` naming `list_providers`. Optional `model` and `effort` are passed to the CLI's own flags. The subagent's profile can be specified or inherited. ### Method MCP Tool ### Endpoint canvastty_agents.spawn_agent ### Parameters #### Request Body - **provider** (string) - Required - The provider id from `list_providers`. - **model** (string) - Optional - The model to use for the subagent run. Passed to the CLI's `--model` flag. - **effort** (string) - Optional - The reasoning effort to use. Passed to the CLI's effort flag. - **profile** (string) - Optional - One of `auto`, `normal`, `acceptEdits`, `plan`. If omitted, inherits the orchestrator's profile or the next lower one available. ### Request Example ```json { "provider": "codex", "model": "gpt-5", "effort": "high", "profile": "acceptEdits" } ``` ### Response #### Success Response - **sessionId** (string) - The session ID of the spawned subagent. - **profile** (string) - The profile the subagent actually got. - **profileInherited** (boolean) - Whether the profile was inherited. #### Response Example ```json { "sessionId": "abc123", "profile": "acceptEdits", "profileInherited": false } ``` ### Error Handling - **INVALID_REQUEST** - If the provider is unknown, the error names `list_providers` as the source of valid ids. ``` -------------------------------- ### host.visibility() Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Returns the current visibility state: 'visible' or 'hidden'. ```APIDOC ## host.visibility() ### Description Returns the current visibility state: `'visible'` or `'hidden'`. ### Method SDK Call ### Endpoint `host.visibility()` ### Parameters None ### Request Example ```js const state = host.visibility(); ``` ### Response #### Success Response - **state** (string) - `'visible'` or `'hidden'`. #### Response Example ```json "visible" ``` ``` -------------------------------- ### Host validation of install-approved result Source: https://github.com/howdeploy/canvastty/blob/main/assets/mascot-pipeline/SKILL.md Host validation uses this command without rewriting the requested result. ```text python scripts/finalize_mascot.py /character.json --verify-only --install-approved ``` -------------------------------- ### Handle visibility change Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Pauses playback when the app becomes hidden and resumes when visible. ```javascript document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') { pausePlayback(); } else { resumePlayback(); } }); ``` -------------------------------- ### host.playlists.list Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Lists playlists in a given music library. ```APIDOC ## host.playlists.list ### Description Lists playlists in a given music library. ### Method list ### Parameters #### Library ID - **libraryId** (string) - Required - The ID of the library. ### Request Example ```js const playlists = await host.playlists.list(library.id); ``` ### Response Returns an array of playlist objects, each with an `id` field. ``` -------------------------------- ### Tailscale Serve commands for Web companion Source: https://github.com/howdeploy/canvastty/blob/main/docs/mobile-companion.md Run these commands on the host computer to proxy the HTTPS tailnet address to CanvasTTY's HTTP listener at 127.0.0.1:3481. Use `tailscale serve --bg 3481` first, then check status. On Linux, if Serve reports `Access denied: serve config denied`, use the sudo variant with `--https=443`. Never use `tailscale funnel` as it exposes the service publicly. ```bash tailscale serve --bg 3481 ``` ```bash tailscale serve status ``` ```bash sudo tailscale serve --bg --https=443 http://127.0.0.1:3481 ``` -------------------------------- ### Write playlist Source: https://github.com/howdeploy/canvastty/blob/main/docs/plugins.md Writes a playlist to a media library. ```javascript host.playlists.write(libraryId, name, content) ```