@riddledc/openclaw-riddledc 0.3.0 → 0.3.1
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 +19 -0
- package/dist/index.js +19 -0
- package/openclaw.plugin.json +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -80,8 +80,25 @@ async function writeArtifact(workspace, subdir, filename, content) {
|
|
|
80
80
|
await (0, import_promises.writeFile)(filePath, buf);
|
|
81
81
|
return { path: `riddle/${subdir}/${filename}`, sizeBytes: buf.byteLength };
|
|
82
82
|
}
|
|
83
|
+
async function writeArtifactBinary(workspace, subdir, filename, base64Content) {
|
|
84
|
+
const dir = (0, import_node_path.join)(workspace, "riddle", subdir);
|
|
85
|
+
await (0, import_promises.mkdir)(dir, { recursive: true });
|
|
86
|
+
const filePath = (0, import_node_path.join)(dir, filename);
|
|
87
|
+
const buf = Buffer.from(base64Content, "base64");
|
|
88
|
+
await (0, import_promises.writeFile)(filePath, buf);
|
|
89
|
+
return { path: `riddle/${subdir}/${filename}`, sizeBytes: buf.byteLength };
|
|
90
|
+
}
|
|
83
91
|
async function applySafetySpec(result, opts) {
|
|
84
92
|
const jobId = result.job_id ?? "unknown";
|
|
93
|
+
if (result.screenshot != null && typeof result.screenshot === "string") {
|
|
94
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, result.screenshot);
|
|
95
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
96
|
+
}
|
|
97
|
+
if (result.rawPngBase64 != null) {
|
|
98
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, result.rawPngBase64);
|
|
99
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
100
|
+
delete result.rawPngBase64;
|
|
101
|
+
}
|
|
85
102
|
if (result.har != null) {
|
|
86
103
|
const harStr = typeof result.har === "string" ? result.har : JSON.stringify(result.har);
|
|
87
104
|
const harBytes = Buffer.byteLength(harStr, "utf8");
|
|
@@ -147,6 +164,8 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
147
164
|
const duration = headers.get("x-duration-ms");
|
|
148
165
|
out.duration_ms = duration ? Number(duration) : void 0;
|
|
149
166
|
out.sync = true;
|
|
167
|
+
const workspace2 = getWorkspacePath(api);
|
|
168
|
+
await applySafetySpec(out, { workspace: workspace2, harInline });
|
|
150
169
|
return out;
|
|
151
170
|
}
|
|
152
171
|
const txt = Buffer.from(body).toString("utf8");
|
package/dist/index.js
CHANGED
|
@@ -56,8 +56,25 @@ async function writeArtifact(workspace, subdir, filename, content) {
|
|
|
56
56
|
await writeFile(filePath, buf);
|
|
57
57
|
return { path: `riddle/${subdir}/${filename}`, sizeBytes: buf.byteLength };
|
|
58
58
|
}
|
|
59
|
+
async function writeArtifactBinary(workspace, subdir, filename, base64Content) {
|
|
60
|
+
const dir = join(workspace, "riddle", subdir);
|
|
61
|
+
await mkdir(dir, { recursive: true });
|
|
62
|
+
const filePath = join(dir, filename);
|
|
63
|
+
const buf = Buffer.from(base64Content, "base64");
|
|
64
|
+
await writeFile(filePath, buf);
|
|
65
|
+
return { path: `riddle/${subdir}/${filename}`, sizeBytes: buf.byteLength };
|
|
66
|
+
}
|
|
59
67
|
async function applySafetySpec(result, opts) {
|
|
60
68
|
const jobId = result.job_id ?? "unknown";
|
|
69
|
+
if (result.screenshot != null && typeof result.screenshot === "string") {
|
|
70
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, result.screenshot);
|
|
71
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
72
|
+
}
|
|
73
|
+
if (result.rawPngBase64 != null) {
|
|
74
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, result.rawPngBase64);
|
|
75
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
76
|
+
delete result.rawPngBase64;
|
|
77
|
+
}
|
|
61
78
|
if (result.har != null) {
|
|
62
79
|
const harStr = typeof result.har === "string" ? result.har : JSON.stringify(result.har);
|
|
63
80
|
const harBytes = Buffer.byteLength(harStr, "utf8");
|
|
@@ -123,6 +140,8 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
123
140
|
const duration = headers.get("x-duration-ms");
|
|
124
141
|
out.duration_ms = duration ? Number(duration) : void 0;
|
|
125
142
|
out.sync = true;
|
|
143
|
+
const workspace2 = getWorkspacePath(api);
|
|
144
|
+
await applySafetySpec(out, { workspace: workspace2, harInline });
|
|
126
145
|
return out;
|
|
127
146
|
}
|
|
128
147
|
const txt = Buffer.from(body).toString("utf8");
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"id": "openclaw-riddledc",
|
|
3
3
|
"name": "Riddle",
|
|
4
4
|
"description": "Riddle (riddledc.com) hosted browser API tools for OpenClaw agents.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.1",
|
|
6
|
+
"notes": "0.3.1: Screenshots now saved to workspace files instead of inline base64 to prevent context bloat.",
|
|
6
7
|
"configSchema": {
|
|
7
8
|
"type": "object",
|
|
8
9
|
"additionalProperties": false,
|