openclaw-opencode-bridge 2.0.8 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-opencode-bridge",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "Bridge OpenClaw messaging channels to OpenCode via tmux persistent sessions",
5
5
  "main": "./lib/onboard.js",
6
6
  "bin": {
@@ -1,11 +1,12 @@
1
1
  #!/bin/bash
2
- # bridge-version: 4
3
- # Keep OpenCode server alive (runs every 30s via daemon)
4
- # Safe: idempotent, flock-protected (with fallback)
2
+ # bridge-version: 5
3
+ # Keep OpenCode server running in background (for faster message processing)
4
+ # Daemon runs every 30s to ensure server stays alive
5
5
 
6
6
  OPENCODE="{{OPENCODE_BIN}}"
7
7
  WORKSPACE="{{WORKSPACE}}"
8
8
  LOCK_FILE="/tmp/opencode-session.lock"
9
+ PID_FILE="/tmp/opencode-session.pid"
9
10
  TIMEOUT=10
10
11
 
11
12
  # Use flock for lock protection if available
@@ -25,10 +26,17 @@ fi
25
26
 
26
27
  cd "$WORKSPACE"
27
28
 
28
- # Start OpenCode in server mode if not running
29
- if ! pgrep -f "opencode serve" > /dev/null 2>&1; then
30
- "$OPENCODE" serve &
31
- sleep 2
29
+ # Check if server is already running
30
+ if [ -f "$PID_FILE" ]; then
31
+ OLD_PID=$(cat "$PID_FILE")
32
+ if [ -n "$OLD_PID" ] && kill -0 "$OLD_PID" 2>/dev/null; then
33
+ exit 0
34
+ fi
32
35
  fi
33
36
 
37
+ # Start OpenCode server in background
38
+ nohup "$OPENCODE" serve > /tmp/opencode-serve.log 2>&1 &
39
+ echo $! > "$PID_FILE"
40
+ sleep 3
41
+
34
42
  exit 0
@@ -2,23 +2,33 @@
2
2
 
3
3
  ## Bot Mode
4
4
 
5
- When a message starts with `[{CHANNEL}:{ID}]` prefix, you **MUST** follow this procedure.
5
+ When a message starts with `[{CHANNEL}:{ID}]` prefix, you are being used as a bot.
6
+
7
+ ### Message Format
8
+
9
+ The format is: `[CHANNEL:ID] actual message`
10
+
11
+ **Examples:**
12
+ - `[telegram:850961516] hello` → Channel=telegram, ID=850961516, Message="hello"
13
+ - `[discord:123456] build a website` → Channel=discord, ID=123456, Message="build a website"
14
+
15
+ **IMPORTANT:** The prefix `[channel:id]` is metadata. You should ONLY respond to the actual message, NOT repeat the prefix or the user's name in your response.
6
16
 
7
17
  ### Procedure
8
18
 
9
- 1. Extract `{CHANNEL}` and `{ID}` from the prefix
10
- 2. Perform the task described after the prefix
11
- 3. **After completion, send the response via:**
19
+ 1. Extract `{CHANNEL}` and `{ID}` from the `[...]` prefix
20
+ 2. Ignore everything before `] ` — that is the prefix, not the message
21
+ 3. Perform the task described in the actual message
22
+ 4. **After completion, send the response via:**
12
23
  ```bash
13
- openclaw message send --channel {CHANNEL} --target {ID} -m '🔗 response'
24
+ openclaw message send --channel {CHANNEL} --target {ID} -m '🔗 your response here'
14
25
  ```
15
- 4. **Every message MUST start with 🔗** — this identifies you as OpenCode
16
- 5. Split messages over 4000 characters into multiple sends (each starts with 🔗)
26
+ 5. **Every message MUST start with 🔗** — this identifies you as OpenCode
27
+ 6. Split messages over 4000 characters into multiple sends (each starts with 🔗)
17
28
 
18
29
  ### Response transmission is mandatory (never skip)
19
30
 
20
- - **Every `[{CHANNEL}:{ID}]` message MUST receive a response via the channel.**
21
- - Regardless of success, failure, or error, you must always send the result.
22
- - Ending a turn without sending is **strictly forbidden**.
31
+ - **Every message MUST receive a response.**
32
+ - Ignore the prefix, only respond to the actual message content.
23
33
  - If the task failed, send the failure reason. If it succeeded, send the result.
24
34
  - If you did not run `openclaw message send`, the task is **NOT** complete.