@blokkli/editor 2.0.0-alpha.37 → 2.0.0-alpha.38
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/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/modules/agent/index.mjs +75 -35
- package/dist/runtime/editor/components/FlexTextarea/index.d.vue.ts +1 -1
- package/dist/runtime/editor/components/FlexTextarea/index.vue.d.ts +1 -1
- package/dist/runtime/editor/plugins/Sidebar/Detached/index.d.vue.ts +1 -1
- package/dist/runtime/editor/plugins/Sidebar/Detached/index.vue.d.ts +1 -1
- package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +1 -1
- package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import { d as defineCodeTemplate, a as defineFileTemplate, w as withHelper } fro
|
|
|
18
18
|
import { defu, createDefu } from 'defu';
|
|
19
19
|
|
|
20
20
|
const name = "@blokkli/editor";
|
|
21
|
-
const version = "2.0.0-alpha.
|
|
21
|
+
const version = "2.0.0-alpha.38";
|
|
22
22
|
|
|
23
23
|
function sortObjectKeys(obj) {
|
|
24
24
|
if (Array.isArray(obj)) {
|
|
@@ -8,7 +8,7 @@ import { d as defineCodeTemplate } from '../../shared/editor.6D5vApr0.mjs';
|
|
|
8
8
|
import MagicString from 'magic-string';
|
|
9
9
|
import { parse } from 'acorn';
|
|
10
10
|
import { walk } from 'estree-walker-ts';
|
|
11
|
-
import { transformSync } from 'esbuild';
|
|
11
|
+
import { transformSync, buildSync } from 'esbuild';
|
|
12
12
|
|
|
13
13
|
function toImportName(prefix, fileName) {
|
|
14
14
|
const name = fileName.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
@@ -253,27 +253,18 @@ export const toolDefinitions: ServerToolMetadata[]
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const QUERY = "?blokkliAgentTool";
|
|
256
|
-
const
|
|
257
|
-
"
|
|
258
|
-
"
|
|
259
|
-
"
|
|
260
|
-
"
|
|
261
|
-
"
|
|
262
|
-
"
|
|
263
|
-
"
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
|
|
267
|
-
const SERVER_SAFE_IMPORTS = /* @__PURE__ */ new Set([
|
|
268
|
-
"zod",
|
|
269
|
-
"../schemas",
|
|
270
|
-
"#blokkli/agent/app/tools/schemas",
|
|
271
|
-
"../chart_schemas",
|
|
272
|
-
"#blokkli-build/charts-config"
|
|
256
|
+
const PROPERTIES_TO_KEEP = /* @__PURE__ */ new Set([
|
|
257
|
+
"name",
|
|
258
|
+
"description",
|
|
259
|
+
"category",
|
|
260
|
+
"paramsSchema",
|
|
261
|
+
"modes",
|
|
262
|
+
"lazy",
|
|
263
|
+
"volatile",
|
|
264
|
+
"requiredAdapterMethods",
|
|
265
|
+
"requiredFeatures",
|
|
266
|
+
"resolve"
|
|
273
267
|
]);
|
|
274
|
-
function isServerSafeImport(source) {
|
|
275
|
-
return SERVER_SAFE_IMPORTS.has(source);
|
|
276
|
-
}
|
|
277
268
|
function agentToolStripPlugin() {
|
|
278
269
|
return {
|
|
279
270
|
name: "blokkli:agent-tool-strip",
|
|
@@ -299,7 +290,7 @@ function agentToolStripPlugin() {
|
|
|
299
290
|
try {
|
|
300
291
|
rawSource = fs.readFileSync(filePath, "utf-8");
|
|
301
292
|
} catch {
|
|
302
|
-
this.error(`Cannot read agent tool file: ${filePath}`);
|
|
293
|
+
return this.error(`Cannot read agent tool file: ${filePath}`);
|
|
303
294
|
}
|
|
304
295
|
const { code: jsSource } = transformSync(rawSource, {
|
|
305
296
|
loader: "ts",
|
|
@@ -395,25 +386,61 @@ function validateTransformedOutput(output, filePath) {
|
|
|
395
386
|
}
|
|
396
387
|
return null;
|
|
397
388
|
}
|
|
398
|
-
function
|
|
399
|
-
const
|
|
389
|
+
function treeShake(code) {
|
|
390
|
+
const result = buildSync({
|
|
391
|
+
stdin: { contents: code, loader: "js", resolveDir: "/tmp" },
|
|
392
|
+
bundle: true,
|
|
393
|
+
write: false,
|
|
394
|
+
format: "esm",
|
|
395
|
+
target: "esnext",
|
|
396
|
+
treeShaking: true,
|
|
397
|
+
external: ["*"]
|
|
398
|
+
});
|
|
399
|
+
return result.outputFiles[0].text;
|
|
400
|
+
}
|
|
401
|
+
function removeDeadImports(code) {
|
|
402
|
+
const ast = parse(code, {
|
|
400
403
|
sourceType: "module",
|
|
401
404
|
ecmaVersion: "latest"
|
|
402
405
|
});
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
406
|
+
const importRanges = [];
|
|
407
|
+
walk(ast, {
|
|
408
|
+
enter(node) {
|
|
409
|
+
if (node.type === "ImportDeclaration") {
|
|
410
|
+
const n = node;
|
|
411
|
+
importRanges.push({ start: n.start, end: n.end });
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
leave() {
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
418
|
+
walk(ast, {
|
|
419
|
+
enter(node) {
|
|
420
|
+
if (node.type === "Identifier") {
|
|
421
|
+
const n = node;
|
|
422
|
+
const inImport = importRanges.some(
|
|
423
|
+
(r) => n.start >= r.start && n.start < r.end
|
|
424
|
+
);
|
|
425
|
+
if (!inImport) {
|
|
426
|
+
usedIds.add(n.name);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
leave() {
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
const s = new MagicString(code);
|
|
409
434
|
walk(ast, {
|
|
410
435
|
enter(node) {
|
|
411
436
|
if (node.type !== "ImportDeclaration") return;
|
|
412
437
|
const importDecl = node;
|
|
413
|
-
const
|
|
414
|
-
|
|
438
|
+
const hasUsedBinding = (importDecl.specifiers || []).some(
|
|
439
|
+
(spec) => usedIds.has(spec.local.name)
|
|
440
|
+
);
|
|
441
|
+
if (!hasUsedBinding) {
|
|
415
442
|
let removeEnd = importDecl.end;
|
|
416
|
-
if (
|
|
443
|
+
if (code[removeEnd] === "\n") {
|
|
417
444
|
removeEnd++;
|
|
418
445
|
}
|
|
419
446
|
s.remove(importDecl.start, removeEnd);
|
|
@@ -422,6 +449,19 @@ function transformToolSource(source, filePath) {
|
|
|
422
449
|
leave() {
|
|
423
450
|
}
|
|
424
451
|
});
|
|
452
|
+
return s.toString();
|
|
453
|
+
}
|
|
454
|
+
function transformToolSource(source, filePath) {
|
|
455
|
+
const ast = parse(source, {
|
|
456
|
+
sourceType: "module",
|
|
457
|
+
ecmaVersion: "latest"
|
|
458
|
+
});
|
|
459
|
+
const exportInfo = findToolExport(ast);
|
|
460
|
+
if (!exportInfo) {
|
|
461
|
+
return source;
|
|
462
|
+
}
|
|
463
|
+
const s = new MagicString(source);
|
|
464
|
+
const { toolObject, call } = exportInfo;
|
|
425
465
|
for (const prop of toolObject.properties) {
|
|
426
466
|
if (prop.type !== "Property") continue;
|
|
427
467
|
const key = prop.key;
|
|
@@ -431,7 +471,7 @@ function transformToolSource(source, filePath) {
|
|
|
431
471
|
} else if (key.type === "Literal" && typeof key.value === "string") {
|
|
432
472
|
name = key.value;
|
|
433
473
|
}
|
|
434
|
-
if (name &&
|
|
474
|
+
if (name && !PROPERTIES_TO_KEEP.has(name)) {
|
|
435
475
|
const propNode = prop;
|
|
436
476
|
let removeEnd = propNode.end;
|
|
437
477
|
const afterProp = source.substring(removeEnd);
|
|
@@ -444,7 +484,7 @@ function transformToolSource(source, filePath) {
|
|
|
444
484
|
}
|
|
445
485
|
s.overwrite(call.start, toolObject.start, "");
|
|
446
486
|
s.overwrite(toolObject.end, call.end, "");
|
|
447
|
-
const result = s.toString();
|
|
487
|
+
const result = removeDeadImports(treeShake(s.toString()));
|
|
448
488
|
const error = validateTransformedOutput(result, filePath);
|
|
449
489
|
if (error) {
|
|
450
490
|
throw new Error(error);
|
|
@@ -28,8 +28,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
28
28
|
onSubmit?: (() => any) | undefined;
|
|
29
29
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
30
30
|
}>, {
|
|
31
|
-
minHeight: number;
|
|
32
31
|
maxHeight: number;
|
|
32
|
+
minHeight: number;
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const _default: typeof __VLS_export;
|
|
35
35
|
export default _default;
|
|
@@ -28,8 +28,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
28
28
|
onSubmit?: (() => any) | undefined;
|
|
29
29
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
30
30
|
}>, {
|
|
31
|
-
minHeight: number;
|
|
32
31
|
maxHeight: number;
|
|
32
|
+
minHeight: number;
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const _default: typeof __VLS_export;
|
|
35
35
|
export default _default;
|
|
@@ -34,8 +34,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
34
34
|
width: number;
|
|
35
35
|
height: number;
|
|
36
36
|
};
|
|
37
|
-
minWidth: number;
|
|
38
37
|
minHeight: number;
|
|
38
|
+
minWidth: number;
|
|
39
39
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
40
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
41
41
|
declare const _default: typeof __VLS_export;
|
|
@@ -34,8 +34,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
|
34
34
|
width: number;
|
|
35
35
|
height: number;
|
|
36
36
|
};
|
|
37
|
-
minWidth: number;
|
|
38
37
|
minHeight: number;
|
|
38
|
+
minWidth: number;
|
|
39
39
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
40
40
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
41
41
|
declare const _default: typeof __VLS_export;
|
|
@@ -200,9 +200,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
200
200
|
width: number;
|
|
201
201
|
height: number;
|
|
202
202
|
};
|
|
203
|
+
minHeight: number;
|
|
203
204
|
tourText: string;
|
|
204
205
|
minWidth: number;
|
|
205
|
-
minHeight: number;
|
|
206
206
|
region: SidebarRegion;
|
|
207
207
|
tooltipTitle: string;
|
|
208
208
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
@@ -200,9 +200,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
200
200
|
width: number;
|
|
201
201
|
height: number;
|
|
202
202
|
};
|
|
203
|
+
minHeight: number;
|
|
203
204
|
tourText: string;
|
|
204
205
|
minWidth: number;
|
|
205
|
-
minHeight: number;
|
|
206
206
|
region: SidebarRegion;
|
|
207
207
|
tooltipTitle: string;
|
|
208
208
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|