@shwfed/config 2.11.5 → 2.12.0
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 -0
- package/dist/runtime/components/actions/buttons/2026-04-18/com.shwfed.actions.button.http.request.json.confirm/schema.d.ts +13 -7
- package/dist/runtime/components/actions/buttons/2026-04-18/com.shwfed.actions.button.prototype/config.vue +1 -0
- package/dist/runtime/components/actions/buttons/2026-05-11/com.shwfed.actions.button.modal.layout/schema.d.ts +13 -7
- package/dist/runtime/components/actions/buttons/2026-06-08/com.shwfed.actions.button.http.request.json.batch/schema.d.ts +13 -7
- package/dist/runtime/components/actions/config.vue +2 -0
- package/dist/runtime/components/actions/items/2026-05-21/com.shwfed.actions.item.markdown/schema.d.ts +13 -7
- package/dist/runtime/components/actions/schema.d.ts +82 -52
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.actions/schema.d.ts +5 -5
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.markdown/schema.d.ts +13 -7
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/schema.d.ts +62 -38
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.tabs/schema.d.ts +26 -14
- package/dist/runtime/components/config/blocks/2026-05-17/com.shwfed.block.chart.xy/schema.d.ts +39 -21
- package/dist/runtime/components/config/blocks/2026-06-01/com.shwfed.block.animated.number/schema.d.ts +13 -7
- package/dist/runtime/components/config/blocks/2026-06-02/com.shwfed.block.card/schema.d.ts +26 -14
- package/dist/runtime/components/config/blocks/2026-06-17/com.shwfed.block.tree.single/schema.d.ts +44 -26
- package/dist/runtime/components/config/schema.d.ts +13 -7
- package/dist/runtime/components/form/fields/2026-04-22/com.shwfed.form.field.markdown/schema.d.ts +26 -14
- package/dist/runtime/components/form/fields/2026-04-22/com.shwfed.form.field.text/schema.d.ts +57 -33
- package/dist/runtime/components/form/fields/2026-04-22/com.shwfed.form.field.textarea/schema.d.ts +52 -28
- package/dist/runtime/components/form/fields/2026-04-24/com.shwfed.form.field.actions/schema.d.ts +18 -12
- package/dist/runtime/components/form/fields/2026-04-24/com.shwfed.form.field.combobox.single/schema.d.ts +65 -35
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.date/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.daterange/schema.d.ts +91 -49
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetime/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.datetimerange/schema.d.ts +91 -49
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.time/schema.d.ts +39 -21
- package/dist/runtime/components/form/fields/2026-04-27/com.shwfed.form.field.timerange/schema.d.ts +39 -21
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.number/schema.d.ts +57 -33
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.numberrange/schema.d.ts +65 -35
- package/dist/runtime/components/form/fields/2026-04-28/com.shwfed.form.field.switch/schema.d.ts +65 -35
- package/dist/runtime/components/form/fields/2026-04-29/com.shwfed.form.field.combobox.single/schema.d.ts +104 -56
- package/dist/runtime/components/form/fields/2026-05-12/com.shwfed.form.field.upload/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.combobox.single.remote/schema.d.ts +65 -35
- package/dist/runtime/components/form/fields/2026-05-13/com.shwfed.form.field.list/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-17/com.shwfed.form.field.checkbox.group/schema.d.ts +91 -49
- package/dist/runtime/components/form/fields/2026-05-17/com.shwfed.form.field.radio.group/schema.d.ts +91 -49
- package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/schema.d.ts +39 -21
- package/dist/runtime/components/form/fields/2026-05-20/com.shwfed.form.field.collapsible/schema.d.ts +13 -7
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-23/com.shwfed.form.field.tree.multi/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-24/com.shwfed.form.field.month/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-24/com.shwfed.form.field.monthrange/schema.d.ts +91 -49
- package/dist/runtime/components/form/fields/2026-05-25/com.shwfed.form.field.combobox.multi/schema.d.ts +65 -35
- package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.multi/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.multi/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.multi/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.single/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.single/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-26/com.shwfed.form.field.tree.combobox.single/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.multi/schema.d.ts +169 -91
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.combobox.single/schema.d.ts +169 -91
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.multi/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.combobox.single/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.multi/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/config.d.vue.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/config.vue.d.ts +22 -22
- package/dist/runtime/components/form/fields/2026-05-28/com.shwfed.form.field.tree.single/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-06-09/com.shwfed.form.field.upload/schema.d.ts +78 -42
- package/dist/runtime/components/form/fields/2026-06-14/com.shwfed.form.field.combobox.multi/schema.d.ts +130 -70
- package/dist/runtime/components/form/fields/2026-06-14/com.shwfed.form.field.combobox.single/schema.d.ts +130 -70
- package/dist/runtime/components/form/fields/2026-06-20/com.shwfed.form.field.tabs/schema.d.ts +26 -14
- package/dist/runtime/components/form/utils/common.d.ts +26 -14
- package/dist/runtime/components/operations/2026-06-09/com.shwfed.operation.alert/schema.d.ts +13 -7
- package/dist/runtime/components/operations/2026-06-11/com.shwfed.operation.http.request.json/schema.d.ts +13 -7
- package/dist/runtime/components/operations/2026-06-15/com.shwfed.operation.http.download/schema.d.ts +13 -7
- package/dist/runtime/components/table/ai-generate.d.vue.ts +16 -0
- package/dist/runtime/components/table/ai-generate.system.d.ts +1 -0
- package/dist/runtime/components/table/ai-generate.system.js +10 -0
- package/dist/runtime/components/table/ai-generate.system.md +95 -0
- package/dist/runtime/components/table/ai-generate.vue +172 -0
- package/dist/runtime/components/table/ai-generate.vue.d.ts +16 -0
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.actions/schema.d.ts +18 -12
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.date/schema.d.ts +26 -14
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.icon/runtime.vue +3 -4
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.icon/schema.d.ts +26 -14
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.markdown/runtime.vue +3 -3
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.markdown/schema.d.ts +39 -21
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.number/schema.d.ts +26 -14
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.select/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-04-14/com.shwfed.table.column.text/schema.d.ts +26 -14
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch/runtime.vue +5 -6
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch/schema.d.ts +26 -14
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/runtime.vue +5 -6
- package/dist/runtime/components/table/columns/2026-05-13/com.shwfed.table.column.switch.remote/schema.d.ts +26 -14
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.combobox-single/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.combobox-single/schema.d.ts +91 -49
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.number-input/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.number-input/schema.d.ts +44 -26
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/schema.d.ts +52 -28
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch.local/schema.d.ts +52 -28
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.text-input/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.text-input/schema.d.ts +44 -26
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-remote/schema.d.ts +52 -28
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-24/com.shwfed.table.column.combobox-single.remote.options-static/schema.d.ts +91 -49
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi/schema.d.ts +91 -49
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-remote/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-remote/schema.d.ts +52 -28
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-static/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-25/com.shwfed.table.column.combobox-multi.remote.options-static/schema.d.ts +91 -49
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi/schema.d.ts +156 -84
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-multi.remote/schema.d.ts +156 -84
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single/schema.d.ts +156 -84
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-26/com.shwfed.table.column.combobox-single.remote/schema.d.ts +156 -84
- package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-multi/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-multi/schema.d.ts +65 -35
- package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-single/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-27/com.shwfed.table.column.tree-combobox-single/schema.d.ts +65 -35
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-multi/schema.d.ts +156 -84
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.combobox-single/schema.d.ts +156 -84
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-multi/schema.d.ts +65 -35
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-05-28/com.shwfed.table.column.tree-combobox-single/schema.d.ts +65 -35
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.combobox-multi/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.combobox-multi/schema.d.ts +117 -63
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.combobox-single/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.combobox-single/schema.d.ts +117 -63
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-multi/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-multi/schema.d.ts +52 -28
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-single/runtime.vue +2 -2
- package/dist/runtime/components/table/columns/2026-06-14/com.shwfed.table.column.tree-combobox-single/schema.d.ts +52 -28
- package/dist/runtime/components/table/columns/2026-06-17/com.shwfed.table.column.date-input/runtime.vue +3 -3
- package/dist/runtime/components/table/columns/2026-06-17/com.shwfed.table.column.date-input/schema.d.ts +70 -40
- package/dist/runtime/components/table/columns/2026-06-22/com.shwfed.table.column.date-range-input/runtime.vue +4 -4
- package/dist/runtime/components/table/columns/2026-06-22/com.shwfed.table.column.date-range-input/schema.d.ts +78 -42
- package/dist/runtime/components/table/config.d.vue.ts +3 -3
- package/dist/runtime/components/table/config.vue +38 -3
- package/dist/runtime/components/table/config.vue.d.ts +3 -3
- package/dist/runtime/components/table/row-provider.vue +2 -2
- package/dist/runtime/components/table/schema.d.ts +114 -66
- package/dist/runtime/components/table/utils/ai-tools.d.ts +11 -0
- package/dist/runtime/components/table/utils/ai-tools.js +458 -0
- package/dist/runtime/components/table/utils/resolve.d.ts +23 -0
- package/dist/runtime/components/table/utils/resolve.js +3 -0
- package/dist/runtime/components/table/utils/shared.d.ts +65 -35
- package/dist/runtime/components/table/utils/shared.js +16 -17
- package/dist/runtime/components/ui/alert-dialog/AlertDialogFooter.vue +1 -1
- package/dist/runtime/components/ui/chat/ChatMessage.d.vue.ts +7 -0
- package/dist/runtime/components/ui/chat/ChatMessage.vue +35 -0
- package/dist/runtime/components/ui/chat/ChatMessage.vue.d.ts +7 -0
- package/dist/runtime/components/ui/chat/ChatMessagePart.d.vue.ts +7 -0
- package/dist/runtime/components/ui/chat/ChatMessagePart.vue +43 -0
- package/dist/runtime/components/ui/chat/ChatMessagePart.vue.d.ts +7 -0
- package/dist/runtime/components/ui/chat/ChatMessages.d.vue.ts +18 -0
- package/dist/runtime/components/ui/chat/ChatMessages.vue +63 -0
- package/dist/runtime/components/ui/chat/ChatMessages.vue.d.ts +18 -0
- package/dist/runtime/components/ui/chat/ChatPrompt.d.vue.ts +24 -0
- package/dist/runtime/components/ui/chat/ChatPrompt.vue +43 -0
- package/dist/runtime/components/ui/chat/ChatPrompt.vue.d.ts +24 -0
- package/dist/runtime/components/ui/chat/ChatPromptSubmit.d.vue.ts +18 -0
- package/dist/runtime/components/ui/chat/ChatPromptSubmit.vue +41 -0
- package/dist/runtime/components/ui/chat/ChatPromptSubmit.vue.d.ts +18 -0
- package/dist/runtime/components/ui/chat/ChatReasoning.d.vue.ts +7 -0
- package/dist/runtime/components/ui/chat/ChatReasoning.vue +33 -0
- package/dist/runtime/components/ui/chat/ChatReasoning.vue.d.ts +7 -0
- package/dist/runtime/components/ui/chat/ChatToolCall.d.vue.ts +10 -0
- package/dist/runtime/components/ui/chat/ChatToolCall.vue +92 -0
- package/dist/runtime/components/ui/chat/ChatToolCall.vue.d.ts +10 -0
- package/dist/runtime/components/ui/chat/index.d.ts +9 -0
- package/dist/runtime/components/ui/chat/index.js +8 -0
- package/dist/runtime/components/ui/stream-markdown/StreamMarkdown.d.vue.ts +15 -0
- package/dist/runtime/components/ui/stream-markdown/StreamMarkdown.vue +22 -0
- package/dist/runtime/components/ui/stream-markdown/StreamMarkdown.vue.d.ts +15 -0
- package/dist/runtime/components/ui/stream-markdown/index.d.ts +1 -0
- package/dist/runtime/components/ui/stream-markdown/index.js +1 -0
- package/dist/runtime/share/coerce-from-string.d.ts +62 -0
- package/dist/runtime/share/coerce-from-string.js +154 -0
- package/dist/runtime/share/locale.d.ts +13 -7
- package/dist/runtime/share/locale.js +27 -5
- package/dist/runtime/share/use-persisted-chat.d.ts +30 -0
- package/dist/runtime/share/use-persisted-chat.js +34 -0
- package/dist/runtime/utils/ai/index.d.ts +10 -0
- package/dist/runtime/utils/ai/index.js +123 -33
- package/dist/runtime/utils/ai/parts.d.ts +30 -0
- package/dist/runtime/utils/ai/parts.js +9 -0
- package/dist/runtime/utils/cel-context.d.ts +1 -0
- package/dist/runtime/utils/cel-context.js +28 -0
- package/package.json +4 -8
- package/dist/mcp.mjs +0 -102434
- package/dist/preview/assets/FieldGroup.vue_vue_type_script_setup_true_lang-BK4nj6mF.js +0 -1
- package/dist/preview/assets/badge-Df9KgnrB.js +0 -1
- package/dist/preview/assets/config-B3NwVBxT.js +0 -1
- package/dist/preview/assets/config-BrtNnMlJ.js +0 -1
- package/dist/preview/assets/config-CUJNegvX.js +0 -1
- package/dist/preview/assets/config-ChrXUmKf.js +0 -1
- package/dist/preview/assets/config-CmEXMpIU.js +0 -1
- package/dist/preview/assets/config-CrBoFiYB.js +0 -1
- package/dist/preview/assets/config-D-Hf0dls.js +0 -1
- package/dist/preview/assets/config-D4cXwy75.js +0 -1
- package/dist/preview/assets/config-DCj5Qyiq.js +0 -1
- package/dist/preview/assets/config-DPfx03nM.js +0 -1
- package/dist/preview/assets/config-DWF0bcmF.js +0 -1
- package/dist/preview/assets/config-Do4K9hI7.js +0 -1
- package/dist/preview/assets/config-DwblM1r8.js +0 -1
- package/dist/preview/assets/config-MW5Hs8yE.js +0 -1
- package/dist/preview/assets/config-uNoNEc-1.js +0 -1
- package/dist/preview/assets/definition.vue_vue_type_script_setup_true_lang-CbtpddWK.js +0 -1
- package/dist/preview/assets/index-Bm7I4Tr0.css +0 -1
- package/dist/preview/assets/index-CkyV576r.js +0 -775
- package/dist/preview/assets/index-CtW2E0ME.js +0 -1
- package/dist/preview/assets/index-xDmBF3zO.js +0 -1
- package/dist/preview/assets/item-D0e9Cx1Q.js +0 -1
- package/dist/preview/assets/runtime-3tGIbclh.js +0 -1
- package/dist/preview/assets/runtime-BCePD3XR.js +0 -1
- package/dist/preview/assets/runtime-BMyFUaSM.js +0 -1
- package/dist/preview/assets/runtime-BXZU3EqA.js +0 -1
- package/dist/preview/assets/runtime-BySNFNSO.js +0 -1
- package/dist/preview/assets/runtime-CI02gDFj.js +0 -1
- package/dist/preview/assets/runtime-DCo1Qp8a.js +0 -1
- package/dist/preview/assets/runtime-DDSKV70N.js +0 -1
- package/dist/preview/assets/runtime-Dc7pytUy.js +0 -1
- package/dist/preview/assets/runtime-ckLrkTMm.js +0 -1
- package/dist/preview/assets/runtime-y4oJ8VkY.js +0 -1
- package/dist/preview/assets/schema-meta-D0y0sKal.js +0 -1
- package/dist/preview/index.html +0 -19
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
source: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
source: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { useRuntimeConfig } from "#app";
|
|
3
|
+
import remend from "remend";
|
|
4
|
+
import { computed, defineComponent, h } from "vue";
|
|
5
|
+
import { md } from "../../../utils/markdown";
|
|
6
|
+
const REMEND_OPTIONS = {
|
|
7
|
+
linkMode: "text-only",
|
|
8
|
+
katex: false,
|
|
9
|
+
inlineKatex: false
|
|
10
|
+
};
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
name: "UiStreamMarkdown",
|
|
13
|
+
props: {
|
|
14
|
+
source: { type: String, required: true }
|
|
15
|
+
},
|
|
16
|
+
setup(props) {
|
|
17
|
+
const env = { base: useRuntimeConfig().app.baseURL || "/" };
|
|
18
|
+
const html = computed(() => md.render(remend(props.source, REMEND_OPTIONS), env));
|
|
19
|
+
return () => h("div", { "data-slot": "stream-markdown", "innerHTML": html.value });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
source: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
source: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as StreamMarkdown } from './StreamMarkdown.vue.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as StreamMarkdown } from "./StreamMarkdown.vue";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { SchemaAST } from 'effect';
|
|
2
|
+
/**
|
|
3
|
+
* Coerce AI tool-call outputs that the model accidentally stringified.
|
|
4
|
+
*
|
|
5
|
+
* The AI tool-call loop accumulates `partial_json` deltas and concatenates them
|
|
6
|
+
* into one JSON string, then `JSON.parse`s it. When the model is unsure about a
|
|
7
|
+
* field's wire shape — does `size` want a number or a string? — it sometimes
|
|
8
|
+
* stringifies the value, so the parser hands us e.g. `size: "120"` while the
|
|
9
|
+
* column schema declares `Schema.Number.pipe(Schema.finite(), Schema.positive())`.
|
|
10
|
+
*
|
|
11
|
+
* `Schema.decodeUnknownSync` then rejects with `Expected number, actual string`,
|
|
12
|
+
* the chat loop can't recover, and the user sees the "改写配置中…" card spin
|
|
13
|
+
* forever. The same bug also affects `grow` (Boolean), `gap` (Number),
|
|
14
|
+
* `expandAll` (Boolean), every column/button/block schema's primitive fields —
|
|
15
|
+
* per-schema `Schema.transform` workarounds would touch dozens of files and
|
|
16
|
+
* pollute the JSON Schema we hand back to the model (it would advertise
|
|
17
|
+
* `oneOf: [number, string]` and tell the model "strings are OK", which they
|
|
18
|
+
* aren't).
|
|
19
|
+
*
|
|
20
|
+
* This helper takes a different path: walk the raw value in parallel with the
|
|
21
|
+
* schema's AST, and silently coerce string → number / boolean based on what the
|
|
22
|
+
* schema expects. The schema is never modified, so:
|
|
23
|
+
*
|
|
24
|
+
* - `JSONSchema.make(schema)` still emits `type: number` / `type: boolean`
|
|
25
|
+
* for the model (it sees the canonical types and is asked to honor them).
|
|
26
|
+
* - Existing `Schema.suspend(Schema.transform(...))` wrappers (e.g. `Locale`,
|
|
27
|
+
* which already forgives stringified tuples) keep working — this preprocessor
|
|
28
|
+
* passes strings through for fields whose schema accepts strings.
|
|
29
|
+
* - Effect 3.21.2's `Schema.optionalWith` quirk (it strips peer property
|
|
30
|
+
* Transformation wrappers — see the `Locale` fix) cannot fire, because we
|
|
31
|
+
* never add a Transformation anywhere.
|
|
32
|
+
*
|
|
33
|
+
* Apply this at the AI decode chokepoint, BEFORE `Schema.decodeUnknownSync`.
|
|
34
|
+
* After preprocessing, the raw value is structurally compatible with the
|
|
35
|
+
* schema, and the schema's own validators (finite/positive/etc.) still run.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Pre-process `raw` so it decodes cleanly against `schema`. The schema is read
|
|
39
|
+
* but never modified — this is a pure transformation of the value side.
|
|
40
|
+
*
|
|
41
|
+
* Safe to call on already-typed values (numbers stay numbers, etc.); the only
|
|
42
|
+
* change is `string → number` when the schema expects a number, and the
|
|
43
|
+
* equivalent for booleans. JSON-stringified object/array payloads are also
|
|
44
|
+
* parsed once, mirroring the `Locale` tuple fix at the general level.
|
|
45
|
+
*
|
|
46
|
+
* `S` is inferred from the call site. We don't pin it to one of Effect's
|
|
47
|
+
* bundled `Schema.Any` / `Schema.All` aliases because their third type
|
|
48
|
+
* parameter (Context / R) collides between `never` and `unknown` under
|
|
49
|
+
* strict mode, making any of them reject callers that pass the other.
|
|
50
|
+
*/
|
|
51
|
+
export declare function coerceFromString<S extends {
|
|
52
|
+
readonly ast: SchemaAST.AST;
|
|
53
|
+
}>(raw: unknown, schema: S): unknown;
|
|
54
|
+
/**
|
|
55
|
+
* Build a JSON Schema with the same shape as `JSONSchema.make(schema)` —
|
|
56
|
+
* exposed only for the test suite to lock in the "no JSONSchema pollution"
|
|
57
|
+
* guarantee. If this drifts from `JSONSchema.make`, the implementation
|
|
58
|
+
* accidentally changed the schema and the model will be misled.
|
|
59
|
+
*/
|
|
60
|
+
export declare function peekJsonSchema<S extends {
|
|
61
|
+
ast: SchemaAST.AST;
|
|
62
|
+
}>(schema: S): unknown;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { JSONSchema, SchemaAST } from "effect";
|
|
2
|
+
export function coerceFromString(raw, schema) {
|
|
3
|
+
return preprocess(raw, schema.ast);
|
|
4
|
+
}
|
|
5
|
+
function preprocess(value, ast) {
|
|
6
|
+
const shape = unwrap(ast);
|
|
7
|
+
if (value === null || value === void 0) return value;
|
|
8
|
+
if (typeof value !== "object") return value;
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
if (shape._tag === "TupleType") {
|
|
11
|
+
const elements = shape.elements;
|
|
12
|
+
const restAst = shape.rest[0]?.type ?? SchemaAST.unknownKeyword;
|
|
13
|
+
return value.map((v, i) => {
|
|
14
|
+
const elementType = i < elements.length ? elements[i].type : restAst;
|
|
15
|
+
return preprocessField(v, elementType);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return value.map((v) => preprocessField(v, shape));
|
|
19
|
+
}
|
|
20
|
+
if (shape._tag === "TypeLiteral") {
|
|
21
|
+
return preprocessStruct(value, shape);
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function preprocessStruct(value, ast) {
|
|
26
|
+
const result = {};
|
|
27
|
+
for (const ps of ast.propertySignatures) {
|
|
28
|
+
const key = ps.name;
|
|
29
|
+
if (!(key in value)) continue;
|
|
30
|
+
result[key] = preprocessField(value[key], ps.type);
|
|
31
|
+
}
|
|
32
|
+
for (const key of Object.keys(value)) {
|
|
33
|
+
if (!(key in result)) result[key] = value[key];
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
function preprocessField(value, ast) {
|
|
38
|
+
if (typeof value === "string") {
|
|
39
|
+
const parsedJson = tryParseJson(value, ast);
|
|
40
|
+
if (parsedJson !== void 0) return preprocess(parsedJson, ast);
|
|
41
|
+
}
|
|
42
|
+
if (typeof value === "string") {
|
|
43
|
+
if (expectsNumber(ast)) {
|
|
44
|
+
if (value.trim() !== "") return Number(value);
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
if (expectsBoolean(ast)) {
|
|
48
|
+
if (value === "true") return true;
|
|
49
|
+
if (value === "false") return false;
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (ast._tag === "TypeLiteral" && isPlainObject(value)) {
|
|
54
|
+
return preprocessStruct(value, ast);
|
|
55
|
+
}
|
|
56
|
+
if (ast._tag === "TupleType" && Array.isArray(value)) {
|
|
57
|
+
const elements = ast.elements;
|
|
58
|
+
const restAst = ast.rest[0]?.type ?? SchemaAST.unknownKeyword;
|
|
59
|
+
return value.map((v, i) => {
|
|
60
|
+
const elementType = i < elements.length ? elements[i].type : restAst;
|
|
61
|
+
return preprocessField(v, elementType);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (ast._tag === "Union") {
|
|
65
|
+
if (typeof value === "string") {
|
|
66
|
+
const wantsNumber = ast.types.some(expectsNumber);
|
|
67
|
+
const wantsBoolean = ast.types.some(expectsBoolean);
|
|
68
|
+
if (wantsNumber && !wantsBoolean) {
|
|
69
|
+
if (value.trim() !== "") return Number(value);
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
if (wantsBoolean && !wantsNumber) {
|
|
73
|
+
return value === "true";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
if (ast._tag === "Refinement") return preprocessField(value, ast.from);
|
|
79
|
+
if (ast._tag === "Suspend") return preprocessField(value, ast.f());
|
|
80
|
+
if (ast._tag === "Declaration") {
|
|
81
|
+
return preprocessField(value, ast.typeParameters[0] ?? ast);
|
|
82
|
+
}
|
|
83
|
+
if (ast._tag === "Transformation") {
|
|
84
|
+
return preprocessField(value, ast.from);
|
|
85
|
+
}
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
function unwrap(ast) {
|
|
89
|
+
switch (ast._tag) {
|
|
90
|
+
case "Suspend":
|
|
91
|
+
return unwrap(ast.f());
|
|
92
|
+
case "Refinement":
|
|
93
|
+
return unwrap(ast.from);
|
|
94
|
+
case "Declaration":
|
|
95
|
+
return unwrap(ast.typeParameters[0] ?? ast);
|
|
96
|
+
case "Transformation":
|
|
97
|
+
return unwrap(ast.from);
|
|
98
|
+
default:
|
|
99
|
+
return ast;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function expectsNumber(ast) {
|
|
103
|
+
switch (ast._tag) {
|
|
104
|
+
case "NumberKeyword":
|
|
105
|
+
return true;
|
|
106
|
+
case "Refinement":
|
|
107
|
+
return expectsNumber(ast.from);
|
|
108
|
+
case "Suspend":
|
|
109
|
+
return expectsNumber(ast.f());
|
|
110
|
+
case "Declaration":
|
|
111
|
+
return expectsNumber(ast.typeParameters[0] ?? ast);
|
|
112
|
+
case "Union":
|
|
113
|
+
return ast.types.some(expectsNumber);
|
|
114
|
+
case "Transformation":
|
|
115
|
+
return expectsNumber(ast.from);
|
|
116
|
+
default:
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function expectsBoolean(ast) {
|
|
121
|
+
switch (ast._tag) {
|
|
122
|
+
case "BooleanKeyword":
|
|
123
|
+
return true;
|
|
124
|
+
case "Refinement":
|
|
125
|
+
return expectsBoolean(ast.from);
|
|
126
|
+
case "Suspend":
|
|
127
|
+
return expectsBoolean(ast.f());
|
|
128
|
+
case "Declaration":
|
|
129
|
+
return expectsBoolean(ast.typeParameters[0] ?? ast);
|
|
130
|
+
case "Union":
|
|
131
|
+
return ast.types.some(expectsBoolean);
|
|
132
|
+
case "Transformation":
|
|
133
|
+
return expectsBoolean(ast.from);
|
|
134
|
+
default:
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function isPlainObject(value) {
|
|
139
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
140
|
+
}
|
|
141
|
+
function tryParseJson(value, ast) {
|
|
142
|
+
const unwrapped = unwrap(ast);
|
|
143
|
+
if (unwrapped._tag !== "TypeLiteral" && unwrapped._tag !== "TupleType") return void 0;
|
|
144
|
+
const trimmed = value.trimStart();
|
|
145
|
+
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return void 0;
|
|
146
|
+
try {
|
|
147
|
+
return JSON.parse(value);
|
|
148
|
+
} catch {
|
|
149
|
+
return void 0;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export function peekJsonSchema(schema) {
|
|
153
|
+
return JSONSchema.make(schema);
|
|
154
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
-
export declare const Locale: Schema.
|
|
3
|
-
locale:
|
|
4
|
-
message:
|
|
5
|
-
}
|
|
6
|
-
locale:
|
|
7
|
-
message:
|
|
8
|
-
}
|
|
2
|
+
export declare const Locale: Schema.suspend<readonly [{
|
|
3
|
+
readonly locale: "zh";
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}, ...{
|
|
6
|
+
readonly locale: "en" | "ja" | "ko";
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}[]], string | readonly [{
|
|
9
|
+
readonly locale: "zh";
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}, ...{
|
|
12
|
+
readonly locale: "en" | "ja" | "ko";
|
|
13
|
+
readonly message: string;
|
|
14
|
+
}[]], never>;
|
|
9
15
|
export type LocaleValue = Schema.Schema.Type<typeof Locale>;
|
|
10
16
|
export declare function hasVisibleLocaleValue(value: LocaleValue | undefined): boolean;
|
|
11
17
|
export declare function getLocalizedText(messages: LocaleValue | undefined, locale: string): string | undefined;
|
|
@@ -15,13 +15,35 @@ const OtherLocaleItem = Schema.Struct({
|
|
|
15
15
|
description: "\u9488\u5BF9\u8BE5\u8BED\u8A00\u7684 UI \u6587\u672C"
|
|
16
16
|
})
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
const LocaleTuple = Schema.Tuple(
|
|
19
19
|
[ZhLocaleItem],
|
|
20
20
|
OtherLocaleItem
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
);
|
|
22
|
+
function coerceStringToLocale(input) {
|
|
23
|
+
if (input.trimStart().startsWith("[")) {
|
|
24
|
+
try {
|
|
25
|
+
const parsed = JSON.parse(input);
|
|
26
|
+
if (Array.isArray(parsed)) return parsed;
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return [{ locale: "zh", message: input }];
|
|
31
|
+
}
|
|
32
|
+
export const Locale = Schema.suspend(
|
|
33
|
+
() => Schema.transform(
|
|
34
|
+
Schema.Union(LocaleTuple, Schema.String),
|
|
35
|
+
LocaleTuple,
|
|
36
|
+
{
|
|
37
|
+
strict: true,
|
|
38
|
+
decode: (input) => typeof input === "string" ? coerceStringToLocale(input) : input,
|
|
39
|
+
encode: (input) => input
|
|
40
|
+
}
|
|
41
|
+
).annotations({
|
|
42
|
+
identifier: "Locale",
|
|
43
|
+
title: "Locale",
|
|
44
|
+
description: "\u672C\u5730\u5316\u6587\u672C\u5217\u8868\uFF0Czh \u5FC5\u987B\u4E3A\u9996\u9879\uFF1B\u63A5\u53D7\u7EAF\u5B57\u7B26\u4E32\uFF08\u82E5\u662F JSON-encoded tuple \u5219\u89E3\u6790\u5B83\uFF0C\u5426\u5219\u5F53\u4F5C zh \u6587\u672C\u6765\u7528\uFF09"
|
|
45
|
+
})
|
|
46
|
+
);
|
|
25
47
|
export function hasVisibleLocaleValue(value) {
|
|
26
48
|
return value?.some((item) => item.message.trim().length > 0) ?? false;
|
|
27
49
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { UIMessage } from '../utils/ai/parts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mirrors a table editor's AI-chat history into `sessionStorage`, keyed on the
|
|
5
|
+
* table's stable `config.id`, so the conversation survives both the chat
|
|
6
|
+
* component unmounting — switching away from the "AI 生成" section `v-if`-
|
|
7
|
+
* unmounts `<TableAiGenerate>`, dropping its local `ref<UIMessage[]>` — and a
|
|
8
|
+
* page reload. It clears when the browser tab is closed (`sessionStorage`
|
|
9
|
+
* lifetime), giving each table a per-instance, session-scoped chat memory.
|
|
10
|
+
*
|
|
11
|
+
* Modeled on `usePersistedQuery`: every access is SSR-guarded and guarded
|
|
12
|
+
* against unavailable storage (privacy modes). With no `tableId()` persistence
|
|
13
|
+
* is a no-op (in-memory only) so id-less drafts can't collide on a shared key.
|
|
14
|
+
*
|
|
15
|
+
* - `restore()` seeds `messages` from the stored snapshot. Call it in
|
|
16
|
+
* `onMounted`, after the fresh component's empty ref exists, so a remount
|
|
17
|
+
* rehydrates the prior conversation.
|
|
18
|
+
* - `clear()` drops the stored snapshot (for a future "new conversation"
|
|
19
|
+
* affordance / a hard reset).
|
|
20
|
+
* - A deep watch persists committed turns; an emptied history removes the key
|
|
21
|
+
* rather than storing `"[]"`.
|
|
22
|
+
*
|
|
23
|
+
* Restored turns keep their tool-call parts for display, but `streamChat`
|
|
24
|
+
* replays history as prose only (`partsToText` in `utils/ai`), so a continued
|
|
25
|
+
* conversation never re-sends a dangling tool_use across the restore boundary.
|
|
26
|
+
*/
|
|
27
|
+
export declare function usePersistedChat(tableId: () => string | undefined, messages: Ref<UIMessage[]>): {
|
|
28
|
+
restore: () => void;
|
|
29
|
+
clear: () => void;
|
|
30
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
const STORAGE_PREFIX = "shwfed.table.ai-chat.";
|
|
3
|
+
export function usePersistedChat(tableId, messages) {
|
|
4
|
+
const key = () => `${STORAGE_PREFIX}${tableId()}`;
|
|
5
|
+
const active = () => Boolean(tableId()) && typeof window !== "undefined";
|
|
6
|
+
function restore() {
|
|
7
|
+
if (!active()) return;
|
|
8
|
+
try {
|
|
9
|
+
const raw = window.sessionStorage.getItem(key());
|
|
10
|
+
if (!raw) return;
|
|
11
|
+
const parsed = JSON.parse(raw);
|
|
12
|
+
if (Array.isArray(parsed)) messages.value = parsed;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function clear() {
|
|
17
|
+
if (typeof window === "undefined") return;
|
|
18
|
+
const id = tableId();
|
|
19
|
+
if (!id) return;
|
|
20
|
+
try {
|
|
21
|
+
window.sessionStorage.removeItem(`${STORAGE_PREFIX}${id}`);
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
watch(messages, (next) => {
|
|
26
|
+
if (!active()) return;
|
|
27
|
+
try {
|
|
28
|
+
if (next.length === 0) window.sessionStorage.removeItem(key());
|
|
29
|
+
else window.sessionStorage.setItem(key(), JSON.stringify(next));
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}, { deep: true });
|
|
33
|
+
return { restore, clear };
|
|
34
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ComputedRef } from 'vue';
|
|
2
2
|
import { Schema } from 'effect';
|
|
3
|
+
import type { UIMessage } from './parts.js';
|
|
3
4
|
export interface GenerateTextInput {
|
|
4
5
|
readonly prompt: string;
|
|
5
6
|
readonly system?: string;
|
|
@@ -27,10 +28,19 @@ export interface GenerateObjectInput<A, I extends Record<string, unknown>> {
|
|
|
27
28
|
readonly feedback: string;
|
|
28
29
|
};
|
|
29
30
|
}
|
|
31
|
+
export interface StreamChatInput {
|
|
32
|
+
readonly messages: ReadonlyArray<UIMessage>;
|
|
33
|
+
readonly system?: string;
|
|
34
|
+
readonly tools?: ReadonlyArray<AgenticTool>;
|
|
35
|
+
readonly signal?: AbortSignal;
|
|
36
|
+
readonly maxTokens?: number;
|
|
37
|
+
readonly onMessageUpdate?: (assistant: UIMessage) => void;
|
|
38
|
+
}
|
|
30
39
|
export interface Ai {
|
|
31
40
|
readonly available: ComputedRef<boolean>;
|
|
32
41
|
readonly generateText: (input: GenerateTextInput) => Promise<string>;
|
|
33
42
|
readonly generateObject: <A, I extends Record<string, unknown>>(input: GenerateObjectInput<A, I>) => Promise<A>;
|
|
43
|
+
readonly streamChat: (input: StreamChatInput) => Promise<UIMessage>;
|
|
34
44
|
}
|
|
35
45
|
export declare class StructuredOutputDecodeError extends Error {
|
|
36
46
|
readonly rawOutput: unknown;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { JSONSchema, Schema } from "effect";
|
|
3
|
+
import { createMessageId, isToolUIPart } from "./parts.js";
|
|
4
|
+
import { coerceFromString } from "../../share/coerce-from-string.js";
|
|
3
5
|
const ENDPOINT = "http://192.168.168.10/anthropic/v1/messages";
|
|
4
6
|
const MODEL = "MiniMax-M2.7";
|
|
5
7
|
const ANTHROPIC_VERSION = "2023-06-01";
|
|
@@ -76,7 +78,7 @@ async function call(messages, system, options, signal) {
|
|
|
76
78
|
}
|
|
77
79
|
return await res.json();
|
|
78
80
|
}
|
|
79
|
-
async function callStream(messages, system, options, signal, onProgress) {
|
|
81
|
+
async function callStream(messages, system, options, signal, onProgress, events) {
|
|
80
82
|
const body = { ...buildBody(messages, system, options), stream: true };
|
|
81
83
|
const res = await fetch(ENDPOINT, buildInit(body, signal));
|
|
82
84
|
if (!res.ok) {
|
|
@@ -95,22 +97,26 @@ async function callStream(messages, system, options, signal, onProgress) {
|
|
|
95
97
|
const p = payload;
|
|
96
98
|
if (p.type === "content_block_start" && typeof p.index === "number" && p.content_block) {
|
|
97
99
|
const cb = p.content_block;
|
|
98
|
-
|
|
100
|
+
const block = {
|
|
99
101
|
type: cb.type === "tool_use" ? "tool_use" : "text",
|
|
100
102
|
text: "",
|
|
101
103
|
toolId: cb.id,
|
|
102
104
|
toolName: cb.name,
|
|
103
105
|
inputJson: ""
|
|
104
|
-
}
|
|
106
|
+
};
|
|
107
|
+
blocks.set(p.index, block);
|
|
108
|
+
events?.onStart?.(p.index, block);
|
|
105
109
|
} else if (p.type === "content_block_delta" && typeof p.index === "number" && p.delta) {
|
|
106
110
|
const cur = blocks.get(p.index);
|
|
107
111
|
if (!cur) continue;
|
|
108
112
|
if (p.delta.type === "text_delta" && p.delta.text) {
|
|
109
113
|
cur.text += p.delta.text;
|
|
110
114
|
onProgress();
|
|
115
|
+
events?.onDelta?.(p.index, cur);
|
|
111
116
|
} else if (p.delta.type === "input_json_delta" && p.delta.partial_json) {
|
|
112
117
|
cur.inputJson += p.delta.partial_json;
|
|
113
118
|
onProgress();
|
|
119
|
+
events?.onDelta?.(p.index, cur);
|
|
114
120
|
}
|
|
115
121
|
} else if (p.type === "message_delta" && p.delta?.stop_reason) {
|
|
116
122
|
stopReason = p.delta.stop_reason;
|
|
@@ -162,6 +168,33 @@ function appendRetry(messages, retry, toolName) {
|
|
|
162
168
|
}]
|
|
163
169
|
});
|
|
164
170
|
}
|
|
171
|
+
async function runToolResults(messages, assistantContent, toolUses, helperByName, onOutcome) {
|
|
172
|
+
messages.push({ role: "assistant", content: assistantContent });
|
|
173
|
+
const results = [];
|
|
174
|
+
for (const useBlock of toolUses) {
|
|
175
|
+
const tool = helperByName.get(useBlock.name);
|
|
176
|
+
if (!tool) {
|
|
177
|
+
const errorText = `Unknown tool: ${useBlock.name}`;
|
|
178
|
+
results.push({ type: "tool_result", tool_use_id: useBlock.id, content: errorText });
|
|
179
|
+
onOutcome?.(useBlock, { status: "output-error", errorText });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
const result = await tool.execute(useBlock.input ?? {});
|
|
184
|
+
results.push({
|
|
185
|
+
type: "tool_result",
|
|
186
|
+
tool_use_id: useBlock.id,
|
|
187
|
+
content: typeof result === "string" ? result : JSON.stringify(result)
|
|
188
|
+
});
|
|
189
|
+
onOutcome?.(useBlock, { status: "output-available", output: result });
|
|
190
|
+
} catch (err) {
|
|
191
|
+
const errorText = err instanceof Error ? err.message : String(err);
|
|
192
|
+
results.push({ type: "tool_result", tool_use_id: useBlock.id, content: errorText });
|
|
193
|
+
onOutcome?.(useBlock, { status: "output-error", errorText });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
messages.push({ role: "user", content: results });
|
|
197
|
+
}
|
|
165
198
|
async function generateText(input) {
|
|
166
199
|
const messages = buildUserMessages(input.prompt);
|
|
167
200
|
const opts = input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {};
|
|
@@ -195,7 +228,7 @@ async function generateObject(input) {
|
|
|
195
228
|
};
|
|
196
229
|
const decode = (raw) => {
|
|
197
230
|
try {
|
|
198
|
-
return Schema.decodeUnknownSync(input.schema)(raw);
|
|
231
|
+
return Schema.decodeUnknownSync(input.schema)(coerceFromString(raw, input.schema));
|
|
199
232
|
} catch (cause) {
|
|
200
233
|
throw new StructuredOutputDecodeError(raw, cause);
|
|
201
234
|
}
|
|
@@ -217,41 +250,98 @@ async function generateObject(input) {
|
|
|
217
250
|
const reason = response.stop_reason ? `\uFF08stop_reason=${response.stop_reason}\uFF09` : "";
|
|
218
251
|
throw new Error(`\u6A21\u578B\u672A\u8FD4\u56DE\u7ED3\u6784\u5316\u8F93\u51FA${reason}${text ? `: ${text.slice(0, 200)}` : ""}`);
|
|
219
252
|
}
|
|
220
|
-
messages
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
253
|
+
await runToolResults(messages, toolUses, toolUses, helperByName);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function partsToText(parts) {
|
|
257
|
+
return parts.filter((p) => p.type === "text").map((p) => p.text).join("");
|
|
258
|
+
}
|
|
259
|
+
async function streamChat(input) {
|
|
260
|
+
const helperTools = input.tools ?? [];
|
|
261
|
+
const helperByName = new Map(helperTools.map((t) => [t.name, t]));
|
|
262
|
+
const tools = helperTools.length > 0 ? helperTools.map((t) => ({
|
|
263
|
+
name: t.name,
|
|
264
|
+
description: t.description,
|
|
265
|
+
input_schema: t.inputJsonSchema
|
|
266
|
+
})) : void 0;
|
|
267
|
+
const messages = input.messages.map(
|
|
268
|
+
(m) => ({ role: m.role, content: partsToText(m.parts) })
|
|
269
|
+
);
|
|
270
|
+
const opts = {
|
|
271
|
+
...tools !== void 0 ? { tools } : {},
|
|
272
|
+
...input.maxTokens !== void 0 ? { maxTokens: input.maxTokens } : {}
|
|
273
|
+
};
|
|
274
|
+
const assistant = { id: createMessageId(), role: "assistant", parts: [] };
|
|
275
|
+
const publish = () => input.onMessageUpdate?.(assistant);
|
|
276
|
+
for (; ; ) {
|
|
277
|
+
const partByIndex = /* @__PURE__ */ new Map();
|
|
278
|
+
const response = await callStream(messages, input.system, opts, input.signal, () => {
|
|
279
|
+
}, {
|
|
280
|
+
onStart: (index, block) => {
|
|
281
|
+
const part = block.type === "tool_use" ? {
|
|
282
|
+
type: `tool-${block.toolName ?? ""}`,
|
|
283
|
+
toolCallId: block.toolId ?? "",
|
|
284
|
+
state: "input-streaming"
|
|
285
|
+
} : { type: "text", text: "", state: "streaming" };
|
|
286
|
+
assistant.parts.push(part);
|
|
287
|
+
partByIndex.set(index, part);
|
|
288
|
+
publish();
|
|
289
|
+
},
|
|
290
|
+
onDelta: (index, block) => {
|
|
291
|
+
const part = partByIndex.get(index);
|
|
292
|
+
if (part?.type === "text") {
|
|
293
|
+
part.text = block.text;
|
|
294
|
+
publish();
|
|
295
|
+
}
|
|
234
296
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
});
|
|
297
|
+
});
|
|
298
|
+
response.content.forEach((block, i) => {
|
|
299
|
+
const part = partByIndex.get(i);
|
|
300
|
+
if (!part) return;
|
|
301
|
+
if (block.type === "text") {
|
|
302
|
+
if (part.type === "text") {
|
|
303
|
+
part.text = block.text;
|
|
304
|
+
part.state = "done";
|
|
305
|
+
}
|
|
306
|
+
} else if (part.type !== "text") {
|
|
307
|
+
part.input = block.input;
|
|
308
|
+
if (part.state === "input-streaming") part.state = "input-available";
|
|
248
309
|
}
|
|
310
|
+
});
|
|
311
|
+
publish();
|
|
312
|
+
const toolUses = response.content.filter(
|
|
313
|
+
(b) => b.type === "tool_use"
|
|
314
|
+
);
|
|
315
|
+
if (toolUses.length === 0) {
|
|
316
|
+
return assistant;
|
|
249
317
|
}
|
|
250
|
-
|
|
318
|
+
await runToolResults(
|
|
319
|
+
messages,
|
|
320
|
+
response.content,
|
|
321
|
+
toolUses,
|
|
322
|
+
helperByName,
|
|
323
|
+
(useBlock, outcome) => {
|
|
324
|
+
const part = assistant.parts.find(
|
|
325
|
+
(p) => isToolUIPart(p) && p.toolCallId === useBlock.id
|
|
326
|
+
);
|
|
327
|
+
if (!part) return;
|
|
328
|
+
if (outcome.status === "output-available") {
|
|
329
|
+
part.state = "output-available";
|
|
330
|
+
part.output = outcome.output;
|
|
331
|
+
} else {
|
|
332
|
+
part.state = "output-error";
|
|
333
|
+
part.errorText = outcome.errorText;
|
|
334
|
+
}
|
|
335
|
+
publish();
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
assistant.parts.push({ type: "step-start" });
|
|
339
|
+
publish();
|
|
251
340
|
}
|
|
252
341
|
}
|
|
253
342
|
export const ai = {
|
|
254
343
|
available: computed(() => true),
|
|
255
344
|
generateText,
|
|
256
|
-
generateObject
|
|
345
|
+
generateObject,
|
|
346
|
+
streamChat
|
|
257
347
|
};
|