openclaw-remote 0.5.8 → 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 -161
  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,57 +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
- case "agent.generate":
2925
- return [
2926
- `Generate an AI agent bundle for the role: "${task_title}" (Role ID: ${task_id}).`,
2927
- ``,
2928
- wake_reason ? `Context: ${wake_reason}` : "",
2929
- ``,
2930
- `Use your agent-creation skill to build a complete agent bundle for this role.`,
2931
- `When done, publish it with clawpack push.`
2932
- ].filter(Boolean).join("\n");
2933
- default:
2934
- return `Task update on "${task_title}" (ID: ${task_id}): ${event}${wake_reason ? ` \u2014 ${wake_reason}` : ""}`;
2935
- }
2936
- }
2937
2859
  function createRemotePlugin() {
2938
2860
  return {
2939
2861
  id: CHANNEL_ID,
@@ -3070,91 +2992,10 @@ function createRemotePlugin() {
3070
2992
  return waitUntilAbort(ctx.abortSignal);
3071
2993
  }
3072
2994
  log?.info?.(
3073
- `Starting Remote channel (account: ${accountId}, webhookPath: ${account.webhookPath})`
2995
+ `Starting Remote channel (account: ${accountId})`
3074
2996
  );
3075
- const handler = async (req, res) => {
3076
- if (req.method !== "POST") {
3077
- respondJson(res, 405, { error: "Method not allowed" });
3078
- return;
3079
- }
3080
- const payload = await readJsonBody(req);
3081
- if (!payload || !payload.event || !payload.task_id) {
3082
- respondJson(res, 400, { error: "Invalid payload: missing event or task_id" });
3083
- return;
3084
- }
3085
- log?.info?.(`Webhook received: ${payload.event} for task ${payload.task_id} (agent: ${payload.agent_name})`);
3086
- respondJson(res, 200, { ok: true, event: payload.event });
3087
- const body = formatWebhookEvent(payload);
3088
- const sessionKey = `remote:${account.accountId}:${payload.task_id}`;
3089
- try {
3090
- const rt = getRemoteRuntime();
3091
- const currentCfg = await rt.config.loadConfig();
3092
- const msgCtx = rt.channel.reply.finalizeInboundContext({
3093
- Body: body,
3094
- RawBody: body,
3095
- CommandBody: body,
3096
- From: `remote:${payload.task_id}`,
3097
- To: `remote:${account.accountId}`,
3098
- SessionKey: sessionKey,
3099
- AccountId: account.accountId,
3100
- OriginatingChannel: CHANNEL_ID,
3101
- OriginatingTo: `remote:${payload.task_id}`,
3102
- ChatType: "direct",
3103
- SenderName: payload.author_name || "Remote Board",
3104
- SenderId: payload.task_id,
3105
- Provider: CHANNEL_ID,
3106
- Surface: CHANNEL_ID,
3107
- ConversationLabel: payload.task_title || `Task ${payload.task_id}`,
3108
- Timestamp: Date.now()
3109
- });
3110
- log?.info?.(`Dispatching to agent for task ${payload.task_id}, body length=${body.length}, sessionKey=${sessionKey}`);
3111
- const result = await rt.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
3112
- ctx: msgCtx,
3113
- cfg: currentCfg,
3114
- dispatcherOptions: {
3115
- deliver: async (deliverPayload) => {
3116
- log?.info?.(`Deliver callback for task ${payload.task_id}: isReasoning=${deliverPayload.isReasoning}, hasText=${!!(deliverPayload?.text ?? deliverPayload?.body)}, textLen=${(deliverPayload?.text ?? deliverPayload?.body ?? "").length}`);
3117
- if (deliverPayload.isReasoning) return;
3118
- const text = deliverPayload?.text ?? deliverPayload?.body;
3119
- if (text) {
3120
- await postComment(account, payload.task_id, text);
3121
- log?.info?.(`Comment posted for task ${payload.task_id}, len=${text.length}`);
3122
- }
3123
- },
3124
- onReplyStart: () => {
3125
- log?.info?.(`Agent reply started for task ${payload.task_id}`);
3126
- }
3127
- }
3128
- });
3129
- log?.info?.(`Dispatch completed for task ${payload.task_id}, result=${JSON.stringify(result ?? null)}`);
3130
- } catch (err) {
3131
- log?.error?.(
3132
- `Error dispatching webhook event: ${err instanceof Error ? err.message : String(err)}, stack=${err instanceof Error ? err.stack : "N/A"}`
3133
- );
3134
- }
3135
- };
3136
- const routeKey = `${accountId}:${account.webhookPath}`;
3137
- const prevUnregister = activeRouteUnregisters.get(routeKey);
3138
- if (prevUnregister) {
3139
- log?.info?.(`Deregistering stale route before re-registering: ${account.webhookPath}`);
3140
- prevUnregister();
3141
- activeRouteUnregisters.delete(routeKey);
3142
- }
3143
- const unregister = registerPluginHttpRoute({
3144
- path: account.webhookPath,
3145
- auth: "plugin",
3146
- replaceExisting: true,
3147
- pluginId: CHANNEL_ID,
3148
- accountId: account.accountId,
3149
- log: (msg) => log?.info?.(msg),
3150
- handler
3151
- });
3152
- activeRouteUnregisters.set(routeKey, unregister);
3153
- log?.info?.(`Registered HTTP route: ${account.webhookPath} for Remote`);
3154
2997
  return waitUntilAbort(ctx.abortSignal, () => {
3155
2998
  log?.info?.(`Stopping Remote channel (account: ${accountId})`);
3156
- if (typeof unregister === "function") unregister();
3157
- activeRouteUnregisters.delete(routeKey);
3158
2999
  });
3159
3000
  },
3160
3001
  stopAccount: async (ctx) => {
@@ -3779,6 +3620,12 @@ function extractTaskId(to) {
3779
3620
  return void 0;
3780
3621
  }
3781
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
+
3782
3629
  // index.ts
3783
3630
  var plugin = {
3784
3631
  id: "remote",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-remote",
3
- "version": "0.5.8",
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",