@blokkli/editor 2.0.0-alpha.35 → 2.0.0-alpha.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/global/types/blockOptions.d.ts +10 -2
- package/dist/global/types/definitions.d.ts +12 -5
- package/dist/module.d.mts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +126 -7
- package/dist/modules/agent/index.d.mts +1 -1
- package/dist/modules/agent/index.mjs +273 -25
- package/dist/modules/agent/runtime/app/composables/agentProvider.d.ts +2 -2
- package/dist/modules/agent/runtime/app/composables/agentProvider.js +34 -17
- package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.d.ts +2 -20
- package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.js +0 -3
- package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/Assistant/index.vue +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/User/index.vue +1 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/DebugGallery/index.vue +1 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.d.vue.ts +1 -0
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue +67 -86
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue.d.ts +1 -0
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/index.vue +10 -12
- package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/de.md +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/en.md +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue +1 -5
- package/dist/modules/agent/runtime/app/features/agent/Transcript/index.d.vue.ts +8 -0
- package/dist/modules/agent/runtime/app/features/agent/Transcript/index.vue +138 -0
- package/dist/modules/agent/runtime/app/features/agent/Transcript/index.vue.d.ts +8 -0
- package/dist/modules/agent/runtime/app/features/agent/index.vue +94 -38
- package/dist/modules/agent/runtime/app/helpers/index.d.ts +16 -19
- package/dist/modules/agent/runtime/app/helpers/index.js +22 -46
- package/dist/modules/agent/runtime/app/helpers/pageStructure.js +1 -1
- package/dist/modules/agent/runtime/app/tools/add_content_search_paragraph/index.js +5 -9
- package/dist/modules/agent/runtime/app/tools/add_fragment/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_media_paragraph/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_paragraphs/index.js +2 -3
- package/dist/modules/agent/runtime/app/tools/add_reusable_paragraph/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_template/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/analyze_content/index.js +120 -0
- package/dist/modules/agent/runtime/app/tools/check_readability/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/check_readability/index.js +57 -0
- package/dist/modules/agent/runtime/app/tools/duplicate_paragraphs/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/get_all_page_content/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +176 -0
- package/dist/modules/agent/runtime/app/tools/get_content_fields/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +7 -5
- package/dist/modules/agent/runtime/app/tools/get_paragraph_options/index.js +2 -1
- package/dist/modules/agent/runtime/app/tools/get_selected_paragraphs/index.js +2 -3
- package/dist/modules/agent/runtime/app/tools/helpers.d.ts +53 -0
- package/dist/modules/agent/runtime/app/tools/helpers.js +187 -0
- package/dist/modules/agent/runtime/app/tools/move_paragraphs/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/schemas.d.ts +1 -44
- package/dist/modules/agent/runtime/app/tools/schemas.js +0 -174
- package/dist/modules/agent/runtime/app/tools/search_content/index.js +40 -47
- package/dist/modules/agent/runtime/app/tools/set_paragraph_options/index.js +2 -5
- package/dist/modules/agent/runtime/app/types/index.d.ts +0 -61
- package/dist/modules/agent/runtime/server/Session.d.ts +29 -8
- package/dist/modules/agent/runtime/server/Session.js +168 -85
- package/dist/modules/agent/runtime/server/SessionManager.d.ts +3 -0
- package/dist/modules/agent/runtime/server/SessionManager.js +4 -1
- package/dist/modules/agent/runtime/server/agent.js +3 -2
- package/dist/modules/agent/runtime/server/agentPrompt.d.ts +9 -1
- package/dist/modules/agent/runtime/server/agentPrompt.js +26 -0
- package/dist/modules/agent/runtime/server/default-skills/fixReadability.d.ts +2 -0
- package/dist/modules/agent/runtime/server/default-skills/fixReadability.js +69 -0
- package/dist/modules/agent/runtime/server/default-system-prompts/page-context.js +28 -0
- package/dist/modules/agent/runtime/server/server-tools/index.d.ts +10 -2
- package/dist/modules/agent/runtime/server/server-tools/index.js +1 -1
- package/dist/modules/agent/runtime/server/server-tools/load_tools/index.js +1 -1
- package/dist/modules/agent/runtime/shared/types.d.ts +81 -12
- package/dist/modules/agent/runtime/shared/types.js +22 -10
- package/dist/modules/charts/index.d.mts +35 -0
- package/dist/modules/charts/index.mjs +57 -0
- package/dist/modules/charts/runtime/blokkli/skills/charts.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/skills/charts.js +42 -0
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.d.ts +86 -0
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.js +136 -0
- package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.js +93 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.js +66 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.js +40 -0
- package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.d.ts +2 -0
- package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.js +89 -0
- package/dist/modules/charts/runtime/chartTypes/area.d.ts +7 -0
- package/dist/modules/charts/runtime/chartTypes/area.js +68 -0
- package/dist/modules/charts/runtime/chartTypes/bar.d.ts +8 -0
- package/dist/modules/charts/runtime/chartTypes/bar.js +76 -0
- package/dist/modules/charts/runtime/chartTypes/define.d.ts +2 -0
- package/dist/modules/charts/runtime/chartTypes/define.js +3 -0
- package/dist/modules/charts/runtime/chartTypes/donut.d.ts +6 -0
- package/dist/modules/charts/runtime/chartTypes/donut.js +45 -0
- package/dist/modules/charts/runtime/chartTypes/heatmap.d.ts +4 -0
- package/dist/modules/charts/runtime/chartTypes/heatmap.js +54 -0
- package/dist/modules/charts/runtime/chartTypes/index.d.ts +39 -0
- package/dist/modules/charts/runtime/chartTypes/index.js +47 -0
- package/dist/modules/charts/runtime/chartTypes/line.d.ts +7 -0
- package/dist/modules/charts/runtime/chartTypes/line.js +68 -0
- package/dist/modules/charts/runtime/chartTypes/pie.d.ts +5 -0
- package/dist/modules/charts/runtime/chartTypes/pie.js +28 -0
- package/dist/modules/charts/runtime/chartTypes/radar.d.ts +7 -0
- package/dist/modules/charts/runtime/chartTypes/radar.js +52 -0
- package/dist/modules/charts/runtime/chartTypes/radialBar.d.ts +6 -0
- package/dist/modules/charts/runtime/chartTypes/radialBar.js +44 -0
- package/dist/modules/charts/runtime/chartTypes/shared.d.ts +67 -0
- package/dist/modules/charts/runtime/chartTypes/shared.js +103 -0
- package/dist/modules/charts/runtime/chartTypes/types.d.ts +29 -0
- package/dist/modules/charts/runtime/chartTypes/types.js +0 -0
- package/dist/modules/charts/runtime/components/ChartRenderer/index.d.vue.ts +147 -0
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue +120 -0
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue.d.ts +147 -0
- package/dist/modules/charts/runtime/components/index.d.ts +1 -0
- package/dist/modules/charts/runtime/components/index.js +1 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.d.vue.ts +16 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue +97 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue.d.ts +16 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.d.vue.ts +11 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.vue +34 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.vue.d.ts +11 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.d.vue.ts +12 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.vue +49 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.vue.d.ts +12 -0
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.d.vue.ts +19 -0
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue +89 -0
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue.d.ts +19 -0
- package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.d.vue.ts +23 -0
- package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.vue +224 -0
- package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.vue.d.ts +23 -0
- package/dist/{runtime/editor/features/clipboard/List → modules/charts/runtime/features/charts/Editor/FootnoteEditor}/index.d.vue.ts +4 -5
- package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue +61 -0
- package/dist/{runtime/editor/features/clipboard/List → modules/charts/runtime/features/charts/Editor/FootnoteEditor}/index.vue.d.ts +4 -5
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.d.vue.ts +10 -0
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue +45 -0
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue.d.ts +10 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.d.vue.ts +11 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue +249 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue.d.ts +11 -0
- package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.d.ts +17 -0
- package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.js +90 -0
- package/dist/modules/charts/runtime/features/charts/index.d.vue.ts +3 -0
- package/dist/modules/charts/runtime/features/charts/index.vue +72 -0
- package/dist/modules/charts/runtime/features/charts/index.vue.d.ts +3 -0
- package/dist/modules/charts/runtime/helpers/index.d.ts +26 -0
- package/dist/modules/charts/runtime/helpers/index.js +80 -0
- package/dist/modules/charts/runtime/types.d.ts +33 -0
- package/dist/modules/charts/runtime/types.js +0 -0
- package/dist/modules/drupal/graphql/features/fragments.graphql +2 -0
- package/dist/modules/drupal/index.d.mts +1 -1
- package/dist/modules/drupal/runtime/adapter/index.d.ts +3 -1
- package/dist/modules/drupal/runtime/adapter/index.js +16 -12
- package/dist/modules/table-of-contents/index.d.mts +11 -0
- package/dist/modules/table-of-contents/index.mjs +24 -0
- package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.d.vue.ts +44 -0
- package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.vue +43 -0
- package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.vue.d.ts +44 -0
- package/dist/modules/table-of-contents/runtime/types/index.d.ts +4 -0
- package/dist/modules/table-of-contents/runtime/types/index.js +0 -0
- package/dist/runtime/components/Blocks/Fragment/index.vue +6 -2
- package/dist/runtime/components/BlokkliItem.vue +9 -4
- package/dist/runtime/components/BlokkliProvider.d.vue.ts +7 -0
- package/dist/runtime/components/BlokkliProvider.vue +7 -1
- package/dist/runtime/components/BlokkliProvider.vue.d.ts +7 -0
- package/dist/runtime/composables/defineBlokkli.js +1 -1
- package/dist/runtime/composables/useBlokkliHelper.js +4 -2
- package/dist/runtime/editor/components/AnimationCanvas/index.vue +17 -27
- package/dist/runtime/editor/components/Banner/index.d.vue.ts +13 -2
- package/dist/runtime/editor/components/Banner/index.vue +4 -2
- package/dist/runtime/editor/components/Banner/index.vue.d.ts +13 -2
- package/dist/runtime/editor/components/Dropdown/index.d.vue.ts +27 -0
- package/dist/runtime/editor/components/Dropdown/index.vue +107 -0
- package/dist/runtime/editor/components/Dropdown/index.vue.d.ts +27 -0
- package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.d.vue.ts +1 -0
- package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.vue +3 -2
- package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/EditProvider.d.vue.ts +2 -0
- package/dist/runtime/editor/components/EditProvider.vue +11 -7
- package/dist/runtime/editor/components/EditProvider.vue.d.ts +2 -0
- package/dist/runtime/editor/components/FlexTextarea/index.d.vue.ts +5 -1
- package/dist/runtime/editor/components/FlexTextarea/index.vue +24 -101
- package/dist/runtime/editor/components/FlexTextarea/index.vue.d.ts +5 -1
- package/dist/runtime/editor/components/Form/Radio/index.d.vue.ts +1 -0
- package/dist/runtime/editor/components/Form/Radio/index.vue +3 -2
- package/dist/runtime/editor/components/Form/Radio/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/ItemIcon/index.vue +10 -2
- package/dist/runtime/editor/components/NestedEditorOverlay/index.d.vue.ts +13 -3
- package/dist/runtime/editor/components/NestedEditorOverlay/index.vue +43 -16
- package/dist/runtime/editor/components/NestedEditorOverlay/index.vue.d.ts +13 -3
- package/dist/runtime/editor/components/Popup/index.d.vue.ts +30 -0
- package/dist/runtime/editor/components/Popup/index.vue +82 -0
- package/dist/runtime/editor/components/Popup/index.vue.d.ts +30 -0
- package/dist/runtime/editor/components/PreviewProvider.d.vue.ts +2 -0
- package/dist/runtime/editor/components/PreviewProvider.vue +3 -2
- package/dist/runtime/editor/components/PreviewProvider.vue.d.ts +2 -0
- package/dist/runtime/editor/components/Resizable/index.vue +4 -1
- package/dist/runtime/editor/components/ShortcutIndicator/index.vue +1 -1
- package/dist/runtime/editor/components/Toolbar/index.vue +107 -6
- package/dist/runtime/editor/components/index.d.ts +4 -1
- package/dist/runtime/editor/components/index.js +6 -0
- package/dist/runtime/editor/composables/defineDropAreas.js +3 -3
- package/dist/runtime/editor/composables/defineDropHandler.d.ts +3 -0
- package/dist/runtime/editor/composables/defineDropHandler.js +10 -0
- package/dist/runtime/editor/composables/index.d.ts +1 -0
- package/dist/runtime/editor/composables/index.js +1 -0
- package/dist/runtime/editor/composables/onElementResize.js +0 -1
- package/dist/runtime/editor/composables/useEditableFieldOverride.js +4 -5
- package/dist/runtime/editor/css/output.css +1 -1
- package/dist/runtime/editor/events/index.d.ts +16 -0
- package/dist/runtime/editor/features/add-list/Help/Item.vue +5 -2
- package/dist/runtime/editor/features/add-list/index.vue +58 -1
- package/dist/runtime/editor/features/analyze/Main.d.vue.ts +3 -2
- package/dist/runtime/editor/features/analyze/Main.vue +28 -44
- package/dist/runtime/editor/features/analyze/Main.vue.d.ts +3 -2
- package/dist/runtime/editor/features/analyze/analyzers/readability.js +65 -0
- package/dist/runtime/editor/features/analyze/analyzers/types.d.ts +19 -0
- package/dist/runtime/editor/features/analyze/index.vue +18 -15
- package/dist/runtime/editor/features/artboard/Renderer.vue +1 -1
- package/dist/runtime/editor/features/clipboard/DropElement/Video.d.vue.ts +8 -0
- package/dist/runtime/editor/features/clipboard/{List/Item → DropElement}/Video.vue +1 -5
- package/dist/runtime/editor/features/clipboard/DropElement/Video.vue.d.ts +8 -0
- package/dist/runtime/editor/features/clipboard/DropElement/helpers.d.ts +1 -0
- package/dist/runtime/editor/features/clipboard/DropElement/helpers.js +14 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.d.vue.ts +16 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.vue +97 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.vue.d.ts +16 -0
- package/dist/runtime/editor/features/clipboard/helpers.d.ts +15 -0
- package/dist/runtime/editor/features/clipboard/helpers.js +62 -0
- package/dist/runtime/editor/features/clipboard/index.vue +586 -338
- package/dist/runtime/editor/features/clipboard/types.d.ts +14 -2
- package/dist/runtime/editor/features/debug/index.vue +1 -1
- package/dist/runtime/editor/features/dev-mode/index.vue +86 -2
- package/dist/runtime/editor/features/dragging-overlay/DragItems/index.vue +17 -5
- package/dist/runtime/editor/features/dragging-overlay/Renderer/index.vue +2 -2
- package/dist/runtime/editor/features/dragging-overlay/index.vue +125 -219
- package/dist/runtime/editor/features/edit/index.vue +20 -0
- package/dist/runtime/editor/features/editable-field/Overlay/Plaintext/index.vue +4 -4
- package/dist/runtime/editor/features/editable-field/Overlay/index.vue +6 -0
- package/dist/runtime/editor/features/fragments/types.d.ts +1 -0
- package/dist/runtime/editor/features/hover/Renderer/index.vue +30 -3
- package/dist/runtime/editor/features/hover/index.vue +1 -1
- package/dist/runtime/editor/features/library/index.vue +14 -0
- package/dist/runtime/editor/features/media-library/index.vue +32 -1
- package/dist/runtime/editor/features/options/Form/Checkbox/index.d.vue.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Checkbox/index.vue +3 -3
- package/dist/runtime/editor/features/options/Form/Checkbox/index.vue.d.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Checkboxes/index.d.vue.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Checkboxes/index.vue +5 -5
- package/dist/runtime/editor/features/options/Form/Checkboxes/index.vue.d.ts +2 -2
- package/dist/runtime/editor/features/options/Form/ComplexType/index.d.vue.ts +11 -0
- package/dist/runtime/editor/features/options/Form/ComplexType/index.vue +36 -0
- package/dist/runtime/editor/features/options/Form/ComplexType/index.vue.d.ts +11 -0
- package/dist/runtime/editor/features/options/Form/Item.d.vue.ts +5 -4
- package/dist/runtime/editor/features/options/Form/Item.vue +24 -50
- package/dist/runtime/editor/features/options/Form/Item.vue.d.ts +5 -4
- package/dist/runtime/editor/features/options/Form/Number/index.d.vue.ts +3 -3
- package/dist/runtime/editor/features/options/Form/Number/index.vue +7 -17
- package/dist/runtime/editor/features/options/Form/Number/index.vue.d.ts +3 -3
- package/dist/runtime/editor/features/options/Form/Range/index.d.vue.ts +2 -2
- package/dist/runtime/editor/features/options/Form/Range/index.vue +4 -4
- package/dist/runtime/editor/features/options/Form/Range/index.vue.d.ts +2 -2
- package/dist/runtime/editor/features/options/Form/index.vue +15 -5
- package/dist/runtime/editor/features/search/index.vue +25 -1
- package/dist/runtime/editor/features/selection/index.vue +2 -2
- package/dist/runtime/editor/features/structure/index.vue +25 -1
- package/dist/runtime/editor/features/tour/index.vue +22 -12
- package/dist/runtime/editor/features/transform/index.vue +1 -3
- package/dist/runtime/editor/helpers/clipboardData/index.d.ts +11 -0
- package/dist/runtime/editor/helpers/clipboardData/index.js +157 -0
- package/dist/runtime/editor/helpers/options/index.js +5 -0
- package/dist/runtime/editor/icons/svg/stars.svg +5 -1
- package/dist/runtime/editor/plugins/Sidebar/Detached/index.d.vue.ts +1 -1
- package/dist/runtime/editor/plugins/Sidebar/Detached/index.vue.d.ts +1 -1
- package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +15 -4
- package/dist/runtime/editor/plugins/Sidebar/index.vue +4 -2
- package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +15 -4
- package/dist/runtime/editor/providers/analyze.d.ts +43 -0
- package/dist/runtime/editor/providers/analyze.js +78 -0
- package/dist/runtime/editor/providers/animation.d.ts +4 -0
- package/dist/runtime/editor/providers/animation.js +6 -0
- package/dist/runtime/editor/providers/definition.d.ts +2 -2
- package/dist/runtime/editor/providers/definition.js +7 -1
- package/dist/runtime/editor/providers/dom.d.ts +5 -0
- package/dist/runtime/editor/providers/dom.js +11 -2
- package/dist/runtime/editor/providers/dragdrop.d.ts +55 -0
- package/dist/runtime/editor/providers/dragdrop.js +37 -0
- package/dist/runtime/editor/providers/fields.d.ts +19 -1
- package/dist/runtime/editor/providers/fields.js +54 -2
- package/dist/runtime/editor/providers/storage.js +15 -0
- package/dist/runtime/editor/providers/ui.d.ts +6 -0
- package/dist/runtime/editor/providers/ui.js +19 -0
- package/dist/runtime/editor/translations/de.json +338 -58
- package/dist/runtime/editor/translations/fr.json +331 -51
- package/dist/runtime/editor/translations/gsw_CH.json +336 -56
- package/dist/runtime/editor/translations/it.json +331 -51
- package/dist/runtime/editor/types/app.d.ts +4 -2
- package/dist/runtime/editor/types/draggable.d.ts +1 -0
- package/dist/runtime/editor/types/ui.d.ts +1 -1
- package/dist/runtime/helpers/imports/index.d.ts +8 -1
- package/dist/runtime/helpers/imports/index.js +15 -6
- package/dist/runtime/helpers/injections.d.ts +6 -2
- package/dist/runtime/helpers/injections.js +3 -0
- package/dist/runtime/helpers/runtimeHelpers/index.js +14 -0
- package/dist/runtime/types/blockOptions.d.ts +2 -1
- package/dist/runtime/types/definitions.d.ts +12 -5
- package/dist/runtime/types/provider.d.ts +2 -0
- package/dist/shared/editor.6D5vApr0.mjs +30 -0
- package/dist/shared/{editor.DMFfaLVE.mjs → editor.BFIzNSQM.mjs} +1 -30
- package/dist/shared/{editor.Iax3GCvt.d.mts → editor.BdBm1Z7C.d.mts} +34 -0
- package/dist/types.d.mts +1 -1
- package/package.json +21 -3
- package/dist/modules/agent/runtime/app/tools/get_available_bundles/index.js +0 -104
- package/dist/runtime/editor/features/clipboard/List/Item/File.d.vue.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/File.vue +0 -60
- package/dist/runtime/editor/features/clipboard/List/Item/File.vue.d.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/Video.d.vue.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/Video.vue.d.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/index.vue +0 -72
- package/dist/runtime/editor/features/tour/Popup/index.d.vue.ts +0 -9
- package/dist/runtime/editor/features/tour/Popup/index.vue +0 -34
- package/dist/runtime/editor/features/tour/Popup/index.vue.d.ts +0 -9
- package/dist/runtime/editor/providers/dropArea.d.ts +0 -48
- package/dist/runtime/editor/providers/dropArea.js +0 -22
- /package/dist/modules/agent/runtime/app/tools/{get_available_bundles → analyze_content}/index.d.ts +0 -0
|
@@ -4,11 +4,8 @@ import {
|
|
|
4
4
|
getAvailableOptions,
|
|
5
5
|
optionValueToStorable
|
|
6
6
|
} from "#blokkli/editor/helpers/options";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
optionValueSchema,
|
|
10
|
-
validateOptionValue
|
|
11
|
-
} from "../schemas.js";
|
|
7
|
+
import { mutationResultSchema, optionValueSchema } from "../schemas.js";
|
|
8
|
+
import { validateOptionValue } from "../helpers.js";
|
|
12
9
|
import { onlyUnique } from "#blokkli/helpers";
|
|
13
10
|
const paragraphOptionsSchema = z.object({
|
|
14
11
|
uuid: z.string().describe("The paragraph UUID"),
|
|
@@ -200,67 +200,6 @@ export type McpToolDefinition<TParamsSchema extends z.ZodType = z.ZodType, TResu
|
|
|
200
200
|
*/
|
|
201
201
|
mockParamsVariants?: () => z.infer<TParamsSchema>[];
|
|
202
202
|
};
|
|
203
|
-
/**
|
|
204
|
-
* A tool definition with a relaxed execute signature.
|
|
205
|
-
*
|
|
206
|
-
* Used as the return type for factory resolve callbacks. Preserves structural
|
|
207
|
-
* checking on all other properties (catches typos and excess properties) while
|
|
208
|
-
* allowing each tool to have its own specific execute signature via
|
|
209
|
-
* defineBlokkliAgentTool().
|
|
210
|
-
*/
|
|
211
|
-
export type FactoryResolvedTool = {
|
|
212
|
-
name: string;
|
|
213
|
-
description: string;
|
|
214
|
-
icon?: string;
|
|
215
|
-
category: McpToolCategory;
|
|
216
|
-
label: ($t: TranslationFunction) => string;
|
|
217
|
-
paramsSchema: z.ZodType;
|
|
218
|
-
resultSchema: z.ZodType;
|
|
219
|
-
requiredAdapterMethods?: readonly AdapterMethods[];
|
|
220
|
-
modes: EditMode[];
|
|
221
|
-
component?: Component;
|
|
222
|
-
requiresApproval?: boolean;
|
|
223
|
-
lazy?: boolean;
|
|
224
|
-
volatile?: boolean;
|
|
225
|
-
prunedSummary?: (result: any) => string;
|
|
226
|
-
execute: (...args: any[]) => any;
|
|
227
|
-
mockParams?: () => any;
|
|
228
|
-
mockParamsVariants?: () => any[];
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* Input for a tool factory that dynamically creates tools at runtime.
|
|
232
|
-
*
|
|
233
|
-
* Instead of defining a single static tool, a factory uses a `resolve` callback
|
|
234
|
-
* that is called when the agent connects. The callback returns an array of
|
|
235
|
-
* McpToolDefinition objects, allowing tools to be created based on runtime state
|
|
236
|
-
* (e.g., available content search tabs from the adapter).
|
|
237
|
-
*/
|
|
238
|
-
export type McpToolFactoryInput = {
|
|
239
|
-
/**
|
|
240
|
-
* Called once when the agent connects. Returns an array of tool definitions
|
|
241
|
-
* that are registered as if they were statically defined.
|
|
242
|
-
*
|
|
243
|
-
* Each returned tool is a full McpToolDefinition with its own
|
|
244
|
-
* requiredAdapterMethods, execute function, and schemas. Use
|
|
245
|
-
* defineBlokkliAgentTool() for each tool to get full type inference.
|
|
246
|
-
*
|
|
247
|
-
* The context provides access to the app and adapter so the factory can
|
|
248
|
-
* query runtime state (e.g., available content search tabs) to decide
|
|
249
|
-
* which tools to create. If adapter methods are optional, check for their
|
|
250
|
-
* existence before calling them (or return an empty array).
|
|
251
|
-
*/
|
|
252
|
-
resolve: (context: McpToolContext) => Promise<FactoryResolvedTool[]> | FactoryResolvedTool[];
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* A tool factory with the __factory marker for runtime identification.
|
|
256
|
-
*/
|
|
257
|
-
export type McpToolFactory = McpToolFactoryInput & {
|
|
258
|
-
__factory: true;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* A tool item is either a static tool definition or a factory that produces tools.
|
|
262
|
-
*/
|
|
263
|
-
export type McpToolItem = McpToolDefinition | McpToolFactory;
|
|
264
203
|
/**
|
|
265
204
|
* A pre-defined agent prompt that users can select.
|
|
266
205
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Peer } from 'crossws';
|
|
2
|
-
import type { PageContext, ClientToolDefinition, ConversationStateSnapshot, GenericMessage } from '../shared/types.js';
|
|
2
|
+
import type { PageContext, ClientToolDefinition, ServerToolMetadata, ConversationStateSnapshot, GenericMessage } from '../shared/types.js';
|
|
3
3
|
import type { ServerPlan } from './server-tools/index.js';
|
|
4
4
|
export declare class Session {
|
|
5
5
|
messages: GenericMessage[];
|
|
@@ -12,10 +12,10 @@ export declare class Session {
|
|
|
12
12
|
}>;
|
|
13
13
|
abortController: AbortController | null;
|
|
14
14
|
isProcessing: boolean;
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
15
|
+
/** Names of eager tools sent to the LLM on every turn */
|
|
16
|
+
toolNames: string[];
|
|
17
|
+
/** Names of lazy tools held back until activated via load_tools */
|
|
18
|
+
lazyToolNames: string[];
|
|
19
19
|
/** Names of lazy tools that have been activated via load_tools */
|
|
20
20
|
activatedLazyTools: Set<string>;
|
|
21
21
|
/** Names of skills that have been loaded via load_skill */
|
|
@@ -28,9 +28,30 @@ export declare class Session {
|
|
|
28
28
|
pendingPlanApproval: {
|
|
29
29
|
resolve: (approved: boolean) => void;
|
|
30
30
|
} | null;
|
|
31
|
-
/**
|
|
32
|
-
private
|
|
33
|
-
|
|
31
|
+
/** Pre-pruned messages snapshot for transcript (captured before pruneMessages) */
|
|
32
|
+
private unprunedMessages;
|
|
33
|
+
/** Last generic tool definitions for transcript */
|
|
34
|
+
private lastTools;
|
|
35
|
+
/** Bundled tool metadata map for server-side resolution */
|
|
36
|
+
private bundledToolMap;
|
|
37
|
+
/** Cache for resolved JSON Schemas (Zod→JSON Schema is deterministic) */
|
|
38
|
+
private jsonSchemaCache;
|
|
39
|
+
constructor(toolDefinitions: ServerToolMetadata[]);
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a single tool name into a ClientToolDefinition.
|
|
42
|
+
* Resolves from bundled metadata. Caches the JSON Schema conversion.
|
|
43
|
+
*/
|
|
44
|
+
resolveToolDefinition(name: string): ClientToolDefinition | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve multiple tool names into ClientToolDefinition objects.
|
|
47
|
+
* Skips names that cannot be resolved.
|
|
48
|
+
*/
|
|
49
|
+
resolveToolDefinitions(names: string[]): ClientToolDefinition[];
|
|
50
|
+
/**
|
|
51
|
+
* Look up name + description for a tool.
|
|
52
|
+
*/
|
|
53
|
+
private getToolSummary;
|
|
54
|
+
init(toolNames: string[], pageContext: PageContext): void;
|
|
34
55
|
start(peer: Peer, prompt: string, apiKey: string, authSecret: string, selectedUuids?: string[]): void;
|
|
35
56
|
resolveToolResult(callId: string, result: {
|
|
36
57
|
result: unknown;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { buildSystemPrompt, buildSystemPromptEntries } from "./agentPrompt.js";
|
|
2
3
|
import { provider, models } from "#blokkli-build/agent-server";
|
|
3
4
|
import {
|
|
4
5
|
send,
|
|
@@ -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
|
-
/**
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
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 */
|
|
@@ -42,14 +43,77 @@ export class Session {
|
|
|
42
43
|
plan = null;
|
|
43
44
|
/** Pending plan approval promise resolver */
|
|
44
45
|
pendingPlanApproval = null;
|
|
45
|
-
/**
|
|
46
|
-
|
|
46
|
+
/** Pre-pruned messages snapshot for transcript (captured before pruneMessages) */
|
|
47
|
+
unprunedMessages = [];
|
|
48
|
+
/** Last generic tool definitions for transcript */
|
|
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
|
+
}
|
|
47
102
|
// --------------------------------------------------------------------------
|
|
48
103
|
// Public methods
|
|
49
104
|
// --------------------------------------------------------------------------
|
|
50
|
-
init(
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
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
|
+
}
|
|
53
117
|
this.activatedLazyTools = /* @__PURE__ */ new Set();
|
|
54
118
|
this.loadedSkills = /* @__PURE__ */ new Set();
|
|
55
119
|
this.pageContext = pageContext;
|
|
@@ -110,12 +174,14 @@ export class Session {
|
|
|
110
174
|
getTranscript(peer) {
|
|
111
175
|
send(peer, {
|
|
112
176
|
type: "transcript",
|
|
113
|
-
|
|
177
|
+
transcript: this.buildTranscript()
|
|
114
178
|
});
|
|
115
179
|
}
|
|
116
180
|
newConversation(peer, authSecret) {
|
|
117
181
|
this.abortController?.abort();
|
|
118
182
|
this.messages = [];
|
|
183
|
+
this.unprunedMessages = [];
|
|
184
|
+
this.lastTools = [];
|
|
119
185
|
this.activatedLazyTools.clear();
|
|
120
186
|
this.loadedSkills.clear();
|
|
121
187
|
this.plan = null;
|
|
@@ -138,8 +204,8 @@ export class Session {
|
|
|
138
204
|
}
|
|
139
205
|
this.plan = null;
|
|
140
206
|
this.messages = [];
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
207
|
+
this.toolNames = [];
|
|
208
|
+
this.lazyToolNames = [];
|
|
143
209
|
this.activatedLazyTools.clear();
|
|
144
210
|
this.loadedSkills.clear();
|
|
145
211
|
this.pageContext = void 0;
|
|
@@ -182,7 +248,9 @@ export class Session {
|
|
|
182
248
|
return { success: false, reason: "Invalid message structure" };
|
|
183
249
|
}
|
|
184
250
|
this.messages = state.messages;
|
|
185
|
-
|
|
251
|
+
this.unprunedMessages = [];
|
|
252
|
+
this.lastTools = [];
|
|
253
|
+
const validLazyToolNames = new Set(this.lazyToolNames);
|
|
186
254
|
this.activatedLazyTools = new Set(
|
|
187
255
|
state.activatedLazyTools.filter((name) => validLazyToolNames.has(name))
|
|
188
256
|
);
|
|
@@ -234,7 +302,7 @@ export class Session {
|
|
|
234
302
|
});
|
|
235
303
|
}
|
|
236
304
|
async runAgentLoop(peer, prompt, apiKey, authSecret, selectedUuids) {
|
|
237
|
-
if (this.
|
|
305
|
+
if (this.toolNames.length === 0) {
|
|
238
306
|
send(peer, {
|
|
239
307
|
type: "error",
|
|
240
308
|
errorType: "bad_request",
|
|
@@ -251,10 +319,9 @@ export class Session {
|
|
|
251
319
|
return;
|
|
252
320
|
}
|
|
253
321
|
const resolvedSkills = resolveSkills(this.pageContext);
|
|
254
|
-
const lazyToolSummaries = this.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}));
|
|
322
|
+
const lazyToolSummaries = this.lazyToolNames.map((name) => this.getToolSummary(name)).filter(
|
|
323
|
+
(s) => s !== void 0
|
|
324
|
+
);
|
|
258
325
|
const userParts = [];
|
|
259
326
|
if (selectedUuids?.length) {
|
|
260
327
|
userParts.push(
|
|
@@ -273,6 +340,9 @@ export class Session {
|
|
|
273
340
|
let planRetryCount = 0;
|
|
274
341
|
let streamRetryCount = 0;
|
|
275
342
|
const MAX_STREAM_RETRIES = 1;
|
|
343
|
+
let lastToolCallKey = "";
|
|
344
|
+
let consecutiveIdenticalCalls = 0;
|
|
345
|
+
const MAX_IDENTICAL_CALLS = 2;
|
|
276
346
|
try {
|
|
277
347
|
while (true) {
|
|
278
348
|
if (this.abortController.signal.aborted) {
|
|
@@ -286,11 +356,16 @@ export class Session {
|
|
|
286
356
|
let currentToolUse = null;
|
|
287
357
|
let currentTextContent = "";
|
|
288
358
|
let inTextBlock = false;
|
|
289
|
-
const
|
|
290
|
-
|
|
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)
|
|
291
366
|
);
|
|
292
|
-
const unloadedLazyTools = this.
|
|
293
|
-
(
|
|
367
|
+
const unloadedLazyTools = unloadedLazyToolNames.map((name) => this.getToolSummary(name)).filter(
|
|
368
|
+
(s) => s !== void 0
|
|
294
369
|
);
|
|
295
370
|
const defCtx = {
|
|
296
371
|
resolvedSkills,
|
|
@@ -298,7 +373,8 @@ export class Session {
|
|
|
298
373
|
unloadedLazyTools
|
|
299
374
|
};
|
|
300
375
|
const serverToolDefs = serverTools.map((t) => buildDefinition(t, defCtx)).filter((d) => d !== null);
|
|
301
|
-
const allTools = [...serverToolDefs, ...
|
|
376
|
+
const allTools = [...serverToolDefs, ...eagerTools, ...activatedTools];
|
|
377
|
+
this.lastTools = allTools;
|
|
302
378
|
const systemPrompt = buildSystemPrompt(
|
|
303
379
|
this.pageContext,
|
|
304
380
|
resolvedSkills,
|
|
@@ -326,7 +402,6 @@ export class Session {
|
|
|
326
402
|
}
|
|
327
403
|
switch (event.type) {
|
|
328
404
|
case "debug_request":
|
|
329
|
-
this.lastProviderTools = event.tools;
|
|
330
405
|
break;
|
|
331
406
|
case "text_start":
|
|
332
407
|
inTextBlock = true;
|
|
@@ -392,6 +467,25 @@ export class Session {
|
|
|
392
467
|
name: currentToolUse.name,
|
|
393
468
|
input
|
|
394
469
|
});
|
|
470
|
+
const toolCallKey = currentToolUse.name + ":" + currentToolUse.inputJson;
|
|
471
|
+
if (toolCallKey === lastToolCallKey) {
|
|
472
|
+
consecutiveIdenticalCalls++;
|
|
473
|
+
} else {
|
|
474
|
+
lastToolCallKey = toolCallKey;
|
|
475
|
+
consecutiveIdenticalCalls = 1;
|
|
476
|
+
}
|
|
477
|
+
if (consecutiveIdenticalCalls > MAX_IDENTICAL_CALLS) {
|
|
478
|
+
toolResults.push({
|
|
479
|
+
type: "tool_result",
|
|
480
|
+
tool_use_id: currentToolUse.id,
|
|
481
|
+
content: JSON.stringify({
|
|
482
|
+
error: `You have called "${currentToolUse.name}" ${consecutiveIdenticalCalls} times in a row with identical parameters and received the same result each time. Stop repeating this call. Use the information you already have or try a different approach.`
|
|
483
|
+
}),
|
|
484
|
+
is_error: true
|
|
485
|
+
});
|
|
486
|
+
currentToolUse = null;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
395
489
|
const matchedServerTool = serverTools.find(
|
|
396
490
|
(t) => t.name === currentToolUse.name
|
|
397
491
|
);
|
|
@@ -412,7 +506,7 @@ export class Session {
|
|
|
412
506
|
toolUseId: currentToolUse.id,
|
|
413
507
|
send: (msg) => send(peer, msg),
|
|
414
508
|
resolvedSkills,
|
|
415
|
-
|
|
509
|
+
lazyToolNames: this.lazyToolNames,
|
|
416
510
|
activatedLazyTools: this.activatedLazyTools,
|
|
417
511
|
loadedSkills: this.loadedSkills,
|
|
418
512
|
plan: this.plan,
|
|
@@ -448,7 +542,20 @@ export class Session {
|
|
|
448
542
|
}
|
|
449
543
|
};
|
|
450
544
|
try {
|
|
451
|
-
const
|
|
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);
|
|
452
559
|
const result = await matchedServerTool.handle(
|
|
453
560
|
handlerCtx,
|
|
454
561
|
parsed
|
|
@@ -600,6 +707,7 @@ export class Session {
|
|
|
600
707
|
} finally {
|
|
601
708
|
this.isProcessing = false;
|
|
602
709
|
this.abortController = null;
|
|
710
|
+
this.unprunedMessages = structuredClone(this.messages);
|
|
603
711
|
pruneMessages(
|
|
604
712
|
this.messages,
|
|
605
713
|
KEEP_RECENT_TURNS,
|
|
@@ -666,69 +774,44 @@ export class Session {
|
|
|
666
774
|
*/
|
|
667
775
|
buildToolMetadataMap() {
|
|
668
776
|
const map = /* @__PURE__ */ new Map();
|
|
669
|
-
for (const
|
|
670
|
-
|
|
671
|
-
|
|
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 });
|
|
672
781
|
}
|
|
673
782
|
}
|
|
674
783
|
return map;
|
|
675
784
|
}
|
|
676
785
|
buildTranscript() {
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
if (this.lastProviderTools) {
|
|
698
|
-
lines.push("=".repeat(80));
|
|
699
|
-
lines.push("TOOLS (exact payload sent to provider)");
|
|
700
|
-
lines.push("=".repeat(80));
|
|
701
|
-
lines.push(JSON.stringify(this.lastProviderTools, null, 2));
|
|
702
|
-
lines.push("");
|
|
703
|
-
}
|
|
704
|
-
for (const message of this.messages) {
|
|
705
|
-
lines.push("=".repeat(80));
|
|
706
|
-
lines.push(`${message.role.toUpperCase()}`);
|
|
707
|
-
lines.push("=".repeat(80));
|
|
708
|
-
if (typeof message.content === "string") {
|
|
709
|
-
lines.push(message.content);
|
|
710
|
-
} else if (Array.isArray(message.content)) {
|
|
711
|
-
for (const block of message.content) {
|
|
712
|
-
if (block.type === "text") {
|
|
713
|
-
lines.push(block.text);
|
|
714
|
-
} else if (block.type === "skill") {
|
|
715
|
-
lines.push(`[Skill: ${block.name}]`);
|
|
716
|
-
lines.push(block.text);
|
|
717
|
-
} else if (block.type === "tool_use") {
|
|
718
|
-
lines.push(`[Tool Call: ${block.name}]`);
|
|
719
|
-
lines.push(JSON.stringify(block.input, null, 2));
|
|
720
|
-
} else if (block.type === "tool_result") {
|
|
721
|
-
lines.push(`[Tool Result: ${block.tool_use_id}]`);
|
|
722
|
-
try {
|
|
723
|
-
lines.push(JSON.stringify(JSON.parse(block.content), null, 2));
|
|
724
|
-
} catch {
|
|
725
|
-
lines.push(block.content);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
786
|
+
const system = this.pageContext ? buildSystemPromptEntries(
|
|
787
|
+
this.pageContext,
|
|
788
|
+
resolveSkills(this.pageContext),
|
|
789
|
+
this.lazyToolNames.map((name) => this.getToolSummary(name)).filter(
|
|
790
|
+
(s) => s !== void 0
|
|
791
|
+
),
|
|
792
|
+
this.getActivePlanContext(),
|
|
793
|
+
this.loadedSkills
|
|
794
|
+
) : [];
|
|
795
|
+
const messages = this.messages.map((msg, i) => {
|
|
796
|
+
const entry = {
|
|
797
|
+
type: msg.role === "assistant" ? "agent" : "user",
|
|
798
|
+
seen: msg.content
|
|
799
|
+
};
|
|
800
|
+
const unpruned = this.unprunedMessages[i];
|
|
801
|
+
if (unpruned) {
|
|
802
|
+
const seenJson = JSON.stringify(msg.content);
|
|
803
|
+
const fullJson = JSON.stringify(unpruned.content);
|
|
804
|
+
if (seenJson !== fullJson) {
|
|
805
|
+
entry.full = unpruned.content;
|
|
728
806
|
}
|
|
729
807
|
}
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
|
|
808
|
+
return entry;
|
|
809
|
+
});
|
|
810
|
+
const tools = this.lastTools.map((t) => ({
|
|
811
|
+
name: t.name,
|
|
812
|
+
description: t.description,
|
|
813
|
+
input_schema: t.input_schema
|
|
814
|
+
}));
|
|
815
|
+
return { system, messages, tools };
|
|
733
816
|
}
|
|
734
817
|
}
|
|
@@ -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
|
-
|
|
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.
|
|
73
|
+
session.init(data.toolNames, data.pageContext);
|
|
73
74
|
break;
|
|
74
75
|
case "start":
|
|
75
76
|
if (!apiKey) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PageContext } from '../shared/types.js';
|
|
1
|
+
import type { PageContext, TranscriptSystemPrompt } from '../shared/types.js';
|
|
2
2
|
import type { ResolvedSkill } from './skills/types.js';
|
|
3
3
|
import type { ActivePlanContext, SystemPromptBlock } from './system-prompts/types.js';
|
|
4
4
|
/**
|
|
@@ -20,3 +20,11 @@ export declare function buildSystemPromptText(context: PageContext, resolvedSkil
|
|
|
20
20
|
name: string;
|
|
21
21
|
description: string;
|
|
22
22
|
}[], activePlan?: ActivePlanContext, loadedSkills?: ReadonlySet<string>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Build structured system prompt entries for the transcript.
|
|
25
|
+
* Returns one entry per prompt definition with id, name, and content.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildSystemPromptEntries(context: PageContext, resolvedSkills: ResolvedSkill[], lazyTools?: {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
}[], activePlan?: ActivePlanContext, loadedSkills?: ReadonlySet<string>): TranscriptSystemPrompt[];
|
|
@@ -51,3 +51,29 @@ export function buildSystemPromptText(context, resolvedSkills, lazyTools = [], a
|
|
|
51
51
|
loadedSkills
|
|
52
52
|
).map((b) => b.text).join("\n\n");
|
|
53
53
|
}
|
|
54
|
+
export function buildSystemPromptEntries(context, resolvedSkills, lazyTools = [], activePlan, loadedSkills = /* @__PURE__ */ new Set()) {
|
|
55
|
+
const promptContext = {
|
|
56
|
+
pageContext: context,
|
|
57
|
+
resolvedSkills,
|
|
58
|
+
lazyTools,
|
|
59
|
+
isDebugMode: !!(import.meta.dev && debugPrompt),
|
|
60
|
+
activePlan,
|
|
61
|
+
loadedSkills
|
|
62
|
+
};
|
|
63
|
+
const sorted = systemPrompts.filter((sp) => !sp.modes?.length || sp.modes.includes(context.editMode)).sort((a, b) => {
|
|
64
|
+
const groupDiff = getCacheGroupOrder(a) - getCacheGroupOrder(b);
|
|
65
|
+
if (groupDiff !== 0) return groupDiff;
|
|
66
|
+
return a.weight - b.weight;
|
|
67
|
+
});
|
|
68
|
+
const entries = [];
|
|
69
|
+
for (const sp of sorted) {
|
|
70
|
+
const text = sp.getPrompt(promptContext)?.trim();
|
|
71
|
+
if (!text) continue;
|
|
72
|
+
entries.push({
|
|
73
|
+
id: sp.id,
|
|
74
|
+
name: sp.title,
|
|
75
|
+
content: text
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return entries;
|
|
79
|
+
}
|