@riddledc/openclaw-riddledc 0.2.2 → 0.3.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/dist/index.cjs +70 -20
- package/dist/index.js +70 -20
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,9 @@ __export(index_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(index_exports);
|
|
26
26
|
var import_typebox = require("@sinclair/typebox");
|
|
27
|
+
var import_promises = require("fs/promises");
|
|
28
|
+
var import_node_path = require("path");
|
|
29
|
+
var INLINE_CAP = 50 * 1024;
|
|
27
30
|
function getCfg(api) {
|
|
28
31
|
const cfg = api?.config ?? {};
|
|
29
32
|
const pluginCfg = cfg?.plugins?.entries?.["openclaw-riddledc"]?.config ?? {};
|
|
@@ -66,6 +69,41 @@ async function postRun(baseUrl, apiKey, payload) {
|
|
|
66
69
|
function abToBase64(ab) {
|
|
67
70
|
return Buffer.from(ab).toString("base64");
|
|
68
71
|
}
|
|
72
|
+
function getWorkspacePath(api) {
|
|
73
|
+
return api?.workspacePath ?? process.cwd();
|
|
74
|
+
}
|
|
75
|
+
async function writeArtifact(workspace, subdir, filename, content) {
|
|
76
|
+
const dir = (0, import_node_path.join)(workspace, "riddle", subdir);
|
|
77
|
+
await (0, import_promises.mkdir)(dir, { recursive: true });
|
|
78
|
+
const filePath = (0, import_node_path.join)(dir, filename);
|
|
79
|
+
const buf = Buffer.from(content, "utf8");
|
|
80
|
+
await (0, import_promises.writeFile)(filePath, buf);
|
|
81
|
+
return { path: `riddle/${subdir}/${filename}`, sizeBytes: buf.byteLength };
|
|
82
|
+
}
|
|
83
|
+
async function applySafetySpec(result, opts) {
|
|
84
|
+
const jobId = result.job_id ?? "unknown";
|
|
85
|
+
if (result.har != null) {
|
|
86
|
+
const harStr = typeof result.har === "string" ? result.har : JSON.stringify(result.har);
|
|
87
|
+
const harBytes = Buffer.byteLength(harStr, "utf8");
|
|
88
|
+
if (opts.harInline && harBytes <= INLINE_CAP) {
|
|
89
|
+
} else {
|
|
90
|
+
const ref = await writeArtifact(opts.workspace, "har", `${jobId}.har.json`, harStr);
|
|
91
|
+
if (opts.harInline && harBytes > INLINE_CAP) {
|
|
92
|
+
result.har = { saved: ref.path, sizeBytes: ref.sizeBytes, warning: "Exceeded 50KB inline cap; wrote to file" };
|
|
93
|
+
} else {
|
|
94
|
+
result.har = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (result.console != null) {
|
|
99
|
+
const consoleStr = typeof result.console === "string" ? result.console : JSON.stringify(result.console);
|
|
100
|
+
const consoleBytes = Buffer.byteLength(consoleStr, "utf8");
|
|
101
|
+
if (consoleBytes > INLINE_CAP) {
|
|
102
|
+
const ref = await writeArtifact(opts.workspace, "console", `${jobId}.log`, consoleStr);
|
|
103
|
+
result.console = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
69
107
|
async function runWithDefaults(api, payload, defaults) {
|
|
70
108
|
const { apiKey, baseUrl } = getCfg(api);
|
|
71
109
|
if (!apiKey) {
|
|
@@ -76,14 +114,17 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
76
114
|
}
|
|
77
115
|
assertAllowedBaseUrl(baseUrl);
|
|
78
116
|
const mode = detectMode(payload);
|
|
117
|
+
const userInclude = payload.include ?? [];
|
|
118
|
+
const userRequestedHar = userInclude.includes("har");
|
|
119
|
+
const harInline = !!payload.harInline;
|
|
79
120
|
const merged = { ...payload };
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
merged.
|
|
121
|
+
delete merged.harInline;
|
|
122
|
+
const defaultInc = defaults?.include ?? ["screenshot", "console"];
|
|
123
|
+
merged.include = Array.from(/* @__PURE__ */ new Set([...userInclude, ...defaultInc]));
|
|
124
|
+
merged.inlineConsole = merged.inlineConsole ?? true;
|
|
125
|
+
merged.inlineResult = merged.inlineResult ?? true;
|
|
126
|
+
if (userRequestedHar) {
|
|
127
|
+
merged.inlineHar = true;
|
|
87
128
|
}
|
|
88
129
|
const out = { ok: true, mode };
|
|
89
130
|
const { contentType, body, headers, status } = await postRun(baseUrl, apiKey, merged);
|
|
@@ -112,20 +153,21 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
112
153
|
const json = JSON.parse(txt);
|
|
113
154
|
Object.assign(out, json);
|
|
114
155
|
out.job_id = json.job_id ?? json.jobId ?? out.job_id;
|
|
156
|
+
const workspace = getWorkspacePath(api);
|
|
157
|
+
await applySafetySpec(out, { workspace, harInline });
|
|
115
158
|
return out;
|
|
116
159
|
}
|
|
117
160
|
function register(api) {
|
|
118
161
|
api.registerTool(
|
|
119
162
|
{
|
|
120
163
|
name: "riddle_run",
|
|
121
|
-
description:
|
|
164
|
+
description: 'Run a Riddle job (pass-through payload) against https://api.riddledc.com/v1/run. Supports url/urls/steps/script. Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
122
165
|
parameters: import_typebox.Type.Object({
|
|
123
166
|
payload: import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())
|
|
124
167
|
}),
|
|
125
168
|
async execute(_id, params) {
|
|
126
169
|
const result = await runWithDefaults(api, params.payload, {
|
|
127
|
-
include: ["
|
|
128
|
-
inline: true
|
|
170
|
+
include: ["screenshot", "console", "result"]
|
|
129
171
|
});
|
|
130
172
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
131
173
|
}
|
|
@@ -135,12 +177,13 @@ function register(api) {
|
|
|
135
177
|
api.registerTool(
|
|
136
178
|
{
|
|
137
179
|
name: "riddle_screenshot",
|
|
138
|
-
description:
|
|
180
|
+
description: 'Riddle: take a screenshot of a single URL. Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
139
181
|
parameters: import_typebox.Type.Object({
|
|
140
182
|
url: import_typebox.Type.String(),
|
|
141
183
|
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
142
184
|
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()))
|
|
185
|
+
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String())),
|
|
186
|
+
harInline: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
144
187
|
}),
|
|
145
188
|
async execute(_id, params) {
|
|
146
189
|
if (!params.url || typeof params.url !== "string") throw new Error("url must be a string");
|
|
@@ -148,7 +191,8 @@ function register(api) {
|
|
|
148
191
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
149
192
|
if (params.options) payload.options = params.options;
|
|
150
193
|
if (params.include) payload.include = params.include;
|
|
151
|
-
|
|
194
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
195
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console"] });
|
|
152
196
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
153
197
|
}
|
|
154
198
|
},
|
|
@@ -157,12 +201,13 @@ function register(api) {
|
|
|
157
201
|
api.registerTool(
|
|
158
202
|
{
|
|
159
203
|
name: "riddle_screenshots",
|
|
160
|
-
description:
|
|
204
|
+
description: 'Riddle: take screenshots for multiple URLs in one job. Returns screenshots + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
161
205
|
parameters: import_typebox.Type.Object({
|
|
162
206
|
urls: import_typebox.Type.Array(import_typebox.Type.String()),
|
|
163
207
|
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
164
208
|
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()))
|
|
209
|
+
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String())),
|
|
210
|
+
harInline: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
166
211
|
}),
|
|
167
212
|
async execute(_id, params) {
|
|
168
213
|
if (!Array.isArray(params.urls) || params.urls.some((url) => typeof url !== "string")) {
|
|
@@ -172,7 +217,8 @@ function register(api) {
|
|
|
172
217
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
173
218
|
if (params.options) payload.options = params.options;
|
|
174
219
|
if (params.include) payload.include = params.include;
|
|
175
|
-
|
|
220
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
221
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console"] });
|
|
176
222
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
177
223
|
}
|
|
178
224
|
},
|
|
@@ -181,12 +227,13 @@ function register(api) {
|
|
|
181
227
|
api.registerTool(
|
|
182
228
|
{
|
|
183
229
|
name: "riddle_steps",
|
|
184
|
-
description:
|
|
230
|
+
description: 'Riddle: run a workflow in steps mode (goto/click/fill/etc.). Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
185
231
|
parameters: import_typebox.Type.Object({
|
|
186
232
|
steps: import_typebox.Type.Array(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
187
233
|
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
188
234
|
options: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
189
235
|
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String())),
|
|
236
|
+
harInline: import_typebox.Type.Optional(import_typebox.Type.Boolean()),
|
|
190
237
|
sync: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
191
238
|
}),
|
|
192
239
|
async execute(_id, params) {
|
|
@@ -196,7 +243,8 @@ function register(api) {
|
|
|
196
243
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
197
244
|
if (params.options) payload.options = params.options;
|
|
198
245
|
if (params.include) payload.include = params.include;
|
|
199
|
-
|
|
246
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
247
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console", "result"] });
|
|
200
248
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
201
249
|
}
|
|
202
250
|
},
|
|
@@ -205,12 +253,13 @@ function register(api) {
|
|
|
205
253
|
api.registerTool(
|
|
206
254
|
{
|
|
207
255
|
name: "riddle_script",
|
|
208
|
-
description:
|
|
256
|
+
description: 'Riddle: run full Playwright code (script mode). Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
209
257
|
parameters: import_typebox.Type.Object({
|
|
210
258
|
script: import_typebox.Type.String(),
|
|
211
259
|
timeout_sec: import_typebox.Type.Optional(import_typebox.Type.Number()),
|
|
212
260
|
options: import_typebox.Type.Optional(import_typebox.Type.Record(import_typebox.Type.String(), import_typebox.Type.Any())),
|
|
213
261
|
include: import_typebox.Type.Optional(import_typebox.Type.Array(import_typebox.Type.String())),
|
|
262
|
+
harInline: import_typebox.Type.Optional(import_typebox.Type.Boolean()),
|
|
214
263
|
sync: import_typebox.Type.Optional(import_typebox.Type.Boolean())
|
|
215
264
|
}),
|
|
216
265
|
async execute(_id, params) {
|
|
@@ -220,7 +269,8 @@ function register(api) {
|
|
|
220
269
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
221
270
|
if (params.options) payload.options = params.options;
|
|
222
271
|
if (params.include) payload.include = params.include;
|
|
223
|
-
|
|
272
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
273
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console", "result"] });
|
|
224
274
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
225
275
|
}
|
|
226
276
|
},
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { writeFile, mkdir } from "fs/promises";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
var INLINE_CAP = 50 * 1024;
|
|
3
6
|
function getCfg(api) {
|
|
4
7
|
const cfg = api?.config ?? {};
|
|
5
8
|
const pluginCfg = cfg?.plugins?.entries?.["openclaw-riddledc"]?.config ?? {};
|
|
@@ -42,6 +45,41 @@ async function postRun(baseUrl, apiKey, payload) {
|
|
|
42
45
|
function abToBase64(ab) {
|
|
43
46
|
return Buffer.from(ab).toString("base64");
|
|
44
47
|
}
|
|
48
|
+
function getWorkspacePath(api) {
|
|
49
|
+
return api?.workspacePath ?? process.cwd();
|
|
50
|
+
}
|
|
51
|
+
async function writeArtifact(workspace, subdir, filename, content) {
|
|
52
|
+
const dir = join(workspace, "riddle", subdir);
|
|
53
|
+
await mkdir(dir, { recursive: true });
|
|
54
|
+
const filePath = join(dir, filename);
|
|
55
|
+
const buf = Buffer.from(content, "utf8");
|
|
56
|
+
await writeFile(filePath, buf);
|
|
57
|
+
return { path: `riddle/${subdir}/${filename}`, sizeBytes: buf.byteLength };
|
|
58
|
+
}
|
|
59
|
+
async function applySafetySpec(result, opts) {
|
|
60
|
+
const jobId = result.job_id ?? "unknown";
|
|
61
|
+
if (result.har != null) {
|
|
62
|
+
const harStr = typeof result.har === "string" ? result.har : JSON.stringify(result.har);
|
|
63
|
+
const harBytes = Buffer.byteLength(harStr, "utf8");
|
|
64
|
+
if (opts.harInline && harBytes <= INLINE_CAP) {
|
|
65
|
+
} else {
|
|
66
|
+
const ref = await writeArtifact(opts.workspace, "har", `${jobId}.har.json`, harStr);
|
|
67
|
+
if (opts.harInline && harBytes > INLINE_CAP) {
|
|
68
|
+
result.har = { saved: ref.path, sizeBytes: ref.sizeBytes, warning: "Exceeded 50KB inline cap; wrote to file" };
|
|
69
|
+
} else {
|
|
70
|
+
result.har = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (result.console != null) {
|
|
75
|
+
const consoleStr = typeof result.console === "string" ? result.console : JSON.stringify(result.console);
|
|
76
|
+
const consoleBytes = Buffer.byteLength(consoleStr, "utf8");
|
|
77
|
+
if (consoleBytes > INLINE_CAP) {
|
|
78
|
+
const ref = await writeArtifact(opts.workspace, "console", `${jobId}.log`, consoleStr);
|
|
79
|
+
result.console = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
45
83
|
async function runWithDefaults(api, payload, defaults) {
|
|
46
84
|
const { apiKey, baseUrl } = getCfg(api);
|
|
47
85
|
if (!apiKey) {
|
|
@@ -52,14 +90,17 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
52
90
|
}
|
|
53
91
|
assertAllowedBaseUrl(baseUrl);
|
|
54
92
|
const mode = detectMode(payload);
|
|
93
|
+
const userInclude = payload.include ?? [];
|
|
94
|
+
const userRequestedHar = userInclude.includes("har");
|
|
95
|
+
const harInline = !!payload.harInline;
|
|
55
96
|
const merged = { ...payload };
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
merged.
|
|
97
|
+
delete merged.harInline;
|
|
98
|
+
const defaultInc = defaults?.include ?? ["screenshot", "console"];
|
|
99
|
+
merged.include = Array.from(/* @__PURE__ */ new Set([...userInclude, ...defaultInc]));
|
|
100
|
+
merged.inlineConsole = merged.inlineConsole ?? true;
|
|
101
|
+
merged.inlineResult = merged.inlineResult ?? true;
|
|
102
|
+
if (userRequestedHar) {
|
|
103
|
+
merged.inlineHar = true;
|
|
63
104
|
}
|
|
64
105
|
const out = { ok: true, mode };
|
|
65
106
|
const { contentType, body, headers, status } = await postRun(baseUrl, apiKey, merged);
|
|
@@ -88,20 +129,21 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
88
129
|
const json = JSON.parse(txt);
|
|
89
130
|
Object.assign(out, json);
|
|
90
131
|
out.job_id = json.job_id ?? json.jobId ?? out.job_id;
|
|
132
|
+
const workspace = getWorkspacePath(api);
|
|
133
|
+
await applySafetySpec(out, { workspace, harInline });
|
|
91
134
|
return out;
|
|
92
135
|
}
|
|
93
136
|
function register(api) {
|
|
94
137
|
api.registerTool(
|
|
95
138
|
{
|
|
96
139
|
name: "riddle_run",
|
|
97
|
-
description:
|
|
140
|
+
description: 'Run a Riddle job (pass-through payload) against https://api.riddledc.com/v1/run. Supports url/urls/steps/script. Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
98
141
|
parameters: Type.Object({
|
|
99
142
|
payload: Type.Record(Type.String(), Type.Any())
|
|
100
143
|
}),
|
|
101
144
|
async execute(_id, params) {
|
|
102
145
|
const result = await runWithDefaults(api, params.payload, {
|
|
103
|
-
include: ["
|
|
104
|
-
inline: true
|
|
146
|
+
include: ["screenshot", "console", "result"]
|
|
105
147
|
});
|
|
106
148
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
107
149
|
}
|
|
@@ -111,12 +153,13 @@ function register(api) {
|
|
|
111
153
|
api.registerTool(
|
|
112
154
|
{
|
|
113
155
|
name: "riddle_screenshot",
|
|
114
|
-
description:
|
|
156
|
+
description: 'Riddle: take a screenshot of a single URL. Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
115
157
|
parameters: Type.Object({
|
|
116
158
|
url: Type.String(),
|
|
117
159
|
timeout_sec: Type.Optional(Type.Number()),
|
|
118
160
|
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
119
|
-
include: Type.Optional(Type.Array(Type.String()))
|
|
161
|
+
include: Type.Optional(Type.Array(Type.String())),
|
|
162
|
+
harInline: Type.Optional(Type.Boolean())
|
|
120
163
|
}),
|
|
121
164
|
async execute(_id, params) {
|
|
122
165
|
if (!params.url || typeof params.url !== "string") throw new Error("url must be a string");
|
|
@@ -124,7 +167,8 @@ function register(api) {
|
|
|
124
167
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
125
168
|
if (params.options) payload.options = params.options;
|
|
126
169
|
if (params.include) payload.include = params.include;
|
|
127
|
-
|
|
170
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
171
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console"] });
|
|
128
172
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
129
173
|
}
|
|
130
174
|
},
|
|
@@ -133,12 +177,13 @@ function register(api) {
|
|
|
133
177
|
api.registerTool(
|
|
134
178
|
{
|
|
135
179
|
name: "riddle_screenshots",
|
|
136
|
-
description:
|
|
180
|
+
description: 'Riddle: take screenshots for multiple URLs in one job. Returns screenshots + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
137
181
|
parameters: Type.Object({
|
|
138
182
|
urls: Type.Array(Type.String()),
|
|
139
183
|
timeout_sec: Type.Optional(Type.Number()),
|
|
140
184
|
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
141
|
-
include: Type.Optional(Type.Array(Type.String()))
|
|
185
|
+
include: Type.Optional(Type.Array(Type.String())),
|
|
186
|
+
harInline: Type.Optional(Type.Boolean())
|
|
142
187
|
}),
|
|
143
188
|
async execute(_id, params) {
|
|
144
189
|
if (!Array.isArray(params.urls) || params.urls.some((url) => typeof url !== "string")) {
|
|
@@ -148,7 +193,8 @@ function register(api) {
|
|
|
148
193
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
149
194
|
if (params.options) payload.options = params.options;
|
|
150
195
|
if (params.include) payload.include = params.include;
|
|
151
|
-
|
|
196
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
197
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console"] });
|
|
152
198
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
153
199
|
}
|
|
154
200
|
},
|
|
@@ -157,12 +203,13 @@ function register(api) {
|
|
|
157
203
|
api.registerTool(
|
|
158
204
|
{
|
|
159
205
|
name: "riddle_steps",
|
|
160
|
-
description:
|
|
206
|
+
description: 'Riddle: run a workflow in steps mode (goto/click/fill/etc.). Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
161
207
|
parameters: Type.Object({
|
|
162
208
|
steps: Type.Array(Type.Record(Type.String(), Type.Any())),
|
|
163
209
|
timeout_sec: Type.Optional(Type.Number()),
|
|
164
210
|
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
165
211
|
include: Type.Optional(Type.Array(Type.String())),
|
|
212
|
+
harInline: Type.Optional(Type.Boolean()),
|
|
166
213
|
sync: Type.Optional(Type.Boolean())
|
|
167
214
|
}),
|
|
168
215
|
async execute(_id, params) {
|
|
@@ -172,7 +219,8 @@ function register(api) {
|
|
|
172
219
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
173
220
|
if (params.options) payload.options = params.options;
|
|
174
221
|
if (params.include) payload.include = params.include;
|
|
175
|
-
|
|
222
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
223
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console", "result"] });
|
|
176
224
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
177
225
|
}
|
|
178
226
|
},
|
|
@@ -181,12 +229,13 @@ function register(api) {
|
|
|
181
229
|
api.registerTool(
|
|
182
230
|
{
|
|
183
231
|
name: "riddle_script",
|
|
184
|
-
description:
|
|
232
|
+
description: 'Riddle: run full Playwright code (script mode). Returns screenshot + console by default; pass include:["har"] to opt in to HAR capture.',
|
|
185
233
|
parameters: Type.Object({
|
|
186
234
|
script: Type.String(),
|
|
187
235
|
timeout_sec: Type.Optional(Type.Number()),
|
|
188
236
|
options: Type.Optional(Type.Record(Type.String(), Type.Any())),
|
|
189
237
|
include: Type.Optional(Type.Array(Type.String())),
|
|
238
|
+
harInline: Type.Optional(Type.Boolean()),
|
|
190
239
|
sync: Type.Optional(Type.Boolean())
|
|
191
240
|
}),
|
|
192
241
|
async execute(_id, params) {
|
|
@@ -196,7 +245,8 @@ function register(api) {
|
|
|
196
245
|
if (params.timeout_sec) payload.timeout_sec = params.timeout_sec;
|
|
197
246
|
if (params.options) payload.options = params.options;
|
|
198
247
|
if (params.include) payload.include = params.include;
|
|
199
|
-
|
|
248
|
+
if (params.harInline) payload.harInline = params.harInline;
|
|
249
|
+
const result = await runWithDefaults(api, payload, { include: ["screenshot", "console", "result"] });
|
|
200
250
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
201
251
|
}
|
|
202
252
|
},
|
package/openclaw.plugin.json
CHANGED