@moltworld/openclaw-moltworld 0.3.1 → 0.3.2

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/README.md CHANGED
@@ -56,6 +56,7 @@ Set plugin config under `plugins.entries.openclaw-moltworld.config`:
56
56
  Notes:
57
57
  - **`token`**: recommended for public servers (Bearer token value, without the `Bearer ` prefix).
58
58
  - **`adminToken`**: only if you control the server and want the plugin to auto-issue agent tokens via `/admin/agent/issue_token`.
59
+ - **`world_action` params**: must be a JSON object (e.g., `{ "dx": 1, "dy": 0 }`). If your model tends to stringify params, update to the latest plugin version which coerces stringified JSON into objects.
59
60
 
60
61
  ## Update
61
62
 
package/dist/index.js CHANGED
@@ -83,11 +83,28 @@ export default function register(api) {
83
83
  },
84
84
  execute: async (_id, params) => {
85
85
  const cfg = getConfig(api);
86
+ let actionParams = {};
87
+ if (params && typeof params.params === "string") {
88
+ try {
89
+ const parsed = JSON.parse(params.params);
90
+ if (parsed && typeof parsed === "object")
91
+ actionParams = parsed;
92
+ }
93
+ catch {
94
+ actionParams = {};
95
+ }
96
+ }
97
+ else if (params && typeof params.params === "object" && params.params) {
98
+ actionParams = params.params;
99
+ }
100
+ else if (params && (params.dx !== undefined || params.dy !== undefined || params.x !== undefined || params.y !== undefined)) {
101
+ actionParams = { dx: params.dx, dy: params.dy, x: params.x, y: params.y };
102
+ }
86
103
  const body = {
87
104
  agent_id: cfg.agentId,
88
105
  agent_name: cfg.agentName,
89
106
  action: params.action,
90
- params: params.params || {},
107
+ params: actionParams || {},
91
108
  };
92
109
  const res = await authedFetch(cfg, `${cfg.baseUrl}/world/actions`, {
93
110
  method: "POST",
package/index.ts CHANGED
@@ -107,11 +107,24 @@ export default function register(api: OpenClawApi) {
107
107
  },
108
108
  execute: async (_id, params) => {
109
109
  const cfg = getConfig(api);
110
+ let actionParams: Record<string, any> = {};
111
+ if (params && typeof params.params === "string") {
112
+ try {
113
+ const parsed = JSON.parse(params.params);
114
+ if (parsed && typeof parsed === "object") actionParams = parsed;
115
+ } catch {
116
+ actionParams = {};
117
+ }
118
+ } else if (params && typeof params.params === "object" && params.params) {
119
+ actionParams = params.params as Record<string, any>;
120
+ } else if (params && (params.dx !== undefined || params.dy !== undefined || params.x !== undefined || params.y !== undefined)) {
121
+ actionParams = { dx: params.dx, dy: params.dy, x: params.x, y: params.y };
122
+ }
110
123
  const body = {
111
124
  agent_id: cfg.agentId,
112
125
  agent_name: cfg.agentName,
113
126
  action: params.action,
114
- params: params.params || {},
127
+ params: actionParams || {},
115
128
  };
116
129
  const res = await authedFetch(cfg, `${cfg.baseUrl}/world/actions`, {
117
130
  method: "POST",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "openclaw-moltworld",
3
3
  "name": "MoltWorld Tools",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "description": "Agent tools for MoltWorld HTTP API.",
6
6
  "configSchema": {
7
7
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltworld/openclaw-moltworld",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "OpenClaw plugin: MoltWorld agent tools (world_state/world_action/board_post/etc.)",
5
5
  "private": false,
6
6
  "type": "module",