openclaw-remote 0.5.1 → 0.5.3

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2798,6 +2798,24 @@ var { setRuntime: setRemoteRuntime, getRuntime: getRemoteRuntime } = createPlugi
2798
2798
  );
2799
2799
 
2800
2800
  // src/channel.ts
2801
+ function readJsonBody(req) {
2802
+ return new Promise((resolve, reject) => {
2803
+ const chunks = [];
2804
+ req.on("data", (chunk) => chunks.push(chunk));
2805
+ req.on("end", () => {
2806
+ try {
2807
+ resolve(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
2808
+ } catch {
2809
+ resolve(null);
2810
+ }
2811
+ });
2812
+ req.on("error", reject);
2813
+ });
2814
+ }
2815
+ function respondJson(res, status, data) {
2816
+ res.writeHead(status, { "Content-Type": "application/json" });
2817
+ res.end(JSON.stringify(data));
2818
+ }
2801
2819
  var CHANNEL_ID = "remote";
2802
2820
  var activeRouteUnregisters = /* @__PURE__ */ new Map();
2803
2821
  function waitUntilAbort(signal, onAbort) {
@@ -2996,15 +3014,18 @@ function createRemotePlugin() {
2996
3014
  log?.info?.(
2997
3015
  `Starting Remote channel (account: ${accountId}, webhookPath: ${account.webhookPath})`
2998
3016
  );
2999
- const handler = async (req) => {
3017
+ const handler = async (req, res) => {
3000
3018
  if (req.method !== "POST") {
3001
- return { status: 405, body: { error: "Method not allowed" } };
3019
+ respondJson(res, 405, { error: "Method not allowed" });
3020
+ return;
3002
3021
  }
3003
- const payload = req.body;
3022
+ const payload = await readJsonBody(req);
3004
3023
  if (!payload || !payload.event || !payload.task_id) {
3005
- return { status: 400, body: { error: "Invalid payload: missing event or task_id" } };
3024
+ respondJson(res, 400, { error: "Invalid payload: missing event or task_id" });
3025
+ return;
3006
3026
  }
3007
3027
  log?.info?.(`Webhook received: ${payload.event} for task ${payload.task_id} (agent: ${payload.agent_name})`);
3028
+ respondJson(res, 200, { ok: true, event: payload.event });
3008
3029
  const body = formatWebhookEvent(payload);
3009
3030
  const sessionKey = `remote:${account.accountId}:${payload.task_id}`;
3010
3031
  try {
@@ -3048,9 +3069,7 @@ function createRemotePlugin() {
3048
3069
  log?.error?.(
3049
3070
  `Error dispatching webhook event: ${err instanceof Error ? err.message : String(err)}`
3050
3071
  );
3051
- return { status: 500, body: { error: "Internal error" } };
3052
3072
  }
3053
- return { status: 200, body: { ok: true } };
3054
3073
  };
3055
3074
  const routeKey = `${accountId}:${account.webhookPath}`;
3056
3075
  const prevUnregister = activeRouteUnregisters.get(routeKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-remote",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Remote project board channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",