Specify a webhook-driven task for OpenClaw
Describe event inputs, validation, deduplication, and intended actions before integration work.
5,421,327 AI resources indexedWorking toward the world’s largest AI resource index.
Facilitates the integration of Tauri commands in MooshieUI, enabling seamless backend command and IPC endpoint creation.
---
name: add-tauri-command-965fd1b20ff4
description: >-
Adds a MooshieUI Tauri command end-to-end — Rust handler, lib.rs registration,
and TypeScript ipcInvoke wrapper. Use when adding a backend command, IPC endpoint,
or /add-tauri-command.
---
# Add Tauri Command (MooshieUI)
Minimum **3 files**, in this order. Works in **desktop and browser mode** only if you use `ipcInvoke()` (never raw `invoke()`).
## Gather from user
1. Command name (Rust `snake_case`, TS `camelCase` function)
2. Parameters (name + type each)
3. Return type
4. Module: `api` | `server` | `websocket` | `workflow` | `config` | new
5. Needs `AppHandle`? (only for events / app paths)
## 1. Rust — `src-tauri/src/commands/{module}.rs`
```rust
#[tauri::command]
pub async fn my_command(
state: State<'_, AppState>,
my_param: String,
) -> Result<ReturnType, AppError> {
let config = state.config.read().await;
// ...
drop(config);
Ok(result)
}
```
- `Result<T, AppError>` only; no panic
- `AppHandle` only if emitting events / spawning tasks
- Drop `RwLock` before I/O `.await`
- HTTP via `state.http_client`
- New module → `pub mod x;` in `commands/mod.rs`
## 2. Register — `src-tauri/src/lib.rs`
```rust
.invoke_handler(tauri::generate_handler![
commands::api::my_command,
])
```
## 3. TypeScript — `src/lib/utils/api.ts`
```typescript
export async function myCommand(myParam: string): Promise<ReturnType> {
return ipcInvoke("my_command", { myParam });
}
```
- camelCase keys in payload; Rust receives snake_case
- New shapes → `src/lib/types/index.ts` (serde field names, often snake_case)
## Verify
```powershell
cargo check --manifest-path src-tauri/Cargo.toml
```
```
- [ ] #[tauri::command] + Result<_, AppError>
- [ ] Listed in generate_handler!
- [ ] api.ts uses ipcInvoke("my_command", ...)
- [ ] Names aligned TS camelCase ↔ Rust snake_case
- [ ] Browser mode: matching arm in `webserver.rs` `dispatch_command` (and `ADMIN_COMMANDS` / `MODERATOR_COMMANDS` if restricted)
- [ ] MCP: would an AI assistant want this? If so, consider a tool in `src-tauri/src/mcp/tools.rs` (see `docs/MCP.md`)
```
---
name: add-tauri-command-965fd1b20ff4
description: >-
Adds a MooshieUI Tauri command end-to-end — Rust handler, lib.rs registration,
and TypeScript ipcInvoke wrapper. Use when adding a backend command, IPC endpoint,
or /add-tauri-command.
---
# Add Tauri Command (MooshieUI)
Minimum **3 files**, in this order. Works in **desktop and browser mode** only if you use `ipcInvoke()` (never raw `invoke()`).
## Gather from user
1. Command name (Rust `snake_case`, TS `camelCase` function)
2. Parameters (name + type each)
3. Return type
4. Module: `api` | `server` | `websocket` | `workflow` | `config` | new
5. Needs `AppHandle`? (only for events / app paths)
## 1. Rust — `src-tauri/src/commands/{module}.rs`
```rust
#[tauri::command]
pub async fn my_command(
state: State<'_, AppState>,
my_param: String,
) -> Result<ReturnType, AppError> {
let config = state.config.read().await;
// ...
drop(config);
Ok(result)
}
```
- `Result<T, AppError>` only; no panic
- `AppHandle` only if emitting events / spawning tasks
- Drop `RwLock` before I/O `.await`
- HTTP via `state.http_client`
- New module → `pub mod x;` in `commands/mod.rs`
## 2. Register — `src-tauri/src/lib.rs`
```rust
.invoke_handler(tauri::generate_handler![
commands::api::my_command,
])
```
## 3. TypeScript — `src/lib/utils/api.ts`
```typescript
export async function myCommand(myParam: string): Promise<ReturnType> {
return ipcInvoke("my_command", { myParam });
}
```
- camelCase keys in payload; Rust receives snake_case
- New shapes → `src/lib/types/index.ts` (serde field names, often snake_case)
## Verify
```powershell
cargo check --manifest-path src-tauri/Cargo.toml
```
```
- [ ] #[tauri::command] + Result<_, AppError>
- [ ] Listed in generate_handler!
- [ ] api.ts uses ipcInvoke("my_command", ...)
- [ ] Names aligned TS camelCase ↔ Rust snake_case
- [ ] Browser mode: matching arm in `webserver.rs` `dispatch_command` (and `ADMIN_COMMANDS` / `MODERATOR_COMMANDS` if restricted)
- [ ] MCP: would an AI assistant want this? If so, consider a tool in `src-tauri/src/mcp/tools.rs` (see `docs/MCP.md`)
```
Imported from the listed AgentSkill.sh category. Complete supplied package files and notices are retained. Required external tools and credentials are not installed. No bundled code was executed during import. Individual agent task behavior has not been tested.