@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.
- package/dist/module.json +1 -1
- package/dist/module.mjs +15 -105
- package/dist/modules/agent/index.d.mts +1 -0
- package/dist/modules/agent/index.mjs +81 -8
- package/dist/modules/agent/runtime/app/composables/agentProvider.d.ts +8 -3
- package/dist/modules/agent/runtime/app/composables/agentProvider.js +108 -13
- package/dist/modules/agent/runtime/app/features/agent/Panel/DebugGallery/index.vue +7 -6
- package/dist/modules/agent/runtime/app/features/agent/Panel/index.d.vue.ts +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue +12 -10
- package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue.d.ts +2 -2
- package/dist/modules/agent/runtime/app/features/agent/index.vue +29 -5
- package/dist/modules/agent/runtime/app/helpers/pageStructure.js +7 -17
- package/dist/modules/agent/runtime/app/prompts/fixReadability.d.ts +2 -0
- package/dist/modules/agent/runtime/app/prompts/fixReadability.js +49 -0
- package/dist/modules/agent/runtime/app/tools/add_paragraphs/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/check_readability/index.js +24 -15
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.d.vue.ts +46 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.vue +739 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.vue.d.ts +46 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Details/index.d.vue.ts +6 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Details/index.vue +38 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Details/index.vue.d.ts +6 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/index.d.ts +38 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/index.js +115 -0
- package/dist/modules/agent/runtime/app/tools/delete_paragraphs/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/get_all_page_content/index.js +3 -5
- package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/get_child_paragraphs/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/get_content_fields/index.js +4 -7
- package/dist/modules/agent/runtime/app/tools/get_page_structure/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +10 -17
- package/dist/modules/agent/runtime/app/tools/get_paragraph_options/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/get_paragraphs_in_viewport/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/get_readability_issues/index.js +17 -70
- package/dist/modules/agent/runtime/app/tools/get_selected_paragraphs/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/helpers.d.ts +38 -10
- package/dist/modules/agent/runtime/app/tools/helpers.js +90 -27
- package/dist/modules/agent/runtime/app/tools/move_paragraphs/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/rearrange_paragraphs/index.js +1 -0
- package/dist/modules/agent/runtime/app/tools/schemas.d.ts +1 -1
- package/dist/modules/agent/runtime/app/tools/update_text_fields/Component.vue +66 -84
- package/dist/modules/agent/runtime/app/tools/update_text_fields/index.d.ts +8 -1
- package/dist/modules/agent/runtime/app/tools/update_text_fields/index.js +21 -14
- package/dist/modules/agent/runtime/app/types/index.d.ts +41 -0
- package/dist/modules/agent/runtime/server/Session.d.ts +8 -1
- package/dist/modules/agent/runtime/server/Session.js +154 -6
- package/dist/modules/agent/runtime/server/agent.js +5 -1
- package/dist/modules/agent/runtime/server/default-skills/fixReadability.js +31 -51
- package/dist/modules/agent/runtime/server/default-skills/rewriteAndTranslate.js +45 -4
- package/dist/modules/agent/runtime/server/providers/anthropic.js +2 -1
- package/dist/modules/agent/runtime/server/providers/openai.js +2 -1
- package/dist/modules/agent/runtime/server/providers/types.d.ts +2 -0
- package/dist/modules/agent/runtime/server/route.d.ts +2 -0
- package/dist/modules/agent/runtime/server/route.js +40 -0
- package/dist/modules/agent/runtime/server/routing.d.ts +18 -0
- package/dist/modules/agent/runtime/server/routing.js +111 -0
- package/dist/modules/agent/runtime/server/skills/types.d.ts +10 -0
- package/dist/modules/agent/runtime/server/stream.d.ts +2 -0
- package/dist/modules/agent/runtime/server/stream.js +190 -0
- package/dist/modules/agent/runtime/server/streamParser.d.ts +85 -0
- package/dist/modules/agent/runtime/server/streamParser.js +227 -0
- package/dist/modules/agent/runtime/server/templates/defineStreamTemplate.d.ts +21 -0
- package/dist/modules/agent/runtime/server/templates/defineStreamTemplate.js +3 -0
- package/dist/modules/agent/runtime/server/templates/definitions/fixReadability.d.ts +26 -0
- package/dist/modules/agent/runtime/server/templates/definitions/fixReadability.js +84 -0
- package/dist/modules/agent/runtime/server/templates/definitions/generateContent.d.ts +6 -0
- package/dist/modules/agent/runtime/server/templates/definitions/generateContent.js +29 -0
- package/dist/modules/agent/runtime/server/templates/definitions/rewrite.d.ts +5 -0
- package/dist/modules/agent/runtime/server/templates/definitions/rewrite.js +14 -0
- package/dist/modules/agent/runtime/server/templates/definitions/translate.d.ts +5 -0
- package/dist/modules/agent/runtime/server/templates/definitions/translate.js +23 -0
- package/dist/modules/agent/runtime/server/templates/index.d.ts +37 -0
- package/dist/modules/agent/runtime/server/templates/index.js +25 -0
- package/dist/modules/agent/runtime/server/templates/types.d.ts +17 -0
- package/dist/modules/agent/runtime/server/templates/types.js +0 -0
- package/dist/modules/agent/runtime/server/templates/utils.d.ts +5 -0
- package/dist/modules/agent/runtime/server/templates/utils.js +69 -0
- package/dist/modules/agent/runtime/shared/types.d.ts +18 -0
- package/dist/modules/agent/runtime/shared/types.js +16 -1
- package/dist/runtime/components/BlokkliItem.d.vue.ts +1 -1
- package/dist/runtime/components/BlokkliItem.vue +34 -3
- package/dist/runtime/components/BlokkliItem.vue.d.ts +1 -1
- package/dist/runtime/editor/components/Actions/index.vue +2 -2
- package/dist/runtime/editor/components/AnimationCanvas/index.vue +23 -2
- package/dist/runtime/editor/components/DiffApproval/Highlight/Item.d.vue.ts +19 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/Item.vue +106 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/Item.vue.d.ts +19 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/index.d.vue.ts +22 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/index.vue +50 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/index.vue.d.ts +22 -0
- package/dist/runtime/editor/components/DiffApproval/Toolbar/index.d.vue.ts +24 -0
- package/dist/runtime/editor/components/DiffApproval/Toolbar/index.vue +113 -0
- package/dist/runtime/editor/components/DiffApproval/Toolbar/index.vue.d.ts +24 -0
- package/dist/runtime/editor/components/DiffApproval/index.d.vue.ts +19 -0
- package/dist/runtime/editor/components/DiffApproval/index.vue +158 -0
- package/dist/runtime/editor/components/DiffApproval/index.vue.d.ts +19 -0
- package/dist/runtime/editor/components/DiffApproval/types.d.ts +7 -0
- package/dist/runtime/editor/components/DiffApproval/types.js +0 -0
- package/dist/runtime/editor/components/DiffViewer/DiffValue.vue +2 -11
- package/dist/runtime/editor/components/DraggableList.vue +1 -1
- package/dist/runtime/editor/components/EditProvider.vue +18 -1
- package/dist/runtime/editor/components/ShortcutIndicator/index.d.vue.ts +2 -2
- package/dist/runtime/editor/components/ShortcutIndicator/index.vue +27 -33
- package/dist/runtime/editor/components/ShortcutIndicator/index.vue.d.ts +2 -2
- package/dist/runtime/editor/components/index.d.ts +2 -1
- package/dist/runtime/editor/components/index.js +2 -0
- package/dist/runtime/editor/composables/useEditableFieldOverride.d.ts +2 -0
- package/dist/runtime/editor/composables/useEditableFieldOverride.js +21 -15
- package/dist/runtime/editor/css/output.css +1 -1
- package/dist/runtime/editor/events/index.d.ts +3 -0
- package/dist/runtime/editor/features/add-list/index.vue +1 -0
- package/dist/runtime/editor/features/analyze/Main.vue +1 -1
- package/dist/runtime/editor/features/analyze/analyzers/helpers/Context.d.ts +7 -2
- package/dist/runtime/editor/features/analyze/analyzers/helpers/Context.js +6 -1
- package/dist/runtime/editor/features/analyze/analyzers/readability.js +52 -222
- package/dist/runtime/editor/features/analyze/analyzers/types.d.ts +2 -2
- package/dist/runtime/editor/features/analyze/readability/adapterTypes.d.ts +9 -0
- package/dist/runtime/editor/features/analyze/readability/adapterTypes.js +0 -0
- package/dist/runtime/editor/features/analyze/readability/builtinAnalyzer.d.ts +6 -0
- package/dist/runtime/editor/features/analyze/readability/builtinAnalyzer.js +200 -0
- package/dist/runtime/editor/features/analyze/readability/chunkHtml.d.ts +15 -0
- package/dist/runtime/editor/features/analyze/readability/chunkHtml.js +97 -0
- package/dist/runtime/editor/features/analyze/readability/types.d.ts +72 -0
- package/dist/runtime/editor/features/analyze/readability/types.js +0 -0
- package/dist/runtime/editor/features/artboard/Renderer.vue +9 -5
- package/dist/runtime/editor/features/breadcrumbs/index.vue +1 -1
- package/dist/runtime/editor/features/dragging-overlay/index.vue +1 -1
- package/dist/runtime/editor/features/editable-field/index.vue +1 -1
- package/dist/runtime/editor/features/hover/index.vue +1 -1
- package/dist/runtime/editor/features/options/index.vue +1 -1
- package/dist/runtime/editor/features/selection/AddButtons/Renderer/index.vue +1 -1
- package/dist/runtime/editor/features/selection/index.vue +2 -2
- package/dist/runtime/editor/features/structure/List/Item/index.vue +1 -3
- package/dist/runtime/editor/helpers/diff/index.d.ts +11 -0
- package/dist/runtime/editor/helpers/diff/index.js +227 -0
- package/dist/runtime/editor/plugins/Sidebar/index.vue +1 -1
- package/dist/runtime/editor/providers/analyze.d.ts +2 -1
- package/dist/runtime/editor/providers/analyze.js +6 -3
- package/dist/runtime/editor/providers/directive.js +1 -0
- package/dist/runtime/editor/providers/fieldValue.d.ts +54 -0
- package/dist/runtime/editor/providers/fieldValue.js +126 -0
- package/dist/runtime/editor/providers/fieldValueAdapterTypes.d.ts +13 -0
- package/dist/runtime/editor/providers/fieldValueAdapterTypes.js +0 -0
- package/dist/runtime/editor/providers/readability.d.ts +23 -0
- package/dist/runtime/editor/providers/readability.js +130 -0
- package/dist/runtime/editor/providers/state.d.ts +16 -0
- package/dist/runtime/editor/providers/state.js +19 -1
- package/dist/runtime/editor/providers/ui.d.ts +7 -0
- package/dist/runtime/editor/providers/ui.js +7 -1
- package/dist/runtime/editor/translations/de.json +80 -8
- package/dist/runtime/editor/translations/fr.json +80 -8
- package/dist/runtime/editor/translations/gsw_CH.json +80 -8
- package/dist/runtime/editor/translations/it.json +80 -8
- package/dist/runtime/editor/types/app.d.ts +4 -0
- package/dist/shared/editor.9vf8ZnOp.mjs +288 -0
- package/package.json +2 -2
- package/dist/modules/agent/runtime/app/tools/update_text_fields/Item.d.vue.ts +0 -22
- package/dist/modules/agent/runtime/app/tools/update_text_fields/Item.vue +0 -95
- package/dist/modules/agent/runtime/app/tools/update_text_fields/Item.vue.d.ts +0 -22
- package/dist/shared/editor.BFIzNSQM.mjs +0 -146
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<DropHandler
|
|
3
|
-
v-if="hasBeenReady ||
|
|
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="
|
|
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="
|
|
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 && !
|
|
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 && !
|
|
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 (
|
|
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
|
|
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
|
-
|
|
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) + "
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
73
|
+
const text = raw;
|
|
84
74
|
const truncated = truncate(text);
|
|
85
75
|
if (truncated) {
|
|
86
76
|
if (!entityContentFields) entityContentFields = {};
|
|
@@ -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
|
|
4
|
-
if (
|
|
5
|
-
if (
|
|
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
|
-
|
|
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 {
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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;
|