@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.
Files changed (216) hide show
  1. package/dist/global/types/blockOptions.d.ts +4 -3
  2. package/dist/module.d.mts +2 -2
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +71 -4
  5. package/dist/modules/agent/index.d.mts +1 -1
  6. package/dist/modules/agent/index.mjs +276 -6
  7. package/dist/modules/agent/runtime/app/composables/agentProvider.js +31 -14
  8. package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.d.ts +2 -20
  9. package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.js +0 -3
  10. package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/Assistant/index.vue +2 -2
  11. package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/User/index.vue +1 -2
  12. package/dist/modules/agent/runtime/app/features/agent/Panel/DebugGallery/index.vue +1 -2
  13. package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.d.vue.ts +1 -0
  14. package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue +66 -59
  15. package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue.d.ts +1 -0
  16. package/dist/modules/agent/runtime/app/features/agent/Panel/Input/index.vue +10 -12
  17. package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/de.md +2 -2
  18. package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/en.md +2 -2
  19. package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue +1 -5
  20. package/dist/modules/agent/runtime/app/features/agent/index.vue +89 -37
  21. package/dist/modules/agent/runtime/app/helpers/index.d.ts +16 -19
  22. package/dist/modules/agent/runtime/app/helpers/index.js +22 -46
  23. package/dist/modules/agent/runtime/app/helpers/pageStructure.js +1 -1
  24. package/dist/modules/agent/runtime/app/tools/add_content_search_paragraph/index.js +5 -9
  25. package/dist/modules/agent/runtime/app/tools/add_fragment/index.js +2 -6
  26. package/dist/modules/agent/runtime/app/tools/add_media_paragraph/index.js +2 -6
  27. package/dist/modules/agent/runtime/app/tools/add_paragraphs/index.js +2 -3
  28. package/dist/modules/agent/runtime/app/tools/add_reusable_paragraph/index.js +2 -6
  29. package/dist/modules/agent/runtime/app/tools/add_template/index.js +2 -6
  30. package/dist/modules/agent/runtime/app/tools/analyze_content/index.d.ts +2 -0
  31. package/dist/modules/agent/runtime/app/tools/analyze_content/index.js +120 -0
  32. package/dist/modules/agent/runtime/app/tools/check_readability/index.d.ts +2 -0
  33. package/dist/modules/agent/runtime/app/tools/check_readability/index.js +57 -0
  34. package/dist/modules/agent/runtime/app/tools/duplicate_paragraphs/index.js +2 -6
  35. package/dist/modules/agent/runtime/app/tools/get_all_page_content/index.js +1 -1
  36. package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +2 -1
  37. package/dist/modules/agent/runtime/app/tools/get_content_fields/index.js +1 -1
  38. package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +2 -5
  39. package/dist/modules/agent/runtime/app/tools/get_paragraph_options/index.js +2 -1
  40. package/dist/modules/agent/runtime/app/tools/get_selected_paragraphs/index.js +2 -3
  41. package/dist/modules/agent/runtime/app/tools/helpers.d.ts +53 -0
  42. package/dist/modules/agent/runtime/app/tools/helpers.js +187 -0
  43. package/dist/modules/agent/runtime/app/tools/move_paragraphs/index.js +2 -6
  44. package/dist/modules/agent/runtime/app/tools/schemas.d.ts +0 -52
  45. package/dist/modules/agent/runtime/app/tools/schemas.js +0 -187
  46. package/dist/modules/agent/runtime/app/tools/search_content/index.js +40 -47
  47. package/dist/modules/agent/runtime/app/tools/set_paragraph_options/index.js +2 -5
  48. package/dist/modules/agent/runtime/app/types/index.d.ts +0 -61
  49. package/dist/modules/agent/runtime/server/Session.d.ts +25 -6
  50. package/dist/modules/agent/runtime/server/Session.js +109 -30
  51. package/dist/modules/agent/runtime/server/SessionManager.d.ts +3 -0
  52. package/dist/modules/agent/runtime/server/SessionManager.js +4 -1
  53. package/dist/modules/agent/runtime/server/agent.js +3 -2
  54. package/dist/modules/agent/runtime/server/default-skills/fixReadability.d.ts +2 -0
  55. package/dist/modules/agent/runtime/server/default-skills/fixReadability.js +69 -0
  56. package/dist/modules/agent/runtime/server/default-system-prompts/page-context.js +28 -0
  57. package/dist/modules/agent/runtime/server/server-tools/index.d.ts +10 -2
  58. package/dist/modules/agent/runtime/server/server-tools/index.js +1 -1
  59. package/dist/modules/agent/runtime/server/server-tools/load_tools/index.js +1 -1
  60. package/dist/modules/agent/runtime/shared/types.d.ts +46 -11
  61. package/dist/modules/agent/runtime/shared/types.js +22 -10
  62. package/dist/modules/charts/index.d.mts +1 -1
  63. package/dist/modules/charts/index.mjs +21 -7
  64. package/dist/modules/charts/runtime/blokkli/skills/charts.js +6 -6
  65. package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.d.ts +25 -2
  66. package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.js +39 -1
  67. package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.js +24 -17
  68. package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.js +11 -19
  69. package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.js +2 -4
  70. package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.js +8 -20
  71. package/dist/modules/charts/runtime/chartTypes/area.d.ts +6 -1
  72. package/dist/modules/charts/runtime/chartTypes/bar.d.ts +7 -1
  73. package/dist/modules/charts/runtime/chartTypes/define.d.ts +1 -1
  74. package/dist/modules/charts/runtime/chartTypes/donut.d.ts +5 -1
  75. package/dist/modules/charts/runtime/chartTypes/heatmap.d.ts +3 -1
  76. package/dist/modules/charts/runtime/chartTypes/index.d.ts +18 -0
  77. package/dist/modules/charts/runtime/chartTypes/line.d.ts +6 -1
  78. package/dist/modules/charts/runtime/chartTypes/pie.d.ts +4 -1
  79. package/dist/modules/charts/runtime/chartTypes/radar.d.ts +6 -1
  80. package/dist/modules/charts/runtime/chartTypes/radialBar.d.ts +5 -1
  81. package/dist/modules/charts/runtime/chartTypes/shared.d.ts +20 -5
  82. package/dist/modules/charts/runtime/chartTypes/types.d.ts +6 -6
  83. package/dist/modules/charts/runtime/components/ChartRenderer/index.d.vue.ts +145 -2
  84. package/dist/modules/charts/runtime/components/ChartRenderer/index.vue +2 -2
  85. package/dist/modules/charts/runtime/components/ChartRenderer/index.vue.d.ts +145 -2
  86. package/dist/modules/charts/runtime/components/index.d.ts +1 -0
  87. package/dist/modules/charts/runtime/components/index.js +1 -0
  88. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.d.vue.ts +3 -2
  89. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue.d.ts +3 -2
  90. package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue +1 -2
  91. package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue +1 -1
  92. package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.d.vue.ts +2 -0
  93. package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue +35 -13
  94. package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue.d.ts +2 -0
  95. package/dist/modules/charts/runtime/features/charts/Editor/index.d.vue.ts +1 -0
  96. package/dist/modules/charts/runtime/features/charts/Editor/index.vue +9 -3
  97. package/dist/modules/charts/runtime/features/charts/Editor/index.vue.d.ts +1 -0
  98. package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.js +1 -1
  99. package/dist/modules/charts/runtime/features/charts/index.vue +6 -6
  100. package/dist/modules/charts/runtime/helpers/index.d.ts +25 -0
  101. package/dist/modules/charts/runtime/helpers/index.js +63 -0
  102. package/dist/modules/charts/runtime/types.d.ts +10 -28
  103. package/dist/modules/charts/runtime/types.js +0 -64
  104. package/dist/modules/drupal/index.d.mts +1 -1
  105. package/dist/modules/drupal/runtime/adapter/index.d.ts +3 -1
  106. package/dist/modules/drupal/runtime/adapter/index.js +4 -4
  107. package/dist/modules/table-of-contents/index.d.mts +1 -1
  108. package/dist/runtime/components/BlokkliItem.vue +1 -1
  109. package/dist/runtime/composables/defineBlokkli.js +1 -1
  110. package/dist/runtime/editor/components/AnimationCanvas/index.vue +13 -7
  111. package/dist/runtime/editor/components/Banner/index.d.vue.ts +1 -0
  112. package/dist/runtime/editor/components/Banner/index.vue +1 -1
  113. package/dist/runtime/editor/components/Banner/index.vue.d.ts +1 -0
  114. package/dist/runtime/editor/components/DropdownItem/index.d.vue.ts +1 -0
  115. package/dist/runtime/editor/components/DropdownItem/index.vue +3 -2
  116. package/dist/runtime/editor/components/DropdownItem/index.vue.d.ts +1 -0
  117. package/dist/runtime/editor/components/EditProvider.vue +7 -4
  118. package/dist/runtime/editor/components/FlexTextarea/index.d.vue.ts +4 -0
  119. package/dist/runtime/editor/components/FlexTextarea/index.vue +24 -101
  120. package/dist/runtime/editor/components/FlexTextarea/index.vue.d.ts +4 -0
  121. package/dist/runtime/editor/components/NestedEditorOverlay/index.vue +28 -9
  122. package/dist/runtime/editor/components/Popup/index.d.vue.ts +30 -0
  123. package/dist/runtime/editor/components/Popup/index.vue +82 -0
  124. package/dist/runtime/editor/components/Popup/index.vue.d.ts +30 -0
  125. package/dist/runtime/editor/components/Resizable/index.vue +4 -1
  126. package/dist/runtime/editor/components/Toolbar/index.vue +107 -6
  127. package/dist/runtime/editor/components/index.d.ts +4 -3
  128. package/dist/runtime/editor/components/index.js +6 -4
  129. package/dist/runtime/editor/composables/defineDropAreas.js +3 -3
  130. package/dist/runtime/editor/composables/defineDropHandler.d.ts +3 -0
  131. package/dist/runtime/editor/composables/defineDropHandler.js +10 -0
  132. package/dist/runtime/editor/composables/index.d.ts +1 -0
  133. package/dist/runtime/editor/composables/index.js +1 -0
  134. package/dist/runtime/editor/css/output.css +1 -1
  135. package/dist/runtime/editor/events/index.d.ts +9 -0
  136. package/dist/runtime/editor/features/add-list/index.vue +58 -1
  137. package/dist/runtime/editor/features/analyze/Main.d.vue.ts +3 -2
  138. package/dist/runtime/editor/features/analyze/Main.vue +28 -44
  139. package/dist/runtime/editor/features/analyze/Main.vue.d.ts +3 -2
  140. package/dist/runtime/editor/features/analyze/analyzers/readability.js +65 -0
  141. package/dist/runtime/editor/features/analyze/analyzers/types.d.ts +19 -0
  142. package/dist/runtime/editor/features/analyze/index.vue +18 -15
  143. package/dist/runtime/editor/features/clipboard/DropElement/Video.d.vue.ts +8 -0
  144. package/dist/runtime/editor/features/clipboard/{List/Item → DropElement}/Video.vue +1 -5
  145. package/dist/runtime/editor/features/clipboard/DropElement/Video.vue.d.ts +8 -0
  146. package/dist/runtime/editor/features/clipboard/DropElement/helpers.d.ts +1 -0
  147. package/dist/runtime/editor/features/clipboard/DropElement/helpers.js +14 -0
  148. package/dist/runtime/editor/features/clipboard/DropElement/index.d.vue.ts +16 -0
  149. package/dist/runtime/editor/features/clipboard/DropElement/index.vue +97 -0
  150. package/dist/runtime/editor/features/clipboard/DropElement/index.vue.d.ts +16 -0
  151. package/dist/runtime/editor/features/clipboard/helpers.d.ts +15 -0
  152. package/dist/runtime/editor/features/clipboard/helpers.js +62 -0
  153. package/dist/runtime/editor/features/clipboard/index.vue +585 -337
  154. package/dist/runtime/editor/features/clipboard/types.d.ts +14 -2
  155. package/dist/runtime/editor/features/dragging-overlay/DragItems/index.vue +17 -5
  156. package/dist/runtime/editor/features/dragging-overlay/Renderer/index.vue +2 -2
  157. package/dist/runtime/editor/features/dragging-overlay/index.vue +125 -219
  158. package/dist/runtime/editor/features/editable-field/Overlay/Plaintext/index.vue +4 -4
  159. package/dist/runtime/editor/features/editable-field/Overlay/index.vue +6 -0
  160. package/dist/runtime/editor/features/library/index.vue +14 -0
  161. package/dist/runtime/editor/features/media-library/index.vue +32 -1
  162. package/dist/runtime/editor/features/options/Form/ComplexType/index.d.vue.ts +11 -0
  163. package/dist/runtime/editor/features/options/Form/ComplexType/index.vue +36 -0
  164. package/dist/runtime/editor/features/options/Form/ComplexType/index.vue.d.ts +11 -0
  165. package/dist/runtime/editor/features/options/Form/Item.d.vue.ts +3 -2
  166. package/dist/runtime/editor/features/options/Form/Item.vue +10 -2
  167. package/dist/runtime/editor/features/options/Form/Item.vue.d.ts +3 -2
  168. package/dist/runtime/editor/features/options/Form/index.vue +5 -0
  169. package/dist/runtime/editor/features/search/index.vue +25 -1
  170. package/dist/runtime/editor/features/structure/index.vue +25 -1
  171. package/dist/runtime/editor/features/tour/index.vue +22 -12
  172. package/dist/runtime/editor/helpers/clipboardData/index.d.ts +11 -0
  173. package/dist/runtime/editor/helpers/clipboardData/index.js +157 -0
  174. package/dist/runtime/editor/helpers/options/index.js +5 -0
  175. package/dist/runtime/editor/icons/svg/stars.svg +5 -1
  176. package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +13 -2
  177. package/dist/runtime/editor/plugins/Sidebar/index.vue +4 -2
  178. package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +13 -2
  179. package/dist/runtime/editor/providers/analyze.d.ts +43 -0
  180. package/dist/runtime/editor/providers/analyze.js +78 -0
  181. package/dist/runtime/editor/providers/animation.d.ts +4 -0
  182. package/dist/runtime/editor/providers/animation.js +6 -0
  183. package/dist/runtime/editor/providers/dragdrop.d.ts +55 -0
  184. package/dist/runtime/editor/providers/dragdrop.js +37 -0
  185. package/dist/runtime/editor/providers/storage.js +15 -0
  186. package/dist/runtime/editor/providers/ui.d.ts +6 -0
  187. package/dist/runtime/editor/providers/ui.js +19 -0
  188. package/dist/runtime/editor/translations/de.json +73 -61
  189. package/dist/runtime/editor/translations/fr.json +67 -55
  190. package/dist/runtime/editor/translations/gsw_CH.json +71 -59
  191. package/dist/runtime/editor/translations/it.json +67 -55
  192. package/dist/runtime/editor/types/app.d.ts +4 -2
  193. package/dist/runtime/editor/types/draggable.d.ts +1 -0
  194. package/dist/runtime/editor/types/ui.d.ts +1 -1
  195. package/dist/runtime/helpers/injections.d.ts +1 -1
  196. package/dist/runtime/types/blockOptions.d.ts +2 -1
  197. package/dist/runtime/types/definitions.d.ts +4 -0
  198. package/dist/shared/{editor.CWQIFIEQ.d.mts → editor.BdBm1Z7C.d.mts} +12 -0
  199. package/dist/types.d.mts +1 -1
  200. package/package.json +5 -3
  201. package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.d.vue.ts +0 -3
  202. package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue +0 -29
  203. package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue.d.ts +0 -3
  204. package/dist/runtime/editor/features/clipboard/List/Item/File.d.vue.ts +0 -4
  205. package/dist/runtime/editor/features/clipboard/List/Item/File.vue +0 -60
  206. package/dist/runtime/editor/features/clipboard/List/Item/File.vue.d.ts +0 -4
  207. package/dist/runtime/editor/features/clipboard/List/Item/Video.d.vue.ts +0 -4
  208. package/dist/runtime/editor/features/clipboard/List/Item/Video.vue.d.ts +0 -4
  209. package/dist/runtime/editor/features/clipboard/List/index.d.vue.ts +0 -11
  210. package/dist/runtime/editor/features/clipboard/List/index.vue +0 -72
  211. package/dist/runtime/editor/features/clipboard/List/index.vue.d.ts +0 -11
  212. package/dist/runtime/editor/features/tour/Popup/index.d.vue.ts +0 -9
  213. package/dist/runtime/editor/features/tour/Popup/index.vue +0 -34
  214. package/dist/runtime/editor/features/tour/Popup/index.vue.d.ts +0 -9
  215. package/dist/runtime/editor/providers/dropArea.d.ts +0 -48
  216. package/dist/runtime/editor/providers/dropArea.js +0 -22
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  import { buildSystemPrompt, buildSystemPromptEntries } from "./agentPrompt.js";
2
3
  import { provider, models } from "#blokkli-build/agent-server";
3
4
  import {
@@ -12,7 +13,7 @@ import {
12
13
  verifyStateHash,
13
14
  validateMessages
14
15
  } from "./helpers.js";
15
- import { buildDefinition } from "./server-tools/index.js";
16
+ import { buildDefinition, stripSchemaOverhead } from "./server-tools/index.js";
16
17
  import loadSkillTool from "./server-tools/load_skill/index.js";
17
18
  import loadToolsTool from "./server-tools/load_tools/index.js";
18
19
  import createPlanTool from "./server-tools/create_plan/index.js";
@@ -28,10 +29,10 @@ export class Session {
28
29
  pendingToolCalls = /* @__PURE__ */ new Map();
29
30
  abortController = null;
30
31
  isProcessing = false;
31
- /** Eager tools sent to the LLM on every turn */
32
- tools = [];
33
- /** Lazy tools held back until activated via load_tools */
34
- lazyTools = [];
32
+ /** Names of eager tools sent to the LLM on every turn */
33
+ toolNames = [];
34
+ /** Names of lazy tools held back until activated via load_tools */
35
+ lazyToolNames = [];
35
36
  /** Names of lazy tools that have been activated via load_tools */
36
37
  activatedLazyTools = /* @__PURE__ */ new Set();
37
38
  /** Names of skills that have been loaded via load_skill */
@@ -46,12 +47,73 @@ export class Session {
46
47
  unprunedMessages = [];
47
48
  /** Last generic tool definitions for transcript */
48
49
  lastTools = [];
50
+ /** Bundled tool metadata map for server-side resolution */
51
+ bundledToolMap;
52
+ /** Cache for resolved JSON Schemas (Zod→JSON Schema is deterministic) */
53
+ jsonSchemaCache = /* @__PURE__ */ new Map();
54
+ constructor(toolDefinitions) {
55
+ this.bundledToolMap = new Map(toolDefinitions.map((t) => [t.name, t]));
56
+ }
57
+ /**
58
+ * Resolve a single tool name into a ClientToolDefinition.
59
+ * Resolves from bundled metadata. Caches the JSON Schema conversion.
60
+ */
61
+ resolveToolDefinition(name) {
62
+ const bundled = this.bundledToolMap.get(name);
63
+ if (!bundled) return void 0;
64
+ let inputSchema = this.jsonSchemaCache.get(name);
65
+ if (!inputSchema) {
66
+ inputSchema = stripSchemaOverhead(
67
+ z.toJSONSchema(bundled.paramsSchema)
68
+ );
69
+ this.jsonSchemaCache.set(name, inputSchema);
70
+ }
71
+ return {
72
+ name: bundled.name,
73
+ description: bundled.description,
74
+ input_schema: inputSchema,
75
+ ...bundled.lazy ? { lazy: true } : {},
76
+ category: bundled.category,
77
+ ...bundled.volatile ? { volatile: true } : {}
78
+ };
79
+ }
80
+ /**
81
+ * Resolve multiple tool names into ClientToolDefinition objects.
82
+ * Skips names that cannot be resolved.
83
+ */
84
+ resolveToolDefinitions(names) {
85
+ const result = [];
86
+ for (const name of names) {
87
+ const def = this.resolveToolDefinition(name);
88
+ if (def) {
89
+ result.push(def);
90
+ }
91
+ }
92
+ return result;
93
+ }
94
+ /**
95
+ * Look up name + description for a tool.
96
+ */
97
+ getToolSummary(name) {
98
+ const bundled = this.bundledToolMap.get(name);
99
+ if (!bundled) return void 0;
100
+ return { name: bundled.name, description: bundled.description };
101
+ }
49
102
  // --------------------------------------------------------------------------
50
103
  // Public methods
51
104
  // --------------------------------------------------------------------------
52
- init(tools, pageContext) {
53
- this.tools = tools.filter((t) => !t.lazy);
54
- this.lazyTools = tools.filter((t) => !!t.lazy);
105
+ init(toolNames, pageContext) {
106
+ this.toolNames = [];
107
+ this.lazyToolNames = [];
108
+ for (const name of toolNames) {
109
+ const bundled = this.bundledToolMap.get(name);
110
+ const isLazy = bundled?.lazy ?? false;
111
+ if (isLazy) {
112
+ this.lazyToolNames.push(name);
113
+ } else {
114
+ this.toolNames.push(name);
115
+ }
116
+ }
55
117
  this.activatedLazyTools = /* @__PURE__ */ new Set();
56
118
  this.loadedSkills = /* @__PURE__ */ new Set();
57
119
  this.pageContext = pageContext;
@@ -142,8 +204,8 @@ export class Session {
142
204
  }
143
205
  this.plan = null;
144
206
  this.messages = [];
145
- this.tools = [];
146
- this.lazyTools = [];
207
+ this.toolNames = [];
208
+ this.lazyToolNames = [];
147
209
  this.activatedLazyTools.clear();
148
210
  this.loadedSkills.clear();
149
211
  this.pageContext = void 0;
@@ -188,7 +250,7 @@ export class Session {
188
250
  this.messages = state.messages;
189
251
  this.unprunedMessages = [];
190
252
  this.lastTools = [];
191
- const validLazyToolNames = new Set(this.lazyTools.map((t) => t.name));
253
+ const validLazyToolNames = new Set(this.lazyToolNames);
192
254
  this.activatedLazyTools = new Set(
193
255
  state.activatedLazyTools.filter((name) => validLazyToolNames.has(name))
194
256
  );
@@ -240,7 +302,7 @@ export class Session {
240
302
  });
241
303
  }
242
304
  async runAgentLoop(peer, prompt, apiKey, authSecret, selectedUuids) {
243
- if (this.tools.length === 0) {
305
+ if (this.toolNames.length === 0) {
244
306
  send(peer, {
245
307
  type: "error",
246
308
  errorType: "bad_request",
@@ -257,10 +319,9 @@ export class Session {
257
319
  return;
258
320
  }
259
321
  const resolvedSkills = resolveSkills(this.pageContext);
260
- const lazyToolSummaries = this.lazyTools.map((t) => ({
261
- name: t.name,
262
- description: t.description
263
- }));
322
+ const lazyToolSummaries = this.lazyToolNames.map((name) => this.getToolSummary(name)).filter(
323
+ (s) => s !== void 0
324
+ );
264
325
  const userParts = [];
265
326
  if (selectedUuids?.length) {
266
327
  userParts.push(
@@ -295,11 +356,16 @@ export class Session {
295
356
  let currentToolUse = null;
296
357
  let currentTextContent = "";
297
358
  let inTextBlock = false;
298
- const activatedTools = this.lazyTools.filter(
299
- (t) => this.activatedLazyTools.has(t.name)
359
+ const eagerTools = this.resolveToolDefinitions(this.toolNames);
360
+ const activatedToolNames = this.lazyToolNames.filter(
361
+ (name) => this.activatedLazyTools.has(name)
362
+ );
363
+ const activatedTools = this.resolveToolDefinitions(activatedToolNames);
364
+ const unloadedLazyToolNames = this.lazyToolNames.filter(
365
+ (name) => !this.activatedLazyTools.has(name)
300
366
  );
301
- const unloadedLazyTools = this.lazyTools.filter(
302
- (t) => !this.activatedLazyTools.has(t.name)
367
+ const unloadedLazyTools = unloadedLazyToolNames.map((name) => this.getToolSummary(name)).filter(
368
+ (s) => s !== void 0
303
369
  );
304
370
  const defCtx = {
305
371
  resolvedSkills,
@@ -307,7 +373,7 @@ export class Session {
307
373
  unloadedLazyTools
308
374
  };
309
375
  const serverToolDefs = serverTools.map((t) => buildDefinition(t, defCtx)).filter((d) => d !== null);
310
- const allTools = [...serverToolDefs, ...this.tools, ...activatedTools];
376
+ const allTools = [...serverToolDefs, ...eagerTools, ...activatedTools];
311
377
  this.lastTools = allTools;
312
378
  const systemPrompt = buildSystemPrompt(
313
379
  this.pageContext,
@@ -440,7 +506,7 @@ export class Session {
440
506
  toolUseId: currentToolUse.id,
441
507
  send: (msg) => send(peer, msg),
442
508
  resolvedSkills,
443
- lazyTools: this.lazyTools,
509
+ lazyToolNames: this.lazyToolNames,
444
510
  activatedLazyTools: this.activatedLazyTools,
445
511
  loadedSkills: this.loadedSkills,
446
512
  plan: this.plan,
@@ -476,7 +542,20 @@ export class Session {
476
542
  }
477
543
  };
478
544
  try {
479
- const parsed = matchedServerTool.inputSchema(defCtx).parse(input);
545
+ const coercedInput = {};
546
+ for (const key of Object.keys(input)) {
547
+ const value = input[key];
548
+ if (typeof value === "string" && (value[0] === "[" || value[0] === "{")) {
549
+ try {
550
+ coercedInput[key] = JSON.parse(value);
551
+ } catch {
552
+ coercedInput[key] = value;
553
+ }
554
+ } else {
555
+ coercedInput[key] = value;
556
+ }
557
+ }
558
+ const parsed = matchedServerTool.inputSchema(defCtx).parse(coercedInput);
480
559
  const result = await matchedServerTool.handle(
481
560
  handlerCtx,
482
561
  parsed
@@ -695,9 +774,10 @@ export class Session {
695
774
  */
696
775
  buildToolMetadataMap() {
697
776
  const map = /* @__PURE__ */ new Map();
698
- for (const tool of [...this.tools, ...this.lazyTools]) {
699
- if (tool.volatile) {
700
- map.set(tool.name, { volatile: true });
777
+ for (const name of [...this.toolNames, ...this.lazyToolNames]) {
778
+ const bundled = this.bundledToolMap.get(name);
779
+ if (bundled?.volatile) {
780
+ map.set(name, { volatile: true });
701
781
  }
702
782
  }
703
783
  return map;
@@ -706,10 +786,9 @@ export class Session {
706
786
  const system = this.pageContext ? buildSystemPromptEntries(
707
787
  this.pageContext,
708
788
  resolveSkills(this.pageContext),
709
- this.lazyTools.map((t) => ({
710
- name: t.name,
711
- description: t.description
712
- })),
789
+ this.lazyToolNames.map((name) => this.getToolSummary(name)).filter(
790
+ (s) => s !== void 0
791
+ ),
713
792
  this.getActivePlanContext(),
714
793
  this.loadedSkills
715
794
  ) : [];
@@ -1,9 +1,12 @@
1
1
  import { Session } from './Session.js';
2
+ import type { ServerToolMetadata } from '../shared/types.js';
2
3
  export declare class SessionManager {
4
+ private toolDefinitions;
3
5
  private sessions;
4
6
  /** Maps used token strings to their embedded timestamp (seconds). */
5
7
  private usedTokens;
6
8
  private pruneTimer;
9
+ constructor(toolDefinitions: ServerToolMetadata[]);
7
10
  create(peerId: string): Session;
8
11
  get(peerId: string): Session | undefined;
9
12
  /**
@@ -3,6 +3,9 @@ import { Session } from "./Session.js";
3
3
  const TOKEN_EXPIRY_SECONDS = 300;
4
4
  const SESSION_IDLE_TIMEOUT_MS = 5 * 60 * 1e3;
5
5
  export class SessionManager {
6
+ constructor(toolDefinitions) {
7
+ this.toolDefinitions = toolDefinitions;
8
+ }
6
9
  sessions = /* @__PURE__ */ new Map();
7
10
  /** Maps used token strings to their embedded timestamp (seconds). */
8
11
  usedTokens = /* @__PURE__ */ new Map();
@@ -11,7 +14,7 @@ export class SessionManager {
11
14
  this.pruneTokens();
12
15
  }, 6e4);
13
16
  create(peerId) {
14
- const session = new Session();
17
+ const session = new Session(this.toolDefinitions);
15
18
  this.sessions.set(peerId, { session, lastActivity: Date.now() });
16
19
  return session;
17
20
  }
@@ -2,7 +2,8 @@ import { defineWebSocketHandler, useRuntimeConfig } from "#imports";
2
2
  import { clientMessageSchema } from "../shared/types.js";
3
3
  import { SessionManager } from "./SessionManager.js";
4
4
  import { send } from "./helpers.js";
5
- const sessionManager = new SessionManager();
5
+ import { toolDefinitions } from "#blokkli-build/agent-server";
6
+ const sessionManager = new SessionManager(toolDefinitions);
6
7
  const config = useRuntimeConfig();
7
8
  const authSecret = config.blokkli?.agent?.authSecret || "";
8
9
  const apiKey = config.blokkli?.agent?.apiKey || "";
@@ -69,7 +70,7 @@ export default defineWebSocketHandler({
69
70
  }
70
71
  switch (data.type) {
71
72
  case "init":
72
- session.init(data.tools, data.pageContext);
73
+ session.init(data.toolNames, data.pageContext);
73
74
  break;
74
75
  case "start":
75
76
  if (!apiKey) {
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../skills/index.js").SkillDefinition;
2
+ export default _default;
@@ -0,0 +1,69 @@
1
+ import { defineBlokkliAgentSkill } from "../skills/index.js";
2
+ export default defineBlokkliAgentSkill({
3
+ name: "fix-readability",
4
+ label: { en: "Fix Readability", de: "Lesbarkeit verbessern" },
5
+ description: "Load this skill when asked to check, fix, or improve readability of texts on the page.",
6
+ getContents: () => `
7
+ # Fix Readability - Iterative Workflow
8
+
9
+ Fixing readability is an **iterative process**. You must verify your rewrites actually improved the scores before moving on.
10
+
11
+ ## Step 1: Analyze
12
+
13
+ Call \`get_readability_issues\` to get current issues.
14
+
15
+ The result is an object keyed by paragraph UUID, then by field name:
16
+ \`\`\`
17
+ {
18
+ "<uuid>": {
19
+ "<fieldName>": {
20
+ "fieldValue": "current text",
21
+ "issues": [
22
+ { "text": "flagged segment", "impact": "critical", "scores": { "lix": 85 } }
23
+ ]
24
+ }
25
+ }
26
+ }
27
+ \`\`\`
28
+
29
+ - \`fieldValue\` is the full editable field content.
30
+ - Each issue is a text segment within the field that was flagged, with its own scores.
31
+ - A field can have multiple issues (e.g. a rich text field with several hard-to-read paragraphs).
32
+
33
+ ## Step 2: Pre-check with \`check_readability_for_texts\`
34
+
35
+ Before applying a rewrite, use \`check_readability_for_texts\` to verify your rewritten text actually scores better. Pass the proposed new text and check that the scores improved compared to the original.
36
+
37
+ This is cheap and fast \u2014 use it to iterate on your wording before committing a rewrite.
38
+
39
+ ## Step 3: Rewrite
40
+
41
+ Use \`batch_rewrite_text\` to apply the improved texts. The UUID and field name from the analyze result map directly to the batch_rewrite_text input:
42
+ \`\`\`
43
+ { "uuids": { "<uuid>": { "<fieldName>": "improved text" } } }
44
+ \`\`\`
45
+
46
+ When rewriting:
47
+ - Use shorter sentences and simpler words.
48
+ - Keep the original meaning and tone.
49
+ - Focus on fields with "critical" and "serious" impact first.
50
+
51
+ ## Step 4: Verify
52
+
53
+ After the rewrites are applied, call \`get_readability_issues\` **again** to check if the issues are resolved.
54
+
55
+ - If issues remain: rewrite again with different wording.
56
+ - If new issues appeared: fix those too.
57
+ - Repeat until no more readability issues are reported.
58
+
59
+ **Do NOT skip the verification step.** A rewrite can easily make readability worse if sentences become longer or more complex.
60
+
61
+ ## Important
62
+
63
+ - Always pre-check with \`check_readability_for_texts\` before applying rewrites.
64
+ - Always verify with \`get_readability_issues\` after applying rewrites.
65
+ - Never assume a rewrite fixed the issue.
66
+ - The scores (LIX, CLI, ARI) measure sentence length and word complexity. Lower is easier to read.
67
+ - LIX above 60 is flagged. Above 70 is critical.
68
+ `
69
+ });
@@ -51,6 +51,34 @@ export default defineBlokkliAgentSystemPrompt({
51
51
  lines.push(formatContentField(field));
52
52
  }
53
53
  }
54
+ if (pageContext.contentSearchTabs?.length) {
55
+ lines.push(
56
+ "",
57
+ "## Content Search Tabs",
58
+ "",
59
+ "Use the `search_content` tool with one of these tab IDs to search for content:",
60
+ ""
61
+ );
62
+ for (const tab of pageContext.contentSearchTabs) {
63
+ const typesDescription = tab.types.map((t) => `${t.type} (${t.bundles.join(", ")})`).join(", ");
64
+ lines.push(`- **\`${tab.id}\`** \u2014 ${tab.title}: ${typesDescription}`);
65
+ }
66
+ }
67
+ if (pageContext.analyzers?.length) {
68
+ lines.push(
69
+ "",
70
+ "## Available Analyzers",
71
+ "",
72
+ "Use `get_readability_issues` to run all readability analyzers. The following analyzers are available:",
73
+ ""
74
+ );
75
+ for (const a of pageContext.analyzers) {
76
+ const parts = [`- **\`${a.id}\`**`];
77
+ if (a.label) parts.push(`\u2014 ${a.label}`);
78
+ if (a.description) parts.push(`: ${a.description}`);
79
+ lines.push(parts.join(""));
80
+ }
81
+ }
54
82
  const editModeDescription = getEditModeDescription(pageContext.editMode);
55
83
  if (editModeDescription) {
56
84
  lines.push("", "## Edit Mode", "", editModeDescription);
@@ -23,7 +23,10 @@ export type ToolResultEntry = {
23
23
  export type ToolDefinitionContext = {
24
24
  resolvedSkills: ResolvedSkill[];
25
25
  plan: ServerPlan | null;
26
- unloadedLazyTools: ClientToolDefinition[];
26
+ unloadedLazyTools: {
27
+ name: string;
28
+ description: string;
29
+ }[];
27
30
  };
28
31
  /**
29
32
  * Context passed to `handle()` — provides access to session state
@@ -33,7 +36,7 @@ export type ServerToolContext = {
33
36
  toolUseId: string;
34
37
  send: (message: ServerMessage) => void;
35
38
  resolvedSkills: ResolvedSkill[];
36
- lazyTools: ClientToolDefinition[];
39
+ lazyToolNames: string[];
37
40
  activatedLazyTools: Set<string>;
38
41
  loadedSkills: Set<string>;
39
42
  plan: ServerPlan | null;
@@ -79,6 +82,11 @@ export type ServerSideTool<T extends z.ZodType = z.ZodType> = {
79
82
  * Identity function for type inference when defining a server-side tool.
80
83
  */
81
84
  export declare function defineServerSideTool<T extends z.ZodType>(tool: ServerSideTool<T>): ServerSideTool<T>;
85
+ /**
86
+ * Recursively strip $schema and additionalProperties from a JSON Schema object.
87
+ * These are unnecessary for the LLM and waste context window tokens.
88
+ */
89
+ export declare function stripSchemaOverhead(obj: unknown): unknown;
82
90
  /**
83
91
  * Build a ClientToolDefinition from a ServerSideTool for a given context.
84
92
  * Returns null when the tool should not be offered this turn.
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  export function defineServerSideTool(tool) {
3
3
  return tool;
4
4
  }
5
- function stripSchemaOverhead(obj) {
5
+ export function stripSchemaOverhead(obj) {
6
6
  if (Array.isArray(obj)) {
7
7
  return obj.map(stripSchemaOverhead);
8
8
  }
@@ -18,7 +18,7 @@ export default defineServerSideTool({
18
18
  handle(ctx, input) {
19
19
  const loaded = [];
20
20
  for (const name of input.tools) {
21
- if (ctx.lazyTools.some((t) => t.name === name)) {
21
+ if (ctx.lazyToolNames.includes(name)) {
22
22
  ctx.activatedLazyTools.add(name);
23
23
  loaded.push(name);
24
24
  }
@@ -113,6 +113,21 @@ export type BlockBundle = {
113
113
  * Edit mode determines what actions the user is allowed to perform.
114
114
  */
115
115
  export type EditMode = 'readonly' | 'editing' | 'translating' | 'review';
116
+ /**
117
+ * Server-side tool metadata extracted at build time.
118
+ * Contains only static properties needed by the server — no execute(), label(),
119
+ * component, or other runtime-only fields.
120
+ */
121
+ export type ServerToolMetadata = {
122
+ name: string;
123
+ description: string;
124
+ category: 'query' | 'mutation';
125
+ modes: EditMode[];
126
+ paramsSchema: z.ZodType;
127
+ lazy?: boolean;
128
+ volatile?: boolean;
129
+ requiredAdapterMethods?: string[];
130
+ };
116
131
  /**
117
132
  * Fragment definition for reusable content blocks.
118
133
  */
@@ -152,6 +167,22 @@ export type PageContext = {
152
167
  fragments: Fragment[];
153
168
  /** Content fields on the page entity itself (e.g., lead text, hero image) */
154
169
  entityContentFields: BlockBundleContentField[];
170
+ /** Available content search tabs (for the search_content tool) */
171
+ contentSearchTabs?: {
172
+ id: string;
173
+ title: string;
174
+ types: {
175
+ type: string;
176
+ bundles: string[];
177
+ }[];
178
+ }[];
179
+ /** Available content analyzers (for the get_readability_issues tool) */
180
+ analyzers?: {
181
+ id: string;
182
+ type?: string;
183
+ label?: string;
184
+ description?: string;
185
+ }[];
155
186
  };
156
187
  /**
157
188
  * Classified error categories for AI provider errors.
@@ -266,17 +297,7 @@ export declare const clientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
266
297
  authToken: z.ZodString;
267
298
  }, z.core.$strip>, z.ZodObject<{
268
299
  type: z.ZodLiteral<"init">;
269
- tools: z.ZodArray<z.ZodObject<{
270
- name: z.ZodString;
271
- description: z.ZodString;
272
- input_schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
273
- lazy: z.ZodOptional<z.ZodBoolean>;
274
- category: z.ZodOptional<z.ZodEnum<{
275
- query: "query";
276
- mutation: "mutation";
277
- }>>;
278
- volatile: z.ZodOptional<z.ZodBoolean>;
279
- }, z.core.$strip>>;
300
+ toolNames: z.ZodArray<z.ZodString>;
280
301
  pageContext: z.ZodObject<{
281
302
  title: z.ZodString;
282
303
  entityType: z.ZodString;
@@ -347,6 +368,20 @@ export declare const clientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
347
368
  bundles: z.ZodArray<z.ZodString>;
348
369
  }, z.core.$strip>>;
349
370
  }, z.core.$strip>]>>;
371
+ contentSearchTabs: z.ZodOptional<z.ZodArray<z.ZodObject<{
372
+ id: z.ZodString;
373
+ title: z.ZodString;
374
+ types: z.ZodArray<z.ZodObject<{
375
+ type: z.ZodString;
376
+ bundles: z.ZodArray<z.ZodString>;
377
+ }, z.core.$strip>>;
378
+ }, z.core.$strip>>>;
379
+ analyzers: z.ZodOptional<z.ZodArray<z.ZodObject<{
380
+ id: z.ZodString;
381
+ type: z.ZodOptional<z.ZodString>;
382
+ label: z.ZodOptional<z.ZodString>;
383
+ description: z.ZodOptional<z.ZodString>;
384
+ }, z.core.$strip>>>;
350
385
  }, z.core.$strip>;
351
386
  }, z.core.$strip>, z.ZodObject<{
352
387
  type: z.ZodLiteral<"start">;
@@ -66,7 +66,27 @@ const pageContextSchema = z.object({
66
66
  isPublished: z.boolean().nullable(),
67
67
  editMode: z.enum(["readonly", "editing", "translating", "review"]),
68
68
  fragments: z.array(fragmentSchema),
69
- entityContentFields: z.array(blockBundleContentFieldSchema)
69
+ entityContentFields: z.array(blockBundleContentFieldSchema),
70
+ contentSearchTabs: z.array(
71
+ z.object({
72
+ id: z.string(),
73
+ title: z.string(),
74
+ types: z.array(
75
+ z.object({
76
+ type: z.string(),
77
+ bundles: z.array(z.string())
78
+ })
79
+ )
80
+ })
81
+ ).optional(),
82
+ analyzers: z.array(
83
+ z.object({
84
+ id: z.string(),
85
+ type: z.string().optional(),
86
+ label: z.string().optional(),
87
+ description: z.string().optional()
88
+ })
89
+ ).optional()
70
90
  });
71
91
  const pageStructureBlockSchema = z.lazy(
72
92
  () => z.object({
@@ -81,14 +101,6 @@ export const pageStructureSchema = z.object({
81
101
  fields: z.record(z.string(), z.array(pageStructureBlockSchema)),
82
102
  entityContentFields: z.record(z.string(), z.string()).optional()
83
103
  });
84
- const clientToolDefinitionSchema = z.object({
85
- name: z.string(),
86
- description: z.string(),
87
- input_schema: z.record(z.string(), z.unknown()),
88
- lazy: z.boolean().optional(),
89
- category: z.enum(["query", "mutation"]).optional(),
90
- volatile: z.boolean().optional()
91
- });
92
104
  const genericContentBlockSchema = z.discriminatedUnion("type", [
93
105
  z.object({ type: z.literal("text"), text: z.string() }),
94
106
  z.object({ type: z.literal("skill"), name: z.string(), text: z.string() }),
@@ -118,7 +130,7 @@ export const clientMessageSchema = z.discriminatedUnion("type", [
118
130
  z.object({ type: z.literal("authenticate"), authToken: z.string() }),
119
131
  z.object({
120
132
  type: z.literal("init"),
121
- tools: z.array(clientToolDefinitionSchema),
133
+ toolNames: z.array(z.string()),
122
134
  pageContext: pageContextSchema
123
135
  }),
124
136
  z.object({
@@ -1,4 +1,4 @@
1
- import { B as BlokkliModule } from '../../shared/editor.CWQIFIEQ.mjs';
1
+ import { B as BlokkliModule } from '../../shared/editor.BdBm1Z7C.mjs';
2
2
  import 'nuxt/schema';
3
3
  import 'consola';
4
4
  import '../../../dist/global/types/definitions.js';
@@ -17,6 +17,10 @@ import type { ChartColor } from '#blokkli/charts/types'
17
17
 
18
18
  export const COLORS: Record<string, ChartColor>
19
19
  `;
20
+ },
21
+ {
22
+ context: "both",
23
+ write: true
20
24
  }
21
25
  );
22
26
  }
@@ -29,14 +33,24 @@ const index = defineBlokkliModule({
29
33
  options.blokkliDirs ??= [];
30
34
  options.blokkliDirs.push(resolve("./runtime/blokkli"));
31
35
  },
32
- setup(ctx, options) {
33
- ctx.context.blocks.addFile(
34
- resolve("./runtime/components/Fragment/BlokkliChart.vue")
36
+ setup({ context, helper, $t }, options) {
37
+ context.features.addFile(resolve("./runtime/features/charts/index.vue"));
38
+ context.addTemplate(chartsConfigTemplate(options));
39
+ helper.addAlias("#blokkli/charts/types", resolve("./runtime/types"));
40
+ helper.addAlias(
41
+ "#blokkli/charts/components",
42
+ resolve("./runtime/components")
35
43
  );
36
- ctx.context.features.addFile(resolve("./runtime/features/charts/index.vue"));
37
- ctx.context.addFeatureFragment("blokkli_chart");
38
- ctx.context.addTemplate(chartsConfigTemplate(options));
39
- ctx.helper.addAlias("#blokkli/charts/types", resolve("./runtime/types"));
44
+ context.registerComplexOptionType({
45
+ id: "chart",
46
+ typeName: "BlokkliChartData",
47
+ typePath: resolve("./runtime/types"),
48
+ editorComponentPath: resolve(
49
+ "./runtime/features/charts/Editor/index.vue"
50
+ ),
51
+ editorButtonLabel: $t("chartsEditButton", "Edit chart..."),
52
+ editorIcon: "bk_mdi_area_chart"
53
+ });
40
54
  }
41
55
  });
42
56