openclaw-remote 0.5.7 → 0.6.0

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 +8 -148
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8,7 +8,6 @@ var __export = (target, all) => {
8
8
  import {
9
9
  DEFAULT_ACCOUNT_ID,
10
10
  setAccountEnabledInConfigSection,
11
- registerPluginHttpRoute,
12
11
  optionalStringEnum
13
12
  } from "openclaw/plugin-sdk/compat";
14
13
 
@@ -2658,8 +2657,7 @@ function resolveAccount(cfg, accountId) {
2658
2657
  dmPolicy: accountOverride.dmPolicy ?? channelCfg.dmPolicy ?? "open",
2659
2658
  allowedUserIds: parseAllowedUserIds(
2660
2659
  accountOverride.allowedUserIds ?? channelCfg.allowedUserIds ?? envAllowedUserIds
2661
- ),
2662
- webhookPath: accountOverride.webhookPath ?? channelCfg.webhookPath ?? `/webhooks/remote/${id}`
2660
+ )
2663
2661
  };
2664
2662
  }
2665
2663
 
@@ -2840,33 +2838,8 @@ async function getTeam(account) {
2840
2838
  );
2841
2839
  }
2842
2840
 
2843
- // src/runtime.ts
2844
- import { createPluginRuntimeStore } from "openclaw/plugin-sdk/compat";
2845
- var { setRuntime: setRemoteRuntime, getRuntime: getRemoteRuntime } = createPluginRuntimeStore(
2846
- "Remote runtime not initialized - plugin not registered"
2847
- );
2848
-
2849
2841
  // src/channel.ts
2850
- function readJsonBody(req) {
2851
- return new Promise((resolve, reject) => {
2852
- const chunks = [];
2853
- req.on("data", (chunk) => chunks.push(chunk));
2854
- req.on("end", () => {
2855
- try {
2856
- resolve(JSON.parse(Buffer.concat(chunks).toString("utf-8")));
2857
- } catch {
2858
- resolve(null);
2859
- }
2860
- });
2861
- req.on("error", reject);
2862
- });
2863
- }
2864
- function respondJson(res, status, data) {
2865
- res.writeHead(status, { "Content-Type": "application/json" });
2866
- res.end(JSON.stringify(data));
2867
- }
2868
2842
  var CHANNEL_ID = "remote";
2869
- var activeRouteUnregisters = /* @__PURE__ */ new Map();
2870
2843
  function waitUntilAbort(signal, onAbort) {
2871
2844
  return new Promise((resolve) => {
2872
2845
  const complete = () => {
@@ -2883,48 +2856,6 @@ function waitUntilAbort(signal, onAbort) {
2883
2856
  signal.addEventListener("abort", complete, { once: true });
2884
2857
  });
2885
2858
  }
2886
- function formatWebhookEvent(payload) {
2887
- const { event, task_id, task_title, comment_body, author_name, wake_reason } = payload;
2888
- switch (event) {
2889
- case "task.assigned":
2890
- case "task.created":
2891
- return [
2892
- `You've been assigned a new task:`,
2893
- ``,
2894
- `**${task_title}** (ID: ${task_id})`,
2895
- ``,
2896
- wake_reason ? `Reason: ${wake_reason}` : "",
2897
- ``,
2898
- `Use this task ID for API calls (e.g. to move it to in_progress).`,
2899
- `Review the task and share your initial thoughts or plan.`
2900
- ].filter(Boolean).join("\n");
2901
- case "task.commented":
2902
- return [
2903
- `${author_name || "Someone"} commented on "${task_title}" (ID: ${task_id}):`,
2904
- ``,
2905
- `> ${comment_body || ""}`,
2906
- ``,
2907
- `Respond to their comment.`
2908
- ].join("\n");
2909
- case "task.mentioned":
2910
- return [
2911
- `You were mentioned in a comment on "${task_title}" (ID: ${task_id}):`,
2912
- ``,
2913
- `> ${comment_body || ""}`,
2914
- ``,
2915
- `Respond to the mention.`
2916
- ].join("\n");
2917
- case "task.status_changed":
2918
- return [
2919
- `Task "${task_title}" (ID: ${task_id}) status changed.`,
2920
- wake_reason ? `Details: ${wake_reason}` : "",
2921
- ``,
2922
- `Acknowledge the status change if relevant to your work.`
2923
- ].filter(Boolean).join("\n");
2924
- default:
2925
- return `Task update on "${task_title}" (ID: ${task_id}): ${event}${wake_reason ? ` \u2014 ${wake_reason}` : ""}`;
2926
- }
2927
- }
2928
2859
  function createRemotePlugin() {
2929
2860
  return {
2930
2861
  id: CHANNEL_ID,
@@ -3061,87 +2992,10 @@ function createRemotePlugin() {
3061
2992
  return waitUntilAbort(ctx.abortSignal);
3062
2993
  }
3063
2994
  log?.info?.(
3064
- `Starting Remote channel (account: ${accountId}, webhookPath: ${account.webhookPath})`
2995
+ `Starting Remote channel (account: ${accountId})`
3065
2996
  );
3066
- const handler = async (req, res) => {
3067
- if (req.method !== "POST") {
3068
- respondJson(res, 405, { error: "Method not allowed" });
3069
- return;
3070
- }
3071
- const payload = await readJsonBody(req);
3072
- if (!payload || !payload.event || !payload.task_id) {
3073
- respondJson(res, 400, { error: "Invalid payload: missing event or task_id" });
3074
- return;
3075
- }
3076
- log?.info?.(`Webhook received: ${payload.event} for task ${payload.task_id} (agent: ${payload.agent_name})`);
3077
- respondJson(res, 200, { ok: true, event: payload.event });
3078
- const body = formatWebhookEvent(payload);
3079
- const sessionKey = `remote:${account.accountId}:${payload.task_id}`;
3080
- try {
3081
- const rt = getRemoteRuntime();
3082
- const currentCfg = await rt.config.loadConfig();
3083
- const msgCtx = rt.channel.reply.finalizeInboundContext({
3084
- Body: body,
3085
- RawBody: body,
3086
- CommandBody: body,
3087
- From: `remote:${payload.task_id}`,
3088
- To: `remote:${account.accountId}`,
3089
- SessionKey: sessionKey,
3090
- AccountId: account.accountId,
3091
- OriginatingChannel: CHANNEL_ID,
3092
- OriginatingTo: `remote:${payload.task_id}`,
3093
- ChatType: "direct",
3094
- SenderName: payload.author_name || "Remote Board",
3095
- SenderId: payload.task_id,
3096
- Provider: CHANNEL_ID,
3097
- Surface: CHANNEL_ID,
3098
- ConversationLabel: payload.task_title || `Task ${payload.task_id}`,
3099
- Timestamp: Date.now()
3100
- });
3101
- await rt.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
3102
- ctx: msgCtx,
3103
- cfg: currentCfg,
3104
- dispatcherOptions: {
3105
- deliver: async (deliverPayload) => {
3106
- if (deliverPayload.isReasoning) return;
3107
- const text = deliverPayload?.text ?? deliverPayload?.body;
3108
- if (text) {
3109
- await postComment(account, payload.task_id, text);
3110
- }
3111
- },
3112
- onReplyStart: () => {
3113
- log?.info?.(`Agent reply started for task ${payload.task_id}`);
3114
- }
3115
- }
3116
- });
3117
- } catch (err) {
3118
- log?.error?.(
3119
- `Error dispatching webhook event: ${err instanceof Error ? err.message : String(err)}`
3120
- );
3121
- }
3122
- };
3123
- const routeKey = `${accountId}:${account.webhookPath}`;
3124
- const prevUnregister = activeRouteUnregisters.get(routeKey);
3125
- if (prevUnregister) {
3126
- log?.info?.(`Deregistering stale route before re-registering: ${account.webhookPath}`);
3127
- prevUnregister();
3128
- activeRouteUnregisters.delete(routeKey);
3129
- }
3130
- const unregister = registerPluginHttpRoute({
3131
- path: account.webhookPath,
3132
- auth: "plugin",
3133
- replaceExisting: true,
3134
- pluginId: CHANNEL_ID,
3135
- accountId: account.accountId,
3136
- log: (msg) => log?.info?.(msg),
3137
- handler
3138
- });
3139
- activeRouteUnregisters.set(routeKey, unregister);
3140
- log?.info?.(`Registered HTTP route: ${account.webhookPath} for Remote`);
3141
2997
  return waitUntilAbort(ctx.abortSignal, () => {
3142
2998
  log?.info?.(`Stopping Remote channel (account: ${accountId})`);
3143
- if (typeof unregister === "function") unregister();
3144
- activeRouteUnregisters.delete(routeKey);
3145
2999
  });
3146
3000
  },
3147
3001
  stopAccount: async (ctx) => {
@@ -3766,6 +3620,12 @@ function extractTaskId(to) {
3766
3620
  return void 0;
3767
3621
  }
3768
3622
 
3623
+ // src/runtime.ts
3624
+ import { createPluginRuntimeStore } from "openclaw/plugin-sdk/compat";
3625
+ var { setRuntime: setRemoteRuntime, getRuntime: getRemoteRuntime } = createPluginRuntimeStore(
3626
+ "Remote runtime not initialized - plugin not registered"
3627
+ );
3628
+
3769
3629
  // index.ts
3770
3630
  var plugin = {
3771
3631
  id: "remote",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-remote",
3
- "version": "0.5.7",
3
+ "version": "0.6.0",
4
4
  "description": "Remote project board channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",