@blokkli/editor 2.0.0-alpha.36 → 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/global/types/blockOptions.d.ts +4 -3
- package/dist/module.d.mts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +71 -4
- package/dist/modules/agent/index.d.mts +1 -1
- package/dist/modules/agent/index.mjs +276 -6
- package/dist/modules/agent/runtime/app/composables/agentProvider.js +31 -14
- package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.d.ts +2 -20
- package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.js +0 -3
- package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/Assistant/index.vue +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/User/index.vue +1 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/DebugGallery/index.vue +1 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.d.vue.ts +1 -0
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue +66 -59
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue.d.ts +1 -0
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/index.vue +10 -12
- package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/de.md +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/en.md +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue +1 -5
- package/dist/modules/agent/runtime/app/features/agent/index.vue +89 -37
- package/dist/modules/agent/runtime/app/helpers/index.d.ts +16 -19
- package/dist/modules/agent/runtime/app/helpers/index.js +22 -46
- package/dist/modules/agent/runtime/app/helpers/pageStructure.js +1 -1
- package/dist/modules/agent/runtime/app/tools/add_content_search_paragraph/index.js +5 -9
- package/dist/modules/agent/runtime/app/tools/add_fragment/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_media_paragraph/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_paragraphs/index.js +2 -3
- package/dist/modules/agent/runtime/app/tools/add_reusable_paragraph/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_template/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/analyze_content/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/analyze_content/index.js +120 -0
- package/dist/modules/agent/runtime/app/tools/check_readability/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/check_readability/index.js +57 -0
- package/dist/modules/agent/runtime/app/tools/duplicate_paragraphs/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/get_all_page_content/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +2 -1
- package/dist/modules/agent/runtime/app/tools/get_content_fields/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +2 -5
- package/dist/modules/agent/runtime/app/tools/get_paragraph_options/index.js +2 -1
- package/dist/modules/agent/runtime/app/tools/get_selected_paragraphs/index.js +2 -3
- package/dist/modules/agent/runtime/app/tools/helpers.d.ts +53 -0
- package/dist/modules/agent/runtime/app/tools/helpers.js +187 -0
- package/dist/modules/agent/runtime/app/tools/move_paragraphs/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/schemas.d.ts +0 -52
- package/dist/modules/agent/runtime/app/tools/schemas.js +0 -187
- package/dist/modules/agent/runtime/app/tools/search_content/index.js +40 -47
- package/dist/modules/agent/runtime/app/tools/set_paragraph_options/index.js +2 -5
- package/dist/modules/agent/runtime/app/types/index.d.ts +0 -61
- package/dist/modules/agent/runtime/server/Session.d.ts +25 -6
- package/dist/modules/agent/runtime/server/Session.js +109 -30
- package/dist/modules/agent/runtime/server/SessionManager.d.ts +3 -0
- package/dist/modules/agent/runtime/server/SessionManager.js +4 -1
- package/dist/modules/agent/runtime/server/agent.js +3 -2
- package/dist/modules/agent/runtime/server/default-skills/fixReadability.d.ts +2 -0
- package/dist/modules/agent/runtime/server/default-skills/fixReadability.js +69 -0
- package/dist/modules/agent/runtime/server/default-system-prompts/page-context.js +28 -0
- package/dist/modules/agent/runtime/server/server-tools/index.d.ts +10 -2
- package/dist/modules/agent/runtime/server/server-tools/index.js +1 -1
- package/dist/modules/agent/runtime/server/server-tools/load_tools/index.js +1 -1
- package/dist/modules/agent/runtime/shared/types.d.ts +46 -11
- package/dist/modules/agent/runtime/shared/types.js +22 -10
- package/dist/modules/charts/index.d.mts +1 -1
- package/dist/modules/charts/index.mjs +21 -7
- package/dist/modules/charts/runtime/blokkli/skills/charts.js +6 -6
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.d.ts +25 -2
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.js +39 -1
- package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.js +24 -17
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.js +11 -19
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.js +2 -4
- package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.js +8 -20
- package/dist/modules/charts/runtime/chartTypes/area.d.ts +6 -1
- package/dist/modules/charts/runtime/chartTypes/bar.d.ts +7 -1
- package/dist/modules/charts/runtime/chartTypes/define.d.ts +1 -1
- package/dist/modules/charts/runtime/chartTypes/donut.d.ts +5 -1
- package/dist/modules/charts/runtime/chartTypes/heatmap.d.ts +3 -1
- package/dist/modules/charts/runtime/chartTypes/index.d.ts +18 -0
- package/dist/modules/charts/runtime/chartTypes/line.d.ts +6 -1
- package/dist/modules/charts/runtime/chartTypes/pie.d.ts +4 -1
- package/dist/modules/charts/runtime/chartTypes/radar.d.ts +6 -1
- package/dist/modules/charts/runtime/chartTypes/radialBar.d.ts +5 -1
- package/dist/modules/charts/runtime/chartTypes/shared.d.ts +20 -5
- package/dist/modules/charts/runtime/chartTypes/types.d.ts +6 -6
- package/dist/modules/charts/runtime/components/ChartRenderer/index.d.vue.ts +145 -2
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue +2 -2
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue.d.ts +145 -2
- package/dist/modules/charts/runtime/components/index.d.ts +1 -0
- package/dist/modules/charts/runtime/components/index.js +1 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.d.vue.ts +3 -2
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue.d.ts +3 -2
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue +1 -2
- package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue +1 -1
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.d.vue.ts +2 -0
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue +35 -13
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue.d.ts +2 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.d.vue.ts +1 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue +9 -3
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue.d.ts +1 -0
- package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.js +1 -1
- package/dist/modules/charts/runtime/features/charts/index.vue +6 -6
- package/dist/modules/charts/runtime/helpers/index.d.ts +25 -0
- package/dist/modules/charts/runtime/helpers/index.js +63 -0
- package/dist/modules/charts/runtime/types.d.ts +10 -28
- package/dist/modules/charts/runtime/types.js +0 -64
- package/dist/modules/drupal/index.d.mts +1 -1
- package/dist/modules/drupal/runtime/adapter/index.d.ts +3 -1
- package/dist/modules/drupal/runtime/adapter/index.js +4 -4
- package/dist/modules/table-of-contents/index.d.mts +1 -1
- package/dist/runtime/components/BlokkliItem.vue +1 -1
- package/dist/runtime/composables/defineBlokkli.js +1 -1
- package/dist/runtime/editor/components/AnimationCanvas/index.vue +13 -7
- package/dist/runtime/editor/components/Banner/index.d.vue.ts +1 -0
- package/dist/runtime/editor/components/Banner/index.vue +1 -1
- package/dist/runtime/editor/components/Banner/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/DropdownItem/index.d.vue.ts +1 -0
- package/dist/runtime/editor/components/DropdownItem/index.vue +3 -2
- package/dist/runtime/editor/components/DropdownItem/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/EditProvider.vue +7 -4
- package/dist/runtime/editor/components/FlexTextarea/index.d.vue.ts +4 -0
- package/dist/runtime/editor/components/FlexTextarea/index.vue +24 -101
- package/dist/runtime/editor/components/FlexTextarea/index.vue.d.ts +4 -0
- package/dist/runtime/editor/components/NestedEditorOverlay/index.vue +28 -9
- package/dist/runtime/editor/components/Popup/index.d.vue.ts +30 -0
- package/dist/runtime/editor/components/Popup/index.vue +82 -0
- package/dist/runtime/editor/components/Popup/index.vue.d.ts +30 -0
- package/dist/runtime/editor/components/Resizable/index.vue +4 -1
- package/dist/runtime/editor/components/Toolbar/index.vue +107 -6
- package/dist/runtime/editor/components/index.d.ts +4 -3
- package/dist/runtime/editor/components/index.js +6 -4
- package/dist/runtime/editor/composables/defineDropAreas.js +3 -3
- package/dist/runtime/editor/composables/defineDropHandler.d.ts +3 -0
- package/dist/runtime/editor/composables/defineDropHandler.js +10 -0
- package/dist/runtime/editor/composables/index.d.ts +1 -0
- package/dist/runtime/editor/composables/index.js +1 -0
- package/dist/runtime/editor/css/output.css +1 -1
- package/dist/runtime/editor/events/index.d.ts +9 -0
- package/dist/runtime/editor/features/add-list/index.vue +58 -1
- package/dist/runtime/editor/features/analyze/Main.d.vue.ts +3 -2
- package/dist/runtime/editor/features/analyze/Main.vue +28 -44
- package/dist/runtime/editor/features/analyze/Main.vue.d.ts +3 -2
- package/dist/runtime/editor/features/analyze/analyzers/readability.js +65 -0
- package/dist/runtime/editor/features/analyze/analyzers/types.d.ts +19 -0
- package/dist/runtime/editor/features/analyze/index.vue +18 -15
- package/dist/runtime/editor/features/clipboard/DropElement/Video.d.vue.ts +8 -0
- package/dist/runtime/editor/features/clipboard/{List/Item → DropElement}/Video.vue +1 -5
- package/dist/runtime/editor/features/clipboard/DropElement/Video.vue.d.ts +8 -0
- package/dist/runtime/editor/features/clipboard/DropElement/helpers.d.ts +1 -0
- package/dist/runtime/editor/features/clipboard/DropElement/helpers.js +14 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.d.vue.ts +16 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.vue +97 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.vue.d.ts +16 -0
- package/dist/runtime/editor/features/clipboard/helpers.d.ts +15 -0
- package/dist/runtime/editor/features/clipboard/helpers.js +62 -0
- package/dist/runtime/editor/features/clipboard/index.vue +585 -337
- package/dist/runtime/editor/features/clipboard/types.d.ts +14 -2
- package/dist/runtime/editor/features/dragging-overlay/DragItems/index.vue +17 -5
- package/dist/runtime/editor/features/dragging-overlay/Renderer/index.vue +2 -2
- package/dist/runtime/editor/features/dragging-overlay/index.vue +125 -219
- package/dist/runtime/editor/features/editable-field/Overlay/Plaintext/index.vue +4 -4
- package/dist/runtime/editor/features/editable-field/Overlay/index.vue +6 -0
- package/dist/runtime/editor/features/library/index.vue +14 -0
- package/dist/runtime/editor/features/media-library/index.vue +32 -1
- package/dist/runtime/editor/features/options/Form/ComplexType/index.d.vue.ts +11 -0
- package/dist/runtime/editor/features/options/Form/ComplexType/index.vue +36 -0
- package/dist/runtime/editor/features/options/Form/ComplexType/index.vue.d.ts +11 -0
- package/dist/runtime/editor/features/options/Form/Item.d.vue.ts +3 -2
- package/dist/runtime/editor/features/options/Form/Item.vue +10 -2
- package/dist/runtime/editor/features/options/Form/Item.vue.d.ts +3 -2
- package/dist/runtime/editor/features/options/Form/index.vue +5 -0
- package/dist/runtime/editor/features/search/index.vue +25 -1
- package/dist/runtime/editor/features/structure/index.vue +25 -1
- package/dist/runtime/editor/features/tour/index.vue +22 -12
- package/dist/runtime/editor/helpers/clipboardData/index.d.ts +11 -0
- package/dist/runtime/editor/helpers/clipboardData/index.js +157 -0
- package/dist/runtime/editor/helpers/options/index.js +5 -0
- package/dist/runtime/editor/icons/svg/stars.svg +5 -1
- package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +13 -2
- package/dist/runtime/editor/plugins/Sidebar/index.vue +4 -2
- package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +13 -2
- package/dist/runtime/editor/providers/analyze.d.ts +43 -0
- package/dist/runtime/editor/providers/analyze.js +78 -0
- package/dist/runtime/editor/providers/animation.d.ts +4 -0
- package/dist/runtime/editor/providers/animation.js +6 -0
- package/dist/runtime/editor/providers/dragdrop.d.ts +55 -0
- package/dist/runtime/editor/providers/dragdrop.js +37 -0
- package/dist/runtime/editor/providers/storage.js +15 -0
- package/dist/runtime/editor/providers/ui.d.ts +6 -0
- package/dist/runtime/editor/providers/ui.js +19 -0
- package/dist/runtime/editor/translations/de.json +73 -61
- package/dist/runtime/editor/translations/fr.json +67 -55
- package/dist/runtime/editor/translations/gsw_CH.json +71 -59
- package/dist/runtime/editor/translations/it.json +67 -55
- package/dist/runtime/editor/types/app.d.ts +4 -2
- package/dist/runtime/editor/types/draggable.d.ts +1 -0
- package/dist/runtime/editor/types/ui.d.ts +1 -1
- package/dist/runtime/helpers/injections.d.ts +1 -1
- package/dist/runtime/types/blockOptions.d.ts +2 -1
- package/dist/runtime/types/definitions.d.ts +4 -0
- package/dist/shared/{editor.CWQIFIEQ.d.mts → editor.BdBm1Z7C.d.mts} +12 -0
- package/dist/types.d.mts +1 -1
- package/package.json +5 -3
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.d.vue.ts +0 -3
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue +0 -29
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue.d.ts +0 -3
- package/dist/runtime/editor/features/clipboard/List/Item/File.d.vue.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/File.vue +0 -60
- package/dist/runtime/editor/features/clipboard/List/Item/File.vue.d.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/Video.d.vue.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/Video.vue.d.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/index.d.vue.ts +0 -11
- package/dist/runtime/editor/features/clipboard/List/index.vue +0 -72
- package/dist/runtime/editor/features/clipboard/List/index.vue.d.ts +0 -11
- package/dist/runtime/editor/features/tour/Popup/index.d.vue.ts +0 -9
- package/dist/runtime/editor/features/tour/Popup/index.vue +0 -34
- package/dist/runtime/editor/features/tour/Popup/index.vue.d.ts +0 -9
- package/dist/runtime/editor/providers/dropArea.d.ts +0 -48
- package/dist/runtime/editor/providers/dropArea.js +0 -22
|
@@ -344,14 +344,15 @@ type DefinitionOptionRadiosBase<Icon extends string = string> = {
|
|
|
344
344
|
*/
|
|
345
345
|
group?: string;
|
|
346
346
|
} & (DefinitionOptionRadiosColors | DefinitionOptionRadiosGrid | DefinitionOptionRadiosRadios | DefinitionOptionRadiosIconsBase<Icon>);
|
|
347
|
-
type
|
|
347
|
+
type DefinitionOptionJsonBase<DataType extends string = string> = {
|
|
348
348
|
type: 'json';
|
|
349
349
|
label: string;
|
|
350
350
|
default: string;
|
|
351
|
+
dataType?: DataType;
|
|
351
352
|
description?: string;
|
|
352
353
|
group?: string;
|
|
353
354
|
};
|
|
354
|
-
export type BlockOptionDefinitionBase<Icon extends string = string> =
|
|
355
|
+
export type BlockOptionDefinitionBase<Icon extends string = string, DataType extends string = string> = DefinitionOptionJsonBase<DataType> | DefinitionOptionColor | DefinitionOptionCheckbox | DefinitionOptionCheckboxes | DefinitionOptionRadiosBase<Icon> | DefinitionOptionText | DefinitionOptionRange | DefinitionOptionNumber | DefinitionOptionDateTimeLocal;
|
|
355
356
|
/**
|
|
356
357
|
* Runtime block option array with validation data.
|
|
357
358
|
* The third element varies by option type:
|
|
@@ -360,7 +361,7 @@ export type BlockOptionDefinitionBase<Icon extends string = string> = Definition
|
|
|
360
361
|
* - datetime-local: optional [min?, max?] tuple
|
|
361
362
|
* - other types: no third element
|
|
362
363
|
*/
|
|
363
|
-
export type RuntimeBlockOptionArray = ['text', string] | ['json', string] | ['checkbox', boolean] | ['color', `#${string}`] | ['radios', string, string[]] | ['checkboxes', string[], string[]] | ['number', number, [number, number]] | ['range', number, [number, number]] | ['datetime-local', string | undefined] | [
|
|
364
|
+
export type RuntimeBlockOptionArray = ['text', string] | ['json', string] | ['json', string, string] | ['checkbox', boolean] | ['color', `#${string}`] | ['radios', string, string[]] | ['checkboxes', string[], string[]] | ['number', number, [number, number]] | ['range', number, [number, number]] | ['datetime-local', string | undefined] | [
|
|
364
365
|
'datetime-local',
|
|
365
366
|
string | undefined,
|
|
366
367
|
[
|
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NuxtModule } from 'nuxt/schema';
|
|
2
|
-
import { M as ModuleOptions } from './shared/editor.
|
|
3
|
-
export { a as ModuleHooks } from './shared/editor.
|
|
2
|
+
import { M as ModuleOptions } from './shared/editor.BdBm1Z7C.mjs';
|
|
3
|
+
export { a as ModuleHooks } from './shared/editor.BdBm1Z7C.mjs';
|
|
4
4
|
import 'consola';
|
|
5
5
|
import '../dist/global/types/definitions.js';
|
|
6
6
|
import '../dist/global/types/theme.js';
|
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)) {
|
|
@@ -1270,6 +1270,7 @@ class ModuleContext {
|
|
|
1270
1270
|
templateContents = /* @__PURE__ */ new Map();
|
|
1271
1271
|
adapterExtensions = [];
|
|
1272
1272
|
featureFragments = /* @__PURE__ */ new Set();
|
|
1273
|
+
complexOptionTypes = /* @__PURE__ */ new Map();
|
|
1273
1274
|
collectors = [];
|
|
1274
1275
|
addFeatureFragment(name) {
|
|
1275
1276
|
if (this.featureFragments.has(name)) {
|
|
@@ -1280,6 +1281,17 @@ class ModuleContext {
|
|
|
1280
1281
|
getFeatureFragmentNames() {
|
|
1281
1282
|
return [...this.featureFragments.values()];
|
|
1282
1283
|
}
|
|
1284
|
+
registerComplexOptionType(def) {
|
|
1285
|
+
if (this.complexOptionTypes.has(def.id)) {
|
|
1286
|
+
throw new Error(
|
|
1287
|
+
`A complex option type with id "${def.id}" already exists.`
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1290
|
+
this.complexOptionTypes.set(def.id, def);
|
|
1291
|
+
}
|
|
1292
|
+
getComplexOptionTypes() {
|
|
1293
|
+
return [...this.complexOptionTypes.values()];
|
|
1294
|
+
}
|
|
1283
1295
|
registerAdapterExtension(namespace, path) {
|
|
1284
1296
|
if (this.adapterExtensions.some((e) => e.namespace === namespace)) {
|
|
1285
1297
|
throw new Error(`Duplicate adapter extension namespace: ${namespace}`);
|
|
@@ -1516,6 +1528,7 @@ const USED_MATERIAL_ICONS = [
|
|
|
1516
1528
|
"bk_mdi_chevron_backward",
|
|
1517
1529
|
"bk_mdi_chevron_forward",
|
|
1518
1530
|
"bk_mdi_close",
|
|
1531
|
+
"bk_mdi_collapse_all",
|
|
1519
1532
|
"bk_mdi_comment",
|
|
1520
1533
|
"bk_mdi_construction",
|
|
1521
1534
|
"bk_mdi_content_copy",
|
|
@@ -1529,7 +1542,9 @@ const USED_MATERIAL_ICONS = [
|
|
|
1529
1542
|
"bk_mdi_drag_pan",
|
|
1530
1543
|
"bk_mdi_edit",
|
|
1531
1544
|
"bk_mdi_exit_to_app",
|
|
1545
|
+
"bk_mdi_expand_all",
|
|
1532
1546
|
"bk_mdi_extension",
|
|
1547
|
+
"bk_mdi_forum",
|
|
1533
1548
|
"bk_mdi_function",
|
|
1534
1549
|
"bk_mdi_grid_view",
|
|
1535
1550
|
"bk_mdi_grid_view-fill",
|
|
@@ -1546,7 +1561,6 @@ const USED_MATERIAL_ICONS = [
|
|
|
1546
1561
|
"bk_mdi_menu",
|
|
1547
1562
|
"bk_mdi_mobile",
|
|
1548
1563
|
"bk_mdi_mobile_rotate",
|
|
1549
|
-
"bk_mdi_more_horiz",
|
|
1550
1564
|
"bk_mdi_newspaper",
|
|
1551
1565
|
"bk_mdi_open_in_new",
|
|
1552
1566
|
"bk_mdi_palette",
|
|
@@ -3013,6 +3027,9 @@ function toRuntimeOptionArray(option) {
|
|
|
3013
3027
|
} else if (option.type === "color") {
|
|
3014
3028
|
return [option.type, option.default];
|
|
3015
3029
|
} else if (option.type === "json") {
|
|
3030
|
+
if (option.dataType) {
|
|
3031
|
+
return [option.type, option.default, option.dataType];
|
|
3032
|
+
}
|
|
3016
3033
|
return [option.type, option.default];
|
|
3017
3034
|
}
|
|
3018
3035
|
return [option.type, option.default];
|
|
@@ -3608,6 +3625,54 @@ ${iconNames.map((name) => ` | '${name}'`).join("\n")}
|
|
|
3608
3625
|
`;
|
|
3609
3626
|
});
|
|
3610
3627
|
|
|
3628
|
+
const complexOptionTypes = defineCodeTemplate(
|
|
3629
|
+
"complex-option-types",
|
|
3630
|
+
(ctx) => {
|
|
3631
|
+
const types = ctx.getComplexOptionTypes();
|
|
3632
|
+
if (types.length === 0) {
|
|
3633
|
+
return `export const COMPLEX_OPTION_TYPES = {}`;
|
|
3634
|
+
}
|
|
3635
|
+
const entries = types.map(
|
|
3636
|
+
(t) => ` '${t.id}': {
|
|
3637
|
+
editorComponent: defineAsyncComponent(() => import('${ctx.helper.toModuleBuildRelative(t.editorComponentPath)}')),
|
|
3638
|
+
editorButtonLabel: '${t.editorButtonLabel}',
|
|
3639
|
+
editorIcon: '${t.editorIcon}',
|
|
3640
|
+
}`
|
|
3641
|
+
).join(",\n");
|
|
3642
|
+
return `import { defineAsyncComponent } from 'vue'
|
|
3643
|
+
|
|
3644
|
+
export const COMPLEX_OPTION_TYPES = {
|
|
3645
|
+
${entries}
|
|
3646
|
+
}`;
|
|
3647
|
+
},
|
|
3648
|
+
(ctx) => {
|
|
3649
|
+
const types = ctx.getComplexOptionTypes();
|
|
3650
|
+
if (types.length === 0) {
|
|
3651
|
+
return `export interface ComplexOptionTypeMap {}
|
|
3652
|
+
export const COMPLEX_OPTION_TYPES: Record<string, never>`;
|
|
3653
|
+
}
|
|
3654
|
+
const imports = types.map(
|
|
3655
|
+
(t) => `import type { ${t.typeName} } from '${ctx.helper.toModuleBuildRelative(t.typePath)}'`
|
|
3656
|
+
).join("\n");
|
|
3657
|
+
const entries = types.map((t) => ` '${t.id}': ${t.typeName}`).join("\n");
|
|
3658
|
+
return `${imports}
|
|
3659
|
+
import type { BlokkliIcon } from './icons'
|
|
3660
|
+
|
|
3661
|
+
export interface ComplexOptionTypeMap {
|
|
3662
|
+
${entries}
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
export const COMPLEX_OPTION_TYPES: Record<string, {
|
|
3666
|
+
editorComponent: import('vue').Component
|
|
3667
|
+
editorButtonLabel: string
|
|
3668
|
+
editorIcon: BlokkliIcon
|
|
3669
|
+
}>`;
|
|
3670
|
+
},
|
|
3671
|
+
{
|
|
3672
|
+
write: true
|
|
3673
|
+
}
|
|
3674
|
+
);
|
|
3675
|
+
|
|
3611
3676
|
const TEMPLATES = [
|
|
3612
3677
|
icons,
|
|
3613
3678
|
features,
|
|
@@ -3629,7 +3694,8 @@ const TEMPLATES = [
|
|
|
3629
3694
|
chunkGroup,
|
|
3630
3695
|
chunkEditing,
|
|
3631
3696
|
importMeta,
|
|
3632
|
-
materialIcons
|
|
3697
|
+
materialIcons,
|
|
3698
|
+
complexOptionTypes
|
|
3633
3699
|
];
|
|
3634
3700
|
|
|
3635
3701
|
class CollectedFeatureFile extends CollectedFile {
|
|
@@ -3872,7 +3938,8 @@ const module$1 = defineNuxtModule({
|
|
|
3872
3938
|
);
|
|
3873
3939
|
const app = {
|
|
3874
3940
|
helper,
|
|
3875
|
-
context
|
|
3941
|
+
context,
|
|
3942
|
+
$t: (key, _defaultText) => key
|
|
3876
3943
|
};
|
|
3877
3944
|
for (const module of blokkliModules) {
|
|
3878
3945
|
await module.init.setup(app, module.options);
|
|
@@ -5,6 +5,10 @@ import { d as defineBlokkliModule } from '../../shared/editor.CGf7C_0M.mjs';
|
|
|
5
5
|
import * as fs from 'node:fs';
|
|
6
6
|
import { C as Collector, a as CollectedFile } from '../../shared/editor.BFIzNSQM.mjs';
|
|
7
7
|
import { d as defineCodeTemplate } from '../../shared/editor.6D5vApr0.mjs';
|
|
8
|
+
import MagicString from 'magic-string';
|
|
9
|
+
import { parse } from 'acorn';
|
|
10
|
+
import { walk } from 'estree-walker-ts';
|
|
11
|
+
import { transformSync, buildSync } from 'esbuild';
|
|
8
12
|
|
|
9
13
|
function toImportName(prefix, fileName) {
|
|
10
14
|
const name = fileName.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
@@ -131,7 +135,7 @@ function createClientTemplate(toolCollector, promptCollector, options) {
|
|
|
131
135
|
);
|
|
132
136
|
exports$1.push(`export const models = ${JSON.stringify(options.models)}`);
|
|
133
137
|
exports$1.push(
|
|
134
|
-
`export const agentName = ${JSON.stringify(options.agentName ?? "
|
|
138
|
+
`export const agentName = ${JSON.stringify(options.agentName ?? "Superbl\xF6kkli")}`
|
|
135
139
|
);
|
|
136
140
|
exports$1.push(
|
|
137
141
|
`export const hasWebFetch = ${JSON.stringify(!!options.allowedFetchOrigins)}`
|
|
@@ -144,10 +148,10 @@ function createClientTemplate(toolCollector, promptCollector, options) {
|
|
|
144
148
|
return parts.join("\n\n") + "\n";
|
|
145
149
|
},
|
|
146
150
|
() => {
|
|
147
|
-
return `import type {
|
|
151
|
+
return `import type { McpToolDefinition, AgentPromptItem } from '#blokkli/agent/app/types'
|
|
148
152
|
import type { AgentModelDefinition } from '#blokkli/agent/shared/types'
|
|
149
153
|
|
|
150
|
-
export const mcpTools:
|
|
154
|
+
export const mcpTools: McpToolDefinition[]
|
|
151
155
|
export const agentPrompts: AgentPromptItem[]
|
|
152
156
|
export const defaultPrompts: string[]
|
|
153
157
|
export const agentName: string
|
|
@@ -166,7 +170,8 @@ function createServerTemplate(options) {
|
|
|
166
170
|
skillsCollector,
|
|
167
171
|
skillsTypesPath,
|
|
168
172
|
systemPromptCollector,
|
|
169
|
-
systemPromptTypesPath
|
|
173
|
+
systemPromptTypesPath,
|
|
174
|
+
mcpToolsCollector
|
|
170
175
|
} = options;
|
|
171
176
|
const { allowedFetchOrigins, provider, models } = moduleOptions;
|
|
172
177
|
return defineCodeTemplate(
|
|
@@ -198,6 +203,15 @@ function createServerTemplate(options) {
|
|
|
198
203
|
const systemPromptsExport = systemPrompts.length === 0 ? `export const systemPrompts = []` : `export const systemPrompts = [
|
|
199
204
|
${systemPrompts.map((sp) => sp.importName).join(",\n ")}
|
|
200
205
|
]`;
|
|
206
|
+
const tools = mcpToolsCollector.getItems();
|
|
207
|
+
for (const tool of tools) {
|
|
208
|
+
imports.push(
|
|
209
|
+
`import ${tool.importName} from '${rel(tool.filePath)}?blokkliAgentTool'`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
const toolDefinitionsExport = tools.length === 0 ? `export const toolDefinitions = []` : `export const toolDefinitions = [
|
|
213
|
+
${tools.map((t) => t.importName).join(",\n ")},
|
|
214
|
+
].filter(v => v !== null)`;
|
|
201
215
|
const originsJson = JSON.stringify(allowedFetchOrigins, null, 2);
|
|
202
216
|
return `${imports.join("\n")}
|
|
203
217
|
|
|
@@ -211,6 +225,8 @@ export const debugPrompt = ${!!moduleOptions.debugPrompt}
|
|
|
211
225
|
${skillsExport}
|
|
212
226
|
|
|
213
227
|
${systemPromptsExport}
|
|
228
|
+
|
|
229
|
+
${toolDefinitionsExport}
|
|
214
230
|
`;
|
|
215
231
|
},
|
|
216
232
|
(ctx) => {
|
|
@@ -218,7 +234,7 @@ ${systemPromptsExport}
|
|
|
218
234
|
return `import type { AIProvider } from '${rel(providersPath)}/types'
|
|
219
235
|
import type { SkillDefinition } from '${rel(skillsTypesPath)}'
|
|
220
236
|
import type { SystemPromptDefinition } from '${rel(systemPromptTypesPath)}'
|
|
221
|
-
import type { AgentModelDefinition } from '${rel(sharedTypesPath)}'
|
|
237
|
+
import type { AgentModelDefinition, ServerToolMetadata } from '${rel(sharedTypesPath)}'
|
|
222
238
|
|
|
223
239
|
export const allowedFetchOrigins: string[]
|
|
224
240
|
export const provider: AIProvider
|
|
@@ -226,6 +242,7 @@ export const models: AgentModelDefinition[]
|
|
|
226
242
|
export const debugPrompt: boolean
|
|
227
243
|
export const skills: SkillDefinition[]
|
|
228
244
|
export const systemPrompts: SystemPromptDefinition[]
|
|
245
|
+
export const toolDefinitions: ServerToolMetadata[]
|
|
229
246
|
`;
|
|
230
247
|
},
|
|
231
248
|
{
|
|
@@ -235,6 +252,246 @@ export const systemPrompts: SystemPromptDefinition[]
|
|
|
235
252
|
);
|
|
236
253
|
}
|
|
237
254
|
|
|
255
|
+
const QUERY = "?blokkliAgentTool";
|
|
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"
|
|
267
|
+
]);
|
|
268
|
+
function agentToolStripPlugin() {
|
|
269
|
+
return {
|
|
270
|
+
name: "blokkli:agent-tool-strip",
|
|
271
|
+
resolveId(source, importer) {
|
|
272
|
+
if (!source.includes(QUERY)) return null;
|
|
273
|
+
const cleanPath = source.replace(QUERY, "");
|
|
274
|
+
let resolved;
|
|
275
|
+
if (importer && (cleanPath.startsWith(".") || cleanPath.startsWith("/"))) {
|
|
276
|
+
const importerDir = path.dirname(importer);
|
|
277
|
+
resolved = path.resolve(importerDir, cleanPath);
|
|
278
|
+
} else {
|
|
279
|
+
resolved = cleanPath;
|
|
280
|
+
}
|
|
281
|
+
if (!fs.existsSync(resolved) && fs.existsSync(resolved + ".ts")) {
|
|
282
|
+
resolved = resolved + ".ts";
|
|
283
|
+
}
|
|
284
|
+
return resolved + QUERY;
|
|
285
|
+
},
|
|
286
|
+
load(id) {
|
|
287
|
+
if (!id.includes(QUERY)) return null;
|
|
288
|
+
const filePath = id.replace(QUERY, "");
|
|
289
|
+
let rawSource;
|
|
290
|
+
try {
|
|
291
|
+
rawSource = fs.readFileSync(filePath, "utf-8");
|
|
292
|
+
} catch {
|
|
293
|
+
return this.error(`Cannot read agent tool file: ${filePath}`);
|
|
294
|
+
}
|
|
295
|
+
const { code: jsSource } = transformSync(rawSource, {
|
|
296
|
+
loader: "ts",
|
|
297
|
+
format: "esm",
|
|
298
|
+
target: "esnext"
|
|
299
|
+
});
|
|
300
|
+
return transformToolSource(jsSource, filePath);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function findToolExport(ast) {
|
|
305
|
+
let result = null;
|
|
306
|
+
walk(ast, {
|
|
307
|
+
enter(node) {
|
|
308
|
+
if (result) return;
|
|
309
|
+
let callExpr = null;
|
|
310
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
311
|
+
const decl = node.declaration;
|
|
312
|
+
if (decl?.type === "CallExpression" && decl.callee?.type === "Identifier" && decl.callee.name === "defineBlokkliAgentTool") {
|
|
313
|
+
callExpr = decl;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (node.type === "VariableDeclarator") {
|
|
317
|
+
const init = node.init;
|
|
318
|
+
if (init?.type === "CallExpression" && init.callee?.type === "Identifier" && init.callee.name === "defineBlokkliAgentTool") {
|
|
319
|
+
callExpr = init;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (!callExpr) return;
|
|
323
|
+
const arg = callExpr.arguments[0];
|
|
324
|
+
if (arg?.type !== "ObjectExpression") return;
|
|
325
|
+
const toolObject = arg;
|
|
326
|
+
result = { toolObject, call: callExpr };
|
|
327
|
+
},
|
|
328
|
+
leave() {
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
const REQUIRED_PROPERTIES = /* @__PURE__ */ new Set([
|
|
334
|
+
"name",
|
|
335
|
+
"description",
|
|
336
|
+
"category",
|
|
337
|
+
"paramsSchema"
|
|
338
|
+
]);
|
|
339
|
+
function validateTransformedOutput(output, filePath) {
|
|
340
|
+
let ast;
|
|
341
|
+
try {
|
|
342
|
+
ast = parse(output, {
|
|
343
|
+
sourceType: "module",
|
|
344
|
+
ecmaVersion: "latest"
|
|
345
|
+
});
|
|
346
|
+
} catch (e) {
|
|
347
|
+
return `Transformed output is not valid JavaScript${filePath ? ` (${filePath})` : ""}: ${e}`;
|
|
348
|
+
}
|
|
349
|
+
let exportedObject = null;
|
|
350
|
+
walk(ast, {
|
|
351
|
+
enter(node) {
|
|
352
|
+
if (exportedObject) return;
|
|
353
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
354
|
+
const decl = node.declaration;
|
|
355
|
+
if (decl?.type === "ObjectExpression") {
|
|
356
|
+
exportedObject = decl;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (node.type === "VariableDeclarator") {
|
|
360
|
+
const id = node.id;
|
|
361
|
+
const init = node.init;
|
|
362
|
+
if (id?.type === "Identifier" && id.name === "stdin_default" && init?.type === "ObjectExpression") {
|
|
363
|
+
exportedObject = init;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
leave() {
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
if (!exportedObject) {
|
|
371
|
+
return `No default-exported object found in transformed output${filePath ? ` (${filePath})` : ""}`;
|
|
372
|
+
}
|
|
373
|
+
const foundProps = /* @__PURE__ */ new Set();
|
|
374
|
+
for (const prop of exportedObject.properties) {
|
|
375
|
+
if (prop.type !== "Property") continue;
|
|
376
|
+
const key = prop.key;
|
|
377
|
+
if (key.type === "Identifier") {
|
|
378
|
+
foundProps.add(key.name);
|
|
379
|
+
} else if (key.type === "Literal" && typeof key.value === "string") {
|
|
380
|
+
foundProps.add(key.value);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const missing = [...REQUIRED_PROPERTIES].filter((p) => !foundProps.has(p));
|
|
384
|
+
if (missing.length > 0) {
|
|
385
|
+
return `Transformed tool output is missing required properties: ${missing.join(", ")}${filePath ? ` (${filePath})` : ""}`;
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
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, {
|
|
403
|
+
sourceType: "module",
|
|
404
|
+
ecmaVersion: "latest"
|
|
405
|
+
});
|
|
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);
|
|
434
|
+
walk(ast, {
|
|
435
|
+
enter(node) {
|
|
436
|
+
if (node.type !== "ImportDeclaration") return;
|
|
437
|
+
const importDecl = node;
|
|
438
|
+
const hasUsedBinding = (importDecl.specifiers || []).some(
|
|
439
|
+
(spec) => usedIds.has(spec.local.name)
|
|
440
|
+
);
|
|
441
|
+
if (!hasUsedBinding) {
|
|
442
|
+
let removeEnd = importDecl.end;
|
|
443
|
+
if (code[removeEnd] === "\n") {
|
|
444
|
+
removeEnd++;
|
|
445
|
+
}
|
|
446
|
+
s.remove(importDecl.start, removeEnd);
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
leave() {
|
|
450
|
+
}
|
|
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;
|
|
465
|
+
for (const prop of toolObject.properties) {
|
|
466
|
+
if (prop.type !== "Property") continue;
|
|
467
|
+
const key = prop.key;
|
|
468
|
+
let name = null;
|
|
469
|
+
if (key.type === "Identifier") {
|
|
470
|
+
name = key.name;
|
|
471
|
+
} else if (key.type === "Literal" && typeof key.value === "string") {
|
|
472
|
+
name = key.value;
|
|
473
|
+
}
|
|
474
|
+
if (name && !PROPERTIES_TO_KEEP.has(name)) {
|
|
475
|
+
const propNode = prop;
|
|
476
|
+
let removeEnd = propNode.end;
|
|
477
|
+
const afterProp = source.substring(removeEnd);
|
|
478
|
+
const commaMatch = afterProp.match(/^\s*,/);
|
|
479
|
+
if (commaMatch) {
|
|
480
|
+
removeEnd += commaMatch[0].length;
|
|
481
|
+
}
|
|
482
|
+
s.remove(propNode.start, removeEnd);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
s.overwrite(call.start, toolObject.start, "");
|
|
486
|
+
s.overwrite(toolObject.end, call.end, "");
|
|
487
|
+
const result = removeDeadImports(treeShake(s.toString()));
|
|
488
|
+
const error = validateTransformedOutput(result, filePath);
|
|
489
|
+
if (error) {
|
|
490
|
+
throw new Error(error);
|
|
491
|
+
}
|
|
492
|
+
return result;
|
|
493
|
+
}
|
|
494
|
+
|
|
238
495
|
const AGENT_ROUTE = "/api/blokkli/agent";
|
|
239
496
|
const FETCH_ROUTE = "/api/blokkli/agent/fetch";
|
|
240
497
|
const index = defineBlokkliModule({
|
|
@@ -386,7 +643,8 @@ export default defineNuxtConfig({
|
|
|
386
643
|
systemPromptCollector,
|
|
387
644
|
systemPromptTypesPath: moduleResolver.resolve(
|
|
388
645
|
"./runtime/server/system-prompts/types"
|
|
389
|
-
)
|
|
646
|
+
),
|
|
647
|
+
mcpToolsCollector: mcpTools
|
|
390
648
|
})
|
|
391
649
|
);
|
|
392
650
|
addServerHandler({
|
|
@@ -412,6 +670,18 @@ export default defineNuxtConfig({
|
|
|
412
670
|
nitroConfig.typescript.tsConfig.include ||= [];
|
|
413
671
|
nitroConfig.typescript.tsConfig.include.push(relativeSkillsDir);
|
|
414
672
|
nitroConfig.typescript.tsConfig.include.push(relativeSystemPromptsDir);
|
|
673
|
+
nitroConfig.rollupConfig ||= {};
|
|
674
|
+
nitroConfig.rollupConfig.plugins ||= [];
|
|
675
|
+
nitroConfig.rollupConfig.plugins.push(
|
|
676
|
+
agentToolStripPlugin()
|
|
677
|
+
);
|
|
678
|
+
nitroConfig.alias ||= {};
|
|
679
|
+
nitroConfig.alias["#blokkli/agent/app/tools/schemas"] = moduleResolver.resolve("./runtime/app/tools/schemas");
|
|
680
|
+
for (const [key, value] of Object.entries(nuxt.options.alias)) {
|
|
681
|
+
if (key.startsWith("#blokkli/") && !nitroConfig.alias[key]) {
|
|
682
|
+
nitroConfig.alias[key] = value;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
415
685
|
});
|
|
416
686
|
nuxt.hook("nitro:init", (nitro) => {
|
|
417
687
|
nitro.hooks.hook("types:extend", (types) => {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
createToolMap,
|
|
7
7
|
executeTool,
|
|
8
8
|
getToolCategory,
|
|
9
|
-
|
|
9
|
+
getToolInfoForServer,
|
|
10
10
|
getToolDefinition,
|
|
11
11
|
isMutationAction,
|
|
12
12
|
isQueryResult,
|
|
@@ -251,6 +251,19 @@ export default function(app, adapter, agentName) {
|
|
|
251
251
|
const ctx = createToolContext();
|
|
252
252
|
const resolved = await resolveTools(mcpTools, ctx);
|
|
253
253
|
toolMap = createToolMap(resolved);
|
|
254
|
+
const toolNames = getToolInfoForServer(
|
|
255
|
+
resolved,
|
|
256
|
+
state.editMode.value,
|
|
257
|
+
adapter
|
|
258
|
+
);
|
|
259
|
+
let contentSearchTabs;
|
|
260
|
+
if (adapter.getContentSearchTabs) {
|
|
261
|
+
try {
|
|
262
|
+
contentSearchTabs = await adapter.getContentSearchTabs();
|
|
263
|
+
} catch (e) {
|
|
264
|
+
console.warn("[blokkli agent] Failed to fetch content search tabs:", e);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
254
267
|
if (adapter.getAgentAuthToken) {
|
|
255
268
|
try {
|
|
256
269
|
const authToken = await adapter.getAgentAuthToken();
|
|
@@ -264,23 +277,18 @@ export default function(app, adapter, agentName) {
|
|
|
264
277
|
disconnect();
|
|
265
278
|
return;
|
|
266
279
|
}
|
|
280
|
+
const pageContext = await buildPageContext(contentSearchTabs);
|
|
281
|
+
pendingInit = { toolNames, pageContext };
|
|
267
282
|
send({ type: "authenticate", authToken });
|
|
268
|
-
pendingInit = {
|
|
269
|
-
tools: getToolsForServer(resolved, state.editMode.value, adapter),
|
|
270
|
-
pageContext: buildPageContext()
|
|
271
|
-
};
|
|
272
283
|
return;
|
|
273
284
|
} catch (e) {
|
|
274
285
|
console.error("Failed to obtain agent auth token:", e);
|
|
275
286
|
}
|
|
276
287
|
}
|
|
277
|
-
sendInit(
|
|
278
|
-
getToolsForServer(resolved, state.editMode.value, adapter),
|
|
279
|
-
buildPageContext()
|
|
280
|
-
);
|
|
288
|
+
sendInit(toolNames, await buildPageContext(contentSearchTabs));
|
|
281
289
|
}
|
|
282
|
-
async function sendInit(
|
|
283
|
-
send({ type: "init",
|
|
290
|
+
async function sendInit(toolNames, pageContext) {
|
|
291
|
+
send({ type: "init", toolNames, pageContext });
|
|
284
292
|
isReady.value = true;
|
|
285
293
|
hasBeenReady.value = true;
|
|
286
294
|
if (adapter.agentConversations && !pendingPrompt) {
|
|
@@ -305,7 +313,7 @@ export default function(app, adapter, agentName) {
|
|
|
305
313
|
sendPrompt(prompt, displayPrompt, selectedUuids, attachments);
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
|
-
function buildPageContext() {
|
|
316
|
+
async function buildPageContext(contentSearchTabs) {
|
|
309
317
|
const { types, definitions } = app;
|
|
310
318
|
const bundles = [];
|
|
311
319
|
for (const bundle of types.generallyAvailableBundles) {
|
|
@@ -360,6 +368,13 @@ export default function(app, adapter, agentName) {
|
|
|
360
368
|
allowed: f.allowed
|
|
361
369
|
}))
|
|
362
370
|
];
|
|
371
|
+
await app.analyze.ensureInitialized();
|
|
372
|
+
const analyzersList = app.analyze.analyzers.value.filter((a) => !a.requireRawPage).map((a) => ({
|
|
373
|
+
id: a.id,
|
|
374
|
+
type: a.type,
|
|
375
|
+
label: typeof a.label === "function" ? a.label(context.value.language) : a.label,
|
|
376
|
+
description: typeof a.description === "function" ? a.description(context.value.language) : a.description
|
|
377
|
+
}));
|
|
363
378
|
const pageContext = {
|
|
364
379
|
title: state.entity.value.label || "",
|
|
365
380
|
entityType: context.value.entityType,
|
|
@@ -373,7 +388,9 @@ export default function(app, adapter, agentName) {
|
|
|
373
388
|
isPublished: state.entity.value.status ?? null,
|
|
374
389
|
editMode: state.editMode.value,
|
|
375
390
|
fragments,
|
|
376
|
-
entityContentFields
|
|
391
|
+
entityContentFields,
|
|
392
|
+
...contentSearchTabs?.length ? { contentSearchTabs } : {},
|
|
393
|
+
...analyzersList.length ? { analyzers: analyzersList } : {}
|
|
377
394
|
};
|
|
378
395
|
return pageContext;
|
|
379
396
|
}
|
|
@@ -412,7 +429,7 @@ export default function(app, adapter, agentName) {
|
|
|
412
429
|
switch (data.type) {
|
|
413
430
|
case "authenticated":
|
|
414
431
|
if (pendingInit) {
|
|
415
|
-
sendInit(pendingInit.
|
|
432
|
+
sendInit(pendingInit.toolNames, pendingInit.pageContext);
|
|
416
433
|
pendingInit = null;
|
|
417
434
|
}
|
|
418
435
|
break;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { McpToolDefinition, McpToolCategory
|
|
1
|
+
import type { McpToolDefinition, McpToolCategory } from '#blokkli/agent/app/types';
|
|
2
2
|
import type { AdapterMethods } from '#blokkli/editor/adapter';
|
|
3
3
|
import type { z } from 'zod';
|
|
4
4
|
import type { Component } from 'vue';
|
|
@@ -7,7 +7,7 @@ import type { Component } from 'vue';
|
|
|
7
7
|
*
|
|
8
8
|
* Tools are defined once and compiled into two bundles:
|
|
9
9
|
* - Client bundle: Full definition with execute function (for Vue component)
|
|
10
|
-
* - Server bundle:
|
|
10
|
+
* - Server bundle: Static metadata extracted at build time
|
|
11
11
|
*
|
|
12
12
|
* The Zod schemas provide:
|
|
13
13
|
* - Type-safe parameter and result definitions with TypeScript inference
|
|
@@ -43,23 +43,5 @@ import type { Component } from 'vue';
|
|
|
43
43
|
* },
|
|
44
44
|
* })
|
|
45
45
|
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example Factory pattern for dynamic tools:
|
|
48
|
-
* ```typescript
|
|
49
|
-
* export default defineBlokkliAgentTool({
|
|
50
|
-
* resolve: async (ctx) => {
|
|
51
|
-
* if (!ctx.adapter.getContentSearchTabs) return []
|
|
52
|
-
* const tabs = await ctx.adapter.getContentSearchTabs()
|
|
53
|
-
* return Object.entries(tabs).map(([id, label]) =>
|
|
54
|
-
* defineBlokkliAgentTool({
|
|
55
|
-
* name: `search_${id}`,
|
|
56
|
-
* requiredAdapterMethods: ['getContentSearchResults'],
|
|
57
|
-
* // ... each tool has full type safety
|
|
58
|
-
* })
|
|
59
|
-
* )
|
|
60
|
-
* },
|
|
61
|
-
* })
|
|
62
|
-
* ```
|
|
63
46
|
*/
|
|
64
47
|
export declare function defineBlokkliAgentTool<TParamsSchema extends z.ZodType, TResultSchema extends z.ZodType, const TMethods extends readonly AdapterMethods[] = readonly [], TComponent extends Component | undefined = undefined, TCategory extends McpToolCategory = McpToolCategory>(options: McpToolDefinition<TParamsSchema, TResultSchema, TMethods, TComponent, TCategory>): McpToolDefinition<TParamsSchema, TResultSchema, TMethods, TComponent, TCategory>;
|
|
65
|
-
export declare function defineBlokkliAgentTool(options: McpToolFactoryInput): McpToolFactory;
|