@blokkli/editor 2.0.0-alpha.39 → 2.0.0-alpha.40

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 (160) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +15 -105
  3. package/dist/modules/agent/index.d.mts +1 -0
  4. package/dist/modules/agent/index.mjs +81 -8
  5. package/dist/modules/agent/runtime/app/composables/agentProvider.d.ts +8 -3
  6. package/dist/modules/agent/runtime/app/composables/agentProvider.js +108 -13
  7. package/dist/modules/agent/runtime/app/features/agent/Panel/DebugGallery/index.vue +7 -6
  8. package/dist/modules/agent/runtime/app/features/agent/Panel/index.d.vue.ts +2 -2
  9. package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue +12 -10
  10. package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue.d.ts +2 -2
  11. package/dist/modules/agent/runtime/app/features/agent/index.vue +29 -5
  12. package/dist/modules/agent/runtime/app/helpers/pageStructure.js +7 -17
  13. package/dist/modules/agent/runtime/app/prompts/fixReadability.d.ts +2 -0
  14. package/dist/modules/agent/runtime/app/prompts/fixReadability.js +49 -0
  15. package/dist/modules/agent/runtime/app/tools/add_paragraphs/index.js +1 -0
  16. package/dist/modules/agent/runtime/app/tools/check_readability/index.js +24 -15
  17. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.d.vue.ts +46 -0
  18. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.vue +739 -0
  19. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.vue.d.ts +46 -0
  20. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Details/index.d.vue.ts +6 -0
  21. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Details/index.vue +38 -0
  22. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Details/index.vue.d.ts +6 -0
  23. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/index.d.ts +38 -0
  24. package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/index.js +115 -0
  25. package/dist/modules/agent/runtime/app/tools/delete_paragraphs/index.js +1 -0
  26. package/dist/modules/agent/runtime/app/tools/get_all_page_content/index.js +3 -5
  27. package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +1 -0
  28. package/dist/modules/agent/runtime/app/tools/get_child_paragraphs/index.js +1 -0
  29. package/dist/modules/agent/runtime/app/tools/get_content_fields/index.js +4 -7
  30. package/dist/modules/agent/runtime/app/tools/get_page_structure/index.js +1 -0
  31. package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +10 -17
  32. package/dist/modules/agent/runtime/app/tools/get_paragraph_options/index.js +1 -0
  33. package/dist/modules/agent/runtime/app/tools/get_paragraphs_in_viewport/index.js +1 -0
  34. package/dist/modules/agent/runtime/app/tools/get_readability_issues/index.js +17 -70
  35. package/dist/modules/agent/runtime/app/tools/get_selected_paragraphs/index.js +1 -0
  36. package/dist/modules/agent/runtime/app/tools/helpers.d.ts +38 -10
  37. package/dist/modules/agent/runtime/app/tools/helpers.js +90 -27
  38. package/dist/modules/agent/runtime/app/tools/move_paragraphs/index.js +1 -0
  39. package/dist/modules/agent/runtime/app/tools/rearrange_paragraphs/index.js +1 -0
  40. package/dist/modules/agent/runtime/app/tools/schemas.d.ts +1 -1
  41. package/dist/modules/agent/runtime/app/tools/update_text_fields/Component.vue +66 -84
  42. package/dist/modules/agent/runtime/app/tools/update_text_fields/index.d.ts +8 -1
  43. package/dist/modules/agent/runtime/app/tools/update_text_fields/index.js +21 -14
  44. package/dist/modules/agent/runtime/app/types/index.d.ts +41 -0
  45. package/dist/modules/agent/runtime/server/Session.d.ts +8 -1
  46. package/dist/modules/agent/runtime/server/Session.js +154 -6
  47. package/dist/modules/agent/runtime/server/agent.js +5 -1
  48. package/dist/modules/agent/runtime/server/default-skills/fixReadability.js +31 -51
  49. package/dist/modules/agent/runtime/server/default-skills/rewriteAndTranslate.js +45 -4
  50. package/dist/modules/agent/runtime/server/providers/anthropic.js +2 -1
  51. package/dist/modules/agent/runtime/server/providers/openai.js +2 -1
  52. package/dist/modules/agent/runtime/server/providers/types.d.ts +2 -0
  53. package/dist/modules/agent/runtime/server/route.d.ts +2 -0
  54. package/dist/modules/agent/runtime/server/route.js +40 -0
  55. package/dist/modules/agent/runtime/server/routing.d.ts +18 -0
  56. package/dist/modules/agent/runtime/server/routing.js +111 -0
  57. package/dist/modules/agent/runtime/server/skills/types.d.ts +10 -0
  58. package/dist/modules/agent/runtime/server/stream.d.ts +2 -0
  59. package/dist/modules/agent/runtime/server/stream.js +190 -0
  60. package/dist/modules/agent/runtime/server/streamParser.d.ts +85 -0
  61. package/dist/modules/agent/runtime/server/streamParser.js +227 -0
  62. package/dist/modules/agent/runtime/server/templates/defineStreamTemplate.d.ts +21 -0
  63. package/dist/modules/agent/runtime/server/templates/defineStreamTemplate.js +3 -0
  64. package/dist/modules/agent/runtime/server/templates/definitions/fixReadability.d.ts +26 -0
  65. package/dist/modules/agent/runtime/server/templates/definitions/fixReadability.js +84 -0
  66. package/dist/modules/agent/runtime/server/templates/definitions/generateContent.d.ts +6 -0
  67. package/dist/modules/agent/runtime/server/templates/definitions/generateContent.js +29 -0
  68. package/dist/modules/agent/runtime/server/templates/definitions/rewrite.d.ts +5 -0
  69. package/dist/modules/agent/runtime/server/templates/definitions/rewrite.js +14 -0
  70. package/dist/modules/agent/runtime/server/templates/definitions/translate.d.ts +5 -0
  71. package/dist/modules/agent/runtime/server/templates/definitions/translate.js +23 -0
  72. package/dist/modules/agent/runtime/server/templates/index.d.ts +37 -0
  73. package/dist/modules/agent/runtime/server/templates/index.js +25 -0
  74. package/dist/modules/agent/runtime/server/templates/types.d.ts +17 -0
  75. package/dist/modules/agent/runtime/server/templates/types.js +0 -0
  76. package/dist/modules/agent/runtime/server/templates/utils.d.ts +5 -0
  77. package/dist/modules/agent/runtime/server/templates/utils.js +69 -0
  78. package/dist/modules/agent/runtime/shared/types.d.ts +18 -0
  79. package/dist/modules/agent/runtime/shared/types.js +16 -1
  80. package/dist/runtime/components/BlokkliItem.d.vue.ts +1 -1
  81. package/dist/runtime/components/BlokkliItem.vue +34 -3
  82. package/dist/runtime/components/BlokkliItem.vue.d.ts +1 -1
  83. package/dist/runtime/editor/components/Actions/index.vue +2 -2
  84. package/dist/runtime/editor/components/AnimationCanvas/index.vue +23 -2
  85. package/dist/runtime/editor/components/DiffApproval/Highlight/Item.d.vue.ts +19 -0
  86. package/dist/runtime/editor/components/DiffApproval/Highlight/Item.vue +106 -0
  87. package/dist/runtime/editor/components/DiffApproval/Highlight/Item.vue.d.ts +19 -0
  88. package/dist/runtime/editor/components/DiffApproval/Highlight/index.d.vue.ts +22 -0
  89. package/dist/runtime/editor/components/DiffApproval/Highlight/index.vue +50 -0
  90. package/dist/runtime/editor/components/DiffApproval/Highlight/index.vue.d.ts +22 -0
  91. package/dist/runtime/editor/components/DiffApproval/Toolbar/index.d.vue.ts +24 -0
  92. package/dist/runtime/editor/components/DiffApproval/Toolbar/index.vue +113 -0
  93. package/dist/runtime/editor/components/DiffApproval/Toolbar/index.vue.d.ts +24 -0
  94. package/dist/runtime/editor/components/DiffApproval/index.d.vue.ts +19 -0
  95. package/dist/runtime/editor/components/DiffApproval/index.vue +158 -0
  96. package/dist/runtime/editor/components/DiffApproval/index.vue.d.ts +19 -0
  97. package/dist/runtime/editor/components/DiffApproval/types.d.ts +7 -0
  98. package/dist/runtime/editor/components/DiffApproval/types.js +0 -0
  99. package/dist/runtime/editor/components/DiffViewer/DiffValue.vue +2 -11
  100. package/dist/runtime/editor/components/DraggableList.vue +1 -1
  101. package/dist/runtime/editor/components/EditProvider.vue +18 -1
  102. package/dist/runtime/editor/components/ShortcutIndicator/index.d.vue.ts +2 -2
  103. package/dist/runtime/editor/components/ShortcutIndicator/index.vue +27 -33
  104. package/dist/runtime/editor/components/ShortcutIndicator/index.vue.d.ts +2 -2
  105. package/dist/runtime/editor/components/index.d.ts +2 -1
  106. package/dist/runtime/editor/components/index.js +2 -0
  107. package/dist/runtime/editor/composables/useEditableFieldOverride.d.ts +2 -0
  108. package/dist/runtime/editor/composables/useEditableFieldOverride.js +21 -15
  109. package/dist/runtime/editor/css/output.css +1 -1
  110. package/dist/runtime/editor/events/index.d.ts +3 -0
  111. package/dist/runtime/editor/features/add-list/index.vue +1 -0
  112. package/dist/runtime/editor/features/analyze/Main.vue +1 -1
  113. package/dist/runtime/editor/features/analyze/analyzers/helpers/Context.d.ts +7 -2
  114. package/dist/runtime/editor/features/analyze/analyzers/helpers/Context.js +6 -1
  115. package/dist/runtime/editor/features/analyze/analyzers/readability.js +52 -222
  116. package/dist/runtime/editor/features/analyze/analyzers/types.d.ts +2 -2
  117. package/dist/runtime/editor/features/analyze/readability/adapterTypes.d.ts +9 -0
  118. package/dist/runtime/editor/features/analyze/readability/adapterTypes.js +0 -0
  119. package/dist/runtime/editor/features/analyze/readability/builtinAnalyzer.d.ts +6 -0
  120. package/dist/runtime/editor/features/analyze/readability/builtinAnalyzer.js +200 -0
  121. package/dist/runtime/editor/features/analyze/readability/chunkHtml.d.ts +15 -0
  122. package/dist/runtime/editor/features/analyze/readability/chunkHtml.js +97 -0
  123. package/dist/runtime/editor/features/analyze/readability/types.d.ts +72 -0
  124. package/dist/runtime/editor/features/analyze/readability/types.js +0 -0
  125. package/dist/runtime/editor/features/artboard/Renderer.vue +9 -5
  126. package/dist/runtime/editor/features/breadcrumbs/index.vue +1 -1
  127. package/dist/runtime/editor/features/dragging-overlay/index.vue +1 -1
  128. package/dist/runtime/editor/features/editable-field/index.vue +1 -1
  129. package/dist/runtime/editor/features/hover/index.vue +1 -1
  130. package/dist/runtime/editor/features/options/index.vue +1 -1
  131. package/dist/runtime/editor/features/selection/AddButtons/Renderer/index.vue +1 -1
  132. package/dist/runtime/editor/features/selection/index.vue +2 -2
  133. package/dist/runtime/editor/features/structure/List/Item/index.vue +1 -3
  134. package/dist/runtime/editor/helpers/diff/index.d.ts +11 -0
  135. package/dist/runtime/editor/helpers/diff/index.js +227 -0
  136. package/dist/runtime/editor/plugins/Sidebar/index.vue +1 -1
  137. package/dist/runtime/editor/providers/analyze.d.ts +2 -1
  138. package/dist/runtime/editor/providers/analyze.js +6 -3
  139. package/dist/runtime/editor/providers/directive.js +1 -0
  140. package/dist/runtime/editor/providers/fieldValue.d.ts +54 -0
  141. package/dist/runtime/editor/providers/fieldValue.js +126 -0
  142. package/dist/runtime/editor/providers/fieldValueAdapterTypes.d.ts +13 -0
  143. package/dist/runtime/editor/providers/fieldValueAdapterTypes.js +0 -0
  144. package/dist/runtime/editor/providers/readability.d.ts +23 -0
  145. package/dist/runtime/editor/providers/readability.js +130 -0
  146. package/dist/runtime/editor/providers/state.d.ts +16 -0
  147. package/dist/runtime/editor/providers/state.js +19 -1
  148. package/dist/runtime/editor/providers/ui.d.ts +7 -0
  149. package/dist/runtime/editor/providers/ui.js +7 -1
  150. package/dist/runtime/editor/translations/de.json +80 -8
  151. package/dist/runtime/editor/translations/fr.json +80 -8
  152. package/dist/runtime/editor/translations/gsw_CH.json +80 -8
  153. package/dist/runtime/editor/translations/it.json +80 -8
  154. package/dist/runtime/editor/types/app.d.ts +4 -0
  155. package/dist/shared/editor.9vf8ZnOp.mjs +288 -0
  156. package/package.json +2 -2
  157. package/dist/modules/agent/runtime/app/tools/update_text_fields/Item.d.vue.ts +0 -22
  158. package/dist/modules/agent/runtime/app/tools/update_text_fields/Item.vue +0 -95
  159. package/dist/modules/agent/runtime/app/tools/update_text_fields/Item.vue.d.ts +0 -22
  160. package/dist/shared/editor.BFIzNSQM.mjs +0 -146
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <DropHandler
3
- v-if="hasBeenReady || debugStyling"
3
+ v-if="hasBeenReady || DEBUG_STYLING"
4
4
  class="bk bk-agent-panel"
5
5
  @mousedown.capture.stop
6
6
  @pointerdown.capture.stop
@@ -17,13 +17,13 @@
17
17
  >
18
18
  <div ref="conversationContainer" class="bk-agent-panel-conversation">
19
19
  <button
20
- v-if="debugStyling"
20
+ v-if="DEBUG_STYLING"
21
21
  class="bk-button"
22
22
  @click="debugShowPlan = !debugShowPlan"
23
23
  >
24
24
  {{ debugShowPlan ? "Hide" : "Show" }} Plan
25
25
  </button>
26
- <DebugGallery v-if="debugStyling" />
26
+ <DebugGallery v-if="DEBUG_STYLING" />
27
27
  <template v-else>
28
28
  <Welcome v-if="showWelcome" :agent-name @prompt="onWelcomePrompt" />
29
29
  <Conversation
@@ -70,7 +70,7 @@
70
70
  >
71
71
  <TransitionHeight opacity :duration="300">
72
72
  <div
73
- v-if="!isConnected && hasBeenReady && !debugStyling"
73
+ v-if="!isConnected && hasBeenReady && !DEBUG_STYLING"
74
74
  class="bk-agent-disconnected"
75
75
  >
76
76
  <Icon name="loader" />
@@ -141,7 +141,6 @@ import { itemEntityType } from "#blokkli-build/config";
141
141
  const props = defineProps({
142
142
  agentName: { type: String, required: true },
143
143
  isShown: { type: Boolean, required: true },
144
- debugStyling: { type: Boolean, required: false },
145
144
  conversation: { type: Array, required: true },
146
145
  activeItem: { type: null, required: true },
147
146
  isThinking: { type: Boolean, required: true },
@@ -155,15 +154,17 @@ const props = defineProps({
155
154
  conversationList: { type: Array, required: true },
156
155
  showConversationList: { type: Boolean, required: true },
157
156
  plan: { type: [Object, null], required: true },
158
- usageTurns: { type: Array, required: true }
157
+ usageTurns: { type: Array, required: true },
158
+ pageContext: { type: [Object, null], required: true }
159
159
  });
160
160
  const emit = defineEmits(["connect", "sendPrompt", "cancel", "approve", "reject", "setAutoApprove", "newConversation", "getTranscript", "toolComponentDone", "switchConversation", "deleteConversation", "showConversations", "hideConversations", "retry", "approvePlan", "rejectPlan"]);
161
+ const DEBUG_STYLING = import.meta.dev && false;
161
162
  const app = useBlokkli();
162
163
  const { $t } = app;
163
164
  watch(
164
165
  () => props.isShown,
165
166
  (isShown) => {
166
- if (isShown && !props.debugStyling) {
167
+ if (isShown && !DEBUG_STYLING) {
167
168
  emit("connect");
168
169
  }
169
170
  },
@@ -172,7 +173,8 @@ watch(
172
173
  const toolContext = computed(() => ({
173
174
  app,
174
175
  itemEntityType,
175
- adapter: app.adapter
176
+ adapter: app.adapter,
177
+ pageContext: props.pageContext
176
178
  }));
177
179
  const pendingToolComponent = computed(() => {
178
180
  if (!props.pendingToolCall) return null;
@@ -237,13 +239,13 @@ const debugPlan = {
237
239
  };
238
240
  const debugShowPlan = ref(true);
239
241
  const debugIsProcessing = computed(() => {
240
- if (props.debugStyling) {
242
+ if (DEBUG_STYLING) {
241
243
  return debugShowPlan.value;
242
244
  }
243
245
  return props.isProcessing;
244
246
  });
245
247
  const activePlan = computed(() => {
246
- return props.debugStyling ? debugShowPlan.value ? debugPlan : null : props.plan;
248
+ return DEBUG_STYLING ? debugShowPlan.value ? debugPlan : null : props.plan;
247
249
  });
248
250
  const isPlanPendingApproval = computed(() => {
249
251
  return activePlan.value !== null && activePlan.value.steps.every((s) => s.status === "pending");
@@ -1,10 +1,9 @@
1
1
  import type { AgentConversationSummary, PendingMutationState, PendingToolCall } from '#blokkli/agent/app/composables';
2
2
  import type { ConversationItem, ActiveItem } from '#blokkli/agent/app/types';
3
- import type { ClientPlanState, UsageTurn } from '#blokkli/agent/shared/types';
3
+ import type { ClientPlanState, PageContext, UsageTurn } from '#blokkli/agent/shared/types';
4
4
  type __VLS_Props = {
5
5
  agentName: string;
6
6
  isShown: boolean;
7
- debugStyling?: boolean;
8
7
  conversation: ConversationItem[];
9
8
  activeItem: ActiveItem | null;
10
9
  isThinking: boolean;
@@ -19,6 +18,7 @@ type __VLS_Props = {
19
18
  showConversationList: boolean;
20
19
  plan: ClientPlanState | null;
21
20
  usageTurns: UsageTurn[];
21
+ pageContext: PageContext | null;
22
22
  };
23
23
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
24
24
  cancel: () => any;
@@ -19,7 +19,6 @@
19
19
  <template #default="{ isShown }">
20
20
  <AgentPanel
21
21
  :is-shown
22
- :debug-styling="DEBUG_STYLING"
23
22
  :agent-name
24
23
  :conversation
25
24
  :active-item
@@ -35,6 +34,7 @@
35
34
  :plan
36
35
  :tool-details
37
36
  :usage-turns="usageTurns"
37
+ :page-context="pageContext"
38
38
  @connect="connect"
39
39
  @send-prompt="sendPrompt"
40
40
  @retry="retry"
@@ -108,7 +108,6 @@ import { agentPrompts, agentName } from "#blokkli-build/agent-client";
108
108
  import AgentPanel from "./Panel/index.vue";
109
109
  import AgentTranscript from "./Transcript/index.vue";
110
110
  import { defineItemDropdownAction } from "#blokkli/editor/composables";
111
- const DEBUG_STYLING = false;
112
111
  const { adapter } = defineBlokkliFeature({
113
112
  id: "agent",
114
113
  icon: "stars",
@@ -162,6 +161,7 @@ const {
162
161
  rejectPlan,
163
162
  usageTurns,
164
163
  sendPrompt,
164
+ runToolForPrompt,
165
165
  retry,
166
166
  approve,
167
167
  reject,
@@ -177,7 +177,8 @@ const {
177
177
  showConversationList,
178
178
  switchConversation,
179
179
  deleteConversation,
180
- refreshConversationList
180
+ refreshConversationList,
181
+ pageContext
181
182
  } = agentProvider(app, adapter, agentName);
182
183
  async function onShowConversations() {
183
184
  await refreshConversationList();
@@ -203,9 +204,32 @@ defineItemDropdownAction(() => {
203
204
  group: "agent",
204
205
  variant: "agent",
205
206
  weight: -900,
206
- callback: () => {
207
+ callback: async () => {
207
208
  app.eventBus.emit("sidebar:open", "agent");
208
- sendPrompt(promptText, userPromptText, [...app.selection.uuids.value]);
209
+ const selectedUuids = [...app.selection.uuids.value];
210
+ let preSeededResults = void 0;
211
+ let autoExecuteTools = void 0;
212
+ if (prompt.preExecute) {
213
+ const preResult = await prompt.preExecute({
214
+ app,
215
+ selectedUuids,
216
+ runTool: runToolForPrompt
217
+ });
218
+ if (preResult) {
219
+ preSeededResults = preResult.preSeededResults;
220
+ autoExecuteTools = preResult.autoExecuteTools;
221
+ }
222
+ }
223
+ sendPrompt(
224
+ promptText,
225
+ userPromptText,
226
+ selectedUuids,
227
+ void 0,
228
+ prompt.tools,
229
+ prompt.skills,
230
+ preSeededResults,
231
+ autoExecuteTools
232
+ );
209
233
  }
210
234
  };
211
235
  });
@@ -1,39 +1,30 @@
1
- import {
2
- getFieldType,
3
- getEditableValue,
4
- getParagraphChildren
5
- } from "#blokkli/agent/app/tools/helpers";
1
+ import { getParagraphChildren } from "#blokkli/agent/app/tools/helpers";
6
2
  import { itemEntityType } from "#blokkli-build/config";
7
3
  const MAX_CONTENT_LENGTH = 150;
8
- function stripHtml(html) {
9
- return html.replace(/<[^>]*>/g, "").trim();
10
- }
11
4
  function truncate(text) {
12
5
  const cleaned = text.trim();
13
6
  if (cleaned.length <= MAX_CONTENT_LENGTH) return cleaned;
14
- return cleaned.slice(0, MAX_CONTENT_LENGTH) + "\u2026";
7
+ return cleaned.slice(0, MAX_CONTENT_LENGTH) + " [TRUNCATED]";
15
8
  }
16
9
  export function buildBlock(app, uuid, bundle) {
17
10
  const block = { uuid, bundle };
18
11
  const editables = app.directive.getEditablesForBlock(uuid);
19
12
  const content = {};
20
13
  for (const editable of editables) {
21
- const fieldType = getFieldType(
22
- app,
14
+ const fieldType = app.fieldValue.resolveFieldType(
23
15
  itemEntityType,
24
16
  bundle,
25
17
  editable.fieldName
26
18
  );
27
19
  if (!fieldType) continue;
28
- const raw = getEditableValue(
29
- app,
20
+ const raw = app.fieldValue.readValue(
30
21
  itemEntityType,
31
22
  uuid,
32
23
  bundle,
33
24
  editable.fieldName,
34
25
  fieldType
35
26
  );
36
- const text = fieldType === "markup" ? stripHtml(raw) : raw;
27
+ const text = raw;
37
28
  const truncated = truncate(text);
38
29
  if (truncated) {
39
30
  content[editable.fieldName] = truncated;
@@ -72,15 +63,14 @@ export function buildPageStructure(app) {
72
63
  let entityContentFields;
73
64
  for (const config of entityEditableConfigs) {
74
65
  const fieldType = config.type === "frame" || config.type === "markup" ? "markup" : "plain";
75
- const raw = getEditableValue(
76
- app,
66
+ const raw = app.fieldValue.readValue(
77
67
  entityType,
78
68
  pageUuid,
79
69
  entityBundle,
80
70
  config.name,
81
71
  fieldType
82
72
  );
83
- const text = fieldType === "markup" ? stripHtml(raw) : raw;
73
+ const text = raw;
84
74
  const truncated = truncate(text);
85
75
  if (truncated) {
86
76
  if (!entityContentFields) entityContentFields = {};
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,49 @@
1
+ import { defineBlokkliAgentPrompt } from "#blokkli/agent/app/composables";
2
+ export default defineBlokkliAgentPrompt({
3
+ id: "fix_readability",
4
+ skills: ["rewrite-and-translate", "asses-and-fix-readability"],
5
+ tools: [
6
+ "get_readability_issues",
7
+ "check_readability_for_texts",
8
+ "delegate_text_rewrite"
9
+ ],
10
+ getLabel: ({ $t }) => {
11
+ return $t("agentPromptReadabilityLabel", "Fix readability...");
12
+ },
13
+ getPrompt: ({ $t }) => {
14
+ return $t(
15
+ "agentPromptReadabilityPrompt",
16
+ "The readability issues have already been analyzed and the fix has been applied. Do not call any more tools. Just very briefly confirm that you are done."
17
+ );
18
+ },
19
+ getUserPrompt: ({ $t }) => {
20
+ return $t(
21
+ "agentPromptReadabilityUserPrompt",
22
+ "Fix the readability of the selected paragraphs."
23
+ );
24
+ },
25
+ async preExecute({ selectedUuids, runTool }) {
26
+ const readability = await runTool(
27
+ "get_readability_issues",
28
+ selectedUuids.length ? {
29
+ uuids: selectedUuids
30
+ } : {}
31
+ );
32
+ const fields = Object.entries(readability.result).flatMap(
33
+ ([uuid, fieldMap]) => Object.keys(fieldMap).map((fieldName) => ({ uuid, fieldName }))
34
+ );
35
+ return {
36
+ preSeededResults: [readability],
37
+ autoExecuteTools: fields.length > 0 ? [
38
+ {
39
+ toolName: "delegate_text_rewrite",
40
+ params: {
41
+ template: "fix_readability",
42
+ templateParams: {},
43
+ fields
44
+ }
45
+ }
46
+ ] : void 0
47
+ };
48
+ }
49
+ });
@@ -217,6 +217,7 @@ export default defineBlokkliAgentTool({
217
217
  name: "add_paragraphs",
218
218
  description: "Add one or more new paragraphs to the page. Supports nested structures via the `children` property \u2014 define entire paragraph trees in a single call. IMPORTANT: Always provide content field values (text, media/entity references) directly via contentFields, instead of adding empty paragraphs! For reference content fields (media), set the value to { entityType, entityId } from search_media results. NOTE: You can ONLY provide content fields, NOT paragraph fields! For nested paragraphs, use the `children` property keyed by paragraph field name. You can also set paragraph options inline via the `options` property (key-value pairs).",
219
219
  category: "mutation",
220
+ lazy: false,
220
221
  prunedSummary: (r) => r.success ? `added ${r.newParagraphs?.length || 0} paragraphs` : "rejected",
221
222
  modes: ["editing"],
222
223
  label($t) {
@@ -1,14 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
3
- function impactToLevel(impact) {
4
- if (impact === "critical" || impact === "serious") return "hard";
5
- if (impact === "moderate") return "ok";
3
+ function bandToLevel(band) {
4
+ if (band === "hard") return "hard";
5
+ if (band === "ok") return "ok";
6
6
  return "good";
7
7
  }
8
8
  const textResultSchema = z.object({
9
9
  text: z.string(),
10
10
  level: z.enum(["good", "ok", "hard"]),
11
- scores: z.record(z.string(), z.number())
11
+ score: z.number()
12
12
  });
13
13
  const paramsSchema = z.object({
14
14
  texts: z.array(z.string()).describe(
@@ -34,17 +34,26 @@ export default defineBlokkliAgentTool({
34
34
  paramsSchema,
35
35
  resultSchema,
36
36
  async execute(ctx, params) {
37
- const { analyze, $t } = ctx.app;
38
- await analyze.ensureInitialized();
39
- const rawResults = await analyze.runOnTexts(params.texts, "readability");
40
- const results = rawResults.map((tr) => {
41
- const node = tr.nodes[0];
42
- return {
43
- text: tr.text,
44
- level: impactToLevel(node?.impact),
45
- scores: node?.scores ?? {}
46
- };
47
- });
37
+ const { readability, $t, context } = ctx.app;
38
+ const langcode = context.value.language;
39
+ const results = [];
40
+ for (const text of params.texts) {
41
+ const chunks = await readability.analyzeText(text, langcode);
42
+ let worstLevel = "good";
43
+ let worstScore = 0;
44
+ for (const chunk of chunks) {
45
+ const level = bandToLevel(chunk.band);
46
+ if (level === "hard" || level === "ok" && worstLevel === "good") {
47
+ worstLevel = level;
48
+ worstScore = chunk.score;
49
+ }
50
+ }
51
+ results.push({
52
+ text,
53
+ level: worstLevel,
54
+ score: worstScore
55
+ });
56
+ }
48
57
  return {
49
58
  label: $t(
50
59
  "aiAgentCheckReadabilityDone",
@@ -0,0 +1,46 @@
1
+ import type { McpToolContext } from '#blokkli/agent/app/types';
2
+ import type { ComponentParams } from './index.js';
3
+ import type { UsageTurn } from '#blokkli/agent/shared/types';
4
+ type __VLS_Props = {
5
+ context: McpToolContext;
6
+ params: ComponentParams;
7
+ };
8
+ export type StreamTextFieldsDetailItem = {
9
+ fieldLabel: string;
10
+ before: string;
11
+ after: string;
12
+ mode: 'full' | 'patch';
13
+ operations: Array<{
14
+ search: string;
15
+ replace: string;
16
+ }>;
17
+ };
18
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
19
+ done: (result: {
20
+ acceptedCount: number;
21
+ rejectedByUser: Record<string, Record<string, {
22
+ reasonForRejection: string;
23
+ }>>;
24
+ label: string;
25
+ agentMessage?: string | undefined;
26
+ historyIndex?: number | undefined;
27
+ } & {
28
+ _details?: StreamTextFieldsDetailItem[];
29
+ _usage?: UsageTurn;
30
+ }) => any;
31
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
32
+ onDone?: ((result: {
33
+ acceptedCount: number;
34
+ rejectedByUser: Record<string, Record<string, {
35
+ reasonForRejection: string;
36
+ }>>;
37
+ label: string;
38
+ agentMessage?: string | undefined;
39
+ historyIndex?: number | undefined;
40
+ } & {
41
+ _details?: StreamTextFieldsDetailItem[];
42
+ _usage?: UsageTurn;
43
+ }) => any) | undefined;
44
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
45
+ declare const _default: typeof __VLS_export;
46
+ export default _default;