@riddledc/openclaw-riddledc 0.3.0 → 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/dist/index.cjs +27 -0
- package/dist/index.js +27 -0
- package/openclaw.plugin.json +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -80,8 +80,33 @@ 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) {
|
|
94
|
+
let base64Data = null;
|
|
95
|
+
if (typeof result.screenshot === "string") {
|
|
96
|
+
base64Data = result.screenshot;
|
|
97
|
+
} else if (typeof result.screenshot === "object" && result.screenshot.data) {
|
|
98
|
+
base64Data = result.screenshot.data;
|
|
99
|
+
}
|
|
100
|
+
if (base64Data) {
|
|
101
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, base64Data);
|
|
102
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (result.rawPngBase64 != null) {
|
|
106
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, result.rawPngBase64);
|
|
107
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
108
|
+
delete result.rawPngBase64;
|
|
109
|
+
}
|
|
85
110
|
if (result.har != null) {
|
|
86
111
|
const harStr = typeof result.har === "string" ? result.har : JSON.stringify(result.har);
|
|
87
112
|
const harBytes = Buffer.byteLength(harStr, "utf8");
|
|
@@ -147,6 +172,8 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
147
172
|
const duration = headers.get("x-duration-ms");
|
|
148
173
|
out.duration_ms = duration ? Number(duration) : void 0;
|
|
149
174
|
out.sync = true;
|
|
175
|
+
const workspace2 = getWorkspacePath(api);
|
|
176
|
+
await applySafetySpec(out, { workspace: workspace2, harInline });
|
|
150
177
|
return out;
|
|
151
178
|
}
|
|
152
179
|
const txt = Buffer.from(body).toString("utf8");
|
package/dist/index.js
CHANGED
|
@@ -56,8 +56,33 @@ 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) {
|
|
70
|
+
let base64Data = null;
|
|
71
|
+
if (typeof result.screenshot === "string") {
|
|
72
|
+
base64Data = result.screenshot;
|
|
73
|
+
} else if (typeof result.screenshot === "object" && result.screenshot.data) {
|
|
74
|
+
base64Data = result.screenshot.data;
|
|
75
|
+
}
|
|
76
|
+
if (base64Data) {
|
|
77
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, base64Data);
|
|
78
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (result.rawPngBase64 != null) {
|
|
82
|
+
const ref = await writeArtifactBinary(opts.workspace, "screenshots", `${jobId}.png`, result.rawPngBase64);
|
|
83
|
+
result.screenshot = { saved: ref.path, sizeBytes: ref.sizeBytes };
|
|
84
|
+
delete result.rawPngBase64;
|
|
85
|
+
}
|
|
61
86
|
if (result.har != null) {
|
|
62
87
|
const harStr = typeof result.har === "string" ? result.har : JSON.stringify(result.har);
|
|
63
88
|
const harBytes = Buffer.byteLength(harStr, "utf8");
|
|
@@ -123,6 +148,8 @@ async function runWithDefaults(api, payload, defaults) {
|
|
|
123
148
|
const duration = headers.get("x-duration-ms");
|
|
124
149
|
out.duration_ms = duration ? Number(duration) : void 0;
|
|
125
150
|
out.sync = true;
|
|
151
|
+
const workspace2 = getWorkspacePath(api);
|
|
152
|
+
await applySafetySpec(out, { workspace: workspace2, harInline });
|
|
126
153
|
return out;
|
|
127
154
|
}
|
|
128
155
|
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.2",
|
|
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,
|