Skip to content

feat: implement OpenClaw integration#2607

Merged
code-yeongyu merged 2 commits intodevfrom
feat/openclaw-integration
Mar 16, 2026
Merged

feat: implement OpenClaw integration#2607
code-yeongyu merged 2 commits intodevfrom
feat/openclaw-integration

Conversation

@code-yeongyu
Copy link
Copy Markdown
Owner

@code-yeongyu code-yeongyu commented Mar 16, 2026

feat: implement OpenClaw integration

Ports the OMX OpenClaw module into oh-my-openagent as a first-class integration.
This integration allows forwarding internal events (session lifecycle, tool execution) to external gateways (HTTP or command-based).

  • Added src/openclaw directory with implementation:
    • dispatcher.ts: Handles HTTP/Command dispatching with interpolation
    • types.ts: TypeScript definitions
    • client.ts: Main entry point wakeOpenClaw
    • index.ts: Public API
  • Added src/config/schema/openclaw.ts for Zod schema validation
  • Updated src/config/schema/oh-my-opencode-config.ts to include openclaw config
  • Added src/hooks/openclaw-sender/index.ts to listen for events
  • Registered the hook in src/plugin/hooks/create-session-hooks.ts
  • Added unit tests in src/openclaw/__tests__

Events handled:

  • session-start (via session.created)
  • session-end (via session.deleted)
  • session-idle (via session.idle)
  • ask-user-question (via tool.execute.before for ask_user_question)
  • stop (via tool.execute.before for stop-continuation command)

Summary by cubic

Add OpenClaw integration to forward session and tool events to external gateways (HTTP or command). Also fixes session ID extraction by reading from event properties.info.id for reliable session-start/session-end routing.

  • New Features

    • Core: added src/openclaw (client, dispatcher, types) with wakeOpenClaw, templated instructions, and non-blocking dispatch + tests.
    • Config: introduced Zod schema src/config/schema/openclaw.ts; wired into oh-my-opencode-config.ts; added and registered openclaw-sender in session and tool hooks.
    • Events: sends session-start, session-end, session-idle, ask-user-question, stop.
    • Gateways: HTTP (HTTPS enforced; localhost HTTP allowed; JSON; per-request timeout). Command (gated by OMX_OPENCLAW_COMMAND=1; shell-escaped vars; bounded timeouts).
    • Fix: derive session ID from properties.info.id on session.created/session.deleted.
  • Migration

    • Set OMX_OPENCLAW=1 to activate.
    • Configure openclaw in plugin config with gateways and hooks.
    • Enable the openclaw-sender hook.
    • For command gateways, set OMX_OPENCLAW_COMMAND=1 (optional OMX_OPENCLAW_COMMAND_TIMEOUT_MS).

Written for commit 450685f. Summary will update on new commits.

Ports the OMX OpenClaw module into oh-my-openagent as a first-class integration.
This integration allows forwarding internal events (session lifecycle, tool execution) to external gateways (HTTP or command-based).

- Added `src/openclaw` directory with implementation:
  - `dispatcher.ts`: Handles HTTP/Command dispatching with interpolation
  - `types.ts`: TypeScript definitions
  - `client.ts`: Main entry point `wakeOpenClaw`
  - `index.ts`: Public API
- Added `src/config/schema/openclaw.ts` for Zod schema validation
- Updated `src/config/schema/oh-my-opencode-config.ts` to include `openclaw` config
- Added `src/hooks/openclaw-sender/index.ts` to listen for events
- Registered the hook in `src/plugin/hooks/create-session-hooks.ts`
- Added unit tests in `src/openclaw/__tests__`

Events handled:
- `session-start` (via `session.created`)
- `session-end` (via `session.deleted`)
- `session-idle` (via `session.idle`)
- `ask-user-question` (via `tool.execute.before` for `ask_user_question`)
- `stop` (via `tool.execute.before` for `stop-continuation` command)
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 14 files

Confidence score: 2/5

  • There is a high-confidence compatibility bug in src/hooks/openclaw-sender/index.ts: session.created/session.deleted can carry the ID at properties.info.id, but the hook only checks properties.sessionID.
  • Because this affects session lifecycle events, it can prevent correct session tracking/deletion for Opencode agents, which is user-impacting behavior rather than a minor edge case.
  • The issue is marked severe (8/10) with strong confidence (10/10), so this looks risky to merge without a fix.
  • Pay close attention to src/hooks/openclaw-sender/index.ts - session ID extraction for session.created and session.deleted needs to handle properties.info.id.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/hooks/openclaw-sender/index.ts">

<violation number="1" location="src/hooks/openclaw-sender/index.ts:16">
P1: Custom agent: **Opencode Compatibility**

For `session.created` and `session.deleted` events, the session ID is located at `properties.info.id` rather than `properties.sessionID`. Without checking `info.id`, the hook will fall back to `getMainSessionID()` which may yield an incorrect ID for these events.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Auto-approved: Additive and isolated integration. New logic is guarded by opt-in configuration and hook-enable checks, posing zero risk to existing functionality.

@code-yeongyu code-yeongyu merged commit 8213534 into dev Mar 16, 2026
8 checks passed
@code-yeongyu code-yeongyu deleted the feat/openclaw-integration branch March 16, 2026 08:48
@KennyDizi
Copy link
Copy Markdown

Wow, I do believe this is what many users want: OpenClaw + Oh-my-OpenAgent. Looking for a stable feature and documentation for the integration.
Thanks @code-yeongyu

code-yeongyu added a commit that referenced this pull request Mar 16, 2026
…gration"

This reverts commit 8213534, reversing
changes made to 84fb111.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants