@riddledc/openclaw-riddledc 0.2.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.
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/index.cjs +229 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +208 -0
- package/openclaw.plugin.json +18 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RiddleDC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @riddledc/openclaw-riddledc
|
|
2
|
+
|
|
3
|
+
OpenClaw integration package for RiddleDC. No secrets. No assumption about MCP.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pnpm add @riddledc/openclaw-riddledc
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## OpenClaw plugin metadata
|
|
12
|
+
|
|
13
|
+
This package ships `openclaw.plugin.json` for OpenClaw registration.
|
|
14
|
+
|
|
15
|
+
## Required OpenClaw config
|
|
16
|
+
|
|
17
|
+
Because the tools register as `optional: true`, add:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
tools.alsoAllow: ["riddle"]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
The plugin accepts:
|
|
26
|
+
- `apiKey` (or `RIDDLE_API_KEY` env var)
|
|
27
|
+
- `baseUrl` (defaults to `https://api.riddledc.com`)
|
|
28
|
+
|
|
29
|
+
## Tools
|
|
30
|
+
|
|
31
|
+
- `riddle_run`
|
|
32
|
+
- `riddle_screenshot`
|
|
33
|
+
- `riddle_screenshots`
|
|
34
|
+
- `riddle_steps`
|
|
35
|
+
- `riddle_script`
|
|
36
|
+
|
|
37
|
+
## Security
|
|
38
|
+
|
|
39
|
+
Do not hardcode keys. Provide credentials via env vars or your secret manager.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
default: () => register
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_typebox = require("@sinclair/typebox");
|
|
27
|
+
function getCfg(api) {
|
|
28
|
+
const cfg = api?.config ?? {};
|
|
29
|
+
const pluginCfg = cfg?.plugins?.entries?.riddle?.config ?? {};
|
|
30
|
+
return {
|
|
31
|
+
apiKey: process.env.RIDDLE_API_KEY || pluginCfg.apiKey,
|
|
32
|
+
baseUrl: pluginCfg.baseUrl || "https://api.riddledc.com"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function assertAllowedBaseUrl(baseUrl) {
|
|
36
|
+
const url = new URL(baseUrl);
|
|
37
|
+
if (url.protocol !== "https:") throw new Error(`Riddle baseUrl must be https: (${baseUrl})`);
|
|
38
|
+
if (url.hostname !== "api.riddledc.com") {
|
|
39
|
+
throw new Error(`Refusing to use non-official Riddle host: ${url.hostname}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function detectMode(payload) {
|
|
43
|
+
if (payload.url) return "url";
|
|
44
|
+
if (payload.urls) return "urls";
|
|
45
|
+
if (payload.steps) return "steps";
|
|
46
|
+
if (payload.script) return "script";
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
async function postRun(baseUrl, apiKey, payload) {
|
|
50
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, "")}/v1/run`, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: `Bearer ${apiKey}`,
|
|
54
|
+
"Content-Type": "application/json"
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify(payload)
|
|
57
|
+
});
|
|
58
|
+
const body = await res.arrayBuffer();
|
|
59
|
+
return {
|
|
60
|
+
contentType: res.headers.get("content-type"),
|
|
61
|
+
body,
|
|
62
|
+
headers: res.headers,
|
|
63
|
+
status: res.status
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function abToBase64(ab) {
|
|
67
|
+
return Buffer.from(ab).toString("base64");
|
|
68
|
+
}
|
|
69
|
+
async function runWithDefaults(api, payload, defaults) {
|
|
70
|
+
const { apiKey, baseUrl } = getCfg(api);
|
|
71
|
+
if (!apiKey) {
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
error: "Missing Riddle API key. Set RIDDLE_API_KEY env var or plugins.entries.riddle.config.apiKey."
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
assertAllowedBaseUrl(baseUrl);
|
|
78
|
+
const mode = detectMode(payload);
|
|
79
|
+
const merged = { ...payload };
|
|
80
|
+
if (defaults?.include?.length) {
|
|
81
|
+
merged.include = Array.from(/* @__PURE__ */ new Set([...merged.include ?? [], ...defaults.include]));
|
|
82
|
+
}
|
|
83
|
+
if (defaults?.inline) {
|
|
84
|
+
merged.inlineConsole = merged.inlineConsole ?? true;
|
|
85
|
+
merged.inlineHar = merged.inlineHar ?? true;
|
|
86
|
+
merged.inlineResult = merged.inlineResult ?? true;
|
|
87
|
+
}
|
|
88
|
+
const out = { ok: true, mode };
|
|
89
|
+
const { contentType, body, headers, status } = await postRun(baseUrl, apiKey, merged);
|
|
90
|
+
out.rawContentType = contentType ?? void 0;
|
|
91
|
+
if (status >= 400) {
|
|
92
|
+
try {
|
|
93
|
+
const txt2 = Buffer.from(body).toString("utf8");
|
|
94
|
+
out.ok = false;
|
|
95
|
+
out.error = JSON.parse(txt2);
|
|
96
|
+
return out;
|
|
97
|
+
} catch {
|
|
98
|
+
out.ok = false;
|
|
99
|
+
out.error = `HTTP ${status}`;
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (contentType && contentType.includes("image/png")) {
|
|
104
|
+
out.rawPngBase64 = abToBase64(body);
|
|
105
|
+
out.job_id = headers.get("x-job-id") ?? void 0;
|
|
106
|
+
const duration = headers.get("x-duration-ms");
|
|
107
|
+
out.duration_ms = duration ? Number(duration) : void 0;
|
|
108
|
+
out.sync = true;
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
const txt = Buffer.from(body).toString("utf8");
|
|
112
|
+
const json = JSON.parse(txt);
|
|
113
|
+
Object.assign(out, json);
|
|
114
|
+
out.job_id = json.job_id ?? json.jobId ?? out.job_id;
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
function register(api) {
|
|
118
|
+
api.registerTool(
|
|
119
|
+
{
|
|
120
|
+
name: "riddle_run",
|
|
121
|
+
description: "Run a Riddle job (pass-through payload) against https://api.riddledc.com/v1/run. Supports url/urls/steps/script. Returns screenshot/console/har/result when requested.",
|
|
122
|
+
parameters: import_typebox.Type.Object({
|
|
123
|
+
payload: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())
|
|
124
|
+
}),
|
|
125
|
+
async execute(_id, params) {
|
|
126
|
+
const result = await runWithDefaults(api, params.payload, {
|
|
127
|
+
include: ["console", "har", "result"],
|
|
128
|
+
inline: true
|
|
129
|
+
});
|
|
130
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{ optional: true }
|
|
134
|
+
);
|
|
135
|
+
api.registerTool(
|
|
136
|
+
{
|
|
137
|
+
name: "riddle_screenshot",
|
|
138
|
+
description: "Riddle: take a screenshot of a single URL (url mode).",
|
|
139
|
+
parameters: import_typebox.Type.Object({
|
|
140
|
+
url: import_typebox.Type.String(),
|
|
141
|
+
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
142
|
+
options: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
143
|
+
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String()))
|
|
144
|
+
}),
|
|
145
|
+
async execute(_id, params) {
|
|
146
|
+
if (!params.url || typeof params.url !== "string") throw new Error("url must be a string");
|
|
147
|
+
const payload = { url: params.url };
|
|
148
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
149
|
+
if (params.options) payload.options = params.options;
|
|
150
|
+
if (params.include) payload.include = params.include;
|
|
151
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har"], inline: true });
|
|
152
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{ optional: true }
|
|
156
|
+
);
|
|
157
|
+
api.registerTool(
|
|
158
|
+
{
|
|
159
|
+
name: "riddle_screenshots",
|
|
160
|
+
description: "Riddle: take screenshots for multiple URLs in one job (urls mode).",
|
|
161
|
+
parameters: import_typebox.Type.Object({
|
|
162
|
+
urls: import_typebox.Type.Array(import_typebox.Type.String()),
|
|
163
|
+
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
164
|
+
options: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
165
|
+
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String()))
|
|
166
|
+
}),
|
|
167
|
+
async execute(_id, params) {
|
|
168
|
+
if (!Array.isArray(params.urls) || params.urls.some((url) => typeof url !== "string")) {
|
|
169
|
+
throw new Error("urls must be an array of strings");
|
|
170
|
+
}
|
|
171
|
+
const payload = { urls: params.urls };
|
|
172
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
173
|
+
if (params.options) payload.options = params.options;
|
|
174
|
+
if (params.include) payload.include = params.include;
|
|
175
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har"], inline: true });
|
|
176
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{ optional: true }
|
|
180
|
+
);
|
|
181
|
+
api.registerTool(
|
|
182
|
+
{
|
|
183
|
+
name: "riddle_steps",
|
|
184
|
+
description: "Riddle: run a workflow in steps mode (goto/click/fill/etc.).",
|
|
185
|
+
parameters: import_typebox.Type.Object({
|
|
186
|
+
steps: import_typebox.Type.Array(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
187
|
+
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
188
|
+
options: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
189
|
+
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String())),
|
|
190
|
+
sync: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
191
|
+
}),
|
|
192
|
+
async execute(_id, params) {
|
|
193
|
+
if (!Array.isArray(params.steps)) throw new Error("steps must be an array");
|
|
194
|
+
const payload = { steps: params.steps };
|
|
195
|
+
if (typeof params.sync === "boolean") payload.sync = params.sync;
|
|
196
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
197
|
+
if (params.options) payload.options = params.options;
|
|
198
|
+
if (params.include) payload.include = params.include;
|
|
199
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har", "result"], inline: true });
|
|
200
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{ optional: true }
|
|
204
|
+
);
|
|
205
|
+
api.registerTool(
|
|
206
|
+
{
|
|
207
|
+
name: "riddle_script",
|
|
208
|
+
description: "Riddle: run full Playwright code (script mode).",
|
|
209
|
+
parameters: import_typebox.Type.Object({
|
|
210
|
+
script: import_typebox.Type.String(),
|
|
211
|
+
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
212
|
+
options: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
213
|
+
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String())),
|
|
214
|
+
sync: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
215
|
+
}),
|
|
216
|
+
async execute(_id, params) {
|
|
217
|
+
if (!params.script || typeof params.script !== "string") throw new Error("script must be a string");
|
|
218
|
+
const payload = { script: params.script };
|
|
219
|
+
if (typeof params.sync === "boolean") payload.sync = params.sync;
|
|
220
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
221
|
+
if (params.options) payload.options = params.options;
|
|
222
|
+
if (params.include) payload.include = params.include;
|
|
223
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har", "result"], inline: true });
|
|
224
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{ optional: true }
|
|
228
|
+
);
|
|
229
|
+
}
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
function getCfg(api) {
|
|
4
|
+
const cfg = api?.config ?? {};
|
|
5
|
+
const pluginCfg = cfg?.plugins?.entries?.riddle?.config ?? {};
|
|
6
|
+
return {
|
|
7
|
+
apiKey: process.env.RIDDLE_API_KEY || pluginCfg.apiKey,
|
|
8
|
+
baseUrl: pluginCfg.baseUrl || "https://api.riddledc.com"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function assertAllowedBaseUrl(baseUrl) {
|
|
12
|
+
const url = new URL(baseUrl);
|
|
13
|
+
if (url.protocol !== "https:") throw new Error(`Riddle baseUrl must be https: (${baseUrl})`);
|
|
14
|
+
if (url.hostname !== "api.riddledc.com") {
|
|
15
|
+
throw new Error(`Refusing to use non-official Riddle host: ${url.hostname}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function detectMode(payload) {
|
|
19
|
+
if (payload.url) return "url";
|
|
20
|
+
if (payload.urls) return "urls";
|
|
21
|
+
if (payload.steps) return "steps";
|
|
22
|
+
if (payload.script) return "script";
|
|
23
|
+
return void 0;
|
|
24
|
+
}
|
|
25
|
+
async function postRun(baseUrl, apiKey, payload) {
|
|
26
|
+
const res = await fetch(`${baseUrl.replace(/\/$/, "")}/v1/run`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${apiKey}`,
|
|
30
|
+
"Content-Type": "application/json"
|
|
31
|
+
},
|
|
32
|
+
body: JSON.stringify(payload)
|
|
33
|
+
});
|
|
34
|
+
const body = await res.arrayBuffer();
|
|
35
|
+
return {
|
|
36
|
+
contentType: res.headers.get("content-type"),
|
|
37
|
+
body,
|
|
38
|
+
headers: res.headers,
|
|
39
|
+
status: res.status
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function abToBase64(ab) {
|
|
43
|
+
return Buffer.from(ab).toString("base64");
|
|
44
|
+
}
|
|
45
|
+
async function runWithDefaults(api, payload, defaults) {
|
|
46
|
+
const { apiKey, baseUrl } = getCfg(api);
|
|
47
|
+
if (!apiKey) {
|
|
48
|
+
return {
|
|
49
|
+
ok: false,
|
|
50
|
+
error: "Missing Riddle API key. Set RIDDLE_API_KEY env var or plugins.entries.riddle.config.apiKey."
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
assertAllowedBaseUrl(baseUrl);
|
|
54
|
+
const mode = detectMode(payload);
|
|
55
|
+
const merged = { ...payload };
|
|
56
|
+
if (defaults?.include?.length) {
|
|
57
|
+
merged.include = Array.from(/* @__PURE__ */ new Set([...merged.include ?? [], ...defaults.include]));
|
|
58
|
+
}
|
|
59
|
+
if (defaults?.inline) {
|
|
60
|
+
merged.inlineConsole = merged.inlineConsole ?? true;
|
|
61
|
+
merged.inlineHar = merged.inlineHar ?? true;
|
|
62
|
+
merged.inlineResult = merged.inlineResult ?? true;
|
|
63
|
+
}
|
|
64
|
+
const out = { ok: true, mode };
|
|
65
|
+
const { contentType, body, headers, status } = await postRun(baseUrl, apiKey, merged);
|
|
66
|
+
out.rawContentType = contentType ?? void 0;
|
|
67
|
+
if (status >= 400) {
|
|
68
|
+
try {
|
|
69
|
+
const txt2 = Buffer.from(body).toString("utf8");
|
|
70
|
+
out.ok = false;
|
|
71
|
+
out.error = JSON.parse(txt2);
|
|
72
|
+
return out;
|
|
73
|
+
} catch {
|
|
74
|
+
out.ok = false;
|
|
75
|
+
out.error = `HTTP ${status}`;
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (contentType && contentType.includes("image/png")) {
|
|
80
|
+
out.rawPngBase64 = abToBase64(body);
|
|
81
|
+
out.job_id = headers.get("x-job-id") ?? void 0;
|
|
82
|
+
const duration = headers.get("x-duration-ms");
|
|
83
|
+
out.duration_ms = duration ? Number(duration) : void 0;
|
|
84
|
+
out.sync = true;
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
const txt = Buffer.from(body).toString("utf8");
|
|
88
|
+
const json = JSON.parse(txt);
|
|
89
|
+
Object.assign(out, json);
|
|
90
|
+
out.job_id = json.job_id ?? json.jobId ?? out.job_id;
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
function register(api) {
|
|
94
|
+
api.registerTool(
|
|
95
|
+
{
|
|
96
|
+
name: "riddle_run",
|
|
97
|
+
description: "Run a Riddle job (pass-through payload) against https://api.riddledc.com/v1/run. Supports url/urls/steps/script. Returns screenshot/console/har/result when requested.",
|
|
98
|
+
parameters: Type.Object({
|
|
99
|
+
payload: Type.Record(Type.String(), Type.Any())
|
|
100
|
+
}),
|
|
101
|
+
async execute(_id, params) {
|
|
102
|
+
const result = await runWithDefaults(api, params.payload, {
|
|
103
|
+
include: ["console", "har", "result"],
|
|
104
|
+
inline: true
|
|
105
|
+
});
|
|
106
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{ optional: true }
|
|
110
|
+
);
|
|
111
|
+
api.registerTool(
|
|
112
|
+
{
|
|
113
|
+
name: "riddle_screenshot",
|
|
114
|
+
description: "Riddle: take a screenshot of a single URL (url mode).",
|
|
115
|
+
parameters: Type.Object({
|
|
116
|
+
url: Type.String(),
|
|
117
|
+
timeout_sec: Type.Optional(Type.Number()),
|
|
118
|
+
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
119
|
+
include: Type.Optional(Type.Array(Type.String()))
|
|
120
|
+
}),
|
|
121
|
+
async execute(_id, params) {
|
|
122
|
+
if (!params.url || typeof params.url !== "string") throw new Error("url must be a string");
|
|
123
|
+
const payload = { url: params.url };
|
|
124
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
125
|
+
if (params.options) payload.options = params.options;
|
|
126
|
+
if (params.include) payload.include = params.include;
|
|
127
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har"], inline: true });
|
|
128
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{ optional: true }
|
|
132
|
+
);
|
|
133
|
+
api.registerTool(
|
|
134
|
+
{
|
|
135
|
+
name: "riddle_screenshots",
|
|
136
|
+
description: "Riddle: take screenshots for multiple URLs in one job (urls mode).",
|
|
137
|
+
parameters: Type.Object({
|
|
138
|
+
urls: Type.Array(Type.String()),
|
|
139
|
+
timeout_sec: Type.Optional(Type.Number()),
|
|
140
|
+
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
141
|
+
include: Type.Optional(Type.Array(Type.String()))
|
|
142
|
+
}),
|
|
143
|
+
async execute(_id, params) {
|
|
144
|
+
if (!Array.isArray(params.urls) || params.urls.some((url) => typeof url !== "string")) {
|
|
145
|
+
throw new Error("urls must be an array of strings");
|
|
146
|
+
}
|
|
147
|
+
const payload = { urls: params.urls };
|
|
148
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
149
|
+
if (params.options) payload.options = params.options;
|
|
150
|
+
if (params.include) payload.include = params.include;
|
|
151
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har"], inline: true });
|
|
152
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{ optional: true }
|
|
156
|
+
);
|
|
157
|
+
api.registerTool(
|
|
158
|
+
{
|
|
159
|
+
name: "riddle_steps",
|
|
160
|
+
description: "Riddle: run a workflow in steps mode (goto/click/fill/etc.).",
|
|
161
|
+
parameters: Type.Object({
|
|
162
|
+
steps: Type.Array(Type.Record(Type.String(), Type.Any())),
|
|
163
|
+
timeout_sec: Type.Optional(Type.Number()),
|
|
164
|
+
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
165
|
+
include: Type.Optional(Type.Array(Type.String())),
|
|
166
|
+
sync: Type.Optional(Type.Boolean())
|
|
167
|
+
}),
|
|
168
|
+
async execute(_id, params) {
|
|
169
|
+
if (!Array.isArray(params.steps)) throw new Error("steps must be an array");
|
|
170
|
+
const payload = { steps: params.steps };
|
|
171
|
+
if (typeof params.sync === "boolean") payload.sync = params.sync;
|
|
172
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
173
|
+
if (params.options) payload.options = params.options;
|
|
174
|
+
if (params.include) payload.include = params.include;
|
|
175
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har", "result"], inline: true });
|
|
176
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{ optional: true }
|
|
180
|
+
);
|
|
181
|
+
api.registerTool(
|
|
182
|
+
{
|
|
183
|
+
name: "riddle_script",
|
|
184
|
+
description: "Riddle: run full Playwright code (script mode).",
|
|
185
|
+
parameters: Type.Object({
|
|
186
|
+
script: Type.String(),
|
|
187
|
+
timeout_sec: Type.Optional(Type.Number()),
|
|
188
|
+
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
189
|
+
include: Type.Optional(Type.Array(Type.String())),
|
|
190
|
+
sync: Type.Optional(Type.Boolean())
|
|
191
|
+
}),
|
|
192
|
+
async execute(_id, params) {
|
|
193
|
+
if (!params.script || typeof params.script !== "string") throw new Error("script must be a string");
|
|
194
|
+
const payload = { script: params.script };
|
|
195
|
+
if (typeof params.sync === "boolean") payload.sync = params.sync;
|
|
196
|
+
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
197
|
+
if (params.options) payload.options = params.options;
|
|
198
|
+
if (params.include) payload.include = params.include;
|
|
199
|
+
const result = await runWithDefaults(api, payload, { include: ["console", "har", "result"], inline: true });
|
|
200
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{ optional: true }
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
export {
|
|
207
|
+
register as default
|
|
208
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "riddle",
|
|
3
|
+
"name": "Riddle",
|
|
4
|
+
"description": "Riddle (riddledc.com) hosted browser API tools for OpenClaw agents.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"configSchema": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"apiKey": { "type": "string" },
|
|
11
|
+
"baseUrl": { "type": "string", "default": "https://api.riddledc.com" }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"uiHints": {
|
|
15
|
+
"apiKey": { "label": "Riddle API Key", "sensitive": true, "placeholder": "rdc_live_..." },
|
|
16
|
+
"baseUrl": { "label": "API Base URL", "placeholder": "https://api.riddledc.com" }
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@riddledc/openclaw-riddledc",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "OpenClaw integration package for RiddleDC (no secrets).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "RiddleDC",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"openclaw.plugin.json"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"openclaw": {
|
|
27
|
+
"extensions": [
|
|
28
|
+
"."
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@sinclair/typebox": "^0.32.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^22.0.0",
|
|
36
|
+
"tsup": "^8.0.1",
|
|
37
|
+
"typescript": "^5.4.5"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --out-dir dist",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"lint": "echo 'lint: (not configured)'",
|
|
43
|
+
"test": "echo 'test: (not configured)'"
|
|
44
|
+
}
|
|
45
|
+
}
|