@ecsplico/editor 2.0.0 → 2.1.1
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/CHANGELOG.md +37 -0
- package/README.md +4 -3
- package/dist/adapters/anchors.d.ts +80 -0
- package/dist/adapters/anchors.js +270 -0
- package/dist/adapters/anchors.js.map +1 -0
- package/dist/adapters/comments/client.d.ts +64 -0
- package/dist/adapters/comments/client.js +536 -0
- package/dist/adapters/comments/client.js.map +1 -0
- package/dist/adapters/comments/drizzle.d.ts +430 -0
- package/dist/adapters/comments/drizzle.js +236 -0
- package/dist/adapters/comments/drizzle.js.map +1 -0
- package/dist/adapters/comments/errors.d.ts +9 -0
- package/dist/adapters/comments/errors.js +19 -0
- package/dist/adapters/comments/errors.js.map +1 -0
- package/dist/adapters/comments/json.d.ts +19 -0
- package/dist/adapters/comments/json.js +94 -0
- package/dist/adapters/comments/json.js.map +1 -0
- package/dist/adapters/comments/record.js +78 -0
- package/dist/adapters/comments/record.js.map +1 -0
- package/dist/adapters/comments/server.d.ts +23 -0
- package/dist/adapters/comments/server.js +102 -0
- package/dist/adapters/comments/server.js.map +1 -0
- package/dist/adapters/comments/types.d.ts +109 -0
- package/dist/adapters/documents.js +108 -0
- package/dist/adapters/documents.js.map +1 -0
- package/dist/adapters/drizzle.d.ts +293 -0
- package/dist/adapters/drizzle.js +157 -0
- package/dist/adapters/drizzle.js.map +1 -0
- package/dist/adapters/files.js +30 -0
- package/dist/adapters/files.js.map +1 -0
- package/dist/adapters/forge.d.ts +58 -0
- package/dist/adapters/forge.js +91 -0
- package/dist/adapters/forge.js.map +1 -0
- package/dist/adapters/index.d.ts +13 -0
- package/dist/adapters/index.js +0 -0
- package/dist/adapters/json.d.ts +24 -0
- package/dist/adapters/json.js +128 -0
- package/dist/adapters/json.js.map +1 -0
- package/dist/adapters/nitro.d.ts +61 -0
- package/dist/adapters/nitro.js +212 -0
- package/dist/adapters/nitro.js.map +1 -0
- package/dist/adapters/routes.js +16 -0
- package/dist/adapters/routes.js.map +1 -0
- package/dist/adapters/shared.d.ts +37 -0
- package/dist/adapters/shared.js +32 -0
- package/dist/adapters/shared.js.map +1 -0
- package/dist/adapters/vue.d.ts +67 -0
- package/dist/adapters/vue.js +187 -0
- package/dist/adapters/vue.js.map +1 -0
- package/dist/code/CodeSurface.vue.d.ts +3 -3
- package/dist/core/doc-anchors.d.ts +5 -0
- package/dist/core/doc-anchors.js +4 -3
- package/dist/core/doc-anchors.js.map +1 -1
- package/dist/core/editor-ui.js +57 -1
- package/dist/core/editor-ui.js.map +1 -1
- package/dist/core/surface-session.js +139 -0
- package/dist/core/surface-session.js.map +1 -0
- package/dist/document/DocumentSurface.d.ts +1 -1
- package/dist/document/DocumentSurface.vue.d.ts +3 -3
- package/dist/features/ai/agent-op-review.d.ts +2 -2
- package/dist/features/ai/agent-op-review.js.map +1 -1
- package/dist/features/ai/agent-ops.d.ts +1 -1
- package/dist/features/ai/agent-ops.js +9 -6
- package/dist/features/ai/agent-ops.js.map +1 -1
- package/dist/features/ai/ai-apply.d.ts +1 -1
- package/dist/features/ai/ai-review.js +10 -1
- package/dist/features/ai/ai-review.js.map +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js +78 -252
- package/dist/features/ai/components/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/components/AiSelectionMenu.vue.d.ts +2 -1
- package/dist/features/ai/components/AiSidebar.js +2 -2
- package/dist/features/ai/components/DocumentChatAnswer.js +1 -1
- package/dist/features/ai/components/DocumentChatOps.js +1 -0
- package/dist/features/ai/components/DocumentChatOps.js.map +1 -1
- package/dist/features/ai/components/ModelQuickSwitch.js +1 -1
- package/dist/features/ai/components/SettingsAiTab.js +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/document-chat.d.ts +3 -2
- package/dist/features/ai/document-chat.js +16 -19
- package/dist/features/ai/document-chat.js.map +1 -1
- package/dist/features/ai/index.d.ts +5 -3
- package/dist/features/ai/index.js +4 -2
- package/dist/features/ai/protocol/agent-ops.d.ts +22 -17
- package/dist/features/ai/protocol/agent-ops.js +65 -39
- package/dist/features/ai/protocol/agent-ops.js.map +1 -1
- package/dist/features/ai/protocol/block-lines.d.ts +89 -0
- package/dist/features/ai/protocol/block-lines.js +177 -0
- package/dist/features/ai/protocol/block-lines.js.map +1 -0
- package/dist/features/ai/protocol/chat.js +10 -10
- package/dist/features/ai/protocol/chat.js.map +1 -1
- package/dist/features/ai/protocol/index.d.ts +3 -2
- package/dist/features/ai/protocol/index.js +3 -2
- package/dist/features/ai/react/AiSelectionMenu.d.ts +3 -2
- package/dist/features/ai/react/AiSelectionMenu.js +64 -255
- package/dist/features/ai/react/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/react/AiSidebar.js +2 -2
- package/dist/features/ai/react/DocumentChatAnswer.js +1 -1
- package/dist/features/ai/react/DocumentChatOps.js +1 -0
- package/dist/features/ai/react/DocumentChatOps.js.map +1 -1
- package/dist/features/ai/react/ModelQuickSwitch.js +1 -1
- package/dist/features/ai/react/SettingsAiTab.js +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/react/use-ai-selection-flow.js +34 -0
- package/dist/features/ai/react/use-ai-selection-flow.js.map +1 -0
- package/dist/features/ai/selection-flow.d.ts +133 -0
- package/dist/features/ai/selection-flow.js +283 -0
- package/dist/features/ai/selection-flow.js.map +1 -0
- package/dist/features/ai/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/use-document-chat.d.ts +1 -1
- package/dist/features/authors/components/AuthorColorsPanel.js +1 -1
- package/dist/features/authors/feature.js +1 -1
- package/dist/features/authors/index.js +1 -1
- package/dist/features/authors/react/AuthorColorsPanel.js +1 -1
- package/dist/features/comments/components/CommentBubble.js +1 -1
- package/dist/features/comments/components/CommentComposer.js +1 -1
- package/dist/features/comments/components/CommentThreadView.js +5 -2
- package/dist/features/comments/components/CommentThreadView.js.map +1 -1
- package/dist/features/comments/components/CommentsMargin.js +108 -230
- package/dist/features/comments/components/CommentsMargin.js.map +1 -1
- package/dist/features/comments/components/CommentsOverlay.js +1 -1
- package/dist/features/comments/feature.js +1 -1
- package/dist/features/comments/index.d.ts +4 -2
- package/dist/features/comments/index.js +4 -2
- package/dist/features/comments/margin-controller.d.ts +44 -0
- package/dist/features/comments/margin-controller.js +132 -0
- package/dist/features/comments/margin-controller.js.map +1 -0
- package/dist/features/comments/margin-layout.d.ts +55 -0
- package/dist/features/comments/margin-layout.js +79 -0
- package/dist/features/comments/margin-layout.js.map +1 -0
- package/dist/features/comments/model.d.ts +8 -0
- package/dist/features/comments/model.js +60 -34
- package/dist/features/comments/model.js.map +1 -1
- package/dist/features/comments/react/CommentBubble.js +1 -1
- package/dist/features/comments/react/CommentComposer.js +1 -1
- package/dist/features/comments/react/CommentThreadView.js +2 -2
- package/dist/features/comments/react/CommentThreadView.js.map +1 -1
- package/dist/features/comments/react/CommentsMargin.d.ts +0 -5
- package/dist/features/comments/react/CommentsMargin.js +85 -251
- package/dist/features/comments/react/CommentsMargin.js.map +1 -1
- package/dist/features/comments/react/CommentsOverlay.js +1 -1
- package/dist/features/comments/react/use-comments.js +1 -1
- package/dist/features/comments/react/use-margin-layout.js +45 -0
- package/dist/features/comments/react/use-margin-layout.js.map +1 -0
- package/dist/features/comments/react.d.ts +1 -1
- package/dist/features/comments/schema.d.ts +23 -0
- package/dist/features/comments/schema.js.map +1 -1
- package/dist/features/comments/snapshot-equality.js +40 -0
- package/dist/features/comments/snapshot-equality.js.map +1 -0
- package/dist/features/comments/thread-anchor.js +33 -0
- package/dist/features/comments/thread-anchor.js.map +1 -0
- package/dist/features/comments/use-comments.d.ts +3 -1
- package/dist/features/comments/use-comments.js +1 -0
- package/dist/features/comments/use-comments.js.map +1 -1
- package/dist/features/comments/use-margin-layout.js +29 -0
- package/dist/features/comments/use-margin-layout.js.map +1 -0
- package/dist/features/comments/vue.d.ts +1 -1
- package/dist/features/composites/accepted-children.d.ts +21 -0
- package/dist/features/composites/accepted-children.js +126 -0
- package/dist/features/composites/accepted-children.js.map +1 -0
- package/dist/features/composites/components/CompositeDetails.js +1 -1
- package/dist/features/composites/components/CompositeInspector.js +38 -164
- package/dist/features/composites/components/CompositeInspector.js.map +1 -1
- package/dist/features/composites/feature.d.ts +2 -1
- package/dist/features/composites/feature.js +8 -2
- package/dist/features/composites/feature.js.map +1 -1
- package/dist/features/composites/index.d.ts +5 -3
- package/dist/features/composites/index.js +8 -6
- package/dist/features/composites/inspector-model.d.ts +97 -0
- package/dist/features/composites/inspector-model.js +255 -0
- package/dist/features/composites/inspector-model.js.map +1 -0
- package/dist/features/composites/kinds.d.ts +11 -0
- package/dist/features/composites/kinds.js +17 -2
- package/dist/features/composites/kinds.js.map +1 -1
- package/dist/features/composites/outline.d.ts +18 -5
- package/dist/features/composites/outline.js +44 -12
- package/dist/features/composites/outline.js.map +1 -1
- package/dist/features/composites/react/CompositeDetails.js +1 -1
- package/dist/features/composites/react/CompositeInspector.d.ts +1 -1
- package/dist/features/composites/react/CompositeInspector.js +21 -180
- package/dist/features/composites/react/CompositeInspector.js.map +1 -1
- package/dist/features/composites/react/CompositeStatusMenu.d.ts +1 -1
- package/dist/features/composites/react/CompositeView.js +1 -1
- package/dist/features/composites/react/use-composite-inspector.js +29 -0
- package/dist/features/composites/react/use-composite-inspector.js.map +1 -0
- package/dist/features/composites/schema.d.ts +2 -2
- package/dist/features/composites/schema.js +2 -2
- package/dist/features/composites/schema.js.map +1 -1
- package/dist/features/composites/use-composite-anchors.d.ts +1 -1
- package/dist/features/composites/use-composite-inspector.js +41 -0
- package/dist/features/composites/use-composite-inspector.js.map +1 -0
- package/dist/features/composites/use-composite-rows.d.ts +1 -1
- package/dist/features/media/index.d.ts +1 -1
- package/dist/features/media/vue.d.ts +1 -1
- package/dist/features/mentions/index.d.ts +3 -3
- package/dist/features/mentions/index.js +3 -3
- package/dist/features/mentions/schema.d.ts +1 -1
- package/dist/features/mentions/schema.js +1 -1
- package/dist/features/themes/index.d.ts +1 -1
- package/dist/features/themes/index.js +1 -1
- package/dist/features/transcript/feature.js +1 -1
- package/dist/features/transcript/index.js +2 -2
- package/dist/i18n/de/ai.js +2 -0
- package/dist/i18n/de/ai.js.map +1 -1
- package/dist/i18n/de/composites.js +8 -1
- package/dist/i18n/de/composites.js.map +1 -1
- package/dist/i18n/de/tree.js +14 -1
- package/dist/i18n/de/tree.js.map +1 -1
- package/dist/i18n/de.d.ts +22 -0
- package/dist/i18n/en/ai.js +2 -0
- package/dist/i18n/en/ai.js.map +1 -1
- package/dist/i18n/en/composites.js +8 -1
- package/dist/i18n/en/composites.js.map +1 -1
- package/dist/i18n/en/tree.js +14 -1
- package/dist/i18n/en/tree.js.map +1 -1
- package/dist/integrations/composite-ai/composite-fill.js +2 -2
- package/dist/integrations/composite-ai/composite-summary.js +2 -2
- package/dist/integrations/composite-ai/index.js +2 -2
- package/dist/integrations/transcript-ai/transcript-cleanup.js +1 -1
- package/dist/markdown/MarkdownSurface.d.ts +1 -1
- package/dist/markdown/MarkdownSurface.js +2 -2
- package/dist/markdown/MarkdownSurface.vue.d.ts +9 -9
- package/dist/markdown/index.d.ts +2 -2
- package/dist/nuxt/runtime/server/routes/collab/[id].js +1 -1
- package/dist/react/EditorSurface.d.ts +1 -1
- package/dist/react/EditorSurface.js +43 -149
- package/dist/react/EditorSurface.js.map +1 -1
- package/dist/react/EditorToolbar.js +3 -40
- package/dist/react/EditorToolbar.js.map +1 -1
- package/dist/schema/advanced.js +2 -2
- package/dist/server/adapter.d.ts +2 -2
- package/dist/server/collab.js +1 -1
- package/dist/server/handlers/ai.d.ts +4 -2
- package/dist/server/handlers/ai.js +11 -9
- package/dist/server/handlers/ai.js.map +1 -1
- package/dist/server/handlers/context.d.ts +1 -1
- package/dist/server/handlers/editor.d.ts +1 -1
- package/dist/server/handlers/editor.js +2 -2
- package/dist/server/host.d.ts +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/settings/index.d.ts +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/tree/DocumentTree.js +159 -387
- package/dist/tree/DocumentTree.js.map +1 -1
- package/dist/tree/drop-rules.js +37 -0
- package/dist/tree/drop-rules.js.map +1 -0
- package/dist/tree/react/DocumentTree.d.ts +2 -2
- package/dist/tree/react/DocumentTree.js +135 -397
- package/dist/tree/react/DocumentTree.js.map +1 -1
- package/dist/tree/react/use-tree-model.js +129 -0
- package/dist/tree/react/use-tree-model.js.map +1 -0
- package/dist/tree/react.js +1 -1
- package/dist/tree/tree-host.js +100 -0
- package/dist/tree/tree-host.js.map +1 -0
- package/dist/tree/tree-items.js +22 -43
- package/dist/tree/tree-items.js.map +1 -1
- package/dist/tree/tree-model.js +580 -0
- package/dist/tree/tree-model.js.map +1 -0
- package/dist/tree/tree-rows.js +77 -0
- package/dist/tree/tree-rows.js.map +1 -0
- package/dist/tree/use-tree-model.js +94 -0
- package/dist/tree/use-tree-model.js.map +1 -0
- package/dist/tree/vue.js +1 -1
- package/dist/vue/AdvancedEditor.vue.d.ts +6 -6
- package/dist/vue/SimpleEditor.vue.d.ts +2 -2
- package/dist/vue/components/EditorSurface.js +27 -87
- package/dist/vue/components/EditorSurface.js.map +1 -1
- package/dist/vue/components/EditorSurface.vue.d.ts +6 -6
- package/dist/vue/components/EditorToolbar.js +7 -44
- package/dist/vue/components/EditorToolbar.js.map +1 -1
- package/dist/vue/context.d.ts +1 -1
- package/dist/vue/context.js +1 -1
- package/dist/vue/context.js.map +1 -1
- package/dist/vue/use-editor-ui.d.ts +1 -1
- package/dist/vue/use-notifier.d.ts +1 -1
- package/docs/integration.md +97 -4
- package/docs/llms.md +9 -1
- package/docs/usage.md +10 -5
- package/package.json +67 -5
|
@@ -5,7 +5,8 @@ import { Editor } from "@tiptap/vue-3";
|
|
|
5
5
|
* (`selectionMenu`), the result streams into a preview and is applied over the range captured when the menu opened.
|
|
6
6
|
* Caret mode (`/ai`, see `openAiMenuAtCaret`): the same popover opens at the caret with the `caretMenu` tasks and
|
|
7
7
|
* `generate` as free prompt; the result is inserted at the caret line (`insertAtCaretLine`).
|
|
8
|
-
* Needs the AiSelectionHighlight extension on the editor.
|
|
8
|
+
* Needs the AiSelectionHighlight extension on the editor. The flow (`createAiSelectionFlow`) owns every step; this
|
|
9
|
+
* component renders its state, places the popover and shows the preview.
|
|
9
10
|
*/
|
|
10
11
|
type __VLS_Props = {
|
|
11
12
|
editor: Editor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { conversionsOf } from "../../../core/pipeline.js";
|
|
2
|
-
import { useUiKit } from "../../../vue/kit/use-ui-kit.js";
|
|
3
|
-
import { useEditorI18n } from "../../../vue/use-editor-i18n.js";
|
|
4
2
|
import { CHAT_LIMITS } from "../protocol/chat.js";
|
|
5
3
|
import { AI_LIMITS, blockTasks, withTaskHeading } from "../protocol/tasks.js";
|
|
4
|
+
import { useUiKit } from "../../../vue/kit/use-ui-kit.js";
|
|
5
|
+
import { useEditorI18n } from "../../../vue/use-editor-i18n.js";
|
|
6
6
|
import { selectionScope } from "../agent-ops.js";
|
|
7
7
|
import { createAiSidebarFlow } from "../sidebar-flow.js";
|
|
8
8
|
import { useNotifier } from "../../../vue/use-notifier.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEditorI18n } from "../../../vue/use-editor-i18n.js";
|
|
2
1
|
import { citationBlockId } from "../protocol/chat.js";
|
|
2
|
+
import { useEditorI18n } from "../../../vue/use-editor-i18n.js";
|
|
3
3
|
import { documentChatAnswerContent } from "../document-chat.js";
|
|
4
4
|
import { previewExtensions } from "../preview-extensions.js";
|
|
5
5
|
import { useNotifier } from "../../../vue/use-notifier.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentChatOps.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createVNode","_unref","_createElementVNode","_toDisplayString","_createBlock","_createCommentVNode"],"sources":["../../../../src/features/ai/components/DocumentChatOps.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { type ConversionProvider, conversionLabel, parseConversionTarget } from '../../../core'\nimport { AGENT_OP_OUTCOME_KEYS } from '../agent-ops'\nimport type { AgentOp, AgentOpOutcome, AgentOpProblem } from '../protocol'\nimport type { AgentOpState } from '../use-document-chat'\nimport { useUiKit } from '../../../vue/kit/use-ui-kit'\nimport { useEditorI18n } from '../../../vue/use-editor-i18n'\n\nconst { Alert: UAlert, Badge: UBadge, Button: UButton, Icon: UIcon } = useUiKit()\nconst { t } = useEditorI18n()\n\n/** The edit operations of one chat answer with their review state; open ones can be decided right here. */\nconst props = defineProps<{\n ops: AgentOp[]\n states: Record<string, AgentOpState>\n /** Operations the server dropped (invalid block IDs after the retries). */\n problems?: AgentOpProblem[]\n /** The editor's conversion providers, to name `convert` targets. */\n providers: readonly ConversionProvider[]\n}>()\n\nconst emit = defineEmits<{\n decide: [id: string, accept: boolean]\n reveal: [op: AgentOp]\n}>()\n\nconst ICONS: Record<AgentOp['type'], string> = { add: 'i-lucide-plus', update: 'i-lucide-pencil', delete: 'i-lucide-trash-2', convert: 'i-lucide-replace' }\n\nconst BADGE_COLORS: Record<AgentOpOutcome, 'primary' | 'success' | 'neutral' | 'warning' | 'info'> = {\n pending: 'primary',\n accepted: 'success',\n rejected: 'neutral',\n partial: 'info',\n invalid: 'warning',\n unchanged: 'neutral',\n missing: 'warning',\n overlap: 'warning',\n empty: 'warning',\n blocked: 'warning',\n}\n\nfunction label(op: AgentOp, snippet: string): string {\n if (op.type === 'add') return op.afterId === null ? t('ai.op.addAtStart') : t('ai.op.addAfter', { snippet })\n if (op.type === 'convert') {\n const target = parseConversionTarget(props.providers, op.to)\n return t('ai.op.convert', { target: target ? conversionLabel(props.providers, target, t).label : op.to, snippet })\n }\n return t(op.type === 'update' ? 'ai.op.update' : 'ai.op.delete', { snippet })\n}\n</script>\n\n<template>\n <div class=\"mt-2 flex flex-col gap-1\">\n <div\n v-for=\"op in ops\"\n :key=\"op.op\"\n class=\"flex items-center gap-2 rounded-md border border-[var(--sk-border)] px-2 py-1\"\n :data-agent-op=\"op.op\"\n >\n <UIcon :name=\"ICONS[op.type]\" class=\"size-4 shrink-0 text-[var(--sk-muted)]\" />\n <button type=\"button\" class=\"min-w-0 flex-1 truncate text-left text-xs hover:underline\" :title=\"'markdown' in op ? op.markdown : undefined\" @click=\"emit('reveal', op)\">\n {{ label(op, states[op.op]?.snippet ?? '') }}\n </button>\n <UBadge\n v-if=\"states[op.op]\"\n size=\"sm\"\n variant=\"subtle\"\n :color=\"BADGE_COLORS[states[op.op]!.outcome]\"\n :label=\"t(AGENT_OP_OUTCOME_KEYS[states[op.op]!.outcome].badge)\"\n :title=\"t(AGENT_OP_OUTCOME_KEYS[states[op.op]!.outcome].hover)\"\n />\n <template v-if=\"states[op.op]?.outcome === 'pending'\">\n <UButton size=\"xs\" color=\"neutral\" variant=\"ghost\" icon=\"i-lucide-x\" :aria-label=\"t('ai.op.discard')\" @click=\"emit('decide', op.op, false)\" />\n <UButton size=\"xs\" color=\"success\" variant=\"ghost\" icon=\"i-lucide-check\" :aria-label=\"t('ai.op.accept')\" @click=\"emit('decide', op.op, true)\" />\n </template>\n </div>\n <UAlert\n v-if=\"problems?.length\"\n color=\"warning\"\n variant=\"subtle\"\n icon=\"i-lucide-triangle-alert\"\n :title=\"problems.length === 1 ? t('ai.op.problems.one') : t('ai.op.problems.other', { n: problems.length })\"\n :description=\"t('ai.op.problems.description')\"\n />\n </div>\n</template>\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"DocumentChatOps.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_createVNode","_unref","_createElementVNode","_toDisplayString","_createBlock","_createCommentVNode"],"sources":["../../../../src/features/ai/components/DocumentChatOps.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { type ConversionProvider, conversionLabel, parseConversionTarget } from '../../../core'\nimport { AGENT_OP_OUTCOME_KEYS } from '../agent-ops'\nimport type { AgentOp, AgentOpOutcome, AgentOpProblem } from '../protocol'\nimport type { AgentOpState } from '../use-document-chat'\nimport { useUiKit } from '../../../vue/kit/use-ui-kit'\nimport { useEditorI18n } from '../../../vue/use-editor-i18n'\n\nconst { Alert: UAlert, Badge: UBadge, Button: UButton, Icon: UIcon } = useUiKit()\nconst { t } = useEditorI18n()\n\n/** The edit operations of one chat answer with their review state; open ones can be decided right here. */\nconst props = defineProps<{\n ops: AgentOp[]\n states: Record<string, AgentOpState>\n /** Operations the server dropped (invalid block IDs after the retries). */\n problems?: AgentOpProblem[]\n /** The editor's conversion providers, to name `convert` targets. */\n providers: readonly ConversionProvider[]\n}>()\n\nconst emit = defineEmits<{\n decide: [id: string, accept: boolean]\n reveal: [op: AgentOp]\n}>()\n\nconst ICONS: Record<AgentOp['type'], string> = { add: 'i-lucide-plus', update: 'i-lucide-pencil', delete: 'i-lucide-trash-2', convert: 'i-lucide-replace' }\n\nconst BADGE_COLORS: Record<AgentOpOutcome, 'primary' | 'success' | 'neutral' | 'warning' | 'info'> = {\n pending: 'primary',\n accepted: 'success',\n rejected: 'neutral',\n partial: 'info',\n invalid: 'warning',\n unchanged: 'neutral',\n missing: 'warning',\n stale: 'warning',\n overlap: 'warning',\n empty: 'warning',\n blocked: 'warning',\n}\n\nfunction label(op: AgentOp, snippet: string): string {\n if (op.type === 'add') return op.afterId === null ? t('ai.op.addAtStart') : t('ai.op.addAfter', { snippet })\n if (op.type === 'convert') {\n const target = parseConversionTarget(props.providers, op.to)\n return t('ai.op.convert', { target: target ? conversionLabel(props.providers, target, t).label : op.to, snippet })\n }\n return t(op.type === 'update' ? 'ai.op.update' : 'ai.op.delete', { snippet })\n}\n</script>\n\n<template>\n <div class=\"mt-2 flex flex-col gap-1\">\n <div\n v-for=\"op in ops\"\n :key=\"op.op\"\n class=\"flex items-center gap-2 rounded-md border border-[var(--sk-border)] px-2 py-1\"\n :data-agent-op=\"op.op\"\n >\n <UIcon :name=\"ICONS[op.type]\" class=\"size-4 shrink-0 text-[var(--sk-muted)]\" />\n <button type=\"button\" class=\"min-w-0 flex-1 truncate text-left text-xs hover:underline\" :title=\"'markdown' in op ? op.markdown : undefined\" @click=\"emit('reveal', op)\">\n {{ label(op, states[op.op]?.snippet ?? '') }}\n </button>\n <UBadge\n v-if=\"states[op.op]\"\n size=\"sm\"\n variant=\"subtle\"\n :color=\"BADGE_COLORS[states[op.op]!.outcome]\"\n :label=\"t(AGENT_OP_OUTCOME_KEYS[states[op.op]!.outcome].badge)\"\n :title=\"t(AGENT_OP_OUTCOME_KEYS[states[op.op]!.outcome].hover)\"\n />\n <template v-if=\"states[op.op]?.outcome === 'pending'\">\n <UButton size=\"xs\" color=\"neutral\" variant=\"ghost\" icon=\"i-lucide-x\" :aria-label=\"t('ai.op.discard')\" @click=\"emit('decide', op.op, false)\" />\n <UButton size=\"xs\" color=\"success\" variant=\"ghost\" icon=\"i-lucide-check\" :aria-label=\"t('ai.op.accept')\" @click=\"emit('decide', op.op, true)\" />\n </template>\n </div>\n <UAlert\n v-if=\"problems?.length\"\n color=\"warning\"\n variant=\"subtle\"\n icon=\"i-lucide-triangle-alert\"\n :title=\"problems.length === 1 ? t('ai.op.problems.one') : t('ai.op.problems.other', { n: problems.length })\"\n :description=\"t('ai.op.problems.description')\"\n />\n </div>\n</template>\n"],"mappings":"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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { MODEL_SLOT_KEYS } from "../protocol/models.js";
|
|
1
2
|
import { useUiKit } from "../../../vue/kit/use-ui-kit.js";
|
|
2
3
|
import { useEditorSettings } from "../../../vue/settings.js";
|
|
3
4
|
import { useEditorI18n } from "../../../vue/use-editor-i18n.js";
|
|
4
5
|
import { useEditorUi } from "../../../vue/use-editor-ui.js";
|
|
5
|
-
import { MODEL_SLOT_KEYS } from "../protocol/models.js";
|
|
6
6
|
import { useModelProfiles } from "../use-model-profiles.js";
|
|
7
7
|
import { computed, createBlock, defineComponent, openBlock, ref, unref } from "vue";
|
|
8
8
|
//#region src/features/ai/components/ModelQuickSwitch.vue
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AI_LANGUAGES, MODEL_SLOTS } from "../../../settings/values.js";
|
|
2
|
+
import { AI_LANGUAGE_KEYS, MODEL_SLOT_KEYS } from "../protocol/models.js";
|
|
2
3
|
import { useUiKit } from "../../../vue/kit/use-ui-kit.js";
|
|
3
4
|
import { useEditorSettings } from "../../../vue/settings.js";
|
|
4
5
|
import { useEditorI18n } from "../../../vue/use-editor-i18n.js";
|
|
5
|
-
import { AI_LANGUAGE_KEYS, MODEL_SLOT_KEYS } from "../protocol/models.js";
|
|
6
6
|
import _sfc_main$1 from "./ModelQuickSwitch.js";
|
|
7
7
|
import _sfc_main$2 from "../../../vue/components/SettingsSection.js";
|
|
8
8
|
import _sfc_main$3 from "./SettingsModelProfiles.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fetchErrorMessage } from "../../../core/fetch-error.js";
|
|
2
|
+
import { modelRefSchema } from "../protocol/models.js";
|
|
2
3
|
import { useUiKit } from "../../../vue/kit/use-ui-kit.js";
|
|
3
4
|
import { useEditorI18n } from "../../../vue/use-editor-i18n.js";
|
|
4
|
-
import { modelRefSchema } from "../protocol/models.js";
|
|
5
5
|
import { isRateLimited } from "../rate-limit.js";
|
|
6
6
|
import { useModelProfiles } from "../use-model-profiles.js";
|
|
7
7
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, ref, renderList, shallowRef, toDisplayString, unref, watch, withCtx, withModifiers } from "vue";
|
|
@@ -2,8 +2,9 @@ import { Editor, JSONContent } from "@tiptap/core";
|
|
|
2
2
|
import { Node as Node$1 } from "@tiptap/pm/model";
|
|
3
3
|
//#region src/features/ai/document-chat.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* The document as sent to the chat
|
|
6
|
-
*
|
|
5
|
+
* The document as sent to the chat, in the line format of `protocol/block-lines.ts` (which also reads and describes
|
|
6
|
+
* it): one line per text block, `[<block id>] <Markdown>` (e.g. `[…] **Anna:** Text`), with list markers and quote
|
|
7
|
+
* prefixes after the ID. Nested blocks carry their own IDs, so quotes from list items or
|
|
7
8
|
* block quotes link to exactly that paragraph. A block container below the document (a composite: the schema flags it
|
|
8
9
|
* `editorBlockContainer`, its title/description/tags rows `editorChrome`) is a header line `[<id>] ::: <kind> {meta} |
|
|
9
10
|
* <title> | <description> | Tags: #a` (empty parts left out), its body blocks two spaces further in, and a closing
|
|
@@ -2,13 +2,14 @@ import { blockIdOf, findBlockById } from "../../core/schema/block-ids.js";
|
|
|
2
2
|
import { isBlockContainer, isChromeNode } from "../../core/schema/node-flags.js";
|
|
3
3
|
import { isWrapperBlock } from "../../core/convert.js";
|
|
4
4
|
import { parseBlocks } from "../../core/pipeline.js";
|
|
5
|
+
import { TRUNCATED_LINE, blockLine, compositeChromePart, compositeLineClose, compositeLineHeader, continuedLinePrefix, listLinePrefix, nestedLinePrefix, quoteLinePrefix, singleBlockLine } from "./protocol/block-lines.js";
|
|
5
6
|
import { CHAT_LIMITS, CITATION_HREF_PREFIX, citationBlockId } from "./protocol/chat.js";
|
|
6
7
|
import { Fragment } from "@tiptap/pm/model";
|
|
7
8
|
//#region src/features/ai/document-chat.ts
|
|
8
|
-
const TRUNCATED = "[…] (Rest des Dokuments gekürzt)";
|
|
9
9
|
/**
|
|
10
|
-
* The document as sent to the chat
|
|
11
|
-
*
|
|
10
|
+
* The document as sent to the chat, in the line format of `protocol/block-lines.ts` (which also reads and describes
|
|
11
|
+
* it): one line per text block, `[<block id>] <Markdown>` (e.g. `[…] **Anna:** Text`), with list markers and quote
|
|
12
|
+
* prefixes after the ID. Nested blocks carry their own IDs, so quotes from list items or
|
|
12
13
|
* block quotes link to exactly that paragraph. A block container below the document (a composite: the schema flags it
|
|
13
14
|
* `editorBlockContainer`, its title/description/tags rows `editorChrome`) is a header line `[<id>] ::: <kind> {meta} |
|
|
14
15
|
* <title> | <description> | Tags: #a` (empty parts left out), its body blocks two spaces further in, and a closing
|
|
@@ -36,25 +37,21 @@ function documentChatText(editor) {
|
|
|
36
37
|
const emit = (node, prefix, id) => {
|
|
37
38
|
const markdown = markdownOf(node);
|
|
38
39
|
if (!markdown) return;
|
|
39
|
-
|
|
40
|
-
push(`${id ? `[${id}] ` : ""}${prefix}${text}`);
|
|
40
|
+
push(blockLine(id, prefix, node.type.name === "codeBlock" ? markdown : singleBlockLine(markdown)));
|
|
41
41
|
};
|
|
42
42
|
const container = (node, prefix, id) => {
|
|
43
|
-
const
|
|
44
|
-
const parts = [`::: ${String(node.attrs.kind)}${meta && typeof meta === "object" && Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : ""}`];
|
|
43
|
+
const chrome = [];
|
|
45
44
|
node.forEach((child) => {
|
|
46
|
-
if (
|
|
47
|
-
const text = markdownOf(child).replace(/^(?:#+|>) ?/, "").replace(/\s*\n\s*/g, " ");
|
|
48
|
-
if (text) parts.push(text);
|
|
45
|
+
if (isChromeNode(child)) chrome.push(compositeChromePart(markdownOf(child)));
|
|
49
46
|
});
|
|
50
|
-
push(
|
|
51
|
-
visit(node,
|
|
52
|
-
push(
|
|
47
|
+
push(blockLine(id, prefix, compositeLineHeader(String(node.attrs.kind), node.attrs.meta, chrome)));
|
|
48
|
+
visit(node, nestedLinePrefix(prefix), id);
|
|
49
|
+
push(compositeLineClose(prefix));
|
|
53
50
|
};
|
|
54
51
|
const wrapper = (node, prefix, id) => {
|
|
55
52
|
const header = markdownOf(node.copy(Fragment.empty)).split("\n")[0] ?? "";
|
|
56
|
-
if (header) push(
|
|
57
|
-
visit(node, header ?
|
|
53
|
+
if (header) push(blockLine(id, prefix, header));
|
|
54
|
+
visit(node, header ? nestedLinePrefix(prefix) : prefix, id);
|
|
58
55
|
};
|
|
59
56
|
const visit = (node, prefix, parentId) => {
|
|
60
57
|
let current = prefix;
|
|
@@ -63,17 +60,17 @@ function documentChatText(editor) {
|
|
|
63
60
|
const id = blockIdOf(child) ?? parentId;
|
|
64
61
|
if (child.isTextblock || child.isLeaf) emit(child, current, id);
|
|
65
62
|
else if (isBlockContainer(child)) container(child, current, id);
|
|
66
|
-
else if (child.type.name === "blockquote") visit(child,
|
|
63
|
+
else if (child.type.name === "blockquote") visit(child, quoteLinePrefix(current), id);
|
|
67
64
|
else if (child.type.name === "bulletList" || child.type.name === "orderedList") {
|
|
68
65
|
const start = Number(child.attrs.start ?? 1);
|
|
69
|
-
child.forEach((item, _o, i) => visit(item,
|
|
66
|
+
child.forEach((item, _o, i) => visit(item, listLinePrefix(current, child.type.name === "orderedList", start + i), id));
|
|
70
67
|
} else if (isWrapperBlock(child)) wrapper(child, current, id);
|
|
71
68
|
else visit(child, current, id);
|
|
72
|
-
if (index === 0) current = prefix
|
|
69
|
+
if (index === 0) current = continuedLinePrefix(prefix);
|
|
73
70
|
});
|
|
74
71
|
};
|
|
75
72
|
visit(editor.state.doc, "", null);
|
|
76
|
-
if (full) lines.push(
|
|
73
|
+
if (full) lines.push(TRUNCATED_LINE);
|
|
77
74
|
return lines.join("\n");
|
|
78
75
|
}
|
|
79
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-chat.js","names":[],"sources":["../../../src/features/ai/document-chat.ts"],"sourcesContent":["import type { Editor, JSONContent } from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport { isWrapperBlock, parseBlocks } from '../../core'\nimport { blockIdOf, findBlockById, isBlockContainer, isChromeNode } from '../../core/schema'\nimport { CHAT_LIMITS, CITATION_HREF_PREFIX, citationBlockId } from './protocol'\n\n
|
|
1
|
+
{"version":3,"file":"document-chat.js","names":[],"sources":["../../../src/features/ai/document-chat.ts"],"sourcesContent":["import type { Editor, JSONContent } from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport { isWrapperBlock, parseBlocks } from '../../core'\nimport { blockIdOf, findBlockById, isBlockContainer, isChromeNode } from '../../core/schema'\nimport { blockLine, CHAT_LIMITS, CITATION_HREF_PREFIX, citationBlockId, compositeChromePart, compositeLineClose, compositeLineHeader, continuedLinePrefix, listLinePrefix, nestedLinePrefix, quoteLinePrefix, singleBlockLine, TRUNCATED_LINE } from './protocol'\n\n/**\n * The document as sent to the chat, in the line format of `protocol/block-lines.ts` (which also reads and describes\n * it): one line per text block, `[<block id>] <Markdown>` (e.g. `[…] **Anna:** Text`), with list markers and quote\n * prefixes after the ID. Nested blocks carry their own IDs, so quotes from list items or\n * block quotes link to exactly that paragraph. A block container below the document (a composite: the schema flags it\n * `editorBlockContainer`, its title/description/tags rows `editorChrome`) is a header line `[<id>] ::: <kind> {meta} |\n * <title> | <description> | Tags: #a` (empty parts left out), its body blocks two spaces further in, and a closing\n * `:::` line without ID at that indent. Any other non-list block with block content (a host block such as a callout) is\n * a header line `[<id>] <first line of its Markdown form without content>` (`!!! info`) with its body blocks two spaces\n * further in, each with its own ID and no closing line; if that header is empty, only the body blocks appear. Cut at\n * whole lines to fit `CHAT_LIMITS.document`.\n */\nexport function documentChatText(editor: Editor): string {\n const lines: string[] = []\n let size = 0\n let full = false\n\n const push = (line: string) => {\n if (full || size + line.length + 1 > CHAT_LIMITS.document - TRUNCATED_LINE.length - 1) {\n full = true\n return\n }\n lines.push(line)\n size += line.length + 1\n }\n const markdownOf = (node: PMNode) => editor.markdown!.serialize({ type: 'doc', content: [node.toJSON()] }).trim()\n\n const emit = (node: PMNode, prefix: string, id: string | null) => {\n const markdown = markdownOf(node)\n if (!markdown) return\n // Hard breaks and wrapped lines would start new \"blocks\"; code keeps its lines.\n push(blockLine(id, prefix, node.type.name === 'codeBlock' ? markdown : singleBlockLine(markdown)))\n }\n\n const container = (node: PMNode, prefix: string, id: string | null) => {\n const chrome: string[] = []\n // The chrome's own Markdown (`## title`, `> description`, `Tags: #a`) without the block markers.\n node.forEach((child) => {\n if (isChromeNode(child)) chrome.push(compositeChromePart(markdownOf(child)))\n })\n push(blockLine(id, prefix, compositeLineHeader(String(node.attrs.kind), node.attrs.meta, chrome)))\n visit(node, nestedLinePrefix(prefix), id)\n push(compositeLineClose(prefix))\n }\n\n // A host block with block content (a callout): its own Markdown form without content as the header line, the body\n // blocks two spaces further in, each with its own ID, no closing line (the form has none).\n const wrapper = (node: PMNode, prefix: string, id: string | null) => {\n const header = markdownOf(node.copy(Fragment.empty)).split('\\n')[0] ?? ''\n if (header) push(blockLine(id, prefix, header))\n visit(node, header ? nestedLinePrefix(prefix) : prefix, id)\n }\n\n const visit = (node: PMNode, prefix: string, parentId: string | null) => {\n let current = prefix\n node.forEach((child, _offset, index) => {\n if (full || isChromeNode(child)) return\n const id = blockIdOf(child) ?? parentId\n if (child.isTextblock || child.isLeaf) emit(child, current, id)\n else if (isBlockContainer(child)) container(child, current, id)\n else if (child.type.name === 'blockquote') visit(child, quoteLinePrefix(current), id)\n else if (child.type.name === 'bulletList' || child.type.name === 'orderedList') {\n const start = Number(child.attrs.start ?? 1)\n child.forEach((item, _o, i) => visit(item, listLinePrefix(current, child.type.name === 'orderedList', start + i), id))\n }\n else if (isWrapperBlock(child)) wrapper(child, current, id)\n else visit(child, current, id)\n // Later blocks of the same list item continue under its marker instead of repeating it.\n if (index === 0) current = continuedLinePrefix(prefix)\n })\n }\n\n visit(editor.state.doc, '', null)\n if (full) lines.push(TRUNCATED_LINE)\n return lines.join('\\n')\n}\n\n/**\n * Chat answer Markdown parsed for display with the pipeline of `editor` (speaker lines become segments where a feature\n * contributes them): quote links whose block exists in `doc` point to `#block-<id>`, and quote links to unknown blocks\n * lose the link (plain text).\n */\nexport function documentChatAnswerContent(editor: Editor, markdown: string, doc: PMNode | undefined): JSONContent {\n const resolve = (node: JSONContent): JSONContent => {\n const marks = node.marks?.flatMap((mark) => {\n if (mark.type !== 'link') return [mark]\n const id = citationBlockId(mark.attrs?.href)\n if (id === null) return [mark]\n return doc && findBlockById(doc, id) ? [{ ...mark, attrs: { ...mark.attrs, href: `${CITATION_HREF_PREFIX}${id}` } }] : []\n })\n return { ...node, ...(marks && { marks }), ...(node.content && { content: node.content.map(resolve) }) }\n }\n return resolve({ type: 'doc', content: parseBlocks(editor, markdown).blocks })\n}\n"],"mappings":"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"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AGENT_LIMITS, AGENT_OP_OUTCOMES, AGENT_OP_OUTCOME_TEXT, AGENT_OP_TYPES, AGENT_TOOL, AgentOp, AgentOpContext, AgentOpFeedback, AgentOpOutcome, AgentOpProblem, AgentOpProblemReason, AgentOpType, AgentTextOptions, ModelAgentOp, agentFeedbackText, agentOpSummary, agentOpTarget, agentRetryMessage, agentShownMessage, agentUnreadableProblem, checkAgentOps
|
|
1
|
+
import { BLOCK_LINES_LABEL, BLOCK_LINE_COMPOSITE_TEXT, BLOCK_LINE_ECHO_TEXT, BLOCK_LINE_EXAMPLE, BLOCK_LINE_EXAMPLE_ID, BLOCK_LINE_EXAMPLE_TEXT, BLOCK_LINE_HOST_TEXT, BLOCK_LINE_IDS_HINT, BLOCK_LINE_INTRO, BLOCK_LINE_LIST_TEXT, BLOCK_LINE_MARKERS, BlockLines, TRUNCATED_LINE, blockLine, compositeChromePart, compositeLineClose, compositeLineHeader, continuedLinePrefix, listLinePrefix, nestedLinePrefix, quoteLinePrefix, readBlockLines, singleBlockLine, stripBlockLineEcho, stripListMarkerEcho } from "./protocol/block-lines.js";
|
|
2
|
+
import { AGENT_LIMITS, AGENT_OP_OUTCOMES, AGENT_OP_OUTCOME_TEXT, AGENT_OP_TYPES, AGENT_TOOL, AgentOp, AgentOpContext, AgentOpFeedback, AgentOpOutcome, AgentOpProblem, AgentOpProblemReason, AgentOpType, AgentTextOptions, ModelAgentOp, agentFeedbackText, agentOpSummary, agentOpTarget, agentRetryMessage, agentShownMessage, agentUnreadableProblem, checkAgentOps } from "./protocol/agent-ops.js";
|
|
3
3
|
import { CHAT_LIMITS, CITATION_HREF_PREFIX, ChatBlock, ChatBlockModel, ChatCompositeKind, DocumentChatMessage, citationBlockId, documentChatMessages } from "./protocol/chat.js";
|
|
4
4
|
import { AI_COMPLETE_LIMITS, AiCompleteMessage, cleanCompletion, completeMessages, completionReady } from "./protocol/complete.js";
|
|
5
5
|
import { AI_LANGUAGE_KEYS, MODEL_REF_LIMITS, MODEL_SLOT_KEYS, ModelProfile, ModelRef, UserModelProfile, modelRefSchema } from "./protocol/models.js";
|
|
6
6
|
import { AI_ID_PATTERN, aiBlockInputSchema, aiBlockSchema } from "./protocol/schemas.js";
|
|
7
7
|
import { AI_LIMITS, AI_TASKS, AI_TASK_IDS, AiApplyMode, AiBlockInput, AiInput, AiMessage, AiTask, AiTaskId, blockTasks, inBlockTasks, withHeading, withTaskHeading } from "./protocol/tasks.js";
|
|
8
8
|
import "./protocol/index.js";
|
|
9
|
+
import { AiReview, AiReviewChange, AiReviewChangeSummary, AiReviewDecision, AiReviewHandle, AiReviewHunk, AiReviewOptions, AiReviewOutcome, AiReviewSkipReason, AiReviewState, acceptAiReview, aiReviewKey, rejectAiReview, setActiveAiReviewHunk, startAiReview } from "./ai-review.js";
|
|
9
10
|
import { AgentScope, selectionScope } from "./agent-ops.js";
|
|
10
11
|
import { AgentOpReview, AgentOpReviewOptions, AgentOpReviewState, AgentOpState, createAgentOpReview } from "./agent-op-review.js";
|
|
11
12
|
import { AiApplyOutcome, AiResultAction, AiTarget, aiApplyFailure, applyAiResult, captureTarget, documentMarkdown, formatTaskResult, insertAtCaretLine, insertBlocksAtTarget, insertBlocksBelow, rangeMarkdown, resultBlocks, selectionMarkdown } from "./ai-apply.js";
|
|
@@ -21,4 +22,5 @@ import { GhostAutocompleteOptions, completionFetcher, ghostAutocomplete, ghostAu
|
|
|
21
22
|
import { ModelProfilesModel, modelProfiles } from "./model-profiles.js";
|
|
22
23
|
import { isRateLimited, notifyAiRateLimited } from "./rate-limit.js";
|
|
23
24
|
import { AiSidebarFlow, AiSidebarFlowOptions, createAiSidebarFlow } from "./sidebar-flow.js";
|
|
24
|
-
|
|
25
|
+
import { AI_SELECTION_MENU_KEY, AiSelectionFlow, AiSelectionFlowOptions, AiSelectionMode, AiSelectionRequest, AiSelectionState, createAiSelectionFlow } from "./selection-flow.js";
|
|
26
|
+
export { AGENT_LIMITS, AGENT_OP_OUTCOMES, AGENT_OP_OUTCOME_TEXT, AGENT_OP_TYPES, AGENT_TOOL, AI_COMPLETE_LIMITS, AI_ID_PATTERN, AI_LANGUAGE_KEYS, AI_LIMITS, AI_MENU_AT_CARET, AI_MENU_FOR_SELECTION, AI_SELECTION_MENU_KEY, AI_TASKS, AI_TASK_IDS, AgentOp, AgentOpContext, AgentOpFeedback, AgentOpOutcome, AgentOpProblem, AgentOpProblemReason, type AgentOpReview, type AgentOpReviewOptions, type AgentOpReviewState, type AgentOpState, AgentOpType, type AgentScope, AgentTextOptions, AiApplyMode, type AiApplyOutcome, type AiAssistant, type AiAssistantOptions, type AiAssistantState, AiBlockInput, AiCompleteMessage, AiInput, type AiMenuAction, AiMessage, type AiResultAction, AiReview, type AiReviewChange, type AiReviewChangeSummary, type AiReviewDecision, type AiReviewHandle, type AiReviewHunk, type AiReviewOptions, type AiReviewOutcome, type AiReviewSkipReason, type AiReviewState, type AiRunBody, type AiSelectionFlow, type AiSelectionFlowOptions, AiSelectionHighlight, type AiSelectionMode, type AiSelectionRequest, type AiSelectionState, type AiSidebarFlow, type AiSidebarFlowOptions, type AiSseOutcome, type AiStatus, type AiTarget, AiTask, AiTaskId, type AiUi, BLOCK_LINES_LABEL, BLOCK_LINE_COMPOSITE_TEXT, BLOCK_LINE_ECHO_TEXT, BLOCK_LINE_EXAMPLE, BLOCK_LINE_EXAMPLE_ID, BLOCK_LINE_EXAMPLE_TEXT, BLOCK_LINE_HOST_TEXT, BLOCK_LINE_IDS_HINT, BLOCK_LINE_INTRO, BLOCK_LINE_LIST_TEXT, BLOCK_LINE_MARKERS, BlockLines, CHAT_LIMITS, CITATION_HREF_PREFIX, ChatBlock, ChatBlockModel, ChatCompositeKind, type DocumentChat, type DocumentChatGeneration, DocumentChatMessage, type DocumentChatOptions, type DocumentChatState, type DocumentChatTurn, type GhostAutocompleteOptions, MODEL_REF_LIMITS, MODEL_SLOT_KEYS, ModelAgentOp, ModelProfile, type ModelProfilesModel, ModelRef, TRUNCATED_LINE, UserModelProfile, acceptAiReview, agentFeedbackText, agentOpSummary, agentOpTarget, agentRetryMessage, agentShownMessage, agentUnreadableProblem, aiApplyFailure, aiBlockAction, aiBlockInputSchema, aiBlockSchema, aiFeatureCore, aiMenuActionsOf, aiReviewKey, aiSelectionHighlightKey, aiSlashCommand, applyAiResult, blockLine, blockTasks, blockTextRange, captureTarget, checkAgentOps, citationBlockId, cleanCompletion, completeMessages, completionFetcher, completionReady, compositeChromePart, compositeLineClose, compositeLineHeader, continuedLinePrefix, createAgentOpReview, createAiAssistant, createAiSelectionFlow, createAiSidebarFlow, createDocumentChat, documentChatMessages, documentChatText, documentMarkdown, formatTaskResult, ghostAutocomplete, ghostAutocompleteKey, hideAiSelectionHighlight, inBlockTasks, insertAtCaretLine, insertBlocksAtTarget, insertBlocksBelow, isRateLimited, listLinePrefix, modelProfiles, modelRefSchema, nestedLinePrefix, notifyAiRateLimited, openAiMenuAtCaret, openAiMenuForSelection, postAiSse, quoteLinePrefix, rangeMarkdown, readBlockLines, rejectAiReview, resultBlocks, selectionMarkdown, selectionScope, setActiveAiReviewHunk, showAiSelectionHighlight, singleBlockLine, startAiReview, stripBlockLineEcho, stripListMarkerEcho, withHeading, withTaskHeading };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BLOCK_LINES_LABEL, BLOCK_LINE_COMPOSITE_TEXT, BLOCK_LINE_ECHO_TEXT, BLOCK_LINE_EXAMPLE, BLOCK_LINE_EXAMPLE_ID, BLOCK_LINE_EXAMPLE_TEXT, BLOCK_LINE_HOST_TEXT, BLOCK_LINE_IDS_HINT, BLOCK_LINE_INTRO, BLOCK_LINE_LIST_TEXT, BLOCK_LINE_MARKERS, TRUNCATED_LINE, blockLine, compositeChromePart, compositeLineClose, compositeLineHeader, continuedLinePrefix, listLinePrefix, nestedLinePrefix, quoteLinePrefix, readBlockLines, singleBlockLine, stripBlockLineEcho, stripListMarkerEcho } from "./protocol/block-lines.js";
|
|
2
|
+
import { AGENT_LIMITS, AGENT_OP_OUTCOMES, AGENT_OP_OUTCOME_TEXT, AGENT_OP_TYPES, AGENT_TOOL, agentFeedbackText, agentOpSummary, agentOpTarget, agentRetryMessage, agentShownMessage, agentUnreadableProblem, checkAgentOps } from "./protocol/agent-ops.js";
|
|
2
3
|
import { CHAT_LIMITS, CITATION_HREF_PREFIX, citationBlockId, documentChatMessages } from "./protocol/chat.js";
|
|
3
4
|
import { AI_COMPLETE_LIMITS, cleanCompletion, completeMessages, completionReady } from "./protocol/complete.js";
|
|
4
5
|
import { AI_LANGUAGE_KEYS, MODEL_REF_LIMITS, MODEL_SLOT_KEYS, modelRefSchema } from "./protocol/models.js";
|
|
@@ -20,4 +21,5 @@ import { completionFetcher, ghostAutocomplete, ghostAutocompleteKey } from "./gh
|
|
|
20
21
|
import { modelProfiles } from "./model-profiles.js";
|
|
21
22
|
import { aiFeatureCore } from "./feature.js";
|
|
22
23
|
import { createAiSidebarFlow } from "./sidebar-flow.js";
|
|
23
|
-
|
|
24
|
+
import { AI_SELECTION_MENU_KEY, createAiSelectionFlow } from "./selection-flow.js";
|
|
25
|
+
export { AGENT_LIMITS, AGENT_OP_OUTCOMES, AGENT_OP_OUTCOME_TEXT, AGENT_OP_TYPES, AGENT_TOOL, AI_COMPLETE_LIMITS, AI_ID_PATTERN, AI_LANGUAGE_KEYS, AI_LIMITS, AI_MENU_AT_CARET, AI_MENU_FOR_SELECTION, AI_SELECTION_MENU_KEY, AI_TASKS, AI_TASK_IDS, AiReview, AiSelectionHighlight, BLOCK_LINES_LABEL, BLOCK_LINE_COMPOSITE_TEXT, BLOCK_LINE_ECHO_TEXT, BLOCK_LINE_EXAMPLE, BLOCK_LINE_EXAMPLE_ID, BLOCK_LINE_EXAMPLE_TEXT, BLOCK_LINE_HOST_TEXT, BLOCK_LINE_IDS_HINT, BLOCK_LINE_INTRO, BLOCK_LINE_LIST_TEXT, BLOCK_LINE_MARKERS, CHAT_LIMITS, CITATION_HREF_PREFIX, MODEL_REF_LIMITS, MODEL_SLOT_KEYS, TRUNCATED_LINE, acceptAiReview, agentFeedbackText, agentOpSummary, agentOpTarget, agentRetryMessage, agentShownMessage, agentUnreadableProblem, aiApplyFailure, aiBlockAction, aiBlockInputSchema, aiBlockSchema, aiFeatureCore, aiMenuActionsOf, aiReviewKey, aiSelectionHighlightKey, aiSlashCommand, applyAiResult, blockLine, blockTasks, blockTextRange, captureTarget, checkAgentOps, citationBlockId, cleanCompletion, completeMessages, completionFetcher, completionReady, compositeChromePart, compositeLineClose, compositeLineHeader, continuedLinePrefix, createAgentOpReview, createAiAssistant, createAiSelectionFlow, createAiSidebarFlow, createDocumentChat, documentChatMessages, documentChatText, documentMarkdown, formatTaskResult, ghostAutocomplete, ghostAutocompleteKey, hideAiSelectionHighlight, inBlockTasks, insertAtCaretLine, insertBlocksAtTarget, insertBlocksBelow, isRateLimited, listLinePrefix, modelProfiles, modelRefSchema, nestedLinePrefix, notifyAiRateLimited, openAiMenuAtCaret, openAiMenuForSelection, postAiSse, quoteLinePrefix, rangeMarkdown, readBlockLines, rejectAiReview, resultBlocks, selectionMarkdown, selectionScope, setActiveAiReviewHunk, showAiSelectionHighlight, singleBlockLine, startAiReview, stripBlockLineEcho, stripListMarkerEcho, withHeading, withTaskHeading };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Locale } from "../../../i18n/index.js";
|
|
2
|
+
import { BlockLines } from "./block-lines.js";
|
|
2
3
|
//#region src/features/ai/protocol/agent-ops.d.ts
|
|
3
4
|
/** Name of the tool the chat model calls to propose edits. */
|
|
4
5
|
export declare const AGENT_TOOL = "edit_document";
|
|
@@ -13,8 +14,9 @@ export declare const AGENT_OP_TYPES: readonly ["add", "update", "delete", "conve
|
|
|
13
14
|
export type AgentOpType = typeof AGENT_OP_TYPES[number];
|
|
14
15
|
/**
|
|
15
16
|
* One proposed edit as the model writes it: `update` replaces block `id` by `markdown`, `delete` removes block `id`,
|
|
16
|
-
* `add` inserts `markdown` (one or more blocks) after block `afterId` (`null`: at the start of the document
|
|
17
|
-
* turns block `id` into the block type `to` (a `CONVERT_TARGET_IDS` entry or
|
|
17
|
+
* `add` inserts `markdown` (one or more blocks) after block `afterId` (`null`: at the start of the document; the key
|
|
18
|
+
* is required), `convert` turns block `id` into the block type `to` (a `CONVERT_TARGET_IDS` entry or
|
|
19
|
+
* `composite:<kind>`), keeping its content.
|
|
18
20
|
*/
|
|
19
21
|
export type ModelAgentOp = {
|
|
20
22
|
type: 'update';
|
|
@@ -38,11 +40,11 @@ export type AgentOp = ModelAgentOp & {
|
|
|
38
40
|
};
|
|
39
41
|
/**
|
|
40
42
|
* What became of an operation: decided in the review (`accepted`, `rejected`, `partial` for mixed hunks, `invalid`
|
|
41
|
-
* when its text changed underneath), still `pending`, or never reviewed: the
|
|
42
|
-
*
|
|
43
|
-
*
|
|
43
|
+
* when its text changed underneath), still `pending`, or never reviewed: the client found its block deleted since the
|
|
44
|
+
* document went to the model (`stale`) or refused it as out of scope (`blocked`), or the review found nothing to show
|
|
45
|
+
* (`unchanged`, `missing` block, `overlap` with open AI changes, `empty` result).
|
|
44
46
|
*/
|
|
45
|
-
export declare const AGENT_OP_OUTCOMES: readonly ["accepted", "rejected", "partial", "invalid", "pending", "unchanged", "missing", "overlap", "empty", "blocked"];
|
|
47
|
+
export declare const AGENT_OP_OUTCOMES: readonly ["accepted", "rejected", "partial", "invalid", "pending", "unchanged", "missing", "stale", "overlap", "empty", "blocked"];
|
|
46
48
|
export type AgentOpOutcome = typeof AGENT_OP_OUTCOMES[number];
|
|
47
49
|
/** Decision state of an earlier operation, sent with the next user message. */
|
|
48
50
|
export interface AgentOpFeedback {
|
|
@@ -53,9 +55,10 @@ export interface AgentOpFeedback {
|
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Why an operation was dropped: unknown block ID, ID outside the scope, a missing/invalid field, a block edited twice,
|
|
56
|
-
* too many ops, a `convert` target that is not offered
|
|
58
|
+
* too many ops, a `convert` target that is not offered, a block inside another block that an operation of the same
|
|
59
|
+
* answer replaces or deletes (`inside`).
|
|
57
60
|
*/
|
|
58
|
-
export type AgentOpProblemReason = 'unknown' | 'scope' | 'field' | 'duplicate' | 'limit' | 'target';
|
|
61
|
+
export type AgentOpProblemReason = 'unknown' | 'scope' | 'field' | 'duplicate' | 'limit' | 'target' | 'inside';
|
|
59
62
|
/** A dropped operation: its 1-based position in the tool call, type and target as far as readable, and the offending ID. */
|
|
60
63
|
export interface AgentOpProblem {
|
|
61
64
|
index: number;
|
|
@@ -65,17 +68,16 @@ export interface AgentOpProblem {
|
|
|
65
68
|
detail: string;
|
|
66
69
|
}
|
|
67
70
|
/**
|
|
68
|
-
* Where operations may point: `
|
|
69
|
-
* `
|
|
71
|
+
* Where operations may point: `lines` the block IDs of the document text and which blocks lie inside which (see
|
|
72
|
+
* `readBlockLines`); `allowed` the selection scope (null: the whole document); `targets` the block types `convert`
|
|
73
|
+
* may turn a block into; `locale` the language of the problem details (default `de`).
|
|
70
74
|
*/
|
|
71
75
|
export interface AgentOpContext {
|
|
72
|
-
|
|
76
|
+
lines: BlockLines;
|
|
73
77
|
allowed: ReadonlySet<string> | null;
|
|
74
78
|
targets: ReadonlySet<string>;
|
|
75
79
|
locale?: Locale;
|
|
76
80
|
}
|
|
77
|
-
/** Block IDs of the chat document text (`[<id>] …` per line, see documentChatText). */
|
|
78
|
-
export declare function documentBlockIds(document: string): Set<string>;
|
|
79
81
|
/** The block an operation targets: `update`/`delete` its `id`, `add` its `afterId` (null: document start). */
|
|
80
82
|
export declare function agentOpTarget(op: ModelAgentOp): string | null;
|
|
81
83
|
/** How an outcome reads for the model, per locale; the chat shows the catalog's `ai.opTitle.*` texts. */
|
|
@@ -91,10 +93,13 @@ export declare function agentOpSummary(op: {
|
|
|
91
93
|
to?: string;
|
|
92
94
|
}, { locale }?: AgentTextOptions): string;
|
|
93
95
|
/**
|
|
94
|
-
* Checks the raw `ops` of `edit_document` calls: every ID must exist and lie in the scope (`add`
|
|
95
|
-
*
|
|
96
|
-
* block is updated, converted or deleted at most once
|
|
97
|
-
*
|
|
96
|
+
* Checks the raw `ops` of `edit_document` calls: every ID must exist and lie in the scope (`add` needs its `afterId`
|
|
97
|
+
* key, `null` for the document start, and in a selection scope an `afterId` from the selection), fields must be
|
|
98
|
+
* present, a `convert` target must be one of `targets`, a block is updated, converted or deleted at most once, and no
|
|
99
|
+
* operation may point into a block (`lines.below`) that another operation replaces (`update`) or deletes: the
|
|
100
|
+
* operation on the outer block wins. Several `add`s after the same block are fine; the client inserts them in the
|
|
101
|
+
* order they were written. Returns the valid operations in order and the problems of the others; the problems'
|
|
102
|
+
* `detail` is written in `context.locale` (default `de`).
|
|
98
103
|
*/
|
|
99
104
|
export declare function checkAgentOps(raw: readonly unknown[], context: AgentOpContext): {
|
|
100
105
|
valid: ModelAgentOp[];
|