ai4scholar 0.6.5 → 0.6.7
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.js +17 -8
- package/package.json +11 -16
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
if(typeof globalThis.DOMMatrix==='undefined'){class DM{constructor(a){this.a=1;this.b=0;this.c=0;this.d=1;this.e=0;this.f=0;if(Array.isArray(a)){[this.a,this.b,this.c,this.d,this.e,this.f]=a}}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0}inverse(){return new DM()}translate(){return this}scale(){return this}multiply(){return this}transformPoint(p){return p||{x:0,y:0}}}globalThis.DOMMatrix=DM}
|
|
2
2
|
if(typeof globalThis.ImageData==='undefined'){globalThis.ImageData=class ImageData{constructor(w,h){this.width=w||0;this.height=h||0;this.data=new Uint8ClampedArray(4*this.width*this.height)}}}
|
|
3
3
|
if(typeof globalThis.Path2D==='undefined'){globalThis.Path2D=class Path2D{}}
|
|
4
|
+
;(function(){try{var M=process.getBuiltinModule?.('module');if(!M||!M._resolveFilename)return;var _r=M._resolveFilename;M._resolveFilename=function(req){if(req==='@napi-rs/canvas')return'__napi_canvas_stub__';return _r.apply(this,arguments)};(M._cache||(M._cache={}))['__napi_canvas_stub__']={id:'__napi_canvas_stub__',filename:'__napi_canvas_stub__',loaded:true,exports:{createCanvas:function(){return{getContext:function(){return{}}}}}}}catch(e){}})();
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
@@ -24822,19 +24823,19 @@ function createSciDrawTool() {
|
|
|
24822
24823
|
return {
|
|
24823
24824
|
label: "Scientific Drawing",
|
|
24824
24825
|
name: "sci_draw",
|
|
24825
|
-
description: "Generate or process scientific figures using AI. IMPORTANT: Image generation takes 30-60 seconds. You MUST tell the user '\u6B63\u5728\u751F\u6210\u79D1\u7814\u56FE\u7247\uFF0C\u5927\u7EA6\u9700\u8981 30-60 \u79D2\uFF0C\u8BF7\u7A0D\u5019...' BEFORE calling this tool, so the user knows to wait. Actions: 'smart' (auto-optimize prompt, supports Chinese, recommended), 'generate' (text-to-image), 'edit' (modify existing image), 'style' (style transfer), 'compose' (combine multiple images), 'iterate' (auto-review and refine), 'critic' (expert review, returns text), 'svg' (generate SVG vector graphics). Models: 'flash' (fast), 'flash31' (balanced, default), 'pro' (high quality). Returns image URL or
|
|
24826
|
+
description: "Generate or process scientific figures using AI. IMPORTANT: Image generation takes 30-60 seconds. You MUST tell the user '\u6B63\u5728\u751F\u6210\u79D1\u7814\u56FE\u7247\uFF0C\u5927\u7EA6\u9700\u8981 30-60 \u79D2\uFF0C\u8BF7\u7A0D\u5019...' BEFORE calling this tool, so the user knows to wait. Actions: 'smart' (auto-optimize prompt, supports Chinese, recommended), 'generate' (text-to-image), 'edit' (modify existing image), 'style' (style transfer), 'compose' (combine multiple images), 'iterate' (auto-review and refine), 'critic' (expert review, returns text), 'svg' (generate SVG vector graphics), 'vectorize' (convert PNG/JPG to PDF+PPTX vector format). Models: 'flash' (fast), 'flash31' (balanced, default), 'pro' (high quality), 'gptimage' (GPT Image 2, best for detailed illustrations, promo price 2 credits). Returns image URL or download links. After receiving the result, display the imageUrl as an image to the user.",
|
|
24826
24827
|
parameters: Type.Object({
|
|
24827
24828
|
action: Type.String({
|
|
24828
|
-
description: "Operation type: 'smart', 'generate', 'edit', 'style', 'compose', 'iterate', 'critic', 'svg'",
|
|
24829
|
-
enum: ["smart", "generate", "edit", "style", "compose", "iterate", "critic", "svg"]
|
|
24829
|
+
description: "Operation type: 'smart', 'generate', 'edit', 'style', 'compose', 'iterate', 'critic', 'svg', 'vectorize'",
|
|
24830
|
+
enum: ["smart", "generate", "edit", "style", "compose", "iterate", "critic", "svg", "vectorize"]
|
|
24830
24831
|
}),
|
|
24831
24832
|
prompt: Type.String({
|
|
24832
|
-
description: "Description or instruction for the image. Can be empty for 'critic'
|
|
24833
|
+
description: "Description or instruction for the image. Can be empty for 'critic' and 'vectorize' actions. Supports Chinese in 'smart' mode."
|
|
24833
24834
|
}),
|
|
24834
24835
|
model: Type.Optional(
|
|
24835
24836
|
Type.String({
|
|
24836
|
-
description: "Model: 'flash' (fast), 'flash31' (balanced, default), 'pro' (high quality)",
|
|
24837
|
-
enum: ["flash", "flash31", "pro"]
|
|
24837
|
+
description: "Model: 'flash' (fast), 'flash31' (balanced, default), 'pro' (high quality), 'gptimage' (GPT Image 2, promo 2 credits)",
|
|
24838
|
+
enum: ["flash", "flash31", "pro", "gptimage"]
|
|
24838
24839
|
})
|
|
24839
24840
|
),
|
|
24840
24841
|
imageSize: Type.Optional(
|
|
@@ -24861,12 +24862,18 @@ function createSciDrawTool() {
|
|
|
24861
24862
|
description: "Language: 'en' (default), 'zh'",
|
|
24862
24863
|
enum: ["en", "zh"]
|
|
24863
24864
|
})
|
|
24865
|
+
),
|
|
24866
|
+
vectorizeMode: Type.Optional(
|
|
24867
|
+
Type.String({
|
|
24868
|
+
description: "Vectorize quality: 'fast' (default), 'standard', 'premium'. Only for 'vectorize' action.",
|
|
24869
|
+
enum: ["fast", "standard", "premium"]
|
|
24870
|
+
})
|
|
24864
24871
|
)
|
|
24865
24872
|
}),
|
|
24866
24873
|
execute: async (_id, raw) => {
|
|
24867
24874
|
let p = raw, apiKey = getApiKey();
|
|
24868
24875
|
if (!apiKey) return Result.err("no_api_key", "API key not configured");
|
|
24869
|
-
let action = readString(p, "action", { required: !0 }), prompt = readString(p, "prompt") ?? "", needsImages = ["edit", "style", "compose", "iterate", "critic"], images = p.images;
|
|
24876
|
+
let action = readString(p, "action", { required: !0 }), prompt = readString(p, "prompt") ?? "", needsImages = ["edit", "style", "compose", "iterate", "critic", "vectorize"], images = p.images;
|
|
24870
24877
|
if (needsImages.includes(action) && (!images || images.length === 0))
|
|
24871
24878
|
return Result.err("missing_images", `Action '${action}' requires at least one image in the 'images' parameter`);
|
|
24872
24879
|
if (action === "compose" && images && images.length < 2)
|
|
@@ -24881,6 +24888,8 @@ function createSciDrawTool() {
|
|
|
24881
24888
|
stylePreset && (body.stylePreset = stylePreset);
|
|
24882
24889
|
let lang = readString(p, "lang");
|
|
24883
24890
|
lang && (body.lang = lang);
|
|
24891
|
+
let vectorizeMode = readString(p, "vectorizeMode");
|
|
24892
|
+
vectorizeMode && action === "vectorize" && (body.vectorizeMode = vectorizeMode);
|
|
24884
24893
|
try {
|
|
24885
24894
|
let res = await fetch(`${BASE_URL2}/api/proxy/nano/generate`, {
|
|
24886
24895
|
method: "POST",
|
|
@@ -24900,7 +24909,7 @@ function createSciDrawTool() {
|
|
|
24900
24909
|
if (!data.success)
|
|
24901
24910
|
return Result.err("generation_failed", "Image generation failed. Credits have been refunded automatically.");
|
|
24902
24911
|
let result = { action };
|
|
24903
|
-
return data.imageUrl ? result.imageUrl = data.imageUrl : action !== "critic" && action !== "svg" && (result.warning = "Image was generated but imageUrl is empty. This may be a transient issue \u2014 please retry."), data.svgCode && (result.svgCode = data.svgCode), data.svgUrl && (result.svgUrl = data.svgUrl), data.optimizedPrompt && (result.optimizedPrompt = data.optimizedPrompt), data.critique && (result.critique = data.critique), data.creditCost !== void 0 && (result.creditCost = data.creditCost), Result.ok(result);
|
|
24912
|
+
return data.imageUrl ? result.imageUrl = data.imageUrl : action !== "critic" && action !== "svg" && action !== "vectorize" && (result.warning = "Image was generated but imageUrl is empty. This may be a transient issue \u2014 please retry."), data.svgCode && (result.svgCode = data.svgCode), data.svgUrl && (result.svgUrl = data.svgUrl), data.pdfUrl && (result.pdfUrl = data.pdfUrl), data.pptxUrl && (result.pptxUrl = data.pptxUrl), data.optimizedPrompt && (result.optimizedPrompt = data.optimizedPrompt), data.critique && (result.critique = data.critique), data.creditCost !== void 0 && (result.creditCost = data.creditCost), Result.ok(result);
|
|
24904
24913
|
} catch (e) {
|
|
24905
24914
|
return Result.err("request_failed", e instanceof Error ? e.message : String(e));
|
|
24906
24915
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai4scholar",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Multi-source academic literature search, management, and analysis plugin for OpenClaw. Powered by ai4scholar.net.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,16 +24,6 @@
|
|
|
24
24
|
"author": "ai4scholar",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"homepage": "https://ai4scholar.net?src=openclaw",
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "node esbuild.config.mjs",
|
|
29
|
-
"build:tsc": "tsc --noEmit",
|
|
30
|
-
"clean": "rm -rf dist",
|
|
31
|
-
"dev": "tsc --watch --noEmit",
|
|
32
|
-
"dev:link": "pnpm build && openclaw plugins install -l .",
|
|
33
|
-
"dev:unlink": "openclaw plugins uninstall ai4scholar",
|
|
34
|
-
"dev:reload": "pnpm build && pkill -USR1 -f 'openclaw.mjs gateway' || true",
|
|
35
|
-
"prepublishOnly": "pnpm clean && pnpm build"
|
|
36
|
-
},
|
|
37
27
|
"devDependencies": {
|
|
38
28
|
"@sinclair/typebox": "^0.32.0",
|
|
39
29
|
"@types/node": "^20.0.0",
|
|
@@ -49,8 +39,13 @@
|
|
|
49
39
|
"./dist/index.js"
|
|
50
40
|
]
|
|
51
41
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "node esbuild.config.mjs",
|
|
44
|
+
"build:tsc": "tsc --noEmit",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"dev": "tsc --watch --noEmit",
|
|
47
|
+
"dev:link": "pnpm build && openclaw plugins install -l .",
|
|
48
|
+
"dev:unlink": "openclaw plugins uninstall ai4scholar",
|
|
49
|
+
"dev:reload": "pnpm build && pkill -USR1 -f 'openclaw.mjs gateway' || true"
|
|
50
|
+
}
|
|
51
|
+
}
|