@blokkli/editor 2.0.0-alpha.40 → 2.0.0-alpha.42
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 +1 -1
- package/dist/modules/agent/index.d.mts +7 -0
- package/dist/modules/agent/index.mjs +29 -14
- package/dist/modules/agent/runtime/app/composables/agentProvider.js +3 -3
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.vue +2 -1
- package/dist/modules/agent/runtime/app/tools/web_fetch/index.js +2 -1
- package/dist/modules/drupal/runtime/adapter/index.js +2 -1
- package/dist/runtime/components/BlokkliProvider.vue +39 -37
- package/dist/runtime/editor/components/PreviewProvider.vue +12 -2
- package/dist/runtime/editor/features/analyze/readability/builtinAnalyzer.js +9 -9
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -19,6 +19,12 @@ type AgentModelDefinition = {
|
|
|
19
19
|
output: number;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
type AgentModuleOptionsRoutes = {
|
|
23
|
+
agent: string;
|
|
24
|
+
fetch: string;
|
|
25
|
+
stream: string;
|
|
26
|
+
routing: string;
|
|
27
|
+
};
|
|
22
28
|
type AgentModuleOptions = {
|
|
23
29
|
/**
|
|
24
30
|
* Allowed origins for the fetch endpoint.
|
|
@@ -58,6 +64,7 @@ type AgentModuleOptions = {
|
|
|
58
64
|
* The name of the agent as shown to the user.
|
|
59
65
|
*/
|
|
60
66
|
agentName?: string;
|
|
67
|
+
routes?: Partial<AgentModuleOptionsRoutes>;
|
|
61
68
|
};
|
|
62
69
|
|
|
63
70
|
declare const _default: (options: AgentModuleOptions) => BlokkliModule<AgentModuleOptions>;
|
|
@@ -109,7 +109,7 @@ class AgentCollector extends Collector {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function createClientTemplate(toolCollector, promptCollector, skillsCollector, options) {
|
|
112
|
+
function createClientTemplate(toolCollector, promptCollector, skillsCollector, options, routes) {
|
|
113
113
|
return defineCodeTemplate(
|
|
114
114
|
"agent-client",
|
|
115
115
|
(ctx) => {
|
|
@@ -154,6 +154,10 @@ function createClientTemplate(toolCollector, promptCollector, skillsCollector, o
|
|
|
154
154
|
exports$1.push(
|
|
155
155
|
`export const hasWebFetch = ${JSON.stringify(!!options.allowedFetchOrigins)}`
|
|
156
156
|
);
|
|
157
|
+
exports$1.push(`export const routeAgent = ${JSON.stringify(routes.agent)}`);
|
|
158
|
+
exports$1.push(`export const routeFetch = ${JSON.stringify(routes.fetch)}`);
|
|
159
|
+
exports$1.push(`export const routeStream = ${JSON.stringify(routes.stream)}`);
|
|
160
|
+
exports$1.push(`export const routeRoute = ${JSON.stringify(routes.routing)}`);
|
|
157
161
|
exports$1.push(
|
|
158
162
|
`export const toolNames = ${JSON.stringify(toolCollector.getNames())}`
|
|
159
163
|
);
|
|
@@ -203,6 +207,10 @@ ${toolMapBlock}
|
|
|
203
207
|
export type AgentToolName = ${agentToolNameType}
|
|
204
208
|
export type AgentSkillName = ${agentSkillNameType}
|
|
205
209
|
|
|
210
|
+
export const routeAgent: string
|
|
211
|
+
export const routeFetch: string
|
|
212
|
+
export const routeStream: string
|
|
213
|
+
export const routeRoute: string
|
|
206
214
|
export const mcpTools: McpToolDefinition[]
|
|
207
215
|
export const agentPrompts: AgentPromptItem[]
|
|
208
216
|
export const defaultPrompts: string[]
|
|
@@ -546,10 +554,12 @@ function transformToolSource(source, filePath) {
|
|
|
546
554
|
return result;
|
|
547
555
|
}
|
|
548
556
|
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
557
|
+
const DEFAULT_ROUTES = {
|
|
558
|
+
agent: "/api/blokkli/agent",
|
|
559
|
+
fetch: "/api/blokkli/agent/fetch",
|
|
560
|
+
stream: "/api/blokkli/agent/stream",
|
|
561
|
+
routing: "/api/blokkli/agent/route"
|
|
562
|
+
};
|
|
553
563
|
const index = defineBlokkliModule({
|
|
554
564
|
alterOptions: (options) => {
|
|
555
565
|
options.featureImports ||= [];
|
|
@@ -583,6 +593,10 @@ export default defineNuxtConfig({
|
|
|
583
593
|
`);
|
|
584
594
|
throw new Error("Experimental WebSocket support of Nitro is not enabled.");
|
|
585
595
|
}
|
|
596
|
+
const routes = {
|
|
597
|
+
...DEFAULT_ROUTES,
|
|
598
|
+
...options.routes
|
|
599
|
+
};
|
|
586
600
|
const nuxt = ctx.helper.nuxt;
|
|
587
601
|
const moduleResolver = createResolver(
|
|
588
602
|
fileURLToPath(new URL("./", import.meta.url))
|
|
@@ -673,7 +687,8 @@ export default defineNuxtConfig({
|
|
|
673
687
|
mcpTools,
|
|
674
688
|
promptsCollector,
|
|
675
689
|
skillsCollector,
|
|
676
|
-
options
|
|
690
|
+
options,
|
|
691
|
+
routes
|
|
677
692
|
)
|
|
678
693
|
);
|
|
679
694
|
const moduleSystemPromptsDir = moduleResolver.resolve(
|
|
@@ -711,20 +726,20 @@ export default defineNuxtConfig({
|
|
|
711
726
|
})
|
|
712
727
|
);
|
|
713
728
|
addServerHandler({
|
|
714
|
-
route:
|
|
729
|
+
route: routes.agent,
|
|
715
730
|
handler: moduleResolver.resolve("./runtime/server/agent"),
|
|
716
731
|
lazy: true
|
|
717
732
|
});
|
|
718
733
|
addServerHandler({
|
|
719
|
-
route:
|
|
734
|
+
route: routes.fetch,
|
|
720
735
|
handler: moduleResolver.resolve("./runtime/server/fetch")
|
|
721
736
|
});
|
|
722
737
|
addServerHandler({
|
|
723
|
-
route:
|
|
738
|
+
route: routes.stream,
|
|
724
739
|
handler: moduleResolver.resolve("./runtime/server/stream")
|
|
725
740
|
});
|
|
726
741
|
addServerHandler({
|
|
727
|
-
route:
|
|
742
|
+
route: routes.routing,
|
|
728
743
|
handler: moduleResolver.resolve("./runtime/server/route")
|
|
729
744
|
});
|
|
730
745
|
const relativeSkillsDir = path.relative(
|
|
@@ -756,10 +771,10 @@ export default defineNuxtConfig({
|
|
|
756
771
|
});
|
|
757
772
|
nuxt.hook("nitro:init", (nitro) => {
|
|
758
773
|
nitro.hooks.hook("types:extend", (types) => {
|
|
759
|
-
Reflect.deleteProperty(types.routes,
|
|
760
|
-
Reflect.deleteProperty(types.routes,
|
|
761
|
-
Reflect.deleteProperty(types.routes,
|
|
762
|
-
Reflect.deleteProperty(types.routes,
|
|
774
|
+
Reflect.deleteProperty(types.routes, routes.agent);
|
|
775
|
+
Reflect.deleteProperty(types.routes, routes.fetch);
|
|
776
|
+
Reflect.deleteProperty(types.routes, routes.stream);
|
|
777
|
+
Reflect.deleteProperty(types.routes, routes.routing);
|
|
763
778
|
});
|
|
764
779
|
});
|
|
765
780
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
isToolError,
|
|
14
14
|
resolveTools
|
|
15
15
|
} from "#blokkli/agent/app/helpers";
|
|
16
|
-
import { mcpTools } from "#blokkli-build/agent-client";
|
|
16
|
+
import { mcpTools, routeAgent, routeRoute } from "#blokkli-build/agent-client";
|
|
17
17
|
import { generateUUID } from "#blokkli/editor/helpers/uuid";
|
|
18
18
|
import { itemEntityType } from "#blokkli-build/config";
|
|
19
19
|
export default function(app, adapter, agentName) {
|
|
@@ -234,7 +234,7 @@ export default function(app, adapter, agentName) {
|
|
|
234
234
|
ws = null;
|
|
235
235
|
}
|
|
236
236
|
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
237
|
-
const url = `${protocol}//${window.location.host}
|
|
237
|
+
const url = `${protocol}//${window.location.host}${routeAgent}`;
|
|
238
238
|
ws = new WebSocket(url);
|
|
239
239
|
ws.addEventListener("open", onWebSocketOpen);
|
|
240
240
|
ws.addEventListener("close", onWebSocketClose);
|
|
@@ -838,7 +838,7 @@ export default function(app, adapter, agentName) {
|
|
|
838
838
|
let resolvedAutoLoadSkills = autoLoadSkills;
|
|
839
839
|
if (isFirstMessage && !hasClientDirectives && storedPageContext.value) {
|
|
840
840
|
try {
|
|
841
|
-
const routingResult = await fetch(
|
|
841
|
+
const routingResult = await fetch(routeRoute, {
|
|
842
842
|
method: "POST",
|
|
843
843
|
headers: { "Content-Type": "application/json" },
|
|
844
844
|
body: JSON.stringify({
|
|
@@ -44,6 +44,7 @@ import { useBlokkli, ref, reactive, onMounted, onBeforeUnmount } from "#imports"
|
|
|
44
44
|
import { Icon, DiffApproval } from "#blokkli/editor/components";
|
|
45
45
|
import ToolCard from "../../features/agent/Panel/ToolCard/index.vue";
|
|
46
46
|
import { itemEntityType } from "#blokkli-build/config";
|
|
47
|
+
import { routeStream } from "#blokkli-build/agent-client";
|
|
47
48
|
import { useEditableFieldOverride } from "#blokkli/editor/composables";
|
|
48
49
|
import { applyOperations } from "../helpers";
|
|
49
50
|
const props = defineProps({
|
|
@@ -358,7 +359,7 @@ function handleSSEEvent(eventType, data) {
|
|
|
358
359
|
async function fetchStream(authToken, requestFields, templateParams) {
|
|
359
360
|
abortController = new AbortController();
|
|
360
361
|
try {
|
|
361
|
-
const response = await fetch(
|
|
362
|
+
const response = await fetch(routeStream, {
|
|
362
363
|
method: "POST",
|
|
363
364
|
headers: { "Content-Type": "application/json" },
|
|
364
365
|
body: JSON.stringify({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
import { routeFetch } from "#blokkli-build/agent-client";
|
|
3
4
|
const paramsSchema = z.object({
|
|
4
5
|
url: z.string().url().describe("The URL to fetch content from"),
|
|
5
6
|
format: z.enum(["markdown", "html"]).default("markdown").describe(
|
|
@@ -25,7 +26,7 @@ export default defineBlokkliAgentTool({
|
|
|
25
26
|
resultSchema,
|
|
26
27
|
async execute(ctx, params) {
|
|
27
28
|
const { $t } = ctx.app;
|
|
28
|
-
const response = await fetch(
|
|
29
|
+
const response = await fetch(routeFetch, {
|
|
29
30
|
method: "POST",
|
|
30
31
|
headers: { "Content-Type": "application/json" },
|
|
31
32
|
body: JSON.stringify({ url: params.url, format: params.format })
|
|
@@ -291,7 +291,8 @@ export default defineBlokkliEditAdapter(
|
|
|
291
291
|
const route = useRoute();
|
|
292
292
|
const router = useRouter();
|
|
293
293
|
const changeLanguage = (translation) => {
|
|
294
|
-
|
|
294
|
+
const path = translation.url.includes("http") ? new URL(translation.url).pathname : translation.url;
|
|
295
|
+
return router.push({ path, query: route.query });
|
|
295
296
|
};
|
|
296
297
|
const buildEditableFrameUrl = (e) => {
|
|
297
298
|
const url = "/" + [
|
|
@@ -7,43 +7,45 @@
|
|
|
7
7
|
:data-blokkli-provider-active="isInEditor ? 'true' : 'false'"
|
|
8
8
|
>
|
|
9
9
|
<BlokkliRootErrorBoundary v-if="isInEditor">
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
10
|
+
<ClientOnly>
|
|
11
|
+
<PreviewProvider
|
|
12
|
+
v-if="isPreviewing"
|
|
13
|
+
v-slot="{ mutatedEntity }"
|
|
14
|
+
:entity
|
|
15
|
+
:entity-type
|
|
16
|
+
:entity-uuid
|
|
17
|
+
:entity-bundle
|
|
18
|
+
:language
|
|
19
|
+
:provider-type
|
|
20
|
+
>
|
|
21
|
+
<slot
|
|
22
|
+
:entity="mutatedEntity"
|
|
23
|
+
:is-editing
|
|
24
|
+
:can-edit
|
|
25
|
+
:is-preview="isPreviewing"
|
|
26
|
+
/>
|
|
27
|
+
</PreviewProvider>
|
|
28
|
+
<EditProvider
|
|
29
|
+
v-else-if="isEditing && shouldRender && providerEl"
|
|
30
|
+
v-slot="{ mutatedEntity }"
|
|
31
|
+
:provider-el
|
|
32
|
+
:entity
|
|
33
|
+
:entity-type
|
|
34
|
+
:entity-uuid
|
|
35
|
+
:entity-bundle
|
|
36
|
+
:language
|
|
37
|
+
:isolate
|
|
38
|
+
:permissions
|
|
39
|
+
:provider-type
|
|
40
|
+
>
|
|
41
|
+
<slot
|
|
42
|
+
:is-editing
|
|
43
|
+
:can-edit
|
|
44
|
+
:is-preview="isPreviewing"
|
|
45
|
+
:entity="mutatedEntity"
|
|
46
|
+
/>
|
|
47
|
+
</EditProvider>
|
|
48
|
+
</ClientOnly>
|
|
47
49
|
</BlokkliRootErrorBoundary>
|
|
48
50
|
|
|
49
51
|
<slot
|
|
@@ -59,10 +59,20 @@ const { data, refresh, error } = await useAsyncData(
|
|
|
59
59
|
() => adapter.loadState().then((v) => adapter.mapState(v))
|
|
60
60
|
);
|
|
61
61
|
function updateMutatedFields(fields) {
|
|
62
|
-
|
|
62
|
+
const existingKeys = Object.keys(mutatedFieldsMap);
|
|
63
|
+
const newKeys = /* @__PURE__ */ new Set();
|
|
64
|
+
for (let i = 0; i < fields.length; i++) {
|
|
65
|
+
const field = fields[i];
|
|
63
66
|
const key = getFieldKey(field.entityUuid, field.name);
|
|
64
67
|
mutatedFieldsMap[key] = field;
|
|
65
|
-
|
|
68
|
+
newKeys.add(key);
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < existingKeys.length; i++) {
|
|
71
|
+
const key = existingKeys[i];
|
|
72
|
+
if (!newKeys.has(key)) {
|
|
73
|
+
delete mutatedFieldsMap[key];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
66
76
|
}
|
|
67
77
|
const updateState = () => {
|
|
68
78
|
const fields = data.value?.mutatedState?.fields || [];
|
|
@@ -21,18 +21,18 @@ const SCORE_CONFIGS = {
|
|
|
21
21
|
label: "WSTF",
|
|
22
22
|
compute: (tr, text) => tr.wienerSachtextformel(text, 1),
|
|
23
23
|
direction: "higher_harder",
|
|
24
|
-
bands: { easy:
|
|
25
|
-
impactThresholds: [
|
|
24
|
+
bands: { easy: 7, ok: 14 },
|
|
25
|
+
impactThresholds: [12, 16, 20],
|
|
26
26
|
referenceTable: [
|
|
27
|
-
{ range: "4
|
|
28
|
-
{ range: "
|
|
29
|
-
{ range: "
|
|
30
|
-
{ range: "
|
|
27
|
+
{ range: "Below 4", label: "Very easy (children's books)" },
|
|
28
|
+
{ range: "4\u20137", label: "Easy (simple articles)" },
|
|
29
|
+
{ range: "7\u201311", label: "Medium (standard website content)" },
|
|
30
|
+
{ range: "11\u201314", label: "Moderately difficult (official documents)" },
|
|
31
31
|
{
|
|
32
|
-
range: "Above
|
|
33
|
-
label: "
|
|
32
|
+
range: "Above 14",
|
|
33
|
+
label: "Difficult \u2014 this is what gets flagged"
|
|
34
34
|
},
|
|
35
|
-
{ range: "Above
|
|
35
|
+
{ range: "Above 20", label: "Critical \u2014 must be simplified" }
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
38
|
fr: {
|