@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
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { OptionItem } from '#blokkli/editor/helpers/options';
|
|
3
|
-
import type { BlokkliApp } from '#blokkli/editor/types/app';
|
|
4
|
-
/**
|
|
5
|
-
* Extract a simple key→label map from the various radios/checkboxes option formats.
|
|
6
|
-
* Handles plain strings, icon objects, color objects, grid objects, etc.
|
|
7
|
-
*/
|
|
8
|
-
export declare function extractOptionLabels(option: Record<string, unknown>): Record<string, string> | undefined;
|
|
9
2
|
/**
|
|
10
3
|
* Shared schema for a single block option with its current value.
|
|
11
4
|
*/
|
|
@@ -33,14 +26,6 @@ export declare const blockOptionsMapSchema: z.ZodRecord<z.ZodString, z.ZodObject
|
|
|
33
26
|
currentValue: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodArray<z.ZodString>]>;
|
|
34
27
|
}, z.core.$strip>>;
|
|
35
28
|
export type BlockOptionsMap = z.infer<typeof blockOptionsMapSchema>;
|
|
36
|
-
/**
|
|
37
|
-
* Build a block options map from available options and mutated state.
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildBlockOptionsMap(availableOptions: OptionItem[], mutatedOptions: Record<string, Record<string, string>>, uuid: string): BlockOptionsMap;
|
|
40
|
-
/**
|
|
41
|
-
* Build a block options map from option definitions, using defaults as current values.
|
|
42
|
-
*/
|
|
43
|
-
export declare function buildBlockOptionsMapFromDefinitions(options: Record<string, Record<string, unknown>>): BlockOptionsMap;
|
|
44
29
|
/**
|
|
45
30
|
* Schema for a parent entity (the container of a block).
|
|
46
31
|
* A parent is an entity + field combination where blocks can be placed.
|
|
@@ -71,32 +56,6 @@ export declare const mutationResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
71
56
|
* Shared schema for option values (used by add_blocks and set_block_options).
|
|
72
57
|
*/
|
|
73
58
|
export declare const optionValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodNumber, z.ZodArray<z.ZodString>]>;
|
|
74
|
-
/**
|
|
75
|
-
* Validate a single option value against its definition.
|
|
76
|
-
* Returns an error string or undefined if valid.
|
|
77
|
-
*/
|
|
78
|
-
export declare function validateOptionValue(key: string, value: string | boolean | number | string[], optionDef: OptionItem): string | undefined;
|
|
79
|
-
/**
|
|
80
|
-
* Resolve an editable field config to its simplified type.
|
|
81
|
-
* Returns 'plain' for text fields, 'markup' for rich text/frame fields, null for unsupported.
|
|
82
|
-
*/
|
|
83
|
-
export declare function getFieldType(app: BlokkliApp, entityType: string, bundle: string, fieldName: string): 'plain' | 'markup' | null;
|
|
84
|
-
/**
|
|
85
|
-
* Read the current value of an editable field on a block or entity.
|
|
86
|
-
* Tries the registered getValue() callback first, falls back to DOM element reading.
|
|
87
|
-
*/
|
|
88
|
-
export declare function getEditableValue(app: BlokkliApp, entityType: string, uuid: string, bundle: string, fieldName: string, fieldType: 'plain' | 'markup'): string;
|
|
89
|
-
/**
|
|
90
|
-
* Get all child fields and their paragraphs for a given entity UUID.
|
|
91
|
-
* Walks mutatedFields to find fields belonging to the entity.
|
|
92
|
-
*/
|
|
93
|
-
export declare function getParagraphChildren(app: BlokkliApp, uuid: string): {
|
|
94
|
-
fieldName: string;
|
|
95
|
-
paragraphs: {
|
|
96
|
-
uuid: string;
|
|
97
|
-
bundle: string;
|
|
98
|
-
}[];
|
|
99
|
-
}[];
|
|
100
59
|
/**
|
|
101
60
|
* Shared schema for the `position` parameter used by mutation tools that insert blocks.
|
|
102
61
|
*
|
|
@@ -107,17 +66,6 @@ export declare function getParagraphChildren(app: BlokkliApp, uuid: string): {
|
|
|
107
66
|
* - `"before:<UUID>"` — insert before the block with the given UUID
|
|
108
67
|
*/
|
|
109
68
|
export declare const positionSchema: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
110
|
-
/**
|
|
111
|
-
* Resolve a `position` string to the `afterUuid` value expected by adapter methods.
|
|
112
|
-
*
|
|
113
|
-
* Returns `{ afterUuid: string | null }` on success, or `{ error: string }` if
|
|
114
|
-
* the referenced UUID is not found in the target field.
|
|
115
|
-
*/
|
|
116
|
-
export declare function resolvePosition(app: BlokkliApp, parentUuid: string, fieldName: string, position?: string): {
|
|
117
|
-
afterUuid: string | null;
|
|
118
|
-
} | {
|
|
119
|
-
error: string;
|
|
120
|
-
};
|
|
121
69
|
/**
|
|
122
70
|
* Schema for the success result sent back to the AI after mutation is applied.
|
|
123
71
|
*/
|
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { getMutatedOptionValue } from "#blokkli/editor/helpers/options";
|
|
3
|
-
import { getRuntimeOptionValue } from "#blokkli/runtime-helpers";
|
|
4
|
-
export function extractOptionLabels(option) {
|
|
5
|
-
if (!("options" in option) || !option.options) return void 0;
|
|
6
|
-
const raw = option.options;
|
|
7
|
-
const labels = {};
|
|
8
|
-
for (const [key, value] of Object.entries(raw)) {
|
|
9
|
-
if (typeof value === "string") {
|
|
10
|
-
labels[key] = value;
|
|
11
|
-
} else if (typeof value === "object" && value !== null && "label" in value) {
|
|
12
|
-
labels[key] = String(value.label);
|
|
13
|
-
} else {
|
|
14
|
-
labels[key] = key;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return labels;
|
|
18
|
-
}
|
|
19
2
|
export const blockOptionSchema = z.object({
|
|
20
3
|
type: z.string().describe(
|
|
21
4
|
"The option type (checkbox, radios, checkboxes, text, number, range, color, datetime-local)"
|
|
@@ -32,54 +15,6 @@ export const blockOptionsMapSchema = z.record(
|
|
|
32
15
|
z.string().describe("Option property name"),
|
|
33
16
|
blockOptionSchema
|
|
34
17
|
);
|
|
35
|
-
export function buildBlockOptionsMap(availableOptions, mutatedOptions, uuid) {
|
|
36
|
-
const result = {};
|
|
37
|
-
for (const opt of availableOptions) {
|
|
38
|
-
const rawValue = getMutatedOptionValue(
|
|
39
|
-
mutatedOptions,
|
|
40
|
-
uuid,
|
|
41
|
-
opt.property,
|
|
42
|
-
opt.option.default
|
|
43
|
-
);
|
|
44
|
-
const currentValue = getRuntimeOptionValue(opt.option, rawValue);
|
|
45
|
-
result[opt.property] = buildBlockOptionEntry(opt.option, currentValue);
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
export function buildBlockOptionsMapFromDefinitions(options) {
|
|
50
|
-
const result = {};
|
|
51
|
-
for (const [key, opt] of Object.entries(options)) {
|
|
52
|
-
result[key] = buildBlockOptionEntry(
|
|
53
|
-
opt,
|
|
54
|
-
opt.default
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
function buildBlockOptionEntry(opt, currentValue) {
|
|
60
|
-
const entry = {
|
|
61
|
-
type: opt.type,
|
|
62
|
-
label: opt.label,
|
|
63
|
-
currentValue
|
|
64
|
-
};
|
|
65
|
-
if (opt.description) {
|
|
66
|
-
entry.description = opt.description;
|
|
67
|
-
}
|
|
68
|
-
const labels = extractOptionLabels(opt);
|
|
69
|
-
if (labels) {
|
|
70
|
-
entry.options = labels;
|
|
71
|
-
}
|
|
72
|
-
if ("min" in opt) {
|
|
73
|
-
entry.min = opt.min;
|
|
74
|
-
}
|
|
75
|
-
if ("max" in opt) {
|
|
76
|
-
entry.max = opt.max;
|
|
77
|
-
}
|
|
78
|
-
if ("step" in opt && opt.type === "range") {
|
|
79
|
-
entry.step = opt.step;
|
|
80
|
-
}
|
|
81
|
-
return entry;
|
|
82
|
-
}
|
|
83
18
|
export const parentSchema = z.object({
|
|
84
19
|
type: z.string().describe(
|
|
85
20
|
"The entity type of the parent. Do NOT guess this - always use the parent object returned by get_child_paragraphs."
|
|
@@ -104,131 +39,9 @@ export const optionValueSchema = z.union([
|
|
|
104
39
|
z.number(),
|
|
105
40
|
z.array(z.string())
|
|
106
41
|
]);
|
|
107
|
-
export function validateOptionValue(key, value, optionDef) {
|
|
108
|
-
const optionType = optionDef.option.type;
|
|
109
|
-
if (optionType === "checkbox") {
|
|
110
|
-
if (typeof value !== "boolean" && value !== "1" && value !== "0" && value !== "true" && value !== "false") {
|
|
111
|
-
return `Option "${key}" expects a boolean value`;
|
|
112
|
-
}
|
|
113
|
-
} else if (optionType === "radios") {
|
|
114
|
-
if (typeof value !== "string") {
|
|
115
|
-
return `Option "${key}" expects a string value`;
|
|
116
|
-
}
|
|
117
|
-
if ("options" in optionDef.option && optionDef.option.options) {
|
|
118
|
-
const allowedKeys = Object.keys(optionDef.option.options);
|
|
119
|
-
if (!allowedKeys.includes(value)) {
|
|
120
|
-
return `Option "${key}" value must be one of: ${allowedKeys.join(", ")}`;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
} else if (optionType === "checkboxes") {
|
|
124
|
-
if (!Array.isArray(value) && typeof value !== "string") {
|
|
125
|
-
return `Option "${key}" expects an array of strings or comma-separated string`;
|
|
126
|
-
}
|
|
127
|
-
if ("options" in optionDef.option && optionDef.option.options) {
|
|
128
|
-
const allowedKeys = Object.keys(optionDef.option.options);
|
|
129
|
-
const values = Array.isArray(value) ? value : value.split(",");
|
|
130
|
-
for (const v of values) {
|
|
131
|
-
if (!allowedKeys.includes(v)) {
|
|
132
|
-
return `Option "${key}" value "${v}" is not allowed. Must be one of: ${allowedKeys.join(", ")}`;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
} else if (optionType === "number" || optionType === "range") {
|
|
137
|
-
const numValue = typeof value === "number" ? value : Number.parseFloat(String(value));
|
|
138
|
-
if (Number.isNaN(numValue)) {
|
|
139
|
-
return `Option "${key}" expects a numeric value`;
|
|
140
|
-
}
|
|
141
|
-
if ("min" in optionDef.option && numValue < optionDef.option.min) {
|
|
142
|
-
return `Option "${key}" value must be >= ${optionDef.option.min}`;
|
|
143
|
-
}
|
|
144
|
-
if ("max" in optionDef.option && numValue > optionDef.option.max) {
|
|
145
|
-
return `Option "${key}" value must be <= ${optionDef.option.max}`;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return void 0;
|
|
149
|
-
}
|
|
150
|
-
export function getFieldType(app, entityType, bundle, fieldName) {
|
|
151
|
-
const config = app.types.editableFieldConfig.forName(
|
|
152
|
-
entityType,
|
|
153
|
-
bundle,
|
|
154
|
-
fieldName
|
|
155
|
-
);
|
|
156
|
-
if (!config) return null;
|
|
157
|
-
if (config.type === "table") return null;
|
|
158
|
-
if (config.type === "frame" || config.type === "markup") return "markup";
|
|
159
|
-
return "plain";
|
|
160
|
-
}
|
|
161
|
-
export function getEditableValue(app, entityType, uuid, bundle, fieldName, fieldType) {
|
|
162
|
-
const editables = app.directive.getEditablesForBlock(uuid);
|
|
163
|
-
const editable = editables.find((e) => e.fieldName === fieldName);
|
|
164
|
-
if (editable?.getValue) {
|
|
165
|
-
return editable.getValue();
|
|
166
|
-
}
|
|
167
|
-
const element = app.directive.findEditableElement(fieldName, {
|
|
168
|
-
type: entityType,
|
|
169
|
-
uuid,
|
|
170
|
-
bundle
|
|
171
|
-
});
|
|
172
|
-
if (element) {
|
|
173
|
-
return fieldType === "markup" ? element.innerHTML || "" : element.textContent || "";
|
|
174
|
-
}
|
|
175
|
-
return "";
|
|
176
|
-
}
|
|
177
|
-
export function getParagraphChildren(app, uuid) {
|
|
178
|
-
const result = [];
|
|
179
|
-
for (const field of app.state.mutatedFields.value) {
|
|
180
|
-
if (field.entityUuid === uuid && field.list.length > 0) {
|
|
181
|
-
result.push({
|
|
182
|
-
fieldName: field.name,
|
|
183
|
-
paragraphs: field.list.map((item) => ({
|
|
184
|
-
uuid: item.uuid,
|
|
185
|
-
bundle: item.bundle
|
|
186
|
-
}))
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
42
|
export const positionSchema = z.string().optional().default("end").describe(
|
|
193
43
|
'Where to place the paragraph(s). "start" = beginning, "end" (default) = append at end, "after:<UUID>" = after a specific paragraph, "before:<UUID>" = before a specific paragraph.'
|
|
194
44
|
);
|
|
195
|
-
export function resolvePosition(app, parentUuid, fieldName, position) {
|
|
196
|
-
const fieldList = app.state.mutatedFields.value.find(
|
|
197
|
-
(f) => f.entityUuid === parentUuid && f.name === fieldName
|
|
198
|
-
);
|
|
199
|
-
const list = fieldList?.list ?? [];
|
|
200
|
-
if (position === void 0 || position === "end") {
|
|
201
|
-
const lastBlock = list.at(-1);
|
|
202
|
-
return { afterUuid: lastBlock?.uuid ?? null };
|
|
203
|
-
}
|
|
204
|
-
if (position === "start") {
|
|
205
|
-
return { afterUuid: null };
|
|
206
|
-
}
|
|
207
|
-
if (position.startsWith("after:")) {
|
|
208
|
-
const uuid = position.slice(6);
|
|
209
|
-
const found = list.find((b) => b.uuid === uuid);
|
|
210
|
-
if (!found) {
|
|
211
|
-
return {
|
|
212
|
-
error: `Position "after:${uuid}": paragraph not found in field "${fieldName}".`
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
return { afterUuid: uuid };
|
|
216
|
-
}
|
|
217
|
-
if (position.startsWith("before:")) {
|
|
218
|
-
const uuid = position.slice(7);
|
|
219
|
-
const index = list.findIndex((b) => b.uuid === uuid);
|
|
220
|
-
if (index === -1) {
|
|
221
|
-
return {
|
|
222
|
-
error: `Position "before:${uuid}": paragraph not found in field "${fieldName}".`
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
const preceding = index > 0 ? list[index - 1] : void 0;
|
|
226
|
-
return { afterUuid: preceding?.uuid ?? null };
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
error: `Invalid position value: "${position}". Use "start", "end", "after:<UUID>", or "before:<UUID>".`
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
45
|
export const mutationSuccessSchema = z.union([
|
|
233
46
|
z.object({
|
|
234
47
|
success: z.literal(true),
|
|
@@ -13,53 +13,46 @@ const resultSchema = z.array(
|
|
|
13
13
|
})
|
|
14
14
|
);
|
|
15
15
|
export default defineBlokkliAgentTool({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
name: "search_content",
|
|
17
|
+
description: 'Search for content items by tab ID and query. The available tab IDs and their entity types are listed in the system prompt under "Content Search Tabs". Use the tab ID that matches the type of content you are looking for.',
|
|
18
|
+
category: "query",
|
|
19
|
+
lazy: true,
|
|
20
|
+
requiredAdapterMethods: ["getContentSearchTabs", "getContentSearchResults"],
|
|
21
|
+
modes: ["readonly", "editing", "translating", "review"],
|
|
22
|
+
label($t) {
|
|
23
|
+
return $t("aiAgentSearchContentRunning", "Searching content...");
|
|
24
|
+
},
|
|
25
|
+
paramsSchema: z.object({
|
|
26
|
+
tab: z.string().describe(
|
|
27
|
+
"The tab ID to search in. See the system prompt for available tab IDs."
|
|
28
|
+
),
|
|
29
|
+
query: z.string().describe("The search query")
|
|
30
|
+
}),
|
|
31
|
+
resultSchema,
|
|
32
|
+
async execute(ctx, params) {
|
|
20
33
|
const tabs = await ctx.adapter.getContentSearchTabs();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const items = await toolCtx.adapter.getContentSearchResults(
|
|
45
|
-
tab.id,
|
|
46
|
-
params.query
|
|
47
|
-
);
|
|
48
|
-
return {
|
|
49
|
-
label: `Searched ${tab.title} for "${params.query}"`,
|
|
50
|
-
result: items.map((item) => ({
|
|
51
|
-
id: item.id,
|
|
52
|
-
title: item.title,
|
|
53
|
-
entityType: item.entityType,
|
|
54
|
-
entityBundle: item.entityBundle,
|
|
55
|
-
targetBundles: item.targetBundles,
|
|
56
|
-
context: item.context,
|
|
57
|
-
text: item.text,
|
|
58
|
-
imageUrl: item.imageUrl
|
|
59
|
-
}))
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
34
|
+
const tab = tabs.find((t) => t.id === params.tab);
|
|
35
|
+
if (!tab) {
|
|
36
|
+
return {
|
|
37
|
+
error: `Invalid tab ID "${params.tab}". Available tabs: ${tabs.map((t) => t.id).join(", ")}`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const items = await ctx.adapter.getContentSearchResults(
|
|
41
|
+
params.tab,
|
|
42
|
+
params.query
|
|
43
|
+
);
|
|
44
|
+
return {
|
|
45
|
+
label: `Searched ${tab.title} for "${params.query}"`,
|
|
46
|
+
result: items.map((item) => ({
|
|
47
|
+
id: item.id,
|
|
48
|
+
title: item.title,
|
|
49
|
+
entityType: item.entityType,
|
|
50
|
+
entityBundle: item.entityBundle,
|
|
51
|
+
targetBundles: item.targetBundles,
|
|
52
|
+
context: item.context,
|
|
53
|
+
text: item.text,
|
|
54
|
+
imageUrl: item.imageUrl
|
|
55
|
+
}))
|
|
56
|
+
};
|
|
64
57
|
}
|
|
65
58
|
});
|
|
@@ -4,11 +4,8 @@ import {
|
|
|
4
4
|
getAvailableOptions,
|
|
5
5
|
optionValueToStorable
|
|
6
6
|
} from "#blokkli/editor/helpers/options";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
optionValueSchema,
|
|
10
|
-
validateOptionValue
|
|
11
|
-
} from "../schemas.js";
|
|
7
|
+
import { mutationResultSchema, optionValueSchema } from "../schemas.js";
|
|
8
|
+
import { validateOptionValue } from "../helpers.js";
|
|
12
9
|
import { onlyUnique } from "#blokkli/helpers";
|
|
13
10
|
const paragraphOptionsSchema = z.object({
|
|
14
11
|
uuid: z.string().describe("The paragraph UUID"),
|
|
@@ -200,67 +200,6 @@ export type McpToolDefinition<TParamsSchema extends z.ZodType = z.ZodType, TResu
|
|
|
200
200
|
*/
|
|
201
201
|
mockParamsVariants?: () => z.infer<TParamsSchema>[];
|
|
202
202
|
};
|
|
203
|
-
/**
|
|
204
|
-
* A tool definition with a relaxed execute signature.
|
|
205
|
-
*
|
|
206
|
-
* Used as the return type for factory resolve callbacks. Preserves structural
|
|
207
|
-
* checking on all other properties (catches typos and excess properties) while
|
|
208
|
-
* allowing each tool to have its own specific execute signature via
|
|
209
|
-
* defineBlokkliAgentTool().
|
|
210
|
-
*/
|
|
211
|
-
export type FactoryResolvedTool = {
|
|
212
|
-
name: string;
|
|
213
|
-
description: string;
|
|
214
|
-
icon?: string;
|
|
215
|
-
category: McpToolCategory;
|
|
216
|
-
label: ($t: TranslationFunction) => string;
|
|
217
|
-
paramsSchema: z.ZodType;
|
|
218
|
-
resultSchema: z.ZodType;
|
|
219
|
-
requiredAdapterMethods?: readonly AdapterMethods[];
|
|
220
|
-
modes: EditMode[];
|
|
221
|
-
component?: Component;
|
|
222
|
-
requiresApproval?: boolean;
|
|
223
|
-
lazy?: boolean;
|
|
224
|
-
volatile?: boolean;
|
|
225
|
-
prunedSummary?: (result: any) => string;
|
|
226
|
-
execute: (...args: any[]) => any;
|
|
227
|
-
mockParams?: () => any;
|
|
228
|
-
mockParamsVariants?: () => any[];
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* Input for a tool factory that dynamically creates tools at runtime.
|
|
232
|
-
*
|
|
233
|
-
* Instead of defining a single static tool, a factory uses a `resolve` callback
|
|
234
|
-
* that is called when the agent connects. The callback returns an array of
|
|
235
|
-
* McpToolDefinition objects, allowing tools to be created based on runtime state
|
|
236
|
-
* (e.g., available content search tabs from the adapter).
|
|
237
|
-
*/
|
|
238
|
-
export type McpToolFactoryInput = {
|
|
239
|
-
/**
|
|
240
|
-
* Called once when the agent connects. Returns an array of tool definitions
|
|
241
|
-
* that are registered as if they were statically defined.
|
|
242
|
-
*
|
|
243
|
-
* Each returned tool is a full McpToolDefinition with its own
|
|
244
|
-
* requiredAdapterMethods, execute function, and schemas. Use
|
|
245
|
-
* defineBlokkliAgentTool() for each tool to get full type inference.
|
|
246
|
-
*
|
|
247
|
-
* The context provides access to the app and adapter so the factory can
|
|
248
|
-
* query runtime state (e.g., available content search tabs) to decide
|
|
249
|
-
* which tools to create. If adapter methods are optional, check for their
|
|
250
|
-
* existence before calling them (or return an empty array).
|
|
251
|
-
*/
|
|
252
|
-
resolve: (context: McpToolContext) => Promise<FactoryResolvedTool[]> | FactoryResolvedTool[];
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* A tool factory with the __factory marker for runtime identification.
|
|
256
|
-
*/
|
|
257
|
-
export type McpToolFactory = McpToolFactoryInput & {
|
|
258
|
-
__factory: true;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* A tool item is either a static tool definition or a factory that produces tools.
|
|
262
|
-
*/
|
|
263
|
-
export type McpToolItem = McpToolDefinition | McpToolFactory;
|
|
264
203
|
/**
|
|
265
204
|
* A pre-defined agent prompt that users can select.
|
|
266
205
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Peer } from 'crossws';
|
|
2
|
-
import type { PageContext, ClientToolDefinition, ConversationStateSnapshot, GenericMessage } from '../shared/types.js';
|
|
2
|
+
import type { PageContext, ClientToolDefinition, ServerToolMetadata, ConversationStateSnapshot, GenericMessage } from '../shared/types.js';
|
|
3
3
|
import type { ServerPlan } from './server-tools/index.js';
|
|
4
4
|
export declare class Session {
|
|
5
5
|
messages: GenericMessage[];
|
|
@@ -12,10 +12,10 @@ export declare class Session {
|
|
|
12
12
|
}>;
|
|
13
13
|
abortController: AbortController | null;
|
|
14
14
|
isProcessing: boolean;
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
15
|
+
/** Names of eager tools sent to the LLM on every turn */
|
|
16
|
+
toolNames: string[];
|
|
17
|
+
/** Names of lazy tools held back until activated via load_tools */
|
|
18
|
+
lazyToolNames: string[];
|
|
19
19
|
/** Names of lazy tools that have been activated via load_tools */
|
|
20
20
|
activatedLazyTools: Set<string>;
|
|
21
21
|
/** Names of skills that have been loaded via load_skill */
|
|
@@ -32,7 +32,26 @@ export declare class Session {
|
|
|
32
32
|
private unprunedMessages;
|
|
33
33
|
/** Last generic tool definitions for transcript */
|
|
34
34
|
private lastTools;
|
|
35
|
-
|
|
35
|
+
/** Bundled tool metadata map for server-side resolution */
|
|
36
|
+
private bundledToolMap;
|
|
37
|
+
/** Cache for resolved JSON Schemas (Zod→JSON Schema is deterministic) */
|
|
38
|
+
private jsonSchemaCache;
|
|
39
|
+
constructor(toolDefinitions: ServerToolMetadata[]);
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a single tool name into a ClientToolDefinition.
|
|
42
|
+
* Resolves from bundled metadata. Caches the JSON Schema conversion.
|
|
43
|
+
*/
|
|
44
|
+
resolveToolDefinition(name: string): ClientToolDefinition | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve multiple tool names into ClientToolDefinition objects.
|
|
47
|
+
* Skips names that cannot be resolved.
|
|
48
|
+
*/
|
|
49
|
+
resolveToolDefinitions(names: string[]): ClientToolDefinition[];
|
|
50
|
+
/**
|
|
51
|
+
* Look up name + description for a tool.
|
|
52
|
+
*/
|
|
53
|
+
private getToolSummary;
|
|
54
|
+
init(toolNames: string[], pageContext: PageContext): void;
|
|
36
55
|
start(peer: Peer, prompt: string, apiKey: string, authSecret: string, selectedUuids?: string[]): void;
|
|
37
56
|
resolveToolResult(callId: string, result: {
|
|
38
57
|
result: unknown;
|