Files
optimclaw/channels-src/discord
97a7637f30 feat: extension registry with metadata catalog and onboarding integration (#238)
* feat: add extension registry with metadata catalog, CLI, and onboarding integration

Adds a central registry that catalogs all 14 available extensions (10 tools,
4 channels) with their capabilities, auth requirements, and artifact references.
The onboarding wizard now shows installable channels from the registry and
offers tool installation as a new Step 7.

- registry/ folder with per-extension JSON manifests and bundle definitions
- src/registry/ module: manifest structs, catalog loader, installer
- `ironclaw registry list|info|install|install-defaults` CLI commands
- Setup wizard enhanced: channels from registry, new extensions step (8 steps)

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(setup): resolve workspace errors for tool crates and channels-only onboarding

Tool crates in tools-src/ and channels-src/ failed `cargo metadata` during
onboard install because Cargo resolved them as part of the root workspace.
Add `[workspace]` table to each standalone crate and extend the root
`workspace.exclude` list so they build independently.

Channels-only mode (`onboard --channels-only`) failed with "Secrets not
configured" and "No database connection" because it skipped database and
security setup. Add `reconnect_existing_db()` to establish the DB connection
and load saved settings before running channel configuration.

Also improve the tunnel "already configured" display to show full provider
details (domain, mode, command) instead of just the provider name.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(registry): address PR review feedback on installer and catalog

- Use manifest.name (not crate_name) for installed filenames so
  discovery, auth, and CLI commands all agree on the stem (#1)
- Add AlreadyInstalled error variant instead of misleading
  ExtensionNotFound (#2)
- Add DownloadFailed error variant with URL context instead of
  stuffing URLs into PathBuf (#3)
- Validate HTTP status with error_for_status() before reading
  response bytes in artifact downloads (#4)
- Switch build_wasm_component to tokio::process::Command with
  status() so build output streams to the terminal (#6)
- Find WASM artifact by crate_name specifically instead of picking
  the first .wasm file in the release directory (#7)
- Add is_file() guard in catalog loader to skip directories (#8)
- Detect ambiguous bare-name lookups when both tools/<name> and
  channels/<name> exist, with get_strict() returning an error (#9)
- Fix wizard step_extensions to check tool.name for installed
  detection, consistent with the new naming (#11, #12)
- Fix redundant closures and map_or clippy warnings in changed files

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(setup): restore DB connection fields after settings reload

reconnect_postgres() and reconnect_libsql() called Settings::from_db_map()
which overwrote database_url / libsql_path / libsql_url set from env vars.
Also use get_strict() in cmd_info to surface ambiguous bare-name errors.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* style: fix clippy collapsible_if and print_literal warnings

Collapse nested if-let chains and inline string literals in format
macros to satisfy CI clippy lint checks (deny warnings).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* fix(registry): prefer artifacts for install-defaults and improve dir lookup

- InstallDefaults now defaults to downloading pre-built artifacts
  (matching `registry install` behavior), with --build flag for source builds.
- find_registry_dir() walks up 3 ancestor levels from the exe and adds
  a CARGO_MANIFEST_DIR fallback, matching load_registry_catalog() logic.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-02-20 01:17:44 +00:00
..

Discord Channel for IronClaw

WASM channel for Discord integration - handle slash commands and button interactions via webhooks.

Features

  • Slash Commands - Process Discord slash commands
  • Button Interactions - Handle button clicks
  • Thread Support - Respond in threads
  • DM Support - Handle direct messages

Setup

  1. Create a Discord Application at https://discord.com/developers/applications

  2. Create a Bot and get the token

  3. Set up Interactions URL to point to your IronClaw instance

  4. Copy the Application ID and Public Key

  5. Store in IronClaw secrets:

    ironclaw secret set discord_bot_token YOUR_BOT_TOKEN
    

    Note: The discord_bot_token secret is the only value read directly by this Discord channel WASM component. The discord_app_id and discord_public_key secrets are used by the IronClaw host (for example, to verify Discord interaction signatures and manage slash command registration) and are not accessed from the WASM module itself.

Discord Configuration

Register Slash Commands

curl -X POST \
  -H "Authorization: Bot YOUR_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  https://discord.com/api/v10/applications/YOUR_APP_ID/commands \
  -d '{
    "name": "ask",
    "description": "Ask the AI agent",
    "options": [{
      "name": "question",
      "description": "Your question",
      "type": 3,
      "required": true
    }]
  }'

Set Interactions Endpoint

In your Discord app settings, set:

  • Interactions Endpoint URL: https://your-ironclaw.com/webhook/discord

Usage Examples

Slash Command

User types: /ask question: What is the weather?

The agent receives:

User: @username
Content: /ask question: What is the weather?

Button Click

When a user clicks a button in a message, the agent receives:

User: @username
Content: [Button clicked] Original message content

Error Handling

If an internal error occurs (e.g., metadata serialization failure), the tool attempts to send an ephemeral message to the user:

❌ Internal Error: Failed to process command metadata.

Check the host logs for detailed error information.

Advanced Usage

Embeds

To send embeds, include an embeds array in the metadata_json field of the agent's response. The structure should match the Discord API embed object.

Troubleshooting

"Invalid Signature"

  • Check that discord_public_key is set correctly in IronClaw secrets.
  • This validation happens on the host before reaching the WASM.

"401 Unauthorized"

  • Check that discord_bot_token is set correctly in IronClaw secrets.
  • Ensure the bot is added to the server.

"Interaction Failed"

  • The interaction might have timed out (Discord requires a response within 3 seconds).
  • The interactions_endpoint_url might be unreachable.

Building

cd channels-src/discord
cargo build --target wasm32-wasi --release

License

MIT/Apache-2.0