@riddledc/openclaw-riddledc 0.9.2 → 0.9.3
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/CHECKSUMS.txt +7 -2
- package/README.md +10 -0
- package/dist/chunk-LJCZ53PU.js +833 -0
- package/dist/core.cjs +872 -0
- package/dist/core.d.cts +57 -0
- package/dist/core.d.ts +57 -0
- package/dist/core.js +36 -0
- package/dist/index.cjs +292 -173
- package/dist/index.js +10 -99
- package/openclaw.plugin.json +1 -1
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configFromOpenClawApi,
|
|
3
|
+
createStaticPreview,
|
|
4
|
+
deleteStaticPreview
|
|
5
|
+
} from "./chunk-LJCZ53PU.js";
|
|
6
|
+
|
|
1
7
|
// src/index.ts
|
|
2
8
|
import { Type } from "@sinclair/typebox";
|
|
3
9
|
import { writeFile, mkdir, readFile, stat, rm } from "fs/promises";
|
|
@@ -860,85 +866,8 @@ function register(api) {
|
|
|
860
866
|
framework: Type.Optional(Type.String({ description: "Framework hint: 'spa' (default) or 'static'" }))
|
|
861
867
|
}),
|
|
862
868
|
async execute(_id, params) {
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: "Missing Riddle API key." }, null, 2) }] };
|
|
866
|
-
}
|
|
867
|
-
assertAllowedBaseUrl(baseUrl);
|
|
868
|
-
const dir = params.directory;
|
|
869
|
-
if (!dir || typeof dir !== "string") throw new Error("directory must be an absolute path");
|
|
870
|
-
try {
|
|
871
|
-
const st = await stat(dir);
|
|
872
|
-
if (!st.isDirectory()) throw new Error(`Not a directory: ${dir}`);
|
|
873
|
-
} catch (e) {
|
|
874
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: `Cannot access directory: ${e.message}` }, null, 2) }] };
|
|
875
|
-
}
|
|
876
|
-
const endpoint = baseUrl.replace(/\/$/, "");
|
|
877
|
-
let createRes;
|
|
878
|
-
try {
|
|
879
|
-
createRes = await fetchWithRetry(`${endpoint}/v1/preview`, {
|
|
880
|
-
method: "POST",
|
|
881
|
-
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
882
|
-
body: JSON.stringify({ framework: params.framework || "spa" })
|
|
883
|
-
}, PREVIEW_REQUEST_TIMEOUT_MS, "preview create");
|
|
884
|
-
} catch (e) {
|
|
885
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: `Create failed: ${describeError(e)}` }, null, 2) }] };
|
|
886
|
-
}
|
|
887
|
-
if (!createRes.ok) {
|
|
888
|
-
const err = await createRes.text();
|
|
889
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: `Create failed: HTTP ${createRes.status} ${err}` }, null, 2) }] };
|
|
890
|
-
}
|
|
891
|
-
const created = await createRes.json();
|
|
892
|
-
const tarball = `/tmp/riddle-preview-${created.id}.tar.gz`;
|
|
893
|
-
try {
|
|
894
|
-
await execFile("tar", ["czf", tarball, "-C", dir, "."], { timeout: 6e4 });
|
|
895
|
-
const tarData = await readFile(tarball);
|
|
896
|
-
let uploadRes;
|
|
897
|
-
try {
|
|
898
|
-
uploadRes = await fetchWithRetry(created.upload_url, {
|
|
899
|
-
method: "PUT",
|
|
900
|
-
headers: { "Content-Type": "application/gzip" },
|
|
901
|
-
body: tarData
|
|
902
|
-
}, PREVIEW_UPLOAD_TIMEOUT_MS, "preview upload");
|
|
903
|
-
} catch (e) {
|
|
904
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, id: created.id, error: `Upload failed: ${describeError(e)}` }, null, 2) }] };
|
|
905
|
-
}
|
|
906
|
-
if (!uploadRes.ok) {
|
|
907
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, id: created.id, error: `Upload failed: HTTP ${uploadRes.status}` }, null, 2) }] };
|
|
908
|
-
}
|
|
909
|
-
} finally {
|
|
910
|
-
try {
|
|
911
|
-
await rm(tarball, { force: true });
|
|
912
|
-
} catch {
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
let publishRes;
|
|
916
|
-
try {
|
|
917
|
-
publishRes = await fetchWithTimeout(`${endpoint}/v1/preview/${created.id}/publish`, {
|
|
918
|
-
method: "POST",
|
|
919
|
-
headers: { Authorization: `Bearer ${apiKey}` }
|
|
920
|
-
}, PREVIEW_REQUEST_TIMEOUT_MS, "preview publish");
|
|
921
|
-
} catch (e) {
|
|
922
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, id: created.id, error: `Publish failed: ${describeError(e)}` }, null, 2) }] };
|
|
923
|
-
}
|
|
924
|
-
if (!publishRes.ok) {
|
|
925
|
-
const err = await publishRes.text();
|
|
926
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, id: created.id, error: `Publish failed: HTTP ${publishRes.status} ${err}` }, null, 2) }] };
|
|
927
|
-
}
|
|
928
|
-
const published = await publishRes.json();
|
|
929
|
-
return {
|
|
930
|
-
content: [{
|
|
931
|
-
type: "text",
|
|
932
|
-
text: JSON.stringify({
|
|
933
|
-
ok: true,
|
|
934
|
-
id: published.id,
|
|
935
|
-
preview_url: published.preview_url,
|
|
936
|
-
file_count: published.file_count,
|
|
937
|
-
total_bytes: published.total_bytes,
|
|
938
|
-
expires_at: created.expires_at
|
|
939
|
-
}, null, 2)
|
|
940
|
-
}]
|
|
941
|
-
};
|
|
869
|
+
const result = await createStaticPreview(configFromOpenClawApi(api), params);
|
|
870
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
942
871
|
}
|
|
943
872
|
},
|
|
944
873
|
{ optional: true }
|
|
@@ -951,26 +880,8 @@ function register(api) {
|
|
|
951
880
|
id: Type.String({ description: "Preview ID (e.g. pv_a1b2c3d4)" })
|
|
952
881
|
}),
|
|
953
882
|
async execute(_id, params) {
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: "Missing Riddle API key." }, null, 2) }] };
|
|
957
|
-
}
|
|
958
|
-
assertAllowedBaseUrl(baseUrl);
|
|
959
|
-
let res;
|
|
960
|
-
try {
|
|
961
|
-
res = await fetchWithTimeout(`${baseUrl.replace(/\/$/, "")}/v1/preview/${params.id}`, {
|
|
962
|
-
method: "DELETE",
|
|
963
|
-
headers: { Authorization: `Bearer ${apiKey}` }
|
|
964
|
-
}, PREVIEW_REQUEST_TIMEOUT_MS, "preview delete");
|
|
965
|
-
} catch (e) {
|
|
966
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: `Delete failed: ${describeError(e)}` }, null, 2) }] };
|
|
967
|
-
}
|
|
968
|
-
if (!res.ok) {
|
|
969
|
-
const err = await res.text();
|
|
970
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: false, error: `Delete failed: HTTP ${res.status} ${err}` }, null, 2) }] };
|
|
971
|
-
}
|
|
972
|
-
const data = await res.json();
|
|
973
|
-
return { content: [{ type: "text", text: JSON.stringify({ ok: true, deleted: true, files_removed: data.files_removed }, null, 2) }] };
|
|
883
|
+
const result = await deleteStaticPreview(configFromOpenClawApi(api), params.id);
|
|
884
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
974
885
|
}
|
|
975
886
|
},
|
|
976
887
|
{ optional: true }
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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.9.
|
|
5
|
+
"version": "0.9.3",
|
|
6
6
|
"notes": "0.8.0: Added riddle_build_preview for Dockerfile-based builds with image caching.",
|
|
7
7
|
"type": "plugin",
|
|
8
8
|
"bundledSkills": [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riddledc/openclaw-riddledc",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "OpenClaw integration package for RiddleDC (no secrets).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "RiddleDC",
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./core": {
|
|
23
|
+
"types": "./dist/core.d.ts",
|
|
24
|
+
"import": "./dist/core.js",
|
|
25
|
+
"require": "./dist/core.cjs"
|
|
21
26
|
}
|
|
22
27
|
},
|
|
23
28
|
"files": [
|
|
@@ -45,7 +50,7 @@
|
|
|
45
50
|
"typescript": "^5.4.5"
|
|
46
51
|
},
|
|
47
52
|
"scripts": {
|
|
48
|
-
"build": "npm run sync:openclaw-plugin-version && tsup src/index.ts --format cjs,esm --dts --out-dir dist",
|
|
53
|
+
"build": "npm run sync:openclaw-plugin-version && tsup src/index.ts src/core.ts --format cjs,esm --dts --out-dir dist",
|
|
49
54
|
"clean": "rm -rf dist",
|
|
50
55
|
"lint": "echo 'lint: (not configured)'",
|
|
51
56
|
"test": "echo 'test: (not configured)'",
|